bundle.min.js 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/source-map')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/source-map'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
  5. })(this, (function (exports, sourceMap) { 'use strict';
  6. /***********************************************************************
  7. A JavaScript tokenizer / parser / beautifier / compressor.
  8. https://github.com/mishoo/UglifyJS2
  9. -------------------------------- (C) ---------------------------------
  10. Author: Mihai Bazon
  11. <mihai.bazon@gmail.com>
  12. http://mihai.bazon.net/blog
  13. Distributed under the BSD license:
  14. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15. Redistribution and use in source and binary forms, with or without
  16. modification, are permitted provided that the following conditions
  17. are met:
  18. * Redistributions of source code must retain the above
  19. copyright notice, this list of conditions and the following
  20. disclaimer.
  21. * Redistributions in binary form must reproduce the above
  22. copyright notice, this list of conditions and the following
  23. disclaimer in the documentation and/or other materials
  24. provided with the distribution.
  25. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  26. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  28. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  31. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  32. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  35. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. SUCH DAMAGE.
  37. ***********************************************************************/
  38. function characters(str) {
  39. return str.split("");
  40. }
  41. function member(name, array) {
  42. return array.includes(name);
  43. }
  44. class DefaultsError extends Error {
  45. constructor(msg, defs) {
  46. super();
  47. this.name = "DefaultsError";
  48. this.message = msg;
  49. this.defs = defs;
  50. }
  51. }
  52. function defaults(args, defs, croak) {
  53. if (args === true) {
  54. args = {};
  55. } else if (args != null && typeof args === "object") {
  56. args = {...args};
  57. }
  58. const ret = args || {};
  59. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  60. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  61. }
  62. for (const i in defs) if (HOP(defs, i)) {
  63. if (!args || !HOP(args, i)) {
  64. ret[i] = defs[i];
  65. } else if (i === "ecma" || i === "builtins_ecma") {
  66. let ecma = args[i] | 0;
  67. if (ecma > 5 && ecma < 2015) ecma += 2009;
  68. ret[i] = ecma;
  69. } else {
  70. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  71. }
  72. }
  73. return ret;
  74. }
  75. function noop() {}
  76. function return_false() { return false; }
  77. function return_true() { return true; }
  78. function return_this() { return this; }
  79. function return_null() { return null; }
  80. var MAP = (function() {
  81. function MAP(a, tw, allow_splicing = true) {
  82. const new_a = [];
  83. for (let i = 0; i < a.length; ++i) {
  84. let item = a[i];
  85. let ret = item.transform(tw, allow_splicing);
  86. if (ret instanceof AST_Node) {
  87. new_a.push(ret);
  88. } else if (ret instanceof Splice) {
  89. new_a.push(...ret.v);
  90. }
  91. }
  92. return new_a;
  93. }
  94. MAP.splice = function(val) { return new Splice(val); };
  95. MAP.skip = {};
  96. function Splice(val) { this.v = val; }
  97. return MAP;
  98. })();
  99. function make_node(ctor, orig, props) {
  100. if (!props) props = {};
  101. if (orig) {
  102. if (!props.start) props.start = orig.start;
  103. if (!props.end) props.end = orig.end;
  104. }
  105. return new ctor(props);
  106. }
  107. /** Makes a `void 0` expression. Use instead of AST_Undefined which may conflict
  108. * with an existing variable called `undefined` */
  109. function make_void_0(orig) {
  110. return make_node(AST_UnaryPrefix, orig, {
  111. operator: "void",
  112. expression: make_node(AST_Number, orig, { value: 0 })
  113. });
  114. }
  115. function push_uniq(array, el) {
  116. if (!array.includes(el))
  117. array.push(el);
  118. }
  119. function string_template(text, props) {
  120. return text.replace(/{(.+?)}/g, function(str, p) {
  121. return props && props[p];
  122. });
  123. }
  124. function remove(array, el) {
  125. for (var i = array.length; --i >= 0;) {
  126. if (array[i] === el) array.splice(i, 1);
  127. }
  128. }
  129. function mergeSort(array, cmp) {
  130. if (array.length < 2) return array.slice();
  131. function merge(a, b) {
  132. var r = [], ai = 0, bi = 0, i = 0;
  133. while (ai < a.length && bi < b.length) {
  134. cmp(a[ai], b[bi]) <= 0
  135. ? r[i++] = a[ai++]
  136. : r[i++] = b[bi++];
  137. }
  138. if (ai < a.length) r.push.apply(r, a.slice(ai));
  139. if (bi < b.length) r.push.apply(r, b.slice(bi));
  140. return r;
  141. }
  142. function _ms(a) {
  143. if (a.length <= 1)
  144. return a;
  145. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  146. left = _ms(left);
  147. right = _ms(right);
  148. return merge(left, right);
  149. }
  150. return _ms(array);
  151. }
  152. function makePredicate(words) {
  153. if (!Array.isArray(words)) words = words.split(" ");
  154. return new Set(words.sort());
  155. }
  156. function map_add(map, key, value) {
  157. if (map.has(key)) {
  158. map.get(key).push(value);
  159. } else {
  160. map.set(key, [ value ]);
  161. }
  162. }
  163. function map_from_object(obj) {
  164. var map = new Map();
  165. for (var key in obj) {
  166. if (HOP(obj, key) && key.charAt(0) === "$") {
  167. map.set(key.substr(1), obj[key]);
  168. }
  169. }
  170. return map;
  171. }
  172. function map_to_object(map) {
  173. var obj = Object.create(null);
  174. map.forEach(function (value, key) {
  175. obj["$" + key] = value;
  176. });
  177. return obj;
  178. }
  179. function HOP(obj, prop) {
  180. return Object.prototype.hasOwnProperty.call(obj, prop);
  181. }
  182. function keep_name(keep_setting, name) {
  183. return keep_setting === true
  184. || (keep_setting instanceof RegExp && keep_setting.test(name));
  185. }
  186. var lineTerminatorEscape = {
  187. "\0": "0",
  188. "\n": "n",
  189. "\r": "r",
  190. "\u2028": "u2028",
  191. "\u2029": "u2029",
  192. };
  193. function regexp_source_fix(source) {
  194. // V8 does not escape line terminators in regexp patterns in node 12
  195. // We'll also remove literal \0
  196. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  197. var escaped = source[offset - 1] == "\\"
  198. && (source[offset - 2] != "\\"
  199. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  200. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  201. });
  202. }
  203. // Subset of regexps that is not going to cause regexp based DDOS
  204. // https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
  205. const re_safe_regexp = /^[\\/|\0\s\w^$.[\]()]*$/;
  206. /** Check if the regexp is safe for Terser to create without risking a RegExp DOS */
  207. const regexp_is_safe = (source) => re_safe_regexp.test(source);
  208. const all_flags = "dgimsuyv";
  209. function sort_regexp_flags(flags) {
  210. const existing_flags = new Set(flags.split(""));
  211. let out = "";
  212. for (const flag of all_flags) {
  213. if (existing_flags.has(flag)) {
  214. out += flag;
  215. existing_flags.delete(flag);
  216. }
  217. }
  218. if (existing_flags.size) {
  219. // Flags Terser doesn't know about
  220. existing_flags.forEach(flag => { out += flag; });
  221. }
  222. return out;
  223. }
  224. function has_annotation(node, annotation) {
  225. return node._annotations & annotation;
  226. }
  227. function set_annotation(node, annotation) {
  228. node._annotations |= annotation;
  229. }
  230. function clear_annotation(node, annotation) {
  231. node._annotations &= ~annotation;
  232. }
  233. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  234. /** Used for checking if a string is an identifier during output.
  235. * We don't use \p{ID_Start} and \p{ID_Continue} because that's a moving target
  236. * and Terser's output should run on old browsers.
  237. */
  238. var UNICODE_NARROW = {
  239. 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]/,
  240. 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])+/,
  241. };
  242. /** For detecting and bounding identifiers in source text. Broader than
  243. * UNICODE_NARROW depending on the JS runtime's unicode version */
  244. var UNICODE_BROAD = UNICODE_NARROW;
  245. try {
  246. UNICODE_BROAD = {
  247. // https://262.ecma-international.org/13.0/#prod-IdentifierStartChar
  248. // $, _, ID_Start
  249. ID_Start: new RegExp("[_$\\p{ID_Start}]", "u"),
  250. // https://262.ecma-international.org/13.0/#prod-IdentifierPartChar
  251. // $, zero-width-joiner, zero-width-non-joiner, ID_Continue
  252. ID_Continue: new RegExp("[$\\u200C\\u200D\\p{ID_Continue}]+", "u"),
  253. };
  254. } catch(e) {
  255. // Could not use modern JS \p{...}.
  256. }
  257. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  258. function is_basic_identifier_string(str) {
  259. return BASIC_IDENT.test(str);
  260. }
  261. function get_full_char(str, pos) {
  262. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  263. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  264. return str.charAt(pos) + str.charAt(pos + 1);
  265. }
  266. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  267. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  268. return str.charAt(pos - 1) + str.charAt(pos);
  269. }
  270. }
  271. return str.charAt(pos);
  272. }
  273. function get_full_char_code(str, pos) {
  274. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  275. const char_code = str.charCodeAt(pos);
  276. if (is_surrogate_pair_head(char_code)) {
  277. return 0x10000 + (char_code - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  278. }
  279. return char_code;
  280. }
  281. function get_full_char_length(str) {
  282. var surrogates = 0;
  283. for (var i = 0; i < str.length; i++) {
  284. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  285. surrogates++;
  286. i++;
  287. }
  288. }
  289. return str.length - surrogates;
  290. }
  291. function from_char_code(code) {
  292. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  293. if (code > 0xFFFF) {
  294. code -= 0x10000;
  295. return (String.fromCharCode((code >> 10) + 0xD800) +
  296. String.fromCharCode((code % 0x400) + 0xDC00));
  297. }
  298. return String.fromCharCode(code);
  299. }
  300. function is_surrogate_pair_head(code) {
  301. return code >= 0xd800 && code <= 0xdbff;
  302. }
  303. function is_surrogate_pair_tail(code) {
  304. return code >= 0xdc00 && code <= 0xdfff;
  305. }
  306. function is_identifier_start(ch) {
  307. return UNICODE_NARROW.ID_Start.test(ch);
  308. }
  309. function is_identifier_char(ch) {
  310. return UNICODE_NARROW.ID_Continue.test(ch);
  311. }
  312. /** supports a "wider" range of identifiers -- as unicode evolves, new characters are accepted */
  313. function is_identifier_start_broad(ch) {
  314. return UNICODE_BROAD.ID_Start.test(ch);
  315. }
  316. /** supports a "wider" range of identifiers -- as unicode evolves, new characters are accepted */
  317. function is_identifier_char_broad(ch) {
  318. return UNICODE_BROAD.ID_Continue.test(ch);
  319. }
  320. function is_identifier_string(str, allow_surrogates) {
  321. if (BASIC_IDENT.test(str)) {
  322. return true;
  323. }
  324. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  325. return false;
  326. }
  327. var match = UNICODE_NARROW.ID_Start.exec(str);
  328. if (!match || match.index !== 0) {
  329. return false;
  330. }
  331. str = str.slice(match[0].length);
  332. if (!str) {
  333. return true;
  334. }
  335. match = UNICODE_NARROW.ID_Continue.exec(str);
  336. return !!match && match[0].length === str.length;
  337. }
  338. /***********************************************************************
  339. A JavaScript tokenizer / parser / beautifier / compressor.
  340. https://github.com/mishoo/UglifyJS2
  341. -------------------------------- (C) ---------------------------------
  342. Author: Mihai Bazon
  343. <mihai.bazon@gmail.com>
  344. http://mihai.bazon.net/blog
  345. Distributed under the BSD license:
  346. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  347. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  348. Redistribution and use in source and binary forms, with or without
  349. modification, are permitted provided that the following conditions
  350. are met:
  351. * Redistributions of source code must retain the above
  352. copyright notice, this list of conditions and the following
  353. disclaimer.
  354. * Redistributions in binary form must reproduce the above
  355. copyright notice, this list of conditions and the following
  356. disclaimer in the documentation and/or other materials
  357. provided with the distribution.
  358. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  359. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  360. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  361. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  362. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  363. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  364. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  365. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  366. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  367. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  368. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  369. SUCH DAMAGE.
  370. ***********************************************************************/
  371. var LATEST_RAW = ""; // Only used for numbers and template strings
  372. var TEMPLATE_RAWS = new Map(); // Raw template strings
  373. 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";
  374. var KEYWORDS_ATOM = "false null true";
  375. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  376. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  377. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  378. KEYWORDS = makePredicate(KEYWORDS);
  379. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  380. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  381. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  382. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  383. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  384. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  385. var RE_OCT_NUMBER = /^0[0-7]+$/;
  386. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  387. var RE_BIN_NUMBER = /^0b[01]+$/i;
  388. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  389. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  390. var RE_KEYWORD_RELATIONAL_OPERATORS = /in(?:stanceof)?/y;
  391. var OPERATORS = makePredicate([
  392. "in",
  393. "instanceof",
  394. "typeof",
  395. "new",
  396. "void",
  397. "delete",
  398. "++",
  399. "--",
  400. "+",
  401. "-",
  402. "!",
  403. "~",
  404. "&",
  405. "|",
  406. "^",
  407. "*",
  408. "**",
  409. "/",
  410. "%",
  411. ">>",
  412. "<<",
  413. ">>>",
  414. "<",
  415. ">",
  416. "<=",
  417. ">=",
  418. "==",
  419. "===",
  420. "!=",
  421. "!==",
  422. "?",
  423. "=",
  424. "+=",
  425. "-=",
  426. "||=",
  427. "&&=",
  428. "??=",
  429. "/=",
  430. "*=",
  431. "**=",
  432. "%=",
  433. ">>=",
  434. "<<=",
  435. ">>>=",
  436. "|=",
  437. "^=",
  438. "&=",
  439. "&&",
  440. "??",
  441. "||",
  442. ]);
  443. 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"));
  444. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  445. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  446. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  447. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  448. /* -----[ Tokenizer ]----- */
  449. function is_digit(code) {
  450. return code >= 48 && code <= 57;
  451. }
  452. function parse_js_number(num, allow_e = true) {
  453. if (!allow_e && num.includes("e")) {
  454. return NaN;
  455. }
  456. if (RE_HEX_NUMBER.test(num)) {
  457. return parseInt(num.substr(2), 16);
  458. } else if (RE_OCT_NUMBER.test(num)) {
  459. return parseInt(num.substr(1), 8);
  460. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  461. return parseInt(num.substr(2), 8);
  462. } else if (RE_BIN_NUMBER.test(num)) {
  463. return parseInt(num.substr(2), 2);
  464. } else if (RE_DEC_NUMBER.test(num)) {
  465. return parseFloat(num);
  466. } else {
  467. var val = parseFloat(num);
  468. if (val == num) return val;
  469. }
  470. }
  471. class JS_Parse_Error extends Error {
  472. constructor(message, filename, line, col, pos) {
  473. super();
  474. this.name = "SyntaxError";
  475. this.message = message;
  476. this.filename = filename;
  477. this.line = line;
  478. this.col = col;
  479. this.pos = pos;
  480. }
  481. }
  482. function js_error(message, filename, line, col, pos) {
  483. throw new JS_Parse_Error(message, filename, line, col, pos);
  484. }
  485. function is_token(token, type, val) {
  486. return token.type == type && (val == null || token.value == val);
  487. }
  488. var EX_EOF = {};
  489. function tokenizer($TEXT, filename, html5_comments, shebang) {
  490. var S = {
  491. text : $TEXT,
  492. filename : filename,
  493. pos : 0,
  494. tokpos : 0,
  495. line : 1,
  496. tokline : 0,
  497. col : 0,
  498. tokcol : 0,
  499. newline_before : false,
  500. regex_allowed : false,
  501. brace_counter : 0,
  502. template_braces : [],
  503. comments_before : [],
  504. directives : {},
  505. directive_stack : []
  506. };
  507. function peek() { return get_full_char(S.text, S.pos); }
  508. // Used because parsing ?. involves a lookahead for a digit
  509. function is_option_chain_op() {
  510. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  511. if (!must_be_dot) return false;
  512. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  513. return cannot_be_digit < 48 || cannot_be_digit > 57;
  514. }
  515. function next(signal_eof, in_string) {
  516. var ch = get_full_char(S.text, S.pos++);
  517. if (signal_eof && !ch)
  518. throw EX_EOF;
  519. if (NEWLINE_CHARS.has(ch)) {
  520. S.newline_before = S.newline_before || !in_string;
  521. ++S.line;
  522. S.col = 0;
  523. if (ch == "\r" && peek() == "\n") {
  524. // treat a \r\n sequence as a single \n
  525. ++S.pos;
  526. ch = "\n";
  527. }
  528. } else {
  529. if (ch.length > 1) {
  530. ++S.pos;
  531. ++S.col;
  532. }
  533. ++S.col;
  534. }
  535. return ch;
  536. }
  537. function forward(i) {
  538. while (i--) next();
  539. }
  540. function looking_at(str) {
  541. return S.text.substr(S.pos, str.length) == str;
  542. }
  543. function find_eol() {
  544. var text = S.text;
  545. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  546. var ch = text[i];
  547. if (NEWLINE_CHARS.has(ch))
  548. return i;
  549. }
  550. return -1;
  551. }
  552. function find(what, signal_eof) {
  553. var pos = S.text.indexOf(what, S.pos);
  554. if (signal_eof && pos == -1) throw EX_EOF;
  555. return pos;
  556. }
  557. function start_token() {
  558. S.tokline = S.line;
  559. S.tokcol = S.col;
  560. S.tokpos = S.pos;
  561. }
  562. var prev_was_dot = false;
  563. var previous_token = null;
  564. function token(type, value, is_comment) {
  565. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  566. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  567. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  568. (type == "arrow");
  569. if (type == "punc" && (value == "." || value == "?.")) {
  570. prev_was_dot = true;
  571. } else if (!is_comment) {
  572. prev_was_dot = false;
  573. }
  574. const line = S.tokline;
  575. const col = S.tokcol;
  576. const pos = S.tokpos;
  577. const nlb = S.newline_before;
  578. const file = filename;
  579. let comments_before = [];
  580. let comments_after = [];
  581. if (!is_comment) {
  582. comments_before = S.comments_before;
  583. comments_after = S.comments_before = [];
  584. }
  585. S.newline_before = false;
  586. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  587. if (!is_comment) previous_token = tok;
  588. return tok;
  589. }
  590. function skip_whitespace() {
  591. while (WHITESPACE_CHARS.has(peek()))
  592. next();
  593. }
  594. function peek_next_token_start_or_newline() {
  595. var pos = S.pos;
  596. for (var in_multiline_comment = false; pos < S.text.length; ) {
  597. var ch = get_full_char(S.text, pos);
  598. if (NEWLINE_CHARS.has(ch)) {
  599. return { char: ch, pos: pos };
  600. } else if (in_multiline_comment) {
  601. if (ch == "*" && get_full_char(S.text, pos + 1) == "/") {
  602. pos += 2;
  603. in_multiline_comment = false;
  604. } else {
  605. pos++;
  606. }
  607. } else if (!WHITESPACE_CHARS.has(ch)) {
  608. if (ch == "/") {
  609. var next_ch = get_full_char(S.text, pos + 1);
  610. if (next_ch == "/") {
  611. pos = find_eol();
  612. return { char: get_full_char(S.text, pos), pos: pos };
  613. } else if (next_ch == "*") {
  614. in_multiline_comment = true;
  615. pos += 2;
  616. continue;
  617. }
  618. }
  619. return { char: ch, pos: pos };
  620. } else {
  621. pos++;
  622. }
  623. }
  624. return { char: null, pos: pos };
  625. }
  626. function ch_starts_binding_identifier(ch, pos) {
  627. if (ch == "\\") {
  628. return true;
  629. } else if (is_identifier_start_broad(ch)) {
  630. RE_KEYWORD_RELATIONAL_OPERATORS.lastIndex = pos;
  631. if (RE_KEYWORD_RELATIONAL_OPERATORS.test(S.text)) {
  632. var after = get_full_char(S.text, RE_KEYWORD_RELATIONAL_OPERATORS.lastIndex);
  633. if (!is_identifier_char_broad(after) && after != "\\") {
  634. // "in" or "instanceof" are keywords, not binding identifiers
  635. return false;
  636. }
  637. }
  638. return true;
  639. }
  640. return false;
  641. }
  642. function read_while(pred) {
  643. var ret = "", ch, i = 0;
  644. while ((ch = peek()) && pred(ch, i++))
  645. ret += next();
  646. return ret;
  647. }
  648. function parse_error(err) {
  649. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  650. }
  651. function read_num(prefix) {
  652. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  653. var num = read_while(function(ch, i) {
  654. if (is_big_int) return false;
  655. var code = ch.charCodeAt(0);
  656. switch (code) {
  657. case 95: // _
  658. return (numeric_separator = true);
  659. case 98: case 66: // bB
  660. return (has_x = true); // Can occur in hex sequence, don't return false yet
  661. case 111: case 79: // oO
  662. case 120: case 88: // xX
  663. return has_x ? false : (has_x = true);
  664. case 101: case 69: // eE
  665. return has_x ? true : has_e ? false : (has_e = after_e = true);
  666. case 45: // -
  667. return after_e || (i == 0 && !prefix);
  668. case 43: // +
  669. return after_e;
  670. case (after_e = false, 46): // .
  671. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  672. case 110: // n
  673. is_big_int = true;
  674. return true;
  675. }
  676. return (
  677. code >= 48 && code <= 57 // 0-9
  678. || code >= 97 && code <= 102 // a-f
  679. || code >= 65 && code <= 70 // A-F
  680. );
  681. });
  682. if (prefix) num = prefix + num;
  683. LATEST_RAW = num;
  684. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  685. parse_error("Legacy octal literals are not allowed in strict mode");
  686. }
  687. if (numeric_separator) {
  688. if (num.endsWith("_")) {
  689. parse_error("Numeric separators are not allowed at the end of numeric literals");
  690. } else if (num.includes("__")) {
  691. parse_error("Only one underscore is allowed as numeric separator");
  692. }
  693. num = num.replace(/_/g, "");
  694. }
  695. if (is_big_int) {
  696. const without_n = num.slice(0, -1);
  697. const allow_e = RE_HEX_NUMBER.test(without_n);
  698. const valid = parse_js_number(without_n, allow_e);
  699. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  700. return token("big_int", without_n);
  701. parse_error("Invalid or unexpected token");
  702. }
  703. var valid = parse_js_number(num);
  704. if (!isNaN(valid)) {
  705. return token("num", valid);
  706. } else {
  707. parse_error("Invalid syntax: " + num);
  708. }
  709. }
  710. function is_octal(ch) {
  711. return ch >= "0" && ch <= "7";
  712. }
  713. function read_escaped_char(in_string, strict_hex, template_string) {
  714. var ch = next(true, in_string);
  715. switch (ch.charCodeAt(0)) {
  716. case 110 : return "\n";
  717. case 114 : return "\r";
  718. case 116 : return "\t";
  719. case 98 : return "\b";
  720. case 118 : return "\u000b"; // \v
  721. case 102 : return "\f";
  722. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  723. case 117 : // \u
  724. if (peek() == "{") {
  725. next(true);
  726. if (peek() === "}")
  727. parse_error("Expecting hex-character between {}");
  728. while (peek() == "0") next(true); // No significance
  729. var result, length = find("}", true) - S.pos;
  730. // Avoid 32 bit integer overflow (1 << 32 === 1)
  731. // We know first character isn't 0 and thus out of range anyway
  732. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  733. parse_error("Unicode reference out of bounds");
  734. }
  735. next(true);
  736. return from_char_code(result);
  737. }
  738. return String.fromCharCode(hex_bytes(4, strict_hex));
  739. case 10 : return ""; // newline
  740. case 13 : // \r
  741. if (peek() == "\n") { // DOS newline
  742. next(true, in_string);
  743. return "";
  744. }
  745. }
  746. if (is_octal(ch)) {
  747. if (template_string && strict_hex) {
  748. const represents_null_character = ch === "0" && !is_octal(peek());
  749. if (!represents_null_character) {
  750. parse_error("Octal escape sequences are not allowed in template strings");
  751. }
  752. }
  753. return read_octal_escape_sequence(ch, strict_hex);
  754. }
  755. return ch;
  756. }
  757. function read_octal_escape_sequence(ch, strict_octal) {
  758. // Read
  759. var p = peek();
  760. if (p >= "0" && p <= "7") {
  761. ch += next(true);
  762. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  763. ch += next(true);
  764. }
  765. // Parse
  766. if (ch === "0") return "\0";
  767. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  768. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  769. return String.fromCharCode(parseInt(ch, 8));
  770. }
  771. function hex_bytes(n, strict_hex) {
  772. var num = 0;
  773. for (; n > 0; --n) {
  774. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  775. return parseInt(num, 16) || "";
  776. }
  777. var digit = next(true);
  778. if (isNaN(parseInt(digit, 16)))
  779. parse_error("Invalid hex-character pattern in string");
  780. num += digit;
  781. }
  782. return parseInt(num, 16);
  783. }
  784. var read_string = with_eof_error("Unterminated string constant", function() {
  785. const start_pos = S.pos;
  786. var quote = next(), ret = [];
  787. for (;;) {
  788. var ch = next(true, true);
  789. if (ch == "\\") ch = read_escaped_char(true, true);
  790. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  791. else if (ch == quote) break;
  792. ret.push(ch);
  793. }
  794. var tok = token("string", ret.join(""));
  795. LATEST_RAW = S.text.slice(start_pos, S.pos);
  796. tok.quote = quote;
  797. return tok;
  798. });
  799. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  800. if (begin) {
  801. S.template_braces.push(S.brace_counter);
  802. }
  803. var content = "", raw = "", ch, tok;
  804. next(true, true);
  805. while ((ch = next(true, true)) != "`") {
  806. if (ch == "\r") {
  807. if (peek() == "\n") ++S.pos;
  808. ch = "\n";
  809. } else if (ch == "$" && peek() == "{") {
  810. next(true, true);
  811. S.brace_counter++;
  812. tok = token(begin ? "template_head" : "template_cont", content);
  813. TEMPLATE_RAWS.set(tok, raw);
  814. tok.template_end = false;
  815. return tok;
  816. }
  817. raw += ch;
  818. if (ch == "\\") {
  819. var tmp = S.pos;
  820. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  821. ch = read_escaped_char(true, !prev_is_tag, true);
  822. raw += S.text.substr(tmp, S.pos - tmp);
  823. }
  824. content += ch;
  825. }
  826. S.template_braces.pop();
  827. tok = token(begin ? "template_head" : "template_cont", content);
  828. TEMPLATE_RAWS.set(tok, raw);
  829. tok.template_end = true;
  830. return tok;
  831. });
  832. function skip_line_comment(type) {
  833. var regex_allowed = S.regex_allowed;
  834. var i = find_eol(), ret;
  835. if (i == -1) {
  836. ret = S.text.substr(S.pos);
  837. S.pos = S.text.length;
  838. } else {
  839. ret = S.text.substring(S.pos, i);
  840. S.pos = i;
  841. }
  842. S.col = S.tokcol + (S.pos - S.tokpos);
  843. S.comments_before.push(token(type, ret, true));
  844. S.regex_allowed = regex_allowed;
  845. return next_token;
  846. }
  847. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  848. var regex_allowed = S.regex_allowed;
  849. var i = find("*/", true);
  850. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  851. // update stream position
  852. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  853. S.comments_before.push(token("comment2", text, true));
  854. S.newline_before = S.newline_before || text.includes("\n");
  855. S.regex_allowed = regex_allowed;
  856. return next_token;
  857. });
  858. var read_name = function () {
  859. let start = S.pos, end = start - 1, ch = "c";
  860. while (
  861. (ch = S.text.charAt(++end))
  862. && (ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z")
  863. );
  864. // 0x7F is very rare in actual code, so we compare it to "~" (0x7E)
  865. if (end > start + 1 && ch && ch !== "\\" && !is_identifier_char_broad(ch) && ch <= "~") {
  866. S.pos += end - start;
  867. S.col += end - start;
  868. return S.text.slice(start, S.pos);
  869. }
  870. return read_name_hard();
  871. };
  872. var read_name_hard = with_eof_error("Unterminated identifier name", function() {
  873. var name = [], ch, escaped = false;
  874. var read_escaped_identifier_char = function() {
  875. escaped = true;
  876. next();
  877. if (peek() !== "u") {
  878. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  879. }
  880. return read_escaped_char(false, true);
  881. };
  882. // Read first character (ID_Start)
  883. if ((ch = peek()) === "\\") {
  884. ch = read_escaped_identifier_char();
  885. if (!is_identifier_start_broad(ch)) {
  886. parse_error("First identifier char is an invalid identifier char");
  887. }
  888. } else if (is_identifier_start_broad(ch)) {
  889. next();
  890. } else {
  891. return "";
  892. }
  893. name.push(ch);
  894. // Read ID_Continue
  895. while ((ch = peek()) != null) {
  896. if ((ch = peek()) === "\\") {
  897. ch = read_escaped_identifier_char();
  898. if (!is_identifier_char_broad(ch)) {
  899. parse_error("Invalid escaped identifier char");
  900. }
  901. } else {
  902. if (!is_identifier_char_broad(ch)) {
  903. break;
  904. }
  905. next();
  906. }
  907. name.push(ch);
  908. }
  909. const name_str = name.join("");
  910. if (RESERVED_WORDS.has(name_str) && escaped) {
  911. parse_error("Escaped characters are not allowed in keywords");
  912. }
  913. return name_str;
  914. });
  915. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  916. var prev_backslash = false, ch, in_class = false;
  917. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  918. parse_error("Unexpected line terminator");
  919. } else if (prev_backslash) {
  920. if (/^[\u0000-\u007F]$/.test(ch)) {
  921. source += "\\" + ch;
  922. } else {
  923. // Remove the useless slash before the escape, but only for characters that won't be added to regexp syntax
  924. source += ch;
  925. }
  926. prev_backslash = false;
  927. } else if (ch == "[") {
  928. in_class = true;
  929. source += ch;
  930. } else if (ch == "]" && in_class) {
  931. in_class = false;
  932. source += ch;
  933. } else if (ch == "/" && !in_class) {
  934. break;
  935. } else if (ch == "\\") {
  936. prev_backslash = true;
  937. } else {
  938. source += ch;
  939. }
  940. const flags = read_name();
  941. return token("regexp", "/" + source + "/" + flags);
  942. });
  943. function read_operator(prefix) {
  944. function grow(op) {
  945. if (!peek()) return op;
  946. var bigger = op + peek();
  947. if (OPERATORS.has(bigger)) {
  948. next();
  949. return grow(bigger);
  950. } else {
  951. return op;
  952. }
  953. }
  954. return token("operator", grow(prefix || next()));
  955. }
  956. function handle_slash() {
  957. next();
  958. switch (peek()) {
  959. case "/":
  960. next();
  961. return skip_line_comment("comment1");
  962. case "*":
  963. next();
  964. return skip_multiline_comment();
  965. }
  966. return S.regex_allowed ? read_regexp("") : read_operator("/");
  967. }
  968. function handle_eq_sign() {
  969. next();
  970. if (peek() === ">") {
  971. next();
  972. return token("arrow", "=>");
  973. } else {
  974. return read_operator("=");
  975. }
  976. }
  977. function handle_dot() {
  978. next();
  979. if (is_digit(peek().charCodeAt(0))) {
  980. return read_num(".");
  981. }
  982. if (peek() === ".") {
  983. next(); // Consume second dot
  984. next(); // Consume third dot
  985. return token("expand", "...");
  986. }
  987. return token("punc", ".");
  988. }
  989. function read_word() {
  990. var word = read_name();
  991. if (prev_was_dot) return token("name", word);
  992. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  993. : !KEYWORDS.has(word) ? token("name", word)
  994. : OPERATORS.has(word) ? token("operator", word)
  995. : token("keyword", word);
  996. }
  997. function read_private_word() {
  998. next();
  999. return token("privatename", read_name());
  1000. }
  1001. function with_eof_error(eof_error, cont) {
  1002. return function(x) {
  1003. try {
  1004. return cont(x);
  1005. } catch(ex) {
  1006. if (ex === EX_EOF) parse_error(eof_error);
  1007. else throw ex;
  1008. }
  1009. };
  1010. }
  1011. function next_token(force_regexp) {
  1012. if (force_regexp != null)
  1013. return read_regexp(force_regexp);
  1014. if (shebang && S.pos == 0 && looking_at("#!")) {
  1015. start_token();
  1016. forward(2);
  1017. skip_line_comment("comment5");
  1018. }
  1019. for (;;) {
  1020. skip_whitespace();
  1021. start_token();
  1022. if (html5_comments) {
  1023. if (looking_at("<!--")) {
  1024. forward(4);
  1025. skip_line_comment("comment3");
  1026. continue;
  1027. }
  1028. if (looking_at("-->") && S.newline_before) {
  1029. forward(3);
  1030. skip_line_comment("comment4");
  1031. continue;
  1032. }
  1033. }
  1034. var ch = peek();
  1035. if (!ch) return token("eof");
  1036. var code = ch.charCodeAt(0);
  1037. switch (code) {
  1038. case 34: case 39: return read_string();
  1039. case 46: return handle_dot();
  1040. case 47: {
  1041. var tok = handle_slash();
  1042. if (tok === next_token) continue;
  1043. return tok;
  1044. }
  1045. case 61: return handle_eq_sign();
  1046. case 63: {
  1047. if (!is_option_chain_op()) break; // Handled below
  1048. next(); // ?
  1049. next(); // .
  1050. return token("punc", "?.");
  1051. }
  1052. case 96: return read_template_characters(true);
  1053. case 123:
  1054. S.brace_counter++;
  1055. break;
  1056. case 125:
  1057. S.brace_counter--;
  1058. if (S.template_braces.length > 0
  1059. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  1060. return read_template_characters(false);
  1061. break;
  1062. }
  1063. if (is_digit(code)) return read_num();
  1064. if (PUNC_CHARS.has(ch)) return token("punc", next());
  1065. if (OPERATOR_CHARS.has(ch)) return read_operator();
  1066. if (code == 92 || is_identifier_start_broad(ch)) return read_word();
  1067. if (code == 35) return read_private_word();
  1068. break;
  1069. }
  1070. parse_error("Unexpected character '" + ch + "'");
  1071. }
  1072. next_token.next = next;
  1073. next_token.peek = peek;
  1074. next_token.context = function(nc) {
  1075. if (nc) S = nc;
  1076. return S;
  1077. };
  1078. next_token.add_directive = function(directive) {
  1079. S.directive_stack[S.directive_stack.length - 1].push(directive);
  1080. if (S.directives[directive] === undefined) {
  1081. S.directives[directive] = 1;
  1082. } else {
  1083. S.directives[directive]++;
  1084. }
  1085. };
  1086. next_token.push_directives_stack = function() {
  1087. S.directive_stack.push([]);
  1088. };
  1089. next_token.pop_directives_stack = function() {
  1090. var directives = S.directive_stack[S.directive_stack.length - 1];
  1091. for (var i = 0; i < directives.length; i++) {
  1092. S.directives[directives[i]]--;
  1093. }
  1094. S.directive_stack.pop();
  1095. };
  1096. next_token.has_directive = function(directive) {
  1097. return S.directives[directive] > 0;
  1098. };
  1099. next_token.peek_next_token_start_or_newline = peek_next_token_start_or_newline;
  1100. next_token.ch_starts_binding_identifier = ch_starts_binding_identifier;
  1101. next_token.typescript_is_type_parameters_before_call = () => {
  1102. const stack = [">"]; // We start at the opening "<"
  1103. const peek = () => get_full_char(S.text, i + 1);
  1104. const next = () => get_full_char(S.text, ++i);
  1105. let i = S.pos;
  1106. for (; stack.length; i++) {
  1107. let ch = get_full_char(S.text, i);
  1108. if (!ch) return false;
  1109. if (ch === stack[stack.length - 1]) {
  1110. stack.pop();
  1111. continue;
  1112. }
  1113. // Skip comments
  1114. if (ch === "/") {
  1115. ch = next();
  1116. if (ch === "/") {
  1117. while ((ch = next()) && ch !== "\n");
  1118. } else if (ch === "*") {
  1119. while ((ch = next()) && !(ch === "*" && peek() === "/"));
  1120. }
  1121. }
  1122. // Skip strings
  1123. if (ch === "'" || ch === '"') {
  1124. const start = ch;
  1125. do {
  1126. ch = next();
  1127. if (ch === "\\") ++i; // skip over \"
  1128. } while (ch && ch !== start && ch !== "\n");
  1129. }
  1130. // Skip template strings
  1131. if (
  1132. ch === "`"
  1133. || ch === "}" && stack[stack.length - 1] === "${" && stack.pop()
  1134. ) {
  1135. do {
  1136. ch = next();
  1137. if (ch === "$" && peek() === "{") {
  1138. next();
  1139. stack.push("${");
  1140. break;
  1141. }
  1142. } while (ch && ch !== "`");
  1143. }
  1144. // for each opener, push the closer
  1145. if (ch === "<") { stack.push(">"); continue; }
  1146. if (ch === "[") { stack.push("]"); continue; }
  1147. if (ch === "(") { stack.push(")"); continue; }
  1148. if (ch === "{") { stack.push("}"); continue; }
  1149. // When we see a closer, see if it's the same as the opener
  1150. if (ch === ">" || ch === "]" || ch === ")" || ch === "}") {
  1151. if (stack.pop() !== ch) return false;
  1152. continue;
  1153. }
  1154. }
  1155. while (WHITESPACE_CHARS.has(get_full_char(S.text, i))) i++;
  1156. return S.text[i] === "(" || S.text.slice(i, i + 2) === "?.";
  1157. };
  1158. return next_token;
  1159. }
  1160. /* -----[ Parser (constants) ]----- */
  1161. var UNARY_PREFIX = makePredicate([
  1162. "typeof",
  1163. "void",
  1164. "delete",
  1165. "--",
  1166. "++",
  1167. "!",
  1168. "~",
  1169. "-",
  1170. "+"
  1171. ]);
  1172. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  1173. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  1174. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  1175. var PRECEDENCE = (function(a, ret) {
  1176. for (var i = 0; i < a.length; ++i) {
  1177. for (const op of a[i]) {
  1178. ret[op] = i + 1;
  1179. }
  1180. }
  1181. return ret;
  1182. })(
  1183. [
  1184. ["||"],
  1185. ["??"],
  1186. ["&&"],
  1187. ["|"],
  1188. ["^"],
  1189. ["&"],
  1190. ["==", "===", "!=", "!=="],
  1191. ["<", ">", "<=", ">=", "in", "instanceof"],
  1192. [">>", "<<", ">>>"],
  1193. ["+", "-"],
  1194. ["*", "/", "%"],
  1195. ["**"]
  1196. ],
  1197. {}
  1198. );
  1199. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name"]);
  1200. /* -----[ Parser ]----- */
  1201. function parse($TEXT, options) {
  1202. // maps start tokens to count of comments found outside of their parens
  1203. // Example: /* I count */ ( /* I don't */ foo() )
  1204. // Useful because comments_before property of call with parens outside
  1205. // contains both comments inside and outside these parens. Used to find the
  1206. const outer_comments_before_counts = new WeakMap();
  1207. options = defaults(options, {
  1208. bare_returns : false,
  1209. ecma : null, // Legacy
  1210. expression : false,
  1211. filename : null,
  1212. html5_comments : true,
  1213. module : false,
  1214. shebang : true,
  1215. strict : false,
  1216. toplevel : null,
  1217. experimental_typescript: false,
  1218. }, true);
  1219. var S = {
  1220. input : (typeof $TEXT == "string"
  1221. ? tokenizer($TEXT, options.filename,
  1222. options.html5_comments, options.shebang)
  1223. : $TEXT),
  1224. token : null,
  1225. prev : null,
  1226. peeked : null,
  1227. in_function : 0,
  1228. in_async : -1,
  1229. in_generator : -1,
  1230. in_directives : true,
  1231. in_loop : 0,
  1232. labels : []
  1233. };
  1234. S.token = next();
  1235. function is(type, value) {
  1236. return is_token(S.token, type, value);
  1237. }
  1238. function peek() { return S.peeked || (S.peeked = S.input()); }
  1239. function next() {
  1240. S.prev = S.token;
  1241. if (!S.peeked) peek();
  1242. S.token = S.peeked;
  1243. S.peeked = null;
  1244. S.in_directives = S.in_directives && (
  1245. S.token.type == "string" || is("punc", ";")
  1246. );
  1247. return S.token;
  1248. }
  1249. function prev() {
  1250. return S.prev;
  1251. }
  1252. function croak(msg, line, col, pos) {
  1253. var ctx = S.input.context();
  1254. js_error(msg,
  1255. ctx.filename,
  1256. line != null ? line : ctx.tokline,
  1257. col != null ? col : ctx.tokcol,
  1258. pos != null ? pos : ctx.tokpos);
  1259. }
  1260. function token_error(token, msg) {
  1261. croak(msg, token.line, token.col);
  1262. }
  1263. function unexpected(token) {
  1264. if (token == null)
  1265. token = S.token;
  1266. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  1267. }
  1268. function expect_token(type, val) {
  1269. if (is(type, val)) {
  1270. return next();
  1271. }
  1272. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  1273. }
  1274. function expect(punc) { return expect_token("punc", punc); }
  1275. function has_newline_before(token) {
  1276. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  1277. }
  1278. function can_insert_semicolon() {
  1279. return !options.strict
  1280. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  1281. }
  1282. function is_in_generator() {
  1283. return S.in_generator === S.in_function;
  1284. }
  1285. function is_in_async() {
  1286. return S.in_async === S.in_function;
  1287. }
  1288. function can_await() {
  1289. return (
  1290. S.in_async === S.in_function
  1291. || S.in_function === 0 && S.input.has_directive("use strict")
  1292. );
  1293. }
  1294. function semicolon(optional) {
  1295. if (is("punc", ";")) next();
  1296. else if (!optional && !can_insert_semicolon()) unexpected();
  1297. }
  1298. function parenthesised() {
  1299. expect("(");
  1300. var exp = expression(true);
  1301. expect(")");
  1302. return exp;
  1303. }
  1304. function embed_tokens(parser) {
  1305. return function _embed_tokens_wrapper(...args) {
  1306. const start = S.token;
  1307. const expr = parser(...args);
  1308. expr.start = start;
  1309. expr.end = prev();
  1310. return expr;
  1311. };
  1312. }
  1313. function handle_regexp() {
  1314. if (is("operator", "/") || is("operator", "/=")) {
  1315. S.peeked = null;
  1316. S.token = S.input(S.token.value.substr(1)); // force regexp
  1317. }
  1318. }
  1319. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  1320. handle_regexp();
  1321. switch (S.token.type) {
  1322. case "string":
  1323. if (S.in_directives) {
  1324. var token = peek();
  1325. if (!LATEST_RAW.includes("\\")
  1326. && (is_token(token, "punc", ";")
  1327. || is_token(token, "punc", "}")
  1328. || has_newline_before(token)
  1329. || is_token(token, "eof"))) {
  1330. S.input.add_directive(S.token.value);
  1331. } else {
  1332. S.in_directives = false;
  1333. }
  1334. }
  1335. var dir = S.in_directives, stat = simple_statement();
  1336. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  1337. case "template_head":
  1338. case "num":
  1339. case "big_int":
  1340. case "regexp":
  1341. case "operator":
  1342. case "atom":
  1343. return simple_statement();
  1344. case "name":
  1345. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  1346. next();
  1347. next();
  1348. if (is_for_body) {
  1349. croak("functions are not allowed as the body of a loop");
  1350. }
  1351. const func = function_(AST_Defun, false, true, is_export_default);
  1352. if (func == typescript_ellide) return new AST_EmptyStatement();
  1353. return func;
  1354. }
  1355. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  1356. next();
  1357. var node = import_statement();
  1358. semicolon();
  1359. return node;
  1360. }
  1361. if (S.token.value == "using" && is_token(peek(), "name") && !has_newline_before(peek())) {
  1362. next();
  1363. var node = using_();
  1364. semicolon();
  1365. return node;
  1366. }
  1367. if (S.token.value == "await" && can_await() && is_token(peek(), "name", "using") && !has_newline_before(peek())) {
  1368. var next_next = S.input.peek_next_token_start_or_newline();
  1369. if (S.input.ch_starts_binding_identifier(next_next.char, next_next.pos)) {
  1370. next();
  1371. // The "using" token will be consumed by the await_using_ function.
  1372. var node = await_using_();
  1373. semicolon();
  1374. return node;
  1375. }
  1376. }
  1377. if (S.token.value === "type" && is_token(peek(), "name") && !has_newline_before(peek())) {
  1378. typescript_type_statement();
  1379. return new AST_EmptyStatement();
  1380. }
  1381. if (S.token.value === "interface" && is_token(peek(), "name") && !has_newline_before(peek())) {
  1382. typescript_interface_statement();
  1383. return new AST_EmptyStatement();
  1384. }
  1385. return is_token(peek(), "punc", ":")
  1386. ? labeled_statement()
  1387. : simple_statement();
  1388. case "privatename":
  1389. if(!S.in_class)
  1390. croak("Private field must be used in an enclosing class");
  1391. return simple_statement();
  1392. case "punc":
  1393. switch (S.token.value) {
  1394. case "{":
  1395. return new AST_BlockStatement({
  1396. start : S.token,
  1397. body : block_(),
  1398. end : prev()
  1399. });
  1400. case "[":
  1401. case "(":
  1402. return simple_statement();
  1403. case ";":
  1404. S.in_directives = false;
  1405. next();
  1406. return new AST_EmptyStatement();
  1407. default:
  1408. unexpected();
  1409. }
  1410. case "keyword":
  1411. switch (S.token.value) {
  1412. case "break":
  1413. next();
  1414. return break_cont(AST_Break);
  1415. case "continue":
  1416. next();
  1417. return break_cont(AST_Continue);
  1418. case "debugger":
  1419. next();
  1420. semicolon();
  1421. return new AST_Debugger();
  1422. case "do":
  1423. next();
  1424. var body = in_loop(statement);
  1425. expect_token("keyword", "while");
  1426. var condition = parenthesised();
  1427. semicolon(true);
  1428. return new AST_Do({
  1429. body : body,
  1430. condition : condition
  1431. });
  1432. case "while":
  1433. next();
  1434. return new AST_While({
  1435. condition : parenthesised(),
  1436. body : in_loop(function() { return statement(false, true); })
  1437. });
  1438. case "for":
  1439. next();
  1440. return for_();
  1441. case "class":
  1442. next();
  1443. if (is_for_body) {
  1444. croak("classes are not allowed as the body of a loop");
  1445. }
  1446. if (is_if_body) {
  1447. croak("classes are not allowed as the body of an if");
  1448. }
  1449. return class_(AST_DefClass, is_export_default);
  1450. case "function":
  1451. next();
  1452. if (is_for_body) {
  1453. croak("functions are not allowed as the body of a loop");
  1454. }
  1455. const func = function_(AST_Defun, false, false, is_export_default);
  1456. if (func == typescript_ellide) return new AST_EmptyStatement();
  1457. return func;
  1458. case "if":
  1459. next();
  1460. return if_();
  1461. case "return":
  1462. if (S.in_function == 0 && !options.bare_returns)
  1463. croak("'return' outside of function");
  1464. next();
  1465. var value = null;
  1466. if (is("punc", ";")) {
  1467. next();
  1468. } else if (!can_insert_semicolon()) {
  1469. value = expression(true);
  1470. semicolon();
  1471. }
  1472. return new AST_Return({
  1473. value: value
  1474. });
  1475. case "switch":
  1476. next();
  1477. return new AST_Switch({
  1478. expression : parenthesised(),
  1479. body : in_loop(switch_body_)
  1480. });
  1481. case "throw":
  1482. next();
  1483. if (has_newline_before(S.token))
  1484. croak("Illegal newline after 'throw'");
  1485. var value = expression(true);
  1486. semicolon();
  1487. return new AST_Throw({
  1488. value: value
  1489. });
  1490. case "try":
  1491. next();
  1492. return try_();
  1493. case "var":
  1494. next();
  1495. var node = var_();
  1496. semicolon();
  1497. return node;
  1498. case "let":
  1499. next();
  1500. var node = let_();
  1501. semicolon();
  1502. return node;
  1503. case "const":
  1504. next();
  1505. var node = const_();
  1506. semicolon();
  1507. return node;
  1508. case "with":
  1509. if (S.input.has_directive("use strict")) {
  1510. croak("Strict mode may not include a with statement");
  1511. }
  1512. next();
  1513. return new AST_With({
  1514. expression : parenthesised(),
  1515. body : statement()
  1516. });
  1517. case "export":
  1518. if (!is_token(peek(), "punc", "(")) {
  1519. next();
  1520. var node = export_statement();
  1521. if (is("punc", ";")) semicolon();
  1522. return node;
  1523. }
  1524. }
  1525. }
  1526. unexpected();
  1527. });
  1528. function labeled_statement() {
  1529. var label = as_symbol(AST_Label);
  1530. if (label.name === "await" && is_in_async()) {
  1531. token_error(S.prev, "await cannot be used as label inside async function");
  1532. }
  1533. if (S.labels.some((l) => l.name === label.name)) {
  1534. // ECMA-262, 12.12: An ECMAScript program is considered
  1535. // syntactically incorrect if it contains a
  1536. // LabelledStatement that is enclosed by a
  1537. // LabelledStatement with the same Identifier as label.
  1538. croak("Label " + label.name + " defined twice");
  1539. }
  1540. expect(":");
  1541. S.labels.push(label);
  1542. var stat = statement();
  1543. S.labels.pop();
  1544. if (!(stat instanceof AST_IterationStatement)) {
  1545. // check for `continue` that refers to this label.
  1546. // those should be reported as syntax errors.
  1547. // https://github.com/mishoo/UglifyJS2/issues/287
  1548. label.references.forEach(function(ref) {
  1549. if (ref instanceof AST_Continue) {
  1550. ref = ref.label.start;
  1551. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  1552. ref.line, ref.col, ref.pos);
  1553. }
  1554. });
  1555. }
  1556. return new AST_LabeledStatement({ body: stat, label: label });
  1557. }
  1558. function simple_statement(tmp) {
  1559. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  1560. }
  1561. function break_cont(type) {
  1562. var label = null, ldef;
  1563. if (!can_insert_semicolon()) {
  1564. label = as_symbol(AST_LabelRef, true);
  1565. }
  1566. if (label != null) {
  1567. ldef = S.labels.find((l) => l.name === label.name);
  1568. if (!ldef)
  1569. croak("Undefined label " + label.name);
  1570. label.thedef = ldef;
  1571. } else if (S.in_loop == 0)
  1572. croak(type.TYPE + " not inside a loop or switch");
  1573. semicolon();
  1574. var stat = new type({ label: label });
  1575. if (ldef) ldef.references.push(stat);
  1576. return stat;
  1577. }
  1578. function for_() {
  1579. var for_await_error = "`for await` invalid in this context";
  1580. var await_tok = S.token;
  1581. if (await_tok.type == "name" && await_tok.value == "await") {
  1582. if (!can_await()) {
  1583. token_error(await_tok, for_await_error);
  1584. }
  1585. next();
  1586. } else {
  1587. await_tok = false;
  1588. }
  1589. expect("(");
  1590. var init = null;
  1591. if (!is("punc", ";")) {
  1592. init =
  1593. is("keyword", "var") ? (next(), var_(true)) :
  1594. is("keyword", "let") ? (next(), let_(true)) :
  1595. is("keyword", "const") ? (next(), const_(true)) :
  1596. is("name", "using") && is_token(peek(), "name") && (peek().value != "of" || S.input.peek_next_token_start_or_newline().char == "=") ? (next(), using_(true)) :
  1597. is("name", "await") && can_await() && is_token(peek(), "name", "using") ? (next(), await_using_(true)) :
  1598. expression(true, true);
  1599. var is_in = is("operator", "in");
  1600. var is_of = is("name", "of");
  1601. if (await_tok && !is_of) {
  1602. token_error(await_tok, for_await_error);
  1603. }
  1604. if (is_in || is_of) {
  1605. if (init instanceof AST_DefinitionsLike) {
  1606. if (init.definitions.length > 1)
  1607. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  1608. if (is_in && init instanceof AST_Using) {
  1609. token_error(init.start, "Invalid using declaration in for..in loop");
  1610. }
  1611. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  1612. token_error(init.start, "Invalid left-hand side in for..in loop");
  1613. }
  1614. next();
  1615. if (is_in) {
  1616. return for_in(init);
  1617. } else {
  1618. return for_of(init, !!await_tok);
  1619. }
  1620. }
  1621. } else if (await_tok) {
  1622. token_error(await_tok, for_await_error);
  1623. }
  1624. return regular_for(init);
  1625. }
  1626. function regular_for(init) {
  1627. expect(";");
  1628. var test = is("punc", ";") ? null : expression(true);
  1629. expect(";");
  1630. var step = is("punc", ")") ? null : expression(true);
  1631. expect(")");
  1632. return new AST_For({
  1633. init : init,
  1634. condition : test,
  1635. step : step,
  1636. body : in_loop(function() { return statement(false, true); })
  1637. });
  1638. }
  1639. function for_of(init, is_await) {
  1640. var lhs = init instanceof AST_DefinitionsLike ? init.definitions[0].name : null;
  1641. var obj = expression(true);
  1642. expect(")");
  1643. return new AST_ForOf({
  1644. await : is_await,
  1645. init : init,
  1646. name : lhs,
  1647. object : obj,
  1648. body : in_loop(function() { return statement(false, true); })
  1649. });
  1650. }
  1651. function for_in(init) {
  1652. var obj = expression(true);
  1653. expect(")");
  1654. return new AST_ForIn({
  1655. init : init,
  1656. object : obj,
  1657. body : in_loop(function() { return statement(false, true); })
  1658. });
  1659. }
  1660. var arrow_function = function(start, argnames, is_async) {
  1661. if (has_newline_before(S.token)) {
  1662. croak("Unexpected newline before arrow (=>)");
  1663. }
  1664. expect_token("arrow", "=>");
  1665. var body = _function_body(is("punc", "{"), false, is_async);
  1666. // (should never return typescript_ellide)
  1667. return new AST_Arrow({
  1668. start : start,
  1669. end : body.end,
  1670. async : is_async,
  1671. argnames : argnames,
  1672. body : body
  1673. });
  1674. };
  1675. var function_ = function(ctor, is_generator, is_async, is_export_default) {
  1676. var in_statement = ctor === AST_Defun;
  1677. if (is("operator", "*")) {
  1678. is_generator = true;
  1679. next();
  1680. }
  1681. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  1682. if (in_statement && !name) {
  1683. if (is_export_default) {
  1684. ctor = AST_Function;
  1685. } else {
  1686. unexpected();
  1687. }
  1688. }
  1689. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  1690. unexpected(prev());
  1691. if (is("operator", "<")) {
  1692. typescript_type_parameters();
  1693. }
  1694. var args = [];
  1695. const start = S.token;
  1696. var body = _function_body(true, is_generator, is_async, name, args);
  1697. if (body == typescript_ellide) return body;
  1698. return new ctor({
  1699. start,
  1700. is_generator: is_generator,
  1701. async : is_async,
  1702. name : name,
  1703. argnames: args,
  1704. body : body,
  1705. end : prev(),
  1706. });
  1707. };
  1708. class UsedParametersTracker {
  1709. constructor(is_parameter, strict, duplicates_ok = false) {
  1710. this.is_parameter = is_parameter;
  1711. this.duplicates_ok = duplicates_ok;
  1712. this.parameters = new Set();
  1713. this.duplicate = null;
  1714. this.default_assignment = false;
  1715. this.spread = false;
  1716. this.strict_mode = !!strict;
  1717. }
  1718. add_parameter(token) {
  1719. if (this.parameters.has(token.value)) {
  1720. if (this.duplicate === null) {
  1721. this.duplicate = token;
  1722. }
  1723. this.check_strict();
  1724. } else {
  1725. this.parameters.add(token.value);
  1726. if (this.is_parameter) {
  1727. switch (token.value) {
  1728. case "arguments":
  1729. case "eval":
  1730. case "yield":
  1731. if (this.strict_mode) {
  1732. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1733. }
  1734. break;
  1735. default:
  1736. if (RESERVED_WORDS.has(token.value)) {
  1737. unexpected();
  1738. }
  1739. }
  1740. }
  1741. }
  1742. }
  1743. mark_default_assignment(token) {
  1744. if (this.default_assignment === false) {
  1745. this.default_assignment = token;
  1746. }
  1747. }
  1748. mark_spread(token) {
  1749. if (this.spread === false) {
  1750. this.spread = token;
  1751. }
  1752. }
  1753. mark_strict_mode() {
  1754. this.strict_mode = true;
  1755. }
  1756. is_strict() {
  1757. return this.default_assignment !== false || this.spread !== false || this.strict_mode;
  1758. }
  1759. check_strict() {
  1760. if (this.is_strict() && this.duplicate !== null && !this.duplicates_ok) {
  1761. token_error(this.duplicate, "Parameter " + this.duplicate.value + " was used already");
  1762. }
  1763. }
  1764. }
  1765. function parameters(params) {
  1766. var used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1767. expect("(");
  1768. while (!is("punc", ")")) {
  1769. if (is("name", "this") && typescript_skip_this_type()) {
  1770. continue;
  1771. }
  1772. var param = parameter(used_parameters);
  1773. params.push(param);
  1774. if (!is("punc", ")")) {
  1775. expect(",");
  1776. }
  1777. if (param instanceof AST_Expansion) {
  1778. break;
  1779. }
  1780. }
  1781. next();
  1782. }
  1783. function parameter(used_parameters, symbol_type) {
  1784. var param;
  1785. var expand = false;
  1786. if (used_parameters === undefined) {
  1787. used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1788. }
  1789. if (is("expand", "...")) {
  1790. expand = S.token;
  1791. used_parameters.mark_spread(S.token);
  1792. next();
  1793. }
  1794. param = binding_element(used_parameters, symbol_type);
  1795. if (is("punc", ":") || is("operator", "?")) {
  1796. typescript_maybe_annotation();
  1797. }
  1798. if (is("operator", "=") && expand === false) {
  1799. used_parameters.mark_default_assignment(S.token);
  1800. next();
  1801. param = new AST_DefaultAssign({
  1802. start: param.start,
  1803. left: param,
  1804. operator: "=",
  1805. right: expression(false),
  1806. end: S.token
  1807. });
  1808. }
  1809. if (expand !== false) {
  1810. if (!is("punc", ")")) {
  1811. unexpected();
  1812. }
  1813. param = new AST_Expansion({
  1814. start: expand,
  1815. expression: param,
  1816. end: expand
  1817. });
  1818. }
  1819. used_parameters.check_strict();
  1820. return param;
  1821. }
  1822. function binding_element(used_parameters, symbol_type) {
  1823. var elements = [];
  1824. var first = true;
  1825. var is_expand = false;
  1826. var expand_token;
  1827. var first_token = S.token;
  1828. if (used_parameters === undefined) {
  1829. const strict = S.input.has_directive("use strict");
  1830. const duplicates_ok = symbol_type === AST_SymbolVar;
  1831. used_parameters = new UsedParametersTracker(false, strict, duplicates_ok);
  1832. }
  1833. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1834. if (is("punc", "[")) {
  1835. next();
  1836. while (!is("punc", "]")) {
  1837. if (first) {
  1838. first = false;
  1839. } else {
  1840. expect(",");
  1841. }
  1842. if (is("expand", "...")) {
  1843. is_expand = true;
  1844. expand_token = S.token;
  1845. used_parameters.mark_spread(S.token);
  1846. next();
  1847. }
  1848. if (is("punc")) {
  1849. switch (S.token.value) {
  1850. case ",":
  1851. elements.push(new AST_Hole({
  1852. start: S.token,
  1853. end: S.token
  1854. }));
  1855. continue;
  1856. case "]": // Trailing comma after last element
  1857. break;
  1858. case "[":
  1859. case "{":
  1860. elements.push(binding_element(used_parameters, symbol_type));
  1861. break;
  1862. default:
  1863. unexpected();
  1864. }
  1865. } else if (is("name")) {
  1866. used_parameters.add_parameter(S.token);
  1867. elements.push(as_symbol(symbol_type));
  1868. } else {
  1869. croak("Invalid function parameter");
  1870. }
  1871. if (is("operator", "=") && is_expand === false) {
  1872. used_parameters.mark_default_assignment(S.token);
  1873. next();
  1874. elements[elements.length - 1] = new AST_DefaultAssign({
  1875. start: elements[elements.length - 1].start,
  1876. left: elements[elements.length - 1],
  1877. operator: "=",
  1878. right: expression(false),
  1879. end: S.token
  1880. });
  1881. }
  1882. if (is_expand) {
  1883. if (!is("punc", "]")) {
  1884. croak("Rest element must be last element");
  1885. }
  1886. elements[elements.length - 1] = new AST_Expansion({
  1887. start: expand_token,
  1888. expression: elements[elements.length - 1],
  1889. end: expand_token
  1890. });
  1891. }
  1892. }
  1893. expect("]");
  1894. used_parameters.check_strict();
  1895. return new AST_Destructuring({
  1896. start: first_token,
  1897. names: elements,
  1898. is_array: true,
  1899. end: prev()
  1900. });
  1901. } else if (is("punc", "{")) {
  1902. next();
  1903. while (!is("punc", "}")) {
  1904. if (first) {
  1905. first = false;
  1906. } else {
  1907. expect(",");
  1908. }
  1909. if (is("expand", "...")) {
  1910. is_expand = true;
  1911. expand_token = S.token;
  1912. used_parameters.mark_spread(S.token);
  1913. next();
  1914. }
  1915. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1916. used_parameters.add_parameter(S.token);
  1917. var start = prev();
  1918. var value = as_symbol(symbol_type);
  1919. if (is_expand) {
  1920. elements.push(new AST_Expansion({
  1921. start: expand_token,
  1922. expression: value,
  1923. end: value.end,
  1924. }));
  1925. } else {
  1926. elements.push(new AST_ObjectKeyVal({
  1927. start: start,
  1928. key: value.name,
  1929. value: value,
  1930. end: value.end,
  1931. }));
  1932. }
  1933. } else if (is("punc", "}")) {
  1934. continue; // Allow trailing hole
  1935. } else {
  1936. var property_token = S.token;
  1937. var property = as_property_name();
  1938. if (property === null) {
  1939. unexpected(prev());
  1940. } else if (prev().type === "name" && !is("punc", ":")) {
  1941. elements.push(new AST_ObjectKeyVal({
  1942. start: prev(),
  1943. key: property,
  1944. value: new symbol_type({
  1945. start: prev(),
  1946. name: property,
  1947. end: prev()
  1948. }),
  1949. end: prev()
  1950. }));
  1951. } else {
  1952. expect(":");
  1953. elements.push(new AST_ObjectKeyVal({
  1954. start: property_token,
  1955. quote: property_token.quote,
  1956. key: property,
  1957. value: binding_element(used_parameters, symbol_type),
  1958. end: prev()
  1959. }));
  1960. }
  1961. }
  1962. if (is_expand) {
  1963. if (!is("punc", "}")) {
  1964. croak("Rest element must be last element");
  1965. }
  1966. } else if (is("operator", "=")) {
  1967. used_parameters.mark_default_assignment(S.token);
  1968. next();
  1969. elements[elements.length - 1].value = new AST_DefaultAssign({
  1970. start: elements[elements.length - 1].value.start,
  1971. left: elements[elements.length - 1].value,
  1972. operator: "=",
  1973. right: expression(false),
  1974. end: S.token
  1975. });
  1976. }
  1977. }
  1978. expect("}");
  1979. used_parameters.check_strict();
  1980. return new AST_Destructuring({
  1981. start: first_token,
  1982. names: elements,
  1983. is_array: false,
  1984. end: prev()
  1985. });
  1986. } else if (is("name")) {
  1987. used_parameters.add_parameter(S.token);
  1988. return as_symbol(symbol_type);
  1989. } else {
  1990. croak("Invalid function parameter");
  1991. }
  1992. }
  1993. function params_or_seq_(allow_arrows, maybe_sequence) {
  1994. var spread_token;
  1995. var invalid_sequence;
  1996. var trailing_comma;
  1997. var a = [];
  1998. expect("(");
  1999. while (!is("punc", ")")) {
  2000. if (spread_token) unexpected(spread_token);
  2001. if (is("expand", "...")) {
  2002. spread_token = S.token;
  2003. if (maybe_sequence) invalid_sequence = S.token;
  2004. next();
  2005. a.push(new AST_Expansion({
  2006. start: prev(),
  2007. expression: expression(),
  2008. end: S.token,
  2009. }));
  2010. } else {
  2011. a.push(expression());
  2012. }
  2013. if (is("punc", ":") || is("operator", "?")) {
  2014. typescript_maybe_annotation();
  2015. }
  2016. if (!is("punc", ")")) {
  2017. expect(",");
  2018. if (is("punc", ")")) {
  2019. trailing_comma = prev();
  2020. if (maybe_sequence) invalid_sequence = trailing_comma;
  2021. }
  2022. }
  2023. }
  2024. expect(")");
  2025. if (allow_arrows && is("punc", ":")) {
  2026. typescript_type_annotation();
  2027. }
  2028. if (allow_arrows && is("arrow", "=>")) {
  2029. if (spread_token && trailing_comma) unexpected(trailing_comma);
  2030. } else if (invalid_sequence) {
  2031. unexpected(invalid_sequence);
  2032. }
  2033. return a;
  2034. }
  2035. function _function_body(block, generator, is_async, name, args) {
  2036. var loop = S.in_loop;
  2037. var labels = S.labels;
  2038. var current_generator = S.in_generator;
  2039. var current_async = S.in_async;
  2040. ++S.in_function;
  2041. if (generator)
  2042. S.in_generator = S.in_function;
  2043. if (is_async)
  2044. S.in_async = S.in_function;
  2045. if (args) {
  2046. parameters(args);
  2047. if (is("punc", ":")) typescript_type_annotation();
  2048. if (block && !is("punc", "{") && typescript_is_function_no_body()) {
  2049. return typescript_ellide;
  2050. }
  2051. }
  2052. if (block)
  2053. S.in_directives = true;
  2054. S.in_loop = 0;
  2055. S.labels = [];
  2056. if (block) {
  2057. S.input.push_directives_stack();
  2058. var a = block_();
  2059. if (name) _verify_symbol(name);
  2060. if (args) args.forEach(_verify_symbol);
  2061. S.input.pop_directives_stack();
  2062. } else {
  2063. var a = [new AST_Return({
  2064. start: S.token,
  2065. value: expression(false),
  2066. end: S.token
  2067. })];
  2068. }
  2069. --S.in_function;
  2070. S.in_loop = loop;
  2071. S.labels = labels;
  2072. S.in_generator = current_generator;
  2073. S.in_async = current_async;
  2074. return a;
  2075. }
  2076. function _await_expression() {
  2077. // Previous token must be "await" and not be interpreted as an identifier
  2078. if (!can_await()) {
  2079. croak("Unexpected await expression outside async function",
  2080. S.prev.line, S.prev.col, S.prev.pos);
  2081. }
  2082. // the await expression is parsed as a unary expression in Babel
  2083. return new AST_Await({
  2084. start: prev(),
  2085. end: S.token,
  2086. expression : maybe_unary(true),
  2087. });
  2088. }
  2089. function _yield_expression() {
  2090. var start = S.token;
  2091. var star = false;
  2092. var has_expression = true;
  2093. // Attempt to get expression or star (and then the mandatory expression)
  2094. // behind yield on the same line.
  2095. //
  2096. // If nothing follows on the same line of the yieldExpression,
  2097. // it should default to the value `undefined` for yield to return.
  2098. // In that case, the `undefined` stored as `null` in ast.
  2099. //
  2100. // Note 1: It isn't allowed for yield* to close without an expression
  2101. // Note 2: If there is a nlb between yield and star, it is interpret as
  2102. // yield <explicit undefined> <inserted automatic semicolon> *
  2103. if (
  2104. can_insert_semicolon()
  2105. || is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value)
  2106. || is("template_cont")
  2107. ) {
  2108. has_expression = false;
  2109. } else if (is("operator", "*")) {
  2110. star = true;
  2111. next();
  2112. }
  2113. return new AST_Yield({
  2114. start : start,
  2115. is_star : star,
  2116. expression : has_expression ? expression() : null,
  2117. end : prev()
  2118. });
  2119. }
  2120. function if_() {
  2121. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  2122. if (is("keyword", "else")) {
  2123. next();
  2124. belse = statement(false, false, true);
  2125. }
  2126. return new AST_If({
  2127. condition : cond,
  2128. body : body,
  2129. alternative : belse
  2130. });
  2131. }
  2132. function block_() {
  2133. expect("{");
  2134. var a = [];
  2135. while (!is("punc", "}")) {
  2136. if (is("eof")) unexpected();
  2137. a.push(statement());
  2138. }
  2139. next();
  2140. return a;
  2141. }
  2142. function switch_body_() {
  2143. expect("{");
  2144. var a = [], cur = null, branch = null, tmp;
  2145. while (!is("punc", "}")) {
  2146. if (is("eof")) unexpected();
  2147. if (is("keyword", "case")) {
  2148. if (branch) branch.end = prev();
  2149. cur = [];
  2150. branch = new AST_Case({
  2151. start : (tmp = S.token, next(), tmp),
  2152. expression : expression(true),
  2153. body : cur
  2154. });
  2155. a.push(branch);
  2156. expect(":");
  2157. } else if (is("keyword", "default")) {
  2158. if (branch) branch.end = prev();
  2159. cur = [];
  2160. branch = new AST_Default({
  2161. start : (tmp = S.token, next(), expect(":"), tmp),
  2162. body : cur
  2163. });
  2164. a.push(branch);
  2165. } else {
  2166. if (!cur) unexpected();
  2167. cur.push(statement());
  2168. }
  2169. }
  2170. if (branch) branch.end = prev();
  2171. next();
  2172. return a;
  2173. }
  2174. function try_() {
  2175. var body, bcatch = null, bfinally = null;
  2176. body = new AST_TryBlock({
  2177. start : S.token,
  2178. body : block_(),
  2179. end : prev(),
  2180. });
  2181. if (is("keyword", "catch")) {
  2182. var start = S.token;
  2183. next();
  2184. if (is("punc", "{")) {
  2185. var name = null;
  2186. } else {
  2187. expect("(");
  2188. var name = parameter(undefined, AST_SymbolCatch);
  2189. expect(")");
  2190. }
  2191. bcatch = new AST_Catch({
  2192. start : start,
  2193. argname : name,
  2194. body : block_(),
  2195. end : prev()
  2196. });
  2197. }
  2198. if (is("keyword", "finally")) {
  2199. var start = S.token;
  2200. next();
  2201. bfinally = new AST_Finally({
  2202. start : start,
  2203. body : block_(),
  2204. end : prev()
  2205. });
  2206. }
  2207. if (!bcatch && !bfinally)
  2208. croak("Missing catch/finally blocks");
  2209. return new AST_Try({
  2210. body : body,
  2211. bcatch : bcatch,
  2212. bfinally : bfinally
  2213. });
  2214. }
  2215. /**
  2216. * var
  2217. * vardef1 = 2,
  2218. * vardef2 = 3;
  2219. */
  2220. function vardefs(no_in, kind) {
  2221. var var_defs = [];
  2222. for (;;) {
  2223. var sym_type =
  2224. kind === "var" ? AST_SymbolVar :
  2225. kind === "const" ? AST_SymbolConst :
  2226. kind === "let" ? AST_SymbolLet :
  2227. kind === "using" ? AST_SymbolUsing :
  2228. kind === "await using" ? AST_SymbolUsing : null;
  2229. var def_type = kind === "using" || kind === "await using" ? AST_UsingDef : AST_VarDef;
  2230. var start = S.token;
  2231. var name = is("punc", "{") || is("punc", "[")
  2232. ? binding_element(undefined, sym_type)
  2233. : as_symbol(sym_type);
  2234. if (name.name == "import") croak("Unexpected token: import");
  2235. if (is("punc", ":")) {
  2236. typescript_type_annotation();
  2237. }
  2238. var value = is("operator", "=")
  2239. ? (next(), expression(false, no_in))
  2240. : null;
  2241. if (!value && !no_in && (kind === "const" || kind === "using" || kind === "await using")) {
  2242. croak("Missing initializer in " + kind + " declaration");
  2243. }
  2244. var def = new def_type({
  2245. start,
  2246. name,
  2247. value,
  2248. end: prev()
  2249. });
  2250. var_defs.push(def);
  2251. if (!is("punc", ","))
  2252. break;
  2253. next();
  2254. }
  2255. return var_defs;
  2256. }
  2257. var var_ = function(no_in) {
  2258. return new AST_Var({
  2259. start : prev(),
  2260. definitions : vardefs(no_in, "var"),
  2261. end : prev()
  2262. });
  2263. };
  2264. var let_ = function(no_in) {
  2265. return new AST_Let({
  2266. start : prev(),
  2267. definitions : vardefs(no_in, "let"),
  2268. end : prev()
  2269. });
  2270. };
  2271. var const_ = function(no_in) {
  2272. return new AST_Const({
  2273. start : prev(),
  2274. definitions : vardefs(no_in, "const"),
  2275. end : prev()
  2276. });
  2277. };
  2278. var using_ = function(no_in) {
  2279. return new AST_Using({
  2280. start : prev(),
  2281. await : false,
  2282. definitions : vardefs(no_in, "using"),
  2283. end : prev()
  2284. });
  2285. };
  2286. var await_using_ = function(no_in) {
  2287. // Assumption: When await_using_ is called, only the `await` token has been consumed.
  2288. return new AST_Using({
  2289. start : prev(),
  2290. await : true,
  2291. definitions : (next(), vardefs(no_in, "await using")),
  2292. end : prev()
  2293. });
  2294. };
  2295. var new_ = function(allow_calls) {
  2296. var start = S.token;
  2297. expect_token("operator", "new");
  2298. if (is("punc", ".")) {
  2299. next();
  2300. expect_token("name", "target");
  2301. return subscripts(new AST_NewTarget({
  2302. start : start,
  2303. end : prev()
  2304. }), allow_calls);
  2305. }
  2306. var newexp = expr_atom(false), args;
  2307. if (is("punc", "(")) {
  2308. next();
  2309. args = expr_list(")", true);
  2310. } else {
  2311. args = [];
  2312. }
  2313. var call = new AST_New({
  2314. start : start,
  2315. expression : newexp,
  2316. args : args,
  2317. end : prev()
  2318. });
  2319. annotate(call);
  2320. return subscripts(call, allow_calls);
  2321. };
  2322. function as_atom_node() {
  2323. var tok = S.token, ret;
  2324. switch (tok.type) {
  2325. case "name":
  2326. ret = _make_symbol(AST_SymbolRef);
  2327. break;
  2328. case "num":
  2329. if (tok.value === Infinity) {
  2330. // very large float values are parsed as Infinity
  2331. ret = new AST_Infinity({
  2332. start: tok,
  2333. end: tok,
  2334. });
  2335. } else {
  2336. ret = new AST_Number({
  2337. start: tok,
  2338. end: tok,
  2339. value: tok.value,
  2340. raw: LATEST_RAW
  2341. });
  2342. }
  2343. break;
  2344. case "big_int":
  2345. ret = new AST_BigInt({
  2346. start: tok,
  2347. end: tok,
  2348. value: tok.value,
  2349. raw: LATEST_RAW,
  2350. });
  2351. break;
  2352. case "string":
  2353. ret = new AST_String({
  2354. start : tok,
  2355. end : tok,
  2356. value : tok.value,
  2357. quote : tok.quote
  2358. });
  2359. annotate(ret);
  2360. break;
  2361. case "regexp":
  2362. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  2363. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  2364. break;
  2365. case "atom":
  2366. switch (tok.value) {
  2367. case "false":
  2368. ret = new AST_False({ start: tok, end: tok });
  2369. break;
  2370. case "true":
  2371. ret = new AST_True({ start: tok, end: tok });
  2372. break;
  2373. case "null":
  2374. ret = new AST_Null({ start: tok, end: tok });
  2375. break;
  2376. }
  2377. break;
  2378. }
  2379. next();
  2380. return ret;
  2381. }
  2382. function to_fun_args(ex, default_seen_above) {
  2383. var insert_default = function(ex, default_value) {
  2384. if (default_value) {
  2385. return new AST_DefaultAssign({
  2386. start: ex.start,
  2387. left: ex,
  2388. operator: "=",
  2389. right: default_value,
  2390. end: default_value.end
  2391. });
  2392. }
  2393. return ex;
  2394. };
  2395. if (ex instanceof AST_Object) {
  2396. return insert_default(new AST_Destructuring({
  2397. start: ex.start,
  2398. end: ex.end,
  2399. is_array: false,
  2400. names: ex.properties.map(prop => to_fun_args(prop))
  2401. }), default_seen_above);
  2402. } else if (ex instanceof AST_ObjectKeyVal) {
  2403. ex.value = to_fun_args(ex.value);
  2404. return insert_default(ex, default_seen_above);
  2405. } else if (ex instanceof AST_Hole) {
  2406. return ex;
  2407. } else if (ex instanceof AST_Destructuring) {
  2408. ex.names = ex.names.map(name => to_fun_args(name));
  2409. return insert_default(ex, default_seen_above);
  2410. } else if (ex instanceof AST_SymbolRef) {
  2411. return insert_default(new AST_SymbolFunarg({
  2412. name: ex.name,
  2413. start: ex.start,
  2414. end: ex.end
  2415. }), default_seen_above);
  2416. } else if (ex instanceof AST_Expansion) {
  2417. ex.expression = to_fun_args(ex.expression);
  2418. return insert_default(ex, default_seen_above);
  2419. } else if (ex instanceof AST_Array) {
  2420. return insert_default(new AST_Destructuring({
  2421. start: ex.start,
  2422. end: ex.end,
  2423. is_array: true,
  2424. names: ex.elements.map(elm => to_fun_args(elm))
  2425. }), default_seen_above);
  2426. } else if (ex instanceof AST_Assign) {
  2427. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2428. } else if (ex instanceof AST_DefaultAssign) {
  2429. ex.left = to_fun_args(ex.left);
  2430. return ex;
  2431. } else {
  2432. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2433. }
  2434. }
  2435. var expr_atom = function(allow_calls, allow_arrows) {
  2436. if (is("operator", "<")) {
  2437. typescript_skip_type_parameters_before_call();
  2438. }
  2439. if (is("operator", "new")) {
  2440. return new_(allow_calls);
  2441. }
  2442. if (is("name", "import")) {
  2443. return import_expr(allow_calls);
  2444. }
  2445. var start = S.token;
  2446. var peeked;
  2447. var async = is("name", "async")
  2448. && (peeked = peek()).value != "["
  2449. && peeked.type != "arrow"
  2450. && as_atom_node();
  2451. if (async && is("operator", "<")) {
  2452. // async <T>() => null
  2453. typescript_skip_type_parameters_before_call();
  2454. }
  2455. if (is("punc")) {
  2456. switch (S.token.value) {
  2457. case "(":
  2458. if (async && !allow_calls) break;
  2459. var exprs = params_or_seq_(allow_arrows, !async);
  2460. if (allow_arrows && is("punc", ":")) {
  2461. typescript_type_annotation();
  2462. }
  2463. if (allow_arrows && is("arrow", "=>")) {
  2464. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2465. }
  2466. var ex = async ? new AST_Call({
  2467. expression: async,
  2468. args: exprs
  2469. }) : to_expr_or_sequence(start, exprs);
  2470. if (ex.start) {
  2471. const outer_comments_before = start.comments_before.length;
  2472. outer_comments_before_counts.set(start, outer_comments_before);
  2473. ex.start.comments_before.unshift(...start.comments_before);
  2474. start.comments_before = ex.start.comments_before;
  2475. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2476. var comment = start.comments_before[0];
  2477. if (!comment.nlb) {
  2478. comment.nlb = start.nlb;
  2479. start.nlb = false;
  2480. }
  2481. }
  2482. start.comments_after = ex.start.comments_after;
  2483. }
  2484. ex.start = start;
  2485. var end = prev();
  2486. if (ex.end) {
  2487. end.comments_before = ex.end.comments_before;
  2488. ex.end.comments_after.push(...end.comments_after);
  2489. end.comments_after = ex.end.comments_after;
  2490. }
  2491. ex.end = end;
  2492. if (ex instanceof AST_Call) annotate(ex);
  2493. return subscripts(ex, allow_calls);
  2494. case "[":
  2495. return subscripts(array_(), allow_calls);
  2496. case "{":
  2497. return subscripts(object_or_destructuring_(), allow_calls);
  2498. }
  2499. if (!async) unexpected();
  2500. }
  2501. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2502. var param = new AST_SymbolFunarg({
  2503. name: S.token.value,
  2504. start: start,
  2505. end: start,
  2506. });
  2507. next();
  2508. return arrow_function(start, [param], !!async);
  2509. }
  2510. if (is("keyword", "function")) {
  2511. next();
  2512. var func = function_(AST_Function, false, !!async);
  2513. if (func == typescript_ellide) typescript_croak();
  2514. func.start = start;
  2515. func.end = prev();
  2516. return subscripts(func, allow_calls);
  2517. }
  2518. if (async) return subscripts(async, allow_calls);
  2519. if (is("keyword", "class")) {
  2520. next();
  2521. var cls = class_(AST_ClassExpression);
  2522. cls.start = start;
  2523. cls.end = prev();
  2524. return subscripts(cls, allow_calls);
  2525. }
  2526. if (is("template_head")) {
  2527. return subscripts(template_string(), allow_calls);
  2528. }
  2529. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2530. return subscripts(as_atom_node(), allow_calls);
  2531. }
  2532. unexpected();
  2533. };
  2534. function template_string() {
  2535. var segments = [], start = S.token;
  2536. segments.push(new AST_TemplateSegment({
  2537. start: S.token,
  2538. raw: TEMPLATE_RAWS.get(S.token),
  2539. value: S.token.value,
  2540. end: S.token
  2541. }));
  2542. while (!S.token.template_end) {
  2543. next();
  2544. handle_regexp();
  2545. segments.push(expression(true));
  2546. segments.push(new AST_TemplateSegment({
  2547. start: S.token,
  2548. raw: TEMPLATE_RAWS.get(S.token),
  2549. value: S.token.value,
  2550. end: S.token
  2551. }));
  2552. }
  2553. next();
  2554. return new AST_TemplateString({
  2555. start: start,
  2556. segments: segments,
  2557. end: S.token
  2558. });
  2559. }
  2560. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2561. var first = true, a = [];
  2562. while (!is("punc", closing)) {
  2563. if (first) first = false; else expect(",");
  2564. if (allow_trailing_comma && is("punc", closing)) break;
  2565. if (is("punc", ",") && allow_empty) {
  2566. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2567. } else if (is("expand", "...")) {
  2568. next();
  2569. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2570. } else {
  2571. a.push(expression(false));
  2572. }
  2573. }
  2574. next();
  2575. return a;
  2576. }
  2577. var array_ = embed_tokens(function() {
  2578. expect("[");
  2579. return new AST_Array({
  2580. elements: expr_list("]", !options.strict, true)
  2581. });
  2582. });
  2583. var create_accessor = (is_generator, is_async) => {
  2584. return function_(AST_Accessor, is_generator, is_async);
  2585. };
  2586. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2587. var start = S.token, first = true, a = [];
  2588. expect("{");
  2589. while (!is("punc", "}")) {
  2590. if (first) first = false; else expect(",");
  2591. if (!options.strict && is("punc", "}"))
  2592. // allow trailing comma
  2593. break;
  2594. start = S.token;
  2595. if (start.type == "expand") {
  2596. next();
  2597. a.push(new AST_Expansion({
  2598. start: start,
  2599. expression: expression(false),
  2600. end: prev(),
  2601. }));
  2602. continue;
  2603. }
  2604. if(is("privatename")) {
  2605. croak("private fields are not allowed in an object");
  2606. }
  2607. var name = as_property_name();
  2608. var value;
  2609. // Check property and fetch value
  2610. if (!is("punc", ":")) {
  2611. var concise = object_or_class_property(name, start);
  2612. if (concise === typescript_ellide) {
  2613. continue;
  2614. }
  2615. if (concise) {
  2616. a.push(concise);
  2617. continue;
  2618. }
  2619. value = new AST_SymbolRef({
  2620. start: prev(),
  2621. name: name,
  2622. end: prev()
  2623. });
  2624. } else if (name === null) {
  2625. unexpected(prev());
  2626. } else {
  2627. next(); // `:` - see first condition
  2628. value = expression(false);
  2629. }
  2630. // Check for default value and alter value accordingly if necessary
  2631. if (is("operator", "=")) {
  2632. next();
  2633. value = new AST_Assign({
  2634. start: start,
  2635. left: value,
  2636. operator: "=",
  2637. right: expression(false),
  2638. logical: false,
  2639. end: prev()
  2640. });
  2641. }
  2642. // Create property
  2643. const kv = new AST_ObjectKeyVal({
  2644. start: start,
  2645. quote: start.quote,
  2646. key: name,
  2647. value: value,
  2648. end: prev()
  2649. });
  2650. a.push(annotate(kv));
  2651. }
  2652. next();
  2653. return new AST_Object({ properties: a });
  2654. });
  2655. function class_(KindOfClass, is_export_default) {
  2656. var start, method, class_name, extends_, properties = [];
  2657. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2658. S.input.add_directive("use strict");
  2659. if (S.token.type == "name" && S.token.value != "extends") {
  2660. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2661. }
  2662. if (KindOfClass === AST_DefClass && !class_name) {
  2663. if (is_export_default) {
  2664. KindOfClass = AST_ClassExpression;
  2665. } else {
  2666. unexpected();
  2667. }
  2668. }
  2669. if (is("operator", "<")) {
  2670. typescript_type_parameters();
  2671. }
  2672. if (S.token.value == "extends") {
  2673. next();
  2674. extends_ = expression(true);
  2675. }
  2676. if (is("name", "implements")) {
  2677. typescript_extends_implements();
  2678. }
  2679. expect("{");
  2680. // mark in class feild,
  2681. const save_in_class = S.in_class;
  2682. S.in_class = true;
  2683. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2684. while (!is("punc", "}")) {
  2685. start = S.token;
  2686. method = object_or_class_property(as_property_name(true), start, true);
  2687. if (!method) { unexpected(); }
  2688. if (method !== typescript_ellide) {
  2689. properties.push(method);
  2690. }
  2691. while (is("punc", ";")) { next(); }
  2692. }
  2693. // mark in class feild,
  2694. S.in_class = save_in_class;
  2695. S.input.pop_directives_stack();
  2696. next();
  2697. return new KindOfClass({
  2698. start: start,
  2699. name: class_name,
  2700. extends: extends_,
  2701. properties: properties,
  2702. end: prev(),
  2703. });
  2704. }
  2705. function object_or_class_property(name, start, is_class) {
  2706. const get_symbol_ast = (name, SymbolClass) => {
  2707. if (typeof name === "string") {
  2708. return new SymbolClass({ start, name, end: prev() });
  2709. } else if (name === null) {
  2710. unexpected();
  2711. }
  2712. return name;
  2713. };
  2714. var is_private = prev().type === "privatename";
  2715. const is_not_method_start = () =>
  2716. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=") && !is_private;
  2717. var is_async = false;
  2718. var is_static = false;
  2719. var is_generator = false;
  2720. var accessor_type = null;
  2721. if (name === typescript_ellide) return name;
  2722. if (is_class && (name === "public" || name === "private" || name === "protected") && is_not_method_start()) {
  2723. const did_eat = typescript_is_accessibility_modifier();
  2724. if (did_eat) name = as_property_name(true);
  2725. }
  2726. if (name === typescript_ellide) return name;
  2727. if (is_class && name === "static" && is_not_method_start()) {
  2728. const static_block = class_static_block();
  2729. if (static_block != null) {
  2730. return static_block;
  2731. }
  2732. is_static = true;
  2733. name = as_property_name(true);
  2734. }
  2735. if (name === typescript_ellide) return name;
  2736. if (name === "readonly" && typescript_is_readonly() && is_not_method_start()) {
  2737. name = as_property_name(true);
  2738. }
  2739. if (name === typescript_ellide) return name;
  2740. if (name === "async" && is_not_method_start()) {
  2741. is_async = true;
  2742. name = as_property_name();
  2743. }
  2744. if (prev().type === "operator" && prev().value === "*") {
  2745. is_generator = true;
  2746. name = as_property_name();
  2747. }
  2748. if ((name === "get" || name === "set") && is_not_method_start()) {
  2749. accessor_type = name;
  2750. name = as_property_name();
  2751. }
  2752. if (!is_private && prev().type === "privatename") {
  2753. is_private = true;
  2754. }
  2755. const property_token = prev();
  2756. if (is("punc", ":")) {
  2757. typescript_type_annotation();
  2758. }
  2759. if (accessor_type != null) {
  2760. if (!is_private) {
  2761. const AccessorClass = accessor_type === "get"
  2762. ? AST_ObjectGetter
  2763. : AST_ObjectSetter;
  2764. name = get_symbol_ast(name, AST_SymbolMethod);
  2765. const accessor = create_accessor();
  2766. if (accessor == typescript_ellide) return accessor;
  2767. return annotate(new AccessorClass({
  2768. start,
  2769. static: is_static,
  2770. key: name,
  2771. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  2772. value: accessor,
  2773. end: prev()
  2774. }));
  2775. } else {
  2776. const AccessorClass = accessor_type === "get"
  2777. ? AST_PrivateGetter
  2778. : AST_PrivateSetter;
  2779. name = get_symbol_ast(name, AST_SymbolMethod);
  2780. const accessor = create_accessor();
  2781. if (accessor == typescript_ellide) return accessor;
  2782. return annotate(new AccessorClass({
  2783. start,
  2784. static: is_static,
  2785. key: name,
  2786. value: accessor,
  2787. end: prev(),
  2788. }));
  2789. }
  2790. }
  2791. if (is_class && is("operator", "<")) {
  2792. typescript_type_parameters();
  2793. }
  2794. if (is("punc", "(")) {
  2795. name = get_symbol_ast(name, AST_SymbolMethod);
  2796. const AST_MethodVariant = is_private
  2797. ? AST_PrivateMethod
  2798. : AST_ConciseMethod;
  2799. const accessor = create_accessor(is_generator, is_async);
  2800. if (accessor == typescript_ellide) return accessor;
  2801. var node = new AST_MethodVariant({
  2802. start : start,
  2803. static : is_static,
  2804. key : name,
  2805. quote : name instanceof AST_SymbolMethod ?
  2806. property_token.quote : undefined,
  2807. value : accessor,
  2808. end : prev()
  2809. });
  2810. return annotate(node);
  2811. }
  2812. if (is_class) {
  2813. const AST_SymbolVariant = is_private
  2814. ? AST_SymbolPrivateProperty
  2815. : AST_SymbolClassProperty;
  2816. const AST_ClassPropertyVariant = is_private
  2817. ? AST_ClassPrivateProperty
  2818. : AST_ClassProperty;
  2819. const key = get_symbol_ast(name, AST_SymbolVariant);
  2820. const quote = key instanceof AST_SymbolClassProperty
  2821. ? property_token.quote
  2822. : undefined;
  2823. if (is("operator", "=")) {
  2824. next();
  2825. return annotate(
  2826. new AST_ClassPropertyVariant({
  2827. start,
  2828. static: is_static,
  2829. quote,
  2830. key,
  2831. value: expression(false),
  2832. end: prev()
  2833. })
  2834. );
  2835. } else if (
  2836. is("name")
  2837. || is("privatename")
  2838. || is("punc", "[")
  2839. || is("operator", "*")
  2840. || is("punc", ";")
  2841. || is("punc", "}")
  2842. || is("string")
  2843. || is("num")
  2844. || is("big_int")
  2845. ) {
  2846. return annotate(
  2847. new AST_ClassPropertyVariant({
  2848. start,
  2849. static: is_static,
  2850. quote,
  2851. key,
  2852. end: prev()
  2853. })
  2854. );
  2855. }
  2856. }
  2857. }
  2858. function class_static_block() {
  2859. if (!is("punc", "{")) {
  2860. return null;
  2861. }
  2862. const start = S.token;
  2863. const body = [];
  2864. next();
  2865. while (!is("punc", "}")) {
  2866. body.push(statement());
  2867. }
  2868. next();
  2869. return new AST_ClassStaticBlock({ start, body, end: prev() });
  2870. }
  2871. function maybe_import_attributes() {
  2872. if (
  2873. (is("keyword", "with") || is("name", "assert"))
  2874. && !has_newline_before(S.token)
  2875. ) {
  2876. next();
  2877. return object_or_destructuring_();
  2878. }
  2879. return null;
  2880. }
  2881. function import_statement() {
  2882. var start = prev();
  2883. // import source x from "..."
  2884. // import defer * as x from "..."
  2885. var phase = null;
  2886. if (is("name", "source") || is("name", "defer")) {
  2887. var peeked = peek();
  2888. if (!is_token(peeked, "name", "from") && !is_token(peeked, "punc", ",")) {
  2889. phase = S.token.value;
  2890. next();
  2891. }
  2892. }
  2893. if (
  2894. is("name", "type")
  2895. && typescript_import_type_statement()
  2896. ) {
  2897. return new AST_EmptyStatement({ start, end: prev() });
  2898. }
  2899. var imported_name;
  2900. var imported_names;
  2901. if (is("name")) {
  2902. imported_name = as_symbol(AST_SymbolImport);
  2903. }
  2904. if (is("punc", ",")) {
  2905. next();
  2906. }
  2907. imported_names = map_names(true);
  2908. if (imported_names || imported_name) {
  2909. expect_token("name", "from");
  2910. }
  2911. var mod_str = S.token; // expect_token("string");
  2912. if (mod_str.type !== "string") {
  2913. unexpected();
  2914. }
  2915. next();
  2916. const attributes = maybe_import_attributes();
  2917. return new AST_Import({
  2918. start,
  2919. imported_name,
  2920. imported_names,
  2921. module_name: new AST_String({
  2922. start: mod_str,
  2923. value: mod_str.value,
  2924. quote: mod_str.quote,
  2925. end: mod_str,
  2926. }),
  2927. attributes,
  2928. phase,
  2929. end: S.token,
  2930. });
  2931. }
  2932. // import()
  2933. // import.source("module")
  2934. // import.defer("module")
  2935. // import.meta
  2936. function import_expr(allow_calls) {
  2937. var start = S.token;
  2938. expect_token("name", "import");
  2939. if (is("punc", "(")) {
  2940. next();
  2941. const args = expr_list(")");
  2942. return subscripts(new AST_DynamicImport({
  2943. start: start,
  2944. args,
  2945. phase: null,
  2946. end: prev(),
  2947. }), allow_calls);
  2948. }
  2949. expect_token("punc", ".");
  2950. if (is("name", "source") || is("name", "defer")) {
  2951. var phase = S.token.value;
  2952. next();
  2953. if (!is("punc", "(")) {
  2954. croak("'import." + phase + "' can only be used in a dynamic import");
  2955. }
  2956. next();
  2957. var args = expr_list(")");
  2958. return subscripts(new AST_DynamicImport({
  2959. start: start,
  2960. phase: phase,
  2961. args: args,
  2962. end: prev()
  2963. }), allow_calls);
  2964. }
  2965. expect_token("name", "meta");
  2966. return subscripts(new AST_ImportMeta({
  2967. start: start,
  2968. end: prev()
  2969. }), allow_calls);
  2970. }
  2971. function map_name(is_import) {
  2972. function make_symbol(type, quote) {
  2973. return new type({
  2974. name: as_property_name(),
  2975. quote: quote || undefined,
  2976. start: prev(),
  2977. end: prev()
  2978. });
  2979. }
  2980. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2981. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2982. var start = S.token;
  2983. var foreign_name;
  2984. var name;
  2985. if (is_import) {
  2986. foreign_name = make_symbol(foreign_type, start.quote);
  2987. } else {
  2988. name = make_symbol(type, start.quote);
  2989. }
  2990. if (is("name", "as")) {
  2991. next(); // The "as" word
  2992. if (is_import) {
  2993. name = make_symbol(type);
  2994. } else {
  2995. foreign_name = make_symbol(foreign_type, S.token.quote);
  2996. }
  2997. } else {
  2998. if (is_import) {
  2999. name = new type(foreign_name);
  3000. } else {
  3001. foreign_name = new foreign_type(name);
  3002. }
  3003. }
  3004. return new AST_NameMapping({
  3005. start: start,
  3006. foreign_name: foreign_name,
  3007. name: name,
  3008. end: prev(),
  3009. });
  3010. }
  3011. function map_nameAsterisk(is_import, import_or_export_foreign_name) {
  3012. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  3013. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  3014. var start = S.token;
  3015. var name, foreign_name;
  3016. var end = prev();
  3017. if (is_import) {
  3018. name = import_or_export_foreign_name;
  3019. } else {
  3020. foreign_name = import_or_export_foreign_name;
  3021. }
  3022. name = name || new type({
  3023. start: start,
  3024. name: "*",
  3025. end: end,
  3026. });
  3027. foreign_name = foreign_name || new foreign_type({
  3028. start: start,
  3029. name: "*",
  3030. end: end,
  3031. });
  3032. return new AST_NameMapping({
  3033. start: start,
  3034. foreign_name: foreign_name,
  3035. name: name,
  3036. end: end,
  3037. });
  3038. }
  3039. function map_names(is_import) {
  3040. var names;
  3041. if (is("punc", "{")) {
  3042. next();
  3043. names = [];
  3044. while (!is("punc", "}")) {
  3045. if (
  3046. is("name", "type")
  3047. && !(is_token(peek(), "name", "as") || is_token(peek(), "punc", ",") || is_token(peek(), "punc", "}"))
  3048. && typescript_import_named_type()
  3049. ) ; else {
  3050. names.push(map_name(is_import));
  3051. }
  3052. if (!is("punc", "}")) {
  3053. expect_token("punc", ",");
  3054. }
  3055. }
  3056. next();
  3057. } else if (is("operator", "*")) {
  3058. var name;
  3059. next();
  3060. if (is("name", "as")) {
  3061. next(); // The "as" word
  3062. name = is_import ? as_symbol(AST_SymbolImport) : as_symbol_or_string(AST_SymbolExportForeign);
  3063. }
  3064. names = [map_nameAsterisk(is_import, name)];
  3065. }
  3066. return names;
  3067. }
  3068. function export_statement() {
  3069. var start = S.token;
  3070. var is_default;
  3071. var exported_names;
  3072. if ((is("name", "type") || is("name", "interface"))) {
  3073. typescript_export_type_statement();
  3074. return new AST_EmptyStatement({ start, end: prev() });
  3075. }
  3076. if (is("keyword", "default")) {
  3077. is_default = true;
  3078. next();
  3079. } else if (exported_names = map_names(false)) {
  3080. if (is("name", "from")) {
  3081. next();
  3082. var mod_str = S.token;
  3083. if (mod_str.type !== "string") {
  3084. unexpected();
  3085. }
  3086. next();
  3087. const attributes = maybe_import_attributes();
  3088. return new AST_Export({
  3089. start: start,
  3090. is_default: is_default,
  3091. exported_names: exported_names,
  3092. module_name: new AST_String({
  3093. start: mod_str,
  3094. value: mod_str.value,
  3095. quote: mod_str.quote,
  3096. end: mod_str,
  3097. }),
  3098. end: prev(),
  3099. attributes
  3100. });
  3101. } else {
  3102. return new AST_Export({
  3103. start: start,
  3104. is_default: is_default,
  3105. exported_names: exported_names,
  3106. end: prev(),
  3107. });
  3108. }
  3109. }
  3110. var node;
  3111. var exported_value;
  3112. var exported_definition;
  3113. if (is("punc", "{")
  3114. || is_default
  3115. && (is("keyword", "class") || is("keyword", "function"))
  3116. && is_token(peek(), "punc")) {
  3117. exported_value = expression(false);
  3118. semicolon();
  3119. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  3120. unexpected(node.start);
  3121. } else if (
  3122. node instanceof AST_Definitions
  3123. || node instanceof AST_Defun
  3124. || node instanceof AST_DefClass
  3125. ) {
  3126. exported_definition = node;
  3127. } else if (
  3128. node instanceof AST_ClassExpression
  3129. || node instanceof AST_Function
  3130. ) {
  3131. exported_value = node;
  3132. } else if (node instanceof AST_SimpleStatement) {
  3133. exported_value = node.body;
  3134. } else {
  3135. unexpected(node.start);
  3136. }
  3137. return new AST_Export({
  3138. start: start,
  3139. is_default: is_default,
  3140. exported_value: exported_value,
  3141. exported_definition: exported_definition,
  3142. end: prev(),
  3143. attributes: null
  3144. });
  3145. }
  3146. function as_property_name(typescript_class_index_notation = false) {
  3147. var tmp = S.token;
  3148. switch (tmp.type) {
  3149. case "punc":
  3150. if (tmp.value === "[") {
  3151. next();
  3152. var ex = expression(false);
  3153. if (typescript_class_index_notation && is("punc", ":") && typescript_type_annotation()) {
  3154. expect("]");
  3155. if (is("punc", ":")) typescript_type_annotation();
  3156. return typescript_ellide;
  3157. }
  3158. expect("]");
  3159. return ex;
  3160. } else unexpected(tmp);
  3161. case "operator":
  3162. if (tmp.value === "*") {
  3163. next();
  3164. return null;
  3165. }
  3166. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  3167. unexpected(tmp);
  3168. }
  3169. /* falls through */
  3170. case "name":
  3171. case "privatename":
  3172. case "string":
  3173. case "keyword":
  3174. case "atom":
  3175. next();
  3176. return tmp.value;
  3177. case "num":
  3178. case "big_int":
  3179. next();
  3180. return "" + tmp.value;
  3181. default:
  3182. unexpected(tmp);
  3183. }
  3184. }
  3185. function as_name() {
  3186. var tmp = S.token;
  3187. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  3188. next();
  3189. return tmp.value;
  3190. }
  3191. function _make_symbol(type) {
  3192. var name = S.token.value;
  3193. return new (name == "this" ? AST_This :
  3194. name == "super" ? AST_Super :
  3195. type)({
  3196. name : String(name),
  3197. start : S.token,
  3198. end : S.token
  3199. });
  3200. }
  3201. function _verify_symbol(sym) {
  3202. var name = sym.name;
  3203. if (is_in_generator() && name == "yield") {
  3204. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  3205. }
  3206. if (S.input.has_directive("use strict")) {
  3207. if (name == "yield") {
  3208. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  3209. }
  3210. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  3211. token_error(sym.start, "Unexpected " + name + " in strict mode");
  3212. }
  3213. }
  3214. }
  3215. function as_symbol(type, noerror) {
  3216. if (!is("name")) {
  3217. if (!noerror) croak("Name expected");
  3218. return null;
  3219. }
  3220. var sym = _make_symbol(type);
  3221. _verify_symbol(sym);
  3222. next();
  3223. return sym;
  3224. }
  3225. function as_symbol_or_string(type) {
  3226. if (!is("name")) {
  3227. if (!is("string")) {
  3228. croak("Name or string expected");
  3229. }
  3230. var tok = S.token;
  3231. var ret = new type({
  3232. start : tok,
  3233. end : tok,
  3234. name : tok.value,
  3235. quote : tok.quote
  3236. });
  3237. next();
  3238. return ret;
  3239. }
  3240. var sym = _make_symbol(type);
  3241. _verify_symbol(sym);
  3242. next();
  3243. return sym;
  3244. }
  3245. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  3246. function annotate(node, before_token = node.start) {
  3247. var comments = before_token.comments_before;
  3248. const comments_outside_parens = outer_comments_before_counts.get(before_token);
  3249. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  3250. while (--i >= 0) {
  3251. var comment = comments[i];
  3252. if (/[@#]__/.test(comment.value)) {
  3253. if (/[@#]__PURE__/.test(comment.value)) {
  3254. set_annotation(node, _PURE);
  3255. break;
  3256. }
  3257. if (/[@#]__INLINE__/.test(comment.value)) {
  3258. set_annotation(node, _INLINE);
  3259. break;
  3260. }
  3261. if (/[@#]__NOINLINE__/.test(comment.value)) {
  3262. set_annotation(node, _NOINLINE);
  3263. break;
  3264. }
  3265. if (/[@#]__KEY__/.test(comment.value)) {
  3266. set_annotation(node, _KEY);
  3267. break;
  3268. }
  3269. if (/[@#]__MANGLE_PROP__/.test(comment.value)) {
  3270. set_annotation(node, _MANGLEPROP);
  3271. break;
  3272. }
  3273. }
  3274. }
  3275. return node;
  3276. }
  3277. var subscripts = function(expr, allow_calls, is_chain) {
  3278. var start = expr.start;
  3279. if (is("punc", ".")) {
  3280. next();
  3281. if(is("privatename") && !S.in_class)
  3282. croak("Private field must be used in an enclosing class");
  3283. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  3284. return annotate(subscripts(new AST_DotVariant({
  3285. start : start,
  3286. expression : expr,
  3287. optional : false,
  3288. property : as_name(),
  3289. end : prev()
  3290. }), allow_calls, is_chain));
  3291. }
  3292. if (is("punc", "[")) {
  3293. next();
  3294. var prop = expression(true);
  3295. expect("]");
  3296. return annotate(subscripts(new AST_Sub({
  3297. start : start,
  3298. expression : expr,
  3299. optional : false,
  3300. property : prop,
  3301. end : prev()
  3302. }), allow_calls, is_chain));
  3303. }
  3304. if (allow_calls && is("operator", "<")) typescript_skip_type_parameters_before_call();
  3305. if (allow_calls && is("punc", "(")) {
  3306. next();
  3307. var call = new AST_Call({
  3308. start : start,
  3309. expression : expr,
  3310. optional : false,
  3311. args : call_args(),
  3312. end : prev()
  3313. });
  3314. annotate(call);
  3315. return subscripts(call, true, is_chain);
  3316. }
  3317. // Optional chain
  3318. if (is("punc", "?.")) {
  3319. next();
  3320. let chain_contents;
  3321. if (allow_calls && is("operator", "<")) typescript_type_parameters();
  3322. if (allow_calls && is("punc", "(")) {
  3323. next();
  3324. const call = new AST_Call({
  3325. start,
  3326. optional: true,
  3327. expression: expr,
  3328. args: call_args(),
  3329. end: prev()
  3330. });
  3331. annotate(call);
  3332. chain_contents = subscripts(call, true, true);
  3333. } else if (is("name") || is("privatename")) {
  3334. if(is("privatename") && !S.in_class)
  3335. croak("Private field must be used in an enclosing class");
  3336. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  3337. chain_contents = annotate(subscripts(new AST_DotVariant({
  3338. start,
  3339. expression: expr,
  3340. optional: true,
  3341. property: as_name(),
  3342. end: prev()
  3343. }), allow_calls, true));
  3344. } else if (is("punc", "[")) {
  3345. next();
  3346. const property = expression(true);
  3347. expect("]");
  3348. chain_contents = annotate(subscripts(new AST_Sub({
  3349. start,
  3350. expression: expr,
  3351. optional: true,
  3352. property,
  3353. end: prev()
  3354. }), allow_calls, true));
  3355. }
  3356. if (!chain_contents) unexpected();
  3357. if (chain_contents instanceof AST_Chain) return chain_contents;
  3358. return new AST_Chain({
  3359. start,
  3360. expression: chain_contents,
  3361. end: prev()
  3362. });
  3363. }
  3364. if (is("template_head")) {
  3365. if (is_chain) {
  3366. // a?.b`c` is a syntax error
  3367. unexpected();
  3368. }
  3369. return subscripts(new AST_PrefixedTemplateString({
  3370. start: start,
  3371. prefix: expr,
  3372. template_string: template_string(),
  3373. end: prev()
  3374. }), allow_calls);
  3375. }
  3376. return expr;
  3377. };
  3378. function call_args() {
  3379. var args = [];
  3380. while (!is("punc", ")")) {
  3381. if (is("expand", "...")) {
  3382. next();
  3383. args.push(new AST_Expansion({
  3384. start: prev(),
  3385. expression: expression(false),
  3386. end: prev()
  3387. }));
  3388. } else {
  3389. args.push(expression(false));
  3390. }
  3391. if (!is("punc", ")")) {
  3392. expect(",");
  3393. }
  3394. }
  3395. next();
  3396. return args;
  3397. }
  3398. var maybe_unary = function(allow_calls, allow_arrows) {
  3399. var start = S.token;
  3400. if (start.type == "name" && start.value == "await" && can_await()) {
  3401. next();
  3402. return _await_expression();
  3403. }
  3404. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  3405. next();
  3406. handle_regexp();
  3407. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  3408. ex.start = start;
  3409. ex.end = prev();
  3410. return ex;
  3411. }
  3412. var val = expr_atom(allow_calls, allow_arrows);
  3413. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  3414. if (val instanceof AST_Arrow) unexpected();
  3415. val = make_unary(AST_UnaryPostfix, S.token, val);
  3416. val.start = start;
  3417. val.end = S.token;
  3418. next();
  3419. }
  3420. if (is("name", "as") || is("name", "satisfies")) {
  3421. typescript_as_satisfies();
  3422. }
  3423. return val;
  3424. };
  3425. function make_unary(ctor, token, expr) {
  3426. var op = token.value;
  3427. switch (op) {
  3428. case "++":
  3429. case "--":
  3430. if (!is_assignable(expr))
  3431. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  3432. break;
  3433. case "delete":
  3434. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3435. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3436. break;
  3437. }
  3438. return new ctor({ operator: op, expression: expr });
  3439. }
  3440. var expr_op = function(left, min_prec, no_in) {
  3441. var op = is("operator") ? S.token.value : null;
  3442. if (op == "in" && no_in) op = null;
  3443. if (op == "**" && left instanceof AST_UnaryPrefix
  3444. /* unary token in front not allowed - parenthesis required */
  3445. && !is_token(left.start, "punc", "(")
  3446. && left.operator !== "--" && left.operator !== "++")
  3447. unexpected(left.start);
  3448. var prec = op != null ? PRECEDENCE[op] : null;
  3449. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3450. next();
  3451. var right = expr_ops(no_in, prec, true);
  3452. return expr_op(new AST_Binary({
  3453. start : left.start,
  3454. left : left,
  3455. operator : op,
  3456. right : right,
  3457. end : right.end
  3458. }), min_prec, no_in);
  3459. }
  3460. return left;
  3461. };
  3462. function expr_ops(no_in, min_prec, allow_calls, allow_arrows) {
  3463. // maybe_unary won't return us a AST_SymbolPrivateProperty
  3464. if (!no_in && min_prec < PRECEDENCE["in"] && is("privatename")) {
  3465. if(!S.in_class) {
  3466. croak("Private field must be used in an enclosing class");
  3467. }
  3468. const start = S.token;
  3469. const key = new AST_SymbolPrivateProperty({
  3470. start,
  3471. name: start.value,
  3472. end: start
  3473. });
  3474. next();
  3475. expect_token("operator", "in");
  3476. const private_in = new AST_PrivateIn({
  3477. start,
  3478. key,
  3479. value: expr_ops(no_in, PRECEDENCE["in"], true),
  3480. end: prev()
  3481. });
  3482. return expr_op(private_in, 0, no_in);
  3483. } else {
  3484. return expr_op(maybe_unary(allow_calls, allow_arrows), min_prec, no_in);
  3485. }
  3486. }
  3487. var maybe_conditional = function(no_in) {
  3488. var start = S.token;
  3489. var expr = expr_ops(no_in, 0, true, true);
  3490. if (is("operator", "?")) {
  3491. next();
  3492. if (is("punc", ":") && typescript_maybe_annotation()) {
  3493. return expr;
  3494. }
  3495. var yes = expression(false);
  3496. expect(":");
  3497. return new AST_Conditional({
  3498. start : start,
  3499. condition : expr,
  3500. consequent : yes,
  3501. alternative : expression(false, no_in),
  3502. end : prev()
  3503. });
  3504. }
  3505. return expr;
  3506. };
  3507. function is_assignable(expr) {
  3508. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3509. }
  3510. function to_destructuring(node) {
  3511. if (node instanceof AST_Object) {
  3512. node = new AST_Destructuring({
  3513. start: node.start,
  3514. names: node.properties.map(to_destructuring),
  3515. is_array: false,
  3516. end: node.end
  3517. });
  3518. } else if (node instanceof AST_Array) {
  3519. var names = [];
  3520. for (var i = 0; i < node.elements.length; i++) {
  3521. // Only allow expansion as last element
  3522. if (node.elements[i] instanceof AST_Expansion) {
  3523. if (i + 1 !== node.elements.length) {
  3524. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3525. }
  3526. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3527. }
  3528. names.push(to_destructuring(node.elements[i]));
  3529. }
  3530. node = new AST_Destructuring({
  3531. start: node.start,
  3532. names: names,
  3533. is_array: true,
  3534. end: node.end
  3535. });
  3536. } else if (node instanceof AST_ObjectProperty) {
  3537. node.value = to_destructuring(node.value);
  3538. } else if (node instanceof AST_Assign) {
  3539. node = new AST_DefaultAssign({
  3540. start: node.start,
  3541. left: node.left,
  3542. operator: "=",
  3543. right: node.right,
  3544. end: node.end
  3545. });
  3546. }
  3547. return node;
  3548. }
  3549. // In ES6, AssignmentExpression can also be an ArrowFunction
  3550. var maybe_assign = function(no_in) {
  3551. handle_regexp();
  3552. var start = S.token;
  3553. if (start.type == "name" && start.value == "yield") {
  3554. if (is_in_generator()) {
  3555. next();
  3556. return _yield_expression();
  3557. } else if (S.input.has_directive("use strict")) {
  3558. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3559. }
  3560. }
  3561. var left = maybe_conditional(no_in);
  3562. var val = S.token.value;
  3563. if (is("operator") && ASSIGNMENT.has(val)) {
  3564. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3565. next();
  3566. return new AST_Assign({
  3567. start : start,
  3568. left : left,
  3569. operator : val,
  3570. right : maybe_assign(no_in),
  3571. logical : LOGICAL_ASSIGNMENT.has(val),
  3572. end : prev()
  3573. });
  3574. }
  3575. croak("Invalid assignment");
  3576. }
  3577. return left;
  3578. };
  3579. var to_expr_or_sequence = function(start, exprs) {
  3580. if (exprs.length === 1) {
  3581. return exprs[0];
  3582. } else if (exprs.length > 1) {
  3583. return new AST_Sequence({ start, expressions: exprs, end: peek() });
  3584. } else {
  3585. croak("Invalid parenthesized expression");
  3586. }
  3587. };
  3588. var expression = function(commas, no_in) {
  3589. var start = S.token;
  3590. var exprs = [];
  3591. while (true) {
  3592. exprs.push(maybe_assign(no_in));
  3593. if (!commas || !is("punc", ",")) break;
  3594. next();
  3595. commas = true;
  3596. }
  3597. return to_expr_or_sequence(start, exprs);
  3598. };
  3599. function in_loop(cont) {
  3600. ++S.in_loop;
  3601. var ret = cont();
  3602. --S.in_loop;
  3603. return ret;
  3604. }
  3605. // TS type stripping
  3606. // These functions are called when we know S.token begins some TS fluff
  3607. // Just call next() and friends, skipping TypeScript information
  3608. // Typescript entrypoints, from the rest of the parser
  3609. function typescript_type_parameters() {
  3610. if (!options.experimental_typescript) return;
  3611. expect_token("operator", "<");
  3612. do {
  3613. _ts_type_parameter();
  3614. } while (is("punc", ",") && next());
  3615. if (!_ts_gt_operator()) typescript_croak();
  3616. }
  3617. const typescript_ellide = Symbol("typescript_ellide");
  3618. function typescript_as_satisfies() {
  3619. if (!options.experimental_typescript) return;
  3620. while (is("name", "as") || is("name", "satisfies")) {
  3621. next();
  3622. _ts_type();
  3623. }
  3624. }
  3625. function typescript_type_statement() {
  3626. if (!options.experimental_typescript) return;
  3627. expect_token("name", "type");
  3628. expect_token("name");
  3629. if (is("operator", "<")) {
  3630. typescript_type_parameters();
  3631. }
  3632. expect_token("operator", "=");
  3633. _ts_type();
  3634. }
  3635. function typescript_interface_statement() {
  3636. if (!options.experimental_typescript) return;
  3637. expect_token("name", "interface");
  3638. expect_token("name");
  3639. if (is("operator", "<")) {
  3640. typescript_type_parameters();
  3641. }
  3642. if (is("keyword", "extends") || is("keyword", "implements")) {
  3643. typescript_extends_implements();
  3644. }
  3645. _ts_object_body();
  3646. }
  3647. function typescript_import_type_statement() {
  3648. if (!options.experimental_typescript) return;
  3649. if (
  3650. is_token(peek(), "name", "from")
  3651. || is_token(peek(), "punc", ",")
  3652. ) {
  3653. // not TS: `import type from ...`, `import type, { ...`
  3654. return false;
  3655. }
  3656. expect_token("name", "type");
  3657. if (!is("punc", "{")) {
  3658. next(); // star or name
  3659. if (is("name", "as")) {
  3660. next();
  3661. _ts_type_name(); // import type 'string' as NotString
  3662. }
  3663. if (is("punc", ",")) {
  3664. next();
  3665. _ts_import_export_name_mapping();
  3666. }
  3667. } else if (is("punc", "{")) {
  3668. _ts_import_export_name_mapping();
  3669. }
  3670. expect_token("name", "from");
  3671. expect_token("string");
  3672. return true;
  3673. }
  3674. function typescript_export_type_statement() {
  3675. if (!options.experimental_typescript) return;
  3676. if (is("name", "type") && is_token(peek(), "name")) {
  3677. typescript_type_statement();
  3678. return;
  3679. }
  3680. if (is("name", "interface")) {
  3681. typescript_interface_statement();
  3682. return;
  3683. }
  3684. expect_token("name", "type");
  3685. if (is("operator", "*")) {
  3686. next();
  3687. if (is("name", "as")) {
  3688. next();
  3689. next();
  3690. }
  3691. }
  3692. if (is("punc", "{")) {
  3693. _ts_import_export_name_mapping();
  3694. }
  3695. if (is("name", "from")) {
  3696. expect_token("name", "from");
  3697. expect_token("string");
  3698. }
  3699. }
  3700. function typescript_maybe_annotation() {
  3701. if (!options.experimental_typescript) return;
  3702. if (
  3703. is("operator", "?") && is_token(peek(), "punc", ":") && next()
  3704. || is("punc", ":")
  3705. ) {
  3706. typescript_type_annotation();
  3707. return true;
  3708. }
  3709. return false;
  3710. }
  3711. function typescript_import_named_type() {
  3712. if (!options.experimental_typescript) return false;
  3713. expect_token("name", "type");
  3714. next(); // name or string
  3715. if (is("name", "as")) {
  3716. next();
  3717. if (is("keyword", "default")) next();
  3718. else _ts_type();
  3719. }
  3720. return true;
  3721. }
  3722. function typescript_type_annotation() {
  3723. if (!options.experimental_typescript) return;
  3724. expect_token("punc", ":");
  3725. _ts_type();
  3726. return true;
  3727. }
  3728. function typescript_skip_this_type() {
  3729. if (!options.experimental_typescript) return;
  3730. if (is("name", "this")) {
  3731. next();
  3732. typescript_type_annotation();
  3733. if (is("punc", ",")) next();
  3734. return true;
  3735. }
  3736. }
  3737. function typescript_extends_implements() {
  3738. if (!options.experimental_typescript) return;
  3739. next(); // "extends" / "implements"
  3740. _ts_commatized_while("name", _ts_type);
  3741. }
  3742. function typescript_is_accessibility_modifier() {
  3743. if (!options.experimental_typescript) return;
  3744. // Known to be 'private', 'public' or 'protected'
  3745. return true;
  3746. }
  3747. function typescript_is_readonly() {
  3748. if (!options.experimental_typescript) return;
  3749. // Known to be 'readonly'
  3750. return true;
  3751. }
  3752. function typescript_is_function_no_body() {
  3753. if (!options.experimental_typescript) return;
  3754. // There's no body. Is this okay?
  3755. return true;
  3756. }
  3757. function typescript_skip_type_parameters_before_call() {
  3758. if (!options.experimental_typescript) return;
  3759. // Skip type parameters without parsing ahead. Differentiates between comparisons and type parameters: varname < T > (1)
  3760. // Go until "?." or "("
  3761. const matches = S.input.typescript_is_type_parameters_before_call();
  3762. if (matches) typescript_type_parameters();
  3763. }
  3764. function typescript_croak() {
  3765. croak("invalid or unsupported TypeScript syntax");
  3766. }
  3767. // Internal stuff
  3768. function _ts_gt_operator() {
  3769. // HACK: JS has >, >>, >>>. TS only knows >
  3770. if (S.token.type === "operator" && S.token.value.startsWith(">")) {
  3771. if (S.token.value === ">") {
  3772. return next();
  3773. } else {
  3774. S.token.value = S.token.value.slice(1);
  3775. return true;
  3776. }
  3777. }
  3778. }
  3779. function _ts_type_parameter() {
  3780. _ts_type();
  3781. _ts_constraint();
  3782. }
  3783. function _ts_constraint() {
  3784. if (is("keyword", "extends")) {
  3785. expect_token("keyword", "extends");
  3786. _ts_type();
  3787. if (is("operator", "=")) {
  3788. expect_token("operator", "=");
  3789. _ts_type();
  3790. }
  3791. }
  3792. }
  3793. function _ts_type() {
  3794. if (is("operator", "new")) {
  3795. // new(...args) => Type
  3796. next();
  3797. if (is("operator", "<")) typescript_type_parameters();
  3798. _ts_parenthesized_params();
  3799. expect_token("arrow", "=>");
  3800. _ts_type();
  3801. } else if (is("punc", "(")) {
  3802. // (...args) => Type
  3803. _ts_parenthesized_params();
  3804. expect_token("arrow", "=>");
  3805. _ts_type();
  3806. expect_token("punc", ")");
  3807. } else {
  3808. do {
  3809. if (is("operator", "|") || is("operator", "&")) next();
  3810. _ts_primary_type();
  3811. } while (is("operator", "|") || is("operator", "&"));
  3812. }
  3813. }
  3814. var _TS_PREDEFINED_TYPES = makePredicate(["any", "unknown", "const", "number", "boolean", "string", "symbol", "void"]);
  3815. function _ts_primary_type() {
  3816. if (is("name", "readonly")) next();
  3817. if (is("name", "import") && is_token(peek(), "punc", "(")) {
  3818. next();
  3819. expect("(");
  3820. _ts_type();
  3821. expect(")");
  3822. _ts_subscripts();
  3823. } else if (is("punc", "(")) {
  3824. next();
  3825. _ts_type();
  3826. expect(")");
  3827. } else if (is("name") && _TS_PREDEFINED_TYPES.has(S.token.value)) {
  3828. next();
  3829. } else if (is("template_head")) {
  3830. _ts_template_string();
  3831. } else if (is("string") || is("num") || is("big_int") || is("atom")) {
  3832. next();
  3833. } else if (is("name")) {
  3834. _ts_type_name();
  3835. if (is("operator", "<")) typescript_type_parameters();
  3836. } else if (is("punc", "{")) {
  3837. _ts_object_body();
  3838. } else if (is("punc", "[")) {
  3839. next();
  3840. _ts_tuple_types();
  3841. expect_token("punc", "]");
  3842. } else if (is("operator", "typeof")) {
  3843. next();
  3844. _ts_type_name();
  3845. } else {
  3846. typescript_croak();
  3847. }
  3848. // NestedArraySuffixes[][][][]
  3849. while (is("punc", "[") && is_token(peek(), "punc", "]")) {
  3850. next();
  3851. next();
  3852. }
  3853. }
  3854. // Also used as `typeof`'s argument
  3855. function _ts_type_name() {
  3856. expect_token("name");
  3857. _ts_subscripts();
  3858. }
  3859. function _ts_subscripts() {
  3860. if (is("punc", ".")) {
  3861. next();
  3862. expect_token("name");
  3863. return _ts_subscripts();
  3864. }
  3865. if (is("punc", "[") && !is_token(peek(), "punc", "]")) {
  3866. expect_token("punc", "[");
  3867. _ts_type();
  3868. expect_token("punc", "]");
  3869. return _ts_subscripts();
  3870. }
  3871. }
  3872. function _ts_object_body() {
  3873. const is_method_key = (token) =>
  3874. is_token(token, "name")
  3875. || is_token(token, "num")
  3876. || is_token(token, "string")
  3877. || is_token(token, "operator", "new");
  3878. expect_token("punc", "{");
  3879. _ts_commas_or_semicolons("punc", "}", () => {
  3880. // SKIP `readonly` WHEN IT'S A KEYWORD
  3881. if (
  3882. is("name", "readonly")
  3883. && (is_method_key(peek())
  3884. || is_token(peek(), "template_head")
  3885. || is_token(peek(), "punc", "["))
  3886. ) {
  3887. next();
  3888. }
  3889. // KEY
  3890. if (is_method_key(S.token)) {
  3891. next();
  3892. } else if (is("template_head")) {
  3893. _ts_template_string();
  3894. } else if (is("punc", "[")) {
  3895. next();
  3896. if (is_method_key(S.token)) next();
  3897. typescript_maybe_annotation();
  3898. expect("]");
  3899. } else ;
  3900. // OPTIONAL
  3901. if (is("operator", "?")) next();
  3902. // TYPE PARAMETERS
  3903. if (is("operator", "<")) {
  3904. typescript_type_parameters();
  3905. }
  3906. // VALUE (method or thing)
  3907. if (is("punc", "(")) {
  3908. _ts_parenthesized_params();
  3909. typescript_maybe_annotation();
  3910. } else if (is("punc", ":")) {
  3911. next();
  3912. _ts_type();
  3913. } else {
  3914. typescript_croak();
  3915. }
  3916. });
  3917. expect_token("punc", "}");
  3918. }
  3919. function _ts_tuple_types() {
  3920. _ts_commatized("punc", "]", () => {
  3921. if (is("expand", "...")) next(); // [...T]
  3922. _ts_type();
  3923. if (is("punc", ":") || is("operator", "?")) {
  3924. typescript_maybe_annotation(); // [name?: T]
  3925. }
  3926. if (is("operator", "?")) next(); // ["value"?]
  3927. });
  3928. }
  3929. function _ts_parenthesized_params() {
  3930. expect("(");
  3931. _ts_commatized("punc", ")", () => {
  3932. if (is("expand", "...")) next();
  3933. expect_token("name");
  3934. if (is("operator", "?")) next();
  3935. expect(":");
  3936. _ts_type();
  3937. });
  3938. expect(")");
  3939. }
  3940. function _ts_import_export_name_mapping() {
  3941. expect("{");
  3942. _ts_commatized("punc", "}", () => {
  3943. next();
  3944. if (is("name", "as")) {
  3945. next();
  3946. if (is("string") || is("keyword")) next();
  3947. else _ts_type_name();
  3948. }
  3949. });
  3950. expect("}");
  3951. }
  3952. function _ts_commatized(till_type, till, cb) {
  3953. while (!(is(till_type, till))) {
  3954. cb();
  3955. if (!is(till_type, till)) expect(",");
  3956. }
  3957. }
  3958. function _ts_commatized_while(while_type, cb) {
  3959. while (is(while_type)) {
  3960. cb();
  3961. if (!is("punc", ",")) break;
  3962. next();
  3963. }
  3964. }
  3965. function _ts_commas_or_semicolons(till_type, till, cb) {
  3966. while (!is(till_type, till)) {
  3967. cb();
  3968. if (!is(till_type, till)) {
  3969. if (is("punc", ",") || is("punc", ";")) next();
  3970. else if (S.token.nlb) ; // ASI
  3971. else typescript_croak();
  3972. }
  3973. }
  3974. }
  3975. function _ts_template_string() {
  3976. while (!S.token.template_end) {
  3977. next(); // eat "string" part
  3978. _ts_type(); // eat "code" part
  3979. if (!is("template_cont")) typescript_croak();
  3980. }
  3981. next(); // eat last part
  3982. }
  3983. if (options.expression) {
  3984. return expression(true);
  3985. }
  3986. return (function parse_toplevel() {
  3987. var start = S.token;
  3988. var body = [];
  3989. S.input.push_directives_stack();
  3990. if (options.module) S.input.add_directive("use strict");
  3991. while (!is("eof")) {
  3992. body.push(statement());
  3993. }
  3994. S.input.pop_directives_stack();
  3995. var end = prev();
  3996. var toplevel = options.toplevel;
  3997. if (toplevel) {
  3998. toplevel.body = toplevel.body.concat(body);
  3999. toplevel.end = end;
  4000. } else {
  4001. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  4002. }
  4003. TEMPLATE_RAWS = new Map();
  4004. return toplevel;
  4005. })();
  4006. }
  4007. /***********************************************************************
  4008. A JavaScript tokenizer / parser / beautifier / compressor.
  4009. https://github.com/mishoo/UglifyJS2
  4010. -------------------------------- (C) ---------------------------------
  4011. Author: Mihai Bazon
  4012. <mihai.bazon@gmail.com>
  4013. http://mihai.bazon.net/blog
  4014. Distributed under the BSD license:
  4015. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  4016. Redistribution and use in source and binary forms, with or without
  4017. modification, are permitted provided that the following conditions
  4018. are met:
  4019. * Redistributions of source code must retain the above
  4020. copyright notice, this list of conditions and the following
  4021. disclaimer.
  4022. * Redistributions in binary form must reproduce the above
  4023. copyright notice, this list of conditions and the following
  4024. disclaimer in the documentation and/or other materials
  4025. provided with the distribution.
  4026. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  4027. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4028. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  4029. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  4030. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  4031. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  4032. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  4033. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  4034. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  4035. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  4036. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4037. SUCH DAMAGE.
  4038. ***********************************************************************/
  4039. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  4040. if (!props) props = [];
  4041. else props = props.split(/\s+/);
  4042. var self_props = props;
  4043. if (base && base.PROPS)
  4044. props = props.concat(base.PROPS);
  4045. const proto = base && Object.create(base.prototype);
  4046. if (proto) {
  4047. ctor.prototype = proto;
  4048. ctor.BASE = base;
  4049. }
  4050. if (base) base.SUBCLASSES.push(ctor);
  4051. ctor.prototype.CTOR = ctor;
  4052. ctor.prototype.constructor = ctor;
  4053. ctor.PROPS = props || null;
  4054. ctor.SELF_PROPS = self_props;
  4055. ctor.SUBCLASSES = [];
  4056. if (type) {
  4057. ctor.prototype.TYPE = ctor.TYPE = type;
  4058. }
  4059. if (methods) for (let i in methods) if (HOP(methods, i)) {
  4060. if (i[0] === "$") {
  4061. ctor[i.substr(1)] = methods[i];
  4062. } else {
  4063. ctor.prototype[i] = methods[i];
  4064. }
  4065. }
  4066. ctor.DEFMETHOD = function(name, method) {
  4067. this.prototype[name] = method;
  4068. };
  4069. return ctor;
  4070. }
  4071. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  4072. const set_tok_flag = (tok, flag, truth) => {
  4073. if (truth) {
  4074. tok.flags |= flag;
  4075. } else {
  4076. tok.flags &= ~flag;
  4077. }
  4078. };
  4079. const TOK_FLAG_NLB = 0b0001;
  4080. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  4081. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  4082. const TOK_FLAG_TEMPLATE_END = 0b1000;
  4083. class AST_Token {
  4084. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  4085. this.flags = (nlb ? 1 : 0);
  4086. this.type = type;
  4087. this.value = value;
  4088. this.line = line;
  4089. this.col = col;
  4090. this.pos = pos;
  4091. this.comments_before = comments_before;
  4092. this.comments_after = comments_after;
  4093. this.file = file;
  4094. Object.seal(this);
  4095. }
  4096. // Return a string summary of the token for node.js console.log
  4097. [Symbol.for("nodejs.util.inspect.custom")](_depth, options) {
  4098. const special = str => options.stylize(str, "special");
  4099. const quote = typeof this.value === "string" && this.value.includes("`") ? "'" : "`";
  4100. const value = `${quote}${this.value}${quote}`;
  4101. return `${special("[AST_Token")} ${value} at ${this.line}:${this.col}${special("]")}`;
  4102. }
  4103. get nlb() {
  4104. return has_tok_flag(this, TOK_FLAG_NLB);
  4105. }
  4106. set nlb(new_nlb) {
  4107. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  4108. }
  4109. get quote() {
  4110. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  4111. ? ""
  4112. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  4113. }
  4114. set quote(quote_type) {
  4115. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  4116. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  4117. }
  4118. get template_end() {
  4119. return has_tok_flag(this, TOK_FLAG_TEMPLATE_END);
  4120. }
  4121. set template_end(new_template_end) {
  4122. set_tok_flag(this, TOK_FLAG_TEMPLATE_END, new_template_end);
  4123. }
  4124. }
  4125. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  4126. if (props) {
  4127. this.start = props.start;
  4128. this.end = props.end;
  4129. }
  4130. this.flags = 0;
  4131. }, {
  4132. _clone: function(deep) {
  4133. if (deep) {
  4134. var self = this.clone();
  4135. return self.transform(new TreeTransformer(function(node) {
  4136. if (node !== self) {
  4137. return node.clone(true);
  4138. }
  4139. }));
  4140. }
  4141. return new this.CTOR(this);
  4142. },
  4143. clone: function(deep) {
  4144. return this._clone(deep);
  4145. },
  4146. $documentation: "Base class of all AST nodes",
  4147. $propdoc: {
  4148. start: "[AST_Token] The first token of this node",
  4149. end: "[AST_Token] The last token of this node"
  4150. },
  4151. _walk: function(visitor) {
  4152. return visitor._visit(this);
  4153. },
  4154. walk: function(visitor) {
  4155. return this._walk(visitor); // not sure the indirection will be any help
  4156. },
  4157. _children_backwards: () => {}
  4158. }, null);
  4159. /* -----[ statements ]----- */
  4160. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  4161. if (props) {
  4162. this.start = props.start;
  4163. this.end = props.end;
  4164. }
  4165. this.flags = 0;
  4166. }, {
  4167. $documentation: "Base class of all statements",
  4168. });
  4169. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  4170. if (props) {
  4171. this.start = props.start;
  4172. this.end = props.end;
  4173. }
  4174. this.flags = 0;
  4175. }, {
  4176. $documentation: "Represents a debugger statement",
  4177. }, AST_Statement);
  4178. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  4179. if (props) {
  4180. this.value = props.value;
  4181. this.quote = props.quote;
  4182. this.start = props.start;
  4183. this.end = props.end;
  4184. }
  4185. this.flags = 0;
  4186. }, {
  4187. $documentation: "Represents a directive, like \"use strict\";",
  4188. $propdoc: {
  4189. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  4190. quote: "[string] the original quote character"
  4191. },
  4192. }, AST_Statement);
  4193. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  4194. if (props) {
  4195. this.body = props.body;
  4196. this.start = props.start;
  4197. this.end = props.end;
  4198. }
  4199. this.flags = 0;
  4200. }, {
  4201. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  4202. $propdoc: {
  4203. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  4204. },
  4205. _walk: function(visitor) {
  4206. return visitor._visit(this, function() {
  4207. this.body._walk(visitor);
  4208. });
  4209. },
  4210. _children_backwards(push) {
  4211. push(this.body);
  4212. }
  4213. }, AST_Statement);
  4214. function walk_body(node, visitor) {
  4215. const body = node.body;
  4216. for (var i = 0, len = body.length; i < len; i++) {
  4217. body[i]._walk(visitor);
  4218. }
  4219. }
  4220. function clone_block_scope(deep) {
  4221. var clone = this._clone(deep);
  4222. if (this.block_scope) {
  4223. clone.block_scope = this.block_scope.clone();
  4224. }
  4225. return clone;
  4226. }
  4227. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  4228. if (props) {
  4229. this.body = props.body;
  4230. this.block_scope = props.block_scope;
  4231. this.start = props.start;
  4232. this.end = props.end;
  4233. }
  4234. this.flags = 0;
  4235. }, {
  4236. $documentation: "A body of statements (usually braced)",
  4237. $propdoc: {
  4238. body: "[AST_Statement*] an array of statements",
  4239. block_scope: "[AST_Scope] the block scope"
  4240. },
  4241. _walk: function(visitor) {
  4242. return visitor._visit(this, function() {
  4243. walk_body(this, visitor);
  4244. });
  4245. },
  4246. _children_backwards(push) {
  4247. let i = this.body.length;
  4248. while (i--) push(this.body[i]);
  4249. },
  4250. clone: clone_block_scope
  4251. }, AST_Statement);
  4252. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  4253. if (props) {
  4254. this.body = props.body;
  4255. this.block_scope = props.block_scope;
  4256. this.start = props.start;
  4257. this.end = props.end;
  4258. }
  4259. this.flags = 0;
  4260. }, {
  4261. $documentation: "A block statement",
  4262. }, AST_Block);
  4263. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  4264. if (props) {
  4265. this.start = props.start;
  4266. this.end = props.end;
  4267. }
  4268. this.flags = 0;
  4269. }, {
  4270. $documentation: "The empty statement (empty block or simply a semicolon)"
  4271. }, AST_Statement);
  4272. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  4273. if (props) {
  4274. this.body = props.body;
  4275. this.start = props.start;
  4276. this.end = props.end;
  4277. }
  4278. this.flags = 0;
  4279. }, {
  4280. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  4281. $propdoc: {
  4282. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  4283. }
  4284. }, AST_Statement);
  4285. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  4286. if (props) {
  4287. this.label = props.label;
  4288. this.body = props.body;
  4289. this.start = props.start;
  4290. this.end = props.end;
  4291. }
  4292. this.flags = 0;
  4293. }, {
  4294. $documentation: "Statement with a label",
  4295. $propdoc: {
  4296. label: "[AST_Label] a label definition"
  4297. },
  4298. _walk: function(visitor) {
  4299. return visitor._visit(this, function() {
  4300. this.label._walk(visitor);
  4301. this.body._walk(visitor);
  4302. });
  4303. },
  4304. _children_backwards(push) {
  4305. push(this.body);
  4306. push(this.label);
  4307. },
  4308. clone: function(deep) {
  4309. var node = this._clone(deep);
  4310. if (deep) {
  4311. var label = node.label;
  4312. var def = this.label;
  4313. node.walk(new TreeWalker(function(node) {
  4314. if (node instanceof AST_LoopControl
  4315. && node.label && node.label.thedef === def) {
  4316. node.label.thedef = label;
  4317. label.references.push(node);
  4318. }
  4319. }));
  4320. }
  4321. return node;
  4322. }
  4323. }, AST_StatementWithBody);
  4324. var AST_IterationStatement = DEFNODE(
  4325. "IterationStatement",
  4326. "block_scope",
  4327. function AST_IterationStatement(props) {
  4328. if (props) {
  4329. this.block_scope = props.block_scope;
  4330. this.body = props.body;
  4331. this.start = props.start;
  4332. this.end = props.end;
  4333. }
  4334. this.flags = 0;
  4335. },
  4336. {
  4337. $documentation: "Internal class. All loops inherit from it.",
  4338. $propdoc: {
  4339. block_scope: "[AST_Scope] the block scope for this iteration statement."
  4340. },
  4341. clone: clone_block_scope
  4342. },
  4343. AST_StatementWithBody
  4344. );
  4345. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  4346. if (props) {
  4347. this.condition = props.condition;
  4348. this.block_scope = props.block_scope;
  4349. this.body = props.body;
  4350. this.start = props.start;
  4351. this.end = props.end;
  4352. }
  4353. this.flags = 0;
  4354. }, {
  4355. $documentation: "Base class for do/while statements",
  4356. $propdoc: {
  4357. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  4358. }
  4359. }, AST_IterationStatement);
  4360. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  4361. if (props) {
  4362. this.condition = props.condition;
  4363. this.block_scope = props.block_scope;
  4364. this.body = props.body;
  4365. this.start = props.start;
  4366. this.end = props.end;
  4367. }
  4368. this.flags = 0;
  4369. }, {
  4370. $documentation: "A `do` statement",
  4371. _walk: function(visitor) {
  4372. return visitor._visit(this, function() {
  4373. this.body._walk(visitor);
  4374. this.condition._walk(visitor);
  4375. });
  4376. },
  4377. _children_backwards(push) {
  4378. push(this.condition);
  4379. push(this.body);
  4380. }
  4381. }, AST_DWLoop);
  4382. var AST_While = DEFNODE("While", null, function AST_While(props) {
  4383. if (props) {
  4384. this.condition = props.condition;
  4385. this.block_scope = props.block_scope;
  4386. this.body = props.body;
  4387. this.start = props.start;
  4388. this.end = props.end;
  4389. }
  4390. this.flags = 0;
  4391. }, {
  4392. $documentation: "A `while` statement",
  4393. _walk: function(visitor) {
  4394. return visitor._visit(this, function() {
  4395. this.condition._walk(visitor);
  4396. this.body._walk(visitor);
  4397. });
  4398. },
  4399. _children_backwards(push) {
  4400. push(this.body);
  4401. push(this.condition);
  4402. },
  4403. }, AST_DWLoop);
  4404. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  4405. if (props) {
  4406. this.init = props.init;
  4407. this.condition = props.condition;
  4408. this.step = props.step;
  4409. this.block_scope = props.block_scope;
  4410. this.body = props.body;
  4411. this.start = props.start;
  4412. this.end = props.end;
  4413. }
  4414. this.flags = 0;
  4415. }, {
  4416. $documentation: "A `for` statement",
  4417. $propdoc: {
  4418. init: "[AST_Node?] the `for` initialization code, or null if empty",
  4419. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  4420. step: "[AST_Node?] the `for` update clause, or null if empty"
  4421. },
  4422. _walk: function(visitor) {
  4423. return visitor._visit(this, function() {
  4424. if (this.init) this.init._walk(visitor);
  4425. if (this.condition) this.condition._walk(visitor);
  4426. if (this.step) this.step._walk(visitor);
  4427. this.body._walk(visitor);
  4428. });
  4429. },
  4430. _children_backwards(push) {
  4431. push(this.body);
  4432. if (this.step) push(this.step);
  4433. if (this.condition) push(this.condition);
  4434. if (this.init) push(this.init);
  4435. },
  4436. }, AST_IterationStatement);
  4437. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  4438. if (props) {
  4439. this.init = props.init;
  4440. this.object = props.object;
  4441. this.block_scope = props.block_scope;
  4442. this.body = props.body;
  4443. this.start = props.start;
  4444. this.end = props.end;
  4445. }
  4446. this.flags = 0;
  4447. }, {
  4448. $documentation: "A `for ... in` statement",
  4449. $propdoc: {
  4450. init: "[AST_Node] the `for/in` initialization code",
  4451. object: "[AST_Node] the object that we're looping through"
  4452. },
  4453. _walk: function(visitor) {
  4454. return visitor._visit(this, function() {
  4455. this.init._walk(visitor);
  4456. this.object._walk(visitor);
  4457. this.body._walk(visitor);
  4458. });
  4459. },
  4460. _children_backwards(push) {
  4461. push(this.body);
  4462. if (this.object) push(this.object);
  4463. if (this.init) push(this.init);
  4464. },
  4465. }, AST_IterationStatement);
  4466. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  4467. if (props) {
  4468. this.await = props.await;
  4469. this.init = props.init;
  4470. this.object = props.object;
  4471. this.block_scope = props.block_scope;
  4472. this.body = props.body;
  4473. this.start = props.start;
  4474. this.end = props.end;
  4475. }
  4476. this.flags = 0;
  4477. }, {
  4478. $documentation: "A `for ... of` statement",
  4479. }, AST_ForIn);
  4480. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  4481. if (props) {
  4482. this.expression = props.expression;
  4483. this.body = props.body;
  4484. this.start = props.start;
  4485. this.end = props.end;
  4486. }
  4487. this.flags = 0;
  4488. }, {
  4489. $documentation: "A `with` statement",
  4490. $propdoc: {
  4491. expression: "[AST_Node] the `with` expression"
  4492. },
  4493. _walk: function(visitor) {
  4494. return visitor._visit(this, function() {
  4495. this.expression._walk(visitor);
  4496. this.body._walk(visitor);
  4497. });
  4498. },
  4499. _children_backwards(push) {
  4500. push(this.body);
  4501. push(this.expression);
  4502. },
  4503. }, AST_StatementWithBody);
  4504. /* -----[ scope and functions ]----- */
  4505. var AST_Scope = DEFNODE(
  4506. "Scope",
  4507. "variables uses_with uses_eval screwy_argnames_scope parent_scope enclosed cname",
  4508. function AST_Scope(props) {
  4509. if (props) {
  4510. this.variables = props.variables;
  4511. this.uses_with = props.uses_with;
  4512. this.uses_eval = props.uses_eval;
  4513. this.screwy_argnames_scope = props.screwy_argnames_scope;
  4514. this.parent_scope = props.parent_scope;
  4515. this.enclosed = props.enclosed;
  4516. this.cname = props.cname;
  4517. this.body = props.body;
  4518. this.block_scope = props.block_scope;
  4519. this.start = props.start;
  4520. this.end = props.end;
  4521. }
  4522. this.flags = 0;
  4523. },
  4524. {
  4525. $documentation: "Base class for all statements introducing a lexical scope",
  4526. $propdoc: {
  4527. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  4528. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  4529. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  4530. parent_scope: "[AST_Scope?/S] link to the parent scope",
  4531. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  4532. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  4533. },
  4534. get_defun_scope: function() {
  4535. var self = this;
  4536. while (self.is_block_scope()) {
  4537. self = self.parent_scope;
  4538. }
  4539. return self;
  4540. },
  4541. clone: function(deep, toplevel) {
  4542. var node = this._clone(deep);
  4543. if (deep && this.variables && toplevel && !this._block_scope) {
  4544. node.figure_out_scope({}, {
  4545. toplevel: toplevel,
  4546. parent_scope: this.parent_scope
  4547. });
  4548. } else {
  4549. if (this.variables) node.variables = new Map(this.variables);
  4550. if (this.enclosed) node.enclosed = this.enclosed.slice();
  4551. if (this._block_scope) node._block_scope = this._block_scope;
  4552. }
  4553. return node;
  4554. },
  4555. pinned: function() {
  4556. return this.uses_eval || this.uses_with;
  4557. }
  4558. },
  4559. AST_Block
  4560. );
  4561. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  4562. if (props) {
  4563. this.globals = props.globals;
  4564. this.variables = props.variables;
  4565. this.uses_with = props.uses_with;
  4566. this.uses_eval = props.uses_eval;
  4567. this.parent_scope = props.parent_scope;
  4568. this.enclosed = props.enclosed;
  4569. this.cname = props.cname;
  4570. this.body = props.body;
  4571. this.block_scope = props.block_scope;
  4572. this.start = props.start;
  4573. this.end = props.end;
  4574. }
  4575. this.flags = 0;
  4576. }, {
  4577. $documentation: "The toplevel scope",
  4578. $propdoc: {
  4579. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  4580. },
  4581. wrap_commonjs: function(name) {
  4582. var body = this.body;
  4583. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  4584. wrapped_tl = parse(wrapped_tl);
  4585. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  4586. if (node instanceof AST_Directive && node.value == "$ORIG") {
  4587. return MAP.splice(body);
  4588. }
  4589. }));
  4590. return wrapped_tl;
  4591. },
  4592. wrap_enclose: function(args_values) {
  4593. if (typeof args_values != "string") args_values = "";
  4594. var index = args_values.indexOf(":");
  4595. if (index < 0) index = args_values.length;
  4596. var body = this.body;
  4597. return parse([
  4598. "(function(",
  4599. args_values.slice(0, index),
  4600. '){"$ORIG"})(',
  4601. args_values.slice(index + 1),
  4602. ")"
  4603. ].join("")).transform(new TreeTransformer(function(node) {
  4604. if (node instanceof AST_Directive && node.value == "$ORIG") {
  4605. return MAP.splice(body);
  4606. }
  4607. }));
  4608. }
  4609. }, AST_Scope);
  4610. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  4611. if (props) {
  4612. this.expression = props.expression;
  4613. this.start = props.start;
  4614. this.end = props.end;
  4615. }
  4616. this.flags = 0;
  4617. }, {
  4618. $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",
  4619. $propdoc: {
  4620. expression: "[AST_Node] the thing to be expanded"
  4621. },
  4622. _walk: function(visitor) {
  4623. return visitor._visit(this, function() {
  4624. this.expression.walk(visitor);
  4625. });
  4626. },
  4627. _children_backwards(push) {
  4628. push(this.expression);
  4629. },
  4630. });
  4631. var AST_Lambda = DEFNODE(
  4632. "Lambda",
  4633. "name argnames uses_arguments is_generator async",
  4634. function AST_Lambda(props) {
  4635. if (props) {
  4636. this.name = props.name;
  4637. this.argnames = props.argnames;
  4638. this.uses_arguments = props.uses_arguments;
  4639. this.is_generator = props.is_generator;
  4640. this.async = props.async;
  4641. this.variables = props.variables;
  4642. this.uses_with = props.uses_with;
  4643. this.uses_eval = props.uses_eval;
  4644. this.parent_scope = props.parent_scope;
  4645. this.enclosed = props.enclosed;
  4646. this.cname = props.cname;
  4647. this.body = props.body;
  4648. this.block_scope = props.block_scope;
  4649. this.start = props.start;
  4650. this.end = props.end;
  4651. }
  4652. this.flags = 0;
  4653. },
  4654. {
  4655. $documentation: "Base class for functions",
  4656. $propdoc: {
  4657. name: "[AST_SymbolDeclaration?] the name of this function",
  4658. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  4659. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  4660. screwy_argnames_scope: "[boolean/S] argnames contain a reference to a name that's shadowed in the function",
  4661. is_generator: "[boolean] is this a generator method",
  4662. async: "[boolean] is this method async",
  4663. },
  4664. args_as_names: function () {
  4665. // fast-path
  4666. if (this.argnames.every(a => a instanceof AST_SymbolDeclaration)) {
  4667. return this.argnames;
  4668. }
  4669. var out = [];
  4670. for (var i = 0; i < this.argnames.length; i++) {
  4671. if (this.argnames[i] instanceof AST_Destructuring) {
  4672. out.push(...this.argnames[i].all_symbols());
  4673. } else if (this.argnames[i] instanceof AST_Expansion) {
  4674. out.push(...this.argnames[i].expression.all_symbols());
  4675. } else if (this.argnames[i] instanceof AST_DefaultAssign) {
  4676. out.push(...this.argnames[i].left.all_symbols());
  4677. } else {
  4678. out.push(this.argnames[i]);
  4679. }
  4680. }
  4681. return out;
  4682. },
  4683. _walk: function(visitor) {
  4684. return visitor._visit(this, function() {
  4685. if (this.name) this.name._walk(visitor);
  4686. var argnames = this.argnames;
  4687. for (var i = 0, len = argnames.length; i < len; i++) {
  4688. argnames[i]._walk(visitor);
  4689. }
  4690. walk_body(this, visitor);
  4691. });
  4692. },
  4693. _children_backwards(push) {
  4694. let i = this.body.length;
  4695. while (i--) push(this.body[i]);
  4696. i = this.argnames.length;
  4697. while (i--) push(this.argnames[i]);
  4698. if (this.name) push(this.name);
  4699. },
  4700. is_braceless() {
  4701. return this.body[0] instanceof AST_Return && this.body[0].value;
  4702. },
  4703. // Default args and expansion don't count, so .argnames.length doesn't cut it
  4704. length_property() {
  4705. let length = 0;
  4706. for (const arg of this.argnames) {
  4707. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  4708. length++;
  4709. }
  4710. }
  4711. return length;
  4712. }
  4713. },
  4714. AST_Scope
  4715. );
  4716. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  4717. if (props) {
  4718. this.name = props.name;
  4719. this.argnames = props.argnames;
  4720. this.uses_arguments = props.uses_arguments;
  4721. this.is_generator = props.is_generator;
  4722. this.async = props.async;
  4723. this.variables = props.variables;
  4724. this.uses_with = props.uses_with;
  4725. this.uses_eval = props.uses_eval;
  4726. this.parent_scope = props.parent_scope;
  4727. this.enclosed = props.enclosed;
  4728. this.cname = props.cname;
  4729. this.body = props.body;
  4730. this.block_scope = props.block_scope;
  4731. this.start = props.start;
  4732. this.end = props.end;
  4733. }
  4734. this.flags = 0;
  4735. }, {
  4736. $documentation: "A setter/getter function. The `name` property is always null."
  4737. }, AST_Lambda);
  4738. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  4739. if (props) {
  4740. this.name = props.name;
  4741. this.argnames = props.argnames;
  4742. this.uses_arguments = props.uses_arguments;
  4743. this.is_generator = props.is_generator;
  4744. this.async = props.async;
  4745. this.variables = props.variables;
  4746. this.uses_with = props.uses_with;
  4747. this.uses_eval = props.uses_eval;
  4748. this.parent_scope = props.parent_scope;
  4749. this.enclosed = props.enclosed;
  4750. this.cname = props.cname;
  4751. this.body = props.body;
  4752. this.block_scope = props.block_scope;
  4753. this.start = props.start;
  4754. this.end = props.end;
  4755. }
  4756. this.flags = 0;
  4757. }, {
  4758. $documentation: "A function expression"
  4759. }, AST_Lambda);
  4760. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  4761. if (props) {
  4762. this.name = props.name;
  4763. this.argnames = props.argnames;
  4764. this.uses_arguments = props.uses_arguments;
  4765. this.is_generator = props.is_generator;
  4766. this.async = props.async;
  4767. this.variables = props.variables;
  4768. this.uses_with = props.uses_with;
  4769. this.uses_eval = props.uses_eval;
  4770. this.parent_scope = props.parent_scope;
  4771. this.enclosed = props.enclosed;
  4772. this.cname = props.cname;
  4773. this.body = props.body;
  4774. this.block_scope = props.block_scope;
  4775. this.start = props.start;
  4776. this.end = props.end;
  4777. }
  4778. this.flags = 0;
  4779. }, {
  4780. $documentation: "An ES6 Arrow function ((a) => b)"
  4781. }, AST_Lambda);
  4782. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  4783. if (props) {
  4784. this.name = props.name;
  4785. this.argnames = props.argnames;
  4786. this.uses_arguments = props.uses_arguments;
  4787. this.is_generator = props.is_generator;
  4788. this.async = props.async;
  4789. this.variables = props.variables;
  4790. this.uses_with = props.uses_with;
  4791. this.uses_eval = props.uses_eval;
  4792. this.parent_scope = props.parent_scope;
  4793. this.enclosed = props.enclosed;
  4794. this.cname = props.cname;
  4795. this.body = props.body;
  4796. this.block_scope = props.block_scope;
  4797. this.start = props.start;
  4798. this.end = props.end;
  4799. }
  4800. this.flags = 0;
  4801. }, {
  4802. $documentation: "A function definition"
  4803. }, AST_Lambda);
  4804. /* -----[ DESTRUCTURING ]----- */
  4805. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  4806. if (props) {
  4807. this.names = props.names;
  4808. this.is_array = props.is_array;
  4809. this.start = props.start;
  4810. this.end = props.end;
  4811. }
  4812. this.flags = 0;
  4813. }, {
  4814. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  4815. $propdoc: {
  4816. "names": "[AST_Node*] Array of properties or elements",
  4817. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  4818. },
  4819. _walk: function(visitor) {
  4820. return visitor._visit(this, function() {
  4821. this.names.forEach(function(name) {
  4822. name._walk(visitor);
  4823. });
  4824. });
  4825. },
  4826. _children_backwards(push) {
  4827. let i = this.names.length;
  4828. while (i--) push(this.names[i]);
  4829. },
  4830. all_symbols: function() {
  4831. var out = [];
  4832. walk(this, node => {
  4833. if (node instanceof AST_SymbolDeclaration) {
  4834. out.push(node);
  4835. }
  4836. if (node instanceof AST_Lambda) {
  4837. return true;
  4838. }
  4839. });
  4840. return out;
  4841. }
  4842. });
  4843. var AST_PrefixedTemplateString = DEFNODE(
  4844. "PrefixedTemplateString",
  4845. "template_string prefix",
  4846. function AST_PrefixedTemplateString(props) {
  4847. if (props) {
  4848. this.template_string = props.template_string;
  4849. this.prefix = props.prefix;
  4850. this.start = props.start;
  4851. this.end = props.end;
  4852. }
  4853. this.flags = 0;
  4854. },
  4855. {
  4856. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  4857. $propdoc: {
  4858. template_string: "[AST_TemplateString] The template string",
  4859. prefix: "[AST_Node] The prefix, which will get called."
  4860. },
  4861. _walk: function(visitor) {
  4862. return visitor._visit(this, function () {
  4863. this.prefix._walk(visitor);
  4864. this.template_string._walk(visitor);
  4865. });
  4866. },
  4867. _children_backwards(push) {
  4868. push(this.template_string);
  4869. push(this.prefix);
  4870. },
  4871. }
  4872. );
  4873. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  4874. if (props) {
  4875. this.segments = props.segments;
  4876. this.start = props.start;
  4877. this.end = props.end;
  4878. }
  4879. this.flags = 0;
  4880. }, {
  4881. $documentation: "A template string literal",
  4882. $propdoc: {
  4883. 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."
  4884. },
  4885. _walk: function(visitor) {
  4886. return visitor._visit(this, function() {
  4887. this.segments.forEach(function(seg) {
  4888. seg._walk(visitor);
  4889. });
  4890. });
  4891. },
  4892. _children_backwards(push) {
  4893. let i = this.segments.length;
  4894. while (i--) push(this.segments[i]);
  4895. }
  4896. });
  4897. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  4898. if (props) {
  4899. this.value = props.value;
  4900. this.raw = props.raw;
  4901. this.start = props.start;
  4902. this.end = props.end;
  4903. }
  4904. this.flags = 0;
  4905. }, {
  4906. $documentation: "A segment of a template string literal",
  4907. $propdoc: {
  4908. value: "Content of the segment",
  4909. raw: "Raw source of the segment",
  4910. }
  4911. });
  4912. /* -----[ JUMPS ]----- */
  4913. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  4914. if (props) {
  4915. this.start = props.start;
  4916. this.end = props.end;
  4917. }
  4918. this.flags = 0;
  4919. }, {
  4920. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  4921. }, AST_Statement);
  4922. /** Base class for “exits” (`return` and `throw`) */
  4923. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  4924. if (props) {
  4925. this.value = props.value;
  4926. this.start = props.start;
  4927. this.end = props.end;
  4928. }
  4929. this.flags = 0;
  4930. }, {
  4931. $documentation: "Base class for “exits” (`return` and `throw`)",
  4932. $propdoc: {
  4933. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  4934. },
  4935. _walk: function(visitor) {
  4936. return visitor._visit(this, this.value && function() {
  4937. this.value._walk(visitor);
  4938. });
  4939. },
  4940. _children_backwards(push) {
  4941. if (this.value) push(this.value);
  4942. },
  4943. }, AST_Jump);
  4944. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  4945. if (props) {
  4946. this.value = props.value;
  4947. this.start = props.start;
  4948. this.end = props.end;
  4949. }
  4950. this.flags = 0;
  4951. }, {
  4952. $documentation: "A `return` statement"
  4953. }, AST_Exit);
  4954. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  4955. if (props) {
  4956. this.value = props.value;
  4957. this.start = props.start;
  4958. this.end = props.end;
  4959. }
  4960. this.flags = 0;
  4961. }, {
  4962. $documentation: "A `throw` statement"
  4963. }, AST_Exit);
  4964. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  4965. if (props) {
  4966. this.label = props.label;
  4967. this.start = props.start;
  4968. this.end = props.end;
  4969. }
  4970. this.flags = 0;
  4971. }, {
  4972. $documentation: "Base class for loop control statements (`break` and `continue`)",
  4973. $propdoc: {
  4974. label: "[AST_LabelRef?] the label, or null if none",
  4975. },
  4976. _walk: function(visitor) {
  4977. return visitor._visit(this, this.label && function() {
  4978. this.label._walk(visitor);
  4979. });
  4980. },
  4981. _children_backwards(push) {
  4982. if (this.label) push(this.label);
  4983. },
  4984. }, AST_Jump);
  4985. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  4986. if (props) {
  4987. this.label = props.label;
  4988. this.start = props.start;
  4989. this.end = props.end;
  4990. }
  4991. this.flags = 0;
  4992. }, {
  4993. $documentation: "A `break` statement"
  4994. }, AST_LoopControl);
  4995. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  4996. if (props) {
  4997. this.label = props.label;
  4998. this.start = props.start;
  4999. this.end = props.end;
  5000. }
  5001. this.flags = 0;
  5002. }, {
  5003. $documentation: "A `continue` statement"
  5004. }, AST_LoopControl);
  5005. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  5006. if (props) {
  5007. this.expression = props.expression;
  5008. this.start = props.start;
  5009. this.end = props.end;
  5010. }
  5011. this.flags = 0;
  5012. }, {
  5013. $documentation: "An `await` statement",
  5014. $propdoc: {
  5015. expression: "[AST_Node] the mandatory expression being awaited",
  5016. },
  5017. _walk: function(visitor) {
  5018. return visitor._visit(this, function() {
  5019. this.expression._walk(visitor);
  5020. });
  5021. },
  5022. _children_backwards(push) {
  5023. push(this.expression);
  5024. },
  5025. });
  5026. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  5027. if (props) {
  5028. this.expression = props.expression;
  5029. this.is_star = props.is_star;
  5030. this.start = props.start;
  5031. this.end = props.end;
  5032. }
  5033. this.flags = 0;
  5034. }, {
  5035. $documentation: "A `yield` statement",
  5036. $propdoc: {
  5037. 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",
  5038. is_star: "[Boolean] Whether this is a yield or yield* statement"
  5039. },
  5040. _walk: function(visitor) {
  5041. return visitor._visit(this, this.expression && function() {
  5042. this.expression._walk(visitor);
  5043. });
  5044. },
  5045. _children_backwards(push) {
  5046. if (this.expression) push(this.expression);
  5047. }
  5048. });
  5049. /* -----[ IF ]----- */
  5050. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  5051. if (props) {
  5052. this.condition = props.condition;
  5053. this.alternative = props.alternative;
  5054. this.body = props.body;
  5055. this.start = props.start;
  5056. this.end = props.end;
  5057. }
  5058. this.flags = 0;
  5059. }, {
  5060. $documentation: "A `if` statement",
  5061. $propdoc: {
  5062. condition: "[AST_Node] the `if` condition",
  5063. alternative: "[AST_Statement?] the `else` part, or null if not present"
  5064. },
  5065. _walk: function(visitor) {
  5066. return visitor._visit(this, function() {
  5067. this.condition._walk(visitor);
  5068. this.body._walk(visitor);
  5069. if (this.alternative) this.alternative._walk(visitor);
  5070. });
  5071. },
  5072. _children_backwards(push) {
  5073. if (this.alternative) {
  5074. push(this.alternative);
  5075. }
  5076. push(this.body);
  5077. push(this.condition);
  5078. }
  5079. }, AST_StatementWithBody);
  5080. /* -----[ SWITCH ]----- */
  5081. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  5082. if (props) {
  5083. this.expression = props.expression;
  5084. this.body = props.body;
  5085. this.block_scope = props.block_scope;
  5086. this.start = props.start;
  5087. this.end = props.end;
  5088. }
  5089. this.flags = 0;
  5090. }, {
  5091. $documentation: "A `switch` statement",
  5092. $propdoc: {
  5093. expression: "[AST_Node] the `switch` “discriminant”"
  5094. },
  5095. _walk: function(visitor) {
  5096. return visitor._visit(this, function() {
  5097. this.expression._walk(visitor);
  5098. walk_body(this, visitor);
  5099. });
  5100. },
  5101. _children_backwards(push) {
  5102. let i = this.body.length;
  5103. while (i--) push(this.body[i]);
  5104. push(this.expression);
  5105. }
  5106. }, AST_Block);
  5107. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  5108. if (props) {
  5109. this.body = props.body;
  5110. this.block_scope = props.block_scope;
  5111. this.start = props.start;
  5112. this.end = props.end;
  5113. }
  5114. this.flags = 0;
  5115. }, {
  5116. $documentation: "Base class for `switch` branches",
  5117. }, AST_Block);
  5118. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  5119. if (props) {
  5120. this.body = props.body;
  5121. this.block_scope = props.block_scope;
  5122. this.start = props.start;
  5123. this.end = props.end;
  5124. }
  5125. this.flags = 0;
  5126. }, {
  5127. $documentation: "A `default` switch branch",
  5128. }, AST_SwitchBranch);
  5129. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  5130. if (props) {
  5131. this.expression = props.expression;
  5132. this.body = props.body;
  5133. this.block_scope = props.block_scope;
  5134. this.start = props.start;
  5135. this.end = props.end;
  5136. }
  5137. this.flags = 0;
  5138. }, {
  5139. $documentation: "A `case` switch branch",
  5140. $propdoc: {
  5141. expression: "[AST_Node] the `case` expression"
  5142. },
  5143. _walk: function(visitor) {
  5144. return visitor._visit(this, function() {
  5145. this.expression._walk(visitor);
  5146. walk_body(this, visitor);
  5147. });
  5148. },
  5149. _children_backwards(push) {
  5150. let i = this.body.length;
  5151. while (i--) push(this.body[i]);
  5152. push(this.expression);
  5153. },
  5154. }, AST_SwitchBranch);
  5155. /* -----[ EXCEPTIONS ]----- */
  5156. var AST_Try = DEFNODE("Try", "body bcatch bfinally", function AST_Try(props) {
  5157. if (props) {
  5158. this.body = props.body;
  5159. this.bcatch = props.bcatch;
  5160. this.bfinally = props.bfinally;
  5161. this.start = props.start;
  5162. this.end = props.end;
  5163. }
  5164. this.flags = 0;
  5165. }, {
  5166. $documentation: "A `try` statement",
  5167. $propdoc: {
  5168. body: "[AST_TryBlock] the try block",
  5169. bcatch: "[AST_Catch?] the catch block, or null if not present",
  5170. bfinally: "[AST_Finally?] the finally block, or null if not present"
  5171. },
  5172. _walk: function(visitor) {
  5173. return visitor._visit(this, function() {
  5174. this.body._walk(visitor);
  5175. if (this.bcatch) this.bcatch._walk(visitor);
  5176. if (this.bfinally) this.bfinally._walk(visitor);
  5177. });
  5178. },
  5179. _children_backwards(push) {
  5180. if (this.bfinally) push(this.bfinally);
  5181. if (this.bcatch) push(this.bcatch);
  5182. push(this.body);
  5183. },
  5184. }, AST_Statement);
  5185. var AST_TryBlock = DEFNODE("TryBlock", null, function AST_TryBlock(props) {
  5186. if (props) {
  5187. this.body = props.body;
  5188. this.block_scope = props.block_scope;
  5189. this.start = props.start;
  5190. this.end = props.end;
  5191. }
  5192. this.flags = 0;
  5193. }, {
  5194. $documentation: "The `try` block of a try statement"
  5195. }, AST_Block);
  5196. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  5197. if (props) {
  5198. this.argname = props.argname;
  5199. this.body = props.body;
  5200. this.block_scope = props.block_scope;
  5201. this.start = props.start;
  5202. this.end = props.end;
  5203. }
  5204. this.flags = 0;
  5205. }, {
  5206. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  5207. $propdoc: {
  5208. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  5209. },
  5210. _walk: function(visitor) {
  5211. return visitor._visit(this, function() {
  5212. if (this.argname) this.argname._walk(visitor);
  5213. walk_body(this, visitor);
  5214. });
  5215. },
  5216. _children_backwards(push) {
  5217. let i = this.body.length;
  5218. while (i--) push(this.body[i]);
  5219. if (this.argname) push(this.argname);
  5220. },
  5221. }, AST_Block);
  5222. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  5223. if (props) {
  5224. this.body = props.body;
  5225. this.block_scope = props.block_scope;
  5226. this.start = props.start;
  5227. this.end = props.end;
  5228. }
  5229. this.flags = 0;
  5230. }, {
  5231. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  5232. }, AST_Block);
  5233. /* -----[ VAR/CONST ]----- */
  5234. var AST_DefinitionsLike = DEFNODE("DefinitionsLike", "definitions", function AST_DefinitionsLike(props) {
  5235. if (props) {
  5236. this.definitions = props.definitions;
  5237. this.start = props.start;
  5238. this.end = props.end;
  5239. }
  5240. this.flags = 0;
  5241. }, {
  5242. $documentation: "Base class for variable definitions and `using`",
  5243. $propdoc: {
  5244. definitions: "[AST_VarDef*|AST_UsingDef*] array of variable definitions"
  5245. },
  5246. _walk: function(visitor) {
  5247. return visitor._visit(this, function() {
  5248. var definitions = this.definitions;
  5249. for (var i = 0, len = definitions.length; i < len; i++) {
  5250. definitions[i]._walk(visitor);
  5251. }
  5252. });
  5253. },
  5254. _children_backwards(push) {
  5255. let i = this.definitions.length;
  5256. while (i--) push(this.definitions[i]);
  5257. },
  5258. }, AST_Statement);
  5259. var AST_Definitions = DEFNODE("Definitions", null, function AST_Definitions(props) {
  5260. if (props) {
  5261. this.definitions = props.definitions;
  5262. this.start = props.start;
  5263. this.end = props.end;
  5264. }
  5265. this.flags = 0;
  5266. }, {
  5267. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  5268. }, AST_DefinitionsLike);
  5269. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  5270. if (props) {
  5271. this.definitions = props.definitions;
  5272. this.start = props.start;
  5273. this.end = props.end;
  5274. }
  5275. this.flags = 0;
  5276. }, {
  5277. $documentation: "A `var` statement"
  5278. }, AST_Definitions);
  5279. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  5280. if (props) {
  5281. this.definitions = props.definitions;
  5282. this.start = props.start;
  5283. this.end = props.end;
  5284. }
  5285. this.flags = 0;
  5286. }, {
  5287. $documentation: "A `let` statement"
  5288. }, AST_Definitions);
  5289. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  5290. if (props) {
  5291. this.definitions = props.definitions;
  5292. this.start = props.start;
  5293. this.end = props.end;
  5294. }
  5295. this.flags = 0;
  5296. }, {
  5297. $documentation: "A `const` statement"
  5298. }, AST_Definitions);
  5299. var AST_Using = DEFNODE("Using", "await", function AST_Using(props) {
  5300. if (props) {
  5301. this.await = props.await;
  5302. this.definitions = props.definitions;
  5303. this.start = props.start;
  5304. this.end = props.end;
  5305. }
  5306. this.flags = 0;
  5307. }, {
  5308. $documentation: "A `using` statement",
  5309. $propdoc: {
  5310. await: "[boolean] Whether it's `await using`"
  5311. },
  5312. }, AST_DefinitionsLike);
  5313. var AST_VarDefLike = DEFNODE("VarDefLike", "name value", function AST_VarDefLike(props) {
  5314. if (props) {
  5315. this.name = props.name;
  5316. this.value = props.value;
  5317. this.start = props.start;
  5318. this.end = props.end;
  5319. }
  5320. this.flags = 0;
  5321. }, {
  5322. $documentation: "A name=value pair in a variable definition statement or `using`",
  5323. $propdoc: {
  5324. name: "[AST_Destructuring|AST_SymbolDeclaration] name of the variable",
  5325. value: "[AST_Node?] initializer, or null of there's no initializer"
  5326. },
  5327. _walk: function(visitor) {
  5328. return visitor._visit(this, function() {
  5329. this.name._walk(visitor);
  5330. if (this.value) this.value._walk(visitor);
  5331. });
  5332. },
  5333. _children_backwards(push) {
  5334. if (this.value) push(this.value);
  5335. push(this.name);
  5336. },
  5337. declarations_as_names() {
  5338. if (this.name instanceof AST_SymbolDeclaration) {
  5339. return [this.name];
  5340. } else {
  5341. return this.name.all_symbols();
  5342. }
  5343. }
  5344. });
  5345. var AST_VarDef = DEFNODE("VarDef", null, function AST_VarDef(props) {
  5346. if (props) {
  5347. this.name = props.name;
  5348. this.value = props.value;
  5349. this.start = props.start;
  5350. this.end = props.end;
  5351. }
  5352. this.flags = 0;
  5353. }, {
  5354. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  5355. }, AST_VarDefLike);
  5356. var AST_UsingDef = DEFNODE("UsingDef", null, function AST_UsingDef(props) {
  5357. if (props) {
  5358. this.name = props.name;
  5359. this.value = props.value;
  5360. this.start = props.start;
  5361. this.end = props.end;
  5362. }
  5363. this.flags = 0;
  5364. }, {
  5365. $documentation: "Like VarDef but specific to AST_Using",
  5366. }, AST_VarDefLike);
  5367. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  5368. if (props) {
  5369. this.foreign_name = props.foreign_name;
  5370. this.name = props.name;
  5371. this.start = props.start;
  5372. this.end = props.end;
  5373. }
  5374. this.flags = 0;
  5375. }, {
  5376. $documentation: "The part of the export/import statement that declare names from a module.",
  5377. $propdoc: {
  5378. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  5379. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  5380. },
  5381. _walk: function (visitor) {
  5382. return visitor._visit(this, function() {
  5383. this.foreign_name._walk(visitor);
  5384. this.name._walk(visitor);
  5385. });
  5386. },
  5387. _children_backwards(push) {
  5388. push(this.name);
  5389. push(this.foreign_name);
  5390. },
  5391. });
  5392. var AST_Import = DEFNODE(
  5393. "Import",
  5394. "phase imported_name imported_names module_name attributes",
  5395. function AST_Import(props) {
  5396. if (props) {
  5397. this.phase = props.phase;
  5398. this.imported_name = props.imported_name;
  5399. this.imported_names = props.imported_names;
  5400. this.module_name = props.module_name;
  5401. this.attributes = props.attributes;
  5402. this.start = props.start;
  5403. this.end = props.end;
  5404. }
  5405. this.flags = 0;
  5406. },
  5407. {
  5408. $documentation: "An `import` statement",
  5409. $propdoc: {
  5410. phase: "[string?] Phase keyword: 'source', 'defer', or null.",
  5411. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  5412. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  5413. module_name: "[AST_String] String literal describing where this module came from",
  5414. attributes: "[AST_Object?] The import attributes (with {...})"
  5415. },
  5416. _walk: function(visitor) {
  5417. return visitor._visit(this, function() {
  5418. if (this.imported_name) {
  5419. this.imported_name._walk(visitor);
  5420. }
  5421. if (this.imported_names) {
  5422. this.imported_names.forEach(function(name_import) {
  5423. name_import._walk(visitor);
  5424. });
  5425. }
  5426. this.module_name._walk(visitor);
  5427. });
  5428. },
  5429. _children_backwards(push) {
  5430. push(this.module_name);
  5431. if (this.imported_names) {
  5432. let i = this.imported_names.length;
  5433. while (i--) push(this.imported_names[i]);
  5434. }
  5435. if (this.imported_name) push(this.imported_name);
  5436. },
  5437. }
  5438. );
  5439. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  5440. if (props) {
  5441. this.start = props.start;
  5442. this.end = props.end;
  5443. }
  5444. this.flags = 0;
  5445. }, {
  5446. $documentation: "A reference to import.meta",
  5447. });
  5448. var AST_DynamicImport = DEFNODE(
  5449. "DynamicImport",
  5450. "phase args",
  5451. function AST_DynamicImport(props) {
  5452. if (props) {
  5453. this.phase = props.phase;
  5454. this.args = props.args;
  5455. this.start = props.start;
  5456. this.end = props.end;
  5457. }
  5458. this.flags = 0;
  5459. },
  5460. {
  5461. $documentation: "A dynamic import expression",
  5462. $propdoc: {
  5463. phase: "[string?] Phase keyword ('source' or 'defer') if present",
  5464. args: "[AST_Node*] specifier followed by optional options argument"
  5465. },
  5466. _walk: function(visitor) {
  5467. return visitor._visit(this, function() {
  5468. var args = this.args;
  5469. for (var i = 0, len = args.length; i < len; i++) {
  5470. args[i]._walk(visitor);
  5471. }
  5472. });
  5473. },
  5474. _children_backwards(push) {
  5475. let i = this.args.length;
  5476. while (i--) push(this.args[i]);
  5477. },
  5478. }
  5479. );
  5480. var AST_Export = DEFNODE(
  5481. "Export",
  5482. "exported_definition exported_value is_default exported_names module_name attributes",
  5483. function AST_Export(props) {
  5484. if (props) {
  5485. this.exported_definition = props.exported_definition;
  5486. this.exported_value = props.exported_value;
  5487. this.is_default = props.is_default;
  5488. this.exported_names = props.exported_names;
  5489. this.module_name = props.module_name;
  5490. this.attributes = props.attributes;
  5491. this.start = props.start;
  5492. this.end = props.end;
  5493. }
  5494. this.flags = 0;
  5495. },
  5496. {
  5497. $documentation: "An `export` statement",
  5498. $propdoc: {
  5499. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  5500. exported_value: "[AST_Node?] An exported value",
  5501. exported_names: "[AST_NameMapping*?] List of exported names",
  5502. module_name: "[AST_String?] Name of the file to load exports from",
  5503. is_default: "[Boolean] Whether this is the default exported value of this module",
  5504. attributes: "[AST_Object?] The import attributes"
  5505. },
  5506. _walk: function (visitor) {
  5507. return visitor._visit(this, function () {
  5508. if (this.exported_definition) {
  5509. this.exported_definition._walk(visitor);
  5510. }
  5511. if (this.exported_value) {
  5512. this.exported_value._walk(visitor);
  5513. }
  5514. if (this.exported_names) {
  5515. this.exported_names.forEach(function(name_export) {
  5516. name_export._walk(visitor);
  5517. });
  5518. }
  5519. if (this.module_name) {
  5520. this.module_name._walk(visitor);
  5521. }
  5522. });
  5523. },
  5524. _children_backwards(push) {
  5525. if (this.module_name) push(this.module_name);
  5526. if (this.exported_names) {
  5527. let i = this.exported_names.length;
  5528. while (i--) push(this.exported_names[i]);
  5529. }
  5530. if (this.exported_value) push(this.exported_value);
  5531. if (this.exported_definition) push(this.exported_definition);
  5532. }
  5533. },
  5534. AST_Statement
  5535. );
  5536. /* -----[ OTHER ]----- */
  5537. var AST_Call = DEFNODE(
  5538. "Call",
  5539. "expression args optional _annotations",
  5540. function AST_Call(props) {
  5541. if (props) {
  5542. this.expression = props.expression;
  5543. this.args = props.args;
  5544. this.optional = props.optional;
  5545. this._annotations = props._annotations;
  5546. this.start = props.start;
  5547. this.end = props.end;
  5548. this.initialize();
  5549. }
  5550. this.flags = 0;
  5551. },
  5552. {
  5553. $documentation: "A function call expression",
  5554. $propdoc: {
  5555. expression: "[AST_Node] expression to invoke as function",
  5556. args: "[AST_Node*] array of arguments",
  5557. optional: "[boolean] whether this is an optional call (IE ?.() )",
  5558. _annotations: "[number] bitfield containing information about the call"
  5559. },
  5560. initialize() {
  5561. if (this._annotations == null) this._annotations = 0;
  5562. },
  5563. _walk(visitor) {
  5564. return visitor._visit(this, function() {
  5565. var args = this.args;
  5566. for (var i = 0, len = args.length; i < len; i++) {
  5567. args[i]._walk(visitor);
  5568. }
  5569. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  5570. });
  5571. },
  5572. _children_backwards(push) {
  5573. let i = this.args.length;
  5574. while (i--) push(this.args[i]);
  5575. push(this.expression);
  5576. },
  5577. }
  5578. );
  5579. var AST_New = DEFNODE("New", null, function AST_New(props) {
  5580. if (props) {
  5581. this.expression = props.expression;
  5582. this.args = props.args;
  5583. this.optional = props.optional;
  5584. this._annotations = props._annotations;
  5585. this.start = props.start;
  5586. this.end = props.end;
  5587. this.initialize();
  5588. }
  5589. this.flags = 0;
  5590. }, {
  5591. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  5592. }, AST_Call);
  5593. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  5594. if (props) {
  5595. this.expressions = props.expressions;
  5596. this.start = props.start;
  5597. this.end = props.end;
  5598. }
  5599. this.flags = 0;
  5600. }, {
  5601. $documentation: "A sequence expression (comma-separated expressions)",
  5602. $propdoc: {
  5603. expressions: "[AST_Node*] array of expressions (at least two)"
  5604. },
  5605. _walk: function(visitor) {
  5606. return visitor._visit(this, function() {
  5607. this.expressions.forEach(function(node) {
  5608. node._walk(visitor);
  5609. });
  5610. });
  5611. },
  5612. _children_backwards(push) {
  5613. let i = this.expressions.length;
  5614. while (i--) push(this.expressions[i]);
  5615. },
  5616. });
  5617. var AST_PropAccess = DEFNODE(
  5618. "PropAccess",
  5619. "expression property optional",
  5620. function AST_PropAccess(props) {
  5621. if (props) {
  5622. this.expression = props.expression;
  5623. this.property = props.property;
  5624. this.optional = props.optional;
  5625. this.start = props.start;
  5626. this.end = props.end;
  5627. }
  5628. this.flags = 0;
  5629. },
  5630. {
  5631. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  5632. $propdoc: {
  5633. expression: "[AST_Node] the “container” expression",
  5634. 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",
  5635. optional: "[boolean] whether this is an optional property access (IE ?.)"
  5636. }
  5637. }
  5638. );
  5639. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  5640. if (props) {
  5641. this.quote = props.quote;
  5642. this.expression = props.expression;
  5643. this.property = props.property;
  5644. this.optional = props.optional;
  5645. this._annotations = props._annotations;
  5646. this.start = props.start;
  5647. this.end = props.end;
  5648. }
  5649. this.flags = 0;
  5650. }, {
  5651. $documentation: "A dotted property access expression",
  5652. $propdoc: {
  5653. quote: "[string] the original quote character when transformed from AST_Sub",
  5654. },
  5655. _walk: function(visitor) {
  5656. return visitor._visit(this, function() {
  5657. this.expression._walk(visitor);
  5658. });
  5659. },
  5660. _children_backwards(push) {
  5661. push(this.expression);
  5662. },
  5663. }, AST_PropAccess);
  5664. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  5665. if (props) {
  5666. this.expression = props.expression;
  5667. this.property = props.property;
  5668. this.optional = props.optional;
  5669. this.start = props.start;
  5670. this.end = props.end;
  5671. }
  5672. this.flags = 0;
  5673. }, {
  5674. $documentation: "A dotted property access to a private property",
  5675. _walk: function(visitor) {
  5676. return visitor._visit(this, function() {
  5677. this.expression._walk(visitor);
  5678. });
  5679. },
  5680. _children_backwards(push) {
  5681. push(this.expression);
  5682. },
  5683. }, AST_PropAccess);
  5684. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  5685. if (props) {
  5686. this.expression = props.expression;
  5687. this.property = props.property;
  5688. this.optional = props.optional;
  5689. this._annotations = props._annotations;
  5690. this.start = props.start;
  5691. this.end = props.end;
  5692. }
  5693. this.flags = 0;
  5694. }, {
  5695. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  5696. _walk: function(visitor) {
  5697. return visitor._visit(this, function() {
  5698. this.expression._walk(visitor);
  5699. this.property._walk(visitor);
  5700. });
  5701. },
  5702. _children_backwards(push) {
  5703. push(this.property);
  5704. push(this.expression);
  5705. },
  5706. }, AST_PropAccess);
  5707. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  5708. if (props) {
  5709. this.expression = props.expression;
  5710. this.start = props.start;
  5711. this.end = props.end;
  5712. }
  5713. this.flags = 0;
  5714. }, {
  5715. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  5716. $propdoc: {
  5717. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  5718. },
  5719. _walk: function (visitor) {
  5720. return visitor._visit(this, function() {
  5721. this.expression._walk(visitor);
  5722. });
  5723. },
  5724. _children_backwards(push) {
  5725. push(this.expression);
  5726. },
  5727. });
  5728. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  5729. if (props) {
  5730. this.operator = props.operator;
  5731. this.expression = props.expression;
  5732. this.start = props.start;
  5733. this.end = props.end;
  5734. }
  5735. this.flags = 0;
  5736. }, {
  5737. $documentation: "Base class for unary expressions",
  5738. $propdoc: {
  5739. operator: "[string] the operator",
  5740. expression: "[AST_Node] expression that this unary operator applies to"
  5741. },
  5742. _walk: function(visitor) {
  5743. return visitor._visit(this, function() {
  5744. this.expression._walk(visitor);
  5745. });
  5746. },
  5747. _children_backwards(push) {
  5748. push(this.expression);
  5749. },
  5750. });
  5751. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  5752. if (props) {
  5753. this.operator = props.operator;
  5754. this.expression = props.expression;
  5755. this.start = props.start;
  5756. this.end = props.end;
  5757. }
  5758. this.flags = 0;
  5759. }, {
  5760. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  5761. }, AST_Unary);
  5762. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  5763. if (props) {
  5764. this.operator = props.operator;
  5765. this.expression = props.expression;
  5766. this.start = props.start;
  5767. this.end = props.end;
  5768. }
  5769. this.flags = 0;
  5770. }, {
  5771. $documentation: "Unary postfix expression, i.e. `i++`"
  5772. }, AST_Unary);
  5773. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  5774. if (props) {
  5775. this.operator = props.operator;
  5776. this.left = props.left;
  5777. this.right = props.right;
  5778. this.start = props.start;
  5779. this.end = props.end;
  5780. }
  5781. this.flags = 0;
  5782. }, {
  5783. $documentation: "Binary expression, i.e. `a + b`",
  5784. $propdoc: {
  5785. left: "[AST_Node] left-hand side expression",
  5786. operator: "[string] the operator",
  5787. right: "[AST_Node] right-hand side expression"
  5788. },
  5789. _walk: function(visitor) {
  5790. return visitor._visit(this, function() {
  5791. this.left._walk(visitor);
  5792. this.right._walk(visitor);
  5793. });
  5794. },
  5795. _children_backwards(push) {
  5796. push(this.right);
  5797. push(this.left);
  5798. },
  5799. });
  5800. var AST_Conditional = DEFNODE(
  5801. "Conditional",
  5802. "condition consequent alternative",
  5803. function AST_Conditional(props) {
  5804. if (props) {
  5805. this.condition = props.condition;
  5806. this.consequent = props.consequent;
  5807. this.alternative = props.alternative;
  5808. this.start = props.start;
  5809. this.end = props.end;
  5810. }
  5811. this.flags = 0;
  5812. },
  5813. {
  5814. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  5815. $propdoc: {
  5816. condition: "[AST_Node]",
  5817. consequent: "[AST_Node]",
  5818. alternative: "[AST_Node]"
  5819. },
  5820. _walk: function(visitor) {
  5821. return visitor._visit(this, function() {
  5822. this.condition._walk(visitor);
  5823. this.consequent._walk(visitor);
  5824. this.alternative._walk(visitor);
  5825. });
  5826. },
  5827. _children_backwards(push) {
  5828. push(this.alternative);
  5829. push(this.consequent);
  5830. push(this.condition);
  5831. },
  5832. }
  5833. );
  5834. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  5835. if (props) {
  5836. this.logical = props.logical;
  5837. this.operator = props.operator;
  5838. this.left = props.left;
  5839. this.right = props.right;
  5840. this.start = props.start;
  5841. this.end = props.end;
  5842. }
  5843. this.flags = 0;
  5844. }, {
  5845. $documentation: "An assignment expression — `a = b + 5`",
  5846. $propdoc: {
  5847. logical: "Whether it's a logical assignment"
  5848. }
  5849. }, AST_Binary);
  5850. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  5851. if (props) {
  5852. this.operator = props.operator;
  5853. this.left = props.left;
  5854. this.right = props.right;
  5855. this.start = props.start;
  5856. this.end = props.end;
  5857. }
  5858. this.flags = 0;
  5859. }, {
  5860. $documentation: "A default assignment expression like in `(a = 3) => a`",
  5861. all_symbols() {
  5862. return this.left.all_symbols();
  5863. },
  5864. }, AST_Binary);
  5865. /* -----[ LITERALS ]----- */
  5866. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  5867. if (props) {
  5868. this.elements = props.elements;
  5869. this.start = props.start;
  5870. this.end = props.end;
  5871. }
  5872. this.flags = 0;
  5873. }, {
  5874. $documentation: "An array literal",
  5875. $propdoc: {
  5876. elements: "[AST_Node*] array of elements"
  5877. },
  5878. _walk: function(visitor) {
  5879. return visitor._visit(this, function() {
  5880. var elements = this.elements;
  5881. for (var i = 0, len = elements.length; i < len; i++) {
  5882. elements[i]._walk(visitor);
  5883. }
  5884. });
  5885. },
  5886. _children_backwards(push) {
  5887. let i = this.elements.length;
  5888. while (i--) push(this.elements[i]);
  5889. },
  5890. });
  5891. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  5892. if (props) {
  5893. this.properties = props.properties;
  5894. this.start = props.start;
  5895. this.end = props.end;
  5896. }
  5897. this.flags = 0;
  5898. }, {
  5899. $documentation: "An object literal",
  5900. $propdoc: {
  5901. properties: "[AST_ObjectProperty*] array of properties"
  5902. },
  5903. _walk: function(visitor) {
  5904. return visitor._visit(this, function() {
  5905. var properties = this.properties;
  5906. for (var i = 0, len = properties.length; i < len; i++) {
  5907. properties[i]._walk(visitor);
  5908. }
  5909. });
  5910. },
  5911. _children_backwards(push) {
  5912. let i = this.properties.length;
  5913. while (i--) push(this.properties[i]);
  5914. },
  5915. });
  5916. /* -----[ OBJECT/CLASS PROPERTIES ]----- */
  5917. /**
  5918. * Everything inside the curly braces of an object/class is a subclass of AST_ObjectProperty, except for AST_ClassStaticBlock.
  5919. **/
  5920. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  5921. if (props) {
  5922. this.key = props.key;
  5923. this.value = props.value;
  5924. this.start = props.start;
  5925. this.end = props.end;
  5926. this._annotations = props._annotations;
  5927. }
  5928. this.flags = 0;
  5929. }, {
  5930. $documentation: "Base class for literal object properties",
  5931. $propdoc: {
  5932. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  5933. value: "[AST_Node] property value. For getters, setters and methods this is an AST_Accessor."
  5934. },
  5935. _walk: function(visitor) {
  5936. return visitor._visit(this, function() {
  5937. if (this.key instanceof AST_Node)
  5938. this.key._walk(visitor);
  5939. this.value._walk(visitor);
  5940. });
  5941. },
  5942. _children_backwards(push) {
  5943. push(this.value);
  5944. if (this.key instanceof AST_Node) push(this.key);
  5945. },
  5946. });
  5947. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  5948. if (props) {
  5949. this.quote = props.quote;
  5950. this.key = props.key;
  5951. this.value = props.value;
  5952. this.start = props.start;
  5953. this.end = props.end;
  5954. this._annotations = props._annotations;
  5955. }
  5956. this.flags = 0;
  5957. }, {
  5958. $documentation: "A key: value object property",
  5959. $propdoc: {
  5960. quote: "[string] the original quote character"
  5961. },
  5962. computed_key() {
  5963. return this.key instanceof AST_Node;
  5964. }
  5965. }, AST_ObjectProperty);
  5966. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  5967. if (props) {
  5968. this.static = props.static;
  5969. this.key = props.key;
  5970. this.value = props.value;
  5971. this.start = props.start;
  5972. this.end = props.end;
  5973. }
  5974. this.flags = 0;
  5975. }, {
  5976. $propdoc: {
  5977. static: "[boolean] whether this is a static private setter"
  5978. },
  5979. $documentation: "A private setter property",
  5980. computed_key() {
  5981. return false;
  5982. }
  5983. }, AST_ObjectProperty);
  5984. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
  5985. if (props) {
  5986. this.static = props.static;
  5987. this.key = props.key;
  5988. this.value = props.value;
  5989. this.start = props.start;
  5990. this.end = props.end;
  5991. }
  5992. this.flags = 0;
  5993. }, {
  5994. $propdoc: {
  5995. static: "[boolean] whether this is a static private getter"
  5996. },
  5997. $documentation: "A private getter property",
  5998. computed_key() {
  5999. return false;
  6000. }
  6001. }, AST_ObjectProperty);
  6002. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  6003. if (props) {
  6004. this.quote = props.quote;
  6005. this.static = props.static;
  6006. this.key = props.key;
  6007. this.value = props.value;
  6008. this.start = props.start;
  6009. this.end = props.end;
  6010. this._annotations = props._annotations;
  6011. }
  6012. this.flags = 0;
  6013. }, {
  6014. $propdoc: {
  6015. quote: "[string|undefined] the original quote character, if any",
  6016. static: "[boolean] whether this is a static setter (classes only)"
  6017. },
  6018. $documentation: "An object setter property",
  6019. computed_key() {
  6020. return !(this.key instanceof AST_SymbolMethod);
  6021. }
  6022. }, AST_ObjectProperty);
  6023. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  6024. if (props) {
  6025. this.quote = props.quote;
  6026. this.static = props.static;
  6027. this.key = props.key;
  6028. this.value = props.value;
  6029. this.start = props.start;
  6030. this.end = props.end;
  6031. this._annotations = props._annotations;
  6032. }
  6033. this.flags = 0;
  6034. }, {
  6035. $propdoc: {
  6036. quote: "[string|undefined] the original quote character, if any",
  6037. static: "[boolean] whether this is a static getter (classes only)"
  6038. },
  6039. $documentation: "An object getter property",
  6040. computed_key() {
  6041. return !(this.key instanceof AST_SymbolMethod);
  6042. }
  6043. }, AST_ObjectProperty);
  6044. var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static", function AST_ConciseMethod(props) {
  6045. if (props) {
  6046. this.quote = props.quote;
  6047. this.static = props.static;
  6048. this.key = props.key;
  6049. this.value = props.value;
  6050. this.start = props.start;
  6051. this.end = props.end;
  6052. this._annotations = props._annotations;
  6053. }
  6054. this.flags = 0;
  6055. }, {
  6056. $propdoc: {
  6057. quote: "[string|undefined] the original quote character, if any",
  6058. static: "[boolean] is this method static (classes only)",
  6059. },
  6060. $documentation: "An ES6 concise method inside an object or class",
  6061. computed_key() {
  6062. return !(this.key instanceof AST_SymbolMethod);
  6063. }
  6064. }, AST_ObjectProperty);
  6065. var AST_PrivateMethod = DEFNODE("PrivateMethod", "static", function AST_PrivateMethod(props) {
  6066. if (props) {
  6067. this.static = props.static;
  6068. this.key = props.key;
  6069. this.value = props.value;
  6070. this.start = props.start;
  6071. this.end = props.end;
  6072. }
  6073. this.flags = 0;
  6074. }, {
  6075. $documentation: "A private class method inside a class",
  6076. $propdoc: {
  6077. static: "[boolean] is this a static private method",
  6078. },
  6079. computed_key() {
  6080. return false;
  6081. },
  6082. }, AST_ObjectProperty);
  6083. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  6084. if (props) {
  6085. this.name = props.name;
  6086. this.extends = props.extends;
  6087. this.properties = props.properties;
  6088. this.variables = props.variables;
  6089. this.uses_with = props.uses_with;
  6090. this.uses_eval = props.uses_eval;
  6091. this.parent_scope = props.parent_scope;
  6092. this.enclosed = props.enclosed;
  6093. this.cname = props.cname;
  6094. this.body = props.body;
  6095. this.block_scope = props.block_scope;
  6096. this.start = props.start;
  6097. this.end = props.end;
  6098. }
  6099. this.flags = 0;
  6100. }, {
  6101. $propdoc: {
  6102. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  6103. extends: "[AST_Node]? optional parent class",
  6104. properties: "[AST_ObjectProperty|AST_ClassStaticBlock]* array of properties or static blocks"
  6105. },
  6106. $documentation: "An ES6 class",
  6107. _walk: function(visitor) {
  6108. return visitor._visit(this, function() {
  6109. if (this.name) {
  6110. this.name._walk(visitor);
  6111. }
  6112. if (this.extends) {
  6113. this.extends._walk(visitor);
  6114. }
  6115. this.properties.forEach((prop) => prop._walk(visitor));
  6116. });
  6117. },
  6118. _children_backwards(push) {
  6119. let i = this.properties.length;
  6120. while (i--) push(this.properties[i]);
  6121. if (this.extends) push(this.extends);
  6122. if (this.name) push(this.name);
  6123. },
  6124. /** go through the bits that are executed instantly, not when the class is `new`'d. Doesn't walk the name. */
  6125. visit_nondeferred_class_parts(visitor) {
  6126. if (this.extends) {
  6127. this.extends._walk(visitor);
  6128. }
  6129. this.properties.forEach((prop) => {
  6130. if (prop instanceof AST_ClassStaticBlock) {
  6131. prop._walk(visitor);
  6132. return;
  6133. }
  6134. if (prop.computed_key()) {
  6135. visitor.push(prop);
  6136. prop.key._walk(visitor);
  6137. visitor.pop();
  6138. }
  6139. if (
  6140. prop instanceof AST_ClassPrivateProperty && prop.static && prop.value
  6141. || prop instanceof AST_ClassProperty && prop.static && prop.value
  6142. ) {
  6143. visitor.push(prop);
  6144. prop.value._walk(visitor);
  6145. visitor.pop();
  6146. }
  6147. });
  6148. },
  6149. /** go through the bits that are executed later, when the class is `new`'d or a static method is called */
  6150. visit_deferred_class_parts(visitor) {
  6151. this.properties.forEach((prop) => {
  6152. if (
  6153. prop instanceof AST_ConciseMethod
  6154. || prop instanceof AST_PrivateMethod
  6155. ) {
  6156. prop.walk(visitor);
  6157. } else if (
  6158. prop instanceof AST_ClassProperty && !prop.static && prop.value
  6159. || prop instanceof AST_ClassPrivateProperty && !prop.static && prop.value
  6160. ) {
  6161. visitor.push(prop);
  6162. prop.value._walk(visitor);
  6163. visitor.pop();
  6164. }
  6165. });
  6166. },
  6167. is_self_referential: function() {
  6168. const this_id = this.name && this.name.definition().id;
  6169. let found = false;
  6170. let class_this = true;
  6171. this.visit_nondeferred_class_parts(new TreeWalker((node, descend) => {
  6172. if (found) return true;
  6173. if (node instanceof AST_This) return (found = class_this);
  6174. if (node instanceof AST_SymbolRef) return (found = node.definition().id === this_id);
  6175. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  6176. const class_this_save = class_this;
  6177. class_this = false;
  6178. descend();
  6179. class_this = class_this_save;
  6180. return true;
  6181. }
  6182. }));
  6183. return found;
  6184. },
  6185. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  6186. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  6187. if (props) {
  6188. this.static = props.static;
  6189. this.quote = props.quote;
  6190. this.key = props.key;
  6191. this.value = props.value;
  6192. this.start = props.start;
  6193. this.end = props.end;
  6194. this._annotations = props._annotations;
  6195. }
  6196. this.flags = 0;
  6197. }, {
  6198. $documentation: "A class property",
  6199. $propdoc: {
  6200. static: "[boolean] whether this is a static key",
  6201. quote: "[string] which quote is being used"
  6202. },
  6203. _walk: function(visitor) {
  6204. return visitor._visit(this, function() {
  6205. if (this.key instanceof AST_Node)
  6206. this.key._walk(visitor);
  6207. if (this.value instanceof AST_Node)
  6208. this.value._walk(visitor);
  6209. });
  6210. },
  6211. _children_backwards(push) {
  6212. if (this.value instanceof AST_Node) push(this.value);
  6213. if (this.key instanceof AST_Node) push(this.key);
  6214. },
  6215. computed_key() {
  6216. return !(this.key instanceof AST_SymbolClassProperty);
  6217. }
  6218. }, AST_ObjectProperty);
  6219. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  6220. if (props) {
  6221. this.static = props.static;
  6222. this.key = props.key;
  6223. this.value = props.value;
  6224. this.start = props.start;
  6225. this.end = props.end;
  6226. }
  6227. this.flags = 0;
  6228. }, {
  6229. $documentation: "A class property for a private property",
  6230. _walk: function(visitor) {
  6231. return visitor._visit(this, function() {
  6232. if (this.value instanceof AST_Node)
  6233. this.value._walk(visitor);
  6234. });
  6235. },
  6236. _children_backwards(push) {
  6237. if (this.value instanceof AST_Node) push(this.value);
  6238. },
  6239. computed_key() {
  6240. return false;
  6241. },
  6242. }, AST_ObjectProperty);
  6243. var AST_PrivateIn = DEFNODE("PrivateIn", "key value", function AST_PrivateIn(props) {
  6244. if (props) {
  6245. this.key = props.key;
  6246. this.value = props.value;
  6247. this.start = props.start;
  6248. this.end = props.end;
  6249. }
  6250. this.flags = 0;
  6251. }, {
  6252. $documentation: "An `in` binop when the key is private, eg #x in this",
  6253. _walk: function(visitor) {
  6254. return visitor._visit(this, function() {
  6255. this.key._walk(visitor);
  6256. this.value._walk(visitor);
  6257. });
  6258. },
  6259. _children_backwards(push) {
  6260. push(this.value);
  6261. push(this.key);
  6262. },
  6263. });
  6264. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  6265. if (props) {
  6266. this.name = props.name;
  6267. this.extends = props.extends;
  6268. this.properties = props.properties;
  6269. this.variables = props.variables;
  6270. this.uses_with = props.uses_with;
  6271. this.uses_eval = props.uses_eval;
  6272. this.parent_scope = props.parent_scope;
  6273. this.enclosed = props.enclosed;
  6274. this.cname = props.cname;
  6275. this.body = props.body;
  6276. this.block_scope = props.block_scope;
  6277. this.start = props.start;
  6278. this.end = props.end;
  6279. }
  6280. this.flags = 0;
  6281. }, {
  6282. $documentation: "A class definition",
  6283. }, AST_Class);
  6284. var AST_ClassStaticBlock = DEFNODE("ClassStaticBlock", "body block_scope", function AST_ClassStaticBlock (props) {
  6285. this.body = props.body;
  6286. this.block_scope = props.block_scope;
  6287. this.start = props.start;
  6288. this.end = props.end;
  6289. }, {
  6290. $documentation: "A block containing statements to be executed in the context of the class",
  6291. $propdoc: {
  6292. body: "[AST_Statement*] an array of statements",
  6293. },
  6294. _walk: function(visitor) {
  6295. return visitor._visit(this, function() {
  6296. walk_body(this, visitor);
  6297. });
  6298. },
  6299. _children_backwards(push) {
  6300. let i = this.body.length;
  6301. while (i--) push(this.body[i]);
  6302. },
  6303. clone: clone_block_scope,
  6304. computed_key() {
  6305. return false;
  6306. },
  6307. }, AST_Scope);
  6308. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  6309. if (props) {
  6310. this.name = props.name;
  6311. this.extends = props.extends;
  6312. this.properties = props.properties;
  6313. this.variables = props.variables;
  6314. this.uses_with = props.uses_with;
  6315. this.uses_eval = props.uses_eval;
  6316. this.parent_scope = props.parent_scope;
  6317. this.enclosed = props.enclosed;
  6318. this.cname = props.cname;
  6319. this.body = props.body;
  6320. this.block_scope = props.block_scope;
  6321. this.start = props.start;
  6322. this.end = props.end;
  6323. }
  6324. this.flags = 0;
  6325. }, {
  6326. $documentation: "A class expression."
  6327. }, AST_Class);
  6328. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  6329. if (props) {
  6330. this.scope = props.scope;
  6331. this.name = props.name;
  6332. this.thedef = props.thedef;
  6333. this.start = props.start;
  6334. this.end = props.end;
  6335. }
  6336. this.flags = 0;
  6337. }, {
  6338. $propdoc: {
  6339. name: "[string] name of this symbol",
  6340. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  6341. thedef: "[SymbolDef/S] the definition of this symbol"
  6342. },
  6343. $documentation: "Base class for all symbols"
  6344. });
  6345. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  6346. if (props) {
  6347. this.start = props.start;
  6348. this.end = props.end;
  6349. }
  6350. this.flags = 0;
  6351. }, {
  6352. $documentation: "A reference to new.target"
  6353. });
  6354. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  6355. if (props) {
  6356. this.init = props.init;
  6357. this.scope = props.scope;
  6358. this.name = props.name;
  6359. this.thedef = props.thedef;
  6360. this.start = props.start;
  6361. this.end = props.end;
  6362. }
  6363. this.flags = 0;
  6364. }, {
  6365. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  6366. all_symbols() {
  6367. return [this];
  6368. },
  6369. }, AST_Symbol);
  6370. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
  6371. if (props) {
  6372. this.init = props.init;
  6373. this.scope = props.scope;
  6374. this.name = props.name;
  6375. this.thedef = props.thedef;
  6376. this.start = props.start;
  6377. this.end = props.end;
  6378. }
  6379. this.flags = 0;
  6380. }, {
  6381. $documentation: "Symbol defining a variable",
  6382. }, AST_SymbolDeclaration);
  6383. var AST_SymbolBlockDeclaration = DEFNODE(
  6384. "SymbolBlockDeclaration",
  6385. null,
  6386. function AST_SymbolBlockDeclaration(props) {
  6387. if (props) {
  6388. this.init = props.init;
  6389. this.scope = props.scope;
  6390. this.name = props.name;
  6391. this.thedef = props.thedef;
  6392. this.start = props.start;
  6393. this.end = props.end;
  6394. }
  6395. this.flags = 0;
  6396. },
  6397. {
  6398. $documentation: "Base class for block-scoped declaration symbols"
  6399. },
  6400. AST_SymbolDeclaration
  6401. );
  6402. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  6403. if (props) {
  6404. this.init = props.init;
  6405. this.scope = props.scope;
  6406. this.name = props.name;
  6407. this.thedef = props.thedef;
  6408. this.start = props.start;
  6409. this.end = props.end;
  6410. }
  6411. this.flags = 0;
  6412. }, {
  6413. $documentation: "A constant declaration"
  6414. }, AST_SymbolBlockDeclaration);
  6415. var AST_SymbolUsing = DEFNODE("SymbolUsing", null, function AST_SymbolUsing(props) {
  6416. if (props) {
  6417. this.init = props.init;
  6418. this.scope = props.scope;
  6419. this.name = props.name;
  6420. this.thedef = props.thedef;
  6421. this.start = props.start;
  6422. this.end = props.end;
  6423. }
  6424. this.flags = 0;
  6425. }, {
  6426. $documentation: "A `using` declaration"
  6427. }, AST_SymbolBlockDeclaration);
  6428. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(props) {
  6429. if (props) {
  6430. this.init = props.init;
  6431. this.scope = props.scope;
  6432. this.name = props.name;
  6433. this.thedef = props.thedef;
  6434. this.start = props.start;
  6435. this.end = props.end;
  6436. }
  6437. this.flags = 0;
  6438. }, {
  6439. $documentation: "A block-scoped `let` declaration"
  6440. }, AST_SymbolBlockDeclaration);
  6441. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
  6442. if (props) {
  6443. this.init = props.init;
  6444. this.scope = props.scope;
  6445. this.name = props.name;
  6446. this.thedef = props.thedef;
  6447. this.start = props.start;
  6448. this.end = props.end;
  6449. }
  6450. this.flags = 0;
  6451. }, {
  6452. $documentation: "Symbol naming a function argument",
  6453. }, AST_SymbolVar);
  6454. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
  6455. if (props) {
  6456. this.init = props.init;
  6457. this.scope = props.scope;
  6458. this.name = props.name;
  6459. this.thedef = props.thedef;
  6460. this.start = props.start;
  6461. this.end = props.end;
  6462. }
  6463. this.flags = 0;
  6464. }, {
  6465. $documentation: "Symbol defining a function",
  6466. }, AST_SymbolDeclaration);
  6467. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  6468. if (props) {
  6469. this.scope = props.scope;
  6470. this.name = props.name;
  6471. this.thedef = props.thedef;
  6472. this.start = props.start;
  6473. this.end = props.end;
  6474. }
  6475. this.flags = 0;
  6476. }, {
  6477. $documentation: "Symbol in an object defining a method",
  6478. }, AST_Symbol);
  6479. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  6480. if (props) {
  6481. this.scope = props.scope;
  6482. this.name = props.name;
  6483. this.thedef = props.thedef;
  6484. this.start = props.start;
  6485. this.end = props.end;
  6486. }
  6487. this.flags = 0;
  6488. }, {
  6489. $documentation: "Symbol for a class property",
  6490. }, AST_Symbol);
  6491. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  6492. if (props) {
  6493. this.init = props.init;
  6494. this.scope = props.scope;
  6495. this.name = props.name;
  6496. this.thedef = props.thedef;
  6497. this.start = props.start;
  6498. this.end = props.end;
  6499. }
  6500. this.flags = 0;
  6501. }, {
  6502. $documentation: "Symbol naming a function expression",
  6503. }, AST_SymbolDeclaration);
  6504. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
  6505. if (props) {
  6506. this.init = props.init;
  6507. this.scope = props.scope;
  6508. this.name = props.name;
  6509. this.thedef = props.thedef;
  6510. this.start = props.start;
  6511. this.end = props.end;
  6512. }
  6513. this.flags = 0;
  6514. }, {
  6515. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  6516. }, AST_SymbolBlockDeclaration);
  6517. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
  6518. if (props) {
  6519. this.init = props.init;
  6520. this.scope = props.scope;
  6521. this.name = props.name;
  6522. this.thedef = props.thedef;
  6523. this.start = props.start;
  6524. this.end = props.end;
  6525. }
  6526. this.flags = 0;
  6527. }, {
  6528. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  6529. }, AST_SymbolDeclaration);
  6530. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
  6531. if (props) {
  6532. this.init = props.init;
  6533. this.scope = props.scope;
  6534. this.name = props.name;
  6535. this.thedef = props.thedef;
  6536. this.start = props.start;
  6537. this.end = props.end;
  6538. }
  6539. this.flags = 0;
  6540. }, {
  6541. $documentation: "Symbol naming the exception in catch",
  6542. }, AST_SymbolBlockDeclaration);
  6543. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
  6544. if (props) {
  6545. this.init = props.init;
  6546. this.scope = props.scope;
  6547. this.name = props.name;
  6548. this.thedef = props.thedef;
  6549. this.start = props.start;
  6550. this.end = props.end;
  6551. }
  6552. this.flags = 0;
  6553. }, {
  6554. $documentation: "Symbol referring to an imported name",
  6555. }, AST_SymbolBlockDeclaration);
  6556. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", "quote", function AST_SymbolImportForeign(props) {
  6557. if (props) {
  6558. this.quote = props.quote;
  6559. this.scope = props.scope;
  6560. this.name = props.name;
  6561. this.thedef = props.thedef;
  6562. this.start = props.start;
  6563. this.end = props.end;
  6564. }
  6565. this.flags = 0;
  6566. }, {
  6567. $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",
  6568. }, AST_Symbol);
  6569. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  6570. if (props) {
  6571. this.references = props.references;
  6572. this.scope = props.scope;
  6573. this.name = props.name;
  6574. this.thedef = props.thedef;
  6575. this.start = props.start;
  6576. this.end = props.end;
  6577. this.initialize();
  6578. }
  6579. this.flags = 0;
  6580. }, {
  6581. $documentation: "Symbol naming a label (declaration)",
  6582. $propdoc: {
  6583. references: "[AST_LoopControl*] a list of nodes referring to this label"
  6584. },
  6585. initialize: function() {
  6586. this.references = [];
  6587. this.thedef = this;
  6588. }
  6589. }, AST_Symbol);
  6590. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  6591. if (props) {
  6592. this.scope = props.scope;
  6593. this.name = props.name;
  6594. this.thedef = props.thedef;
  6595. this.start = props.start;
  6596. this.end = props.end;
  6597. }
  6598. this.flags = 0;
  6599. }, {
  6600. $documentation: "Reference to some symbol (not definition/declaration)",
  6601. }, AST_Symbol);
  6602. var AST_SymbolExport = DEFNODE("SymbolExport", "quote", function AST_SymbolExport(props) {
  6603. if (props) {
  6604. this.quote = props.quote;
  6605. this.scope = props.scope;
  6606. this.name = props.name;
  6607. this.thedef = props.thedef;
  6608. this.start = props.start;
  6609. this.end = props.end;
  6610. }
  6611. this.flags = 0;
  6612. }, {
  6613. $documentation: "Symbol referring to a name to export",
  6614. }, AST_SymbolRef);
  6615. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", "quote", function AST_SymbolExportForeign(props) {
  6616. if (props) {
  6617. this.quote = props.quote;
  6618. this.scope = props.scope;
  6619. this.name = props.name;
  6620. this.thedef = props.thedef;
  6621. this.start = props.start;
  6622. this.end = props.end;
  6623. }
  6624. this.flags = 0;
  6625. }, {
  6626. $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",
  6627. }, AST_Symbol);
  6628. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  6629. if (props) {
  6630. this.scope = props.scope;
  6631. this.name = props.name;
  6632. this.thedef = props.thedef;
  6633. this.start = props.start;
  6634. this.end = props.end;
  6635. }
  6636. this.flags = 0;
  6637. }, {
  6638. $documentation: "Reference to a label symbol",
  6639. }, AST_Symbol);
  6640. var AST_SymbolPrivateProperty = DEFNODE("SymbolPrivateProperty", null, function AST_SymbolPrivateProperty(props) {
  6641. if (props) {
  6642. this.scope = props.scope;
  6643. this.name = props.name;
  6644. this.thedef = props.thedef;
  6645. this.start = props.start;
  6646. this.end = props.end;
  6647. }
  6648. this.flags = 0;
  6649. }, {
  6650. $documentation: "A symbol that refers to a private property",
  6651. }, AST_Symbol);
  6652. var AST_This = DEFNODE("This", null, function AST_This(props) {
  6653. if (props) {
  6654. this.scope = props.scope;
  6655. this.name = props.name;
  6656. this.thedef = props.thedef;
  6657. this.start = props.start;
  6658. this.end = props.end;
  6659. }
  6660. this.flags = 0;
  6661. }, {
  6662. $documentation: "The `this` symbol",
  6663. }, AST_Symbol);
  6664. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  6665. if (props) {
  6666. this.scope = props.scope;
  6667. this.name = props.name;
  6668. this.thedef = props.thedef;
  6669. this.start = props.start;
  6670. this.end = props.end;
  6671. }
  6672. this.flags = 0;
  6673. }, {
  6674. $documentation: "The `super` symbol",
  6675. }, AST_This);
  6676. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  6677. if (props) {
  6678. this.start = props.start;
  6679. this.end = props.end;
  6680. }
  6681. this.flags = 0;
  6682. }, {
  6683. $documentation: "Base class for all constants",
  6684. getValue: function() {
  6685. return this.value;
  6686. }
  6687. });
  6688. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  6689. if (props) {
  6690. this.value = props.value;
  6691. this.quote = props.quote;
  6692. this.start = props.start;
  6693. this.end = props.end;
  6694. this._annotations = props._annotations;
  6695. }
  6696. this.flags = 0;
  6697. }, {
  6698. $documentation: "A string literal",
  6699. $propdoc: {
  6700. value: "[string] the contents of this string",
  6701. quote: "[string] the original quote character"
  6702. }
  6703. }, AST_Constant);
  6704. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  6705. if (props) {
  6706. this.value = props.value;
  6707. this.raw = props.raw;
  6708. this.start = props.start;
  6709. this.end = props.end;
  6710. }
  6711. this.flags = 0;
  6712. }, {
  6713. $documentation: "A number literal",
  6714. $propdoc: {
  6715. value: "[number] the numeric value",
  6716. raw: "[string] numeric value as string"
  6717. }
  6718. }, AST_Constant);
  6719. var AST_BigInt = DEFNODE("BigInt", "value raw", function AST_BigInt(props) {
  6720. if (props) {
  6721. this.value = props.value;
  6722. this.raw = props.raw;
  6723. this.start = props.start;
  6724. this.end = props.end;
  6725. }
  6726. this.flags = 0;
  6727. }, {
  6728. $documentation: "A big int literal",
  6729. $propdoc: {
  6730. value: "[string] big int value, represented as a string",
  6731. raw: "[string] the original format preserved"
  6732. }
  6733. }, AST_Constant);
  6734. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  6735. if (props) {
  6736. this.value = props.value;
  6737. this.start = props.start;
  6738. this.end = props.end;
  6739. }
  6740. this.flags = 0;
  6741. }, {
  6742. $documentation: "A regexp literal",
  6743. $propdoc: {
  6744. value: "[RegExp] the actual regexp",
  6745. }
  6746. }, AST_Constant);
  6747. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  6748. if (props) {
  6749. this.start = props.start;
  6750. this.end = props.end;
  6751. }
  6752. this.flags = 0;
  6753. }, {
  6754. $documentation: "Base class for atoms",
  6755. }, AST_Constant);
  6756. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  6757. if (props) {
  6758. this.start = props.start;
  6759. this.end = props.end;
  6760. }
  6761. this.flags = 0;
  6762. }, {
  6763. $documentation: "The `null` atom",
  6764. value: null
  6765. }, AST_Atom);
  6766. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  6767. if (props) {
  6768. this.start = props.start;
  6769. this.end = props.end;
  6770. }
  6771. this.flags = 0;
  6772. }, {
  6773. $documentation: "The impossible value",
  6774. value: 0/0
  6775. }, AST_Atom);
  6776. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  6777. if (props) {
  6778. this.start = props.start;
  6779. this.end = props.end;
  6780. }
  6781. this.flags = 0;
  6782. }, {
  6783. $documentation: "The `undefined` value",
  6784. value: (function() {}())
  6785. }, AST_Atom);
  6786. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  6787. if (props) {
  6788. this.start = props.start;
  6789. this.end = props.end;
  6790. }
  6791. this.flags = 0;
  6792. }, {
  6793. $documentation: "A hole in an array",
  6794. value: (function() {}())
  6795. }, AST_Atom);
  6796. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  6797. if (props) {
  6798. this.start = props.start;
  6799. this.end = props.end;
  6800. }
  6801. this.flags = 0;
  6802. }, {
  6803. $documentation: "The `Infinity` value",
  6804. value: 1/0
  6805. }, AST_Atom);
  6806. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  6807. if (props) {
  6808. this.start = props.start;
  6809. this.end = props.end;
  6810. }
  6811. this.flags = 0;
  6812. }, {
  6813. $documentation: "Base class for booleans",
  6814. }, AST_Atom);
  6815. var AST_False = DEFNODE("False", null, function AST_False(props) {
  6816. if (props) {
  6817. this.start = props.start;
  6818. this.end = props.end;
  6819. }
  6820. this.flags = 0;
  6821. }, {
  6822. $documentation: "The `false` atom",
  6823. value: false
  6824. }, AST_Boolean);
  6825. var AST_True = DEFNODE("True", null, function AST_True(props) {
  6826. if (props) {
  6827. this.start = props.start;
  6828. this.end = props.end;
  6829. }
  6830. this.flags = 0;
  6831. }, {
  6832. $documentation: "The `true` atom",
  6833. value: true
  6834. }, AST_Boolean);
  6835. /* -----[ Walk function ]---- */
  6836. /**
  6837. * Walk nodes in depth-first search fashion.
  6838. * Callback can return `walk_abort` symbol to stop iteration.
  6839. * It can also return `true` to stop iteration just for child nodes.
  6840. * Iteration can be stopped and continued by passing the `to_visit` argument,
  6841. * which is given to the callback in the second argument.
  6842. **/
  6843. function walk(node, cb, to_visit = [node]) {
  6844. const push = to_visit.push.bind(to_visit);
  6845. while (to_visit.length) {
  6846. const node = to_visit.pop();
  6847. const ret = cb(node, to_visit);
  6848. if (ret) {
  6849. if (ret === walk_abort) return true;
  6850. continue;
  6851. }
  6852. node._children_backwards(push);
  6853. }
  6854. return false;
  6855. }
  6856. /**
  6857. * Walks an AST node and its children.
  6858. *
  6859. * {cb} can return `walk_abort` to interrupt the walk.
  6860. *
  6861. * @param node
  6862. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  6863. *
  6864. * @returns {boolean} whether the walk was aborted
  6865. *
  6866. * @example
  6867. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  6868. * if (some_cond(node, parent())) return walk_abort
  6869. * });
  6870. */
  6871. function walk_parent(node, cb, initial_stack) {
  6872. const to_visit = [node];
  6873. const push = to_visit.push.bind(to_visit);
  6874. const stack = initial_stack ? initial_stack.slice() : [];
  6875. const parent_pop_indices = [];
  6876. let current;
  6877. const info = {
  6878. parent: (n = 0) => {
  6879. if (n === -1) {
  6880. return current;
  6881. }
  6882. // [ p1 p0 ] [ 1 0 ]
  6883. if (initial_stack && n >= stack.length) {
  6884. n -= stack.length;
  6885. return initial_stack[
  6886. initial_stack.length - (n + 1)
  6887. ];
  6888. }
  6889. return stack[stack.length - (1 + n)];
  6890. },
  6891. };
  6892. while (to_visit.length) {
  6893. current = to_visit.pop();
  6894. while (
  6895. parent_pop_indices.length &&
  6896. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  6897. ) {
  6898. stack.pop();
  6899. parent_pop_indices.pop();
  6900. }
  6901. const ret = cb(current, info);
  6902. if (ret) {
  6903. if (ret === walk_abort) return true;
  6904. continue;
  6905. }
  6906. const visit_length = to_visit.length;
  6907. current._children_backwards(push);
  6908. // Push only if we're going to traverse the children
  6909. if (to_visit.length > visit_length) {
  6910. stack.push(current);
  6911. parent_pop_indices.push(visit_length - 1);
  6912. }
  6913. }
  6914. return false;
  6915. }
  6916. const walk_abort = Symbol("abort walk");
  6917. /* -----[ TreeWalker ]----- */
  6918. class TreeWalker {
  6919. constructor(callback) {
  6920. this.visit = callback;
  6921. this.stack = [];
  6922. this.directives = Object.create(null);
  6923. }
  6924. _visit(node, descend) {
  6925. this.push(node);
  6926. var ret = this.visit(node, descend ? function() {
  6927. descend.call(node);
  6928. } : noop);
  6929. if (!ret && descend) {
  6930. descend.call(node);
  6931. }
  6932. this.pop();
  6933. return ret;
  6934. }
  6935. parent(n) {
  6936. return this.stack[this.stack.length - 2 - (n || 0)];
  6937. }
  6938. push(node) {
  6939. if (node instanceof AST_Lambda) {
  6940. this.directives = Object.create(this.directives);
  6941. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  6942. this.directives[node.value] = node;
  6943. } else if (node instanceof AST_Class) {
  6944. this.directives = Object.create(this.directives);
  6945. if (!this.directives["use strict"]) {
  6946. this.directives["use strict"] = node;
  6947. }
  6948. }
  6949. this.stack.push(node);
  6950. }
  6951. pop() {
  6952. var node = this.stack.pop();
  6953. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  6954. this.directives = Object.getPrototypeOf(this.directives);
  6955. }
  6956. }
  6957. self() {
  6958. return this.stack[this.stack.length - 1];
  6959. }
  6960. find_parent(type) {
  6961. var stack = this.stack;
  6962. for (var i = stack.length; --i >= 0;) {
  6963. var x = stack[i];
  6964. if (x instanceof type) return x;
  6965. }
  6966. }
  6967. is_within_loop() {
  6968. let i = this.stack.length - 1;
  6969. let child = this.stack[i];
  6970. while (i--) {
  6971. const node = this.stack[i];
  6972. if (node instanceof AST_Lambda) return false;
  6973. if (
  6974. node instanceof AST_IterationStatement
  6975. // exclude for-loop bits that only run once
  6976. && !((node instanceof AST_For) && child === node.init)
  6977. && !((node instanceof AST_ForIn || node instanceof AST_ForOf) && child === node.object)
  6978. ) {
  6979. return true;
  6980. }
  6981. child = node;
  6982. }
  6983. return false;
  6984. }
  6985. find_scope() {
  6986. var stack = this.stack;
  6987. for (var i = stack.length; --i >= 0;) {
  6988. const p = stack[i];
  6989. if (p instanceof AST_Toplevel) return p;
  6990. if (p instanceof AST_Lambda) return p;
  6991. if (p.block_scope) return p.block_scope;
  6992. }
  6993. }
  6994. has_directive(type) {
  6995. var dir = this.directives[type];
  6996. if (dir) return dir;
  6997. var node = this.stack[this.stack.length - 1];
  6998. if (node instanceof AST_Scope && node.body) {
  6999. for (var i = 0; i < node.body.length; ++i) {
  7000. var st = node.body[i];
  7001. if (!(st instanceof AST_Directive)) break;
  7002. if (st.value == type) return st;
  7003. }
  7004. }
  7005. }
  7006. loopcontrol_target(node) {
  7007. var stack = this.stack;
  7008. if (node.label) for (var i = stack.length; --i >= 0;) {
  7009. var x = stack[i];
  7010. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  7011. return x.body;
  7012. } else for (var i = stack.length; --i >= 0;) {
  7013. var x = stack[i];
  7014. if (x instanceof AST_IterationStatement
  7015. || node instanceof AST_Break && x instanceof AST_Switch)
  7016. return x;
  7017. }
  7018. }
  7019. }
  7020. // Tree transformer helpers.
  7021. class TreeTransformer extends TreeWalker {
  7022. constructor(before, after) {
  7023. super();
  7024. this.before = before;
  7025. this.after = after;
  7026. }
  7027. }
  7028. const _PURE = 0b00000001;
  7029. const _INLINE = 0b00000010;
  7030. const _NOINLINE = 0b00000100;
  7031. const _KEY = 0b00001000;
  7032. const _MANGLEPROP = 0b00010000;
  7033. /***********************************************************************
  7034. A JavaScript tokenizer / parser / beautifier / compressor.
  7035. https://github.com/mishoo/UglifyJS2
  7036. -------------------------------- (C) ---------------------------------
  7037. Author: Mihai Bazon
  7038. <mihai.bazon@gmail.com>
  7039. http://mihai.bazon.net/blog
  7040. Distributed under the BSD license:
  7041. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  7042. Redistribution and use in source and binary forms, with or without
  7043. modification, are permitted provided that the following conditions
  7044. are met:
  7045. * Redistributions of source code must retain the above
  7046. copyright notice, this list of conditions and the following
  7047. disclaimer.
  7048. * Redistributions in binary form must reproduce the above
  7049. copyright notice, this list of conditions and the following
  7050. disclaimer in the documentation and/or other materials
  7051. provided with the distribution.
  7052. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  7053. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7054. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  7055. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  7056. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  7057. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  7058. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  7059. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7060. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  7061. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  7062. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  7063. SUCH DAMAGE.
  7064. ***********************************************************************/
  7065. function def_transform(node, descend) {
  7066. node.DEFMETHOD("transform", function(tw, in_list) {
  7067. let transformed = undefined;
  7068. tw.push(this);
  7069. if (tw.before) transformed = tw.before(this, descend, in_list);
  7070. if (transformed === undefined) {
  7071. transformed = this;
  7072. descend(transformed, tw);
  7073. if (tw.after) {
  7074. const after_ret = tw.after(transformed, in_list);
  7075. if (after_ret !== undefined) transformed = after_ret;
  7076. }
  7077. }
  7078. tw.pop();
  7079. return transformed;
  7080. });
  7081. }
  7082. def_transform(AST_Node, noop);
  7083. def_transform(AST_LabeledStatement, function(self, tw) {
  7084. self.label = self.label.transform(tw);
  7085. self.body = self.body.transform(tw);
  7086. });
  7087. def_transform(AST_SimpleStatement, function(self, tw) {
  7088. self.body = self.body.transform(tw);
  7089. });
  7090. def_transform(AST_Block, function(self, tw) {
  7091. self.body = MAP(self.body, tw);
  7092. });
  7093. def_transform(AST_Do, function(self, tw) {
  7094. self.body = self.body.transform(tw);
  7095. self.condition = self.condition.transform(tw);
  7096. });
  7097. def_transform(AST_While, function(self, tw) {
  7098. self.condition = self.condition.transform(tw);
  7099. self.body = self.body.transform(tw);
  7100. });
  7101. def_transform(AST_For, function(self, tw) {
  7102. if (self.init) self.init = self.init.transform(tw);
  7103. if (self.condition) self.condition = self.condition.transform(tw);
  7104. if (self.step) self.step = self.step.transform(tw);
  7105. self.body = self.body.transform(tw);
  7106. });
  7107. def_transform(AST_ForIn, function(self, tw) {
  7108. self.init = self.init.transform(tw);
  7109. self.object = self.object.transform(tw);
  7110. self.body = self.body.transform(tw);
  7111. });
  7112. def_transform(AST_With, function(self, tw) {
  7113. self.expression = self.expression.transform(tw);
  7114. self.body = self.body.transform(tw);
  7115. });
  7116. def_transform(AST_Exit, function(self, tw) {
  7117. if (self.value) self.value = self.value.transform(tw);
  7118. });
  7119. def_transform(AST_LoopControl, function(self, tw) {
  7120. if (self.label) self.label = self.label.transform(tw);
  7121. });
  7122. def_transform(AST_If, function(self, tw) {
  7123. self.condition = self.condition.transform(tw);
  7124. self.body = self.body.transform(tw);
  7125. if (self.alternative) self.alternative = self.alternative.transform(tw);
  7126. });
  7127. def_transform(AST_Switch, function(self, tw) {
  7128. self.expression = self.expression.transform(tw);
  7129. self.body = MAP(self.body, tw);
  7130. });
  7131. def_transform(AST_Case, function(self, tw) {
  7132. self.expression = self.expression.transform(tw);
  7133. self.body = MAP(self.body, tw);
  7134. });
  7135. def_transform(AST_Try, function(self, tw) {
  7136. self.body = self.body.transform(tw);
  7137. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  7138. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  7139. });
  7140. def_transform(AST_Catch, function(self, tw) {
  7141. if (self.argname) self.argname = self.argname.transform(tw);
  7142. self.body = MAP(self.body, tw);
  7143. });
  7144. def_transform(AST_DefinitionsLike, function(self, tw) {
  7145. self.definitions = MAP(self.definitions, tw);
  7146. });
  7147. def_transform(AST_VarDefLike, function(self, tw) {
  7148. self.name = self.name.transform(tw);
  7149. if (self.value) self.value = self.value.transform(tw);
  7150. });
  7151. def_transform(AST_Destructuring, function(self, tw) {
  7152. self.names = MAP(self.names, tw);
  7153. });
  7154. def_transform(AST_Lambda, function(self, tw) {
  7155. if (self.name) self.name = self.name.transform(tw);
  7156. self.argnames = MAP(self.argnames, tw, /* allow_splicing */ false);
  7157. if (self.body instanceof AST_Node) {
  7158. self.body = self.body.transform(tw);
  7159. } else {
  7160. self.body = MAP(self.body, tw);
  7161. }
  7162. });
  7163. def_transform(AST_Call, function(self, tw) {
  7164. self.expression = self.expression.transform(tw);
  7165. self.args = MAP(self.args, tw, /* allow_splicing */ false);
  7166. });
  7167. def_transform(AST_Sequence, function(self, tw) {
  7168. const result = MAP(self.expressions, tw);
  7169. self.expressions = result.length
  7170. ? result
  7171. : [new AST_Number({ value: 0 })];
  7172. });
  7173. def_transform(AST_PropAccess, function(self, tw) {
  7174. self.expression = self.expression.transform(tw);
  7175. });
  7176. def_transform(AST_Sub, function(self, tw) {
  7177. self.expression = self.expression.transform(tw);
  7178. self.property = self.property.transform(tw);
  7179. });
  7180. def_transform(AST_Chain, function(self, tw) {
  7181. self.expression = self.expression.transform(tw);
  7182. });
  7183. def_transform(AST_Yield, function(self, tw) {
  7184. if (self.expression) self.expression = self.expression.transform(tw);
  7185. });
  7186. def_transform(AST_Await, function(self, tw) {
  7187. self.expression = self.expression.transform(tw);
  7188. });
  7189. def_transform(AST_Unary, function(self, tw) {
  7190. self.expression = self.expression.transform(tw);
  7191. });
  7192. def_transform(AST_Binary, function(self, tw) {
  7193. self.left = self.left.transform(tw);
  7194. self.right = self.right.transform(tw);
  7195. });
  7196. def_transform(AST_PrivateIn, function(self, tw) {
  7197. self.key = self.key.transform(tw);
  7198. self.value = self.value.transform(tw);
  7199. });
  7200. def_transform(AST_Conditional, function(self, tw) {
  7201. self.condition = self.condition.transform(tw);
  7202. self.consequent = self.consequent.transform(tw);
  7203. self.alternative = self.alternative.transform(tw);
  7204. });
  7205. def_transform(AST_Array, function(self, tw) {
  7206. self.elements = MAP(self.elements, tw);
  7207. });
  7208. def_transform(AST_Object, function(self, tw) {
  7209. self.properties = MAP(self.properties, tw);
  7210. });
  7211. def_transform(AST_ObjectProperty, function(self, tw) {
  7212. if (self.key instanceof AST_Node) {
  7213. self.key = self.key.transform(tw);
  7214. }
  7215. if (self.value) self.value = self.value.transform(tw);
  7216. });
  7217. def_transform(AST_Class, function(self, tw) {
  7218. if (self.name) self.name = self.name.transform(tw);
  7219. if (self.extends) self.extends = self.extends.transform(tw);
  7220. self.properties = MAP(self.properties, tw);
  7221. });
  7222. def_transform(AST_ClassStaticBlock, function(self, tw) {
  7223. self.body = MAP(self.body, tw);
  7224. });
  7225. def_transform(AST_Expansion, function(self, tw) {
  7226. self.expression = self.expression.transform(tw);
  7227. });
  7228. def_transform(AST_NameMapping, function(self, tw) {
  7229. self.foreign_name = self.foreign_name.transform(tw);
  7230. self.name = self.name.transform(tw);
  7231. });
  7232. def_transform(AST_Import, function(self, tw) {
  7233. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  7234. if (self.imported_names) MAP(self.imported_names, tw);
  7235. self.module_name = self.module_name.transform(tw);
  7236. });
  7237. def_transform(AST_DynamicImport, function(self, tw) {
  7238. self.args = MAP(self.args, tw);
  7239. });
  7240. def_transform(AST_Export, function(self, tw) {
  7241. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  7242. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  7243. if (self.exported_names) MAP(self.exported_names, tw);
  7244. if (self.module_name) self.module_name = self.module_name.transform(tw);
  7245. });
  7246. def_transform(AST_TemplateString, function(self, tw) {
  7247. self.segments = MAP(self.segments, tw);
  7248. });
  7249. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  7250. self.prefix = self.prefix.transform(tw);
  7251. self.template_string = self.template_string.transform(tw);
  7252. });
  7253. /***********************************************************************
  7254. A JavaScript tokenizer / parser / beautifier / compressor.
  7255. https://github.com/mishoo/UglifyJS2
  7256. -------------------------------- (C) ---------------------------------
  7257. Author: Mihai Bazon
  7258. <mihai.bazon@gmail.com>
  7259. http://mihai.bazon.net/blog
  7260. Distributed under the BSD license:
  7261. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  7262. Redistribution and use in source and binary forms, with or without
  7263. modification, are permitted provided that the following conditions
  7264. are met:
  7265. * Redistributions of source code must retain the above
  7266. copyright notice, this list of conditions and the following
  7267. disclaimer.
  7268. * Redistributions in binary form must reproduce the above
  7269. copyright notice, this list of conditions and the following
  7270. disclaimer in the documentation and/or other materials
  7271. provided with the distribution.
  7272. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  7273. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7274. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  7275. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  7276. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  7277. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  7278. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  7279. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7280. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  7281. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  7282. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  7283. SUCH DAMAGE.
  7284. ***********************************************************************/
  7285. (function() {
  7286. var normalize_directives = function(body) {
  7287. for (var i = 0; i < body.length; i++) {
  7288. if (body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  7289. body[i] = new AST_Directive({
  7290. start: body[i].start,
  7291. end: body[i].end,
  7292. quote: '"',
  7293. value: body[i].body.value
  7294. });
  7295. } else {
  7296. return body;
  7297. }
  7298. }
  7299. return body;
  7300. };
  7301. function import_attributes_from_moz(attributes) {
  7302. if (attributes && attributes.length > 0) {
  7303. return new AST_Object({
  7304. start: my_start_token(attributes),
  7305. end: my_end_token(attributes),
  7306. properties: attributes.map((attr) =>
  7307. new AST_ObjectKeyVal({
  7308. start: my_start_token(attr),
  7309. end: my_end_token(attr),
  7310. key: attr.key.name || attr.key.value,
  7311. value: from_moz(attr.value)
  7312. })
  7313. )
  7314. });
  7315. }
  7316. return null;
  7317. }
  7318. var MOZ_TO_ME = {
  7319. Program: function(M) {
  7320. return new AST_Toplevel({
  7321. start: my_start_token(M),
  7322. end: my_end_token(M),
  7323. body: normalize_directives(M.body.map(from_moz))
  7324. });
  7325. },
  7326. ArrayPattern: function(M) {
  7327. return new AST_Destructuring({
  7328. start: my_start_token(M),
  7329. end: my_end_token(M),
  7330. names: M.elements.map(function(elm) {
  7331. if (elm === null) {
  7332. return new AST_Hole();
  7333. }
  7334. return from_moz(elm);
  7335. }),
  7336. is_array: true
  7337. });
  7338. },
  7339. ObjectPattern: function(M) {
  7340. return new AST_Destructuring({
  7341. start: my_start_token(M),
  7342. end: my_end_token(M),
  7343. names: M.properties.map(from_moz),
  7344. is_array: false
  7345. });
  7346. },
  7347. AssignmentPattern: function(M) {
  7348. return new AST_DefaultAssign({
  7349. start: my_start_token(M),
  7350. end: my_end_token(M),
  7351. left: from_moz(M.left),
  7352. operator: "=",
  7353. right: from_moz(M.right)
  7354. });
  7355. },
  7356. SpreadElement: function(M) {
  7357. return new AST_Expansion({
  7358. start: my_start_token(M),
  7359. end: my_end_token(M),
  7360. expression: from_moz(M.argument)
  7361. });
  7362. },
  7363. RestElement: function(M) {
  7364. return new AST_Expansion({
  7365. start: my_start_token(M),
  7366. end: my_end_token(M),
  7367. expression: from_moz(M.argument)
  7368. });
  7369. },
  7370. TemplateElement: function(M) {
  7371. return new AST_TemplateSegment({
  7372. start: my_start_token(M),
  7373. end: my_end_token(M),
  7374. value: M.value.cooked,
  7375. raw: M.value.raw
  7376. });
  7377. },
  7378. TemplateLiteral: function(M) {
  7379. var segments = [];
  7380. for (var i = 0; i < M.quasis.length; i++) {
  7381. segments.push(from_moz(M.quasis[i]));
  7382. if (M.expressions[i]) {
  7383. segments.push(from_moz(M.expressions[i]));
  7384. }
  7385. }
  7386. return new AST_TemplateString({
  7387. start: my_start_token(M),
  7388. end: my_end_token(M),
  7389. segments: segments
  7390. });
  7391. },
  7392. TaggedTemplateExpression: function(M) {
  7393. return new AST_PrefixedTemplateString({
  7394. start: my_start_token(M),
  7395. end: my_end_token(M),
  7396. template_string: from_moz(M.quasi),
  7397. prefix: from_moz(M.tag)
  7398. });
  7399. },
  7400. FunctionDeclaration: function(M) {
  7401. return new AST_Defun({
  7402. start: my_start_token(M),
  7403. end: my_end_token(M),
  7404. name: M.id && from_moz_symbol(AST_SymbolDefun, M.id),
  7405. argnames: M.params.map(M => from_moz_pattern(M, AST_SymbolFunarg)),
  7406. is_generator: M.generator,
  7407. async: M.async,
  7408. body: normalize_directives(from_moz(M.body).body)
  7409. });
  7410. },
  7411. FunctionExpression: function(M) {
  7412. return from_moz_lambda(M, /*is_method=*/false);
  7413. },
  7414. ArrowFunctionExpression: function(M) {
  7415. const body = M.body.type === "BlockStatement"
  7416. ? from_moz(M.body).body
  7417. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  7418. return new AST_Arrow({
  7419. start: my_start_token(M),
  7420. end: my_end_token(M),
  7421. argnames: M.params.map(p => from_moz_pattern(p, AST_SymbolFunarg)),
  7422. body,
  7423. async: M.async,
  7424. });
  7425. },
  7426. ExpressionStatement: function(M) {
  7427. return new AST_SimpleStatement({
  7428. start: my_start_token(M),
  7429. end: my_end_token(M),
  7430. body: from_moz(M.expression)
  7431. });
  7432. },
  7433. TryStatement: function(M) {
  7434. var handlers = M.handlers || [M.handler];
  7435. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  7436. throw new Error("Multiple catch clauses are not supported.");
  7437. }
  7438. return new AST_Try({
  7439. start : my_start_token(M),
  7440. end : my_end_token(M),
  7441. body : new AST_TryBlock(from_moz(M.block)),
  7442. bcatch : from_moz(handlers[0]),
  7443. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  7444. });
  7445. },
  7446. Property: function(M) {
  7447. if (M.kind == "init" && !M.method) {
  7448. var args = {
  7449. start : my_start_token(M.key || M.value),
  7450. end : my_end_token(M.value),
  7451. key : M.computed
  7452. ? from_moz(M.key)
  7453. : M.key.name || String(M.key.value),
  7454. quote : from_moz_quote(M.key, M.computed),
  7455. static : false, // always an object
  7456. value : from_moz(M.value)
  7457. };
  7458. return new AST_ObjectKeyVal(args);
  7459. } else {
  7460. var value = from_moz_lambda(M.value, /*is_method=*/true);
  7461. var args = {
  7462. start : my_start_token(M.key || M.value),
  7463. end : my_end_token(M.value),
  7464. key : M.computed
  7465. ? from_moz(M.key)
  7466. : from_moz_symbol(AST_SymbolMethod, M.key),
  7467. quote : from_moz_quote(M.key, M.computed),
  7468. static : false, // always an object
  7469. value,
  7470. };
  7471. if (M.kind == "get") return new AST_ObjectGetter(args);
  7472. if (M.kind == "set") return new AST_ObjectSetter(args);
  7473. if (M.method) return new AST_ConciseMethod(args);
  7474. }
  7475. },
  7476. MethodDefinition: function(M) {
  7477. const is_private = M.key.type === "PrivateIdentifier";
  7478. const key = M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || String(M.key.value) });
  7479. var args = {
  7480. start : my_start_token(M),
  7481. end : my_end_token(M),
  7482. key,
  7483. quote : from_moz_quote(M.key, M.computed),
  7484. value : from_moz_lambda(M.value, /*is_method=*/true),
  7485. static : M.static,
  7486. };
  7487. if (M.kind == "get") {
  7488. return new (is_private ? AST_PrivateGetter : AST_ObjectGetter)(args);
  7489. }
  7490. if (M.kind == "set") {
  7491. return new (is_private ? AST_PrivateSetter : AST_ObjectSetter)(args);
  7492. }
  7493. return new (is_private ? AST_PrivateMethod : AST_ConciseMethod)(args);
  7494. },
  7495. FieldDefinition: function(M) {
  7496. let key;
  7497. if (M.computed) {
  7498. key = from_moz(M.key);
  7499. } else {
  7500. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  7501. key = from_moz(M.key);
  7502. }
  7503. return new AST_ClassProperty({
  7504. start : my_start_token(M),
  7505. end : my_end_token(M),
  7506. quote : from_moz_quote(M.key, M.computed),
  7507. key,
  7508. value : from_moz(M.value),
  7509. static : M.static,
  7510. });
  7511. },
  7512. PropertyDefinition: function(M) {
  7513. let key;
  7514. if (M.computed) {
  7515. key = from_moz(M.key);
  7516. } else if (M.key.type === "PrivateIdentifier") {
  7517. return new AST_ClassPrivateProperty({
  7518. start : my_start_token(M),
  7519. end : my_end_token(M),
  7520. key : from_moz(M.key),
  7521. value : from_moz(M.value),
  7522. static : M.static,
  7523. });
  7524. } else {
  7525. key = from_moz_symbol(AST_SymbolClassProperty, M.key);
  7526. }
  7527. return new AST_ClassProperty({
  7528. start : my_start_token(M),
  7529. end : my_end_token(M),
  7530. quote : from_moz_quote(M.key, M.computed),
  7531. key,
  7532. value : from_moz(M.value),
  7533. static : M.static,
  7534. });
  7535. },
  7536. PrivateIdentifier: function (M) {
  7537. return new AST_SymbolPrivateProperty({
  7538. start: my_start_token(M),
  7539. end: my_end_token(M),
  7540. name: M.name
  7541. });
  7542. },
  7543. StaticBlock: function(M) {
  7544. return new AST_ClassStaticBlock({
  7545. start : my_start_token(M),
  7546. end : my_end_token(M),
  7547. body : M.body.map(from_moz),
  7548. });
  7549. },
  7550. ArrayExpression: function(M) {
  7551. return new AST_Array({
  7552. start : my_start_token(M),
  7553. end : my_end_token(M),
  7554. elements : M.elements.map(function(elem) {
  7555. return elem === null ? new AST_Hole() : from_moz(elem);
  7556. })
  7557. });
  7558. },
  7559. ObjectExpression: function(M) {
  7560. return new AST_Object({
  7561. start : my_start_token(M),
  7562. end : my_end_token(M),
  7563. properties : M.properties.map(function(prop) {
  7564. if (prop.type === "SpreadElement") {
  7565. return from_moz(prop);
  7566. }
  7567. prop.type = "Property";
  7568. return from_moz(prop);
  7569. })
  7570. });
  7571. },
  7572. SequenceExpression: function(M) {
  7573. return new AST_Sequence({
  7574. start : my_start_token(M),
  7575. end : my_end_token(M),
  7576. expressions: M.expressions.map(from_moz)
  7577. });
  7578. },
  7579. MemberExpression: function(M) {
  7580. if (M.property.type === "PrivateIdentifier") {
  7581. return new AST_DotHash({
  7582. start : my_start_token(M),
  7583. end : my_end_token(M),
  7584. property : M.property.name,
  7585. expression : from_moz(M.object),
  7586. optional : M.optional || false
  7587. });
  7588. }
  7589. return new (M.computed ? AST_Sub : AST_Dot)({
  7590. start : my_start_token(M),
  7591. end : my_end_token(M),
  7592. property : M.computed ? from_moz(M.property) : M.property.name,
  7593. expression : from_moz(M.object),
  7594. optional : M.optional || false
  7595. });
  7596. },
  7597. ChainExpression: function(M) {
  7598. return new AST_Chain({
  7599. start : my_start_token(M),
  7600. end : my_end_token(M),
  7601. expression : from_moz(M.expression)
  7602. });
  7603. },
  7604. SwitchCase: function(M) {
  7605. return new (M.test ? AST_Case : AST_Default)({
  7606. start : my_start_token(M),
  7607. end : my_end_token(M),
  7608. expression : from_moz(M.test),
  7609. body : M.consequent.map(from_moz)
  7610. });
  7611. },
  7612. VariableDeclaration: function(M) {
  7613. let decl_type;
  7614. let defs_type = AST_VarDef;
  7615. let sym_type;
  7616. let await_using = false;
  7617. if (M.kind === "const") {
  7618. decl_type = AST_Const;
  7619. sym_type = AST_SymbolConst;
  7620. } else if (M.kind === "let") {
  7621. decl_type = AST_Let;
  7622. sym_type = AST_SymbolLet;
  7623. } else if (M.kind === "using") {
  7624. decl_type = AST_Using;
  7625. defs_type = AST_UsingDef;
  7626. sym_type = AST_SymbolUsing;
  7627. } else if (M.kind === "await using") {
  7628. decl_type = AST_Using;
  7629. defs_type = AST_UsingDef;
  7630. sym_type = AST_SymbolUsing;
  7631. await_using = true;
  7632. } else {
  7633. decl_type = AST_Var;
  7634. sym_type = AST_SymbolVar;
  7635. }
  7636. const definitions = M.declarations.map(M => {
  7637. return new defs_type({
  7638. start: my_start_token(M),
  7639. end: my_end_token(M),
  7640. name: from_moz_pattern(M.id, sym_type),
  7641. value: from_moz(M.init),
  7642. });
  7643. });
  7644. return new decl_type({
  7645. start : my_start_token(M),
  7646. end : my_end_token(M),
  7647. definitions : definitions,
  7648. await : await_using,
  7649. });
  7650. },
  7651. ImportDeclaration: function(M) {
  7652. var imported_name = null;
  7653. var imported_names = null;
  7654. M.specifiers.forEach(function (specifier) {
  7655. if (specifier.type === "ImportSpecifier" || specifier.type === "ImportNamespaceSpecifier") {
  7656. if (!imported_names) { imported_names = []; }
  7657. imported_names.push(from_moz(specifier));
  7658. } else if (specifier.type === "ImportDefaultSpecifier") {
  7659. imported_name = from_moz(specifier);
  7660. }
  7661. });
  7662. return new AST_Import({
  7663. start : my_start_token(M),
  7664. end : my_end_token(M),
  7665. imported_name: imported_name,
  7666. imported_names : imported_names,
  7667. module_name : from_moz(M.source),
  7668. attributes: import_attributes_from_moz(M.attributes || M.assertions),
  7669. phase: M.phase || null
  7670. });
  7671. },
  7672. ImportSpecifier: function(M) {
  7673. return new AST_NameMapping({
  7674. start: my_start_token(M),
  7675. end: my_end_token(M),
  7676. foreign_name: from_moz_symbol(AST_SymbolImportForeign, M.imported, M.imported.type === "Literal"),
  7677. name: from_moz_symbol(AST_SymbolImport, M.local)
  7678. });
  7679. },
  7680. ImportDefaultSpecifier: function(M) {
  7681. return from_moz_symbol(AST_SymbolImport, M.local);
  7682. },
  7683. ImportNamespaceSpecifier: function(M) {
  7684. return new AST_NameMapping({
  7685. start: my_start_token(M),
  7686. end: my_end_token(M),
  7687. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  7688. name: from_moz_symbol(AST_SymbolImport, M.local)
  7689. });
  7690. },
  7691. ImportExpression: function(M) {
  7692. const args = [from_moz(M.source)];
  7693. if (M.options) {
  7694. args.push(from_moz(M.options));
  7695. }
  7696. return new AST_DynamicImport({
  7697. start: my_start_token(M),
  7698. end: my_end_token(M),
  7699. phase: M.phase,
  7700. args: args,
  7701. });
  7702. },
  7703. ExportAllDeclaration: function(M) {
  7704. var foreign_name = M.exported == null ?
  7705. new AST_SymbolExportForeign({ name: "*" }) :
  7706. from_moz_symbol(AST_SymbolExportForeign, M.exported, M.exported.type === "Literal");
  7707. return new AST_Export({
  7708. start: my_start_token(M),
  7709. end: my_end_token(M),
  7710. exported_names: [
  7711. new AST_NameMapping({
  7712. start: my_start_token(M),
  7713. end: my_end_token(M),
  7714. name: new AST_SymbolExport({ name: "*" }),
  7715. foreign_name: foreign_name
  7716. })
  7717. ],
  7718. module_name: from_moz(M.source),
  7719. attributes: import_attributes_from_moz(M.attributes || M.assertions)
  7720. });
  7721. },
  7722. ExportNamedDeclaration: function(M) {
  7723. if (M.declaration) {
  7724. // export const, export function, ...
  7725. return new AST_Export({
  7726. start: my_start_token(M),
  7727. end: my_end_token(M),
  7728. exported_definition: from_moz(M.declaration),
  7729. exported_names: null,
  7730. module_name: null,
  7731. attributes: null,
  7732. });
  7733. } else {
  7734. return new AST_Export({
  7735. start: my_start_token(M),
  7736. end: my_end_token(M),
  7737. exported_definition: null,
  7738. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : [],
  7739. module_name: from_moz(M.source),
  7740. attributes: import_attributes_from_moz(M.attributes || M.assertions),
  7741. });
  7742. }
  7743. },
  7744. ExportDefaultDeclaration: function(M) {
  7745. return new AST_Export({
  7746. start: my_start_token(M),
  7747. end: my_end_token(M),
  7748. exported_value: from_moz(M.declaration),
  7749. is_default: true
  7750. });
  7751. },
  7752. ExportSpecifier: function(M) {
  7753. return new AST_NameMapping({
  7754. start: my_start_token(M),
  7755. end: my_end_token(M),
  7756. foreign_name: from_moz_symbol(AST_SymbolExportForeign, M.exported, M.exported.type === "Literal"),
  7757. name: from_moz_symbol(AST_SymbolExport, M.local, M.local.type === "Literal"),
  7758. });
  7759. },
  7760. Literal: function(M) {
  7761. var val = M.value, args = {
  7762. start : my_start_token(M),
  7763. end : my_end_token(M)
  7764. };
  7765. var rx = M.regex;
  7766. if (rx && rx.pattern) {
  7767. // RegExpLiteral as per ESTree AST spec
  7768. args.value = {
  7769. source: rx.pattern,
  7770. flags: rx.flags
  7771. };
  7772. return new AST_RegExp(args);
  7773. } else if (rx) {
  7774. // support legacy RegExp
  7775. const rx_source = M.raw || val;
  7776. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  7777. if (!match) throw new Error("Invalid regex source " + rx_source);
  7778. const [_, source, flags] = match;
  7779. args.value = { source, flags };
  7780. return new AST_RegExp(args);
  7781. }
  7782. const bi = typeof M.value === "bigint" ? M.value.toString() : M.bigint;
  7783. if (typeof bi === "string") {
  7784. args.value = bi;
  7785. args.raw = M.raw;
  7786. return new AST_BigInt(args);
  7787. }
  7788. if (val === null) return new AST_Null(args);
  7789. switch (typeof val) {
  7790. case "string":
  7791. args.quote = "\"";
  7792. args.value = val;
  7793. return new AST_String(args);
  7794. case "number":
  7795. args.value = val;
  7796. args.raw = M.raw || val.toString();
  7797. return new AST_Number(args);
  7798. case "boolean":
  7799. return new (val ? AST_True : AST_False)(args);
  7800. }
  7801. },
  7802. MetaProperty: function(M) {
  7803. if (M.meta.name === "new" && M.property.name === "target") {
  7804. return new AST_NewTarget({
  7805. start: my_start_token(M),
  7806. end: my_end_token(M)
  7807. });
  7808. } else if (M.meta.name === "import" && M.property.name === "meta") {
  7809. return new AST_ImportMeta({
  7810. start: my_start_token(M),
  7811. end: my_end_token(M)
  7812. });
  7813. }
  7814. },
  7815. Identifier: function(M) {
  7816. return new AST_SymbolRef({
  7817. start : my_start_token(M),
  7818. end : my_end_token(M),
  7819. name : M.name
  7820. });
  7821. },
  7822. EmptyStatement: function(M) {
  7823. return new AST_EmptyStatement({
  7824. start: my_start_token(M),
  7825. end: my_end_token(M)
  7826. });
  7827. },
  7828. BlockStatement: function(M) {
  7829. return new AST_BlockStatement({
  7830. start: my_start_token(M),
  7831. end: my_end_token(M),
  7832. body: M.body.map(from_moz)
  7833. });
  7834. },
  7835. IfStatement: function(M) {
  7836. return new AST_If({
  7837. start: my_start_token(M),
  7838. end: my_end_token(M),
  7839. condition: from_moz(M.test),
  7840. body: from_moz(M.consequent),
  7841. alternative: from_moz(M.alternate)
  7842. });
  7843. },
  7844. LabeledStatement: function(M) {
  7845. try {
  7846. const label = from_moz_symbol(AST_Label, M.label);
  7847. FROM_MOZ_LABELS.push(label);
  7848. const stat = new AST_LabeledStatement({
  7849. start: my_start_token(M),
  7850. end: my_end_token(M),
  7851. label,
  7852. body: from_moz(M.body)
  7853. });
  7854. return stat;
  7855. } finally {
  7856. FROM_MOZ_LABELS.pop();
  7857. }
  7858. },
  7859. BreakStatement: function(M) {
  7860. return new AST_Break({
  7861. start: my_start_token(M),
  7862. end: my_end_token(M),
  7863. label: from_moz_label_ref(M.label),
  7864. });
  7865. },
  7866. ContinueStatement: function(M) {
  7867. return new AST_Continue({
  7868. start: my_start_token(M),
  7869. end: my_end_token(M),
  7870. label: from_moz_label_ref(M.label),
  7871. });
  7872. },
  7873. WithStatement: function(M) {
  7874. return new AST_With({
  7875. start: my_start_token(M),
  7876. end: my_end_token(M),
  7877. expression: from_moz(M.object),
  7878. body: from_moz(M.body)
  7879. });
  7880. },
  7881. SwitchStatement: function(M) {
  7882. return new AST_Switch({
  7883. start: my_start_token(M),
  7884. end: my_end_token(M),
  7885. expression: from_moz(M.discriminant),
  7886. body: M.cases.map(from_moz)
  7887. });
  7888. },
  7889. ReturnStatement: function(M) {
  7890. return new AST_Return({
  7891. start: my_start_token(M),
  7892. end: my_end_token(M),
  7893. value: from_moz(M.argument)
  7894. });
  7895. },
  7896. ThrowStatement: function(M) {
  7897. return new AST_Throw({
  7898. start: my_start_token(M),
  7899. end: my_end_token(M),
  7900. value: from_moz(M.argument)
  7901. });
  7902. },
  7903. WhileStatement: function(M) {
  7904. return new AST_While({
  7905. start: my_start_token(M),
  7906. end: my_end_token(M),
  7907. condition: from_moz(M.test),
  7908. body: from_moz(M.body)
  7909. });
  7910. },
  7911. DoWhileStatement: function(M) {
  7912. return new AST_Do({
  7913. start: my_start_token(M),
  7914. end: my_end_token(M),
  7915. condition: from_moz(M.test),
  7916. body: from_moz(M.body)
  7917. });
  7918. },
  7919. ForStatement: function(M) {
  7920. return new AST_For({
  7921. start: my_start_token(M),
  7922. end: my_end_token(M),
  7923. init: from_moz(M.init),
  7924. condition: from_moz(M.test),
  7925. step: from_moz(M.update),
  7926. body: from_moz(M.body)
  7927. });
  7928. },
  7929. ForInStatement: function(M) {
  7930. return new AST_ForIn({
  7931. start: my_start_token(M),
  7932. end: my_end_token(M),
  7933. init: from_moz(M.left),
  7934. object: from_moz(M.right),
  7935. body: from_moz(M.body)
  7936. });
  7937. },
  7938. ForOfStatement: function(M) {
  7939. return new AST_ForOf({
  7940. start: my_start_token(M),
  7941. end: my_end_token(M),
  7942. init: from_moz(M.left),
  7943. object: from_moz(M.right),
  7944. body: from_moz(M.body),
  7945. await: M.await
  7946. });
  7947. },
  7948. AwaitExpression: function(M) {
  7949. return new AST_Await({
  7950. start: my_start_token(M),
  7951. end: my_end_token(M),
  7952. expression: from_moz(M.argument)
  7953. });
  7954. },
  7955. YieldExpression: function(M) {
  7956. return new AST_Yield({
  7957. start: my_start_token(M),
  7958. end: my_end_token(M),
  7959. expression: from_moz(M.argument),
  7960. is_star: M.delegate
  7961. });
  7962. },
  7963. DebuggerStatement: function(M) {
  7964. return new AST_Debugger({
  7965. start: my_start_token(M),
  7966. end: my_end_token(M)
  7967. });
  7968. },
  7969. CatchClause: function(M) {
  7970. return new AST_Catch({
  7971. start: my_start_token(M),
  7972. end: my_end_token(M),
  7973. argname: M.param ? from_moz_pattern(M.param, AST_SymbolCatch) : null,
  7974. body: from_moz(M.body).body
  7975. });
  7976. },
  7977. ThisExpression: function(M) {
  7978. return new AST_This({
  7979. start: my_start_token(M),
  7980. name: "this",
  7981. end: my_end_token(M)
  7982. });
  7983. },
  7984. Super: function(M) {
  7985. return new AST_Super({
  7986. start: my_start_token(M),
  7987. end: my_end_token(M),
  7988. name: "super",
  7989. });
  7990. },
  7991. BinaryExpression: function(M) {
  7992. if (M.left.type === "PrivateIdentifier") {
  7993. return new AST_PrivateIn({
  7994. start: my_start_token(M),
  7995. end: my_end_token(M),
  7996. key: new AST_SymbolPrivateProperty({
  7997. start: my_start_token(M.left),
  7998. end: my_end_token(M.left),
  7999. name: M.left.name
  8000. }),
  8001. value: from_moz(M.right),
  8002. });
  8003. }
  8004. return new AST_Binary({
  8005. start: my_start_token(M),
  8006. end: my_end_token(M),
  8007. operator: M.operator,
  8008. left: from_moz(M.left),
  8009. right: from_moz(M.right)
  8010. });
  8011. },
  8012. LogicalExpression: function(M) {
  8013. return new AST_Binary({
  8014. start: my_start_token(M),
  8015. end: my_end_token(M),
  8016. operator: M.operator,
  8017. left: from_moz(M.left),
  8018. right: from_moz(M.right)
  8019. });
  8020. },
  8021. AssignmentExpression: function(M) {
  8022. return new AST_Assign({
  8023. start: my_start_token(M),
  8024. end: my_end_token(M),
  8025. operator: M.operator,
  8026. logical: M.operator === "??=" || M.operator === "&&=" || M.operator === "||=",
  8027. left: from_moz(M.left),
  8028. right: from_moz(M.right)
  8029. });
  8030. },
  8031. ConditionalExpression: function(M) {
  8032. return new AST_Conditional({
  8033. start: my_start_token(M),
  8034. end: my_end_token(M),
  8035. condition: from_moz(M.test),
  8036. consequent: from_moz(M.consequent),
  8037. alternative: from_moz(M.alternate)
  8038. });
  8039. },
  8040. NewExpression: function(M) {
  8041. return new AST_New({
  8042. start: my_start_token(M),
  8043. end: my_end_token(M),
  8044. expression: from_moz(M.callee),
  8045. args: M.arguments.map(from_moz)
  8046. });
  8047. },
  8048. CallExpression: function(M) {
  8049. return new AST_Call({
  8050. start: my_start_token(M),
  8051. end: my_end_token(M),
  8052. expression: from_moz(M.callee),
  8053. optional: M.optional,
  8054. args: M.arguments.map(from_moz)
  8055. });
  8056. }
  8057. };
  8058. MOZ_TO_ME.UpdateExpression =
  8059. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  8060. var prefix = "prefix" in M ? M.prefix
  8061. : M.type == "UnaryExpression" ? true : false;
  8062. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  8063. start : my_start_token(M),
  8064. end : my_end_token(M),
  8065. operator : M.operator,
  8066. expression : from_moz(M.argument)
  8067. });
  8068. };
  8069. MOZ_TO_ME.ClassDeclaration =
  8070. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  8071. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  8072. start : my_start_token(M),
  8073. end : my_end_token(M),
  8074. name : M.id && from_moz_symbol(M.type === "ClassDeclaration" ? AST_SymbolDefClass : AST_SymbolClass, M.id),
  8075. extends : from_moz(M.superClass),
  8076. properties: M.body.body.map(from_moz)
  8077. });
  8078. };
  8079. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  8080. return {
  8081. type: "EmptyStatement"
  8082. };
  8083. });
  8084. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  8085. return {
  8086. type: "BlockStatement",
  8087. body: M.body.map(to_moz)
  8088. };
  8089. });
  8090. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  8091. return {
  8092. type: "IfStatement",
  8093. test: to_moz(M.condition),
  8094. consequent: to_moz(M.body),
  8095. alternate: to_moz(M.alternative)
  8096. };
  8097. });
  8098. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  8099. return {
  8100. type: "LabeledStatement",
  8101. label: to_moz(M.label),
  8102. body: to_moz(M.body)
  8103. };
  8104. });
  8105. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  8106. return {
  8107. type: "BreakStatement",
  8108. label: to_moz(M.label)
  8109. };
  8110. });
  8111. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  8112. return {
  8113. type: "ContinueStatement",
  8114. label: to_moz(M.label)
  8115. };
  8116. });
  8117. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  8118. return {
  8119. type: "WithStatement",
  8120. object: to_moz(M.expression),
  8121. body: to_moz(M.body)
  8122. };
  8123. });
  8124. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  8125. return {
  8126. type: "SwitchStatement",
  8127. discriminant: to_moz(M.expression),
  8128. cases: M.body.map(to_moz)
  8129. };
  8130. });
  8131. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  8132. return {
  8133. type: "ReturnStatement",
  8134. argument: to_moz(M.value)
  8135. };
  8136. });
  8137. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  8138. return {
  8139. type: "ThrowStatement",
  8140. argument: to_moz(M.value)
  8141. };
  8142. });
  8143. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  8144. return {
  8145. type: "WhileStatement",
  8146. test: to_moz(M.condition),
  8147. body: to_moz(M.body)
  8148. };
  8149. });
  8150. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  8151. return {
  8152. type: "DoWhileStatement",
  8153. test: to_moz(M.condition),
  8154. body: to_moz(M.body)
  8155. };
  8156. });
  8157. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  8158. return {
  8159. type: "ForStatement",
  8160. init: to_moz(M.init),
  8161. test: to_moz(M.condition),
  8162. update: to_moz(M.step),
  8163. body: to_moz(M.body)
  8164. };
  8165. });
  8166. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  8167. return {
  8168. type: "ForInStatement",
  8169. left: to_moz(M.init),
  8170. right: to_moz(M.object),
  8171. body: to_moz(M.body)
  8172. };
  8173. });
  8174. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  8175. return {
  8176. type: "ForOfStatement",
  8177. left: to_moz(M.init),
  8178. right: to_moz(M.object),
  8179. body: to_moz(M.body),
  8180. await: M.await
  8181. };
  8182. });
  8183. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  8184. return {
  8185. type: "AwaitExpression",
  8186. argument: to_moz(M.expression)
  8187. };
  8188. });
  8189. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  8190. return {
  8191. type: "YieldExpression",
  8192. argument: to_moz(M.expression),
  8193. delegate: M.is_star
  8194. };
  8195. });
  8196. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  8197. return {
  8198. type: "DebuggerStatement"
  8199. };
  8200. });
  8201. def_to_moz(AST_VarDefLike, function To_Moz_VariableDeclarator(M) {
  8202. return {
  8203. type: "VariableDeclarator",
  8204. id: to_moz(M.name),
  8205. init: to_moz(M.value)
  8206. };
  8207. });
  8208. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  8209. return {
  8210. type: "ThisExpression"
  8211. };
  8212. });
  8213. def_to_moz(AST_Super, function To_Moz_Super() {
  8214. return {
  8215. type: "Super"
  8216. };
  8217. });
  8218. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  8219. return {
  8220. type: "ConditionalExpression",
  8221. test: to_moz(M.condition),
  8222. consequent: to_moz(M.consequent),
  8223. alternate: to_moz(M.alternative)
  8224. };
  8225. });
  8226. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  8227. return {
  8228. type: "NewExpression",
  8229. callee: to_moz(M.expression),
  8230. arguments: M.args.map(to_moz)
  8231. };
  8232. });
  8233. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  8234. return {
  8235. type: "CallExpression",
  8236. callee: to_moz(M.expression),
  8237. optional: M.optional,
  8238. arguments: M.args.map(to_moz)
  8239. };
  8240. });
  8241. def_to_moz(AST_DynamicImport, function To_Moz_ImportExpression(M) {
  8242. const [source, options] = M.args.map(to_moz);
  8243. return {
  8244. type: "ImportExpression",
  8245. source,
  8246. options: options || null,
  8247. phase: M.phase
  8248. };
  8249. });
  8250. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  8251. return to_moz_scope("Program", M);
  8252. });
  8253. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  8254. return {
  8255. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  8256. argument: to_moz(M.expression)
  8257. };
  8258. });
  8259. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  8260. return {
  8261. type: "TaggedTemplateExpression",
  8262. tag: to_moz(M.prefix),
  8263. quasi: to_moz(M.template_string)
  8264. };
  8265. });
  8266. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  8267. var quasis = [];
  8268. var expressions = [];
  8269. for (var i = 0; i < M.segments.length; i++) {
  8270. if (i % 2 !== 0) {
  8271. expressions.push(to_moz(M.segments[i]));
  8272. } else {
  8273. quasis.push({
  8274. type: "TemplateElement",
  8275. value: {
  8276. raw: M.segments[i].raw,
  8277. cooked: M.segments[i].value
  8278. },
  8279. tail: i === M.segments.length - 1
  8280. });
  8281. }
  8282. }
  8283. return {
  8284. type: "TemplateLiteral",
  8285. quasis: quasis,
  8286. expressions: expressions
  8287. };
  8288. });
  8289. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  8290. return {
  8291. type: "FunctionDeclaration",
  8292. id: to_moz(M.name),
  8293. params: M.argnames.map(to_moz_pattern),
  8294. generator: M.is_generator,
  8295. async: M.async,
  8296. body: to_moz_scope("BlockStatement", M)
  8297. };
  8298. });
  8299. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M) {
  8300. return {
  8301. type: "FunctionExpression",
  8302. id: to_moz(M.name),
  8303. params: M.argnames.map(to_moz_pattern),
  8304. generator: M.is_generator || false,
  8305. async: M.async || false,
  8306. body: to_moz_scope("BlockStatement", M)
  8307. };
  8308. });
  8309. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  8310. var body = M.body.length === 1 && M.body[0] instanceof AST_Return && M.body[0].value
  8311. ? to_moz(M.body[0].value)
  8312. : {
  8313. type: "BlockStatement",
  8314. body: M.body.map(to_moz)
  8315. };
  8316. return {
  8317. type: "ArrowFunctionExpression",
  8318. params: M.argnames.map(to_moz_pattern),
  8319. async: M.async,
  8320. body: body,
  8321. };
  8322. });
  8323. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  8324. if (M.is_array) {
  8325. return {
  8326. type: "ArrayPattern",
  8327. elements: M.names.map(
  8328. M => M instanceof AST_Hole ? null : to_moz_pattern(M)
  8329. ),
  8330. };
  8331. }
  8332. return {
  8333. type: "ObjectPattern",
  8334. properties: M.names.map(M => {
  8335. if (M instanceof AST_ObjectKeyVal) {
  8336. var computed = M.computed_key();
  8337. const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  8338. return {
  8339. type: "Property",
  8340. computed,
  8341. kind: "init",
  8342. key: key,
  8343. method: false,
  8344. shorthand,
  8345. value: to_moz_pattern(M.value)
  8346. };
  8347. } else {
  8348. return to_moz_pattern(M);
  8349. }
  8350. }),
  8351. };
  8352. });
  8353. def_to_moz(AST_DefaultAssign, function To_Moz_AssignmentExpression(M) {
  8354. return {
  8355. type: "AssignmentPattern",
  8356. left: to_moz_pattern(M.left),
  8357. right: to_moz(M.right),
  8358. };
  8359. });
  8360. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  8361. return {
  8362. type: "ExpressionStatement",
  8363. expression: {
  8364. type: "Literal",
  8365. value: M.value,
  8366. raw: M.print_to_string()
  8367. },
  8368. directive: M.value
  8369. };
  8370. });
  8371. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  8372. return {
  8373. type: "ExpressionStatement",
  8374. expression: to_moz(M.body)
  8375. };
  8376. });
  8377. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  8378. return {
  8379. type: "SwitchCase",
  8380. test: to_moz(M.expression),
  8381. consequent: M.body.map(to_moz)
  8382. };
  8383. });
  8384. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  8385. return {
  8386. type: "TryStatement",
  8387. block: to_moz_block(M.body),
  8388. handler: to_moz(M.bcatch),
  8389. guardedHandlers: [],
  8390. finalizer: to_moz(M.bfinally)
  8391. };
  8392. });
  8393. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  8394. return {
  8395. type: "CatchClause",
  8396. param: M.argname != null ? to_moz_pattern(M.argname) : null,
  8397. body: to_moz_block(M)
  8398. };
  8399. });
  8400. def_to_moz(AST_DefinitionsLike, function To_Moz_VariableDeclaration(M) {
  8401. return {
  8402. type: "VariableDeclaration",
  8403. kind:
  8404. M instanceof AST_Const ? "const" :
  8405. M instanceof AST_Let ? "let" :
  8406. M instanceof AST_Using ? (M.await ? "await using" : "using") :
  8407. "var",
  8408. declarations: M.definitions.map(to_moz)
  8409. };
  8410. });
  8411. function import_attributes_to_moz(attribute) {
  8412. const import_attributes = [];
  8413. if (attribute) {
  8414. for (const { key, value } of attribute.properties) {
  8415. const key_moz = is_basic_identifier_string(key)
  8416. ? { type: "Identifier", name: key }
  8417. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  8418. import_attributes.push({
  8419. type: "ImportAttribute",
  8420. key: key_moz,
  8421. value: to_moz(value)
  8422. });
  8423. }
  8424. }
  8425. return import_attributes;
  8426. }
  8427. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  8428. if (M.exported_names) {
  8429. var first_exported = M.exported_names[0];
  8430. if (first_exported && first_exported.name.name === "*" && !first_exported.name.quote) {
  8431. var foreign_name = first_exported.foreign_name;
  8432. var exported = foreign_name.name === "*" && !foreign_name.quote
  8433. ? null
  8434. : to_moz(foreign_name);
  8435. return {
  8436. type: "ExportAllDeclaration",
  8437. source: to_moz(M.module_name),
  8438. exported: exported,
  8439. attributes: import_attributes_to_moz(M.attributes)
  8440. };
  8441. }
  8442. return {
  8443. type: "ExportNamedDeclaration",
  8444. specifiers: M.exported_names.map(function (name_mapping) {
  8445. return {
  8446. type: "ExportSpecifier",
  8447. exported: to_moz(name_mapping.foreign_name),
  8448. local: to_moz(name_mapping.name)
  8449. };
  8450. }),
  8451. declaration: to_moz(M.exported_definition),
  8452. source: to_moz(M.module_name),
  8453. attributes: import_attributes_to_moz(M.attributes)
  8454. };
  8455. }
  8456. if (M.is_default) {
  8457. return {
  8458. type: "ExportDefaultDeclaration",
  8459. declaration: to_moz(M.exported_value || M.exported_definition),
  8460. };
  8461. } else {
  8462. return {
  8463. type: "ExportNamedDeclaration",
  8464. declaration: to_moz(M.exported_value || M.exported_definition),
  8465. specifiers: [],
  8466. source: null,
  8467. };
  8468. }
  8469. });
  8470. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  8471. var specifiers = [];
  8472. if (M.imported_name) {
  8473. specifiers.push({
  8474. type: "ImportDefaultSpecifier",
  8475. local: to_moz(M.imported_name)
  8476. });
  8477. }
  8478. if (M.imported_names) {
  8479. var first_foreign_name = M.imported_names[0] && M.imported_names[0].foreign_name;
  8480. if (first_foreign_name && first_foreign_name.name === "*" && !first_foreign_name.quote) {
  8481. specifiers.push({
  8482. type: "ImportNamespaceSpecifier",
  8483. local: to_moz(M.imported_names[0].name)
  8484. });
  8485. } else {
  8486. M.imported_names.forEach(function(name_mapping) {
  8487. specifiers.push({
  8488. type: "ImportSpecifier",
  8489. local: to_moz(name_mapping.name),
  8490. imported: to_moz(name_mapping.foreign_name)
  8491. });
  8492. });
  8493. }
  8494. }
  8495. var moz = {
  8496. type: "ImportDeclaration",
  8497. specifiers: specifiers,
  8498. source: to_moz(M.module_name),
  8499. attributes: import_attributes_to_moz(M.attributes)
  8500. };
  8501. if (M.phase) moz.phase = M.phase;
  8502. return moz;
  8503. });
  8504. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  8505. return {
  8506. type: "MetaProperty",
  8507. meta: {
  8508. type: "Identifier",
  8509. name: "import"
  8510. },
  8511. property: {
  8512. type: "Identifier",
  8513. name: "meta"
  8514. }
  8515. };
  8516. });
  8517. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  8518. return {
  8519. type: "SequenceExpression",
  8520. expressions: M.expressions.map(to_moz)
  8521. };
  8522. });
  8523. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  8524. return {
  8525. type: "MemberExpression",
  8526. object: to_moz(M.expression),
  8527. computed: false,
  8528. property: {
  8529. type: "PrivateIdentifier",
  8530. name: M.property
  8531. },
  8532. optional: M.optional
  8533. };
  8534. });
  8535. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  8536. var isComputed = M instanceof AST_Sub;
  8537. return {
  8538. type: "MemberExpression",
  8539. object: to_moz(M.expression),
  8540. computed: isComputed,
  8541. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  8542. optional: M.optional
  8543. };
  8544. });
  8545. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  8546. return {
  8547. type: "ChainExpression",
  8548. expression: to_moz(M.expression)
  8549. };
  8550. });
  8551. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  8552. return {
  8553. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  8554. operator: M.operator,
  8555. prefix: M instanceof AST_UnaryPrefix,
  8556. argument: to_moz(M.expression)
  8557. };
  8558. });
  8559. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  8560. if (M.operator == "=" && to_moz_in_destructuring()) {
  8561. return {
  8562. type: "AssignmentPattern",
  8563. left: to_moz(M.left),
  8564. right: to_moz(M.right)
  8565. };
  8566. }
  8567. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  8568. ? "LogicalExpression"
  8569. : "BinaryExpression";
  8570. return {
  8571. type,
  8572. left: to_moz(M.left),
  8573. operator: M.operator,
  8574. right: to_moz(M.right)
  8575. };
  8576. });
  8577. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  8578. return {
  8579. type: "AssignmentExpression",
  8580. operator: M.operator,
  8581. left: to_moz(M.left),
  8582. right: to_moz(M.right)
  8583. };
  8584. });
  8585. def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
  8586. return {
  8587. type: "BinaryExpression",
  8588. left: { type: "PrivateIdentifier", name: M.key.name },
  8589. operator: "in",
  8590. right: to_moz(M.value),
  8591. };
  8592. });
  8593. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  8594. return {
  8595. type: "ArrayExpression",
  8596. elements: M.elements.map(to_moz)
  8597. };
  8598. });
  8599. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  8600. return {
  8601. type: "ObjectExpression",
  8602. properties: M.properties.map(to_moz)
  8603. };
  8604. });
  8605. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  8606. var computed = M.computed_key();
  8607. const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  8608. var kind;
  8609. if (M instanceof AST_ObjectGetter) {
  8610. kind = "get";
  8611. } else
  8612. if (M instanceof AST_ObjectSetter) {
  8613. kind = "set";
  8614. }
  8615. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  8616. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  8617. return {
  8618. type: "MethodDefinition",
  8619. computed: false,
  8620. kind: kind,
  8621. static: M.static,
  8622. key: {
  8623. type: "PrivateIdentifier",
  8624. name: M.key.name
  8625. },
  8626. value: to_moz(M.value)
  8627. };
  8628. }
  8629. if (M instanceof AST_ClassPrivateProperty) {
  8630. return {
  8631. type: "PropertyDefinition",
  8632. key: {
  8633. type: "PrivateIdentifier",
  8634. name: M.key.name
  8635. },
  8636. value: to_moz(M.value),
  8637. computed: false,
  8638. static: M.static
  8639. };
  8640. }
  8641. if (M instanceof AST_ClassProperty) {
  8642. return {
  8643. type: "PropertyDefinition",
  8644. key,
  8645. value: to_moz(M.value),
  8646. computed,
  8647. static: M.static
  8648. };
  8649. }
  8650. if (parent instanceof AST_Class) {
  8651. return {
  8652. type: "MethodDefinition",
  8653. computed: computed,
  8654. kind: kind,
  8655. static: M.static,
  8656. key: to_moz(M.key),
  8657. value: to_moz(M.value)
  8658. };
  8659. }
  8660. return {
  8661. type: "Property",
  8662. computed: computed,
  8663. method: false,
  8664. shorthand,
  8665. kind: kind,
  8666. key: key,
  8667. value: to_moz(M.value)
  8668. };
  8669. });
  8670. def_to_moz(AST_ObjectKeyVal, function To_Moz_Property(M) {
  8671. var computed = M.computed_key();
  8672. const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  8673. return {
  8674. type: "Property",
  8675. computed: computed,
  8676. shorthand: shorthand,
  8677. method: false,
  8678. kind: "init",
  8679. key: key,
  8680. value: to_moz(M.value)
  8681. };
  8682. });
  8683. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  8684. const computed = M.computed_key();
  8685. const [_always_false, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  8686. if (parent instanceof AST_Object) {
  8687. return {
  8688. type: "Property",
  8689. kind: "init",
  8690. computed,
  8691. method: true,
  8692. shorthand: false,
  8693. key,
  8694. value: to_moz(M.value),
  8695. };
  8696. }
  8697. return {
  8698. type: "MethodDefinition",
  8699. kind: !computed && M.key.name === "constructor" ? "constructor" : "method",
  8700. computed,
  8701. key,
  8702. value: to_moz(M.value),
  8703. static: M.static,
  8704. };
  8705. });
  8706. def_to_moz(AST_PrivateMethod, function To_Moz_MethodDefinition(M) {
  8707. return {
  8708. type: "MethodDefinition",
  8709. kind: "method",
  8710. key: { type: "PrivateIdentifier", name: M.key.name },
  8711. value: to_moz(M.value),
  8712. computed: false,
  8713. static: M.static,
  8714. };
  8715. });
  8716. def_to_moz(AST_Class, function To_Moz_Class(M) {
  8717. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  8718. return {
  8719. type: type,
  8720. superClass: to_moz(M.extends),
  8721. id: M.name ? to_moz(M.name) : null,
  8722. body: {
  8723. type: "ClassBody",
  8724. body: M.properties.map(to_moz)
  8725. }
  8726. };
  8727. });
  8728. def_to_moz(AST_ClassStaticBlock, function To_Moz_StaticBlock(M) {
  8729. return {
  8730. type: "StaticBlock",
  8731. body: M.body.map(to_moz),
  8732. };
  8733. });
  8734. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  8735. return {
  8736. type: "MetaProperty",
  8737. meta: {
  8738. type: "Identifier",
  8739. name: "new"
  8740. },
  8741. property: {
  8742. type: "Identifier",
  8743. name: "target"
  8744. }
  8745. };
  8746. });
  8747. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  8748. if (
  8749. (M instanceof AST_SymbolMethod && parent.quote) ||
  8750. ((
  8751. M instanceof AST_SymbolImportForeign ||
  8752. M instanceof AST_SymbolExportForeign ||
  8753. M instanceof AST_SymbolExport
  8754. ) && M.quote)
  8755. ) {
  8756. return {
  8757. type: "Literal",
  8758. value: M.name
  8759. };
  8760. }
  8761. var def = M.definition();
  8762. return {
  8763. type: "Identifier",
  8764. name: def ? def.mangled_name || def.name : M.name
  8765. };
  8766. });
  8767. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  8768. const pattern = M.value.source;
  8769. const flags = M.value.flags;
  8770. return {
  8771. type: "Literal",
  8772. value: null,
  8773. raw: M.print_to_string(),
  8774. regex: { pattern, flags }
  8775. };
  8776. });
  8777. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  8778. var value = M.value;
  8779. return {
  8780. type: "Literal",
  8781. value: value,
  8782. raw: M.raw || M.print_to_string()
  8783. };
  8784. });
  8785. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  8786. return {
  8787. type: "Identifier",
  8788. name: String(M.value)
  8789. };
  8790. });
  8791. def_to_moz(AST_BigInt, M => ({
  8792. type: "Literal",
  8793. // value cannot be represented natively
  8794. // see: https://github.com/estree/estree/blob/master/es2020.md#bigintliteral
  8795. value: null,
  8796. // `M.value` is a string that may be a hex number representation.
  8797. // but "bigint" property should have only decimal digits
  8798. bigint: typeof BigInt === "function" ? BigInt(M.value).toString() : M.value,
  8799. raw: M.raw,
  8800. }));
  8801. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  8802. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  8803. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  8804. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  8805. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  8806. /* -----[ tools ]----- */
  8807. function my_start_token(moznode) {
  8808. var loc = moznode.loc, start = loc && loc.start;
  8809. var range = moznode.range;
  8810. return new AST_Token(
  8811. "",
  8812. "",
  8813. start && start.line || 0,
  8814. start && start.column || 0,
  8815. range ? range [0] : moznode.start,
  8816. false,
  8817. [],
  8818. [],
  8819. loc && loc.source,
  8820. );
  8821. }
  8822. function my_end_token(moznode) {
  8823. var loc = moznode.loc, end = loc && loc.end;
  8824. var range = moznode.range;
  8825. return new AST_Token(
  8826. "",
  8827. "",
  8828. end && end.line || 0,
  8829. end && end.column || 0,
  8830. range ? range [0] : moznode.end,
  8831. false,
  8832. [],
  8833. [],
  8834. loc && loc.source,
  8835. );
  8836. }
  8837. var FROM_MOZ_LABELS = null;
  8838. function from_moz(node) {
  8839. if (node == null) return null;
  8840. return MOZ_TO_ME[node.type](node);
  8841. }
  8842. function from_moz_quote(moz_key, computed) {
  8843. if (!computed && moz_key.type === "Literal" && typeof moz_key.value === "string") {
  8844. return '"';
  8845. } else {
  8846. return "";
  8847. }
  8848. }
  8849. function from_moz_symbol(symbol_type, M, has_quote) {
  8850. return new symbol_type({
  8851. start: my_start_token(M),
  8852. quote: has_quote ? '"' : undefined,
  8853. name: M.type === "Identifier" ? M.name : String(M.value),
  8854. end: my_end_token(M),
  8855. });
  8856. }
  8857. function from_moz_lambda(M, is_method) {
  8858. return new (is_method ? AST_Accessor : AST_Function)({
  8859. start: my_start_token(M),
  8860. end: my_end_token(M),
  8861. name: M.id && from_moz_symbol(is_method ? AST_SymbolMethod : AST_SymbolLambda, M.id),
  8862. argnames: M.params.map(M => from_moz_pattern(M, AST_SymbolFunarg)),
  8863. is_generator: M.generator,
  8864. async: M.async,
  8865. body: normalize_directives(from_moz(M.body).body)
  8866. });
  8867. }
  8868. function from_moz_pattern(M, sym_type) {
  8869. switch (M.type) {
  8870. case "ObjectPattern":
  8871. return new AST_Destructuring({
  8872. start: my_start_token(M),
  8873. end: my_end_token(M),
  8874. names: M.properties.map(p => from_moz_pattern(p, sym_type)),
  8875. is_array: false
  8876. });
  8877. case "Property":
  8878. var key = M.key;
  8879. var args = {
  8880. start : my_start_token(key || M.value),
  8881. end : my_end_token(M.value),
  8882. key : key.type == "Identifier" ? key.name : String(key.value),
  8883. quote : !M.computed && key.type === "Literal" && typeof key.value === "string"
  8884. ? '"'
  8885. : "",
  8886. value : from_moz_pattern(M.value, sym_type)
  8887. };
  8888. if (M.computed) {
  8889. args.key = from_moz(M.key);
  8890. }
  8891. return new AST_ObjectKeyVal(args);
  8892. case "ArrayPattern":
  8893. return new AST_Destructuring({
  8894. start: my_start_token(M),
  8895. end: my_end_token(M),
  8896. names: M.elements.map(function(elm) {
  8897. if (elm === null) {
  8898. return new AST_Hole();
  8899. }
  8900. return from_moz_pattern(elm, sym_type);
  8901. }),
  8902. is_array: true
  8903. });
  8904. case "SpreadElement":
  8905. case "RestElement":
  8906. return new AST_Expansion({
  8907. start: my_start_token(M),
  8908. end: my_end_token(M),
  8909. expression: from_moz_pattern(M.argument, sym_type),
  8910. });
  8911. case "AssignmentPattern":
  8912. return new AST_DefaultAssign({
  8913. start : my_start_token(M),
  8914. end : my_end_token(M),
  8915. left : from_moz_pattern(M.left, sym_type),
  8916. operator: "=",
  8917. right : from_moz(M.right),
  8918. });
  8919. case "Identifier":
  8920. return new sym_type({
  8921. start : my_start_token(M),
  8922. end : my_end_token(M),
  8923. name : M.name,
  8924. });
  8925. default:
  8926. throw new Error("Invalid node type for destructuring: " + M.type);
  8927. }
  8928. }
  8929. function from_moz_label_ref(m_label) {
  8930. if (!m_label) return null;
  8931. const label = from_moz_symbol(AST_LabelRef, m_label);
  8932. let i = FROM_MOZ_LABELS.length;
  8933. while (i--) {
  8934. const label_origin = FROM_MOZ_LABELS[i];
  8935. if (label.name === label_origin.name) {
  8936. label.thedef = label_origin;
  8937. break;
  8938. }
  8939. }
  8940. return label;
  8941. }
  8942. AST_Node.from_mozilla_ast = function(node) {
  8943. var save_labels = FROM_MOZ_LABELS;
  8944. FROM_MOZ_LABELS = [];
  8945. var ast = from_moz(node);
  8946. FROM_MOZ_LABELS = save_labels;
  8947. return ast;
  8948. };
  8949. function set_moz_loc(mynode, moznode) {
  8950. var start = mynode.start;
  8951. var end = mynode.end;
  8952. if (!(start && end)) {
  8953. return moznode;
  8954. }
  8955. if (start.pos != null && end.endpos != null) {
  8956. moznode.range = [start.pos, end.endpos];
  8957. }
  8958. if (start.line) {
  8959. moznode.loc = {
  8960. start: {line: start.line, column: start.col},
  8961. end: end.endline ? {line: end.endline, column: end.endcol} : null
  8962. };
  8963. if (start.file) {
  8964. moznode.loc.source = start.file;
  8965. }
  8966. }
  8967. return moznode;
  8968. }
  8969. function def_to_moz(mytype, handler) {
  8970. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  8971. return set_moz_loc(this, handler(this, parent));
  8972. });
  8973. }
  8974. var TO_MOZ_STACK = null;
  8975. function to_moz(node) {
  8976. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  8977. TO_MOZ_STACK.push(node);
  8978. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  8979. TO_MOZ_STACK.pop();
  8980. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  8981. return ast;
  8982. }
  8983. /** Object property keys can be number literals, string literals, or raw names. Additionally they can be shorthand. We decide that here. */
  8984. function to_moz_property_key(key, computed = false, quote = false, value = null) {
  8985. if (computed) {
  8986. return [false, to_moz(key)];
  8987. }
  8988. const key_name = typeof key === "string" ? key : key.name;
  8989. let moz_key;
  8990. if (quote) {
  8991. moz_key = { type: "Literal", value: key_name, raw: JSON.stringify(key_name) };
  8992. } else if ("" + +key_name === key_name && +key_name >= 0) {
  8993. // representable as a number
  8994. moz_key = { type: "Literal", value: +key_name, raw: JSON.stringify(+key_name) };
  8995. } else {
  8996. moz_key = { type: "Identifier", name: key_name };
  8997. }
  8998. const shorthand =
  8999. moz_key.type === "Identifier"
  9000. && moz_key.name === key_name
  9001. && (value instanceof AST_Symbol && value.name === key_name
  9002. || value instanceof AST_DefaultAssign && value.left.name === key_name);
  9003. return [shorthand, moz_key];
  9004. }
  9005. function to_moz_pattern(node) {
  9006. if (node instanceof AST_Expansion) {
  9007. return {
  9008. type: "RestElement",
  9009. argument: to_moz_pattern(node.expression),
  9010. };
  9011. }
  9012. if ((
  9013. node instanceof AST_Symbol
  9014. || node instanceof AST_Destructuring
  9015. || node instanceof AST_DefaultAssign
  9016. || node instanceof AST_PropAccess
  9017. )) {
  9018. // Plain translation
  9019. return to_moz(node);
  9020. }
  9021. throw new Error(node.TYPE);
  9022. }
  9023. function to_moz_in_destructuring() {
  9024. var i = TO_MOZ_STACK.length;
  9025. while (i--) {
  9026. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  9027. return true;
  9028. }
  9029. }
  9030. return false;
  9031. }
  9032. function to_moz_block(node) {
  9033. return {
  9034. type: "BlockStatement",
  9035. body: node.body.map(to_moz)
  9036. };
  9037. }
  9038. function to_moz_scope(type, node) {
  9039. var body = node.body.map(to_moz);
  9040. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  9041. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  9042. }
  9043. return {
  9044. type: type,
  9045. body: body
  9046. };
  9047. }
  9048. })();
  9049. // return true if the node at the top of the stack (that means the
  9050. // innermost node in the current output) is lexically the first in
  9051. // a statement.
  9052. function first_in_statement(stack) {
  9053. let node = stack.parent(-1);
  9054. for (let i = 0, p; p = stack.parent(i); i++) {
  9055. if (p instanceof AST_Statement && p.body === node)
  9056. return true;
  9057. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  9058. (p.TYPE === "Call" && p.expression === node) ||
  9059. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  9060. (p instanceof AST_Dot && p.expression === node) ||
  9061. (p instanceof AST_Sub && p.expression === node) ||
  9062. (p instanceof AST_Chain && p.expression === node) ||
  9063. (p instanceof AST_Conditional && p.condition === node) ||
  9064. (p instanceof AST_Binary && p.left === node) ||
  9065. (p instanceof AST_UnaryPostfix && p.expression === node)
  9066. ) {
  9067. node = p;
  9068. } else {
  9069. return false;
  9070. }
  9071. }
  9072. }
  9073. // Returns whether the leftmost item in the expression is an object
  9074. function left_is_object(node) {
  9075. if (node instanceof AST_Object) return true;
  9076. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  9077. if (node.TYPE === "Call") return left_is_object(node.expression);
  9078. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  9079. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  9080. if (node instanceof AST_Chain) return left_is_object(node.expression);
  9081. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  9082. if (node instanceof AST_Binary) return left_is_object(node.left);
  9083. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  9084. return false;
  9085. }
  9086. /***********************************************************************
  9087. A JavaScript tokenizer / parser / beautifier / compressor.
  9088. https://github.com/mishoo/UglifyJS2
  9089. -------------------------------- (C) ---------------------------------
  9090. Author: Mihai Bazon
  9091. <mihai.bazon@gmail.com>
  9092. http://mihai.bazon.net/blog
  9093. Distributed under the BSD license:
  9094. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  9095. Redistribution and use in source and binary forms, with or without
  9096. modification, are permitted provided that the following conditions
  9097. are met:
  9098. * Redistributions of source code must retain the above
  9099. copyright notice, this list of conditions and the following
  9100. disclaimer.
  9101. * Redistributions in binary form must reproduce the above
  9102. copyright notice, this list of conditions and the following
  9103. disclaimer in the documentation and/or other materials
  9104. provided with the distribution.
  9105. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  9106. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9107. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9108. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  9109. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  9110. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9111. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9112. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9113. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  9114. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  9115. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9116. SUCH DAMAGE.
  9117. ***********************************************************************/
  9118. const CODE_LINE_BREAK = 10;
  9119. const CODE_SPACE = 32;
  9120. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/;
  9121. function is_some_comments(comment) {
  9122. // multiline comment
  9123. return (
  9124. (comment.type === "comment2" || comment.type === "comment1")
  9125. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  9126. );
  9127. }
  9128. const ROPE_COMMIT_WHEN = 8 * 1000;
  9129. class Rope {
  9130. constructor() {
  9131. this.committed = "";
  9132. this.current = "";
  9133. }
  9134. append(str) {
  9135. /** When `this.current` is too long, commit it. */
  9136. if (this.current.length > ROPE_COMMIT_WHEN) {
  9137. this.committed += this.current + str;
  9138. this.current = "";
  9139. } else {
  9140. this.current += str;
  9141. }
  9142. }
  9143. insertAt(char, index) {
  9144. const { committed, current } = this;
  9145. if (index < committed.length) {
  9146. this.committed = committed.slice(0, index) + char + committed.slice(index);
  9147. } else if (index === committed.length) {
  9148. this.committed += char;
  9149. } else {
  9150. index -= committed.length;
  9151. this.committed += current.slice(0, index) + char;
  9152. this.current = current.slice(index);
  9153. }
  9154. }
  9155. charAt(index) {
  9156. const { committed } = this;
  9157. if (index < committed.length) return committed[index];
  9158. return this.current[index - committed.length];
  9159. }
  9160. charCodeAt(index) {
  9161. const { committed } = this;
  9162. if (index < committed.length) return committed.charCodeAt(index);
  9163. return this.current.charCodeAt(index - committed.length);
  9164. }
  9165. length() {
  9166. return this.committed.length + this.current.length;
  9167. }
  9168. expectDirective() {
  9169. // /^$|[;{][\s\n]*$/
  9170. let ch, n = this.length();
  9171. if (n <= 0) return true;
  9172. // Skip N whitespace from the end
  9173. while (
  9174. (ch = this.charCodeAt(--n))
  9175. && (ch == CODE_SPACE || ch == CODE_LINE_BREAK)
  9176. );
  9177. // either ";", or "{", or the string ended
  9178. return !ch || ch === 59 || ch === 123;
  9179. }
  9180. hasNLB() {
  9181. let n = this.length() - 1;
  9182. while (n >= 0) {
  9183. const code = this.charCodeAt(n--);
  9184. if (code === CODE_LINE_BREAK) return true;
  9185. if (code !== CODE_SPACE) return false;
  9186. }
  9187. return true;
  9188. }
  9189. toString() {
  9190. return this.committed + this.current;
  9191. }
  9192. }
  9193. function OutputStream(options) {
  9194. var readonly = !options;
  9195. options = defaults(options, {
  9196. ascii_only : false,
  9197. beautify : false,
  9198. braces : false,
  9199. comments : "some",
  9200. ecma : 5,
  9201. ie8 : false,
  9202. indent_level : 4,
  9203. indent_start : 0,
  9204. inline_script : true,
  9205. keep_numbers : false,
  9206. keep_quoted_props : false,
  9207. max_line_len : false,
  9208. preamble : null,
  9209. preserve_annotations : false,
  9210. quote_keys : false,
  9211. quote_style : 0,
  9212. safari10 : false,
  9213. semicolons : true,
  9214. shebang : true,
  9215. shorthand : undefined,
  9216. source_map : null,
  9217. webkit : false,
  9218. width : 80,
  9219. wrap_iife : false,
  9220. wrap_func_args : false,
  9221. _destroy_ast : false
  9222. }, true);
  9223. if (options.shorthand === undefined)
  9224. options.shorthand = options.ecma > 5;
  9225. // Convert comment option to RegExp if necessary and set up comments filter
  9226. var comment_filter = return_false; // Default case, throw all comments away
  9227. if (options.comments) {
  9228. let comments = options.comments;
  9229. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  9230. var regex_pos = options.comments.lastIndexOf("/");
  9231. comments = new RegExp(
  9232. options.comments.substr(1, regex_pos - 1),
  9233. options.comments.substr(regex_pos + 1)
  9234. );
  9235. }
  9236. if (comments instanceof RegExp) {
  9237. comment_filter = function(comment) {
  9238. return comment.type != "comment5" && comments.test(comment.value);
  9239. };
  9240. } else if (typeof comments === "function") {
  9241. comment_filter = function(comment) {
  9242. return comment.type != "comment5" && comments(this, comment);
  9243. };
  9244. } else if (comments === "some") {
  9245. comment_filter = is_some_comments;
  9246. } else { // NOTE includes "all" option
  9247. comment_filter = return_true;
  9248. }
  9249. }
  9250. if (options.preserve_annotations) {
  9251. let prev_comment_filter = comment_filter;
  9252. comment_filter = function (comment) {
  9253. return r_annotation.test(comment.value) || prev_comment_filter.apply(this, arguments);
  9254. };
  9255. }
  9256. var indentation = 0;
  9257. var current_col = 0;
  9258. var current_line = 1;
  9259. var current_pos = 0;
  9260. var OUTPUT = new Rope();
  9261. let printed_comments = new Set();
  9262. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  9263. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  9264. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  9265. var code = get_full_char_code(ch, 0).toString(16);
  9266. return "\\u{" + code + "}";
  9267. });
  9268. }
  9269. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  9270. var code = ch.charCodeAt(0).toString(16);
  9271. if (code.length <= 2 && !identifier) {
  9272. while (code.length < 2) code = "0" + code;
  9273. return "\\x" + code;
  9274. } else {
  9275. while (code.length < 4) code = "0" + code;
  9276. return "\\u" + code;
  9277. }
  9278. });
  9279. } : function(str) {
  9280. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  9281. if (lone) {
  9282. return "\\u" + lone.charCodeAt(0).toString(16);
  9283. }
  9284. return match;
  9285. });
  9286. };
  9287. /** Matches an identifier with non-ascii characters */
  9288. var re_high_identifier = (() => {
  9289. try {
  9290. return new RegExp("^(?![\\u0000-\\u00ff]+$)([\\p{ID_Start}][\\p{ID_Continue}]*)$", "u");
  9291. } catch (_) {
  9292. return undefined; /* \p in regex above is unsupported */
  9293. }
  9294. })();
  9295. var ident_to_utf8 = (options.ascii_only || !re_high_identifier) ? to_utf8 : function (str) {
  9296. if (re_high_identifier.test(str)) {
  9297. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  9298. if (lone) {
  9299. return "\\u" + lone.charCodeAt(0).toString(16).padStart(4, "0");
  9300. }
  9301. return match;
  9302. });
  9303. // Escape identifier characters from higher unicode versions
  9304. var char = get_full_char(str, 0);
  9305. var escaped = char;
  9306. if (
  9307. is_identifier_start_broad(char)
  9308. && !is_identifier_start(char)
  9309. ) {
  9310. const code_point = char.codePointAt(0);
  9311. escaped = code_point <= 0xffff
  9312. ? `\\u${code_point.toString(16).padStart(4, "0")}`
  9313. : `\\u{${code_point.toString(16)}}`;
  9314. }
  9315. for (var i = char.length; i < str.length; i += char.length) {
  9316. char = get_full_char(str, i);
  9317. if (
  9318. is_identifier_char_broad(char)
  9319. && !is_identifier_char(char)
  9320. ) {
  9321. const code_point = char.codePointAt(0);
  9322. escaped += code_point <= 0xffff
  9323. ? `\\u${code_point.toString(16).padStart(4, "0")}`
  9324. : `\\u{${code_point.toString(16)}}`;
  9325. } else {
  9326. escaped += char;
  9327. }
  9328. }
  9329. return escaped;
  9330. } else {
  9331. return str;
  9332. }
  9333. };
  9334. function make_string(str, quote) {
  9335. var dq = 0, sq = 0;
  9336. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  9337. function(s, i) {
  9338. switch (s) {
  9339. case '"': ++dq; return '"';
  9340. case "'": ++sq; return "'";
  9341. case "\\": return "\\\\";
  9342. case "\n": return "\\n";
  9343. case "\r": return "\\r";
  9344. case "\t": return "\\t";
  9345. case "\b": return "\\b";
  9346. case "\f": return "\\f";
  9347. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  9348. case "\u2028": return "\\u2028";
  9349. case "\u2029": return "\\u2029";
  9350. case "\ufeff": return "\\ufeff";
  9351. case "\0":
  9352. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  9353. }
  9354. return s;
  9355. });
  9356. function quote_single() {
  9357. return "'" + str.replace(/\x27/g, "\\'") + "'";
  9358. }
  9359. function quote_double() {
  9360. return '"' + str.replace(/\x22/g, '\\"') + '"';
  9361. }
  9362. function quote_template() {
  9363. return "`" + str.replace(/`/g, "\\`") + "`";
  9364. }
  9365. str = to_utf8(str);
  9366. if (quote === "`") return quote_template();
  9367. switch (options.quote_style) {
  9368. case 1:
  9369. return quote_single();
  9370. case 2:
  9371. return quote_double();
  9372. case 3:
  9373. return quote == "'" ? quote_single() : quote_double();
  9374. default:
  9375. return dq > sq ? quote_single() : quote_double();
  9376. }
  9377. }
  9378. function encode_string(str, quote) {
  9379. var ret = make_string(str, quote);
  9380. if (options.inline_script) {
  9381. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  9382. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  9383. ret = ret.replace(/--\x3e/g, "--\\x3e");
  9384. }
  9385. return ret;
  9386. }
  9387. function make_name(name) {
  9388. name = name.toString();
  9389. name = ident_to_utf8(name, true);
  9390. return name;
  9391. }
  9392. function make_indent(back) {
  9393. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  9394. }
  9395. /* -----[ beautification/minification ]----- */
  9396. var has_parens = false;
  9397. var might_need_space = false;
  9398. var might_need_semicolon = false;
  9399. var might_add_newline = 0;
  9400. var need_newline_indented = false;
  9401. var need_space = false;
  9402. var newline_insert = -1;
  9403. var last = "";
  9404. var mapping_token, mapping_name, mappings = options.source_map && [];
  9405. var do_add_mapping = mappings ? function() {
  9406. mappings.forEach(function(mapping) {
  9407. try {
  9408. let { name, token } = mapping;
  9409. if (name !== false) {
  9410. if (token.type == "name" || token.type === "privatename") {
  9411. name = token.value;
  9412. } else if (name instanceof AST_Symbol) {
  9413. name = token.type === "string" ? token.value : name.name;
  9414. }
  9415. }
  9416. options.source_map.add(
  9417. mapping.token.file,
  9418. mapping.line, mapping.col,
  9419. mapping.token.line, mapping.token.col,
  9420. is_basic_identifier_string(name) ? name : undefined
  9421. );
  9422. } catch(ex) {
  9423. // Ignore bad mapping
  9424. }
  9425. });
  9426. mappings = [];
  9427. } : noop;
  9428. var ensure_line_len = options.max_line_len ? function() {
  9429. if (current_col > options.max_line_len) {
  9430. if (might_add_newline) {
  9431. OUTPUT.insertAt("\n", might_add_newline);
  9432. const len_after_newline = OUTPUT.length() - might_add_newline - 1;
  9433. if (mappings) {
  9434. var delta = len_after_newline - current_col;
  9435. mappings.forEach(function(mapping) {
  9436. mapping.line++;
  9437. mapping.col += delta;
  9438. });
  9439. }
  9440. current_line++;
  9441. current_pos++;
  9442. current_col = len_after_newline;
  9443. }
  9444. }
  9445. if (might_add_newline) {
  9446. might_add_newline = 0;
  9447. do_add_mapping();
  9448. }
  9449. } : noop;
  9450. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  9451. function print(str) {
  9452. str = String(str);
  9453. var ch = get_full_char(str, 0);
  9454. if (need_newline_indented && ch) {
  9455. need_newline_indented = false;
  9456. if (ch !== "\n") {
  9457. print("\n");
  9458. indent();
  9459. }
  9460. }
  9461. if (need_space && ch) {
  9462. need_space = false;
  9463. if (!/[\s;})]/.test(ch)) {
  9464. space();
  9465. }
  9466. }
  9467. newline_insert = -1;
  9468. var prev = last.charAt(last.length - 1);
  9469. if (might_need_semicolon) {
  9470. might_need_semicolon = false;
  9471. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  9472. if (options.semicolons || requireSemicolonChars.has(ch)) {
  9473. OUTPUT.append(";");
  9474. current_col++;
  9475. current_pos++;
  9476. } else {
  9477. ensure_line_len();
  9478. if (current_col > 0) {
  9479. OUTPUT.append("\n");
  9480. current_pos++;
  9481. current_line++;
  9482. current_col = 0;
  9483. }
  9484. if (/^\s+$/.test(str)) {
  9485. // reset the semicolon flag, since we didn't print one
  9486. // now and might still have to later
  9487. might_need_semicolon = true;
  9488. }
  9489. }
  9490. if (!options.beautify)
  9491. might_need_space = false;
  9492. }
  9493. }
  9494. if (might_need_space) {
  9495. if ((is_identifier_char_broad(prev)
  9496. && (is_identifier_char_broad(ch) || ch == "\\"))
  9497. || (ch == "/" && ch == prev)
  9498. || ((ch == "+" || ch == "-") && ch == last)
  9499. ) {
  9500. OUTPUT.append(" ");
  9501. current_col++;
  9502. current_pos++;
  9503. }
  9504. might_need_space = false;
  9505. }
  9506. if (mapping_token) {
  9507. mappings.push({
  9508. token: mapping_token,
  9509. name: mapping_name,
  9510. line: current_line,
  9511. col: current_col
  9512. });
  9513. mapping_token = false;
  9514. if (!might_add_newline) do_add_mapping();
  9515. }
  9516. OUTPUT.append(str);
  9517. has_parens = str[str.length - 1] == "(";
  9518. current_pos += str.length;
  9519. var a = str.split(/\r?\n/), n = a.length - 1;
  9520. current_line += n;
  9521. current_col += a[0].length;
  9522. if (n > 0) {
  9523. ensure_line_len();
  9524. current_col = a[n].length;
  9525. }
  9526. last = str;
  9527. }
  9528. var star = function() {
  9529. print("*");
  9530. };
  9531. var space = options.beautify ? function() {
  9532. print(" ");
  9533. } : function() {
  9534. might_need_space = true;
  9535. };
  9536. var indent = options.beautify ? function(half) {
  9537. if (options.beautify) {
  9538. print(make_indent(half ? 0.5 : 0));
  9539. }
  9540. } : noop;
  9541. var with_indent = options.beautify ? function(col, cont) {
  9542. if (col === true) col = next_indent();
  9543. var save_indentation = indentation;
  9544. indentation = col;
  9545. var ret = cont();
  9546. indentation = save_indentation;
  9547. return ret;
  9548. } : function(col, cont) { return cont(); };
  9549. var newline = options.beautify ? function() {
  9550. if (newline_insert < 0) return print("\n");
  9551. if (OUTPUT.charAt(newline_insert) != "\n") {
  9552. OUTPUT.insertAt("\n", newline_insert);
  9553. current_pos++;
  9554. current_line++;
  9555. }
  9556. newline_insert++;
  9557. } : options.max_line_len ? function() {
  9558. ensure_line_len();
  9559. might_add_newline = OUTPUT.length();
  9560. } : noop;
  9561. var semicolon = options.beautify ? function() {
  9562. print(";");
  9563. } : function() {
  9564. might_need_semicolon = true;
  9565. };
  9566. function force_semicolon() {
  9567. might_need_semicolon = false;
  9568. print(";");
  9569. }
  9570. function next_indent() {
  9571. return indentation + options.indent_level;
  9572. }
  9573. function with_block(cont) {
  9574. var ret;
  9575. print("{");
  9576. newline();
  9577. with_indent(next_indent(), function() {
  9578. ret = cont();
  9579. });
  9580. indent();
  9581. print("}");
  9582. return ret;
  9583. }
  9584. function with_parens(cont) {
  9585. print("(");
  9586. //XXX: still nice to have that for argument lists
  9587. //var ret = with_indent(current_col, cont);
  9588. var ret = cont();
  9589. print(")");
  9590. return ret;
  9591. }
  9592. function with_square(cont) {
  9593. print("[");
  9594. //var ret = with_indent(current_col, cont);
  9595. var ret = cont();
  9596. print("]");
  9597. return ret;
  9598. }
  9599. function comma() {
  9600. print(",");
  9601. space();
  9602. }
  9603. function colon() {
  9604. print(":");
  9605. space();
  9606. }
  9607. var add_mapping = mappings ? function(token, name) {
  9608. mapping_token = token;
  9609. mapping_name = name;
  9610. } : noop;
  9611. function get() {
  9612. if (might_add_newline) {
  9613. ensure_line_len();
  9614. }
  9615. return OUTPUT.toString();
  9616. }
  9617. function filter_comment(comment) {
  9618. if (!options.preserve_annotations) {
  9619. comment = comment.replace(r_annotation, " ");
  9620. }
  9621. if (/^\s*$/.test(comment)) {
  9622. return "";
  9623. }
  9624. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  9625. }
  9626. function prepend_comments(node) {
  9627. var self = this;
  9628. var start = node.start;
  9629. if (!start) return;
  9630. var printed_comments = self.printed_comments;
  9631. // There cannot be a newline between return/yield and its value.
  9632. const keyword_with_value =
  9633. node instanceof AST_Exit && node.value
  9634. || (node instanceof AST_Await || node instanceof AST_Yield)
  9635. && node.expression;
  9636. if (
  9637. start.comments_before
  9638. && printed_comments.has(start.comments_before)
  9639. ) {
  9640. if (keyword_with_value) {
  9641. start.comments_before = [];
  9642. } else {
  9643. return;
  9644. }
  9645. }
  9646. var comments = start.comments_before;
  9647. if (!comments) {
  9648. comments = start.comments_before = [];
  9649. }
  9650. printed_comments.add(comments);
  9651. if (keyword_with_value) {
  9652. var tw = new TreeWalker(function(node) {
  9653. var parent = tw.parent();
  9654. if (parent instanceof AST_Exit
  9655. || parent instanceof AST_Await
  9656. || parent instanceof AST_Yield
  9657. || parent instanceof AST_Binary && parent.left === node
  9658. || parent.TYPE == "Call" && parent.expression === node
  9659. || parent instanceof AST_Conditional && parent.condition === node
  9660. || parent instanceof AST_Dot && parent.expression === node
  9661. || parent instanceof AST_Sequence && parent.expressions[0] === node
  9662. || parent instanceof AST_Sub && parent.expression === node
  9663. || parent instanceof AST_UnaryPostfix) {
  9664. if (!node.start) return;
  9665. var text = node.start.comments_before;
  9666. if (text && !printed_comments.has(text)) {
  9667. printed_comments.add(text);
  9668. comments = comments.concat(text);
  9669. }
  9670. } else {
  9671. return true;
  9672. }
  9673. });
  9674. tw.push(node);
  9675. keyword_with_value.walk(tw);
  9676. }
  9677. if (current_pos == 0) {
  9678. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  9679. && !printed_comments.has(comments[0])) {
  9680. print("#!" + comments.shift().value + "\n");
  9681. indent();
  9682. }
  9683. var preamble = options.preamble;
  9684. if (preamble) {
  9685. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  9686. }
  9687. }
  9688. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  9689. if (comments.length == 0) return;
  9690. var last_nlb = OUTPUT.hasNLB();
  9691. comments.forEach(function(c, i) {
  9692. printed_comments.add(c);
  9693. if (!last_nlb) {
  9694. if (c.nlb) {
  9695. print("\n");
  9696. indent();
  9697. last_nlb = true;
  9698. } else if (i > 0) {
  9699. space();
  9700. }
  9701. }
  9702. if (/comment[134]/.test(c.type)) {
  9703. var value = filter_comment(c.value);
  9704. if (value) {
  9705. print("//" + value + "\n");
  9706. indent();
  9707. }
  9708. last_nlb = true;
  9709. } else if (c.type == "comment2") {
  9710. var value = filter_comment(c.value);
  9711. if (value) {
  9712. print("/*" + value + "*/");
  9713. }
  9714. last_nlb = false;
  9715. }
  9716. });
  9717. if (!last_nlb) {
  9718. if (start.nlb) {
  9719. print("\n");
  9720. indent();
  9721. } else {
  9722. space();
  9723. }
  9724. }
  9725. }
  9726. function append_comments(node, tail) {
  9727. var self = this;
  9728. var token = node.end;
  9729. if (!token) return;
  9730. var printed_comments = self.printed_comments;
  9731. var comments = token[tail ? "comments_before" : "comments_after"];
  9732. if (!comments || printed_comments.has(comments)) return;
  9733. if (!(node instanceof AST_Statement || comments.every((c) =>
  9734. !/comment[134]/.test(c.type)
  9735. ))) return;
  9736. printed_comments.add(comments);
  9737. var insert = OUTPUT.length();
  9738. comments.filter(comment_filter, node).forEach(function(c, i) {
  9739. if (printed_comments.has(c)) return;
  9740. printed_comments.add(c);
  9741. need_space = false;
  9742. if (need_newline_indented) {
  9743. print("\n");
  9744. indent();
  9745. need_newline_indented = false;
  9746. } else if (c.nlb && (i > 0 || !OUTPUT.hasNLB())) {
  9747. print("\n");
  9748. indent();
  9749. } else if (i > 0 || !tail) {
  9750. space();
  9751. }
  9752. if (/comment[134]/.test(c.type)) {
  9753. const value = filter_comment(c.value);
  9754. if (value) {
  9755. print("//" + value);
  9756. }
  9757. need_newline_indented = true;
  9758. } else if (c.type == "comment2") {
  9759. const value = filter_comment(c.value);
  9760. if (value) {
  9761. print("/*" + value + "*/");
  9762. }
  9763. need_space = true;
  9764. }
  9765. });
  9766. if (OUTPUT.length() > insert) newline_insert = insert;
  9767. }
  9768. /**
  9769. * When output.option("_destroy_ast") is enabled, destroy the function.
  9770. * Call this after printing it.
  9771. */
  9772. const gc_scope =
  9773. options["_destroy_ast"]
  9774. ? function gc_scope(scope) {
  9775. scope.body.length = 0;
  9776. scope.argnames.length = 0;
  9777. }
  9778. : noop;
  9779. var stack = [];
  9780. return {
  9781. get : get,
  9782. toString : get,
  9783. indent : indent,
  9784. in_directive : false,
  9785. use_asm : null,
  9786. active_scope : null,
  9787. indentation : function() { return indentation; },
  9788. current_width : function() { return current_col - indentation; },
  9789. should_break : function() { return options.width && this.current_width() >= options.width; },
  9790. has_parens : function() { return has_parens; },
  9791. newline : newline,
  9792. print : print,
  9793. star : star,
  9794. space : space,
  9795. comma : comma,
  9796. colon : colon,
  9797. last : function() { return last; },
  9798. semicolon : semicolon,
  9799. force_semicolon : force_semicolon,
  9800. to_utf8 : to_utf8,
  9801. print_name : function(name) { print(make_name(name)); },
  9802. print_string : function(str, quote, escape_directive) {
  9803. var encoded = encode_string(str, quote);
  9804. if (escape_directive === true && !encoded.includes("\\")) {
  9805. // Insert semicolons to break directive prologue
  9806. if (!OUTPUT.expectDirective()) {
  9807. force_semicolon();
  9808. }
  9809. force_semicolon();
  9810. }
  9811. print(encoded);
  9812. },
  9813. print_template_string_chars: function(str) {
  9814. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  9815. return print(encoded.substr(1, encoded.length - 2));
  9816. },
  9817. encode_string : encode_string,
  9818. next_indent : next_indent,
  9819. with_indent : with_indent,
  9820. with_block : with_block,
  9821. with_parens : with_parens,
  9822. with_square : with_square,
  9823. add_mapping : add_mapping,
  9824. option : function(opt) { return options[opt]; },
  9825. gc_scope,
  9826. printed_comments: printed_comments,
  9827. prepend_comments: readonly ? noop : prepend_comments,
  9828. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  9829. line : function() { return current_line; },
  9830. col : function() { return current_col; },
  9831. pos : function() { return current_pos; },
  9832. push_node : function(node) { stack.push(node); },
  9833. pop_node : function() { return stack.pop(); },
  9834. parent : function(n) {
  9835. return stack[stack.length - 2 - (n || 0)];
  9836. }
  9837. };
  9838. }
  9839. /* -----[ code generators ]----- */
  9840. (function() {
  9841. /* -----[ utils ]----- */
  9842. function DEFPRINT(nodetype, generator) {
  9843. nodetype.DEFMETHOD("_codegen", generator);
  9844. }
  9845. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  9846. var self = this, generator = self._codegen;
  9847. if (self instanceof AST_Scope) {
  9848. output.active_scope = self;
  9849. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  9850. output.use_asm = output.active_scope;
  9851. }
  9852. function doit() {
  9853. output.prepend_comments(self);
  9854. self.add_source_map(output);
  9855. generator(self, output);
  9856. output.append_comments(self);
  9857. }
  9858. output.push_node(self);
  9859. if (force_parens || self.needs_parens(output)) {
  9860. output.with_parens(doit);
  9861. } else {
  9862. doit();
  9863. }
  9864. output.pop_node();
  9865. if (self === output.use_asm) {
  9866. output.use_asm = null;
  9867. }
  9868. });
  9869. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  9870. AST_Node.DEFMETHOD("print_to_string", function(options) {
  9871. var output = OutputStream(options);
  9872. this.print(output);
  9873. return output.get();
  9874. });
  9875. /* -----[ PARENTHESES ]----- */
  9876. function PARENS(nodetype, func) {
  9877. if (Array.isArray(nodetype)) {
  9878. nodetype.forEach(function(nodetype) {
  9879. PARENS(nodetype, func);
  9880. });
  9881. } else {
  9882. nodetype.DEFMETHOD("needs_parens", func);
  9883. }
  9884. }
  9885. PARENS(AST_Node, return_false);
  9886. // a function expression needs parens around it when it's provably
  9887. // the first token to appear in a statement.
  9888. PARENS(AST_Function, function(output) {
  9889. if (!output.has_parens() && first_in_statement(output)) {
  9890. return true;
  9891. }
  9892. if (output.option("webkit")) {
  9893. var p = output.parent();
  9894. if (p instanceof AST_PropAccess && p.expression === this) {
  9895. return true;
  9896. }
  9897. }
  9898. if (output.option("wrap_iife")) {
  9899. var p = output.parent();
  9900. if (p instanceof AST_Call && p.expression === this) {
  9901. return true;
  9902. }
  9903. }
  9904. if (output.option("wrap_func_args")) {
  9905. var p = output.parent();
  9906. if (p instanceof AST_Call && p.args.includes(this)) {
  9907. return true;
  9908. }
  9909. }
  9910. return false;
  9911. });
  9912. PARENS(AST_Arrow, function(output) {
  9913. var p = output.parent();
  9914. if (
  9915. output.option("wrap_func_args")
  9916. && p instanceof AST_Call
  9917. && p.args.includes(this)
  9918. ) {
  9919. return true;
  9920. }
  9921. return p instanceof AST_PropAccess && p.expression === this
  9922. || p instanceof AST_Conditional && p.condition === this;
  9923. });
  9924. // same goes for an object literal (as in AST_Function), because
  9925. // otherwise {...} would be interpreted as a block of code.
  9926. PARENS(AST_Object, function(output) {
  9927. return !output.has_parens() && first_in_statement(output);
  9928. });
  9929. PARENS(AST_ClassExpression, first_in_statement);
  9930. PARENS(AST_Unary, function(output) {
  9931. var p = output.parent();
  9932. return p instanceof AST_PropAccess && p.expression === this
  9933. || p instanceof AST_Call && p.expression === this
  9934. || p instanceof AST_Binary
  9935. && p.operator === "**"
  9936. && this instanceof AST_UnaryPrefix
  9937. && p.left === this
  9938. && this.operator !== "++"
  9939. && this.operator !== "--";
  9940. });
  9941. PARENS(AST_Await, function(output) {
  9942. var p = output.parent();
  9943. return p instanceof AST_PropAccess && p.expression === this
  9944. || p instanceof AST_Call && p.expression === this
  9945. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  9946. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  9947. });
  9948. PARENS(AST_Sequence, function(output) {
  9949. var p = output.parent();
  9950. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  9951. || p instanceof AST_Unary // !(foo, bar, baz)
  9952. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  9953. || p instanceof AST_VarDefLike // var a = (1, 2), b = a + a; ==> b == 4
  9954. || p instanceof AST_PropAccess && this !== p.property // (1, {foo:2}).foo, (1, {foo:2})["foo"], not foo[1, 2]
  9955. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  9956. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  9957. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  9958. * ==> 20 (side effect, set a := 10 and b := 20) */
  9959. || p instanceof AST_Arrow // x => (x, x)
  9960. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  9961. || p instanceof AST_Expansion // [...(a, b)]
  9962. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  9963. || p instanceof AST_Yield // yield (foo, bar)
  9964. || p instanceof AST_Export // export default (foo, bar)
  9965. ;
  9966. });
  9967. PARENS(AST_Binary, function(output) {
  9968. var p = output.parent();
  9969. // (foo && bar)()
  9970. if (p instanceof AST_Call && p.expression === this)
  9971. return true;
  9972. // typeof (foo && bar)
  9973. if (p instanceof AST_Unary)
  9974. return true;
  9975. // (foo && bar)["prop"], (foo && bar).prop
  9976. if (p instanceof AST_PropAccess && p.expression === this)
  9977. return true;
  9978. // this deals with precedence: 3 * (2 + 1)
  9979. if (p instanceof AST_Binary) {
  9980. const parent_op = p.operator;
  9981. const op = this.operator;
  9982. // It is forbidden for ?? to be used with || or && without parens.
  9983. if (op === "??" && (parent_op === "||" || parent_op === "&&")) {
  9984. return true;
  9985. }
  9986. if (parent_op === "??" && (op === "||" || op === "&&")) {
  9987. return true;
  9988. }
  9989. const pp = PRECEDENCE[parent_op];
  9990. const sp = PRECEDENCE[op];
  9991. if (pp > sp
  9992. || (pp == sp
  9993. && (this === p.right || parent_op == "**"))) {
  9994. return true;
  9995. }
  9996. }
  9997. if (p instanceof AST_PrivateIn) {
  9998. const op = this.operator;
  9999. const pp = PRECEDENCE["in"];
  10000. const sp = PRECEDENCE[op];
  10001. if (pp > sp || (pp == sp && this === p.value)) {
  10002. return true;
  10003. }
  10004. }
  10005. });
  10006. PARENS(AST_PrivateIn, function(output) {
  10007. var p = output.parent();
  10008. // (#x in this)()
  10009. if (p instanceof AST_Call && p.expression === this) {
  10010. return true;
  10011. }
  10012. // typeof (#x in this)
  10013. if (p instanceof AST_Unary) {
  10014. return true;
  10015. }
  10016. // (#x in this)["prop"], (#x in this).prop
  10017. if (p instanceof AST_PropAccess && p.expression === this) {
  10018. return true;
  10019. }
  10020. // same precedence as regular in operator
  10021. if (p instanceof AST_Binary) {
  10022. const parent_op = p.operator;
  10023. const pp = PRECEDENCE[parent_op];
  10024. const sp = PRECEDENCE["in"];
  10025. if (pp > sp
  10026. || (pp == sp
  10027. && (this === p.right || parent_op == "**"))) {
  10028. return true;
  10029. }
  10030. }
  10031. // rules are the same as binary in, but the class differs
  10032. if (p instanceof AST_PrivateIn && this === p.value) {
  10033. return true;
  10034. }
  10035. });
  10036. PARENS(AST_Yield, function(output) {
  10037. var p = output.parent();
  10038. // (yield 1) + (yield 2)
  10039. // a = yield 3
  10040. if (p instanceof AST_Binary && p.operator !== "=")
  10041. return true;
  10042. // (yield 1)()
  10043. // new (yield 1)()
  10044. if (p instanceof AST_Call && p.expression === this)
  10045. return true;
  10046. // (yield 1) ? yield 2 : yield 3
  10047. if (p instanceof AST_Conditional && p.condition === this)
  10048. return true;
  10049. // -(yield 4)
  10050. if (p instanceof AST_Unary)
  10051. return true;
  10052. // (yield x).foo
  10053. // (yield x)['foo']
  10054. if (p instanceof AST_PropAccess && p.expression === this)
  10055. return true;
  10056. });
  10057. PARENS(AST_Chain, function(output) {
  10058. var p = output.parent();
  10059. if (!(p instanceof AST_Call || p instanceof AST_PropAccess)) return false;
  10060. return p.expression === this;
  10061. });
  10062. PARENS(AST_PropAccess, function(output) {
  10063. var p = output.parent();
  10064. if (p instanceof AST_New && p.expression === this) {
  10065. // i.e. new (foo.bar().baz)
  10066. //
  10067. // if there's one call into this subtree, then we need
  10068. // parens around it too, otherwise the call will be
  10069. // interpreted as passing the arguments to the upper New
  10070. // expression.
  10071. return walk(this, node => {
  10072. if (node instanceof AST_Scope) return true;
  10073. if (node instanceof AST_Call) {
  10074. return walk_abort; // makes walk() return true.
  10075. }
  10076. });
  10077. }
  10078. });
  10079. PARENS(AST_PrefixedTemplateString, function(output) {
  10080. var p = output.parent();
  10081. if (p instanceof AST_New && p.expression === this) {
  10082. return true; // new (foo()`bar`)
  10083. }
  10084. });
  10085. PARENS(AST_Call, function(output) {
  10086. var p = output.parent(), p1;
  10087. if (p instanceof AST_New && p.expression === this
  10088. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  10089. return true;
  10090. // workaround for Safari bug.
  10091. // https://bugs.webkit.org/show_bug.cgi?id=123506
  10092. return this.expression instanceof AST_Function
  10093. && p instanceof AST_PropAccess
  10094. && p.expression === this
  10095. && (p1 = output.parent(1)) instanceof AST_Assign
  10096. && p1.left === p;
  10097. });
  10098. PARENS(AST_New, function(output) {
  10099. var p = output.parent();
  10100. if (this.args.length === 0
  10101. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  10102. || p instanceof AST_Call && p.expression === this
  10103. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  10104. return true;
  10105. });
  10106. PARENS(AST_Number, function(output) {
  10107. var p = output.parent();
  10108. if (p instanceof AST_PropAccess && p.expression === this) {
  10109. var value = this.getValue();
  10110. if (value < 0 || /^0/.test(make_num(value))) {
  10111. return true;
  10112. }
  10113. }
  10114. });
  10115. PARENS(AST_BigInt, function(output) {
  10116. var p = output.parent();
  10117. if (p instanceof AST_PropAccess && p.expression === this) {
  10118. var value = this.getValue();
  10119. if (value.startsWith("-")) {
  10120. return true;
  10121. }
  10122. }
  10123. });
  10124. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  10125. var p = output.parent();
  10126. // !(a = false) → true
  10127. if (p instanceof AST_Unary)
  10128. return true;
  10129. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  10130. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  10131. return true;
  10132. // (a = func)() —or— new (a = Object)()
  10133. if (p instanceof AST_Call && p.expression === this)
  10134. return true;
  10135. // (a = foo) ? bar : baz
  10136. if (p instanceof AST_Conditional && p.condition === this)
  10137. return true;
  10138. // (a = foo)["prop"] —or— (a = foo).prop
  10139. if (p instanceof AST_PropAccess && p.expression === this)
  10140. return true;
  10141. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  10142. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  10143. return true;
  10144. });
  10145. /* -----[ PRINTERS ]----- */
  10146. DEFPRINT(AST_Directive, function(self, output) {
  10147. output.print_string(self.value, self.quote);
  10148. output.semicolon();
  10149. });
  10150. DEFPRINT(AST_Expansion, function (self, output) {
  10151. output.print("...");
  10152. self.expression.print(output);
  10153. });
  10154. DEFPRINT(AST_Destructuring, function (self, output) {
  10155. output.print(self.is_array ? "[" : "{");
  10156. var len = self.names.length;
  10157. self.names.forEach(function (name, i) {
  10158. if (i > 0) output.comma();
  10159. name.print(output);
  10160. // If the final element is a hole, we need to make sure it
  10161. // doesn't look like a trailing comma, by inserting an actual
  10162. // trailing comma.
  10163. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  10164. });
  10165. output.print(self.is_array ? "]" : "}");
  10166. });
  10167. DEFPRINT(AST_Debugger, function(self, output) {
  10168. output.print("debugger");
  10169. output.semicolon();
  10170. });
  10171. /* -----[ statements ]----- */
  10172. function display_body(body, is_toplevel, output, allow_directives) {
  10173. var last = body.length - 1;
  10174. output.in_directive = allow_directives;
  10175. body.forEach(function(stmt, i) {
  10176. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  10177. stmt instanceof AST_EmptyStatement ||
  10178. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  10179. )) {
  10180. output.in_directive = false;
  10181. }
  10182. if (!(stmt instanceof AST_EmptyStatement)) {
  10183. output.indent();
  10184. stmt.print(output);
  10185. if (!(i == last && is_toplevel)) {
  10186. output.newline();
  10187. if (is_toplevel) output.newline();
  10188. }
  10189. }
  10190. if (output.in_directive === true &&
  10191. stmt instanceof AST_SimpleStatement &&
  10192. stmt.body instanceof AST_String
  10193. ) {
  10194. output.in_directive = false;
  10195. }
  10196. });
  10197. output.in_directive = false;
  10198. }
  10199. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  10200. print_maybe_braced_body(this.body, output);
  10201. });
  10202. DEFPRINT(AST_Statement, function(self, output) {
  10203. self.body.print(output);
  10204. output.semicolon();
  10205. });
  10206. DEFPRINT(AST_Toplevel, function(self, output) {
  10207. display_body(self.body, true, output, true);
  10208. output.print("");
  10209. });
  10210. DEFPRINT(AST_LabeledStatement, function(self, output) {
  10211. self.label.print(output);
  10212. output.colon();
  10213. self.body.print(output);
  10214. });
  10215. DEFPRINT(AST_SimpleStatement, function(self, output) {
  10216. self.body.print(output);
  10217. output.semicolon();
  10218. });
  10219. function print_braced_empty(self, output) {
  10220. output.print("{");
  10221. output.with_indent(output.next_indent(), function() {
  10222. output.append_comments(self, true);
  10223. });
  10224. output.add_mapping(self.end);
  10225. output.print("}");
  10226. }
  10227. function print_braced(self, output, allow_directives) {
  10228. if (self.body.length > 0) {
  10229. output.with_block(function() {
  10230. display_body(self.body, false, output, allow_directives);
  10231. output.add_mapping(self.end);
  10232. });
  10233. } else print_braced_empty(self, output);
  10234. }
  10235. DEFPRINT(AST_BlockStatement, function(self, output) {
  10236. print_braced(self, output);
  10237. });
  10238. DEFPRINT(AST_EmptyStatement, function(self, output) {
  10239. output.semicolon();
  10240. });
  10241. DEFPRINT(AST_Do, function(self, output) {
  10242. output.print("do");
  10243. output.space();
  10244. make_block(self.body, output);
  10245. output.space();
  10246. output.print("while");
  10247. output.space();
  10248. output.with_parens(function() {
  10249. self.condition.print(output);
  10250. });
  10251. output.semicolon();
  10252. });
  10253. DEFPRINT(AST_While, function(self, output) {
  10254. output.print("while");
  10255. output.space();
  10256. output.with_parens(function() {
  10257. self.condition.print(output);
  10258. });
  10259. output.space();
  10260. self._do_print_body(output);
  10261. });
  10262. DEFPRINT(AST_For, function(self, output) {
  10263. output.print("for");
  10264. output.space();
  10265. output.with_parens(function() {
  10266. if (self.init) {
  10267. if (self.init instanceof AST_DefinitionsLike) {
  10268. self.init.print(output);
  10269. } else {
  10270. parenthesize_for_noin(self.init, output, true);
  10271. }
  10272. output.print(";");
  10273. output.space();
  10274. } else {
  10275. output.print(";");
  10276. }
  10277. if (self.condition) {
  10278. self.condition.print(output);
  10279. output.print(";");
  10280. output.space();
  10281. } else {
  10282. output.print(";");
  10283. }
  10284. if (self.step) {
  10285. self.step.print(output);
  10286. }
  10287. });
  10288. output.space();
  10289. self._do_print_body(output);
  10290. });
  10291. DEFPRINT(AST_ForIn, function(self, output) {
  10292. output.print("for");
  10293. if (self.await) {
  10294. output.space();
  10295. output.print("await");
  10296. }
  10297. output.space();
  10298. output.with_parens(function() {
  10299. self.init.print(output);
  10300. output.space();
  10301. output.print(self instanceof AST_ForOf ? "of" : "in");
  10302. output.space();
  10303. self.object.print(output);
  10304. });
  10305. output.space();
  10306. self._do_print_body(output);
  10307. });
  10308. DEFPRINT(AST_With, function(self, output) {
  10309. output.print("with");
  10310. output.space();
  10311. output.with_parens(function() {
  10312. self.expression.print(output);
  10313. });
  10314. output.space();
  10315. self._do_print_body(output);
  10316. });
  10317. /* -----[ functions ]----- */
  10318. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  10319. var self = this;
  10320. if (!nokeyword) {
  10321. if (self.async) {
  10322. output.print("async");
  10323. output.space();
  10324. }
  10325. output.print("function");
  10326. if (self.is_generator) {
  10327. output.star();
  10328. }
  10329. if (self.name) {
  10330. output.space();
  10331. }
  10332. }
  10333. if (self.name instanceof AST_Symbol) {
  10334. self.name.print(output);
  10335. } else if (nokeyword && self.name instanceof AST_Node) {
  10336. output.with_square(function() {
  10337. self.name.print(output); // Computed method name
  10338. });
  10339. }
  10340. output.with_parens(function() {
  10341. self.argnames.forEach(function(arg, i) {
  10342. if (i) output.comma();
  10343. arg.print(output);
  10344. });
  10345. });
  10346. output.space();
  10347. print_braced(self, output, true);
  10348. });
  10349. DEFPRINT(AST_Lambda, function(self, output) {
  10350. self._do_print(output);
  10351. output.gc_scope(self);
  10352. });
  10353. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  10354. var tag = self.prefix;
  10355. var parenthesize_tag = tag instanceof AST_Lambda
  10356. || tag instanceof AST_Binary
  10357. || tag instanceof AST_Conditional
  10358. || tag instanceof AST_Sequence
  10359. || tag instanceof AST_Unary
  10360. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  10361. if (parenthesize_tag) output.print("(");
  10362. self.prefix.print(output);
  10363. if (parenthesize_tag) output.print(")");
  10364. self.template_string.print(output);
  10365. });
  10366. DEFPRINT(AST_TemplateString, function(self, output) {
  10367. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  10368. output.print("`");
  10369. for (var i = 0; i < self.segments.length; i++) {
  10370. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  10371. output.print("${");
  10372. self.segments[i].print(output);
  10373. output.print("}");
  10374. } else if (is_tagged) {
  10375. output.print(self.segments[i].raw);
  10376. } else {
  10377. output.print_template_string_chars(self.segments[i].value);
  10378. }
  10379. }
  10380. output.print("`");
  10381. });
  10382. DEFPRINT(AST_TemplateSegment, function(self, output) {
  10383. output.print_template_string_chars(self.value);
  10384. });
  10385. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  10386. var self = this;
  10387. var parent = output.parent();
  10388. var needs_parens = (parent instanceof AST_Binary &&
  10389. !(parent instanceof AST_Assign) &&
  10390. !(parent instanceof AST_DefaultAssign)) ||
  10391. parent instanceof AST_Unary ||
  10392. (parent instanceof AST_Call && self === parent.expression);
  10393. if (needs_parens) { output.print("("); }
  10394. if (self.async) {
  10395. output.print("async");
  10396. output.space();
  10397. }
  10398. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  10399. self.argnames[0].print(output);
  10400. } else {
  10401. output.with_parens(function() {
  10402. self.argnames.forEach(function(arg, i) {
  10403. if (i) output.comma();
  10404. arg.print(output);
  10405. });
  10406. });
  10407. }
  10408. output.space();
  10409. output.print("=>");
  10410. output.space();
  10411. const first_statement = self.body[0];
  10412. if (
  10413. self.body.length === 1
  10414. && first_statement instanceof AST_Return
  10415. ) {
  10416. const returned = first_statement.value;
  10417. if (!returned) {
  10418. output.print("{}");
  10419. } else if (left_is_object(returned)) {
  10420. output.print("(");
  10421. returned.print(output);
  10422. output.print(")");
  10423. } else {
  10424. returned.print(output);
  10425. }
  10426. } else {
  10427. print_braced(self, output);
  10428. }
  10429. if (needs_parens) { output.print(")"); }
  10430. output.gc_scope(self);
  10431. });
  10432. /* -----[ exits ]----- */
  10433. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  10434. output.print(kind);
  10435. if (this.value) {
  10436. output.space();
  10437. const comments = this.value.start.comments_before;
  10438. if (comments && comments.length && !output.printed_comments.has(comments)) {
  10439. output.print("(");
  10440. this.value.print(output);
  10441. output.print(")");
  10442. } else {
  10443. this.value.print(output);
  10444. }
  10445. }
  10446. output.semicolon();
  10447. });
  10448. DEFPRINT(AST_Return, function(self, output) {
  10449. self._do_print(output, "return");
  10450. });
  10451. DEFPRINT(AST_Throw, function(self, output) {
  10452. self._do_print(output, "throw");
  10453. });
  10454. /* -----[ yield ]----- */
  10455. DEFPRINT(AST_Yield, function(self, output) {
  10456. var star = self.is_star ? "*" : "";
  10457. output.print("yield" + star);
  10458. if (self.expression) {
  10459. output.space();
  10460. self.expression.print(output);
  10461. }
  10462. });
  10463. DEFPRINT(AST_Await, function(self, output) {
  10464. output.print("await");
  10465. output.space();
  10466. var e = self.expression;
  10467. var parens = !(
  10468. e instanceof AST_Call
  10469. || e instanceof AST_SymbolRef
  10470. || e instanceof AST_PropAccess
  10471. || e instanceof AST_Unary
  10472. || e instanceof AST_Constant
  10473. || e instanceof AST_Await
  10474. || e instanceof AST_Object
  10475. );
  10476. if (parens) output.print("(");
  10477. self.expression.print(output);
  10478. if (parens) output.print(")");
  10479. });
  10480. /* -----[ loop control ]----- */
  10481. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  10482. output.print(kind);
  10483. if (this.label) {
  10484. output.space();
  10485. this.label.print(output);
  10486. }
  10487. output.semicolon();
  10488. });
  10489. DEFPRINT(AST_Break, function(self, output) {
  10490. self._do_print(output, "break");
  10491. });
  10492. DEFPRINT(AST_Continue, function(self, output) {
  10493. self._do_print(output, "continue");
  10494. });
  10495. /* -----[ if ]----- */
  10496. function make_then(self, output) {
  10497. var b = self.body;
  10498. if (output.option("braces")
  10499. || output.option("ie8") && b instanceof AST_Do)
  10500. return make_block(b, output);
  10501. // The squeezer replaces "block"-s that contain only a single
  10502. // statement with the statement itself; technically, the AST
  10503. // is correct, but this can create problems when we output an
  10504. // IF having an ELSE clause where the THEN clause ends in an
  10505. // IF *without* an ELSE block (then the outer ELSE would refer
  10506. // to the inner IF). This function checks for this case and
  10507. // adds the block braces if needed.
  10508. if (!b) return output.force_semicolon();
  10509. while (true) {
  10510. if (b instanceof AST_If) {
  10511. if (!b.alternative) {
  10512. make_block(self.body, output);
  10513. return;
  10514. }
  10515. b = b.alternative;
  10516. } else if (b instanceof AST_StatementWithBody) {
  10517. b = b.body;
  10518. } else break;
  10519. }
  10520. print_maybe_braced_body(self.body, output);
  10521. }
  10522. DEFPRINT(AST_If, function(self, output) {
  10523. output.print("if");
  10524. output.space();
  10525. output.with_parens(function() {
  10526. self.condition.print(output);
  10527. });
  10528. output.space();
  10529. if (self.alternative) {
  10530. make_then(self, output);
  10531. output.space();
  10532. output.print("else");
  10533. output.space();
  10534. if (self.alternative instanceof AST_If)
  10535. self.alternative.print(output);
  10536. else
  10537. print_maybe_braced_body(self.alternative, output);
  10538. } else {
  10539. self._do_print_body(output);
  10540. }
  10541. });
  10542. /* -----[ switch ]----- */
  10543. DEFPRINT(AST_Switch, function(self, output) {
  10544. output.print("switch");
  10545. output.space();
  10546. output.with_parens(function() {
  10547. self.expression.print(output);
  10548. });
  10549. output.space();
  10550. var last = self.body.length - 1;
  10551. if (last < 0) print_braced_empty(self, output);
  10552. else output.with_block(function() {
  10553. self.body.forEach(function(branch, i) {
  10554. output.indent(true);
  10555. branch.print(output);
  10556. if (i < last && branch.body.length > 0)
  10557. output.newline();
  10558. });
  10559. });
  10560. });
  10561. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  10562. output.newline();
  10563. this.body.forEach(function(stmt) {
  10564. output.indent();
  10565. stmt.print(output);
  10566. output.newline();
  10567. });
  10568. });
  10569. DEFPRINT(AST_Default, function(self, output) {
  10570. output.print("default:");
  10571. self._do_print_body(output);
  10572. });
  10573. DEFPRINT(AST_Case, function(self, output) {
  10574. output.print("case");
  10575. output.space();
  10576. self.expression.print(output);
  10577. output.print(":");
  10578. self._do_print_body(output);
  10579. });
  10580. /* -----[ exceptions ]----- */
  10581. DEFPRINT(AST_Try, function(self, output) {
  10582. output.print("try");
  10583. output.space();
  10584. self.body.print(output);
  10585. if (self.bcatch) {
  10586. output.space();
  10587. self.bcatch.print(output);
  10588. }
  10589. if (self.bfinally) {
  10590. output.space();
  10591. self.bfinally.print(output);
  10592. }
  10593. });
  10594. DEFPRINT(AST_TryBlock, function(self, output) {
  10595. print_braced(self, output);
  10596. });
  10597. DEFPRINT(AST_Catch, function(self, output) {
  10598. output.print("catch");
  10599. if (self.argname) {
  10600. output.space();
  10601. output.with_parens(function() {
  10602. self.argname.print(output);
  10603. });
  10604. }
  10605. output.space();
  10606. print_braced(self, output);
  10607. });
  10608. DEFPRINT(AST_Finally, function(self, output) {
  10609. output.print("finally");
  10610. output.space();
  10611. print_braced(self, output);
  10612. });
  10613. /* -----[ var/const ]----- */
  10614. AST_DefinitionsLike.DEFMETHOD("_do_print", function(output, kind) {
  10615. output.print(kind);
  10616. output.space();
  10617. this.definitions.forEach(function(def, i) {
  10618. if (i) output.comma();
  10619. def.print(output);
  10620. });
  10621. var p = output.parent();
  10622. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  10623. var output_semicolon = !in_for || p && p.init !== this;
  10624. if (output_semicolon)
  10625. output.semicolon();
  10626. });
  10627. DEFPRINT(AST_Let, function(self, output) {
  10628. self._do_print(output, "let");
  10629. });
  10630. DEFPRINT(AST_Var, function(self, output) {
  10631. self._do_print(output, "var");
  10632. });
  10633. DEFPRINT(AST_Const, function(self, output) {
  10634. self._do_print(output, "const");
  10635. });
  10636. DEFPRINT(AST_Using, function(self, output) {
  10637. self._do_print(output, self.await ? "await using" : "using");
  10638. });
  10639. DEFPRINT(AST_Import, function(self, output) {
  10640. output.print("import");
  10641. output.space();
  10642. if (self.phase) {
  10643. output.print(self.phase);
  10644. output.space();
  10645. }
  10646. if (self.imported_name) {
  10647. self.imported_name.print(output);
  10648. }
  10649. if (self.imported_name && self.imported_names) {
  10650. output.print(",");
  10651. output.space();
  10652. }
  10653. if (self.imported_names) {
  10654. if (self.imported_names.length === 1 &&
  10655. self.imported_names[0].foreign_name.name === "*" &&
  10656. !self.imported_names[0].foreign_name.quote) {
  10657. self.imported_names[0].print(output);
  10658. } else {
  10659. output.print("{");
  10660. self.imported_names.forEach(function (name_import, i) {
  10661. output.space();
  10662. name_import.print(output);
  10663. if (i < self.imported_names.length - 1) {
  10664. output.print(",");
  10665. }
  10666. });
  10667. output.space();
  10668. output.print("}");
  10669. }
  10670. }
  10671. if (self.imported_name || self.imported_names) {
  10672. output.space();
  10673. output.print("from");
  10674. output.space();
  10675. }
  10676. self.module_name.print(output);
  10677. if (self.attributes) {
  10678. output.print("with");
  10679. self.attributes.print(output);
  10680. }
  10681. output.semicolon();
  10682. });
  10683. DEFPRINT(AST_ImportMeta, function(self, output) {
  10684. output.print("import.meta");
  10685. });
  10686. DEFPRINT(AST_DynamicImport, function(self, output) {
  10687. if (self.phase) output.print("import." + self.phase);
  10688. else output.print("import");
  10689. output.with_parens(function() {
  10690. self.args.forEach(function(arg, i) {
  10691. if (i) output.comma();
  10692. arg.print(output);
  10693. });
  10694. });
  10695. });
  10696. DEFPRINT(AST_NameMapping, function(self, output) {
  10697. var is_import = output.parent() instanceof AST_Import;
  10698. var definition = self.name.definition();
  10699. var foreign_name = self.foreign_name;
  10700. var names_are_different =
  10701. (definition && definition.mangled_name || self.name.name) !==
  10702. foreign_name.name;
  10703. if (!names_are_different &&
  10704. foreign_name.name === "*" &&
  10705. !!foreign_name.quote != !!self.name.quote) {
  10706. // export * as "*"
  10707. names_are_different = true;
  10708. }
  10709. var foreign_name_is_name = !foreign_name.quote;
  10710. if (names_are_different) {
  10711. if (is_import) {
  10712. if (foreign_name_is_name) {
  10713. output.print(foreign_name.name);
  10714. } else {
  10715. output.print_string(foreign_name.name, foreign_name.quote);
  10716. }
  10717. } else {
  10718. if (!self.name.quote) {
  10719. self.name.print(output);
  10720. } else {
  10721. output.print_string(self.name.name, self.name.quote);
  10722. }
  10723. }
  10724. output.space();
  10725. output.print("as");
  10726. output.space();
  10727. if (is_import) {
  10728. self.name.print(output);
  10729. } else {
  10730. if (foreign_name_is_name) {
  10731. output.print(foreign_name.name);
  10732. } else {
  10733. output.print_string(foreign_name.name, foreign_name.quote);
  10734. }
  10735. }
  10736. } else {
  10737. if (!self.name.quote) {
  10738. self.name.print(output);
  10739. } else {
  10740. output.print_string(self.name.name, self.name.quote);
  10741. }
  10742. }
  10743. });
  10744. DEFPRINT(AST_Export, function(self, output) {
  10745. output.print("export");
  10746. output.space();
  10747. if (self.is_default) {
  10748. output.print("default");
  10749. output.space();
  10750. }
  10751. if (self.exported_names) {
  10752. if (self.exported_names.length === 1 &&
  10753. self.exported_names[0].name.name === "*" &&
  10754. !self.exported_names[0].name.quote) {
  10755. self.exported_names[0].print(output);
  10756. } else {
  10757. output.print("{");
  10758. self.exported_names.forEach(function(name_export, i) {
  10759. output.space();
  10760. name_export.print(output);
  10761. if (i < self.exported_names.length - 1) {
  10762. output.print(",");
  10763. }
  10764. });
  10765. output.space();
  10766. output.print("}");
  10767. }
  10768. } else if (self.exported_value) {
  10769. self.exported_value.print(output);
  10770. } else if (self.exported_definition) {
  10771. self.exported_definition.print(output);
  10772. if (self.exported_definition instanceof AST_Definitions) return;
  10773. }
  10774. if (self.module_name) {
  10775. output.space();
  10776. output.print("from");
  10777. output.space();
  10778. self.module_name.print(output);
  10779. }
  10780. if (self.attributes) {
  10781. output.print("with");
  10782. self.attributes.print(output);
  10783. }
  10784. if (self.exported_value
  10785. && !(self.exported_value instanceof AST_Defun ||
  10786. self.exported_value instanceof AST_Function ||
  10787. self.exported_value instanceof AST_Class)
  10788. || self.module_name
  10789. || self.exported_names
  10790. ) {
  10791. output.semicolon();
  10792. }
  10793. });
  10794. function parenthesize_for_noin(node, output, noin) {
  10795. var parens = false;
  10796. // need to take some precautions here:
  10797. // https://github.com/mishoo/UglifyJS2/issues/60
  10798. if (noin) {
  10799. parens = walk(node, node => {
  10800. // Don't go into scopes -- except arrow functions:
  10801. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  10802. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  10803. return true;
  10804. }
  10805. if (
  10806. node instanceof AST_Binary && node.operator == "in"
  10807. || node instanceof AST_PrivateIn
  10808. ) {
  10809. return walk_abort; // makes walk() return true
  10810. }
  10811. });
  10812. }
  10813. node.print(output, parens);
  10814. }
  10815. DEFPRINT(AST_VarDefLike, function(self, output) {
  10816. self.name.print(output);
  10817. if (self.value) {
  10818. output.space();
  10819. output.print("=");
  10820. output.space();
  10821. var p = output.parent(1);
  10822. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  10823. parenthesize_for_noin(self.value, output, noin);
  10824. }
  10825. });
  10826. /* -----[ other expressions ]----- */
  10827. DEFPRINT(AST_Call, function(self, output) {
  10828. self.expression.print(output);
  10829. if (self instanceof AST_New && self.args.length === 0)
  10830. return;
  10831. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  10832. output.add_mapping(self.start);
  10833. }
  10834. if (self.optional) output.print("?.");
  10835. output.with_parens(function() {
  10836. self.args.forEach(function(expr, i) {
  10837. if (i) output.comma();
  10838. expr.print(output);
  10839. });
  10840. });
  10841. });
  10842. DEFPRINT(AST_New, function(self, output) {
  10843. output.print("new");
  10844. output.space();
  10845. AST_Call.prototype._codegen(self, output);
  10846. });
  10847. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  10848. this.expressions.forEach(function(node, index) {
  10849. if (index > 0) {
  10850. output.comma();
  10851. if (output.should_break()) {
  10852. output.newline();
  10853. output.indent();
  10854. }
  10855. }
  10856. node.print(output);
  10857. });
  10858. });
  10859. DEFPRINT(AST_Sequence, function(self, output) {
  10860. self._do_print(output);
  10861. // var p = output.parent();
  10862. // if (p instanceof AST_Statement) {
  10863. // output.with_indent(output.next_indent(), function(){
  10864. // self._do_print(output);
  10865. // });
  10866. // } else {
  10867. // self._do_print(output);
  10868. // }
  10869. });
  10870. DEFPRINT(AST_Dot, function(self, output) {
  10871. var expr = self.expression;
  10872. expr.print(output);
  10873. var prop = self.property;
  10874. var print_computed = ALL_RESERVED_WORDS.has(prop)
  10875. ? output.option("ie8")
  10876. : !is_identifier_string(
  10877. prop,
  10878. output.option("ecma") >= 2015 && !output.option("safari10")
  10879. );
  10880. if (self.optional) output.print("?.");
  10881. if (print_computed) {
  10882. output.print("[");
  10883. output.add_mapping(self.end);
  10884. output.print_string(prop);
  10885. output.print("]");
  10886. } else {
  10887. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  10888. if (!/[xa-f.)]/i.test(output.last())) {
  10889. output.print(".");
  10890. }
  10891. }
  10892. if (!self.optional) output.print(".");
  10893. // the name after dot would be mapped about here.
  10894. output.add_mapping(self.end);
  10895. output.print_name(prop);
  10896. }
  10897. });
  10898. DEFPRINT(AST_DotHash, function(self, output) {
  10899. var expr = self.expression;
  10900. expr.print(output);
  10901. var prop = self.property;
  10902. if (self.optional) output.print("?");
  10903. output.print(".#");
  10904. output.add_mapping(self.end);
  10905. output.print_name(prop);
  10906. });
  10907. DEFPRINT(AST_Sub, function(self, output) {
  10908. self.expression.print(output);
  10909. if (self.optional) output.print("?.");
  10910. output.print("[");
  10911. self.property.print(output);
  10912. output.print("]");
  10913. });
  10914. DEFPRINT(AST_Chain, function(self, output) {
  10915. self.expression.print(output);
  10916. });
  10917. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  10918. var op = self.operator;
  10919. if (op === "--" && output.last().endsWith("!")) {
  10920. // avoid printing "<!--"
  10921. output.print(" ");
  10922. }
  10923. output.print(op);
  10924. if (/^[a-z]/i.test(op)
  10925. || (/[+-]$/.test(op)
  10926. && self.expression instanceof AST_UnaryPrefix
  10927. && /^[+-]/.test(self.expression.operator))) {
  10928. output.space();
  10929. }
  10930. self.expression.print(output);
  10931. });
  10932. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  10933. self.expression.print(output);
  10934. output.print(self.operator);
  10935. });
  10936. DEFPRINT(AST_Binary, function(self, output) {
  10937. var op = self.operator;
  10938. self.left.print(output);
  10939. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  10940. && output.last().endsWith("--")) {
  10941. // space is mandatory to avoid outputting -->
  10942. output.print(" ");
  10943. } else {
  10944. // the space is optional depending on "beautify"
  10945. output.space();
  10946. }
  10947. output.print(op);
  10948. output.space();
  10949. self.right.print(output);
  10950. });
  10951. DEFPRINT(AST_Conditional, function(self, output) {
  10952. self.condition.print(output);
  10953. output.space();
  10954. output.print("?");
  10955. output.space();
  10956. self.consequent.print(output);
  10957. output.space();
  10958. output.colon();
  10959. self.alternative.print(output);
  10960. });
  10961. /* -----[ literals ]----- */
  10962. DEFPRINT(AST_Array, function(self, output) {
  10963. output.with_square(function() {
  10964. var a = self.elements, len = a.length;
  10965. if (len > 0) output.space();
  10966. a.forEach(function(exp, i) {
  10967. if (i) output.comma();
  10968. exp.print(output);
  10969. // If the final element is a hole, we need to make sure it
  10970. // doesn't look like a trailing comma, by inserting an actual
  10971. // trailing comma.
  10972. if (i === len - 1 && exp instanceof AST_Hole)
  10973. output.comma();
  10974. });
  10975. if (len > 0) output.space();
  10976. });
  10977. });
  10978. DEFPRINT(AST_Object, function(self, output) {
  10979. if (self.properties.length > 0) output.with_block(function() {
  10980. self.properties.forEach(function(prop, i) {
  10981. if (i) {
  10982. output.print(",");
  10983. output.newline();
  10984. }
  10985. output.indent();
  10986. prop.print(output);
  10987. });
  10988. output.newline();
  10989. });
  10990. else print_braced_empty(self, output);
  10991. });
  10992. DEFPRINT(AST_Class, function(self, output) {
  10993. output.print("class");
  10994. output.space();
  10995. if (self.name) {
  10996. self.name.print(output);
  10997. output.space();
  10998. }
  10999. if (self.extends) {
  11000. var parens = (
  11001. !(self.extends instanceof AST_SymbolRef)
  11002. && !(self.extends instanceof AST_PropAccess)
  11003. && !(self.extends instanceof AST_ClassExpression)
  11004. && !(self.extends instanceof AST_Function)
  11005. );
  11006. output.print("extends");
  11007. if (parens) {
  11008. output.print("(");
  11009. } else {
  11010. output.space();
  11011. }
  11012. self.extends.print(output);
  11013. if (parens) {
  11014. output.print(")");
  11015. } else {
  11016. output.space();
  11017. }
  11018. }
  11019. if (self.properties.length > 0) output.with_block(function() {
  11020. self.properties.forEach(function(prop, i) {
  11021. if (i) {
  11022. output.newline();
  11023. }
  11024. output.indent();
  11025. prop.print(output);
  11026. });
  11027. output.newline();
  11028. });
  11029. else output.print("{}");
  11030. });
  11031. DEFPRINT(AST_NewTarget, function(self, output) {
  11032. output.print("new.target");
  11033. });
  11034. /** Prints a prop name. Returns whether it can be used as a shorthand. */
  11035. function print_property_name(key, quote, output) {
  11036. if (output.option("quote_keys")) {
  11037. output.print_string(key);
  11038. return false;
  11039. }
  11040. if ("" + +key == key && key >= 0) {
  11041. if (output.option("keep_numbers")) {
  11042. output.print(key);
  11043. return false;
  11044. }
  11045. output.print(make_num(key));
  11046. return false;
  11047. }
  11048. var print_string = ALL_RESERVED_WORDS.has(key)
  11049. ? output.option("ie8")
  11050. : (
  11051. output.option("ecma") < 2015 || output.option("safari10")
  11052. ? !is_basic_identifier_string(key)
  11053. : !is_identifier_string(key, true)
  11054. );
  11055. if (print_string || (quote && output.option("keep_quoted_props"))) {
  11056. output.print_string(key, quote);
  11057. return false;
  11058. }
  11059. output.print_name(key);
  11060. return true;
  11061. }
  11062. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  11063. function get_name(self) {
  11064. var def = self.definition();
  11065. return def ? def.mangled_name || def.name : self.name;
  11066. }
  11067. const try_shorthand = output.option("shorthand") && !(self.key instanceof AST_Node);
  11068. if (
  11069. try_shorthand
  11070. && self.value instanceof AST_Symbol
  11071. && get_name(self.value) === self.key
  11072. && !ALL_RESERVED_WORDS.has(self.key)
  11073. ) {
  11074. const was_shorthand = print_property_name(self.key, self.quote, output);
  11075. if (!was_shorthand) {
  11076. output.colon();
  11077. self.value.print(output);
  11078. }
  11079. } else if (
  11080. try_shorthand
  11081. && self.value instanceof AST_DefaultAssign
  11082. && self.value.left instanceof AST_Symbol
  11083. && get_name(self.value.left) === self.key
  11084. ) {
  11085. const was_shorthand = print_property_name(self.key, self.quote, output);
  11086. if (!was_shorthand) {
  11087. output.colon();
  11088. self.value.left.print(output);
  11089. }
  11090. output.space();
  11091. output.print("=");
  11092. output.space();
  11093. self.value.right.print(output);
  11094. } else {
  11095. if (!(self.key instanceof AST_Node)) {
  11096. print_property_name(self.key, self.quote, output);
  11097. } else {
  11098. output.with_square(function() {
  11099. self.key.print(output);
  11100. });
  11101. }
  11102. output.colon();
  11103. self.value.print(output);
  11104. }
  11105. });
  11106. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  11107. if (self.static) {
  11108. output.print("static");
  11109. output.space();
  11110. }
  11111. output.print("#");
  11112. print_property_name(self.key.name, undefined, output);
  11113. if (self.value) {
  11114. output.print("=");
  11115. self.value.print(output);
  11116. }
  11117. output.semicolon();
  11118. });
  11119. DEFPRINT(AST_ClassProperty, (self, output) => {
  11120. if (self.static) {
  11121. output.print("static");
  11122. output.space();
  11123. }
  11124. if (self.key instanceof AST_SymbolClassProperty) {
  11125. print_property_name(self.key.name, self.quote, output);
  11126. } else {
  11127. output.print("[");
  11128. self.key.print(output);
  11129. output.print("]");
  11130. }
  11131. if (self.value) {
  11132. output.print("=");
  11133. self.value.print(output);
  11134. }
  11135. output.semicolon();
  11136. });
  11137. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  11138. var self = this;
  11139. if (self.static) {
  11140. output.print("static");
  11141. output.space();
  11142. }
  11143. if (type) {
  11144. output.print(type);
  11145. output.space();
  11146. }
  11147. if (self.key instanceof AST_SymbolMethod) {
  11148. if (is_private) output.print("#");
  11149. print_property_name(self.key.name, self.quote, output);
  11150. self.key.add_source_map(output);
  11151. } else {
  11152. output.with_square(function() {
  11153. self.key.print(output);
  11154. });
  11155. }
  11156. self.value._do_print(output, true);
  11157. });
  11158. DEFPRINT(AST_ObjectSetter, function(self, output) {
  11159. self._print_getter_setter("set", false, output);
  11160. });
  11161. DEFPRINT(AST_ObjectGetter, function(self, output) {
  11162. self._print_getter_setter("get", false, output);
  11163. });
  11164. DEFPRINT(AST_PrivateSetter, function(self, output) {
  11165. self._print_getter_setter("set", true, output);
  11166. });
  11167. DEFPRINT(AST_PrivateGetter, function(self, output) {
  11168. self._print_getter_setter("get", true, output);
  11169. });
  11170. DEFPRINT(AST_ConciseMethod, function(self, output) {
  11171. var type;
  11172. if (self.value.is_generator && self.value.async) {
  11173. type = "async*";
  11174. } else if (self.value.is_generator) {
  11175. type = "*";
  11176. } else if (self.value.async) {
  11177. type = "async";
  11178. }
  11179. self._print_getter_setter(type, false, output);
  11180. });
  11181. DEFPRINT(AST_PrivateMethod, function(self, output) {
  11182. var type;
  11183. if (self.value.is_generator && self.value.async) {
  11184. type = "async*";
  11185. } else if (self.value.is_generator) {
  11186. type = "*";
  11187. } else if (self.value.async) {
  11188. type = "async";
  11189. }
  11190. self._print_getter_setter(type, true, output);
  11191. });
  11192. DEFPRINT(AST_PrivateIn, function(self, output) {
  11193. self.key.print(output);
  11194. output.space();
  11195. output.print("in");
  11196. output.space();
  11197. self.value.print(output);
  11198. });
  11199. DEFPRINT(AST_SymbolPrivateProperty, function(self, output) {
  11200. output.print("#" + self.name);
  11201. });
  11202. DEFPRINT(AST_ClassStaticBlock, function (self, output) {
  11203. output.print("static");
  11204. output.space();
  11205. print_braced(self, output);
  11206. });
  11207. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  11208. var def = this.definition();
  11209. output.print_name(def ? def.mangled_name || def.name : this.name);
  11210. });
  11211. DEFPRINT(AST_Symbol, function (self, output) {
  11212. self._do_print(output);
  11213. });
  11214. DEFPRINT(AST_Hole, noop);
  11215. DEFPRINT(AST_This, function(self, output) {
  11216. output.print("this");
  11217. });
  11218. DEFPRINT(AST_Super, function(self, output) {
  11219. output.print("super");
  11220. });
  11221. DEFPRINT(AST_Constant, function(self, output) {
  11222. output.print(self.getValue());
  11223. });
  11224. DEFPRINT(AST_String, function(self, output) {
  11225. output.print_string(self.getValue(), self.quote, output.in_directive);
  11226. });
  11227. DEFPRINT(AST_Number, function(self, output) {
  11228. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  11229. output.print(self.raw);
  11230. } else {
  11231. output.print(make_num(self.getValue()));
  11232. }
  11233. });
  11234. DEFPRINT(AST_BigInt, function(self, output) {
  11235. if (output.option("keep_numbers") && self.raw) {
  11236. output.print(self.raw);
  11237. } else {
  11238. output.print(self.getValue() + "n");
  11239. }
  11240. });
  11241. const r_slash_script = /(<\s*\/\s*script)/i;
  11242. const r_starts_with_script = /^\s*script/i;
  11243. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  11244. DEFPRINT(AST_RegExp, function(self, output) {
  11245. let { source, flags } = self.getValue();
  11246. source = regexp_source_fix(source);
  11247. flags = flags ? sort_regexp_flags(flags) : "";
  11248. // Avoid outputting end of script tag
  11249. source = source.replace(r_slash_script, slash_script_replace);
  11250. if (r_starts_with_script.test(source) && output.last().endsWith("<")) {
  11251. output.print(" ");
  11252. }
  11253. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  11254. const parent = output.parent();
  11255. if (
  11256. parent instanceof AST_Binary
  11257. && /^\w/.test(parent.operator)
  11258. && parent.left === self
  11259. ) {
  11260. output.print(" ");
  11261. }
  11262. });
  11263. /** if, for, while, may or may not have braces surrounding its body */
  11264. function print_maybe_braced_body(stat, output) {
  11265. if (output.option("braces")) {
  11266. make_block(stat, output);
  11267. } else {
  11268. if (!stat || stat instanceof AST_EmptyStatement)
  11269. output.force_semicolon();
  11270. else if ((stat instanceof AST_DefinitionsLike && !(stat instanceof AST_Var)) || stat instanceof AST_Class)
  11271. make_block(stat, output);
  11272. else
  11273. stat.print(output);
  11274. }
  11275. }
  11276. function best_of(a) {
  11277. var best = a[0], len = best.length;
  11278. for (var i = 1; i < a.length; ++i) {
  11279. if (a[i].length < len) {
  11280. best = a[i];
  11281. len = best.length;
  11282. }
  11283. }
  11284. return best;
  11285. }
  11286. function make_num(num) {
  11287. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  11288. var candidates = [ str ];
  11289. if (Math.floor(num) === num) {
  11290. if (num < 0) {
  11291. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  11292. } else {
  11293. candidates.push("0x" + num.toString(16).toLowerCase());
  11294. }
  11295. }
  11296. var match, len, digits;
  11297. if (match = /^\.0+/.exec(str)) {
  11298. len = match[0].length;
  11299. digits = str.slice(len);
  11300. candidates.push(digits + "e-" + (digits.length + len - 1));
  11301. } else if (match = /0+$/.exec(str)) {
  11302. len = match[0].length;
  11303. candidates.push(str.slice(0, -len) + "e" + len);
  11304. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  11305. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  11306. }
  11307. return best_of(candidates);
  11308. }
  11309. function make_block(stmt, output) {
  11310. if (!stmt || stmt instanceof AST_EmptyStatement)
  11311. output.print("{}");
  11312. else if (stmt instanceof AST_BlockStatement)
  11313. stmt.print(output);
  11314. else output.with_block(function() {
  11315. output.indent();
  11316. stmt.print(output);
  11317. output.newline();
  11318. });
  11319. }
  11320. /* -----[ source map generators ]----- */
  11321. function DEFMAP(nodetype, generator) {
  11322. nodetype.forEach(function(nodetype) {
  11323. nodetype.DEFMETHOD("add_source_map", generator);
  11324. });
  11325. }
  11326. DEFMAP([
  11327. // We could easily add info for ALL nodes, but it seems to me that
  11328. // would be quite wasteful, hence this noop in the base class.
  11329. AST_Node,
  11330. // since the label symbol will mark it
  11331. AST_LabeledStatement,
  11332. AST_Toplevel,
  11333. ], noop);
  11334. // XXX: I'm not exactly sure if we need it for all of these nodes,
  11335. // or if we should add even more.
  11336. DEFMAP([
  11337. AST_Array,
  11338. AST_BlockStatement,
  11339. AST_Catch,
  11340. AST_Class,
  11341. AST_Constant,
  11342. AST_Debugger,
  11343. AST_DefinitionsLike,
  11344. AST_Directive,
  11345. AST_Finally,
  11346. AST_Jump,
  11347. AST_Lambda,
  11348. AST_New,
  11349. AST_Object,
  11350. AST_StatementWithBody,
  11351. AST_Symbol,
  11352. AST_Switch,
  11353. AST_SwitchBranch,
  11354. AST_TemplateString,
  11355. AST_TemplateSegment,
  11356. AST_Try,
  11357. ], function(output) {
  11358. output.add_mapping(this.start);
  11359. });
  11360. DEFMAP([
  11361. AST_ObjectGetter,
  11362. AST_ObjectSetter,
  11363. AST_PrivateGetter,
  11364. AST_PrivateSetter,
  11365. AST_ConciseMethod,
  11366. AST_PrivateMethod,
  11367. ], function(output) {
  11368. output.add_mapping(this.start, false /*name handled below*/);
  11369. });
  11370. DEFMAP([
  11371. AST_SymbolMethod,
  11372. AST_SymbolPrivateProperty
  11373. ], function(output) {
  11374. const tok_type = this.end && this.end.type;
  11375. if (tok_type === "name" || tok_type === "privatename") {
  11376. output.add_mapping(this.end, this.name);
  11377. } else {
  11378. output.add_mapping(this.end);
  11379. }
  11380. });
  11381. DEFMAP([ AST_ObjectProperty ], function(output) {
  11382. output.add_mapping(this.start, this.key);
  11383. });
  11384. })();
  11385. const shallow_cmp = (node1, node2) => {
  11386. return (
  11387. node1 === null && node2 === null
  11388. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  11389. );
  11390. };
  11391. const equivalent_to = (tree1, tree2) => {
  11392. if (!shallow_cmp(tree1, tree2)) return false;
  11393. const walk_1_state = [tree1];
  11394. const walk_2_state = [tree2];
  11395. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  11396. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  11397. while (walk_1_state.length && walk_2_state.length) {
  11398. const node_1 = walk_1_state.pop();
  11399. const node_2 = walk_2_state.pop();
  11400. if (!shallow_cmp(node_1, node_2)) return false;
  11401. node_1._children_backwards(walk_1_push);
  11402. node_2._children_backwards(walk_2_push);
  11403. if (walk_1_state.length !== walk_2_state.length) {
  11404. // Different number of children
  11405. return false;
  11406. }
  11407. }
  11408. return walk_1_state.length == 0 && walk_2_state.length == 0;
  11409. };
  11410. const pass_through = () => true;
  11411. AST_Node.prototype.shallow_cmp = function () {
  11412. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  11413. };
  11414. AST_Debugger.prototype.shallow_cmp = pass_through;
  11415. AST_Directive.prototype.shallow_cmp = function(other) {
  11416. return this.value === other.value;
  11417. };
  11418. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  11419. AST_Block.prototype.shallow_cmp = pass_through;
  11420. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  11421. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  11422. return this.label.name === other.label.name;
  11423. };
  11424. AST_Do.prototype.shallow_cmp = pass_through;
  11425. AST_While.prototype.shallow_cmp = pass_through;
  11426. AST_For.prototype.shallow_cmp = function(other) {
  11427. return (this.init == null ? other.init == null : this.init === other.init) && (this.condition == null ? other.condition == null : this.condition === other.condition) && (this.step == null ? other.step == null : this.step === other.step);
  11428. };
  11429. AST_ForIn.prototype.shallow_cmp = pass_through;
  11430. AST_ForOf.prototype.shallow_cmp = pass_through;
  11431. AST_With.prototype.shallow_cmp = pass_through;
  11432. AST_Toplevel.prototype.shallow_cmp = pass_through;
  11433. AST_Expansion.prototype.shallow_cmp = pass_through;
  11434. AST_Lambda.prototype.shallow_cmp = function(other) {
  11435. return this.is_generator === other.is_generator && this.async === other.async;
  11436. };
  11437. AST_Destructuring.prototype.shallow_cmp = function(other) {
  11438. return this.is_array === other.is_array;
  11439. };
  11440. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  11441. AST_TemplateString.prototype.shallow_cmp = pass_through;
  11442. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  11443. return this.value === other.value;
  11444. };
  11445. AST_Jump.prototype.shallow_cmp = pass_through;
  11446. AST_LoopControl.prototype.shallow_cmp = pass_through;
  11447. AST_Await.prototype.shallow_cmp = pass_through;
  11448. AST_Yield.prototype.shallow_cmp = function(other) {
  11449. return this.is_star === other.is_star;
  11450. };
  11451. AST_If.prototype.shallow_cmp = function(other) {
  11452. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  11453. };
  11454. AST_Switch.prototype.shallow_cmp = pass_through;
  11455. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  11456. AST_Try.prototype.shallow_cmp = function(other) {
  11457. return (this.body === other.body) && (this.bcatch == null ? other.bcatch == null : this.bcatch === other.bcatch) && (this.bfinally == null ? other.bfinally == null : this.bfinally === other.bfinally);
  11458. };
  11459. AST_Catch.prototype.shallow_cmp = function(other) {
  11460. return this.argname == null ? other.argname == null : this.argname === other.argname;
  11461. };
  11462. AST_Finally.prototype.shallow_cmp = pass_through;
  11463. AST_DefinitionsLike.prototype.shallow_cmp = pass_through;
  11464. AST_VarDefLike.prototype.shallow_cmp = function(other) {
  11465. return this.value == null ? other.value == null : this.value === other.value;
  11466. };
  11467. AST_NameMapping.prototype.shallow_cmp = pass_through;
  11468. AST_Import.prototype.shallow_cmp = function(other) {
  11469. return (this.imported_name || null) === (other.imported_name || null)
  11470. && (this.imported_names || null) === (other.imported_names || null)
  11471. && (this.attributes || null) === (other.attributes || null)
  11472. && (this.phase || null) === (other.phase || null);
  11473. };
  11474. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  11475. AST_DynamicImport.prototype.shallow_cmp = function(other) {
  11476. return (this.phase || null) === (other.phase || null) && this.args.length === other.args.length;
  11477. };
  11478. AST_Export.prototype.shallow_cmp = function(other) {
  11479. return (this.exported_definition == null ? other.exported_definition == null : this.exported_definition === other.exported_definition) && (this.exported_value == null ? other.exported_value == null : this.exported_value === other.exported_value) && (this.exported_names == null ? other.exported_names == null : this.exported_names === other.exported_names) && (this.attributes == null ? other.attributes == null : this.attributes === other.attributes) && this.module_name === other.module_name && this.is_default === other.is_default;
  11480. };
  11481. AST_Call.prototype.shallow_cmp = pass_through;
  11482. AST_Sequence.prototype.shallow_cmp = pass_through;
  11483. AST_PropAccess.prototype.shallow_cmp = pass_through;
  11484. AST_Chain.prototype.shallow_cmp = pass_through;
  11485. AST_Dot.prototype.shallow_cmp = function(other) {
  11486. return (
  11487. this.property === other.property
  11488. && !!this.quote === !!other.quote
  11489. );
  11490. };
  11491. AST_DotHash.prototype.shallow_cmp = function(other) {
  11492. return this.property === other.property;
  11493. };
  11494. AST_Unary.prototype.shallow_cmp = function(other) {
  11495. return this.operator === other.operator;
  11496. };
  11497. AST_Binary.prototype.shallow_cmp = function(other) {
  11498. return this.operator === other.operator;
  11499. };
  11500. AST_PrivateIn.prototype.shallow_cmp = pass_through;
  11501. AST_Conditional.prototype.shallow_cmp = pass_through;
  11502. AST_Array.prototype.shallow_cmp = pass_through;
  11503. AST_Object.prototype.shallow_cmp = pass_through;
  11504. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  11505. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  11506. return this.key === other.key && this.quote === other.quote;
  11507. };
  11508. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  11509. return this.static === other.static;
  11510. };
  11511. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  11512. return this.static === other.static;
  11513. };
  11514. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  11515. return this.static === other.static;
  11516. };
  11517. AST_PrivateMethod.prototype.shallow_cmp = function(other) {
  11518. return this.static === other.static;
  11519. };
  11520. AST_Class.prototype.shallow_cmp = function(other) {
  11521. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  11522. };
  11523. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  11524. return this.static === other.static
  11525. && (typeof this.key === "string"
  11526. ? this.key === other.key
  11527. : true /* AST_Node handled elsewhere */);
  11528. };
  11529. AST_ClassPrivateProperty.prototype.shallow_cmp = function(other) {
  11530. return this.static === other.static;
  11531. };
  11532. AST_Symbol.prototype.shallow_cmp = function(other) {
  11533. return this.name === other.name;
  11534. };
  11535. AST_NewTarget.prototype.shallow_cmp = pass_through;
  11536. AST_This.prototype.shallow_cmp = pass_through;
  11537. AST_Super.prototype.shallow_cmp = pass_through;
  11538. AST_String.prototype.shallow_cmp = function(other) {
  11539. return this.value === other.value;
  11540. };
  11541. AST_Number.prototype.shallow_cmp = function(other) {
  11542. return this.value === other.value;
  11543. };
  11544. AST_BigInt.prototype.shallow_cmp = function(other) {
  11545. return this.value === other.value;
  11546. };
  11547. AST_RegExp.prototype.shallow_cmp = function (other) {
  11548. return (
  11549. this.value.flags === other.value.flags
  11550. && this.value.source === other.value.source
  11551. );
  11552. };
  11553. AST_Atom.prototype.shallow_cmp = pass_through;
  11554. /***********************************************************************
  11555. A JavaScript tokenizer / parser / beautifier / compressor.
  11556. https://github.com/mishoo/UglifyJS2
  11557. -------------------------------- (C) ---------------------------------
  11558. Author: Mihai Bazon
  11559. <mihai.bazon@gmail.com>
  11560. http://mihai.bazon.net/blog
  11561. Distributed under the BSD license:
  11562. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11563. Redistribution and use in source and binary forms, with or without
  11564. modification, are permitted provided that the following conditions
  11565. are met:
  11566. * Redistributions of source code must retain the above
  11567. copyright notice, this list of conditions and the following
  11568. disclaimer.
  11569. * Redistributions in binary form must reproduce the above
  11570. copyright notice, this list of conditions and the following
  11571. disclaimer in the documentation and/or other materials
  11572. provided with the distribution.
  11573. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11574. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11575. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11576. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11577. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11578. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11579. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11580. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11581. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11582. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11583. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11584. SUCH DAMAGE.
  11585. ***********************************************************************/
  11586. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  11587. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  11588. let function_defs = null;
  11589. let unmangleable_names = null;
  11590. /**
  11591. * When defined, there is a function declaration somewhere that's inside of a block.
  11592. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  11593. */
  11594. let scopes_with_block_defuns = null;
  11595. class SymbolDef {
  11596. constructor(scope, orig, init) {
  11597. this.name = orig.name;
  11598. this.orig = [ orig ];
  11599. this.init = init;
  11600. this.eliminated = 0;
  11601. this.assignments = 0;
  11602. this.scope = scope;
  11603. this.replaced = 0;
  11604. this.global = false;
  11605. this.export = 0;
  11606. this.mangled_name = null;
  11607. this.undeclared = false;
  11608. this.id = SymbolDef.next_id++;
  11609. this.chained = false;
  11610. this.direct_access = false;
  11611. this.escaped = 0;
  11612. this.recursive_refs = 0;
  11613. this.references = [];
  11614. this.should_replace = undefined;
  11615. this.single_use = false;
  11616. this.fixed = false;
  11617. Object.seal(this);
  11618. }
  11619. fixed_value() {
  11620. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  11621. return this.fixed();
  11622. }
  11623. unmangleable(options) {
  11624. if (!options) options = {};
  11625. if (
  11626. function_defs &&
  11627. function_defs.has(this.id) &&
  11628. keep_name(options.keep_fnames, this.orig[0].name)
  11629. ) return true;
  11630. return this.global && !options.toplevel
  11631. || (this.export & MASK_EXPORT_DONT_MANGLE)
  11632. || this.undeclared
  11633. || !options.eval && this.scope.pinned()
  11634. || (this.orig[0] instanceof AST_SymbolLambda
  11635. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  11636. || this.orig[0] instanceof AST_SymbolMethod
  11637. || (this.orig[0] instanceof AST_SymbolClass
  11638. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  11639. }
  11640. mangle(options) {
  11641. const cache = options.cache && options.cache.props;
  11642. if (this.global && cache && cache.has(this.name)) {
  11643. this.mangled_name = cache.get(this.name);
  11644. } else if (!this.mangled_name && !this.unmangleable(options)) {
  11645. var s = this.scope;
  11646. var sym = this.orig[0];
  11647. if (options.ie8 && sym instanceof AST_SymbolLambda)
  11648. s = s.parent_scope;
  11649. const redefinition = redefined_catch_def(this);
  11650. this.mangled_name = redefinition
  11651. ? redefinition.mangled_name || redefinition.name
  11652. : s.next_mangled(options, this);
  11653. if (this.global && cache) {
  11654. cache.set(this.name, this.mangled_name);
  11655. }
  11656. }
  11657. }
  11658. }
  11659. SymbolDef.next_id = 1;
  11660. function redefined_catch_def(def) {
  11661. if (def.orig[0] instanceof AST_SymbolCatch
  11662. && def.scope.is_block_scope()
  11663. ) {
  11664. return def.scope.get_defun_scope().variables.get(def.name);
  11665. }
  11666. }
  11667. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = undefined, toplevel = this } = {}) {
  11668. options = defaults(options, {
  11669. cache: null,
  11670. ie8: false,
  11671. safari10: false,
  11672. module: false,
  11673. });
  11674. if (!(toplevel instanceof AST_Toplevel)) {
  11675. throw new Error("Invalid toplevel scope");
  11676. }
  11677. // pass 1: setup scope chaining and handle definitions
  11678. var scope = this.parent_scope = parent_scope;
  11679. var labels = new Map();
  11680. var defun = null;
  11681. var in_destructuring = null;
  11682. var for_scopes = [];
  11683. var tw = new TreeWalker((node, descend) => {
  11684. if (node.is_block_scope()) {
  11685. const save_scope = scope;
  11686. node.block_scope = scope = new AST_Scope(node);
  11687. scope._block_scope = true;
  11688. scope.init_scope_vars(save_scope);
  11689. scope.uses_with = save_scope.uses_with;
  11690. scope.uses_eval = save_scope.uses_eval;
  11691. if (options.safari10) {
  11692. if (node instanceof AST_For || node instanceof AST_ForIn || node instanceof AST_ForOf) {
  11693. for_scopes.push(scope);
  11694. }
  11695. }
  11696. if (node instanceof AST_Switch) {
  11697. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  11698. // AST_Switch has a scope within the body, but it itself "is a block scope"
  11699. // This means the switched expression has to belong to the outer scope
  11700. // while the body inside belongs to the switch itself.
  11701. // This is pretty nasty and warrants an AST change
  11702. const the_block_scope = scope;
  11703. scope = save_scope;
  11704. node.expression.walk(tw);
  11705. scope = the_block_scope;
  11706. for (let i = 0; i < node.body.length; i++) {
  11707. node.body[i].walk(tw);
  11708. }
  11709. } else {
  11710. descend();
  11711. }
  11712. scope = save_scope;
  11713. return true;
  11714. }
  11715. if (node instanceof AST_Destructuring) {
  11716. const save_destructuring = in_destructuring;
  11717. in_destructuring = node;
  11718. descend();
  11719. in_destructuring = save_destructuring;
  11720. return true;
  11721. }
  11722. if (node instanceof AST_Scope) {
  11723. node.init_scope_vars(scope);
  11724. var save_scope = scope;
  11725. var save_defun = defun;
  11726. var save_labels = labels;
  11727. defun = scope = node;
  11728. labels = new Map();
  11729. descend();
  11730. scope = save_scope;
  11731. defun = save_defun;
  11732. labels = save_labels;
  11733. if (node instanceof AST_Lambda) {
  11734. detect_screwy_argnames_scope(node, scope);
  11735. }
  11736. return true; // don't descend again in TreeWalker
  11737. }
  11738. if (node instanceof AST_LabeledStatement) {
  11739. var l = node.label;
  11740. if (labels.has(l.name)) {
  11741. throw new Error(string_template("Label {name} defined twice", l));
  11742. }
  11743. labels.set(l.name, l);
  11744. descend();
  11745. labels.delete(l.name);
  11746. return true; // no descend again
  11747. }
  11748. if (node instanceof AST_With) {
  11749. for (var s = scope; s; s = s.parent_scope)
  11750. s.uses_with = true;
  11751. return;
  11752. }
  11753. if (node instanceof AST_Symbol) {
  11754. node.scope = scope;
  11755. }
  11756. if (node instanceof AST_Label) {
  11757. node.thedef = node;
  11758. node.references = [];
  11759. }
  11760. if (node instanceof AST_SymbolLambda) {
  11761. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  11762. } else if (node instanceof AST_SymbolDefun) {
  11763. // Careful here, the scope where this should be defined is
  11764. // the parent scope. The reason is that we enter a new
  11765. // scope when we encounter the AST_Defun node (which is
  11766. // instanceof AST_Scope) but we get to the symbol a bit
  11767. // later.
  11768. const closest_scope = defun.parent_scope;
  11769. // In strict mode, function definitions are block-scoped
  11770. node.scope = tw.directives["use strict"]
  11771. ? closest_scope
  11772. : closest_scope.get_defun_scope();
  11773. mark_export(node.scope.def_function(node, defun), 1);
  11774. } else if (node instanceof AST_SymbolClass) {
  11775. mark_export(defun.def_variable(node, defun), 1);
  11776. } else if (node instanceof AST_SymbolImport) {
  11777. scope.def_variable(node);
  11778. } else if (node instanceof AST_SymbolDefClass) {
  11779. // This deals with the name of the class being available
  11780. // inside the class.
  11781. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  11782. } else if (
  11783. node instanceof AST_SymbolVar
  11784. || node instanceof AST_SymbolLet
  11785. || node instanceof AST_SymbolConst
  11786. || node instanceof AST_SymbolUsing
  11787. || node instanceof AST_SymbolCatch
  11788. ) {
  11789. var def;
  11790. if (node instanceof AST_SymbolBlockDeclaration) {
  11791. def = scope.def_variable(node, null);
  11792. } else {
  11793. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  11794. }
  11795. if (!def.orig.every((sym) => {
  11796. if (sym === node) return true;
  11797. if (node instanceof AST_SymbolBlockDeclaration) {
  11798. return sym instanceof AST_SymbolLambda;
  11799. }
  11800. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst || sym instanceof AST_SymbolUsing);
  11801. })) {
  11802. js_error(
  11803. `"${node.name}" is redeclared`,
  11804. node.start.file,
  11805. node.start.line,
  11806. node.start.col,
  11807. node.start.pos
  11808. );
  11809. }
  11810. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  11811. if (defun !== scope) {
  11812. node.mark_enclosed();
  11813. var def = scope.find_variable(node);
  11814. if (node.thedef !== def) {
  11815. node.thedef = def;
  11816. node.reference();
  11817. }
  11818. }
  11819. } else if (node instanceof AST_LabelRef) {
  11820. var sym = labels.get(node.name);
  11821. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  11822. name: node.name,
  11823. line: node.start.line,
  11824. col: node.start.col
  11825. }));
  11826. node.thedef = sym;
  11827. }
  11828. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  11829. js_error(
  11830. `"${node.TYPE}" statement may only appear at the top level`,
  11831. node.start.file,
  11832. node.start.line,
  11833. node.start.col,
  11834. node.start.pos
  11835. );
  11836. }
  11837. });
  11838. if (options.module) {
  11839. tw.directives["use strict"] = true;
  11840. }
  11841. this.walk(tw);
  11842. function mark_export(def, level) {
  11843. if (in_destructuring) {
  11844. var i = 0;
  11845. do {
  11846. level++;
  11847. } while (tw.parent(i++) !== in_destructuring);
  11848. }
  11849. var node = tw.parent(level);
  11850. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  11851. var exported = node.exported_definition;
  11852. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  11853. def.export = MASK_EXPORT_WANT_MANGLE;
  11854. }
  11855. }
  11856. }
  11857. // pass 2: find back references and eval
  11858. const is_toplevel = this instanceof AST_Toplevel;
  11859. if (is_toplevel) {
  11860. this.globals = new Map();
  11861. }
  11862. var tw = new TreeWalker(node => {
  11863. if (node instanceof AST_LoopControl && node.label) {
  11864. node.label.thedef.references.push(node);
  11865. return true;
  11866. }
  11867. if (node instanceof AST_SymbolRef) {
  11868. var name = node.name;
  11869. if (name == "eval" && tw.parent() instanceof AST_Call) {
  11870. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  11871. s.uses_eval = true;
  11872. }
  11873. }
  11874. var sym;
  11875. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  11876. || !(sym = node.scope.find_variable(name))) {
  11877. sym = toplevel.def_global(node);
  11878. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  11879. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  11880. sym.scope.get_defun_scope().uses_arguments = true;
  11881. }
  11882. node.thedef = sym;
  11883. node.reference();
  11884. if (node.scope.is_block_scope()
  11885. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  11886. node.scope = node.scope.get_defun_scope();
  11887. }
  11888. return true;
  11889. }
  11890. // ensure mangling works if catch reuses a scope variable
  11891. var def;
  11892. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  11893. var s = node.scope;
  11894. while (s) {
  11895. push_uniq(s.enclosed, def);
  11896. if (s === def.scope) break;
  11897. s = s.parent_scope;
  11898. }
  11899. }
  11900. });
  11901. this.walk(tw);
  11902. // pass 3: work around IE8 and Safari catch scope bugs
  11903. if (options.ie8 || options.safari10) {
  11904. walk(this, node => {
  11905. if (node instanceof AST_SymbolCatch) {
  11906. var name = node.name;
  11907. var refs = node.thedef.references;
  11908. var scope = node.scope.get_defun_scope();
  11909. var def = scope.find_variable(name)
  11910. || toplevel.globals.get(name)
  11911. || scope.def_variable(node);
  11912. refs.forEach(function(ref) {
  11913. ref.thedef = def;
  11914. ref.reference();
  11915. });
  11916. node.thedef = def;
  11917. node.reference();
  11918. return true;
  11919. }
  11920. });
  11921. }
  11922. // pass 4: add symbol definitions to loop scopes
  11923. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  11924. // https://github.com/mishoo/UglifyJS2/issues/1753
  11925. // https://bugs.webkit.org/show_bug.cgi?id=171041
  11926. if (options.safari10) {
  11927. for (const scope of for_scopes) {
  11928. scope.parent_scope.variables.forEach(function(def) {
  11929. push_uniq(scope.enclosed, def);
  11930. });
  11931. }
  11932. }
  11933. // Arguments have their own scope, different from the scope of `var`.
  11934. // This is apparent when default args are used.
  11935. function detect_screwy_argnames_scope(lambda, parent_scope) {
  11936. let cached_argnames;
  11937. for (const arg of lambda.argnames) {
  11938. walk(arg, sym => {
  11939. if (sym instanceof AST_SymbolRef) {
  11940. const in_lambda = lambda.variables.get(sym.name);
  11941. if (!in_lambda) return;
  11942. // In funargs and also a `var` inside
  11943. // (sym, x = sym) => { var sym }
  11944. if (in_lambda.orig.length > 1 && find_name_in_arg_names(sym.name)) {
  11945. mark_screwy(sym.definition());
  11946. }
  11947. // Outside and in a `var`
  11948. // var sym = ...; (x = sym) => { var sym }
  11949. const outside_lambda = parent_scope.find_variable(sym.name);
  11950. if (outside_lambda) {
  11951. mark_screwy(sym.definition());
  11952. mark_screwy(outside_lambda);
  11953. }
  11954. }
  11955. });
  11956. }
  11957. function find_name_in_arg_names(name) {
  11958. if (!cached_argnames) cached_argnames = lambda.args_as_names();
  11959. return cached_argnames.some(s => s.name === name);
  11960. }
  11961. function mark_screwy(def) {
  11962. if (def) def.scope.screwy_argnames_scope = true;
  11963. lambda.screwy_argnames_scope = true;
  11964. }
  11965. }
  11966. });
  11967. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  11968. var globals = this.globals, name = node.name;
  11969. if (globals.has(name)) {
  11970. return globals.get(name);
  11971. } else {
  11972. var g = new SymbolDef(this, node);
  11973. g.undeclared = true;
  11974. g.global = true;
  11975. globals.set(name, g);
  11976. return g;
  11977. }
  11978. });
  11979. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  11980. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  11981. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  11982. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  11983. this.screwy_argnames_scope = false;
  11984. this.parent_scope = parent_scope; // the parent scope
  11985. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  11986. this.cname = -1; // the current index for mangling functions/variables
  11987. });
  11988. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  11989. return (
  11990. this.enclosed.find(def => def.name === name)
  11991. || this.variables.has(name)
  11992. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  11993. );
  11994. });
  11995. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  11996. return (
  11997. this.enclosed.find(def => def.name === name)
  11998. || this.variables.has(name)
  11999. );
  12000. });
  12001. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  12002. // `scope` is going to be moved into `this` right now.
  12003. // Update the required scopes' information
  12004. if (scope.parent_scope === this) return;
  12005. scope.parent_scope = this;
  12006. // Propagate to this.uses_arguments from arrow functions
  12007. if ((scope instanceof AST_Arrow) && (this instanceof AST_Lambda && !this.uses_arguments)) {
  12008. this.uses_arguments = walk(scope, node => {
  12009. if (
  12010. node instanceof AST_SymbolRef
  12011. && node.scope instanceof AST_Lambda
  12012. && node.name === "arguments"
  12013. ) {
  12014. return walk_abort;
  12015. }
  12016. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  12017. return true;
  12018. }
  12019. });
  12020. }
  12021. this.uses_with = this.uses_with || scope.uses_with;
  12022. this.uses_eval = this.uses_eval || scope.uses_eval;
  12023. const scope_ancestry = (() => {
  12024. const ancestry = [];
  12025. let cur = this;
  12026. do {
  12027. ancestry.push(cur);
  12028. } while ((cur = cur.parent_scope));
  12029. ancestry.reverse();
  12030. return ancestry;
  12031. })();
  12032. const new_scope_enclosed_set = new Set(scope.enclosed);
  12033. const to_enclose = [];
  12034. for (const scope_topdown of scope_ancestry) {
  12035. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  12036. for (const def of scope_topdown.variables.values()) {
  12037. if (new_scope_enclosed_set.has(def)) {
  12038. push_uniq(to_enclose, def);
  12039. push_uniq(scope_topdown.enclosed, def);
  12040. }
  12041. }
  12042. }
  12043. });
  12044. function find_scopes_visible_from(scopes) {
  12045. const found_scopes = new Set();
  12046. for (const scope of new Set(scopes)) {
  12047. (function bubble_up(scope) {
  12048. if (scope == null || found_scopes.has(scope)) return;
  12049. found_scopes.add(scope);
  12050. bubble_up(scope.parent_scope);
  12051. })(scope);
  12052. }
  12053. return [...found_scopes];
  12054. }
  12055. // Creates a symbol during compression
  12056. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  12057. source,
  12058. tentative_name,
  12059. scope,
  12060. conflict_scopes = [scope],
  12061. init = null
  12062. } = {}) {
  12063. let symbol_name;
  12064. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  12065. if (tentative_name) {
  12066. // Implement hygiene (no new names are conflicting with existing names)
  12067. tentative_name =
  12068. symbol_name =
  12069. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  12070. let i = 0;
  12071. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  12072. symbol_name = tentative_name + "$" + i++;
  12073. }
  12074. }
  12075. if (!symbol_name) {
  12076. throw new Error("No symbol name could be generated in create_symbol()");
  12077. }
  12078. const symbol = make_node(SymClass, source, {
  12079. name: symbol_name,
  12080. scope
  12081. });
  12082. this.def_variable(symbol, init || null);
  12083. symbol.mark_enclosed();
  12084. return symbol;
  12085. });
  12086. AST_Node.DEFMETHOD("is_block_scope", return_false);
  12087. AST_Class.DEFMETHOD("is_block_scope", return_false);
  12088. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  12089. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  12090. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  12091. AST_Block.DEFMETHOD("is_block_scope", return_true);
  12092. AST_Scope.DEFMETHOD("is_block_scope", function () {
  12093. return this._block_scope || false;
  12094. });
  12095. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  12096. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  12097. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  12098. this.uses_arguments = false;
  12099. this.def_variable(new AST_SymbolFunarg({
  12100. name: "arguments",
  12101. start: this.start,
  12102. end: this.end
  12103. }));
  12104. });
  12105. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  12106. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  12107. this.uses_arguments = false;
  12108. });
  12109. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  12110. var def = this.definition();
  12111. var s = this.scope;
  12112. while (s) {
  12113. push_uniq(s.enclosed, def);
  12114. if (s === def.scope) break;
  12115. s = s.parent_scope;
  12116. }
  12117. });
  12118. AST_Symbol.DEFMETHOD("reference", function() {
  12119. this.definition().references.push(this);
  12120. this.mark_enclosed();
  12121. });
  12122. AST_Scope.DEFMETHOD("find_variable", function(name) {
  12123. if (name instanceof AST_Symbol) name = name.name;
  12124. return this.variables.get(name)
  12125. || (this.parent_scope && this.parent_scope.find_variable(name));
  12126. });
  12127. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  12128. var def = this.def_variable(symbol, init);
  12129. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  12130. return def;
  12131. });
  12132. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  12133. var def = this.variables.get(symbol.name);
  12134. if (def) {
  12135. def.orig.push(symbol);
  12136. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  12137. def.init = init;
  12138. }
  12139. } else {
  12140. def = new SymbolDef(this, symbol, init);
  12141. this.variables.set(symbol.name, def);
  12142. def.global = !this.parent_scope;
  12143. }
  12144. return symbol.thedef = def;
  12145. });
  12146. function next_mangled(scope, options) {
  12147. let defun_scope;
  12148. if (
  12149. scopes_with_block_defuns
  12150. && (defun_scope = scope.get_defun_scope())
  12151. && scopes_with_block_defuns.has(defun_scope)
  12152. ) {
  12153. scope = defun_scope;
  12154. }
  12155. var ext = scope.enclosed;
  12156. var nth_identifier = options.nth_identifier;
  12157. out: while (true) {
  12158. var m = nth_identifier.get(++scope.cname);
  12159. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  12160. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  12161. // shadow a name reserved from mangling.
  12162. if (options.reserved.has(m)) continue;
  12163. // Functions with short names might collide with base54 output
  12164. // and therefore cause collisions when keep_fnames is true.
  12165. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  12166. // we must ensure that the mangled name does not shadow a name
  12167. // from some parent scope that is referenced in this or in
  12168. // inner scopes.
  12169. for (let i = ext.length; --i >= 0;) {
  12170. const def = ext[i];
  12171. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  12172. if (m == name) continue out;
  12173. }
  12174. return m;
  12175. }
  12176. }
  12177. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  12178. return next_mangled(this, options);
  12179. });
  12180. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  12181. let name;
  12182. const mangled_names = this.mangled_names;
  12183. do {
  12184. name = next_mangled(this, options);
  12185. } while (mangled_names.has(name));
  12186. return name;
  12187. });
  12188. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  12189. // #179, #326
  12190. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  12191. // a function expression's argument cannot shadow the function expression's name
  12192. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  12193. // the function's mangled_name is null when keep_fnames is true
  12194. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  12195. while (true) {
  12196. var name = next_mangled(this, options);
  12197. if (!tricky_name || tricky_name != name)
  12198. return name;
  12199. }
  12200. });
  12201. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  12202. var def = this.definition();
  12203. return !def || def.unmangleable(options);
  12204. });
  12205. // labels are always mangleable
  12206. AST_Label.DEFMETHOD("unmangleable", return_false);
  12207. AST_Symbol.DEFMETHOD("unreferenced", function() {
  12208. return !this.definition().references.length && !this.scope.pinned();
  12209. });
  12210. AST_Symbol.DEFMETHOD("definition", function() {
  12211. return this.thedef;
  12212. });
  12213. AST_Symbol.DEFMETHOD("global", function() {
  12214. return this.thedef.global;
  12215. });
  12216. /**
  12217. * Format the mangler options (if any) into their appropriate types
  12218. */
  12219. function format_mangler_options(options) {
  12220. options = defaults(options, {
  12221. eval : false,
  12222. nth_identifier : base54,
  12223. ie8 : false,
  12224. keep_classnames: false,
  12225. keep_fnames : false,
  12226. module : false,
  12227. reserved : [],
  12228. toplevel : false,
  12229. });
  12230. if (options.module) options.toplevel = true;
  12231. if (!Array.isArray(options.reserved)
  12232. && !(options.reserved instanceof Set)
  12233. ) {
  12234. options.reserved = [];
  12235. }
  12236. options.reserved = new Set(options.reserved);
  12237. // Never mangle arguments
  12238. options.reserved.add("arguments");
  12239. return options;
  12240. }
  12241. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  12242. options = format_mangler_options(options);
  12243. var nth_identifier = options.nth_identifier;
  12244. // We only need to mangle declaration nodes. Special logic wired
  12245. // into the code generator will display the mangled name if it's
  12246. // present (and for AST_SymbolRef-s it'll use the mangled name of
  12247. // the AST_SymbolDeclaration that it points to).
  12248. var lname = -1;
  12249. var to_mangle = [];
  12250. if (options.keep_fnames) {
  12251. function_defs = new Set();
  12252. }
  12253. const mangled_names = this.mangled_names = new Set();
  12254. unmangleable_names = new Set();
  12255. if (options.cache) {
  12256. this.globals.forEach(collect);
  12257. if (options.cache.props) {
  12258. options.cache.props.forEach(function(mangled_name) {
  12259. mangled_names.add(mangled_name);
  12260. });
  12261. }
  12262. }
  12263. var tw = new TreeWalker(function(node, descend) {
  12264. if (node instanceof AST_LabeledStatement) {
  12265. // lname is incremented when we get to the AST_Label
  12266. var save_nesting = lname;
  12267. descend();
  12268. lname = save_nesting;
  12269. return true; // don't descend again in TreeWalker
  12270. }
  12271. if (
  12272. node instanceof AST_Defun
  12273. && !(tw.parent() instanceof AST_Scope)
  12274. ) {
  12275. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  12276. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  12277. }
  12278. if (node instanceof AST_Scope) {
  12279. node.variables.forEach(collect);
  12280. return;
  12281. }
  12282. if (node.is_block_scope()) {
  12283. node.block_scope.variables.forEach(collect);
  12284. return;
  12285. }
  12286. if (
  12287. function_defs
  12288. && node instanceof AST_VarDef
  12289. && node.name instanceof AST_Symbol
  12290. && node.value instanceof AST_Lambda
  12291. && !node.value.name
  12292. && keep_name(options.keep_fnames, node.name.name)
  12293. ) {
  12294. function_defs.add(node.name.definition().id);
  12295. return;
  12296. }
  12297. if (node instanceof AST_Label) {
  12298. let name;
  12299. do {
  12300. name = nth_identifier.get(++lname);
  12301. } while (ALL_RESERVED_WORDS.has(name));
  12302. node.mangled_name = name;
  12303. return true;
  12304. }
  12305. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  12306. to_mangle.push(node.definition());
  12307. return;
  12308. }
  12309. });
  12310. this.walk(tw);
  12311. if (options.keep_fnames || options.keep_classnames) {
  12312. // Collect a set of short names which are unmangleable,
  12313. // for use in avoiding collisions in next_mangled.
  12314. to_mangle.forEach(def => {
  12315. if (def.name.length < 6 && def.unmangleable(options)) {
  12316. unmangleable_names.add(def.name);
  12317. }
  12318. });
  12319. }
  12320. to_mangle.forEach(def => { def.mangle(options); });
  12321. function_defs = null;
  12322. unmangleable_names = null;
  12323. scopes_with_block_defuns = null;
  12324. function collect(symbol) {
  12325. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  12326. unmangleable_names.add(symbol.name);
  12327. } else if (!options.reserved.has(symbol.name)) {
  12328. to_mangle.push(symbol);
  12329. }
  12330. }
  12331. });
  12332. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  12333. const cache = options.cache && options.cache.props;
  12334. const avoid = new Set();
  12335. options.reserved.forEach(to_avoid);
  12336. this.globals.forEach(add_def);
  12337. this.walk(new TreeWalker(function(node) {
  12338. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  12339. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  12340. }));
  12341. return avoid;
  12342. function to_avoid(name) {
  12343. avoid.add(name);
  12344. }
  12345. function add_def(def) {
  12346. var name = def.name;
  12347. if (def.global && cache && cache.has(name)) name = cache.get(name);
  12348. else if (!def.unmangleable(options)) return;
  12349. to_avoid(name);
  12350. }
  12351. });
  12352. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  12353. options = format_mangler_options(options);
  12354. var nth_identifier = options.nth_identifier;
  12355. if (nth_identifier.reset && nth_identifier.sort) {
  12356. nth_identifier.reset();
  12357. nth_identifier.sort();
  12358. }
  12359. var avoid = this.find_colliding_names(options);
  12360. var cname = 0;
  12361. this.globals.forEach(rename);
  12362. this.walk(new TreeWalker(function(node) {
  12363. if (node instanceof AST_Scope) node.variables.forEach(rename);
  12364. if (node instanceof AST_SymbolCatch) rename(node.definition());
  12365. }));
  12366. function next_name() {
  12367. var name;
  12368. do {
  12369. name = nth_identifier.get(cname++);
  12370. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  12371. return name;
  12372. }
  12373. function rename(def) {
  12374. if (def.global && options.cache) return;
  12375. if (def.unmangleable(options)) return;
  12376. if (options.reserved.has(def.name)) return;
  12377. const redefinition = redefined_catch_def(def);
  12378. const name = def.name = redefinition ? redefinition.name : next_name();
  12379. def.orig.forEach(function(sym) {
  12380. sym.name = name;
  12381. });
  12382. def.references.forEach(function(sym) {
  12383. sym.name = name;
  12384. });
  12385. }
  12386. });
  12387. AST_Node.DEFMETHOD("tail_node", return_this);
  12388. AST_Sequence.DEFMETHOD("tail_node", function() {
  12389. return this.expressions[this.expressions.length - 1];
  12390. });
  12391. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  12392. options = format_mangler_options(options);
  12393. var nth_identifier = options.nth_identifier;
  12394. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  12395. // If the identifier mangler is invariant, skip computing character frequency.
  12396. return;
  12397. }
  12398. nth_identifier.reset();
  12399. try {
  12400. AST_Node.prototype.print = function(stream, force_parens) {
  12401. this._print(stream, force_parens);
  12402. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  12403. nth_identifier.consider(this.name, -1);
  12404. } else if (options.properties) {
  12405. if (this instanceof AST_DotHash) {
  12406. nth_identifier.consider("#" + this.property, -1);
  12407. } else if (this instanceof AST_Dot) {
  12408. nth_identifier.consider(this.property, -1);
  12409. } else if (this instanceof AST_Sub) {
  12410. skip_string(this.property);
  12411. }
  12412. }
  12413. };
  12414. nth_identifier.consider(this.print_to_string(), 1);
  12415. } finally {
  12416. AST_Node.prototype.print = AST_Node.prototype._print;
  12417. }
  12418. nth_identifier.sort();
  12419. function skip_string(node) {
  12420. if (node instanceof AST_String) {
  12421. nth_identifier.consider(node.value, -1);
  12422. } else if (node instanceof AST_Conditional) {
  12423. skip_string(node.consequent);
  12424. skip_string(node.alternative);
  12425. } else if (node instanceof AST_Sequence) {
  12426. skip_string(node.tail_node());
  12427. }
  12428. }
  12429. });
  12430. const base54 = (() => {
  12431. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  12432. const digits = "0123456789".split("");
  12433. let chars;
  12434. let frequency;
  12435. function reset() {
  12436. frequency = new Map();
  12437. leading.forEach(function(ch) {
  12438. frequency.set(ch, 0);
  12439. });
  12440. digits.forEach(function(ch) {
  12441. frequency.set(ch, 0);
  12442. });
  12443. }
  12444. function consider(str, delta) {
  12445. for (var i = str.length; --i >= 0;) {
  12446. frequency.set(str[i], frequency.get(str[i]) + delta);
  12447. }
  12448. }
  12449. function compare(a, b) {
  12450. return frequency.get(b) - frequency.get(a);
  12451. }
  12452. function sort() {
  12453. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  12454. }
  12455. // Ensure this is in a usable initial state.
  12456. reset();
  12457. sort();
  12458. function base54(num) {
  12459. var ret = "", base = 54;
  12460. num++;
  12461. do {
  12462. num--;
  12463. ret += chars[num % base];
  12464. num = Math.floor(num / base);
  12465. base = 64;
  12466. } while (num > 0);
  12467. return ret;
  12468. }
  12469. return {
  12470. get: base54,
  12471. consider,
  12472. reset,
  12473. sort
  12474. };
  12475. })();
  12476. let mangle_options = undefined;
  12477. AST_Node.prototype.size = function (compressor, stack) {
  12478. mangle_options = compressor && compressor._mangle_options;
  12479. let size = 0;
  12480. walk_parent(this, (node, info) => {
  12481. size += node._size(info);
  12482. // Braceless arrow functions have fake "return" statements
  12483. if (node instanceof AST_Arrow && node.is_braceless()) {
  12484. size += node.body[0].value._size(info);
  12485. return true;
  12486. }
  12487. }, stack || (compressor && compressor.stack));
  12488. // just to save a bit of memory
  12489. mangle_options = undefined;
  12490. return size;
  12491. };
  12492. AST_Node.prototype._size = () => 0;
  12493. AST_Debugger.prototype._size = () => 8;
  12494. AST_Directive.prototype._size = function () {
  12495. // TODO string encoding stuff
  12496. return 2 + this.value.length;
  12497. };
  12498. /** Count commas/semicolons necessary to show a list of expressions/statements */
  12499. const list_overhead = (array) => array.length && array.length - 1;
  12500. AST_Block.prototype._size = function () {
  12501. return 2 + list_overhead(this.body);
  12502. };
  12503. AST_Toplevel.prototype._size = function() {
  12504. return list_overhead(this.body);
  12505. };
  12506. AST_EmptyStatement.prototype._size = () => 1;
  12507. AST_LabeledStatement.prototype._size = () => 2; // x:
  12508. AST_Do.prototype._size = () => 9;
  12509. AST_While.prototype._size = () => 7;
  12510. AST_For.prototype._size = () => 8;
  12511. AST_ForIn.prototype._size = () => 8;
  12512. // AST_ForOf inherits ^
  12513. AST_With.prototype._size = () => 6;
  12514. AST_Expansion.prototype._size = () => 3;
  12515. const lambda_modifiers = func =>
  12516. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  12517. AST_Accessor.prototype._size = function () {
  12518. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  12519. };
  12520. AST_Function.prototype._size = function (info) {
  12521. const first = !!first_in_statement(info);
  12522. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  12523. };
  12524. AST_Defun.prototype._size = function () {
  12525. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  12526. };
  12527. AST_Arrow.prototype._size = function () {
  12528. let args_and_arrow = 2 + list_overhead(this.argnames);
  12529. if (
  12530. !(
  12531. this.argnames.length === 1
  12532. && this.argnames[0] instanceof AST_Symbol
  12533. )
  12534. ) {
  12535. args_and_arrow += 2; // parens around the args
  12536. }
  12537. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  12538. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  12539. };
  12540. AST_Destructuring.prototype._size = () => 2;
  12541. AST_TemplateString.prototype._size = function () {
  12542. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  12543. };
  12544. AST_TemplateSegment.prototype._size = function () {
  12545. return this.value.length;
  12546. };
  12547. AST_Return.prototype._size = function () {
  12548. return this.value ? 7 : 6;
  12549. };
  12550. AST_Throw.prototype._size = () => 6;
  12551. AST_Break.prototype._size = function () {
  12552. return this.label ? 6 : 5;
  12553. };
  12554. AST_Continue.prototype._size = function () {
  12555. return this.label ? 9 : 8;
  12556. };
  12557. AST_If.prototype._size = () => 4;
  12558. AST_Switch.prototype._size = function () {
  12559. return 8 + list_overhead(this.body);
  12560. };
  12561. AST_Case.prototype._size = function () {
  12562. return 5 + list_overhead(this.body);
  12563. };
  12564. AST_Default.prototype._size = function () {
  12565. return 8 + list_overhead(this.body);
  12566. };
  12567. AST_Try.prototype._size = () => 3;
  12568. AST_Catch.prototype._size = function () {
  12569. let size = 7 + list_overhead(this.body);
  12570. if (this.argname) {
  12571. size += 2;
  12572. }
  12573. return size;
  12574. };
  12575. AST_Finally.prototype._size = function () {
  12576. return 7 + list_overhead(this.body);
  12577. };
  12578. AST_Var.prototype._size = function () {
  12579. return 4 + list_overhead(this.definitions);
  12580. };
  12581. AST_Let.prototype._size = function () {
  12582. return 4 + list_overhead(this.definitions);
  12583. };
  12584. AST_Const.prototype._size = function () {
  12585. return 6 + list_overhead(this.definitions);
  12586. };
  12587. AST_Using.prototype._size = function () {
  12588. const await_size = this.await ? 6 : 0;
  12589. return await_size + 6 + list_overhead(this.definitions);
  12590. };
  12591. AST_VarDefLike.prototype._size = function () {
  12592. return this.value ? 1 : 0;
  12593. };
  12594. AST_NameMapping.prototype._size = function () {
  12595. // foreign name isn't mangled
  12596. return this.name ? 4 : 0;
  12597. };
  12598. AST_Import.prototype._size = function () {
  12599. // import
  12600. let size = 6;
  12601. if (this.imported_name) size += 1;
  12602. // from
  12603. if (this.imported_name || this.imported_names) size += 5;
  12604. // braces, and the commas
  12605. if (this.imported_names) {
  12606. size += 2 + list_overhead(this.imported_names);
  12607. }
  12608. return size;
  12609. };
  12610. AST_ImportMeta.prototype._size = () => 11;
  12611. AST_DynamicImport.prototype._size = function () {
  12612. // `import.` + phase + `()` + arg overhead
  12613. if (this.phase) {
  12614. return 9 + this.phase.length + list_overhead(this.args);
  12615. } else {
  12616. return 8 + list_overhead(this.args);
  12617. }
  12618. };
  12619. AST_Export.prototype._size = function () {
  12620. let size = 7 + (this.is_default ? 8 : 0);
  12621. if (this.exported_value) {
  12622. size += this.exported_value._size();
  12623. }
  12624. if (this.exported_names) {
  12625. // Braces and commas
  12626. size += 2 + list_overhead(this.exported_names);
  12627. }
  12628. if (this.module_name) {
  12629. // "from "
  12630. size += 5;
  12631. }
  12632. return size;
  12633. };
  12634. AST_Call.prototype._size = function () {
  12635. if (this.optional) {
  12636. return 4 + list_overhead(this.args);
  12637. }
  12638. return 2 + list_overhead(this.args);
  12639. };
  12640. AST_New.prototype._size = function () {
  12641. return 6 + list_overhead(this.args);
  12642. };
  12643. AST_Sequence.prototype._size = function () {
  12644. return list_overhead(this.expressions);
  12645. };
  12646. AST_Dot.prototype._size = function () {
  12647. if (this.optional) {
  12648. return this.property.length + 2;
  12649. }
  12650. return this.property.length + 1;
  12651. };
  12652. AST_DotHash.prototype._size = function () {
  12653. if (this.optional) {
  12654. return this.property.length + 3;
  12655. }
  12656. return this.property.length + 2;
  12657. };
  12658. AST_Sub.prototype._size = function () {
  12659. return this.optional ? 4 : 2;
  12660. };
  12661. AST_Unary.prototype._size = function () {
  12662. if (this.operator === "typeof") return 7;
  12663. if (this.operator === "void") return 5;
  12664. return this.operator.length;
  12665. };
  12666. AST_Binary.prototype._size = function (info) {
  12667. if (this.operator === "in") return 4;
  12668. let size = this.operator.length;
  12669. if (
  12670. (this.operator === "+" || this.operator === "-")
  12671. && this.right instanceof AST_Unary && this.right.operator === this.operator
  12672. ) {
  12673. // 1+ +a > needs space between the +
  12674. size += 1;
  12675. }
  12676. if (this.needs_parens(info)) {
  12677. size += 2;
  12678. }
  12679. return size;
  12680. };
  12681. AST_Conditional.prototype._size = () => 3;
  12682. AST_Array.prototype._size = function () {
  12683. return 2 + list_overhead(this.elements);
  12684. };
  12685. AST_Object.prototype._size = function (info) {
  12686. let base = 2;
  12687. if (first_in_statement(info)) {
  12688. base += 2; // parens
  12689. }
  12690. return base + list_overhead(this.properties);
  12691. };
  12692. /*#__INLINE__*/
  12693. const key_size = key =>
  12694. typeof key === "string" ? key.length : 0;
  12695. AST_ObjectKeyVal.prototype._size = function () {
  12696. return key_size(this.key) + 1;
  12697. };
  12698. /*#__INLINE__*/
  12699. const static_size = is_static => is_static ? 7 : 0;
  12700. AST_ObjectGetter.prototype._size = function () {
  12701. return 5 + static_size(this.static) + key_size(this.key);
  12702. };
  12703. AST_ObjectSetter.prototype._size = function () {
  12704. return 5 + static_size(this.static) + key_size(this.key);
  12705. };
  12706. AST_ConciseMethod.prototype._size = function () {
  12707. return static_size(this.static) + key_size(this.key);
  12708. };
  12709. AST_PrivateMethod.prototype._size = function () {
  12710. return AST_ConciseMethod.prototype._size.call(this) + 1;
  12711. };
  12712. AST_PrivateGetter.prototype._size = function () {
  12713. return AST_ConciseMethod.prototype._size.call(this) + 4;
  12714. };
  12715. AST_PrivateSetter.prototype._size = function () {
  12716. return AST_ConciseMethod.prototype._size.call(this) + 4;
  12717. };
  12718. AST_PrivateIn.prototype._size = function () {
  12719. return 5; // "#", and " in "
  12720. };
  12721. AST_Class.prototype._size = function () {
  12722. return (
  12723. (this.name ? 8 : 7)
  12724. + (this.extends ? 8 : 0)
  12725. );
  12726. };
  12727. AST_ClassStaticBlock.prototype._size = function () {
  12728. // "static{}" + semicolons
  12729. return 8 + list_overhead(this.body);
  12730. };
  12731. AST_ClassProperty.prototype._size = function () {
  12732. return (
  12733. static_size(this.static)
  12734. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  12735. + (this.value ? 1 : 0)
  12736. );
  12737. };
  12738. AST_ClassPrivateProperty.prototype._size = function () {
  12739. return AST_ClassProperty.prototype._size.call(this) + 1;
  12740. };
  12741. AST_Symbol.prototype._size = function () {
  12742. if (!(mangle_options && this.thedef && !this.thedef.unmangleable(mangle_options))) {
  12743. return this.name.length;
  12744. } else {
  12745. return 1;
  12746. }
  12747. };
  12748. // TODO take propmangle into account
  12749. AST_SymbolClassProperty.prototype._size = function () {
  12750. return this.name.length;
  12751. };
  12752. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  12753. if (this.name === "arguments") return 9;
  12754. return AST_Symbol.prototype._size.call(this);
  12755. };
  12756. AST_NewTarget.prototype._size = () => 10;
  12757. AST_SymbolImportForeign.prototype._size = function () {
  12758. return this.name.length;
  12759. };
  12760. AST_SymbolExportForeign.prototype._size = function () {
  12761. return this.name.length;
  12762. };
  12763. AST_This.prototype._size = () => 4;
  12764. AST_Super.prototype._size = () => 5;
  12765. AST_String.prototype._size = function () {
  12766. return this.value.length + 2;
  12767. };
  12768. AST_Number.prototype._size = function () {
  12769. const { value } = this;
  12770. if (value === 0) return 1;
  12771. if (value > 0 && Math.floor(value) === value) {
  12772. return Math.floor(Math.log10(value) + 1);
  12773. }
  12774. return value.toString().length;
  12775. };
  12776. AST_BigInt.prototype._size = function () {
  12777. return this.value.length;
  12778. };
  12779. AST_RegExp.prototype._size = function () {
  12780. return this.value.toString().length;
  12781. };
  12782. AST_Null.prototype._size = () => 4;
  12783. AST_NaN.prototype._size = () => 3;
  12784. AST_Undefined.prototype._size = () => 6; // "void 0"
  12785. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  12786. AST_Infinity.prototype._size = () => 8;
  12787. AST_True.prototype._size = () => 4;
  12788. AST_False.prototype._size = () => 5;
  12789. AST_Await.prototype._size = () => 6;
  12790. AST_Yield.prototype._size = () => 6;
  12791. /***********************************************************************
  12792. A JavaScript tokenizer / parser / beautifier / compressor.
  12793. https://github.com/mishoo/UglifyJS2
  12794. -------------------------------- (C) ---------------------------------
  12795. Author: Mihai Bazon
  12796. <mihai.bazon@gmail.com>
  12797. http://mihai.bazon.net/blog
  12798. Distributed under the BSD license:
  12799. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12800. Redistribution and use in source and binary forms, with or without
  12801. modification, are permitted provided that the following conditions
  12802. are met:
  12803. * Redistributions of source code must retain the above
  12804. copyright notice, this list of conditions and the following
  12805. disclaimer.
  12806. * Redistributions in binary form must reproduce the above
  12807. copyright notice, this list of conditions and the following
  12808. disclaimer in the documentation and/or other materials
  12809. provided with the distribution.
  12810. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12811. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12812. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12813. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12814. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12815. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12816. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12817. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12818. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12819. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12820. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12821. SUCH DAMAGE.
  12822. ***********************************************************************/
  12823. // bitfield flags to be stored in node.flags.
  12824. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  12825. const UNUSED = 0b00000001;
  12826. const TRUTHY = 0b00000010;
  12827. const FALSY = 0b00000100;
  12828. const UNDEFINED = 0b00001000;
  12829. const INLINED = 0b00010000;
  12830. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  12831. const WRITE_ONLY = 0b00100000;
  12832. // information specific to a single compression pass
  12833. const SQUEEZED = 0b0000000100000000;
  12834. const OPTIMIZED = 0b0000001000000000;
  12835. const TOP = 0b0000010000000000;
  12836. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  12837. const has_flag = (node, flag) => node.flags & flag;
  12838. const set_flag = (node, flag) => { node.flags |= flag; };
  12839. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  12840. /***********************************************************************
  12841. A JavaScript tokenizer / parser / beautifier / compressor.
  12842. https://github.com/mishoo/UglifyJS2
  12843. -------------------------------- (C) ---------------------------------
  12844. Author: Mihai Bazon
  12845. <mihai.bazon@gmail.com>
  12846. http://mihai.bazon.net/blog
  12847. Distributed under the BSD license:
  12848. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12849. Redistribution and use in source and binary forms, with or without
  12850. modification, are permitted provided that the following conditions
  12851. are met:
  12852. * Redistributions of source code must retain the above
  12853. copyright notice, this list of conditions and the following
  12854. disclaimer.
  12855. * Redistributions in binary form must reproduce the above
  12856. copyright notice, this list of conditions and the following
  12857. disclaimer in the documentation and/or other materials
  12858. provided with the distribution.
  12859. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12860. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12861. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12862. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12863. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12864. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12865. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12866. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12867. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12868. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12869. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12870. SUCH DAMAGE.
  12871. ***********************************************************************/
  12872. function merge_sequence(array, node) {
  12873. if (node instanceof AST_Sequence) {
  12874. array.push(...node.expressions);
  12875. } else {
  12876. array.push(node);
  12877. }
  12878. return array;
  12879. }
  12880. function make_sequence(orig, expressions) {
  12881. if (expressions.length == 1) return expressions[0];
  12882. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  12883. return make_node(AST_Sequence, orig, {
  12884. expressions: expressions.reduce(merge_sequence, [])
  12885. });
  12886. }
  12887. function make_empty_function(self) {
  12888. return make_node(AST_Function, self, {
  12889. uses_arguments: false,
  12890. argnames: [],
  12891. body: [],
  12892. is_generator: false,
  12893. async: false,
  12894. variables: new Map(),
  12895. uses_with: false,
  12896. uses_eval: false,
  12897. parent_scope: null,
  12898. enclosed: [],
  12899. cname: 0,
  12900. block_scope: undefined,
  12901. });
  12902. }
  12903. function make_node_from_constant(val, orig) {
  12904. switch (typeof val) {
  12905. case "string":
  12906. return make_node(AST_String, orig, {
  12907. value: val
  12908. });
  12909. case "number":
  12910. if (isNaN(val)) return make_node(AST_NaN, orig);
  12911. if (isFinite(val)) {
  12912. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  12913. operator: "-",
  12914. expression: make_node(AST_Number, orig, { value: -val })
  12915. }) : make_node(AST_Number, orig, { value: val });
  12916. }
  12917. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  12918. operator: "-",
  12919. expression: make_node(AST_Infinity, orig)
  12920. }) : make_node(AST_Infinity, orig);
  12921. case "bigint":
  12922. return make_node(AST_BigInt, orig, { value: val.toString() });
  12923. case "boolean":
  12924. return make_node(val ? AST_True : AST_False, orig);
  12925. case "undefined":
  12926. return make_void_0(orig);
  12927. default:
  12928. if (val === null) {
  12929. return make_node(AST_Null, orig, { value: null });
  12930. }
  12931. if (val instanceof RegExp) {
  12932. return make_node(AST_RegExp, orig, {
  12933. value: {
  12934. source: regexp_source_fix(val.source),
  12935. flags: val.flags
  12936. }
  12937. });
  12938. }
  12939. throw new Error(string_template("Can't handle constant of type: {type}", {
  12940. type: typeof val
  12941. }));
  12942. }
  12943. }
  12944. function best_of_expression(ast1, ast2) {
  12945. return ast1.size() > ast2.size() ? ast2 : ast1;
  12946. }
  12947. function best_of_statement(ast1, ast2) {
  12948. return best_of_expression(
  12949. make_node(AST_SimpleStatement, ast1, {
  12950. body: ast1
  12951. }),
  12952. make_node(AST_SimpleStatement, ast2, {
  12953. body: ast2
  12954. })
  12955. ).body;
  12956. }
  12957. /** Find which node is smaller, and return that */
  12958. function best_of(compressor, ast1, ast2) {
  12959. if (first_in_statement(compressor)) {
  12960. return best_of_statement(ast1, ast2);
  12961. } else {
  12962. return best_of_expression(ast1, ast2);
  12963. }
  12964. }
  12965. /** Simplify an object property's key, if possible */
  12966. function get_simple_key(key) {
  12967. if (key instanceof AST_Constant) {
  12968. return key.getValue();
  12969. }
  12970. if (key instanceof AST_UnaryPrefix
  12971. && key.operator == "void"
  12972. && key.expression instanceof AST_Constant) {
  12973. return undefined;
  12974. }
  12975. return key;
  12976. }
  12977. function read_property(obj, key) {
  12978. key = get_simple_key(key);
  12979. if (key instanceof AST_Node) return;
  12980. var value;
  12981. if (obj instanceof AST_Array) {
  12982. var elements = obj.elements;
  12983. if (key == "length") return make_node_from_constant(elements.length, obj);
  12984. if (typeof key == "number" && key in elements) value = elements[key];
  12985. } else if (obj instanceof AST_Object) {
  12986. key = "" + key;
  12987. var props = obj.properties;
  12988. for (var i = props.length; --i >= 0;) {
  12989. var prop = props[i];
  12990. if (!(prop instanceof AST_ObjectKeyVal)) return;
  12991. if (!value && props[i].key === key) value = props[i].value;
  12992. }
  12993. }
  12994. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  12995. }
  12996. function has_break_or_continue(loop, parent) {
  12997. var found = false;
  12998. var tw = new TreeWalker(function(node) {
  12999. if (found || node instanceof AST_Scope) return true;
  13000. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  13001. return found = true;
  13002. }
  13003. });
  13004. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  13005. tw.push(loop);
  13006. loop.body.walk(tw);
  13007. return found;
  13008. }
  13009. // we shouldn't compress (1,func)(something) to
  13010. // func(something) because that changes the meaning of
  13011. // the func (becomes lexical instead of global).
  13012. function maintain_this_binding(parent, orig, val) {
  13013. if (requires_sequence_to_maintain_binding(parent, orig, val)) {
  13014. const zero = make_node(AST_Number, orig, { value: 0 });
  13015. return make_sequence(orig, [ zero, val ]);
  13016. } else {
  13017. return val;
  13018. }
  13019. }
  13020. /** Detect (1, x.noThis)(), (0, eval)(), which need sequences */
  13021. function requires_sequence_to_maintain_binding(parent, orig, val) {
  13022. return (
  13023. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  13024. || parent instanceof AST_Call && parent.expression === orig
  13025. && (
  13026. val instanceof AST_Chain
  13027. || val instanceof AST_PropAccess
  13028. || val instanceof AST_SymbolRef && val.name == "eval"
  13029. )
  13030. );
  13031. }
  13032. function is_func_expr(node) {
  13033. return node instanceof AST_Arrow || node instanceof AST_Function;
  13034. }
  13035. /**
  13036. * Used to determine whether the node can benefit from negation.
  13037. * Not the case with arrow functions (you need an extra set of parens). */
  13038. function is_iife_call(node) {
  13039. if (node.TYPE != "Call") return false;
  13040. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  13041. }
  13042. function is_empty(thing) {
  13043. if (thing === null) return true;
  13044. if (thing instanceof AST_EmptyStatement) return true;
  13045. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  13046. return false;
  13047. }
  13048. const identifier_atom = makePredicate("Infinity NaN undefined");
  13049. function is_identifier_atom(node) {
  13050. return node instanceof AST_Infinity
  13051. || node instanceof AST_NaN
  13052. || node instanceof AST_Undefined;
  13053. }
  13054. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  13055. function is_ref_of(ref, type) {
  13056. if (!(ref instanceof AST_SymbolRef)) return false;
  13057. var orig = ref.definition().orig;
  13058. for (var i = orig.length; --i >= 0;) {
  13059. if (orig[i] instanceof type) return true;
  13060. }
  13061. }
  13062. /**Can we turn { block contents... } into just the block contents ?
  13063. * Not if one of these is inside.
  13064. **/
  13065. function can_be_evicted_from_block(node) {
  13066. return !(
  13067. node instanceof AST_DefClass ||
  13068. node instanceof AST_Defun ||
  13069. node instanceof AST_Let ||
  13070. node instanceof AST_Const ||
  13071. node instanceof AST_Using ||
  13072. node instanceof AST_Export ||
  13073. node instanceof AST_Import
  13074. );
  13075. }
  13076. function as_statement_array(thing) {
  13077. if (thing === null) return [];
  13078. if (thing instanceof AST_BlockStatement) return thing.body;
  13079. if (thing instanceof AST_EmptyStatement) return [];
  13080. if (thing instanceof AST_Statement) return [ thing ];
  13081. throw new Error("Can't convert thing to statement array");
  13082. }
  13083. function is_reachable(scope_node, defs) {
  13084. const find_ref = node => {
  13085. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  13086. return walk_abort;
  13087. }
  13088. };
  13089. return walk_parent(scope_node, (node, info) => {
  13090. if (node instanceof AST_Scope && node !== scope_node) {
  13091. var parent = info.parent();
  13092. if (
  13093. parent instanceof AST_Call
  13094. && parent.expression === node
  13095. // Async/Generators aren't guaranteed to sync evaluate all of
  13096. // their body steps, so it's possible they close over the variable.
  13097. && !(node.async || node.is_generator)
  13098. ) {
  13099. return;
  13100. }
  13101. if (walk(node, find_ref)) return walk_abort;
  13102. return true;
  13103. }
  13104. });
  13105. }
  13106. /** Check if a ref refers to the name of a function/class it's defined within */
  13107. function is_recursive_ref(tw, def) {
  13108. var node;
  13109. for (var i = 0; node = tw.parent(i); i++) {
  13110. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  13111. var name = node.name;
  13112. if (name && name.definition() === def) {
  13113. return true;
  13114. }
  13115. }
  13116. }
  13117. return false;
  13118. }
  13119. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  13120. function retain_top_func(fn, compressor) {
  13121. return compressor.top_retain
  13122. && fn instanceof AST_Defun
  13123. && has_flag(fn, TOP)
  13124. && fn.name
  13125. && compressor.top_retain(fn.name.definition());
  13126. }
  13127. /***********************************************************************
  13128. A JavaScript tokenizer / parser / beautifier / compressor.
  13129. https://github.com/mishoo/UglifyJS2
  13130. -------------------------------- (C) ---------------------------------
  13131. Author: Mihai Bazon
  13132. <mihai.bazon@gmail.com>
  13133. http://mihai.bazon.net/blog
  13134. Distributed under the BSD license:
  13135. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13136. Redistribution and use in source and binary forms, with or without
  13137. modification, are permitted provided that the following conditions
  13138. are met:
  13139. * Redistributions of source code must retain the above
  13140. copyright notice, this list of conditions and the following
  13141. disclaimer.
  13142. * Redistributions in binary form must reproduce the above
  13143. copyright notice, this list of conditions and the following
  13144. disclaimer in the documentation and/or other materials
  13145. provided with the distribution.
  13146. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13147. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13148. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13149. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13150. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13151. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13152. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13153. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13154. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13155. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13156. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13157. SUCH DAMAGE.
  13158. ***********************************************************************/
  13159. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  13160. // Note: Lots of methods and functions are missing here, in case they aren't pure
  13161. // or not available in all JS environments.
  13162. const make_nested_lookup = (feature_callback) => (compressor) => {
  13163. const obj = feature_callback(feature_variables(compressor));
  13164. const out = new Map();
  13165. for (var key of Object.keys(obj)) {
  13166. if (obj[key]) {
  13167. out.set(key, makePredicate(remove_false(obj[key])));
  13168. }
  13169. }
  13170. const does_have = (global_name, fname) => {
  13171. const inner_map = out.get(global_name);
  13172. return inner_map != null && inner_map.has(fname);
  13173. };
  13174. return does_have;
  13175. };
  13176. const make_lookup = (feature_callback) => (compressor) => {
  13177. const obj = feature_callback(feature_variables(compressor));
  13178. const predicate = makePredicate(remove_false(obj));
  13179. const does_have = (global_name) => {
  13180. return predicate.has(global_name);
  13181. };
  13182. return does_have;
  13183. };
  13184. function remove_false(arr) {
  13185. for (let i = 0; i < arr.length; i++) {
  13186. if (arr[i] === false) {
  13187. arr.splice(i, 1);
  13188. i--;
  13189. }
  13190. }
  13191. return arr;
  13192. }
  13193. /** Generate the object with arguments seen below */
  13194. function feature_variables(compressor) {
  13195. return {
  13196. sloppy: compressor.option("unsafe"),
  13197. es: compressor.option("builtins_ecma"),
  13198. };
  13199. }
  13200. // eslint-disable-next-line no-unused-vars
  13201. const pure_access_globals = make_lookup(({ sloppy, es }) => [
  13202. "Array",
  13203. "Boolean",
  13204. "clearInterval",
  13205. "clearTimeout",
  13206. "console",
  13207. "Date",
  13208. "decodeURI",
  13209. "decodeURIComponent",
  13210. "encodeURI",
  13211. "encodeURIComponent",
  13212. "Error",
  13213. "escape",
  13214. "eval",
  13215. "EvalError",
  13216. "Function",
  13217. es >= 2020 && "globalThis",
  13218. "isFinite",
  13219. "isNaN",
  13220. "JSON",
  13221. "Math",
  13222. "Number",
  13223. "parseFloat",
  13224. "parseInt",
  13225. "RangeError",
  13226. "ReferenceError",
  13227. "RegExp",
  13228. "Object",
  13229. "setInterval",
  13230. "setTimeout",
  13231. "String",
  13232. "SyntaxError",
  13233. "TypeError",
  13234. "unescape",
  13235. "URIError",
  13236. ]);
  13237. // Objects which are safe to access without throwing or causing a side effect.
  13238. // Usually we'd check the `unsafe` option first but these are way too common for that
  13239. const pure_prop_access_globals = new Set([
  13240. "Number",
  13241. "String",
  13242. "Array",
  13243. "Object",
  13244. "Function",
  13245. "Promise",
  13246. ]);
  13247. // eslint-disable-next-line no-unused-vars
  13248. const is_pure_native_fn = make_lookup(({ sloppy, es }) => [
  13249. sloppy && es >= 2021 && "AggregateError",
  13250. "Array",
  13251. "ArrayBuffer",
  13252. es >= 2020 && "BigInt",
  13253. es >= 2020 && "BigInt64Array",
  13254. es >= 2020 && "BigUint64Array",
  13255. "Boolean",
  13256. "Date",
  13257. sloppy && "decodeURI",
  13258. sloppy && "decodeURIComponent",
  13259. sloppy && "encodeURI",
  13260. sloppy && "encodeURIComponent",
  13261. "Error",
  13262. "escape",
  13263. "EvalError",
  13264. es >= 2021 && "FinalizationRegistry",
  13265. es >= 2026 && "Float16Array",
  13266. "Float32Array",
  13267. "Float64Array",
  13268. "Int16Array",
  13269. "Int32Array",
  13270. "Int8Array",
  13271. "isFinite",
  13272. "isNaN",
  13273. es >= 2026 && "Iterator",
  13274. es >= 2015 && "Map",
  13275. "Number",
  13276. "parseFloat",
  13277. "parseInt",
  13278. es >= 2015 && "Promise",
  13279. es >= 2015 && "Proxy",
  13280. "RangeError",
  13281. "ReferenceError",
  13282. sloppy && "RegExp",
  13283. es >= 2015 && "Set",
  13284. "String",
  13285. es >= 2015 && "Symbol",
  13286. "SyntaxError",
  13287. "TypeError",
  13288. "Uint16Array",
  13289. "Uint32Array",
  13290. "Uint8Array",
  13291. "Uint8ClampedArray",
  13292. sloppy && "unescape",
  13293. "URIError",
  13294. sloppy && es >= 2015 && "WeakMap",
  13295. sloppy && es >= 2021 && "WeakRef",
  13296. sloppy && es >= 2015 && "WeakSet",
  13297. ]);
  13298. const arg1_is_iterable = new Set([
  13299. "Map",
  13300. "Set",
  13301. "WeakMap",
  13302. "WeakSet",
  13303. ]);
  13304. const arg1_is_range_or_iterable = new Set([
  13305. "ArrayBuffer",
  13306. "Float32Array",
  13307. "Float64Array",
  13308. "Int16Array",
  13309. "Int32Array",
  13310. "Int8Array",
  13311. "Uint16Array",
  13312. "Uint32Array",
  13313. "Uint8Array",
  13314. "Uint8ClampedArray",
  13315. ]);
  13316. const lone_arg_is_range = new Set(["Array"]);
  13317. const object_methods = [
  13318. "constructor",
  13319. "toString",
  13320. "valueOf",
  13321. ];
  13322. // eslint-disable-next-line no-unused-vars
  13323. const is_pure_native_method = make_nested_lookup(({ sloppy, es }) => ({
  13324. Array: [
  13325. es >= 2022 && "at",
  13326. es >= 2019 && "flat",
  13327. es >= 2016 && "includes",
  13328. "indexOf",
  13329. "join",
  13330. "lastIndexOf",
  13331. "slice",
  13332. ...object_methods,
  13333. ],
  13334. Boolean: object_methods,
  13335. Function: object_methods,
  13336. Number: [
  13337. "toExponential",
  13338. "toFixed",
  13339. "toPrecision",
  13340. ...object_methods,
  13341. ],
  13342. Object: object_methods,
  13343. RegExp: [
  13344. "test",
  13345. ...object_methods,
  13346. ],
  13347. String: [
  13348. es >= 2022 && "at",
  13349. "charAt",
  13350. "charCodeAt",
  13351. es >= 2015 && "codePointAt",
  13352. "concat",
  13353. es >= 2025 && "endsWith",
  13354. es >= 2015 && "includes",
  13355. "indexOf",
  13356. "italics",
  13357. "lastIndexOf",
  13358. es >= 2020 && "localeCompare",
  13359. "match",
  13360. es >= 2020 && "matchAll",
  13361. es >= 2015 && "normalize",
  13362. es >= 2017 && "padStart",
  13363. es >= 2017 && "padEnd",
  13364. es >= 2015 && sloppy && "repeat",
  13365. "replace",
  13366. es >= 2021 && "replaceAll",
  13367. "search",
  13368. "slice",
  13369. "split",
  13370. es >= 2015 && "startsWith",
  13371. "substr",
  13372. "substring",
  13373. es >= 2015 && "repeat",
  13374. "toLocaleLowerCase",
  13375. "toLocaleUpperCase",
  13376. "toLowerCase",
  13377. "toUpperCase",
  13378. "trim",
  13379. es >= 2019 && "trimEnd",
  13380. es >= 2019 && "trimStart",
  13381. es >= 2019 && "trimLeft",
  13382. es >= 2019 && "trimRight",
  13383. ...object_methods,
  13384. ],
  13385. }));
  13386. // eslint-disable-next-line no-unused-vars
  13387. const is_pure_native_static_fn = make_nested_lookup(({ sloppy, es }) => ({
  13388. Array: [
  13389. "isArray",
  13390. es >= 2015 && "of",
  13391. ],
  13392. ArrayBuffer: [
  13393. "isView",
  13394. ],
  13395. BigInt: es >= 2020 && [
  13396. sloppy && "asIntN",
  13397. sloppy && "asUintN",
  13398. ],
  13399. BigInt64Array: sloppy && es >= 2020 && ["of"],
  13400. BigUint64Array: sloppy && es >= 2020 && ["of"],
  13401. Date: [
  13402. "now",
  13403. "parse",
  13404. "UTC",
  13405. ],
  13406. Error: [
  13407. es >= 2026 && "isError",
  13408. ],
  13409. Float16Array: sloppy && es >= 2026 && ["of"],
  13410. Float32Array: sloppy && ["of"],
  13411. Float64Array: sloppy && ["of"],
  13412. Int16Array: sloppy && ["of"],
  13413. Int32Array: sloppy && ["of"],
  13414. Int8Array: sloppy && ["of"],
  13415. Math: [
  13416. "abs",
  13417. "acos",
  13418. es >= 2015 && "acosh",
  13419. "asin",
  13420. es >= 2015 && "asinh",
  13421. "atan",
  13422. "atan2",
  13423. es >= 2015 && "atanh",
  13424. es >= 2015 && "cbrt",
  13425. "ceil",
  13426. es >= 2015 && "clz32",
  13427. "cos",
  13428. es >= 2015 && "cosh",
  13429. "exp",
  13430. es >= 2015 && "expm1",
  13431. "floor",
  13432. es >= 2026 && "f16round",
  13433. es >= 2015 && "fround",
  13434. es >= 2015 && "hypot",
  13435. es >= 2015 && "imul",
  13436. "log",
  13437. es >= 2015 && "log10",
  13438. es >= 2015 && "log1p",
  13439. es >= 2015 && "log2",
  13440. "max",
  13441. "min",
  13442. "pow",
  13443. "round",
  13444. es >= 2015 && "sign",
  13445. "sin",
  13446. es >= 2015 && "sinh",
  13447. "sqrt",
  13448. "tan",
  13449. es >= 2015 && "tanh",
  13450. es >= 2015 && "trunc",
  13451. ],
  13452. Number: [
  13453. es >= 2015 && "isFinite",
  13454. es >= 2015 && "isInteger",
  13455. es >= 2015 && "isSafeInteger",
  13456. es >= 2015 && "isNaN",
  13457. es >= 2015 && "parseFloat",
  13458. es >= 2015 && "parseInt",
  13459. ],
  13460. Object: [
  13461. sloppy && "create",
  13462. sloppy && "getOwnPropertyDescriptor",
  13463. es >= 2017 && sloppy && "getOwnPropertyDescriptors",
  13464. sloppy && "getOwnPropertyNames",
  13465. es >= 2015 && sloppy && "getOwnPropertySymbols",
  13466. sloppy && "getPrototypeOf",
  13467. es >= 2022 && sloppy && "hasOwn",
  13468. es >= 2015 && "is",
  13469. "isExtensible",
  13470. "isFrozen",
  13471. "isSealed",
  13472. es >= 2015 && sloppy && "keys",
  13473. ],
  13474. Promise: es >= 2015 && [
  13475. es >= 2024 && "withResolvers",
  13476. ],
  13477. Proxy: es >= 2015 && [
  13478. sloppy && "revocable",
  13479. ],
  13480. Reflect: es >= 2015 && [
  13481. sloppy && "has",
  13482. sloppy && "isExtensible",
  13483. sloppy && "ownKeys",
  13484. ],
  13485. RegExp: [
  13486. es >= 2026 && sloppy && "escape",
  13487. ],
  13488. String: [
  13489. "fromCharCode",
  13490. sloppy && es >= 2025 && "fromCodePoint",
  13491. ],
  13492. Uint16Array: ["of"],
  13493. Uint32Array: ["of"],
  13494. Uint8Array: ["of"],
  13495. Uint8ClampedArray: ["of"],
  13496. }));
  13497. // Known numeric values which come with JS environments
  13498. // eslint-disable-next-line no-unused-vars
  13499. const is_pure_native_static_property = make_nested_lookup(({ sloppy, es }) => ({
  13500. Math: [
  13501. "E",
  13502. "LN10",
  13503. "LN2",
  13504. "LOG2E",
  13505. "LOG10E",
  13506. "PI",
  13507. "SQRT1_2",
  13508. "SQRT2",
  13509. ],
  13510. Number: [
  13511. es >= 2015 && "EPSILON",
  13512. es >= 2015 && "MAX_SAFE_VALUE",
  13513. "MAX_VALUE",
  13514. es >= 2015 && "MIN_SAFE_VALUE",
  13515. "MIN_VALUE",
  13516. "NaN",
  13517. "NEGATIVE_INFINITY",
  13518. "POSITIVE_INFINITY",
  13519. ],
  13520. RegExp: [
  13521. "$_",
  13522. "$0",
  13523. "$1",
  13524. "$2",
  13525. "$3",
  13526. "$4",
  13527. "$5",
  13528. "$6",
  13529. "$7",
  13530. "$8",
  13531. "$9",
  13532. "input",
  13533. "lastMatch",
  13534. "lastParen",
  13535. "leftContext",
  13536. "rightContext",
  13537. ],
  13538. }));
  13539. const re_uppercase_first_letter = /^[A-Z]/;
  13540. function is_pure_builtin_call(compressor, call) {
  13541. let builtin = "";
  13542. let method = "";
  13543. let exp = call.expression;
  13544. if (is_undeclared_ref(exp)) {
  13545. builtin = exp.name;
  13546. } else if (exp instanceof AST_Dot) {
  13547. method = exp.property;
  13548. exp = exp.expression;
  13549. if (is_undeclared_ref(exp)) {
  13550. if (
  13551. // globalThis.pureFunc()
  13552. exp.name === "globalThis"
  13553. && compressor.option("builtins_ecma") >= 2020
  13554. ) {
  13555. builtin = method;
  13556. method = "";
  13557. } else {
  13558. // SomeBuiltin.pureFunc()
  13559. builtin = exp.name;
  13560. }
  13561. } else if (exp instanceof AST_Dot) {
  13562. if (
  13563. is_undeclared_ref(exp.expression)
  13564. && exp.expression.name === "globalThis"
  13565. && compressor.option("builtins_ecma") >= 2020
  13566. ) {
  13567. // globalThis.SomeBuiltin.pureFunc()
  13568. builtin = exp.property;
  13569. } else {
  13570. return false;
  13571. }
  13572. } else {
  13573. return false;
  13574. }
  13575. } else {
  13576. return false;
  13577. }
  13578. if (!method) {
  13579. if (compressor.is_pure_native_fn(builtin)) {
  13580. // some require `new`, others throw if you use it
  13581. const is_new = call instanceof AST_New;
  13582. const should_be_new = re_uppercase_first_letter.test(builtin); // true of all `is_pure_native_fn`
  13583. if (is_new !== should_be_new) return false;
  13584. if (!is_builtin_pure_with_these_args(builtin, call.args)) {
  13585. return false;
  13586. }
  13587. return true;
  13588. }
  13589. return false;
  13590. } else {
  13591. return compressor.is_pure_native_static_fn(builtin, method);
  13592. }
  13593. }
  13594. /** Some builtins are listed above but their purity is subject to some conditions */
  13595. function is_builtin_pure_with_these_args(builtin, args) {
  13596. // all the builtins we deal with here are ok with getting 0 args
  13597. if (args.length === 0) return true;
  13598. let arg1 = args[0];
  13599. if (arg1 instanceof AST_SymbolRef) {
  13600. arg1 = arg1.fixed_value();
  13601. }
  13602. if (lone_arg_is_range.has(builtin)) { // new Array(number)
  13603. const arg_valid = args.length > 1
  13604. || arg1 instanceof AST_Number
  13605. && arg1.value >= 0 && arg1.value <= 0xffffffff;
  13606. // TODO: or, we are asked to ignore TypeError
  13607. if (!arg_valid) return false;
  13608. }
  13609. if (arg1_is_range_or_iterable.has(builtin)) { // new Float32Array(number | Array)
  13610. const arg_valid = args.length === 0
  13611. || arg1 instanceof AST_Array
  13612. || arg1 instanceof AST_Number
  13613. && arg1.value >= 0 && arg1.value <= 0xffffffff;
  13614. if (!arg_valid) return false;
  13615. }
  13616. if (arg1_is_iterable.has(builtin)) { // new Set(iterable)
  13617. const arg_valid = args.length === 0 || arg1 instanceof AST_Array;
  13618. if (!arg_valid) return false;
  13619. }
  13620. return true;
  13621. }
  13622. /***********************************************************************
  13623. A JavaScript tokenizer / parser / beautifier / compressor.
  13624. https://github.com/mishoo/UglifyJS2
  13625. -------------------------------- (C) ---------------------------------
  13626. Author: Mihai Bazon
  13627. <mihai.bazon@gmail.com>
  13628. http://mihai.bazon.net/blog
  13629. Distributed under the BSD license:
  13630. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13631. Redistribution and use in source and binary forms, with or without
  13632. modification, are permitted provided that the following conditions
  13633. are met:
  13634. * Redistributions of source code must retain the above
  13635. copyright notice, this list of conditions and the following
  13636. disclaimer.
  13637. * Redistributions in binary form must reproduce the above
  13638. copyright notice, this list of conditions and the following
  13639. disclaimer in the documentation and/or other materials
  13640. provided with the distribution.
  13641. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13642. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13643. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13644. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13645. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13646. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13647. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13648. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13649. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13650. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13651. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13652. SUCH DAMAGE.
  13653. ***********************************************************************/
  13654. // Functions and methods to infer certain facts about expressions
  13655. // It's not always possible to be 100% sure about something just by static analysis,
  13656. // so `true` means yes, and `false` means maybe
  13657. const is_undeclared_ref = (node) =>
  13658. node instanceof AST_SymbolRef && node.definition().undeclared;
  13659. const bitwise_binop = makePredicate("<<< >> << & | ^ ~");
  13660. const lazy_op = makePredicate("&& || ??");
  13661. const unary_side_effects = makePredicate("delete ++ --");
  13662. // methods to determine whether an expression has a boolean result type
  13663. (function(def_is_boolean) {
  13664. const unary_bool = makePredicate("! delete");
  13665. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  13666. def_is_boolean(AST_Node, return_false);
  13667. def_is_boolean(AST_UnaryPrefix, function() {
  13668. return unary_bool.has(this.operator);
  13669. });
  13670. def_is_boolean(AST_Binary, function() {
  13671. return binary_bool.has(this.operator)
  13672. || lazy_op.has(this.operator)
  13673. && this.left.is_boolean()
  13674. && this.right.is_boolean();
  13675. });
  13676. def_is_boolean(AST_Conditional, function() {
  13677. return this.consequent.is_boolean() && this.alternative.is_boolean();
  13678. });
  13679. def_is_boolean(AST_Assign, function() {
  13680. return this.operator == "=" && this.right.is_boolean();
  13681. });
  13682. def_is_boolean(AST_Sequence, function() {
  13683. return this.tail_node().is_boolean();
  13684. });
  13685. def_is_boolean(AST_True, return_true);
  13686. def_is_boolean(AST_False, return_true);
  13687. })(function(node, func) {
  13688. node.DEFMETHOD("is_boolean", func);
  13689. });
  13690. // methods to determine if an expression has a numeric result type
  13691. (function(def_is_number) {
  13692. def_is_number(AST_Node, return_false);
  13693. def_is_number(AST_Number, return_true);
  13694. const unary = makePredicate("+ - ~ ++ --");
  13695. def_is_number(AST_Unary, function(compressor) {
  13696. return unary.has(this.operator) && this.expression.is_number(compressor);
  13697. });
  13698. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  13699. def_is_number(AST_Binary, function(compressor) {
  13700. if (this.operator === "+") {
  13701. // Both sides need to be `number`. Or one is a `number` and the other is number-ish.
  13702. return this.left.is_number(compressor) && this.right.is_number_or_bigint(compressor)
  13703. || this.right.is_number(compressor) && this.left.is_number_or_bigint(compressor);
  13704. } else if (numeric_ops.has(this.operator)) {
  13705. return this.left.is_number(compressor) || this.right.is_number(compressor);
  13706. } else {
  13707. return false;
  13708. }
  13709. });
  13710. def_is_number(AST_Assign, function(compressor) {
  13711. return (this.operator === "=" || numeric_ops.has(this.operator.slice(0, -1)))
  13712. && this.right.is_number(compressor);
  13713. });
  13714. def_is_number(AST_Sequence, function(compressor) {
  13715. return this.tail_node().is_number(compressor);
  13716. });
  13717. def_is_number(AST_Conditional, function(compressor) {
  13718. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  13719. });
  13720. })(function(node, func) {
  13721. node.DEFMETHOD("is_number", func);
  13722. });
  13723. // methods to determine if an expression returns a BigInt
  13724. (function(def_is_bigint) {
  13725. def_is_bigint(AST_Node, return_false);
  13726. def_is_bigint(AST_BigInt, return_true);
  13727. const unary = makePredicate("+ - ~ ++ --");
  13728. def_is_bigint(AST_Unary, function(compressor) {
  13729. return unary.has(this.operator) && this.expression.is_bigint(compressor);
  13730. });
  13731. const numeric_ops = makePredicate("- * / % & | ^ << >>");
  13732. def_is_bigint(AST_Binary, function(compressor) {
  13733. if (this.operator === "+") {
  13734. return this.left.is_bigint(compressor) && this.right.is_number_or_bigint(compressor)
  13735. || this.right.is_bigint(compressor) && this.left.is_number_or_bigint(compressor);
  13736. } else if (numeric_ops.has(this.operator)) {
  13737. return this.left.is_bigint(compressor) || this.right.is_bigint(compressor);
  13738. } else {
  13739. return false;
  13740. }
  13741. });
  13742. def_is_bigint(AST_Assign, function(compressor) {
  13743. return (numeric_ops.has(this.operator.slice(0, -1)) || this.operator == "=")
  13744. && this.right.is_bigint(compressor);
  13745. });
  13746. def_is_bigint(AST_Sequence, function(compressor) {
  13747. return this.tail_node().is_bigint(compressor);
  13748. });
  13749. def_is_bigint(AST_Conditional, function(compressor) {
  13750. return this.consequent.is_bigint(compressor) && this.alternative.is_bigint(compressor);
  13751. });
  13752. })(function(node, func) {
  13753. node.DEFMETHOD("is_bigint", func);
  13754. });
  13755. // methods to determine if an expression is a number or a bigint
  13756. (function(def_is_number_or_bigint) {
  13757. def_is_number_or_bigint(AST_Node, return_false);
  13758. def_is_number_or_bigint(AST_Number, return_true);
  13759. def_is_number_or_bigint(AST_BigInt, return_true);
  13760. const numeric_unary_ops = makePredicate("+ - ~ ++ --");
  13761. def_is_number_or_bigint(AST_Unary, function(_compressor) {
  13762. return numeric_unary_ops.has(this.operator);
  13763. });
  13764. const numeric_ops = makePredicate("- * / % & | ^ << >>");
  13765. def_is_number_or_bigint(AST_Binary, function(compressor) {
  13766. return this.operator === "+"
  13767. ? this.left.is_number_or_bigint(compressor) && this.right.is_number_or_bigint(compressor)
  13768. : numeric_ops.has(this.operator);
  13769. });
  13770. def_is_number_or_bigint(AST_Assign, function(compressor) {
  13771. return numeric_ops.has(this.operator.slice(0, -1))
  13772. || this.operator == "=" && this.right.is_number_or_bigint(compressor);
  13773. });
  13774. def_is_number_or_bigint(AST_Sequence, function(compressor) {
  13775. return this.tail_node().is_number_or_bigint(compressor);
  13776. });
  13777. def_is_number_or_bigint(AST_Conditional, function(compressor) {
  13778. return this.consequent.is_number_or_bigint(compressor) && this.alternative.is_number_or_bigint(compressor);
  13779. });
  13780. }(function (node, func) {
  13781. node.DEFMETHOD("is_number_or_bigint", func);
  13782. }));
  13783. // methods to determine if an expression is a 32 bit integer (IE results from bitwise ops, or is an integer constant fitting in that size
  13784. (function(def_is_32_bit_integer) {
  13785. def_is_32_bit_integer(AST_Node, return_false);
  13786. def_is_32_bit_integer(AST_Number, function(_compressor) {
  13787. return this.value === (this.value | 0);
  13788. });
  13789. def_is_32_bit_integer(AST_UnaryPrefix, function(compressor) {
  13790. return this.operator == "~" ? this.expression.is_number(compressor)
  13791. : this.operator === "+" ? this.expression.is_32_bit_integer(compressor)
  13792. : false;
  13793. });
  13794. def_is_32_bit_integer(AST_Binary, function(compressor) {
  13795. return bitwise_binop.has(this.operator)
  13796. && (this.left.is_number(compressor) || this.right.is_number(compressor));
  13797. });
  13798. }(function (node, func) {
  13799. node.DEFMETHOD("is_32_bit_integer", func);
  13800. }));
  13801. // methods to determine if an expression has a string result type
  13802. (function(def_is_string) {
  13803. def_is_string(AST_Node, return_false);
  13804. def_is_string(AST_String, return_true);
  13805. def_is_string(AST_TemplateString, return_true);
  13806. def_is_string(AST_UnaryPrefix, function() {
  13807. return this.operator == "typeof";
  13808. });
  13809. def_is_string(AST_Binary, function(compressor) {
  13810. return this.operator == "+" &&
  13811. (this.left.is_string(compressor) || this.right.is_string(compressor));
  13812. });
  13813. def_is_string(AST_Assign, function(compressor) {
  13814. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  13815. });
  13816. def_is_string(AST_Sequence, function(compressor) {
  13817. return this.tail_node().is_string(compressor);
  13818. });
  13819. def_is_string(AST_Conditional, function(compressor) {
  13820. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  13821. });
  13822. })(function(node, func) {
  13823. node.DEFMETHOD("is_string", func);
  13824. });
  13825. function is_undefined(node, compressor) {
  13826. return (
  13827. has_flag(node, UNDEFINED)
  13828. || node instanceof AST_Undefined
  13829. || node instanceof AST_UnaryPrefix
  13830. && node.operator == "void"
  13831. && !node.expression.has_side_effects(compressor)
  13832. );
  13833. }
  13834. // Is the node explicitly null or undefined.
  13835. function is_null_or_undefined(node, compressor) {
  13836. let fixed;
  13837. return (
  13838. node instanceof AST_Null
  13839. || is_undefined(node, compressor)
  13840. || (
  13841. node instanceof AST_SymbolRef
  13842. && (fixed = node.definition().fixed) instanceof AST_Node
  13843. && is_nullish(fixed, compressor)
  13844. )
  13845. );
  13846. }
  13847. // Find out if this expression is optionally chained from a base-point that we
  13848. // can statically analyze as null or undefined.
  13849. function is_nullish_shortcircuited(node, compressor) {
  13850. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  13851. return (
  13852. (node.optional && is_null_or_undefined(node.expression, compressor))
  13853. || is_nullish_shortcircuited(node.expression, compressor)
  13854. );
  13855. }
  13856. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  13857. return false;
  13858. }
  13859. // Find out if something is == null, or can short circuit into nullish.
  13860. // Used to optimize ?. and ??
  13861. function is_nullish(node, compressor) {
  13862. if (is_null_or_undefined(node, compressor)) return true;
  13863. return is_nullish_shortcircuited(node, compressor);
  13864. }
  13865. // Determine if expression might cause side effects
  13866. // If there's a possibility that a node may change something when it's executed, this returns true
  13867. (function(def_has_side_effects) {
  13868. def_has_side_effects(AST_Node, return_true);
  13869. def_has_side_effects(AST_EmptyStatement, return_false);
  13870. def_has_side_effects(AST_Constant, return_false);
  13871. def_has_side_effects(AST_This, return_false);
  13872. function any(list, compressor) {
  13873. for (var i = list.length; --i >= 0;)
  13874. if (list[i].has_side_effects(compressor))
  13875. return true;
  13876. return false;
  13877. }
  13878. def_has_side_effects(AST_Block, function(compressor) {
  13879. return any(this.body, compressor);
  13880. });
  13881. def_has_side_effects(AST_Call, function(compressor) {
  13882. if (
  13883. !this.is_callee_pure(compressor)
  13884. && (!this.expression.is_call_pure(compressor)
  13885. || this.expression.has_side_effects(compressor))
  13886. ) {
  13887. return true;
  13888. }
  13889. return any(this.args, compressor);
  13890. });
  13891. def_has_side_effects(AST_Switch, function(compressor) {
  13892. return this.expression.has_side_effects(compressor)
  13893. || any(this.body, compressor);
  13894. });
  13895. def_has_side_effects(AST_Case, function(compressor) {
  13896. return this.expression.has_side_effects(compressor)
  13897. || any(this.body, compressor);
  13898. });
  13899. def_has_side_effects(AST_Try, function(compressor) {
  13900. return this.body.has_side_effects(compressor)
  13901. || this.bcatch && this.bcatch.has_side_effects(compressor)
  13902. || this.bfinally && this.bfinally.has_side_effects(compressor);
  13903. });
  13904. def_has_side_effects(AST_If, function(compressor) {
  13905. return this.condition.has_side_effects(compressor)
  13906. || this.body && this.body.has_side_effects(compressor)
  13907. || this.alternative && this.alternative.has_side_effects(compressor);
  13908. });
  13909. def_has_side_effects(AST_ImportMeta, return_false);
  13910. def_has_side_effects(AST_DynamicImport, function() {
  13911. // `import.source(x)` only compiles the module, which is side-effect free
  13912. return this.phase !== "source";
  13913. });
  13914. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  13915. return this.body.has_side_effects(compressor);
  13916. });
  13917. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  13918. return this.body.has_side_effects(compressor);
  13919. });
  13920. def_has_side_effects(AST_Lambda, return_false);
  13921. def_has_side_effects(AST_Class, function (compressor) {
  13922. if (this.extends && this.extends.has_side_effects(compressor)) {
  13923. return true;
  13924. }
  13925. return any(this.properties, compressor);
  13926. });
  13927. def_has_side_effects(AST_ClassStaticBlock, function(compressor) {
  13928. return any(this.body, compressor);
  13929. });
  13930. def_has_side_effects(AST_Binary, function(compressor) {
  13931. return this.left.has_side_effects(compressor)
  13932. || this.right.has_side_effects(compressor);
  13933. });
  13934. def_has_side_effects(AST_Assign, return_true);
  13935. def_has_side_effects(AST_Conditional, function(compressor) {
  13936. return this.condition.has_side_effects(compressor)
  13937. || this.consequent.has_side_effects(compressor)
  13938. || this.alternative.has_side_effects(compressor);
  13939. });
  13940. def_has_side_effects(AST_Unary, function(compressor) {
  13941. return unary_side_effects.has(this.operator)
  13942. || this.expression.has_side_effects(compressor);
  13943. });
  13944. def_has_side_effects(AST_SymbolRef, function(compressor) {
  13945. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  13946. });
  13947. def_has_side_effects(AST_SymbolClassProperty, return_false);
  13948. def_has_side_effects(AST_SymbolDeclaration, return_false);
  13949. def_has_side_effects(AST_Object, function(compressor) {
  13950. return any(this.properties, compressor);
  13951. });
  13952. def_has_side_effects(AST_ObjectKeyVal, function(compressor) {
  13953. return (
  13954. this.computed_key() && this.key.has_side_effects(compressor)
  13955. || this.value && this.value.has_side_effects(compressor)
  13956. );
  13957. });
  13958. def_has_side_effects([
  13959. AST_ClassProperty,
  13960. AST_ClassPrivateProperty,
  13961. ], function(compressor) {
  13962. return (
  13963. this.computed_key() && this.key.has_side_effects(compressor)
  13964. || this.static && this.value && this.value.has_side_effects(compressor)
  13965. );
  13966. });
  13967. def_has_side_effects([
  13968. AST_PrivateMethod,
  13969. AST_PrivateGetter,
  13970. AST_PrivateSetter,
  13971. AST_ConciseMethod,
  13972. AST_ObjectGetter,
  13973. AST_ObjectSetter,
  13974. ], function(compressor) {
  13975. return this.computed_key() && this.key.has_side_effects(compressor);
  13976. });
  13977. def_has_side_effects(AST_Array, function(compressor) {
  13978. return any(this.elements, compressor);
  13979. });
  13980. def_has_side_effects(AST_Dot, function(compressor) {
  13981. if (is_nullish(this, compressor)) {
  13982. return this.expression.has_side_effects(compressor);
  13983. }
  13984. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  13985. return true;
  13986. }
  13987. return this.expression.has_side_effects(compressor);
  13988. });
  13989. def_has_side_effects(AST_Sub, function(compressor) {
  13990. if (is_nullish(this, compressor)) {
  13991. return this.expression.has_side_effects(compressor);
  13992. }
  13993. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  13994. return true;
  13995. }
  13996. var property = this.property.has_side_effects(compressor);
  13997. if (property && this.optional) return true; // "?." is a condition
  13998. return property || this.expression.has_side_effects(compressor);
  13999. });
  14000. def_has_side_effects(AST_Chain, function (compressor) {
  14001. return this.expression.has_side_effects(compressor);
  14002. });
  14003. def_has_side_effects(AST_Sequence, function(compressor) {
  14004. return any(this.expressions, compressor);
  14005. });
  14006. def_has_side_effects(AST_Definitions, function(compressor) {
  14007. return any(this.definitions, compressor);
  14008. });
  14009. def_has_side_effects(AST_VarDef, function() {
  14010. return this.value != null;
  14011. });
  14012. def_has_side_effects(AST_TemplateSegment, return_false);
  14013. def_has_side_effects(AST_TemplateString, function(compressor) {
  14014. return any(this.segments, compressor);
  14015. });
  14016. })(function(node_or_nodes, func) {
  14017. for (const node of [].concat(node_or_nodes)) {
  14018. node.DEFMETHOD("has_side_effects", func);
  14019. }
  14020. });
  14021. // determine if expression may throw
  14022. (function(def_may_throw) {
  14023. def_may_throw(AST_Node, return_true);
  14024. def_may_throw(AST_Constant, return_false);
  14025. def_may_throw(AST_EmptyStatement, return_false);
  14026. def_may_throw(AST_Lambda, return_false);
  14027. def_may_throw(AST_SymbolDeclaration, return_false);
  14028. def_may_throw(AST_This, return_false);
  14029. def_may_throw(AST_ImportMeta, return_false);
  14030. function any(list, compressor) {
  14031. for (var i = list.length; --i >= 0;)
  14032. if (list[i].may_throw(compressor))
  14033. return true;
  14034. return false;
  14035. }
  14036. def_may_throw(AST_Class, function(compressor) {
  14037. if (this.extends && this.extends.may_throw(compressor)) return true;
  14038. return any(this.properties, compressor);
  14039. });
  14040. def_may_throw(AST_ClassStaticBlock, function (compressor) {
  14041. return any(this.body, compressor);
  14042. });
  14043. def_may_throw(AST_Array, function(compressor) {
  14044. return any(this.elements, compressor);
  14045. });
  14046. def_may_throw(AST_Assign, function(compressor) {
  14047. if (this.right.may_throw(compressor)) return true;
  14048. if (!compressor.has_directive("use strict")
  14049. && this.operator == "="
  14050. && this.left instanceof AST_SymbolRef) {
  14051. return false;
  14052. }
  14053. return this.left.may_throw(compressor);
  14054. });
  14055. def_may_throw(AST_Binary, function(compressor) {
  14056. return this.left.may_throw(compressor)
  14057. || this.right.may_throw(compressor);
  14058. });
  14059. def_may_throw(AST_Block, function(compressor) {
  14060. return any(this.body, compressor);
  14061. });
  14062. def_may_throw(AST_Call, function(compressor) {
  14063. if (is_nullish(this, compressor)) return false;
  14064. if (any(this.args, compressor)) return true;
  14065. if (this.is_callee_pure(compressor)) return false;
  14066. if (this.expression.may_throw(compressor)) return true;
  14067. return !(this.expression instanceof AST_Lambda)
  14068. || any(this.expression.body, compressor);
  14069. });
  14070. def_may_throw(AST_Case, function(compressor) {
  14071. return this.expression.may_throw(compressor)
  14072. || any(this.body, compressor);
  14073. });
  14074. def_may_throw(AST_Conditional, function(compressor) {
  14075. return this.condition.may_throw(compressor)
  14076. || this.consequent.may_throw(compressor)
  14077. || this.alternative.may_throw(compressor);
  14078. });
  14079. def_may_throw(AST_Definitions, function(compressor) {
  14080. return any(this.definitions, compressor);
  14081. });
  14082. def_may_throw(AST_If, function(compressor) {
  14083. return this.condition.may_throw(compressor)
  14084. || this.body && this.body.may_throw(compressor)
  14085. || this.alternative && this.alternative.may_throw(compressor);
  14086. });
  14087. def_may_throw(AST_LabeledStatement, function(compressor) {
  14088. return this.body.may_throw(compressor);
  14089. });
  14090. def_may_throw(AST_Object, function(compressor) {
  14091. return any(this.properties, compressor);
  14092. });
  14093. def_may_throw(AST_ObjectKeyVal, function(compressor) {
  14094. return (
  14095. this.computed_key() && this.key.may_throw(compressor)
  14096. || this.value ? this.value.may_throw(compressor) : false
  14097. );
  14098. });
  14099. def_may_throw([
  14100. AST_ClassProperty,
  14101. AST_ClassPrivateProperty,
  14102. ], function(compressor) {
  14103. return (
  14104. this.computed_key() && this.key.may_throw(compressor)
  14105. || this.static && this.value && this.value.may_throw(compressor)
  14106. );
  14107. });
  14108. def_may_throw([
  14109. AST_ConciseMethod,
  14110. AST_ObjectGetter,
  14111. AST_ObjectSetter,
  14112. ], function(compressor) {
  14113. return this.computed_key() && this.key.may_throw(compressor);
  14114. });
  14115. def_may_throw([
  14116. AST_PrivateMethod,
  14117. AST_PrivateGetter,
  14118. AST_PrivateSetter,
  14119. ], return_false);
  14120. def_may_throw(AST_Return, function(compressor) {
  14121. return this.value && this.value.may_throw(compressor);
  14122. });
  14123. def_may_throw(AST_Sequence, function(compressor) {
  14124. return any(this.expressions, compressor);
  14125. });
  14126. def_may_throw(AST_SimpleStatement, function(compressor) {
  14127. return this.body.may_throw(compressor);
  14128. });
  14129. def_may_throw(AST_Dot, function(compressor) {
  14130. if (is_nullish(this, compressor)) return false;
  14131. return !this.optional && this.expression.may_throw_on_access(compressor)
  14132. || this.expression.may_throw(compressor);
  14133. });
  14134. def_may_throw(AST_Sub, function(compressor) {
  14135. if (is_nullish(this, compressor)) return false;
  14136. return !this.optional && this.expression.may_throw_on_access(compressor)
  14137. || this.expression.may_throw(compressor)
  14138. || this.property.may_throw(compressor);
  14139. });
  14140. def_may_throw(AST_Chain, function(compressor) {
  14141. return this.expression.may_throw(compressor);
  14142. });
  14143. def_may_throw(AST_Switch, function(compressor) {
  14144. return this.expression.may_throw(compressor)
  14145. || any(this.body, compressor);
  14146. });
  14147. def_may_throw(AST_SymbolRef, function(compressor) {
  14148. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  14149. });
  14150. def_may_throw(AST_SymbolClassProperty, return_false);
  14151. def_may_throw(AST_Try, function(compressor) {
  14152. return this.bcatch ? this.bcatch.may_throw(compressor) : this.body.may_throw(compressor)
  14153. || this.bfinally && this.bfinally.may_throw(compressor);
  14154. });
  14155. def_may_throw(AST_Unary, function(compressor) {
  14156. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  14157. return false;
  14158. return this.expression.may_throw(compressor);
  14159. });
  14160. def_may_throw(AST_VarDef, function(compressor) {
  14161. if (!this.value) return false;
  14162. return this.value.may_throw(compressor);
  14163. });
  14164. })(function(node_or_nodes, func) {
  14165. for (const node of [].concat(node_or_nodes)) {
  14166. node.DEFMETHOD("may_throw", func);
  14167. }
  14168. });
  14169. // determine if expression is constant
  14170. (function(def_is_constant_expression) {
  14171. function all_refs_local(scope) {
  14172. let result = true;
  14173. walk(this, node => {
  14174. if (node instanceof AST_SymbolRef) {
  14175. if (has_flag(this, INLINED)) {
  14176. result = false;
  14177. return walk_abort;
  14178. }
  14179. var def = node.definition();
  14180. if (
  14181. member(def, this.enclosed)
  14182. && !this.variables.has(def.name)
  14183. ) {
  14184. if (scope) {
  14185. var scope_def = scope.find_variable(node);
  14186. if (def.undeclared ? !scope_def : scope_def === def) {
  14187. result = "f";
  14188. return true;
  14189. }
  14190. }
  14191. result = false;
  14192. return walk_abort;
  14193. }
  14194. return true;
  14195. }
  14196. if (node instanceof AST_This && this instanceof AST_Arrow) {
  14197. result = false;
  14198. return walk_abort;
  14199. }
  14200. });
  14201. return result;
  14202. }
  14203. def_is_constant_expression(AST_Node, return_false);
  14204. def_is_constant_expression(AST_Constant, return_true);
  14205. def_is_constant_expression(AST_Class, function(scope) {
  14206. if (this.extends && !this.extends.is_constant_expression(scope)) {
  14207. return false;
  14208. }
  14209. for (const prop of this.properties) {
  14210. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  14211. return false;
  14212. }
  14213. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  14214. return false;
  14215. }
  14216. if (prop instanceof AST_ClassStaticBlock) {
  14217. return false;
  14218. }
  14219. }
  14220. return all_refs_local.call(this, scope);
  14221. });
  14222. def_is_constant_expression(AST_Lambda, all_refs_local);
  14223. def_is_constant_expression(AST_Unary, function() {
  14224. return this.expression.is_constant_expression();
  14225. });
  14226. def_is_constant_expression(AST_Binary, function() {
  14227. return this.left.is_constant_expression()
  14228. && this.right.is_constant_expression();
  14229. });
  14230. def_is_constant_expression(AST_Array, function() {
  14231. return this.elements.every((l) => l.is_constant_expression());
  14232. });
  14233. def_is_constant_expression(AST_Object, function() {
  14234. return this.properties.every((l) => l.is_constant_expression());
  14235. });
  14236. def_is_constant_expression(AST_ObjectProperty, function() {
  14237. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  14238. });
  14239. })(function(node, func) {
  14240. node.DEFMETHOD("is_constant_expression", func);
  14241. });
  14242. // may_throw_on_access()
  14243. // returns true if this node may be null, undefined or contain `AST_Accessor`
  14244. (function(def_may_throw_on_access) {
  14245. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  14246. return !compressor.option("pure_getters")
  14247. || this._dot_throw(compressor);
  14248. });
  14249. function is_strict(compressor) {
  14250. return /strict/.test(compressor.option("pure_getters"));
  14251. }
  14252. def_may_throw_on_access(AST_Node, is_strict);
  14253. def_may_throw_on_access(AST_Null, return_true);
  14254. def_may_throw_on_access(AST_Undefined, return_true);
  14255. def_may_throw_on_access(AST_Constant, return_false);
  14256. def_may_throw_on_access(AST_Array, return_false);
  14257. def_may_throw_on_access(AST_Object, function(compressor) {
  14258. if (!is_strict(compressor)) return false;
  14259. for (var i = this.properties.length; --i >=0;)
  14260. if (this.properties[i]._dot_throw(compressor)) return true;
  14261. return false;
  14262. });
  14263. // Do not be as strict with classes as we are with objects.
  14264. // Hopefully the community is not going to abuse static getters and setters.
  14265. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  14266. def_may_throw_on_access(AST_Class, return_false);
  14267. def_may_throw_on_access(AST_ObjectProperty, return_false);
  14268. def_may_throw_on_access(AST_ObjectGetter, return_true);
  14269. def_may_throw_on_access(AST_Expansion, function(compressor) {
  14270. return this.expression._dot_throw(compressor);
  14271. });
  14272. def_may_throw_on_access(AST_Function, return_false);
  14273. def_may_throw_on_access(AST_Arrow, return_false);
  14274. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  14275. def_may_throw_on_access(AST_UnaryPrefix, function() {
  14276. return this.operator == "void";
  14277. });
  14278. def_may_throw_on_access(AST_Binary, function(compressor) {
  14279. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  14280. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  14281. });
  14282. def_may_throw_on_access(AST_Assign, function(compressor) {
  14283. if (this.logical) return true;
  14284. return this.operator == "="
  14285. && this.right._dot_throw(compressor);
  14286. });
  14287. def_may_throw_on_access(AST_Conditional, function(compressor) {
  14288. return this.consequent._dot_throw(compressor)
  14289. || this.alternative._dot_throw(compressor);
  14290. });
  14291. def_may_throw_on_access(AST_Dot, function(compressor) {
  14292. if (!is_strict(compressor)) return false;
  14293. if (this.property == "prototype") {
  14294. return !(
  14295. this.expression instanceof AST_Function
  14296. || this.expression instanceof AST_Class
  14297. );
  14298. }
  14299. return true;
  14300. });
  14301. def_may_throw_on_access(AST_Chain, function(compressor) {
  14302. return this.expression._dot_throw(compressor);
  14303. });
  14304. def_may_throw_on_access(AST_Sequence, function(compressor) {
  14305. return this.tail_node()._dot_throw(compressor);
  14306. });
  14307. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  14308. if (this.name === "arguments" && this.scope instanceof AST_Lambda) return false;
  14309. if (has_flag(this, UNDEFINED)) return true;
  14310. if (!is_strict(compressor)) return false;
  14311. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  14312. if (this.is_immutable()) return false;
  14313. var fixed = this.fixed_value();
  14314. return !fixed || fixed._dot_throw(compressor);
  14315. });
  14316. })(function(node, func) {
  14317. node.DEFMETHOD("_dot_throw", func);
  14318. });
  14319. function is_lhs(node, parent) {
  14320. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  14321. if (parent instanceof AST_Assign && parent.left === node) return node;
  14322. if (parent instanceof AST_ForIn && parent.init === node) return node;
  14323. }
  14324. // method to negate an expression
  14325. (function(def_negate) {
  14326. function basic_negation(exp) {
  14327. return make_node(AST_UnaryPrefix, exp, {
  14328. operator: "!",
  14329. expression: exp
  14330. });
  14331. }
  14332. function best(orig, alt, first_in_statement) {
  14333. var negated = basic_negation(orig);
  14334. if (first_in_statement) {
  14335. var stat = make_node(AST_SimpleStatement, alt, {
  14336. body: alt
  14337. });
  14338. return best_of_expression(negated, stat) === stat ? alt : negated;
  14339. }
  14340. return best_of_expression(negated, alt);
  14341. }
  14342. def_negate(AST_Node, function() {
  14343. return basic_negation(this);
  14344. });
  14345. def_negate(AST_Statement, function() {
  14346. throw new Error("Cannot negate a statement");
  14347. });
  14348. def_negate(AST_Function, function() {
  14349. return basic_negation(this);
  14350. });
  14351. def_negate(AST_Class, function() {
  14352. return basic_negation(this);
  14353. });
  14354. def_negate(AST_Arrow, function() {
  14355. return basic_negation(this);
  14356. });
  14357. def_negate(AST_UnaryPrefix, function() {
  14358. if (this.operator == "!")
  14359. return this.expression;
  14360. return basic_negation(this);
  14361. });
  14362. def_negate(AST_Sequence, function(compressor) {
  14363. var expressions = this.expressions.slice();
  14364. expressions.push(expressions.pop().negate(compressor));
  14365. return make_sequence(this, expressions);
  14366. });
  14367. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  14368. var self = this.clone();
  14369. self.consequent = self.consequent.negate(compressor);
  14370. self.alternative = self.alternative.negate(compressor);
  14371. return best(this, self, first_in_statement);
  14372. });
  14373. def_negate(AST_Binary, function(compressor, first_in_statement) {
  14374. var self = this.clone(), op = this.operator;
  14375. if (compressor.option("unsafe_comps")) {
  14376. switch (op) {
  14377. case "<=" : self.operator = ">" ; return self;
  14378. case "<" : self.operator = ">=" ; return self;
  14379. case ">=" : self.operator = "<" ; return self;
  14380. case ">" : self.operator = "<=" ; return self;
  14381. }
  14382. }
  14383. switch (op) {
  14384. case "==" : self.operator = "!="; return self;
  14385. case "!=" : self.operator = "=="; return self;
  14386. case "===": self.operator = "!=="; return self;
  14387. case "!==": self.operator = "==="; return self;
  14388. case "&&":
  14389. self.operator = "||";
  14390. self.left = self.left.negate(compressor, first_in_statement);
  14391. self.right = self.right.negate(compressor);
  14392. return best(this, self, first_in_statement);
  14393. case "||":
  14394. self.operator = "&&";
  14395. self.left = self.left.negate(compressor, first_in_statement);
  14396. self.right = self.right.negate(compressor);
  14397. return best(this, self, first_in_statement);
  14398. }
  14399. return basic_negation(this);
  14400. });
  14401. })(function(node, func) {
  14402. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  14403. return func.call(this, compressor, first_in_statement);
  14404. });
  14405. });
  14406. (function (def_bitwise_negate) {
  14407. function basic_bitwise_negation(exp) {
  14408. return make_node(AST_UnaryPrefix, exp, {
  14409. operator: "~",
  14410. expression: exp
  14411. });
  14412. }
  14413. def_bitwise_negate(AST_Node, function(_compressor) {
  14414. return basic_bitwise_negation(this);
  14415. });
  14416. def_bitwise_negate(AST_Number, function(_compressor) {
  14417. const neg = ~this.value;
  14418. if (neg.toString().length > this.value.toString().length) {
  14419. return basic_bitwise_negation(this);
  14420. }
  14421. return make_node(AST_Number, this, { value: neg });
  14422. });
  14423. def_bitwise_negate(AST_UnaryPrefix, function(compressor, in_32_bit_context) {
  14424. if (
  14425. this.operator == "~"
  14426. && (
  14427. this.expression.is_32_bit_integer(compressor) ||
  14428. (in_32_bit_context != null ? in_32_bit_context : compressor.in_32_bit_context())
  14429. )
  14430. ) {
  14431. return this.expression;
  14432. } else {
  14433. return basic_bitwise_negation(this);
  14434. }
  14435. });
  14436. })(function (node, func) {
  14437. node.DEFMETHOD("bitwise_negate", func);
  14438. });
  14439. // Is the callee of this function pure?
  14440. 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");
  14441. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  14442. if (compressor.option("unsafe")) {
  14443. var expr = this.expression;
  14444. var first_arg;
  14445. if (
  14446. expr.expression && expr.expression.name === "hasOwnProperty" &&
  14447. (
  14448. (first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor))) == null
  14449. || first_arg.thedef && first_arg.thedef.undeclared
  14450. )
  14451. ) {
  14452. return false;
  14453. }
  14454. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  14455. if (is_pure_builtin_call(compressor, this)) return true;
  14456. } else if (compressor.option("builtins_pure")) {
  14457. if (is_pure_builtin_call(compressor, this)) return true;
  14458. }
  14459. if ((this instanceof AST_New) && compressor.option("pure_new")) {
  14460. return true;
  14461. }
  14462. if (compressor.option("side_effects") && has_annotation(this, _PURE)) {
  14463. return true;
  14464. }
  14465. return !compressor.pure_funcs(this);
  14466. });
  14467. // If I call this, is it a pure function?
  14468. AST_Node.DEFMETHOD("is_call_pure", return_false);
  14469. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  14470. if (!compressor.option("unsafe")) return;
  14471. const expr = this.expression;
  14472. let native_obj;
  14473. if (expr instanceof AST_Array) {
  14474. native_obj = "Array";
  14475. } else if (expr.is_boolean()) {
  14476. native_obj = "Boolean";
  14477. } else if (expr.is_number(compressor)) {
  14478. native_obj = "Number";
  14479. } else if (expr instanceof AST_RegExp) {
  14480. native_obj = "RegExp";
  14481. } else if (expr.is_string(compressor)) {
  14482. native_obj = "String";
  14483. } else if (!this.may_throw_on_access(compressor)) {
  14484. native_obj = "Object";
  14485. }
  14486. return native_obj != null && compressor.is_pure_native_method(native_obj, this.property);
  14487. });
  14488. // tell me if a statement aborts
  14489. const aborts = (thing) => thing && thing.aborts();
  14490. (function(def_aborts) {
  14491. def_aborts(AST_Statement, return_null);
  14492. def_aborts(AST_Jump, return_this);
  14493. function block_aborts() {
  14494. for (var i = 0; i < this.body.length; i++) {
  14495. if (aborts(this.body[i])) {
  14496. return this.body[i];
  14497. }
  14498. }
  14499. return null;
  14500. }
  14501. def_aborts(AST_Import, return_null);
  14502. def_aborts(AST_BlockStatement, block_aborts);
  14503. def_aborts(AST_SwitchBranch, block_aborts);
  14504. def_aborts(AST_DefClass, function () {
  14505. for (const prop of this.properties) {
  14506. if (prop instanceof AST_ClassStaticBlock) {
  14507. if (prop.aborts()) return prop;
  14508. }
  14509. }
  14510. return null;
  14511. });
  14512. def_aborts(AST_ClassStaticBlock, block_aborts);
  14513. def_aborts(AST_If, function() {
  14514. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  14515. });
  14516. })(function(node, func) {
  14517. node.DEFMETHOD("aborts", func);
  14518. });
  14519. AST_Node.DEFMETHOD("contains_this", function() {
  14520. return walk(this, node => {
  14521. if (node instanceof AST_This) return walk_abort;
  14522. if (
  14523. node !== this
  14524. && node instanceof AST_Scope
  14525. && !(node instanceof AST_Arrow)
  14526. ) {
  14527. return true;
  14528. }
  14529. });
  14530. });
  14531. function is_modified(compressor, tw, node, value, level, immutable) {
  14532. var parent = tw.parent(level);
  14533. var lhs = is_lhs(node, parent);
  14534. if (lhs) return lhs;
  14535. if (!immutable
  14536. && parent instanceof AST_Call
  14537. && parent.expression === node
  14538. && !(value instanceof AST_Arrow)
  14539. && !(value instanceof AST_Class)
  14540. && !parent.is_callee_pure(compressor)
  14541. && (!(value instanceof AST_Function)
  14542. || !(parent instanceof AST_New) && value.contains_this())) {
  14543. return true;
  14544. }
  14545. if (parent instanceof AST_Array) {
  14546. return is_modified(compressor, tw, parent, parent, level + 1);
  14547. }
  14548. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  14549. var obj = tw.parent(level + 1);
  14550. return is_modified(compressor, tw, obj, obj, level + 2);
  14551. }
  14552. if (parent instanceof AST_PropAccess && parent.expression === node) {
  14553. var prop = read_property(value, parent.property);
  14554. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  14555. }
  14556. }
  14557. /**
  14558. * Check if a node may be used by the expression it's in
  14559. * void (0, 1, {node}, 2) -> false
  14560. * console.log(0, {node}) -> true
  14561. */
  14562. function is_used_in_expression(tw) {
  14563. for (let p = -1, node, parent; node = tw.parent(p), parent = tw.parent(p + 1); p++) {
  14564. if (parent instanceof AST_Sequence) {
  14565. const nth_expression = parent.expressions.indexOf(node);
  14566. if (nth_expression !== parent.expressions.length - 1) {
  14567. // Detect (0, x.noThis)() constructs
  14568. const grandparent = tw.parent(p + 2);
  14569. if (
  14570. parent.expressions.length > 2
  14571. || parent.expressions.length === 1
  14572. || !requires_sequence_to_maintain_binding(grandparent, parent, parent.expressions[1])
  14573. ) {
  14574. return false;
  14575. }
  14576. return true;
  14577. } else {
  14578. continue;
  14579. }
  14580. }
  14581. if (parent instanceof AST_Unary) {
  14582. const op = parent.operator;
  14583. if (op === "void") {
  14584. return false;
  14585. }
  14586. if (op === "typeof" || op === "+" || op === "-" || op === "!" || op === "~") {
  14587. continue;
  14588. }
  14589. }
  14590. if (
  14591. parent instanceof AST_SimpleStatement
  14592. || parent instanceof AST_LabeledStatement
  14593. ) {
  14594. return false;
  14595. }
  14596. if (parent instanceof AST_Scope) {
  14597. return false;
  14598. }
  14599. return true;
  14600. }
  14601. return true;
  14602. }
  14603. /***********************************************************************
  14604. A JavaScript tokenizer / parser / beautifier / compressor.
  14605. https://github.com/mishoo/UglifyJS2
  14606. -------------------------------- (C) ---------------------------------
  14607. Author: Mihai Bazon
  14608. <mihai.bazon@gmail.com>
  14609. http://mihai.bazon.net/blog
  14610. Distributed under the BSD license:
  14611. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14612. Redistribution and use in source and binary forms, with or without
  14613. modification, are permitted provided that the following conditions
  14614. are met:
  14615. * Redistributions of source code must retain the above
  14616. copyright notice, this list of conditions and the following
  14617. disclaimer.
  14618. * Redistributions in binary form must reproduce the above
  14619. copyright notice, this list of conditions and the following
  14620. disclaimer in the documentation and/or other materials
  14621. provided with the distribution.
  14622. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14623. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14624. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14625. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14626. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14627. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14628. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14629. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14630. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14631. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14632. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14633. SUCH DAMAGE.
  14634. ***********************************************************************/
  14635. // methods to evaluate a constant expression
  14636. function def_eval(node, func) {
  14637. node.DEFMETHOD("_eval", func);
  14638. }
  14639. // Used to propagate a nullish short-circuit signal upwards through the chain.
  14640. const nullish = Symbol("This AST_Chain is nullish");
  14641. // If the node has been successfully reduced to a constant,
  14642. // then its value is returned; otherwise the element itself
  14643. // is returned.
  14644. // They can be distinguished as constant value is never a
  14645. // descendant of AST_Node.
  14646. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  14647. if (!compressor.option("evaluate"))
  14648. return this;
  14649. var val = this._eval(compressor, 1);
  14650. if (!val || val instanceof RegExp)
  14651. return val;
  14652. if (typeof val == "function" || typeof val == "object" || val == nullish)
  14653. return this;
  14654. // Evaluated strings can be larger than the original expression
  14655. if (typeof val === "string") {
  14656. const unevaluated_size = this.size(compressor);
  14657. if (val.length + 2 > unevaluated_size) return this;
  14658. }
  14659. return val;
  14660. });
  14661. var unaryPrefix = makePredicate("! ~ - + void");
  14662. AST_Node.DEFMETHOD("is_constant", function () {
  14663. // Accomodate when compress option evaluate=false
  14664. // as well as the common constant expressions !0 and -1
  14665. if (this instanceof AST_Constant) {
  14666. return !(this instanceof AST_RegExp);
  14667. } else {
  14668. return this instanceof AST_UnaryPrefix
  14669. && unaryPrefix.has(this.operator)
  14670. && (
  14671. // `this.expression` may be an `AST_RegExp`,
  14672. // so not only `.is_constant()`.
  14673. this.expression instanceof AST_Constant
  14674. || this.expression.is_constant()
  14675. );
  14676. }
  14677. });
  14678. def_eval(AST_Statement, function () {
  14679. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  14680. });
  14681. def_eval(AST_Lambda, return_this);
  14682. def_eval(AST_Class, return_this);
  14683. def_eval(AST_Node, return_this);
  14684. def_eval(AST_Constant, function () {
  14685. return this.getValue();
  14686. });
  14687. const supports_bigint = typeof BigInt === "function";
  14688. def_eval(AST_BigInt, function () {
  14689. if (supports_bigint) {
  14690. return BigInt(this.value);
  14691. } else {
  14692. return this;
  14693. }
  14694. });
  14695. def_eval(AST_RegExp, function (compressor) {
  14696. let evaluated = compressor.evaluated_regexps.get(this.value);
  14697. if (evaluated === undefined && regexp_is_safe(this.value.source)) {
  14698. try {
  14699. const { source, flags } = this.value;
  14700. evaluated = new RegExp(source, flags);
  14701. } catch (e) {
  14702. evaluated = null;
  14703. }
  14704. compressor.evaluated_regexps.set(this.value, evaluated);
  14705. }
  14706. return evaluated || this;
  14707. });
  14708. def_eval(AST_TemplateString, function () {
  14709. if (this.segments.length !== 1) return this;
  14710. return this.segments[0].value;
  14711. });
  14712. def_eval(AST_Function, function (compressor) {
  14713. if (compressor.option("unsafe")) {
  14714. var fn = function () { };
  14715. fn.node = this;
  14716. fn.toString = () => this.print_to_string();
  14717. return fn;
  14718. }
  14719. return this;
  14720. });
  14721. def_eval(AST_Array, function (compressor, depth) {
  14722. if (compressor.option("unsafe")) {
  14723. var elements = [];
  14724. for (var i = 0, len = this.elements.length; i < len; i++) {
  14725. var element = this.elements[i];
  14726. var value = element._eval(compressor, depth);
  14727. if (element === value)
  14728. return this;
  14729. elements.push(value);
  14730. }
  14731. return elements;
  14732. }
  14733. return this;
  14734. });
  14735. def_eval(AST_Object, function (compressor, depth) {
  14736. if (compressor.option("unsafe")) {
  14737. var val = {};
  14738. for (var i = 0, len = this.properties.length; i < len; i++) {
  14739. var prop = this.properties[i];
  14740. if (prop instanceof AST_Expansion)
  14741. return this;
  14742. var key = prop.key;
  14743. if (key instanceof AST_Symbol) {
  14744. key = key.name;
  14745. } else if (key instanceof AST_Node) {
  14746. key = key._eval(compressor, depth);
  14747. if (key === prop.key)
  14748. return this;
  14749. }
  14750. if (typeof Object.prototype[key] === "function") {
  14751. return this;
  14752. }
  14753. if (prop.value instanceof AST_Function)
  14754. continue;
  14755. val[key] = prop.value._eval(compressor, depth);
  14756. if (val[key] === prop.value)
  14757. return this;
  14758. }
  14759. return val;
  14760. }
  14761. return this;
  14762. });
  14763. var non_converting_unary = makePredicate("! typeof void");
  14764. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  14765. var e = this.expression;
  14766. if (compressor.option("typeofs")
  14767. && this.operator == "typeof") {
  14768. // Function would be evaluated to an array and so typeof would
  14769. // incorrectly return 'object'. Hence making is a special case.
  14770. if (e instanceof AST_Lambda
  14771. || e instanceof AST_SymbolRef
  14772. && e.fixed_value() instanceof AST_Lambda) {
  14773. return typeof function () { };
  14774. }
  14775. if (
  14776. (e instanceof AST_Object
  14777. || e instanceof AST_Array
  14778. || (e instanceof AST_SymbolRef
  14779. && (e.fixed_value() instanceof AST_Object
  14780. || e.fixed_value() instanceof AST_Array)))
  14781. && !e.has_side_effects(compressor)
  14782. ) {
  14783. return typeof {};
  14784. }
  14785. }
  14786. if (!non_converting_unary.has(this.operator))
  14787. depth++;
  14788. e = e._eval(compressor, depth);
  14789. if (e === this.expression)
  14790. return this;
  14791. switch (this.operator) {
  14792. case "!": return !e;
  14793. case "typeof":
  14794. // typeof <RegExp> returns "object" or "function" on different platforms
  14795. // so cannot evaluate reliably
  14796. if (e instanceof RegExp)
  14797. return this;
  14798. return typeof e;
  14799. case "void": return void e;
  14800. case "~": return ~e;
  14801. case "-": return -e;
  14802. case "+": return +e;
  14803. }
  14804. return this;
  14805. });
  14806. var non_converting_binary = makePredicate("&& || ?? === !==");
  14807. const identity_comparison = makePredicate("== != === !==");
  14808. const has_identity = value => typeof value === "object"
  14809. || typeof value === "function"
  14810. || typeof value === "symbol";
  14811. def_eval(AST_Binary, function (compressor, depth) {
  14812. if (!non_converting_binary.has(this.operator))
  14813. depth++;
  14814. var left = this.left._eval(compressor, depth);
  14815. if (left === this.left)
  14816. return this;
  14817. var right = this.right._eval(compressor, depth);
  14818. if (right === this.right)
  14819. return this;
  14820. if (left != null
  14821. && right != null
  14822. && identity_comparison.has(this.operator)
  14823. && has_identity(left)
  14824. && has_identity(right)
  14825. && typeof left === typeof right) {
  14826. // Do not compare by reference
  14827. return this;
  14828. }
  14829. // Do not mix BigInt and Number
  14830. // Don't use `>>>` on BigInt or `/ 0n` (error)
  14831. // Don't use `**` on BigInt (slow)
  14832. if (
  14833. (typeof left === "bigint") !== (typeof right === "bigint")
  14834. || typeof left === "bigint"
  14835. && (this.operator === "/" && Number(right) === 0
  14836. || this.operator === ">>>"
  14837. || this.operator === "**")
  14838. ) {
  14839. return this;
  14840. }
  14841. var result;
  14842. switch (this.operator) {
  14843. case "&&": result = left && right; break;
  14844. case "||": result = left || right; break;
  14845. case "??": result = left != null ? left : right; break;
  14846. case "|": result = left | right; break;
  14847. case "&": result = left & right; break;
  14848. case "^": result = left ^ right; break;
  14849. case "+": result = left + right; break;
  14850. case "*": result = left * right; break;
  14851. case "**": result = left ** right; break;
  14852. case "/": result = left / right; break;
  14853. case "%": result = left % right; break;
  14854. case "-": result = left - right; break;
  14855. case "<<": result = left << right; break;
  14856. case ">>": result = left >> right; break;
  14857. case ">>>": result = left >>> right; break;
  14858. case "==": result = left == right; break;
  14859. case "===": result = left === right; break;
  14860. case "!=": result = left != right; break;
  14861. case "!==": result = left !== right; break;
  14862. case "<": result = left < right; break;
  14863. case "<=": result = left <= right; break;
  14864. case ">": result = left > right; break;
  14865. case ">=": result = left >= right; break;
  14866. default:
  14867. return this;
  14868. }
  14869. if (typeof result === "number" && isNaN(result) && compressor.find_parent(AST_With)) {
  14870. // leave original expression as is
  14871. return this;
  14872. }
  14873. return result;
  14874. });
  14875. def_eval(AST_Conditional, function (compressor, depth) {
  14876. var condition = this.condition._eval(compressor, depth);
  14877. if (condition === this.condition)
  14878. return this;
  14879. var node = condition ? this.consequent : this.alternative;
  14880. var value = node._eval(compressor, depth);
  14881. return value === node ? this : value;
  14882. });
  14883. // Set of AST_SymbolRef which are currently being evaluated.
  14884. // Avoids infinite recursion of ._eval()
  14885. const reentrant_ref_eval = new Set();
  14886. def_eval(AST_SymbolRef, function (compressor, depth) {
  14887. if (reentrant_ref_eval.has(this))
  14888. return this;
  14889. var fixed = this.fixed_value();
  14890. if (!fixed)
  14891. return this;
  14892. reentrant_ref_eval.add(this);
  14893. const value = fixed._eval(compressor, depth);
  14894. reentrant_ref_eval.delete(this);
  14895. if (value === fixed)
  14896. return this;
  14897. if (value && typeof value == "object") {
  14898. var escaped = this.definition().escaped;
  14899. if (escaped && depth > escaped)
  14900. return this;
  14901. }
  14902. return value;
  14903. });
  14904. def_eval(AST_Chain, function (compressor, depth) {
  14905. const evaluated = this.expression._eval(compressor, depth, /*ast_chain=*/true);
  14906. return evaluated === nullish
  14907. ? undefined
  14908. : evaluated === this.expression
  14909. ? this
  14910. : evaluated;
  14911. });
  14912. const global_objs = { Array, Math, Number, Object, String };
  14913. const regexp_flags = new Set([
  14914. "dotAll",
  14915. "global",
  14916. "ignoreCase",
  14917. "multiline",
  14918. "sticky",
  14919. "unicode",
  14920. ]);
  14921. def_eval(AST_PropAccess, function (compressor, depth, ast_chain) {
  14922. let obj = (ast_chain || this.property === "length" || compressor.option("unsafe"))
  14923. && this.expression._eval(compressor, depth + 1, ast_chain);
  14924. if (ast_chain) {
  14925. if (obj === nullish || (this.optional && obj == null)) return nullish;
  14926. }
  14927. // `.length` of strings and arrays is always safe
  14928. if (this.property === "length") {
  14929. if (typeof obj === "string") {
  14930. return obj.length;
  14931. }
  14932. const is_spreadless_array =
  14933. obj instanceof AST_Array
  14934. && obj.elements.every(el => !(el instanceof AST_Expansion));
  14935. if (
  14936. is_spreadless_array
  14937. && obj.elements.every(el => !el.has_side_effects(compressor))
  14938. ) {
  14939. return obj.elements.length;
  14940. }
  14941. }
  14942. if (compressor.option("unsafe")) {
  14943. var key = this.property;
  14944. if (key instanceof AST_Node) {
  14945. key = key._eval(compressor, depth);
  14946. if (key === this.property)
  14947. return this;
  14948. }
  14949. var exp = this.expression;
  14950. if (is_undeclared_ref(exp)) {
  14951. var aa;
  14952. var first_arg = exp.name === "hasOwnProperty"
  14953. && key === "call"
  14954. && (aa = compressor.parent() && compressor.parent().args)
  14955. && (aa && aa[0]
  14956. && aa[0].evaluate(compressor));
  14957. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  14958. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  14959. return this.clone();
  14960. }
  14961. if (!compressor.is_pure_native_static_property(exp.name, key))
  14962. return this;
  14963. obj = global_objs[exp.name];
  14964. } else {
  14965. if (obj instanceof RegExp) {
  14966. if (key == "source") {
  14967. return regexp_source_fix(obj.source);
  14968. } else if (key == "flags" || regexp_flags.has(key)) {
  14969. return obj[key];
  14970. }
  14971. }
  14972. if (!obj || obj === exp || !HOP(obj, key))
  14973. return this;
  14974. if (typeof obj == "function")
  14975. switch (key) {
  14976. case "name":
  14977. return obj.node.name ? obj.node.name.name : "";
  14978. case "length":
  14979. return obj.node.length_property();
  14980. default:
  14981. return this;
  14982. }
  14983. }
  14984. return obj[key];
  14985. }
  14986. return this;
  14987. });
  14988. def_eval(AST_Call, function (compressor, depth, ast_chain) {
  14989. var exp = this.expression;
  14990. if (ast_chain) {
  14991. const callee = exp._eval(compressor, depth, ast_chain);
  14992. if (callee === nullish || (this.optional && callee == null)) return nullish;
  14993. }
  14994. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  14995. var key = exp.property;
  14996. if (key instanceof AST_Node) {
  14997. key = key._eval(compressor, depth);
  14998. if (typeof key !== "string" && typeof key !== "number")
  14999. return this;
  15000. }
  15001. var val;
  15002. var e = exp.expression;
  15003. if (is_undeclared_ref(e)) {
  15004. var first_arg = e.name === "hasOwnProperty" &&
  15005. key === "call" &&
  15006. (this.args[0] && this.args[0].evaluate(compressor));
  15007. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  15008. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  15009. return this.clone();
  15010. }
  15011. if (!compressor.is_pure_native_static_fn(e.name, key)) return this;
  15012. val = global_objs[e.name];
  15013. } else {
  15014. val = e._eval(compressor, depth + 1, /* don't pass ast_chain (exponential work) */);
  15015. if (val === e || !val)
  15016. return this;
  15017. if (!compressor.is_pure_native_method(val.constructor.name, key))
  15018. return this;
  15019. }
  15020. var args = [];
  15021. for (var i = 0, len = this.args.length; i < len; i++) {
  15022. var arg = this.args[i];
  15023. var value = arg._eval(compressor, depth);
  15024. if (arg === value)
  15025. return this;
  15026. if (arg instanceof AST_Lambda)
  15027. return this;
  15028. args.push(value);
  15029. }
  15030. try {
  15031. return val[key].apply(val, args);
  15032. } catch (ex) {
  15033. // We don't really care
  15034. }
  15035. }
  15036. return this;
  15037. });
  15038. // Also a subclass of AST_Call
  15039. def_eval(AST_New, return_this);
  15040. /***********************************************************************
  15041. A JavaScript tokenizer / parser / beautifier / compressor.
  15042. https://github.com/mishoo/UglifyJS2
  15043. -------------------------------- (C) ---------------------------------
  15044. Author: Mihai Bazon
  15045. <mihai.bazon@gmail.com>
  15046. http://mihai.bazon.net/blog
  15047. Distributed under the BSD license:
  15048. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15049. Redistribution and use in source and binary forms, with or without
  15050. modification, are permitted provided that the following conditions
  15051. are met:
  15052. * Redistributions of source code must retain the above
  15053. copyright notice, this list of conditions and the following
  15054. disclaimer.
  15055. * Redistributions in binary form must reproduce the above
  15056. copyright notice, this list of conditions and the following
  15057. disclaimer in the documentation and/or other materials
  15058. provided with the distribution.
  15059. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15060. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15061. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15062. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15063. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15064. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15065. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15066. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15067. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15068. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15069. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15070. SUCH DAMAGE.
  15071. ***********************************************************************/
  15072. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  15073. // only about side effects. We'll be defining this method for each node type in this module
  15074. //
  15075. // Examples:
  15076. // foo++ -> foo++
  15077. // 1 + func() -> func()
  15078. // 10 -> (nothing)
  15079. // knownPureFunc(foo++) -> foo++
  15080. function def_drop_side_effect_free(node_or_nodes, func) {
  15081. for (const node of [].concat(node_or_nodes)) {
  15082. node.DEFMETHOD("drop_side_effect_free", func);
  15083. }
  15084. }
  15085. // Drop side-effect-free elements from an array of expressions.
  15086. // Returns an array of expressions with side-effects or null
  15087. // if all elements were dropped. Note: original array may be
  15088. // returned if nothing changed.
  15089. function trim(nodes, compressor, first_in_statement) {
  15090. var len = nodes.length;
  15091. if (!len) return null;
  15092. var ret = [], changed = false;
  15093. for (var i = 0; i < len; i++) {
  15094. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  15095. changed |= node !== nodes[i];
  15096. if (node) {
  15097. ret.push(node);
  15098. first_in_statement = false;
  15099. }
  15100. }
  15101. return changed ? ret.length ? ret : null : nodes;
  15102. }
  15103. def_drop_side_effect_free(AST_Node, return_this);
  15104. def_drop_side_effect_free(AST_Constant, return_null);
  15105. def_drop_side_effect_free(AST_This, return_null);
  15106. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  15107. if (is_nullish_shortcircuited(this, compressor)) {
  15108. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15109. }
  15110. if (!this.is_callee_pure(compressor)) {
  15111. if (this.expression.is_call_pure(compressor)) {
  15112. var exprs = this.args.slice();
  15113. exprs.unshift(this.expression.expression);
  15114. exprs = trim(exprs, compressor, first_in_statement);
  15115. return exprs && make_sequence(this, exprs);
  15116. }
  15117. if (is_func_expr(this.expression)
  15118. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  15119. var node = this.clone();
  15120. node.expression.process_expression(false, compressor);
  15121. return node;
  15122. }
  15123. return this;
  15124. }
  15125. var args = trim(this.args, compressor, first_in_statement);
  15126. return args && make_sequence(this, args);
  15127. });
  15128. def_drop_side_effect_free(AST_DynamicImport, function (compressor, first_in_statement) {
  15129. if (this.phase !== "source") return this;
  15130. var args = trim(this.args, compressor, first_in_statement);
  15131. return args && make_sequence(this, args);
  15132. });
  15133. def_drop_side_effect_free(AST_Accessor, return_null);
  15134. def_drop_side_effect_free(AST_Function, return_null);
  15135. def_drop_side_effect_free(AST_Arrow, return_null);
  15136. def_drop_side_effect_free(AST_Class, function (compressor) {
  15137. const with_effects = [];
  15138. if (this.is_self_referential() && this.has_side_effects(compressor)) {
  15139. return this;
  15140. }
  15141. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  15142. if (trimmed_extends) with_effects.push(trimmed_extends);
  15143. for (const prop of this.properties) {
  15144. if (prop instanceof AST_ClassStaticBlock) {
  15145. if (prop.has_side_effects(compressor)) {
  15146. return this; // Be cautious about these
  15147. }
  15148. } else {
  15149. const trimmed_prop = prop.drop_side_effect_free(compressor);
  15150. if (trimmed_prop) with_effects.push(trimmed_prop);
  15151. }
  15152. }
  15153. if (!with_effects.length)
  15154. return null;
  15155. const exprs = make_sequence(this, with_effects);
  15156. if (this instanceof AST_DefClass) {
  15157. // We want a statement
  15158. return make_node(AST_SimpleStatement, this, { body: exprs });
  15159. } else {
  15160. return exprs;
  15161. }
  15162. });
  15163. def_drop_side_effect_free([
  15164. AST_ClassProperty,
  15165. AST_ClassPrivateProperty,
  15166. ], function (compressor) {
  15167. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  15168. const value = this.static && this.value
  15169. && this.value.drop_side_effect_free(compressor);
  15170. if (key && value)
  15171. return make_sequence(this, [key, value]);
  15172. return key || value || null;
  15173. });
  15174. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  15175. var right = this.right.drop_side_effect_free(compressor);
  15176. if (!right)
  15177. return this.left.drop_side_effect_free(compressor, first_in_statement);
  15178. if (lazy_op.has(this.operator)) {
  15179. if (right === this.right)
  15180. return this;
  15181. var node = this.clone();
  15182. node.right = right;
  15183. return node;
  15184. } else {
  15185. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  15186. if (!left)
  15187. return this.right.drop_side_effect_free(compressor, first_in_statement);
  15188. return make_sequence(this, [left, right]);
  15189. }
  15190. });
  15191. def_drop_side_effect_free(AST_Assign, function (compressor) {
  15192. if (this.logical)
  15193. return this;
  15194. var left = this.left;
  15195. if (left.has_side_effects(compressor)
  15196. || compressor.has_directive("use strict")
  15197. && left instanceof AST_PropAccess
  15198. && left.expression.is_constant()) {
  15199. return this;
  15200. }
  15201. set_flag(this, WRITE_ONLY);
  15202. while (left instanceof AST_PropAccess) {
  15203. left = left.expression;
  15204. }
  15205. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  15206. return this.right.drop_side_effect_free(compressor);
  15207. }
  15208. return this;
  15209. });
  15210. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  15211. var consequent = this.consequent.drop_side_effect_free(compressor);
  15212. var alternative = this.alternative.drop_side_effect_free(compressor);
  15213. if (consequent === this.consequent && alternative === this.alternative)
  15214. return this;
  15215. if (!consequent)
  15216. return alternative ? make_node(AST_Binary, this, {
  15217. operator: "||",
  15218. left: this.condition,
  15219. right: alternative
  15220. }) : this.condition.drop_side_effect_free(compressor);
  15221. if (!alternative)
  15222. return make_node(AST_Binary, this, {
  15223. operator: "&&",
  15224. left: this.condition,
  15225. right: consequent
  15226. });
  15227. var node = this.clone();
  15228. node.consequent = consequent;
  15229. node.alternative = alternative;
  15230. return node;
  15231. });
  15232. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  15233. if (unary_side_effects.has(this.operator)) {
  15234. if (!this.expression.has_side_effects(compressor)) {
  15235. set_flag(this, WRITE_ONLY);
  15236. } else {
  15237. clear_flag(this, WRITE_ONLY);
  15238. }
  15239. return this;
  15240. }
  15241. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  15242. return null;
  15243. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  15244. if (first_in_statement && expression && is_iife_call(expression)) {
  15245. if (expression === this.expression && this.operator == "!")
  15246. return this;
  15247. return expression.negate(compressor, first_in_statement);
  15248. }
  15249. return expression;
  15250. });
  15251. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  15252. const safe_access = this.is_declared(compressor)
  15253. || pure_prop_access_globals.has(this.name);
  15254. return safe_access ? null : this;
  15255. });
  15256. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  15257. var values = trim(this.properties, compressor, first_in_statement);
  15258. return values && make_sequence(this, values);
  15259. });
  15260. def_drop_side_effect_free(AST_ObjectKeyVal, function (compressor, first_in_statement) {
  15261. const computed_key = this.key instanceof AST_Node;
  15262. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  15263. const value = this.value.drop_side_effect_free(compressor, first_in_statement);
  15264. if (key && value) {
  15265. return make_sequence(this, [key, value]);
  15266. }
  15267. return key || value;
  15268. });
  15269. def_drop_side_effect_free([
  15270. AST_ConciseMethod,
  15271. AST_ObjectGetter,
  15272. AST_ObjectSetter,
  15273. ], function (compressor, first_in_statement) {
  15274. return this.computed_key() ? this.key.drop_side_effect_free(compressor, first_in_statement) : null;
  15275. });
  15276. def_drop_side_effect_free([
  15277. AST_PrivateMethod,
  15278. AST_PrivateGetter,
  15279. AST_PrivateSetter,
  15280. ], function () {
  15281. return null;
  15282. });
  15283. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  15284. var values = trim(this.elements, compressor, first_in_statement);
  15285. return values && make_sequence(this, values);
  15286. });
  15287. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  15288. if (is_nullish_shortcircuited(this, compressor)) {
  15289. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15290. }
  15291. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  15292. return this;
  15293. }
  15294. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15295. });
  15296. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  15297. if (is_nullish_shortcircuited(this, compressor)) {
  15298. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15299. }
  15300. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  15301. return this;
  15302. }
  15303. var property = this.property.drop_side_effect_free(compressor);
  15304. if (property && this.optional) return this;
  15305. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  15306. if (expression && property) return make_sequence(this, [expression, property]);
  15307. return expression || property;
  15308. });
  15309. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  15310. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15311. });
  15312. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  15313. var last = this.tail_node();
  15314. var expr = last.drop_side_effect_free(compressor);
  15315. if (expr === last)
  15316. return this;
  15317. var expressions = this.expressions.slice(0, -1);
  15318. if (expr)
  15319. expressions.push(expr);
  15320. if (!expressions.length) {
  15321. return make_node(AST_Number, this, { value: 0 });
  15322. }
  15323. return make_sequence(this, expressions);
  15324. });
  15325. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  15326. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  15327. });
  15328. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  15329. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  15330. var values = trim(this.segments, compressor, first_in_statement);
  15331. return values && make_sequence(this, values);
  15332. });
  15333. /***********************************************************************
  15334. A JavaScript tokenizer / parser / beautifier / compressor.
  15335. https://github.com/mishoo/UglifyJS2
  15336. -------------------------------- (C) ---------------------------------
  15337. Author: Mihai Bazon
  15338. <mihai.bazon@gmail.com>
  15339. http://mihai.bazon.net/blog
  15340. Distributed under the BSD license:
  15341. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15342. Redistribution and use in source and binary forms, with or without
  15343. modification, are permitted provided that the following conditions
  15344. are met:
  15345. * Redistributions of source code must retain the above
  15346. copyright notice, this list of conditions and the following
  15347. disclaimer.
  15348. * Redistributions in binary form must reproduce the above
  15349. copyright notice, this list of conditions and the following
  15350. disclaimer in the documentation and/or other materials
  15351. provided with the distribution.
  15352. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15353. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15354. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15355. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15356. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15357. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15358. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15359. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15360. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15361. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15362. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15363. SUCH DAMAGE.
  15364. ***********************************************************************/
  15365. const r_keep_assign = /keep_assign/;
  15366. /** Drop unused variables from this scope */
  15367. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  15368. if (!compressor.option("unused")) return;
  15369. if (compressor.has_directive("use asm")) return;
  15370. if (!this.variables) return; // not really a scope (eg: AST_Class)
  15371. var self = this;
  15372. if (self.pinned()) return;
  15373. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  15374. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  15375. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  15376. if (node instanceof AST_Assign
  15377. && !node.logical
  15378. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  15379. ) {
  15380. return node.left;
  15381. }
  15382. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  15383. return node.expression;
  15384. }
  15385. };
  15386. var in_use_ids = new Map();
  15387. var fixed_ids = new Map();
  15388. if (self instanceof AST_Toplevel && compressor.top_retain) {
  15389. self.variables.forEach(function(def) {
  15390. if (compressor.top_retain(def)) {
  15391. in_use_ids.set(def.id, def);
  15392. }
  15393. });
  15394. }
  15395. var var_defs_by_id = new Map();
  15396. var initializations = new Map();
  15397. // pass 1: find out which symbols are directly used in
  15398. // this scope (not in nested scopes).
  15399. var scope = this;
  15400. var tw = new TreeWalker(function(node, descend) {
  15401. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  15402. node.argnames.forEach(function(argname) {
  15403. if (!(argname instanceof AST_SymbolDeclaration)) return;
  15404. var def = argname.definition();
  15405. in_use_ids.set(def.id, def);
  15406. });
  15407. }
  15408. if (node === self) return;
  15409. if (node instanceof AST_Class && node.has_side_effects(compressor)) {
  15410. if (node.is_self_referential()) {
  15411. descend();
  15412. } else {
  15413. node.visit_nondeferred_class_parts(tw);
  15414. }
  15415. }
  15416. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  15417. var node_def = node.name.definition();
  15418. const in_export = tw.parent() instanceof AST_Export;
  15419. if (in_export || !drop_funcs && scope === self) {
  15420. if (node_def.global) {
  15421. in_use_ids.set(node_def.id, node_def);
  15422. }
  15423. }
  15424. map_add(initializations, node_def.id, node);
  15425. return true; // don't go in nested scopes
  15426. }
  15427. // In the root scope, we drop things. In inner scopes, we just check for uses.
  15428. const in_root_scope = scope === self;
  15429. if (node instanceof AST_SymbolFunarg && in_root_scope) {
  15430. map_add(var_defs_by_id, node.definition().id, node);
  15431. }
  15432. if (node instanceof AST_Definitions && in_root_scope) {
  15433. const in_export = tw.parent() instanceof AST_Export;
  15434. node.definitions.forEach(function(def) {
  15435. if (def.name instanceof AST_SymbolVar) {
  15436. map_add(var_defs_by_id, def.name.definition().id, def);
  15437. }
  15438. if (in_export || !drop_vars) {
  15439. walk(def.name, node => {
  15440. if (node instanceof AST_SymbolDeclaration) {
  15441. const def = node.definition();
  15442. if (def.global) {
  15443. in_use_ids.set(def.id, def);
  15444. }
  15445. }
  15446. });
  15447. }
  15448. if (def.name instanceof AST_Destructuring) {
  15449. def.walk(tw);
  15450. }
  15451. if (def.name instanceof AST_SymbolDeclaration && def.value) {
  15452. var node_def = def.name.definition();
  15453. map_add(initializations, node_def.id, def.value);
  15454. if (!node_def.chained && def.name.fixed_value() === def.value) {
  15455. fixed_ids.set(node_def.id, def);
  15456. }
  15457. if (def.value.has_side_effects(compressor)) {
  15458. def.value.walk(tw);
  15459. }
  15460. }
  15461. });
  15462. return true;
  15463. }
  15464. return scan_ref_scoped(node, descend);
  15465. });
  15466. self.walk(tw);
  15467. // pass 2: for every used symbol we need to walk its
  15468. // initialization code to figure out if it uses other
  15469. // symbols (that may not be in_use).
  15470. tw = new TreeWalker(scan_ref_scoped);
  15471. in_use_ids.forEach(function (def) {
  15472. var init = initializations.get(def.id);
  15473. if (init) init.forEach(function(init) {
  15474. init.walk(tw);
  15475. });
  15476. });
  15477. // pass 3: we should drop declarations not in_use
  15478. var tt = new TreeTransformer(
  15479. function before(node, descend, in_list) {
  15480. var parent = tt.parent();
  15481. if (drop_vars) {
  15482. const sym = assign_as_unused(node);
  15483. if (sym instanceof AST_SymbolRef) {
  15484. var def = sym.definition();
  15485. var in_use = in_use_ids.has(def.id);
  15486. if (node instanceof AST_Assign) {
  15487. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  15488. const assignee = node.right.transform(tt);
  15489. if (!in_use && !assignee.has_side_effects(compressor) && !is_used_in_expression(tt)) {
  15490. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  15491. }
  15492. return maintain_this_binding(parent, node, assignee);
  15493. }
  15494. } else if (!in_use) {
  15495. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  15496. }
  15497. }
  15498. }
  15499. if (scope !== self) return;
  15500. var def;
  15501. if (node.name
  15502. && (node instanceof AST_ClassExpression
  15503. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  15504. || node instanceof AST_Function
  15505. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  15506. // any declarations with same name will overshadow
  15507. // name of this anonymous function and can therefore
  15508. // never be used anywhere
  15509. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  15510. }
  15511. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  15512. var trim =
  15513. !compressor.option("keep_fargs")
  15514. // Is this an IIFE that won't refer to its name?
  15515. || parent instanceof AST_Call
  15516. && parent.expression === node
  15517. && !node.pinned()
  15518. && (!node.name || node.name.unreferenced());
  15519. for (var a = node.argnames, i = a.length; --i >= 0;) {
  15520. var sym = a[i];
  15521. if (sym instanceof AST_Expansion) {
  15522. sym = sym.expression;
  15523. }
  15524. if (sym instanceof AST_DefaultAssign) {
  15525. sym = sym.left;
  15526. }
  15527. // Do not drop destructuring arguments.
  15528. // They constitute a type assertion of sorts
  15529. if (
  15530. !(sym instanceof AST_Destructuring)
  15531. && !in_use_ids.has(sym.definition().id)
  15532. ) {
  15533. set_flag(sym, UNUSED);
  15534. if (trim) {
  15535. a.pop();
  15536. }
  15537. } else {
  15538. trim = false;
  15539. }
  15540. }
  15541. }
  15542. if (node instanceof AST_DefClass && node !== self) {
  15543. const def = node.name.definition();
  15544. descend(node, this);
  15545. const keep_class = def.global && !drop_funcs || in_use_ids.has(def.id);
  15546. if (!keep_class) {
  15547. const kept = node.drop_side_effect_free(compressor);
  15548. if (kept == null) {
  15549. def.eliminated++;
  15550. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  15551. }
  15552. return kept;
  15553. }
  15554. return node;
  15555. }
  15556. if (node instanceof AST_Defun && node !== self) {
  15557. const def = node.name.definition();
  15558. const keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  15559. if (!keep) {
  15560. def.eliminated++;
  15561. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  15562. }
  15563. }
  15564. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  15565. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  15566. // place uninitialized names at the start
  15567. var body = [], head = [], tail = [];
  15568. // for unused names whose initialization has
  15569. // side effects, we can cascade the init. code
  15570. // into the next one, or next statement.
  15571. var side_effects = [];
  15572. node.definitions.forEach(function(def) {
  15573. if (def.value) def.value = def.value.transform(tt);
  15574. var is_destructure = def.name instanceof AST_Destructuring;
  15575. var sym = is_destructure
  15576. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  15577. : def.name.definition();
  15578. if (drop_block && sym.global) return tail.push(def);
  15579. if (!(drop_vars || drop_block)
  15580. || is_destructure
  15581. && (def.name.names.length
  15582. || def.name.is_array
  15583. || compressor.option("pure_getters") != true)
  15584. || in_use_ids.has(sym.id)
  15585. ) {
  15586. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  15587. def.value = def.value.drop_side_effect_free(compressor);
  15588. }
  15589. if (def.name instanceof AST_SymbolVar) {
  15590. var var_defs = var_defs_by_id.get(sym.id);
  15591. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  15592. if (def.value) {
  15593. var ref = make_node(AST_SymbolRef, def.name, def.name);
  15594. sym.references.push(ref);
  15595. var assign = make_node(AST_Assign, def, {
  15596. operator: "=",
  15597. logical: false,
  15598. left: ref,
  15599. right: def.value
  15600. });
  15601. if (fixed_ids.get(sym.id) === def) {
  15602. fixed_ids.set(sym.id, assign);
  15603. }
  15604. side_effects.push(assign.transform(tt));
  15605. }
  15606. remove(var_defs, def);
  15607. sym.eliminated++;
  15608. return;
  15609. }
  15610. }
  15611. if (def.value) {
  15612. if (side_effects.length > 0) {
  15613. if (tail.length > 0) {
  15614. side_effects.push(def.value);
  15615. def.value = make_sequence(def.value, side_effects);
  15616. } else {
  15617. body.push(make_node(AST_SimpleStatement, node, {
  15618. body: make_sequence(node, side_effects)
  15619. }));
  15620. }
  15621. side_effects = [];
  15622. }
  15623. tail.push(def);
  15624. } else {
  15625. head.push(def);
  15626. }
  15627. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  15628. var value = def.value && def.value.drop_side_effect_free(compressor);
  15629. if (value) side_effects.push(value);
  15630. def.value = null;
  15631. head.push(def);
  15632. } else {
  15633. var value = def.value && def.value.drop_side_effect_free(compressor);
  15634. if (value) {
  15635. side_effects.push(value);
  15636. }
  15637. sym.eliminated++;
  15638. }
  15639. });
  15640. if (head.length > 0 || tail.length > 0) {
  15641. node.definitions = head.concat(tail);
  15642. body.push(node);
  15643. }
  15644. if (side_effects.length > 0) {
  15645. body.push(make_node(AST_SimpleStatement, node, {
  15646. body: make_sequence(node, side_effects)
  15647. }));
  15648. }
  15649. switch (body.length) {
  15650. case 0:
  15651. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  15652. case 1:
  15653. return body[0];
  15654. default:
  15655. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, { body });
  15656. }
  15657. }
  15658. // certain combination of unused name + side effect leads to:
  15659. // https://github.com/mishoo/UglifyJS2/issues/44
  15660. // https://github.com/mishoo/UglifyJS2/issues/1830
  15661. // https://github.com/mishoo/UglifyJS2/issues/1838
  15662. // that's an invalid AST.
  15663. // We fix it at this stage by moving the `var` outside the `for`.
  15664. if (node instanceof AST_For) {
  15665. descend(node, this);
  15666. var block;
  15667. if (node.init instanceof AST_BlockStatement) {
  15668. block = node.init;
  15669. node.init = block.body.pop();
  15670. block.body.push(node);
  15671. }
  15672. if (node.init instanceof AST_SimpleStatement) {
  15673. node.init = node.init.body;
  15674. } else if (is_empty(node.init)) {
  15675. node.init = null;
  15676. }
  15677. return !block ? node : in_list ? MAP.splice(block.body) : block;
  15678. }
  15679. if (node instanceof AST_LabeledStatement
  15680. && node.body instanceof AST_For
  15681. ) {
  15682. descend(node, this);
  15683. if (node.body instanceof AST_BlockStatement) {
  15684. var block = node.body;
  15685. node.body = block.body.pop();
  15686. block.body.push(node);
  15687. return in_list ? MAP.splice(block.body) : block;
  15688. }
  15689. return node;
  15690. }
  15691. if (node instanceof AST_BlockStatement) {
  15692. descend(node, this);
  15693. if (in_list && node.body.every(can_be_evicted_from_block)) {
  15694. return MAP.splice(node.body);
  15695. }
  15696. return node;
  15697. }
  15698. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  15699. const save_scope = scope;
  15700. scope = node;
  15701. descend(node, this);
  15702. scope = save_scope;
  15703. return node;
  15704. }
  15705. },
  15706. function after(node, in_list) {
  15707. if (node instanceof AST_Sequence) {
  15708. switch (node.expressions.length) {
  15709. case 0: return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  15710. case 1: return node.expressions[0];
  15711. }
  15712. }
  15713. }
  15714. );
  15715. self.transform(tt);
  15716. function scan_ref_scoped(node, descend) {
  15717. var node_def;
  15718. const sym = assign_as_unused(node);
  15719. if (sym instanceof AST_SymbolRef
  15720. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  15721. && self.variables.get(sym.name) === (node_def = sym.definition())
  15722. ) {
  15723. if (node instanceof AST_Assign) {
  15724. node.right.walk(tw);
  15725. if (!node_def.chained && node.left.fixed_value() === node.right) {
  15726. fixed_ids.set(node_def.id, node);
  15727. }
  15728. }
  15729. return true;
  15730. }
  15731. if (node instanceof AST_SymbolRef) {
  15732. node_def = node.definition();
  15733. if (!in_use_ids.has(node_def.id)) {
  15734. in_use_ids.set(node_def.id, node_def);
  15735. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  15736. const redef = node_def.scope.is_block_scope()
  15737. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  15738. if (redef) in_use_ids.set(redef.id, redef);
  15739. }
  15740. }
  15741. return true;
  15742. }
  15743. if (node instanceof AST_Class) {
  15744. descend();
  15745. return true;
  15746. }
  15747. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  15748. var save_scope = scope;
  15749. scope = node;
  15750. descend();
  15751. scope = save_scope;
  15752. return true;
  15753. }
  15754. }
  15755. });
  15756. /***********************************************************************
  15757. A JavaScript tokenizer / parser / beautifier / compressor.
  15758. https://github.com/mishoo/UglifyJS2
  15759. -------------------------------- (C) ---------------------------------
  15760. Author: Mihai Bazon
  15761. <mihai.bazon@gmail.com>
  15762. http://mihai.bazon.net/blog
  15763. Distributed under the BSD license:
  15764. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15765. Redistribution and use in source and binary forms, with or without
  15766. modification, are permitted provided that the following conditions
  15767. are met:
  15768. * Redistributions of source code must retain the above
  15769. copyright notice, this list of conditions and the following
  15770. disclaimer.
  15771. * Redistributions in binary form must reproduce the above
  15772. copyright notice, this list of conditions and the following
  15773. disclaimer in the documentation and/or other materials
  15774. provided with the distribution.
  15775. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15776. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15777. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15778. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15779. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15780. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15781. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15782. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15783. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15784. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15785. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15786. SUCH DAMAGE.
  15787. ***********************************************************************/
  15788. /**
  15789. * Define the method AST_Node#reduce_vars, which goes through the AST in
  15790. * execution order to perform basic flow analysis
  15791. */
  15792. function def_reduce_vars(node, func) {
  15793. node.DEFMETHOD("reduce_vars", func);
  15794. }
  15795. def_reduce_vars(AST_Node, noop);
  15796. /** Clear definition properties */
  15797. function reset_def(compressor, def) {
  15798. def.assignments = 0;
  15799. def.chained = false;
  15800. def.direct_access = false;
  15801. def.escaped = 0;
  15802. def.recursive_refs = 0;
  15803. def.references = [];
  15804. def.single_use = undefined;
  15805. if (
  15806. def.scope.pinned()
  15807. || (def.orig[0] instanceof AST_SymbolFunarg && def.scope.uses_arguments)
  15808. ) {
  15809. def.fixed = false;
  15810. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  15811. def.fixed = def.init;
  15812. } else {
  15813. def.fixed = false;
  15814. }
  15815. }
  15816. function reset_variables(tw, compressor, node) {
  15817. node.variables.forEach(function(def) {
  15818. reset_def(compressor, def);
  15819. if (def.fixed === null) {
  15820. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  15821. mark(tw, def, true);
  15822. } else if (def.fixed) {
  15823. tw.loop_ids.set(def.id, tw.in_loop);
  15824. mark(tw, def, true);
  15825. }
  15826. });
  15827. }
  15828. function reset_block_variables(compressor, node) {
  15829. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  15830. reset_def(compressor, def);
  15831. });
  15832. }
  15833. function push(tw) {
  15834. tw.safe_ids = Object.create(tw.safe_ids);
  15835. }
  15836. function pop(tw) {
  15837. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  15838. }
  15839. function mark(tw, def, safe) {
  15840. tw.safe_ids[def.id] = safe;
  15841. }
  15842. function safe_to_read(tw, def) {
  15843. if (def.single_use == "m") return false;
  15844. if (tw.safe_ids[def.id]) {
  15845. if (def.fixed == null) {
  15846. var orig = def.orig[0];
  15847. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  15848. def.fixed = make_void_0(orig);
  15849. }
  15850. return true;
  15851. }
  15852. return def.fixed instanceof AST_Defun;
  15853. }
  15854. function safe_to_assign(tw, def, scope, value) {
  15855. if (def.fixed === undefined) return true;
  15856. let def_safe_ids;
  15857. if (def.fixed === null
  15858. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  15859. ) {
  15860. def_safe_ids[def.id] = false;
  15861. tw.defs_to_safe_ids.delete(def.id);
  15862. return true;
  15863. }
  15864. if (!HOP(tw.safe_ids, def.id)) return false;
  15865. if (!safe_to_read(tw, def)) return false;
  15866. if (def.fixed === false) return false;
  15867. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  15868. if (def.fixed instanceof AST_Defun) {
  15869. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  15870. }
  15871. return def.orig.every((sym) => {
  15872. return !(sym instanceof AST_SymbolConst
  15873. || sym instanceof AST_SymbolDefun
  15874. || sym instanceof AST_SymbolLambda);
  15875. });
  15876. }
  15877. function ref_once(tw, compressor, def) {
  15878. return compressor.option("unused")
  15879. && !def.scope.pinned()
  15880. && def.references.length - def.recursive_refs == 1
  15881. && tw.loop_ids.get(def.id) === tw.in_loop;
  15882. }
  15883. function is_immutable(value) {
  15884. if (!value) return false;
  15885. return value.is_constant()
  15886. || value instanceof AST_Lambda
  15887. || value instanceof AST_This;
  15888. }
  15889. // A definition "escapes" when its value can leave the point of use.
  15890. // Example: `a = b || c`
  15891. // In this example, "b" and "c" are escaping, because they're going into "a"
  15892. //
  15893. // def.escaped is != 0 when it escapes.
  15894. //
  15895. // When greater than 1, it means that N chained properties will be read off
  15896. // of that def before an escape occurs. This is useful for evaluating
  15897. // property accesses, where you need to know when to stop.
  15898. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  15899. var parent = tw.parent(level);
  15900. if (value) {
  15901. if (value.is_constant()) return;
  15902. if (value instanceof AST_ClassExpression) return;
  15903. }
  15904. if (
  15905. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  15906. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  15907. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  15908. || parent instanceof AST_VarDefLike && node === parent.value
  15909. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  15910. ) {
  15911. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  15912. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  15913. return;
  15914. } else if (
  15915. parent instanceof AST_Array
  15916. || parent instanceof AST_Await
  15917. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  15918. || parent instanceof AST_Conditional && node !== parent.condition
  15919. || parent instanceof AST_Expansion
  15920. || parent instanceof AST_Sequence && node === parent.tail_node()
  15921. ) {
  15922. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  15923. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  15924. var obj = tw.parent(level + 1);
  15925. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  15926. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  15927. value = read_property(value, parent.property);
  15928. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  15929. if (value) return;
  15930. }
  15931. if (level > 0) return;
  15932. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  15933. if (parent instanceof AST_SimpleStatement) return;
  15934. d.direct_access = true;
  15935. }
  15936. const suppress = node => walk(node, node => {
  15937. if (!(node instanceof AST_Symbol)) return;
  15938. var d = node.definition();
  15939. if (!d) return;
  15940. if (node instanceof AST_SymbolRef) d.references.push(node);
  15941. d.fixed = false;
  15942. });
  15943. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  15944. push(tw);
  15945. reset_variables(tw, compressor, this);
  15946. descend();
  15947. pop(tw);
  15948. return true;
  15949. });
  15950. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  15951. var node = this;
  15952. if (node.left instanceof AST_Destructuring) {
  15953. suppress(node.left);
  15954. return;
  15955. }
  15956. const finish_walk = () => {
  15957. if (node.logical) {
  15958. node.left.walk(tw);
  15959. push(tw);
  15960. node.right.walk(tw);
  15961. pop(tw);
  15962. return true;
  15963. }
  15964. };
  15965. var sym = node.left;
  15966. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  15967. var def = sym.definition();
  15968. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  15969. def.assignments++;
  15970. if (!safe) return finish_walk();
  15971. var fixed = def.fixed;
  15972. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  15973. var eq = node.operator == "=";
  15974. var value = eq ? node.right : node;
  15975. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  15976. def.references.push(sym);
  15977. if (!node.logical) {
  15978. if (!eq) def.chained = true;
  15979. def.fixed = eq ? function() {
  15980. return node.right;
  15981. } : function() {
  15982. return make_node(AST_Binary, node, {
  15983. operator: node.operator.slice(0, -1),
  15984. left: fixed instanceof AST_Node ? fixed : fixed(),
  15985. right: node.right
  15986. });
  15987. };
  15988. }
  15989. if (node.logical) {
  15990. mark(tw, def, false);
  15991. push(tw);
  15992. node.right.walk(tw);
  15993. pop(tw);
  15994. return true;
  15995. }
  15996. mark(tw, def, false);
  15997. node.right.walk(tw);
  15998. mark(tw, def, true);
  15999. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  16000. return true;
  16001. });
  16002. def_reduce_vars(AST_Binary, function(tw) {
  16003. if (!lazy_op.has(this.operator)) return;
  16004. this.left.walk(tw);
  16005. push(tw);
  16006. this.right.walk(tw);
  16007. pop(tw);
  16008. return true;
  16009. });
  16010. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  16011. reset_block_variables(compressor, this);
  16012. });
  16013. def_reduce_vars(AST_Case, function(tw) {
  16014. push(tw);
  16015. this.expression.walk(tw);
  16016. pop(tw);
  16017. push(tw);
  16018. walk_body(this, tw);
  16019. pop(tw);
  16020. return true;
  16021. });
  16022. def_reduce_vars(AST_Class, function(tw, descend) {
  16023. clear_flag(this, INLINED);
  16024. push(tw);
  16025. descend();
  16026. pop(tw);
  16027. return true;
  16028. });
  16029. def_reduce_vars(AST_ClassStaticBlock, function(tw, descend, compressor) {
  16030. reset_block_variables(compressor, this);
  16031. });
  16032. def_reduce_vars(AST_Conditional, function(tw) {
  16033. this.condition.walk(tw);
  16034. push(tw);
  16035. this.consequent.walk(tw);
  16036. pop(tw);
  16037. push(tw);
  16038. this.alternative.walk(tw);
  16039. pop(tw);
  16040. return true;
  16041. });
  16042. def_reduce_vars(AST_Chain, function(tw, descend) {
  16043. // Chains' conditions apply left-to-right, cumulatively.
  16044. // If we walk normally we don't go in that order because we would pop before pushing again
  16045. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  16046. // Then we pop everything when they are done being walked.
  16047. const safe_ids = tw.safe_ids;
  16048. descend();
  16049. // Unroll back to start
  16050. tw.safe_ids = safe_ids;
  16051. return true;
  16052. });
  16053. def_reduce_vars(AST_Call, function (tw) {
  16054. this.expression.walk(tw);
  16055. if (this.optional) {
  16056. // Never pop -- it's popped at AST_Chain above
  16057. push(tw);
  16058. }
  16059. for (const arg of this.args) arg.walk(tw);
  16060. return true;
  16061. });
  16062. def_reduce_vars(AST_PropAccess, function (tw) {
  16063. if (!this.optional) return;
  16064. this.expression.walk(tw);
  16065. // Never pop -- it's popped at AST_Chain above
  16066. push(tw);
  16067. if (this.property instanceof AST_Node) this.property.walk(tw);
  16068. return true;
  16069. });
  16070. def_reduce_vars(AST_Default, function(tw, descend) {
  16071. push(tw);
  16072. descend();
  16073. pop(tw);
  16074. return true;
  16075. });
  16076. function mark_lambda(tw, descend, compressor) {
  16077. clear_flag(this, INLINED);
  16078. push(tw);
  16079. reset_variables(tw, compressor, this);
  16080. var iife;
  16081. if (!this.name
  16082. && !this.uses_arguments
  16083. && !this.pinned()
  16084. && (iife = tw.parent()) instanceof AST_Call
  16085. && iife.expression === this
  16086. && !iife.args.some(arg => arg instanceof AST_Expansion)
  16087. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  16088. ) {
  16089. // Virtually turn IIFE parameters into variable definitions:
  16090. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  16091. // So existing transformation rules can work on them.
  16092. this.argnames.forEach((arg, i) => {
  16093. if (!arg.definition) return;
  16094. var d = arg.definition();
  16095. // Avoid setting fixed when there's more than one origin for a variable value
  16096. if (d.orig.length > 1) return;
  16097. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  16098. d.fixed = function() {
  16099. return iife.args[i] || make_void_0(iife);
  16100. };
  16101. tw.loop_ids.set(d.id, tw.in_loop);
  16102. mark(tw, d, true);
  16103. } else {
  16104. d.fixed = false;
  16105. }
  16106. });
  16107. }
  16108. descend();
  16109. pop(tw);
  16110. handle_defined_after_hoist(this);
  16111. return true;
  16112. }
  16113. /**
  16114. * It's possible for a hoisted function to use something that's not defined yet. Example:
  16115. *
  16116. * hoisted();
  16117. * var defined_after = true;
  16118. * function hoisted() {
  16119. * // use defined_after
  16120. * }
  16121. *
  16122. * Or even indirectly:
  16123. *
  16124. * B();
  16125. * var defined_after = true;
  16126. * function A() {
  16127. * // use defined_after
  16128. * }
  16129. * function B() {
  16130. * A();
  16131. * }
  16132. *
  16133. * Access a variable before declaration will either throw a ReferenceError
  16134. * (if the variable is declared with `let` or `const`),
  16135. * or get an `undefined` (if the variable is declared with `var`).
  16136. *
  16137. * If the variable is inlined into the function, the behavior will change.
  16138. *
  16139. * This function is called on the parent to disallow inlining of such variables,
  16140. */
  16141. function handle_defined_after_hoist(parent) {
  16142. const defuns = [];
  16143. walk(parent, node => {
  16144. if (node === parent) return;
  16145. if (node instanceof AST_Defun) {
  16146. defuns.push(node);
  16147. return true;
  16148. }
  16149. if (
  16150. node instanceof AST_Scope
  16151. || node instanceof AST_SimpleStatement
  16152. ) return true;
  16153. });
  16154. // `defun` id to array of `defun` it uses
  16155. const defun_dependencies_map = new Map();
  16156. // `defun` id to array of enclosing `def` that are used by the function
  16157. const dependencies_map = new Map();
  16158. // all symbol ids that will be tracked for read/write
  16159. const symbols_of_interest = new Set();
  16160. const defuns_of_interest = new Set();
  16161. for (const defun of defuns) {
  16162. const fname_def = defun.name.definition();
  16163. const enclosing_defs = [];
  16164. for (const def of defun.enclosed) {
  16165. if (
  16166. def.fixed === false
  16167. || def === fname_def
  16168. || def.scope.get_defun_scope() !== parent
  16169. ) {
  16170. continue;
  16171. }
  16172. symbols_of_interest.add(def.id);
  16173. // found a reference to another function
  16174. if (
  16175. def.assignments === 0
  16176. && def.orig.length === 1
  16177. && def.orig[0] instanceof AST_SymbolDefun
  16178. ) {
  16179. defuns_of_interest.add(def.id);
  16180. symbols_of_interest.add(def.id);
  16181. defuns_of_interest.add(fname_def.id);
  16182. symbols_of_interest.add(fname_def.id);
  16183. if (!defun_dependencies_map.has(fname_def.id)) {
  16184. defun_dependencies_map.set(fname_def.id, []);
  16185. }
  16186. defun_dependencies_map.get(fname_def.id).push(def.id);
  16187. continue;
  16188. }
  16189. enclosing_defs.push(def);
  16190. }
  16191. if (enclosing_defs.length) {
  16192. dependencies_map.set(fname_def.id, enclosing_defs);
  16193. defuns_of_interest.add(fname_def.id);
  16194. symbols_of_interest.add(fname_def.id);
  16195. }
  16196. }
  16197. // No defuns use outside constants
  16198. if (!dependencies_map.size) {
  16199. return;
  16200. }
  16201. // Increment to count "symbols of interest" (defuns or defs) that we found.
  16202. // These are tracked in AST order so we can check which is after which.
  16203. let symbol_index = 1;
  16204. // Map a defun ID to its first read (a `symbol_index`)
  16205. const defun_first_read_map = new Map();
  16206. // Map a symbol ID to its last write (a `symbol_index`)
  16207. const symbol_last_write_map = new Map();
  16208. walk_parent(parent, (node, walk_info) => {
  16209. if (node instanceof AST_Symbol && node.thedef) {
  16210. const id = node.definition().id;
  16211. symbol_index++;
  16212. // Track last-writes to symbols
  16213. if (symbols_of_interest.has(id)) {
  16214. if (node instanceof AST_SymbolDeclaration || is_lhs(node, walk_info.parent())) {
  16215. symbol_last_write_map.set(id, symbol_index);
  16216. }
  16217. }
  16218. // Track first-reads of defuns (refined later)
  16219. if (defuns_of_interest.has(id)) {
  16220. if (!defun_first_read_map.has(id) && !is_recursive_ref(walk_info, id)) {
  16221. defun_first_read_map.set(id, symbol_index);
  16222. }
  16223. }
  16224. }
  16225. });
  16226. // Refine `defun_first_read_map` to be as high as possible
  16227. for (const [defun, defun_first_read] of defun_first_read_map) {
  16228. // Update all dependencies of `defun`
  16229. const queue = new Set(defun_dependencies_map.get(defun));
  16230. for (const enclosed_defun of queue) {
  16231. let enclosed_defun_first_read = defun_first_read_map.get(enclosed_defun);
  16232. if (enclosed_defun_first_read != null && enclosed_defun_first_read < defun_first_read) {
  16233. continue;
  16234. }
  16235. defun_first_read_map.set(enclosed_defun, defun_first_read);
  16236. for (const enclosed_enclosed_defun of defun_dependencies_map.get(enclosed_defun) || []) {
  16237. queue.add(enclosed_enclosed_defun);
  16238. }
  16239. }
  16240. }
  16241. // ensure write-then-read order, otherwise clear `fixed`
  16242. // This is safe because last-writes (found_symbol_writes) are assumed to be as late as possible, and first-reads (defun_first_read_map) are assumed to be as early as possible.
  16243. for (const [defun, defs] of dependencies_map) {
  16244. const defun_first_read = defun_first_read_map.get(defun);
  16245. if (defun_first_read === undefined) {
  16246. continue;
  16247. }
  16248. for (const def of defs) {
  16249. if (def.fixed === false) {
  16250. continue;
  16251. }
  16252. let def_last_write = symbol_last_write_map.get(def.id) || 0;
  16253. if (defun_first_read < def_last_write) {
  16254. def.fixed = false;
  16255. }
  16256. }
  16257. }
  16258. }
  16259. def_reduce_vars(AST_Lambda, mark_lambda);
  16260. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  16261. reset_block_variables(compressor, this);
  16262. const saved_loop = tw.in_loop;
  16263. tw.in_loop = this;
  16264. push(tw);
  16265. this.body.walk(tw);
  16266. if (has_break_or_continue(this)) {
  16267. pop(tw);
  16268. push(tw);
  16269. }
  16270. this.condition.walk(tw);
  16271. pop(tw);
  16272. tw.in_loop = saved_loop;
  16273. return true;
  16274. });
  16275. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  16276. reset_block_variables(compressor, this);
  16277. if (this.init) this.init.walk(tw);
  16278. const saved_loop = tw.in_loop;
  16279. tw.in_loop = this;
  16280. push(tw);
  16281. if (this.condition) this.condition.walk(tw);
  16282. this.body.walk(tw);
  16283. if (this.step) {
  16284. if (has_break_or_continue(this)) {
  16285. pop(tw);
  16286. push(tw);
  16287. }
  16288. this.step.walk(tw);
  16289. }
  16290. pop(tw);
  16291. tw.in_loop = saved_loop;
  16292. return true;
  16293. });
  16294. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  16295. reset_block_variables(compressor, this);
  16296. suppress(this.init);
  16297. this.object.walk(tw);
  16298. const saved_loop = tw.in_loop;
  16299. tw.in_loop = this;
  16300. push(tw);
  16301. this.body.walk(tw);
  16302. pop(tw);
  16303. tw.in_loop = saved_loop;
  16304. return true;
  16305. });
  16306. def_reduce_vars(AST_If, function(tw) {
  16307. this.condition.walk(tw);
  16308. push(tw);
  16309. this.body.walk(tw);
  16310. pop(tw);
  16311. if (this.alternative) {
  16312. push(tw);
  16313. this.alternative.walk(tw);
  16314. pop(tw);
  16315. }
  16316. return true;
  16317. });
  16318. def_reduce_vars(AST_LabeledStatement, function(tw) {
  16319. push(tw);
  16320. this.body.walk(tw);
  16321. pop(tw);
  16322. return true;
  16323. });
  16324. def_reduce_vars(AST_SymbolCatch, function() {
  16325. this.definition().fixed = false;
  16326. });
  16327. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  16328. var d = this.definition();
  16329. d.references.push(this);
  16330. if (d.references.length == 1
  16331. && !d.fixed
  16332. && d.orig[0] instanceof AST_SymbolDefun) {
  16333. tw.loop_ids.set(d.id, tw.in_loop);
  16334. }
  16335. var fixed_value;
  16336. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  16337. d.fixed = false;
  16338. } else if (d.fixed) {
  16339. fixed_value = this.fixed_value();
  16340. if (
  16341. fixed_value instanceof AST_Lambda
  16342. && is_recursive_ref(tw, d)
  16343. ) {
  16344. d.recursive_refs++;
  16345. } else if (fixed_value
  16346. && !compressor.exposed(d)
  16347. && ref_once(tw, compressor, d)
  16348. ) {
  16349. d.single_use =
  16350. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  16351. || fixed_value instanceof AST_Class
  16352. || d.scope === this.scope && fixed_value.is_constant_expression();
  16353. } else {
  16354. d.single_use = false;
  16355. }
  16356. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  16357. if (d.single_use) {
  16358. d.single_use = "m";
  16359. } else {
  16360. d.fixed = false;
  16361. }
  16362. }
  16363. }
  16364. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  16365. });
  16366. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  16367. this.globals.forEach(function(def) {
  16368. reset_def(compressor, def);
  16369. });
  16370. reset_variables(tw, compressor, this);
  16371. descend();
  16372. handle_defined_after_hoist(this);
  16373. return true;
  16374. });
  16375. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  16376. reset_block_variables(compressor, this);
  16377. push(tw);
  16378. this.body.walk(tw);
  16379. pop(tw);
  16380. if (this.bcatch) {
  16381. push(tw);
  16382. this.bcatch.walk(tw);
  16383. pop(tw);
  16384. }
  16385. if (this.bfinally) this.bfinally.walk(tw);
  16386. return true;
  16387. });
  16388. def_reduce_vars(AST_Unary, function(tw) {
  16389. var node = this;
  16390. if (node.operator !== "++" && node.operator !== "--") return;
  16391. var exp = node.expression;
  16392. if (!(exp instanceof AST_SymbolRef)) return;
  16393. var def = exp.definition();
  16394. var safe = safe_to_assign(tw, def, exp.scope, true);
  16395. def.assignments++;
  16396. if (!safe) return;
  16397. var fixed = def.fixed;
  16398. if (!fixed) return;
  16399. def.references.push(exp);
  16400. def.chained = true;
  16401. def.fixed = function() {
  16402. return make_node(AST_Binary, node, {
  16403. operator: node.operator.slice(0, -1),
  16404. left: make_node(AST_UnaryPrefix, node, {
  16405. operator: "+",
  16406. expression: fixed instanceof AST_Node ? fixed : fixed()
  16407. }),
  16408. right: make_node(AST_Number, node, {
  16409. value: 1
  16410. })
  16411. });
  16412. };
  16413. mark(tw, def, true);
  16414. return true;
  16415. });
  16416. def_reduce_vars(AST_VarDef, function(tw, descend) {
  16417. var node = this;
  16418. if (node.name instanceof AST_Destructuring) {
  16419. suppress(node.name);
  16420. return;
  16421. }
  16422. var d = node.name.definition();
  16423. if (node.value) {
  16424. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  16425. d.fixed = function() {
  16426. return node.value;
  16427. };
  16428. tw.loop_ids.set(d.id, tw.in_loop);
  16429. mark(tw, d, false);
  16430. descend();
  16431. mark(tw, d, true);
  16432. return true;
  16433. } else {
  16434. d.fixed = false;
  16435. }
  16436. }
  16437. });
  16438. def_reduce_vars(AST_UsingDef, function() {
  16439. suppress(this.name);
  16440. });
  16441. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  16442. reset_block_variables(compressor, this);
  16443. const saved_loop = tw.in_loop;
  16444. tw.in_loop = this;
  16445. push(tw);
  16446. descend();
  16447. pop(tw);
  16448. tw.in_loop = saved_loop;
  16449. return true;
  16450. });
  16451. /***********************************************************************
  16452. A JavaScript tokenizer / parser / beautifier / compressor.
  16453. https://github.com/mishoo/UglifyJS2
  16454. -------------------------------- (C) ---------------------------------
  16455. Author: Mihai Bazon
  16456. <mihai.bazon@gmail.com>
  16457. http://mihai.bazon.net/blog
  16458. Distributed under the BSD license:
  16459. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16460. Redistribution and use in source and binary forms, with or without
  16461. modification, are permitted provided that the following conditions
  16462. are met:
  16463. * Redistributions of source code must retain the above
  16464. copyright notice, this list of conditions and the following
  16465. disclaimer.
  16466. * Redistributions in binary form must reproduce the above
  16467. copyright notice, this list of conditions and the following
  16468. disclaimer in the documentation and/or other materials
  16469. provided with the distribution.
  16470. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16471. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16472. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16473. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16474. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16475. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16476. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16477. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16478. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16479. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16480. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16481. SUCH DAMAGE.
  16482. ***********************************************************************/
  16483. function loop_body(x) {
  16484. if (x instanceof AST_IterationStatement) {
  16485. return x.body instanceof AST_BlockStatement ? x.body : x;
  16486. }
  16487. return x;
  16488. }
  16489. function is_lhs_read_only(lhs) {
  16490. if (lhs instanceof AST_This) return true;
  16491. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  16492. if (lhs instanceof AST_PropAccess) {
  16493. lhs = lhs.expression;
  16494. if (lhs instanceof AST_SymbolRef) {
  16495. if (lhs.is_immutable()) return false;
  16496. lhs = lhs.fixed_value();
  16497. }
  16498. if (!lhs) return true;
  16499. if (lhs instanceof AST_RegExp) return false;
  16500. if (lhs instanceof AST_Constant) return true;
  16501. return is_lhs_read_only(lhs);
  16502. }
  16503. return false;
  16504. }
  16505. /** var a = 1 --> var a*/
  16506. function remove_initializers(var_statement) {
  16507. var decls = [];
  16508. var_statement.definitions.forEach(function(def) {
  16509. if (def.name instanceof AST_SymbolDeclaration) {
  16510. def.value = null;
  16511. decls.push(def);
  16512. } else {
  16513. def.declarations_as_names().forEach(name => {
  16514. decls.push(make_node(AST_VarDef, def, {
  16515. name,
  16516. value: null
  16517. }));
  16518. });
  16519. }
  16520. });
  16521. return decls.length ? make_node(AST_Var, var_statement, { definitions: decls }) : null;
  16522. }
  16523. /** Called on code which won't be executed but has an effect outside of itself: `var`, `function` statements, `export`, `import`. */
  16524. function extract_from_unreachable_code(compressor, stat, target) {
  16525. walk(stat, node => {
  16526. if (node instanceof AST_Var) {
  16527. const no_initializers = remove_initializers(node);
  16528. if (no_initializers) target.push(no_initializers);
  16529. return true;
  16530. }
  16531. if (
  16532. node instanceof AST_Defun
  16533. && (node === stat || !compressor.has_directive("use strict"))
  16534. ) {
  16535. target.push(node === stat ? node : make_node(AST_Var, node, {
  16536. definitions: [
  16537. make_node(AST_VarDef, node, {
  16538. name: make_node(AST_SymbolVar, node.name, node.name),
  16539. value: null
  16540. })
  16541. ]
  16542. }));
  16543. return true;
  16544. }
  16545. if (node instanceof AST_Export || node instanceof AST_Import) {
  16546. target.push(node);
  16547. return true;
  16548. }
  16549. if (node instanceof AST_Scope || node instanceof AST_Class) {
  16550. // Do not go into nested scopes
  16551. return true;
  16552. }
  16553. });
  16554. }
  16555. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  16556. function tighten_body(statements, compressor) {
  16557. const nearest_scope = compressor.find_scope();
  16558. const defun_scope = nearest_scope.get_defun_scope();
  16559. const { in_loop, in_try } = find_loop_scope_try();
  16560. var CHANGED, max_iter = 10;
  16561. do {
  16562. CHANGED = false;
  16563. eliminate_spurious_blocks(statements);
  16564. if (compressor.option("dead_code")) {
  16565. eliminate_dead_code(statements, compressor);
  16566. }
  16567. if (compressor.option("if_return")) {
  16568. handle_if_return(statements, compressor);
  16569. }
  16570. if (compressor.sequences_limit > 0) {
  16571. sequencesize(statements, compressor);
  16572. sequencesize_2(statements, compressor);
  16573. }
  16574. if (compressor.option("join_vars")) {
  16575. join_consecutive_vars(statements);
  16576. }
  16577. if (compressor.option("collapse_vars")) {
  16578. collapse(statements, compressor);
  16579. }
  16580. } while (CHANGED && max_iter-- > 0);
  16581. function find_loop_scope_try() {
  16582. var node = compressor.self(), level = 0, in_loop = false, in_try = false;
  16583. do {
  16584. if (node instanceof AST_IterationStatement) {
  16585. in_loop = true;
  16586. } else if (node instanceof AST_Scope) {
  16587. break;
  16588. } else if (node instanceof AST_TryBlock) {
  16589. in_try = true;
  16590. }
  16591. } while (node = compressor.parent(level++));
  16592. return { in_loop, in_try };
  16593. }
  16594. // Search from right to left for assignment-like expressions:
  16595. // - `var a = x;`
  16596. // - `a = x;`
  16597. // - `++a`
  16598. // For each candidate, scan from left to right for first usage, then try
  16599. // to fold assignment into the site for compression.
  16600. // Will not attempt to collapse assignments into or past code blocks
  16601. // which are not sequentially executed, e.g. loops and conditionals.
  16602. function collapse(statements, compressor) {
  16603. if (nearest_scope.pinned() || defun_scope.pinned())
  16604. return statements;
  16605. var args;
  16606. var candidates = [];
  16607. var stat_index = statements.length;
  16608. var scanner = new TreeTransformer(function (node) {
  16609. if (abort)
  16610. return node;
  16611. // Skip nodes before `candidate` as quickly as possible
  16612. if (!hit) {
  16613. if (node !== hit_stack[hit_index])
  16614. return node;
  16615. hit_index++;
  16616. if (hit_index < hit_stack.length)
  16617. return handle_custom_scan_order(node);
  16618. hit = true;
  16619. stop_after = find_stop(node, 0);
  16620. if (stop_after === node)
  16621. abort = true;
  16622. return node;
  16623. }
  16624. // Stop immediately if these node types are encountered
  16625. var parent = scanner.parent();
  16626. if (node instanceof AST_Assign
  16627. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  16628. || node instanceof AST_Await
  16629. || node instanceof AST_Using
  16630. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  16631. ||
  16632. (node instanceof AST_Call || node instanceof AST_PropAccess)
  16633. && node.optional
  16634. || node instanceof AST_Debugger
  16635. || node instanceof AST_Destructuring
  16636. || node instanceof AST_Expansion
  16637. && node.expression instanceof AST_Symbol
  16638. && (
  16639. node.expression instanceof AST_This
  16640. || node.expression.definition().references.length > 1
  16641. )
  16642. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  16643. || node instanceof AST_LoopControl
  16644. || node instanceof AST_Try
  16645. || node instanceof AST_With
  16646. || node instanceof AST_Yield
  16647. || node instanceof AST_Export
  16648. || node instanceof AST_Class
  16649. || parent instanceof AST_For && node !== parent.init
  16650. || !replace_all
  16651. && (
  16652. node instanceof AST_SymbolRef
  16653. && !node.is_declared(compressor)
  16654. && !pure_prop_access_globals.has(node)
  16655. )
  16656. || node instanceof AST_SymbolRef
  16657. && parent instanceof AST_Call
  16658. && has_annotation(parent, _NOINLINE)
  16659. || node instanceof AST_ObjectProperty && node.key instanceof AST_Node
  16660. ) {
  16661. abort = true;
  16662. return node;
  16663. }
  16664. // Stop only if candidate is found within conditional branches
  16665. if (!stop_if_hit && (!lhs_local || !replace_all)
  16666. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  16667. || parent instanceof AST_Conditional && parent.condition !== node
  16668. || parent instanceof AST_If && parent.condition !== node)) {
  16669. stop_if_hit = parent;
  16670. }
  16671. // Replace variable with assignment when found
  16672. if (
  16673. can_replace
  16674. && !(node instanceof AST_SymbolDeclaration)
  16675. && lhs.equivalent_to(node)
  16676. && !shadows(scanner.find_scope() || nearest_scope, lvalues)
  16677. ) {
  16678. if (stop_if_hit) {
  16679. abort = true;
  16680. return node;
  16681. }
  16682. if (is_lhs(node, parent)) {
  16683. if (value_def)
  16684. replaced++;
  16685. return node;
  16686. } else {
  16687. replaced++;
  16688. if (value_def && candidate instanceof AST_VarDef)
  16689. return node;
  16690. }
  16691. CHANGED = abort = true;
  16692. if (candidate instanceof AST_UnaryPostfix) {
  16693. return make_node(AST_UnaryPrefix, candidate, candidate);
  16694. }
  16695. if (candidate instanceof AST_VarDef) {
  16696. var def = candidate.name.definition();
  16697. var value = candidate.value;
  16698. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  16699. def.replaced++;
  16700. if (funarg && is_identifier_atom(value)) {
  16701. return value.transform(compressor);
  16702. } else {
  16703. return maintain_this_binding(parent, node, value);
  16704. }
  16705. }
  16706. return make_node(AST_Assign, candidate, {
  16707. operator: "=",
  16708. logical: false,
  16709. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  16710. right: value
  16711. });
  16712. }
  16713. clear_flag(candidate, WRITE_ONLY);
  16714. return candidate;
  16715. }
  16716. // These node types have child nodes that execute sequentially,
  16717. // but are otherwise not safe to scan into or beyond them.
  16718. var sym;
  16719. if (node instanceof AST_Call
  16720. || node instanceof AST_Exit
  16721. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  16722. || node instanceof AST_PropAccess
  16723. && (side_effects || node.expression.may_throw_on_access(compressor))
  16724. || node instanceof AST_SymbolRef
  16725. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  16726. || node instanceof AST_VarDef && node.value
  16727. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  16728. || node instanceof AST_Using
  16729. || (sym = is_lhs(node.left, node))
  16730. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  16731. || may_throw
  16732. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  16733. stop_after = node;
  16734. if (node instanceof AST_Scope)
  16735. abort = true;
  16736. }
  16737. return handle_custom_scan_order(node);
  16738. }, function (node) {
  16739. if (abort)
  16740. return;
  16741. if (stop_after === node)
  16742. abort = true;
  16743. if (stop_if_hit === node)
  16744. stop_if_hit = null;
  16745. });
  16746. var multi_replacer = new TreeTransformer(function (node) {
  16747. if (abort)
  16748. return node;
  16749. // Skip nodes before `candidate` as quickly as possible
  16750. if (!hit) {
  16751. if (node !== hit_stack[hit_index])
  16752. return node;
  16753. hit_index++;
  16754. if (hit_index < hit_stack.length)
  16755. return;
  16756. hit = true;
  16757. return node;
  16758. }
  16759. // Replace variable when found
  16760. if (node instanceof AST_SymbolRef
  16761. && node.name == def.name) {
  16762. if (!--replaced)
  16763. abort = true;
  16764. if (is_lhs(node, multi_replacer.parent()))
  16765. return node;
  16766. def.replaced++;
  16767. value_def.replaced--;
  16768. return candidate.value;
  16769. }
  16770. // Skip (non-executed) functions and (leading) default case in switch statements
  16771. if (node instanceof AST_Default || node instanceof AST_Scope)
  16772. return node;
  16773. });
  16774. while (--stat_index >= 0) {
  16775. // Treat parameters as collapsible in IIFE, i.e.
  16776. // function(a, b){ ... }(x());
  16777. // would be translated into equivalent assignments:
  16778. // var a = x(), b = undefined;
  16779. if (stat_index == 0 && compressor.option("unused"))
  16780. extract_args();
  16781. // Find collapsible assignments
  16782. var hit_stack = [];
  16783. extract_candidates(statements[stat_index]);
  16784. while (candidates.length > 0) {
  16785. hit_stack = candidates.pop();
  16786. var hit_index = 0;
  16787. var candidate = hit_stack[hit_stack.length - 1];
  16788. var value_def = null;
  16789. var stop_after = null;
  16790. var stop_if_hit = null;
  16791. var lhs = get_lhs(candidate);
  16792. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  16793. continue;
  16794. // Locate symbols which may execute code outside of scanning range
  16795. var lvalues = get_lvalues(candidate);
  16796. var lhs_local = is_lhs_local(lhs);
  16797. if (lhs instanceof AST_SymbolRef) {
  16798. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  16799. }
  16800. var side_effects = value_has_side_effects(candidate);
  16801. var replace_all = replace_all_symbols();
  16802. var may_throw = candidate.may_throw(compressor);
  16803. var funarg = candidate.name instanceof AST_SymbolFunarg;
  16804. var hit = funarg;
  16805. var abort = false, replaced = 0, can_replace = !args || !hit;
  16806. if (!can_replace) {
  16807. for (
  16808. let j = compressor.self().argnames.lastIndexOf(candidate.name) + 1;
  16809. !abort && j < args.length;
  16810. j++
  16811. ) {
  16812. args[j].transform(scanner);
  16813. }
  16814. can_replace = true;
  16815. }
  16816. for (var i = stat_index; !abort && i < statements.length; i++) {
  16817. statements[i].transform(scanner);
  16818. }
  16819. if (value_def) {
  16820. var def = candidate.name.definition();
  16821. if (abort && def.references.length - def.replaced > replaced)
  16822. replaced = false;
  16823. else {
  16824. abort = false;
  16825. hit_index = 0;
  16826. hit = funarg;
  16827. for (var i = stat_index; !abort && i < statements.length; i++) {
  16828. statements[i].transform(multi_replacer);
  16829. }
  16830. value_def.single_use = false;
  16831. }
  16832. }
  16833. if (replaced && !remove_candidate(candidate))
  16834. statements.splice(stat_index, 1);
  16835. }
  16836. }
  16837. function handle_custom_scan_order(node) {
  16838. // Skip (non-executed) functions
  16839. if (node instanceof AST_Scope)
  16840. return node;
  16841. // Scan case expressions first in a switch statement
  16842. if (node instanceof AST_Switch) {
  16843. node.expression = node.expression.transform(scanner);
  16844. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  16845. var branch = node.body[i];
  16846. if (branch instanceof AST_Case) {
  16847. if (!hit) {
  16848. if (branch !== hit_stack[hit_index])
  16849. continue;
  16850. hit_index++;
  16851. }
  16852. branch.expression = branch.expression.transform(scanner);
  16853. if (!replace_all)
  16854. break;
  16855. }
  16856. }
  16857. abort = true;
  16858. return node;
  16859. }
  16860. }
  16861. function redefined_within_scope(def, scope) {
  16862. if (def.global)
  16863. return false;
  16864. let cur_scope = def.scope;
  16865. while (cur_scope && cur_scope !== scope) {
  16866. if (cur_scope.variables.has(def.name)) {
  16867. return true;
  16868. }
  16869. cur_scope = cur_scope.parent_scope;
  16870. }
  16871. return false;
  16872. }
  16873. function has_overlapping_symbol(fn, arg, fn_strict) {
  16874. var found = false, scan_this = !(fn instanceof AST_Arrow);
  16875. arg.walk(new TreeWalker(function (node, descend) {
  16876. if (found)
  16877. return true;
  16878. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  16879. var s = node.definition().scope;
  16880. if (s !== defun_scope)
  16881. while (s = s.parent_scope) {
  16882. if (s === defun_scope)
  16883. return true;
  16884. }
  16885. return found = true;
  16886. }
  16887. if ((fn_strict || scan_this) && node instanceof AST_This) {
  16888. return found = true;
  16889. }
  16890. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  16891. var prev = scan_this;
  16892. scan_this = false;
  16893. descend();
  16894. scan_this = prev;
  16895. return true;
  16896. }
  16897. }));
  16898. return found;
  16899. }
  16900. function arg_is_injectable(arg) {
  16901. if (arg instanceof AST_Expansion) return false;
  16902. const contains_await = walk(arg, (node) => {
  16903. if (node instanceof AST_Await) return walk_abort;
  16904. });
  16905. if (contains_await) return false;
  16906. return true;
  16907. }
  16908. function extract_args() {
  16909. var iife, fn = compressor.self();
  16910. if (is_func_expr(fn)
  16911. && !fn.name
  16912. && !fn.uses_arguments
  16913. && !fn.pinned()
  16914. && (iife = compressor.parent()) instanceof AST_Call
  16915. && iife.expression === fn
  16916. && iife.args.every(arg_is_injectable)
  16917. ) {
  16918. var fn_strict = compressor.has_directive("use strict");
  16919. if (fn_strict && !member(fn_strict, fn.body))
  16920. fn_strict = false;
  16921. var len = fn.argnames.length;
  16922. args = iife.args.slice(len);
  16923. var names = new Set();
  16924. for (var i = len; --i >= 0;) {
  16925. var sym = fn.argnames[i];
  16926. var arg = iife.args[i];
  16927. // The following two line fix is a duplicate of the fix at
  16928. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  16929. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  16930. // Might be doing the exact same thing.
  16931. const def = sym.definition && sym.definition();
  16932. const is_reassigned = def && def.orig.length > 1;
  16933. if (is_reassigned)
  16934. continue;
  16935. args.unshift(make_node(AST_VarDef, sym, {
  16936. name: sym,
  16937. value: arg
  16938. }));
  16939. if (names.has(sym.name))
  16940. continue;
  16941. names.add(sym.name);
  16942. if (sym instanceof AST_Expansion) {
  16943. var elements = iife.args.slice(i);
  16944. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  16945. )) {
  16946. candidates.unshift([make_node(AST_VarDef, sym, {
  16947. name: sym.expression,
  16948. value: make_node(AST_Array, iife, {
  16949. elements: elements
  16950. })
  16951. })]);
  16952. }
  16953. } else {
  16954. if (!arg) {
  16955. arg = make_void_0(sym).transform(compressor);
  16956. } else if (arg instanceof AST_Lambda && arg.pinned()
  16957. || has_overlapping_symbol(fn, arg, fn_strict)) {
  16958. arg = null;
  16959. }
  16960. if (arg)
  16961. candidates.unshift([make_node(AST_VarDef, sym, {
  16962. name: sym,
  16963. value: arg
  16964. })]);
  16965. }
  16966. }
  16967. }
  16968. }
  16969. function extract_candidates(expr) {
  16970. hit_stack.push(expr);
  16971. if (expr instanceof AST_Assign) {
  16972. if (!expr.left.has_side_effects(compressor)
  16973. && !(expr.right instanceof AST_Chain)) {
  16974. candidates.push(hit_stack.slice());
  16975. }
  16976. extract_candidates(expr.right);
  16977. } else if (expr instanceof AST_Binary) {
  16978. extract_candidates(expr.left);
  16979. extract_candidates(expr.right);
  16980. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  16981. extract_candidates(expr.expression);
  16982. expr.args.forEach(extract_candidates);
  16983. } else if (expr instanceof AST_Case) {
  16984. extract_candidates(expr.expression);
  16985. } else if (expr instanceof AST_Conditional) {
  16986. extract_candidates(expr.condition);
  16987. extract_candidates(expr.consequent);
  16988. extract_candidates(expr.alternative);
  16989. } else if (expr instanceof AST_Definitions) {
  16990. var len = expr.definitions.length;
  16991. // limit number of trailing variable definitions for consideration
  16992. var i = len - 200;
  16993. if (i < 0)
  16994. i = 0;
  16995. for (; i < len; i++) {
  16996. extract_candidates(expr.definitions[i]);
  16997. }
  16998. } else if (expr instanceof AST_DWLoop) {
  16999. extract_candidates(expr.condition);
  17000. if (!(expr.body instanceof AST_Block)) {
  17001. extract_candidates(expr.body);
  17002. }
  17003. } else if (expr instanceof AST_Exit) {
  17004. if (expr.value)
  17005. extract_candidates(expr.value);
  17006. } else if (expr instanceof AST_For) {
  17007. if (expr.init)
  17008. extract_candidates(expr.init);
  17009. if (expr.condition)
  17010. extract_candidates(expr.condition);
  17011. if (expr.step)
  17012. extract_candidates(expr.step);
  17013. if (!(expr.body instanceof AST_Block)) {
  17014. extract_candidates(expr.body);
  17015. }
  17016. } else if (expr instanceof AST_ForIn) {
  17017. extract_candidates(expr.object);
  17018. if (!(expr.body instanceof AST_Block)) {
  17019. extract_candidates(expr.body);
  17020. }
  17021. } else if (expr instanceof AST_If) {
  17022. extract_candidates(expr.condition);
  17023. if (!(expr.body instanceof AST_Block)) {
  17024. extract_candidates(expr.body);
  17025. }
  17026. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  17027. extract_candidates(expr.alternative);
  17028. }
  17029. } else if (expr instanceof AST_Sequence) {
  17030. expr.expressions.forEach(extract_candidates);
  17031. } else if (expr instanceof AST_SimpleStatement) {
  17032. extract_candidates(expr.body);
  17033. } else if (expr instanceof AST_Switch) {
  17034. extract_candidates(expr.expression);
  17035. expr.body.forEach(extract_candidates);
  17036. } else if (expr instanceof AST_Unary) {
  17037. if (expr.operator == "++" || expr.operator == "--") {
  17038. candidates.push(hit_stack.slice());
  17039. }
  17040. } else if (expr instanceof AST_VarDef) {
  17041. if (expr.value && !(expr.value instanceof AST_Chain)) {
  17042. candidates.push(hit_stack.slice());
  17043. extract_candidates(expr.value);
  17044. }
  17045. }
  17046. hit_stack.pop();
  17047. }
  17048. function find_stop(node, level, write_only) {
  17049. var parent = scanner.parent(level);
  17050. if (parent instanceof AST_Assign) {
  17051. if (write_only
  17052. && !parent.logical
  17053. && !(parent.left instanceof AST_PropAccess
  17054. || lvalues.has(parent.left.name))) {
  17055. return find_stop(parent, level + 1, write_only);
  17056. }
  17057. return node;
  17058. }
  17059. if (parent instanceof AST_Binary) {
  17060. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  17061. return find_stop(parent, level + 1, write_only);
  17062. }
  17063. return node;
  17064. }
  17065. if (parent instanceof AST_Call)
  17066. return node;
  17067. if (parent instanceof AST_Case)
  17068. return node;
  17069. if (parent instanceof AST_Conditional) {
  17070. if (write_only && parent.condition === node) {
  17071. return find_stop(parent, level + 1, write_only);
  17072. }
  17073. return node;
  17074. }
  17075. if (parent instanceof AST_Definitions) {
  17076. return find_stop(parent, level + 1, true);
  17077. }
  17078. if (parent instanceof AST_Exit) {
  17079. return write_only ? find_stop(parent, level + 1, write_only) : node;
  17080. }
  17081. if (parent instanceof AST_If) {
  17082. if (write_only && parent.condition === node) {
  17083. return find_stop(parent, level + 1, write_only);
  17084. }
  17085. return node;
  17086. }
  17087. if (parent instanceof AST_IterationStatement)
  17088. return node;
  17089. if (parent instanceof AST_Sequence) {
  17090. return find_stop(parent, level + 1, parent.tail_node() !== node);
  17091. }
  17092. if (parent instanceof AST_SimpleStatement) {
  17093. return find_stop(parent, level + 1, true);
  17094. }
  17095. if (parent instanceof AST_Switch)
  17096. return node;
  17097. if (parent instanceof AST_VarDef)
  17098. return node;
  17099. return null;
  17100. }
  17101. function mangleable_var(var_def) {
  17102. var value = var_def.value;
  17103. if (!(value instanceof AST_SymbolRef))
  17104. return;
  17105. if (value.name == "arguments")
  17106. return;
  17107. var def = value.definition();
  17108. if (def.undeclared)
  17109. return;
  17110. return value_def = def;
  17111. }
  17112. function get_lhs(expr) {
  17113. if (expr instanceof AST_Assign && expr.logical) {
  17114. return false;
  17115. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  17116. var def = expr.name.definition();
  17117. if (!member(expr.name, def.orig))
  17118. return;
  17119. var referenced = def.references.length - def.replaced;
  17120. if (!referenced)
  17121. return;
  17122. var declared = def.orig.length - def.eliminated;
  17123. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  17124. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  17125. return make_node(AST_SymbolRef, expr.name, expr.name);
  17126. }
  17127. } else {
  17128. const lhs = expr instanceof AST_Assign
  17129. ? expr.left
  17130. : expr.expression;
  17131. return !is_ref_of(lhs, AST_SymbolConst)
  17132. && !is_ref_of(lhs, AST_SymbolLet)
  17133. && !is_ref_of(lhs, AST_SymbolUsing)
  17134. && lhs;
  17135. }
  17136. }
  17137. function get_rvalue(expr) {
  17138. if (expr instanceof AST_Assign) {
  17139. return expr.right;
  17140. } else {
  17141. return expr.value;
  17142. }
  17143. }
  17144. function get_lvalues(expr) {
  17145. var lvalues = new Map();
  17146. if (expr instanceof AST_Unary)
  17147. return lvalues;
  17148. var tw = new TreeWalker(function (node) {
  17149. var sym = node;
  17150. while (sym instanceof AST_PropAccess)
  17151. sym = sym.expression;
  17152. if (sym instanceof AST_SymbolRef) {
  17153. const prev = lvalues.get(sym.name);
  17154. if (!prev || !prev.modified) {
  17155. lvalues.set(sym.name, {
  17156. def: sym.definition(),
  17157. modified: is_modified(compressor, tw, node, node, 0)
  17158. });
  17159. }
  17160. }
  17161. });
  17162. get_rvalue(expr).walk(tw);
  17163. return lvalues;
  17164. }
  17165. function remove_candidate(expr) {
  17166. if (expr.name instanceof AST_SymbolFunarg) {
  17167. var iife = compressor.parent(), argnames = compressor.self().argnames;
  17168. var index = argnames.indexOf(expr.name);
  17169. if (index < 0) {
  17170. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  17171. } else {
  17172. var args = iife.args;
  17173. if (args[index])
  17174. args[index] = make_node(AST_Number, args[index], {
  17175. value: 0
  17176. });
  17177. }
  17178. return true;
  17179. }
  17180. var found = false;
  17181. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  17182. if (found)
  17183. return node;
  17184. if (node === expr || node.body === expr) {
  17185. found = true;
  17186. if (node instanceof AST_VarDef) {
  17187. node.value = node.name instanceof AST_SymbolConst
  17188. ? make_void_0(node.value) // `const` always needs value.
  17189. : null;
  17190. return node;
  17191. }
  17192. return in_list ? MAP.skip : null;
  17193. }
  17194. }, function (node) {
  17195. if (node instanceof AST_Sequence)
  17196. switch (node.expressions.length) {
  17197. case 0: return null;
  17198. case 1: return node.expressions[0];
  17199. }
  17200. }));
  17201. }
  17202. function is_lhs_local(lhs) {
  17203. while (lhs instanceof AST_PropAccess)
  17204. lhs = lhs.expression;
  17205. return lhs instanceof AST_SymbolRef
  17206. && lhs.definition().scope.get_defun_scope() === defun_scope
  17207. && !(in_loop
  17208. && (lvalues.has(lhs.name)
  17209. || candidate instanceof AST_Unary
  17210. || (candidate instanceof AST_Assign
  17211. && !candidate.logical
  17212. && candidate.operator != "=")));
  17213. }
  17214. function value_has_side_effects(expr) {
  17215. if (expr instanceof AST_Unary)
  17216. return unary_side_effects.has(expr.operator);
  17217. return get_rvalue(expr).has_side_effects(compressor);
  17218. }
  17219. function replace_all_symbols() {
  17220. if (side_effects)
  17221. return false;
  17222. if (value_def)
  17223. return true;
  17224. if (lhs instanceof AST_SymbolRef) {
  17225. var def = lhs.definition();
  17226. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  17227. return true;
  17228. }
  17229. }
  17230. return false;
  17231. }
  17232. function may_modify(sym) {
  17233. if (!sym.definition)
  17234. return true; // AST_Destructuring
  17235. var def = sym.definition();
  17236. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  17237. return false;
  17238. if (def.scope.get_defun_scope() !== defun_scope)
  17239. return true;
  17240. return def.references.some((ref) =>
  17241. ref.scope.get_defun_scope() !== defun_scope
  17242. );
  17243. }
  17244. function side_effects_external(node, lhs) {
  17245. if (node instanceof AST_Assign)
  17246. return side_effects_external(node.left, true);
  17247. if (node instanceof AST_Unary)
  17248. return side_effects_external(node.expression, true);
  17249. if (node instanceof AST_VarDef)
  17250. return node.value && side_effects_external(node.value);
  17251. if (lhs) {
  17252. if (node instanceof AST_Dot)
  17253. return side_effects_external(node.expression, true);
  17254. if (node instanceof AST_Sub)
  17255. return side_effects_external(node.expression, true);
  17256. if (node instanceof AST_SymbolRef)
  17257. return node.definition().scope.get_defun_scope() !== defun_scope;
  17258. }
  17259. return false;
  17260. }
  17261. /**
  17262. * Will any of the pulled-in lvalues shadow a variable in newScope or parents?
  17263. * similar to scope_encloses_variables_in_this_scope */
  17264. function shadows(my_scope, lvalues) {
  17265. for (const { def } of lvalues.values()) {
  17266. const looked_up = my_scope.find_variable(def.name);
  17267. if (looked_up) {
  17268. if (looked_up === def) continue;
  17269. return true;
  17270. }
  17271. }
  17272. return false;
  17273. }
  17274. }
  17275. function eliminate_spurious_blocks(statements) {
  17276. var seen_dirs = [];
  17277. for (var i = 0; i < statements.length;) {
  17278. var stat = statements[i];
  17279. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  17280. CHANGED = true;
  17281. eliminate_spurious_blocks(stat.body);
  17282. statements.splice(i, 1, ...stat.body);
  17283. i += stat.body.length;
  17284. } else if (stat instanceof AST_EmptyStatement) {
  17285. CHANGED = true;
  17286. statements.splice(i, 1);
  17287. } else if (stat instanceof AST_Directive) {
  17288. if (seen_dirs.indexOf(stat.value) < 0) {
  17289. i++;
  17290. seen_dirs.push(stat.value);
  17291. } else {
  17292. CHANGED = true;
  17293. statements.splice(i, 1);
  17294. }
  17295. } else
  17296. i++;
  17297. }
  17298. }
  17299. function handle_if_return(statements, compressor) {
  17300. var self = compressor.self();
  17301. var multiple_if_returns = has_multiple_if_returns(statements);
  17302. var in_lambda = self instanceof AST_Lambda;
  17303. // Prevent extremely deep nesting
  17304. // https://github.com/terser/terser/issues/1432
  17305. // https://github.com/webpack/webpack/issues/17548
  17306. const iteration_start = Math.min(statements.length, 500);
  17307. for (var i = iteration_start; --i >= 0;) {
  17308. var stat = statements[i];
  17309. var j = next_index(i);
  17310. var next = statements[j];
  17311. if (in_lambda && !next && stat instanceof AST_Return) {
  17312. if (!stat.value) {
  17313. CHANGED = true;
  17314. statements.splice(i, 1);
  17315. continue;
  17316. }
  17317. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  17318. CHANGED = true;
  17319. statements[i] = make_node(AST_SimpleStatement, stat, {
  17320. body: stat.value.expression
  17321. });
  17322. continue;
  17323. }
  17324. }
  17325. if (stat instanceof AST_If) {
  17326. let ab, new_else;
  17327. ab = aborts(stat.body);
  17328. if (
  17329. can_merge_flow(ab)
  17330. && (new_else = as_statement_array_with_return(stat.body, ab))
  17331. ) {
  17332. if (ab.label) {
  17333. remove(ab.label.thedef.references, ab);
  17334. }
  17335. CHANGED = true;
  17336. stat = stat.clone();
  17337. stat.condition = stat.condition.negate(compressor);
  17338. stat.body = make_node(AST_BlockStatement, stat, {
  17339. body: as_statement_array(stat.alternative).concat(extract_defuns())
  17340. });
  17341. stat.alternative = make_node(AST_BlockStatement, stat, {
  17342. body: new_else
  17343. });
  17344. statements[i] = stat.transform(compressor);
  17345. continue;
  17346. }
  17347. ab = aborts(stat.alternative);
  17348. if (
  17349. can_merge_flow(ab)
  17350. && (new_else = as_statement_array_with_return(stat.alternative, ab))
  17351. ) {
  17352. if (ab.label) {
  17353. remove(ab.label.thedef.references, ab);
  17354. }
  17355. CHANGED = true;
  17356. stat = stat.clone();
  17357. stat.body = make_node(AST_BlockStatement, stat.body, {
  17358. body: as_statement_array(stat.body).concat(extract_defuns())
  17359. });
  17360. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  17361. body: new_else
  17362. });
  17363. statements[i] = stat.transform(compressor);
  17364. continue;
  17365. }
  17366. }
  17367. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  17368. var value = stat.body.value;
  17369. //---
  17370. // pretty silly case, but:
  17371. // if (foo()) return; return; ==> foo(); return;
  17372. if (!value && !stat.alternative
  17373. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  17374. CHANGED = true;
  17375. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  17376. body: stat.condition
  17377. });
  17378. continue;
  17379. }
  17380. //---
  17381. // if (foo()) return x; return y; ==> return foo() ? x : y;
  17382. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  17383. CHANGED = true;
  17384. stat = stat.clone();
  17385. stat.alternative = next;
  17386. statements[i] = stat.transform(compressor);
  17387. statements.splice(j, 1);
  17388. continue;
  17389. }
  17390. //---
  17391. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  17392. if (value && !stat.alternative
  17393. && (!next && in_lambda && multiple_if_returns
  17394. || next instanceof AST_Return)) {
  17395. CHANGED = true;
  17396. stat = stat.clone();
  17397. stat.alternative = next || make_node(AST_Return, stat, {
  17398. value: null
  17399. });
  17400. statements[i] = stat.transform(compressor);
  17401. if (next)
  17402. statements.splice(j, 1);
  17403. continue;
  17404. }
  17405. //---
  17406. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  17407. //
  17408. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  17409. // however, with sequences on this helps producing slightly better output for
  17410. // the example code.
  17411. var prev = statements[prev_index(i)];
  17412. if (compressor.option("sequences") && in_lambda && !stat.alternative
  17413. && prev instanceof AST_If && prev.body instanceof AST_Return
  17414. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  17415. CHANGED = true;
  17416. stat = stat.clone();
  17417. stat.alternative = make_node(AST_BlockStatement, next, {
  17418. body: [
  17419. next,
  17420. make_node(AST_Return, next, {
  17421. value: null
  17422. })
  17423. ]
  17424. });
  17425. statements[i] = stat.transform(compressor);
  17426. statements.splice(j, 1);
  17427. continue;
  17428. }
  17429. }
  17430. }
  17431. function has_multiple_if_returns(statements) {
  17432. var n = 0;
  17433. for (var i = statements.length; --i >= 0;) {
  17434. var stat = statements[i];
  17435. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  17436. if (++n > 1)
  17437. return true;
  17438. }
  17439. }
  17440. return false;
  17441. }
  17442. function is_return_void(value) {
  17443. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  17444. }
  17445. function can_merge_flow(ab) {
  17446. if (!ab)
  17447. return false;
  17448. for (var j = i + 1, len = statements.length; j < len; j++) {
  17449. var stat = statements[j];
  17450. if (stat instanceof AST_DefinitionsLike && !(stat instanceof AST_Var))
  17451. return false;
  17452. }
  17453. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  17454. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  17455. || ab instanceof AST_Continue && self === loop_body(lct)
  17456. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  17457. }
  17458. function extract_defuns() {
  17459. var tail = statements.slice(i + 1);
  17460. statements.length = i + 1;
  17461. return tail.filter(function (stat) {
  17462. if (stat instanceof AST_Defun) {
  17463. statements.push(stat);
  17464. return false;
  17465. }
  17466. return true;
  17467. });
  17468. }
  17469. function as_statement_array_with_return(node, ab) {
  17470. var body = as_statement_array(node);
  17471. if (ab !== body[body.length - 1]) {
  17472. return undefined;
  17473. }
  17474. body = body.slice(0, -1);
  17475. if (!body.every(stat => can_be_evicted_from_block(stat))) {
  17476. return undefined;
  17477. }
  17478. if (ab.value) {
  17479. body.push(make_node(AST_SimpleStatement, ab.value, {
  17480. body: ab.value.expression
  17481. }));
  17482. }
  17483. return body;
  17484. }
  17485. function next_index(i) {
  17486. for (var j = i + 1, len = statements.length; j < len; j++) {
  17487. var stat = statements[j];
  17488. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  17489. break;
  17490. }
  17491. }
  17492. return j;
  17493. }
  17494. function prev_index(i) {
  17495. for (var j = i; --j >= 0;) {
  17496. var stat = statements[j];
  17497. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  17498. break;
  17499. }
  17500. }
  17501. return j;
  17502. }
  17503. }
  17504. function eliminate_dead_code(statements, compressor) {
  17505. var has_quit;
  17506. var self = compressor.self();
  17507. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  17508. var stat = statements[i];
  17509. if (stat instanceof AST_LoopControl) {
  17510. var lct = compressor.loopcontrol_target(stat);
  17511. if (stat instanceof AST_Break
  17512. && !(lct instanceof AST_IterationStatement)
  17513. && loop_body(lct) === self
  17514. || stat instanceof AST_Continue
  17515. && loop_body(lct) === self) {
  17516. if (stat.label) {
  17517. remove(stat.label.thedef.references, stat);
  17518. }
  17519. } else {
  17520. statements[n++] = stat;
  17521. }
  17522. } else {
  17523. statements[n++] = stat;
  17524. }
  17525. if (aborts(stat)) {
  17526. has_quit = statements.slice(i + 1);
  17527. break;
  17528. }
  17529. }
  17530. statements.length = n;
  17531. CHANGED = n != len;
  17532. if (has_quit)
  17533. has_quit.forEach(function (stat) {
  17534. extract_from_unreachable_code(compressor, stat, statements);
  17535. });
  17536. }
  17537. function declarations_only(node) {
  17538. return node.definitions.every((var_def) => !var_def.value);
  17539. }
  17540. function sequencesize(statements, compressor) {
  17541. if (statements.length < 2)
  17542. return;
  17543. var seq = [], n = 0;
  17544. function push_seq() {
  17545. if (!seq.length)
  17546. return;
  17547. var body = make_sequence(seq[0], seq);
  17548. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  17549. seq = [];
  17550. }
  17551. for (var i = 0, len = statements.length; i < len; i++) {
  17552. var stat = statements[i];
  17553. if (stat instanceof AST_SimpleStatement) {
  17554. if (seq.length >= compressor.sequences_limit)
  17555. push_seq();
  17556. var body = stat.body;
  17557. if (seq.length > 0)
  17558. body = body.drop_side_effect_free(compressor);
  17559. if (body)
  17560. merge_sequence(seq, body);
  17561. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  17562. || stat instanceof AST_Defun) {
  17563. statements[n++] = stat;
  17564. } else {
  17565. push_seq();
  17566. statements[n++] = stat;
  17567. }
  17568. }
  17569. push_seq();
  17570. statements.length = n;
  17571. if (n != len)
  17572. CHANGED = true;
  17573. }
  17574. function to_simple_statement(block, decls) {
  17575. if (!(block instanceof AST_BlockStatement))
  17576. return block;
  17577. var stat = null;
  17578. for (var i = 0, len = block.body.length; i < len; i++) {
  17579. var line = block.body[i];
  17580. if (line instanceof AST_Var && declarations_only(line)) {
  17581. decls.push(line);
  17582. } else if (stat || line instanceof AST_DefinitionsLike && !(line instanceof AST_Var)) {
  17583. return false;
  17584. } else {
  17585. stat = line;
  17586. }
  17587. }
  17588. return stat;
  17589. }
  17590. function sequencesize_2(statements, compressor) {
  17591. function cons_seq(right) {
  17592. n--;
  17593. CHANGED = true;
  17594. var left = prev.body;
  17595. return make_sequence(left, [left, right]).transform(compressor);
  17596. }
  17597. var n = 0, prev;
  17598. for (var i = 0; i < statements.length; i++) {
  17599. var stat = statements[i];
  17600. if (prev) {
  17601. if (stat instanceof AST_Exit) {
  17602. stat.value = cons_seq(stat.value || make_void_0(stat).transform(compressor));
  17603. } else if (stat instanceof AST_For) {
  17604. if (!(stat.init instanceof AST_DefinitionsLike)) {
  17605. const abort = walk(prev.body, node => {
  17606. if (node instanceof AST_Scope)
  17607. return true;
  17608. if (node instanceof AST_Binary
  17609. && node.operator === "in") {
  17610. return walk_abort;
  17611. }
  17612. });
  17613. if (!abort) {
  17614. if (stat.init)
  17615. stat.init = cons_seq(stat.init);
  17616. else {
  17617. stat.init = prev.body;
  17618. n--;
  17619. CHANGED = true;
  17620. }
  17621. }
  17622. }
  17623. } else if (stat instanceof AST_ForIn) {
  17624. if (!(stat.init instanceof AST_DefinitionsLike) || stat.init instanceof AST_Var) {
  17625. stat.object = cons_seq(stat.object);
  17626. }
  17627. } else if (stat instanceof AST_If) {
  17628. stat.condition = cons_seq(stat.condition);
  17629. } else if (stat instanceof AST_Switch) {
  17630. stat.expression = cons_seq(stat.expression);
  17631. } else if (stat instanceof AST_With) {
  17632. stat.expression = cons_seq(stat.expression);
  17633. }
  17634. }
  17635. if (compressor.option("conditionals") && stat instanceof AST_If) {
  17636. var decls = [];
  17637. var body = to_simple_statement(stat.body, decls);
  17638. var alt = to_simple_statement(stat.alternative, decls);
  17639. if (body !== false && alt !== false && decls.length > 0) {
  17640. var len = decls.length;
  17641. decls.push(make_node(AST_If, stat, {
  17642. condition: stat.condition,
  17643. body: body || make_node(AST_EmptyStatement, stat.body),
  17644. alternative: alt
  17645. }));
  17646. decls.unshift(n, 1);
  17647. [].splice.apply(statements, decls);
  17648. i += len;
  17649. n += len + 1;
  17650. prev = null;
  17651. CHANGED = true;
  17652. continue;
  17653. }
  17654. }
  17655. statements[n++] = stat;
  17656. prev = stat instanceof AST_SimpleStatement ? stat : null;
  17657. }
  17658. statements.length = n;
  17659. }
  17660. function join_object_assignments(defn, body) {
  17661. if (!(defn instanceof AST_Definitions))
  17662. return;
  17663. var def = defn.definitions[defn.definitions.length - 1];
  17664. if (!(def.value instanceof AST_Object))
  17665. return;
  17666. var exprs;
  17667. if (body instanceof AST_Assign && !body.logical) {
  17668. exprs = [body];
  17669. } else if (body instanceof AST_Sequence) {
  17670. exprs = body.expressions.slice();
  17671. }
  17672. if (!exprs)
  17673. return;
  17674. var trimmed = false;
  17675. do {
  17676. var node = exprs[0];
  17677. if (!(node instanceof AST_Assign))
  17678. break;
  17679. if (node.operator != "=")
  17680. break;
  17681. if (!(node.left instanceof AST_PropAccess))
  17682. break;
  17683. var sym = node.left.expression;
  17684. if (!(sym instanceof AST_SymbolRef))
  17685. break;
  17686. if (def.name.name != sym.name)
  17687. break;
  17688. if (!node.right.is_constant_expression(nearest_scope))
  17689. break;
  17690. var prop = node.left.property;
  17691. if (prop instanceof AST_Node) {
  17692. prop = prop.evaluate(compressor);
  17693. }
  17694. if (prop instanceof AST_Node)
  17695. break;
  17696. prop = "" + prop;
  17697. var diff = compressor.option("ecma") < 2015
  17698. && compressor.has_directive("use strict") ? function (node) {
  17699. return node.key != prop && (node.key && node.key.name != prop);
  17700. } : function (node) {
  17701. return node.key && node.key.name != prop;
  17702. };
  17703. if (!def.value.properties.every(diff))
  17704. break;
  17705. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  17706. if (!p) {
  17707. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  17708. key: prop,
  17709. value: node.right
  17710. }));
  17711. } else {
  17712. p.value = new AST_Sequence({
  17713. start: p.start,
  17714. expressions: [p.value.clone(), node.right.clone()],
  17715. end: p.end
  17716. });
  17717. }
  17718. exprs.shift();
  17719. trimmed = true;
  17720. } while (exprs.length);
  17721. return trimmed && exprs;
  17722. }
  17723. function join_consecutive_vars(statements) {
  17724. var defs;
  17725. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  17726. var stat = statements[i];
  17727. var prev = statements[j];
  17728. if (stat instanceof AST_Definitions) {
  17729. if (prev && prev.TYPE == stat.TYPE) {
  17730. prev.definitions = prev.definitions.concat(stat.definitions);
  17731. CHANGED = true;
  17732. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  17733. defs.definitions = defs.definitions.concat(stat.definitions);
  17734. CHANGED = true;
  17735. } else {
  17736. statements[++j] = stat;
  17737. defs = stat;
  17738. }
  17739. } else if (
  17740. stat instanceof AST_Using
  17741. && prev instanceof AST_Using
  17742. && prev.await === stat.await
  17743. ) {
  17744. prev.definitions = prev.definitions.concat(stat.definitions);
  17745. } else if (stat instanceof AST_Exit) {
  17746. stat.value = extract_object_assignments(stat.value);
  17747. } else if (stat instanceof AST_For) {
  17748. var exprs = join_object_assignments(prev, stat.init);
  17749. if (exprs) {
  17750. CHANGED = true;
  17751. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  17752. statements[++j] = stat;
  17753. } else if (
  17754. prev instanceof AST_Var
  17755. && (!stat.init || stat.init.TYPE == prev.TYPE)
  17756. ) {
  17757. if (stat.init) {
  17758. prev.definitions = prev.definitions.concat(stat.init.definitions);
  17759. }
  17760. stat.init = prev;
  17761. statements[j] = stat;
  17762. CHANGED = true;
  17763. } else if (
  17764. defs instanceof AST_Var
  17765. && stat.init instanceof AST_Var
  17766. && declarations_only(stat.init)
  17767. ) {
  17768. defs.definitions = defs.definitions.concat(stat.init.definitions);
  17769. stat.init = null;
  17770. statements[++j] = stat;
  17771. CHANGED = true;
  17772. } else {
  17773. statements[++j] = stat;
  17774. }
  17775. } else if (stat instanceof AST_ForIn) {
  17776. stat.object = extract_object_assignments(stat.object);
  17777. } else if (stat instanceof AST_If) {
  17778. stat.condition = extract_object_assignments(stat.condition);
  17779. } else if (stat instanceof AST_SimpleStatement) {
  17780. var exprs = join_object_assignments(prev, stat.body);
  17781. if (exprs) {
  17782. CHANGED = true;
  17783. if (!exprs.length)
  17784. continue;
  17785. stat.body = make_sequence(stat.body, exprs);
  17786. }
  17787. statements[++j] = stat;
  17788. } else if (stat instanceof AST_Switch) {
  17789. stat.expression = extract_object_assignments(stat.expression);
  17790. } else if (stat instanceof AST_With) {
  17791. stat.expression = extract_object_assignments(stat.expression);
  17792. } else {
  17793. statements[++j] = stat;
  17794. }
  17795. }
  17796. statements.length = j + 1;
  17797. function extract_object_assignments(value) {
  17798. statements[++j] = stat;
  17799. var exprs = join_object_assignments(prev, value);
  17800. if (exprs) {
  17801. CHANGED = true;
  17802. if (exprs.length) {
  17803. return make_sequence(value, exprs);
  17804. } else if (value instanceof AST_Sequence) {
  17805. return value.tail_node().left;
  17806. } else {
  17807. return value.left;
  17808. }
  17809. }
  17810. return value;
  17811. }
  17812. }
  17813. }
  17814. /***********************************************************************
  17815. A JavaScript tokenizer / parser / beautifier / compressor.
  17816. https://github.com/mishoo/UglifyJS2
  17817. -------------------------------- (C) ---------------------------------
  17818. Author: Mihai Bazon
  17819. <mihai.bazon@gmail.com>
  17820. http://mihai.bazon.net/blog
  17821. Distributed under the BSD license:
  17822. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17823. Redistribution and use in source and binary forms, with or without
  17824. modification, are permitted provided that the following conditions
  17825. are met:
  17826. * Redistributions of source code must retain the above
  17827. copyright notice, this list of conditions and the following
  17828. disclaimer.
  17829. * Redistributions in binary form must reproduce the above
  17830. copyright notice, this list of conditions and the following
  17831. disclaimer in the documentation and/or other materials
  17832. provided with the distribution.
  17833. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17834. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17835. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17836. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17837. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17838. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17839. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17840. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17841. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17842. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17843. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17844. SUCH DAMAGE.
  17845. ***********************************************************************/
  17846. /**
  17847. * Module that contains the inlining logic.
  17848. *
  17849. * @module
  17850. *
  17851. * The stars of the show are `inline_into_symbolref` and `inline_into_call`.
  17852. */
  17853. function within_array_or_object_literal(compressor) {
  17854. var node, level = 0;
  17855. while (node = compressor.parent(level++)) {
  17856. if (node instanceof AST_Statement) return false;
  17857. if (node instanceof AST_Array
  17858. || node instanceof AST_ObjectKeyVal
  17859. || node instanceof AST_Object) {
  17860. return true;
  17861. }
  17862. }
  17863. return false;
  17864. }
  17865. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  17866. for (const enclosed of pulled_scope.enclosed) {
  17867. if (pulled_scope.variables.has(enclosed.name)) {
  17868. continue;
  17869. }
  17870. const looked_up = scope.find_variable(enclosed.name);
  17871. if (looked_up) {
  17872. if (looked_up === enclosed) continue;
  17873. return true;
  17874. }
  17875. }
  17876. return false;
  17877. }
  17878. /**
  17879. * An extra check function for `top_retain` option, compare the length of const identifier
  17880. * and init value length and return true if init value is longer than identifier. for example:
  17881. * ```
  17882. * // top_retain: ["example"]
  17883. * const example = 100
  17884. * ```
  17885. * it will return false because length of "100" is short than identifier "example".
  17886. */
  17887. function is_const_symbol_short_than_init_value(def, fixed_value) {
  17888. if (def.orig.length === 1 && fixed_value) {
  17889. const init_value_length = fixed_value.size();
  17890. const identifer_length = def.name.length;
  17891. return init_value_length > identifer_length;
  17892. }
  17893. return true;
  17894. }
  17895. function inline_into_symbolref(self, compressor) {
  17896. if (compressor.in_computed_key()) return self;
  17897. const parent = compressor.parent();
  17898. const def = self.definition();
  17899. const nearest_scope = compressor.find_scope();
  17900. let fixed = self.fixed_value();
  17901. if (
  17902. compressor.top_retain &&
  17903. def.global &&
  17904. compressor.top_retain(def) &&
  17905. // when identifier is in top_retain option dose not mean we can always inline it.
  17906. // if identifier name is longer then init value, we can replace it.
  17907. is_const_symbol_short_than_init_value(def, fixed)
  17908. ) {
  17909. // keep it
  17910. def.fixed = false;
  17911. def.single_use = false;
  17912. return self;
  17913. }
  17914. if (dont_inline_lambda_in_loop(compressor, fixed)) return self;
  17915. let single_use = def.single_use
  17916. && !(parent instanceof AST_Call
  17917. && (parent.is_callee_pure(compressor))
  17918. || has_annotation(parent, _NOINLINE))
  17919. && !(parent instanceof AST_Export
  17920. && fixed instanceof AST_Lambda
  17921. && fixed.name);
  17922. if (single_use && fixed instanceof AST_Node) {
  17923. single_use =
  17924. !fixed.has_side_effects(compressor)
  17925. && !fixed.may_throw(compressor);
  17926. }
  17927. if (fixed instanceof AST_Class && def.scope !== self.scope) {
  17928. return self;
  17929. }
  17930. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  17931. if (retain_top_func(fixed, compressor)) {
  17932. single_use = false;
  17933. } else if (def.scope !== self.scope
  17934. && (def.escaped == 1
  17935. || has_flag(fixed, INLINED)
  17936. || within_array_or_object_literal(compressor)
  17937. || !compressor.option("reduce_funcs"))) {
  17938. single_use = false;
  17939. } else if (is_recursive_ref(compressor, def)) {
  17940. single_use = false;
  17941. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  17942. single_use = fixed.is_constant_expression(self.scope);
  17943. if (single_use == "f") {
  17944. var scope = self.scope;
  17945. do {
  17946. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  17947. set_flag(scope, INLINED);
  17948. }
  17949. } while (scope = scope.parent_scope);
  17950. }
  17951. }
  17952. }
  17953. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  17954. single_use =
  17955. def.scope === self.scope
  17956. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  17957. || parent instanceof AST_Call
  17958. && parent.expression === self
  17959. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  17960. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  17961. }
  17962. if (single_use && fixed) {
  17963. if (fixed instanceof AST_DefClass) {
  17964. set_flag(fixed, SQUEEZED);
  17965. fixed = make_node(AST_ClassExpression, fixed, fixed);
  17966. }
  17967. if (fixed instanceof AST_Defun) {
  17968. set_flag(fixed, SQUEEZED);
  17969. fixed = make_node(AST_Function, fixed, fixed);
  17970. }
  17971. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  17972. const defun_def = fixed.name.definition();
  17973. let lambda_def = fixed.variables.get(fixed.name.name);
  17974. let name = lambda_def && lambda_def.orig[0];
  17975. if (!(name instanceof AST_SymbolLambda)) {
  17976. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  17977. name.scope = fixed;
  17978. fixed.name = name;
  17979. lambda_def = fixed.def_function(name);
  17980. }
  17981. walk(fixed, node => {
  17982. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  17983. node.thedef = lambda_def;
  17984. lambda_def.references.push(node);
  17985. }
  17986. });
  17987. }
  17988. if (
  17989. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  17990. && fixed.parent_scope !== nearest_scope
  17991. ) {
  17992. fixed = fixed.clone(true, compressor.get_toplevel());
  17993. nearest_scope.add_child_scope(fixed);
  17994. }
  17995. return fixed.optimize(compressor);
  17996. }
  17997. // multiple uses
  17998. if (fixed) {
  17999. let replace;
  18000. if (fixed instanceof AST_This) {
  18001. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  18002. && def.references.every((ref) =>
  18003. def.scope === ref.scope
  18004. )) {
  18005. replace = fixed;
  18006. }
  18007. } else {
  18008. var ev = fixed.evaluate(compressor);
  18009. if (
  18010. ev !== fixed
  18011. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  18012. ) {
  18013. replace = make_node_from_constant(ev, fixed);
  18014. }
  18015. }
  18016. if (replace) {
  18017. const name_length = self.size(compressor);
  18018. const replace_size = replace.size(compressor);
  18019. let overhead = 0;
  18020. if (compressor.option("unused") && !compressor.exposed(def)) {
  18021. overhead =
  18022. (name_length + 2 + fixed.size(compressor)) /
  18023. (def.references.length - def.assignments);
  18024. }
  18025. if (replace_size <= name_length + overhead) {
  18026. return replace;
  18027. }
  18028. }
  18029. }
  18030. return self;
  18031. }
  18032. function inline_into_call(self, compressor) {
  18033. if (compressor.in_computed_key()) return self;
  18034. var exp = self.expression;
  18035. var fn = exp;
  18036. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  18037. if (compressor.option("reduce_vars")
  18038. && fn instanceof AST_SymbolRef
  18039. && !has_annotation(self, _NOINLINE)
  18040. ) {
  18041. const fixed = fn.fixed_value();
  18042. if (
  18043. retain_top_func(fixed, compressor)
  18044. || !compressor.toplevel.funcs && exp.definition().global
  18045. ) {
  18046. return self;
  18047. }
  18048. fn = fixed;
  18049. }
  18050. if (
  18051. dont_inline_lambda_in_loop(compressor, fn)
  18052. && !has_annotation(self, _INLINE)
  18053. ) return self;
  18054. var is_func = fn instanceof AST_Lambda;
  18055. var stat = is_func && fn.body[0];
  18056. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  18057. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  18058. if (can_inline && stat instanceof AST_Return) {
  18059. let returned = stat.value;
  18060. if (!returned || returned.is_constant_expression()) {
  18061. if (returned) {
  18062. returned = returned.clone(true);
  18063. } else {
  18064. returned = make_void_0(self);
  18065. }
  18066. const args = self.args.concat(returned);
  18067. return make_sequence(self, args).optimize(compressor);
  18068. }
  18069. // optimize identity function
  18070. if (
  18071. fn.argnames.length === 1
  18072. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  18073. && self.args.length < 2
  18074. && !(self.args[0] instanceof AST_Expansion)
  18075. && returned instanceof AST_SymbolRef
  18076. && returned.name === fn.argnames[0].name
  18077. ) {
  18078. const replacement =
  18079. (self.args[0] || make_void_0()).optimize(compressor);
  18080. let parent;
  18081. if (
  18082. replacement instanceof AST_PropAccess
  18083. && (parent = compressor.parent()) instanceof AST_Call
  18084. && parent.expression === self
  18085. ) {
  18086. // identity function was being used to remove `this`, like in
  18087. //
  18088. // id(bag.no_this)(...)
  18089. //
  18090. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  18091. return make_sequence(self, [
  18092. make_node(AST_Number, self, { value: 0 }),
  18093. replacement
  18094. ]);
  18095. }
  18096. // replace call with first argument or undefined if none passed
  18097. return replacement;
  18098. }
  18099. }
  18100. if (can_inline) {
  18101. var scope, in_loop, level = -1;
  18102. let def;
  18103. let returned_value;
  18104. let nearest_scope;
  18105. if (simple_args
  18106. && !fn.uses_arguments
  18107. && !(compressor.parent() instanceof AST_Class)
  18108. && !(fn.name && fn instanceof AST_Function)
  18109. && (returned_value = can_flatten_body(stat))
  18110. && (exp === fn
  18111. || has_annotation(self, _INLINE)
  18112. || compressor.option("unused")
  18113. && (def = exp.definition()).references.length == 1
  18114. && !is_recursive_ref(compressor, def)
  18115. && fn.is_constant_expression(exp.scope))
  18116. && !has_annotation(self, _PURE | _NOINLINE)
  18117. && !fn.contains_this()
  18118. && can_inject_symbols()
  18119. && (nearest_scope = compressor.find_scope())
  18120. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  18121. && !(function in_default_assign() {
  18122. // Due to the fact function parameters have their own scope
  18123. // which can't use `var something` in the function body within,
  18124. // we simply don't inline into DefaultAssign.
  18125. let i = 0;
  18126. let p;
  18127. while ((p = compressor.parent(i++))) {
  18128. if (p instanceof AST_DefaultAssign) return true;
  18129. if (p instanceof AST_Block) break;
  18130. }
  18131. return false;
  18132. })()
  18133. && !(scope instanceof AST_Class)
  18134. ) {
  18135. set_flag(fn, SQUEEZED);
  18136. nearest_scope.add_child_scope(fn);
  18137. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  18138. }
  18139. }
  18140. if (can_inline && has_annotation(self, _INLINE)) {
  18141. set_flag(fn, SQUEEZED);
  18142. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  18143. fn = fn.clone(true);
  18144. fn.figure_out_scope({}, {
  18145. parent_scope: compressor.find_scope(),
  18146. toplevel: compressor.get_toplevel()
  18147. });
  18148. return make_node(AST_Call, self, {
  18149. expression: fn,
  18150. args: self.args,
  18151. }).optimize(compressor);
  18152. }
  18153. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  18154. if (can_drop_this_call) {
  18155. var args = self.args.concat(make_void_0(self));
  18156. return make_sequence(self, args).optimize(compressor);
  18157. }
  18158. if (compressor.option("negate_iife")
  18159. && compressor.parent() instanceof AST_SimpleStatement
  18160. && is_iife_call(self)) {
  18161. return self.negate(compressor, true);
  18162. }
  18163. var ev = self.evaluate(compressor);
  18164. if (ev !== self) {
  18165. ev = make_node_from_constant(ev, self).optimize(compressor);
  18166. return best_of(compressor, ev, self);
  18167. }
  18168. return self;
  18169. function return_value(stat) {
  18170. if (!stat) return make_void_0(self);
  18171. if (stat instanceof AST_Return) {
  18172. if (!stat.value) return make_void_0(self);
  18173. return stat.value.clone(true);
  18174. }
  18175. if (stat instanceof AST_SimpleStatement) {
  18176. return make_node(AST_UnaryPrefix, stat, {
  18177. operator: "void",
  18178. expression: stat.body.clone(true)
  18179. });
  18180. }
  18181. }
  18182. function can_flatten_body(stat) {
  18183. var body = fn.body;
  18184. var len = body.length;
  18185. if (compressor.option("inline") < 3) {
  18186. return len == 1 && return_value(stat);
  18187. }
  18188. stat = null;
  18189. for (var i = 0; i < len; i++) {
  18190. var line = body[i];
  18191. if (line instanceof AST_Var) {
  18192. if (stat && !line.definitions.every((var_def) =>
  18193. !var_def.value
  18194. )) {
  18195. return false;
  18196. }
  18197. } else if (stat) {
  18198. return false;
  18199. } else if (!(line instanceof AST_EmptyStatement)) {
  18200. stat = line;
  18201. }
  18202. }
  18203. return return_value(stat);
  18204. }
  18205. function can_inject_args(block_scoped, safe_to_inject) {
  18206. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  18207. var arg = fn.argnames[i];
  18208. if (arg instanceof AST_DefaultAssign) {
  18209. if (has_flag(arg.left, UNUSED)) continue;
  18210. return false;
  18211. }
  18212. if (arg instanceof AST_Destructuring) return false;
  18213. if (arg instanceof AST_Expansion) {
  18214. if (has_flag(arg.expression, UNUSED)) continue;
  18215. return false;
  18216. }
  18217. if (has_flag(arg, UNUSED)) continue;
  18218. if (!safe_to_inject
  18219. || block_scoped.has(arg.name)
  18220. || identifier_atom.has(arg.name)
  18221. || scope.conflicting_def(arg.name)) {
  18222. return false;
  18223. }
  18224. if (in_loop) in_loop.push(arg.definition());
  18225. }
  18226. return true;
  18227. }
  18228. function can_inject_vars(block_scoped, safe_to_inject) {
  18229. var len = fn.body.length;
  18230. for (var i = 0; i < len; i++) {
  18231. var stat = fn.body[i];
  18232. if (!(stat instanceof AST_Var)) continue;
  18233. if (!safe_to_inject) return false;
  18234. for (var j = stat.definitions.length; --j >= 0;) {
  18235. var name = stat.definitions[j].name;
  18236. if (name instanceof AST_Destructuring
  18237. || block_scoped.has(name.name)
  18238. || identifier_atom.has(name.name)
  18239. || scope.conflicting_def(name.name)) {
  18240. return false;
  18241. }
  18242. if (in_loop) in_loop.push(name.definition());
  18243. }
  18244. }
  18245. return true;
  18246. }
  18247. function can_inject_symbols() {
  18248. var block_scoped = new Set();
  18249. do {
  18250. scope = compressor.parent(++level);
  18251. if (scope.is_block_scope() && scope.block_scope) {
  18252. // TODO this is sometimes undefined during compression.
  18253. // But it should always have a value!
  18254. scope.block_scope.variables.forEach(function (variable) {
  18255. block_scoped.add(variable.name);
  18256. });
  18257. }
  18258. if (scope instanceof AST_Catch) {
  18259. // TODO can we delete? AST_Catch is a block scope.
  18260. if (scope.argname) {
  18261. block_scoped.add(scope.argname.name);
  18262. }
  18263. } else if (scope instanceof AST_IterationStatement) {
  18264. in_loop = [];
  18265. } else if (scope instanceof AST_SymbolRef) {
  18266. if (scope.fixed_value() instanceof AST_Scope) return false;
  18267. }
  18268. } while (!(scope instanceof AST_Scope));
  18269. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  18270. var inline = compressor.option("inline");
  18271. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  18272. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  18273. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  18274. }
  18275. function append_var(decls, expressions, name, value) {
  18276. var def = name.definition();
  18277. // Name already exists, only when a function argument had the same name
  18278. const already_appended = scope.variables.has(name.name);
  18279. if (!already_appended) {
  18280. scope.variables.set(name.name, def);
  18281. scope.enclosed.push(def);
  18282. decls.push(make_node(AST_VarDef, name, {
  18283. name: name,
  18284. value: null
  18285. }));
  18286. }
  18287. var sym = make_node(AST_SymbolRef, name, name);
  18288. def.references.push(sym);
  18289. if (value) expressions.push(make_node(AST_Assign, self, {
  18290. operator: "=",
  18291. logical: false,
  18292. left: sym,
  18293. right: value.clone()
  18294. }));
  18295. }
  18296. function flatten_args(decls, expressions) {
  18297. var len = fn.argnames.length;
  18298. for (var i = self.args.length; --i >= len;) {
  18299. expressions.push(self.args[i]);
  18300. }
  18301. for (i = len; --i >= 0;) {
  18302. var name = fn.argnames[i];
  18303. var value = self.args[i];
  18304. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  18305. if (value) expressions.push(value);
  18306. } else {
  18307. var symbol = make_node(AST_SymbolVar, name, name);
  18308. name.definition().orig.push(symbol);
  18309. if (!value && in_loop) value = make_void_0(self);
  18310. append_var(decls, expressions, symbol, value);
  18311. }
  18312. }
  18313. decls.reverse();
  18314. expressions.reverse();
  18315. }
  18316. function flatten_vars(decls, expressions) {
  18317. var pos = expressions.length;
  18318. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  18319. var stat = fn.body[i];
  18320. if (!(stat instanceof AST_Var)) continue;
  18321. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  18322. var var_def = stat.definitions[j];
  18323. var name = var_def.name;
  18324. append_var(decls, expressions, name, var_def.value);
  18325. if (in_loop && fn.argnames.every((argname) =>
  18326. argname.name != name.name
  18327. )) {
  18328. var def = fn.variables.get(name.name);
  18329. var sym = make_node(AST_SymbolRef, name, name);
  18330. def.references.push(sym);
  18331. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  18332. operator: "=",
  18333. logical: false,
  18334. left: sym,
  18335. right: make_void_0(name),
  18336. }));
  18337. }
  18338. }
  18339. }
  18340. }
  18341. function flatten_fn(returned_value) {
  18342. var decls = [];
  18343. var expressions = [];
  18344. flatten_args(decls, expressions);
  18345. flatten_vars(decls, expressions);
  18346. expressions.push(returned_value);
  18347. if (decls.length) {
  18348. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  18349. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  18350. definitions: decls
  18351. }));
  18352. }
  18353. return expressions.map(exp => exp.clone(true));
  18354. }
  18355. }
  18356. /** prevent inlining functions into loops, for performance reasons */
  18357. function dont_inline_lambda_in_loop(compressor, maybe_lambda) {
  18358. return (
  18359. (maybe_lambda instanceof AST_Lambda || maybe_lambda instanceof AST_Class)
  18360. && !!compressor.is_within_loop()
  18361. );
  18362. }
  18363. (function(def_find_defs) {
  18364. function to_node(value, orig) {
  18365. if (value instanceof AST_Node) {
  18366. if (!(value instanceof AST_Constant)) {
  18367. // Value may be a function, an array including functions and even a complex assign / block expression,
  18368. // so it should never be shared in different places.
  18369. // Otherwise wrong information may be used in the compression phase
  18370. value = value.clone(true);
  18371. }
  18372. return make_node(value.CTOR, orig, value);
  18373. }
  18374. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  18375. elements: value.map(function(value) {
  18376. return to_node(value, orig);
  18377. })
  18378. });
  18379. if (value && typeof value == "object") {
  18380. var props = [];
  18381. for (var key in value) if (HOP(value, key)) {
  18382. props.push(make_node(AST_ObjectKeyVal, orig, {
  18383. key: key,
  18384. value: to_node(value[key], orig)
  18385. }));
  18386. }
  18387. return make_node(AST_Object, orig, {
  18388. properties: props
  18389. });
  18390. }
  18391. return make_node_from_constant(value, orig);
  18392. }
  18393. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  18394. if (!compressor.option("global_defs")) return this;
  18395. this.figure_out_scope({ ie8: compressor.option("ie8") });
  18396. return this.transform(new TreeTransformer(function(node) {
  18397. var def = node._find_defs(compressor, "");
  18398. if (!def) return;
  18399. var level = 0, child = node, parent;
  18400. while (parent = this.parent(level++)) {
  18401. if (!(parent instanceof AST_PropAccess)) break;
  18402. if (parent.expression !== child) break;
  18403. child = parent;
  18404. }
  18405. if (is_lhs(child, parent)) {
  18406. return;
  18407. }
  18408. return def;
  18409. }));
  18410. });
  18411. def_find_defs(AST_Node, noop);
  18412. def_find_defs(AST_Chain, function(compressor, suffix) {
  18413. return this.expression._find_defs(compressor, suffix);
  18414. });
  18415. def_find_defs(AST_Dot, function(compressor, suffix) {
  18416. return this.expression._find_defs(compressor, "." + this.property + suffix);
  18417. });
  18418. def_find_defs(AST_SymbolDeclaration, function() {
  18419. if (!this.global()) return;
  18420. });
  18421. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  18422. if (!this.global()) return;
  18423. var defines = compressor.option("global_defs");
  18424. var name = this.name + suffix;
  18425. if (HOP(defines, name)) return to_node(defines[name], this);
  18426. });
  18427. def_find_defs(AST_ImportMeta, function(compressor, suffix) {
  18428. var defines = compressor.option("global_defs");
  18429. var name = "import.meta" + suffix;
  18430. if (HOP(defines, name)) return to_node(defines[name], this);
  18431. });
  18432. })(function(node, func) {
  18433. node.DEFMETHOD("_find_defs", func);
  18434. });
  18435. /***********************************************************************
  18436. A JavaScript tokenizer / parser / beautifier / compressor.
  18437. https://github.com/mishoo/UglifyJS2
  18438. -------------------------------- (C) ---------------------------------
  18439. Author: Mihai Bazon
  18440. <mihai.bazon@gmail.com>
  18441. http://mihai.bazon.net/blog
  18442. Distributed under the BSD license:
  18443. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  18444. Redistribution and use in source and binary forms, with or without
  18445. modification, are permitted provided that the following conditions
  18446. are met:
  18447. * Redistributions of source code must retain the above
  18448. copyright notice, this list of conditions and the following
  18449. disclaimer.
  18450. * Redistributions in binary form must reproduce the above
  18451. copyright notice, this list of conditions and the following
  18452. disclaimer in the documentation and/or other materials
  18453. provided with the distribution.
  18454. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  18455. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18456. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18457. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  18458. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  18459. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18460. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  18461. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18462. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  18463. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  18464. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  18465. SUCH DAMAGE.
  18466. ***********************************************************************/
  18467. class Compressor extends TreeWalker {
  18468. constructor(options, { false_by_default = false, mangle_options = false }) {
  18469. super();
  18470. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  18471. this.options = defaults(options, {
  18472. arguments : false,
  18473. arrows : !false_by_default,
  18474. booleans : !false_by_default,
  18475. booleans_as_integers : false,
  18476. collapse_vars : !false_by_default,
  18477. comparisons : !false_by_default,
  18478. computed_props: !false_by_default,
  18479. conditionals : !false_by_default,
  18480. dead_code : !false_by_default,
  18481. defaults : true,
  18482. directives : !false_by_default,
  18483. drop_console : false,
  18484. drop_debugger : !false_by_default,
  18485. ecma : 5,
  18486. builtins_ecma : 5,
  18487. builtins_pure : false,
  18488. evaluate : !false_by_default,
  18489. expression : false,
  18490. global_defs : false,
  18491. hoist_funs : false,
  18492. hoist_props : !false_by_default,
  18493. hoist_vars : false,
  18494. ie8 : false,
  18495. if_return : !false_by_default,
  18496. inline : !false_by_default,
  18497. join_vars : !false_by_default,
  18498. keep_classnames: false,
  18499. keep_fargs : true,
  18500. keep_fnames : false,
  18501. keep_infinity : false,
  18502. lhs_constants : !false_by_default,
  18503. loops : !false_by_default,
  18504. module : false,
  18505. negate_iife : !false_by_default,
  18506. passes : 1,
  18507. properties : !false_by_default,
  18508. pure_getters : !false_by_default && "strict",
  18509. pure_funcs : null,
  18510. pure_new : false,
  18511. reduce_funcs : !false_by_default,
  18512. reduce_vars : !false_by_default,
  18513. sequences : !false_by_default,
  18514. side_effects : !false_by_default,
  18515. switches : !false_by_default,
  18516. top_retain : null,
  18517. toplevel : !!(options && options["top_retain"]),
  18518. typeofs : !false_by_default,
  18519. unsafe : false,
  18520. unsafe_arrows : false,
  18521. unsafe_comps : false,
  18522. unsafe_Function: false,
  18523. unsafe_math : false,
  18524. unsafe_symbols: false,
  18525. unsafe_methods: false,
  18526. unsafe_proto : false,
  18527. unsafe_regexp : false,
  18528. unsafe_undefined: false,
  18529. unused : !false_by_default,
  18530. warnings : false // legacy
  18531. }, true);
  18532. var global_defs = this.options["global_defs"];
  18533. if (typeof global_defs == "object") for (var key in global_defs) {
  18534. if (key[0] === "@" && HOP(global_defs, key)) {
  18535. global_defs[key.slice(1)] = parse(global_defs[key], {
  18536. expression: true
  18537. });
  18538. }
  18539. }
  18540. if (this.options["inline"] === true) this.options["inline"] = 3;
  18541. var pure_funcs = this.options["pure_funcs"];
  18542. if (typeof pure_funcs == "function") {
  18543. this.pure_funcs = pure_funcs;
  18544. } else {
  18545. this.pure_funcs = pure_funcs ? function(node) {
  18546. return !pure_funcs.includes(node.expression.print_to_string());
  18547. } : return_true;
  18548. }
  18549. var top_retain = this.options["top_retain"];
  18550. if (top_retain instanceof RegExp) {
  18551. this.top_retain = function(def) {
  18552. return top_retain.test(def.name);
  18553. };
  18554. } else if (typeof top_retain == "function") {
  18555. this.top_retain = top_retain;
  18556. } else if (top_retain) {
  18557. if (typeof top_retain == "string") {
  18558. top_retain = top_retain.split(/,/);
  18559. }
  18560. this.top_retain = function(def) {
  18561. return top_retain.includes(def.name);
  18562. };
  18563. }
  18564. if (this.options["module"]) {
  18565. this.directives["use strict"] = true;
  18566. this.options["toplevel"] = true;
  18567. }
  18568. var toplevel = this.options["toplevel"];
  18569. this.toplevel = typeof toplevel == "string" ? {
  18570. funcs: /funcs/.test(toplevel),
  18571. vars: /vars/.test(toplevel)
  18572. } : {
  18573. funcs: toplevel,
  18574. vars: toplevel
  18575. };
  18576. var sequences = this.options["sequences"];
  18577. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  18578. this.evaluated_regexps = new Map();
  18579. this._toplevel = undefined;
  18580. this._mangle_options = mangle_options
  18581. ? format_mangler_options(mangle_options)
  18582. : mangle_options;
  18583. this.pure_access_globals = pure_access_globals(this);
  18584. this.is_pure_native_fn = is_pure_native_fn(this);
  18585. this.is_pure_native_method = is_pure_native_method(this);
  18586. this.is_pure_native_static_fn = is_pure_native_static_fn(this);
  18587. this.is_pure_native_static_property = is_pure_native_static_property(this);
  18588. }
  18589. mangle_options() {
  18590. var nth_identifier = this._mangle_options && this._mangle_options.nth_identifier || base54;
  18591. var module = this._mangle_options && this._mangle_options.module || this.option("module");
  18592. return { ie8: this.option("ie8"), nth_identifier, module };
  18593. }
  18594. option(key) {
  18595. return this.options[key];
  18596. }
  18597. exposed(def) {
  18598. if (def.export) return true;
  18599. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  18600. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  18601. return true;
  18602. return false;
  18603. }
  18604. in_boolean_context() {
  18605. if (!this.option("booleans")) return false;
  18606. var self = this.self();
  18607. for (var i = 0, p; p = this.parent(i); i++) {
  18608. if (p instanceof AST_SimpleStatement
  18609. || p instanceof AST_Conditional && p.condition === self
  18610. || p instanceof AST_DWLoop && p.condition === self
  18611. || p instanceof AST_For && p.condition === self
  18612. || p instanceof AST_If && p.condition === self
  18613. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  18614. return true;
  18615. }
  18616. if (
  18617. p instanceof AST_Binary && (
  18618. p.operator == "&&" || p.operator == "||"
  18619. )
  18620. || p instanceof AST_Conditional
  18621. || p.tail_node() === self
  18622. ) {
  18623. self = p;
  18624. } else {
  18625. return false;
  18626. }
  18627. }
  18628. }
  18629. /** True if compressor.self()'s result will be turned into a 32-bit integer.
  18630. * ex:
  18631. * ~{expr}
  18632. * (1, 2, {expr}) | 0
  18633. **/
  18634. in_32_bit_context(other_operand_must_be_number) {
  18635. if (!this.option("evaluate")) return false;
  18636. var self = this.self();
  18637. for (var i = 0, p; p = this.parent(i); i++) {
  18638. if (p instanceof AST_Binary && bitwise_binop.has(p.operator)) {
  18639. if (other_operand_must_be_number) {
  18640. return (self === p.left ? p.right : p.left).is_number(this);
  18641. } else {
  18642. return true;
  18643. }
  18644. }
  18645. if (p instanceof AST_UnaryPrefix) {
  18646. return p.operator === "~";
  18647. }
  18648. if (
  18649. p instanceof AST_Binary
  18650. && (
  18651. // Don't talk about p.left. Can change branch taken
  18652. p.operator == "&&" && p.right === self
  18653. || p.operator == "||" && p.right === self
  18654. || p.operator == "??" && p.right === self
  18655. )
  18656. || p instanceof AST_Conditional && p.condition !== self
  18657. || p.tail_node() === self
  18658. ) {
  18659. self = p;
  18660. } else {
  18661. return false;
  18662. }
  18663. }
  18664. }
  18665. in_computed_key() {
  18666. if (!this.option("evaluate")) return false;
  18667. var self = this.self();
  18668. for (var i = 0, p; p = this.parent(i); i++) {
  18669. if (p instanceof AST_ObjectProperty && p.key === self) {
  18670. return true;
  18671. }
  18672. }
  18673. return false;
  18674. }
  18675. get_toplevel() {
  18676. return this._toplevel;
  18677. }
  18678. compress(toplevel) {
  18679. toplevel = toplevel.resolve_defines(this);
  18680. this._toplevel = toplevel;
  18681. if (this.option("expression")) {
  18682. this._toplevel.process_expression(true);
  18683. }
  18684. var passes = +this.options.passes || 1;
  18685. var min_count = 1 / 0;
  18686. var stopping = false;
  18687. var mangle = this.mangle_options();
  18688. for (var pass = 0; pass < passes; pass++) {
  18689. this._toplevel.figure_out_scope(mangle);
  18690. if (pass === 0 && this.option("drop_console")) {
  18691. // must be run before reduce_vars and compress pass
  18692. this._toplevel = this._toplevel.drop_console(this.option("drop_console"));
  18693. }
  18694. if (pass > 0 || this.option("reduce_vars")) {
  18695. this._toplevel.reset_opt_flags(this);
  18696. }
  18697. this._toplevel = this._toplevel.transform(this);
  18698. if (passes > 1) {
  18699. let count = 0;
  18700. walk(this._toplevel, () => { count++; });
  18701. if (count < min_count) {
  18702. min_count = count;
  18703. stopping = false;
  18704. } else if (stopping) {
  18705. break;
  18706. } else {
  18707. stopping = true;
  18708. }
  18709. }
  18710. }
  18711. if (this.option("expression")) {
  18712. this._toplevel.process_expression(false);
  18713. }
  18714. toplevel = this._toplevel;
  18715. this._toplevel = undefined;
  18716. return toplevel;
  18717. }
  18718. before(node, descend) {
  18719. if (has_flag(node, SQUEEZED)) return node;
  18720. var was_scope = false;
  18721. if (node instanceof AST_Scope) {
  18722. node = node.hoist_properties(this);
  18723. node = node.hoist_declarations(this);
  18724. was_scope = true;
  18725. }
  18726. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  18727. // would call AST_Node.transform() if a different instance of AST_Node is
  18728. // produced after def_optimize().
  18729. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  18730. // Migrate and defer all children's AST_Node.transform() to below, which
  18731. // will now happen after this parent AST_Node has been properly substituted
  18732. // thus gives a consistent AST snapshot.
  18733. descend(node, this);
  18734. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  18735. // following replacement call would result in degraded efficiency of both
  18736. // output and performance.
  18737. descend(node, this);
  18738. var opt = node.optimize(this);
  18739. if (was_scope && opt instanceof AST_Scope) {
  18740. opt.drop_unused(this);
  18741. descend(opt, this);
  18742. }
  18743. if (opt === node) set_flag(opt, SQUEEZED);
  18744. return opt;
  18745. }
  18746. /** Alternative to plain is_lhs() which doesn't work within .optimize() */
  18747. is_lhs() {
  18748. const self = this.stack[this.stack.length - 1];
  18749. const parent = this.stack[this.stack.length - 2];
  18750. return is_lhs(self, parent);
  18751. }
  18752. }
  18753. function def_optimize(node, optimizer) {
  18754. node.DEFMETHOD("optimize", function(compressor) {
  18755. var self = this;
  18756. if (has_flag(self, OPTIMIZED)) return self;
  18757. if (compressor.has_directive("use asm")) return self;
  18758. var opt = optimizer(self, compressor);
  18759. set_flag(opt, OPTIMIZED);
  18760. return opt;
  18761. });
  18762. }
  18763. def_optimize(AST_Node, function(self) {
  18764. return self;
  18765. });
  18766. AST_Toplevel.DEFMETHOD("drop_console", function(options) {
  18767. const isArray = Array.isArray(options);
  18768. const tt = new TreeTransformer(function(self) {
  18769. if (self.TYPE !== "Call") {
  18770. return;
  18771. }
  18772. var exp = self.expression;
  18773. if (!(exp instanceof AST_PropAccess)) {
  18774. return;
  18775. }
  18776. var name = exp.expression;
  18777. var property = exp.property;
  18778. var depth = 2;
  18779. while (name.expression) {
  18780. property = name.property;
  18781. name = name.expression;
  18782. depth++;
  18783. }
  18784. if (isArray && !options.includes(property)) {
  18785. return;
  18786. }
  18787. if (is_undeclared_ref(name) && name.name == "console") {
  18788. if (
  18789. depth === 3
  18790. && !["call", "apply"].includes(exp.property)
  18791. && is_used_in_expression(tt)
  18792. ) {
  18793. // a (used) call to Function.prototype methods (eg: console.log.bind(console))
  18794. // but not .call and .apply which would also return undefined.
  18795. exp.expression = make_empty_function(self);
  18796. set_flag(exp.expression, SQUEEZED);
  18797. self.args = [];
  18798. } else {
  18799. return make_void_0(self);
  18800. }
  18801. }
  18802. });
  18803. return this.transform(tt);
  18804. });
  18805. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  18806. return equivalent_to(this, node);
  18807. });
  18808. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  18809. var self = this;
  18810. var tt = new TreeTransformer(function(node) {
  18811. if (insert && node instanceof AST_SimpleStatement) {
  18812. return make_node(AST_Return, node, {
  18813. value: node.body
  18814. });
  18815. }
  18816. if (!insert && node instanceof AST_Return) {
  18817. if (compressor) {
  18818. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  18819. return value
  18820. ? make_node(AST_SimpleStatement, node, { body: value })
  18821. : make_node(AST_EmptyStatement, node);
  18822. }
  18823. return make_node(AST_SimpleStatement, node, {
  18824. body: node.value || make_void_0(node)
  18825. });
  18826. }
  18827. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  18828. return node;
  18829. }
  18830. if (node instanceof AST_Block) {
  18831. var index = node.body.length - 1;
  18832. if (index >= 0) {
  18833. node.body[index] = node.body[index].transform(tt);
  18834. }
  18835. } else if (node instanceof AST_If) {
  18836. node.body = node.body.transform(tt);
  18837. if (node.alternative) {
  18838. node.alternative = node.alternative.transform(tt);
  18839. }
  18840. } else if (node instanceof AST_With) {
  18841. node.body = node.body.transform(tt);
  18842. }
  18843. return node;
  18844. });
  18845. self.transform(tt);
  18846. });
  18847. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  18848. const self = this;
  18849. const reduce_vars = compressor.option("reduce_vars");
  18850. const preparation = new TreeWalker(function(node, descend) {
  18851. clear_flag(node, CLEAR_BETWEEN_PASSES);
  18852. if (reduce_vars) {
  18853. if (compressor.top_retain
  18854. && node instanceof AST_Defun // Only functions are retained
  18855. && preparation.parent() === self
  18856. ) {
  18857. set_flag(node, TOP);
  18858. }
  18859. return node.reduce_vars(preparation, descend, compressor);
  18860. }
  18861. });
  18862. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  18863. // properly assigned before use:
  18864. // - `push()` & `pop()` when visiting conditional branches
  18865. preparation.safe_ids = Object.create(null);
  18866. preparation.in_loop = null;
  18867. preparation.loop_ids = new Map();
  18868. preparation.defs_to_safe_ids = new Map();
  18869. self.walk(preparation);
  18870. });
  18871. AST_Symbol.DEFMETHOD("fixed_value", function() {
  18872. var fixed = this.thedef.fixed;
  18873. if (!fixed || fixed instanceof AST_Node) return fixed;
  18874. return fixed();
  18875. });
  18876. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  18877. var orig = this.definition().orig;
  18878. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  18879. });
  18880. function find_variable(compressor, name) {
  18881. var scope, i = 0;
  18882. while (scope = compressor.parent(i++)) {
  18883. if (scope instanceof AST_Scope) break;
  18884. if (scope instanceof AST_Catch && scope.argname) {
  18885. scope = scope.argname.definition().scope;
  18886. break;
  18887. }
  18888. }
  18889. return scope.find_variable(name);
  18890. }
  18891. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  18892. return !this.definition().undeclared
  18893. || (compressor.option("unsafe") || compressor.option("builtins_pure")) && compressor.pure_access_globals(this.name);
  18894. });
  18895. /* -----[ optimizers ]----- */
  18896. var directives = new Set(["use asm", "use strict"]);
  18897. def_optimize(AST_Directive, function(self, compressor) {
  18898. if (compressor.option("directives")
  18899. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  18900. return make_node(AST_EmptyStatement, self);
  18901. }
  18902. return self;
  18903. });
  18904. def_optimize(AST_Debugger, function(self, compressor) {
  18905. if (compressor.option("drop_debugger"))
  18906. return make_node(AST_EmptyStatement, self);
  18907. return self;
  18908. });
  18909. def_optimize(AST_LabeledStatement, function(self, compressor) {
  18910. if (self.body instanceof AST_Break
  18911. && compressor.loopcontrol_target(self.body) === self.body) {
  18912. return make_node(AST_EmptyStatement, self);
  18913. }
  18914. return self.label.references.length == 0 ? self.body : self;
  18915. });
  18916. def_optimize(AST_Block, function(self, compressor) {
  18917. tighten_body(self.body, compressor);
  18918. return self;
  18919. });
  18920. function can_be_extracted_from_if_block(node) {
  18921. return !(
  18922. node instanceof AST_Const
  18923. || node instanceof AST_Let
  18924. || node instanceof AST_Using
  18925. || node instanceof AST_Class
  18926. );
  18927. }
  18928. def_optimize(AST_BlockStatement, function(self, compressor) {
  18929. tighten_body(self.body, compressor);
  18930. switch (self.body.length) {
  18931. case 1:
  18932. if (!compressor.has_directive("use strict")
  18933. && compressor.parent() instanceof AST_If
  18934. && can_be_extracted_from_if_block(self.body[0])
  18935. || can_be_evicted_from_block(self.body[0])) {
  18936. return self.body[0];
  18937. }
  18938. break;
  18939. case 0: return make_node(AST_EmptyStatement, self);
  18940. }
  18941. return self;
  18942. });
  18943. function opt_AST_Lambda(self, compressor) {
  18944. tighten_body(self.body, compressor);
  18945. if (compressor.option("side_effects")
  18946. && self.body.length == 1
  18947. && self.body[0] === compressor.has_directive("use strict")) {
  18948. self.body.length = 0;
  18949. }
  18950. return self;
  18951. }
  18952. def_optimize(AST_Lambda, opt_AST_Lambda);
  18953. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  18954. var self = this;
  18955. if (compressor.has_directive("use asm")) return self;
  18956. var hoist_funs = compressor.option("hoist_funs");
  18957. var hoist_vars = compressor.option("hoist_vars");
  18958. if (hoist_funs || hoist_vars) {
  18959. var dirs = [];
  18960. var hoisted = [];
  18961. var vars = new Map(), vars_found = 0, var_decl = 0;
  18962. // let's count var_decl first, we seem to waste a lot of
  18963. // space if we hoist `var` when there's only one.
  18964. walk(self, node => {
  18965. if (node instanceof AST_Scope && node !== self)
  18966. return true;
  18967. if (node instanceof AST_Var) {
  18968. ++var_decl;
  18969. return true;
  18970. }
  18971. });
  18972. hoist_vars = hoist_vars && var_decl > 1;
  18973. var tt = new TreeTransformer(
  18974. function before(node) {
  18975. if (node !== self) {
  18976. if (node instanceof AST_Directive) {
  18977. dirs.push(node);
  18978. return make_node(AST_EmptyStatement, node);
  18979. }
  18980. if (hoist_funs && node instanceof AST_Defun
  18981. && !(tt.parent() instanceof AST_Export)
  18982. && tt.parent() === self) {
  18983. hoisted.push(node);
  18984. return make_node(AST_EmptyStatement, node);
  18985. }
  18986. if (
  18987. hoist_vars
  18988. && node instanceof AST_Var
  18989. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  18990. ) {
  18991. node.definitions.forEach(function(def) {
  18992. vars.set(def.name.name, def);
  18993. ++vars_found;
  18994. });
  18995. var seq = node.to_assignments(compressor);
  18996. var p = tt.parent();
  18997. if (p instanceof AST_ForIn && p.init === node) {
  18998. if (seq == null) {
  18999. var def = node.definitions[0].name;
  19000. return make_node(AST_SymbolRef, def, def);
  19001. }
  19002. return seq;
  19003. }
  19004. if (p instanceof AST_For && p.init === node) {
  19005. return seq;
  19006. }
  19007. if (!seq) return make_node(AST_EmptyStatement, node);
  19008. return make_node(AST_SimpleStatement, node, {
  19009. body: seq
  19010. });
  19011. }
  19012. if (node instanceof AST_Scope)
  19013. return node; // to avoid descending in nested scopes
  19014. }
  19015. }
  19016. );
  19017. self = self.transform(tt);
  19018. if (vars_found > 0) {
  19019. // collect only vars which don't show up in self's arguments list
  19020. var defs = [];
  19021. const is_lambda = self instanceof AST_Lambda;
  19022. const args_as_names = is_lambda ? self.args_as_names() : null;
  19023. vars.forEach((def, name) => {
  19024. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  19025. vars.delete(name);
  19026. } else {
  19027. def = def.clone();
  19028. def.value = null;
  19029. defs.push(def);
  19030. vars.set(name, def);
  19031. }
  19032. });
  19033. if (defs.length > 0) {
  19034. // try to merge in assignments
  19035. for (var i = 0; i < self.body.length;) {
  19036. if (self.body[i] instanceof AST_SimpleStatement) {
  19037. var expr = self.body[i].body, sym, assign;
  19038. if (expr instanceof AST_Assign
  19039. && expr.operator == "="
  19040. && (sym = expr.left) instanceof AST_Symbol
  19041. && vars.has(sym.name)
  19042. ) {
  19043. var def = vars.get(sym.name);
  19044. if (def.value) break;
  19045. def.value = expr.right;
  19046. remove(defs, def);
  19047. defs.push(def);
  19048. self.body.splice(i, 1);
  19049. continue;
  19050. }
  19051. if (expr instanceof AST_Sequence
  19052. && (assign = expr.expressions[0]) instanceof AST_Assign
  19053. && assign.operator == "="
  19054. && (sym = assign.left) instanceof AST_Symbol
  19055. && vars.has(sym.name)
  19056. ) {
  19057. var def = vars.get(sym.name);
  19058. if (def.value) break;
  19059. def.value = assign.right;
  19060. remove(defs, def);
  19061. defs.push(def);
  19062. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  19063. continue;
  19064. }
  19065. }
  19066. if (self.body[i] instanceof AST_EmptyStatement) {
  19067. self.body.splice(i, 1);
  19068. continue;
  19069. }
  19070. if (self.body[i] instanceof AST_BlockStatement) {
  19071. self.body.splice(i, 1, ...self.body[i].body);
  19072. continue;
  19073. }
  19074. break;
  19075. }
  19076. defs = make_node(AST_Var, self, {
  19077. definitions: defs
  19078. });
  19079. hoisted.push(defs);
  19080. }
  19081. }
  19082. self.body = dirs.concat(hoisted, self.body);
  19083. }
  19084. return self;
  19085. });
  19086. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  19087. var self = this;
  19088. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  19089. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  19090. var defs_by_id = new Map();
  19091. var hoister = new TreeTransformer(function(node, descend) {
  19092. if (node instanceof AST_VarDef) {
  19093. const sym = node.name;
  19094. let def;
  19095. let value;
  19096. if (sym.scope === self
  19097. && !(sym instanceof AST_SymbolUsing)
  19098. && (def = sym.definition()).escaped != 1
  19099. && !def.assignments
  19100. && !def.direct_access
  19101. && !def.single_use
  19102. && !compressor.exposed(def)
  19103. && !top_retain(def)
  19104. && (value = sym.fixed_value()) === node.value
  19105. && value instanceof AST_Object
  19106. && !value.properties.some(prop =>
  19107. prop instanceof AST_Expansion || prop.computed_key()
  19108. )
  19109. ) {
  19110. descend(node, this);
  19111. const defs = new Map();
  19112. const assignments = [];
  19113. value.properties.forEach(({ key, value }) => {
  19114. const scope = hoister.find_scope();
  19115. const symbol = self.create_symbol(sym.CTOR, {
  19116. source: sym,
  19117. scope,
  19118. conflict_scopes: new Set([
  19119. scope,
  19120. ...sym.definition().references.map(ref => ref.scope)
  19121. ]),
  19122. tentative_name: sym.name + "_" + key
  19123. });
  19124. defs.set(String(key), symbol.definition());
  19125. assignments.push(make_node(AST_VarDef, node, {
  19126. name: symbol,
  19127. value
  19128. }));
  19129. });
  19130. defs_by_id.set(def.id, defs);
  19131. return MAP.splice(assignments);
  19132. }
  19133. } else if (node instanceof AST_PropAccess
  19134. && node.expression instanceof AST_SymbolRef
  19135. ) {
  19136. const defs = defs_by_id.get(node.expression.definition().id);
  19137. if (defs) {
  19138. const def = defs.get(String(get_simple_key(node.property)));
  19139. const sym = make_node(AST_SymbolRef, node, {
  19140. name: def.name,
  19141. scope: node.expression.scope,
  19142. thedef: def
  19143. });
  19144. sym.reference({});
  19145. return sym;
  19146. }
  19147. }
  19148. });
  19149. return self.transform(hoister);
  19150. });
  19151. def_optimize(AST_SimpleStatement, function(self, compressor) {
  19152. if (compressor.option("side_effects")) {
  19153. var body = self.body;
  19154. var node = body.drop_side_effect_free(compressor, true);
  19155. if (!node) {
  19156. return make_node(AST_EmptyStatement, self);
  19157. }
  19158. if (node !== body) {
  19159. return make_node(AST_SimpleStatement, self, { body: node });
  19160. }
  19161. }
  19162. return self;
  19163. });
  19164. def_optimize(AST_While, function(self, compressor) {
  19165. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  19166. });
  19167. def_optimize(AST_Do, function(self, compressor) {
  19168. if (!compressor.option("loops")) return self;
  19169. var cond = self.condition.tail_node().evaluate(compressor);
  19170. if (!(cond instanceof AST_Node)) {
  19171. if (cond) return make_node(AST_For, self, {
  19172. body: make_node(AST_BlockStatement, self.body, {
  19173. body: [
  19174. self.body,
  19175. make_node(AST_SimpleStatement, self.condition, {
  19176. body: self.condition
  19177. })
  19178. ]
  19179. })
  19180. }).optimize(compressor);
  19181. if (!has_break_or_continue(self, compressor.parent())) {
  19182. return make_node(AST_BlockStatement, self.body, {
  19183. body: [
  19184. self.body,
  19185. make_node(AST_SimpleStatement, self.condition, {
  19186. body: self.condition
  19187. })
  19188. ]
  19189. }).optimize(compressor);
  19190. }
  19191. }
  19192. return self;
  19193. });
  19194. function if_break_in_loop(self, compressor) {
  19195. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  19196. if (compressor.option("dead_code") && is_break(first)) {
  19197. var body = [];
  19198. if (self.init instanceof AST_Statement) {
  19199. body.push(self.init);
  19200. } else if (self.init) {
  19201. body.push(make_node(AST_SimpleStatement, self.init, {
  19202. body: self.init
  19203. }));
  19204. }
  19205. if (self.condition) {
  19206. body.push(make_node(AST_SimpleStatement, self.condition, {
  19207. body: self.condition
  19208. }));
  19209. }
  19210. extract_from_unreachable_code(compressor, self.body, body);
  19211. return make_node(AST_BlockStatement, self, {
  19212. body: body
  19213. });
  19214. }
  19215. if (first instanceof AST_If) {
  19216. if (is_break(first.body)) {
  19217. if (self.condition) {
  19218. self.condition = make_node(AST_Binary, self.condition, {
  19219. left: self.condition,
  19220. operator: "&&",
  19221. right: first.condition.negate(compressor),
  19222. });
  19223. } else {
  19224. self.condition = first.condition.negate(compressor);
  19225. }
  19226. drop_it(first.alternative);
  19227. } else if (is_break(first.alternative)) {
  19228. if (self.condition) {
  19229. self.condition = make_node(AST_Binary, self.condition, {
  19230. left: self.condition,
  19231. operator: "&&",
  19232. right: first.condition,
  19233. });
  19234. } else {
  19235. self.condition = first.condition;
  19236. }
  19237. drop_it(first.body);
  19238. }
  19239. }
  19240. return self;
  19241. function is_break(node) {
  19242. return node instanceof AST_Break
  19243. && compressor.loopcontrol_target(node) === compressor.self();
  19244. }
  19245. function drop_it(rest) {
  19246. rest = as_statement_array(rest);
  19247. if (self.body instanceof AST_BlockStatement) {
  19248. self.body = self.body.clone();
  19249. self.body.body = rest.concat(self.body.body.slice(1));
  19250. self.body = self.body.transform(compressor);
  19251. } else {
  19252. self.body = make_node(AST_BlockStatement, self.body, {
  19253. body: rest
  19254. }).transform(compressor);
  19255. }
  19256. self = if_break_in_loop(self, compressor);
  19257. }
  19258. }
  19259. def_optimize(AST_For, function(self, compressor) {
  19260. if (!compressor.option("loops")) return self;
  19261. if (compressor.option("side_effects") && self.init) {
  19262. self.init = self.init.drop_side_effect_free(compressor);
  19263. }
  19264. if (self.condition) {
  19265. var cond = self.condition.evaluate(compressor);
  19266. if (!(cond instanceof AST_Node)) {
  19267. if (cond) self.condition = null;
  19268. else if (!compressor.option("dead_code")) {
  19269. var orig = self.condition;
  19270. self.condition = make_node_from_constant(cond, self.condition);
  19271. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  19272. }
  19273. }
  19274. if (compressor.option("dead_code")) {
  19275. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  19276. if (!cond) {
  19277. var body = [];
  19278. extract_from_unreachable_code(compressor, self.body, body);
  19279. if (self.init instanceof AST_Statement) {
  19280. body.push(self.init);
  19281. } else if (self.init) {
  19282. body.push(make_node(AST_SimpleStatement, self.init, {
  19283. body: self.init
  19284. }));
  19285. }
  19286. body.push(make_node(AST_SimpleStatement, self.condition, {
  19287. body: self.condition
  19288. }));
  19289. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  19290. }
  19291. }
  19292. }
  19293. return if_break_in_loop(self, compressor);
  19294. });
  19295. def_optimize(AST_If, function(self, compressor) {
  19296. if (is_empty(self.alternative)) self.alternative = null;
  19297. if (!compressor.option("conditionals")) return self;
  19298. // if condition can be statically determined, drop
  19299. // one of the blocks. note, statically determined implies
  19300. // “has no side effects”; also it doesn't work for cases like
  19301. // `x && true`, though it probably should.
  19302. var cond = self.condition.evaluate(compressor);
  19303. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  19304. var orig = self.condition;
  19305. self.condition = make_node_from_constant(cond, orig);
  19306. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  19307. }
  19308. if (compressor.option("dead_code")) {
  19309. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  19310. if (!cond) {
  19311. var body = [];
  19312. extract_from_unreachable_code(compressor, self.body, body);
  19313. body.push(make_node(AST_SimpleStatement, self.condition, {
  19314. body: self.condition
  19315. }));
  19316. if (self.alternative) body.push(self.alternative);
  19317. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  19318. } else if (!(cond instanceof AST_Node)) {
  19319. var body = [];
  19320. body.push(make_node(AST_SimpleStatement, self.condition, {
  19321. body: self.condition
  19322. }));
  19323. body.push(self.body);
  19324. if (self.alternative) {
  19325. extract_from_unreachable_code(compressor, self.alternative, body);
  19326. }
  19327. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  19328. }
  19329. }
  19330. var negated = self.condition.negate(compressor);
  19331. var self_condition_length = self.condition.size();
  19332. var negated_length = negated.size();
  19333. var negated_is_best = negated_length < self_condition_length;
  19334. if (self.alternative && negated_is_best) {
  19335. negated_is_best = false; // because we already do the switch here.
  19336. // no need to swap values of self_condition_length and negated_length
  19337. // here because they are only used in an equality comparison later on.
  19338. self.condition = negated;
  19339. var tmp = self.body;
  19340. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  19341. self.alternative = tmp;
  19342. }
  19343. if (is_empty(self.body) && is_empty(self.alternative)) {
  19344. return make_node(AST_SimpleStatement, self.condition, {
  19345. body: self.condition.clone()
  19346. }).optimize(compressor);
  19347. }
  19348. if (self.body instanceof AST_SimpleStatement
  19349. && self.alternative instanceof AST_SimpleStatement) {
  19350. return make_node(AST_SimpleStatement, self, {
  19351. body: make_node(AST_Conditional, self, {
  19352. condition : self.condition,
  19353. consequent : self.body.body,
  19354. alternative : self.alternative.body
  19355. })
  19356. }).optimize(compressor);
  19357. }
  19358. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  19359. if (self_condition_length === negated_length && !negated_is_best
  19360. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  19361. // although the code length of self.condition and negated are the same,
  19362. // negated does not require additional surrounding parentheses.
  19363. // see https://github.com/mishoo/UglifyJS2/issues/979
  19364. negated_is_best = true;
  19365. }
  19366. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  19367. body: make_node(AST_Binary, self, {
  19368. operator : "||",
  19369. left : negated,
  19370. right : self.body.body
  19371. })
  19372. }).optimize(compressor);
  19373. return make_node(AST_SimpleStatement, self, {
  19374. body: make_node(AST_Binary, self, {
  19375. operator : "&&",
  19376. left : self.condition,
  19377. right : self.body.body
  19378. })
  19379. }).optimize(compressor);
  19380. }
  19381. if (self.body instanceof AST_EmptyStatement
  19382. && self.alternative instanceof AST_SimpleStatement) {
  19383. return make_node(AST_SimpleStatement, self, {
  19384. body: make_node(AST_Binary, self, {
  19385. operator : "||",
  19386. left : self.condition,
  19387. right : self.alternative.body
  19388. })
  19389. }).optimize(compressor);
  19390. }
  19391. if (self.body instanceof AST_Exit
  19392. && self.alternative instanceof AST_Exit
  19393. && self.body.TYPE == self.alternative.TYPE) {
  19394. return make_node(self.body.CTOR, self, {
  19395. value: make_node(AST_Conditional, self, {
  19396. condition : self.condition,
  19397. consequent : self.body.value || make_void_0(self.body),
  19398. alternative : self.alternative.value || make_void_0(self.alternative),
  19399. }).transform(compressor)
  19400. }).optimize(compressor);
  19401. }
  19402. if (self.body instanceof AST_If
  19403. && !self.body.alternative
  19404. && !self.alternative) {
  19405. self = make_node(AST_If, self, {
  19406. condition: make_node(AST_Binary, self.condition, {
  19407. operator: "&&",
  19408. left: self.condition,
  19409. right: self.body.condition
  19410. }),
  19411. body: self.body.body,
  19412. alternative: null
  19413. });
  19414. }
  19415. if (aborts(self.body)) {
  19416. if (self.alternative) {
  19417. var alt = self.alternative;
  19418. self.alternative = null;
  19419. return make_node(AST_BlockStatement, self, {
  19420. body: [ self, alt ]
  19421. }).optimize(compressor);
  19422. }
  19423. }
  19424. if (aborts(self.alternative)) {
  19425. var body = self.body;
  19426. self.body = self.alternative;
  19427. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  19428. self.alternative = null;
  19429. return make_node(AST_BlockStatement, self, {
  19430. body: [ self, body ]
  19431. }).optimize(compressor);
  19432. }
  19433. return self;
  19434. });
  19435. def_optimize(AST_Switch, function(self, compressor) {
  19436. if (!compressor.option("switches")) return self;
  19437. var branch;
  19438. var value = self.expression.evaluate(compressor);
  19439. if (!(value instanceof AST_Node)) {
  19440. var orig = self.expression;
  19441. self.expression = make_node_from_constant(value, orig);
  19442. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  19443. }
  19444. if (!compressor.option("dead_code")) return self;
  19445. if (value instanceof AST_Node) {
  19446. value = self.expression.tail_node().evaluate(compressor);
  19447. }
  19448. var decl = [];
  19449. var body = [];
  19450. var default_branch;
  19451. var exact_match;
  19452. // - compress self.body into `body`
  19453. // - find and deduplicate default branch
  19454. // - find the exact match (`case 1234` inside `switch(1234)`)
  19455. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  19456. branch = self.body[i];
  19457. if (branch instanceof AST_Default) {
  19458. if (!default_branch) {
  19459. default_branch = branch;
  19460. } else {
  19461. eliminate_branch(branch, body[body.length - 1]);
  19462. }
  19463. } else if (!(value instanceof AST_Node)) {
  19464. var exp = branch.expression.evaluate(compressor);
  19465. if (!(exp instanceof AST_Node) && exp !== value) {
  19466. eliminate_branch(branch, body[body.length - 1]);
  19467. continue;
  19468. }
  19469. if (exp instanceof AST_Node && !exp.has_side_effects(compressor)) {
  19470. exp = branch.expression.tail_node().evaluate(compressor);
  19471. }
  19472. if (exp === value) {
  19473. exact_match = branch;
  19474. if (default_branch) {
  19475. var default_index = body.indexOf(default_branch);
  19476. body.splice(default_index, 1);
  19477. eliminate_branch(default_branch, body[default_index - 1]);
  19478. default_branch = null;
  19479. }
  19480. }
  19481. }
  19482. body.push(branch);
  19483. }
  19484. // i < len if we found an exact_match. eliminate the rest
  19485. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  19486. self.body = body;
  19487. let default_or_exact = default_branch || exact_match;
  19488. default_branch = null;
  19489. exact_match = null;
  19490. // group equivalent branches so they will be located next to each other,
  19491. // that way the next micro-optimization will merge them.
  19492. // ** bail micro-optimization if not a simple switch case with breaks
  19493. if (body.every((branch, i) =>
  19494. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  19495. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  19496. ) {
  19497. for (let i = 0; i < body.length; i++) {
  19498. const branch = body[i];
  19499. for (let j = i + 1; j < body.length; j++) {
  19500. const next = body[j];
  19501. if (next.body.length === 0) continue;
  19502. const last_branch = j === (body.length - 1);
  19503. const equivalentBranch = branches_equivalent(next, branch, false);
  19504. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  19505. if (!equivalentBranch && last_branch) {
  19506. next.body.push(make_node(AST_Break));
  19507. }
  19508. // let's find previous siblings with inert fallthrough...
  19509. let x = j - 1;
  19510. let fallthroughDepth = 0;
  19511. while (x > i) {
  19512. if (is_inert_body(body[x--])) {
  19513. fallthroughDepth++;
  19514. } else {
  19515. break;
  19516. }
  19517. }
  19518. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  19519. body.splice(i + 1, 0, ...plucked);
  19520. i += plucked.length;
  19521. }
  19522. }
  19523. }
  19524. }
  19525. // merge equivalent branches in a row
  19526. for (let i = 0; i < body.length; i++) {
  19527. let branch = body[i];
  19528. if (branch.body.length === 0) continue;
  19529. if (!aborts(branch)) continue;
  19530. for (let j = i + 1; j < body.length; i++, j++) {
  19531. let next = body[j];
  19532. if (next.body.length === 0) continue;
  19533. if (
  19534. branches_equivalent(next, branch, false)
  19535. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  19536. ) {
  19537. branch.body = [];
  19538. branch = next;
  19539. continue;
  19540. }
  19541. break;
  19542. }
  19543. }
  19544. // Prune any empty branches at the end of the switch statement.
  19545. {
  19546. let i = body.length - 1;
  19547. for (; i >= 0; i--) {
  19548. let bbody = body[i].body;
  19549. while (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  19550. if (!is_inert_body(body[i])) break;
  19551. }
  19552. // i now points to the index of a branch that contains a body. By incrementing, it's
  19553. // pointing to the first branch that's empty.
  19554. i++;
  19555. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  19556. // The default behavior is to do nothing. We can take advantage of that to
  19557. // remove all case expressions that are side-effect free that also do
  19558. // nothing, since they'll default to doing nothing. But we can't remove any
  19559. // case expressions before one that would side-effect, since they may cause
  19560. // the side-effect to be skipped.
  19561. for (let j = body.length - 1; j >= i; j--) {
  19562. let branch = body[j];
  19563. if (branch === default_or_exact) {
  19564. default_or_exact = null;
  19565. eliminate_branch(body.pop());
  19566. } else if (!branch.expression.has_side_effects(compressor)) {
  19567. eliminate_branch(body.pop());
  19568. } else {
  19569. break;
  19570. }
  19571. }
  19572. }
  19573. }
  19574. // Prune side-effect free branches that fall into default.
  19575. DEFAULT: if (default_or_exact) {
  19576. let default_index = body.indexOf(default_or_exact);
  19577. let default_body_index = default_index;
  19578. for (; default_body_index < body.length - 1; default_body_index++) {
  19579. if (!is_inert_body(body[default_body_index])) break;
  19580. }
  19581. if (default_body_index < body.length - 1) {
  19582. break DEFAULT;
  19583. }
  19584. let side_effect_index = body.length - 1;
  19585. for (; side_effect_index >= 0; side_effect_index--) {
  19586. let branch = body[side_effect_index];
  19587. if (branch === default_or_exact) continue;
  19588. if (branch.expression.has_side_effects(compressor)) break;
  19589. }
  19590. // If the default behavior comes after any side-effect case expressions,
  19591. // then we can fold all side-effect free cases into the default branch.
  19592. // If the side-effect case is after the default, then any side-effect
  19593. // free cases could prevent the side-effect from occurring.
  19594. if (default_body_index > side_effect_index) {
  19595. let prev_body_index = default_index - 1;
  19596. for (; prev_body_index >= 0; prev_body_index--) {
  19597. if (!is_inert_body(body[prev_body_index])) break;
  19598. }
  19599. let before = Math.max(side_effect_index, prev_body_index) + 1;
  19600. let after = default_index;
  19601. if (side_effect_index > default_index) {
  19602. // If the default falls into the same body as a side-effect
  19603. // case, then we need preserve that case and only prune the
  19604. // cases after it.
  19605. after = side_effect_index;
  19606. body[side_effect_index].body = body[default_body_index].body;
  19607. } else {
  19608. // The default will be the last branch.
  19609. default_or_exact.body = body[default_body_index].body;
  19610. }
  19611. // Prune everything after the default (or last side-effect case)
  19612. // until the next case with a body.
  19613. body.splice(after + 1, default_body_index - after);
  19614. // Prune everything before the default that falls into it.
  19615. body.splice(before, default_index - before);
  19616. }
  19617. }
  19618. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  19619. DEFAULT: if (default_or_exact) {
  19620. let i = body.findIndex(branch => !is_inert_body(branch));
  19621. let caseBody;
  19622. // `i` is equal to one of the following:
  19623. // - `-1`, there is no body in the switch statement.
  19624. // - `body.length - 1`, all cases fall into the same body.
  19625. // - anything else, there are multiple bodies in the switch.
  19626. if (i === body.length - 1) {
  19627. // All cases fall into the case body.
  19628. let branch = body[i];
  19629. if (has_nested_break(self)) break DEFAULT;
  19630. // This is the last case body, and we've already pruned any breaks, so it's
  19631. // safe to hoist.
  19632. caseBody = make_node(AST_BlockStatement, branch, {
  19633. body: branch.body
  19634. });
  19635. branch.body = [];
  19636. } else if (i !== -1) {
  19637. // If there are multiple bodies, then we cannot optimize anything.
  19638. break DEFAULT;
  19639. }
  19640. let sideEffect = body.find(
  19641. branch => branch !== default_or_exact && branch.expression.has_side_effects(compressor)
  19642. );
  19643. // If no cases cause a side-effect, we can eliminate the switch entirely.
  19644. if (!sideEffect) {
  19645. return make_node(AST_BlockStatement, self, {
  19646. body: decl.concat(
  19647. statement(self.expression),
  19648. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  19649. caseBody || []
  19650. )
  19651. }).optimize(compressor);
  19652. }
  19653. // If we're this far, either there was no body or all cases fell into the same body.
  19654. // If there was no body, then we don't need a default branch (because the default is
  19655. // do nothing). If there was a body, we'll extract it to after the switch, so the
  19656. // switch's new default is to do nothing and we can still prune it.
  19657. const default_index = body.indexOf(default_or_exact);
  19658. body.splice(default_index, 1);
  19659. default_or_exact = null;
  19660. if (caseBody) {
  19661. // Recurse into switch statement one more time so that we can append the case body
  19662. // outside of the switch. This recursion will only happen once since we've pruned
  19663. // the default case.
  19664. return make_node(AST_BlockStatement, self, {
  19665. body: decl.concat(self, caseBody)
  19666. }).optimize(compressor);
  19667. }
  19668. // If we fall here, there is a default branch somewhere, there are no case bodies,
  19669. // and there's a side-effect somewhere. Just let the below paths take care of it.
  19670. }
  19671. // Reintegrate `decl` (var statements)
  19672. if (body.length > 0) {
  19673. body[0].body = decl.concat(body[0].body);
  19674. }
  19675. if (body.length == 0) {
  19676. return make_node(AST_BlockStatement, self, {
  19677. body: decl.concat(statement(self.expression))
  19678. }).optimize(compressor);
  19679. }
  19680. if (body.length == 1 && !has_nested_break(self)) {
  19681. // This is the last case body, and we've already pruned any breaks, so it's
  19682. // safe to hoist.
  19683. let branch = body[0];
  19684. return make_node(AST_If, self, {
  19685. condition: make_node(AST_Binary, self, {
  19686. operator: "===",
  19687. left: self.expression,
  19688. right: branch.expression,
  19689. }),
  19690. body: make_node(AST_BlockStatement, branch, {
  19691. body: branch.body
  19692. }),
  19693. alternative: null
  19694. }).optimize(compressor);
  19695. }
  19696. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  19697. let branch = body[0] === default_or_exact ? body[1] : body[0];
  19698. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  19699. if (aborts(body[0])) {
  19700. // Only the first branch body could have a break (at the last statement)
  19701. let first = body[0];
  19702. if (is_break(first.body[first.body.length - 1], compressor)) {
  19703. first.body.pop();
  19704. }
  19705. return make_node(AST_If, self, {
  19706. condition: make_node(AST_Binary, self, {
  19707. operator: "===",
  19708. left: self.expression,
  19709. right: branch.expression,
  19710. }),
  19711. body: make_node(AST_BlockStatement, branch, {
  19712. body: branch.body
  19713. }),
  19714. alternative: make_node(AST_BlockStatement, default_or_exact, {
  19715. body: [].concat(
  19716. exact_exp || [],
  19717. default_or_exact.body
  19718. )
  19719. })
  19720. }).optimize(compressor);
  19721. }
  19722. let operator = "===";
  19723. let consequent = make_node(AST_BlockStatement, branch, {
  19724. body: branch.body,
  19725. });
  19726. let always = make_node(AST_BlockStatement, default_or_exact, {
  19727. body: [].concat(
  19728. exact_exp || [],
  19729. default_or_exact.body
  19730. )
  19731. });
  19732. if (body[0] === default_or_exact) {
  19733. operator = "!==";
  19734. let tmp = always;
  19735. always = consequent;
  19736. consequent = tmp;
  19737. }
  19738. return make_node(AST_BlockStatement, self, {
  19739. body: [
  19740. make_node(AST_If, self, {
  19741. condition: make_node(AST_Binary, self, {
  19742. operator: operator,
  19743. left: self.expression,
  19744. right: branch.expression,
  19745. }),
  19746. body: consequent,
  19747. alternative: null,
  19748. }),
  19749. always,
  19750. ],
  19751. }).optimize(compressor);
  19752. }
  19753. return self;
  19754. function eliminate_branch(branch, prev) {
  19755. if (prev && !aborts(prev)) {
  19756. prev.body = prev.body.concat(branch.body);
  19757. } else {
  19758. extract_from_unreachable_code(compressor, branch, decl);
  19759. }
  19760. }
  19761. function branches_equivalent(branch, prev, insertBreak) {
  19762. let bbody = branch.body;
  19763. let pbody = prev.body;
  19764. if (insertBreak) {
  19765. bbody = bbody.concat(make_node(AST_Break));
  19766. }
  19767. if (bbody.length !== pbody.length) return false;
  19768. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  19769. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  19770. return bblock.equivalent_to(pblock);
  19771. }
  19772. function statement(body) {
  19773. return make_node(AST_SimpleStatement, body, { body });
  19774. }
  19775. function has_nested_break(root) {
  19776. let has_break = false;
  19777. let tw = new TreeWalker(node => {
  19778. if (has_break) return true;
  19779. if (node instanceof AST_Lambda) return true;
  19780. if (node instanceof AST_SimpleStatement) return true;
  19781. if (!is_break(node, tw)) return;
  19782. let parent = tw.parent();
  19783. if (
  19784. parent instanceof AST_SwitchBranch
  19785. && parent.body[parent.body.length - 1] === node
  19786. ) {
  19787. return;
  19788. }
  19789. has_break = true;
  19790. });
  19791. root.walk(tw);
  19792. return has_break;
  19793. }
  19794. function is_break(node, stack) {
  19795. return node instanceof AST_Break
  19796. && stack.loopcontrol_target(node) === self;
  19797. }
  19798. function is_inert_body(branch) {
  19799. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  19800. body: branch.body
  19801. }).has_side_effects(compressor);
  19802. }
  19803. });
  19804. def_optimize(AST_Try, function(self, compressor) {
  19805. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  19806. if (compressor.option("dead_code") && self.body.body.every(is_empty)) {
  19807. var body = [];
  19808. if (self.bcatch) {
  19809. extract_from_unreachable_code(compressor, self.bcatch, body);
  19810. }
  19811. if (self.bfinally) body.push(...self.bfinally.body);
  19812. return make_node(AST_BlockStatement, self, {
  19813. body: body
  19814. }).optimize(compressor);
  19815. }
  19816. return self;
  19817. });
  19818. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  19819. var reduce_vars = compressor.option("reduce_vars");
  19820. var assignments = [];
  19821. for (const def of this.definitions) {
  19822. if (def.value) {
  19823. var name = make_node(AST_SymbolRef, def.name, def.name);
  19824. assignments.push(make_node(AST_Assign, def, {
  19825. operator : "=",
  19826. logical: false,
  19827. left : name,
  19828. right : def.value
  19829. }));
  19830. if (reduce_vars) name.definition().fixed = false;
  19831. }
  19832. const thedef = def.name.definition();
  19833. thedef.eliminated++;
  19834. thedef.replaced--;
  19835. }
  19836. if (assignments.length == 0) return null;
  19837. return make_sequence(this, assignments);
  19838. });
  19839. def_optimize(AST_Definitions, function(self) {
  19840. if (self.definitions.length == 0) {
  19841. return make_node(AST_EmptyStatement, self);
  19842. }
  19843. return self;
  19844. });
  19845. def_optimize(AST_VarDef, function(self, compressor) {
  19846. if (
  19847. self.name instanceof AST_SymbolLet
  19848. && self.value != null
  19849. && is_undefined(self.value, compressor)
  19850. ) {
  19851. self.value = null;
  19852. }
  19853. return self;
  19854. });
  19855. def_optimize(AST_Import, function(self) {
  19856. return self;
  19857. });
  19858. def_optimize(AST_Call, function(self, compressor) {
  19859. var exp = self.expression;
  19860. var fn = exp;
  19861. inline_array_like_spread(self.args);
  19862. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  19863. if (compressor.option("reduce_vars") && fn instanceof AST_SymbolRef) {
  19864. fn = fn.fixed_value();
  19865. }
  19866. var is_func = fn instanceof AST_Lambda;
  19867. if (is_func && fn.pinned()) return self;
  19868. if (compressor.option("unused")
  19869. && simple_args
  19870. && is_func
  19871. && !fn.uses_arguments) {
  19872. var pos = 0, last = 0;
  19873. for (var i = 0, len = self.args.length; i < len; i++) {
  19874. if (fn.argnames[i] instanceof AST_Expansion) {
  19875. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  19876. var node = self.args[i++].drop_side_effect_free(compressor);
  19877. if (node) {
  19878. self.args[pos++] = node;
  19879. }
  19880. } else while (i < len) {
  19881. self.args[pos++] = self.args[i++];
  19882. }
  19883. last = pos;
  19884. break;
  19885. }
  19886. var trim = i >= fn.argnames.length;
  19887. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  19888. var node = self.args[i].drop_side_effect_free(compressor);
  19889. if (node) {
  19890. self.args[pos++] = node;
  19891. } else if (!trim) {
  19892. self.args[pos++] = make_node(AST_Number, self.args[i], {
  19893. value: 0
  19894. });
  19895. continue;
  19896. }
  19897. } else {
  19898. self.args[pos++] = self.args[i];
  19899. }
  19900. last = pos;
  19901. }
  19902. self.args.length = last;
  19903. }
  19904. if (
  19905. exp instanceof AST_Dot
  19906. && exp.expression instanceof AST_SymbolRef
  19907. && exp.expression.name === "console"
  19908. && exp.expression.definition().undeclared
  19909. && exp.property === "assert"
  19910. ) {
  19911. const condition = self.args[0];
  19912. if (condition) {
  19913. const value = condition.evaluate(compressor);
  19914. if (value === 1 || value === true) {
  19915. return make_void_0(self).optimize(compressor);
  19916. }
  19917. }
  19918. }
  19919. if (compressor.option("unsafe") && !exp.contains_optional()) {
  19920. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  19921. const [argument] = self.args;
  19922. if (argument instanceof AST_Array) {
  19923. return make_node(AST_Array, argument, {
  19924. elements: argument.elements
  19925. }).optimize(compressor);
  19926. }
  19927. }
  19928. if (is_undeclared_ref(exp)) switch (exp.name) {
  19929. case "Array":
  19930. if (self.args.length != 1) {
  19931. return make_node(AST_Array, self, {
  19932. elements: self.args
  19933. }).optimize(compressor);
  19934. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  19935. const elements = [];
  19936. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  19937. return new AST_Array({ elements });
  19938. }
  19939. break;
  19940. case "Object":
  19941. if (self.args.length == 0) {
  19942. return make_node(AST_Object, self, {
  19943. properties: []
  19944. });
  19945. }
  19946. break;
  19947. case "String":
  19948. if (self.args.length == 0) return make_node(AST_String, self, {
  19949. value: ""
  19950. });
  19951. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  19952. left: self.args[0],
  19953. operator: "+",
  19954. right: make_node(AST_String, self, { value: "" })
  19955. }).optimize(compressor);
  19956. break;
  19957. case "Number":
  19958. if (self.args.length == 0) return make_node(AST_Number, self, {
  19959. value: 0
  19960. });
  19961. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  19962. return make_node(AST_UnaryPrefix, self, {
  19963. expression: self.args[0],
  19964. operator: "+"
  19965. }).optimize(compressor);
  19966. }
  19967. break;
  19968. case "Symbol":
  19969. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  19970. self.args.length = 0;
  19971. break;
  19972. case "Boolean":
  19973. if (self.args.length == 0) return make_node(AST_False, self);
  19974. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  19975. expression: make_node(AST_UnaryPrefix, self, {
  19976. expression: self.args[0],
  19977. operator: "!"
  19978. }),
  19979. operator: "!"
  19980. }).optimize(compressor);
  19981. break;
  19982. case "RegExp":
  19983. var params = [];
  19984. if (self.args.length >= 1
  19985. && self.args.length <= 2
  19986. && self.args.every((arg) => {
  19987. var value = arg.evaluate(compressor);
  19988. params.push(value);
  19989. return arg !== value;
  19990. })
  19991. && regexp_is_safe(params[0])
  19992. ) {
  19993. let [ source, flags ] = params;
  19994. source = regexp_source_fix(new RegExp(source).source);
  19995. const rx = make_node(AST_RegExp, self, {
  19996. value: { source, flags }
  19997. });
  19998. if (rx._eval(compressor) !== rx) {
  19999. return rx;
  20000. }
  20001. }
  20002. break;
  20003. } else if (exp instanceof AST_Dot) switch(exp.property) {
  20004. case "toString":
  20005. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  20006. return make_node(AST_Binary, self, {
  20007. left: make_node(AST_String, self, { value: "" }),
  20008. operator: "+",
  20009. right: exp.expression
  20010. }).optimize(compressor);
  20011. }
  20012. break;
  20013. case "join":
  20014. if (exp.expression instanceof AST_Array) EXIT: {
  20015. var separator;
  20016. if (self.args.length > 0) {
  20017. separator = self.args[0].evaluate(compressor);
  20018. if (separator === self.args[0]) break EXIT; // not a constant
  20019. }
  20020. var elements = [];
  20021. var consts = [];
  20022. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  20023. var el = exp.expression.elements[i];
  20024. if (el instanceof AST_Expansion) break EXIT;
  20025. var value = el.evaluate(compressor);
  20026. if (value !== el) {
  20027. consts.push(value);
  20028. } else {
  20029. if (consts.length > 0) {
  20030. elements.push(make_node(AST_String, self, {
  20031. value: consts.join(separator)
  20032. }));
  20033. consts.length = 0;
  20034. }
  20035. elements.push(el);
  20036. }
  20037. }
  20038. if (consts.length > 0) {
  20039. elements.push(make_node(AST_String, self, {
  20040. value: consts.join(separator)
  20041. }));
  20042. }
  20043. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  20044. if (elements.length == 1) {
  20045. if (elements[0].is_string(compressor)) {
  20046. return elements[0];
  20047. }
  20048. return make_node(AST_Binary, elements[0], {
  20049. operator : "+",
  20050. left : make_node(AST_String, self, { value: "" }),
  20051. right : elements[0]
  20052. });
  20053. }
  20054. if (separator == "") {
  20055. var first;
  20056. if (elements[0].is_string(compressor)
  20057. || elements[1].is_string(compressor)) {
  20058. first = elements.shift();
  20059. } else {
  20060. first = make_node(AST_String, self, { value: "" });
  20061. }
  20062. return elements.reduce(function(prev, el) {
  20063. return make_node(AST_Binary, el, {
  20064. operator : "+",
  20065. left : prev,
  20066. right : el
  20067. });
  20068. }, first).optimize(compressor);
  20069. }
  20070. // need this awkward cloning to not affect original element
  20071. // best_of will decide which one to get through.
  20072. var node = self.clone();
  20073. node.expression = node.expression.clone();
  20074. node.expression.expression = node.expression.expression.clone();
  20075. node.expression.expression.elements = elements;
  20076. return best_of(compressor, self, node);
  20077. }
  20078. break;
  20079. case "charAt":
  20080. if (exp.expression.is_string(compressor)) {
  20081. var arg = self.args[0];
  20082. var index = arg ? arg.evaluate(compressor) : 0;
  20083. if (index !== arg) {
  20084. return make_node(AST_Sub, exp, {
  20085. expression: exp.expression,
  20086. property: make_node_from_constant(index | 0, arg || exp)
  20087. }).optimize(compressor);
  20088. }
  20089. }
  20090. break;
  20091. case "apply":
  20092. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  20093. var args = self.args[1].elements.slice();
  20094. args.unshift(self.args[0]);
  20095. return make_node(AST_Call, self, {
  20096. expression: make_node(AST_Dot, exp, {
  20097. expression: exp.expression,
  20098. optional: false,
  20099. property: "call"
  20100. }),
  20101. args: args
  20102. }).optimize(compressor);
  20103. }
  20104. break;
  20105. case "call":
  20106. var func = exp.expression;
  20107. if (func instanceof AST_SymbolRef) {
  20108. func = func.fixed_value();
  20109. }
  20110. if (func instanceof AST_Lambda && !func.contains_this()) {
  20111. return (self.args.length ? make_sequence(this, [
  20112. self.args[0],
  20113. make_node(AST_Call, self, {
  20114. expression: exp.expression,
  20115. args: self.args.slice(1)
  20116. })
  20117. ]) : make_node(AST_Call, self, {
  20118. expression: exp.expression,
  20119. args: []
  20120. })).optimize(compressor);
  20121. }
  20122. break;
  20123. }
  20124. }
  20125. if (compressor.option("unsafe_Function")
  20126. && is_undeclared_ref(exp)
  20127. && exp.name == "Function") {
  20128. // new Function() => function(){}
  20129. if (self.args.length == 0) return make_empty_function(self).optimize(compressor);
  20130. if (self.args.every((x) => x instanceof AST_String)) {
  20131. // quite a corner-case, but we can handle it:
  20132. // https://github.com/mishoo/UglifyJS2/issues/203
  20133. // if the code argument is a constant, then we can minify it.
  20134. try {
  20135. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  20136. return arg.value;
  20137. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  20138. var ast = parse(code);
  20139. var mangle = compressor.mangle_options();
  20140. ast.figure_out_scope(mangle);
  20141. var comp = new Compressor(compressor.options, {
  20142. mangle_options: compressor._mangle_options
  20143. });
  20144. ast = ast.transform(comp);
  20145. ast.figure_out_scope(mangle);
  20146. ast.compute_char_frequency(mangle);
  20147. ast.mangle_names(mangle);
  20148. var fun;
  20149. walk(ast, node => {
  20150. if (is_func_expr(node)) {
  20151. fun = node;
  20152. return walk_abort;
  20153. }
  20154. });
  20155. var code = OutputStream();
  20156. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  20157. self.args = [
  20158. make_node(AST_String, self, {
  20159. value: fun.argnames.map(function(arg) {
  20160. return arg.print_to_string();
  20161. }).join(",")
  20162. }),
  20163. make_node(AST_String, self.args[self.args.length - 1], {
  20164. value: code.get().replace(/^{|}$/g, "")
  20165. })
  20166. ];
  20167. return self;
  20168. } catch (ex) {
  20169. if (!(ex instanceof JS_Parse_Error)) {
  20170. throw ex;
  20171. }
  20172. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  20173. }
  20174. }
  20175. }
  20176. return inline_into_call(self, compressor);
  20177. });
  20178. /** Does this node contain optional property access or optional call? */
  20179. AST_Node.DEFMETHOD("contains_optional", function() {
  20180. if (
  20181. this instanceof AST_PropAccess
  20182. || this instanceof AST_Call
  20183. || this instanceof AST_Chain
  20184. ) {
  20185. if (this.optional) {
  20186. return true;
  20187. } else {
  20188. return this.expression.contains_optional();
  20189. }
  20190. } else {
  20191. return false;
  20192. }
  20193. });
  20194. def_optimize(AST_New, function(self, compressor) {
  20195. if (
  20196. compressor.option("unsafe") &&
  20197. is_undeclared_ref(self.expression) &&
  20198. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  20199. ) return make_node(AST_Call, self, self).transform(compressor);
  20200. return self;
  20201. });
  20202. def_optimize(AST_Sequence, function(self, compressor) {
  20203. if (!compressor.option("side_effects")) return self;
  20204. var expressions = [];
  20205. filter_for_side_effects();
  20206. var end = expressions.length - 1;
  20207. trim_right_for_undefined();
  20208. if (end == 0) {
  20209. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  20210. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  20211. return self;
  20212. }
  20213. self.expressions = expressions;
  20214. return self;
  20215. function filter_for_side_effects() {
  20216. var first = first_in_statement(compressor);
  20217. var last = self.expressions.length - 1;
  20218. self.expressions.forEach(function(expr, index) {
  20219. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  20220. if (expr) {
  20221. merge_sequence(expressions, expr);
  20222. first = false;
  20223. }
  20224. });
  20225. }
  20226. function trim_right_for_undefined() {
  20227. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  20228. if (end < expressions.length - 1) {
  20229. expressions[end] = make_node(AST_UnaryPrefix, self, {
  20230. operator : "void",
  20231. expression : expressions[end]
  20232. });
  20233. expressions.length = end + 1;
  20234. }
  20235. }
  20236. });
  20237. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  20238. if (compressor.option("sequences")) {
  20239. if (this.expression instanceof AST_Sequence) {
  20240. var x = this.expression.expressions.slice();
  20241. var e = this.clone();
  20242. e.expression = x.pop();
  20243. x.push(e);
  20244. return make_sequence(this, x).optimize(compressor);
  20245. }
  20246. }
  20247. return this;
  20248. });
  20249. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  20250. return self.lift_sequences(compressor);
  20251. });
  20252. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  20253. var e = self.expression;
  20254. if (
  20255. self.operator == "delete" &&
  20256. !(
  20257. e instanceof AST_SymbolRef ||
  20258. e instanceof AST_PropAccess ||
  20259. e instanceof AST_Chain ||
  20260. is_identifier_atom(e)
  20261. )
  20262. ) {
  20263. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  20264. }
  20265. // Short-circuit common `void 0`
  20266. if (self.operator === "void" && e instanceof AST_Number && e.value === 0) {
  20267. return unsafe_undefined_ref(self, compressor) || self;
  20268. }
  20269. var seq = self.lift_sequences(compressor);
  20270. if (seq !== self) {
  20271. return seq;
  20272. }
  20273. if (compressor.option("side_effects") && self.operator == "void") {
  20274. e = e.drop_side_effect_free(compressor);
  20275. if (e) {
  20276. self.expression = e;
  20277. return self;
  20278. } else {
  20279. return make_void_0(self).optimize(compressor);
  20280. }
  20281. }
  20282. if (compressor.in_boolean_context()) {
  20283. switch (self.operator) {
  20284. case "!":
  20285. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  20286. // !!foo ==> foo, if we're in boolean context
  20287. return e.expression;
  20288. }
  20289. if (e instanceof AST_Binary) {
  20290. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  20291. }
  20292. break;
  20293. case "typeof":
  20294. // typeof always returns a non-empty string, thus it's
  20295. // always true in booleans
  20296. // And we don't need to check if it's undeclared, because in typeof, that's OK
  20297. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  20298. e,
  20299. make_node(AST_True, self)
  20300. ])).optimize(compressor);
  20301. }
  20302. }
  20303. if (self.operator == "-" && e instanceof AST_Infinity) {
  20304. e = e.transform(compressor);
  20305. }
  20306. if (e instanceof AST_Binary
  20307. && (self.operator == "+" || self.operator == "-")
  20308. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  20309. return make_node(AST_Binary, self, {
  20310. operator: e.operator,
  20311. left: make_node(AST_UnaryPrefix, e.left, {
  20312. operator: self.operator,
  20313. expression: e.left
  20314. }),
  20315. right: e.right
  20316. });
  20317. }
  20318. if (compressor.option("evaluate")) {
  20319. // ~~x => x (in 32-bit context)
  20320. // ~~{32 bit integer} => {32 bit integer}
  20321. if (
  20322. self.operator === "~"
  20323. && self.expression instanceof AST_UnaryPrefix
  20324. && self.expression.operator === "~"
  20325. && (compressor.in_32_bit_context(false) || self.expression.expression.is_32_bit_integer(compressor))
  20326. ) {
  20327. return self.expression.expression;
  20328. }
  20329. // ~(x ^ y) => x ^ ~y
  20330. if (
  20331. self.operator === "~"
  20332. && e instanceof AST_Binary
  20333. && e.operator === "^"
  20334. ) {
  20335. if (e.left instanceof AST_UnaryPrefix && e.left.operator === "~") {
  20336. // ~(~x ^ y) => x ^ y
  20337. e.left = e.left.bitwise_negate(compressor, true);
  20338. } else {
  20339. e.right = e.right.bitwise_negate(compressor, true);
  20340. }
  20341. return e;
  20342. }
  20343. }
  20344. if (
  20345. self.operator != "-"
  20346. // avoid infinite recursion of numerals
  20347. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)
  20348. ) {
  20349. var ev = self.evaluate(compressor);
  20350. if (ev !== self) {
  20351. ev = make_node_from_constant(ev, self).optimize(compressor);
  20352. return best_of(compressor, ev, self);
  20353. }
  20354. }
  20355. return self;
  20356. });
  20357. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  20358. if (compressor.option("sequences")) {
  20359. if (this.left instanceof AST_Sequence) {
  20360. var x = this.left.expressions.slice();
  20361. var e = this.clone();
  20362. e.left = x.pop();
  20363. x.push(e);
  20364. return make_sequence(this, x).optimize(compressor);
  20365. }
  20366. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  20367. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  20368. var x = this.right.expressions;
  20369. var last = x.length - 1;
  20370. for (var i = 0; i < last; i++) {
  20371. if (!assign && x[i].has_side_effects(compressor)) break;
  20372. }
  20373. if (i == last) {
  20374. x = x.slice();
  20375. var e = this.clone();
  20376. e.right = x.pop();
  20377. x.push(e);
  20378. return make_sequence(this, x).optimize(compressor);
  20379. } else if (i > 0) {
  20380. var e = this.clone();
  20381. e.right = make_sequence(this.right, x.slice(i));
  20382. x = x.slice(0, i);
  20383. x.push(e);
  20384. return make_sequence(this, x).optimize(compressor);
  20385. }
  20386. }
  20387. }
  20388. return this;
  20389. });
  20390. var commutativeOperators = makePredicate("== === != !== * & | ^");
  20391. function is_object(node) {
  20392. return node instanceof AST_Array
  20393. || node instanceof AST_Lambda
  20394. || node instanceof AST_Object
  20395. || node instanceof AST_Class;
  20396. }
  20397. def_optimize(AST_Binary, function(self, compressor) {
  20398. function reversible() {
  20399. return self.left.is_constant()
  20400. || self.right.is_constant()
  20401. || !self.left.has_side_effects(compressor)
  20402. && !self.right.has_side_effects(compressor);
  20403. }
  20404. function reverse(op) {
  20405. if (reversible()) {
  20406. if (op) self.operator = op;
  20407. var tmp = self.left;
  20408. self.left = self.right;
  20409. self.right = tmp;
  20410. }
  20411. }
  20412. if (compressor.option("lhs_constants") && commutativeOperators.has(self.operator)) {
  20413. if (self.right.is_constant()
  20414. && !self.left.is_constant()) {
  20415. // if right is a constant, whatever side effects the
  20416. // left side might have could not influence the
  20417. // result. hence, force switch.
  20418. if (!(self.left instanceof AST_Binary
  20419. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  20420. reverse();
  20421. }
  20422. }
  20423. }
  20424. self = self.lift_sequences(compressor);
  20425. if (compressor.option("comparisons")) switch (self.operator) {
  20426. case "===":
  20427. case "!==":
  20428. var is_strict_comparison = true;
  20429. if (
  20430. (self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  20431. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  20432. (self.left.is_bigint(compressor) && self.right.is_bigint(compressor)) ||
  20433. (self.left.is_boolean() && self.right.is_boolean()) ||
  20434. self.left.equivalent_to(self.right)
  20435. ) {
  20436. self.operator = self.operator.substr(0, 2);
  20437. }
  20438. // XXX: intentionally falling down to the next case
  20439. case "==":
  20440. case "!=":
  20441. // void 0 == x => null == x
  20442. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  20443. self.left = make_node(AST_Null, self.left);
  20444. // x == void 0 => x == null
  20445. } else if (!is_strict_comparison && is_undefined(self.right, compressor)) {
  20446. self.right = make_node(AST_Null, self.right);
  20447. } else if (compressor.option("typeofs")
  20448. // "undefined" == typeof x => undefined === x
  20449. && self.left instanceof AST_String
  20450. && self.left.value == "undefined"
  20451. && self.right instanceof AST_UnaryPrefix
  20452. && self.right.operator == "typeof") {
  20453. var expr = self.right.expression;
  20454. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  20455. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  20456. self.right = expr;
  20457. self.left = make_void_0(self.left).optimize(compressor);
  20458. if (self.operator.length == 2) self.operator += "=";
  20459. }
  20460. } else if (compressor.option("typeofs")
  20461. // typeof x === "undefined" => x === undefined
  20462. && self.left instanceof AST_UnaryPrefix
  20463. && self.left.operator == "typeof"
  20464. && self.right instanceof AST_String
  20465. && self.right.value == "undefined") {
  20466. var expr = self.left.expression;
  20467. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  20468. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  20469. self.left = expr;
  20470. self.right = make_void_0(self.right).optimize(compressor);
  20471. if (self.operator.length == 2) self.operator += "=";
  20472. }
  20473. } else if (self.left instanceof AST_SymbolRef
  20474. // obj !== obj => false
  20475. && self.right instanceof AST_SymbolRef
  20476. && self.left.definition() === self.right.definition()
  20477. && is_object(self.left.fixed_value())) {
  20478. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  20479. } else if (self.left.is_32_bit_integer(compressor) && self.right.is_32_bit_integer(compressor)) {
  20480. const not = node => make_node(AST_UnaryPrefix, node, {
  20481. operator: "!",
  20482. expression: node
  20483. });
  20484. const booleanify = (node, truthy) => {
  20485. if (truthy) {
  20486. return compressor.in_boolean_context()
  20487. ? node
  20488. : not(not(node));
  20489. } else {
  20490. return not(node);
  20491. }
  20492. };
  20493. // The only falsy 32-bit integer is 0
  20494. if (self.left instanceof AST_Number && self.left.value === 0) {
  20495. return booleanify(self.right, self.operator[0] === "!");
  20496. }
  20497. if (self.right instanceof AST_Number && self.right.value === 0) {
  20498. return booleanify(self.left, self.operator[0] === "!");
  20499. }
  20500. // Mask all-bits check
  20501. // (x & 0xFF) != 0xFF => !(~x & 0xFF)
  20502. let and_op, x, mask;
  20503. if (
  20504. (and_op =
  20505. self.left instanceof AST_Binary ? self.left
  20506. : self.right instanceof AST_Binary ? self.right : null)
  20507. && (mask = and_op === self.left ? self.right : self.left)
  20508. && and_op.operator === "&"
  20509. && mask instanceof AST_Number
  20510. && mask.is_32_bit_integer(compressor)
  20511. && (x =
  20512. and_op.left.equivalent_to(mask) ? and_op.right
  20513. : and_op.right.equivalent_to(mask) ? and_op.left : null)
  20514. ) {
  20515. let optimized = booleanify(make_node(AST_Binary, self, {
  20516. operator: "&",
  20517. left: mask,
  20518. right: make_node(AST_UnaryPrefix, self, {
  20519. operator: "~",
  20520. expression: x
  20521. })
  20522. }), self.operator[0] === "!");
  20523. return best_of(compressor, optimized, self);
  20524. }
  20525. }
  20526. break;
  20527. case "&&":
  20528. case "||":
  20529. var lhs = self.left;
  20530. if (lhs.operator == self.operator) {
  20531. lhs = lhs.right;
  20532. }
  20533. if (lhs instanceof AST_Binary
  20534. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  20535. && self.right instanceof AST_Binary
  20536. && lhs.operator == self.right.operator
  20537. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  20538. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  20539. && !lhs.right.has_side_effects(compressor)
  20540. && lhs.right.equivalent_to(self.right.right)) {
  20541. var combined = make_node(AST_Binary, self, {
  20542. operator: lhs.operator.slice(0, -1),
  20543. left: make_node(AST_Null, self),
  20544. right: lhs.right
  20545. });
  20546. if (lhs !== self.left) {
  20547. combined = make_node(AST_Binary, self, {
  20548. operator: self.operator,
  20549. left: self.left.left,
  20550. right: combined
  20551. });
  20552. }
  20553. return combined;
  20554. }
  20555. break;
  20556. }
  20557. if (self.operator == "+" && compressor.in_boolean_context()) {
  20558. var ll = self.left.evaluate(compressor);
  20559. var rr = self.right.evaluate(compressor);
  20560. if (ll && typeof ll == "string") {
  20561. return make_sequence(self, [
  20562. self.right,
  20563. make_node(AST_True, self)
  20564. ]).optimize(compressor);
  20565. }
  20566. if (rr && typeof rr == "string") {
  20567. return make_sequence(self, [
  20568. self.left,
  20569. make_node(AST_True, self)
  20570. ]).optimize(compressor);
  20571. }
  20572. }
  20573. if (compressor.option("comparisons") && self.is_boolean()) {
  20574. if (!(compressor.parent() instanceof AST_Binary)
  20575. || compressor.parent() instanceof AST_Assign) {
  20576. var negated = make_node(AST_UnaryPrefix, self, {
  20577. operator: "!",
  20578. expression: self.negate(compressor, first_in_statement(compressor))
  20579. });
  20580. self = best_of(compressor, self, negated);
  20581. }
  20582. if (compressor.option("unsafe_comps")) {
  20583. switch (self.operator) {
  20584. case "<": reverse(">"); break;
  20585. case "<=": reverse(">="); break;
  20586. }
  20587. }
  20588. }
  20589. if (self.operator == "+") {
  20590. if (self.right instanceof AST_String
  20591. && self.right.getValue() == ""
  20592. && self.left.is_string(compressor)) {
  20593. return self.left;
  20594. }
  20595. if (self.left instanceof AST_String
  20596. && self.left.getValue() == ""
  20597. && self.right.is_string(compressor)) {
  20598. return self.right;
  20599. }
  20600. if (self.left instanceof AST_Binary
  20601. && self.left.operator == "+"
  20602. && self.left.left instanceof AST_String
  20603. && self.left.left.getValue() == ""
  20604. && self.right.is_string(compressor)) {
  20605. self.left = self.left.right;
  20606. return self;
  20607. }
  20608. }
  20609. if (compressor.option("evaluate")) {
  20610. switch (self.operator) {
  20611. case "&&":
  20612. var ll = has_flag(self.left, TRUTHY)
  20613. ? true
  20614. : has_flag(self.left, FALSY)
  20615. ? false
  20616. : self.left.evaluate(compressor);
  20617. if (!ll) {
  20618. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  20619. } else if (!(ll instanceof AST_Node)) {
  20620. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  20621. }
  20622. var rr = self.right.evaluate(compressor);
  20623. if (!rr) {
  20624. if (compressor.in_boolean_context()) {
  20625. return make_sequence(self, [
  20626. self.left,
  20627. make_node(AST_False, self)
  20628. ]).optimize(compressor);
  20629. } else {
  20630. set_flag(self, FALSY);
  20631. }
  20632. } else if (!(rr instanceof AST_Node)) {
  20633. var parent = compressor.parent();
  20634. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  20635. return self.left.optimize(compressor);
  20636. }
  20637. }
  20638. // x || false && y ---> x ? y : false
  20639. if (self.left.operator == "||") {
  20640. var lr = self.left.right.evaluate(compressor);
  20641. if (!lr) return make_node(AST_Conditional, self, {
  20642. condition: self.left.left,
  20643. consequent: self.right,
  20644. alternative: self.left.right
  20645. }).optimize(compressor);
  20646. }
  20647. break;
  20648. case "||":
  20649. var ll = has_flag(self.left, TRUTHY)
  20650. ? true
  20651. : has_flag(self.left, FALSY)
  20652. ? false
  20653. : self.left.evaluate(compressor);
  20654. if (!ll) {
  20655. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  20656. } else if (!(ll instanceof AST_Node)) {
  20657. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  20658. }
  20659. var rr = self.right.evaluate(compressor);
  20660. if (!rr) {
  20661. var parent = compressor.parent();
  20662. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  20663. return self.left.optimize(compressor);
  20664. }
  20665. } else if (!(rr instanceof AST_Node)) {
  20666. if (compressor.in_boolean_context()) {
  20667. return make_sequence(self, [
  20668. self.left,
  20669. make_node(AST_True, self)
  20670. ]).optimize(compressor);
  20671. } else {
  20672. set_flag(self, TRUTHY);
  20673. }
  20674. }
  20675. if (self.left.operator == "&&") {
  20676. var lr = self.left.right.evaluate(compressor);
  20677. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  20678. condition: self.left.left,
  20679. consequent: self.left.right,
  20680. alternative: self.right
  20681. }).optimize(compressor);
  20682. }
  20683. break;
  20684. case "??":
  20685. if (is_nullish(self.left, compressor)) {
  20686. return self.right;
  20687. }
  20688. var ll = self.left.evaluate(compressor);
  20689. if (!(ll instanceof AST_Node)) {
  20690. // if we know the value for sure we can simply compute right away.
  20691. return ll == null ? self.right : self.left;
  20692. }
  20693. if (compressor.in_boolean_context()) {
  20694. const rr = self.right.evaluate(compressor);
  20695. if (!(rr instanceof AST_Node) && !rr) {
  20696. return self.left;
  20697. }
  20698. }
  20699. }
  20700. var associative = true;
  20701. switch (self.operator) {
  20702. case "+":
  20703. // (x + "foo") + "bar" => x + "foobar"
  20704. if (self.right instanceof AST_Constant
  20705. && self.left instanceof AST_Binary
  20706. && self.left.operator == "+"
  20707. && self.left.is_string(compressor)) {
  20708. var binary = make_node(AST_Binary, self, {
  20709. operator: "+",
  20710. left: self.left.right,
  20711. right: self.right,
  20712. });
  20713. var r = binary.optimize(compressor);
  20714. if (binary !== r) {
  20715. self = make_node(AST_Binary, self, {
  20716. operator: "+",
  20717. left: self.left.left,
  20718. right: r
  20719. });
  20720. }
  20721. }
  20722. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  20723. if (self.left instanceof AST_Binary
  20724. && self.left.operator == "+"
  20725. && self.left.is_string(compressor)
  20726. && self.right instanceof AST_Binary
  20727. && self.right.operator == "+"
  20728. && self.right.is_string(compressor)) {
  20729. var binary = make_node(AST_Binary, self, {
  20730. operator: "+",
  20731. left: self.left.right,
  20732. right: self.right.left,
  20733. });
  20734. var m = binary.optimize(compressor);
  20735. if (binary !== m) {
  20736. self = make_node(AST_Binary, self, {
  20737. operator: "+",
  20738. left: make_node(AST_Binary, self.left, {
  20739. operator: "+",
  20740. left: self.left.left,
  20741. right: m
  20742. }),
  20743. right: self.right.right
  20744. });
  20745. }
  20746. }
  20747. // a + -b => a - b
  20748. if (self.right instanceof AST_UnaryPrefix
  20749. && self.right.operator == "-"
  20750. && self.left.is_number_or_bigint(compressor)) {
  20751. self = make_node(AST_Binary, self, {
  20752. operator: "-",
  20753. left: self.left,
  20754. right: self.right.expression
  20755. });
  20756. break;
  20757. }
  20758. // -a + b => b - a
  20759. if (self.left instanceof AST_UnaryPrefix
  20760. && self.left.operator == "-"
  20761. && reversible()
  20762. && self.right.is_number_or_bigint(compressor)) {
  20763. self = make_node(AST_Binary, self, {
  20764. operator: "-",
  20765. left: self.right,
  20766. right: self.left.expression
  20767. });
  20768. break;
  20769. }
  20770. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  20771. if (self.left instanceof AST_TemplateString) {
  20772. var l = self.left;
  20773. var r = self.right.evaluate(compressor);
  20774. if (r != self.right) {
  20775. l.segments[l.segments.length - 1].value += String(r);
  20776. return l;
  20777. }
  20778. }
  20779. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  20780. if (self.right instanceof AST_TemplateString) {
  20781. var r = self.right;
  20782. var l = self.left.evaluate(compressor);
  20783. if (l != self.left) {
  20784. r.segments[0].value = String(l) + r.segments[0].value;
  20785. return r;
  20786. }
  20787. }
  20788. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  20789. if (self.left instanceof AST_TemplateString
  20790. && self.right instanceof AST_TemplateString) {
  20791. var l = self.left;
  20792. var segments = l.segments;
  20793. var r = self.right;
  20794. segments[segments.length - 1].value += r.segments[0].value;
  20795. for (var i = 1; i < r.segments.length; i++) {
  20796. segments.push(r.segments[i]);
  20797. }
  20798. return l;
  20799. }
  20800. case "*":
  20801. associative = compressor.option("unsafe_math");
  20802. case "&":
  20803. case "|":
  20804. case "^":
  20805. // a + +b => +b + a
  20806. if (
  20807. self.left.is_number_or_bigint(compressor)
  20808. && self.right.is_number_or_bigint(compressor)
  20809. && reversible()
  20810. && !(self.left instanceof AST_Binary
  20811. && self.left.operator != self.operator
  20812. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  20813. var reversed = make_node(AST_Binary, self, {
  20814. operator: self.operator,
  20815. left: self.right,
  20816. right: self.left
  20817. });
  20818. if (self.right instanceof AST_Constant
  20819. && !(self.left instanceof AST_Constant)) {
  20820. self = best_of(compressor, reversed, self);
  20821. } else {
  20822. self = best_of(compressor, self, reversed);
  20823. }
  20824. }
  20825. if (associative && self.is_number_or_bigint(compressor)) {
  20826. // a + (b + c) => (a + b) + c
  20827. if (self.right instanceof AST_Binary
  20828. && self.right.operator == self.operator) {
  20829. self = make_node(AST_Binary, self, {
  20830. operator: self.operator,
  20831. left: make_node(AST_Binary, self.left, {
  20832. operator: self.operator,
  20833. left: self.left,
  20834. right: self.right.left,
  20835. start: self.left.start,
  20836. end: self.right.left.end
  20837. }),
  20838. right: self.right.right
  20839. });
  20840. }
  20841. // (n + 2) + 3 => 5 + n
  20842. // (2 * n) * 3 => 6 + n
  20843. if (self.right instanceof AST_Constant
  20844. && self.left instanceof AST_Binary
  20845. && self.left.operator == self.operator) {
  20846. if (self.left.left instanceof AST_Constant) {
  20847. self = make_node(AST_Binary, self, {
  20848. operator: self.operator,
  20849. left: make_node(AST_Binary, self.left, {
  20850. operator: self.operator,
  20851. left: self.left.left,
  20852. right: self.right,
  20853. start: self.left.left.start,
  20854. end: self.right.end
  20855. }),
  20856. right: self.left.right
  20857. });
  20858. } else if (self.left.right instanceof AST_Constant) {
  20859. self = make_node(AST_Binary, self, {
  20860. operator: self.operator,
  20861. left: make_node(AST_Binary, self.left, {
  20862. operator: self.operator,
  20863. left: self.left.right,
  20864. right: self.right,
  20865. start: self.left.right.start,
  20866. end: self.right.end
  20867. }),
  20868. right: self.left.left
  20869. });
  20870. }
  20871. }
  20872. // (a | 1) | (2 | d) => (3 | a) | b
  20873. if (self.left instanceof AST_Binary
  20874. && self.left.operator == self.operator
  20875. && self.left.right instanceof AST_Constant
  20876. && self.right instanceof AST_Binary
  20877. && self.right.operator == self.operator
  20878. && self.right.left instanceof AST_Constant) {
  20879. self = make_node(AST_Binary, self, {
  20880. operator: self.operator,
  20881. left: make_node(AST_Binary, self.left, {
  20882. operator: self.operator,
  20883. left: make_node(AST_Binary, self.left.left, {
  20884. operator: self.operator,
  20885. left: self.left.right,
  20886. right: self.right.left,
  20887. start: self.left.right.start,
  20888. end: self.right.left.end
  20889. }),
  20890. right: self.left.left
  20891. }),
  20892. right: self.right.right
  20893. });
  20894. }
  20895. }
  20896. }
  20897. // bitwise ops
  20898. if (bitwise_binop.has(self.operator)) {
  20899. // Use De Morgan's laws
  20900. // z & (X | y)
  20901. // => z & X (given y & z === 0)
  20902. // => z & X | {y & z} (given y & z !== 0)
  20903. let y, z, x_node, y_node, z_node = self.left;
  20904. if (
  20905. self.operator === "&"
  20906. && self.right instanceof AST_Binary
  20907. && self.right.operator === "|"
  20908. && typeof (z = self.left.evaluate(compressor)) === "number"
  20909. ) {
  20910. if (typeof (y = self.right.right.evaluate(compressor)) === "number") {
  20911. // z & (X | y)
  20912. x_node = self.right.left;
  20913. y_node = self.right.right;
  20914. } else if (typeof (y = self.right.left.evaluate(compressor)) === "number") {
  20915. // z & (y | X)
  20916. x_node = self.right.right;
  20917. y_node = self.right.left;
  20918. }
  20919. if (x_node && y_node) {
  20920. if ((y & z) === 0) {
  20921. self = make_node(AST_Binary, self, {
  20922. operator: self.operator,
  20923. left: z_node,
  20924. right: x_node
  20925. });
  20926. } else {
  20927. const reordered_ops = make_node(AST_Binary, self, {
  20928. operator: "|",
  20929. left: make_node(AST_Binary, self, {
  20930. operator: "&",
  20931. left: x_node,
  20932. right: z_node
  20933. }),
  20934. right: make_node_from_constant(y & z, y_node),
  20935. });
  20936. self = best_of(compressor, self, reordered_ops);
  20937. }
  20938. }
  20939. }
  20940. // x | x => 0 | x
  20941. // x & x => 0 | x
  20942. if (
  20943. (self.operator === "|" || self.operator === "&")
  20944. && self.left.equivalent_to(self.right)
  20945. && !self.left.has_side_effects(compressor)
  20946. && compressor.in_32_bit_context(true)
  20947. ) {
  20948. self.left = make_node(AST_Number, self, { value: 0 });
  20949. self.operator = "|";
  20950. }
  20951. // ~x ^ ~y => x ^ y
  20952. if (
  20953. self.operator === "^"
  20954. && self.left instanceof AST_UnaryPrefix
  20955. && self.left.operator === "~"
  20956. && self.right instanceof AST_UnaryPrefix
  20957. && self.right.operator === "~"
  20958. ) {
  20959. self = make_node(AST_Binary, self, {
  20960. operator: "^",
  20961. left: self.left.expression,
  20962. right: self.right.expression
  20963. });
  20964. }
  20965. // Shifts that do nothing
  20966. // {anything} >> 0 => {anything} | 0
  20967. // {anything} << 0 => {anything} | 0
  20968. if (
  20969. (self.operator === "<<" || self.operator === ">>")
  20970. && self.right instanceof AST_Number && self.right.value === 0
  20971. ) {
  20972. self.operator = "|";
  20973. }
  20974. // Find useless to-bitwise conversions
  20975. // {32 bit integer} | 0 => {32 bit integer}
  20976. // {32 bit integer} ^ 0 => {32 bit integer}
  20977. const zero_side = self.right instanceof AST_Number && self.right.value === 0 ? self.right
  20978. : self.left instanceof AST_Number && self.left.value === 0 ? self.left
  20979. : null;
  20980. const non_zero_side = zero_side && (zero_side === self.right ? self.left : self.right);
  20981. if (
  20982. zero_side
  20983. && (self.operator === "|" || self.operator === "^")
  20984. && (non_zero_side.is_32_bit_integer(compressor) || compressor.in_32_bit_context(true))
  20985. ) {
  20986. return non_zero_side;
  20987. }
  20988. // {anything} & 0 => 0
  20989. if (
  20990. zero_side
  20991. && self.operator === "&"
  20992. && !non_zero_side.has_side_effects(compressor)
  20993. && non_zero_side.is_32_bit_integer(compressor)
  20994. ) {
  20995. return zero_side;
  20996. }
  20997. // ~0 is all ones, as well as -1.
  20998. // We can ellide some operations with it.
  20999. const is_full_mask = (node) =>
  21000. node instanceof AST_Number && node.value === -1
  21001. ||
  21002. node instanceof AST_UnaryPrefix
  21003. && node.operator === "-"
  21004. && node.expression instanceof AST_Number
  21005. && node.expression.value === 1;
  21006. const full_mask = is_full_mask(self.right) ? self.right
  21007. : is_full_mask(self.left) ? self.left
  21008. : null;
  21009. const other_side = (full_mask === self.right ? self.left : self.right);
  21010. // {32 bit integer} & -1 => {32 bit integer}
  21011. if (
  21012. full_mask
  21013. && self.operator === "&"
  21014. && (
  21015. other_side.is_32_bit_integer(compressor)
  21016. || compressor.in_32_bit_context(true)
  21017. )
  21018. ) {
  21019. return other_side;
  21020. }
  21021. // {anything} ^ -1 => ~{anything}
  21022. if (
  21023. full_mask
  21024. && self.operator === "^"
  21025. && (
  21026. other_side.is_32_bit_integer(compressor)
  21027. || compressor.in_32_bit_context(true)
  21028. )
  21029. ) {
  21030. return other_side.bitwise_negate(compressor);
  21031. }
  21032. }
  21033. }
  21034. // x && (y && z) ==> x && y && z
  21035. // x || (y || z) ==> x || y || z
  21036. // x + ("y" + z) ==> x + "y" + z
  21037. // "x" + (y + "z")==> "x" + y + "z"
  21038. if (self.right instanceof AST_Binary
  21039. && self.right.operator == self.operator
  21040. && (lazy_op.has(self.operator)
  21041. || (self.operator == "+"
  21042. && (self.right.left.is_string(compressor)
  21043. || (self.left.is_string(compressor)
  21044. && self.right.right.is_string(compressor)))))
  21045. ) {
  21046. self.left = make_node(AST_Binary, self.left, {
  21047. operator : self.operator,
  21048. left : self.left.transform(compressor),
  21049. right : self.right.left.transform(compressor)
  21050. });
  21051. self.right = self.right.right.transform(compressor);
  21052. return self.transform(compressor);
  21053. }
  21054. var ev = self.evaluate(compressor);
  21055. if (ev !== self) {
  21056. ev = make_node_from_constant(ev, self).optimize(compressor);
  21057. return best_of(compressor, ev, self);
  21058. }
  21059. return self;
  21060. });
  21061. def_optimize(AST_SymbolExport, function(self) {
  21062. return self;
  21063. });
  21064. def_optimize(AST_SymbolRef, function(self, compressor) {
  21065. if (
  21066. !compressor.option("ie8")
  21067. && is_undeclared_ref(self)
  21068. && !compressor.find_parent(AST_With)
  21069. ) {
  21070. switch (self.name) {
  21071. case "undefined":
  21072. return make_node(AST_Undefined, self).optimize(compressor);
  21073. case "NaN":
  21074. return make_node(AST_NaN, self).optimize(compressor);
  21075. case "Infinity":
  21076. return make_node(AST_Infinity, self).optimize(compressor);
  21077. }
  21078. }
  21079. if (compressor.option("reduce_vars") && !compressor.is_lhs()) {
  21080. return inline_into_symbolref(self, compressor);
  21081. } else {
  21082. return self;
  21083. }
  21084. });
  21085. function is_atomic(lhs, self) {
  21086. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  21087. }
  21088. /** Apply the `unsafe_undefined` option: find a variable called `undefined` and turn `self` into a reference to it. */
  21089. function unsafe_undefined_ref(self, compressor) {
  21090. if (compressor.option("unsafe_undefined")) {
  21091. var undef = find_variable(compressor, "undefined");
  21092. if (undef) {
  21093. var ref = make_node(AST_SymbolRef, self, {
  21094. name : "undefined",
  21095. scope : undef.scope,
  21096. thedef : undef
  21097. });
  21098. set_flag(ref, UNDEFINED);
  21099. return ref;
  21100. }
  21101. }
  21102. return null;
  21103. }
  21104. def_optimize(AST_Undefined, function(self, compressor) {
  21105. var symbolref = unsafe_undefined_ref(self, compressor);
  21106. if (symbolref) return symbolref;
  21107. var lhs = compressor.is_lhs();
  21108. if (lhs && is_atomic(lhs, self)) return self;
  21109. return make_void_0(self);
  21110. });
  21111. def_optimize(AST_Infinity, function(self, compressor) {
  21112. var lhs = compressor.is_lhs();
  21113. if (lhs && is_atomic(lhs, self)) return self;
  21114. if (
  21115. compressor.option("keep_infinity")
  21116. && !(lhs && !is_atomic(lhs, self))
  21117. && !find_variable(compressor, "Infinity")
  21118. ) {
  21119. return self;
  21120. }
  21121. return make_node(AST_Binary, self, {
  21122. operator: "/",
  21123. left: make_node(AST_Number, self, {
  21124. value: 1
  21125. }),
  21126. right: make_node(AST_Number, self, {
  21127. value: 0
  21128. })
  21129. });
  21130. });
  21131. def_optimize(AST_NaN, function(self, compressor) {
  21132. var lhs = compressor.is_lhs();
  21133. if (lhs && !is_atomic(lhs, self)
  21134. || find_variable(compressor, "NaN")) {
  21135. return make_node(AST_Binary, self, {
  21136. operator: "/",
  21137. left: make_node(AST_Number, self, {
  21138. value: 0
  21139. }),
  21140. right: make_node(AST_Number, self, {
  21141. value: 0
  21142. })
  21143. });
  21144. }
  21145. return self;
  21146. });
  21147. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  21148. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  21149. def_optimize(AST_Assign, function(self, compressor) {
  21150. if (self.logical) {
  21151. return self.lift_sequences(compressor);
  21152. }
  21153. var def;
  21154. // x = x ---> x
  21155. if (
  21156. self.operator === "="
  21157. && self.left instanceof AST_SymbolRef
  21158. && self.left.name !== "arguments"
  21159. && !(def = self.left.definition()).undeclared
  21160. && self.right.equivalent_to(self.left)
  21161. ) {
  21162. return self.right;
  21163. }
  21164. if (compressor.option("dead_code")
  21165. && self.left instanceof AST_SymbolRef
  21166. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  21167. var level = 0, node, parent = self;
  21168. do {
  21169. node = parent;
  21170. parent = compressor.parent(level++);
  21171. if (parent instanceof AST_Exit) {
  21172. if (in_try(level, parent)) break;
  21173. if (is_reachable(def.scope, [ def ])) break;
  21174. if (self.operator == "=") return self.right;
  21175. def.fixed = false;
  21176. return make_node(AST_Binary, self, {
  21177. operator: self.operator.slice(0, -1),
  21178. left: self.left,
  21179. right: self.right
  21180. }).optimize(compressor);
  21181. }
  21182. } while (parent instanceof AST_Binary && parent.right === node
  21183. || parent instanceof AST_Sequence && parent.tail_node() === node);
  21184. }
  21185. self = self.lift_sequences(compressor);
  21186. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  21187. // x = expr1 OP expr2
  21188. if (self.right.left instanceof AST_SymbolRef
  21189. && self.right.left.name == self.left.name
  21190. && ASSIGN_OPS.has(self.right.operator)) {
  21191. // x = x - 2 ---> x -= 2
  21192. self.operator = self.right.operator + "=";
  21193. self.right = self.right.right;
  21194. } else if (self.right.right instanceof AST_SymbolRef
  21195. && self.right.right.name == self.left.name
  21196. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  21197. && !self.right.left.has_side_effects(compressor)) {
  21198. // x = 2 & x ---> x &= 2
  21199. self.operator = self.right.operator + "=";
  21200. self.right = self.right.left;
  21201. }
  21202. }
  21203. return self;
  21204. function in_try(level, node) {
  21205. function may_assignment_throw() {
  21206. const right = self.right;
  21207. self.right = make_node(AST_Null, right);
  21208. const may_throw = node.may_throw(compressor);
  21209. self.right = right;
  21210. return may_throw;
  21211. }
  21212. var stop_at = self.left.definition().scope.get_defun_scope();
  21213. var parent;
  21214. while ((parent = compressor.parent(level++)) !== stop_at) {
  21215. if (parent instanceof AST_Try) {
  21216. if (parent.bfinally) return true;
  21217. if (parent.bcatch && may_assignment_throw()) return true;
  21218. }
  21219. }
  21220. }
  21221. });
  21222. def_optimize(AST_DefaultAssign, function(self, compressor) {
  21223. if (!compressor.option("evaluate")) {
  21224. return self;
  21225. }
  21226. var evaluateRight = self.right.evaluate(compressor);
  21227. // `[x = undefined] = foo` ---> `[x] = foo`
  21228. // `(arg = undefined) => ...` ---> `(arg) => ...` (unless `keep_fargs`)
  21229. // `((arg = undefined) => ...)()` ---> `((arg) => ...)()`
  21230. let lambda, iife;
  21231. if (evaluateRight === undefined) {
  21232. if (
  21233. (lambda = compressor.parent()) instanceof AST_Lambda
  21234. ? (
  21235. compressor.option("keep_fargs") === false
  21236. || (iife = compressor.parent(1)).TYPE === "Call"
  21237. && iife.expression === lambda
  21238. )
  21239. : true
  21240. ) {
  21241. self = self.left;
  21242. }
  21243. } else if (evaluateRight !== self.right) {
  21244. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  21245. self.right = best_of_expression(evaluateRight, self.right);
  21246. }
  21247. return self;
  21248. });
  21249. function is_nullish_check(check, check_subject, compressor) {
  21250. if (check_subject.may_throw(compressor)) return false;
  21251. let nullish_side;
  21252. // foo == null
  21253. if (
  21254. check instanceof AST_Binary
  21255. && check.operator === "=="
  21256. // which side is nullish?
  21257. && (
  21258. (nullish_side = is_nullish(check.left, compressor) && check.left)
  21259. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  21260. )
  21261. // is the other side the same as the check_subject
  21262. && (
  21263. nullish_side === check.left
  21264. ? check.right
  21265. : check.left
  21266. ).equivalent_to(check_subject)
  21267. ) {
  21268. return true;
  21269. }
  21270. // foo === null || foo === undefined
  21271. if (check instanceof AST_Binary && check.operator === "||") {
  21272. let null_cmp;
  21273. let undefined_cmp;
  21274. const find_comparison = cmp => {
  21275. if (!(
  21276. cmp instanceof AST_Binary
  21277. && (cmp.operator === "===" || cmp.operator === "==")
  21278. )) {
  21279. return false;
  21280. }
  21281. let found = 0;
  21282. let defined_side;
  21283. if (cmp.left instanceof AST_Null) {
  21284. found++;
  21285. null_cmp = cmp;
  21286. defined_side = cmp.right;
  21287. }
  21288. if (cmp.right instanceof AST_Null) {
  21289. found++;
  21290. null_cmp = cmp;
  21291. defined_side = cmp.left;
  21292. }
  21293. if (is_undefined(cmp.left, compressor)) {
  21294. found++;
  21295. undefined_cmp = cmp;
  21296. defined_side = cmp.right;
  21297. }
  21298. if (is_undefined(cmp.right, compressor)) {
  21299. found++;
  21300. undefined_cmp = cmp;
  21301. defined_side = cmp.left;
  21302. }
  21303. if (found !== 1) {
  21304. return false;
  21305. }
  21306. if (!defined_side.equivalent_to(check_subject)) {
  21307. return false;
  21308. }
  21309. return true;
  21310. };
  21311. if (!find_comparison(check.left)) return false;
  21312. if (!find_comparison(check.right)) return false;
  21313. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  21314. return true;
  21315. }
  21316. }
  21317. return false;
  21318. }
  21319. def_optimize(AST_Conditional, function(self, compressor) {
  21320. if (!compressor.option("conditionals")) return self;
  21321. // This looks like lift_sequences(), should probably be under "sequences"
  21322. if (self.condition instanceof AST_Sequence) {
  21323. var expressions = self.condition.expressions.slice();
  21324. self.condition = expressions.pop();
  21325. expressions.push(self);
  21326. return make_sequence(self, expressions);
  21327. }
  21328. var cond = self.condition.evaluate(compressor);
  21329. if (cond !== self.condition) {
  21330. if (cond) {
  21331. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  21332. } else {
  21333. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  21334. }
  21335. }
  21336. var negated = cond.negate(compressor, first_in_statement(compressor));
  21337. if (best_of(compressor, cond, negated) === negated) {
  21338. self = make_node(AST_Conditional, self, {
  21339. condition: negated,
  21340. consequent: self.alternative,
  21341. alternative: self.consequent
  21342. });
  21343. }
  21344. var condition = self.condition;
  21345. var consequent = self.consequent;
  21346. var alternative = self.alternative;
  21347. // x?x:y --> x||y
  21348. if (condition instanceof AST_SymbolRef
  21349. && consequent instanceof AST_SymbolRef
  21350. && condition.definition() === consequent.definition()) {
  21351. return make_node(AST_Binary, self, {
  21352. operator: "||",
  21353. left: condition,
  21354. right: alternative
  21355. });
  21356. }
  21357. // if (foo) exp = something; else exp = something_else;
  21358. // |
  21359. // v
  21360. // exp = foo ? something : something_else;
  21361. if (
  21362. consequent instanceof AST_Assign
  21363. && alternative instanceof AST_Assign
  21364. && consequent.operator === alternative.operator
  21365. && consequent.logical === alternative.logical
  21366. && consequent.left.equivalent_to(alternative.left)
  21367. && (!self.condition.has_side_effects(compressor)
  21368. || consequent.operator == "="
  21369. && !consequent.left.has_side_effects(compressor))
  21370. ) {
  21371. return make_node(AST_Assign, self, {
  21372. operator: consequent.operator,
  21373. left: consequent.left,
  21374. logical: consequent.logical,
  21375. right: make_node(AST_Conditional, self, {
  21376. condition: self.condition,
  21377. consequent: consequent.right,
  21378. alternative: alternative.right
  21379. })
  21380. });
  21381. }
  21382. // x ? y(a) : y(b) --> y(x ? a : b)
  21383. var arg_index;
  21384. if (consequent instanceof AST_Call
  21385. && alternative.TYPE === consequent.TYPE
  21386. && consequent.args.length > 0
  21387. && consequent.args.length == alternative.args.length
  21388. && consequent.expression.equivalent_to(alternative.expression)
  21389. && !self.condition.has_side_effects(compressor)
  21390. && !consequent.expression.has_side_effects(compressor)
  21391. && typeof (arg_index = single_arg_diff()) == "number") {
  21392. var node = consequent.clone();
  21393. node.args[arg_index] = make_node(AST_Conditional, self, {
  21394. condition: self.condition,
  21395. consequent: consequent.args[arg_index],
  21396. alternative: alternative.args[arg_index]
  21397. });
  21398. return node;
  21399. }
  21400. // a ? b : c ? b : d --> (a || c) ? b : d
  21401. if (alternative instanceof AST_Conditional
  21402. && consequent.equivalent_to(alternative.consequent)) {
  21403. return make_node(AST_Conditional, self, {
  21404. condition: make_node(AST_Binary, self, {
  21405. operator: "||",
  21406. left: condition,
  21407. right: alternative.condition
  21408. }),
  21409. consequent: consequent,
  21410. alternative: alternative.alternative
  21411. }).optimize(compressor);
  21412. }
  21413. // a == null ? b : a -> a ?? b
  21414. if (
  21415. compressor.option("ecma") >= 2020 &&
  21416. is_nullish_check(condition, alternative, compressor)
  21417. ) {
  21418. return make_node(AST_Binary, self, {
  21419. operator: "??",
  21420. left: alternative,
  21421. right: consequent
  21422. }).optimize(compressor);
  21423. }
  21424. // a ? b : (c, b) --> (a || c), b
  21425. if (alternative instanceof AST_Sequence
  21426. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  21427. return make_sequence(self, [
  21428. make_node(AST_Binary, self, {
  21429. operator: "||",
  21430. left: condition,
  21431. right: make_sequence(self, alternative.expressions.slice(0, -1))
  21432. }),
  21433. consequent
  21434. ]).optimize(compressor);
  21435. }
  21436. // a ? b : (c && b) --> (a || c) && b
  21437. if (alternative instanceof AST_Binary
  21438. && alternative.operator == "&&"
  21439. && consequent.equivalent_to(alternative.right)) {
  21440. return make_node(AST_Binary, self, {
  21441. operator: "&&",
  21442. left: make_node(AST_Binary, self, {
  21443. operator: "||",
  21444. left: condition,
  21445. right: alternative.left
  21446. }),
  21447. right: consequent
  21448. }).optimize(compressor);
  21449. }
  21450. // x?y?z:a:a --> x&&y?z:a
  21451. if (consequent instanceof AST_Conditional
  21452. && consequent.alternative.equivalent_to(alternative)) {
  21453. return make_node(AST_Conditional, self, {
  21454. condition: make_node(AST_Binary, self, {
  21455. left: self.condition,
  21456. operator: "&&",
  21457. right: consequent.condition
  21458. }),
  21459. consequent: consequent.consequent,
  21460. alternative: alternative
  21461. });
  21462. }
  21463. // x ? y : y --> x, y
  21464. if (consequent.equivalent_to(alternative)) {
  21465. return make_sequence(self, [
  21466. self.condition,
  21467. consequent
  21468. ]).optimize(compressor);
  21469. }
  21470. // x ? y || z : z --> x && y || z
  21471. if (consequent instanceof AST_Binary
  21472. && consequent.operator == "||"
  21473. && consequent.right.equivalent_to(alternative)) {
  21474. return make_node(AST_Binary, self, {
  21475. operator: "||",
  21476. left: make_node(AST_Binary, self, {
  21477. operator: "&&",
  21478. left: self.condition,
  21479. right: consequent.left
  21480. }),
  21481. right: alternative
  21482. }).optimize(compressor);
  21483. }
  21484. const in_bool = compressor.in_boolean_context();
  21485. if (is_true(self.consequent)) {
  21486. if (is_false(self.alternative)) {
  21487. // c ? true : false ---> !!c
  21488. return booleanize(self.condition);
  21489. }
  21490. // c ? true : x ---> !!c || x
  21491. return make_node(AST_Binary, self, {
  21492. operator: "||",
  21493. left: booleanize(self.condition),
  21494. right: self.alternative
  21495. });
  21496. }
  21497. if (is_false(self.consequent)) {
  21498. if (is_true(self.alternative)) {
  21499. // c ? false : true ---> !c
  21500. return booleanize(self.condition.negate(compressor));
  21501. }
  21502. // c ? false : x ---> !c && x
  21503. return make_node(AST_Binary, self, {
  21504. operator: "&&",
  21505. left: booleanize(self.condition.negate(compressor)),
  21506. right: self.alternative
  21507. });
  21508. }
  21509. if (is_true(self.alternative)) {
  21510. // c ? x : true ---> !c || x
  21511. return make_node(AST_Binary, self, {
  21512. operator: "||",
  21513. left: booleanize(self.condition.negate(compressor)),
  21514. right: self.consequent
  21515. });
  21516. }
  21517. if (is_false(self.alternative)) {
  21518. // c ? x : false ---> !!c && x
  21519. return make_node(AST_Binary, self, {
  21520. operator: "&&",
  21521. left: booleanize(self.condition),
  21522. right: self.consequent
  21523. });
  21524. }
  21525. return self;
  21526. function booleanize(node) {
  21527. if (node.is_boolean()) return node;
  21528. // !!expression
  21529. return make_node(AST_UnaryPrefix, node, {
  21530. operator: "!",
  21531. expression: node.negate(compressor)
  21532. });
  21533. }
  21534. // AST_True or !0
  21535. function is_true(node) {
  21536. return node instanceof AST_True
  21537. || in_bool
  21538. && node instanceof AST_Constant
  21539. && node.getValue()
  21540. || (node instanceof AST_UnaryPrefix
  21541. && node.operator == "!"
  21542. && node.expression instanceof AST_Constant
  21543. && !node.expression.getValue());
  21544. }
  21545. // AST_False or !1
  21546. function is_false(node) {
  21547. return node instanceof AST_False
  21548. || in_bool
  21549. && node instanceof AST_Constant
  21550. && !node.getValue()
  21551. || (node instanceof AST_UnaryPrefix
  21552. && node.operator == "!"
  21553. && node.expression instanceof AST_Constant
  21554. && node.expression.getValue());
  21555. }
  21556. function single_arg_diff() {
  21557. var a = consequent.args;
  21558. var b = alternative.args;
  21559. for (var i = 0, len = a.length; i < len; i++) {
  21560. if (a[i] instanceof AST_Expansion) return;
  21561. if (!a[i].equivalent_to(b[i])) {
  21562. if (b[i] instanceof AST_Expansion) return;
  21563. for (var j = i + 1; j < len; j++) {
  21564. if (a[j] instanceof AST_Expansion) return;
  21565. if (!a[j].equivalent_to(b[j])) return;
  21566. }
  21567. return i;
  21568. }
  21569. }
  21570. }
  21571. });
  21572. def_optimize(AST_Boolean, function(self, compressor) {
  21573. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  21574. value: +self.value
  21575. });
  21576. var p = compressor.parent();
  21577. if (compressor.option("booleans_as_integers")) {
  21578. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  21579. p.operator = p.operator.replace(/=$/, "");
  21580. }
  21581. return make_node(AST_Number, self, {
  21582. value: +self.value
  21583. });
  21584. }
  21585. if (compressor.option("booleans")) {
  21586. if (p instanceof AST_Binary && (p.operator == "=="
  21587. || p.operator == "!=")) {
  21588. return make_node(AST_Number, self, {
  21589. value: +self.value
  21590. });
  21591. }
  21592. return make_node(AST_UnaryPrefix, self, {
  21593. operator: "!",
  21594. expression: make_node(AST_Number, self, {
  21595. value: 1 - self.value
  21596. })
  21597. });
  21598. }
  21599. return self;
  21600. });
  21601. function safe_to_flatten(value, compressor) {
  21602. if (value instanceof AST_SymbolRef) {
  21603. value = value.fixed_value();
  21604. }
  21605. if (!value) return false;
  21606. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  21607. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  21608. return compressor.parent() instanceof AST_New;
  21609. }
  21610. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  21611. if (!compressor.option("properties")) return;
  21612. if (key === "__proto__") return;
  21613. if (this instanceof AST_DotHash) return;
  21614. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  21615. var expr = this.expression;
  21616. if (expr instanceof AST_Object) {
  21617. var props = expr.properties;
  21618. for (var i = props.length; --i >= 0;) {
  21619. var prop = props[i];
  21620. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  21621. const all_props_flattenable = props.every((p) =>
  21622. (p instanceof AST_ObjectKeyVal
  21623. || arrows && p instanceof AST_ConciseMethod && !p.value.is_generator
  21624. )
  21625. && !p.computed_key()
  21626. );
  21627. if (!all_props_flattenable) return;
  21628. if (!safe_to_flatten(prop.value, compressor)) return;
  21629. return make_node(AST_Sub, this, {
  21630. expression: make_node(AST_Array, expr, {
  21631. elements: props.map(function(prop) {
  21632. var v = prop.value;
  21633. if (v instanceof AST_Accessor) {
  21634. v = make_node(AST_Function, v, v);
  21635. }
  21636. var k = prop.key;
  21637. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  21638. return make_sequence(prop, [ k, v ]);
  21639. }
  21640. return v;
  21641. })
  21642. }),
  21643. property: make_node(AST_Number, this, {
  21644. value: i
  21645. })
  21646. });
  21647. }
  21648. }
  21649. }
  21650. });
  21651. def_optimize(AST_Sub, function(self, compressor) {
  21652. var expr = self.expression;
  21653. var prop = self.property;
  21654. if (compressor.option("properties")) {
  21655. var key = prop.evaluate(compressor);
  21656. if (key !== prop) {
  21657. if (typeof key == "string") {
  21658. if (key == "undefined") {
  21659. key = undefined;
  21660. } else {
  21661. var value = parseFloat(key);
  21662. if (value.toString() == key) {
  21663. key = value;
  21664. }
  21665. }
  21666. }
  21667. prop = self.property = best_of_expression(
  21668. prop,
  21669. make_node_from_constant(key, prop).transform(compressor)
  21670. );
  21671. var property = "" + key;
  21672. if (is_basic_identifier_string(property)
  21673. && property.length <= prop.size() + 1) {
  21674. return make_node(AST_Dot, self, {
  21675. expression: expr,
  21676. optional: self.optional,
  21677. property: property,
  21678. quote: prop.quote,
  21679. }).optimize(compressor);
  21680. }
  21681. }
  21682. }
  21683. var fn;
  21684. OPT_ARGUMENTS: if (compressor.option("arguments")
  21685. && expr instanceof AST_SymbolRef
  21686. && expr.name == "arguments"
  21687. && expr.definition().orig.length == 1
  21688. && (fn = expr.scope) instanceof AST_Lambda
  21689. && fn.uses_arguments
  21690. && !(fn instanceof AST_Arrow)
  21691. && prop instanceof AST_Number) {
  21692. var index = prop.getValue();
  21693. var params = new Set();
  21694. var argnames = fn.argnames;
  21695. for (var n = 0; n < argnames.length; n++) {
  21696. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  21697. break OPT_ARGUMENTS; // destructuring parameter - bail
  21698. }
  21699. var param = argnames[n].name;
  21700. if (params.has(param)) {
  21701. break OPT_ARGUMENTS; // duplicate parameter - bail
  21702. }
  21703. params.add(param);
  21704. }
  21705. var argname = fn.argnames[index];
  21706. if (argname && compressor.has_directive("use strict")) {
  21707. var def = argname.definition();
  21708. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  21709. argname = null;
  21710. }
  21711. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  21712. while (index >= fn.argnames.length) {
  21713. argname = fn.create_symbol(AST_SymbolFunarg, {
  21714. source: fn,
  21715. scope: fn,
  21716. tentative_name: "argument_" + fn.argnames.length,
  21717. });
  21718. fn.argnames.push(argname);
  21719. }
  21720. }
  21721. if (argname) {
  21722. var sym = make_node(AST_SymbolRef, self, argname);
  21723. sym.reference({});
  21724. clear_flag(argname, UNUSED);
  21725. return sym;
  21726. }
  21727. }
  21728. if (compressor.is_lhs()) return self;
  21729. if (key !== prop) {
  21730. var sub = self.flatten_object(property, compressor);
  21731. if (sub) {
  21732. expr = self.expression = sub.expression;
  21733. prop = self.property = sub.property;
  21734. }
  21735. }
  21736. if (compressor.option("properties") && compressor.option("side_effects")
  21737. && prop instanceof AST_Number && expr instanceof AST_Array) {
  21738. var index = prop.getValue();
  21739. var elements = expr.elements;
  21740. var retValue = elements[index];
  21741. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  21742. var flatten = true;
  21743. var values = [];
  21744. for (var i = elements.length; --i > index;) {
  21745. var value = elements[i].drop_side_effect_free(compressor);
  21746. if (value) {
  21747. values.unshift(value);
  21748. if (flatten && value.has_side_effects(compressor)) flatten = false;
  21749. }
  21750. }
  21751. if (retValue instanceof AST_Expansion) break FLATTEN;
  21752. retValue = retValue instanceof AST_Hole ? make_void_0(retValue) : retValue;
  21753. if (!flatten) values.unshift(retValue);
  21754. while (--i >= 0) {
  21755. var value = elements[i];
  21756. if (value instanceof AST_Expansion) break FLATTEN;
  21757. value = value.drop_side_effect_free(compressor);
  21758. if (value) values.unshift(value);
  21759. else index--;
  21760. }
  21761. if (flatten) {
  21762. values.push(retValue);
  21763. return make_sequence(self, values).optimize(compressor);
  21764. } else return make_node(AST_Sub, self, {
  21765. expression: make_node(AST_Array, expr, {
  21766. elements: values
  21767. }),
  21768. property: make_node(AST_Number, prop, {
  21769. value: index
  21770. })
  21771. });
  21772. }
  21773. }
  21774. var ev = self.evaluate(compressor);
  21775. if (ev !== self) {
  21776. ev = make_node_from_constant(ev, self).optimize(compressor);
  21777. return best_of(compressor, ev, self);
  21778. }
  21779. return self;
  21780. });
  21781. def_optimize(AST_Chain, function (self, compressor) {
  21782. if (is_nullish(self.expression, compressor)) {
  21783. let parent = compressor.parent();
  21784. // It's valid to delete a nullish optional chain, but if we optimized
  21785. // this to `delete undefined` then it would appear to be a syntax error
  21786. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  21787. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  21788. return make_node_from_constant(0, self);
  21789. }
  21790. return make_void_0(self).optimize(compressor);
  21791. }
  21792. if (
  21793. self.expression instanceof AST_PropAccess
  21794. || self.expression instanceof AST_Call
  21795. ) {
  21796. return self;
  21797. } else {
  21798. // Keep the AST valid, in case the child swapped itself
  21799. return self.expression;
  21800. }
  21801. });
  21802. def_optimize(AST_Dot, function(self, compressor) {
  21803. const parent = compressor.parent();
  21804. if (compressor.is_lhs()) return self;
  21805. if (compressor.option("unsafe_proto")
  21806. && self.expression instanceof AST_Dot
  21807. && self.expression.property == "prototype") {
  21808. var exp = self.expression.expression;
  21809. if (is_undeclared_ref(exp)) switch (exp.name) {
  21810. case "Array":
  21811. self.expression = make_node(AST_Array, self.expression, {
  21812. elements: []
  21813. });
  21814. break;
  21815. case "Function":
  21816. self.expression = make_empty_function(self.expression);
  21817. break;
  21818. case "Number":
  21819. self.expression = make_node(AST_Number, self.expression, {
  21820. value: 0
  21821. });
  21822. break;
  21823. case "Object":
  21824. self.expression = make_node(AST_Object, self.expression, {
  21825. properties: []
  21826. });
  21827. break;
  21828. case "RegExp":
  21829. self.expression = make_node(AST_RegExp, self.expression, {
  21830. value: { source: "t", flags: "" }
  21831. });
  21832. break;
  21833. case "String":
  21834. self.expression = make_node(AST_String, self.expression, {
  21835. value: ""
  21836. });
  21837. break;
  21838. }
  21839. }
  21840. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  21841. const sub = self.flatten_object(self.property, compressor);
  21842. if (sub) return sub.optimize(compressor);
  21843. }
  21844. if (self.expression instanceof AST_PropAccess
  21845. && parent instanceof AST_PropAccess) {
  21846. return self;
  21847. }
  21848. let ev = self.evaluate(compressor);
  21849. if (ev !== self) {
  21850. ev = make_node_from_constant(ev, self).optimize(compressor);
  21851. return best_of(compressor, ev, self);
  21852. }
  21853. return self;
  21854. });
  21855. function literals_in_boolean_context(self, compressor) {
  21856. if (compressor.in_boolean_context()) {
  21857. return best_of(compressor, self, make_sequence(self, [
  21858. self,
  21859. make_node(AST_True, self)
  21860. ]).optimize(compressor));
  21861. }
  21862. return self;
  21863. }
  21864. function inline_array_like_spread(elements) {
  21865. for (var i = 0; i < elements.length; i++) {
  21866. var el = elements[i];
  21867. if (el instanceof AST_Expansion) {
  21868. var expr = el.expression;
  21869. if (
  21870. expr instanceof AST_Array
  21871. && !expr.elements.some(elm => elm instanceof AST_Hole)
  21872. ) {
  21873. elements.splice(i, 1, ...expr.elements);
  21874. // Step back one, as the element at i is now new.
  21875. i--;
  21876. }
  21877. // In array-like spread, spreading a non-iterable value is TypeError.
  21878. // We therefore can’t optimize anything else, unlike with object spread.
  21879. }
  21880. }
  21881. }
  21882. def_optimize(AST_Array, function(self, compressor) {
  21883. var optimized = literals_in_boolean_context(self, compressor);
  21884. if (optimized !== self) {
  21885. return optimized;
  21886. }
  21887. inline_array_like_spread(self.elements);
  21888. return self;
  21889. });
  21890. function inline_object_prop_spread(props) {
  21891. for (var i = 0; i < props.length; i++) {
  21892. var prop = props[i];
  21893. if (prop instanceof AST_Expansion) {
  21894. const expr = prop.expression;
  21895. if (
  21896. expr instanceof AST_Object
  21897. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  21898. ) {
  21899. props.splice(i, 1, ...expr.properties);
  21900. // Step back one, as the property at i is now new.
  21901. i--;
  21902. } else if ((
  21903. // `expr.is_constant()` returns `false` for `AST_RegExp`, so need both.
  21904. expr instanceof AST_Constant
  21905. || expr.is_constant()
  21906. ) && !(expr instanceof AST_String)) {
  21907. // Unlike array-like spread, in object spread, spreading a
  21908. // non-iterable value silently does nothing; it is thus safe
  21909. // to remove. AST_String is the only iterable constant.
  21910. props.splice(i, 1);
  21911. i--;
  21912. }
  21913. }
  21914. }
  21915. }
  21916. def_optimize(AST_Object, function(self, compressor) {
  21917. var optimized = literals_in_boolean_context(self, compressor);
  21918. if (optimized !== self) {
  21919. return optimized;
  21920. }
  21921. inline_object_prop_spread(self.properties);
  21922. return self;
  21923. });
  21924. def_optimize(AST_RegExp, literals_in_boolean_context);
  21925. def_optimize(AST_Return, function(self, compressor) {
  21926. if (self.value && is_undefined(self.value, compressor)) {
  21927. self.value = null;
  21928. }
  21929. return self;
  21930. });
  21931. def_optimize(AST_Arrow, opt_AST_Lambda);
  21932. def_optimize(AST_Function, function(self, compressor) {
  21933. self = opt_AST_Lambda(self, compressor);
  21934. if (compressor.option("unsafe_arrows")
  21935. && compressor.option("ecma") >= 2015
  21936. && !self.name
  21937. && !self.is_generator
  21938. && !self.uses_arguments
  21939. && !self.pinned()) {
  21940. const uses_this = walk(self, node => {
  21941. if (node instanceof AST_This) return walk_abort;
  21942. });
  21943. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  21944. }
  21945. return self;
  21946. });
  21947. def_optimize(AST_Class, function(self) {
  21948. for (let i = 0; i < self.properties.length; i++) {
  21949. const prop = self.properties[i];
  21950. if (prop instanceof AST_ClassStaticBlock && prop.body.length == 0) {
  21951. self.properties.splice(i, 1);
  21952. i--;
  21953. }
  21954. }
  21955. return self;
  21956. });
  21957. def_optimize(AST_ClassStaticBlock, function(self, compressor) {
  21958. tighten_body(self.body, compressor);
  21959. return self;
  21960. });
  21961. def_optimize(AST_Yield, function(self, compressor) {
  21962. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  21963. self.expression = null;
  21964. }
  21965. return self;
  21966. });
  21967. def_optimize(AST_TemplateString, function(self, compressor) {
  21968. if (
  21969. !compressor.option("evaluate")
  21970. || compressor.parent() instanceof AST_PrefixedTemplateString
  21971. ) {
  21972. return self;
  21973. }
  21974. var segments = [];
  21975. for (var i = 0; i < self.segments.length; i++) {
  21976. var segment = self.segments[i];
  21977. if (segment instanceof AST_Node) {
  21978. var result = segment.evaluate(compressor);
  21979. // Evaluate to constant value
  21980. // Constant value shorter than ${segment}
  21981. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  21982. // There should always be a previous and next segment if segment is a node
  21983. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  21984. continue;
  21985. }
  21986. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  21987. // TODO:
  21988. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  21989. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  21990. if (segment instanceof AST_TemplateString) {
  21991. var inners = segment.segments;
  21992. segments[segments.length - 1].value += inners[0].value;
  21993. for (var j = 1; j < inners.length; j++) {
  21994. segment = inners[j];
  21995. segments.push(segment);
  21996. }
  21997. continue;
  21998. }
  21999. }
  22000. segments.push(segment);
  22001. }
  22002. self.segments = segments;
  22003. // `foo` => "foo"
  22004. if (segments.length == 1) {
  22005. return make_node(AST_String, self, segments[0]);
  22006. }
  22007. if (
  22008. segments.length === 3
  22009. && segments[1] instanceof AST_Node
  22010. && (
  22011. segments[1].is_string(compressor)
  22012. || segments[1].is_number_or_bigint(compressor)
  22013. || is_nullish(segments[1], compressor)
  22014. || compressor.option("unsafe")
  22015. )
  22016. ) {
  22017. // `foo${bar}` => "foo" + bar
  22018. if (segments[2].value === "") {
  22019. return make_node(AST_Binary, self, {
  22020. operator: "+",
  22021. left: make_node(AST_String, self, {
  22022. value: segments[0].value,
  22023. }),
  22024. right: segments[1],
  22025. });
  22026. }
  22027. // `${bar}baz` => bar + "baz"
  22028. if (segments[0].value === "") {
  22029. return make_node(AST_Binary, self, {
  22030. operator: "+",
  22031. left: segments[1],
  22032. right: make_node(AST_String, self, {
  22033. value: segments[2].value,
  22034. }),
  22035. });
  22036. }
  22037. }
  22038. return self;
  22039. });
  22040. def_optimize(AST_PrefixedTemplateString, function(self) {
  22041. return self;
  22042. });
  22043. // ["p"]:1 ---> p:1
  22044. // [42]:1 ---> 42:1
  22045. function lift_key(self, compressor) {
  22046. if (!compressor.option("computed_props")) return self;
  22047. // save a comparison in the typical case
  22048. if (!(self.key instanceof AST_Constant)) return self;
  22049. // allow certain acceptable props as not all AST_Constants are true constants
  22050. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  22051. const key = self.key.value.toString();
  22052. if (key === "__proto__") return self;
  22053. if (key == "constructor"
  22054. && compressor.parent() instanceof AST_Class) return self;
  22055. if (self instanceof AST_ObjectKeyVal) {
  22056. self.quote = self.key.quote;
  22057. self.key = key;
  22058. } else if (self instanceof AST_ClassProperty) {
  22059. self.quote = self.key.quote;
  22060. self.key = make_node(AST_SymbolClassProperty, self.key, {
  22061. name: key,
  22062. });
  22063. } else {
  22064. self.quote = self.key.quote;
  22065. self.key = make_node(AST_SymbolMethod, self.key, {
  22066. name: key,
  22067. });
  22068. }
  22069. }
  22070. return self;
  22071. }
  22072. def_optimize(AST_ObjectProperty, lift_key);
  22073. def_optimize(AST_ConciseMethod, function(self, compressor) {
  22074. lift_key(self, compressor);
  22075. // p(){return x;} ---> p:()=>x
  22076. if (compressor.option("arrows")
  22077. && compressor.parent() instanceof AST_Object
  22078. && !self.value.is_generator
  22079. && !self.value.uses_arguments
  22080. && !self.value.pinned()
  22081. && self.value.body.length == 1
  22082. && self.value.body[0] instanceof AST_Return
  22083. && self.value.body[0].value
  22084. && !self.value.contains_this()) {
  22085. var arrow = make_node(AST_Arrow, self.value, self.value);
  22086. arrow.async = self.value.async;
  22087. arrow.is_generator = self.value.is_generator;
  22088. return make_node(AST_ObjectKeyVal, self, {
  22089. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  22090. value: arrow,
  22091. quote: self.quote,
  22092. });
  22093. }
  22094. return self;
  22095. });
  22096. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  22097. lift_key(self, compressor);
  22098. // p:function(){} ---> p(){}
  22099. // p:function*(){} ---> *p(){}
  22100. // p:async function(){} ---> async p(){}
  22101. // p:()=>{} ---> p(){}
  22102. // p:async()=>{} ---> async p(){}
  22103. var unsafe_methods = compressor.option("unsafe_methods");
  22104. if (unsafe_methods
  22105. && compressor.option("ecma") >= 2015
  22106. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  22107. var key = self.key;
  22108. var value = self.value;
  22109. var is_arrow_with_block = value instanceof AST_Arrow
  22110. && Array.isArray(value.body)
  22111. && !value.contains_this();
  22112. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  22113. return make_node(AST_ConciseMethod, self, {
  22114. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  22115. name: key,
  22116. }),
  22117. value: make_node(AST_Accessor, value, value),
  22118. quote: self.quote,
  22119. });
  22120. }
  22121. }
  22122. return self;
  22123. });
  22124. def_optimize(AST_Destructuring, function(self, compressor) {
  22125. if (compressor.option("pure_getters") == true
  22126. && compressor.option("unused")
  22127. && !self.is_array
  22128. && Array.isArray(self.names)
  22129. && !is_destructuring_export_decl(compressor)
  22130. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  22131. var keep = [];
  22132. for (var i = 0; i < self.names.length; i++) {
  22133. var elem = self.names[i];
  22134. if (!(elem instanceof AST_ObjectKeyVal
  22135. && typeof elem.key == "string"
  22136. && elem.value instanceof AST_SymbolDeclaration
  22137. && !should_retain(compressor, elem.value.definition()))) {
  22138. keep.push(elem);
  22139. }
  22140. }
  22141. if (keep.length != self.names.length) {
  22142. self.names = keep;
  22143. }
  22144. }
  22145. return self;
  22146. function is_destructuring_export_decl(compressor) {
  22147. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  22148. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  22149. var parent = compressor.parent(p);
  22150. if (!parent) return false;
  22151. if (a === 0 && parent.TYPE == "Destructuring") continue;
  22152. if (!ancestors[a].test(parent.TYPE)) {
  22153. return false;
  22154. }
  22155. a++;
  22156. }
  22157. return true;
  22158. }
  22159. function should_retain(compressor, def) {
  22160. if (def.references.length) return true;
  22161. if (!def.global) return false;
  22162. if (compressor.toplevel.vars) {
  22163. if (compressor.top_retain) {
  22164. return compressor.top_retain(def);
  22165. }
  22166. return false;
  22167. }
  22168. return true;
  22169. }
  22170. });
  22171. /***********************************************************************
  22172. A JavaScript tokenizer / parser / beautifier / compressor.
  22173. https://github.com/mishoo/UglifyJS2
  22174. -------------------------------- (C) ---------------------------------
  22175. Author: Mihai Bazon
  22176. <mihai.bazon@gmail.com>
  22177. http://mihai.bazon.net/blog
  22178. Distributed under the BSD license:
  22179. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  22180. Redistribution and use in source and binary forms, with or without
  22181. modification, are permitted provided that the following conditions
  22182. are met:
  22183. * Redistributions of source code must retain the above
  22184. copyright notice, this list of conditions and the following
  22185. disclaimer.
  22186. * Redistributions in binary form must reproduce the above
  22187. copyright notice, this list of conditions and the following
  22188. disclaimer in the documentation and/or other materials
  22189. provided with the distribution.
  22190. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  22191. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22192. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22193. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  22194. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  22195. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22196. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  22197. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22198. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  22199. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  22200. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22201. SUCH DAMAGE.
  22202. ***********************************************************************/
  22203. // a small wrapper around source-map and @jridgewell/source-map
  22204. function* SourceMap(options) {
  22205. options = defaults(options, {
  22206. file : null,
  22207. root : null,
  22208. orig : null,
  22209. files: {},
  22210. });
  22211. var orig_map;
  22212. var generator = new sourceMap.SourceMapGenerator({
  22213. file : options.file,
  22214. sourceRoot : options.root
  22215. });
  22216. let sourcesContent = {__proto__: null};
  22217. let files = options.files;
  22218. for (var name in files) if (HOP(files, name)) {
  22219. sourcesContent[name] = files[name];
  22220. }
  22221. if (options.orig) {
  22222. // We support both @jridgewell/source-map (which has a sync
  22223. // SourceMapConsumer) and source-map (which has an async
  22224. // SourceMapConsumer).
  22225. orig_map = yield new sourceMap.SourceMapConsumer(options.orig);
  22226. if (orig_map.sourcesContent) {
  22227. orig_map.sources.forEach(function(source, i) {
  22228. var content = orig_map.sourcesContent[i];
  22229. if (content) {
  22230. sourcesContent[source] = content;
  22231. }
  22232. });
  22233. }
  22234. }
  22235. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  22236. let generatedPos = { line: gen_line, column: gen_col };
  22237. if (orig_map) {
  22238. var info = orig_map.originalPositionFor({
  22239. line: orig_line,
  22240. column: orig_col
  22241. });
  22242. if (info.source === null) {
  22243. generator.addMapping({
  22244. generated: generatedPos,
  22245. original: null,
  22246. source: null,
  22247. name: null
  22248. });
  22249. return;
  22250. }
  22251. source = info.source;
  22252. orig_line = info.line;
  22253. orig_col = info.column;
  22254. name = info.name || name;
  22255. }
  22256. generator.addMapping({
  22257. generated : generatedPos,
  22258. original : { line: orig_line, column: orig_col },
  22259. source : source,
  22260. name : name
  22261. });
  22262. generator.setSourceContent(source, sourcesContent[source]);
  22263. }
  22264. function clean(map) {
  22265. const allNull = map.sourcesContent && map.sourcesContent.every(c => c == null);
  22266. if (allNull) delete map.sourcesContent;
  22267. if (map.file === undefined) delete map.file;
  22268. if (map.sourceRoot === undefined) delete map.sourceRoot;
  22269. return map;
  22270. }
  22271. function getDecoded() {
  22272. if (!generator.toDecodedMap) return null;
  22273. return clean(generator.toDecodedMap());
  22274. }
  22275. function getEncoded() {
  22276. return clean(generator.toJSON());
  22277. }
  22278. function destroy() {
  22279. // @jridgewell/source-map's SourceMapConsumer does not need to be
  22280. // manually freed.
  22281. if (orig_map && orig_map.destroy) orig_map.destroy();
  22282. }
  22283. return {
  22284. add,
  22285. getDecoded,
  22286. getEncoded,
  22287. destroy,
  22288. };
  22289. }
  22290. var domprops = [
  22291. "$&",
  22292. "$'",
  22293. "$*",
  22294. "$+",
  22295. "$1",
  22296. "$2",
  22297. "$3",
  22298. "$4",
  22299. "$5",
  22300. "$6",
  22301. "$7",
  22302. "$8",
  22303. "$9",
  22304. "$_",
  22305. "$`",
  22306. "$input",
  22307. "-moz-animation",
  22308. "-moz-animation-delay",
  22309. "-moz-animation-direction",
  22310. "-moz-animation-duration",
  22311. "-moz-animation-fill-mode",
  22312. "-moz-animation-iteration-count",
  22313. "-moz-animation-name",
  22314. "-moz-animation-play-state",
  22315. "-moz-animation-timing-function",
  22316. "-moz-appearance",
  22317. "-moz-backface-visibility",
  22318. "-moz-border-end",
  22319. "-moz-border-end-color",
  22320. "-moz-border-end-style",
  22321. "-moz-border-end-width",
  22322. "-moz-border-image",
  22323. "-moz-border-start",
  22324. "-moz-border-start-color",
  22325. "-moz-border-start-style",
  22326. "-moz-border-start-width",
  22327. "-moz-box-align",
  22328. "-moz-box-direction",
  22329. "-moz-box-flex",
  22330. "-moz-box-ordinal-group",
  22331. "-moz-box-orient",
  22332. "-moz-box-pack",
  22333. "-moz-box-sizing",
  22334. "-moz-float-edge",
  22335. "-moz-font-feature-settings",
  22336. "-moz-font-language-override",
  22337. "-moz-force-broken-image-icon",
  22338. "-moz-hyphens",
  22339. "-moz-image-region",
  22340. "-moz-margin-end",
  22341. "-moz-margin-start",
  22342. "-moz-orient",
  22343. "-moz-osx-font-smoothing",
  22344. "-moz-outline-radius",
  22345. "-moz-outline-radius-bottomleft",
  22346. "-moz-outline-radius-bottomright",
  22347. "-moz-outline-radius-topleft",
  22348. "-moz-outline-radius-topright",
  22349. "-moz-padding-end",
  22350. "-moz-padding-start",
  22351. "-moz-perspective",
  22352. "-moz-perspective-origin",
  22353. "-moz-tab-size",
  22354. "-moz-text-size-adjust",
  22355. "-moz-transform",
  22356. "-moz-transform-origin",
  22357. "-moz-transform-style",
  22358. "-moz-transition",
  22359. "-moz-transition-delay",
  22360. "-moz-transition-duration",
  22361. "-moz-transition-property",
  22362. "-moz-transition-timing-function",
  22363. "-moz-user-focus",
  22364. "-moz-user-input",
  22365. "-moz-user-modify",
  22366. "-moz-user-select",
  22367. "-moz-window-dragging",
  22368. "-webkit-align-content",
  22369. "-webkit-align-items",
  22370. "-webkit-align-self",
  22371. "-webkit-animation",
  22372. "-webkit-animation-delay",
  22373. "-webkit-animation-direction",
  22374. "-webkit-animation-duration",
  22375. "-webkit-animation-fill-mode",
  22376. "-webkit-animation-iteration-count",
  22377. "-webkit-animation-name",
  22378. "-webkit-animation-play-state",
  22379. "-webkit-animation-timing-function",
  22380. "-webkit-appearance",
  22381. "-webkit-backface-visibility",
  22382. "-webkit-background-clip",
  22383. "-webkit-background-origin",
  22384. "-webkit-background-size",
  22385. "-webkit-border-bottom-left-radius",
  22386. "-webkit-border-bottom-right-radius",
  22387. "-webkit-border-image",
  22388. "-webkit-border-radius",
  22389. "-webkit-border-top-left-radius",
  22390. "-webkit-border-top-right-radius",
  22391. "-webkit-box-align",
  22392. "-webkit-box-direction",
  22393. "-webkit-box-flex",
  22394. "-webkit-box-ordinal-group",
  22395. "-webkit-box-orient",
  22396. "-webkit-box-pack",
  22397. "-webkit-box-shadow",
  22398. "-webkit-box-sizing",
  22399. "-webkit-clip-path",
  22400. "-webkit-filter",
  22401. "-webkit-flex",
  22402. "-webkit-flex-basis",
  22403. "-webkit-flex-direction",
  22404. "-webkit-flex-flow",
  22405. "-webkit-flex-grow",
  22406. "-webkit-flex-shrink",
  22407. "-webkit-flex-wrap",
  22408. "-webkit-font-feature-settings",
  22409. "-webkit-justify-content",
  22410. "-webkit-line-clamp",
  22411. "-webkit-mask",
  22412. "-webkit-mask-clip",
  22413. "-webkit-mask-composite",
  22414. "-webkit-mask-image",
  22415. "-webkit-mask-origin",
  22416. "-webkit-mask-position",
  22417. "-webkit-mask-position-x",
  22418. "-webkit-mask-position-y",
  22419. "-webkit-mask-repeat",
  22420. "-webkit-mask-size",
  22421. "-webkit-order",
  22422. "-webkit-perspective",
  22423. "-webkit-perspective-origin",
  22424. "-webkit-text-fill-color",
  22425. "-webkit-text-security",
  22426. "-webkit-text-size-adjust",
  22427. "-webkit-text-stroke",
  22428. "-webkit-text-stroke-color",
  22429. "-webkit-text-stroke-width",
  22430. "-webkit-transform",
  22431. "-webkit-transform-origin",
  22432. "-webkit-transform-style",
  22433. "-webkit-transition",
  22434. "-webkit-transition-delay",
  22435. "-webkit-transition-duration",
  22436. "-webkit-transition-property",
  22437. "-webkit-transition-timing-function",
  22438. "-webkit-user-select",
  22439. "@@iterator",
  22440. "ABORT_ERR",
  22441. "ACTIVE",
  22442. "ACTIVE_ATTRIBUTES",
  22443. "ACTIVE_TEXTURE",
  22444. "ACTIVE_UNIFORMS",
  22445. "ACTIVE_UNIFORM_BLOCKS",
  22446. "ADDITION",
  22447. "ALIASED_LINE_WIDTH_RANGE",
  22448. "ALIASED_POINT_SIZE_RANGE",
  22449. "ALL",
  22450. "ALLOW_KEYBOARD_INPUT",
  22451. "ALLPASS",
  22452. "ALPHA",
  22453. "ALPHA_BITS",
  22454. "ALREADY_SIGNALED",
  22455. "ALT_MASK",
  22456. "ALWAYS",
  22457. "ANY_SAMPLES_PASSED",
  22458. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  22459. "ANY_TYPE",
  22460. "ANY_UNORDERED_NODE_TYPE",
  22461. "ARRAY_BUFFER",
  22462. "ARRAY_BUFFER_BINDING",
  22463. "ATTACHED_SHADERS",
  22464. "ATTRIBUTE_NODE",
  22465. "AT_TARGET",
  22466. "AbortController",
  22467. "AbortSignal",
  22468. "AbsoluteOrientationSensor",
  22469. "AbstractRange",
  22470. "Accelerometer",
  22471. "AddSearchProvider",
  22472. "AggregateError",
  22473. "AnalyserNode",
  22474. "Animation",
  22475. "AnimationEffect",
  22476. "AnimationEvent",
  22477. "AnimationPlaybackEvent",
  22478. "AnimationTimeline",
  22479. "AnonXMLHttpRequest",
  22480. "Any",
  22481. "AnyPermissions",
  22482. "ApplicationCache",
  22483. "ApplicationCacheErrorEvent",
  22484. "Array",
  22485. "ArrayBuffer",
  22486. "ArrayType",
  22487. "AsyncDisposableStack",
  22488. "Atomics",
  22489. "Attr",
  22490. "Audio",
  22491. "AudioBuffer",
  22492. "AudioBufferSourceNode",
  22493. "AudioContext",
  22494. "AudioData",
  22495. "AudioDecoder",
  22496. "AudioDestinationNode",
  22497. "AudioEncoder",
  22498. "AudioListener",
  22499. "AudioNode",
  22500. "AudioParam",
  22501. "AudioParamMap",
  22502. "AudioProcessingEvent",
  22503. "AudioScheduledSourceNode",
  22504. "AudioSinkInfo",
  22505. "AudioStreamTrack",
  22506. "AudioWorklet",
  22507. "AudioWorkletNode",
  22508. "AuthenticatorAssertionResponse",
  22509. "AuthenticatorAttestationResponse",
  22510. "AuthenticatorResponse",
  22511. "AutocompleteErrorEvent",
  22512. "BACK",
  22513. "BAD_BOUNDARYPOINTS_ERR",
  22514. "BAD_REQUEST",
  22515. "BANDPASS",
  22516. "BLEND",
  22517. "BLEND_COLOR",
  22518. "BLEND_DST_ALPHA",
  22519. "BLEND_DST_RGB",
  22520. "BLEND_EQUATION",
  22521. "BLEND_EQUATION_ALPHA",
  22522. "BLEND_EQUATION_RGB",
  22523. "BLEND_SRC_ALPHA",
  22524. "BLEND_SRC_RGB",
  22525. "BLUE",
  22526. "BLUE_BITS",
  22527. "BLUR",
  22528. "BOOL",
  22529. "BOOLEAN_TYPE",
  22530. "BOOL_VEC2",
  22531. "BOOL_VEC3",
  22532. "BOOL_VEC4",
  22533. "BOTH",
  22534. "BROWSER_DEFAULT_WEBGL",
  22535. "BUBBLING_PHASE",
  22536. "BUFFER_SIZE",
  22537. "BUFFER_USAGE",
  22538. "BYTE",
  22539. "BYTES_PER_ELEMENT",
  22540. "BackgroundFetchManager",
  22541. "BackgroundFetchRecord",
  22542. "BackgroundFetchRegistration",
  22543. "BarProp",
  22544. "BarcodeDetector",
  22545. "BaseAudioContext",
  22546. "BaseHref",
  22547. "BatteryManager",
  22548. "BeforeInstallPromptEvent",
  22549. "BeforeLoadEvent",
  22550. "BeforeUnloadEvent",
  22551. "BigInt",
  22552. "BigInt64Array",
  22553. "BigUint64Array",
  22554. "BiquadFilterNode",
  22555. "Blob",
  22556. "BlobEvent",
  22557. "Bluetooth",
  22558. "BluetoothCharacteristicProperties",
  22559. "BluetoothDevice",
  22560. "BluetoothRemoteGATTCharacteristic",
  22561. "BluetoothRemoteGATTDescriptor",
  22562. "BluetoothRemoteGATTServer",
  22563. "BluetoothRemoteGATTService",
  22564. "BluetoothUUID",
  22565. "Boolean",
  22566. "BroadcastChannel",
  22567. "BrowserCaptureMediaStreamTrack",
  22568. "BrowserInfo",
  22569. "ByteLengthQueuingStrategy",
  22570. "CAPTURING_PHASE",
  22571. "CCW",
  22572. "CDATASection",
  22573. "CDATA_SECTION_NODE",
  22574. "CHANGE",
  22575. "CHARSET_RULE",
  22576. "CHECKING",
  22577. "CLAMP_TO_EDGE",
  22578. "CLICK",
  22579. "CLOSED",
  22580. "CLOSING",
  22581. "COLOR",
  22582. "COLOR_ATTACHMENT0",
  22583. "COLOR_ATTACHMENT1",
  22584. "COLOR_ATTACHMENT10",
  22585. "COLOR_ATTACHMENT11",
  22586. "COLOR_ATTACHMENT12",
  22587. "COLOR_ATTACHMENT13",
  22588. "COLOR_ATTACHMENT14",
  22589. "COLOR_ATTACHMENT15",
  22590. "COLOR_ATTACHMENT2",
  22591. "COLOR_ATTACHMENT3",
  22592. "COLOR_ATTACHMENT4",
  22593. "COLOR_ATTACHMENT5",
  22594. "COLOR_ATTACHMENT6",
  22595. "COLOR_ATTACHMENT7",
  22596. "COLOR_ATTACHMENT8",
  22597. "COLOR_ATTACHMENT9",
  22598. "COLOR_BUFFER_BIT",
  22599. "COLOR_CLEAR_VALUE",
  22600. "COLOR_WRITEMASK",
  22601. "COMMENT_NODE",
  22602. "COMPARE_REF_TO_TEXTURE",
  22603. "COMPILE_STATUS",
  22604. "COMPLETION_STATUS_KHR",
  22605. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  22606. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  22607. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  22608. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  22609. "COMPRESSED_TEXTURE_FORMATS",
  22610. "COMPUTE",
  22611. "CONDITION_SATISFIED",
  22612. "CONFIGURATION_UNSUPPORTED",
  22613. "CONNECTING",
  22614. "CONSTANT_ALPHA",
  22615. "CONSTANT_COLOR",
  22616. "CONSTRAINT_ERR",
  22617. "CONTEXT_LOST_WEBGL",
  22618. "CONTROL_MASK",
  22619. "COPY_DST",
  22620. "COPY_READ_BUFFER",
  22621. "COPY_READ_BUFFER_BINDING",
  22622. "COPY_SRC",
  22623. "COPY_WRITE_BUFFER",
  22624. "COPY_WRITE_BUFFER_BINDING",
  22625. "COUNTER_STYLE_RULE",
  22626. "CSPViolationReportBody",
  22627. "CSS",
  22628. "CSS2Properties",
  22629. "CSSAnimation",
  22630. "CSSCharsetRule",
  22631. "CSSConditionRule",
  22632. "CSSContainerRule",
  22633. "CSSCounterStyleRule",
  22634. "CSSFontFaceRule",
  22635. "CSSFontFeatureValuesRule",
  22636. "CSSFontPaletteValuesRule",
  22637. "CSSFunctionDeclarations",
  22638. "CSSFunctionDescriptors",
  22639. "CSSFunctionRule",
  22640. "CSSGroupingRule",
  22641. "CSSImageValue",
  22642. "CSSImportRule",
  22643. "CSSKeyframeRule",
  22644. "CSSKeyframesRule",
  22645. "CSSKeywordValue",
  22646. "CSSLayerBlockRule",
  22647. "CSSLayerStatementRule",
  22648. "CSSMarginRule",
  22649. "CSSMathClamp",
  22650. "CSSMathInvert",
  22651. "CSSMathMax",
  22652. "CSSMathMin",
  22653. "CSSMathNegate",
  22654. "CSSMathProduct",
  22655. "CSSMathSum",
  22656. "CSSMathValue",
  22657. "CSSMatrixComponent",
  22658. "CSSMediaRule",
  22659. "CSSMozDocumentRule",
  22660. "CSSNameSpaceRule",
  22661. "CSSNamespaceRule",
  22662. "CSSNestedDeclarations",
  22663. "CSSNumericArray",
  22664. "CSSNumericValue",
  22665. "CSSPageDescriptors",
  22666. "CSSPageRule",
  22667. "CSSPerspective",
  22668. "CSSPositionTryDescriptors",
  22669. "CSSPositionTryRule",
  22670. "CSSPositionValue",
  22671. "CSSPrimitiveValue",
  22672. "CSSPropertyRule",
  22673. "CSSRotate",
  22674. "CSSRule",
  22675. "CSSRuleList",
  22676. "CSSScale",
  22677. "CSSScopeRule",
  22678. "CSSSkew",
  22679. "CSSSkewX",
  22680. "CSSSkewY",
  22681. "CSSStartingStyleRule",
  22682. "CSSStyleDeclaration",
  22683. "CSSStyleProperties",
  22684. "CSSStyleRule",
  22685. "CSSStyleSheet",
  22686. "CSSStyleValue",
  22687. "CSSSupportsRule",
  22688. "CSSTransformComponent",
  22689. "CSSTransformValue",
  22690. "CSSTransition",
  22691. "CSSTranslate",
  22692. "CSSUnitValue",
  22693. "CSSUnknownRule",
  22694. "CSSUnparsedValue",
  22695. "CSSValue",
  22696. "CSSValueList",
  22697. "CSSVariableReferenceValue",
  22698. "CSSVariablesDeclaration",
  22699. "CSSVariablesRule",
  22700. "CSSViewTransitionRule",
  22701. "CSSViewportRule",
  22702. "CSS_ATTR",
  22703. "CSS_CM",
  22704. "CSS_COUNTER",
  22705. "CSS_CUSTOM",
  22706. "CSS_DEG",
  22707. "CSS_DIMENSION",
  22708. "CSS_EMS",
  22709. "CSS_EXS",
  22710. "CSS_FILTER_BLUR",
  22711. "CSS_FILTER_BRIGHTNESS",
  22712. "CSS_FILTER_CONTRAST",
  22713. "CSS_FILTER_CUSTOM",
  22714. "CSS_FILTER_DROP_SHADOW",
  22715. "CSS_FILTER_GRAYSCALE",
  22716. "CSS_FILTER_HUE_ROTATE",
  22717. "CSS_FILTER_INVERT",
  22718. "CSS_FILTER_OPACITY",
  22719. "CSS_FILTER_REFERENCE",
  22720. "CSS_FILTER_SATURATE",
  22721. "CSS_FILTER_SEPIA",
  22722. "CSS_GRAD",
  22723. "CSS_HZ",
  22724. "CSS_IDENT",
  22725. "CSS_IN",
  22726. "CSS_INHERIT",
  22727. "CSS_KHZ",
  22728. "CSS_MATRIX",
  22729. "CSS_MATRIX3D",
  22730. "CSS_MM",
  22731. "CSS_MS",
  22732. "CSS_NUMBER",
  22733. "CSS_PC",
  22734. "CSS_PERCENTAGE",
  22735. "CSS_PERSPECTIVE",
  22736. "CSS_PRIMITIVE_VALUE",
  22737. "CSS_PT",
  22738. "CSS_PX",
  22739. "CSS_RAD",
  22740. "CSS_RECT",
  22741. "CSS_RGBCOLOR",
  22742. "CSS_ROTATE",
  22743. "CSS_ROTATE3D",
  22744. "CSS_ROTATEX",
  22745. "CSS_ROTATEY",
  22746. "CSS_ROTATEZ",
  22747. "CSS_S",
  22748. "CSS_SCALE",
  22749. "CSS_SCALE3D",
  22750. "CSS_SCALEX",
  22751. "CSS_SCALEY",
  22752. "CSS_SCALEZ",
  22753. "CSS_SKEW",
  22754. "CSS_SKEWX",
  22755. "CSS_SKEWY",
  22756. "CSS_STRING",
  22757. "CSS_TRANSLATE",
  22758. "CSS_TRANSLATE3D",
  22759. "CSS_TRANSLATEX",
  22760. "CSS_TRANSLATEY",
  22761. "CSS_TRANSLATEZ",
  22762. "CSS_UNKNOWN",
  22763. "CSS_URI",
  22764. "CSS_VALUE_LIST",
  22765. "CSS_VH",
  22766. "CSS_VMAX",
  22767. "CSS_VMIN",
  22768. "CSS_VW",
  22769. "CULL_FACE",
  22770. "CULL_FACE_MODE",
  22771. "CURRENT_PROGRAM",
  22772. "CURRENT_QUERY",
  22773. "CURRENT_VERTEX_ATTRIB",
  22774. "CUSTOM",
  22775. "CW",
  22776. "Cache",
  22777. "CacheStorage",
  22778. "CanvasCaptureMediaStream",
  22779. "CanvasCaptureMediaStreamTrack",
  22780. "CanvasGradient",
  22781. "CanvasPattern",
  22782. "CanvasRenderingContext2D",
  22783. "CaptureController",
  22784. "CaretPosition",
  22785. "ChannelMergerNode",
  22786. "ChannelSplitterNode",
  22787. "ChapterInformation",
  22788. "CharacterBoundsUpdateEvent",
  22789. "CharacterData",
  22790. "ClientRect",
  22791. "ClientRectList",
  22792. "Clipboard",
  22793. "ClipboardEvent",
  22794. "ClipboardItem",
  22795. "CloseEvent",
  22796. "CloseWatcher",
  22797. "Collator",
  22798. "ColorArray",
  22799. "ColorValue",
  22800. "CommandEvent",
  22801. "Comment",
  22802. "CompileError",
  22803. "CompositionEvent",
  22804. "CompressionStream",
  22805. "Console",
  22806. "ConstantSourceNode",
  22807. "ContentVisibilityAutoStateChangeEvent",
  22808. "ContextFilter",
  22809. "ContextType",
  22810. "Controllers",
  22811. "ConvolverNode",
  22812. "CookieChangeEvent",
  22813. "CookieStore",
  22814. "CookieStoreManager",
  22815. "CountQueuingStrategy",
  22816. "Counter",
  22817. "CreateMonitor",
  22818. "CreateType",
  22819. "Credential",
  22820. "CredentialsContainer",
  22821. "CropTarget",
  22822. "Crypto",
  22823. "CryptoKey",
  22824. "CustomElementRegistry",
  22825. "CustomEvent",
  22826. "CustomStateSet",
  22827. "DATABASE_ERR",
  22828. "DATA_CLONE_ERR",
  22829. "DATA_ERR",
  22830. "DBLCLICK",
  22831. "DECR",
  22832. "DECR_WRAP",
  22833. "DELETE_STATUS",
  22834. "DEPTH",
  22835. "DEPTH24_STENCIL8",
  22836. "DEPTH32F_STENCIL8",
  22837. "DEPTH_ATTACHMENT",
  22838. "DEPTH_BITS",
  22839. "DEPTH_BUFFER_BIT",
  22840. "DEPTH_CLEAR_VALUE",
  22841. "DEPTH_COMPONENT",
  22842. "DEPTH_COMPONENT16",
  22843. "DEPTH_COMPONENT24",
  22844. "DEPTH_COMPONENT32F",
  22845. "DEPTH_FUNC",
  22846. "DEPTH_RANGE",
  22847. "DEPTH_STENCIL",
  22848. "DEPTH_STENCIL_ATTACHMENT",
  22849. "DEPTH_TEST",
  22850. "DEPTH_WRITEMASK",
  22851. "DEVICE_INELIGIBLE",
  22852. "DIRECTION_DOWN",
  22853. "DIRECTION_LEFT",
  22854. "DIRECTION_RIGHT",
  22855. "DIRECTION_UP",
  22856. "DISABLED",
  22857. "DISPATCH_REQUEST_ERR",
  22858. "DITHER",
  22859. "DOCUMENT_FRAGMENT_NODE",
  22860. "DOCUMENT_NODE",
  22861. "DOCUMENT_POSITION_CONTAINED_BY",
  22862. "DOCUMENT_POSITION_CONTAINS",
  22863. "DOCUMENT_POSITION_DISCONNECTED",
  22864. "DOCUMENT_POSITION_FOLLOWING",
  22865. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  22866. "DOCUMENT_POSITION_PRECEDING",
  22867. "DOCUMENT_TYPE_NODE",
  22868. "DOMCursor",
  22869. "DOMError",
  22870. "DOMException",
  22871. "DOMImplementation",
  22872. "DOMImplementationLS",
  22873. "DOMMatrix",
  22874. "DOMMatrixReadOnly",
  22875. "DOMParser",
  22876. "DOMPoint",
  22877. "DOMPointReadOnly",
  22878. "DOMQuad",
  22879. "DOMRect",
  22880. "DOMRectList",
  22881. "DOMRectReadOnly",
  22882. "DOMRequest",
  22883. "DOMSTRING_SIZE_ERR",
  22884. "DOMSettableTokenList",
  22885. "DOMStringList",
  22886. "DOMStringMap",
  22887. "DOMTokenList",
  22888. "DOMTransactionEvent",
  22889. "DOM_DELTA_LINE",
  22890. "DOM_DELTA_PAGE",
  22891. "DOM_DELTA_PIXEL",
  22892. "DOM_INPUT_METHOD_DROP",
  22893. "DOM_INPUT_METHOD_HANDWRITING",
  22894. "DOM_INPUT_METHOD_IME",
  22895. "DOM_INPUT_METHOD_KEYBOARD",
  22896. "DOM_INPUT_METHOD_MULTIMODAL",
  22897. "DOM_INPUT_METHOD_OPTION",
  22898. "DOM_INPUT_METHOD_PASTE",
  22899. "DOM_INPUT_METHOD_SCRIPT",
  22900. "DOM_INPUT_METHOD_UNKNOWN",
  22901. "DOM_INPUT_METHOD_VOICE",
  22902. "DOM_KEY_LOCATION_JOYSTICK",
  22903. "DOM_KEY_LOCATION_LEFT",
  22904. "DOM_KEY_LOCATION_MOBILE",
  22905. "DOM_KEY_LOCATION_NUMPAD",
  22906. "DOM_KEY_LOCATION_RIGHT",
  22907. "DOM_KEY_LOCATION_STANDARD",
  22908. "DOM_VK_0",
  22909. "DOM_VK_1",
  22910. "DOM_VK_2",
  22911. "DOM_VK_3",
  22912. "DOM_VK_4",
  22913. "DOM_VK_5",
  22914. "DOM_VK_6",
  22915. "DOM_VK_7",
  22916. "DOM_VK_8",
  22917. "DOM_VK_9",
  22918. "DOM_VK_A",
  22919. "DOM_VK_ACCEPT",
  22920. "DOM_VK_ADD",
  22921. "DOM_VK_ALT",
  22922. "DOM_VK_ALTGR",
  22923. "DOM_VK_AMPERSAND",
  22924. "DOM_VK_ASTERISK",
  22925. "DOM_VK_AT",
  22926. "DOM_VK_ATTN",
  22927. "DOM_VK_B",
  22928. "DOM_VK_BACKSPACE",
  22929. "DOM_VK_BACK_QUOTE",
  22930. "DOM_VK_BACK_SLASH",
  22931. "DOM_VK_BACK_SPACE",
  22932. "DOM_VK_C",
  22933. "DOM_VK_CANCEL",
  22934. "DOM_VK_CAPS_LOCK",
  22935. "DOM_VK_CIRCUMFLEX",
  22936. "DOM_VK_CLEAR",
  22937. "DOM_VK_CLOSE_BRACKET",
  22938. "DOM_VK_CLOSE_CURLY_BRACKET",
  22939. "DOM_VK_CLOSE_PAREN",
  22940. "DOM_VK_COLON",
  22941. "DOM_VK_COMMA",
  22942. "DOM_VK_CONTEXT_MENU",
  22943. "DOM_VK_CONTROL",
  22944. "DOM_VK_CONVERT",
  22945. "DOM_VK_CRSEL",
  22946. "DOM_VK_CTRL",
  22947. "DOM_VK_D",
  22948. "DOM_VK_DECIMAL",
  22949. "DOM_VK_DELETE",
  22950. "DOM_VK_DIVIDE",
  22951. "DOM_VK_DOLLAR",
  22952. "DOM_VK_DOUBLE_QUOTE",
  22953. "DOM_VK_DOWN",
  22954. "DOM_VK_E",
  22955. "DOM_VK_EISU",
  22956. "DOM_VK_END",
  22957. "DOM_VK_ENTER",
  22958. "DOM_VK_EQUALS",
  22959. "DOM_VK_EREOF",
  22960. "DOM_VK_ESCAPE",
  22961. "DOM_VK_EXCLAMATION",
  22962. "DOM_VK_EXECUTE",
  22963. "DOM_VK_EXSEL",
  22964. "DOM_VK_F",
  22965. "DOM_VK_F1",
  22966. "DOM_VK_F10",
  22967. "DOM_VK_F11",
  22968. "DOM_VK_F12",
  22969. "DOM_VK_F13",
  22970. "DOM_VK_F14",
  22971. "DOM_VK_F15",
  22972. "DOM_VK_F16",
  22973. "DOM_VK_F17",
  22974. "DOM_VK_F18",
  22975. "DOM_VK_F19",
  22976. "DOM_VK_F2",
  22977. "DOM_VK_F20",
  22978. "DOM_VK_F21",
  22979. "DOM_VK_F22",
  22980. "DOM_VK_F23",
  22981. "DOM_VK_F24",
  22982. "DOM_VK_F25",
  22983. "DOM_VK_F26",
  22984. "DOM_VK_F27",
  22985. "DOM_VK_F28",
  22986. "DOM_VK_F29",
  22987. "DOM_VK_F3",
  22988. "DOM_VK_F30",
  22989. "DOM_VK_F31",
  22990. "DOM_VK_F32",
  22991. "DOM_VK_F33",
  22992. "DOM_VK_F34",
  22993. "DOM_VK_F35",
  22994. "DOM_VK_F36",
  22995. "DOM_VK_F4",
  22996. "DOM_VK_F5",
  22997. "DOM_VK_F6",
  22998. "DOM_VK_F7",
  22999. "DOM_VK_F8",
  23000. "DOM_VK_F9",
  23001. "DOM_VK_FINAL",
  23002. "DOM_VK_FRONT",
  23003. "DOM_VK_G",
  23004. "DOM_VK_GREATER_THAN",
  23005. "DOM_VK_H",
  23006. "DOM_VK_HANGUL",
  23007. "DOM_VK_HANJA",
  23008. "DOM_VK_HASH",
  23009. "DOM_VK_HELP",
  23010. "DOM_VK_HK_TOGGLE",
  23011. "DOM_VK_HOME",
  23012. "DOM_VK_HYPHEN_MINUS",
  23013. "DOM_VK_I",
  23014. "DOM_VK_INSERT",
  23015. "DOM_VK_J",
  23016. "DOM_VK_JUNJA",
  23017. "DOM_VK_K",
  23018. "DOM_VK_KANA",
  23019. "DOM_VK_KANJI",
  23020. "DOM_VK_L",
  23021. "DOM_VK_LEFT",
  23022. "DOM_VK_LEFT_TAB",
  23023. "DOM_VK_LESS_THAN",
  23024. "DOM_VK_M",
  23025. "DOM_VK_META",
  23026. "DOM_VK_MODECHANGE",
  23027. "DOM_VK_MULTIPLY",
  23028. "DOM_VK_N",
  23029. "DOM_VK_NONCONVERT",
  23030. "DOM_VK_NUMPAD0",
  23031. "DOM_VK_NUMPAD1",
  23032. "DOM_VK_NUMPAD2",
  23033. "DOM_VK_NUMPAD3",
  23034. "DOM_VK_NUMPAD4",
  23035. "DOM_VK_NUMPAD5",
  23036. "DOM_VK_NUMPAD6",
  23037. "DOM_VK_NUMPAD7",
  23038. "DOM_VK_NUMPAD8",
  23039. "DOM_VK_NUMPAD9",
  23040. "DOM_VK_NUM_LOCK",
  23041. "DOM_VK_O",
  23042. "DOM_VK_OEM_1",
  23043. "DOM_VK_OEM_102",
  23044. "DOM_VK_OEM_2",
  23045. "DOM_VK_OEM_3",
  23046. "DOM_VK_OEM_4",
  23047. "DOM_VK_OEM_5",
  23048. "DOM_VK_OEM_6",
  23049. "DOM_VK_OEM_7",
  23050. "DOM_VK_OEM_8",
  23051. "DOM_VK_OEM_COMMA",
  23052. "DOM_VK_OEM_MINUS",
  23053. "DOM_VK_OEM_PERIOD",
  23054. "DOM_VK_OEM_PLUS",
  23055. "DOM_VK_OPEN_BRACKET",
  23056. "DOM_VK_OPEN_CURLY_BRACKET",
  23057. "DOM_VK_OPEN_PAREN",
  23058. "DOM_VK_P",
  23059. "DOM_VK_PA1",
  23060. "DOM_VK_PAGEDOWN",
  23061. "DOM_VK_PAGEUP",
  23062. "DOM_VK_PAGE_DOWN",
  23063. "DOM_VK_PAGE_UP",
  23064. "DOM_VK_PAUSE",
  23065. "DOM_VK_PERCENT",
  23066. "DOM_VK_PERIOD",
  23067. "DOM_VK_PIPE",
  23068. "DOM_VK_PLAY",
  23069. "DOM_VK_PLUS",
  23070. "DOM_VK_PRINT",
  23071. "DOM_VK_PRINTSCREEN",
  23072. "DOM_VK_PROCESSKEY",
  23073. "DOM_VK_PROPERITES",
  23074. "DOM_VK_Q",
  23075. "DOM_VK_QUESTION_MARK",
  23076. "DOM_VK_QUOTE",
  23077. "DOM_VK_R",
  23078. "DOM_VK_REDO",
  23079. "DOM_VK_RETURN",
  23080. "DOM_VK_RIGHT",
  23081. "DOM_VK_S",
  23082. "DOM_VK_SCROLL_LOCK",
  23083. "DOM_VK_SELECT",
  23084. "DOM_VK_SEMICOLON",
  23085. "DOM_VK_SEPARATOR",
  23086. "DOM_VK_SHIFT",
  23087. "DOM_VK_SLASH",
  23088. "DOM_VK_SLEEP",
  23089. "DOM_VK_SPACE",
  23090. "DOM_VK_SUBTRACT",
  23091. "DOM_VK_T",
  23092. "DOM_VK_TAB",
  23093. "DOM_VK_TILDE",
  23094. "DOM_VK_U",
  23095. "DOM_VK_UNDERSCORE",
  23096. "DOM_VK_UNDO",
  23097. "DOM_VK_UNICODE",
  23098. "DOM_VK_UP",
  23099. "DOM_VK_V",
  23100. "DOM_VK_VOLUME_DOWN",
  23101. "DOM_VK_VOLUME_MUTE",
  23102. "DOM_VK_VOLUME_UP",
  23103. "DOM_VK_W",
  23104. "DOM_VK_WIN",
  23105. "DOM_VK_WINDOW",
  23106. "DOM_VK_WIN_ICO_00",
  23107. "DOM_VK_WIN_ICO_CLEAR",
  23108. "DOM_VK_WIN_ICO_HELP",
  23109. "DOM_VK_WIN_OEM_ATTN",
  23110. "DOM_VK_WIN_OEM_AUTO",
  23111. "DOM_VK_WIN_OEM_BACKTAB",
  23112. "DOM_VK_WIN_OEM_CLEAR",
  23113. "DOM_VK_WIN_OEM_COPY",
  23114. "DOM_VK_WIN_OEM_CUSEL",
  23115. "DOM_VK_WIN_OEM_ENLW",
  23116. "DOM_VK_WIN_OEM_FINISH",
  23117. "DOM_VK_WIN_OEM_FJ_JISHO",
  23118. "DOM_VK_WIN_OEM_FJ_LOYA",
  23119. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  23120. "DOM_VK_WIN_OEM_FJ_ROYA",
  23121. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  23122. "DOM_VK_WIN_OEM_JUMP",
  23123. "DOM_VK_WIN_OEM_PA1",
  23124. "DOM_VK_WIN_OEM_PA2",
  23125. "DOM_VK_WIN_OEM_PA3",
  23126. "DOM_VK_WIN_OEM_RESET",
  23127. "DOM_VK_WIN_OEM_WSCTRL",
  23128. "DOM_VK_X",
  23129. "DOM_VK_XF86XK_ADD_FAVORITE",
  23130. "DOM_VK_XF86XK_APPLICATION_LEFT",
  23131. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  23132. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  23133. "DOM_VK_XF86XK_AUDIO_FORWARD",
  23134. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  23135. "DOM_VK_XF86XK_AUDIO_MEDIA",
  23136. "DOM_VK_XF86XK_AUDIO_MUTE",
  23137. "DOM_VK_XF86XK_AUDIO_NEXT",
  23138. "DOM_VK_XF86XK_AUDIO_PAUSE",
  23139. "DOM_VK_XF86XK_AUDIO_PLAY",
  23140. "DOM_VK_XF86XK_AUDIO_PREV",
  23141. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  23142. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  23143. "DOM_VK_XF86XK_AUDIO_RECORD",
  23144. "DOM_VK_XF86XK_AUDIO_REPEAT",
  23145. "DOM_VK_XF86XK_AUDIO_REWIND",
  23146. "DOM_VK_XF86XK_AUDIO_STOP",
  23147. "DOM_VK_XF86XK_AWAY",
  23148. "DOM_VK_XF86XK_BACK",
  23149. "DOM_VK_XF86XK_BACK_FORWARD",
  23150. "DOM_VK_XF86XK_BATTERY",
  23151. "DOM_VK_XF86XK_BLUE",
  23152. "DOM_VK_XF86XK_BLUETOOTH",
  23153. "DOM_VK_XF86XK_BOOK",
  23154. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  23155. "DOM_VK_XF86XK_CALCULATOR",
  23156. "DOM_VK_XF86XK_CALENDAR",
  23157. "DOM_VK_XF86XK_CD",
  23158. "DOM_VK_XF86XK_CLOSE",
  23159. "DOM_VK_XF86XK_COMMUNITY",
  23160. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  23161. "DOM_VK_XF86XK_COPY",
  23162. "DOM_VK_XF86XK_CUT",
  23163. "DOM_VK_XF86XK_CYCLE_ANGLE",
  23164. "DOM_VK_XF86XK_DISPLAY",
  23165. "DOM_VK_XF86XK_DOCUMENTS",
  23166. "DOM_VK_XF86XK_DOS",
  23167. "DOM_VK_XF86XK_EJECT",
  23168. "DOM_VK_XF86XK_EXCEL",
  23169. "DOM_VK_XF86XK_EXPLORER",
  23170. "DOM_VK_XF86XK_FAVORITES",
  23171. "DOM_VK_XF86XK_FINANCE",
  23172. "DOM_VK_XF86XK_FORWARD",
  23173. "DOM_VK_XF86XK_FRAME_BACK",
  23174. "DOM_VK_XF86XK_FRAME_FORWARD",
  23175. "DOM_VK_XF86XK_GAME",
  23176. "DOM_VK_XF86XK_GO",
  23177. "DOM_VK_XF86XK_GREEN",
  23178. "DOM_VK_XF86XK_HIBERNATE",
  23179. "DOM_VK_XF86XK_HISTORY",
  23180. "DOM_VK_XF86XK_HOME_PAGE",
  23181. "DOM_VK_XF86XK_HOT_LINKS",
  23182. "DOM_VK_XF86XK_I_TOUCH",
  23183. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  23184. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  23185. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  23186. "DOM_VK_XF86XK_LAUNCH0",
  23187. "DOM_VK_XF86XK_LAUNCH1",
  23188. "DOM_VK_XF86XK_LAUNCH2",
  23189. "DOM_VK_XF86XK_LAUNCH3",
  23190. "DOM_VK_XF86XK_LAUNCH4",
  23191. "DOM_VK_XF86XK_LAUNCH5",
  23192. "DOM_VK_XF86XK_LAUNCH6",
  23193. "DOM_VK_XF86XK_LAUNCH7",
  23194. "DOM_VK_XF86XK_LAUNCH8",
  23195. "DOM_VK_XF86XK_LAUNCH9",
  23196. "DOM_VK_XF86XK_LAUNCH_A",
  23197. "DOM_VK_XF86XK_LAUNCH_B",
  23198. "DOM_VK_XF86XK_LAUNCH_C",
  23199. "DOM_VK_XF86XK_LAUNCH_D",
  23200. "DOM_VK_XF86XK_LAUNCH_E",
  23201. "DOM_VK_XF86XK_LAUNCH_F",
  23202. "DOM_VK_XF86XK_LIGHT_BULB",
  23203. "DOM_VK_XF86XK_LOG_OFF",
  23204. "DOM_VK_XF86XK_MAIL",
  23205. "DOM_VK_XF86XK_MAIL_FORWARD",
  23206. "DOM_VK_XF86XK_MARKET",
  23207. "DOM_VK_XF86XK_MEETING",
  23208. "DOM_VK_XF86XK_MEMO",
  23209. "DOM_VK_XF86XK_MENU_KB",
  23210. "DOM_VK_XF86XK_MENU_PB",
  23211. "DOM_VK_XF86XK_MESSENGER",
  23212. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  23213. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  23214. "DOM_VK_XF86XK_MUSIC",
  23215. "DOM_VK_XF86XK_MY_COMPUTER",
  23216. "DOM_VK_XF86XK_MY_SITES",
  23217. "DOM_VK_XF86XK_NEW",
  23218. "DOM_VK_XF86XK_NEWS",
  23219. "DOM_VK_XF86XK_OFFICE_HOME",
  23220. "DOM_VK_XF86XK_OPEN",
  23221. "DOM_VK_XF86XK_OPEN_URL",
  23222. "DOM_VK_XF86XK_OPTION",
  23223. "DOM_VK_XF86XK_PASTE",
  23224. "DOM_VK_XF86XK_PHONE",
  23225. "DOM_VK_XF86XK_PICTURES",
  23226. "DOM_VK_XF86XK_POWER_DOWN",
  23227. "DOM_VK_XF86XK_POWER_OFF",
  23228. "DOM_VK_XF86XK_RED",
  23229. "DOM_VK_XF86XK_REFRESH",
  23230. "DOM_VK_XF86XK_RELOAD",
  23231. "DOM_VK_XF86XK_REPLY",
  23232. "DOM_VK_XF86XK_ROCKER_DOWN",
  23233. "DOM_VK_XF86XK_ROCKER_ENTER",
  23234. "DOM_VK_XF86XK_ROCKER_UP",
  23235. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  23236. "DOM_VK_XF86XK_ROTATION_KB",
  23237. "DOM_VK_XF86XK_ROTATION_PB",
  23238. "DOM_VK_XF86XK_SAVE",
  23239. "DOM_VK_XF86XK_SCREEN_SAVER",
  23240. "DOM_VK_XF86XK_SCROLL_CLICK",
  23241. "DOM_VK_XF86XK_SCROLL_DOWN",
  23242. "DOM_VK_XF86XK_SCROLL_UP",
  23243. "DOM_VK_XF86XK_SEARCH",
  23244. "DOM_VK_XF86XK_SEND",
  23245. "DOM_VK_XF86XK_SHOP",
  23246. "DOM_VK_XF86XK_SPELL",
  23247. "DOM_VK_XF86XK_SPLIT_SCREEN",
  23248. "DOM_VK_XF86XK_STANDBY",
  23249. "DOM_VK_XF86XK_START",
  23250. "DOM_VK_XF86XK_STOP",
  23251. "DOM_VK_XF86XK_SUBTITLE",
  23252. "DOM_VK_XF86XK_SUPPORT",
  23253. "DOM_VK_XF86XK_SUSPEND",
  23254. "DOM_VK_XF86XK_TASK_PANE",
  23255. "DOM_VK_XF86XK_TERMINAL",
  23256. "DOM_VK_XF86XK_TIME",
  23257. "DOM_VK_XF86XK_TOOLS",
  23258. "DOM_VK_XF86XK_TOP_MENU",
  23259. "DOM_VK_XF86XK_TO_DO_LIST",
  23260. "DOM_VK_XF86XK_TRAVEL",
  23261. "DOM_VK_XF86XK_USER1KB",
  23262. "DOM_VK_XF86XK_USER2KB",
  23263. "DOM_VK_XF86XK_USER_PB",
  23264. "DOM_VK_XF86XK_UWB",
  23265. "DOM_VK_XF86XK_VENDOR_HOME",
  23266. "DOM_VK_XF86XK_VIDEO",
  23267. "DOM_VK_XF86XK_VIEW",
  23268. "DOM_VK_XF86XK_WAKE_UP",
  23269. "DOM_VK_XF86XK_WEB_CAM",
  23270. "DOM_VK_XF86XK_WHEEL_BUTTON",
  23271. "DOM_VK_XF86XK_WLAN",
  23272. "DOM_VK_XF86XK_WORD",
  23273. "DOM_VK_XF86XK_WWW",
  23274. "DOM_VK_XF86XK_XFER",
  23275. "DOM_VK_XF86XK_YELLOW",
  23276. "DOM_VK_XF86XK_ZOOM_IN",
  23277. "DOM_VK_XF86XK_ZOOM_OUT",
  23278. "DOM_VK_Y",
  23279. "DOM_VK_Z",
  23280. "DOM_VK_ZOOM",
  23281. "DONE",
  23282. "DONT_CARE",
  23283. "DOWNLOADING",
  23284. "DRAGDROP",
  23285. "DRAW_BUFFER0",
  23286. "DRAW_BUFFER1",
  23287. "DRAW_BUFFER10",
  23288. "DRAW_BUFFER11",
  23289. "DRAW_BUFFER12",
  23290. "DRAW_BUFFER13",
  23291. "DRAW_BUFFER14",
  23292. "DRAW_BUFFER15",
  23293. "DRAW_BUFFER2",
  23294. "DRAW_BUFFER3",
  23295. "DRAW_BUFFER4",
  23296. "DRAW_BUFFER5",
  23297. "DRAW_BUFFER6",
  23298. "DRAW_BUFFER7",
  23299. "DRAW_BUFFER8",
  23300. "DRAW_BUFFER9",
  23301. "DRAW_FRAMEBUFFER",
  23302. "DRAW_FRAMEBUFFER_BINDING",
  23303. "DST_ALPHA",
  23304. "DST_COLOR",
  23305. "DYNAMIC_COPY",
  23306. "DYNAMIC_DRAW",
  23307. "DYNAMIC_READ",
  23308. "DataChannel",
  23309. "DataTransfer",
  23310. "DataTransferItem",
  23311. "DataTransferItemList",
  23312. "DataView",
  23313. "Date",
  23314. "DateTimeFormat",
  23315. "DecompressionStream",
  23316. "DelayNode",
  23317. "DelegatedInkTrailPresenter",
  23318. "DeprecationReportBody",
  23319. "DesktopNotification",
  23320. "DesktopNotificationCenter",
  23321. "Details",
  23322. "DeviceLightEvent",
  23323. "DeviceMotionEvent",
  23324. "DeviceMotionEventAcceleration",
  23325. "DeviceMotionEventRotationRate",
  23326. "DeviceOrientationEvent",
  23327. "DevicePosture",
  23328. "DeviceProximityEvent",
  23329. "DeviceStorage",
  23330. "DeviceStorageChangeEvent",
  23331. "DigitalCredential",
  23332. "Directory",
  23333. "DisplayNames",
  23334. "DisposableStack",
  23335. "Document",
  23336. "DocumentFragment",
  23337. "DocumentPictureInPicture",
  23338. "DocumentPictureInPictureEvent",
  23339. "DocumentTimeline",
  23340. "DocumentType",
  23341. "DragEvent",
  23342. "Duration",
  23343. "DurationFormat",
  23344. "DynamicsCompressorNode",
  23345. "E",
  23346. "ELEMENT_ARRAY_BUFFER",
  23347. "ELEMENT_ARRAY_BUFFER_BINDING",
  23348. "ELEMENT_NODE",
  23349. "EMPTY",
  23350. "ENCODING_ERR",
  23351. "ENDED",
  23352. "END_TO_END",
  23353. "END_TO_START",
  23354. "ENTITY_NODE",
  23355. "ENTITY_REFERENCE_NODE",
  23356. "EPSILON",
  23357. "EQUAL",
  23358. "EQUALPOWER",
  23359. "ERROR",
  23360. "EXPONENTIAL_DISTANCE",
  23361. "EditContext",
  23362. "Element",
  23363. "ElementInternals",
  23364. "ElementQuery",
  23365. "EncodedAudioChunk",
  23366. "EncodedVideoChunk",
  23367. "EnterPictureInPictureEvent",
  23368. "Entity",
  23369. "EntityReference",
  23370. "Error",
  23371. "ErrorEvent",
  23372. "EvalError",
  23373. "Event",
  23374. "EventCounts",
  23375. "EventException",
  23376. "EventSource",
  23377. "EventTarget",
  23378. "Exception",
  23379. "ExtensionContext",
  23380. "ExtensionDisabledReason",
  23381. "ExtensionInfo",
  23382. "ExtensionInstallType",
  23383. "ExtensionType",
  23384. "External",
  23385. "EyeDropper",
  23386. "FASTEST",
  23387. "FIDOSDK",
  23388. "FILTER_ACCEPT",
  23389. "FILTER_INTERRUPT",
  23390. "FILTER_REJECT",
  23391. "FILTER_SKIP",
  23392. "FINISHED_STATE",
  23393. "FIRST_ORDERED_NODE_TYPE",
  23394. "FLOAT",
  23395. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  23396. "FLOAT_MAT2",
  23397. "FLOAT_MAT2x3",
  23398. "FLOAT_MAT2x4",
  23399. "FLOAT_MAT3",
  23400. "FLOAT_MAT3x2",
  23401. "FLOAT_MAT3x4",
  23402. "FLOAT_MAT4",
  23403. "FLOAT_MAT4x2",
  23404. "FLOAT_MAT4x3",
  23405. "FLOAT_VEC2",
  23406. "FLOAT_VEC3",
  23407. "FLOAT_VEC4",
  23408. "FOCUS",
  23409. "FONT_FACE_RULE",
  23410. "FONT_FEATURE_VALUES_RULE",
  23411. "FRAGMENT",
  23412. "FRAGMENT_SHADER",
  23413. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  23414. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  23415. "FRAMEBUFFER",
  23416. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  23417. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  23418. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  23419. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  23420. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  23421. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  23422. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  23423. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  23424. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  23425. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  23426. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  23427. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  23428. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  23429. "FRAMEBUFFER_BINDING",
  23430. "FRAMEBUFFER_COMPLETE",
  23431. "FRAMEBUFFER_DEFAULT",
  23432. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  23433. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  23434. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  23435. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  23436. "FRAMEBUFFER_UNSUPPORTED",
  23437. "FRONT",
  23438. "FRONT_AND_BACK",
  23439. "FRONT_FACE",
  23440. "FUNC_ADD",
  23441. "FUNC_REVERSE_SUBTRACT",
  23442. "FUNC_SUBTRACT",
  23443. "FeaturePolicy",
  23444. "FeaturePolicyViolationReportBody",
  23445. "FederatedCredential",
  23446. "Feed",
  23447. "FeedEntry",
  23448. "Fence",
  23449. "FencedFrameConfig",
  23450. "FetchLaterResult",
  23451. "File",
  23452. "FileError",
  23453. "FileList",
  23454. "FileReader",
  23455. "FileSystem",
  23456. "FileSystemDirectoryEntry",
  23457. "FileSystemDirectoryHandle",
  23458. "FileSystemDirectoryReader",
  23459. "FileSystemEntry",
  23460. "FileSystemFileEntry",
  23461. "FileSystemFileHandle",
  23462. "FileSystemHandle",
  23463. "FileSystemObserver",
  23464. "FileSystemWritableFileStream",
  23465. "FinalizationRegistry",
  23466. "FindInPage",
  23467. "Float16Array",
  23468. "Float32Array",
  23469. "Float64Array",
  23470. "FocusEvent",
  23471. "FontData",
  23472. "FontFace",
  23473. "FontFaceSet",
  23474. "FontFaceSetLoadEvent",
  23475. "FormData",
  23476. "FormDataEvent",
  23477. "FragmentDirective",
  23478. "Function",
  23479. "GENERATE_MIPMAP_HINT",
  23480. "GEQUAL",
  23481. "GPU",
  23482. "GPUAdapter",
  23483. "GPUAdapterInfo",
  23484. "GPUBindGroup",
  23485. "GPUBindGroupLayout",
  23486. "GPUBuffer",
  23487. "GPUBufferUsage",
  23488. "GPUCanvasContext",
  23489. "GPUColorWrite",
  23490. "GPUCommandBuffer",
  23491. "GPUCommandEncoder",
  23492. "GPUCompilationInfo",
  23493. "GPUCompilationMessage",
  23494. "GPUComputePassEncoder",
  23495. "GPUComputePipeline",
  23496. "GPUDevice",
  23497. "GPUDeviceLostInfo",
  23498. "GPUError",
  23499. "GPUExternalTexture",
  23500. "GPUInternalError",
  23501. "GPUMapMode",
  23502. "GPUOutOfMemoryError",
  23503. "GPUPipelineError",
  23504. "GPUPipelineLayout",
  23505. "GPUQuerySet",
  23506. "GPUQueue",
  23507. "GPURenderBundle",
  23508. "GPURenderBundleEncoder",
  23509. "GPURenderPassEncoder",
  23510. "GPURenderPipeline",
  23511. "GPUSampler",
  23512. "GPUShaderModule",
  23513. "GPUShaderStage",
  23514. "GPUSupportedFeatures",
  23515. "GPUSupportedLimits",
  23516. "GPUTexture",
  23517. "GPUTextureUsage",
  23518. "GPUTextureView",
  23519. "GPUUncapturedErrorEvent",
  23520. "GPUValidationError",
  23521. "GREATER",
  23522. "GREEN",
  23523. "GREEN_BITS",
  23524. "GainNode",
  23525. "Gamepad",
  23526. "GamepadAxisMoveEvent",
  23527. "GamepadButton",
  23528. "GamepadButtonEvent",
  23529. "GamepadEvent",
  23530. "GamepadHapticActuator",
  23531. "GamepadPose",
  23532. "Geolocation",
  23533. "GeolocationCoordinates",
  23534. "GeolocationPosition",
  23535. "GeolocationPositionError",
  23536. "GestureEvent",
  23537. "GetInfo",
  23538. "Global",
  23539. "GravitySensor",
  23540. "Gyroscope",
  23541. "HALF_FLOAT",
  23542. "HAVE_CURRENT_DATA",
  23543. "HAVE_ENOUGH_DATA",
  23544. "HAVE_FUTURE_DATA",
  23545. "HAVE_METADATA",
  23546. "HAVE_NOTHING",
  23547. "HEADERS_RECEIVED",
  23548. "HID",
  23549. "HIDConnectionEvent",
  23550. "HIDDEN",
  23551. "HIDDevice",
  23552. "HIDInputReportEvent",
  23553. "HIERARCHY_REQUEST_ERR",
  23554. "HIGHPASS",
  23555. "HIGHSHELF",
  23556. "HIGH_FLOAT",
  23557. "HIGH_INT",
  23558. "HORIZONTAL",
  23559. "HORIZONTAL_AXIS",
  23560. "HRTF",
  23561. "HTMLAllCollection",
  23562. "HTMLAnchorElement",
  23563. "HTMLAppletElement",
  23564. "HTMLAreaElement",
  23565. "HTMLAudioElement",
  23566. "HTMLBRElement",
  23567. "HTMLBaseElement",
  23568. "HTMLBaseFontElement",
  23569. "HTMLBlockquoteElement",
  23570. "HTMLBodyElement",
  23571. "HTMLButtonElement",
  23572. "HTMLCanvasElement",
  23573. "HTMLCollection",
  23574. "HTMLCommandElement",
  23575. "HTMLContentElement",
  23576. "HTMLDListElement",
  23577. "HTMLDataElement",
  23578. "HTMLDataListElement",
  23579. "HTMLDetailsElement",
  23580. "HTMLDialogElement",
  23581. "HTMLDirectoryElement",
  23582. "HTMLDivElement",
  23583. "HTMLDocument",
  23584. "HTMLElement",
  23585. "HTMLEmbedElement",
  23586. "HTMLFencedFrameElement",
  23587. "HTMLFieldSetElement",
  23588. "HTMLFontElement",
  23589. "HTMLFormControlsCollection",
  23590. "HTMLFormElement",
  23591. "HTMLFrameElement",
  23592. "HTMLFrameSetElement",
  23593. "HTMLHRElement",
  23594. "HTMLHeadElement",
  23595. "HTMLHeadingElement",
  23596. "HTMLHtmlElement",
  23597. "HTMLIFrameElement",
  23598. "HTMLImageElement",
  23599. "HTMLInputElement",
  23600. "HTMLIsIndexElement",
  23601. "HTMLKeygenElement",
  23602. "HTMLLIElement",
  23603. "HTMLLabelElement",
  23604. "HTMLLegendElement",
  23605. "HTMLLinkElement",
  23606. "HTMLMapElement",
  23607. "HTMLMarqueeElement",
  23608. "HTMLMediaElement",
  23609. "HTMLMenuElement",
  23610. "HTMLMenuItemElement",
  23611. "HTMLMetaElement",
  23612. "HTMLMeterElement",
  23613. "HTMLModElement",
  23614. "HTMLOListElement",
  23615. "HTMLObjectElement",
  23616. "HTMLOptGroupElement",
  23617. "HTMLOptionElement",
  23618. "HTMLOptionsCollection",
  23619. "HTMLOutputElement",
  23620. "HTMLParagraphElement",
  23621. "HTMLParamElement",
  23622. "HTMLPictureElement",
  23623. "HTMLPreElement",
  23624. "HTMLProgressElement",
  23625. "HTMLPropertiesCollection",
  23626. "HTMLQuoteElement",
  23627. "HTMLScriptElement",
  23628. "HTMLSelectElement",
  23629. "HTMLSelectedContentElement",
  23630. "HTMLShadowElement",
  23631. "HTMLSlotElement",
  23632. "HTMLSourceElement",
  23633. "HTMLSpanElement",
  23634. "HTMLStyleElement",
  23635. "HTMLTableCaptionElement",
  23636. "HTMLTableCellElement",
  23637. "HTMLTableColElement",
  23638. "HTMLTableElement",
  23639. "HTMLTableRowElement",
  23640. "HTMLTableSectionElement",
  23641. "HTMLTemplateElement",
  23642. "HTMLTextAreaElement",
  23643. "HTMLTimeElement",
  23644. "HTMLTitleElement",
  23645. "HTMLTrackElement",
  23646. "HTMLUListElement",
  23647. "HTMLUnknownElement",
  23648. "HTMLVideoElement",
  23649. "HashChangeEvent",
  23650. "Headers",
  23651. "Highlight",
  23652. "HighlightRegistry",
  23653. "History",
  23654. "Hz",
  23655. "ICE_CHECKING",
  23656. "ICE_CLOSED",
  23657. "ICE_COMPLETED",
  23658. "ICE_CONNECTED",
  23659. "ICE_FAILED",
  23660. "ICE_GATHERING",
  23661. "ICE_WAITING",
  23662. "IDBCursor",
  23663. "IDBCursorWithValue",
  23664. "IDBDatabase",
  23665. "IDBDatabaseException",
  23666. "IDBFactory",
  23667. "IDBFileHandle",
  23668. "IDBFileRequest",
  23669. "IDBIndex",
  23670. "IDBKeyRange",
  23671. "IDBMutableFile",
  23672. "IDBObjectStore",
  23673. "IDBOpenDBRequest",
  23674. "IDBRecord",
  23675. "IDBRequest",
  23676. "IDBTransaction",
  23677. "IDBVersionChangeEvent",
  23678. "IDLE",
  23679. "IIRFilterNode",
  23680. "IMPLEMENTATION_COLOR_READ_FORMAT",
  23681. "IMPLEMENTATION_COLOR_READ_TYPE",
  23682. "IMPORT_RULE",
  23683. "INCR",
  23684. "INCR_WRAP",
  23685. "INDEX",
  23686. "INDEX_SIZE_ERR",
  23687. "INDIRECT",
  23688. "INT",
  23689. "INTERLEAVED_ATTRIBS",
  23690. "INT_2_10_10_10_REV",
  23691. "INT_SAMPLER_2D",
  23692. "INT_SAMPLER_2D_ARRAY",
  23693. "INT_SAMPLER_3D",
  23694. "INT_SAMPLER_CUBE",
  23695. "INT_VEC2",
  23696. "INT_VEC3",
  23697. "INT_VEC4",
  23698. "INUSE_ATTRIBUTE_ERR",
  23699. "INVALID_ACCESS_ERR",
  23700. "INVALID_CHARACTER_ERR",
  23701. "INVALID_ENUM",
  23702. "INVALID_EXPRESSION_ERR",
  23703. "INVALID_FRAMEBUFFER_OPERATION",
  23704. "INVALID_INDEX",
  23705. "INVALID_MODIFICATION_ERR",
  23706. "INVALID_NODE_TYPE_ERR",
  23707. "INVALID_OPERATION",
  23708. "INVALID_STATE_ERR",
  23709. "INVALID_VALUE",
  23710. "INVERSE_DISTANCE",
  23711. "INVERT",
  23712. "IceCandidate",
  23713. "IconInfo",
  23714. "IdentityCredential",
  23715. "IdentityCredentialError",
  23716. "IdentityProvider",
  23717. "IdleDeadline",
  23718. "IdleDetector",
  23719. "Image",
  23720. "ImageBitmap",
  23721. "ImageBitmapRenderingContext",
  23722. "ImageCapture",
  23723. "ImageData",
  23724. "ImageDataType",
  23725. "ImageDecoder",
  23726. "ImageTrack",
  23727. "ImageTrackList",
  23728. "Infinity",
  23729. "Ink",
  23730. "InputDeviceCapabilities",
  23731. "InputDeviceInfo",
  23732. "InputEvent",
  23733. "InputMethodContext",
  23734. "InstallTrigger",
  23735. "InstallTriggerImpl",
  23736. "Instance",
  23737. "Instant",
  23738. "Int16Array",
  23739. "Int32Array",
  23740. "Int8Array",
  23741. "IntegrityViolationReportBody",
  23742. "Intent",
  23743. "InterestEvent",
  23744. "InternalError",
  23745. "IntersectionObserver",
  23746. "IntersectionObserverEntry",
  23747. "Intl",
  23748. "IsSearchProviderInstalled",
  23749. "Iterator",
  23750. "JSON",
  23751. "JSTag",
  23752. "KEEP",
  23753. "KEYDOWN",
  23754. "KEYFRAMES_RULE",
  23755. "KEYFRAME_RULE",
  23756. "KEYPRESS",
  23757. "KEYUP",
  23758. "KeyEvent",
  23759. "Keyboard",
  23760. "KeyboardEvent",
  23761. "KeyboardLayoutMap",
  23762. "KeyframeEffect",
  23763. "LENGTHADJUST_SPACING",
  23764. "LENGTHADJUST_SPACINGANDGLYPHS",
  23765. "LENGTHADJUST_UNKNOWN",
  23766. "LEQUAL",
  23767. "LESS",
  23768. "LINEAR",
  23769. "LINEAR_DISTANCE",
  23770. "LINEAR_MIPMAP_LINEAR",
  23771. "LINEAR_MIPMAP_NEAREST",
  23772. "LINES",
  23773. "LINE_LOOP",
  23774. "LINE_STRIP",
  23775. "LINE_WIDTH",
  23776. "LINK_STATUS",
  23777. "LIVE",
  23778. "LN10",
  23779. "LN2",
  23780. "LOADED",
  23781. "LOADING",
  23782. "LOG10E",
  23783. "LOG2E",
  23784. "LOWPASS",
  23785. "LOWSHELF",
  23786. "LOW_FLOAT",
  23787. "LOW_INT",
  23788. "LSException",
  23789. "LSParserFilter",
  23790. "LUMINANCE",
  23791. "LUMINANCE_ALPHA",
  23792. "LanguageCode",
  23793. "LanguageDetector",
  23794. "LargestContentfulPaint",
  23795. "LaunchParams",
  23796. "LaunchQueue",
  23797. "LaunchType",
  23798. "LayoutShift",
  23799. "LayoutShiftAttribution",
  23800. "LinearAccelerationSensor",
  23801. "LinkError",
  23802. "ListFormat",
  23803. "LocalMediaStream",
  23804. "Locale",
  23805. "Location",
  23806. "Lock",
  23807. "LockManager",
  23808. "MAP_READ",
  23809. "MAP_WRITE",
  23810. "MARGIN_RULE",
  23811. "MAX",
  23812. "MAX_3D_TEXTURE_SIZE",
  23813. "MAX_ARRAY_TEXTURE_LAYERS",
  23814. "MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND",
  23815. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  23816. "MAX_COLOR_ATTACHMENTS",
  23817. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  23818. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  23819. "MAX_COMBINED_UNIFORM_BLOCKS",
  23820. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  23821. "MAX_CUBE_MAP_TEXTURE_SIZE",
  23822. "MAX_DRAW_BUFFERS",
  23823. "MAX_ELEMENTS_INDICES",
  23824. "MAX_ELEMENTS_VERTICES",
  23825. "MAX_ELEMENT_INDEX",
  23826. "MAX_FRAGMENT_INPUT_COMPONENTS",
  23827. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  23828. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  23829. "MAX_FRAGMENT_UNIFORM_VECTORS",
  23830. "MAX_PROGRAM_TEXEL_OFFSET",
  23831. "MAX_RENDERBUFFER_SIZE",
  23832. "MAX_SAFE_INTEGER",
  23833. "MAX_SAMPLES",
  23834. "MAX_SERVER_WAIT_TIMEOUT",
  23835. "MAX_TEXTURE_IMAGE_UNITS",
  23836. "MAX_TEXTURE_LOD_BIAS",
  23837. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  23838. "MAX_TEXTURE_SIZE",
  23839. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  23840. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  23841. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  23842. "MAX_UNIFORM_BLOCK_SIZE",
  23843. "MAX_UNIFORM_BUFFER_BINDINGS",
  23844. "MAX_VALUE",
  23845. "MAX_VARYING_COMPONENTS",
  23846. "MAX_VARYING_VECTORS",
  23847. "MAX_VERTEX_ATTRIBS",
  23848. "MAX_VERTEX_OUTPUT_COMPONENTS",
  23849. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  23850. "MAX_VERTEX_UNIFORM_BLOCKS",
  23851. "MAX_VERTEX_UNIFORM_COMPONENTS",
  23852. "MAX_VERTEX_UNIFORM_VECTORS",
  23853. "MAX_VIEWPORT_DIMS",
  23854. "MEDIA_ERR_ABORTED",
  23855. "MEDIA_ERR_DECODE",
  23856. "MEDIA_ERR_ENCRYPTED",
  23857. "MEDIA_ERR_NETWORK",
  23858. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  23859. "MEDIA_KEYERR_CLIENT",
  23860. "MEDIA_KEYERR_DOMAIN",
  23861. "MEDIA_KEYERR_HARDWARECHANGE",
  23862. "MEDIA_KEYERR_OUTPUT",
  23863. "MEDIA_KEYERR_SERVICE",
  23864. "MEDIA_KEYERR_UNKNOWN",
  23865. "MEDIA_RULE",
  23866. "MEDIUM_FLOAT",
  23867. "MEDIUM_INT",
  23868. "META_MASK",
  23869. "MIDIAccess",
  23870. "MIDIConnectionEvent",
  23871. "MIDIInput",
  23872. "MIDIInputMap",
  23873. "MIDIMessageEvent",
  23874. "MIDIOutput",
  23875. "MIDIOutputMap",
  23876. "MIDIPort",
  23877. "MIN",
  23878. "MIN_PROGRAM_TEXEL_OFFSET",
  23879. "MIN_SAFE_INTEGER",
  23880. "MIN_VALUE",
  23881. "MIRRORED_REPEAT",
  23882. "MODE_ASYNCHRONOUS",
  23883. "MODE_SYNCHRONOUS",
  23884. "MODIFICATION",
  23885. "MOUSEDOWN",
  23886. "MOUSEDRAG",
  23887. "MOUSEMOVE",
  23888. "MOUSEOUT",
  23889. "MOUSEOVER",
  23890. "MOUSEUP",
  23891. "MOZ_KEYFRAMES_RULE",
  23892. "MOZ_KEYFRAME_RULE",
  23893. "MOZ_SOURCE_CURSOR",
  23894. "MOZ_SOURCE_ERASER",
  23895. "MOZ_SOURCE_KEYBOARD",
  23896. "MOZ_SOURCE_MOUSE",
  23897. "MOZ_SOURCE_PEN",
  23898. "MOZ_SOURCE_TOUCH",
  23899. "MOZ_SOURCE_UNKNOWN",
  23900. "MSGESTURE_FLAG_BEGIN",
  23901. "MSGESTURE_FLAG_CANCEL",
  23902. "MSGESTURE_FLAG_END",
  23903. "MSGESTURE_FLAG_INERTIA",
  23904. "MSGESTURE_FLAG_NONE",
  23905. "MSPOINTER_TYPE_MOUSE",
  23906. "MSPOINTER_TYPE_PEN",
  23907. "MSPOINTER_TYPE_TOUCH",
  23908. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  23909. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  23910. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  23911. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  23912. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  23913. "MS_ASYNC_OP_STATUS_CANCELED",
  23914. "MS_ASYNC_OP_STATUS_ERROR",
  23915. "MS_ASYNC_OP_STATUS_SUCCESS",
  23916. "MS_MANIPULATION_STATE_ACTIVE",
  23917. "MS_MANIPULATION_STATE_CANCELLED",
  23918. "MS_MANIPULATION_STATE_COMMITTED",
  23919. "MS_MANIPULATION_STATE_DRAGGING",
  23920. "MS_MANIPULATION_STATE_INERTIA",
  23921. "MS_MANIPULATION_STATE_PRESELECT",
  23922. "MS_MANIPULATION_STATE_SELECTING",
  23923. "MS_MANIPULATION_STATE_STOPPED",
  23924. "MS_MEDIA_ERR_ENCRYPTED",
  23925. "MS_MEDIA_KEYERR_CLIENT",
  23926. "MS_MEDIA_KEYERR_DOMAIN",
  23927. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  23928. "MS_MEDIA_KEYERR_OUTPUT",
  23929. "MS_MEDIA_KEYERR_SERVICE",
  23930. "MS_MEDIA_KEYERR_UNKNOWN",
  23931. "Map",
  23932. "Math",
  23933. "MathMLElement",
  23934. "MediaCapabilities",
  23935. "MediaCapabilitiesInfo",
  23936. "MediaController",
  23937. "MediaDeviceInfo",
  23938. "MediaDevices",
  23939. "MediaElementAudioSourceNode",
  23940. "MediaEncryptedEvent",
  23941. "MediaError",
  23942. "MediaKeyError",
  23943. "MediaKeyEvent",
  23944. "MediaKeyMessageEvent",
  23945. "MediaKeyNeededEvent",
  23946. "MediaKeySession",
  23947. "MediaKeyStatusMap",
  23948. "MediaKeySystemAccess",
  23949. "MediaKeys",
  23950. "MediaList",
  23951. "MediaMetadata",
  23952. "MediaQueryList",
  23953. "MediaQueryListEvent",
  23954. "MediaRecorder",
  23955. "MediaRecorderErrorEvent",
  23956. "MediaSession",
  23957. "MediaSettingsRange",
  23958. "MediaSource",
  23959. "MediaSourceHandle",
  23960. "MediaStream",
  23961. "MediaStreamAudioDestinationNode",
  23962. "MediaStreamAudioSourceNode",
  23963. "MediaStreamEvent",
  23964. "MediaStreamTrack",
  23965. "MediaStreamTrackAudioSourceNode",
  23966. "MediaStreamTrackAudioStats",
  23967. "MediaStreamTrackEvent",
  23968. "MediaStreamTrackGenerator",
  23969. "MediaStreamTrackProcessor",
  23970. "MediaStreamTrackVideoStats",
  23971. "Memory",
  23972. "MessageChannel",
  23973. "MessageEvent",
  23974. "MessagePort",
  23975. "MessageSender",
  23976. "Methods",
  23977. "MimeType",
  23978. "MimeTypeArray",
  23979. "Module",
  23980. "MouseEvent",
  23981. "MouseScrollEvent",
  23982. "MozAnimation",
  23983. "MozAnimationDelay",
  23984. "MozAnimationDirection",
  23985. "MozAnimationDuration",
  23986. "MozAnimationFillMode",
  23987. "MozAnimationIterationCount",
  23988. "MozAnimationName",
  23989. "MozAnimationPlayState",
  23990. "MozAnimationTimingFunction",
  23991. "MozAppearance",
  23992. "MozBackfaceVisibility",
  23993. "MozBinding",
  23994. "MozBorderBottomColors",
  23995. "MozBorderEnd",
  23996. "MozBorderEndColor",
  23997. "MozBorderEndStyle",
  23998. "MozBorderEndWidth",
  23999. "MozBorderImage",
  24000. "MozBorderLeftColors",
  24001. "MozBorderRightColors",
  24002. "MozBorderStart",
  24003. "MozBorderStartColor",
  24004. "MozBorderStartStyle",
  24005. "MozBorderStartWidth",
  24006. "MozBorderTopColors",
  24007. "MozBoxAlign",
  24008. "MozBoxDirection",
  24009. "MozBoxFlex",
  24010. "MozBoxOrdinalGroup",
  24011. "MozBoxOrient",
  24012. "MozBoxPack",
  24013. "MozBoxSizing",
  24014. "MozCSSKeyframeRule",
  24015. "MozCSSKeyframesRule",
  24016. "MozColumnCount",
  24017. "MozColumnFill",
  24018. "MozColumnGap",
  24019. "MozColumnRule",
  24020. "MozColumnRuleColor",
  24021. "MozColumnRuleStyle",
  24022. "MozColumnRuleWidth",
  24023. "MozColumnWidth",
  24024. "MozColumns",
  24025. "MozContactChangeEvent",
  24026. "MozFloatEdge",
  24027. "MozFontFeatureSettings",
  24028. "MozFontLanguageOverride",
  24029. "MozForceBrokenImageIcon",
  24030. "MozHyphens",
  24031. "MozImageRegion",
  24032. "MozMarginEnd",
  24033. "MozMarginStart",
  24034. "MozMmsEvent",
  24035. "MozMmsMessage",
  24036. "MozMobileMessageThread",
  24037. "MozOSXFontSmoothing",
  24038. "MozOrient",
  24039. "MozOsxFontSmoothing",
  24040. "MozOutlineRadius",
  24041. "MozOutlineRadiusBottomleft",
  24042. "MozOutlineRadiusBottomright",
  24043. "MozOutlineRadiusTopleft",
  24044. "MozOutlineRadiusTopright",
  24045. "MozPaddingEnd",
  24046. "MozPaddingStart",
  24047. "MozPerspective",
  24048. "MozPerspectiveOrigin",
  24049. "MozPowerManager",
  24050. "MozSettingsEvent",
  24051. "MozSmsEvent",
  24052. "MozSmsMessage",
  24053. "MozStackSizing",
  24054. "MozTabSize",
  24055. "MozTextAlignLast",
  24056. "MozTextDecorationColor",
  24057. "MozTextDecorationLine",
  24058. "MozTextDecorationStyle",
  24059. "MozTextSizeAdjust",
  24060. "MozTransform",
  24061. "MozTransformOrigin",
  24062. "MozTransformStyle",
  24063. "MozTransition",
  24064. "MozTransitionDelay",
  24065. "MozTransitionDuration",
  24066. "MozTransitionProperty",
  24067. "MozTransitionTimingFunction",
  24068. "MozUserFocus",
  24069. "MozUserInput",
  24070. "MozUserModify",
  24071. "MozUserSelect",
  24072. "MozWindowDragging",
  24073. "MozWindowShadow",
  24074. "MutationEvent",
  24075. "MutationObserver",
  24076. "MutationRecord",
  24077. "MutedInfo",
  24078. "MutedInfoReason",
  24079. "NAMESPACE_ERR",
  24080. "NAMESPACE_RULE",
  24081. "NEAREST",
  24082. "NEAREST_MIPMAP_LINEAR",
  24083. "NEAREST_MIPMAP_NEAREST",
  24084. "NEGATIVE_INFINITY",
  24085. "NETWORK_EMPTY",
  24086. "NETWORK_ERR",
  24087. "NETWORK_IDLE",
  24088. "NETWORK_LOADED",
  24089. "NETWORK_LOADING",
  24090. "NETWORK_NO_SOURCE",
  24091. "NEVER",
  24092. "NEW",
  24093. "NEXT",
  24094. "NEXT_NO_DUPLICATE",
  24095. "NICEST",
  24096. "NODE_AFTER",
  24097. "NODE_BEFORE",
  24098. "NODE_BEFORE_AND_AFTER",
  24099. "NODE_INSIDE",
  24100. "NONE",
  24101. "NON_TRANSIENT_ERR",
  24102. "NOTATION_NODE",
  24103. "NOTCH",
  24104. "NOTEQUAL",
  24105. "NOT_ALLOWED_ERR",
  24106. "NOT_FOUND_ERR",
  24107. "NOT_READABLE_ERR",
  24108. "NOT_SUPPORTED_ERR",
  24109. "NO_DATA_ALLOWED_ERR",
  24110. "NO_ERR",
  24111. "NO_ERROR",
  24112. "NO_MODIFICATION_ALLOWED_ERR",
  24113. "NUMBER_TYPE",
  24114. "NUM_COMPRESSED_TEXTURE_FORMATS",
  24115. "NaN",
  24116. "NamedNodeMap",
  24117. "NavigateEvent",
  24118. "Navigation",
  24119. "NavigationActivation",
  24120. "NavigationCurrentEntryChangeEvent",
  24121. "NavigationDestination",
  24122. "NavigationHistoryEntry",
  24123. "NavigationPrecommitController",
  24124. "NavigationPreloadManager",
  24125. "NavigationTransition",
  24126. "Navigator",
  24127. "NavigatorLogin",
  24128. "NavigatorManagedData",
  24129. "NavigatorUAData",
  24130. "NearbyLinks",
  24131. "NetworkInformation",
  24132. "Node",
  24133. "NodeFilter",
  24134. "NodeIterator",
  24135. "NodeList",
  24136. "NotRestoredReasonDetails",
  24137. "NotRestoredReasons",
  24138. "Notation",
  24139. "Notification",
  24140. "NotifyPaintEvent",
  24141. "Now",
  24142. "Number",
  24143. "NumberFormat",
  24144. "OBJECT_TYPE",
  24145. "OBSOLETE",
  24146. "OK",
  24147. "ONE",
  24148. "ONE_MINUS_CONSTANT_ALPHA",
  24149. "ONE_MINUS_CONSTANT_COLOR",
  24150. "ONE_MINUS_DST_ALPHA",
  24151. "ONE_MINUS_DST_COLOR",
  24152. "ONE_MINUS_SRC_ALPHA",
  24153. "ONE_MINUS_SRC_COLOR",
  24154. "OPEN",
  24155. "OPENED",
  24156. "OPENING",
  24157. "ORDERED_NODE_ITERATOR_TYPE",
  24158. "ORDERED_NODE_SNAPSHOT_TYPE",
  24159. "OTHER_ERROR",
  24160. "OTPCredential",
  24161. "OUT_OF_MEMORY",
  24162. "Object",
  24163. "Observable",
  24164. "OfflineAudioCompletionEvent",
  24165. "OfflineAudioContext",
  24166. "OfflineResourceList",
  24167. "OffscreenCanvas",
  24168. "OffscreenCanvasRenderingContext2D",
  24169. "OnClickData",
  24170. "OnInstalledReason",
  24171. "OnPerformanceWarningCategory",
  24172. "OnPerformanceWarningSeverity",
  24173. "OnRestartRequiredReason",
  24174. "Option",
  24175. "OrientationSensor",
  24176. "OscillatorNode",
  24177. "OverconstrainedError",
  24178. "OverflowEvent",
  24179. "PACK_ALIGNMENT",
  24180. "PACK_ROW_LENGTH",
  24181. "PACK_SKIP_PIXELS",
  24182. "PACK_SKIP_ROWS",
  24183. "PAGE_RULE",
  24184. "PARSE_ERR",
  24185. "PATHSEG_ARC_ABS",
  24186. "PATHSEG_ARC_REL",
  24187. "PATHSEG_CLOSEPATH",
  24188. "PATHSEG_CURVETO_CUBIC_ABS",
  24189. "PATHSEG_CURVETO_CUBIC_REL",
  24190. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  24191. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  24192. "PATHSEG_CURVETO_QUADRATIC_ABS",
  24193. "PATHSEG_CURVETO_QUADRATIC_REL",
  24194. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  24195. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  24196. "PATHSEG_LINETO_ABS",
  24197. "PATHSEG_LINETO_HORIZONTAL_ABS",
  24198. "PATHSEG_LINETO_HORIZONTAL_REL",
  24199. "PATHSEG_LINETO_REL",
  24200. "PATHSEG_LINETO_VERTICAL_ABS",
  24201. "PATHSEG_LINETO_VERTICAL_REL",
  24202. "PATHSEG_MOVETO_ABS",
  24203. "PATHSEG_MOVETO_REL",
  24204. "PATHSEG_UNKNOWN",
  24205. "PATH_EXISTS_ERR",
  24206. "PEAKING",
  24207. "PERMISSION_DENIED",
  24208. "PERSISTENT",
  24209. "PI",
  24210. "PIXEL_PACK_BUFFER",
  24211. "PIXEL_PACK_BUFFER_BINDING",
  24212. "PIXEL_UNPACK_BUFFER",
  24213. "PIXEL_UNPACK_BUFFER_BINDING",
  24214. "PLAYING_STATE",
  24215. "POINTS",
  24216. "POLYGON_OFFSET_FACTOR",
  24217. "POLYGON_OFFSET_FILL",
  24218. "POLYGON_OFFSET_UNITS",
  24219. "POSITION_UNAVAILABLE",
  24220. "POSITIVE_INFINITY",
  24221. "PREV",
  24222. "PREV_NO_DUPLICATE",
  24223. "PROCESSING_INSTRUCTION_NODE",
  24224. "PageChangeEvent",
  24225. "PageRevealEvent",
  24226. "PageSettings",
  24227. "PageSwapEvent",
  24228. "PageTransitionEvent",
  24229. "PaintRequest",
  24230. "PaintRequestList",
  24231. "PannerNode",
  24232. "PasswordCredential",
  24233. "Path2D",
  24234. "PaymentAddress",
  24235. "PaymentInstruments",
  24236. "PaymentManager",
  24237. "PaymentMethodChangeEvent",
  24238. "PaymentRequest",
  24239. "PaymentRequestUpdateEvent",
  24240. "PaymentResponse",
  24241. "Performance",
  24242. "PerformanceElementTiming",
  24243. "PerformanceEntry",
  24244. "PerformanceEventTiming",
  24245. "PerformanceLongAnimationFrameTiming",
  24246. "PerformanceLongTaskTiming",
  24247. "PerformanceMark",
  24248. "PerformanceMeasure",
  24249. "PerformanceNavigation",
  24250. "PerformanceNavigationTiming",
  24251. "PerformanceObserver",
  24252. "PerformanceObserverEntryList",
  24253. "PerformancePaintTiming",
  24254. "PerformanceResourceTiming",
  24255. "PerformanceScriptTiming",
  24256. "PerformanceServerTiming",
  24257. "PerformanceTiming",
  24258. "PeriodicSyncManager",
  24259. "PeriodicWave",
  24260. "PermissionStatus",
  24261. "Permissions",
  24262. "PhotoCapabilities",
  24263. "PictureInPictureEvent",
  24264. "PictureInPictureWindow",
  24265. "PlainDate",
  24266. "PlainDateTime",
  24267. "PlainMonthDay",
  24268. "PlainTime",
  24269. "PlainYearMonth",
  24270. "PlatformArch",
  24271. "PlatformInfo",
  24272. "PlatformNaclArch",
  24273. "PlatformOs",
  24274. "Plugin",
  24275. "PluginArray",
  24276. "PluralRules",
  24277. "PointerEvent",
  24278. "PopStateEvent",
  24279. "PopupBlockedEvent",
  24280. "Port",
  24281. "Presentation",
  24282. "PresentationAvailability",
  24283. "PresentationConnection",
  24284. "PresentationConnectionAvailableEvent",
  24285. "PresentationConnectionCloseEvent",
  24286. "PresentationConnectionList",
  24287. "PresentationReceiver",
  24288. "PresentationRequest",
  24289. "PressureObserver",
  24290. "PressureRecord",
  24291. "ProcessingInstruction",
  24292. "Profiler",
  24293. "ProgressEvent",
  24294. "Promise",
  24295. "PromiseRejectionEvent",
  24296. "PropertyNodeList",
  24297. "ProtectedAudience",
  24298. "Proxy",
  24299. "PublicKeyCredential",
  24300. "PushManager",
  24301. "PushSubscription",
  24302. "PushSubscriptionOptions",
  24303. "Q",
  24304. "QUERY_RESOLVE",
  24305. "QUERY_RESULT",
  24306. "QUERY_RESULT_AVAILABLE",
  24307. "QUOTA_ERR",
  24308. "QUOTA_EXCEEDED_ERR",
  24309. "QueryInterface",
  24310. "QuotaExceededError",
  24311. "R11F_G11F_B10F",
  24312. "R16F",
  24313. "R16I",
  24314. "R16UI",
  24315. "R32F",
  24316. "R32I",
  24317. "R32UI",
  24318. "R8",
  24319. "R8I",
  24320. "R8UI",
  24321. "R8_SNORM",
  24322. "RASTERIZER_DISCARD",
  24323. "READ",
  24324. "READ_BUFFER",
  24325. "READ_FRAMEBUFFER",
  24326. "READ_FRAMEBUFFER_BINDING",
  24327. "READ_ONLY",
  24328. "READ_ONLY_ERR",
  24329. "READ_WRITE",
  24330. "RED",
  24331. "RED_BITS",
  24332. "RED_INTEGER",
  24333. "REMOVAL",
  24334. "RENDERBUFFER",
  24335. "RENDERBUFFER_ALPHA_SIZE",
  24336. "RENDERBUFFER_BINDING",
  24337. "RENDERBUFFER_BLUE_SIZE",
  24338. "RENDERBUFFER_DEPTH_SIZE",
  24339. "RENDERBUFFER_GREEN_SIZE",
  24340. "RENDERBUFFER_HEIGHT",
  24341. "RENDERBUFFER_INTERNAL_FORMAT",
  24342. "RENDERBUFFER_RED_SIZE",
  24343. "RENDERBUFFER_SAMPLES",
  24344. "RENDERBUFFER_STENCIL_SIZE",
  24345. "RENDERBUFFER_WIDTH",
  24346. "RENDERER",
  24347. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  24348. "RENDERING_INTENT_AUTO",
  24349. "RENDERING_INTENT_PERCEPTUAL",
  24350. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  24351. "RENDERING_INTENT_SATURATION",
  24352. "RENDERING_INTENT_UNKNOWN",
  24353. "RENDER_ATTACHMENT",
  24354. "REPEAT",
  24355. "REPLACE",
  24356. "RG",
  24357. "RG16F",
  24358. "RG16I",
  24359. "RG16UI",
  24360. "RG32F",
  24361. "RG32I",
  24362. "RG32UI",
  24363. "RG8",
  24364. "RG8I",
  24365. "RG8UI",
  24366. "RG8_SNORM",
  24367. "RGB",
  24368. "RGB10_A2",
  24369. "RGB10_A2UI",
  24370. "RGB16F",
  24371. "RGB16I",
  24372. "RGB16UI",
  24373. "RGB32F",
  24374. "RGB32I",
  24375. "RGB32UI",
  24376. "RGB565",
  24377. "RGB5_A1",
  24378. "RGB8",
  24379. "RGB8I",
  24380. "RGB8UI",
  24381. "RGB8_SNORM",
  24382. "RGB9_E5",
  24383. "RGBA",
  24384. "RGBA16F",
  24385. "RGBA16I",
  24386. "RGBA16UI",
  24387. "RGBA32F",
  24388. "RGBA32I",
  24389. "RGBA32UI",
  24390. "RGBA4",
  24391. "RGBA8",
  24392. "RGBA8I",
  24393. "RGBA8UI",
  24394. "RGBA8_SNORM",
  24395. "RGBA_INTEGER",
  24396. "RGBColor",
  24397. "RGB_INTEGER",
  24398. "RG_INTEGER",
  24399. "ROTATION_CLOCKWISE",
  24400. "ROTATION_COUNTERCLOCKWISE",
  24401. "RTCCertificate",
  24402. "RTCDTMFSender",
  24403. "RTCDTMFToneChangeEvent",
  24404. "RTCDataChannel",
  24405. "RTCDataChannelEvent",
  24406. "RTCDtlsTransport",
  24407. "RTCEncodedAudioFrame",
  24408. "RTCEncodedVideoFrame",
  24409. "RTCError",
  24410. "RTCErrorEvent",
  24411. "RTCIceCandidate",
  24412. "RTCIceTransport",
  24413. "RTCPeerConnection",
  24414. "RTCPeerConnectionIceErrorEvent",
  24415. "RTCPeerConnectionIceEvent",
  24416. "RTCRtpReceiver",
  24417. "RTCRtpScriptTransform",
  24418. "RTCRtpSender",
  24419. "RTCRtpTransceiver",
  24420. "RTCSctpTransport",
  24421. "RTCSessionDescription",
  24422. "RTCStatsReport",
  24423. "RTCTrackEvent",
  24424. "RadioNodeList",
  24425. "Range",
  24426. "RangeError",
  24427. "RangeException",
  24428. "ReadableByteStreamController",
  24429. "ReadableStream",
  24430. "ReadableStreamBYOBReader",
  24431. "ReadableStreamBYOBRequest",
  24432. "ReadableStreamDefaultController",
  24433. "ReadableStreamDefaultReader",
  24434. "RecordErrorEvent",
  24435. "Rect",
  24436. "ReferenceError",
  24437. "Reflect",
  24438. "RegExp",
  24439. "RelativeOrientationSensor",
  24440. "RelativeTimeFormat",
  24441. "RemotePlayback",
  24442. "Report",
  24443. "ReportBody",
  24444. "ReportingObserver",
  24445. "Request",
  24446. "RequestUpdateCheckStatus",
  24447. "ResizeObserver",
  24448. "ResizeObserverEntry",
  24449. "ResizeObserverSize",
  24450. "Response",
  24451. "RestrictionTarget",
  24452. "RuntimeError",
  24453. "SAMPLER_2D",
  24454. "SAMPLER_2D_ARRAY",
  24455. "SAMPLER_2D_ARRAY_SHADOW",
  24456. "SAMPLER_2D_SHADOW",
  24457. "SAMPLER_3D",
  24458. "SAMPLER_BINDING",
  24459. "SAMPLER_CUBE",
  24460. "SAMPLER_CUBE_SHADOW",
  24461. "SAMPLES",
  24462. "SAMPLE_ALPHA_TO_COVERAGE",
  24463. "SAMPLE_BUFFERS",
  24464. "SAMPLE_COVERAGE",
  24465. "SAMPLE_COVERAGE_INVERT",
  24466. "SAMPLE_COVERAGE_VALUE",
  24467. "SAWTOOTH",
  24468. "SCHEDULED_STATE",
  24469. "SCISSOR_BOX",
  24470. "SCISSOR_TEST",
  24471. "SCROLL_PAGE_DOWN",
  24472. "SCROLL_PAGE_UP",
  24473. "SDP_ANSWER",
  24474. "SDP_OFFER",
  24475. "SDP_PRANSWER",
  24476. "SECURITY_ERR",
  24477. "SELECT",
  24478. "SEPARATE_ATTRIBS",
  24479. "SERIALIZE_ERR",
  24480. "SEVERITY_ERROR",
  24481. "SEVERITY_FATAL_ERROR",
  24482. "SEVERITY_WARNING",
  24483. "SHADER_COMPILER",
  24484. "SHADER_TYPE",
  24485. "SHADING_LANGUAGE_VERSION",
  24486. "SHIFT_MASK",
  24487. "SHORT",
  24488. "SHOWING",
  24489. "SHOW_ALL",
  24490. "SHOW_ATTRIBUTE",
  24491. "SHOW_CDATA_SECTION",
  24492. "SHOW_COMMENT",
  24493. "SHOW_DOCUMENT",
  24494. "SHOW_DOCUMENT_FRAGMENT",
  24495. "SHOW_DOCUMENT_TYPE",
  24496. "SHOW_ELEMENT",
  24497. "SHOW_ENTITY",
  24498. "SHOW_ENTITY_REFERENCE",
  24499. "SHOW_NOTATION",
  24500. "SHOW_PROCESSING_INSTRUCTION",
  24501. "SHOW_TEXT",
  24502. "SIGNALED",
  24503. "SIGNED_NORMALIZED",
  24504. "SINE",
  24505. "SOUNDFIELD",
  24506. "SQLException",
  24507. "SQRT1_2",
  24508. "SQRT2",
  24509. "SQUARE",
  24510. "SRC_ALPHA",
  24511. "SRC_ALPHA_SATURATE",
  24512. "SRC_COLOR",
  24513. "SRGB",
  24514. "SRGB8",
  24515. "SRGB8_ALPHA8",
  24516. "START_TO_END",
  24517. "START_TO_START",
  24518. "STATIC_COPY",
  24519. "STATIC_DRAW",
  24520. "STATIC_READ",
  24521. "STENCIL",
  24522. "STENCIL_ATTACHMENT",
  24523. "STENCIL_BACK_FAIL",
  24524. "STENCIL_BACK_FUNC",
  24525. "STENCIL_BACK_PASS_DEPTH_FAIL",
  24526. "STENCIL_BACK_PASS_DEPTH_PASS",
  24527. "STENCIL_BACK_REF",
  24528. "STENCIL_BACK_VALUE_MASK",
  24529. "STENCIL_BACK_WRITEMASK",
  24530. "STENCIL_BITS",
  24531. "STENCIL_BUFFER_BIT",
  24532. "STENCIL_CLEAR_VALUE",
  24533. "STENCIL_FAIL",
  24534. "STENCIL_FUNC",
  24535. "STENCIL_INDEX",
  24536. "STENCIL_INDEX8",
  24537. "STENCIL_PASS_DEPTH_FAIL",
  24538. "STENCIL_PASS_DEPTH_PASS",
  24539. "STENCIL_REF",
  24540. "STENCIL_TEST",
  24541. "STENCIL_VALUE_MASK",
  24542. "STENCIL_WRITEMASK",
  24543. "STORAGE",
  24544. "STORAGE_BINDING",
  24545. "STREAM_COPY",
  24546. "STREAM_DRAW",
  24547. "STREAM_READ",
  24548. "STRING_TYPE",
  24549. "STYLE_RULE",
  24550. "SUBPIXEL_BITS",
  24551. "SUPPORTS_RULE",
  24552. "SVGAElement",
  24553. "SVGAltGlyphDefElement",
  24554. "SVGAltGlyphElement",
  24555. "SVGAltGlyphItemElement",
  24556. "SVGAngle",
  24557. "SVGAnimateColorElement",
  24558. "SVGAnimateElement",
  24559. "SVGAnimateMotionElement",
  24560. "SVGAnimateTransformElement",
  24561. "SVGAnimatedAngle",
  24562. "SVGAnimatedBoolean",
  24563. "SVGAnimatedEnumeration",
  24564. "SVGAnimatedInteger",
  24565. "SVGAnimatedLength",
  24566. "SVGAnimatedLengthList",
  24567. "SVGAnimatedNumber",
  24568. "SVGAnimatedNumberList",
  24569. "SVGAnimatedPreserveAspectRatio",
  24570. "SVGAnimatedRect",
  24571. "SVGAnimatedString",
  24572. "SVGAnimatedTransformList",
  24573. "SVGAnimationElement",
  24574. "SVGCircleElement",
  24575. "SVGClipPathElement",
  24576. "SVGColor",
  24577. "SVGComponentTransferFunctionElement",
  24578. "SVGCursorElement",
  24579. "SVGDefsElement",
  24580. "SVGDescElement",
  24581. "SVGDiscardElement",
  24582. "SVGDocument",
  24583. "SVGElement",
  24584. "SVGElementInstance",
  24585. "SVGElementInstanceList",
  24586. "SVGEllipseElement",
  24587. "SVGException",
  24588. "SVGFEBlendElement",
  24589. "SVGFEColorMatrixElement",
  24590. "SVGFEComponentTransferElement",
  24591. "SVGFECompositeElement",
  24592. "SVGFEConvolveMatrixElement",
  24593. "SVGFEDiffuseLightingElement",
  24594. "SVGFEDisplacementMapElement",
  24595. "SVGFEDistantLightElement",
  24596. "SVGFEDropShadowElement",
  24597. "SVGFEFloodElement",
  24598. "SVGFEFuncAElement",
  24599. "SVGFEFuncBElement",
  24600. "SVGFEFuncGElement",
  24601. "SVGFEFuncRElement",
  24602. "SVGFEGaussianBlurElement",
  24603. "SVGFEImageElement",
  24604. "SVGFEMergeElement",
  24605. "SVGFEMergeNodeElement",
  24606. "SVGFEMorphologyElement",
  24607. "SVGFEOffsetElement",
  24608. "SVGFEPointLightElement",
  24609. "SVGFESpecularLightingElement",
  24610. "SVGFESpotLightElement",
  24611. "SVGFETileElement",
  24612. "SVGFETurbulenceElement",
  24613. "SVGFilterElement",
  24614. "SVGFontElement",
  24615. "SVGFontFaceElement",
  24616. "SVGFontFaceFormatElement",
  24617. "SVGFontFaceNameElement",
  24618. "SVGFontFaceSrcElement",
  24619. "SVGFontFaceUriElement",
  24620. "SVGForeignObjectElement",
  24621. "SVGGElement",
  24622. "SVGGeometryElement",
  24623. "SVGGlyphElement",
  24624. "SVGGlyphRefElement",
  24625. "SVGGradientElement",
  24626. "SVGGraphicsElement",
  24627. "SVGHKernElement",
  24628. "SVGImageElement",
  24629. "SVGLength",
  24630. "SVGLengthList",
  24631. "SVGLineElement",
  24632. "SVGLinearGradientElement",
  24633. "SVGMPathElement",
  24634. "SVGMarkerElement",
  24635. "SVGMaskElement",
  24636. "SVGMatrix",
  24637. "SVGMetadataElement",
  24638. "SVGMissingGlyphElement",
  24639. "SVGNumber",
  24640. "SVGNumberList",
  24641. "SVGPaint",
  24642. "SVGPathElement",
  24643. "SVGPathSeg",
  24644. "SVGPathSegArcAbs",
  24645. "SVGPathSegArcRel",
  24646. "SVGPathSegClosePath",
  24647. "SVGPathSegCurvetoCubicAbs",
  24648. "SVGPathSegCurvetoCubicRel",
  24649. "SVGPathSegCurvetoCubicSmoothAbs",
  24650. "SVGPathSegCurvetoCubicSmoothRel",
  24651. "SVGPathSegCurvetoQuadraticAbs",
  24652. "SVGPathSegCurvetoQuadraticRel",
  24653. "SVGPathSegCurvetoQuadraticSmoothAbs",
  24654. "SVGPathSegCurvetoQuadraticSmoothRel",
  24655. "SVGPathSegLinetoAbs",
  24656. "SVGPathSegLinetoHorizontalAbs",
  24657. "SVGPathSegLinetoHorizontalRel",
  24658. "SVGPathSegLinetoRel",
  24659. "SVGPathSegLinetoVerticalAbs",
  24660. "SVGPathSegLinetoVerticalRel",
  24661. "SVGPathSegList",
  24662. "SVGPathSegMovetoAbs",
  24663. "SVGPathSegMovetoRel",
  24664. "SVGPatternElement",
  24665. "SVGPoint",
  24666. "SVGPointList",
  24667. "SVGPolygonElement",
  24668. "SVGPolylineElement",
  24669. "SVGPreserveAspectRatio",
  24670. "SVGRadialGradientElement",
  24671. "SVGRect",
  24672. "SVGRectElement",
  24673. "SVGRenderingIntent",
  24674. "SVGSVGElement",
  24675. "SVGScriptElement",
  24676. "SVGSetElement",
  24677. "SVGStopElement",
  24678. "SVGStringList",
  24679. "SVGStyleElement",
  24680. "SVGSwitchElement",
  24681. "SVGSymbolElement",
  24682. "SVGTRefElement",
  24683. "SVGTSpanElement",
  24684. "SVGTextContentElement",
  24685. "SVGTextElement",
  24686. "SVGTextPathElement",
  24687. "SVGTextPositioningElement",
  24688. "SVGTitleElement",
  24689. "SVGTransform",
  24690. "SVGTransformList",
  24691. "SVGUnitTypes",
  24692. "SVGUseElement",
  24693. "SVGVKernElement",
  24694. "SVGViewElement",
  24695. "SVGViewSpec",
  24696. "SVGZoomAndPan",
  24697. "SVGZoomEvent",
  24698. "SVG_ANGLETYPE_DEG",
  24699. "SVG_ANGLETYPE_GRAD",
  24700. "SVG_ANGLETYPE_RAD",
  24701. "SVG_ANGLETYPE_UNKNOWN",
  24702. "SVG_ANGLETYPE_UNSPECIFIED",
  24703. "SVG_CHANNEL_A",
  24704. "SVG_CHANNEL_B",
  24705. "SVG_CHANNEL_G",
  24706. "SVG_CHANNEL_R",
  24707. "SVG_CHANNEL_UNKNOWN",
  24708. "SVG_COLORTYPE_CURRENTCOLOR",
  24709. "SVG_COLORTYPE_RGBCOLOR",
  24710. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  24711. "SVG_COLORTYPE_UNKNOWN",
  24712. "SVG_EDGEMODE_DUPLICATE",
  24713. "SVG_EDGEMODE_NONE",
  24714. "SVG_EDGEMODE_UNKNOWN",
  24715. "SVG_EDGEMODE_WRAP",
  24716. "SVG_FEBLEND_MODE_COLOR",
  24717. "SVG_FEBLEND_MODE_COLOR_BURN",
  24718. "SVG_FEBLEND_MODE_COLOR_DODGE",
  24719. "SVG_FEBLEND_MODE_DARKEN",
  24720. "SVG_FEBLEND_MODE_DIFFERENCE",
  24721. "SVG_FEBLEND_MODE_EXCLUSION",
  24722. "SVG_FEBLEND_MODE_HARD_LIGHT",
  24723. "SVG_FEBLEND_MODE_HUE",
  24724. "SVG_FEBLEND_MODE_LIGHTEN",
  24725. "SVG_FEBLEND_MODE_LUMINOSITY",
  24726. "SVG_FEBLEND_MODE_MULTIPLY",
  24727. "SVG_FEBLEND_MODE_NORMAL",
  24728. "SVG_FEBLEND_MODE_OVERLAY",
  24729. "SVG_FEBLEND_MODE_SATURATION",
  24730. "SVG_FEBLEND_MODE_SCREEN",
  24731. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  24732. "SVG_FEBLEND_MODE_UNKNOWN",
  24733. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  24734. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  24735. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  24736. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  24737. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  24738. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  24739. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  24740. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  24741. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  24742. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  24743. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  24744. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  24745. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  24746. "SVG_FECOMPOSITE_OPERATOR_IN",
  24747. "SVG_FECOMPOSITE_OPERATOR_LIGHTER",
  24748. "SVG_FECOMPOSITE_OPERATOR_OUT",
  24749. "SVG_FECOMPOSITE_OPERATOR_OVER",
  24750. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  24751. "SVG_FECOMPOSITE_OPERATOR_XOR",
  24752. "SVG_INVALID_VALUE_ERR",
  24753. "SVG_LENGTHTYPE_CM",
  24754. "SVG_LENGTHTYPE_EMS",
  24755. "SVG_LENGTHTYPE_EXS",
  24756. "SVG_LENGTHTYPE_IN",
  24757. "SVG_LENGTHTYPE_MM",
  24758. "SVG_LENGTHTYPE_NUMBER",
  24759. "SVG_LENGTHTYPE_PC",
  24760. "SVG_LENGTHTYPE_PERCENTAGE",
  24761. "SVG_LENGTHTYPE_PT",
  24762. "SVG_LENGTHTYPE_PX",
  24763. "SVG_LENGTHTYPE_UNKNOWN",
  24764. "SVG_MARKERUNITS_STROKEWIDTH",
  24765. "SVG_MARKERUNITS_UNKNOWN",
  24766. "SVG_MARKERUNITS_USERSPACEONUSE",
  24767. "SVG_MARKER_ORIENT_ANGLE",
  24768. "SVG_MARKER_ORIENT_AUTO",
  24769. "SVG_MARKER_ORIENT_AUTO_START_REVERSE",
  24770. "SVG_MARKER_ORIENT_UNKNOWN",
  24771. "SVG_MASKTYPE_ALPHA",
  24772. "SVG_MASKTYPE_LUMINANCE",
  24773. "SVG_MATRIX_NOT_INVERTABLE",
  24774. "SVG_MEETORSLICE_MEET",
  24775. "SVG_MEETORSLICE_SLICE",
  24776. "SVG_MEETORSLICE_UNKNOWN",
  24777. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  24778. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  24779. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  24780. "SVG_PAINTTYPE_CURRENTCOLOR",
  24781. "SVG_PAINTTYPE_NONE",
  24782. "SVG_PAINTTYPE_RGBCOLOR",
  24783. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  24784. "SVG_PAINTTYPE_UNKNOWN",
  24785. "SVG_PAINTTYPE_URI",
  24786. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  24787. "SVG_PAINTTYPE_URI_NONE",
  24788. "SVG_PAINTTYPE_URI_RGBCOLOR",
  24789. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  24790. "SVG_PRESERVEASPECTRATIO_NONE",
  24791. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  24792. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  24793. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  24794. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  24795. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  24796. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  24797. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  24798. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  24799. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  24800. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  24801. "SVG_SPREADMETHOD_PAD",
  24802. "SVG_SPREADMETHOD_REFLECT",
  24803. "SVG_SPREADMETHOD_REPEAT",
  24804. "SVG_SPREADMETHOD_UNKNOWN",
  24805. "SVG_STITCHTYPE_NOSTITCH",
  24806. "SVG_STITCHTYPE_STITCH",
  24807. "SVG_STITCHTYPE_UNKNOWN",
  24808. "SVG_TRANSFORM_MATRIX",
  24809. "SVG_TRANSFORM_ROTATE",
  24810. "SVG_TRANSFORM_SCALE",
  24811. "SVG_TRANSFORM_SKEWX",
  24812. "SVG_TRANSFORM_SKEWY",
  24813. "SVG_TRANSFORM_TRANSLATE",
  24814. "SVG_TRANSFORM_UNKNOWN",
  24815. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  24816. "SVG_TURBULENCE_TYPE_TURBULENCE",
  24817. "SVG_TURBULENCE_TYPE_UNKNOWN",
  24818. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  24819. "SVG_UNIT_TYPE_UNKNOWN",
  24820. "SVG_UNIT_TYPE_USERSPACEONUSE",
  24821. "SVG_WRONG_TYPE_ERR",
  24822. "SVG_ZOOMANDPAN_DISABLE",
  24823. "SVG_ZOOMANDPAN_MAGNIFY",
  24824. "SVG_ZOOMANDPAN_UNKNOWN",
  24825. "SYNC_CONDITION",
  24826. "SYNC_FENCE",
  24827. "SYNC_FLAGS",
  24828. "SYNC_FLUSH_COMMANDS_BIT",
  24829. "SYNC_GPU_COMMANDS_COMPLETE",
  24830. "SYNC_STATUS",
  24831. "SYNTAX_ERR",
  24832. "SavedPages",
  24833. "Scheduler",
  24834. "Scheduling",
  24835. "Screen",
  24836. "ScreenDetailed",
  24837. "ScreenDetails",
  24838. "ScreenOrientation",
  24839. "Script",
  24840. "ScriptProcessorNode",
  24841. "ScrollAreaEvent",
  24842. "ScrollTimeline",
  24843. "SecurityPolicyViolationEvent",
  24844. "Segmenter",
  24845. "Selection",
  24846. "Sensor",
  24847. "SensorErrorEvent",
  24848. "Serial",
  24849. "SerialPort",
  24850. "ServiceWorker",
  24851. "ServiceWorkerContainer",
  24852. "ServiceWorkerRegistration",
  24853. "SessionDescription",
  24854. "Set",
  24855. "ShadowRoot",
  24856. "SharedArrayBuffer",
  24857. "SharedStorage",
  24858. "SharedStorageAppendMethod",
  24859. "SharedStorageClearMethod",
  24860. "SharedStorageDeleteMethod",
  24861. "SharedStorageModifierMethod",
  24862. "SharedStorageSetMethod",
  24863. "SharedStorageWorklet",
  24864. "SharedWorker",
  24865. "SharingState",
  24866. "SimpleGestureEvent",
  24867. "SnapEvent",
  24868. "SourceBuffer",
  24869. "SourceBufferList",
  24870. "SpeechGrammar",
  24871. "SpeechGrammarList",
  24872. "SpeechRecognition",
  24873. "SpeechRecognitionErrorEvent",
  24874. "SpeechRecognitionEvent",
  24875. "SpeechRecognitionPhrase",
  24876. "SpeechSynthesis",
  24877. "SpeechSynthesisErrorEvent",
  24878. "SpeechSynthesisEvent",
  24879. "SpeechSynthesisUtterance",
  24880. "SpeechSynthesisVoice",
  24881. "StaticRange",
  24882. "StereoPannerNode",
  24883. "StopIteration",
  24884. "Storage",
  24885. "StorageBucket",
  24886. "StorageBucketManager",
  24887. "StorageEvent",
  24888. "StorageManager",
  24889. "String",
  24890. "StructType",
  24891. "StylePropertyMap",
  24892. "StylePropertyMapReadOnly",
  24893. "StyleSheet",
  24894. "StyleSheetList",
  24895. "SubmitEvent",
  24896. "Subscriber",
  24897. "SubtleCrypto",
  24898. "Summarizer",
  24899. "SuppressedError",
  24900. "SuspendError",
  24901. "Suspending",
  24902. "Symbol",
  24903. "SyncManager",
  24904. "SyntaxError",
  24905. "TAB_ID_NONE",
  24906. "TAB_INDEX_NONE",
  24907. "TEMPORARY",
  24908. "TEXTPATH_METHODTYPE_ALIGN",
  24909. "TEXTPATH_METHODTYPE_STRETCH",
  24910. "TEXTPATH_METHODTYPE_UNKNOWN",
  24911. "TEXTPATH_SPACINGTYPE_AUTO",
  24912. "TEXTPATH_SPACINGTYPE_EXACT",
  24913. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  24914. "TEXTURE",
  24915. "TEXTURE0",
  24916. "TEXTURE1",
  24917. "TEXTURE10",
  24918. "TEXTURE11",
  24919. "TEXTURE12",
  24920. "TEXTURE13",
  24921. "TEXTURE14",
  24922. "TEXTURE15",
  24923. "TEXTURE16",
  24924. "TEXTURE17",
  24925. "TEXTURE18",
  24926. "TEXTURE19",
  24927. "TEXTURE2",
  24928. "TEXTURE20",
  24929. "TEXTURE21",
  24930. "TEXTURE22",
  24931. "TEXTURE23",
  24932. "TEXTURE24",
  24933. "TEXTURE25",
  24934. "TEXTURE26",
  24935. "TEXTURE27",
  24936. "TEXTURE28",
  24937. "TEXTURE29",
  24938. "TEXTURE3",
  24939. "TEXTURE30",
  24940. "TEXTURE31",
  24941. "TEXTURE4",
  24942. "TEXTURE5",
  24943. "TEXTURE6",
  24944. "TEXTURE7",
  24945. "TEXTURE8",
  24946. "TEXTURE9",
  24947. "TEXTURE_2D",
  24948. "TEXTURE_2D_ARRAY",
  24949. "TEXTURE_3D",
  24950. "TEXTURE_BASE_LEVEL",
  24951. "TEXTURE_BINDING",
  24952. "TEXTURE_BINDING_2D",
  24953. "TEXTURE_BINDING_2D_ARRAY",
  24954. "TEXTURE_BINDING_3D",
  24955. "TEXTURE_BINDING_CUBE_MAP",
  24956. "TEXTURE_COMPARE_FUNC",
  24957. "TEXTURE_COMPARE_MODE",
  24958. "TEXTURE_CUBE_MAP",
  24959. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  24960. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  24961. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  24962. "TEXTURE_CUBE_MAP_POSITIVE_X",
  24963. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  24964. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  24965. "TEXTURE_IMMUTABLE_FORMAT",
  24966. "TEXTURE_IMMUTABLE_LEVELS",
  24967. "TEXTURE_MAG_FILTER",
  24968. "TEXTURE_MAX_ANISOTROPY_EXT",
  24969. "TEXTURE_MAX_LEVEL",
  24970. "TEXTURE_MAX_LOD",
  24971. "TEXTURE_MIN_FILTER",
  24972. "TEXTURE_MIN_LOD",
  24973. "TEXTURE_WRAP_R",
  24974. "TEXTURE_WRAP_S",
  24975. "TEXTURE_WRAP_T",
  24976. "TEXT_NODE",
  24977. "TIMEOUT",
  24978. "TIMEOUT_ERR",
  24979. "TIMEOUT_EXPIRED",
  24980. "TIMEOUT_IGNORED",
  24981. "TOO_LARGE_ERR",
  24982. "TRANSACTION_INACTIVE_ERR",
  24983. "TRANSFORM_FEEDBACK",
  24984. "TRANSFORM_FEEDBACK_ACTIVE",
  24985. "TRANSFORM_FEEDBACK_BINDING",
  24986. "TRANSFORM_FEEDBACK_BUFFER",
  24987. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  24988. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  24989. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  24990. "TRANSFORM_FEEDBACK_BUFFER_START",
  24991. "TRANSFORM_FEEDBACK_PAUSED",
  24992. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  24993. "TRANSFORM_FEEDBACK_VARYINGS",
  24994. "TRIANGLE",
  24995. "TRIANGLES",
  24996. "TRIANGLE_FAN",
  24997. "TRIANGLE_STRIP",
  24998. "TYPE_BACK_FORWARD",
  24999. "TYPE_ERR",
  25000. "TYPE_MISMATCH_ERR",
  25001. "TYPE_NAVIGATE",
  25002. "TYPE_RELOAD",
  25003. "TYPE_RESERVED",
  25004. "Tab",
  25005. "TabStatus",
  25006. "Table",
  25007. "Tag",
  25008. "TaskAttributionTiming",
  25009. "TaskController",
  25010. "TaskPriorityChangeEvent",
  25011. "TaskSignal",
  25012. "Temporal",
  25013. "Text",
  25014. "TextDecoder",
  25015. "TextDecoderStream",
  25016. "TextEncoder",
  25017. "TextEncoderStream",
  25018. "TextEvent",
  25019. "TextFormat",
  25020. "TextFormatUpdateEvent",
  25021. "TextMetrics",
  25022. "TextTrack",
  25023. "TextTrackCue",
  25024. "TextTrackCueList",
  25025. "TextTrackList",
  25026. "TextUpdateEvent",
  25027. "TimeEvent",
  25028. "TimeRanges",
  25029. "ToggleEvent",
  25030. "Touch",
  25031. "TouchEvent",
  25032. "TouchList",
  25033. "TrackEvent",
  25034. "TransformStream",
  25035. "TransformStreamDefaultController",
  25036. "TransitionEvent",
  25037. "Translator",
  25038. "TreeWalker",
  25039. "TrustedHTML",
  25040. "TrustedScript",
  25041. "TrustedScriptURL",
  25042. "TrustedTypePolicy",
  25043. "TrustedTypePolicyFactory",
  25044. "TypeError",
  25045. "TypedObject",
  25046. "U2F",
  25047. "UIEvent",
  25048. "UNCACHED",
  25049. "UNIFORM",
  25050. "UNIFORM_ARRAY_STRIDE",
  25051. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  25052. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  25053. "UNIFORM_BLOCK_BINDING",
  25054. "UNIFORM_BLOCK_DATA_SIZE",
  25055. "UNIFORM_BLOCK_INDEX",
  25056. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  25057. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  25058. "UNIFORM_BUFFER",
  25059. "UNIFORM_BUFFER_BINDING",
  25060. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  25061. "UNIFORM_BUFFER_SIZE",
  25062. "UNIFORM_BUFFER_START",
  25063. "UNIFORM_IS_ROW_MAJOR",
  25064. "UNIFORM_MATRIX_STRIDE",
  25065. "UNIFORM_OFFSET",
  25066. "UNIFORM_SIZE",
  25067. "UNIFORM_TYPE",
  25068. "UNKNOWN_ERR",
  25069. "UNKNOWN_RULE",
  25070. "UNMASKED_RENDERER_WEBGL",
  25071. "UNMASKED_VENDOR_WEBGL",
  25072. "UNORDERED_NODE_ITERATOR_TYPE",
  25073. "UNORDERED_NODE_SNAPSHOT_TYPE",
  25074. "UNPACK_ALIGNMENT",
  25075. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  25076. "UNPACK_FLIP_Y_WEBGL",
  25077. "UNPACK_IMAGE_HEIGHT",
  25078. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  25079. "UNPACK_ROW_LENGTH",
  25080. "UNPACK_SKIP_IMAGES",
  25081. "UNPACK_SKIP_PIXELS",
  25082. "UNPACK_SKIP_ROWS",
  25083. "UNSCHEDULED_STATE",
  25084. "UNSENT",
  25085. "UNSIGNALED",
  25086. "UNSIGNED_BYTE",
  25087. "UNSIGNED_INT",
  25088. "UNSIGNED_INT_10F_11F_11F_REV",
  25089. "UNSIGNED_INT_24_8",
  25090. "UNSIGNED_INT_2_10_10_10_REV",
  25091. "UNSIGNED_INT_5_9_9_9_REV",
  25092. "UNSIGNED_INT_SAMPLER_2D",
  25093. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  25094. "UNSIGNED_INT_SAMPLER_3D",
  25095. "UNSIGNED_INT_SAMPLER_CUBE",
  25096. "UNSIGNED_INT_VEC2",
  25097. "UNSIGNED_INT_VEC3",
  25098. "UNSIGNED_INT_VEC4",
  25099. "UNSIGNED_NORMALIZED",
  25100. "UNSIGNED_SHORT",
  25101. "UNSIGNED_SHORT_4_4_4_4",
  25102. "UNSIGNED_SHORT_5_5_5_1",
  25103. "UNSIGNED_SHORT_5_6_5",
  25104. "UNSPECIFIED_EVENT_TYPE_ERR",
  25105. "UPDATEREADY",
  25106. "URIError",
  25107. "URL",
  25108. "URLPattern",
  25109. "URLSearchParams",
  25110. "URLUnencoded",
  25111. "URL_MISMATCH_ERR",
  25112. "USB",
  25113. "USBAlternateInterface",
  25114. "USBConfiguration",
  25115. "USBConnectionEvent",
  25116. "USBDevice",
  25117. "USBEndpoint",
  25118. "USBInTransferResult",
  25119. "USBInterface",
  25120. "USBIsochronousInTransferPacket",
  25121. "USBIsochronousInTransferResult",
  25122. "USBIsochronousOutTransferPacket",
  25123. "USBIsochronousOutTransferResult",
  25124. "USBOutTransferResult",
  25125. "UTC",
  25126. "Uint16Array",
  25127. "Uint32Array",
  25128. "Uint8Array",
  25129. "Uint8ClampedArray",
  25130. "UpdateFilter",
  25131. "UpdatePropertyName",
  25132. "UserActivation",
  25133. "UserMessageHandler",
  25134. "UserMessageHandlersNamespace",
  25135. "UserProximityEvent",
  25136. "VALIDATE_STATUS",
  25137. "VALIDATION_ERR",
  25138. "VARIABLES_RULE",
  25139. "VENDOR",
  25140. "VERSION",
  25141. "VERSION_CHANGE",
  25142. "VERSION_ERR",
  25143. "VERTEX",
  25144. "VERTEX_ARRAY_BINDING",
  25145. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  25146. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  25147. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  25148. "VERTEX_ATTRIB_ARRAY_ENABLED",
  25149. "VERTEX_ATTRIB_ARRAY_INTEGER",
  25150. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  25151. "VERTEX_ATTRIB_ARRAY_POINTER",
  25152. "VERTEX_ATTRIB_ARRAY_SIZE",
  25153. "VERTEX_ATTRIB_ARRAY_STRIDE",
  25154. "VERTEX_ATTRIB_ARRAY_TYPE",
  25155. "VERTEX_SHADER",
  25156. "VERTICAL",
  25157. "VERTICAL_AXIS",
  25158. "VER_ERR",
  25159. "VIEWPORT",
  25160. "VIEWPORT_RULE",
  25161. "VRDisplay",
  25162. "VRDisplayCapabilities",
  25163. "VRDisplayEvent",
  25164. "VREyeParameters",
  25165. "VRFieldOfView",
  25166. "VRFrameData",
  25167. "VRPose",
  25168. "VRStageParameters",
  25169. "VTTCue",
  25170. "VTTRegion",
  25171. "ValidityState",
  25172. "VideoColorSpace",
  25173. "VideoDecoder",
  25174. "VideoEncoder",
  25175. "VideoFrame",
  25176. "VideoPlaybackQuality",
  25177. "VideoStreamTrack",
  25178. "ViewTimeline",
  25179. "ViewTransition",
  25180. "ViewTransitionTypeSet",
  25181. "ViewType",
  25182. "Viewport",
  25183. "VirtualKeyboard",
  25184. "VirtualKeyboardGeometryChangeEvent",
  25185. "VisibilityStateEntry",
  25186. "VisualViewport",
  25187. "WAIT_FAILED",
  25188. "WEBKIT_FILTER_RULE",
  25189. "WEBKIT_KEYFRAMES_RULE",
  25190. "WEBKIT_KEYFRAME_RULE",
  25191. "WEBKIT_REGION_RULE",
  25192. "WGSLLanguageFeatures",
  25193. "WINDOW_ID_CURRENT",
  25194. "WINDOW_ID_NONE",
  25195. "WRITE",
  25196. "WRONG_DOCUMENT_ERR",
  25197. "WakeLock",
  25198. "WakeLockSentinel",
  25199. "WasmAnyRef",
  25200. "WaveShaperNode",
  25201. "WeakMap",
  25202. "WeakRef",
  25203. "WeakSet",
  25204. "WebAssembly",
  25205. "WebGL2RenderingContext",
  25206. "WebGLActiveInfo",
  25207. "WebGLBuffer",
  25208. "WebGLContextEvent",
  25209. "WebGLFramebuffer",
  25210. "WebGLObject",
  25211. "WebGLProgram",
  25212. "WebGLQuery",
  25213. "WebGLRenderbuffer",
  25214. "WebGLRenderingContext",
  25215. "WebGLSampler",
  25216. "WebGLShader",
  25217. "WebGLShaderPrecisionFormat",
  25218. "WebGLSync",
  25219. "WebGLTexture",
  25220. "WebGLTransformFeedback",
  25221. "WebGLUniformLocation",
  25222. "WebGLVertexArray",
  25223. "WebGLVertexArrayObject",
  25224. "WebKitAnimationEvent",
  25225. "WebKitBlobBuilder",
  25226. "WebKitCSSFilterRule",
  25227. "WebKitCSSFilterValue",
  25228. "WebKitCSSKeyframeRule",
  25229. "WebKitCSSKeyframesRule",
  25230. "WebKitCSSMatrix",
  25231. "WebKitCSSRegionRule",
  25232. "WebKitCSSTransformValue",
  25233. "WebKitDataCue",
  25234. "WebKitGamepad",
  25235. "WebKitMediaKeyError",
  25236. "WebKitMediaKeyMessageEvent",
  25237. "WebKitMediaKeySession",
  25238. "WebKitMediaKeys",
  25239. "WebKitMediaSource",
  25240. "WebKitMutationObserver",
  25241. "WebKitNamespace",
  25242. "WebKitPlaybackTargetAvailabilityEvent",
  25243. "WebKitPoint",
  25244. "WebKitShadowRoot",
  25245. "WebKitSourceBuffer",
  25246. "WebKitSourceBufferList",
  25247. "WebKitTransitionEvent",
  25248. "WebSocket",
  25249. "WebSocketError",
  25250. "WebSocketStream",
  25251. "WebTransport",
  25252. "WebTransportBidirectionalStream",
  25253. "WebTransportDatagramDuplexStream",
  25254. "WebTransportError",
  25255. "WebTransportReceiveStream",
  25256. "WebTransportSendStream",
  25257. "WebkitAlignContent",
  25258. "WebkitAlignItems",
  25259. "WebkitAlignSelf",
  25260. "WebkitAnimation",
  25261. "WebkitAnimationDelay",
  25262. "WebkitAnimationDirection",
  25263. "WebkitAnimationDuration",
  25264. "WebkitAnimationFillMode",
  25265. "WebkitAnimationIterationCount",
  25266. "WebkitAnimationName",
  25267. "WebkitAnimationPlayState",
  25268. "WebkitAnimationTimingFunction",
  25269. "WebkitAppearance",
  25270. "WebkitBackfaceVisibility",
  25271. "WebkitBackgroundClip",
  25272. "WebkitBackgroundOrigin",
  25273. "WebkitBackgroundSize",
  25274. "WebkitBorderBottomLeftRadius",
  25275. "WebkitBorderBottomRightRadius",
  25276. "WebkitBorderImage",
  25277. "WebkitBorderRadius",
  25278. "WebkitBorderTopLeftRadius",
  25279. "WebkitBorderTopRightRadius",
  25280. "WebkitBoxAlign",
  25281. "WebkitBoxDirection",
  25282. "WebkitBoxFlex",
  25283. "WebkitBoxOrdinalGroup",
  25284. "WebkitBoxOrient",
  25285. "WebkitBoxPack",
  25286. "WebkitBoxShadow",
  25287. "WebkitBoxSizing",
  25288. "WebkitClipPath",
  25289. "WebkitFilter",
  25290. "WebkitFlex",
  25291. "WebkitFlexBasis",
  25292. "WebkitFlexDirection",
  25293. "WebkitFlexFlow",
  25294. "WebkitFlexGrow",
  25295. "WebkitFlexShrink",
  25296. "WebkitFlexWrap",
  25297. "WebkitFontFeatureSettings",
  25298. "WebkitJustifyContent",
  25299. "WebkitLineClamp",
  25300. "WebkitMask",
  25301. "WebkitMaskClip",
  25302. "WebkitMaskComposite",
  25303. "WebkitMaskImage",
  25304. "WebkitMaskOrigin",
  25305. "WebkitMaskPosition",
  25306. "WebkitMaskPositionX",
  25307. "WebkitMaskPositionY",
  25308. "WebkitMaskRepeat",
  25309. "WebkitMaskSize",
  25310. "WebkitOrder",
  25311. "WebkitPerspective",
  25312. "WebkitPerspectiveOrigin",
  25313. "WebkitTextFillColor",
  25314. "WebkitTextSecurity",
  25315. "WebkitTextSizeAdjust",
  25316. "WebkitTextStroke",
  25317. "WebkitTextStrokeColor",
  25318. "WebkitTextStrokeWidth",
  25319. "WebkitTransform",
  25320. "WebkitTransformOrigin",
  25321. "WebkitTransformStyle",
  25322. "WebkitTransition",
  25323. "WebkitTransitionDelay",
  25324. "WebkitTransitionDuration",
  25325. "WebkitTransitionProperty",
  25326. "WebkitTransitionTimingFunction",
  25327. "WebkitUserSelect",
  25328. "WheelEvent",
  25329. "Window",
  25330. "WindowControlsOverlay",
  25331. "WindowControlsOverlayGeometryChangeEvent",
  25332. "WindowState",
  25333. "WindowType",
  25334. "Worker",
  25335. "Worklet",
  25336. "WritableStream",
  25337. "WritableStreamDefaultController",
  25338. "WritableStreamDefaultWriter",
  25339. "XMLDocument",
  25340. "XMLHttpRequest",
  25341. "XMLHttpRequestEventTarget",
  25342. "XMLHttpRequestException",
  25343. "XMLHttpRequestProgressEvent",
  25344. "XMLHttpRequestUpload",
  25345. "XMLSerializer",
  25346. "XMLStylesheetProcessingInstruction",
  25347. "XPathEvaluator",
  25348. "XPathException",
  25349. "XPathExpression",
  25350. "XPathNSResolver",
  25351. "XPathResult",
  25352. "XRAnchor",
  25353. "XRAnchorSet",
  25354. "XRBoundedReferenceSpace",
  25355. "XRCPUDepthInformation",
  25356. "XRCamera",
  25357. "XRDOMOverlayState",
  25358. "XRDepthInformation",
  25359. "XRFrame",
  25360. "XRHand",
  25361. "XRHitTestResult",
  25362. "XRHitTestSource",
  25363. "XRInputSource",
  25364. "XRInputSourceArray",
  25365. "XRInputSourceEvent",
  25366. "XRInputSourcesChangeEvent",
  25367. "XRJointPose",
  25368. "XRJointSpace",
  25369. "XRLayer",
  25370. "XRLightEstimate",
  25371. "XRLightProbe",
  25372. "XRPose",
  25373. "XRRay",
  25374. "XRReferenceSpace",
  25375. "XRReferenceSpaceEvent",
  25376. "XRRenderState",
  25377. "XRRigidTransform",
  25378. "XRSession",
  25379. "XRSessionEvent",
  25380. "XRSpace",
  25381. "XRSystem",
  25382. "XRTransientInputHitTestResult",
  25383. "XRTransientInputHitTestSource",
  25384. "XRView",
  25385. "XRViewerPose",
  25386. "XRViewport",
  25387. "XRWebGLBinding",
  25388. "XRWebGLDepthInformation",
  25389. "XRWebGLLayer",
  25390. "XSLTProcessor",
  25391. "ZERO",
  25392. "ZonedDateTime",
  25393. "ZoomSettings",
  25394. "ZoomSettingsMode",
  25395. "ZoomSettingsScope",
  25396. "_XD0M_",
  25397. "_YD0M_",
  25398. "__REACT_DEVTOOLS_GLOBAL_HOOK__",
  25399. "__brand",
  25400. "__defineGetter__",
  25401. "__defineSetter__",
  25402. "__lookupGetter__",
  25403. "__lookupSetter__",
  25404. "__opera",
  25405. "__proto__",
  25406. "_browserjsran",
  25407. "a",
  25408. "aLink",
  25409. "abbr",
  25410. "abort",
  25411. "aborted",
  25412. "aboutConfigPrefs",
  25413. "abs",
  25414. "absolute",
  25415. "acceleration",
  25416. "accelerationIncludingGravity",
  25417. "accelerator",
  25418. "accent-color",
  25419. "accentColor",
  25420. "accept",
  25421. "acceptCharset",
  25422. "acceptNode",
  25423. "access",
  25424. "accessKey",
  25425. "accessKeyLabel",
  25426. "accuracy",
  25427. "acos",
  25428. "acosh",
  25429. "action",
  25430. "actionURL",
  25431. "actions",
  25432. "activated",
  25433. "activation",
  25434. "activationStart",
  25435. "active",
  25436. "activeCues",
  25437. "activeElement",
  25438. "activeSourceBuffers",
  25439. "activeSourceCount",
  25440. "activeTexture",
  25441. "activeVRDisplays",
  25442. "activeViewTransition",
  25443. "activityLog",
  25444. "actualBoundingBoxAscent",
  25445. "actualBoundingBoxDescent",
  25446. "actualBoundingBoxLeft",
  25447. "actualBoundingBoxRight",
  25448. "adAuctionComponents",
  25449. "adAuctionHeaders",
  25450. "adapterInfo",
  25451. "add",
  25452. "addAll",
  25453. "addBehavior",
  25454. "addCandidate",
  25455. "addColorStop",
  25456. "addCue",
  25457. "addElement",
  25458. "addEventListener",
  25459. "addFilter",
  25460. "addFromString",
  25461. "addFromUri",
  25462. "addIceCandidate",
  25463. "addImport",
  25464. "addListener",
  25465. "addModule",
  25466. "addNamed",
  25467. "addPageRule",
  25468. "addPath",
  25469. "addPointer",
  25470. "addRange",
  25471. "addRegion",
  25472. "addRule",
  25473. "addSearchEngine",
  25474. "addSourceBuffer",
  25475. "addStream",
  25476. "addTeardown",
  25477. "addTextTrack",
  25478. "addTrack",
  25479. "addTransceiver",
  25480. "addWakeLockListener",
  25481. "added",
  25482. "addedNodes",
  25483. "additionalName",
  25484. "additiveSymbols",
  25485. "addons",
  25486. "address",
  25487. "addressLine",
  25488. "addressModeU",
  25489. "addressModeV",
  25490. "addressModeW",
  25491. "adopt",
  25492. "adoptNode",
  25493. "adoptedCallback",
  25494. "adoptedStyleSheets",
  25495. "adr",
  25496. "advance",
  25497. "after",
  25498. "alarms",
  25499. "album",
  25500. "alert",
  25501. "algorithm",
  25502. "align",
  25503. "align-content",
  25504. "align-items",
  25505. "align-self",
  25506. "alignContent",
  25507. "alignItems",
  25508. "alignSelf",
  25509. "alignmentBaseline",
  25510. "alinkColor",
  25511. "all",
  25512. "allSettled",
  25513. "allocationSize",
  25514. "allow",
  25515. "allowFullscreen",
  25516. "allowPaymentRequest",
  25517. "allowedDirections",
  25518. "allowedFeatures",
  25519. "allowedToPlay",
  25520. "allowsFeature",
  25521. "alpha",
  25522. "alphaMode",
  25523. "alphaToCoverageEnabled",
  25524. "alphabeticBaseline",
  25525. "alt",
  25526. "altGraphKey",
  25527. "altHtml",
  25528. "altKey",
  25529. "altLeft",
  25530. "alternate",
  25531. "alternateSetting",
  25532. "alternates",
  25533. "altitude",
  25534. "altitudeAccuracy",
  25535. "altitudeAngle",
  25536. "amplitude",
  25537. "ancestorOrigins",
  25538. "anchor",
  25539. "anchorName",
  25540. "anchorNode",
  25541. "anchorOffset",
  25542. "anchorScope",
  25543. "anchorSpace",
  25544. "anchors",
  25545. "and",
  25546. "angle",
  25547. "angularAcceleration",
  25548. "angularVelocity",
  25549. "animVal",
  25550. "animate",
  25551. "animated",
  25552. "animatedInstanceRoot",
  25553. "animatedNormalizedPathSegList",
  25554. "animatedPathSegList",
  25555. "animatedPoints",
  25556. "animation",
  25557. "animation-composition",
  25558. "animation-delay",
  25559. "animation-direction",
  25560. "animation-duration",
  25561. "animation-fill-mode",
  25562. "animation-iteration-count",
  25563. "animation-name",
  25564. "animation-play-state",
  25565. "animation-timing-function",
  25566. "animationComposition",
  25567. "animationDelay",
  25568. "animationDirection",
  25569. "animationDuration",
  25570. "animationFillMode",
  25571. "animationIterationCount",
  25572. "animationName",
  25573. "animationPlayState",
  25574. "animationStartTime",
  25575. "animationTimingFunction",
  25576. "animationsPaused",
  25577. "anniversary",
  25578. "annotation",
  25579. "antialias",
  25580. "anticipatedRemoval",
  25581. "any",
  25582. "app",
  25583. "appCodeName",
  25584. "appMinorVersion",
  25585. "appName",
  25586. "appNotifications",
  25587. "appVersion",
  25588. "appearance",
  25589. "append",
  25590. "appendBuffer",
  25591. "appendChild",
  25592. "appendData",
  25593. "appendItem",
  25594. "appendMedium",
  25595. "appendNamed",
  25596. "appendRule",
  25597. "appendStream",
  25598. "appendWindowEnd",
  25599. "appendWindowStart",
  25600. "applets",
  25601. "applicationCache",
  25602. "applicationServerKey",
  25603. "apply",
  25604. "applyConstraints",
  25605. "applyElement",
  25606. "arc",
  25607. "arcTo",
  25608. "arch",
  25609. "architecture",
  25610. "archive",
  25611. "areas",
  25612. "arguments",
  25613. "ariaActiveDescendantElement",
  25614. "ariaAtomic",
  25615. "ariaAutoComplete",
  25616. "ariaBrailleLabel",
  25617. "ariaBrailleRoleDescription",
  25618. "ariaBusy",
  25619. "ariaChecked",
  25620. "ariaColCount",
  25621. "ariaColIndex",
  25622. "ariaColIndexText",
  25623. "ariaColSpan",
  25624. "ariaControlsElements",
  25625. "ariaCurrent",
  25626. "ariaDescribedByElements",
  25627. "ariaDescription",
  25628. "ariaDetailsElements",
  25629. "ariaDisabled",
  25630. "ariaErrorMessageElements",
  25631. "ariaExpanded",
  25632. "ariaFlowToElements",
  25633. "ariaHasPopup",
  25634. "ariaHidden",
  25635. "ariaInvalid",
  25636. "ariaKeyShortcuts",
  25637. "ariaLabel",
  25638. "ariaLabelledByElements",
  25639. "ariaLevel",
  25640. "ariaLive",
  25641. "ariaModal",
  25642. "ariaMultiLine",
  25643. "ariaMultiSelectable",
  25644. "ariaNotify",
  25645. "ariaOrientation",
  25646. "ariaOwnsElements",
  25647. "ariaPlaceholder",
  25648. "ariaPosInSet",
  25649. "ariaPressed",
  25650. "ariaReadOnly",
  25651. "ariaRelevant",
  25652. "ariaRequired",
  25653. "ariaRoleDescription",
  25654. "ariaRowCount",
  25655. "ariaRowIndex",
  25656. "ariaRowIndexText",
  25657. "ariaRowSpan",
  25658. "ariaSelected",
  25659. "ariaSetSize",
  25660. "ariaSort",
  25661. "ariaValueMax",
  25662. "ariaValueMin",
  25663. "ariaValueNow",
  25664. "ariaValueText",
  25665. "arrayBuffer",
  25666. "arrayLayerCount",
  25667. "arrayStride",
  25668. "artist",
  25669. "artwork",
  25670. "as",
  25671. "asIntN",
  25672. "asUintN",
  25673. "ascentOverride",
  25674. "asin",
  25675. "asinh",
  25676. "aspect",
  25677. "aspect-ratio",
  25678. "aspectRatio",
  25679. "assert",
  25680. "assign",
  25681. "assignedElements",
  25682. "assignedNodes",
  25683. "assignedSlot",
  25684. "async",
  25685. "asyncDispose",
  25686. "asyncIterator",
  25687. "at",
  25688. "atEnd",
  25689. "atan",
  25690. "atan2",
  25691. "atanh",
  25692. "atob",
  25693. "attachEvent",
  25694. "attachInternals",
  25695. "attachShader",
  25696. "attachShadow",
  25697. "attachedElements",
  25698. "attachments",
  25699. "attack",
  25700. "attestationObject",
  25701. "attrChange",
  25702. "attrName",
  25703. "attributeChangedCallback",
  25704. "attributeFilter",
  25705. "attributeName",
  25706. "attributeNamespace",
  25707. "attributeOldValue",
  25708. "attributeStyleMap",
  25709. "attributes",
  25710. "attribution",
  25711. "attributionSrc",
  25712. "audioBitrateMode",
  25713. "audioBitsPerSecond",
  25714. "audioTracks",
  25715. "audioWorklet",
  25716. "authenticatedSignedWrites",
  25717. "authenticatorAttachment",
  25718. "authenticatorData",
  25719. "autoIncrement",
  25720. "autobuffer",
  25721. "autocapitalize",
  25722. "autocomplete",
  25723. "autocorrect",
  25724. "autofocus",
  25725. "automationRate",
  25726. "autoplay",
  25727. "availHeight",
  25728. "availLeft",
  25729. "availTop",
  25730. "availWidth",
  25731. "availability",
  25732. "available",
  25733. "averageLatency",
  25734. "aversion",
  25735. "ax",
  25736. "axes",
  25737. "axis",
  25738. "ay",
  25739. "azimuth",
  25740. "azimuthAngle",
  25741. "b",
  25742. "back",
  25743. "backdrop-filter",
  25744. "backdropFilter",
  25745. "backends",
  25746. "backface-visibility",
  25747. "backfaceVisibility",
  25748. "background",
  25749. "background-attachment",
  25750. "background-blend-mode",
  25751. "background-clip",
  25752. "background-color",
  25753. "background-image",
  25754. "background-origin",
  25755. "background-position",
  25756. "background-position-x",
  25757. "background-position-y",
  25758. "background-repeat",
  25759. "background-size",
  25760. "backgroundAttachment",
  25761. "backgroundBlendMode",
  25762. "backgroundClip",
  25763. "backgroundColor",
  25764. "backgroundFetch",
  25765. "backgroundImage",
  25766. "backgroundOrigin",
  25767. "backgroundPosition",
  25768. "backgroundPositionX",
  25769. "backgroundPositionY",
  25770. "backgroundRepeat",
  25771. "backgroundSize",
  25772. "badInput",
  25773. "badge",
  25774. "balance",
  25775. "baseArrayLayer",
  25776. "baseFrequencyX",
  25777. "baseFrequencyY",
  25778. "baseLatency",
  25779. "baseLayer",
  25780. "baseMipLevel",
  25781. "baseNode",
  25782. "baseOffset",
  25783. "basePalette",
  25784. "baseURI",
  25785. "baseVal",
  25786. "baseline-source",
  25787. "baselineShift",
  25788. "baselineSource",
  25789. "batchUpdate",
  25790. "battery",
  25791. "bday",
  25792. "before",
  25793. "beginComputePass",
  25794. "beginElement",
  25795. "beginElementAt",
  25796. "beginOcclusionQuery",
  25797. "beginPath",
  25798. "beginQuery",
  25799. "beginRenderPass",
  25800. "beginTransformFeedback",
  25801. "beginningOfPassWriteIndex",
  25802. "behavior",
  25803. "behaviorCookie",
  25804. "behaviorPart",
  25805. "behaviorUrns",
  25806. "beta",
  25807. "bezierCurveTo",
  25808. "bgColor",
  25809. "bgProperties",
  25810. "bias",
  25811. "big",
  25812. "bigint64",
  25813. "biguint64",
  25814. "binaryType",
  25815. "bind",
  25816. "bindAttribLocation",
  25817. "bindBuffer",
  25818. "bindBufferBase",
  25819. "bindBufferRange",
  25820. "bindFramebuffer",
  25821. "bindGroupLayouts",
  25822. "bindRenderbuffer",
  25823. "bindSampler",
  25824. "bindTexture",
  25825. "bindTransformFeedback",
  25826. "bindVertexArray",
  25827. "binding",
  25828. "bitness",
  25829. "blend",
  25830. "blendColor",
  25831. "blendEquation",
  25832. "blendEquationSeparate",
  25833. "blendFunc",
  25834. "blendFuncSeparate",
  25835. "blink",
  25836. "blitFramebuffer",
  25837. "blob",
  25838. "block-size",
  25839. "blockDirection",
  25840. "blockSize",
  25841. "blockedURI",
  25842. "blockedURL",
  25843. "blocking",
  25844. "blockingDuration",
  25845. "blue",
  25846. "bluetooth",
  25847. "blur",
  25848. "body",
  25849. "bodyUsed",
  25850. "bold",
  25851. "bookmarks",
  25852. "booleanValue",
  25853. "boost",
  25854. "border",
  25855. "border-block",
  25856. "border-block-color",
  25857. "border-block-end",
  25858. "border-block-end-color",
  25859. "border-block-end-style",
  25860. "border-block-end-width",
  25861. "border-block-start",
  25862. "border-block-start-color",
  25863. "border-block-start-style",
  25864. "border-block-start-width",
  25865. "border-block-style",
  25866. "border-block-width",
  25867. "border-bottom",
  25868. "border-bottom-color",
  25869. "border-bottom-left-radius",
  25870. "border-bottom-right-radius",
  25871. "border-bottom-style",
  25872. "border-bottom-width",
  25873. "border-collapse",
  25874. "border-color",
  25875. "border-end-end-radius",
  25876. "border-end-start-radius",
  25877. "border-image",
  25878. "border-image-outset",
  25879. "border-image-repeat",
  25880. "border-image-slice",
  25881. "border-image-source",
  25882. "border-image-width",
  25883. "border-inline",
  25884. "border-inline-color",
  25885. "border-inline-end",
  25886. "border-inline-end-color",
  25887. "border-inline-end-style",
  25888. "border-inline-end-width",
  25889. "border-inline-start",
  25890. "border-inline-start-color",
  25891. "border-inline-start-style",
  25892. "border-inline-start-width",
  25893. "border-inline-style",
  25894. "border-inline-width",
  25895. "border-left",
  25896. "border-left-color",
  25897. "border-left-style",
  25898. "border-left-width",
  25899. "border-radius",
  25900. "border-right",
  25901. "border-right-color",
  25902. "border-right-style",
  25903. "border-right-width",
  25904. "border-spacing",
  25905. "border-start-end-radius",
  25906. "border-start-start-radius",
  25907. "border-style",
  25908. "border-top",
  25909. "border-top-color",
  25910. "border-top-left-radius",
  25911. "border-top-right-radius",
  25912. "border-top-style",
  25913. "border-top-width",
  25914. "border-width",
  25915. "borderBlock",
  25916. "borderBlockColor",
  25917. "borderBlockEnd",
  25918. "borderBlockEndColor",
  25919. "borderBlockEndStyle",
  25920. "borderBlockEndWidth",
  25921. "borderBlockStart",
  25922. "borderBlockStartColor",
  25923. "borderBlockStartStyle",
  25924. "borderBlockStartWidth",
  25925. "borderBlockStyle",
  25926. "borderBlockWidth",
  25927. "borderBottom",
  25928. "borderBottomColor",
  25929. "borderBottomLeftRadius",
  25930. "borderBottomRightRadius",
  25931. "borderBottomStyle",
  25932. "borderBottomWidth",
  25933. "borderBoxSize",
  25934. "borderCollapse",
  25935. "borderColor",
  25936. "borderColorDark",
  25937. "borderColorLight",
  25938. "borderEndEndRadius",
  25939. "borderEndStartRadius",
  25940. "borderImage",
  25941. "borderImageOutset",
  25942. "borderImageRepeat",
  25943. "borderImageSlice",
  25944. "borderImageSource",
  25945. "borderImageWidth",
  25946. "borderInline",
  25947. "borderInlineColor",
  25948. "borderInlineEnd",
  25949. "borderInlineEndColor",
  25950. "borderInlineEndStyle",
  25951. "borderInlineEndWidth",
  25952. "borderInlineStart",
  25953. "borderInlineStartColor",
  25954. "borderInlineStartStyle",
  25955. "borderInlineStartWidth",
  25956. "borderInlineStyle",
  25957. "borderInlineWidth",
  25958. "borderLeft",
  25959. "borderLeftColor",
  25960. "borderLeftStyle",
  25961. "borderLeftWidth",
  25962. "borderRadius",
  25963. "borderRight",
  25964. "borderRightColor",
  25965. "borderRightStyle",
  25966. "borderRightWidth",
  25967. "borderSpacing",
  25968. "borderStartEndRadius",
  25969. "borderStartStartRadius",
  25970. "borderStyle",
  25971. "borderTop",
  25972. "borderTopColor",
  25973. "borderTopLeftRadius",
  25974. "borderTopRightRadius",
  25975. "borderTopStyle",
  25976. "borderTopWidth",
  25977. "borderWidth",
  25978. "bottom",
  25979. "bottomMargin",
  25980. "bound",
  25981. "boundElements",
  25982. "boundingClientRect",
  25983. "boundingHeight",
  25984. "boundingLeft",
  25985. "boundingRect",
  25986. "boundingTop",
  25987. "boundingWidth",
  25988. "bounds",
  25989. "boundsGeometry",
  25990. "box",
  25991. "box-decoration-break",
  25992. "box-shadow",
  25993. "box-sizing",
  25994. "boxDecorationBreak",
  25995. "boxShadow",
  25996. "boxSizing",
  25997. "brand",
  25998. "brands",
  25999. "break-after",
  26000. "break-before",
  26001. "break-inside",
  26002. "breakAfter",
  26003. "breakBefore",
  26004. "breakInside",
  26005. "broadcast",
  26006. "browser",
  26007. "browserLanguage",
  26008. "browserSettings",
  26009. "browsingData",
  26010. "browsingTopics",
  26011. "btoa",
  26012. "bubbles",
  26013. "buffer",
  26014. "bufferData",
  26015. "bufferDepth",
  26016. "bufferSize",
  26017. "bufferSubData",
  26018. "buffered",
  26019. "bufferedAmount",
  26020. "bufferedAmountLowThreshold",
  26021. "buffers",
  26022. "buildID",
  26023. "buildNumber",
  26024. "button",
  26025. "buttonID",
  26026. "buttons",
  26027. "byobRequest",
  26028. "byteLength",
  26029. "byteOffset",
  26030. "bytes",
  26031. "bytesPerRow",
  26032. "bytesWritten",
  26033. "c",
  26034. "cache",
  26035. "caches",
  26036. "calendar",
  26037. "call",
  26038. "caller",
  26039. "camera",
  26040. "canBeFormatted",
  26041. "canBeMounted",
  26042. "canBeShared",
  26043. "canConstructInDedicatedWorker",
  26044. "canGoBack",
  26045. "canGoForward",
  26046. "canHaveChildren",
  26047. "canHaveHTML",
  26048. "canInsertDTMF",
  26049. "canIntercept",
  26050. "canLoadAdAuctionFencedFrame",
  26051. "canLoadOpaqueURL",
  26052. "canMakePayment",
  26053. "canParse",
  26054. "canPlayType",
  26055. "canPresent",
  26056. "canShare",
  26057. "canTransition",
  26058. "canTrickleIceCandidates",
  26059. "cancel",
  26060. "cancelAndHoldAtTime",
  26061. "cancelAnimationFrame",
  26062. "cancelBubble",
  26063. "cancelIdleCallback",
  26064. "cancelScheduledValues",
  26065. "cancelVideoFrameCallback",
  26066. "cancelWatchAvailability",
  26067. "cancelable",
  26068. "candidate",
  26069. "canonicalUUID",
  26070. "canvas",
  26071. "cap",
  26072. "capabilities",
  26073. "caption",
  26074. "caption-side",
  26075. "captionSide",
  26076. "captivePortal",
  26077. "capture",
  26078. "captureEvents",
  26079. "captureStackTrace",
  26080. "captureStream",
  26081. "captureTab",
  26082. "captureVisibleTab",
  26083. "caret-color",
  26084. "caretBidiLevel",
  26085. "caretColor",
  26086. "caretPositionFromPoint",
  26087. "caretRangeFromPoint",
  26088. "cast",
  26089. "catch",
  26090. "category",
  26091. "cause",
  26092. "cbrt",
  26093. "cd",
  26094. "ceil",
  26095. "cellIndex",
  26096. "cellPadding",
  26097. "cellSpacing",
  26098. "cells",
  26099. "ch",
  26100. "chOff",
  26101. "chain",
  26102. "challenge",
  26103. "changeType",
  26104. "changed",
  26105. "changedTouches",
  26106. "channel",
  26107. "channelCount",
  26108. "channelCountMode",
  26109. "channelInterpretation",
  26110. "chapterInfo",
  26111. "char",
  26112. "charAt",
  26113. "charCode",
  26114. "charCodeAt",
  26115. "charIndex",
  26116. "charLength",
  26117. "characterBounds",
  26118. "characterBoundsRangeStart",
  26119. "characterData",
  26120. "characterDataOldValue",
  26121. "characterSet",
  26122. "characterVariant",
  26123. "characteristic",
  26124. "charging",
  26125. "chargingTime",
  26126. "charset",
  26127. "check",
  26128. "checkDCE",
  26129. "checkEnclosure",
  26130. "checkFramebufferStatus",
  26131. "checkIntersection",
  26132. "checkValidity",
  26133. "checkVisibility",
  26134. "checked",
  26135. "childElementCount",
  26136. "childList",
  26137. "childNodes",
  26138. "children",
  26139. "chrome",
  26140. "ciphertext",
  26141. "cite",
  26142. "city",
  26143. "claimInterface",
  26144. "claimed",
  26145. "classList",
  26146. "className",
  26147. "classid",
  26148. "clear",
  26149. "clearAppBadge",
  26150. "clearAttributes",
  26151. "clearBuffer",
  26152. "clearBufferfi",
  26153. "clearBufferfv",
  26154. "clearBufferiv",
  26155. "clearBufferuiv",
  26156. "clearColor",
  26157. "clearData",
  26158. "clearDepth",
  26159. "clearHalt",
  26160. "clearImmediate",
  26161. "clearInterval",
  26162. "clearLiveSeekableRange",
  26163. "clearMarks",
  26164. "clearMaxGCPauseAccumulator",
  26165. "clearMeasures",
  26166. "clearOriginJoinedAdInterestGroups",
  26167. "clearParameters",
  26168. "clearRect",
  26169. "clearResourceTimings",
  26170. "clearShadow",
  26171. "clearStencil",
  26172. "clearTimeout",
  26173. "clearValue",
  26174. "clearWatch",
  26175. "click",
  26176. "clickCount",
  26177. "clientDataJSON",
  26178. "clientHeight",
  26179. "clientInformation",
  26180. "clientLeft",
  26181. "clientRect",
  26182. "clientRects",
  26183. "clientTop",
  26184. "clientWaitSync",
  26185. "clientWidth",
  26186. "clientX",
  26187. "clientY",
  26188. "clip",
  26189. "clip-path",
  26190. "clip-rule",
  26191. "clipBottom",
  26192. "clipLeft",
  26193. "clipPath",
  26194. "clipPathUnits",
  26195. "clipRight",
  26196. "clipRule",
  26197. "clipTop",
  26198. "clipboard",
  26199. "clipboardData",
  26200. "clonable",
  26201. "clone",
  26202. "cloneContents",
  26203. "cloneNode",
  26204. "cloneRange",
  26205. "close",
  26206. "closeCode",
  26207. "closePath",
  26208. "closed",
  26209. "closedBy",
  26210. "closest",
  26211. "clz",
  26212. "clz32",
  26213. "cm",
  26214. "cmp",
  26215. "code",
  26216. "codeBase",
  26217. "codePointAt",
  26218. "codeType",
  26219. "codedHeight",
  26220. "codedRect",
  26221. "codedWidth",
  26222. "colSpan",
  26223. "collapse",
  26224. "collapseToEnd",
  26225. "collapseToStart",
  26226. "collapsed",
  26227. "collect",
  26228. "collections",
  26229. "colno",
  26230. "color",
  26231. "color-adjust",
  26232. "color-interpolation",
  26233. "color-interpolation-filters",
  26234. "color-scheme",
  26235. "colorAdjust",
  26236. "colorAttachments",
  26237. "colorDepth",
  26238. "colorFormats",
  26239. "colorInterpolation",
  26240. "colorInterpolationFilters",
  26241. "colorMask",
  26242. "colorScheme",
  26243. "colorSpace",
  26244. "colorType",
  26245. "cols",
  26246. "column-count",
  26247. "column-fill",
  26248. "column-gap",
  26249. "column-rule",
  26250. "column-rule-color",
  26251. "column-rule-style",
  26252. "column-rule-width",
  26253. "column-span",
  26254. "column-width",
  26255. "columnCount",
  26256. "columnFill",
  26257. "columnGap",
  26258. "columnNumber",
  26259. "columnRule",
  26260. "columnRuleColor",
  26261. "columnRuleStyle",
  26262. "columnRuleWidth",
  26263. "columnSpan",
  26264. "columnWidth",
  26265. "columns",
  26266. "command",
  26267. "commandForElement",
  26268. "commands",
  26269. "commit",
  26270. "commitLoadTime",
  26271. "commitPreferences",
  26272. "commitStyles",
  26273. "committed",
  26274. "commonAncestorContainer",
  26275. "compact",
  26276. "compare",
  26277. "compareBoundaryPoints",
  26278. "compareDocumentPosition",
  26279. "compareEndPoints",
  26280. "compareExchange",
  26281. "compareNode",
  26282. "comparePoint",
  26283. "compatMode",
  26284. "compatible",
  26285. "compile",
  26286. "compileShader",
  26287. "compileStreaming",
  26288. "complete",
  26289. "completed",
  26290. "component",
  26291. "componentFromPoint",
  26292. "composed",
  26293. "composedPath",
  26294. "composite",
  26295. "compositionEndOffset",
  26296. "compositionStartOffset",
  26297. "compressedTexImage2D",
  26298. "compressedTexImage3D",
  26299. "compressedTexSubImage2D",
  26300. "compressedTexSubImage3D",
  26301. "compute",
  26302. "computedStyleMap",
  26303. "concat",
  26304. "conditionText",
  26305. "coneInnerAngle",
  26306. "coneOuterAngle",
  26307. "coneOuterGain",
  26308. "config",
  26309. "configURL",
  26310. "configurable",
  26311. "configuration",
  26312. "configurationName",
  26313. "configurationValue",
  26314. "configurations",
  26315. "configure",
  26316. "confirm",
  26317. "confirmComposition",
  26318. "confirmSiteSpecificTrackingException",
  26319. "confirmWebWideTrackingException",
  26320. "congestionControl",
  26321. "connect",
  26322. "connectEnd",
  26323. "connectNative",
  26324. "connectShark",
  26325. "connectStart",
  26326. "connected",
  26327. "connectedCallback",
  26328. "connectedMoveCallback",
  26329. "connection",
  26330. "connectionInfo",
  26331. "connectionList",
  26332. "connectionSpeed",
  26333. "connectionState",
  26334. "connections",
  26335. "console",
  26336. "consolidate",
  26337. "constants",
  26338. "constraint",
  26339. "constrictionActive",
  26340. "construct",
  26341. "constructor",
  26342. "contactID",
  26343. "contain",
  26344. "contain-intrinsic-block-size",
  26345. "contain-intrinsic-height",
  26346. "contain-intrinsic-inline-size",
  26347. "contain-intrinsic-size",
  26348. "contain-intrinsic-width",
  26349. "containIntrinsicBlockSize",
  26350. "containIntrinsicHeight",
  26351. "containIntrinsicInlineSize",
  26352. "containIntrinsicSize",
  26353. "containIntrinsicWidth",
  26354. "container",
  26355. "container-name",
  26356. "container-type",
  26357. "containerId",
  26358. "containerName",
  26359. "containerQuery",
  26360. "containerSrc",
  26361. "containerType",
  26362. "contains",
  26363. "containsNode",
  26364. "content",
  26365. "content-visibility",
  26366. "contentBoxSize",
  26367. "contentDocument",
  26368. "contentEditable",
  26369. "contentEncoding",
  26370. "contentHint",
  26371. "contentOverflow",
  26372. "contentRect",
  26373. "contentScriptType",
  26374. "contentStyleType",
  26375. "contentType",
  26376. "contentVisibility",
  26377. "contentWindow",
  26378. "context",
  26379. "contextId",
  26380. "contextIds",
  26381. "contextMenu",
  26382. "contextMenus",
  26383. "contextType",
  26384. "contextTypes",
  26385. "contextmenu",
  26386. "contextualIdentities",
  26387. "continue",
  26388. "continuePrimaryKey",
  26389. "continuous",
  26390. "control",
  26391. "controlTransferIn",
  26392. "controlTransferOut",
  26393. "controller",
  26394. "controls",
  26395. "controlsList",
  26396. "convertPointFromNode",
  26397. "convertQuadFromNode",
  26398. "convertRectFromNode",
  26399. "convertToBlob",
  26400. "convertToSpecifiedUnits",
  26401. "cookie",
  26402. "cookieEnabled",
  26403. "cookieStore",
  26404. "cookies",
  26405. "coords",
  26406. "copyBufferSubData",
  26407. "copyBufferToBuffer",
  26408. "copyBufferToTexture",
  26409. "copyExternalImageToTexture",
  26410. "copyFromChannel",
  26411. "copyTexImage2D",
  26412. "copyTexSubImage2D",
  26413. "copyTexSubImage3D",
  26414. "copyTextureToBuffer",
  26415. "copyTextureToTexture",
  26416. "copyTo",
  26417. "copyToChannel",
  26418. "copyWithin",
  26419. "correspondingElement",
  26420. "correspondingUseElement",
  26421. "corruptedVideoFrames",
  26422. "cos",
  26423. "cosh",
  26424. "count",
  26425. "countReset",
  26426. "counter-increment",
  26427. "counter-reset",
  26428. "counter-set",
  26429. "counterIncrement",
  26430. "counterReset",
  26431. "counterSet",
  26432. "country",
  26433. "cpuClass",
  26434. "cpuSleepAllowed",
  26435. "cqb",
  26436. "cqh",
  26437. "cqi",
  26438. "cqmax",
  26439. "cqmin",
  26440. "cqw",
  26441. "create",
  26442. "createAnalyser",
  26443. "createAnchor",
  26444. "createAnswer",
  26445. "createAttribute",
  26446. "createAttributeNS",
  26447. "createAuctionNonce",
  26448. "createBidirectionalStream",
  26449. "createBindGroup",
  26450. "createBindGroupLayout",
  26451. "createBiquadFilter",
  26452. "createBuffer",
  26453. "createBufferSource",
  26454. "createCDATASection",
  26455. "createCSSStyleSheet",
  26456. "createCaption",
  26457. "createChannelMerger",
  26458. "createChannelSplitter",
  26459. "createCommandEncoder",
  26460. "createComment",
  26461. "createComputePipeline",
  26462. "createComputePipelineAsync",
  26463. "createConicGradient",
  26464. "createConstantSource",
  26465. "createContextualFragment",
  26466. "createControlRange",
  26467. "createConvolver",
  26468. "createDTMFSender",
  26469. "createDataChannel",
  26470. "createDelay",
  26471. "createDelayNode",
  26472. "createDocument",
  26473. "createDocumentFragment",
  26474. "createDocumentType",
  26475. "createDynamicsCompressor",
  26476. "createElement",
  26477. "createElementNS",
  26478. "createEncodedStreams",
  26479. "createEntityReference",
  26480. "createEvent",
  26481. "createEventObject",
  26482. "createExpression",
  26483. "createFramebuffer",
  26484. "createFunction",
  26485. "createGain",
  26486. "createGainNode",
  26487. "createHTML",
  26488. "createHTMLDocument",
  26489. "createIIRFilter",
  26490. "createImageBitmap",
  26491. "createImageData",
  26492. "createIndex",
  26493. "createJavaScriptNode",
  26494. "createLinearGradient",
  26495. "createMediaElementSource",
  26496. "createMediaKeys",
  26497. "createMediaStreamDestination",
  26498. "createMediaStreamSource",
  26499. "createMediaStreamTrackSource",
  26500. "createMutableFile",
  26501. "createNSResolver",
  26502. "createNodeIterator",
  26503. "createNotification",
  26504. "createObjectStore",
  26505. "createObjectURL",
  26506. "createOffer",
  26507. "createOscillator",
  26508. "createPanner",
  26509. "createPattern",
  26510. "createPeriodicWave",
  26511. "createPipelineLayout",
  26512. "createPolicy",
  26513. "createPopup",
  26514. "createProcessingInstruction",
  26515. "createProgram",
  26516. "createQuery",
  26517. "createQuerySet",
  26518. "createRadialGradient",
  26519. "createRange",
  26520. "createRangeCollection",
  26521. "createReader",
  26522. "createRenderBundleEncoder",
  26523. "createRenderPipeline",
  26524. "createRenderPipelineAsync",
  26525. "createRenderbuffer",
  26526. "createSVGAngle",
  26527. "createSVGLength",
  26528. "createSVGMatrix",
  26529. "createSVGNumber",
  26530. "createSVGPathSegArcAbs",
  26531. "createSVGPathSegArcRel",
  26532. "createSVGPathSegClosePath",
  26533. "createSVGPathSegCurvetoCubicAbs",
  26534. "createSVGPathSegCurvetoCubicRel",
  26535. "createSVGPathSegCurvetoCubicSmoothAbs",
  26536. "createSVGPathSegCurvetoCubicSmoothRel",
  26537. "createSVGPathSegCurvetoQuadraticAbs",
  26538. "createSVGPathSegCurvetoQuadraticRel",
  26539. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  26540. "createSVGPathSegCurvetoQuadraticSmoothRel",
  26541. "createSVGPathSegLinetoAbs",
  26542. "createSVGPathSegLinetoHorizontalAbs",
  26543. "createSVGPathSegLinetoHorizontalRel",
  26544. "createSVGPathSegLinetoRel",
  26545. "createSVGPathSegLinetoVerticalAbs",
  26546. "createSVGPathSegLinetoVerticalRel",
  26547. "createSVGPathSegMovetoAbs",
  26548. "createSVGPathSegMovetoRel",
  26549. "createSVGPoint",
  26550. "createSVGRect",
  26551. "createSVGTransform",
  26552. "createSVGTransformFromMatrix",
  26553. "createSampler",
  26554. "createScript",
  26555. "createScriptProcessor",
  26556. "createScriptURL",
  26557. "createSession",
  26558. "createShader",
  26559. "createShaderModule",
  26560. "createShadowRoot",
  26561. "createStereoPanner",
  26562. "createStyleSheet",
  26563. "createTBody",
  26564. "createTFoot",
  26565. "createTHead",
  26566. "createTask",
  26567. "createTextNode",
  26568. "createTextRange",
  26569. "createTexture",
  26570. "createTouch",
  26571. "createTouchList",
  26572. "createTransformFeedback",
  26573. "createTreeWalker",
  26574. "createUnidirectionalStream",
  26575. "createVertexArray",
  26576. "createView",
  26577. "createWaveShaper",
  26578. "createWorklet",
  26579. "createWritable",
  26580. "creationTime",
  26581. "credentialless",
  26582. "credentials",
  26583. "criticalCHRestart",
  26584. "cropTo",
  26585. "crossOrigin",
  26586. "crossOriginIsolated",
  26587. "crypto",
  26588. "csi",
  26589. "csp",
  26590. "cssFloat",
  26591. "cssRules",
  26592. "cssText",
  26593. "cssValueType",
  26594. "ctrlKey",
  26595. "ctrlLeft",
  26596. "cues",
  26597. "cullFace",
  26598. "cullMode",
  26599. "currentCSSZoom",
  26600. "currentDirection",
  26601. "currentEntry",
  26602. "currentLocalDescription",
  26603. "currentNode",
  26604. "currentPage",
  26605. "currentRect",
  26606. "currentRemoteDescription",
  26607. "currentScale",
  26608. "currentScreen",
  26609. "currentScript",
  26610. "currentSrc",
  26611. "currentState",
  26612. "currentStyle",
  26613. "currentTarget",
  26614. "currentTime",
  26615. "currentTranslate",
  26616. "currentView",
  26617. "cursor",
  26618. "curve",
  26619. "customElements",
  26620. "customError",
  26621. "cx",
  26622. "cy",
  26623. "d",
  26624. "data",
  26625. "dataFld",
  26626. "dataFormatAs",
  26627. "dataLoss",
  26628. "dataLossMessage",
  26629. "dataPageSize",
  26630. "dataSrc",
  26631. "dataTransfer",
  26632. "database",
  26633. "databases",
  26634. "datagrams",
  26635. "dataset",
  26636. "dateStyle",
  26637. "dateTime",
  26638. "day",
  26639. "dayPeriod",
  26640. "days",
  26641. "db",
  26642. "debug",
  26643. "debuggerEnabled",
  26644. "declarativeNetRequest",
  26645. "declare",
  26646. "decode",
  26647. "decodeAudioData",
  26648. "decodeQueueSize",
  26649. "decodeURI",
  26650. "decodeURIComponent",
  26651. "decodedBodySize",
  26652. "decoding",
  26653. "decodingInfo",
  26654. "decreaseZoomLevel",
  26655. "decrypt",
  26656. "default",
  26657. "defaultCharset",
  26658. "defaultChecked",
  26659. "defaultMuted",
  26660. "defaultPlaybackRate",
  26661. "defaultPolicy",
  26662. "defaultPrevented",
  26663. "defaultQueue",
  26664. "defaultRequest",
  26665. "defaultSelected",
  26666. "defaultStatus",
  26667. "defaultURL",
  26668. "defaultValue",
  26669. "defaultView",
  26670. "defaultstatus",
  26671. "defer",
  26672. "define",
  26673. "defineMagicFunction",
  26674. "defineMagicVariable",
  26675. "defineProperties",
  26676. "defineProperty",
  26677. "deg",
  26678. "delay",
  26679. "delayTime",
  26680. "delegatesFocus",
  26681. "delete",
  26682. "deleteBuffer",
  26683. "deleteCaption",
  26684. "deleteCell",
  26685. "deleteContents",
  26686. "deleteData",
  26687. "deleteDatabase",
  26688. "deleteFramebuffer",
  26689. "deleteFromDocument",
  26690. "deleteIndex",
  26691. "deleteMedium",
  26692. "deleteObjectStore",
  26693. "deleteProgram",
  26694. "deleteProperty",
  26695. "deleteQuery",
  26696. "deleteRenderbuffer",
  26697. "deleteRow",
  26698. "deleteRule",
  26699. "deleteSampler",
  26700. "deleteShader",
  26701. "deleteSync",
  26702. "deleteTFoot",
  26703. "deleteTHead",
  26704. "deleteTexture",
  26705. "deleteTransformFeedback",
  26706. "deleteVertexArray",
  26707. "deleted",
  26708. "deliverChangeRecords",
  26709. "deliveredFrames",
  26710. "deliveredFramesDuration",
  26711. "delivery",
  26712. "deliveryInfo",
  26713. "deliveryStatus",
  26714. "deliveryTimestamp",
  26715. "deliveryType",
  26716. "delta",
  26717. "deltaMode",
  26718. "deltaX",
  26719. "deltaY",
  26720. "deltaZ",
  26721. "dependentLocality",
  26722. "deprecatedReplaceInURN",
  26723. "deprecatedRunAdAuctionEnforcesKAnonymity",
  26724. "deprecatedURNToURL",
  26725. "depthActive",
  26726. "depthBias",
  26727. "depthBiasClamp",
  26728. "depthBiasSlopeScale",
  26729. "depthClearValue",
  26730. "depthCompare",
  26731. "depthDataFormat",
  26732. "depthFailOp",
  26733. "depthFar",
  26734. "depthFunc",
  26735. "depthLoadOp",
  26736. "depthMask",
  26737. "depthNear",
  26738. "depthOrArrayLayers",
  26739. "depthRange",
  26740. "depthReadOnly",
  26741. "depthStencil",
  26742. "depthStencilAttachment",
  26743. "depthStencilFormat",
  26744. "depthStoreOp",
  26745. "depthType",
  26746. "depthUsage",
  26747. "depthWriteEnabled",
  26748. "deref",
  26749. "deriveBits",
  26750. "deriveKey",
  26751. "descentOverride",
  26752. "description",
  26753. "deselectAll",
  26754. "designMode",
  26755. "desiredSize",
  26756. "destination",
  26757. "destinationURL",
  26758. "destroy",
  26759. "detach",
  26760. "detachEvent",
  26761. "detachShader",
  26762. "detached",
  26763. "detail",
  26764. "details",
  26765. "detect",
  26766. "detectLanguage",
  26767. "detune",
  26768. "device",
  26769. "deviceClass",
  26770. "deviceId",
  26771. "deviceMemory",
  26772. "devicePixelContentBoxSize",
  26773. "devicePixelRatio",
  26774. "devicePosture",
  26775. "deviceProtocol",
  26776. "deviceSubclass",
  26777. "deviceVersionMajor",
  26778. "deviceVersionMinor",
  26779. "deviceVersionSubminor",
  26780. "deviceXDPI",
  26781. "deviceYDPI",
  26782. "devtools",
  26783. "devtools_panels",
  26784. "didTimeout",
  26785. "difference",
  26786. "diffuseConstant",
  26787. "digest",
  26788. "dimension",
  26789. "dimensions",
  26790. "dir",
  26791. "dirName",
  26792. "direction",
  26793. "dirxml",
  26794. "disable",
  26795. "disablePictureInPicture",
  26796. "disableRemotePlayback",
  26797. "disableVertexAttribArray",
  26798. "disabled",
  26799. "discard",
  26800. "discardedFrames",
  26801. "dischargingTime",
  26802. "disconnect",
  26803. "disconnectShark",
  26804. "disconnectedCallback",
  26805. "dispatchEvent",
  26806. "dispatchWorkgroups",
  26807. "dispatchWorkgroupsIndirect",
  26808. "display",
  26809. "displayHeight",
  26810. "displayId",
  26811. "displayName",
  26812. "displayWidth",
  26813. "dispose",
  26814. "disposeAsync",
  26815. "disposed",
  26816. "disposition",
  26817. "distanceModel",
  26818. "div",
  26819. "divisor",
  26820. "djsapi",
  26821. "djsproxy",
  26822. "dns",
  26823. "doImport",
  26824. "doNotTrack",
  26825. "doScroll",
  26826. "doctype",
  26827. "document",
  26828. "documentElement",
  26829. "documentId",
  26830. "documentIds",
  26831. "documentLifecycle",
  26832. "documentMode",
  26833. "documentOrigin",
  26834. "documentOrigins",
  26835. "documentPictureInPicture",
  26836. "documentURI",
  26837. "documentURL",
  26838. "documentUrl",
  26839. "documentUrls",
  26840. "dolphin",
  26841. "dolphinGameCenter",
  26842. "dolphininfo",
  26843. "dolphinmeta",
  26844. "dom",
  26845. "domComplete",
  26846. "domContentLoadedEventEnd",
  26847. "domContentLoadedEventStart",
  26848. "domInteractive",
  26849. "domLoading",
  26850. "domOverlayState",
  26851. "domain",
  26852. "domainLookupEnd",
  26853. "domainLookupStart",
  26854. "dominant-baseline",
  26855. "dominantBaseline",
  26856. "done",
  26857. "dopplerFactor",
  26858. "dotAll",
  26859. "downDegrees",
  26860. "downlink",
  26861. "download",
  26862. "downloadRequest",
  26863. "downloadTotal",
  26864. "downloaded",
  26865. "downloads",
  26866. "dpcm",
  26867. "dpi",
  26868. "dppx",
  26869. "dragDrop",
  26870. "draggable",
  26871. "draw",
  26872. "drawArrays",
  26873. "drawArraysInstanced",
  26874. "drawArraysInstancedANGLE",
  26875. "drawBuffers",
  26876. "drawCustomFocusRing",
  26877. "drawElements",
  26878. "drawElementsInstanced",
  26879. "drawElementsInstancedANGLE",
  26880. "drawFocusIfNeeded",
  26881. "drawImage",
  26882. "drawImageFromRect",
  26883. "drawIndexed",
  26884. "drawIndexedIndirect",
  26885. "drawIndirect",
  26886. "drawRangeElements",
  26887. "drawSystemFocusRing",
  26888. "drawingBufferColorSpace",
  26889. "drawingBufferFormat",
  26890. "drawingBufferHeight",
  26891. "drawingBufferStorage",
  26892. "drawingBufferWidth",
  26893. "drop",
  26894. "dropEffect",
  26895. "droppedVideoFrames",
  26896. "dropzone",
  26897. "dstFactor",
  26898. "dtmf",
  26899. "dump",
  26900. "dumpProfile",
  26901. "duplex",
  26902. "duplicate",
  26903. "durability",
  26904. "duration",
  26905. "dvb",
  26906. "dvh",
  26907. "dvi",
  26908. "dvmax",
  26909. "dvmin",
  26910. "dvname",
  26911. "dvnum",
  26912. "dvw",
  26913. "dx",
  26914. "dy",
  26915. "dynamicId",
  26916. "dynsrc",
  26917. "e",
  26918. "edgeMode",
  26919. "editContext",
  26920. "effect",
  26921. "effectAllowed",
  26922. "effectiveDirective",
  26923. "effectiveType",
  26924. "effects",
  26925. "elapsedTime",
  26926. "element",
  26927. "elementFromPoint",
  26928. "elementTiming",
  26929. "elements",
  26930. "elementsFromPoint",
  26931. "elevation",
  26932. "ellipse",
  26933. "em",
  26934. "emHeightAscent",
  26935. "emHeightDescent",
  26936. "email",
  26937. "embeds",
  26938. "emit",
  26939. "emma",
  26940. "empty",
  26941. "empty-cells",
  26942. "emptyCells",
  26943. "emptyHTML",
  26944. "emptyScript",
  26945. "emulatedPosition",
  26946. "enable",
  26947. "enableBackground",
  26948. "enableDelegations",
  26949. "enableStyleSheetsForSet",
  26950. "enableVertexAttribArray",
  26951. "enabled",
  26952. "enabledFeatures",
  26953. "enabledPlugin",
  26954. "encode",
  26955. "encodeInto",
  26956. "encodeQueueSize",
  26957. "encodeURI",
  26958. "encodeURIComponent",
  26959. "encodedBodySize",
  26960. "encoding",
  26961. "encodingInfo",
  26962. "encrypt",
  26963. "enctype",
  26964. "end",
  26965. "endContainer",
  26966. "endElement",
  26967. "endElementAt",
  26968. "endOcclusionQuery",
  26969. "endOfPassWriteIndex",
  26970. "endOfStream",
  26971. "endOffset",
  26972. "endQuery",
  26973. "endTime",
  26974. "endTransformFeedback",
  26975. "ended",
  26976. "endpoint",
  26977. "endpointNumber",
  26978. "endpoints",
  26979. "endsWith",
  26980. "enqueue",
  26981. "enterKeyHint",
  26982. "entities",
  26983. "entries",
  26984. "entry",
  26985. "entryPoint",
  26986. "entryType",
  26987. "enumerable",
  26988. "enumerate",
  26989. "enumerateDevices",
  26990. "enumerateEditable",
  26991. "environmentBlendMode",
  26992. "equals",
  26993. "era",
  26994. "error",
  26995. "errorCode",
  26996. "errorDetail",
  26997. "errorText",
  26998. "escape",
  26999. "estimate",
  27000. "eval",
  27001. "evaluate",
  27002. "event",
  27003. "eventCounts",
  27004. "eventPhase",
  27005. "events",
  27006. "every",
  27007. "ex",
  27008. "exception",
  27009. "exchange",
  27010. "exec",
  27011. "execCommand",
  27012. "execCommandShowHelp",
  27013. "execScript",
  27014. "executeBundles",
  27015. "executionStart",
  27016. "exitFullscreen",
  27017. "exitPictureInPicture",
  27018. "exitPointerLock",
  27019. "exitPresent",
  27020. "exp",
  27021. "expand",
  27022. "expandEntityReferences",
  27023. "expando",
  27024. "expansion",
  27025. "expectedContextLanguages",
  27026. "expectedImprovement",
  27027. "expectedInputLanguages",
  27028. "experiments",
  27029. "expiration",
  27030. "expirationTime",
  27031. "expires",
  27032. "expiryDate",
  27033. "explicitOriginalTarget",
  27034. "expm1",
  27035. "exponent",
  27036. "exponentialRampToValueAtTime",
  27037. "exportKey",
  27038. "exports",
  27039. "extend",
  27040. "extension",
  27041. "extensionTypes",
  27042. "extensions",
  27043. "extentNode",
  27044. "extentOffset",
  27045. "external",
  27046. "externalResourcesRequired",
  27047. "externalTexture",
  27048. "extractContents",
  27049. "extractable",
  27050. "eye",
  27051. "f",
  27052. "f16round",
  27053. "face",
  27054. "factoryReset",
  27055. "failOp",
  27056. "failureReason",
  27057. "fallback",
  27058. "family",
  27059. "familyName",
  27060. "farthestViewportElement",
  27061. "fastSeek",
  27062. "fatal",
  27063. "featureId",
  27064. "featurePolicy",
  27065. "featureSettings",
  27066. "features",
  27067. "fence",
  27068. "fenceSync",
  27069. "fetch",
  27070. "fetchLater",
  27071. "fetchPriority",
  27072. "fetchStart",
  27073. "fftSize",
  27074. "fgColor",
  27075. "fieldOfView",
  27076. "file",
  27077. "fileCreatedDate",
  27078. "fileHandle",
  27079. "fileModifiedDate",
  27080. "fileName",
  27081. "fileSize",
  27082. "fileUpdatedDate",
  27083. "filename",
  27084. "files",
  27085. "filesystem",
  27086. "fill",
  27087. "fill-opacity",
  27088. "fill-rule",
  27089. "fillJointRadii",
  27090. "fillLightMode",
  27091. "fillOpacity",
  27092. "fillPoses",
  27093. "fillRect",
  27094. "fillRule",
  27095. "fillStyle",
  27096. "fillText",
  27097. "filter",
  27098. "filterResX",
  27099. "filterResY",
  27100. "filterUnits",
  27101. "filters",
  27102. "finalResponseHeadersStart",
  27103. "finally",
  27104. "find",
  27105. "findIndex",
  27106. "findLast",
  27107. "findLastIndex",
  27108. "findRule",
  27109. "findText",
  27110. "finish",
  27111. "finishDocumentLoadTime",
  27112. "finishLoadTime",
  27113. "finished",
  27114. "fireEvent",
  27115. "firesTouchEvents",
  27116. "first",
  27117. "firstChild",
  27118. "firstElementChild",
  27119. "firstInterimResponseStart",
  27120. "firstPage",
  27121. "firstPaintAfterLoadTime",
  27122. "firstPaintTime",
  27123. "firstUIEventTimestamp",
  27124. "fixed",
  27125. "flags",
  27126. "flat",
  27127. "flatMap",
  27128. "flex",
  27129. "flex-basis",
  27130. "flex-direction",
  27131. "flex-flow",
  27132. "flex-grow",
  27133. "flex-shrink",
  27134. "flex-wrap",
  27135. "flexBasis",
  27136. "flexDirection",
  27137. "flexFlow",
  27138. "flexGrow",
  27139. "flexShrink",
  27140. "flexWrap",
  27141. "flip",
  27142. "flipX",
  27143. "flipY",
  27144. "float",
  27145. "float32",
  27146. "float64",
  27147. "flood-color",
  27148. "flood-opacity",
  27149. "floodColor",
  27150. "floodOpacity",
  27151. "floor",
  27152. "flush",
  27153. "focus",
  27154. "focusNode",
  27155. "focusOffset",
  27156. "font",
  27157. "font-family",
  27158. "font-feature-settings",
  27159. "font-kerning",
  27160. "font-language-override",
  27161. "font-optical-sizing",
  27162. "font-palette",
  27163. "font-size",
  27164. "font-size-adjust",
  27165. "font-stretch",
  27166. "font-style",
  27167. "font-synthesis",
  27168. "font-synthesis-position",
  27169. "font-synthesis-small-caps",
  27170. "font-synthesis-style",
  27171. "font-synthesis-weight",
  27172. "font-variant",
  27173. "font-variant-alternates",
  27174. "font-variant-caps",
  27175. "font-variant-east-asian",
  27176. "font-variant-ligatures",
  27177. "font-variant-numeric",
  27178. "font-variant-position",
  27179. "font-variation-settings",
  27180. "font-weight",
  27181. "fontBoundingBoxAscent",
  27182. "fontBoundingBoxDescent",
  27183. "fontFamily",
  27184. "fontFeatureSettings",
  27185. "fontKerning",
  27186. "fontLanguageOverride",
  27187. "fontOpticalSizing",
  27188. "fontPalette",
  27189. "fontSize",
  27190. "fontSizeAdjust",
  27191. "fontSmoothingEnabled",
  27192. "fontStretch",
  27193. "fontStyle",
  27194. "fontSynthesis",
  27195. "fontSynthesisPosition",
  27196. "fontSynthesisSmallCaps",
  27197. "fontSynthesisStyle",
  27198. "fontSynthesisWeight",
  27199. "fontVariant",
  27200. "fontVariantAlternates",
  27201. "fontVariantCaps",
  27202. "fontVariantEastAsian",
  27203. "fontVariantEmoji",
  27204. "fontVariantLigatures",
  27205. "fontVariantNumeric",
  27206. "fontVariantPosition",
  27207. "fontVariationSettings",
  27208. "fontWeight",
  27209. "fontcolor",
  27210. "fontfaces",
  27211. "fonts",
  27212. "fontsize",
  27213. "for",
  27214. "forEach",
  27215. "force",
  27216. "forceFallbackAdapter",
  27217. "forceRedraw",
  27218. "forced-color-adjust",
  27219. "forcedColorAdjust",
  27220. "forcedStyleAndLayoutDuration",
  27221. "forget",
  27222. "form",
  27223. "formAction",
  27224. "formData",
  27225. "formEnctype",
  27226. "formMethod",
  27227. "formNoValidate",
  27228. "formTarget",
  27229. "format",
  27230. "formatToParts",
  27231. "forms",
  27232. "forward",
  27233. "forwardWheel",
  27234. "forwardX",
  27235. "forwardY",
  27236. "forwardZ",
  27237. "foundation",
  27238. "fr",
  27239. "fractionalSecondDigits",
  27240. "fragment",
  27241. "fragmentDirective",
  27242. "frame",
  27243. "frameBorder",
  27244. "frameCount",
  27245. "frameElement",
  27246. "frameId",
  27247. "frameIds",
  27248. "frameSpacing",
  27249. "framebuffer",
  27250. "framebufferHeight",
  27251. "framebufferRenderbuffer",
  27252. "framebufferTexture2D",
  27253. "framebufferTextureLayer",
  27254. "framebufferWidth",
  27255. "frames",
  27256. "freeSpace",
  27257. "freeze",
  27258. "frequency",
  27259. "frequencyBinCount",
  27260. "from",
  27261. "fromAsync",
  27262. "fromBase64",
  27263. "fromCharCode",
  27264. "fromCodePoint",
  27265. "fromElement",
  27266. "fromEntries",
  27267. "fromFloat32Array",
  27268. "fromFloat64Array",
  27269. "fromHex",
  27270. "fromMatrix",
  27271. "fromPoint",
  27272. "fromQuad",
  27273. "fromRect",
  27274. "frontFace",
  27275. "fround",
  27276. "fullName",
  27277. "fullPath",
  27278. "fullRange",
  27279. "fullScreen",
  27280. "fullVersionList",
  27281. "fullscreen",
  27282. "fullscreenElement",
  27283. "fullscreenEnabled",
  27284. "fx",
  27285. "fy",
  27286. "g",
  27287. "gain",
  27288. "gamepad",
  27289. "gamma",
  27290. "gap",
  27291. "gatheringState",
  27292. "gatt",
  27293. "geckoProfiler",
  27294. "genderIdentity",
  27295. "generateCertificate",
  27296. "generateKey",
  27297. "generateMipmap",
  27298. "generateRequest",
  27299. "geolocation",
  27300. "gestureObject",
  27301. "get",
  27302. "getAcceptLanguages",
  27303. "getActiveAttrib",
  27304. "getActiveUniform",
  27305. "getActiveUniformBlockName",
  27306. "getActiveUniformBlockParameter",
  27307. "getActiveUniforms",
  27308. "getAdjacentText",
  27309. "getAll",
  27310. "getAllKeys",
  27311. "getAllRecords",
  27312. "getAllResponseHeaders",
  27313. "getAllowlistForFeature",
  27314. "getAnimations",
  27315. "getAsFile",
  27316. "getAsFileSystemHandle",
  27317. "getAsString",
  27318. "getAttachedShaders",
  27319. "getAttribLocation",
  27320. "getAttribute",
  27321. "getAttributeNS",
  27322. "getAttributeNames",
  27323. "getAttributeNode",
  27324. "getAttributeNodeNS",
  27325. "getAttributeType",
  27326. "getAudioTracks",
  27327. "getAuthenticatorData",
  27328. "getAutoplayPolicy",
  27329. "getAvailability",
  27330. "getBBox",
  27331. "getBackgroundPage",
  27332. "getBadgeBackgroundColor",
  27333. "getBadgeText",
  27334. "getBadgeTextColor",
  27335. "getBattery",
  27336. "getBigInt64",
  27337. "getBigUint64",
  27338. "getBindGroupLayout",
  27339. "getBlob",
  27340. "getBookmark",
  27341. "getBoundingClientRect",
  27342. "getBounds",
  27343. "getBoxQuads",
  27344. "getBrowserInfo",
  27345. "getBufferParameter",
  27346. "getBufferSubData",
  27347. "getByteFrequencyData",
  27348. "getByteTimeDomainData",
  27349. "getCSSCanvasContext",
  27350. "getCTM",
  27351. "getCameraImage",
  27352. "getCandidateWindowClientRect",
  27353. "getCanonicalLocales",
  27354. "getCapabilities",
  27355. "getCaptureHandle",
  27356. "getChannelData",
  27357. "getCharNumAtPosition",
  27358. "getCharacteristic",
  27359. "getCharacteristics",
  27360. "getClientCapabilities",
  27361. "getClientExtensionResults",
  27362. "getClientRect",
  27363. "getClientRects",
  27364. "getCoalescedEvents",
  27365. "getCompilationInfo",
  27366. "getComposedRanges",
  27367. "getCompositionAlternatives",
  27368. "getComputedStyle",
  27369. "getComputedTextLength",
  27370. "getComputedTiming",
  27371. "getConfiguration",
  27372. "getConstraints",
  27373. "getContext",
  27374. "getContextAttributes",
  27375. "getContexts",
  27376. "getContributingSources",
  27377. "getCounterValue",
  27378. "getCueAsHTML",
  27379. "getCueById",
  27380. "getCurrent",
  27381. "getCurrentPosition",
  27382. "getCurrentTexture",
  27383. "getCurrentTime",
  27384. "getData",
  27385. "getDatabaseNames",
  27386. "getDate",
  27387. "getDay",
  27388. "getDefaultComputedStyle",
  27389. "getDepthInMeters",
  27390. "getDepthInformation",
  27391. "getDescriptor",
  27392. "getDescriptors",
  27393. "getDestinationInsertionPoints",
  27394. "getDevices",
  27395. "getDirectory",
  27396. "getDirectoryHandle",
  27397. "getDisplayMedia",
  27398. "getDistributedNodes",
  27399. "getEditable",
  27400. "getElementById",
  27401. "getElementsByClassName",
  27402. "getElementsByName",
  27403. "getElementsByTagName",
  27404. "getElementsByTagNameNS",
  27405. "getEnclosureList",
  27406. "getEndPositionOfChar",
  27407. "getEntries",
  27408. "getEntriesByName",
  27409. "getEntriesByType",
  27410. "getError",
  27411. "getExtension",
  27412. "getExtentOfChar",
  27413. "getEyeParameters",
  27414. "getFeature",
  27415. "getFiberRoots",
  27416. "getFile",
  27417. "getFileHandle",
  27418. "getFiles",
  27419. "getFilesAndDirectories",
  27420. "getFingerprints",
  27421. "getFloat16",
  27422. "getFloat32",
  27423. "getFloat64",
  27424. "getFloatFrequencyData",
  27425. "getFloatTimeDomainData",
  27426. "getFloatValue",
  27427. "getFragDataLocation",
  27428. "getFrameData",
  27429. "getFrameId",
  27430. "getFramebufferAttachmentParameter",
  27431. "getFrequencyResponse",
  27432. "getFullYear",
  27433. "getGamepads",
  27434. "getHTML",
  27435. "getHeaderExtensionsToNegotiate",
  27436. "getHighEntropyValues",
  27437. "getHitTestResults",
  27438. "getHitTestResultsForTransientInput",
  27439. "getHours",
  27440. "getIdentityAssertion",
  27441. "getIds",
  27442. "getImageData",
  27443. "getIndexedParameter",
  27444. "getInfo",
  27445. "getInnerHTML",
  27446. "getInstalledRelatedApps",
  27447. "getInt16",
  27448. "getInt32",
  27449. "getInt8",
  27450. "getInterestGroupAdAuctionData",
  27451. "getInternalModuleRanges",
  27452. "getInternalformatParameter",
  27453. "getIntersectionList",
  27454. "getItem",
  27455. "getItems",
  27456. "getJointPose",
  27457. "getKey",
  27458. "getKeyframes",
  27459. "getLastFocused",
  27460. "getLayers",
  27461. "getLayoutMap",
  27462. "getLightEstimate",
  27463. "getLineDash",
  27464. "getLocalCandidates",
  27465. "getLocalParameters",
  27466. "getLocalStreams",
  27467. "getManagedConfiguration",
  27468. "getManifest",
  27469. "getMappedRange",
  27470. "getMarks",
  27471. "getMatchedCSSRules",
  27472. "getMaxGCPauseSinceClear",
  27473. "getMeasures",
  27474. "getMessage",
  27475. "getMetadata",
  27476. "getMilliseconds",
  27477. "getMinutes",
  27478. "getModifierState",
  27479. "getMonth",
  27480. "getName",
  27481. "getNamedItem",
  27482. "getNamedItemNS",
  27483. "getNativeFramebufferScaleFactor",
  27484. "getNegotiatedHeaderExtensions",
  27485. "getNestedConfigs",
  27486. "getNotifications",
  27487. "getNotifier",
  27488. "getNumberOfChars",
  27489. "getOffsetReferenceSpace",
  27490. "getOrInsert",
  27491. "getOrInsertComputed",
  27492. "getOutputTimestamp",
  27493. "getOverrideHistoryNavigationMode",
  27494. "getOverrideStyle",
  27495. "getOwnPropertyDescriptor",
  27496. "getOwnPropertyDescriptors",
  27497. "getOwnPropertyNames",
  27498. "getOwnPropertySymbols",
  27499. "getPackageDirectoryEntry",
  27500. "getParameter",
  27501. "getParameters",
  27502. "getParent",
  27503. "getPathData",
  27504. "getPathSegAtLength",
  27505. "getPathSegmentAtLength",
  27506. "getPermissionWarningsByManifest",
  27507. "getPhotoCapabilities",
  27508. "getPhotoSettings",
  27509. "getPlatformInfo",
  27510. "getPointAtLength",
  27511. "getPopup",
  27512. "getPorts",
  27513. "getPose",
  27514. "getPredictedEvents",
  27515. "getPreference",
  27516. "getPreferenceDefault",
  27517. "getPreferredCanvasFormat",
  27518. "getPresentationAttribute",
  27519. "getPreventDefault",
  27520. "getPrimaryService",
  27521. "getPrimaryServices",
  27522. "getProgramInfoLog",
  27523. "getProgramParameter",
  27524. "getPropertyCSSValue",
  27525. "getPropertyPriority",
  27526. "getPropertyShorthand",
  27527. "getPropertyType",
  27528. "getPropertyValue",
  27529. "getPrototypeOf",
  27530. "getPublicKey",
  27531. "getPublicKeyAlgorithm",
  27532. "getQuery",
  27533. "getQueryParameter",
  27534. "getRGBColorValue",
  27535. "getRandomValues",
  27536. "getRangeAt",
  27537. "getReader",
  27538. "getReceivers",
  27539. "getRectValue",
  27540. "getReflectionCubeMap",
  27541. "getRegistration",
  27542. "getRegistrations",
  27543. "getRemoteCandidates",
  27544. "getRemoteCertificates",
  27545. "getRemoteParameters",
  27546. "getRemoteStreams",
  27547. "getRenderbufferParameter",
  27548. "getResponseHeader",
  27549. "getRoot",
  27550. "getRootNode",
  27551. "getRotationOfChar",
  27552. "getSVGDocument",
  27553. "getSamplerParameter",
  27554. "getScreenCTM",
  27555. "getScreenDetails",
  27556. "getSeconds",
  27557. "getSelectedCandidatePair",
  27558. "getSelection",
  27559. "getSelf",
  27560. "getSenders",
  27561. "getService",
  27562. "getSetCookie",
  27563. "getSettings",
  27564. "getShaderInfoLog",
  27565. "getShaderParameter",
  27566. "getShaderPrecisionFormat",
  27567. "getShaderSource",
  27568. "getSignals",
  27569. "getSimpleDuration",
  27570. "getSiteIcons",
  27571. "getSources",
  27572. "getSpeculativeParserUrls",
  27573. "getStartPositionOfChar",
  27574. "getStartTime",
  27575. "getState",
  27576. "getStats",
  27577. "getStatusForPolicy",
  27578. "getStorageUpdates",
  27579. "getStreamById",
  27580. "getStringValue",
  27581. "getSubStringLength",
  27582. "getSubscription",
  27583. "getSubscriptions",
  27584. "getSupportedConstraints",
  27585. "getSupportedExtensions",
  27586. "getSupportedFormats",
  27587. "getSupportedZoomLevels",
  27588. "getSyncParameter",
  27589. "getSynchronizationSources",
  27590. "getTags",
  27591. "getTargetRanges",
  27592. "getTexParameter",
  27593. "getTextFormats",
  27594. "getTime",
  27595. "getTimezoneOffset",
  27596. "getTiming",
  27597. "getTitle",
  27598. "getTitlebarAreaRect",
  27599. "getTotalLength",
  27600. "getTrackById",
  27601. "getTracks",
  27602. "getTransceivers",
  27603. "getTransform",
  27604. "getTransformFeedbackVarying",
  27605. "getTransformToElement",
  27606. "getTransports",
  27607. "getType",
  27608. "getTypeMapping",
  27609. "getUILanguage",
  27610. "getURL",
  27611. "getUTCDate",
  27612. "getUTCDay",
  27613. "getUTCFullYear",
  27614. "getUTCHours",
  27615. "getUTCMilliseconds",
  27616. "getUTCMinutes",
  27617. "getUTCMonth",
  27618. "getUTCSeconds",
  27619. "getUint16",
  27620. "getUint32",
  27621. "getUint8",
  27622. "getUniform",
  27623. "getUniformBlockIndex",
  27624. "getUniformIndices",
  27625. "getUniformLocation",
  27626. "getUserInfo",
  27627. "getUserMedia",
  27628. "getUserSettings",
  27629. "getVRDisplays",
  27630. "getValues",
  27631. "getVarDate",
  27632. "getVariableValue",
  27633. "getVertexAttrib",
  27634. "getVertexAttribOffset",
  27635. "getVideoPlaybackQuality",
  27636. "getVideoTracks",
  27637. "getViewerPose",
  27638. "getViewport",
  27639. "getViews",
  27640. "getVoices",
  27641. "getWakeLockState",
  27642. "getWriter",
  27643. "getYear",
  27644. "getZoom",
  27645. "getZoomSettings",
  27646. "givenName",
  27647. "global",
  27648. "globalAlpha",
  27649. "globalCompositeOperation",
  27650. "globalPrivacyControl",
  27651. "globalThis",
  27652. "glyphOrientationHorizontal",
  27653. "glyphOrientationVertical",
  27654. "glyphRef",
  27655. "go",
  27656. "goBack",
  27657. "goForward",
  27658. "gpu",
  27659. "grabFrame",
  27660. "grad",
  27661. "gradientTransform",
  27662. "gradientUnits",
  27663. "grammars",
  27664. "green",
  27665. "grid",
  27666. "grid-area",
  27667. "grid-auto-columns",
  27668. "grid-auto-flow",
  27669. "grid-auto-rows",
  27670. "grid-column",
  27671. "grid-column-end",
  27672. "grid-column-gap",
  27673. "grid-column-start",
  27674. "grid-gap",
  27675. "grid-row",
  27676. "grid-row-end",
  27677. "grid-row-gap",
  27678. "grid-row-start",
  27679. "grid-template",
  27680. "grid-template-areas",
  27681. "grid-template-columns",
  27682. "grid-template-rows",
  27683. "gridArea",
  27684. "gridAutoColumns",
  27685. "gridAutoFlow",
  27686. "gridAutoRows",
  27687. "gridColumn",
  27688. "gridColumnEnd",
  27689. "gridColumnGap",
  27690. "gridColumnStart",
  27691. "gridGap",
  27692. "gridRow",
  27693. "gridRowEnd",
  27694. "gridRowGap",
  27695. "gridRowStart",
  27696. "gridTemplate",
  27697. "gridTemplateAreas",
  27698. "gridTemplateColumns",
  27699. "gridTemplateRows",
  27700. "gripSpace",
  27701. "group",
  27702. "groupBy",
  27703. "groupCollapsed",
  27704. "groupEnd",
  27705. "groupId",
  27706. "groups",
  27707. "grow",
  27708. "growable",
  27709. "guestProcessId",
  27710. "guestRenderFrameRoutingId",
  27711. "hadRecentInput",
  27712. "hand",
  27713. "handedness",
  27714. "hangingBaseline",
  27715. "hapticActuators",
  27716. "hardwareConcurrency",
  27717. "has",
  27718. "hasAttribute",
  27719. "hasAttributeNS",
  27720. "hasAttributes",
  27721. "hasBeenActive",
  27722. "hasChildNodes",
  27723. "hasComposition",
  27724. "hasDynamicOffset",
  27725. "hasEnrolledInstrument",
  27726. "hasExtension",
  27727. "hasExternalDisplay",
  27728. "hasFeature",
  27729. "hasFocus",
  27730. "hasIndices",
  27731. "hasInstance",
  27732. "hasLayout",
  27733. "hasOrientation",
  27734. "hasOwn",
  27735. "hasOwnProperty",
  27736. "hasPointerCapture",
  27737. "hasPosition",
  27738. "hasPrivateToken",
  27739. "hasReading",
  27740. "hasRedemptionRecord",
  27741. "hasRegExpGroups",
  27742. "hasStorageAccess",
  27743. "hasUAVisualTransition",
  27744. "hasUnpartitionedCookieAccess",
  27745. "hash",
  27746. "hashChange",
  27747. "head",
  27748. "headers",
  27749. "heading",
  27750. "height",
  27751. "hid",
  27752. "hidden",
  27753. "hide",
  27754. "hideFocus",
  27755. "hidePopover",
  27756. "high",
  27757. "highWaterMark",
  27758. "highlight",
  27759. "highlights",
  27760. "highlightsFromPoint",
  27761. "hint",
  27762. "hints",
  27763. "history",
  27764. "honorificPrefix",
  27765. "honorificSuffix",
  27766. "horizontalOverflow",
  27767. "host",
  27768. "hostCandidate",
  27769. "hostname",
  27770. "hour",
  27771. "hour12",
  27772. "hourCycle",
  27773. "hours",
  27774. "href",
  27775. "hrefTranslate",
  27776. "hreflang",
  27777. "hspace",
  27778. "html5TagCheckInerface",
  27779. "htmlFor",
  27780. "htmlText",
  27781. "httpEquiv",
  27782. "httpRequestStatusCode",
  27783. "hwTimestamp",
  27784. "hyphenate-character",
  27785. "hyphenateCharacter",
  27786. "hyphenateLimitChars",
  27787. "hyphens",
  27788. "hypot",
  27789. "i18n",
  27790. "ic",
  27791. "iccId",
  27792. "iceConnectionState",
  27793. "iceGatheringState",
  27794. "iceTransport",
  27795. "icon",
  27796. "iconURL",
  27797. "id",
  27798. "identifier",
  27799. "identity",
  27800. "ideographicBaseline",
  27801. "idle",
  27802. "idpLoginUrl",
  27803. "ignoreBOM",
  27804. "ignoreCase",
  27805. "ignoreDepthValues",
  27806. "image",
  27807. "image-orientation",
  27808. "image-rendering",
  27809. "imageHeight",
  27810. "imageOrientation",
  27811. "imageRendering",
  27812. "imageSizes",
  27813. "imageSmoothingEnabled",
  27814. "imageSmoothingQuality",
  27815. "imageSrcset",
  27816. "imageWidth",
  27817. "images",
  27818. "ime-mode",
  27819. "imeMode",
  27820. "implementation",
  27821. "importExternalTexture",
  27822. "importKey",
  27823. "importNode",
  27824. "importStylesheet",
  27825. "imports",
  27826. "impp",
  27827. "imul",
  27828. "in",
  27829. "in1",
  27830. "in2",
  27831. "inBandMetadataTrackDispatchType",
  27832. "inIncognitoContext",
  27833. "inRange",
  27834. "includes",
  27835. "incognito",
  27836. "incomingBidirectionalStreams",
  27837. "incomingHighWaterMark",
  27838. "incomingMaxAge",
  27839. "incomingUnidirectionalStreams",
  27840. "increaseZoomLevel",
  27841. "incremental",
  27842. "indeterminate",
  27843. "index",
  27844. "indexNames",
  27845. "indexOf",
  27846. "indexedDB",
  27847. "indicate",
  27848. "indices",
  27849. "inert",
  27850. "inertiaDestinationX",
  27851. "inertiaDestinationY",
  27852. "info",
  27853. "inherits",
  27854. "init",
  27855. "initAnimationEvent",
  27856. "initBeforeLoadEvent",
  27857. "initClipboardEvent",
  27858. "initCloseEvent",
  27859. "initCommandEvent",
  27860. "initCompositionEvent",
  27861. "initCustomEvent",
  27862. "initData",
  27863. "initDataType",
  27864. "initDeviceMotionEvent",
  27865. "initDeviceOrientationEvent",
  27866. "initDragEvent",
  27867. "initErrorEvent",
  27868. "initEvent",
  27869. "initFocusEvent",
  27870. "initGestureEvent",
  27871. "initHashChangeEvent",
  27872. "initKeyEvent",
  27873. "initKeyboardEvent",
  27874. "initMSManipulationEvent",
  27875. "initMessageEvent",
  27876. "initMouseEvent",
  27877. "initMouseScrollEvent",
  27878. "initMouseWheelEvent",
  27879. "initMutationEvent",
  27880. "initNSMouseEvent",
  27881. "initOverflowEvent",
  27882. "initPageEvent",
  27883. "initPageTransitionEvent",
  27884. "initPointerEvent",
  27885. "initPopStateEvent",
  27886. "initProgressEvent",
  27887. "initScrollAreaEvent",
  27888. "initSimpleGestureEvent",
  27889. "initStorageEvent",
  27890. "initTextEvent",
  27891. "initTimeEvent",
  27892. "initTouchEvent",
  27893. "initTransitionEvent",
  27894. "initUIEvent",
  27895. "initWebKitAnimationEvent",
  27896. "initWebKitTransitionEvent",
  27897. "initWebKitWheelEvent",
  27898. "initWheelEvent",
  27899. "initialTime",
  27900. "initialValue",
  27901. "initialize",
  27902. "initiatorType",
  27903. "inject",
  27904. "ink",
  27905. "inline-size",
  27906. "inlineSize",
  27907. "inlineVerticalFieldOfView",
  27908. "inner",
  27909. "innerHTML",
  27910. "innerHeight",
  27911. "innerText",
  27912. "innerWidth",
  27913. "input",
  27914. "inputBuffer",
  27915. "inputEncoding",
  27916. "inputMethod",
  27917. "inputMode",
  27918. "inputQuota",
  27919. "inputSource",
  27920. "inputSources",
  27921. "inputType",
  27922. "inputs",
  27923. "insertAdjacentElement",
  27924. "insertAdjacentHTML",
  27925. "insertAdjacentText",
  27926. "insertBefore",
  27927. "insertCell",
  27928. "insertDTMF",
  27929. "insertData",
  27930. "insertDebugMarker",
  27931. "insertItemBefore",
  27932. "insertNode",
  27933. "insertRow",
  27934. "insertRule",
  27935. "inset",
  27936. "inset-block",
  27937. "inset-block-end",
  27938. "inset-block-start",
  27939. "inset-inline",
  27940. "inset-inline-end",
  27941. "inset-inline-start",
  27942. "insetBlock",
  27943. "insetBlockEnd",
  27944. "insetBlockStart",
  27945. "insetInline",
  27946. "insetInlineEnd",
  27947. "insetInlineStart",
  27948. "inspect",
  27949. "install",
  27950. "installing",
  27951. "instanceRoot",
  27952. "instantiate",
  27953. "instantiateStreaming",
  27954. "instruments",
  27955. "int16",
  27956. "int32",
  27957. "int8",
  27958. "integrity",
  27959. "interactionCount",
  27960. "interactionId",
  27961. "interactionMode",
  27962. "intercept",
  27963. "interestForElement",
  27964. "interfaceClass",
  27965. "interfaceName",
  27966. "interfaceNumber",
  27967. "interfaceProtocol",
  27968. "interfaceSubclass",
  27969. "interfaces",
  27970. "interimResults",
  27971. "internalSubset",
  27972. "interpretation",
  27973. "intersection",
  27974. "intersectionRatio",
  27975. "intersectionRect",
  27976. "intersectsNode",
  27977. "interval",
  27978. "invalidIteratorState",
  27979. "invalidateFramebuffer",
  27980. "invalidateSubFramebuffer",
  27981. "inverse",
  27982. "invertSelf",
  27983. "invoker",
  27984. "invokerType",
  27985. "is",
  27986. "is2D",
  27987. "isActive",
  27988. "isAllowedFileSchemeAccess",
  27989. "isAllowedIncognitoAccess",
  27990. "isAlternate",
  27991. "isArray",
  27992. "isAutoSelected",
  27993. "isBingCurrentSearchDefault",
  27994. "isBuffer",
  27995. "isCandidateWindowVisible",
  27996. "isChar",
  27997. "isCollapsed",
  27998. "isComposing",
  27999. "isConcatSpreadable",
  28000. "isConditionalMediationAvailable",
  28001. "isConfigSupported",
  28002. "isConnected",
  28003. "isContentEditable",
  28004. "isContentHandlerRegistered",
  28005. "isContextLost",
  28006. "isDefaultNamespace",
  28007. "isDirectory",
  28008. "isDisabled",
  28009. "isDisjointFrom",
  28010. "isEnabled",
  28011. "isEqual",
  28012. "isEqualNode",
  28013. "isError",
  28014. "isExtended",
  28015. "isExtensible",
  28016. "isExternalCTAP2SecurityKeySupported",
  28017. "isFallbackAdapter",
  28018. "isFile",
  28019. "isFinite",
  28020. "isFirstPersonObserver",
  28021. "isFramebuffer",
  28022. "isFrozen",
  28023. "isGenerator",
  28024. "isHTML",
  28025. "isHistoryNavigation",
  28026. "isId",
  28027. "isIdentity",
  28028. "isInjected",
  28029. "isInputPending",
  28030. "isInteger",
  28031. "isInternal",
  28032. "isIntersecting",
  28033. "isLockFree",
  28034. "isMap",
  28035. "isMultiLine",
  28036. "isNaN",
  28037. "isOpen",
  28038. "isPointInFill",
  28039. "isPointInPath",
  28040. "isPointInRange",
  28041. "isPointInStroke",
  28042. "isPrefAlternate",
  28043. "isPresenting",
  28044. "isPrimary",
  28045. "isProgram",
  28046. "isPropertyImplicit",
  28047. "isProtocolHandlerRegistered",
  28048. "isPrototypeOf",
  28049. "isQuery",
  28050. "isRawJSON",
  28051. "isRenderbuffer",
  28052. "isSafeInteger",
  28053. "isSameEntry",
  28054. "isSameNode",
  28055. "isSampler",
  28056. "isScript",
  28057. "isScriptURL",
  28058. "isSealed",
  28059. "isSecureContext",
  28060. "isSessionSupported",
  28061. "isShader",
  28062. "isSubsetOf",
  28063. "isSupersetOf",
  28064. "isSupported",
  28065. "isSync",
  28066. "isTextEdit",
  28067. "isTexture",
  28068. "isTransformFeedback",
  28069. "isTrusted",
  28070. "isTypeSupported",
  28071. "isUserVerifyingPlatformAuthenticatorAvailable",
  28072. "isVertexArray",
  28073. "isView",
  28074. "isVisible",
  28075. "isWellFormed",
  28076. "isochronousTransferIn",
  28077. "isochronousTransferOut",
  28078. "isolation",
  28079. "italics",
  28080. "item",
  28081. "itemId",
  28082. "itemProp",
  28083. "itemRef",
  28084. "itemScope",
  28085. "itemType",
  28086. "itemValue",
  28087. "items",
  28088. "iterateNext",
  28089. "iterationComposite",
  28090. "iterator",
  28091. "javaEnabled",
  28092. "jitterBufferTarget",
  28093. "jobTitle",
  28094. "join",
  28095. "joinAdInterestGroup",
  28096. "jointName",
  28097. "json",
  28098. "justify-content",
  28099. "justify-items",
  28100. "justify-self",
  28101. "justifyContent",
  28102. "justifyItems",
  28103. "justifySelf",
  28104. "k1",
  28105. "k2",
  28106. "k3",
  28107. "k4",
  28108. "kHz",
  28109. "keepalive",
  28110. "kernelMatrix",
  28111. "kernelUnitLengthX",
  28112. "kernelUnitLengthY",
  28113. "kerning",
  28114. "key",
  28115. "keyCode",
  28116. "keyFor",
  28117. "keyIdentifier",
  28118. "keyLightEnabled",
  28119. "keyLocation",
  28120. "keyPath",
  28121. "keyStatuses",
  28122. "keySystem",
  28123. "keyText",
  28124. "keyUsage",
  28125. "keyboard",
  28126. "keys",
  28127. "keytype",
  28128. "kind",
  28129. "knee",
  28130. "knownSources",
  28131. "label",
  28132. "labels",
  28133. "lang",
  28134. "language",
  28135. "languages",
  28136. "largeArcFlag",
  28137. "last",
  28138. "lastChild",
  28139. "lastElementChild",
  28140. "lastError",
  28141. "lastEventId",
  28142. "lastIndex",
  28143. "lastIndexOf",
  28144. "lastInputTime",
  28145. "lastMatch",
  28146. "lastMessageSubject",
  28147. "lastMessageType",
  28148. "lastModified",
  28149. "lastModifiedDate",
  28150. "lastPage",
  28151. "lastParen",
  28152. "lastState",
  28153. "lastStyleSheetSet",
  28154. "latency",
  28155. "latitude",
  28156. "launchQueue",
  28157. "layerName",
  28158. "layerX",
  28159. "layerY",
  28160. "layout",
  28161. "layoutFlow",
  28162. "layoutGrid",
  28163. "layoutGridChar",
  28164. "layoutGridLine",
  28165. "layoutGridMode",
  28166. "layoutGridType",
  28167. "lbound",
  28168. "leaveAdInterestGroup",
  28169. "left",
  28170. "leftContext",
  28171. "leftDegrees",
  28172. "leftMargin",
  28173. "leftProjectionMatrix",
  28174. "leftViewMatrix",
  28175. "length",
  28176. "lengthAdjust",
  28177. "lengthComputable",
  28178. "letter-spacing",
  28179. "letterSpacing",
  28180. "level",
  28181. "lh",
  28182. "lighting-color",
  28183. "lightingColor",
  28184. "limitingConeAngle",
  28185. "limits",
  28186. "line",
  28187. "line-break",
  28188. "line-height",
  28189. "lineAlign",
  28190. "lineBreak",
  28191. "lineCap",
  28192. "lineDashOffset",
  28193. "lineGapOverride",
  28194. "lineHeight",
  28195. "lineJoin",
  28196. "lineNum",
  28197. "lineNumber",
  28198. "linePos",
  28199. "lineTo",
  28200. "lineWidth",
  28201. "linearAcceleration",
  28202. "linearRampToValueAtTime",
  28203. "linearVelocity",
  28204. "lineno",
  28205. "lines",
  28206. "link",
  28207. "linkColor",
  28208. "linkProgram",
  28209. "links",
  28210. "list",
  28211. "list-style",
  28212. "list-style-image",
  28213. "list-style-position",
  28214. "list-style-type",
  28215. "listStyle",
  28216. "listStyleImage",
  28217. "listStylePosition",
  28218. "listStyleType",
  28219. "listener",
  28220. "listeners",
  28221. "load",
  28222. "loadEventEnd",
  28223. "loadEventStart",
  28224. "loadOp",
  28225. "loadTime",
  28226. "loadTimes",
  28227. "loaded",
  28228. "loading",
  28229. "localDescription",
  28230. "localName",
  28231. "localService",
  28232. "localStorage",
  28233. "locale",
  28234. "localeCompare",
  28235. "location",
  28236. "locationbar",
  28237. "lock",
  28238. "locked",
  28239. "lockedFile",
  28240. "locks",
  28241. "lodMaxClamp",
  28242. "lodMinClamp",
  28243. "log",
  28244. "log10",
  28245. "log1p",
  28246. "log2",
  28247. "logicalXDPI",
  28248. "logicalYDPI",
  28249. "login",
  28250. "loglevel",
  28251. "longDesc",
  28252. "longitude",
  28253. "lookupNamespaceURI",
  28254. "lookupPrefix",
  28255. "loop",
  28256. "loopEnd",
  28257. "loopStart",
  28258. "looping",
  28259. "lost",
  28260. "low",
  28261. "lower",
  28262. "lowerBound",
  28263. "lowerOpen",
  28264. "lowsrc",
  28265. "lvb",
  28266. "lvh",
  28267. "lvi",
  28268. "lvmax",
  28269. "lvmin",
  28270. "lvw",
  28271. "m11",
  28272. "m12",
  28273. "m13",
  28274. "m14",
  28275. "m21",
  28276. "m22",
  28277. "m23",
  28278. "m24",
  28279. "m31",
  28280. "m32",
  28281. "m33",
  28282. "m34",
  28283. "m41",
  28284. "m42",
  28285. "m43",
  28286. "m44",
  28287. "magFilter",
  28288. "makeXRCompatible",
  28289. "managed",
  28290. "management",
  28291. "manifest",
  28292. "manufacturer",
  28293. "manufacturerName",
  28294. "map",
  28295. "mapAsync",
  28296. "mapState",
  28297. "mappedAtCreation",
  28298. "mapping",
  28299. "margin",
  28300. "margin-block",
  28301. "margin-block-end",
  28302. "margin-block-start",
  28303. "margin-bottom",
  28304. "margin-inline",
  28305. "margin-inline-end",
  28306. "margin-inline-start",
  28307. "margin-left",
  28308. "margin-right",
  28309. "margin-top",
  28310. "marginBlock",
  28311. "marginBlockEnd",
  28312. "marginBlockStart",
  28313. "marginBottom",
  28314. "marginHeight",
  28315. "marginInline",
  28316. "marginInlineEnd",
  28317. "marginInlineStart",
  28318. "marginLeft",
  28319. "marginRight",
  28320. "marginTop",
  28321. "marginWidth",
  28322. "mark",
  28323. "marker",
  28324. "marker-end",
  28325. "marker-mid",
  28326. "marker-offset",
  28327. "marker-start",
  28328. "markerEnd",
  28329. "markerHeight",
  28330. "markerMid",
  28331. "markerOffset",
  28332. "markerStart",
  28333. "markerUnits",
  28334. "markerWidth",
  28335. "marks",
  28336. "mask",
  28337. "mask-clip",
  28338. "mask-composite",
  28339. "mask-image",
  28340. "mask-mode",
  28341. "mask-origin",
  28342. "mask-position",
  28343. "mask-position-x",
  28344. "mask-position-y",
  28345. "mask-repeat",
  28346. "mask-size",
  28347. "mask-type",
  28348. "maskClip",
  28349. "maskComposite",
  28350. "maskContentUnits",
  28351. "maskImage",
  28352. "maskMode",
  28353. "maskOrigin",
  28354. "maskPosition",
  28355. "maskPositionX",
  28356. "maskPositionY",
  28357. "maskRepeat",
  28358. "maskSize",
  28359. "maskType",
  28360. "maskUnits",
  28361. "match",
  28362. "matchAll",
  28363. "matchMedia",
  28364. "matchMedium",
  28365. "matchPatterns",
  28366. "matches",
  28367. "math-depth",
  28368. "math-style",
  28369. "mathDepth",
  28370. "mathShift",
  28371. "mathStyle",
  28372. "matrix",
  28373. "matrixTransform",
  28374. "max",
  28375. "max-block-size",
  28376. "max-height",
  28377. "max-inline-size",
  28378. "max-width",
  28379. "maxActions",
  28380. "maxAlternatives",
  28381. "maxAnisotropy",
  28382. "maxBindGroups",
  28383. "maxBindGroupsPlusVertexBuffers",
  28384. "maxBindingsPerBindGroup",
  28385. "maxBlockSize",
  28386. "maxBufferSize",
  28387. "maxByteLength",
  28388. "maxChannelCount",
  28389. "maxChannels",
  28390. "maxColorAttachmentBytesPerSample",
  28391. "maxColorAttachments",
  28392. "maxComputeInvocationsPerWorkgroup",
  28393. "maxComputeWorkgroupSizeX",
  28394. "maxComputeWorkgroupSizeY",
  28395. "maxComputeWorkgroupSizeZ",
  28396. "maxComputeWorkgroupStorageSize",
  28397. "maxComputeWorkgroupsPerDimension",
  28398. "maxConnectionsPerServer",
  28399. "maxDatagramSize",
  28400. "maxDecibels",
  28401. "maxDistance",
  28402. "maxDrawCount",
  28403. "maxDynamicStorageBuffersPerPipelineLayout",
  28404. "maxDynamicUniformBuffersPerPipelineLayout",
  28405. "maxHeight",
  28406. "maxInlineSize",
  28407. "maxInterStageShaderComponents",
  28408. "maxInterStageShaderVariables",
  28409. "maxLayers",
  28410. "maxLength",
  28411. "maxMessageSize",
  28412. "maxPacketLifeTime",
  28413. "maxRetransmits",
  28414. "maxSampledTexturesPerShaderStage",
  28415. "maxSamplersPerShaderStage",
  28416. "maxStorageBufferBindingSize",
  28417. "maxStorageBuffersPerShaderStage",
  28418. "maxStorageTexturesPerShaderStage",
  28419. "maxTextureArrayLayers",
  28420. "maxTextureDimension1D",
  28421. "maxTextureDimension2D",
  28422. "maxTextureDimension3D",
  28423. "maxTouchPoints",
  28424. "maxUniformBufferBindingSize",
  28425. "maxUniformBuffersPerShaderStage",
  28426. "maxValue",
  28427. "maxVertexAttributes",
  28428. "maxVertexBufferArrayStride",
  28429. "maxVertexBuffers",
  28430. "maxWidth",
  28431. "maximumLatency",
  28432. "measure",
  28433. "measureInputUsage",
  28434. "measureText",
  28435. "media",
  28436. "mediaCapabilities",
  28437. "mediaDevices",
  28438. "mediaElement",
  28439. "mediaGroup",
  28440. "mediaKeys",
  28441. "mediaSession",
  28442. "mediaStream",
  28443. "mediaText",
  28444. "meetOrSlice",
  28445. "memory",
  28446. "menubar",
  28447. "menus",
  28448. "menusChild",
  28449. "menusInternal",
  28450. "mergeAttributes",
  28451. "message",
  28452. "messageClass",
  28453. "messageHandlers",
  28454. "messageType",
  28455. "messages",
  28456. "metaKey",
  28457. "metadata",
  28458. "method",
  28459. "methodDetails",
  28460. "methodName",
  28461. "microseconds",
  28462. "mid",
  28463. "milliseconds",
  28464. "mimeType",
  28465. "mimeTypes",
  28466. "min",
  28467. "min-block-size",
  28468. "min-height",
  28469. "min-inline-size",
  28470. "min-width",
  28471. "minBindingSize",
  28472. "minBlockSize",
  28473. "minDecibels",
  28474. "minFilter",
  28475. "minHeight",
  28476. "minInlineSize",
  28477. "minLength",
  28478. "minStorageBufferOffsetAlignment",
  28479. "minUniformBufferOffsetAlignment",
  28480. "minValue",
  28481. "minWidth",
  28482. "minimumLatency",
  28483. "minute",
  28484. "minutes",
  28485. "mipLevel",
  28486. "mipLevelCount",
  28487. "mipmapFilter",
  28488. "miterLimit",
  28489. "mix-blend-mode",
  28490. "mixBlendMode",
  28491. "mm",
  28492. "mobile",
  28493. "mode",
  28494. "model",
  28495. "modify",
  28496. "module",
  28497. "month",
  28498. "months",
  28499. "mount",
  28500. "move",
  28501. "moveBefore",
  28502. "moveBy",
  28503. "moveEnd",
  28504. "moveFirst",
  28505. "moveFocusDown",
  28506. "moveFocusLeft",
  28507. "moveFocusRight",
  28508. "moveFocusUp",
  28509. "moveInSuccession",
  28510. "moveNext",
  28511. "moveRow",
  28512. "moveStart",
  28513. "moveTo",
  28514. "moveToBookmark",
  28515. "moveToElementText",
  28516. "moveToPoint",
  28517. "movementX",
  28518. "movementY",
  28519. "mozAdd",
  28520. "mozAnimationStartTime",
  28521. "mozAnon",
  28522. "mozApps",
  28523. "mozAudioCaptured",
  28524. "mozAudioChannelType",
  28525. "mozAutoplayEnabled",
  28526. "mozCancelAnimationFrame",
  28527. "mozCancelFullScreen",
  28528. "mozCancelRequestAnimationFrame",
  28529. "mozCaptureStream",
  28530. "mozCaptureStreamUntilEnded",
  28531. "mozClearDataAt",
  28532. "mozContact",
  28533. "mozContacts",
  28534. "mozCreateFileHandle",
  28535. "mozCurrentTransform",
  28536. "mozCurrentTransformInverse",
  28537. "mozCursor",
  28538. "mozDash",
  28539. "mozDashOffset",
  28540. "mozDecodedFrames",
  28541. "mozExitPointerLock",
  28542. "mozFillRule",
  28543. "mozFragmentEnd",
  28544. "mozFrameDelay",
  28545. "mozFullScreen",
  28546. "mozFullScreenElement",
  28547. "mozFullScreenEnabled",
  28548. "mozGetAll",
  28549. "mozGetAllKeys",
  28550. "mozGetAsFile",
  28551. "mozGetDataAt",
  28552. "mozGetMetadata",
  28553. "mozGetUserMedia",
  28554. "mozHasAudio",
  28555. "mozHasItem",
  28556. "mozHidden",
  28557. "mozImageSmoothingEnabled",
  28558. "mozIndexedDB",
  28559. "mozInnerScreenX",
  28560. "mozInnerScreenY",
  28561. "mozInputSource",
  28562. "mozIsTextField",
  28563. "mozItem",
  28564. "mozItemCount",
  28565. "mozItems",
  28566. "mozLength",
  28567. "mozLockOrientation",
  28568. "mozMatchesSelector",
  28569. "mozMovementX",
  28570. "mozMovementY",
  28571. "mozOpaque",
  28572. "mozOrientation",
  28573. "mozPaintCount",
  28574. "mozPaintedFrames",
  28575. "mozParsedFrames",
  28576. "mozPay",
  28577. "mozPointerLockElement",
  28578. "mozPresentedFrames",
  28579. "mozPreservesPitch",
  28580. "mozPressure",
  28581. "mozPrintCallback",
  28582. "mozRTCIceCandidate",
  28583. "mozRTCPeerConnection",
  28584. "mozRTCSessionDescription",
  28585. "mozRemove",
  28586. "mozRequestAnimationFrame",
  28587. "mozRequestFullScreen",
  28588. "mozRequestPointerLock",
  28589. "mozSetDataAt",
  28590. "mozSetImageElement",
  28591. "mozSourceNode",
  28592. "mozSrcObject",
  28593. "mozSystem",
  28594. "mozTCPSocket",
  28595. "mozTextStyle",
  28596. "mozTypesAt",
  28597. "mozUnlockOrientation",
  28598. "mozUserCancelled",
  28599. "mozVisibilityState",
  28600. "ms",
  28601. "msAnimation",
  28602. "msAnimationDelay",
  28603. "msAnimationDirection",
  28604. "msAnimationDuration",
  28605. "msAnimationFillMode",
  28606. "msAnimationIterationCount",
  28607. "msAnimationName",
  28608. "msAnimationPlayState",
  28609. "msAnimationStartTime",
  28610. "msAnimationTimingFunction",
  28611. "msBackfaceVisibility",
  28612. "msBlockProgression",
  28613. "msCSSOMElementFloatMetrics",
  28614. "msCaching",
  28615. "msCachingEnabled",
  28616. "msCancelRequestAnimationFrame",
  28617. "msCapsLockWarningOff",
  28618. "msClearImmediate",
  28619. "msClose",
  28620. "msContentZoomChaining",
  28621. "msContentZoomFactor",
  28622. "msContentZoomLimit",
  28623. "msContentZoomLimitMax",
  28624. "msContentZoomLimitMin",
  28625. "msContentZoomSnap",
  28626. "msContentZoomSnapPoints",
  28627. "msContentZoomSnapType",
  28628. "msContentZooming",
  28629. "msConvertURL",
  28630. "msCrypto",
  28631. "msDoNotTrack",
  28632. "msElementsFromPoint",
  28633. "msElementsFromRect",
  28634. "msExitFullscreen",
  28635. "msExtendedCode",
  28636. "msFillRule",
  28637. "msFirstPaint",
  28638. "msFlex",
  28639. "msFlexAlign",
  28640. "msFlexDirection",
  28641. "msFlexFlow",
  28642. "msFlexItemAlign",
  28643. "msFlexLinePack",
  28644. "msFlexNegative",
  28645. "msFlexOrder",
  28646. "msFlexPack",
  28647. "msFlexPositive",
  28648. "msFlexPreferredSize",
  28649. "msFlexWrap",
  28650. "msFlowFrom",
  28651. "msFlowInto",
  28652. "msFontFeatureSettings",
  28653. "msFullscreenElement",
  28654. "msFullscreenEnabled",
  28655. "msGetInputContext",
  28656. "msGetRegionContent",
  28657. "msGetUntransformedBounds",
  28658. "msGraphicsTrustStatus",
  28659. "msGridColumn",
  28660. "msGridColumnAlign",
  28661. "msGridColumnSpan",
  28662. "msGridColumns",
  28663. "msGridRow",
  28664. "msGridRowAlign",
  28665. "msGridRowSpan",
  28666. "msGridRows",
  28667. "msHidden",
  28668. "msHighContrastAdjust",
  28669. "msHyphenateLimitChars",
  28670. "msHyphenateLimitLines",
  28671. "msHyphenateLimitZone",
  28672. "msHyphens",
  28673. "msImageSmoothingEnabled",
  28674. "msImeAlign",
  28675. "msIndexedDB",
  28676. "msInterpolationMode",
  28677. "msIsStaticHTML",
  28678. "msKeySystem",
  28679. "msKeys",
  28680. "msLaunchUri",
  28681. "msLockOrientation",
  28682. "msManipulationViewsEnabled",
  28683. "msMatchMedia",
  28684. "msMatchesSelector",
  28685. "msMaxTouchPoints",
  28686. "msOrientation",
  28687. "msOverflowStyle",
  28688. "msPerspective",
  28689. "msPerspectiveOrigin",
  28690. "msPlayToDisabled",
  28691. "msPlayToPreferredSourceUri",
  28692. "msPlayToPrimary",
  28693. "msPointerEnabled",
  28694. "msRegionOverflow",
  28695. "msReleasePointerCapture",
  28696. "msRequestAnimationFrame",
  28697. "msRequestFullscreen",
  28698. "msSaveBlob",
  28699. "msSaveOrOpenBlob",
  28700. "msScrollChaining",
  28701. "msScrollLimit",
  28702. "msScrollLimitXMax",
  28703. "msScrollLimitXMin",
  28704. "msScrollLimitYMax",
  28705. "msScrollLimitYMin",
  28706. "msScrollRails",
  28707. "msScrollSnapPointsX",
  28708. "msScrollSnapPointsY",
  28709. "msScrollSnapType",
  28710. "msScrollSnapX",
  28711. "msScrollSnapY",
  28712. "msScrollTranslation",
  28713. "msSetImmediate",
  28714. "msSetMediaKeys",
  28715. "msSetPointerCapture",
  28716. "msTextCombineHorizontal",
  28717. "msTextSizeAdjust",
  28718. "msToBlob",
  28719. "msTouchAction",
  28720. "msTouchSelect",
  28721. "msTraceAsyncCallbackCompleted",
  28722. "msTraceAsyncCallbackStarting",
  28723. "msTraceAsyncOperationCompleted",
  28724. "msTraceAsyncOperationStarting",
  28725. "msTransform",
  28726. "msTransformOrigin",
  28727. "msTransformStyle",
  28728. "msTransition",
  28729. "msTransitionDelay",
  28730. "msTransitionDuration",
  28731. "msTransitionProperty",
  28732. "msTransitionTimingFunction",
  28733. "msUnlockOrientation",
  28734. "msUpdateAsyncCallbackRelation",
  28735. "msUserSelect",
  28736. "msVisibilityState",
  28737. "msWrapFlow",
  28738. "msWrapMargin",
  28739. "msWrapThrough",
  28740. "msWriteProfilerMark",
  28741. "msZoom",
  28742. "msZoomTo",
  28743. "mt",
  28744. "mul",
  28745. "multiEntry",
  28746. "multiSelectionObj",
  28747. "multiline",
  28748. "multiple",
  28749. "multiply",
  28750. "multiplySelf",
  28751. "multisample",
  28752. "multisampled",
  28753. "mutableFile",
  28754. "muted",
  28755. "n",
  28756. "nacl_arch",
  28757. "name",
  28758. "nameList",
  28759. "nameProp",
  28760. "namedItem",
  28761. "namedRecordset",
  28762. "names",
  28763. "namespaceURI",
  28764. "namespaces",
  28765. "nanoseconds",
  28766. "nativeApplication",
  28767. "nativeMap",
  28768. "nativeObjectCreate",
  28769. "nativeSet",
  28770. "nativeWeakMap",
  28771. "naturalHeight",
  28772. "naturalWidth",
  28773. "navigate",
  28774. "navigation",
  28775. "navigationMode",
  28776. "navigationPreload",
  28777. "navigationStart",
  28778. "navigationType",
  28779. "navigator",
  28780. "near",
  28781. "nearestViewportElement",
  28782. "negative",
  28783. "negotiated",
  28784. "netscape",
  28785. "networkState",
  28786. "networkStatus",
  28787. "newScale",
  28788. "newState",
  28789. "newTranslate",
  28790. "newURL",
  28791. "newValue",
  28792. "newValueSpecifiedUnits",
  28793. "newVersion",
  28794. "newhome",
  28795. "next",
  28796. "nextElementSibling",
  28797. "nextHopProtocol",
  28798. "nextNode",
  28799. "nextPage",
  28800. "nextSibling",
  28801. "nickname",
  28802. "noHref",
  28803. "noModule",
  28804. "noResize",
  28805. "noShade",
  28806. "noValidate",
  28807. "noWrap",
  28808. "node",
  28809. "nodeName",
  28810. "nodeType",
  28811. "nodeValue",
  28812. "nonce",
  28813. "normDepthBufferFromNormView",
  28814. "normalize",
  28815. "normalizedPathSegList",
  28816. "normandyAddonStudy",
  28817. "notRestoredReasons",
  28818. "notationName",
  28819. "notations",
  28820. "note",
  28821. "noteGrainOn",
  28822. "noteOff",
  28823. "noteOn",
  28824. "notifications",
  28825. "notify",
  28826. "now",
  28827. "npnNegotiatedProtocol",
  28828. "numOctaves",
  28829. "number",
  28830. "numberOfChannels",
  28831. "numberOfFrames",
  28832. "numberOfInputs",
  28833. "numberOfItems",
  28834. "numberOfOutputs",
  28835. "numberValue",
  28836. "numberingSystem",
  28837. "numeric",
  28838. "oMatchesSelector",
  28839. "object",
  28840. "object-fit",
  28841. "object-position",
  28842. "objectFit",
  28843. "objectPosition",
  28844. "objectStore",
  28845. "objectStoreNames",
  28846. "objectType",
  28847. "observe",
  28848. "observedAttributes",
  28849. "occlusionQuerySet",
  28850. "of",
  28851. "off",
  28852. "offscreenBuffering",
  28853. "offset",
  28854. "offset-anchor",
  28855. "offset-distance",
  28856. "offset-path",
  28857. "offset-position",
  28858. "offset-rotate",
  28859. "offsetAnchor",
  28860. "offsetDistance",
  28861. "offsetHeight",
  28862. "offsetLeft",
  28863. "offsetNode",
  28864. "offsetParent",
  28865. "offsetPath",
  28866. "offsetPosition",
  28867. "offsetRotate",
  28868. "offsetTop",
  28869. "offsetWidth",
  28870. "offsetX",
  28871. "offsetY",
  28872. "ok",
  28873. "oldState",
  28874. "oldURL",
  28875. "oldValue",
  28876. "oldVersion",
  28877. "olderShadowRoot",
  28878. "omnibox",
  28879. "on",
  28880. "onActivated",
  28881. "onAdded",
  28882. "onAttached",
  28883. "onBoundsChanged",
  28884. "onBrowserUpdateAvailable",
  28885. "onClicked",
  28886. "onCommitFiberRoot",
  28887. "onCommitFiberUnmount",
  28888. "onConnect",
  28889. "onConnectExternal",
  28890. "onConnectNative",
  28891. "onCreated",
  28892. "onDetached",
  28893. "onDisabled",
  28894. "onEnabled",
  28895. "onFocusChanged",
  28896. "onHighlighted",
  28897. "onInstalled",
  28898. "onLine",
  28899. "onMessage",
  28900. "onMessageExternal",
  28901. "onMoved",
  28902. "onPerformanceWarning",
  28903. "onPostCommitFiberRoot",
  28904. "onRemoved",
  28905. "onReplaced",
  28906. "onRestartRequired",
  28907. "onStartup",
  28908. "onSubmittedWorkDone",
  28909. "onSuspend",
  28910. "onSuspendCanceled",
  28911. "onUninstalled",
  28912. "onUpdateAvailable",
  28913. "onUpdated",
  28914. "onUserScriptConnect",
  28915. "onUserScriptMessage",
  28916. "onUserSettingsChanged",
  28917. "onZoomChange",
  28918. "onabort",
  28919. "onabsolutedeviceorientation",
  28920. "onactivate",
  28921. "onactive",
  28922. "onaddsourcebuffer",
  28923. "onaddstream",
  28924. "onaddtrack",
  28925. "onafterprint",
  28926. "onafterscriptexecute",
  28927. "onafterupdate",
  28928. "onanimationcancel",
  28929. "onanimationend",
  28930. "onanimationiteration",
  28931. "onanimationstart",
  28932. "onappinstalled",
  28933. "onaudioend",
  28934. "onaudioprocess",
  28935. "onaudiostart",
  28936. "onautocomplete",
  28937. "onautocompleteerror",
  28938. "onauxclick",
  28939. "onbeforeactivate",
  28940. "onbeforecopy",
  28941. "onbeforecut",
  28942. "onbeforedeactivate",
  28943. "onbeforeeditfocus",
  28944. "onbeforeinput",
  28945. "onbeforeinstallprompt",
  28946. "onbeforematch",
  28947. "onbeforepaste",
  28948. "onbeforeprint",
  28949. "onbeforescriptexecute",
  28950. "onbeforetoggle",
  28951. "onbeforeunload",
  28952. "onbeforeupdate",
  28953. "onbeforexrselect",
  28954. "onbegin",
  28955. "onblocked",
  28956. "onblur",
  28957. "onbounce",
  28958. "onboundary",
  28959. "onbufferedamountlow",
  28960. "oncached",
  28961. "oncancel",
  28962. "oncandidatewindowhide",
  28963. "oncandidatewindowshow",
  28964. "oncandidatewindowupdate",
  28965. "oncanplay",
  28966. "oncanplaythrough",
  28967. "oncapturehandlechange",
  28968. "once",
  28969. "oncellchange",
  28970. "onchange",
  28971. "oncharacterboundsupdate",
  28972. "oncharacteristicvaluechanged",
  28973. "onchargingchange",
  28974. "onchargingtimechange",
  28975. "onchecking",
  28976. "onclick",
  28977. "onclose",
  28978. "onclosing",
  28979. "oncommand",
  28980. "oncompassneedscalibration",
  28981. "oncomplete",
  28982. "oncompositionend",
  28983. "oncompositionstart",
  28984. "onconnect",
  28985. "onconnecting",
  28986. "onconnectionavailable",
  28987. "onconnectionstatechange",
  28988. "oncontentvisibilityautostatechange",
  28989. "oncontextlost",
  28990. "oncontextmenu",
  28991. "oncontextrestored",
  28992. "oncontrollerchange",
  28993. "oncontrolselect",
  28994. "oncopy",
  28995. "oncuechange",
  28996. "oncurrententrychange",
  28997. "oncurrentscreenchange",
  28998. "oncut",
  28999. "ondataavailable",
  29000. "ondatachannel",
  29001. "ondatasetchanged",
  29002. "ondatasetcomplete",
  29003. "ondblclick",
  29004. "ondeactivate",
  29005. "ondequeue",
  29006. "ondevicechange",
  29007. "ondevicelight",
  29008. "ondevicemotion",
  29009. "ondeviceorientation",
  29010. "ondeviceorientationabsolute",
  29011. "ondeviceproximity",
  29012. "ondischargingtimechange",
  29013. "ondisconnect",
  29014. "ondisplay",
  29015. "ondispose",
  29016. "ondownloading",
  29017. "ondownloadprogress",
  29018. "ondrag",
  29019. "ondragend",
  29020. "ondragenter",
  29021. "ondragexit",
  29022. "ondragleave",
  29023. "ondragover",
  29024. "ondragstart",
  29025. "ondrop",
  29026. "ondurationchange",
  29027. "onemptied",
  29028. "onencrypted",
  29029. "onend",
  29030. "onended",
  29031. "onenter",
  29032. "onenterpictureinpicture",
  29033. "onerror",
  29034. "onerrorupdate",
  29035. "onexit",
  29036. "onfencedtreeclick",
  29037. "onfilterchange",
  29038. "onfinish",
  29039. "onfocus",
  29040. "onfocusin",
  29041. "onfocusout",
  29042. "onformdata",
  29043. "onfreeze",
  29044. "onfullscreenchange",
  29045. "onfullscreenerror",
  29046. "ongamepadconnected",
  29047. "ongamepaddisconnected",
  29048. "ongatheringstatechange",
  29049. "ongattserverdisconnected",
  29050. "ongeometrychange",
  29051. "ongesturechange",
  29052. "ongestureend",
  29053. "ongesturestart",
  29054. "ongotpointercapture",
  29055. "onhashchange",
  29056. "onhelp",
  29057. "onicecandidate",
  29058. "onicecandidateerror",
  29059. "oniceconnectionstatechange",
  29060. "onicegatheringstatechange",
  29061. "oninactive",
  29062. "oninput",
  29063. "oninputreport",
  29064. "oninputsourceschange",
  29065. "oninvalid",
  29066. "onkeydown",
  29067. "onkeypress",
  29068. "onkeystatuseschange",
  29069. "onkeyup",
  29070. "onlanguagechange",
  29071. "onlayoutcomplete",
  29072. "onleavepictureinpicture",
  29073. "onlevelchange",
  29074. "onload",
  29075. "onloadT",
  29076. "onloadeddata",
  29077. "onloadedmetadata",
  29078. "onloadend",
  29079. "onloading",
  29080. "onloadingdone",
  29081. "onloadingerror",
  29082. "onloadstart",
  29083. "onlosecapture",
  29084. "onlostpointercapture",
  29085. "only",
  29086. "onmanagedconfigurationchange",
  29087. "onmark",
  29088. "onmessage",
  29089. "onmessageerror",
  29090. "onmidimessage",
  29091. "onmousedown",
  29092. "onmouseenter",
  29093. "onmouseleave",
  29094. "onmousemove",
  29095. "onmouseout",
  29096. "onmouseover",
  29097. "onmouseup",
  29098. "onmousewheel",
  29099. "onmove",
  29100. "onmoveend",
  29101. "onmovestart",
  29102. "onmozfullscreenchange",
  29103. "onmozfullscreenerror",
  29104. "onmozorientationchange",
  29105. "onmozpointerlockchange",
  29106. "onmozpointerlockerror",
  29107. "onmscontentzoom",
  29108. "onmsfullscreenchange",
  29109. "onmsfullscreenerror",
  29110. "onmsgesturechange",
  29111. "onmsgesturedoubletap",
  29112. "onmsgestureend",
  29113. "onmsgesturehold",
  29114. "onmsgesturestart",
  29115. "onmsgesturetap",
  29116. "onmsgotpointercapture",
  29117. "onmsinertiastart",
  29118. "onmslostpointercapture",
  29119. "onmsmanipulationstatechanged",
  29120. "onmsneedkey",
  29121. "onmsorientationchange",
  29122. "onmspointercancel",
  29123. "onmspointerdown",
  29124. "onmspointerenter",
  29125. "onmspointerhover",
  29126. "onmspointerleave",
  29127. "onmspointermove",
  29128. "onmspointerout",
  29129. "onmspointerover",
  29130. "onmspointerup",
  29131. "onmssitemodejumplistitemremoved",
  29132. "onmsthumbnailclick",
  29133. "onmute",
  29134. "onnavigate",
  29135. "onnavigateerror",
  29136. "onnavigatesuccess",
  29137. "onnegotiationneeded",
  29138. "onnomatch",
  29139. "onnoupdate",
  29140. "onobsolete",
  29141. "onoffline",
  29142. "ononline",
  29143. "onopen",
  29144. "onorientationchange",
  29145. "onpagechange",
  29146. "onpagehide",
  29147. "onpagereveal",
  29148. "onpageshow",
  29149. "onpageswap",
  29150. "onpaste",
  29151. "onpause",
  29152. "onpayerdetailchange",
  29153. "onpaymentmethodchange",
  29154. "onplay",
  29155. "onplaying",
  29156. "onpluginstreamstart",
  29157. "onpointercancel",
  29158. "onpointerdown",
  29159. "onpointerenter",
  29160. "onpointerleave",
  29161. "onpointerlockchange",
  29162. "onpointerlockerror",
  29163. "onpointermove",
  29164. "onpointerout",
  29165. "onpointerover",
  29166. "onpointerrawupdate",
  29167. "onpointerup",
  29168. "onpopstate",
  29169. "onprerenderingchange",
  29170. "onprioritychange",
  29171. "onprocessorerror",
  29172. "onprogress",
  29173. "onpropertychange",
  29174. "onratechange",
  29175. "onreading",
  29176. "onreadystatechange",
  29177. "onreflectionchange",
  29178. "onrejectionhandled",
  29179. "onrelease",
  29180. "onremove",
  29181. "onremovesourcebuffer",
  29182. "onremovestream",
  29183. "onremovetrack",
  29184. "onrepeat",
  29185. "onreset",
  29186. "onresize",
  29187. "onresizeend",
  29188. "onresizestart",
  29189. "onresourcetimingbufferfull",
  29190. "onresult",
  29191. "onresume",
  29192. "onrowenter",
  29193. "onrowexit",
  29194. "onrowsdelete",
  29195. "onrowsinserted",
  29196. "onscreenschange",
  29197. "onscroll",
  29198. "onscrollend",
  29199. "onscrollsnapchange",
  29200. "onscrollsnapchanging",
  29201. "onsearch",
  29202. "onsecuritypolicyviolation",
  29203. "onseeked",
  29204. "onseeking",
  29205. "onselect",
  29206. "onselectedcandidatepairchange",
  29207. "onselectend",
  29208. "onselectionchange",
  29209. "onselectstart",
  29210. "onshippingaddresschange",
  29211. "onshippingoptionchange",
  29212. "onshow",
  29213. "onsignalingstatechange",
  29214. "onsinkchange",
  29215. "onslotchange",
  29216. "onsoundend",
  29217. "onsoundstart",
  29218. "onsourceclose",
  29219. "onsourceclosed",
  29220. "onsourceended",
  29221. "onsourceopen",
  29222. "onspeechend",
  29223. "onspeechstart",
  29224. "onsqueeze",
  29225. "onsqueezeend",
  29226. "onsqueezestart",
  29227. "onstalled",
  29228. "onstart",
  29229. "onstatechange",
  29230. "onstop",
  29231. "onstorage",
  29232. "onstoragecommit",
  29233. "onsubmit",
  29234. "onsuccess",
  29235. "onsuspend",
  29236. "onterminate",
  29237. "ontextformatupdate",
  29238. "ontextinput",
  29239. "ontextupdate",
  29240. "ontimeout",
  29241. "ontimeupdate",
  29242. "ontoggle",
  29243. "ontonechange",
  29244. "ontouchcancel",
  29245. "ontouchend",
  29246. "ontouchmove",
  29247. "ontouchstart",
  29248. "ontrack",
  29249. "ontransitioncancel",
  29250. "ontransitionend",
  29251. "ontransitionrun",
  29252. "ontransitionstart",
  29253. "onuncapturederror",
  29254. "onunhandledrejection",
  29255. "onunload",
  29256. "onunmute",
  29257. "onupdate",
  29258. "onupdateend",
  29259. "onupdatefound",
  29260. "onupdateready",
  29261. "onupdatestart",
  29262. "onupgradeneeded",
  29263. "onuserproximity",
  29264. "onversionchange",
  29265. "onvisibilitychange",
  29266. "onvoiceschanged",
  29267. "onvolumechange",
  29268. "onvrdisplayactivate",
  29269. "onvrdisplayconnect",
  29270. "onvrdisplaydeactivate",
  29271. "onvrdisplaydisconnect",
  29272. "onvrdisplaypresentchange",
  29273. "onwaiting",
  29274. "onwaitingforkey",
  29275. "onwarning",
  29276. "onwebkitanimationend",
  29277. "onwebkitanimationiteration",
  29278. "onwebkitanimationstart",
  29279. "onwebkitcurrentplaybacktargetiswirelesschanged",
  29280. "onwebkitfullscreenchange",
  29281. "onwebkitfullscreenerror",
  29282. "onwebkitkeyadded",
  29283. "onwebkitkeyerror",
  29284. "onwebkitkeymessage",
  29285. "onwebkitneedkey",
  29286. "onwebkitorientationchange",
  29287. "onwebkitplaybacktargetavailabilitychanged",
  29288. "onwebkitpointerlockchange",
  29289. "onwebkitpointerlockerror",
  29290. "onwebkitresourcetimingbufferfull",
  29291. "onwebkittransitionend",
  29292. "onwheel",
  29293. "onzoom",
  29294. "onzoomlevelchange",
  29295. "opacity",
  29296. "open",
  29297. "openCursor",
  29298. "openDatabase",
  29299. "openKeyCursor",
  29300. "openOptionsPage",
  29301. "openOrClosedShadowRoot",
  29302. "openPopup",
  29303. "opened",
  29304. "opener",
  29305. "opera",
  29306. "operation",
  29307. "operationType",
  29308. "operator",
  29309. "opr",
  29310. "optimum",
  29311. "options",
  29312. "or",
  29313. "order",
  29314. "orderX",
  29315. "orderY",
  29316. "ordered",
  29317. "org",
  29318. "organization",
  29319. "orient",
  29320. "orientAngle",
  29321. "orientType",
  29322. "orientation",
  29323. "orientationX",
  29324. "orientationY",
  29325. "orientationZ",
  29326. "origin",
  29327. "originAgentCluster",
  29328. "originalPolicy",
  29329. "originalTarget",
  29330. "ornaments",
  29331. "orphans",
  29332. "os",
  29333. "oscpu",
  29334. "outerHTML",
  29335. "outerHeight",
  29336. "outerText",
  29337. "outerWidth",
  29338. "outgoingHighWaterMark",
  29339. "outgoingMaxAge",
  29340. "outline",
  29341. "outline-color",
  29342. "outline-offset",
  29343. "outline-style",
  29344. "outline-width",
  29345. "outlineColor",
  29346. "outlineOffset",
  29347. "outlineStyle",
  29348. "outlineWidth",
  29349. "outputBuffer",
  29350. "outputChannelCount",
  29351. "outputLanguage",
  29352. "outputLatency",
  29353. "outputs",
  29354. "overallProgress",
  29355. "overflow",
  29356. "overflow-anchor",
  29357. "overflow-block",
  29358. "overflow-clip-margin",
  29359. "overflow-inline",
  29360. "overflow-wrap",
  29361. "overflow-x",
  29362. "overflow-y",
  29363. "overflowAnchor",
  29364. "overflowBlock",
  29365. "overflowClipMargin",
  29366. "overflowInline",
  29367. "overflowWrap",
  29368. "overflowX",
  29369. "overflowY",
  29370. "overlaysContent",
  29371. "overrideColors",
  29372. "overrideMimeType",
  29373. "oversample",
  29374. "overscroll-behavior",
  29375. "overscroll-behavior-block",
  29376. "overscroll-behavior-inline",
  29377. "overscroll-behavior-x",
  29378. "overscroll-behavior-y",
  29379. "overscrollBehavior",
  29380. "overscrollBehaviorBlock",
  29381. "overscrollBehaviorInline",
  29382. "overscrollBehaviorX",
  29383. "overscrollBehaviorY",
  29384. "ownKeys",
  29385. "ownerDocument",
  29386. "ownerElement",
  29387. "ownerNode",
  29388. "ownerRule",
  29389. "ownerSVGElement",
  29390. "owningElement",
  29391. "p1",
  29392. "p2",
  29393. "p3",
  29394. "p4",
  29395. "packetSize",
  29396. "packets",
  29397. "pad",
  29398. "padEnd",
  29399. "padStart",
  29400. "padding",
  29401. "padding-block",
  29402. "padding-block-end",
  29403. "padding-block-start",
  29404. "padding-bottom",
  29405. "padding-inline",
  29406. "padding-inline-end",
  29407. "padding-inline-start",
  29408. "padding-left",
  29409. "padding-right",
  29410. "padding-top",
  29411. "paddingBlock",
  29412. "paddingBlockEnd",
  29413. "paddingBlockStart",
  29414. "paddingBottom",
  29415. "paddingInline",
  29416. "paddingInlineEnd",
  29417. "paddingInlineStart",
  29418. "paddingLeft",
  29419. "paddingRight",
  29420. "paddingTop",
  29421. "page",
  29422. "page-break-after",
  29423. "page-break-before",
  29424. "page-break-inside",
  29425. "page-orientation",
  29426. "pageAction",
  29427. "pageBreakAfter",
  29428. "pageBreakBefore",
  29429. "pageBreakInside",
  29430. "pageCount",
  29431. "pageLeft",
  29432. "pageOrientation",
  29433. "pageT",
  29434. "pageTop",
  29435. "pageX",
  29436. "pageXOffset",
  29437. "pageY",
  29438. "pageYOffset",
  29439. "pages",
  29440. "paint-order",
  29441. "paintOrder",
  29442. "paintRequests",
  29443. "paintTime",
  29444. "paintType",
  29445. "paintWorklet",
  29446. "palette",
  29447. "pan",
  29448. "panningModel",
  29449. "parameterData",
  29450. "parameters",
  29451. "parent",
  29452. "parentElement",
  29453. "parentNode",
  29454. "parentRule",
  29455. "parentStyleSheet",
  29456. "parentTextEdit",
  29457. "parentWindow",
  29458. "parse",
  29459. "parseAll",
  29460. "parseCreationOptionsFromJSON",
  29461. "parseFloat",
  29462. "parseFromString",
  29463. "parseHTMLUnsafe",
  29464. "parseInt",
  29465. "parseRequestOptionsFromJSON",
  29466. "part",
  29467. "participants",
  29468. "passOp",
  29469. "passive",
  29470. "password",
  29471. "pasteHTML",
  29472. "path",
  29473. "pathLength",
  29474. "pathSegList",
  29475. "pathSegType",
  29476. "pathSegTypeAsLetter",
  29477. "pathname",
  29478. "pattern",
  29479. "patternContentUnits",
  29480. "patternMismatch",
  29481. "patternTransform",
  29482. "patternUnits",
  29483. "pause",
  29484. "pauseAnimations",
  29485. "pauseDepthSensing",
  29486. "pauseDuration",
  29487. "pauseOnExit",
  29488. "pauseProfilers",
  29489. "pauseTransformFeedback",
  29490. "paused",
  29491. "payerEmail",
  29492. "payerName",
  29493. "payerPhone",
  29494. "paymentManager",
  29495. "pc",
  29496. "pdfViewerEnabled",
  29497. "peerIdentity",
  29498. "pending",
  29499. "pendingLocalDescription",
  29500. "pendingRemoteDescription",
  29501. "percent",
  29502. "performance",
  29503. "periodicSync",
  29504. "permission",
  29505. "permissionState",
  29506. "permissions",
  29507. "persist",
  29508. "persisted",
  29509. "persistentDeviceId",
  29510. "personalbar",
  29511. "perspective",
  29512. "perspective-origin",
  29513. "perspectiveOrigin",
  29514. "phone",
  29515. "phoneticFamilyName",
  29516. "phoneticGivenName",
  29517. "photo",
  29518. "phrase",
  29519. "phrases",
  29520. "pictureInPictureChild",
  29521. "pictureInPictureElement",
  29522. "pictureInPictureEnabled",
  29523. "pictureInPictureWindow",
  29524. "ping",
  29525. "pipeThrough",
  29526. "pipeTo",
  29527. "pitch",
  29528. "pixelBottom",
  29529. "pixelDepth",
  29530. "pixelFormat",
  29531. "pixelHeight",
  29532. "pixelLeft",
  29533. "pixelRight",
  29534. "pixelStorei",
  29535. "pixelTop",
  29536. "pixelUnitToMillimeterX",
  29537. "pixelUnitToMillimeterY",
  29538. "pixelWidth",
  29539. "pkcs11",
  29540. "place-content",
  29541. "place-items",
  29542. "place-self",
  29543. "placeContent",
  29544. "placeItems",
  29545. "placeSelf",
  29546. "placeholder",
  29547. "platform",
  29548. "platformVersion",
  29549. "platforms",
  29550. "play",
  29551. "playEffect",
  29552. "playState",
  29553. "playbackRate",
  29554. "playbackState",
  29555. "playbackTime",
  29556. "played",
  29557. "playoutDelayHint",
  29558. "playsInline",
  29559. "plugins",
  29560. "pluginspage",
  29561. "pname",
  29562. "pointer-events",
  29563. "pointerBeforeReferenceNode",
  29564. "pointerEnabled",
  29565. "pointerEvents",
  29566. "pointerId",
  29567. "pointerLockElement",
  29568. "pointerType",
  29569. "points",
  29570. "pointsAtX",
  29571. "pointsAtY",
  29572. "pointsAtZ",
  29573. "polygonOffset",
  29574. "pop",
  29575. "popDebugGroup",
  29576. "popErrorScope",
  29577. "popover",
  29578. "popoverTargetAction",
  29579. "popoverTargetElement",
  29580. "populateMatrix",
  29581. "popupWindowFeatures",
  29582. "popupWindowName",
  29583. "popupWindowURI",
  29584. "port",
  29585. "port1",
  29586. "port2",
  29587. "ports",
  29588. "posBottom",
  29589. "posHeight",
  29590. "posLeft",
  29591. "posRight",
  29592. "posTop",
  29593. "posWidth",
  29594. "pose",
  29595. "position",
  29596. "position-anchor",
  29597. "position-area",
  29598. "positionAlign",
  29599. "positionAnchor",
  29600. "positionArea",
  29601. "positionTry",
  29602. "positionTryFallbacks",
  29603. "positionVisibility",
  29604. "positionX",
  29605. "positionY",
  29606. "positionZ",
  29607. "postError",
  29608. "postMessage",
  29609. "postTask",
  29610. "postalCode",
  29611. "poster",
  29612. "postscriptName",
  29613. "pow",
  29614. "powerEfficient",
  29615. "powerOff",
  29616. "powerPreference",
  29617. "preMultiplySelf",
  29618. "precision",
  29619. "preferredReflectionFormat",
  29620. "preferredStyleSheetSet",
  29621. "preferredStylesheetSet",
  29622. "prefix",
  29623. "preload",
  29624. "premultipliedAlpha",
  29625. "prepend",
  29626. "prerendering",
  29627. "presentation",
  29628. "presentationArea",
  29629. "presentationStyle",
  29630. "presentationTime",
  29631. "preserveAlpha",
  29632. "preserveAspectRatio",
  29633. "preserveAspectRatioString",
  29634. "preservesPitch",
  29635. "pressed",
  29636. "pressure",
  29637. "prevValue",
  29638. "preventDefault",
  29639. "preventExtensions",
  29640. "preventSilentAccess",
  29641. "previousElementSibling",
  29642. "previousNode",
  29643. "previousPage",
  29644. "previousPriority",
  29645. "previousRect",
  29646. "previousScale",
  29647. "previousSibling",
  29648. "previousTranslate",
  29649. "primaries",
  29650. "primaryKey",
  29651. "primaryLightDirection",
  29652. "primaryLightIntensity",
  29653. "primitive",
  29654. "primitiveType",
  29655. "primitiveUnits",
  29656. "principals",
  29657. "print",
  29658. "print-color-adjust",
  29659. "printColorAdjust",
  29660. "printPreview",
  29661. "priority",
  29662. "privacy",
  29663. "privateKey",
  29664. "privateToken",
  29665. "probablySupportsContext",
  29666. "probeSpace",
  29667. "process",
  29668. "processIceMessage",
  29669. "processLocally",
  29670. "processingEnd",
  29671. "processingStart",
  29672. "processorOptions",
  29673. "product",
  29674. "productId",
  29675. "productName",
  29676. "productSub",
  29677. "profile",
  29678. "profileEnd",
  29679. "profiles",
  29680. "projectionMatrix",
  29681. "promise",
  29682. "promising",
  29683. "prompt",
  29684. "properties",
  29685. "propertyIsEnumerable",
  29686. "propertyName",
  29687. "protectedAudience",
  29688. "protocol",
  29689. "protocolLong",
  29690. "prototype",
  29691. "provider",
  29692. "proxy",
  29693. "pseudoClass",
  29694. "pseudoElement",
  29695. "pt",
  29696. "publicId",
  29697. "publicKey",
  29698. "published",
  29699. "pulse",
  29700. "push",
  29701. "pushDebugGroup",
  29702. "pushErrorScope",
  29703. "pushManager",
  29704. "pushNotification",
  29705. "pushState",
  29706. "put",
  29707. "putImageData",
  29708. "px",
  29709. "quadraticCurveTo",
  29710. "qualifier",
  29711. "quaternion",
  29712. "query",
  29713. "queryCommandEnabled",
  29714. "queryCommandIndeterm",
  29715. "queryCommandState",
  29716. "queryCommandSupported",
  29717. "queryCommandText",
  29718. "queryCommandValue",
  29719. "queryFeatureSupport",
  29720. "queryLocalFonts",
  29721. "queryPermission",
  29722. "querySelector",
  29723. "querySelectorAll",
  29724. "querySet",
  29725. "queue",
  29726. "queueMicrotask",
  29727. "quota",
  29728. "quote",
  29729. "quotes",
  29730. "r",
  29731. "r1",
  29732. "r2",
  29733. "race",
  29734. "rad",
  29735. "radiogroup",
  29736. "radius",
  29737. "radiusX",
  29738. "radiusY",
  29739. "random",
  29740. "randomUUID",
  29741. "range",
  29742. "rangeCount",
  29743. "rangeEnd",
  29744. "rangeMax",
  29745. "rangeMin",
  29746. "rangeOffset",
  29747. "rangeOverflow",
  29748. "rangeParent",
  29749. "rangeStart",
  29750. "rangeUnderflow",
  29751. "rate",
  29752. "ratio",
  29753. "raw",
  29754. "rawId",
  29755. "rawJSON",
  29756. "rawValueToMeters",
  29757. "rcap",
  29758. "rch",
  29759. "read",
  29760. "readAsArrayBuffer",
  29761. "readAsBinaryString",
  29762. "readAsBlob",
  29763. "readAsDataURL",
  29764. "readAsText",
  29765. "readBuffer",
  29766. "readEntries",
  29767. "readOnly",
  29768. "readPixels",
  29769. "readReportRequested",
  29770. "readText",
  29771. "readValue",
  29772. "readable",
  29773. "ready",
  29774. "readyState",
  29775. "reason",
  29776. "reasons",
  29777. "reboot",
  29778. "receiveFeatureReport",
  29779. "receivedAlert",
  29780. "receiver",
  29781. "receivers",
  29782. "recipient",
  29783. "recommendedViewportScale",
  29784. "reconnect",
  29785. "recordNumber",
  29786. "recordsAvailable",
  29787. "recordset",
  29788. "rect",
  29789. "red",
  29790. "redEyeReduction",
  29791. "redirect",
  29792. "redirectCount",
  29793. "redirectEnd",
  29794. "redirectStart",
  29795. "redirected",
  29796. "reduce",
  29797. "reduceRight",
  29798. "reduction",
  29799. "refDistance",
  29800. "refX",
  29801. "refY",
  29802. "referenceNode",
  29803. "referenceSpace",
  29804. "referrer",
  29805. "referrerPolicy",
  29806. "refresh",
  29807. "region",
  29808. "regionAnchorX",
  29809. "regionAnchorY",
  29810. "regionId",
  29811. "regions",
  29812. "register",
  29813. "registerContentHandler",
  29814. "registerElement",
  29815. "registerInternalModuleStart",
  29816. "registerInternalModuleStop",
  29817. "registerProperty",
  29818. "registerProtocolHandler",
  29819. "reject",
  29820. "rel",
  29821. "relList",
  29822. "relatedAddress",
  29823. "relatedNode",
  29824. "relatedPort",
  29825. "relatedTarget",
  29826. "relayProtocol",
  29827. "release",
  29828. "releaseCapture",
  29829. "releaseEvents",
  29830. "releaseInterface",
  29831. "releaseLock",
  29832. "releasePointerCapture",
  29833. "releaseShaderCompiler",
  29834. "released",
  29835. "reliability",
  29836. "reliable",
  29837. "reliableWrite",
  29838. "reload",
  29839. "rem",
  29840. "remainingSpace",
  29841. "remote",
  29842. "remoteDescription",
  29843. "remove",
  29844. "removeAllRanges",
  29845. "removeAttribute",
  29846. "removeAttributeNS",
  29847. "removeAttributeNode",
  29848. "removeBehavior",
  29849. "removeChild",
  29850. "removeCue",
  29851. "removeEntry",
  29852. "removeEventListener",
  29853. "removeFilter",
  29854. "removeImport",
  29855. "removeItem",
  29856. "removeListener",
  29857. "removeNamedItem",
  29858. "removeNamedItemNS",
  29859. "removeNode",
  29860. "removeParameter",
  29861. "removeProperty",
  29862. "removeRange",
  29863. "removeRegion",
  29864. "removeRule",
  29865. "removeSiteSpecificTrackingException",
  29866. "removeSourceBuffer",
  29867. "removeStream",
  29868. "removeTrack",
  29869. "removeVariable",
  29870. "removeWakeLockListener",
  29871. "removeWebWideTrackingException",
  29872. "removed",
  29873. "removedNodes",
  29874. "renderBlockingStatus",
  29875. "renderHeight",
  29876. "renderStart",
  29877. "renderState",
  29878. "renderTime",
  29879. "renderWidth",
  29880. "renderbufferStorage",
  29881. "renderbufferStorageMultisample",
  29882. "renderedBuffer",
  29883. "rendererInterfaces",
  29884. "renderers",
  29885. "renderingMode",
  29886. "renotify",
  29887. "repeat",
  29888. "repetitionCount",
  29889. "replace",
  29890. "replaceAdjacentText",
  29891. "replaceAll",
  29892. "replaceChild",
  29893. "replaceChildren",
  29894. "replaceData",
  29895. "replaceId",
  29896. "replaceItem",
  29897. "replaceNode",
  29898. "replaceState",
  29899. "replaceSync",
  29900. "replaceTrack",
  29901. "replaceWholeText",
  29902. "replaceWith",
  29903. "reportError",
  29904. "reportEvent",
  29905. "reportId",
  29906. "reportOnly",
  29907. "reportValidity",
  29908. "request",
  29909. "requestAdapter",
  29910. "requestAdapterInfo",
  29911. "requestAnimationFrame",
  29912. "requestAutocomplete",
  29913. "requestClose",
  29914. "requestData",
  29915. "requestDevice",
  29916. "requestFrame",
  29917. "requestFullscreen",
  29918. "requestHitTestSource",
  29919. "requestHitTestSourceForTransientInput",
  29920. "requestId",
  29921. "requestIdleCallback",
  29922. "requestLightProbe",
  29923. "requestMIDIAccess",
  29924. "requestMediaKeySystemAccess",
  29925. "requestPermission",
  29926. "requestPictureInPicture",
  29927. "requestPointerLock",
  29928. "requestPort",
  29929. "requestPresent",
  29930. "requestPresenter",
  29931. "requestReferenceSpace",
  29932. "requestSession",
  29933. "requestStart",
  29934. "requestStorageAccess",
  29935. "requestStorageAccessFor",
  29936. "requestSubmit",
  29937. "requestTime",
  29938. "requestUpdateCheck",
  29939. "requestVideoFrameCallback",
  29940. "requestViewportScale",
  29941. "requestWindow",
  29942. "requested",
  29943. "requestingWindow",
  29944. "requireInteraction",
  29945. "required",
  29946. "requiredExtensions",
  29947. "requiredFeatures",
  29948. "requiredLimits",
  29949. "reset",
  29950. "resetLatency",
  29951. "resetPose",
  29952. "resetTransform",
  29953. "resetZoomLevel",
  29954. "resizable",
  29955. "resize",
  29956. "resizeBy",
  29957. "resizeTo",
  29958. "resolve",
  29959. "resolveQuerySet",
  29960. "resolveTarget",
  29961. "resource",
  29962. "respond",
  29963. "respondWithNewView",
  29964. "response",
  29965. "responseBody",
  29966. "responseEnd",
  29967. "responseReady",
  29968. "responseStart",
  29969. "responseStatus",
  29970. "responseText",
  29971. "responseType",
  29972. "responseURL",
  29973. "responseXML",
  29974. "restart",
  29975. "restartAfterDelay",
  29976. "restartIce",
  29977. "restore",
  29978. "restrictTo",
  29979. "result",
  29980. "resultIndex",
  29981. "resultType",
  29982. "results",
  29983. "resume",
  29984. "resumeDepthSensing",
  29985. "resumeProfilers",
  29986. "resumeTransformFeedback",
  29987. "retry",
  29988. "returnType",
  29989. "returnValue",
  29990. "rev",
  29991. "reverse",
  29992. "reversed",
  29993. "revocable",
  29994. "revokeObjectURL",
  29995. "rex",
  29996. "rgbColor",
  29997. "ric",
  29998. "right",
  29999. "rightContext",
  30000. "rightDegrees",
  30001. "rightMargin",
  30002. "rightProjectionMatrix",
  30003. "rightViewMatrix",
  30004. "rlh",
  30005. "role",
  30006. "rolloffFactor",
  30007. "root",
  30008. "rootBounds",
  30009. "rootElement",
  30010. "rootMargin",
  30011. "rotate",
  30012. "rotateAxisAngle",
  30013. "rotateAxisAngleSelf",
  30014. "rotateFromVector",
  30015. "rotateFromVectorSelf",
  30016. "rotateSelf",
  30017. "rotation",
  30018. "rotationAngle",
  30019. "rotationRate",
  30020. "round",
  30021. "roundRect",
  30022. "row-gap",
  30023. "rowGap",
  30024. "rowIndex",
  30025. "rowSpan",
  30026. "rows",
  30027. "rowsPerImage",
  30028. "rtcpTransport",
  30029. "rtt",
  30030. "ruby-align",
  30031. "ruby-position",
  30032. "rubyAlign",
  30033. "rubyOverhang",
  30034. "rubyPosition",
  30035. "rules",
  30036. "run",
  30037. "runAdAuction",
  30038. "runtime",
  30039. "runtimeStyle",
  30040. "rx",
  30041. "ry",
  30042. "s",
  30043. "safari",
  30044. "sameDocument",
  30045. "sample",
  30046. "sampleCount",
  30047. "sampleCoverage",
  30048. "sampleInterval",
  30049. "sampleRate",
  30050. "sampleType",
  30051. "sampler",
  30052. "samplerParameterf",
  30053. "samplerParameteri",
  30054. "sandbox",
  30055. "save",
  30056. "saveAsPDF",
  30057. "saveData",
  30058. "scale",
  30059. "scale3d",
  30060. "scale3dSelf",
  30061. "scaleNonUniform",
  30062. "scaleNonUniformSelf",
  30063. "scaleSelf",
  30064. "scheduler",
  30065. "scheduling",
  30066. "scheme",
  30067. "scissor",
  30068. "scope",
  30069. "scopeName",
  30070. "scoped",
  30071. "screen",
  30072. "screenBrightness",
  30073. "screenEnabled",
  30074. "screenLeft",
  30075. "screenPixelToMillimeterX",
  30076. "screenPixelToMillimeterY",
  30077. "screenState",
  30078. "screenTop",
  30079. "screenX",
  30080. "screenY",
  30081. "screens",
  30082. "scriptURL",
  30083. "scripting",
  30084. "scripts",
  30085. "scroll",
  30086. "scroll-behavior",
  30087. "scroll-margin",
  30088. "scroll-margin-block",
  30089. "scroll-margin-block-end",
  30090. "scroll-margin-block-start",
  30091. "scroll-margin-bottom",
  30092. "scroll-margin-inline",
  30093. "scroll-margin-inline-end",
  30094. "scroll-margin-inline-start",
  30095. "scroll-margin-left",
  30096. "scroll-margin-right",
  30097. "scroll-margin-top",
  30098. "scroll-padding",
  30099. "scroll-padding-block",
  30100. "scroll-padding-block-end",
  30101. "scroll-padding-block-start",
  30102. "scroll-padding-bottom",
  30103. "scroll-padding-inline",
  30104. "scroll-padding-inline-end",
  30105. "scroll-padding-inline-start",
  30106. "scroll-padding-left",
  30107. "scroll-padding-right",
  30108. "scroll-padding-top",
  30109. "scroll-snap-align",
  30110. "scroll-snap-stop",
  30111. "scroll-snap-type",
  30112. "scrollAmount",
  30113. "scrollBehavior",
  30114. "scrollBy",
  30115. "scrollByLines",
  30116. "scrollByPages",
  30117. "scrollDelay",
  30118. "scrollHeight",
  30119. "scrollIntoView",
  30120. "scrollIntoViewIfNeeded",
  30121. "scrollLeft",
  30122. "scrollLeftMax",
  30123. "scrollMargin",
  30124. "scrollMarginBlock",
  30125. "scrollMarginBlockEnd",
  30126. "scrollMarginBlockStart",
  30127. "scrollMarginBottom",
  30128. "scrollMarginInline",
  30129. "scrollMarginInlineEnd",
  30130. "scrollMarginInlineStart",
  30131. "scrollMarginLeft",
  30132. "scrollMarginRight",
  30133. "scrollMarginTop",
  30134. "scrollMaxX",
  30135. "scrollMaxY",
  30136. "scrollPadding",
  30137. "scrollPaddingBlock",
  30138. "scrollPaddingBlockEnd",
  30139. "scrollPaddingBlockStart",
  30140. "scrollPaddingBottom",
  30141. "scrollPaddingInline",
  30142. "scrollPaddingInlineEnd",
  30143. "scrollPaddingInlineStart",
  30144. "scrollPaddingLeft",
  30145. "scrollPaddingRight",
  30146. "scrollPaddingTop",
  30147. "scrollRestoration",
  30148. "scrollSnapAlign",
  30149. "scrollSnapStop",
  30150. "scrollSnapType",
  30151. "scrollTo",
  30152. "scrollTop",
  30153. "scrollTopMax",
  30154. "scrollWidth",
  30155. "scrollX",
  30156. "scrollY",
  30157. "scrollbar-color",
  30158. "scrollbar-gutter",
  30159. "scrollbar-width",
  30160. "scrollbar3dLightColor",
  30161. "scrollbarArrowColor",
  30162. "scrollbarBaseColor",
  30163. "scrollbarColor",
  30164. "scrollbarDarkShadowColor",
  30165. "scrollbarFaceColor",
  30166. "scrollbarGutter",
  30167. "scrollbarHighlightColor",
  30168. "scrollbarShadowColor",
  30169. "scrollbarTrackColor",
  30170. "scrollbarWidth",
  30171. "scrollbars",
  30172. "scrolling",
  30173. "scrollingElement",
  30174. "sctp",
  30175. "sctpCauseCode",
  30176. "sdp",
  30177. "sdpLineNumber",
  30178. "sdpMLineIndex",
  30179. "sdpMid",
  30180. "seal",
  30181. "search",
  30182. "searchBox",
  30183. "searchBoxJavaBridge_",
  30184. "searchParams",
  30185. "second",
  30186. "seconds",
  30187. "sectionRowIndex",
  30188. "secureConnectionStart",
  30189. "securePaymentConfirmationAvailability",
  30190. "security",
  30191. "seed",
  30192. "seek",
  30193. "seekToNextFrame",
  30194. "seekable",
  30195. "seeking",
  30196. "segments",
  30197. "select",
  30198. "selectAllChildren",
  30199. "selectAlternateInterface",
  30200. "selectAudioOutput",
  30201. "selectConfiguration",
  30202. "selectNode",
  30203. "selectNodeContents",
  30204. "selectNodes",
  30205. "selectSingleNode",
  30206. "selectSubString",
  30207. "selectURL",
  30208. "selected",
  30209. "selectedIndex",
  30210. "selectedOptions",
  30211. "selectedStyleSheetSet",
  30212. "selectedStylesheetSet",
  30213. "selectedTrack",
  30214. "selection",
  30215. "selectionDirection",
  30216. "selectionEnd",
  30217. "selectionStart",
  30218. "selector",
  30219. "selectorText",
  30220. "self",
  30221. "send",
  30222. "sendAsBinary",
  30223. "sendBeacon",
  30224. "sendFeatureReport",
  30225. "sendMessage",
  30226. "sendNativeMessage",
  30227. "sendOrder",
  30228. "sendReport",
  30229. "sender",
  30230. "sentAlert",
  30231. "sentTimestamp",
  30232. "separator",
  30233. "serial",
  30234. "serialNumber",
  30235. "serializable",
  30236. "serializeToString",
  30237. "serverTiming",
  30238. "service",
  30239. "serviceWorker",
  30240. "session",
  30241. "sessionId",
  30242. "sessionStorage",
  30243. "sessions",
  30244. "set",
  30245. "setActionHandler",
  30246. "setActive",
  30247. "setAlpha",
  30248. "setAppBadge",
  30249. "setAttribute",
  30250. "setAttributeNS",
  30251. "setAttributeNode",
  30252. "setAttributeNodeNS",
  30253. "setAttributionReporting",
  30254. "setBadgeBackgroundColor",
  30255. "setBadgeText",
  30256. "setBadgeTextColor",
  30257. "setBaseAndExtent",
  30258. "setBigInt64",
  30259. "setBigUint64",
  30260. "setBindGroup",
  30261. "setBingCurrentSearchDefault",
  30262. "setBlendConstant",
  30263. "setCameraActive",
  30264. "setCapture",
  30265. "setCaptureHandleConfig",
  30266. "setCodecPreferences",
  30267. "setColor",
  30268. "setCompositeOperation",
  30269. "setConfiguration",
  30270. "setConsumer",
  30271. "setCurrentTime",
  30272. "setCustomValidity",
  30273. "setData",
  30274. "setDate",
  30275. "setDragImage",
  30276. "setEnabled",
  30277. "setEnd",
  30278. "setEndAfter",
  30279. "setEndBefore",
  30280. "setEndPoint",
  30281. "setExpires",
  30282. "setFillColor",
  30283. "setFilterRes",
  30284. "setFloat16",
  30285. "setFloat32",
  30286. "setFloat64",
  30287. "setFloatValue",
  30288. "setFocusBehavior",
  30289. "setFormValue",
  30290. "setFromBase64",
  30291. "setFromHex",
  30292. "setFullYear",
  30293. "setHTMLUnsafe",
  30294. "setHeaderExtensionsToNegotiate",
  30295. "setHeaderValue",
  30296. "setHours",
  30297. "setIcon",
  30298. "setIdentityProvider",
  30299. "setImmediate",
  30300. "setIndexBuffer",
  30301. "setInt16",
  30302. "setInt32",
  30303. "setInt8",
  30304. "setInterval",
  30305. "setItem",
  30306. "setKeyframes",
  30307. "setLineCap",
  30308. "setLineDash",
  30309. "setLineJoin",
  30310. "setLineWidth",
  30311. "setLiveSeekableRange",
  30312. "setLocalDescription",
  30313. "setMatrix",
  30314. "setMatrixValue",
  30315. "setMediaKeys",
  30316. "setMicrophoneActive",
  30317. "setMilliseconds",
  30318. "setMinutes",
  30319. "setMiterLimit",
  30320. "setMonth",
  30321. "setNamedItem",
  30322. "setNamedItemNS",
  30323. "setNonUserCodeExceptions",
  30324. "setOrientToAngle",
  30325. "setOrientToAuto",
  30326. "setOrientation",
  30327. "setOverrideHistoryNavigationMode",
  30328. "setPaint",
  30329. "setParameter",
  30330. "setParameters",
  30331. "setPathData",
  30332. "setPeriodicWave",
  30333. "setPipeline",
  30334. "setPointerCapture",
  30335. "setPopup",
  30336. "setPosition",
  30337. "setPositionState",
  30338. "setPreference",
  30339. "setPriority",
  30340. "setPrivateToken",
  30341. "setProperty",
  30342. "setPrototypeOf",
  30343. "setRGBColor",
  30344. "setRGBColorICCColor",
  30345. "setRadius",
  30346. "setRangeText",
  30347. "setRemoteDescription",
  30348. "setReportEventDataForAutomaticBeacons",
  30349. "setRequestHeader",
  30350. "setResizable",
  30351. "setResourceTimingBufferSize",
  30352. "setRotate",
  30353. "setScale",
  30354. "setScissorRect",
  30355. "setSeconds",
  30356. "setSelectionRange",
  30357. "setServerCertificate",
  30358. "setShadow",
  30359. "setSharedStorageContext",
  30360. "setSignals",
  30361. "setSinkId",
  30362. "setSkewX",
  30363. "setSkewY",
  30364. "setStart",
  30365. "setStartAfter",
  30366. "setStartBefore",
  30367. "setStatus",
  30368. "setStdDeviation",
  30369. "setStencilReference",
  30370. "setStreams",
  30371. "setStrictMode",
  30372. "setStringValue",
  30373. "setStrokeColor",
  30374. "setSuggestResult",
  30375. "setTargetAtTime",
  30376. "setTargetValueAtTime",
  30377. "setTime",
  30378. "setTimeout",
  30379. "setTitle",
  30380. "setTransform",
  30381. "setTranslate",
  30382. "setUTCDate",
  30383. "setUTCFullYear",
  30384. "setUTCHours",
  30385. "setUTCMilliseconds",
  30386. "setUTCMinutes",
  30387. "setUTCMonth",
  30388. "setUTCSeconds",
  30389. "setUint16",
  30390. "setUint32",
  30391. "setUint8",
  30392. "setUninstallURL",
  30393. "setUpdateUrlData",
  30394. "setUri",
  30395. "setValidity",
  30396. "setValueAtTime",
  30397. "setValueCurveAtTime",
  30398. "setVariable",
  30399. "setVelocity",
  30400. "setVersion",
  30401. "setVertexBuffer",
  30402. "setViewport",
  30403. "setYear",
  30404. "setZoom",
  30405. "setZoomSettings",
  30406. "settingName",
  30407. "settingValue",
  30408. "sex",
  30409. "shaderLocation",
  30410. "shaderSource",
  30411. "shadowBlur",
  30412. "shadowColor",
  30413. "shadowOffsetX",
  30414. "shadowOffsetY",
  30415. "shadowRoot",
  30416. "shadowRootClonable",
  30417. "shadowRootDelegatesFocus",
  30418. "shadowRootMode",
  30419. "shadowRootSerializable",
  30420. "shape",
  30421. "shape-image-threshold",
  30422. "shape-margin",
  30423. "shape-outside",
  30424. "shape-rendering",
  30425. "shapeImageThreshold",
  30426. "shapeMargin",
  30427. "shapeOutside",
  30428. "shapeRendering",
  30429. "share",
  30430. "sharedContext",
  30431. "sharedStorage",
  30432. "sharedStorageWritable",
  30433. "sheet",
  30434. "shift",
  30435. "shiftKey",
  30436. "shiftLeft",
  30437. "shippingAddress",
  30438. "shippingOption",
  30439. "shippingType",
  30440. "show",
  30441. "showDirectoryPicker",
  30442. "showHelp",
  30443. "showModal",
  30444. "showModalDialog",
  30445. "showModelessDialog",
  30446. "showNotification",
  30447. "showOpenFilePicker",
  30448. "showPicker",
  30449. "showPopover",
  30450. "showSaveFilePicker",
  30451. "sidebar",
  30452. "sidebarAction",
  30453. "sign",
  30454. "signal",
  30455. "signalAllAcceptedCredentials",
  30456. "signalCurrentUserDetails",
  30457. "signalUnknownCredential",
  30458. "signalingState",
  30459. "signature",
  30460. "silent",
  30461. "sin",
  30462. "singleNodeValue",
  30463. "sinh",
  30464. "sinkId",
  30465. "sittingToStandingTransform",
  30466. "size",
  30467. "sizeAdjust",
  30468. "sizeToContent",
  30469. "sizeX",
  30470. "sizeZ",
  30471. "sizes",
  30472. "skewX",
  30473. "skewXSelf",
  30474. "skewY",
  30475. "skewYSelf",
  30476. "skipTransition",
  30477. "skipped",
  30478. "slice",
  30479. "slope",
  30480. "slot",
  30481. "slotAssignment",
  30482. "small",
  30483. "smil",
  30484. "smooth",
  30485. "smoothingTimeConstant",
  30486. "snapTargetBlock",
  30487. "snapTargetInline",
  30488. "snapToLines",
  30489. "snapshotItem",
  30490. "snapshotLength",
  30491. "some",
  30492. "sort",
  30493. "sortingCode",
  30494. "source",
  30495. "sourceBuffer",
  30496. "sourceBuffers",
  30497. "sourceCapabilities",
  30498. "sourceCharPosition",
  30499. "sourceElement",
  30500. "sourceFile",
  30501. "sourceFunctionName",
  30502. "sourceIndex",
  30503. "sourceLanguage",
  30504. "sourceMap",
  30505. "sourceURL",
  30506. "sources",
  30507. "spacing",
  30508. "span",
  30509. "speak",
  30510. "speakAs",
  30511. "speaking",
  30512. "species",
  30513. "specified",
  30514. "specularConstant",
  30515. "specularExponent",
  30516. "speechSynthesis",
  30517. "speed",
  30518. "speedOfSound",
  30519. "spellcheck",
  30520. "sphericalHarmonicsCoefficients",
  30521. "splice",
  30522. "split",
  30523. "splitText",
  30524. "spreadMethod",
  30525. "sqrt",
  30526. "src",
  30527. "srcElement",
  30528. "srcFactor",
  30529. "srcFilter",
  30530. "srcObject",
  30531. "srcUrn",
  30532. "srcdoc",
  30533. "srclang",
  30534. "srcset",
  30535. "stack",
  30536. "stackTraceLimit",
  30537. "stacktrace",
  30538. "stageParameters",
  30539. "standalone",
  30540. "standby",
  30541. "start",
  30542. "startContainer",
  30543. "startE",
  30544. "startIce",
  30545. "startLoadTime",
  30546. "startMessages",
  30547. "startNotifications",
  30548. "startOffset",
  30549. "startProfiling",
  30550. "startRendering",
  30551. "startShark",
  30552. "startTime",
  30553. "startViewTransition",
  30554. "startsWith",
  30555. "state",
  30556. "states",
  30557. "stats",
  30558. "status",
  30559. "statusCode",
  30560. "statusMessage",
  30561. "statusText",
  30562. "statusbar",
  30563. "stdDeviationX",
  30564. "stdDeviationY",
  30565. "stencilBack",
  30566. "stencilClearValue",
  30567. "stencilFront",
  30568. "stencilFunc",
  30569. "stencilFuncSeparate",
  30570. "stencilLoadOp",
  30571. "stencilMask",
  30572. "stencilMaskSeparate",
  30573. "stencilOp",
  30574. "stencilOpSeparate",
  30575. "stencilReadMask",
  30576. "stencilReadOnly",
  30577. "stencilStoreOp",
  30578. "stencilWriteMask",
  30579. "step",
  30580. "stepDown",
  30581. "stepMismatch",
  30582. "stepMode",
  30583. "stepUp",
  30584. "sticky",
  30585. "stitchTiles",
  30586. "stop",
  30587. "stop-color",
  30588. "stop-opacity",
  30589. "stopColor",
  30590. "stopImmediatePropagation",
  30591. "stopNotifications",
  30592. "stopOpacity",
  30593. "stopProfiling",
  30594. "stopPropagation",
  30595. "stopShark",
  30596. "stopped",
  30597. "storage",
  30598. "storageArea",
  30599. "storageBuckets",
  30600. "storageName",
  30601. "storageStatus",
  30602. "storageTexture",
  30603. "store",
  30604. "storeOp",
  30605. "storeSiteSpecificTrackingException",
  30606. "storeWebWideTrackingException",
  30607. "stpVersion",
  30608. "stream",
  30609. "streamErrorCode",
  30610. "streams",
  30611. "stretch",
  30612. "strike",
  30613. "string",
  30614. "stringValue",
  30615. "stringify",
  30616. "stripIndexFormat",
  30617. "stroke",
  30618. "stroke-dasharray",
  30619. "stroke-dashoffset",
  30620. "stroke-linecap",
  30621. "stroke-linejoin",
  30622. "stroke-miterlimit",
  30623. "stroke-opacity",
  30624. "stroke-width",
  30625. "strokeDasharray",
  30626. "strokeDashoffset",
  30627. "strokeLinecap",
  30628. "strokeLinejoin",
  30629. "strokeMiterlimit",
  30630. "strokeOpacity",
  30631. "strokeRect",
  30632. "strokeStyle",
  30633. "strokeText",
  30634. "strokeWidth",
  30635. "structuredClone",
  30636. "style",
  30637. "styleAndLayoutStart",
  30638. "styleFloat",
  30639. "styleMap",
  30640. "styleMedia",
  30641. "styleSheet",
  30642. "styleSheetSets",
  30643. "styleSheets",
  30644. "styleset",
  30645. "stylistic",
  30646. "sub",
  30647. "subarray",
  30648. "subgroupMaxSize",
  30649. "subgroupMinSize",
  30650. "subject",
  30651. "submit",
  30652. "submitFrame",
  30653. "submitter",
  30654. "subscribe",
  30655. "substr",
  30656. "substring",
  30657. "substringData",
  30658. "subtle",
  30659. "subtree",
  30660. "suffix",
  30661. "suffixes",
  30662. "sumPrecise",
  30663. "summarize",
  30664. "summarizeStreaming",
  30665. "summary",
  30666. "sup",
  30667. "supported",
  30668. "supportedContentEncodings",
  30669. "supportedEntryTypes",
  30670. "supportedValuesOf",
  30671. "supports",
  30672. "supportsFiber",
  30673. "supportsSession",
  30674. "supportsText",
  30675. "suppressed",
  30676. "surfaceScale",
  30677. "surroundContents",
  30678. "suspend",
  30679. "suspendRedraw",
  30680. "svb",
  30681. "svh",
  30682. "svi",
  30683. "svmax",
  30684. "svmin",
  30685. "svw",
  30686. "swapCache",
  30687. "swapNode",
  30688. "swash",
  30689. "sweepFlag",
  30690. "switchMap",
  30691. "symbols",
  30692. "symmetricDifference",
  30693. "sync",
  30694. "syntax",
  30695. "sysexEnabled",
  30696. "system",
  30697. "systemCode",
  30698. "systemId",
  30699. "systemLanguage",
  30700. "systemXDPI",
  30701. "systemYDPI",
  30702. "tBodies",
  30703. "tFoot",
  30704. "tHead",
  30705. "tab",
  30706. "tab-size",
  30707. "tabId",
  30708. "tabIds",
  30709. "tabIndex",
  30710. "tabSize",
  30711. "table",
  30712. "table-layout",
  30713. "tableLayout",
  30714. "tableValues",
  30715. "tabs",
  30716. "tag",
  30717. "tagName",
  30718. "tagUrn",
  30719. "tags",
  30720. "taintEnabled",
  30721. "take",
  30722. "takePhoto",
  30723. "takeRecords",
  30724. "takeUntil",
  30725. "tan",
  30726. "tangentialPressure",
  30727. "tanh",
  30728. "target",
  30729. "targetAddressSpace",
  30730. "targetElement",
  30731. "targetLanguage",
  30732. "targetRayMode",
  30733. "targetRaySpace",
  30734. "targetTouches",
  30735. "targetURL",
  30736. "targetX",
  30737. "targetY",
  30738. "targets",
  30739. "tcpType",
  30740. "tee",
  30741. "tel",
  30742. "telemetry",
  30743. "terminate",
  30744. "test",
  30745. "texImage2D",
  30746. "texImage3D",
  30747. "texParameterf",
  30748. "texParameteri",
  30749. "texStorage2D",
  30750. "texStorage3D",
  30751. "texSubImage2D",
  30752. "texSubImage3D",
  30753. "text",
  30754. "text-align",
  30755. "text-align-last",
  30756. "text-anchor",
  30757. "text-combine-upright",
  30758. "text-decoration",
  30759. "text-decoration-color",
  30760. "text-decoration-line",
  30761. "text-decoration-skip-ink",
  30762. "text-decoration-style",
  30763. "text-decoration-thickness",
  30764. "text-emphasis",
  30765. "text-emphasis-color",
  30766. "text-emphasis-position",
  30767. "text-emphasis-style",
  30768. "text-indent",
  30769. "text-justify",
  30770. "text-orientation",
  30771. "text-overflow",
  30772. "text-rendering",
  30773. "text-shadow",
  30774. "text-transform",
  30775. "text-underline-offset",
  30776. "text-underline-position",
  30777. "text-wrap",
  30778. "text-wrap-mode",
  30779. "text-wrap-style",
  30780. "textAlign",
  30781. "textAlignLast",
  30782. "textAnchor",
  30783. "textAutospace",
  30784. "textBaseline",
  30785. "textCombineUpright",
  30786. "textContent",
  30787. "textDecoration",
  30788. "textDecorationBlink",
  30789. "textDecorationColor",
  30790. "textDecorationInset",
  30791. "textDecorationLine",
  30792. "textDecorationLineThrough",
  30793. "textDecorationNone",
  30794. "textDecorationOverline",
  30795. "textDecorationSkipInk",
  30796. "textDecorationStyle",
  30797. "textDecorationThickness",
  30798. "textDecorationUnderline",
  30799. "textEmphasis",
  30800. "textEmphasisColor",
  30801. "textEmphasisPosition",
  30802. "textEmphasisStyle",
  30803. "textIndent",
  30804. "textJustify",
  30805. "textJustifyTrim",
  30806. "textKashida",
  30807. "textKashidaSpace",
  30808. "textLength",
  30809. "textOrientation",
  30810. "textOverflow",
  30811. "textRendering",
  30812. "textShadow",
  30813. "textTracks",
  30814. "textTransform",
  30815. "textUnderlineOffset",
  30816. "textUnderlinePosition",
  30817. "textWrap",
  30818. "textWrapMode",
  30819. "textWrapStyle",
  30820. "texture",
  30821. "theme",
  30822. "then",
  30823. "threadId",
  30824. "threshold",
  30825. "thresholds",
  30826. "throwIfAborted",
  30827. "tiltX",
  30828. "tiltY",
  30829. "time",
  30830. "timeEnd",
  30831. "timeLog",
  30832. "timeOrigin",
  30833. "timeRemaining",
  30834. "timeStamp",
  30835. "timeStyle",
  30836. "timeZone",
  30837. "timeZoneName",
  30838. "timecode",
  30839. "timeline",
  30840. "timelineTime",
  30841. "timeout",
  30842. "timestamp",
  30843. "timestampOffset",
  30844. "timestampWrites",
  30845. "timing",
  30846. "title",
  30847. "titlebarAreaRect",
  30848. "tlsChannelId",
  30849. "to",
  30850. "toArray",
  30851. "toBase64",
  30852. "toBlob",
  30853. "toDataURL",
  30854. "toDateString",
  30855. "toElement",
  30856. "toExponential",
  30857. "toFixed",
  30858. "toFloat32Array",
  30859. "toFloat64Array",
  30860. "toGMTString",
  30861. "toHex",
  30862. "toISOString",
  30863. "toJSON",
  30864. "toLocaleDateString",
  30865. "toLocaleFormat",
  30866. "toLocaleLowerCase",
  30867. "toLocaleString",
  30868. "toLocaleTimeString",
  30869. "toLocaleUpperCase",
  30870. "toLowerCase",
  30871. "toMatrix",
  30872. "toMethod",
  30873. "toPrecision",
  30874. "toPrimitive",
  30875. "toReversed",
  30876. "toSdp",
  30877. "toSorted",
  30878. "toSource",
  30879. "toSpliced",
  30880. "toStaticHTML",
  30881. "toString",
  30882. "toStringTag",
  30883. "toSum",
  30884. "toTemporalInstant",
  30885. "toTimeString",
  30886. "toUTCString",
  30887. "toUpperCase",
  30888. "toWellFormed",
  30889. "toggle",
  30890. "toggleAttribute",
  30891. "toggleLongPressEnabled",
  30892. "togglePopover",
  30893. "toggleReaderMode",
  30894. "token",
  30895. "tone",
  30896. "toneBuffer",
  30897. "tooLong",
  30898. "tooShort",
  30899. "toolbar",
  30900. "top",
  30901. "topMargin",
  30902. "topSites",
  30903. "topology",
  30904. "total",
  30905. "totalFrameDelay",
  30906. "totalFrames",
  30907. "totalFramesDuration",
  30908. "totalVideoFrames",
  30909. "touch-action",
  30910. "touchAction",
  30911. "touched",
  30912. "touches",
  30913. "trace",
  30914. "track",
  30915. "trackVisibility",
  30916. "trackedAnchors",
  30917. "tracks",
  30918. "tran",
  30919. "transaction",
  30920. "transactions",
  30921. "transceiver",
  30922. "transfer",
  30923. "transferControlToOffscreen",
  30924. "transferFromImageBitmap",
  30925. "transferImageBitmap",
  30926. "transferIn",
  30927. "transferOut",
  30928. "transferSize",
  30929. "transferToFixedLength",
  30930. "transferToImageBitmap",
  30931. "transform",
  30932. "transform-box",
  30933. "transform-origin",
  30934. "transform-style",
  30935. "transformBox",
  30936. "transformFeedbackVaryings",
  30937. "transformOrigin",
  30938. "transformPoint",
  30939. "transformString",
  30940. "transformStyle",
  30941. "transformToDocument",
  30942. "transformToFragment",
  30943. "transition",
  30944. "transition-behavior",
  30945. "transition-delay",
  30946. "transition-duration",
  30947. "transition-property",
  30948. "transition-timing-function",
  30949. "transitionBehavior",
  30950. "transitionDelay",
  30951. "transitionDuration",
  30952. "transitionProperty",
  30953. "transitionTimingFunction",
  30954. "translate",
  30955. "translateSelf",
  30956. "translateStreaming",
  30957. "translationX",
  30958. "translationY",
  30959. "transport",
  30960. "traverseTo",
  30961. "trim",
  30962. "trimEnd",
  30963. "trimLeft",
  30964. "trimRight",
  30965. "trimStart",
  30966. "trueSpeed",
  30967. "trunc",
  30968. "truncate",
  30969. "trustedTypes",
  30970. "try",
  30971. "turn",
  30972. "twist",
  30973. "type",
  30974. "typeDetail",
  30975. "typeMismatch",
  30976. "typeMustMatch",
  30977. "types",
  30978. "u2f",
  30979. "ubound",
  30980. "uint16",
  30981. "uint32",
  30982. "uint8",
  30983. "uint8Clamped",
  30984. "unadjustedMovement",
  30985. "unclippedDepth",
  30986. "unconfigure",
  30987. "undefined",
  30988. "underlineStyle",
  30989. "underlineThickness",
  30990. "unescape",
  30991. "uneval",
  30992. "ungroup",
  30993. "unicode",
  30994. "unicode-bidi",
  30995. "unicodeBidi",
  30996. "unicodeRange",
  30997. "unicodeSets",
  30998. "uniform1f",
  30999. "uniform1fv",
  31000. "uniform1i",
  31001. "uniform1iv",
  31002. "uniform1ui",
  31003. "uniform1uiv",
  31004. "uniform2f",
  31005. "uniform2fv",
  31006. "uniform2i",
  31007. "uniform2iv",
  31008. "uniform2ui",
  31009. "uniform2uiv",
  31010. "uniform3f",
  31011. "uniform3fv",
  31012. "uniform3i",
  31013. "uniform3iv",
  31014. "uniform3ui",
  31015. "uniform3uiv",
  31016. "uniform4f",
  31017. "uniform4fv",
  31018. "uniform4i",
  31019. "uniform4iv",
  31020. "uniform4ui",
  31021. "uniform4uiv",
  31022. "uniformBlockBinding",
  31023. "uniformMatrix2fv",
  31024. "uniformMatrix2x3fv",
  31025. "uniformMatrix2x4fv",
  31026. "uniformMatrix3fv",
  31027. "uniformMatrix3x2fv",
  31028. "uniformMatrix3x4fv",
  31029. "uniformMatrix4fv",
  31030. "uniformMatrix4x2fv",
  31031. "uniformMatrix4x3fv",
  31032. "uninstallSelf",
  31033. "union",
  31034. "unique",
  31035. "uniqueID",
  31036. "uniqueNumber",
  31037. "unit",
  31038. "unitType",
  31039. "units",
  31040. "unloadEventEnd",
  31041. "unloadEventStart",
  31042. "unlock",
  31043. "unmap",
  31044. "unmount",
  31045. "unobserve",
  31046. "unpackColorSpace",
  31047. "unpause",
  31048. "unpauseAnimations",
  31049. "unreadCount",
  31050. "unregister",
  31051. "unregisterContentHandler",
  31052. "unregisterProtocolHandler",
  31053. "unscopables",
  31054. "unselectable",
  31055. "unshift",
  31056. "unsubscribe",
  31057. "unsuspendRedraw",
  31058. "unsuspendRedrawAll",
  31059. "unwatch",
  31060. "unwrapKey",
  31061. "upDegrees",
  31062. "upX",
  31063. "upY",
  31064. "upZ",
  31065. "update",
  31066. "updateAdInterestGroups",
  31067. "updateCallbackDone",
  31068. "updateCharacterBounds",
  31069. "updateCommands",
  31070. "updateControlBounds",
  31071. "updateCurrentEntry",
  31072. "updateIce",
  31073. "updateInkTrailStartPoint",
  31074. "updateInterval",
  31075. "updatePlaybackRate",
  31076. "updateRangeEnd",
  31077. "updateRangeStart",
  31078. "updateRenderState",
  31079. "updateSelection",
  31080. "updateSelectionBounds",
  31081. "updateSettings",
  31082. "updateText",
  31083. "updateTiming",
  31084. "updateViaCache",
  31085. "updateWith",
  31086. "updated",
  31087. "updating",
  31088. "upgrade",
  31089. "upload",
  31090. "uploadTotal",
  31091. "uploaded",
  31092. "upper",
  31093. "upperBound",
  31094. "upperOpen",
  31095. "uri",
  31096. "url",
  31097. "urn",
  31098. "urns",
  31099. "usage",
  31100. "usages",
  31101. "usb",
  31102. "usbVersionMajor",
  31103. "usbVersionMinor",
  31104. "usbVersionSubminor",
  31105. "use",
  31106. "useCurrentView",
  31107. "useMap",
  31108. "useProgram",
  31109. "usedSpace",
  31110. "user-select",
  31111. "userActivation",
  31112. "userAgent",
  31113. "userAgentAllowsProtocol",
  31114. "userAgentData",
  31115. "userChoice",
  31116. "userHandle",
  31117. "userHint",
  31118. "userInitiated",
  31119. "userLanguage",
  31120. "userSelect",
  31121. "userState",
  31122. "userVisibleOnly",
  31123. "username",
  31124. "usernameFragment",
  31125. "utterance",
  31126. "uuid",
  31127. "v8BreakIterator",
  31128. "vAlign",
  31129. "vLink",
  31130. "valid",
  31131. "validate",
  31132. "validateProgram",
  31133. "validationMessage",
  31134. "validity",
  31135. "value",
  31136. "valueAsDate",
  31137. "valueAsNumber",
  31138. "valueAsString",
  31139. "valueInSpecifiedUnits",
  31140. "valueMissing",
  31141. "valueOf",
  31142. "valueText",
  31143. "valueType",
  31144. "values",
  31145. "variable",
  31146. "variant",
  31147. "variationSettings",
  31148. "vb",
  31149. "vector-effect",
  31150. "vectorEffect",
  31151. "velocityAngular",
  31152. "velocityExpansion",
  31153. "velocityX",
  31154. "velocityY",
  31155. "vendor",
  31156. "vendorId",
  31157. "vendorSub",
  31158. "verify",
  31159. "version",
  31160. "vertex",
  31161. "vertexAttrib1f",
  31162. "vertexAttrib1fv",
  31163. "vertexAttrib2f",
  31164. "vertexAttrib2fv",
  31165. "vertexAttrib3f",
  31166. "vertexAttrib3fv",
  31167. "vertexAttrib4f",
  31168. "vertexAttrib4fv",
  31169. "vertexAttribDivisor",
  31170. "vertexAttribDivisorANGLE",
  31171. "vertexAttribI4i",
  31172. "vertexAttribI4iv",
  31173. "vertexAttribI4ui",
  31174. "vertexAttribI4uiv",
  31175. "vertexAttribIPointer",
  31176. "vertexAttribPointer",
  31177. "vertical",
  31178. "vertical-align",
  31179. "verticalAlign",
  31180. "verticalOverflow",
  31181. "vh",
  31182. "vi",
  31183. "vibrate",
  31184. "vibrationActuator",
  31185. "videoBitsPerSecond",
  31186. "videoHeight",
  31187. "videoTracks",
  31188. "videoWidth",
  31189. "view",
  31190. "viewBox",
  31191. "viewBoxString",
  31192. "viewDimension",
  31193. "viewFormats",
  31194. "viewTarget",
  31195. "viewTargetString",
  31196. "viewTransition",
  31197. "viewTransitionClass",
  31198. "viewTransitionName",
  31199. "viewport",
  31200. "viewportAnchorX",
  31201. "viewportAnchorY",
  31202. "viewportElement",
  31203. "views",
  31204. "violatedDirective",
  31205. "virtualKeyboard",
  31206. "virtualKeyboardPolicy",
  31207. "visibility",
  31208. "visibilityState",
  31209. "visible",
  31210. "visibleRect",
  31211. "visualViewport",
  31212. "vlinkColor",
  31213. "vmax",
  31214. "vmin",
  31215. "voice",
  31216. "voiceURI",
  31217. "volume",
  31218. "vrml",
  31219. "vspace",
  31220. "vw",
  31221. "w",
  31222. "wait",
  31223. "waitAsync",
  31224. "waitSync",
  31225. "waiting",
  31226. "wake",
  31227. "wakeLock",
  31228. "wand",
  31229. "warmup",
  31230. "warn",
  31231. "wasAlternateProtocolAvailable",
  31232. "wasClean",
  31233. "wasDiscarded",
  31234. "wasFetchedViaSpdy",
  31235. "wasNpnNegotiated",
  31236. "watch",
  31237. "watchAvailability",
  31238. "watchPosition",
  31239. "webNavigation",
  31240. "webRequest",
  31241. "webdriver",
  31242. "webkitAddKey",
  31243. "webkitAlignContent",
  31244. "webkitAlignItems",
  31245. "webkitAlignSelf",
  31246. "webkitAnimation",
  31247. "webkitAnimationDelay",
  31248. "webkitAnimationDirection",
  31249. "webkitAnimationDuration",
  31250. "webkitAnimationFillMode",
  31251. "webkitAnimationIterationCount",
  31252. "webkitAnimationName",
  31253. "webkitAnimationPlayState",
  31254. "webkitAnimationTimingFunction",
  31255. "webkitAppearance",
  31256. "webkitAudioContext",
  31257. "webkitAudioDecodedByteCount",
  31258. "webkitAudioPannerNode",
  31259. "webkitBackfaceVisibility",
  31260. "webkitBackground",
  31261. "webkitBackgroundAttachment",
  31262. "webkitBackgroundClip",
  31263. "webkitBackgroundColor",
  31264. "webkitBackgroundImage",
  31265. "webkitBackgroundOrigin",
  31266. "webkitBackgroundPosition",
  31267. "webkitBackgroundPositionX",
  31268. "webkitBackgroundPositionY",
  31269. "webkitBackgroundRepeat",
  31270. "webkitBackgroundSize",
  31271. "webkitBackingStorePixelRatio",
  31272. "webkitBorderBottomLeftRadius",
  31273. "webkitBorderBottomRightRadius",
  31274. "webkitBorderImage",
  31275. "webkitBorderImageOutset",
  31276. "webkitBorderImageRepeat",
  31277. "webkitBorderImageSlice",
  31278. "webkitBorderImageSource",
  31279. "webkitBorderImageWidth",
  31280. "webkitBorderRadius",
  31281. "webkitBorderTopLeftRadius",
  31282. "webkitBorderTopRightRadius",
  31283. "webkitBoxAlign",
  31284. "webkitBoxDirection",
  31285. "webkitBoxFlex",
  31286. "webkitBoxOrdinalGroup",
  31287. "webkitBoxOrient",
  31288. "webkitBoxPack",
  31289. "webkitBoxShadow",
  31290. "webkitBoxSizing",
  31291. "webkitCancelAnimationFrame",
  31292. "webkitCancelFullScreen",
  31293. "webkitCancelKeyRequest",
  31294. "webkitCancelRequestAnimationFrame",
  31295. "webkitClearResourceTimings",
  31296. "webkitClipPath",
  31297. "webkitClosedCaptionsVisible",
  31298. "webkitConvertPointFromNodeToPage",
  31299. "webkitConvertPointFromPageToNode",
  31300. "webkitCreateShadowRoot",
  31301. "webkitCurrentFullScreenElement",
  31302. "webkitCurrentPlaybackTargetIsWireless",
  31303. "webkitDecodedFrameCount",
  31304. "webkitDirectionInvertedFromDevice",
  31305. "webkitDisplayingFullscreen",
  31306. "webkitDroppedFrameCount",
  31307. "webkitEnterFullScreen",
  31308. "webkitEnterFullscreen",
  31309. "webkitEntries",
  31310. "webkitExitFullScreen",
  31311. "webkitExitFullscreen",
  31312. "webkitExitPointerLock",
  31313. "webkitFilter",
  31314. "webkitFlex",
  31315. "webkitFlexBasis",
  31316. "webkitFlexDirection",
  31317. "webkitFlexFlow",
  31318. "webkitFlexGrow",
  31319. "webkitFlexShrink",
  31320. "webkitFlexWrap",
  31321. "webkitFontFeatureSettings",
  31322. "webkitFullScreenKeyboardInputAllowed",
  31323. "webkitFullscreenElement",
  31324. "webkitFullscreenEnabled",
  31325. "webkitGenerateKeyRequest",
  31326. "webkitGetAsEntry",
  31327. "webkitGetDatabaseNames",
  31328. "webkitGetEntries",
  31329. "webkitGetEntriesByName",
  31330. "webkitGetEntriesByType",
  31331. "webkitGetFlowByName",
  31332. "webkitGetGamepads",
  31333. "webkitGetImageDataHD",
  31334. "webkitGetNamedFlows",
  31335. "webkitGetRegionFlowRanges",
  31336. "webkitGetUserMedia",
  31337. "webkitHasClosedCaptions",
  31338. "webkitHidden",
  31339. "webkitIDBCursor",
  31340. "webkitIDBDatabase",
  31341. "webkitIDBDatabaseError",
  31342. "webkitIDBDatabaseException",
  31343. "webkitIDBFactory",
  31344. "webkitIDBIndex",
  31345. "webkitIDBKeyRange",
  31346. "webkitIDBObjectStore",
  31347. "webkitIDBRequest",
  31348. "webkitIDBTransaction",
  31349. "webkitImageSmoothingEnabled",
  31350. "webkitIndexedDB",
  31351. "webkitInitMessageEvent",
  31352. "webkitIsFullScreen",
  31353. "webkitJustifyContent",
  31354. "webkitKeys",
  31355. "webkitLineClamp",
  31356. "webkitLineDashOffset",
  31357. "webkitLockOrientation",
  31358. "webkitMask",
  31359. "webkitMaskClip",
  31360. "webkitMaskComposite",
  31361. "webkitMaskImage",
  31362. "webkitMaskOrigin",
  31363. "webkitMaskPosition",
  31364. "webkitMaskPositionX",
  31365. "webkitMaskPositionY",
  31366. "webkitMaskRepeat",
  31367. "webkitMaskSize",
  31368. "webkitMatchesSelector",
  31369. "webkitMediaStream",
  31370. "webkitNotifications",
  31371. "webkitOfflineAudioContext",
  31372. "webkitOrder",
  31373. "webkitOrientation",
  31374. "webkitPeerConnection00",
  31375. "webkitPersistentStorage",
  31376. "webkitPerspective",
  31377. "webkitPerspectiveOrigin",
  31378. "webkitPointerLockElement",
  31379. "webkitPostMessage",
  31380. "webkitPreservesPitch",
  31381. "webkitPutImageDataHD",
  31382. "webkitRTCPeerConnection",
  31383. "webkitRegionOverset",
  31384. "webkitRelativePath",
  31385. "webkitRequestAnimationFrame",
  31386. "webkitRequestFileSystem",
  31387. "webkitRequestFullScreen",
  31388. "webkitRequestFullscreen",
  31389. "webkitRequestPointerLock",
  31390. "webkitResolveLocalFileSystemURL",
  31391. "webkitSetMediaKeys",
  31392. "webkitSetResourceTimingBufferSize",
  31393. "webkitShadowRoot",
  31394. "webkitShowPlaybackTargetPicker",
  31395. "webkitSlice",
  31396. "webkitSpeechGrammar",
  31397. "webkitSpeechGrammarList",
  31398. "webkitSpeechRecognition",
  31399. "webkitSpeechRecognitionError",
  31400. "webkitSpeechRecognitionEvent",
  31401. "webkitStorageInfo",
  31402. "webkitSupportsFullscreen",
  31403. "webkitTemporaryStorage",
  31404. "webkitTextFillColor",
  31405. "webkitTextSecurity",
  31406. "webkitTextSizeAdjust",
  31407. "webkitTextStroke",
  31408. "webkitTextStrokeColor",
  31409. "webkitTextStrokeWidth",
  31410. "webkitTransform",
  31411. "webkitTransformOrigin",
  31412. "webkitTransformStyle",
  31413. "webkitTransition",
  31414. "webkitTransitionDelay",
  31415. "webkitTransitionDuration",
  31416. "webkitTransitionProperty",
  31417. "webkitTransitionTimingFunction",
  31418. "webkitURL",
  31419. "webkitUnlockOrientation",
  31420. "webkitUserSelect",
  31421. "webkitVideoDecodedByteCount",
  31422. "webkitVisibilityState",
  31423. "webkitWirelessVideoPlaybackDisabled",
  31424. "webkitdirectory",
  31425. "webkitdropzone",
  31426. "webstore",
  31427. "weekday",
  31428. "weeks",
  31429. "weight",
  31430. "wgslLanguageFeatures",
  31431. "whatToShow",
  31432. "wheelDelta",
  31433. "wheelDeltaX",
  31434. "wheelDeltaY",
  31435. "when",
  31436. "whenDefined",
  31437. "which",
  31438. "white-space",
  31439. "white-space-collapse",
  31440. "whiteSpace",
  31441. "whiteSpaceCollapse",
  31442. "wholeText",
  31443. "widows",
  31444. "width",
  31445. "will-change",
  31446. "willChange",
  31447. "willValidate",
  31448. "window",
  31449. "windowAttribution",
  31450. "windowControlsOverlay",
  31451. "windowId",
  31452. "windowIds",
  31453. "windows",
  31454. "with",
  31455. "withCredentials",
  31456. "withResolvers",
  31457. "word-break",
  31458. "word-spacing",
  31459. "word-wrap",
  31460. "wordBreak",
  31461. "wordSpacing",
  31462. "wordWrap",
  31463. "workerCacheLookupStart",
  31464. "workerFinalSourceType",
  31465. "workerMatchedSourceType",
  31466. "workerRouterEvaluationStart",
  31467. "workerStart",
  31468. "worklet",
  31469. "wow64",
  31470. "wrap",
  31471. "wrapKey",
  31472. "writable",
  31473. "writableAuxiliaries",
  31474. "write",
  31475. "writeBuffer",
  31476. "writeMask",
  31477. "writeText",
  31478. "writeTexture",
  31479. "writeTimestamp",
  31480. "writeValue",
  31481. "writeValueWithResponse",
  31482. "writeValueWithoutResponse",
  31483. "writeWithoutResponse",
  31484. "writeln",
  31485. "writing-mode",
  31486. "writingMode",
  31487. "writingSuggestions",
  31488. "x",
  31489. "x1",
  31490. "x2",
  31491. "xChannelSelector",
  31492. "xmlEncoding",
  31493. "xmlStandalone",
  31494. "xmlVersion",
  31495. "xmlbase",
  31496. "xmllang",
  31497. "xmlspace",
  31498. "xor",
  31499. "xr",
  31500. "y",
  31501. "y1",
  31502. "y2",
  31503. "yChannelSelector",
  31504. "yandex",
  31505. "year",
  31506. "years",
  31507. "yield",
  31508. "z",
  31509. "z-index",
  31510. "zIndex",
  31511. "zoom",
  31512. "zoomAndPan",
  31513. "zoomLevel",
  31514. "zoomRectScreen",
  31515. ];
  31516. /***********************************************************************
  31517. A JavaScript tokenizer / parser / beautifier / compressor.
  31518. https://github.com/mishoo/UglifyJS2
  31519. -------------------------------- (C) ---------------------------------
  31520. Author: Mihai Bazon
  31521. <mihai.bazon@gmail.com>
  31522. http://mihai.bazon.net/blog
  31523. Distributed under the BSD license:
  31524. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  31525. Redistribution and use in source and binary forms, with or without
  31526. modification, are permitted provided that the following conditions
  31527. are met:
  31528. * Redistributions of source code must retain the above
  31529. copyright notice, this list of conditions and the following
  31530. disclaimer.
  31531. * Redistributions in binary form must reproduce the above
  31532. copyright notice, this list of conditions and the following
  31533. disclaimer in the documentation and/or other materials
  31534. provided with the distribution.
  31535. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  31536. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31537. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  31538. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  31539. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  31540. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  31541. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  31542. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31543. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  31544. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31545. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31546. SUCH DAMAGE.
  31547. ***********************************************************************/
  31548. function find_builtins(reserved) {
  31549. domprops.forEach(add);
  31550. // Compatibility fix for some standard defined globals not defined on every js environment
  31551. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  31552. var objects = {};
  31553. var global_ref = typeof global === "object" ? global : self;
  31554. new_globals.forEach(function (new_global) {
  31555. objects[new_global] = global_ref[new_global] || function() {};
  31556. });
  31557. [
  31558. "null",
  31559. "true",
  31560. "false",
  31561. "NaN",
  31562. "Infinity",
  31563. "-Infinity",
  31564. "undefined",
  31565. ].forEach(add);
  31566. [ Object, Array, Function, Number,
  31567. String, Boolean, Error, Math,
  31568. Date, RegExp, objects.Symbol, ArrayBuffer,
  31569. DataView, decodeURI, decodeURIComponent,
  31570. encodeURI, encodeURIComponent, eval, EvalError,
  31571. Float32Array, Float64Array, Int8Array, Int16Array,
  31572. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  31573. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  31574. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  31575. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  31576. objects.WeakMap, objects.WeakSet
  31577. ].forEach(function(ctor) {
  31578. Object.getOwnPropertyNames(ctor).map(add);
  31579. if (ctor.prototype) {
  31580. Object.getOwnPropertyNames(ctor.prototype).map(add);
  31581. }
  31582. });
  31583. function add(name) {
  31584. reserved.add(name);
  31585. }
  31586. }
  31587. function reserve_quoted_keys(ast, reserved) {
  31588. function add(name) {
  31589. push_uniq(reserved, name);
  31590. }
  31591. ast.walk(new TreeWalker(function(node) {
  31592. if (node instanceof AST_ObjectKeyVal && node.quote) {
  31593. add(node.key);
  31594. } else if (node instanceof AST_ObjectProperty && node.quote) {
  31595. add(node.key.name);
  31596. } else if (node instanceof AST_Sub) {
  31597. addStrings(node.property, add);
  31598. }
  31599. }));
  31600. }
  31601. function addStrings(node, add) {
  31602. node.walk(new TreeWalker(function(node) {
  31603. if (node instanceof AST_Sequence) {
  31604. addStrings(node.tail_node(), add);
  31605. } else if (node instanceof AST_String) {
  31606. add(node.value);
  31607. } else if (node instanceof AST_Conditional) {
  31608. addStrings(node.consequent, add);
  31609. addStrings(node.alternative, add);
  31610. }
  31611. return true;
  31612. }));
  31613. }
  31614. function mangle_private_properties(ast, options) {
  31615. var cprivate = -1;
  31616. var private_cache = new Map();
  31617. var nth_identifier = options.nth_identifier || base54;
  31618. ast = ast.transform(new TreeTransformer(function(node) {
  31619. if (
  31620. node instanceof AST_ClassPrivateProperty
  31621. || node instanceof AST_PrivateMethod
  31622. || node instanceof AST_PrivateGetter
  31623. || node instanceof AST_PrivateSetter
  31624. || node instanceof AST_PrivateIn
  31625. ) {
  31626. node.key.name = mangle_private(node.key.name);
  31627. } else if (node instanceof AST_DotHash) {
  31628. node.property = mangle_private(node.property);
  31629. }
  31630. }));
  31631. return ast;
  31632. function mangle_private(name) {
  31633. let mangled = private_cache.get(name);
  31634. if (!mangled) {
  31635. mangled = nth_identifier.get(++cprivate);
  31636. private_cache.set(name, mangled);
  31637. }
  31638. return mangled;
  31639. }
  31640. }
  31641. function find_annotated_props(ast) {
  31642. var annotated_props = new Set();
  31643. walk(ast, node => {
  31644. if (
  31645. node instanceof AST_ClassPrivateProperty
  31646. || node instanceof AST_PrivateMethod
  31647. || node instanceof AST_PrivateGetter
  31648. || node instanceof AST_PrivateSetter
  31649. || node instanceof AST_DotHash
  31650. ) ; else if (node instanceof AST_ObjectKeyVal) {
  31651. if (typeof node.key == "string" && has_annotation(node, _MANGLEPROP)) {
  31652. annotated_props.add(node.key);
  31653. }
  31654. } else if (node instanceof AST_ObjectProperty) {
  31655. // setter or getter, since KeyVal is handled above
  31656. if (has_annotation(node, _MANGLEPROP)) {
  31657. annotated_props.add(node.key.name);
  31658. }
  31659. } else if (node instanceof AST_Dot) {
  31660. if (has_annotation(node, _MANGLEPROP)) {
  31661. annotated_props.add(node.property);
  31662. }
  31663. } else if (node instanceof AST_Sub) {
  31664. if (node.property instanceof AST_String && has_annotation(node, _MANGLEPROP)) {
  31665. annotated_props.add(node.property.value);
  31666. }
  31667. }
  31668. });
  31669. return annotated_props;
  31670. }
  31671. function mangle_properties(ast, options, annotated_props = find_annotated_props(ast)) {
  31672. options = defaults(options, {
  31673. builtins: false,
  31674. cache: null,
  31675. debug: false,
  31676. keep_quoted: false,
  31677. nth_identifier: base54,
  31678. only_cache: false,
  31679. regex: null,
  31680. reserved: null,
  31681. undeclared: false,
  31682. only_annotated: false,
  31683. }, true);
  31684. var nth_identifier = options.nth_identifier;
  31685. var reserved_option = options.reserved;
  31686. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  31687. var reserved = new Set(reserved_option);
  31688. if (!options.builtins) find_builtins(reserved);
  31689. var cname = -1;
  31690. var cache;
  31691. if (options.cache) {
  31692. cache = options.cache.props;
  31693. } else {
  31694. cache = new Map();
  31695. }
  31696. var only_annotated = options.only_annotated;
  31697. var regex = options.regex && new RegExp(options.regex);
  31698. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  31699. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  31700. // the same as passing an empty string.
  31701. var debug = options.debug !== false;
  31702. var debug_name_suffix;
  31703. if (debug) {
  31704. debug_name_suffix = (options.debug === true ? "" : options.debug);
  31705. }
  31706. var names_to_mangle = new Set();
  31707. var unmangleable = new Set();
  31708. // Track each already-mangled name to prevent nth_identifier from generating
  31709. // the same name.
  31710. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  31711. var keep_quoted = !!options.keep_quoted;
  31712. // step 1: find candidates to mangle
  31713. ast.walk(new TreeWalker(function(node) {
  31714. if (
  31715. node instanceof AST_ClassPrivateProperty
  31716. || node instanceof AST_PrivateMethod
  31717. || node instanceof AST_PrivateGetter
  31718. || node instanceof AST_PrivateSetter
  31719. || node instanceof AST_DotHash
  31720. ) ; else if (node instanceof AST_ObjectKeyVal) {
  31721. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  31722. add(node.key);
  31723. }
  31724. } else if (node instanceof AST_ObjectProperty) {
  31725. // setter or getter, since KeyVal is handled above
  31726. if (!keep_quoted || !node.quote) {
  31727. add(node.key.name);
  31728. }
  31729. } else if (node instanceof AST_Dot) {
  31730. var declared = !!options.undeclared;
  31731. if (!declared) {
  31732. var root = node;
  31733. while (root.expression) {
  31734. root = root.expression;
  31735. }
  31736. declared = !(root.thedef && root.thedef.undeclared);
  31737. }
  31738. if (declared &&
  31739. (!keep_quoted || !node.quote)) {
  31740. add(node.property);
  31741. }
  31742. } else if (node instanceof AST_Sub) {
  31743. if (!keep_quoted) {
  31744. addStrings(node.property, add);
  31745. }
  31746. } else if (node instanceof AST_Call
  31747. && node.expression.print_to_string() == "Object.defineProperty") {
  31748. addStrings(node.args[1], add);
  31749. } else if (node instanceof AST_Binary && node.operator === "in") {
  31750. addStrings(node.left, add);
  31751. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  31752. add(node.value);
  31753. }
  31754. }));
  31755. // step 2: transform the tree, renaming properties
  31756. return ast.transform(new TreeTransformer(function(node) {
  31757. if (
  31758. node instanceof AST_ClassPrivateProperty
  31759. || node instanceof AST_PrivateMethod
  31760. || node instanceof AST_PrivateGetter
  31761. || node instanceof AST_PrivateSetter
  31762. || node instanceof AST_DotHash
  31763. ) ; else if (node instanceof AST_ObjectKeyVal) {
  31764. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  31765. node.key = mangle(node.key);
  31766. }
  31767. } else if (node instanceof AST_ObjectProperty) {
  31768. // setter, getter, method or class field
  31769. if (!keep_quoted || !node.quote) {
  31770. if (!node.computed_key()) {
  31771. node.key.name = mangle(node.key.name);
  31772. }
  31773. }
  31774. } else if (node instanceof AST_Dot) {
  31775. if (!keep_quoted || !node.quote) {
  31776. node.property = mangle(node.property);
  31777. }
  31778. } else if (!keep_quoted && node instanceof AST_Sub) {
  31779. node.property = mangleStrings(node.property);
  31780. } else if (node instanceof AST_Call
  31781. && node.expression.print_to_string() == "Object.defineProperty") {
  31782. node.args[1] = mangleStrings(node.args[1]);
  31783. } else if (node instanceof AST_Binary && node.operator === "in") {
  31784. node.left = mangleStrings(node.left);
  31785. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  31786. // Clear _KEY annotation to prevent double mangling
  31787. clear_annotation(node, _KEY);
  31788. node.value = mangle(node.value);
  31789. }
  31790. }));
  31791. // only function declarations after this line
  31792. function can_mangle(name) {
  31793. if (unmangleable.has(name)) return false;
  31794. if (reserved.has(name)) return false;
  31795. if (options.only_cache) {
  31796. return cache.has(name);
  31797. }
  31798. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  31799. return true;
  31800. }
  31801. function should_mangle(name) {
  31802. if (only_annotated && !annotated_props.has(name)) return false;
  31803. if (regex && !regex.test(name)) {
  31804. return annotated_props.has(name);
  31805. }
  31806. if (reserved.has(name)) return false;
  31807. return cache.has(name)
  31808. || names_to_mangle.has(name);
  31809. }
  31810. function add(name) {
  31811. if (can_mangle(name)) {
  31812. names_to_mangle.add(name);
  31813. }
  31814. if (!should_mangle(name)) {
  31815. unmangleable.add(name);
  31816. }
  31817. }
  31818. function mangle(name) {
  31819. if (!should_mangle(name)) {
  31820. return name;
  31821. }
  31822. var mangled = cache.get(name);
  31823. if (!mangled) {
  31824. if (debug) {
  31825. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  31826. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  31827. if (can_mangle(debug_mangled)) {
  31828. mangled = debug_mangled;
  31829. }
  31830. }
  31831. // either debug mode is off, or it is on and we could not use the mangled name
  31832. if (!mangled) {
  31833. do {
  31834. mangled = nth_identifier.get(++cname);
  31835. } while (!can_mangle(mangled));
  31836. }
  31837. cache.set(name, mangled);
  31838. }
  31839. return mangled;
  31840. }
  31841. function mangleStrings(node) {
  31842. return node.transform(new TreeTransformer(function(node) {
  31843. if (node instanceof AST_Sequence) {
  31844. var last = node.expressions.length - 1;
  31845. node.expressions[last] = mangleStrings(node.expressions[last]);
  31846. } else if (node instanceof AST_String) {
  31847. // Clear _KEY annotation to prevent double mangling
  31848. clear_annotation(node, _KEY);
  31849. node.value = mangle(node.value);
  31850. } else if (node instanceof AST_Conditional) {
  31851. node.consequent = mangleStrings(node.consequent);
  31852. node.alternative = mangleStrings(node.alternative);
  31853. }
  31854. return node;
  31855. }));
  31856. }
  31857. }
  31858. // to/from base64 functions
  31859. // Prefer built-in Buffer, if available, then use hack
  31860. // https://developer.mozilla.org/en-US/docs/Glossary/Base64#The_Unicode_Problem
  31861. var to_ascii = typeof Buffer !== "undefined"
  31862. ? (b64) => Buffer.from(b64, "base64").toString()
  31863. : (b64) => decodeURIComponent(escape(atob(b64)));
  31864. var to_base64 = typeof Buffer !== "undefined"
  31865. ? (str) => Buffer.from(str).toString("base64")
  31866. : (str) => btoa(unescape(encodeURIComponent(str)));
  31867. function read_source_map(code) {
  31868. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  31869. if (!match) {
  31870. console.warn("inline source map not found");
  31871. return null;
  31872. }
  31873. return to_ascii(match[2]);
  31874. }
  31875. function set_shorthand(name, options, keys) {
  31876. if (options[name]) {
  31877. keys.forEach(function(key) {
  31878. if (options[key]) {
  31879. if (typeof options[key] != "object") options[key] = {};
  31880. if (!(name in options[key])) options[key][name] = options[name];
  31881. }
  31882. });
  31883. }
  31884. }
  31885. function init_cache(cache) {
  31886. if (!cache) return;
  31887. if (!("props" in cache)) {
  31888. cache.props = new Map();
  31889. } else if (!(cache.props instanceof Map)) {
  31890. cache.props = map_from_object(cache.props);
  31891. }
  31892. }
  31893. function cache_to_json(cache) {
  31894. return {
  31895. props: map_to_object(cache.props)
  31896. };
  31897. }
  31898. function log_input(files, options, fs, debug_folder) {
  31899. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  31900. return;
  31901. }
  31902. try {
  31903. fs.mkdirSync(debug_folder);
  31904. } catch (e) {
  31905. if (e.code !== "EEXIST") throw e;
  31906. }
  31907. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  31908. options = options || {};
  31909. const options_str = JSON.stringify(options, (_key, thing) => {
  31910. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  31911. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  31912. return thing;
  31913. }, 4);
  31914. const files_str = (file) => {
  31915. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  31916. return JSON.stringify(file, null, 2);
  31917. } else if (typeof file === "object") {
  31918. return Object.keys(file)
  31919. .map((key) => key + ": " + files_str(file[key]))
  31920. .join("\n\n");
  31921. } else if (typeof file === "string") {
  31922. return "```\n" + file + "\n```";
  31923. } else {
  31924. return file; // What do?
  31925. }
  31926. };
  31927. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  31928. }
  31929. function* minify_sync_or_async(files, options, _fs_module) {
  31930. if (
  31931. _fs_module
  31932. && typeof process === "object"
  31933. && process.env
  31934. && typeof process.env.TERSER_DEBUG_DIR === "string"
  31935. ) {
  31936. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  31937. }
  31938. options = defaults(options, {
  31939. compress: {},
  31940. ecma: undefined,
  31941. enclose: false,
  31942. ie8: false,
  31943. keep_classnames: undefined,
  31944. keep_fnames: false,
  31945. mangle: {},
  31946. module: false,
  31947. nameCache: null,
  31948. output: null,
  31949. format: null,
  31950. parse: {},
  31951. rename: undefined,
  31952. safari10: false,
  31953. sourceMap: false,
  31954. spidermonkey: false,
  31955. timings: false,
  31956. toplevel: false,
  31957. warnings: false,
  31958. wrap: false,
  31959. }, true);
  31960. var timings = options.timings && {
  31961. start: Date.now()
  31962. };
  31963. if (options.keep_classnames === undefined) {
  31964. options.keep_classnames = options.keep_fnames;
  31965. }
  31966. if (options.rename === undefined) {
  31967. options.rename = options.compress && options.mangle;
  31968. }
  31969. if (options.output && options.format) {
  31970. throw new Error("Please only specify either output or format option, preferrably format.");
  31971. }
  31972. options.format = options.format || options.output || {};
  31973. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  31974. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  31975. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  31976. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  31977. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  31978. set_shorthand("safari10", options, [ "mangle", "format" ]);
  31979. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  31980. set_shorthand("warnings", options, [ "compress" ]); // legacy
  31981. var quoted_props;
  31982. if (options.mangle) {
  31983. options.mangle = defaults(options.mangle, {
  31984. cache: options.nameCache && (options.nameCache.vars || {}),
  31985. eval: false,
  31986. ie8: false,
  31987. keep_classnames: false,
  31988. keep_fnames: false,
  31989. module: false,
  31990. nth_identifier: base54,
  31991. properties: false,
  31992. reserved: [],
  31993. safari10: false,
  31994. toplevel: false,
  31995. }, true);
  31996. if (options.mangle.properties) {
  31997. if (typeof options.mangle.properties != "object") {
  31998. options.mangle.properties = {};
  31999. }
  32000. if (options.mangle.properties.keep_quoted) {
  32001. quoted_props = options.mangle.properties.reserved;
  32002. if (!Array.isArray(quoted_props)) quoted_props = [];
  32003. options.mangle.properties.reserved = quoted_props;
  32004. }
  32005. if (options.nameCache && !("cache" in options.mangle.properties)) {
  32006. options.mangle.properties.cache = options.nameCache.props || {};
  32007. }
  32008. }
  32009. init_cache(options.mangle.cache);
  32010. init_cache(options.mangle.properties.cache);
  32011. }
  32012. if (options.sourceMap) {
  32013. options.sourceMap = defaults(options.sourceMap, {
  32014. asObject: false,
  32015. content: null,
  32016. filename: null,
  32017. includeSources: false,
  32018. root: null,
  32019. url: null,
  32020. }, true);
  32021. }
  32022. // -- Parse phase --
  32023. if (timings) timings.parse = Date.now();
  32024. var toplevel;
  32025. if (files instanceof AST_Toplevel) {
  32026. toplevel = files;
  32027. } else {
  32028. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  32029. files = [ files ];
  32030. }
  32031. options.parse = options.parse || {};
  32032. options.parse.toplevel = null;
  32033. if (options.parse.spidermonkey) {
  32034. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  32035. if (!toplevel) return files[name];
  32036. toplevel.body = toplevel.body.concat(files[name].body);
  32037. return toplevel;
  32038. }, null));
  32039. } else {
  32040. delete options.parse.spidermonkey;
  32041. for (var name in files) if (HOP(files, name)) {
  32042. options.parse.filename = name;
  32043. options.parse.toplevel = parse(files[name], options.parse);
  32044. if (options.sourceMap && options.sourceMap.content == "inline") {
  32045. if (Object.keys(files).length > 1)
  32046. throw new Error("inline source map only works with singular input");
  32047. options.sourceMap.content = read_source_map(files[name]);
  32048. }
  32049. }
  32050. }
  32051. if (options.parse.toplevel === null) {
  32052. throw new Error("no source file given");
  32053. }
  32054. toplevel = options.parse.toplevel;
  32055. }
  32056. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  32057. reserve_quoted_keys(toplevel, quoted_props);
  32058. }
  32059. var annotated_props;
  32060. if (options.mangle && options.mangle.properties) {
  32061. annotated_props = find_annotated_props(toplevel);
  32062. }
  32063. if (options.wrap) {
  32064. toplevel = toplevel.wrap_commonjs(options.wrap);
  32065. }
  32066. if (options.enclose) {
  32067. toplevel = toplevel.wrap_enclose(options.enclose);
  32068. }
  32069. if (timings) timings.rename = Date.now();
  32070. // -- Compress phase --
  32071. if (timings) timings.compress = Date.now();
  32072. if (options.compress) {
  32073. toplevel = new Compressor(options.compress, {
  32074. mangle_options: options.mangle
  32075. }).compress(toplevel);
  32076. }
  32077. // -- Mangle phase --
  32078. if (timings) timings.scope = Date.now();
  32079. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  32080. if (timings) timings.mangle = Date.now();
  32081. if (options.mangle) {
  32082. toplevel.compute_char_frequency(options.mangle);
  32083. toplevel.mangle_names(options.mangle);
  32084. toplevel = mangle_private_properties(toplevel, options.mangle);
  32085. }
  32086. if (timings) timings.properties = Date.now();
  32087. if (options.mangle && options.mangle.properties) {
  32088. toplevel = mangle_properties(toplevel, options.mangle.properties, annotated_props);
  32089. }
  32090. // Format phase
  32091. if (timings) timings.format = Date.now();
  32092. var result = {};
  32093. if (options.format.ast) {
  32094. result.ast = toplevel;
  32095. }
  32096. if (options.format.spidermonkey) {
  32097. result.ast = toplevel.to_mozilla_ast();
  32098. }
  32099. let format_options;
  32100. if (!HOP(options.format, "code") || options.format.code) {
  32101. // Make a shallow copy so that we can modify without mutating the user's input.
  32102. format_options = {...options.format};
  32103. if (!format_options.ast) {
  32104. // Destroy stuff to save RAM. (unless the deprecated `ast` option is on)
  32105. format_options._destroy_ast = true;
  32106. walk(toplevel, node => {
  32107. if (node instanceof AST_Scope) {
  32108. node.variables = undefined;
  32109. node.enclosed = undefined;
  32110. node.parent_scope = undefined;
  32111. }
  32112. if (node.block_scope) {
  32113. node.block_scope.variables = undefined;
  32114. node.block_scope.enclosed = undefined;
  32115. node.block_scope.parent_scope = undefined;
  32116. }
  32117. });
  32118. }
  32119. if (options.sourceMap) {
  32120. if (options.sourceMap.includeSources && files instanceof AST_Toplevel) {
  32121. throw new Error("original source content unavailable");
  32122. }
  32123. format_options.source_map = yield* SourceMap({
  32124. file: options.sourceMap.filename,
  32125. orig: options.sourceMap.content,
  32126. root: options.sourceMap.root,
  32127. files: options.sourceMap.includeSources ? files : null,
  32128. });
  32129. }
  32130. delete format_options.ast;
  32131. delete format_options.code;
  32132. delete format_options.spidermonkey;
  32133. var stream = OutputStream(format_options);
  32134. toplevel.print(stream);
  32135. result.code = stream.get();
  32136. if (options.sourceMap) {
  32137. Object.defineProperty(result, "map", {
  32138. configurable: true,
  32139. enumerable: true,
  32140. get() {
  32141. const map = format_options.source_map.getEncoded();
  32142. return (result.map = options.sourceMap.asObject ? map : JSON.stringify(map));
  32143. },
  32144. set(value) {
  32145. Object.defineProperty(result, "map", {
  32146. value,
  32147. writable: true,
  32148. });
  32149. }
  32150. });
  32151. result.decoded_map = format_options.source_map.getDecoded();
  32152. if (options.sourceMap.url == "inline") {
  32153. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  32154. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  32155. } else if (options.sourceMap.url) {
  32156. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  32157. }
  32158. }
  32159. }
  32160. if (options.nameCache && options.mangle) {
  32161. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  32162. if (options.mangle.properties && options.mangle.properties.cache) {
  32163. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  32164. }
  32165. }
  32166. if (format_options && format_options.source_map) {
  32167. format_options.source_map.destroy();
  32168. }
  32169. if (timings) {
  32170. timings.end = Date.now();
  32171. result.timings = {
  32172. parse: 1e-3 * (timings.rename - timings.parse),
  32173. rename: 1e-3 * (timings.compress - timings.rename),
  32174. compress: 1e-3 * (timings.scope - timings.compress),
  32175. scope: 1e-3 * (timings.mangle - timings.scope),
  32176. mangle: 1e-3 * (timings.properties - timings.mangle),
  32177. properties: 1e-3 * (timings.format - timings.properties),
  32178. format: 1e-3 * (timings.end - timings.format),
  32179. total: 1e-3 * (timings.end - timings.start)
  32180. };
  32181. }
  32182. return result;
  32183. }
  32184. async function minify(files, options, _fs_module) {
  32185. const gen = minify_sync_or_async(files, options, _fs_module);
  32186. let yielded;
  32187. let val;
  32188. do {
  32189. val = gen.next(await yielded);
  32190. yielded = val.value;
  32191. } while (!val.done);
  32192. return val.value;
  32193. }
  32194. function minify_sync(files, options, _fs_module) {
  32195. const gen = minify_sync_or_async(files, options, _fs_module);
  32196. let yielded;
  32197. let val;
  32198. do {
  32199. if (yielded && typeof yielded.then === "function") {
  32200. throw new Error("minify_sync cannot be used with the legacy source-map module");
  32201. }
  32202. val = gen.next(yielded);
  32203. yielded = val.value;
  32204. } while (!val.done);
  32205. return val.value;
  32206. }
  32207. async function run_cli({ program, packageJson, fs, path }) {
  32208. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  32209. var files = {};
  32210. var options = {
  32211. compress: false,
  32212. mangle: false
  32213. };
  32214. const default_options = await _default_options();
  32215. program.version(packageJson.name + " " + packageJson.version);
  32216. program.parseArgv = program.parse;
  32217. program.parse = undefined;
  32218. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  32219. else if (process.argv.includes("options")) program.helpInformation = function() {
  32220. var text = [];
  32221. for (var option in default_options) {
  32222. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  32223. text.push(format_object(default_options[option]));
  32224. text.push("");
  32225. }
  32226. return text.join("\n");
  32227. };
  32228. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  32229. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  32230. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  32231. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  32232. program.option("-f, --format [options]", "Format options.", parse_js());
  32233. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  32234. program.option("-o, --output <file>", "Output file (default STDOUT).");
  32235. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  32236. program.option("--config-file <file>", "Read minify() options from JSON file.");
  32237. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  32238. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  32239. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  32240. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  32241. program.option("--keep-classnames", "Do not mangle/drop class names.");
  32242. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  32243. program.option("--module", "Input is an ES6 module");
  32244. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  32245. program.option("--rename", "Force symbol expansion.");
  32246. program.option("--no-rename", "Disable symbol expansion.");
  32247. program.option("--safari10", "Support non-standard Safari 10.");
  32248. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  32249. program.option("--timings", "Display operations run time on STDERR.");
  32250. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  32251. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  32252. program.arguments("[files...]").parseArgv(process.argv);
  32253. if (program.configFile) {
  32254. options = JSON.parse(read_file(program.configFile));
  32255. }
  32256. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  32257. fatal("ERROR: cannot write source map to STDOUT");
  32258. }
  32259. [
  32260. "compress",
  32261. "enclose",
  32262. "ie8",
  32263. "mangle",
  32264. "module",
  32265. "safari10",
  32266. "sourceMap",
  32267. "toplevel",
  32268. "wrap"
  32269. ].forEach(function(name) {
  32270. if (name in program) {
  32271. options[name] = program[name];
  32272. }
  32273. });
  32274. if ("ecma" in program) {
  32275. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  32276. const ecma = program.ecma | 0;
  32277. if (ecma > 5 && ecma < 2015)
  32278. options.ecma = ecma + 2009;
  32279. else
  32280. options.ecma = ecma;
  32281. }
  32282. if (program.format || program.beautify) {
  32283. const chosenOption = program.format || program.beautify;
  32284. options.format = typeof chosenOption === "object" ? chosenOption : {};
  32285. }
  32286. if (program.comments) {
  32287. if (typeof options.format != "object") options.format = {};
  32288. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  32289. }
  32290. if (program.define) {
  32291. if (typeof options.compress != "object") options.compress = {};
  32292. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  32293. for (var expr in program.define) {
  32294. options.compress.global_defs[expr] = program.define[expr];
  32295. }
  32296. }
  32297. if (program.keepClassnames) {
  32298. options.keep_classnames = true;
  32299. }
  32300. if (program.keepFnames) {
  32301. options.keep_fnames = true;
  32302. }
  32303. if (program.mangleProps) {
  32304. if (program.mangleProps.domprops) {
  32305. delete program.mangleProps.domprops;
  32306. } else {
  32307. if (typeof program.mangleProps != "object") program.mangleProps = {};
  32308. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  32309. }
  32310. if (typeof options.mangle != "object") options.mangle = {};
  32311. options.mangle.properties = program.mangleProps;
  32312. }
  32313. if (program.nameCache) {
  32314. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  32315. }
  32316. if (program.output == "ast") {
  32317. options.format = {
  32318. ast: true,
  32319. code: false
  32320. };
  32321. }
  32322. if (program.parse) {
  32323. if (!program.parse.acorn && !program.parse.spidermonkey) {
  32324. options.parse = program.parse;
  32325. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  32326. fatal("ERROR: inline source map only works with built-in parser");
  32327. }
  32328. }
  32329. if (~program.rawArgs.indexOf("--rename")) {
  32330. options.rename = true;
  32331. } else if (!program.rename) {
  32332. options.rename = false;
  32333. }
  32334. let convert_path = name => name;
  32335. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  32336. convert_path = function() {
  32337. var base = program.sourceMap.base;
  32338. delete options.sourceMap.base;
  32339. return function(name) {
  32340. return path.relative(base, name);
  32341. };
  32342. }();
  32343. }
  32344. let filesList;
  32345. if (options.files && options.files.length) {
  32346. filesList = options.files;
  32347. delete options.files;
  32348. } else if (program.args.length) {
  32349. filesList = program.args;
  32350. }
  32351. if (filesList) {
  32352. simple_glob(filesList).forEach(function(name) {
  32353. files[convert_path(name)] = read_file(name);
  32354. });
  32355. } else {
  32356. await new Promise((resolve) => {
  32357. var chunks = [];
  32358. process.stdin.setEncoding("utf8");
  32359. process.stdin.on("data", function(chunk) {
  32360. chunks.push(chunk);
  32361. }).on("end", function() {
  32362. files = [ chunks.join("") ];
  32363. resolve();
  32364. });
  32365. process.stdin.resume();
  32366. });
  32367. }
  32368. await run_cli();
  32369. function convert_ast(fn) {
  32370. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  32371. }
  32372. async function run_cli() {
  32373. var content = program.sourceMap && program.sourceMap.content;
  32374. if (content && content !== "inline") {
  32375. options.sourceMap.content = read_file(content, content);
  32376. }
  32377. if (program.timings) options.timings = true;
  32378. try {
  32379. if (program.parse) {
  32380. if (program.parse.acorn) {
  32381. files = convert_ast(function(toplevel, name) {
  32382. return require("acorn").parse(files[name], {
  32383. ecmaVersion: 2024,
  32384. locations: true,
  32385. program: toplevel,
  32386. sourceFile: name,
  32387. sourceType: options.module || program.parse.module ? "module" : "script"
  32388. });
  32389. });
  32390. } else if (program.parse.spidermonkey) {
  32391. files = convert_ast(function(toplevel, name) {
  32392. var obj = JSON.parse(files[name]);
  32393. if (!toplevel) return obj;
  32394. toplevel.body = toplevel.body.concat(obj.body);
  32395. return toplevel;
  32396. });
  32397. }
  32398. }
  32399. } catch (ex) {
  32400. fatal(ex);
  32401. }
  32402. let result;
  32403. try {
  32404. result = await minify(files, options, fs);
  32405. } catch (ex) {
  32406. if (ex.name == "SyntaxError") {
  32407. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  32408. var col = ex.col;
  32409. var lines = files[ex.filename].split(/\r?\n/);
  32410. var line = lines[ex.line - 1];
  32411. if (!line && !col) {
  32412. line = lines[ex.line - 2];
  32413. col = line.length;
  32414. }
  32415. if (line) {
  32416. var limit = 70;
  32417. if (col > limit) {
  32418. line = line.slice(col - limit);
  32419. col = limit;
  32420. }
  32421. print_error(line.slice(0, 80));
  32422. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  32423. }
  32424. }
  32425. if (ex.defs) {
  32426. print_error("Supported options:");
  32427. print_error(format_object(ex.defs));
  32428. }
  32429. fatal(ex);
  32430. return;
  32431. }
  32432. if (program.output == "ast") {
  32433. if (!options.compress && !options.mangle) {
  32434. result.ast.figure_out_scope({});
  32435. }
  32436. console.log(JSON.stringify(result.ast, function(key, value) {
  32437. if (value) switch (key) {
  32438. case "thedef":
  32439. return symdef(value);
  32440. case "enclosed":
  32441. return value.length ? value.map(symdef) : undefined;
  32442. case "variables":
  32443. case "globals":
  32444. return value.size ? collect_from_map(value, symdef) : undefined;
  32445. }
  32446. if (skip_keys.has(key)) return;
  32447. if (value instanceof AST_Token) return;
  32448. if (value instanceof Map) return;
  32449. if (value instanceof AST_Node) {
  32450. var result = {
  32451. _class: "AST_" + value.TYPE
  32452. };
  32453. if (value.block_scope) {
  32454. result.variables = value.block_scope.variables;
  32455. result.enclosed = value.block_scope.enclosed;
  32456. }
  32457. value.CTOR.PROPS.forEach(function(prop) {
  32458. if (prop !== "block_scope") {
  32459. result[prop] = value[prop];
  32460. }
  32461. });
  32462. return result;
  32463. }
  32464. return value;
  32465. }, 2));
  32466. } else if (program.output == "spidermonkey") {
  32467. try {
  32468. const minified = await minify(
  32469. result.code,
  32470. {
  32471. compress: false,
  32472. mangle: false,
  32473. format: {
  32474. ast: true,
  32475. code: false
  32476. }
  32477. },
  32478. fs
  32479. );
  32480. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  32481. } catch (ex) {
  32482. fatal(ex);
  32483. return;
  32484. }
  32485. } else if (program.output) {
  32486. fs.mkdirSync(path.dirname(program.output), { recursive: true });
  32487. fs.writeFileSync(program.output, result.code);
  32488. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  32489. fs.writeFileSync(program.output + ".map", result.map);
  32490. }
  32491. } else {
  32492. console.log(result.code);
  32493. }
  32494. if (program.nameCache) {
  32495. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  32496. }
  32497. if (result.timings) for (var phase in result.timings) {
  32498. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  32499. }
  32500. }
  32501. function fatal(message) {
  32502. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  32503. print_error(message);
  32504. process.exit(1);
  32505. }
  32506. // A file glob function that only supports "*" and "?" wildcards in the basename.
  32507. // Example: "foo/bar/*baz??.*.js"
  32508. // Argument `glob` may be a string or an array of strings.
  32509. // Returns an array of strings. Garbage in, garbage out.
  32510. function simple_glob(glob) {
  32511. if (Array.isArray(glob)) {
  32512. return [].concat.apply([], glob.map(simple_glob));
  32513. }
  32514. if (glob && glob.match(/[*?]/)) {
  32515. var dir = path.dirname(glob);
  32516. try {
  32517. var entries = fs.readdirSync(dir);
  32518. } catch (ex) {}
  32519. if (entries) {
  32520. var pattern = "^" + path.basename(glob)
  32521. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  32522. .replace(/\*/g, "[^/\\\\]*")
  32523. .replace(/\?/g, "[^/\\\\]") + "$";
  32524. var mod = process.platform === "win32" ? "i" : "";
  32525. var rx = new RegExp(pattern, mod);
  32526. var results = entries.filter(function(name) {
  32527. return rx.test(name);
  32528. }).map(function(name) {
  32529. return path.join(dir, name);
  32530. });
  32531. if (results.length) return results;
  32532. }
  32533. }
  32534. return [ glob ];
  32535. }
  32536. function read_file(path, default_value) {
  32537. try {
  32538. return fs.readFileSync(path, "utf8");
  32539. } catch (ex) {
  32540. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  32541. fatal(ex);
  32542. }
  32543. }
  32544. function parse_js(flag) {
  32545. return function(value, options) {
  32546. options = options || {};
  32547. try {
  32548. walk(parse(value, { expression: true }), node => {
  32549. if (node instanceof AST_Assign) {
  32550. var name = node.left.print_to_string();
  32551. var value = node.right;
  32552. if (flag) {
  32553. options[name] = value;
  32554. } else if (value instanceof AST_Array) {
  32555. options[name] = value.elements.map(to_string);
  32556. } else if (value instanceof AST_RegExp) {
  32557. value = value.value;
  32558. options[name] = new RegExp(value.source, value.flags);
  32559. } else {
  32560. options[name] = to_string(value);
  32561. }
  32562. return true;
  32563. }
  32564. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  32565. var name = node.print_to_string();
  32566. options[name] = true;
  32567. return true;
  32568. }
  32569. if (!(node instanceof AST_Sequence)) throw node;
  32570. function to_string(value) {
  32571. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  32572. quote_keys: true
  32573. });
  32574. }
  32575. });
  32576. } catch(ex) {
  32577. if (flag) {
  32578. fatal("Error parsing arguments for '" + flag + "': " + value);
  32579. } else {
  32580. options[value] = null;
  32581. }
  32582. }
  32583. return options;
  32584. };
  32585. }
  32586. function symdef(def) {
  32587. var ret = (1e6 + def.id) + " " + def.name;
  32588. if (def.mangled_name) ret += " " + def.mangled_name;
  32589. return ret;
  32590. }
  32591. function collect_from_map(map, callback) {
  32592. var result = [];
  32593. map.forEach(function (def) {
  32594. result.push(callback(def));
  32595. });
  32596. return result;
  32597. }
  32598. function format_object(obj) {
  32599. var lines = [];
  32600. var padding = "";
  32601. Object.keys(obj).map(function(name) {
  32602. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  32603. return [ name, JSON.stringify(obj[name]) ];
  32604. }).forEach(function(tokens) {
  32605. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  32606. });
  32607. return lines.join("\n");
  32608. }
  32609. function print_error(msg) {
  32610. process.stderr.write(msg);
  32611. process.stderr.write("\n");
  32612. }
  32613. function describe_ast() {
  32614. var out = OutputStream({ beautify: true });
  32615. function doitem(ctor) {
  32616. out.print("AST_" + ctor.TYPE);
  32617. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  32618. if (props.length > 0) {
  32619. out.space();
  32620. out.with_parens(function() {
  32621. props.forEach(function(prop, i) {
  32622. if (i) out.space();
  32623. out.print(prop);
  32624. });
  32625. });
  32626. }
  32627. if (ctor.documentation) {
  32628. out.space();
  32629. out.print_string(ctor.documentation);
  32630. }
  32631. if (ctor.SUBCLASSES.length > 0) {
  32632. out.space();
  32633. out.with_block(function() {
  32634. ctor.SUBCLASSES.forEach(function(ctor) {
  32635. out.indent();
  32636. doitem(ctor);
  32637. out.newline();
  32638. });
  32639. });
  32640. }
  32641. }
  32642. doitem(AST_Node);
  32643. return out + "\n";
  32644. }
  32645. }
  32646. async function _default_options() {
  32647. const defs = {};
  32648. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  32649. const options = infer_options({
  32650. [component]: {0: 0}
  32651. });
  32652. if (options) defs[component] = options;
  32653. });
  32654. return defs;
  32655. }
  32656. async function infer_options(options) {
  32657. try {
  32658. await minify("", options);
  32659. } catch (error) {
  32660. return error.defs;
  32661. }
  32662. }
  32663. exports._default_options = _default_options;
  32664. exports._run_cli = run_cli;
  32665. exports.minify = minify;
  32666. exports.minify_sync = minify_sync;
  32667. }));