bundle.min.js 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/source-map')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/source-map'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
  5. })(this, (function (exports, sourceMap) { 'use strict';
  6. /***********************************************************************
  7. A JavaScript tokenizer / parser / beautifier / compressor.
  8. https://github.com/mishoo/UglifyJS2
  9. -------------------------------- (C) ---------------------------------
  10. Author: Mihai Bazon
  11. <mihai.bazon@gmail.com>
  12. http://mihai.bazon.net/blog
  13. Distributed under the BSD license:
  14. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15. Redistribution and use in source and binary forms, with or without
  16. modification, are permitted provided that the following conditions
  17. are met:
  18. * Redistributions of source code must retain the above
  19. copyright notice, this list of conditions and the following
  20. disclaimer.
  21. * Redistributions in binary form must reproduce the above
  22. copyright notice, this list of conditions and the following
  23. disclaimer in the documentation and/or other materials
  24. provided with the distribution.
  25. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  26. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  28. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  31. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  32. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  35. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. SUCH DAMAGE.
  37. ***********************************************************************/
  38. function characters(str) {
  39. return str.split("");
  40. }
  41. function member(name, array) {
  42. return array.includes(name);
  43. }
  44. class DefaultsError extends Error {
  45. constructor(msg, defs) {
  46. super();
  47. this.name = "DefaultsError";
  48. this.message = msg;
  49. this.defs = defs;
  50. }
  51. }
  52. function defaults(args, defs, croak) {
  53. if (args === true) {
  54. args = {};
  55. } else if (args != null && typeof args === "object") {
  56. args = {...args};
  57. }
  58. const ret = args || {};
  59. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  60. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  61. }
  62. for (const i in defs) if (HOP(defs, i)) {
  63. if (!args || !HOP(args, i)) {
  64. ret[i] = defs[i];
  65. } else if (i === "ecma") {
  66. let ecma = args[i] | 0;
  67. if (ecma > 5 && ecma < 2015) ecma += 2009;
  68. ret[i] = ecma;
  69. } else {
  70. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  71. }
  72. }
  73. return ret;
  74. }
  75. function noop() {}
  76. function return_false() { return false; }
  77. function return_true() { return true; }
  78. function return_this() { return this; }
  79. function return_null() { return null; }
  80. var MAP = (function() {
  81. function MAP(a, tw, allow_splicing = true) {
  82. const new_a = [];
  83. for (let i = 0; i < a.length; ++i) {
  84. let item = a[i];
  85. let ret = item.transform(tw, allow_splicing);
  86. if (ret instanceof AST_Node) {
  87. new_a.push(ret);
  88. } else if (ret instanceof Splice) {
  89. new_a.push(...ret.v);
  90. }
  91. }
  92. return new_a;
  93. }
  94. MAP.splice = function(val) { return new Splice(val); };
  95. MAP.skip = {};
  96. function Splice(val) { this.v = val; }
  97. return MAP;
  98. })();
  99. function make_node(ctor, orig, props) {
  100. if (!props) props = {};
  101. if (orig) {
  102. if (!props.start) props.start = orig.start;
  103. if (!props.end) props.end = orig.end;
  104. }
  105. return new ctor(props);
  106. }
  107. function push_uniq(array, el) {
  108. if (!array.includes(el))
  109. array.push(el);
  110. }
  111. function string_template(text, props) {
  112. return text.replace(/{(.+?)}/g, function(str, p) {
  113. return props && props[p];
  114. });
  115. }
  116. function remove(array, el) {
  117. for (var i = array.length; --i >= 0;) {
  118. if (array[i] === el) array.splice(i, 1);
  119. }
  120. }
  121. function mergeSort(array, cmp) {
  122. if (array.length < 2) return array.slice();
  123. function merge(a, b) {
  124. var r = [], ai = 0, bi = 0, i = 0;
  125. while (ai < a.length && bi < b.length) {
  126. cmp(a[ai], b[bi]) <= 0
  127. ? r[i++] = a[ai++]
  128. : r[i++] = b[bi++];
  129. }
  130. if (ai < a.length) r.push.apply(r, a.slice(ai));
  131. if (bi < b.length) r.push.apply(r, b.slice(bi));
  132. return r;
  133. }
  134. function _ms(a) {
  135. if (a.length <= 1)
  136. return a;
  137. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  138. left = _ms(left);
  139. right = _ms(right);
  140. return merge(left, right);
  141. }
  142. return _ms(array);
  143. }
  144. function makePredicate(words) {
  145. if (!Array.isArray(words)) words = words.split(" ");
  146. return new Set(words.sort());
  147. }
  148. function map_add(map, key, value) {
  149. if (map.has(key)) {
  150. map.get(key).push(value);
  151. } else {
  152. map.set(key, [ value ]);
  153. }
  154. }
  155. function map_from_object(obj) {
  156. var map = new Map();
  157. for (var key in obj) {
  158. if (HOP(obj, key) && key.charAt(0) === "$") {
  159. map.set(key.substr(1), obj[key]);
  160. }
  161. }
  162. return map;
  163. }
  164. function map_to_object(map) {
  165. var obj = Object.create(null);
  166. map.forEach(function (value, key) {
  167. obj["$" + key] = value;
  168. });
  169. return obj;
  170. }
  171. function HOP(obj, prop) {
  172. return Object.prototype.hasOwnProperty.call(obj, prop);
  173. }
  174. function keep_name(keep_setting, name) {
  175. return keep_setting === true
  176. || (keep_setting instanceof RegExp && keep_setting.test(name));
  177. }
  178. var lineTerminatorEscape = {
  179. "\0": "0",
  180. "\n": "n",
  181. "\r": "r",
  182. "\u2028": "u2028",
  183. "\u2029": "u2029",
  184. };
  185. function regexp_source_fix(source) {
  186. // V8 does not escape line terminators in regexp patterns in node 12
  187. // We'll also remove literal \0
  188. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  189. var escaped = source[offset - 1] == "\\"
  190. && (source[offset - 2] != "\\"
  191. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  192. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  193. });
  194. }
  195. // Subset of regexps that is not going to cause regexp based DDOS
  196. // https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
  197. const re_safe_regexp = /^[\\/|\0\s\w^$.[\]()]*$/;
  198. /** Check if the regexp is safe for Terser to create without risking a RegExp DOS */
  199. const regexp_is_safe = (source) => re_safe_regexp.test(source);
  200. const all_flags = "dgimsuyv";
  201. function sort_regexp_flags(flags) {
  202. const existing_flags = new Set(flags.split(""));
  203. let out = "";
  204. for (const flag of all_flags) {
  205. if (existing_flags.has(flag)) {
  206. out += flag;
  207. existing_flags.delete(flag);
  208. }
  209. }
  210. if (existing_flags.size) {
  211. // Flags Terser doesn't know about
  212. existing_flags.forEach(flag => { out += flag; });
  213. }
  214. return out;
  215. }
  216. function has_annotation(node, annotation) {
  217. return node._annotations & annotation;
  218. }
  219. function set_annotation(node, annotation) {
  220. node._annotations |= annotation;
  221. }
  222. function clear_annotation(node, annotation) {
  223. node._annotations &= ~annotation;
  224. }
  225. /***********************************************************************
  226. A JavaScript tokenizer / parser / beautifier / compressor.
  227. https://github.com/mishoo/UglifyJS2
  228. -------------------------------- (C) ---------------------------------
  229. Author: Mihai Bazon
  230. <mihai.bazon@gmail.com>
  231. http://mihai.bazon.net/blog
  232. Distributed under the BSD license:
  233. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  234. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  235. Redistribution and use in source and binary forms, with or without
  236. modification, are permitted provided that the following conditions
  237. are met:
  238. * Redistributions of source code must retain the above
  239. copyright notice, this list of conditions and the following
  240. disclaimer.
  241. * Redistributions in binary form must reproduce the above
  242. copyright notice, this list of conditions and the following
  243. disclaimer in the documentation and/or other materials
  244. provided with the distribution.
  245. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  246. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  247. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  248. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  249. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  250. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  251. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  252. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  253. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  254. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  255. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  256. SUCH DAMAGE.
  257. ***********************************************************************/
  258. var LATEST_RAW = ""; // Only used for numbers and template strings
  259. var TEMPLATE_RAWS = new Map(); // Raw template strings
  260. var KEYWORDS = "break case catch class const continue debugger default delete do else export extends finally for function if in instanceof let new return switch throw try typeof var void while with";
  261. var KEYWORDS_ATOM = "false null true";
  262. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  263. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  264. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  265. KEYWORDS = makePredicate(KEYWORDS);
  266. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  267. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  268. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  269. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  270. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  271. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  272. var RE_OCT_NUMBER = /^0[0-7]+$/;
  273. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  274. var RE_BIN_NUMBER = /^0b[01]+$/i;
  275. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  276. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  277. var OPERATORS = makePredicate([
  278. "in",
  279. "instanceof",
  280. "typeof",
  281. "new",
  282. "void",
  283. "delete",
  284. "++",
  285. "--",
  286. "+",
  287. "-",
  288. "!",
  289. "~",
  290. "&",
  291. "|",
  292. "^",
  293. "*",
  294. "**",
  295. "/",
  296. "%",
  297. ">>",
  298. "<<",
  299. ">>>",
  300. "<",
  301. ">",
  302. "<=",
  303. ">=",
  304. "==",
  305. "===",
  306. "!=",
  307. "!==",
  308. "?",
  309. "=",
  310. "+=",
  311. "-=",
  312. "||=",
  313. "&&=",
  314. "??=",
  315. "/=",
  316. "*=",
  317. "**=",
  318. "%=",
  319. ">>=",
  320. "<<=",
  321. ">>>=",
  322. "|=",
  323. "^=",
  324. "&=",
  325. "&&",
  326. "??",
  327. "||",
  328. ]);
  329. 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"));
  330. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  331. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  332. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  333. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  334. /* -----[ Tokenizer ]----- */
  335. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  336. var UNICODE = {
  337. 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]/,
  338. 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])+/,
  339. };
  340. function get_full_char(str, pos) {
  341. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  342. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  343. return str.charAt(pos) + str.charAt(pos + 1);
  344. }
  345. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  346. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  347. return str.charAt(pos - 1) + str.charAt(pos);
  348. }
  349. }
  350. return str.charAt(pos);
  351. }
  352. function get_full_char_code(str, pos) {
  353. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  354. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  355. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  356. }
  357. return str.charCodeAt(pos);
  358. }
  359. function get_full_char_length(str) {
  360. var surrogates = 0;
  361. for (var i = 0; i < str.length; i++) {
  362. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  363. surrogates++;
  364. i++;
  365. }
  366. }
  367. return str.length - surrogates;
  368. }
  369. function from_char_code(code) {
  370. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  371. if (code > 0xFFFF) {
  372. code -= 0x10000;
  373. return (String.fromCharCode((code >> 10) + 0xD800) +
  374. String.fromCharCode((code % 0x400) + 0xDC00));
  375. }
  376. return String.fromCharCode(code);
  377. }
  378. function is_surrogate_pair_head(code) {
  379. return code >= 0xd800 && code <= 0xdbff;
  380. }
  381. function is_surrogate_pair_tail(code) {
  382. return code >= 0xdc00 && code <= 0xdfff;
  383. }
  384. function is_digit(code) {
  385. return code >= 48 && code <= 57;
  386. }
  387. function is_identifier_start(ch) {
  388. return UNICODE.ID_Start.test(ch);
  389. }
  390. function is_identifier_char(ch) {
  391. return UNICODE.ID_Continue.test(ch);
  392. }
  393. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  394. function is_basic_identifier_string(str) {
  395. return BASIC_IDENT.test(str);
  396. }
  397. function is_identifier_string(str, allow_surrogates) {
  398. if (BASIC_IDENT.test(str)) {
  399. return true;
  400. }
  401. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  402. return false;
  403. }
  404. var match = UNICODE.ID_Start.exec(str);
  405. if (!match || match.index !== 0) {
  406. return false;
  407. }
  408. str = str.slice(match[0].length);
  409. if (!str) {
  410. return true;
  411. }
  412. match = UNICODE.ID_Continue.exec(str);
  413. return !!match && match[0].length === str.length;
  414. }
  415. function parse_js_number(num, allow_e = true) {
  416. if (!allow_e && num.includes("e")) {
  417. return NaN;
  418. }
  419. if (RE_HEX_NUMBER.test(num)) {
  420. return parseInt(num.substr(2), 16);
  421. } else if (RE_OCT_NUMBER.test(num)) {
  422. return parseInt(num.substr(1), 8);
  423. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  424. return parseInt(num.substr(2), 8);
  425. } else if (RE_BIN_NUMBER.test(num)) {
  426. return parseInt(num.substr(2), 2);
  427. } else if (RE_DEC_NUMBER.test(num)) {
  428. return parseFloat(num);
  429. } else {
  430. var val = parseFloat(num);
  431. if (val == num) return val;
  432. }
  433. }
  434. class JS_Parse_Error extends Error {
  435. constructor(message, filename, line, col, pos) {
  436. super();
  437. this.name = "SyntaxError";
  438. this.message = message;
  439. this.filename = filename;
  440. this.line = line;
  441. this.col = col;
  442. this.pos = pos;
  443. }
  444. }
  445. function js_error(message, filename, line, col, pos) {
  446. throw new JS_Parse_Error(message, filename, line, col, pos);
  447. }
  448. function is_token(token, type, val) {
  449. return token.type == type && (val == null || token.value == val);
  450. }
  451. var EX_EOF = {};
  452. function tokenizer($TEXT, filename, html5_comments, shebang) {
  453. var S = {
  454. text : $TEXT,
  455. filename : filename,
  456. pos : 0,
  457. tokpos : 0,
  458. line : 1,
  459. tokline : 0,
  460. col : 0,
  461. tokcol : 0,
  462. newline_before : false,
  463. regex_allowed : false,
  464. brace_counter : 0,
  465. template_braces : [],
  466. comments_before : [],
  467. directives : {},
  468. directive_stack : []
  469. };
  470. function peek() { return get_full_char(S.text, S.pos); }
  471. // Used because parsing ?. involves a lookahead for a digit
  472. function is_option_chain_op() {
  473. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  474. if (!must_be_dot) return false;
  475. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  476. return cannot_be_digit < 48 || cannot_be_digit > 57;
  477. }
  478. function next(signal_eof, in_string) {
  479. var ch = get_full_char(S.text, S.pos++);
  480. if (signal_eof && !ch)
  481. throw EX_EOF;
  482. if (NEWLINE_CHARS.has(ch)) {
  483. S.newline_before = S.newline_before || !in_string;
  484. ++S.line;
  485. S.col = 0;
  486. if (ch == "\r" && peek() == "\n") {
  487. // treat a \r\n sequence as a single \n
  488. ++S.pos;
  489. ch = "\n";
  490. }
  491. } else {
  492. if (ch.length > 1) {
  493. ++S.pos;
  494. ++S.col;
  495. }
  496. ++S.col;
  497. }
  498. return ch;
  499. }
  500. function forward(i) {
  501. while (i--) next();
  502. }
  503. function looking_at(str) {
  504. return S.text.substr(S.pos, str.length) == str;
  505. }
  506. function find_eol() {
  507. var text = S.text;
  508. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  509. var ch = text[i];
  510. if (NEWLINE_CHARS.has(ch))
  511. return i;
  512. }
  513. return -1;
  514. }
  515. function find(what, signal_eof) {
  516. var pos = S.text.indexOf(what, S.pos);
  517. if (signal_eof && pos == -1) throw EX_EOF;
  518. return pos;
  519. }
  520. function start_token() {
  521. S.tokline = S.line;
  522. S.tokcol = S.col;
  523. S.tokpos = S.pos;
  524. }
  525. var prev_was_dot = false;
  526. var previous_token = null;
  527. function token(type, value, is_comment) {
  528. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  529. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  530. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  531. (type == "arrow");
  532. if (type == "punc" && (value == "." || value == "?.")) {
  533. prev_was_dot = true;
  534. } else if (!is_comment) {
  535. prev_was_dot = false;
  536. }
  537. const line = S.tokline;
  538. const col = S.tokcol;
  539. const pos = S.tokpos;
  540. const nlb = S.newline_before;
  541. const file = filename;
  542. let comments_before = [];
  543. let comments_after = [];
  544. if (!is_comment) {
  545. comments_before = S.comments_before;
  546. comments_after = S.comments_before = [];
  547. }
  548. S.newline_before = false;
  549. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  550. if (!is_comment) previous_token = tok;
  551. return tok;
  552. }
  553. function skip_whitespace() {
  554. while (WHITESPACE_CHARS.has(peek()))
  555. next();
  556. }
  557. function read_while(pred) {
  558. var ret = "", ch, i = 0;
  559. while ((ch = peek()) && pred(ch, i++))
  560. ret += next();
  561. return ret;
  562. }
  563. function parse_error(err) {
  564. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  565. }
  566. function read_num(prefix) {
  567. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  568. var num = read_while(function(ch, i) {
  569. if (is_big_int) return false;
  570. var code = ch.charCodeAt(0);
  571. switch (code) {
  572. case 95: // _
  573. return (numeric_separator = true);
  574. case 98: case 66: // bB
  575. return (has_x = true); // Can occur in hex sequence, don't return false yet
  576. case 111: case 79: // oO
  577. case 120: case 88: // xX
  578. return has_x ? false : (has_x = true);
  579. case 101: case 69: // eE
  580. return has_x ? true : has_e ? false : (has_e = after_e = true);
  581. case 45: // -
  582. return after_e || (i == 0 && !prefix);
  583. case 43: // +
  584. return after_e;
  585. case (after_e = false, 46): // .
  586. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  587. case 110: // n
  588. is_big_int = true;
  589. return true;
  590. }
  591. return (
  592. code >= 48 && code <= 57 // 0-9
  593. || code >= 97 && code <= 102 // a-f
  594. || code >= 65 && code <= 70 // A-F
  595. );
  596. });
  597. if (prefix) num = prefix + num;
  598. LATEST_RAW = num;
  599. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  600. parse_error("Legacy octal literals are not allowed in strict mode");
  601. }
  602. if (numeric_separator) {
  603. if (num.endsWith("_")) {
  604. parse_error("Numeric separators are not allowed at the end of numeric literals");
  605. } else if (num.includes("__")) {
  606. parse_error("Only one underscore is allowed as numeric separator");
  607. }
  608. num = num.replace(/_/g, "");
  609. }
  610. if (is_big_int) {
  611. const without_n = num.slice(0, -1);
  612. const allow_e = RE_HEX_NUMBER.test(without_n);
  613. const valid = parse_js_number(without_n, allow_e);
  614. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  615. return token("big_int", without_n);
  616. parse_error("Invalid or unexpected token");
  617. }
  618. var valid = parse_js_number(num);
  619. if (!isNaN(valid)) {
  620. return token("num", valid);
  621. } else {
  622. parse_error("Invalid syntax: " + num);
  623. }
  624. }
  625. function is_octal(ch) {
  626. return ch >= "0" && ch <= "7";
  627. }
  628. function read_escaped_char(in_string, strict_hex, template_string) {
  629. var ch = next(true, in_string);
  630. switch (ch.charCodeAt(0)) {
  631. case 110 : return "\n";
  632. case 114 : return "\r";
  633. case 116 : return "\t";
  634. case 98 : return "\b";
  635. case 118 : return "\u000b"; // \v
  636. case 102 : return "\f";
  637. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  638. case 117 : // \u
  639. if (peek() == "{") {
  640. next(true);
  641. if (peek() === "}")
  642. parse_error("Expecting hex-character between {}");
  643. while (peek() == "0") next(true); // No significance
  644. var result, length = find("}", true) - S.pos;
  645. // Avoid 32 bit integer overflow (1 << 32 === 1)
  646. // We know first character isn't 0 and thus out of range anyway
  647. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  648. parse_error("Unicode reference out of bounds");
  649. }
  650. next(true);
  651. return from_char_code(result);
  652. }
  653. return String.fromCharCode(hex_bytes(4, strict_hex));
  654. case 10 : return ""; // newline
  655. case 13 : // \r
  656. if (peek() == "\n") { // DOS newline
  657. next(true, in_string);
  658. return "";
  659. }
  660. }
  661. if (is_octal(ch)) {
  662. if (template_string && strict_hex) {
  663. const represents_null_character = ch === "0" && !is_octal(peek());
  664. if (!represents_null_character) {
  665. parse_error("Octal escape sequences are not allowed in template strings");
  666. }
  667. }
  668. return read_octal_escape_sequence(ch, strict_hex);
  669. }
  670. return ch;
  671. }
  672. function read_octal_escape_sequence(ch, strict_octal) {
  673. // Read
  674. var p = peek();
  675. if (p >= "0" && p <= "7") {
  676. ch += next(true);
  677. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  678. ch += next(true);
  679. }
  680. // Parse
  681. if (ch === "0") return "\0";
  682. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  683. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  684. return String.fromCharCode(parseInt(ch, 8));
  685. }
  686. function hex_bytes(n, strict_hex) {
  687. var num = 0;
  688. for (; n > 0; --n) {
  689. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  690. return parseInt(num, 16) || "";
  691. }
  692. var digit = next(true);
  693. if (isNaN(parseInt(digit, 16)))
  694. parse_error("Invalid hex-character pattern in string");
  695. num += digit;
  696. }
  697. return parseInt(num, 16);
  698. }
  699. var read_string = with_eof_error("Unterminated string constant", function() {
  700. const start_pos = S.pos;
  701. var quote = next(), ret = [];
  702. for (;;) {
  703. var ch = next(true, true);
  704. if (ch == "\\") ch = read_escaped_char(true, true);
  705. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  706. else if (ch == quote) break;
  707. ret.push(ch);
  708. }
  709. var tok = token("string", ret.join(""));
  710. LATEST_RAW = S.text.slice(start_pos, S.pos);
  711. tok.quote = quote;
  712. return tok;
  713. });
  714. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  715. if (begin) {
  716. S.template_braces.push(S.brace_counter);
  717. }
  718. var content = "", raw = "", ch, tok;
  719. next(true, true);
  720. while ((ch = next(true, true)) != "`") {
  721. if (ch == "\r") {
  722. if (peek() == "\n") ++S.pos;
  723. ch = "\n";
  724. } else if (ch == "$" && peek() == "{") {
  725. next(true, true);
  726. S.brace_counter++;
  727. tok = token(begin ? "template_head" : "template_cont", content);
  728. TEMPLATE_RAWS.set(tok, raw);
  729. tok.template_end = false;
  730. return tok;
  731. }
  732. raw += ch;
  733. if (ch == "\\") {
  734. var tmp = S.pos;
  735. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  736. ch = read_escaped_char(true, !prev_is_tag, true);
  737. raw += S.text.substr(tmp, S.pos - tmp);
  738. }
  739. content += ch;
  740. }
  741. S.template_braces.pop();
  742. tok = token(begin ? "template_head" : "template_cont", content);
  743. TEMPLATE_RAWS.set(tok, raw);
  744. tok.template_end = true;
  745. return tok;
  746. });
  747. function skip_line_comment(type) {
  748. var regex_allowed = S.regex_allowed;
  749. var i = find_eol(), ret;
  750. if (i == -1) {
  751. ret = S.text.substr(S.pos);
  752. S.pos = S.text.length;
  753. } else {
  754. ret = S.text.substring(S.pos, i);
  755. S.pos = i;
  756. }
  757. S.col = S.tokcol + (S.pos - S.tokpos);
  758. S.comments_before.push(token(type, ret, true));
  759. S.regex_allowed = regex_allowed;
  760. return next_token;
  761. }
  762. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  763. var regex_allowed = S.regex_allowed;
  764. var i = find("*/", true);
  765. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  766. // update stream position
  767. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  768. S.comments_before.push(token("comment2", text, true));
  769. S.newline_before = S.newline_before || text.includes("\n");
  770. S.regex_allowed = regex_allowed;
  771. return next_token;
  772. });
  773. var read_name = function () {
  774. let start = S.pos, end = start - 1, ch = "c";
  775. while (
  776. (ch = S.text.charAt(++end))
  777. && (ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z")
  778. );
  779. if (end > start + 1 && ch && ch !== "\\" && !is_identifier_char(ch)) {
  780. S.pos += end - start;
  781. S.col += end - start;
  782. return S.text.slice(start, S.pos);
  783. }
  784. return read_name_hard();
  785. };
  786. var read_name_hard = with_eof_error("Unterminated identifier name", function() {
  787. var name = [], ch, escaped = false;
  788. var read_escaped_identifier_char = function() {
  789. escaped = true;
  790. next();
  791. if (peek() !== "u") {
  792. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  793. }
  794. return read_escaped_char(false, true);
  795. };
  796. // Read first character (ID_Start)
  797. if ((ch = peek()) === "\\") {
  798. ch = read_escaped_identifier_char();
  799. if (!is_identifier_start(ch)) {
  800. parse_error("First identifier char is an invalid identifier char");
  801. }
  802. } else if (is_identifier_start(ch)) {
  803. next();
  804. } else {
  805. return "";
  806. }
  807. name.push(ch);
  808. // Read ID_Continue
  809. while ((ch = peek()) != null) {
  810. if ((ch = peek()) === "\\") {
  811. ch = read_escaped_identifier_char();
  812. if (!is_identifier_char(ch)) {
  813. parse_error("Invalid escaped identifier char");
  814. }
  815. } else {
  816. if (!is_identifier_char(ch)) {
  817. break;
  818. }
  819. next();
  820. }
  821. name.push(ch);
  822. }
  823. const name_str = name.join("");
  824. if (RESERVED_WORDS.has(name_str) && escaped) {
  825. parse_error("Escaped characters are not allowed in keywords");
  826. }
  827. return name_str;
  828. });
  829. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  830. var prev_backslash = false, ch, in_class = false;
  831. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  832. parse_error("Unexpected line terminator");
  833. } else if (prev_backslash) {
  834. if (/^[\u0000-\u007F]$/.test(ch)) {
  835. source += "\\" + ch;
  836. } else {
  837. // Remove the useless slash before the escape, but only for characters that won't be added to regexp syntax
  838. source += ch;
  839. }
  840. prev_backslash = false;
  841. } else if (ch == "[") {
  842. in_class = true;
  843. source += ch;
  844. } else if (ch == "]" && in_class) {
  845. in_class = false;
  846. source += ch;
  847. } else if (ch == "/" && !in_class) {
  848. break;
  849. } else if (ch == "\\") {
  850. prev_backslash = true;
  851. } else {
  852. source += ch;
  853. }
  854. const flags = read_name();
  855. return token("regexp", "/" + source + "/" + flags);
  856. });
  857. function read_operator(prefix) {
  858. function grow(op) {
  859. if (!peek()) return op;
  860. var bigger = op + peek();
  861. if (OPERATORS.has(bigger)) {
  862. next();
  863. return grow(bigger);
  864. } else {
  865. return op;
  866. }
  867. }
  868. return token("operator", grow(prefix || next()));
  869. }
  870. function handle_slash() {
  871. next();
  872. switch (peek()) {
  873. case "/":
  874. next();
  875. return skip_line_comment("comment1");
  876. case "*":
  877. next();
  878. return skip_multiline_comment();
  879. }
  880. return S.regex_allowed ? read_regexp("") : read_operator("/");
  881. }
  882. function handle_eq_sign() {
  883. next();
  884. if (peek() === ">") {
  885. next();
  886. return token("arrow", "=>");
  887. } else {
  888. return read_operator("=");
  889. }
  890. }
  891. function handle_dot() {
  892. next();
  893. if (is_digit(peek().charCodeAt(0))) {
  894. return read_num(".");
  895. }
  896. if (peek() === ".") {
  897. next(); // Consume second dot
  898. next(); // Consume third dot
  899. return token("expand", "...");
  900. }
  901. return token("punc", ".");
  902. }
  903. function read_word() {
  904. var word = read_name();
  905. if (prev_was_dot) return token("name", word);
  906. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  907. : !KEYWORDS.has(word) ? token("name", word)
  908. : OPERATORS.has(word) ? token("operator", word)
  909. : token("keyword", word);
  910. }
  911. function read_private_word() {
  912. next();
  913. return token("privatename", read_name());
  914. }
  915. function with_eof_error(eof_error, cont) {
  916. return function(x) {
  917. try {
  918. return cont(x);
  919. } catch(ex) {
  920. if (ex === EX_EOF) parse_error(eof_error);
  921. else throw ex;
  922. }
  923. };
  924. }
  925. function next_token(force_regexp) {
  926. if (force_regexp != null)
  927. return read_regexp(force_regexp);
  928. if (shebang && S.pos == 0 && looking_at("#!")) {
  929. start_token();
  930. forward(2);
  931. skip_line_comment("comment5");
  932. }
  933. for (;;) {
  934. skip_whitespace();
  935. start_token();
  936. if (html5_comments) {
  937. if (looking_at("<!--")) {
  938. forward(4);
  939. skip_line_comment("comment3");
  940. continue;
  941. }
  942. if (looking_at("-->") && S.newline_before) {
  943. forward(3);
  944. skip_line_comment("comment4");
  945. continue;
  946. }
  947. }
  948. var ch = peek();
  949. if (!ch) return token("eof");
  950. var code = ch.charCodeAt(0);
  951. switch (code) {
  952. case 34: case 39: return read_string();
  953. case 46: return handle_dot();
  954. case 47: {
  955. var tok = handle_slash();
  956. if (tok === next_token) continue;
  957. return tok;
  958. }
  959. case 61: return handle_eq_sign();
  960. case 63: {
  961. if (!is_option_chain_op()) break; // Handled below
  962. next(); // ?
  963. next(); // .
  964. return token("punc", "?.");
  965. }
  966. case 96: return read_template_characters(true);
  967. case 123:
  968. S.brace_counter++;
  969. break;
  970. case 125:
  971. S.brace_counter--;
  972. if (S.template_braces.length > 0
  973. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  974. return read_template_characters(false);
  975. break;
  976. }
  977. if (is_digit(code)) return read_num();
  978. if (PUNC_CHARS.has(ch)) return token("punc", next());
  979. if (OPERATOR_CHARS.has(ch)) return read_operator();
  980. if (code == 92 || is_identifier_start(ch)) return read_word();
  981. if (code == 35) return read_private_word();
  982. break;
  983. }
  984. parse_error("Unexpected character '" + ch + "'");
  985. }
  986. next_token.next = next;
  987. next_token.peek = peek;
  988. next_token.context = function(nc) {
  989. if (nc) S = nc;
  990. return S;
  991. };
  992. next_token.add_directive = function(directive) {
  993. S.directive_stack[S.directive_stack.length - 1].push(directive);
  994. if (S.directives[directive] === undefined) {
  995. S.directives[directive] = 1;
  996. } else {
  997. S.directives[directive]++;
  998. }
  999. };
  1000. next_token.push_directives_stack = function() {
  1001. S.directive_stack.push([]);
  1002. };
  1003. next_token.pop_directives_stack = function() {
  1004. var directives = S.directive_stack[S.directive_stack.length - 1];
  1005. for (var i = 0; i < directives.length; i++) {
  1006. S.directives[directives[i]]--;
  1007. }
  1008. S.directive_stack.pop();
  1009. };
  1010. next_token.has_directive = function(directive) {
  1011. return S.directives[directive] > 0;
  1012. };
  1013. return next_token;
  1014. }
  1015. /* -----[ Parser (constants) ]----- */
  1016. var UNARY_PREFIX = makePredicate([
  1017. "typeof",
  1018. "void",
  1019. "delete",
  1020. "--",
  1021. "++",
  1022. "!",
  1023. "~",
  1024. "-",
  1025. "+"
  1026. ]);
  1027. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  1028. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  1029. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  1030. var PRECEDENCE = (function(a, ret) {
  1031. for (var i = 0; i < a.length; ++i) {
  1032. for (const op of a[i]) {
  1033. ret[op] = i + 1;
  1034. }
  1035. }
  1036. return ret;
  1037. })(
  1038. [
  1039. ["||"],
  1040. ["??"],
  1041. ["&&"],
  1042. ["|"],
  1043. ["^"],
  1044. ["&"],
  1045. ["==", "===", "!=", "!=="],
  1046. ["<", ">", "<=", ">=", "in", "instanceof"],
  1047. [">>", "<<", ">>>"],
  1048. ["+", "-"],
  1049. ["*", "/", "%"],
  1050. ["**"]
  1051. ],
  1052. {}
  1053. );
  1054. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name"]);
  1055. /* -----[ Parser ]----- */
  1056. function parse($TEXT, options) {
  1057. // maps start tokens to count of comments found outside of their parens
  1058. // Example: /* I count */ ( /* I don't */ foo() )
  1059. // Useful because comments_before property of call with parens outside
  1060. // contains both comments inside and outside these parens. Used to find the
  1061. const outer_comments_before_counts = new WeakMap();
  1062. options = defaults(options, {
  1063. bare_returns : false,
  1064. ecma : null, // Legacy
  1065. expression : false,
  1066. filename : null,
  1067. html5_comments : true,
  1068. module : false,
  1069. shebang : true,
  1070. strict : false,
  1071. toplevel : null,
  1072. }, true);
  1073. var S = {
  1074. input : (typeof $TEXT == "string"
  1075. ? tokenizer($TEXT, options.filename,
  1076. options.html5_comments, options.shebang)
  1077. : $TEXT),
  1078. token : null,
  1079. prev : null,
  1080. peeked : null,
  1081. in_function : 0,
  1082. in_async : -1,
  1083. in_generator : -1,
  1084. in_directives : true,
  1085. in_loop : 0,
  1086. labels : []
  1087. };
  1088. S.token = next();
  1089. function is(type, value) {
  1090. return is_token(S.token, type, value);
  1091. }
  1092. function peek() { return S.peeked || (S.peeked = S.input()); }
  1093. function next() {
  1094. S.prev = S.token;
  1095. if (!S.peeked) peek();
  1096. S.token = S.peeked;
  1097. S.peeked = null;
  1098. S.in_directives = S.in_directives && (
  1099. S.token.type == "string" || is("punc", ";")
  1100. );
  1101. return S.token;
  1102. }
  1103. function prev() {
  1104. return S.prev;
  1105. }
  1106. function croak(msg, line, col, pos) {
  1107. var ctx = S.input.context();
  1108. js_error(msg,
  1109. ctx.filename,
  1110. line != null ? line : ctx.tokline,
  1111. col != null ? col : ctx.tokcol,
  1112. pos != null ? pos : ctx.tokpos);
  1113. }
  1114. function token_error(token, msg) {
  1115. croak(msg, token.line, token.col);
  1116. }
  1117. function unexpected(token) {
  1118. if (token == null)
  1119. token = S.token;
  1120. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  1121. }
  1122. function expect_token(type, val) {
  1123. if (is(type, val)) {
  1124. return next();
  1125. }
  1126. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  1127. }
  1128. function expect(punc) { return expect_token("punc", punc); }
  1129. function has_newline_before(token) {
  1130. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  1131. }
  1132. function can_insert_semicolon() {
  1133. return !options.strict
  1134. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  1135. }
  1136. function is_in_generator() {
  1137. return S.in_generator === S.in_function;
  1138. }
  1139. function is_in_async() {
  1140. return S.in_async === S.in_function;
  1141. }
  1142. function can_await() {
  1143. return (
  1144. S.in_async === S.in_function
  1145. || S.in_function === 0 && S.input.has_directive("use strict")
  1146. );
  1147. }
  1148. function semicolon(optional) {
  1149. if (is("punc", ";")) next();
  1150. else if (!optional && !can_insert_semicolon()) unexpected();
  1151. }
  1152. function parenthesised() {
  1153. expect("(");
  1154. var exp = expression(true);
  1155. expect(")");
  1156. return exp;
  1157. }
  1158. function embed_tokens(parser) {
  1159. return function _embed_tokens_wrapper(...args) {
  1160. const start = S.token;
  1161. const expr = parser(...args);
  1162. expr.start = start;
  1163. expr.end = prev();
  1164. return expr;
  1165. };
  1166. }
  1167. function handle_regexp() {
  1168. if (is("operator", "/") || is("operator", "/=")) {
  1169. S.peeked = null;
  1170. S.token = S.input(S.token.value.substr(1)); // force regexp
  1171. }
  1172. }
  1173. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  1174. handle_regexp();
  1175. switch (S.token.type) {
  1176. case "string":
  1177. if (S.in_directives) {
  1178. var token = peek();
  1179. if (!LATEST_RAW.includes("\\")
  1180. && (is_token(token, "punc", ";")
  1181. || is_token(token, "punc", "}")
  1182. || has_newline_before(token)
  1183. || is_token(token, "eof"))) {
  1184. S.input.add_directive(S.token.value);
  1185. } else {
  1186. S.in_directives = false;
  1187. }
  1188. }
  1189. var dir = S.in_directives, stat = simple_statement();
  1190. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  1191. case "template_head":
  1192. case "num":
  1193. case "big_int":
  1194. case "regexp":
  1195. case "operator":
  1196. case "atom":
  1197. return simple_statement();
  1198. case "name":
  1199. case "privatename":
  1200. if(is("privatename") && !S.in_class)
  1201. croak("Private field must be used in an enclosing class");
  1202. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  1203. next();
  1204. next();
  1205. if (is_for_body) {
  1206. croak("functions are not allowed as the body of a loop");
  1207. }
  1208. return function_(AST_Defun, false, true, is_export_default);
  1209. }
  1210. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  1211. next();
  1212. var node = import_statement();
  1213. semicolon();
  1214. return node;
  1215. }
  1216. return is_token(peek(), "punc", ":")
  1217. ? labeled_statement()
  1218. : simple_statement();
  1219. case "punc":
  1220. switch (S.token.value) {
  1221. case "{":
  1222. return new AST_BlockStatement({
  1223. start : S.token,
  1224. body : block_(),
  1225. end : prev()
  1226. });
  1227. case "[":
  1228. case "(":
  1229. return simple_statement();
  1230. case ";":
  1231. S.in_directives = false;
  1232. next();
  1233. return new AST_EmptyStatement();
  1234. default:
  1235. unexpected();
  1236. }
  1237. case "keyword":
  1238. switch (S.token.value) {
  1239. case "break":
  1240. next();
  1241. return break_cont(AST_Break);
  1242. case "continue":
  1243. next();
  1244. return break_cont(AST_Continue);
  1245. case "debugger":
  1246. next();
  1247. semicolon();
  1248. return new AST_Debugger();
  1249. case "do":
  1250. next();
  1251. var body = in_loop(statement);
  1252. expect_token("keyword", "while");
  1253. var condition = parenthesised();
  1254. semicolon(true);
  1255. return new AST_Do({
  1256. body : body,
  1257. condition : condition
  1258. });
  1259. case "while":
  1260. next();
  1261. return new AST_While({
  1262. condition : parenthesised(),
  1263. body : in_loop(function() { return statement(false, true); })
  1264. });
  1265. case "for":
  1266. next();
  1267. return for_();
  1268. case "class":
  1269. next();
  1270. if (is_for_body) {
  1271. croak("classes are not allowed as the body of a loop");
  1272. }
  1273. if (is_if_body) {
  1274. croak("classes are not allowed as the body of an if");
  1275. }
  1276. return class_(AST_DefClass, is_export_default);
  1277. case "function":
  1278. next();
  1279. if (is_for_body) {
  1280. croak("functions are not allowed as the body of a loop");
  1281. }
  1282. return function_(AST_Defun, false, false, is_export_default);
  1283. case "if":
  1284. next();
  1285. return if_();
  1286. case "return":
  1287. if (S.in_function == 0 && !options.bare_returns)
  1288. croak("'return' outside of function");
  1289. next();
  1290. var value = null;
  1291. if (is("punc", ";")) {
  1292. next();
  1293. } else if (!can_insert_semicolon()) {
  1294. value = expression(true);
  1295. semicolon();
  1296. }
  1297. return new AST_Return({
  1298. value: value
  1299. });
  1300. case "switch":
  1301. next();
  1302. return new AST_Switch({
  1303. expression : parenthesised(),
  1304. body : in_loop(switch_body_)
  1305. });
  1306. case "throw":
  1307. next();
  1308. if (has_newline_before(S.token))
  1309. croak("Illegal newline after 'throw'");
  1310. var value = expression(true);
  1311. semicolon();
  1312. return new AST_Throw({
  1313. value: value
  1314. });
  1315. case "try":
  1316. next();
  1317. return try_();
  1318. case "var":
  1319. next();
  1320. var node = var_();
  1321. semicolon();
  1322. return node;
  1323. case "let":
  1324. next();
  1325. var node = let_();
  1326. semicolon();
  1327. return node;
  1328. case "const":
  1329. next();
  1330. var node = const_();
  1331. semicolon();
  1332. return node;
  1333. case "with":
  1334. if (S.input.has_directive("use strict")) {
  1335. croak("Strict mode may not include a with statement");
  1336. }
  1337. next();
  1338. return new AST_With({
  1339. expression : parenthesised(),
  1340. body : statement()
  1341. });
  1342. case "export":
  1343. if (!is_token(peek(), "punc", "(")) {
  1344. next();
  1345. var node = export_statement();
  1346. if (is("punc", ";")) semicolon();
  1347. return node;
  1348. }
  1349. }
  1350. }
  1351. unexpected();
  1352. });
  1353. function labeled_statement() {
  1354. var label = as_symbol(AST_Label);
  1355. if (label.name === "await" && is_in_async()) {
  1356. token_error(S.prev, "await cannot be used as label inside async function");
  1357. }
  1358. if (S.labels.some((l) => l.name === label.name)) {
  1359. // ECMA-262, 12.12: An ECMAScript program is considered
  1360. // syntactically incorrect if it contains a
  1361. // LabelledStatement that is enclosed by a
  1362. // LabelledStatement with the same Identifier as label.
  1363. croak("Label " + label.name + " defined twice");
  1364. }
  1365. expect(":");
  1366. S.labels.push(label);
  1367. var stat = statement();
  1368. S.labels.pop();
  1369. if (!(stat instanceof AST_IterationStatement)) {
  1370. // check for `continue` that refers to this label.
  1371. // those should be reported as syntax errors.
  1372. // https://github.com/mishoo/UglifyJS2/issues/287
  1373. label.references.forEach(function(ref) {
  1374. if (ref instanceof AST_Continue) {
  1375. ref = ref.label.start;
  1376. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  1377. ref.line, ref.col, ref.pos);
  1378. }
  1379. });
  1380. }
  1381. return new AST_LabeledStatement({ body: stat, label: label });
  1382. }
  1383. function simple_statement(tmp) {
  1384. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  1385. }
  1386. function break_cont(type) {
  1387. var label = null, ldef;
  1388. if (!can_insert_semicolon()) {
  1389. label = as_symbol(AST_LabelRef, true);
  1390. }
  1391. if (label != null) {
  1392. ldef = S.labels.find((l) => l.name === label.name);
  1393. if (!ldef)
  1394. croak("Undefined label " + label.name);
  1395. label.thedef = ldef;
  1396. } else if (S.in_loop == 0)
  1397. croak(type.TYPE + " not inside a loop or switch");
  1398. semicolon();
  1399. var stat = new type({ label: label });
  1400. if (ldef) ldef.references.push(stat);
  1401. return stat;
  1402. }
  1403. function for_() {
  1404. var for_await_error = "`for await` invalid in this context";
  1405. var await_tok = S.token;
  1406. if (await_tok.type == "name" && await_tok.value == "await") {
  1407. if (!can_await()) {
  1408. token_error(await_tok, for_await_error);
  1409. }
  1410. next();
  1411. } else {
  1412. await_tok = false;
  1413. }
  1414. expect("(");
  1415. var init = null;
  1416. if (!is("punc", ";")) {
  1417. init =
  1418. is("keyword", "var") ? (next(), var_(true)) :
  1419. is("keyword", "let") ? (next(), let_(true)) :
  1420. is("keyword", "const") ? (next(), const_(true)) :
  1421. expression(true, true);
  1422. var is_in = is("operator", "in");
  1423. var is_of = is("name", "of");
  1424. if (await_tok && !is_of) {
  1425. token_error(await_tok, for_await_error);
  1426. }
  1427. if (is_in || is_of) {
  1428. if (init instanceof AST_Definitions) {
  1429. if (init.definitions.length > 1)
  1430. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  1431. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  1432. token_error(init.start, "Invalid left-hand side in for..in loop");
  1433. }
  1434. next();
  1435. if (is_in) {
  1436. return for_in(init);
  1437. } else {
  1438. return for_of(init, !!await_tok);
  1439. }
  1440. }
  1441. } else if (await_tok) {
  1442. token_error(await_tok, for_await_error);
  1443. }
  1444. return regular_for(init);
  1445. }
  1446. function regular_for(init) {
  1447. expect(";");
  1448. var test = is("punc", ";") ? null : expression(true);
  1449. expect(";");
  1450. var step = is("punc", ")") ? null : expression(true);
  1451. expect(")");
  1452. return new AST_For({
  1453. init : init,
  1454. condition : test,
  1455. step : step,
  1456. body : in_loop(function() { return statement(false, true); })
  1457. });
  1458. }
  1459. function for_of(init, is_await) {
  1460. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  1461. var obj = expression(true);
  1462. expect(")");
  1463. return new AST_ForOf({
  1464. await : is_await,
  1465. init : init,
  1466. name : lhs,
  1467. object : obj,
  1468. body : in_loop(function() { return statement(false, true); })
  1469. });
  1470. }
  1471. function for_in(init) {
  1472. var obj = expression(true);
  1473. expect(")");
  1474. return new AST_ForIn({
  1475. init : init,
  1476. object : obj,
  1477. body : in_loop(function() { return statement(false, true); })
  1478. });
  1479. }
  1480. var arrow_function = function(start, argnames, is_async) {
  1481. if (has_newline_before(S.token)) {
  1482. croak("Unexpected newline before arrow (=>)");
  1483. }
  1484. expect_token("arrow", "=>");
  1485. var body = _function_body(is("punc", "{"), false, is_async);
  1486. return new AST_Arrow({
  1487. start : start,
  1488. end : body.end,
  1489. async : is_async,
  1490. argnames : argnames,
  1491. body : body
  1492. });
  1493. };
  1494. var function_ = function(ctor, is_generator, is_async, is_export_default) {
  1495. var in_statement = ctor === AST_Defun;
  1496. if (is("operator", "*")) {
  1497. is_generator = true;
  1498. next();
  1499. }
  1500. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  1501. if (in_statement && !name) {
  1502. if (is_export_default) {
  1503. ctor = AST_Function;
  1504. } else {
  1505. unexpected();
  1506. }
  1507. }
  1508. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  1509. unexpected(prev());
  1510. var args = [];
  1511. var body = _function_body(true, is_generator, is_async, name, args);
  1512. return new ctor({
  1513. start : args.start,
  1514. end : body.end,
  1515. is_generator: is_generator,
  1516. async : is_async,
  1517. name : name,
  1518. argnames: args,
  1519. body : body
  1520. });
  1521. };
  1522. class UsedParametersTracker {
  1523. constructor(is_parameter, strict, duplicates_ok = false) {
  1524. this.is_parameter = is_parameter;
  1525. this.duplicates_ok = duplicates_ok;
  1526. this.parameters = new Set();
  1527. this.duplicate = null;
  1528. this.default_assignment = false;
  1529. this.spread = false;
  1530. this.strict_mode = !!strict;
  1531. }
  1532. add_parameter(token) {
  1533. if (this.parameters.has(token.value)) {
  1534. if (this.duplicate === null) {
  1535. this.duplicate = token;
  1536. }
  1537. this.check_strict();
  1538. } else {
  1539. this.parameters.add(token.value);
  1540. if (this.is_parameter) {
  1541. switch (token.value) {
  1542. case "arguments":
  1543. case "eval":
  1544. case "yield":
  1545. if (this.strict_mode) {
  1546. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1547. }
  1548. break;
  1549. default:
  1550. if (RESERVED_WORDS.has(token.value)) {
  1551. unexpected();
  1552. }
  1553. }
  1554. }
  1555. }
  1556. }
  1557. mark_default_assignment(token) {
  1558. if (this.default_assignment === false) {
  1559. this.default_assignment = token;
  1560. }
  1561. }
  1562. mark_spread(token) {
  1563. if (this.spread === false) {
  1564. this.spread = token;
  1565. }
  1566. }
  1567. mark_strict_mode() {
  1568. this.strict_mode = true;
  1569. }
  1570. is_strict() {
  1571. return this.default_assignment !== false || this.spread !== false || this.strict_mode;
  1572. }
  1573. check_strict() {
  1574. if (this.is_strict() && this.duplicate !== null && !this.duplicates_ok) {
  1575. token_error(this.duplicate, "Parameter " + this.duplicate.value + " was used already");
  1576. }
  1577. }
  1578. }
  1579. function parameters(params) {
  1580. var used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1581. expect("(");
  1582. while (!is("punc", ")")) {
  1583. var param = parameter(used_parameters);
  1584. params.push(param);
  1585. if (!is("punc", ")")) {
  1586. expect(",");
  1587. }
  1588. if (param instanceof AST_Expansion) {
  1589. break;
  1590. }
  1591. }
  1592. next();
  1593. }
  1594. function parameter(used_parameters, symbol_type) {
  1595. var param;
  1596. var expand = false;
  1597. if (used_parameters === undefined) {
  1598. used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1599. }
  1600. if (is("expand", "...")) {
  1601. expand = S.token;
  1602. used_parameters.mark_spread(S.token);
  1603. next();
  1604. }
  1605. param = binding_element(used_parameters, symbol_type);
  1606. if (is("operator", "=") && expand === false) {
  1607. used_parameters.mark_default_assignment(S.token);
  1608. next();
  1609. param = new AST_DefaultAssign({
  1610. start: param.start,
  1611. left: param,
  1612. operator: "=",
  1613. right: expression(false),
  1614. end: S.token
  1615. });
  1616. }
  1617. if (expand !== false) {
  1618. if (!is("punc", ")")) {
  1619. unexpected();
  1620. }
  1621. param = new AST_Expansion({
  1622. start: expand,
  1623. expression: param,
  1624. end: expand
  1625. });
  1626. }
  1627. used_parameters.check_strict();
  1628. return param;
  1629. }
  1630. function binding_element(used_parameters, symbol_type) {
  1631. var elements = [];
  1632. var first = true;
  1633. var is_expand = false;
  1634. var expand_token;
  1635. var first_token = S.token;
  1636. if (used_parameters === undefined) {
  1637. const strict = S.input.has_directive("use strict");
  1638. const duplicates_ok = symbol_type === AST_SymbolVar;
  1639. used_parameters = new UsedParametersTracker(false, strict, duplicates_ok);
  1640. }
  1641. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1642. if (is("punc", "[")) {
  1643. next();
  1644. while (!is("punc", "]")) {
  1645. if (first) {
  1646. first = false;
  1647. } else {
  1648. expect(",");
  1649. }
  1650. if (is("expand", "...")) {
  1651. is_expand = true;
  1652. expand_token = S.token;
  1653. used_parameters.mark_spread(S.token);
  1654. next();
  1655. }
  1656. if (is("punc")) {
  1657. switch (S.token.value) {
  1658. case ",":
  1659. elements.push(new AST_Hole({
  1660. start: S.token,
  1661. end: S.token
  1662. }));
  1663. continue;
  1664. case "]": // Trailing comma after last element
  1665. break;
  1666. case "[":
  1667. case "{":
  1668. elements.push(binding_element(used_parameters, symbol_type));
  1669. break;
  1670. default:
  1671. unexpected();
  1672. }
  1673. } else if (is("name")) {
  1674. used_parameters.add_parameter(S.token);
  1675. elements.push(as_symbol(symbol_type));
  1676. } else {
  1677. croak("Invalid function parameter");
  1678. }
  1679. if (is("operator", "=") && is_expand === false) {
  1680. used_parameters.mark_default_assignment(S.token);
  1681. next();
  1682. elements[elements.length - 1] = new AST_DefaultAssign({
  1683. start: elements[elements.length - 1].start,
  1684. left: elements[elements.length - 1],
  1685. operator: "=",
  1686. right: expression(false),
  1687. end: S.token
  1688. });
  1689. }
  1690. if (is_expand) {
  1691. if (!is("punc", "]")) {
  1692. croak("Rest element must be last element");
  1693. }
  1694. elements[elements.length - 1] = new AST_Expansion({
  1695. start: expand_token,
  1696. expression: elements[elements.length - 1],
  1697. end: expand_token
  1698. });
  1699. }
  1700. }
  1701. expect("]");
  1702. used_parameters.check_strict();
  1703. return new AST_Destructuring({
  1704. start: first_token,
  1705. names: elements,
  1706. is_array: true,
  1707. end: prev()
  1708. });
  1709. } else if (is("punc", "{")) {
  1710. next();
  1711. while (!is("punc", "}")) {
  1712. if (first) {
  1713. first = false;
  1714. } else {
  1715. expect(",");
  1716. }
  1717. if (is("expand", "...")) {
  1718. is_expand = true;
  1719. expand_token = S.token;
  1720. used_parameters.mark_spread(S.token);
  1721. next();
  1722. }
  1723. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1724. used_parameters.add_parameter(S.token);
  1725. var start = prev();
  1726. var value = as_symbol(symbol_type);
  1727. if (is_expand) {
  1728. elements.push(new AST_Expansion({
  1729. start: expand_token,
  1730. expression: value,
  1731. end: value.end,
  1732. }));
  1733. } else {
  1734. elements.push(new AST_ObjectKeyVal({
  1735. start: start,
  1736. key: value.name,
  1737. value: value,
  1738. end: value.end,
  1739. }));
  1740. }
  1741. } else if (is("punc", "}")) {
  1742. continue; // Allow trailing hole
  1743. } else {
  1744. var property_token = S.token;
  1745. var property = as_property_name();
  1746. if (property === null) {
  1747. unexpected(prev());
  1748. } else if (prev().type === "name" && !is("punc", ":")) {
  1749. elements.push(new AST_ObjectKeyVal({
  1750. start: prev(),
  1751. key: property,
  1752. value: new symbol_type({
  1753. start: prev(),
  1754. name: property,
  1755. end: prev()
  1756. }),
  1757. end: prev()
  1758. }));
  1759. } else {
  1760. expect(":");
  1761. elements.push(new AST_ObjectKeyVal({
  1762. start: property_token,
  1763. quote: property_token.quote,
  1764. key: property,
  1765. value: binding_element(used_parameters, symbol_type),
  1766. end: prev()
  1767. }));
  1768. }
  1769. }
  1770. if (is_expand) {
  1771. if (!is("punc", "}")) {
  1772. croak("Rest element must be last element");
  1773. }
  1774. } else if (is("operator", "=")) {
  1775. used_parameters.mark_default_assignment(S.token);
  1776. next();
  1777. elements[elements.length - 1].value = new AST_DefaultAssign({
  1778. start: elements[elements.length - 1].value.start,
  1779. left: elements[elements.length - 1].value,
  1780. operator: "=",
  1781. right: expression(false),
  1782. end: S.token
  1783. });
  1784. }
  1785. }
  1786. expect("}");
  1787. used_parameters.check_strict();
  1788. return new AST_Destructuring({
  1789. start: first_token,
  1790. names: elements,
  1791. is_array: false,
  1792. end: prev()
  1793. });
  1794. } else if (is("name")) {
  1795. used_parameters.add_parameter(S.token);
  1796. return as_symbol(symbol_type);
  1797. } else {
  1798. croak("Invalid function parameter");
  1799. }
  1800. }
  1801. function params_or_seq_(allow_arrows, maybe_sequence) {
  1802. var spread_token;
  1803. var invalid_sequence;
  1804. var trailing_comma;
  1805. var a = [];
  1806. expect("(");
  1807. while (!is("punc", ")")) {
  1808. if (spread_token) unexpected(spread_token);
  1809. if (is("expand", "...")) {
  1810. spread_token = S.token;
  1811. if (maybe_sequence) invalid_sequence = S.token;
  1812. next();
  1813. a.push(new AST_Expansion({
  1814. start: prev(),
  1815. expression: expression(),
  1816. end: S.token,
  1817. }));
  1818. } else {
  1819. a.push(expression());
  1820. }
  1821. if (!is("punc", ")")) {
  1822. expect(",");
  1823. if (is("punc", ")")) {
  1824. trailing_comma = prev();
  1825. if (maybe_sequence) invalid_sequence = trailing_comma;
  1826. }
  1827. }
  1828. }
  1829. expect(")");
  1830. if (allow_arrows && is("arrow", "=>")) {
  1831. if (spread_token && trailing_comma) unexpected(trailing_comma);
  1832. } else if (invalid_sequence) {
  1833. unexpected(invalid_sequence);
  1834. }
  1835. return a;
  1836. }
  1837. function _function_body(block, generator, is_async, name, args) {
  1838. var loop = S.in_loop;
  1839. var labels = S.labels;
  1840. var current_generator = S.in_generator;
  1841. var current_async = S.in_async;
  1842. ++S.in_function;
  1843. if (generator)
  1844. S.in_generator = S.in_function;
  1845. if (is_async)
  1846. S.in_async = S.in_function;
  1847. if (args) parameters(args);
  1848. if (block)
  1849. S.in_directives = true;
  1850. S.in_loop = 0;
  1851. S.labels = [];
  1852. if (block) {
  1853. S.input.push_directives_stack();
  1854. var a = block_();
  1855. if (name) _verify_symbol(name);
  1856. if (args) args.forEach(_verify_symbol);
  1857. S.input.pop_directives_stack();
  1858. } else {
  1859. var a = [new AST_Return({
  1860. start: S.token,
  1861. value: expression(false),
  1862. end: S.token
  1863. })];
  1864. }
  1865. --S.in_function;
  1866. S.in_loop = loop;
  1867. S.labels = labels;
  1868. S.in_generator = current_generator;
  1869. S.in_async = current_async;
  1870. return a;
  1871. }
  1872. function _await_expression() {
  1873. // Previous token must be "await" and not be interpreted as an identifier
  1874. if (!can_await()) {
  1875. croak("Unexpected await expression outside async function",
  1876. S.prev.line, S.prev.col, S.prev.pos);
  1877. }
  1878. // the await expression is parsed as a unary expression in Babel
  1879. return new AST_Await({
  1880. start: prev(),
  1881. end: S.token,
  1882. expression : maybe_unary(true),
  1883. });
  1884. }
  1885. function _yield_expression() {
  1886. var start = S.token;
  1887. var star = false;
  1888. var has_expression = true;
  1889. // Attempt to get expression or star (and then the mandatory expression)
  1890. // behind yield on the same line.
  1891. //
  1892. // If nothing follows on the same line of the yieldExpression,
  1893. // it should default to the value `undefined` for yield to return.
  1894. // In that case, the `undefined` stored as `null` in ast.
  1895. //
  1896. // Note 1: It isn't allowed for yield* to close without an expression
  1897. // Note 2: If there is a nlb between yield and star, it is interpret as
  1898. // yield <explicit undefined> <inserted automatic semicolon> *
  1899. if (
  1900. can_insert_semicolon()
  1901. || is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value)
  1902. || is("template_cont")
  1903. ) {
  1904. has_expression = false;
  1905. } else if (is("operator", "*")) {
  1906. star = true;
  1907. next();
  1908. }
  1909. return new AST_Yield({
  1910. start : start,
  1911. is_star : star,
  1912. expression : has_expression ? expression() : null,
  1913. end : prev()
  1914. });
  1915. }
  1916. function if_() {
  1917. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  1918. if (is("keyword", "else")) {
  1919. next();
  1920. belse = statement(false, false, true);
  1921. }
  1922. return new AST_If({
  1923. condition : cond,
  1924. body : body,
  1925. alternative : belse
  1926. });
  1927. }
  1928. function block_() {
  1929. expect("{");
  1930. var a = [];
  1931. while (!is("punc", "}")) {
  1932. if (is("eof")) unexpected();
  1933. a.push(statement());
  1934. }
  1935. next();
  1936. return a;
  1937. }
  1938. function switch_body_() {
  1939. expect("{");
  1940. var a = [], cur = null, branch = null, tmp;
  1941. while (!is("punc", "}")) {
  1942. if (is("eof")) unexpected();
  1943. if (is("keyword", "case")) {
  1944. if (branch) branch.end = prev();
  1945. cur = [];
  1946. branch = new AST_Case({
  1947. start : (tmp = S.token, next(), tmp),
  1948. expression : expression(true),
  1949. body : cur
  1950. });
  1951. a.push(branch);
  1952. expect(":");
  1953. } else if (is("keyword", "default")) {
  1954. if (branch) branch.end = prev();
  1955. cur = [];
  1956. branch = new AST_Default({
  1957. start : (tmp = S.token, next(), expect(":"), tmp),
  1958. body : cur
  1959. });
  1960. a.push(branch);
  1961. } else {
  1962. if (!cur) unexpected();
  1963. cur.push(statement());
  1964. }
  1965. }
  1966. if (branch) branch.end = prev();
  1967. next();
  1968. return a;
  1969. }
  1970. function try_() {
  1971. var body, bcatch = null, bfinally = null;
  1972. body = new AST_TryBlock({
  1973. start : S.token,
  1974. body : block_(),
  1975. end : prev(),
  1976. });
  1977. if (is("keyword", "catch")) {
  1978. var start = S.token;
  1979. next();
  1980. if (is("punc", "{")) {
  1981. var name = null;
  1982. } else {
  1983. expect("(");
  1984. var name = parameter(undefined, AST_SymbolCatch);
  1985. expect(")");
  1986. }
  1987. bcatch = new AST_Catch({
  1988. start : start,
  1989. argname : name,
  1990. body : block_(),
  1991. end : prev()
  1992. });
  1993. }
  1994. if (is("keyword", "finally")) {
  1995. var start = S.token;
  1996. next();
  1997. bfinally = new AST_Finally({
  1998. start : start,
  1999. body : block_(),
  2000. end : prev()
  2001. });
  2002. }
  2003. if (!bcatch && !bfinally)
  2004. croak("Missing catch/finally blocks");
  2005. return new AST_Try({
  2006. body : body,
  2007. bcatch : bcatch,
  2008. bfinally : bfinally
  2009. });
  2010. }
  2011. /**
  2012. * var
  2013. * vardef1 = 2,
  2014. * vardef2 = 3;
  2015. */
  2016. function vardefs(no_in, kind) {
  2017. var var_defs = [];
  2018. var def;
  2019. for (;;) {
  2020. var sym_type =
  2021. kind === "var" ? AST_SymbolVar :
  2022. kind === "const" ? AST_SymbolConst :
  2023. kind === "let" ? AST_SymbolLet : null;
  2024. // var { a } = b
  2025. if (is("punc", "{") || is("punc", "[")) {
  2026. def = new AST_VarDef({
  2027. start: S.token,
  2028. name: binding_element(undefined, sym_type),
  2029. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  2030. end: prev()
  2031. });
  2032. } else {
  2033. def = new AST_VarDef({
  2034. start : S.token,
  2035. name : as_symbol(sym_type),
  2036. value : is("operator", "=")
  2037. ? (next(), expression(false, no_in))
  2038. : !no_in && kind === "const"
  2039. ? croak("Missing initializer in const declaration") : null,
  2040. end : prev()
  2041. });
  2042. if (def.name.name == "import") croak("Unexpected token: import");
  2043. }
  2044. var_defs.push(def);
  2045. if (!is("punc", ","))
  2046. break;
  2047. next();
  2048. }
  2049. return var_defs;
  2050. }
  2051. var var_ = function(no_in) {
  2052. return new AST_Var({
  2053. start : prev(),
  2054. definitions : vardefs(no_in, "var"),
  2055. end : prev()
  2056. });
  2057. };
  2058. var let_ = function(no_in) {
  2059. return new AST_Let({
  2060. start : prev(),
  2061. definitions : vardefs(no_in, "let"),
  2062. end : prev()
  2063. });
  2064. };
  2065. var const_ = function(no_in) {
  2066. return new AST_Const({
  2067. start : prev(),
  2068. definitions : vardefs(no_in, "const"),
  2069. end : prev()
  2070. });
  2071. };
  2072. var new_ = function(allow_calls) {
  2073. var start = S.token;
  2074. expect_token("operator", "new");
  2075. if (is("punc", ".")) {
  2076. next();
  2077. expect_token("name", "target");
  2078. return subscripts(new AST_NewTarget({
  2079. start : start,
  2080. end : prev()
  2081. }), allow_calls);
  2082. }
  2083. var newexp = expr_atom(false), args;
  2084. if (is("punc", "(")) {
  2085. next();
  2086. args = expr_list(")", true);
  2087. } else {
  2088. args = [];
  2089. }
  2090. var call = new AST_New({
  2091. start : start,
  2092. expression : newexp,
  2093. args : args,
  2094. end : prev()
  2095. });
  2096. annotate(call);
  2097. return subscripts(call, allow_calls);
  2098. };
  2099. function as_atom_node() {
  2100. var tok = S.token, ret;
  2101. switch (tok.type) {
  2102. case "name":
  2103. ret = _make_symbol(AST_SymbolRef);
  2104. break;
  2105. case "num":
  2106. ret = new AST_Number({
  2107. start: tok,
  2108. end: tok,
  2109. value: tok.value,
  2110. raw: LATEST_RAW
  2111. });
  2112. break;
  2113. case "big_int":
  2114. ret = new AST_BigInt({
  2115. start: tok,
  2116. end: tok,
  2117. value: tok.value,
  2118. raw: LATEST_RAW,
  2119. });
  2120. break;
  2121. case "string":
  2122. ret = new AST_String({
  2123. start : tok,
  2124. end : tok,
  2125. value : tok.value,
  2126. quote : tok.quote
  2127. });
  2128. annotate(ret);
  2129. break;
  2130. case "regexp":
  2131. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  2132. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  2133. break;
  2134. case "atom":
  2135. switch (tok.value) {
  2136. case "false":
  2137. ret = new AST_False({ start: tok, end: tok });
  2138. break;
  2139. case "true":
  2140. ret = new AST_True({ start: tok, end: tok });
  2141. break;
  2142. case "null":
  2143. ret = new AST_Null({ start: tok, end: tok });
  2144. break;
  2145. }
  2146. break;
  2147. }
  2148. next();
  2149. return ret;
  2150. }
  2151. function to_fun_args(ex, default_seen_above) {
  2152. var insert_default = function(ex, default_value) {
  2153. if (default_value) {
  2154. return new AST_DefaultAssign({
  2155. start: ex.start,
  2156. left: ex,
  2157. operator: "=",
  2158. right: default_value,
  2159. end: default_value.end
  2160. });
  2161. }
  2162. return ex;
  2163. };
  2164. if (ex instanceof AST_Object) {
  2165. return insert_default(new AST_Destructuring({
  2166. start: ex.start,
  2167. end: ex.end,
  2168. is_array: false,
  2169. names: ex.properties.map(prop => to_fun_args(prop))
  2170. }), default_seen_above);
  2171. } else if (ex instanceof AST_ObjectKeyVal) {
  2172. ex.value = to_fun_args(ex.value);
  2173. return insert_default(ex, default_seen_above);
  2174. } else if (ex instanceof AST_Hole) {
  2175. return ex;
  2176. } else if (ex instanceof AST_Destructuring) {
  2177. ex.names = ex.names.map(name => to_fun_args(name));
  2178. return insert_default(ex, default_seen_above);
  2179. } else if (ex instanceof AST_SymbolRef) {
  2180. return insert_default(new AST_SymbolFunarg({
  2181. name: ex.name,
  2182. start: ex.start,
  2183. end: ex.end
  2184. }), default_seen_above);
  2185. } else if (ex instanceof AST_Expansion) {
  2186. ex.expression = to_fun_args(ex.expression);
  2187. return insert_default(ex, default_seen_above);
  2188. } else if (ex instanceof AST_Array) {
  2189. return insert_default(new AST_Destructuring({
  2190. start: ex.start,
  2191. end: ex.end,
  2192. is_array: true,
  2193. names: ex.elements.map(elm => to_fun_args(elm))
  2194. }), default_seen_above);
  2195. } else if (ex instanceof AST_Assign) {
  2196. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2197. } else if (ex instanceof AST_DefaultAssign) {
  2198. ex.left = to_fun_args(ex.left);
  2199. return ex;
  2200. } else {
  2201. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2202. }
  2203. }
  2204. var expr_atom = function(allow_calls, allow_arrows) {
  2205. if (is("operator", "new")) {
  2206. return new_(allow_calls);
  2207. }
  2208. if (is("name", "import") && is_token(peek(), "punc", ".")) {
  2209. return import_meta(allow_calls);
  2210. }
  2211. var start = S.token;
  2212. var peeked;
  2213. var async = is("name", "async")
  2214. && (peeked = peek()).value != "["
  2215. && peeked.type != "arrow"
  2216. && as_atom_node();
  2217. if (is("punc")) {
  2218. switch (S.token.value) {
  2219. case "(":
  2220. if (async && !allow_calls) break;
  2221. var exprs = params_or_seq_(allow_arrows, !async);
  2222. if (allow_arrows && is("arrow", "=>")) {
  2223. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2224. }
  2225. var ex = async ? new AST_Call({
  2226. expression: async,
  2227. args: exprs
  2228. }) : to_expr_or_sequence(start, exprs);
  2229. if (ex.start) {
  2230. const outer_comments_before = start.comments_before.length;
  2231. outer_comments_before_counts.set(start, outer_comments_before);
  2232. ex.start.comments_before.unshift(...start.comments_before);
  2233. start.comments_before = ex.start.comments_before;
  2234. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2235. var comment = start.comments_before[0];
  2236. if (!comment.nlb) {
  2237. comment.nlb = start.nlb;
  2238. start.nlb = false;
  2239. }
  2240. }
  2241. start.comments_after = ex.start.comments_after;
  2242. }
  2243. ex.start = start;
  2244. var end = prev();
  2245. if (ex.end) {
  2246. end.comments_before = ex.end.comments_before;
  2247. ex.end.comments_after.push(...end.comments_after);
  2248. end.comments_after = ex.end.comments_after;
  2249. }
  2250. ex.end = end;
  2251. if (ex instanceof AST_Call) annotate(ex);
  2252. return subscripts(ex, allow_calls);
  2253. case "[":
  2254. return subscripts(array_(), allow_calls);
  2255. case "{":
  2256. return subscripts(object_or_destructuring_(), allow_calls);
  2257. }
  2258. if (!async) unexpected();
  2259. }
  2260. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2261. var param = new AST_SymbolFunarg({
  2262. name: S.token.value,
  2263. start: start,
  2264. end: start,
  2265. });
  2266. next();
  2267. return arrow_function(start, [param], !!async);
  2268. }
  2269. if (is("keyword", "function")) {
  2270. next();
  2271. var func = function_(AST_Function, false, !!async);
  2272. func.start = start;
  2273. func.end = prev();
  2274. return subscripts(func, allow_calls);
  2275. }
  2276. if (async) return subscripts(async, allow_calls);
  2277. if (is("keyword", "class")) {
  2278. next();
  2279. var cls = class_(AST_ClassExpression);
  2280. cls.start = start;
  2281. cls.end = prev();
  2282. return subscripts(cls, allow_calls);
  2283. }
  2284. if (is("template_head")) {
  2285. return subscripts(template_string(), allow_calls);
  2286. }
  2287. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2288. return subscripts(as_atom_node(), allow_calls);
  2289. }
  2290. unexpected();
  2291. };
  2292. function template_string() {
  2293. var segments = [], start = S.token;
  2294. segments.push(new AST_TemplateSegment({
  2295. start: S.token,
  2296. raw: TEMPLATE_RAWS.get(S.token),
  2297. value: S.token.value,
  2298. end: S.token
  2299. }));
  2300. while (!S.token.template_end) {
  2301. next();
  2302. handle_regexp();
  2303. segments.push(expression(true));
  2304. segments.push(new AST_TemplateSegment({
  2305. start: S.token,
  2306. raw: TEMPLATE_RAWS.get(S.token),
  2307. value: S.token.value,
  2308. end: S.token
  2309. }));
  2310. }
  2311. next();
  2312. return new AST_TemplateString({
  2313. start: start,
  2314. segments: segments,
  2315. end: S.token
  2316. });
  2317. }
  2318. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2319. var first = true, a = [];
  2320. while (!is("punc", closing)) {
  2321. if (first) first = false; else expect(",");
  2322. if (allow_trailing_comma && is("punc", closing)) break;
  2323. if (is("punc", ",") && allow_empty) {
  2324. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2325. } else if (is("expand", "...")) {
  2326. next();
  2327. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2328. } else {
  2329. a.push(expression(false));
  2330. }
  2331. }
  2332. next();
  2333. return a;
  2334. }
  2335. var array_ = embed_tokens(function() {
  2336. expect("[");
  2337. return new AST_Array({
  2338. elements: expr_list("]", !options.strict, true)
  2339. });
  2340. });
  2341. var create_accessor = embed_tokens((is_generator, is_async) => {
  2342. return function_(AST_Accessor, is_generator, is_async);
  2343. });
  2344. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2345. var start = S.token, first = true, a = [];
  2346. expect("{");
  2347. while (!is("punc", "}")) {
  2348. if (first) first = false; else expect(",");
  2349. if (!options.strict && is("punc", "}"))
  2350. // allow trailing comma
  2351. break;
  2352. start = S.token;
  2353. if (start.type == "expand") {
  2354. next();
  2355. a.push(new AST_Expansion({
  2356. start: start,
  2357. expression: expression(false),
  2358. end: prev(),
  2359. }));
  2360. continue;
  2361. }
  2362. if(is("privatename")) {
  2363. croak("private fields are not allowed in an object");
  2364. }
  2365. var name = as_property_name();
  2366. var value;
  2367. // Check property and fetch value
  2368. if (!is("punc", ":")) {
  2369. var concise = object_or_class_property(name, start);
  2370. if (concise) {
  2371. a.push(concise);
  2372. continue;
  2373. }
  2374. value = new AST_SymbolRef({
  2375. start: prev(),
  2376. name: name,
  2377. end: prev()
  2378. });
  2379. } else if (name === null) {
  2380. unexpected(prev());
  2381. } else {
  2382. next(); // `:` - see first condition
  2383. value = expression(false);
  2384. }
  2385. // Check for default value and alter value accordingly if necessary
  2386. if (is("operator", "=")) {
  2387. next();
  2388. value = new AST_Assign({
  2389. start: start,
  2390. left: value,
  2391. operator: "=",
  2392. right: expression(false),
  2393. logical: false,
  2394. end: prev()
  2395. });
  2396. }
  2397. // Create property
  2398. const kv = new AST_ObjectKeyVal({
  2399. start: start,
  2400. quote: start.quote,
  2401. key: name,
  2402. value: value,
  2403. end: prev()
  2404. });
  2405. a.push(annotate(kv));
  2406. }
  2407. next();
  2408. return new AST_Object({ properties: a });
  2409. });
  2410. function class_(KindOfClass, is_export_default) {
  2411. var start, method, class_name, extends_, properties = [];
  2412. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2413. S.input.add_directive("use strict");
  2414. if (S.token.type == "name" && S.token.value != "extends") {
  2415. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2416. }
  2417. if (KindOfClass === AST_DefClass && !class_name) {
  2418. if (is_export_default) {
  2419. KindOfClass = AST_ClassExpression;
  2420. } else {
  2421. unexpected();
  2422. }
  2423. }
  2424. if (S.token.value == "extends") {
  2425. next();
  2426. extends_ = expression(true);
  2427. }
  2428. expect("{");
  2429. // mark in class feild,
  2430. const save_in_class = S.in_class;
  2431. S.in_class = true;
  2432. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2433. while (!is("punc", "}")) {
  2434. start = S.token;
  2435. method = object_or_class_property(as_property_name(), start, true);
  2436. if (!method) { unexpected(); }
  2437. properties.push(method);
  2438. while (is("punc", ";")) { next(); }
  2439. }
  2440. // mark in class feild,
  2441. S.in_class = save_in_class;
  2442. S.input.pop_directives_stack();
  2443. next();
  2444. return new KindOfClass({
  2445. start: start,
  2446. name: class_name,
  2447. extends: extends_,
  2448. properties: properties,
  2449. end: prev(),
  2450. });
  2451. }
  2452. function object_or_class_property(name, start, is_class) {
  2453. const get_symbol_ast = (name, SymbolClass) => {
  2454. if (typeof name === "string") {
  2455. return new SymbolClass({ start, name, end: prev() });
  2456. } else if (name === null) {
  2457. unexpected();
  2458. }
  2459. return name;
  2460. };
  2461. const is_not_method_start = () =>
  2462. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=");
  2463. var is_async = false;
  2464. var is_static = false;
  2465. var is_generator = false;
  2466. var is_private = false;
  2467. var accessor_type = null;
  2468. if (is_class && name === "static" && is_not_method_start()) {
  2469. const static_block = class_static_block();
  2470. if (static_block != null) {
  2471. return static_block;
  2472. }
  2473. is_static = true;
  2474. name = as_property_name();
  2475. }
  2476. if (name === "async" && is_not_method_start()) {
  2477. is_async = true;
  2478. name = as_property_name();
  2479. }
  2480. if (prev().type === "operator" && prev().value === "*") {
  2481. is_generator = true;
  2482. name = as_property_name();
  2483. }
  2484. if ((name === "get" || name === "set") && is_not_method_start()) {
  2485. accessor_type = name;
  2486. name = as_property_name();
  2487. }
  2488. if (prev().type === "privatename") {
  2489. is_private = true;
  2490. }
  2491. const property_token = prev();
  2492. if (accessor_type != null) {
  2493. if (!is_private) {
  2494. const AccessorClass = accessor_type === "get"
  2495. ? AST_ObjectGetter
  2496. : AST_ObjectSetter;
  2497. name = get_symbol_ast(name, AST_SymbolMethod);
  2498. return annotate(new AccessorClass({
  2499. start,
  2500. static: is_static,
  2501. key: name,
  2502. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  2503. value: create_accessor(),
  2504. end: prev()
  2505. }));
  2506. } else {
  2507. const AccessorClass = accessor_type === "get"
  2508. ? AST_PrivateGetter
  2509. : AST_PrivateSetter;
  2510. return annotate(new AccessorClass({
  2511. start,
  2512. static: is_static,
  2513. key: get_symbol_ast(name, AST_SymbolMethod),
  2514. value: create_accessor(),
  2515. end: prev(),
  2516. }));
  2517. }
  2518. }
  2519. if (is("punc", "(")) {
  2520. name = get_symbol_ast(name, AST_SymbolMethod);
  2521. const AST_MethodVariant = is_private
  2522. ? AST_PrivateMethod
  2523. : AST_ConciseMethod;
  2524. var node = new AST_MethodVariant({
  2525. start : start,
  2526. static : is_static,
  2527. key : name,
  2528. quote : name instanceof AST_SymbolMethod ?
  2529. property_token.quote : undefined,
  2530. value : create_accessor(is_generator, is_async),
  2531. end : prev()
  2532. });
  2533. return annotate(node);
  2534. }
  2535. if (is_class) {
  2536. const AST_SymbolVariant = is_private
  2537. ? AST_SymbolPrivateProperty
  2538. : AST_SymbolClassProperty;
  2539. const AST_ClassPropertyVariant = is_private
  2540. ? AST_ClassPrivateProperty
  2541. : AST_ClassProperty;
  2542. const key = get_symbol_ast(name, AST_SymbolVariant);
  2543. const quote = key instanceof AST_SymbolClassProperty
  2544. ? property_token.quote
  2545. : undefined;
  2546. if (is("operator", "=")) {
  2547. next();
  2548. return annotate(
  2549. new AST_ClassPropertyVariant({
  2550. start,
  2551. static: is_static,
  2552. quote,
  2553. key,
  2554. value: expression(false),
  2555. end: prev()
  2556. })
  2557. );
  2558. } else if (
  2559. is("name")
  2560. || is("privatename")
  2561. || is("punc", "[")
  2562. || is("operator", "*")
  2563. || is("punc", ";")
  2564. || is("punc", "}")
  2565. || is("string")
  2566. || is("num")
  2567. || is("big_int")
  2568. ) {
  2569. return annotate(
  2570. new AST_ClassPropertyVariant({
  2571. start,
  2572. static: is_static,
  2573. quote,
  2574. key,
  2575. end: prev()
  2576. })
  2577. );
  2578. }
  2579. }
  2580. }
  2581. function class_static_block() {
  2582. if (!is("punc", "{")) {
  2583. return null;
  2584. }
  2585. const start = S.token;
  2586. const body = [];
  2587. next();
  2588. while (!is("punc", "}")) {
  2589. body.push(statement());
  2590. }
  2591. next();
  2592. return new AST_ClassStaticBlock({ start, body, end: prev() });
  2593. }
  2594. function maybe_import_attributes() {
  2595. if (
  2596. (is("keyword", "with") || is("name", "assert"))
  2597. && !has_newline_before(S.token)
  2598. ) {
  2599. next();
  2600. return object_or_destructuring_();
  2601. }
  2602. return null;
  2603. }
  2604. function import_statement() {
  2605. var start = prev();
  2606. var imported_name;
  2607. var imported_names;
  2608. if (is("name")) {
  2609. imported_name = as_symbol(AST_SymbolImport);
  2610. }
  2611. if (is("punc", ",")) {
  2612. next();
  2613. }
  2614. imported_names = map_names(true);
  2615. if (imported_names || imported_name) {
  2616. expect_token("name", "from");
  2617. }
  2618. var mod_str = S.token;
  2619. if (mod_str.type !== "string") {
  2620. unexpected();
  2621. }
  2622. next();
  2623. const attributes = maybe_import_attributes();
  2624. return new AST_Import({
  2625. start,
  2626. imported_name,
  2627. imported_names,
  2628. module_name: new AST_String({
  2629. start: mod_str,
  2630. value: mod_str.value,
  2631. quote: mod_str.quote,
  2632. end: mod_str,
  2633. }),
  2634. attributes,
  2635. end: S.token,
  2636. });
  2637. }
  2638. function import_meta(allow_calls) {
  2639. var start = S.token;
  2640. expect_token("name", "import");
  2641. expect_token("punc", ".");
  2642. expect_token("name", "meta");
  2643. return subscripts(new AST_ImportMeta({
  2644. start: start,
  2645. end: prev()
  2646. }), allow_calls);
  2647. }
  2648. function map_name(is_import) {
  2649. function make_symbol(type, quote) {
  2650. return new type({
  2651. name: as_property_name(),
  2652. quote: quote || undefined,
  2653. start: prev(),
  2654. end: prev()
  2655. });
  2656. }
  2657. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2658. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2659. var start = S.token;
  2660. var foreign_name;
  2661. var name;
  2662. if (is_import) {
  2663. foreign_name = make_symbol(foreign_type, start.quote);
  2664. } else {
  2665. name = make_symbol(type, start.quote);
  2666. }
  2667. if (is("name", "as")) {
  2668. next(); // The "as" word
  2669. if (is_import) {
  2670. name = make_symbol(type);
  2671. } else {
  2672. foreign_name = make_symbol(foreign_type, S.token.quote);
  2673. }
  2674. } else {
  2675. if (is_import) {
  2676. name = new type(foreign_name);
  2677. } else {
  2678. foreign_name = new foreign_type(name);
  2679. }
  2680. }
  2681. return new AST_NameMapping({
  2682. start: start,
  2683. foreign_name: foreign_name,
  2684. name: name,
  2685. end: prev(),
  2686. });
  2687. }
  2688. function map_nameAsterisk(is_import, import_or_export_foreign_name) {
  2689. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2690. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2691. var start = S.token;
  2692. var name, foreign_name;
  2693. var end = prev();
  2694. if (is_import) {
  2695. name = import_or_export_foreign_name;
  2696. } else {
  2697. foreign_name = import_or_export_foreign_name;
  2698. }
  2699. name = name || new type({
  2700. start: start,
  2701. name: "*",
  2702. end: end,
  2703. });
  2704. foreign_name = foreign_name || new foreign_type({
  2705. start: start,
  2706. name: "*",
  2707. end: end,
  2708. });
  2709. return new AST_NameMapping({
  2710. start: start,
  2711. foreign_name: foreign_name,
  2712. name: name,
  2713. end: end,
  2714. });
  2715. }
  2716. function map_names(is_import) {
  2717. var names;
  2718. if (is("punc", "{")) {
  2719. next();
  2720. names = [];
  2721. while (!is("punc", "}")) {
  2722. names.push(map_name(is_import));
  2723. if (is("punc", ",")) {
  2724. next();
  2725. }
  2726. }
  2727. next();
  2728. } else if (is("operator", "*")) {
  2729. var name;
  2730. next();
  2731. if (is("name", "as")) {
  2732. next(); // The "as" word
  2733. name = is_import ? as_symbol(AST_SymbolImport) : as_symbol_or_string(AST_SymbolExportForeign);
  2734. }
  2735. names = [map_nameAsterisk(is_import, name)];
  2736. }
  2737. return names;
  2738. }
  2739. function export_statement() {
  2740. var start = S.token;
  2741. var is_default;
  2742. var exported_names;
  2743. if (is("keyword", "default")) {
  2744. is_default = true;
  2745. next();
  2746. } else if (exported_names = map_names(false)) {
  2747. if (is("name", "from")) {
  2748. next();
  2749. var mod_str = S.token;
  2750. if (mod_str.type !== "string") {
  2751. unexpected();
  2752. }
  2753. next();
  2754. const attributes = maybe_import_attributes();
  2755. return new AST_Export({
  2756. start: start,
  2757. is_default: is_default,
  2758. exported_names: exported_names,
  2759. module_name: new AST_String({
  2760. start: mod_str,
  2761. value: mod_str.value,
  2762. quote: mod_str.quote,
  2763. end: mod_str,
  2764. }),
  2765. end: prev(),
  2766. attributes
  2767. });
  2768. } else {
  2769. return new AST_Export({
  2770. start: start,
  2771. is_default: is_default,
  2772. exported_names: exported_names,
  2773. end: prev(),
  2774. });
  2775. }
  2776. }
  2777. var node;
  2778. var exported_value;
  2779. var exported_definition;
  2780. if (is("punc", "{")
  2781. || is_default
  2782. && (is("keyword", "class") || is("keyword", "function"))
  2783. && is_token(peek(), "punc")) {
  2784. exported_value = expression(false);
  2785. semicolon();
  2786. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2787. unexpected(node.start);
  2788. } else if (
  2789. node instanceof AST_Definitions
  2790. || node instanceof AST_Defun
  2791. || node instanceof AST_DefClass
  2792. ) {
  2793. exported_definition = node;
  2794. } else if (
  2795. node instanceof AST_ClassExpression
  2796. || node instanceof AST_Function
  2797. ) {
  2798. exported_value = node;
  2799. } else if (node instanceof AST_SimpleStatement) {
  2800. exported_value = node.body;
  2801. } else {
  2802. unexpected(node.start);
  2803. }
  2804. return new AST_Export({
  2805. start: start,
  2806. is_default: is_default,
  2807. exported_value: exported_value,
  2808. exported_definition: exported_definition,
  2809. end: prev(),
  2810. attributes: null
  2811. });
  2812. }
  2813. function as_property_name() {
  2814. var tmp = S.token;
  2815. switch (tmp.type) {
  2816. case "punc":
  2817. if (tmp.value === "[") {
  2818. next();
  2819. var ex = expression(false);
  2820. expect("]");
  2821. return ex;
  2822. } else unexpected(tmp);
  2823. case "operator":
  2824. if (tmp.value === "*") {
  2825. next();
  2826. return null;
  2827. }
  2828. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2829. unexpected(tmp);
  2830. }
  2831. /* falls through */
  2832. case "name":
  2833. case "privatename":
  2834. case "string":
  2835. case "keyword":
  2836. case "atom":
  2837. next();
  2838. return tmp.value;
  2839. case "num":
  2840. case "big_int":
  2841. next();
  2842. return "" + tmp.value;
  2843. default:
  2844. unexpected(tmp);
  2845. }
  2846. }
  2847. function as_name() {
  2848. var tmp = S.token;
  2849. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  2850. next();
  2851. return tmp.value;
  2852. }
  2853. function _make_symbol(type) {
  2854. var name = S.token.value;
  2855. return new (name == "this" ? AST_This :
  2856. name == "super" ? AST_Super :
  2857. type)({
  2858. name : String(name),
  2859. start : S.token,
  2860. end : S.token
  2861. });
  2862. }
  2863. function _verify_symbol(sym) {
  2864. var name = sym.name;
  2865. if (is_in_generator() && name == "yield") {
  2866. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2867. }
  2868. if (S.input.has_directive("use strict")) {
  2869. if (name == "yield") {
  2870. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2871. }
  2872. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2873. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2874. }
  2875. }
  2876. }
  2877. function as_symbol(type, noerror) {
  2878. if (!is("name")) {
  2879. if (!noerror) croak("Name expected");
  2880. return null;
  2881. }
  2882. var sym = _make_symbol(type);
  2883. _verify_symbol(sym);
  2884. next();
  2885. return sym;
  2886. }
  2887. function as_symbol_or_string(type) {
  2888. if (!is("name")) {
  2889. if (!is("string")) {
  2890. croak("Name or string expected");
  2891. }
  2892. var tok = S.token;
  2893. var ret = new type({
  2894. start : tok,
  2895. end : tok,
  2896. name : tok.value,
  2897. quote : tok.quote
  2898. });
  2899. next();
  2900. return ret;
  2901. }
  2902. var sym = _make_symbol(type);
  2903. _verify_symbol(sym);
  2904. next();
  2905. return sym;
  2906. }
  2907. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2908. function annotate(node, before_token = node.start) {
  2909. var comments = before_token.comments_before;
  2910. const comments_outside_parens = outer_comments_before_counts.get(before_token);
  2911. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2912. while (--i >= 0) {
  2913. var comment = comments[i];
  2914. if (/[@#]__/.test(comment.value)) {
  2915. if (/[@#]__PURE__/.test(comment.value)) {
  2916. set_annotation(node, _PURE);
  2917. break;
  2918. }
  2919. if (/[@#]__INLINE__/.test(comment.value)) {
  2920. set_annotation(node, _INLINE);
  2921. break;
  2922. }
  2923. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2924. set_annotation(node, _NOINLINE);
  2925. break;
  2926. }
  2927. if (/[@#]__KEY__/.test(comment.value)) {
  2928. set_annotation(node, _KEY);
  2929. break;
  2930. }
  2931. if (/[@#]__MANGLE_PROP__/.test(comment.value)) {
  2932. set_annotation(node, _MANGLEPROP);
  2933. break;
  2934. }
  2935. }
  2936. }
  2937. return node;
  2938. }
  2939. var subscripts = function(expr, allow_calls, is_chain) {
  2940. var start = expr.start;
  2941. if (is("punc", ".")) {
  2942. next();
  2943. if(is("privatename") && !S.in_class)
  2944. croak("Private field must be used in an enclosing class");
  2945. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2946. return annotate(subscripts(new AST_DotVariant({
  2947. start : start,
  2948. expression : expr,
  2949. optional : false,
  2950. property : as_name(),
  2951. end : prev()
  2952. }), allow_calls, is_chain));
  2953. }
  2954. if (is("punc", "[")) {
  2955. next();
  2956. var prop = expression(true);
  2957. expect("]");
  2958. return annotate(subscripts(new AST_Sub({
  2959. start : start,
  2960. expression : expr,
  2961. optional : false,
  2962. property : prop,
  2963. end : prev()
  2964. }), allow_calls, is_chain));
  2965. }
  2966. if (allow_calls && is("punc", "(")) {
  2967. next();
  2968. var call = new AST_Call({
  2969. start : start,
  2970. expression : expr,
  2971. optional : false,
  2972. args : call_args(),
  2973. end : prev()
  2974. });
  2975. annotate(call);
  2976. return subscripts(call, true, is_chain);
  2977. }
  2978. // Optional chain
  2979. if (is("punc", "?.")) {
  2980. next();
  2981. let chain_contents;
  2982. if (allow_calls && is("punc", "(")) {
  2983. next();
  2984. const call = new AST_Call({
  2985. start,
  2986. optional: true,
  2987. expression: expr,
  2988. args: call_args(),
  2989. end: prev()
  2990. });
  2991. annotate(call);
  2992. chain_contents = subscripts(call, true, true);
  2993. } else if (is("name") || is("privatename")) {
  2994. if(is("privatename") && !S.in_class)
  2995. croak("Private field must be used in an enclosing class");
  2996. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2997. chain_contents = annotate(subscripts(new AST_DotVariant({
  2998. start,
  2999. expression: expr,
  3000. optional: true,
  3001. property: as_name(),
  3002. end: prev()
  3003. }), allow_calls, true));
  3004. } else if (is("punc", "[")) {
  3005. next();
  3006. const property = expression(true);
  3007. expect("]");
  3008. chain_contents = annotate(subscripts(new AST_Sub({
  3009. start,
  3010. expression: expr,
  3011. optional: true,
  3012. property,
  3013. end: prev()
  3014. }), allow_calls, true));
  3015. }
  3016. if (!chain_contents) unexpected();
  3017. if (chain_contents instanceof AST_Chain) return chain_contents;
  3018. return new AST_Chain({
  3019. start,
  3020. expression: chain_contents,
  3021. end: prev()
  3022. });
  3023. }
  3024. if (is("template_head")) {
  3025. if (is_chain) {
  3026. // a?.b`c` is a syntax error
  3027. unexpected();
  3028. }
  3029. return subscripts(new AST_PrefixedTemplateString({
  3030. start: start,
  3031. prefix: expr,
  3032. template_string: template_string(),
  3033. end: prev()
  3034. }), allow_calls);
  3035. }
  3036. return expr;
  3037. };
  3038. function call_args() {
  3039. var args = [];
  3040. while (!is("punc", ")")) {
  3041. if (is("expand", "...")) {
  3042. next();
  3043. args.push(new AST_Expansion({
  3044. start: prev(),
  3045. expression: expression(false),
  3046. end: prev()
  3047. }));
  3048. } else {
  3049. args.push(expression(false));
  3050. }
  3051. if (!is("punc", ")")) {
  3052. expect(",");
  3053. }
  3054. }
  3055. next();
  3056. return args;
  3057. }
  3058. var maybe_unary = function(allow_calls, allow_arrows) {
  3059. var start = S.token;
  3060. if (start.type == "name" && start.value == "await" && can_await()) {
  3061. next();
  3062. return _await_expression();
  3063. }
  3064. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  3065. next();
  3066. handle_regexp();
  3067. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  3068. ex.start = start;
  3069. ex.end = prev();
  3070. return ex;
  3071. }
  3072. var val = expr_atom(allow_calls, allow_arrows);
  3073. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  3074. if (val instanceof AST_Arrow) unexpected();
  3075. val = make_unary(AST_UnaryPostfix, S.token, val);
  3076. val.start = start;
  3077. val.end = S.token;
  3078. next();
  3079. }
  3080. return val;
  3081. };
  3082. function make_unary(ctor, token, expr) {
  3083. var op = token.value;
  3084. switch (op) {
  3085. case "++":
  3086. case "--":
  3087. if (!is_assignable(expr))
  3088. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  3089. break;
  3090. case "delete":
  3091. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3092. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3093. break;
  3094. }
  3095. return new ctor({ operator: op, expression: expr });
  3096. }
  3097. var expr_op = function(left, min_prec, no_in) {
  3098. var op = is("operator") ? S.token.value : null;
  3099. if (op == "in" && no_in) op = null;
  3100. if (op == "**" && left instanceof AST_UnaryPrefix
  3101. /* unary token in front not allowed - parenthesis required */
  3102. && !is_token(left.start, "punc", "(")
  3103. && left.operator !== "--" && left.operator !== "++")
  3104. unexpected(left.start);
  3105. var prec = op != null ? PRECEDENCE[op] : null;
  3106. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3107. next();
  3108. var right = expr_ops(no_in, prec, true);
  3109. return expr_op(new AST_Binary({
  3110. start : left.start,
  3111. left : left,
  3112. operator : op,
  3113. right : right,
  3114. end : right.end
  3115. }), min_prec, no_in);
  3116. }
  3117. return left;
  3118. };
  3119. function expr_ops(no_in, min_prec, allow_calls, allow_arrows) {
  3120. // maybe_unary won't return us a AST_SymbolPrivateProperty
  3121. if (!no_in && min_prec < PRECEDENCE["in"] && is("privatename")) {
  3122. if(!S.in_class) {
  3123. croak("Private field must be used in an enclosing class");
  3124. }
  3125. const start = S.token;
  3126. const key = new AST_SymbolPrivateProperty({
  3127. start,
  3128. name: start.value,
  3129. end: start
  3130. });
  3131. next();
  3132. expect_token("operator", "in");
  3133. const private_in = new AST_PrivateIn({
  3134. start,
  3135. key,
  3136. value: expr_ops(no_in, PRECEDENCE["in"], true),
  3137. end: prev()
  3138. });
  3139. return expr_op(private_in, 0, no_in);
  3140. } else {
  3141. return expr_op(maybe_unary(allow_calls, allow_arrows), min_prec, no_in);
  3142. }
  3143. }
  3144. var maybe_conditional = function(no_in) {
  3145. var start = S.token;
  3146. var expr = expr_ops(no_in, 0, true, true);
  3147. if (is("operator", "?")) {
  3148. next();
  3149. var yes = expression(false);
  3150. expect(":");
  3151. return new AST_Conditional({
  3152. start : start,
  3153. condition : expr,
  3154. consequent : yes,
  3155. alternative : expression(false, no_in),
  3156. end : prev()
  3157. });
  3158. }
  3159. return expr;
  3160. };
  3161. function is_assignable(expr) {
  3162. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3163. }
  3164. function to_destructuring(node) {
  3165. if (node instanceof AST_Object) {
  3166. node = new AST_Destructuring({
  3167. start: node.start,
  3168. names: node.properties.map(to_destructuring),
  3169. is_array: false,
  3170. end: node.end
  3171. });
  3172. } else if (node instanceof AST_Array) {
  3173. var names = [];
  3174. for (var i = 0; i < node.elements.length; i++) {
  3175. // Only allow expansion as last element
  3176. if (node.elements[i] instanceof AST_Expansion) {
  3177. if (i + 1 !== node.elements.length) {
  3178. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3179. }
  3180. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3181. }
  3182. names.push(to_destructuring(node.elements[i]));
  3183. }
  3184. node = new AST_Destructuring({
  3185. start: node.start,
  3186. names: names,
  3187. is_array: true,
  3188. end: node.end
  3189. });
  3190. } else if (node instanceof AST_ObjectProperty) {
  3191. node.value = to_destructuring(node.value);
  3192. } else if (node instanceof AST_Assign) {
  3193. node = new AST_DefaultAssign({
  3194. start: node.start,
  3195. left: node.left,
  3196. operator: "=",
  3197. right: node.right,
  3198. end: node.end
  3199. });
  3200. }
  3201. return node;
  3202. }
  3203. // In ES6, AssignmentExpression can also be an ArrowFunction
  3204. var maybe_assign = function(no_in) {
  3205. handle_regexp();
  3206. var start = S.token;
  3207. if (start.type == "name" && start.value == "yield") {
  3208. if (is_in_generator()) {
  3209. next();
  3210. return _yield_expression();
  3211. } else if (S.input.has_directive("use strict")) {
  3212. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3213. }
  3214. }
  3215. var left = maybe_conditional(no_in);
  3216. var val = S.token.value;
  3217. if (is("operator") && ASSIGNMENT.has(val)) {
  3218. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3219. next();
  3220. return new AST_Assign({
  3221. start : start,
  3222. left : left,
  3223. operator : val,
  3224. right : maybe_assign(no_in),
  3225. logical : LOGICAL_ASSIGNMENT.has(val),
  3226. end : prev()
  3227. });
  3228. }
  3229. croak("Invalid assignment");
  3230. }
  3231. return left;
  3232. };
  3233. var to_expr_or_sequence = function(start, exprs) {
  3234. if (exprs.length === 1) {
  3235. return exprs[0];
  3236. } else if (exprs.length > 1) {
  3237. return new AST_Sequence({ start, expressions: exprs, end: peek() });
  3238. } else {
  3239. croak("Invalid parenthesized expression");
  3240. }
  3241. };
  3242. var expression = function(commas, no_in) {
  3243. var start = S.token;
  3244. var exprs = [];
  3245. while (true) {
  3246. exprs.push(maybe_assign(no_in));
  3247. if (!commas || !is("punc", ",")) break;
  3248. next();
  3249. commas = true;
  3250. }
  3251. return to_expr_or_sequence(start, exprs);
  3252. };
  3253. function in_loop(cont) {
  3254. ++S.in_loop;
  3255. var ret = cont();
  3256. --S.in_loop;
  3257. return ret;
  3258. }
  3259. if (options.expression) {
  3260. return expression(true);
  3261. }
  3262. return (function parse_toplevel() {
  3263. var start = S.token;
  3264. var body = [];
  3265. S.input.push_directives_stack();
  3266. if (options.module) S.input.add_directive("use strict");
  3267. while (!is("eof")) {
  3268. body.push(statement());
  3269. }
  3270. S.input.pop_directives_stack();
  3271. var end = prev();
  3272. var toplevel = options.toplevel;
  3273. if (toplevel) {
  3274. toplevel.body = toplevel.body.concat(body);
  3275. toplevel.end = end;
  3276. } else {
  3277. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3278. }
  3279. TEMPLATE_RAWS = new Map();
  3280. return toplevel;
  3281. })();
  3282. }
  3283. /***********************************************************************
  3284. A JavaScript tokenizer / parser / beautifier / compressor.
  3285. https://github.com/mishoo/UglifyJS2
  3286. -------------------------------- (C) ---------------------------------
  3287. Author: Mihai Bazon
  3288. <mihai.bazon@gmail.com>
  3289. http://mihai.bazon.net/blog
  3290. Distributed under the BSD license:
  3291. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3292. Redistribution and use in source and binary forms, with or without
  3293. modification, are permitted provided that the following conditions
  3294. are met:
  3295. * Redistributions of source code must retain the above
  3296. copyright notice, this list of conditions and the following
  3297. disclaimer.
  3298. * Redistributions in binary form must reproduce the above
  3299. copyright notice, this list of conditions and the following
  3300. disclaimer in the documentation and/or other materials
  3301. provided with the distribution.
  3302. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3303. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3304. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3305. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3306. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3307. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3308. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3309. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3310. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3311. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3312. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3313. SUCH DAMAGE.
  3314. ***********************************************************************/
  3315. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  3316. if (!props) props = [];
  3317. else props = props.split(/\s+/);
  3318. var self_props = props;
  3319. if (base && base.PROPS)
  3320. props = props.concat(base.PROPS);
  3321. const proto = base && Object.create(base.prototype);
  3322. if (proto) {
  3323. ctor.prototype = proto;
  3324. ctor.BASE = base;
  3325. }
  3326. if (base) base.SUBCLASSES.push(ctor);
  3327. ctor.prototype.CTOR = ctor;
  3328. ctor.prototype.constructor = ctor;
  3329. ctor.PROPS = props || null;
  3330. ctor.SELF_PROPS = self_props;
  3331. ctor.SUBCLASSES = [];
  3332. if (type) {
  3333. ctor.prototype.TYPE = ctor.TYPE = type;
  3334. }
  3335. if (methods) for (let i in methods) if (HOP(methods, i)) {
  3336. if (i[0] === "$") {
  3337. ctor[i.substr(1)] = methods[i];
  3338. } else {
  3339. ctor.prototype[i] = methods[i];
  3340. }
  3341. }
  3342. ctor.DEFMETHOD = function(name, method) {
  3343. this.prototype[name] = method;
  3344. };
  3345. return ctor;
  3346. }
  3347. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  3348. const set_tok_flag = (tok, flag, truth) => {
  3349. if (truth) {
  3350. tok.flags |= flag;
  3351. } else {
  3352. tok.flags &= ~flag;
  3353. }
  3354. };
  3355. const TOK_FLAG_NLB = 0b0001;
  3356. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  3357. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  3358. const TOK_FLAG_TEMPLATE_END = 0b1000;
  3359. class AST_Token {
  3360. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  3361. this.flags = (nlb ? 1 : 0);
  3362. this.type = type;
  3363. this.value = value;
  3364. this.line = line;
  3365. this.col = col;
  3366. this.pos = pos;
  3367. this.comments_before = comments_before;
  3368. this.comments_after = comments_after;
  3369. this.file = file;
  3370. Object.seal(this);
  3371. }
  3372. // Return a string summary of the token for node.js console.log
  3373. [Symbol.for("nodejs.util.inspect.custom")](_depth, options) {
  3374. const special = str => options.stylize(str, "special");
  3375. const quote = typeof this.value === "string" && this.value.includes("`") ? "'" : "`";
  3376. const value = `${quote}${this.value}${quote}`;
  3377. return `${special("[AST_Token")} ${value} at ${this.line}:${this.col}${special("]")}`;
  3378. }
  3379. get nlb() {
  3380. return has_tok_flag(this, TOK_FLAG_NLB);
  3381. }
  3382. set nlb(new_nlb) {
  3383. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  3384. }
  3385. get quote() {
  3386. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  3387. ? ""
  3388. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  3389. }
  3390. set quote(quote_type) {
  3391. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  3392. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  3393. }
  3394. get template_end() {
  3395. return has_tok_flag(this, TOK_FLAG_TEMPLATE_END);
  3396. }
  3397. set template_end(new_template_end) {
  3398. set_tok_flag(this, TOK_FLAG_TEMPLATE_END, new_template_end);
  3399. }
  3400. }
  3401. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  3402. if (props) {
  3403. this.start = props.start;
  3404. this.end = props.end;
  3405. }
  3406. this.flags = 0;
  3407. }, {
  3408. _clone: function(deep) {
  3409. if (deep) {
  3410. var self = this.clone();
  3411. return self.transform(new TreeTransformer(function(node) {
  3412. if (node !== self) {
  3413. return node.clone(true);
  3414. }
  3415. }));
  3416. }
  3417. return new this.CTOR(this);
  3418. },
  3419. clone: function(deep) {
  3420. return this._clone(deep);
  3421. },
  3422. $documentation: "Base class of all AST nodes",
  3423. $propdoc: {
  3424. start: "[AST_Token] The first token of this node",
  3425. end: "[AST_Token] The last token of this node"
  3426. },
  3427. _walk: function(visitor) {
  3428. return visitor._visit(this);
  3429. },
  3430. walk: function(visitor) {
  3431. return this._walk(visitor); // not sure the indirection will be any help
  3432. },
  3433. _children_backwards: () => {}
  3434. }, null);
  3435. /* -----[ statements ]----- */
  3436. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  3437. if (props) {
  3438. this.start = props.start;
  3439. this.end = props.end;
  3440. }
  3441. this.flags = 0;
  3442. }, {
  3443. $documentation: "Base class of all statements",
  3444. });
  3445. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  3446. if (props) {
  3447. this.start = props.start;
  3448. this.end = props.end;
  3449. }
  3450. this.flags = 0;
  3451. }, {
  3452. $documentation: "Represents a debugger statement",
  3453. }, AST_Statement);
  3454. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  3455. if (props) {
  3456. this.value = props.value;
  3457. this.quote = props.quote;
  3458. this.start = props.start;
  3459. this.end = props.end;
  3460. }
  3461. this.flags = 0;
  3462. }, {
  3463. $documentation: "Represents a directive, like \"use strict\";",
  3464. $propdoc: {
  3465. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3466. quote: "[string] the original quote character"
  3467. },
  3468. }, AST_Statement);
  3469. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  3470. if (props) {
  3471. this.body = props.body;
  3472. this.start = props.start;
  3473. this.end = props.end;
  3474. }
  3475. this.flags = 0;
  3476. }, {
  3477. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3478. $propdoc: {
  3479. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3480. },
  3481. _walk: function(visitor) {
  3482. return visitor._visit(this, function() {
  3483. this.body._walk(visitor);
  3484. });
  3485. },
  3486. _children_backwards(push) {
  3487. push(this.body);
  3488. }
  3489. }, AST_Statement);
  3490. function walk_body(node, visitor) {
  3491. const body = node.body;
  3492. for (var i = 0, len = body.length; i < len; i++) {
  3493. body[i]._walk(visitor);
  3494. }
  3495. }
  3496. function clone_block_scope(deep) {
  3497. var clone = this._clone(deep);
  3498. if (this.block_scope) {
  3499. clone.block_scope = this.block_scope.clone();
  3500. }
  3501. return clone;
  3502. }
  3503. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  3504. if (props) {
  3505. this.body = props.body;
  3506. this.block_scope = props.block_scope;
  3507. this.start = props.start;
  3508. this.end = props.end;
  3509. }
  3510. this.flags = 0;
  3511. }, {
  3512. $documentation: "A body of statements (usually braced)",
  3513. $propdoc: {
  3514. body: "[AST_Statement*] an array of statements",
  3515. block_scope: "[AST_Scope] the block scope"
  3516. },
  3517. _walk: function(visitor) {
  3518. return visitor._visit(this, function() {
  3519. walk_body(this, visitor);
  3520. });
  3521. },
  3522. _children_backwards(push) {
  3523. let i = this.body.length;
  3524. while (i--) push(this.body[i]);
  3525. },
  3526. clone: clone_block_scope
  3527. }, AST_Statement);
  3528. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  3529. if (props) {
  3530. this.body = props.body;
  3531. this.block_scope = props.block_scope;
  3532. this.start = props.start;
  3533. this.end = props.end;
  3534. }
  3535. this.flags = 0;
  3536. }, {
  3537. $documentation: "A block statement",
  3538. }, AST_Block);
  3539. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  3540. if (props) {
  3541. this.start = props.start;
  3542. this.end = props.end;
  3543. }
  3544. this.flags = 0;
  3545. }, {
  3546. $documentation: "The empty statement (empty block or simply a semicolon)"
  3547. }, AST_Statement);
  3548. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  3549. if (props) {
  3550. this.body = props.body;
  3551. this.start = props.start;
  3552. this.end = props.end;
  3553. }
  3554. this.flags = 0;
  3555. }, {
  3556. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3557. $propdoc: {
  3558. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3559. }
  3560. }, AST_Statement);
  3561. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  3562. if (props) {
  3563. this.label = props.label;
  3564. this.body = props.body;
  3565. this.start = props.start;
  3566. this.end = props.end;
  3567. }
  3568. this.flags = 0;
  3569. }, {
  3570. $documentation: "Statement with a label",
  3571. $propdoc: {
  3572. label: "[AST_Label] a label definition"
  3573. },
  3574. _walk: function(visitor) {
  3575. return visitor._visit(this, function() {
  3576. this.label._walk(visitor);
  3577. this.body._walk(visitor);
  3578. });
  3579. },
  3580. _children_backwards(push) {
  3581. push(this.body);
  3582. push(this.label);
  3583. },
  3584. clone: function(deep) {
  3585. var node = this._clone(deep);
  3586. if (deep) {
  3587. var label = node.label;
  3588. var def = this.label;
  3589. node.walk(new TreeWalker(function(node) {
  3590. if (node instanceof AST_LoopControl
  3591. && node.label && node.label.thedef === def) {
  3592. node.label.thedef = label;
  3593. label.references.push(node);
  3594. }
  3595. }));
  3596. }
  3597. return node;
  3598. }
  3599. }, AST_StatementWithBody);
  3600. var AST_IterationStatement = DEFNODE(
  3601. "IterationStatement",
  3602. "block_scope",
  3603. function AST_IterationStatement(props) {
  3604. if (props) {
  3605. this.block_scope = props.block_scope;
  3606. this.body = props.body;
  3607. this.start = props.start;
  3608. this.end = props.end;
  3609. }
  3610. this.flags = 0;
  3611. },
  3612. {
  3613. $documentation: "Internal class. All loops inherit from it.",
  3614. $propdoc: {
  3615. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3616. },
  3617. clone: clone_block_scope
  3618. },
  3619. AST_StatementWithBody
  3620. );
  3621. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  3622. if (props) {
  3623. this.condition = props.condition;
  3624. this.block_scope = props.block_scope;
  3625. this.body = props.body;
  3626. this.start = props.start;
  3627. this.end = props.end;
  3628. }
  3629. this.flags = 0;
  3630. }, {
  3631. $documentation: "Base class for do/while statements",
  3632. $propdoc: {
  3633. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3634. }
  3635. }, AST_IterationStatement);
  3636. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  3637. if (props) {
  3638. this.condition = props.condition;
  3639. this.block_scope = props.block_scope;
  3640. this.body = props.body;
  3641. this.start = props.start;
  3642. this.end = props.end;
  3643. }
  3644. this.flags = 0;
  3645. }, {
  3646. $documentation: "A `do` statement",
  3647. _walk: function(visitor) {
  3648. return visitor._visit(this, function() {
  3649. this.body._walk(visitor);
  3650. this.condition._walk(visitor);
  3651. });
  3652. },
  3653. _children_backwards(push) {
  3654. push(this.condition);
  3655. push(this.body);
  3656. }
  3657. }, AST_DWLoop);
  3658. var AST_While = DEFNODE("While", null, function AST_While(props) {
  3659. if (props) {
  3660. this.condition = props.condition;
  3661. this.block_scope = props.block_scope;
  3662. this.body = props.body;
  3663. this.start = props.start;
  3664. this.end = props.end;
  3665. }
  3666. this.flags = 0;
  3667. }, {
  3668. $documentation: "A `while` statement",
  3669. _walk: function(visitor) {
  3670. return visitor._visit(this, function() {
  3671. this.condition._walk(visitor);
  3672. this.body._walk(visitor);
  3673. });
  3674. },
  3675. _children_backwards(push) {
  3676. push(this.body);
  3677. push(this.condition);
  3678. },
  3679. }, AST_DWLoop);
  3680. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  3681. if (props) {
  3682. this.init = props.init;
  3683. this.condition = props.condition;
  3684. this.step = props.step;
  3685. this.block_scope = props.block_scope;
  3686. this.body = props.body;
  3687. this.start = props.start;
  3688. this.end = props.end;
  3689. }
  3690. this.flags = 0;
  3691. }, {
  3692. $documentation: "A `for` statement",
  3693. $propdoc: {
  3694. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3695. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3696. step: "[AST_Node?] the `for` update clause, or null if empty"
  3697. },
  3698. _walk: function(visitor) {
  3699. return visitor._visit(this, function() {
  3700. if (this.init) this.init._walk(visitor);
  3701. if (this.condition) this.condition._walk(visitor);
  3702. if (this.step) this.step._walk(visitor);
  3703. this.body._walk(visitor);
  3704. });
  3705. },
  3706. _children_backwards(push) {
  3707. push(this.body);
  3708. if (this.step) push(this.step);
  3709. if (this.condition) push(this.condition);
  3710. if (this.init) push(this.init);
  3711. },
  3712. }, AST_IterationStatement);
  3713. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  3714. if (props) {
  3715. this.init = props.init;
  3716. this.object = props.object;
  3717. this.block_scope = props.block_scope;
  3718. this.body = props.body;
  3719. this.start = props.start;
  3720. this.end = props.end;
  3721. }
  3722. this.flags = 0;
  3723. }, {
  3724. $documentation: "A `for ... in` statement",
  3725. $propdoc: {
  3726. init: "[AST_Node] the `for/in` initialization code",
  3727. object: "[AST_Node] the object that we're looping through"
  3728. },
  3729. _walk: function(visitor) {
  3730. return visitor._visit(this, function() {
  3731. this.init._walk(visitor);
  3732. this.object._walk(visitor);
  3733. this.body._walk(visitor);
  3734. });
  3735. },
  3736. _children_backwards(push) {
  3737. push(this.body);
  3738. if (this.object) push(this.object);
  3739. if (this.init) push(this.init);
  3740. },
  3741. }, AST_IterationStatement);
  3742. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  3743. if (props) {
  3744. this.await = props.await;
  3745. this.init = props.init;
  3746. this.object = props.object;
  3747. this.block_scope = props.block_scope;
  3748. this.body = props.body;
  3749. this.start = props.start;
  3750. this.end = props.end;
  3751. }
  3752. this.flags = 0;
  3753. }, {
  3754. $documentation: "A `for ... of` statement",
  3755. }, AST_ForIn);
  3756. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  3757. if (props) {
  3758. this.expression = props.expression;
  3759. this.body = props.body;
  3760. this.start = props.start;
  3761. this.end = props.end;
  3762. }
  3763. this.flags = 0;
  3764. }, {
  3765. $documentation: "A `with` statement",
  3766. $propdoc: {
  3767. expression: "[AST_Node] the `with` expression"
  3768. },
  3769. _walk: function(visitor) {
  3770. return visitor._visit(this, function() {
  3771. this.expression._walk(visitor);
  3772. this.body._walk(visitor);
  3773. });
  3774. },
  3775. _children_backwards(push) {
  3776. push(this.body);
  3777. push(this.expression);
  3778. },
  3779. }, AST_StatementWithBody);
  3780. /* -----[ scope and functions ]----- */
  3781. var AST_Scope = DEFNODE(
  3782. "Scope",
  3783. "variables uses_with uses_eval parent_scope enclosed cname",
  3784. function AST_Scope(props) {
  3785. if (props) {
  3786. this.variables = props.variables;
  3787. this.uses_with = props.uses_with;
  3788. this.uses_eval = props.uses_eval;
  3789. this.parent_scope = props.parent_scope;
  3790. this.enclosed = props.enclosed;
  3791. this.cname = props.cname;
  3792. this.body = props.body;
  3793. this.block_scope = props.block_scope;
  3794. this.start = props.start;
  3795. this.end = props.end;
  3796. }
  3797. this.flags = 0;
  3798. },
  3799. {
  3800. $documentation: "Base class for all statements introducing a lexical scope",
  3801. $propdoc: {
  3802. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3803. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3804. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3805. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3806. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3807. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3808. },
  3809. get_defun_scope: function() {
  3810. var self = this;
  3811. while (self.is_block_scope()) {
  3812. self = self.parent_scope;
  3813. }
  3814. return self;
  3815. },
  3816. clone: function(deep, toplevel) {
  3817. var node = this._clone(deep);
  3818. if (deep && this.variables && toplevel && !this._block_scope) {
  3819. node.figure_out_scope({}, {
  3820. toplevel: toplevel,
  3821. parent_scope: this.parent_scope
  3822. });
  3823. } else {
  3824. if (this.variables) node.variables = new Map(this.variables);
  3825. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3826. if (this._block_scope) node._block_scope = this._block_scope;
  3827. }
  3828. return node;
  3829. },
  3830. pinned: function() {
  3831. return this.uses_eval || this.uses_with;
  3832. }
  3833. },
  3834. AST_Block
  3835. );
  3836. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  3837. if (props) {
  3838. this.globals = props.globals;
  3839. this.variables = props.variables;
  3840. this.uses_with = props.uses_with;
  3841. this.uses_eval = props.uses_eval;
  3842. this.parent_scope = props.parent_scope;
  3843. this.enclosed = props.enclosed;
  3844. this.cname = props.cname;
  3845. this.body = props.body;
  3846. this.block_scope = props.block_scope;
  3847. this.start = props.start;
  3848. this.end = props.end;
  3849. }
  3850. this.flags = 0;
  3851. }, {
  3852. $documentation: "The toplevel scope",
  3853. $propdoc: {
  3854. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3855. },
  3856. wrap_commonjs: function(name) {
  3857. var body = this.body;
  3858. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3859. wrapped_tl = parse(wrapped_tl);
  3860. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3861. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3862. return MAP.splice(body);
  3863. }
  3864. }));
  3865. return wrapped_tl;
  3866. },
  3867. wrap_enclose: function(args_values) {
  3868. if (typeof args_values != "string") args_values = "";
  3869. var index = args_values.indexOf(":");
  3870. if (index < 0) index = args_values.length;
  3871. var body = this.body;
  3872. return parse([
  3873. "(function(",
  3874. args_values.slice(0, index),
  3875. '){"$ORIG"})(',
  3876. args_values.slice(index + 1),
  3877. ")"
  3878. ].join("")).transform(new TreeTransformer(function(node) {
  3879. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3880. return MAP.splice(body);
  3881. }
  3882. }));
  3883. }
  3884. }, AST_Scope);
  3885. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  3886. if (props) {
  3887. this.expression = props.expression;
  3888. this.start = props.start;
  3889. this.end = props.end;
  3890. }
  3891. this.flags = 0;
  3892. }, {
  3893. $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",
  3894. $propdoc: {
  3895. expression: "[AST_Node] the thing to be expanded"
  3896. },
  3897. _walk: function(visitor) {
  3898. return visitor._visit(this, function() {
  3899. this.expression.walk(visitor);
  3900. });
  3901. },
  3902. _children_backwards(push) {
  3903. push(this.expression);
  3904. },
  3905. });
  3906. var AST_Lambda = DEFNODE(
  3907. "Lambda",
  3908. "name argnames uses_arguments is_generator async",
  3909. function AST_Lambda(props) {
  3910. if (props) {
  3911. this.name = props.name;
  3912. this.argnames = props.argnames;
  3913. this.uses_arguments = props.uses_arguments;
  3914. this.is_generator = props.is_generator;
  3915. this.async = props.async;
  3916. this.variables = props.variables;
  3917. this.uses_with = props.uses_with;
  3918. this.uses_eval = props.uses_eval;
  3919. this.parent_scope = props.parent_scope;
  3920. this.enclosed = props.enclosed;
  3921. this.cname = props.cname;
  3922. this.body = props.body;
  3923. this.block_scope = props.block_scope;
  3924. this.start = props.start;
  3925. this.end = props.end;
  3926. }
  3927. this.flags = 0;
  3928. },
  3929. {
  3930. $documentation: "Base class for functions",
  3931. $propdoc: {
  3932. name: "[AST_SymbolDeclaration?] the name of this function",
  3933. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3934. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3935. is_generator: "[boolean] is this a generator method",
  3936. async: "[boolean] is this method async",
  3937. },
  3938. args_as_names: function () {
  3939. var out = [];
  3940. for (var i = 0; i < this.argnames.length; i++) {
  3941. if (this.argnames[i] instanceof AST_Destructuring) {
  3942. out.push(...this.argnames[i].all_symbols());
  3943. } else {
  3944. out.push(this.argnames[i]);
  3945. }
  3946. }
  3947. return out;
  3948. },
  3949. _walk: function(visitor) {
  3950. return visitor._visit(this, function() {
  3951. if (this.name) this.name._walk(visitor);
  3952. var argnames = this.argnames;
  3953. for (var i = 0, len = argnames.length; i < len; i++) {
  3954. argnames[i]._walk(visitor);
  3955. }
  3956. walk_body(this, visitor);
  3957. });
  3958. },
  3959. _children_backwards(push) {
  3960. let i = this.body.length;
  3961. while (i--) push(this.body[i]);
  3962. i = this.argnames.length;
  3963. while (i--) push(this.argnames[i]);
  3964. if (this.name) push(this.name);
  3965. },
  3966. is_braceless() {
  3967. return this.body[0] instanceof AST_Return && this.body[0].value;
  3968. },
  3969. // Default args and expansion don't count, so .argnames.length doesn't cut it
  3970. length_property() {
  3971. let length = 0;
  3972. for (const arg of this.argnames) {
  3973. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  3974. length++;
  3975. }
  3976. }
  3977. return length;
  3978. }
  3979. },
  3980. AST_Scope
  3981. );
  3982. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  3983. if (props) {
  3984. this.name = props.name;
  3985. this.argnames = props.argnames;
  3986. this.uses_arguments = props.uses_arguments;
  3987. this.is_generator = props.is_generator;
  3988. this.async = props.async;
  3989. this.variables = props.variables;
  3990. this.uses_with = props.uses_with;
  3991. this.uses_eval = props.uses_eval;
  3992. this.parent_scope = props.parent_scope;
  3993. this.enclosed = props.enclosed;
  3994. this.cname = props.cname;
  3995. this.body = props.body;
  3996. this.block_scope = props.block_scope;
  3997. this.start = props.start;
  3998. this.end = props.end;
  3999. }
  4000. this.flags = 0;
  4001. }, {
  4002. $documentation: "A setter/getter function. The `name` property is always null."
  4003. }, AST_Lambda);
  4004. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  4005. if (props) {
  4006. this.name = props.name;
  4007. this.argnames = props.argnames;
  4008. this.uses_arguments = props.uses_arguments;
  4009. this.is_generator = props.is_generator;
  4010. this.async = props.async;
  4011. this.variables = props.variables;
  4012. this.uses_with = props.uses_with;
  4013. this.uses_eval = props.uses_eval;
  4014. this.parent_scope = props.parent_scope;
  4015. this.enclosed = props.enclosed;
  4016. this.cname = props.cname;
  4017. this.body = props.body;
  4018. this.block_scope = props.block_scope;
  4019. this.start = props.start;
  4020. this.end = props.end;
  4021. }
  4022. this.flags = 0;
  4023. }, {
  4024. $documentation: "A function expression"
  4025. }, AST_Lambda);
  4026. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  4027. if (props) {
  4028. this.name = props.name;
  4029. this.argnames = props.argnames;
  4030. this.uses_arguments = props.uses_arguments;
  4031. this.is_generator = props.is_generator;
  4032. this.async = props.async;
  4033. this.variables = props.variables;
  4034. this.uses_with = props.uses_with;
  4035. this.uses_eval = props.uses_eval;
  4036. this.parent_scope = props.parent_scope;
  4037. this.enclosed = props.enclosed;
  4038. this.cname = props.cname;
  4039. this.body = props.body;
  4040. this.block_scope = props.block_scope;
  4041. this.start = props.start;
  4042. this.end = props.end;
  4043. }
  4044. this.flags = 0;
  4045. }, {
  4046. $documentation: "An ES6 Arrow function ((a) => b)"
  4047. }, AST_Lambda);
  4048. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  4049. if (props) {
  4050. this.name = props.name;
  4051. this.argnames = props.argnames;
  4052. this.uses_arguments = props.uses_arguments;
  4053. this.is_generator = props.is_generator;
  4054. this.async = props.async;
  4055. this.variables = props.variables;
  4056. this.uses_with = props.uses_with;
  4057. this.uses_eval = props.uses_eval;
  4058. this.parent_scope = props.parent_scope;
  4059. this.enclosed = props.enclosed;
  4060. this.cname = props.cname;
  4061. this.body = props.body;
  4062. this.block_scope = props.block_scope;
  4063. this.start = props.start;
  4064. this.end = props.end;
  4065. }
  4066. this.flags = 0;
  4067. }, {
  4068. $documentation: "A function definition"
  4069. }, AST_Lambda);
  4070. /* -----[ DESTRUCTURING ]----- */
  4071. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  4072. if (props) {
  4073. this.names = props.names;
  4074. this.is_array = props.is_array;
  4075. this.start = props.start;
  4076. this.end = props.end;
  4077. }
  4078. this.flags = 0;
  4079. }, {
  4080. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  4081. $propdoc: {
  4082. "names": "[AST_Node*] Array of properties or elements",
  4083. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  4084. },
  4085. _walk: function(visitor) {
  4086. return visitor._visit(this, function() {
  4087. this.names.forEach(function(name) {
  4088. name._walk(visitor);
  4089. });
  4090. });
  4091. },
  4092. _children_backwards(push) {
  4093. let i = this.names.length;
  4094. while (i--) push(this.names[i]);
  4095. },
  4096. all_symbols: function() {
  4097. var out = [];
  4098. walk(this, node => {
  4099. if (node instanceof AST_SymbolDeclaration) {
  4100. out.push(node);
  4101. }
  4102. if (node instanceof AST_Lambda) {
  4103. return true;
  4104. }
  4105. });
  4106. return out;
  4107. }
  4108. });
  4109. var AST_PrefixedTemplateString = DEFNODE(
  4110. "PrefixedTemplateString",
  4111. "template_string prefix",
  4112. function AST_PrefixedTemplateString(props) {
  4113. if (props) {
  4114. this.template_string = props.template_string;
  4115. this.prefix = props.prefix;
  4116. this.start = props.start;
  4117. this.end = props.end;
  4118. }
  4119. this.flags = 0;
  4120. },
  4121. {
  4122. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  4123. $propdoc: {
  4124. template_string: "[AST_TemplateString] The template string",
  4125. prefix: "[AST_Node] The prefix, which will get called."
  4126. },
  4127. _walk: function(visitor) {
  4128. return visitor._visit(this, function () {
  4129. this.prefix._walk(visitor);
  4130. this.template_string._walk(visitor);
  4131. });
  4132. },
  4133. _children_backwards(push) {
  4134. push(this.template_string);
  4135. push(this.prefix);
  4136. },
  4137. }
  4138. );
  4139. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  4140. if (props) {
  4141. this.segments = props.segments;
  4142. this.start = props.start;
  4143. this.end = props.end;
  4144. }
  4145. this.flags = 0;
  4146. }, {
  4147. $documentation: "A template string literal",
  4148. $propdoc: {
  4149. 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."
  4150. },
  4151. _walk: function(visitor) {
  4152. return visitor._visit(this, function() {
  4153. this.segments.forEach(function(seg) {
  4154. seg._walk(visitor);
  4155. });
  4156. });
  4157. },
  4158. _children_backwards(push) {
  4159. let i = this.segments.length;
  4160. while (i--) push(this.segments[i]);
  4161. }
  4162. });
  4163. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  4164. if (props) {
  4165. this.value = props.value;
  4166. this.raw = props.raw;
  4167. this.start = props.start;
  4168. this.end = props.end;
  4169. }
  4170. this.flags = 0;
  4171. }, {
  4172. $documentation: "A segment of a template string literal",
  4173. $propdoc: {
  4174. value: "Content of the segment",
  4175. raw: "Raw source of the segment",
  4176. }
  4177. });
  4178. /* -----[ JUMPS ]----- */
  4179. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  4180. if (props) {
  4181. this.start = props.start;
  4182. this.end = props.end;
  4183. }
  4184. this.flags = 0;
  4185. }, {
  4186. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  4187. }, AST_Statement);
  4188. /** Base class for “exits” (`return` and `throw`) */
  4189. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  4190. if (props) {
  4191. this.value = props.value;
  4192. this.start = props.start;
  4193. this.end = props.end;
  4194. }
  4195. this.flags = 0;
  4196. }, {
  4197. $documentation: "Base class for “exits” (`return` and `throw`)",
  4198. $propdoc: {
  4199. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  4200. },
  4201. _walk: function(visitor) {
  4202. return visitor._visit(this, this.value && function() {
  4203. this.value._walk(visitor);
  4204. });
  4205. },
  4206. _children_backwards(push) {
  4207. if (this.value) push(this.value);
  4208. },
  4209. }, AST_Jump);
  4210. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  4211. if (props) {
  4212. this.value = props.value;
  4213. this.start = props.start;
  4214. this.end = props.end;
  4215. }
  4216. this.flags = 0;
  4217. }, {
  4218. $documentation: "A `return` statement"
  4219. }, AST_Exit);
  4220. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  4221. if (props) {
  4222. this.value = props.value;
  4223. this.start = props.start;
  4224. this.end = props.end;
  4225. }
  4226. this.flags = 0;
  4227. }, {
  4228. $documentation: "A `throw` statement"
  4229. }, AST_Exit);
  4230. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  4231. if (props) {
  4232. this.label = props.label;
  4233. this.start = props.start;
  4234. this.end = props.end;
  4235. }
  4236. this.flags = 0;
  4237. }, {
  4238. $documentation: "Base class for loop control statements (`break` and `continue`)",
  4239. $propdoc: {
  4240. label: "[AST_LabelRef?] the label, or null if none",
  4241. },
  4242. _walk: function(visitor) {
  4243. return visitor._visit(this, this.label && function() {
  4244. this.label._walk(visitor);
  4245. });
  4246. },
  4247. _children_backwards(push) {
  4248. if (this.label) push(this.label);
  4249. },
  4250. }, AST_Jump);
  4251. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  4252. if (props) {
  4253. this.label = props.label;
  4254. this.start = props.start;
  4255. this.end = props.end;
  4256. }
  4257. this.flags = 0;
  4258. }, {
  4259. $documentation: "A `break` statement"
  4260. }, AST_LoopControl);
  4261. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  4262. if (props) {
  4263. this.label = props.label;
  4264. this.start = props.start;
  4265. this.end = props.end;
  4266. }
  4267. this.flags = 0;
  4268. }, {
  4269. $documentation: "A `continue` statement"
  4270. }, AST_LoopControl);
  4271. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  4272. if (props) {
  4273. this.expression = props.expression;
  4274. this.start = props.start;
  4275. this.end = props.end;
  4276. }
  4277. this.flags = 0;
  4278. }, {
  4279. $documentation: "An `await` statement",
  4280. $propdoc: {
  4281. expression: "[AST_Node] the mandatory expression being awaited",
  4282. },
  4283. _walk: function(visitor) {
  4284. return visitor._visit(this, function() {
  4285. this.expression._walk(visitor);
  4286. });
  4287. },
  4288. _children_backwards(push) {
  4289. push(this.expression);
  4290. },
  4291. });
  4292. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  4293. if (props) {
  4294. this.expression = props.expression;
  4295. this.is_star = props.is_star;
  4296. this.start = props.start;
  4297. this.end = props.end;
  4298. }
  4299. this.flags = 0;
  4300. }, {
  4301. $documentation: "A `yield` statement",
  4302. $propdoc: {
  4303. 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",
  4304. is_star: "[Boolean] Whether this is a yield or yield* statement"
  4305. },
  4306. _walk: function(visitor) {
  4307. return visitor._visit(this, this.expression && function() {
  4308. this.expression._walk(visitor);
  4309. });
  4310. },
  4311. _children_backwards(push) {
  4312. if (this.expression) push(this.expression);
  4313. }
  4314. });
  4315. /* -----[ IF ]----- */
  4316. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  4317. if (props) {
  4318. this.condition = props.condition;
  4319. this.alternative = props.alternative;
  4320. this.body = props.body;
  4321. this.start = props.start;
  4322. this.end = props.end;
  4323. }
  4324. this.flags = 0;
  4325. }, {
  4326. $documentation: "A `if` statement",
  4327. $propdoc: {
  4328. condition: "[AST_Node] the `if` condition",
  4329. alternative: "[AST_Statement?] the `else` part, or null if not present"
  4330. },
  4331. _walk: function(visitor) {
  4332. return visitor._visit(this, function() {
  4333. this.condition._walk(visitor);
  4334. this.body._walk(visitor);
  4335. if (this.alternative) this.alternative._walk(visitor);
  4336. });
  4337. },
  4338. _children_backwards(push) {
  4339. if (this.alternative) {
  4340. push(this.alternative);
  4341. }
  4342. push(this.body);
  4343. push(this.condition);
  4344. }
  4345. }, AST_StatementWithBody);
  4346. /* -----[ SWITCH ]----- */
  4347. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  4348. if (props) {
  4349. this.expression = props.expression;
  4350. this.body = props.body;
  4351. this.block_scope = props.block_scope;
  4352. this.start = props.start;
  4353. this.end = props.end;
  4354. }
  4355. this.flags = 0;
  4356. }, {
  4357. $documentation: "A `switch` statement",
  4358. $propdoc: {
  4359. expression: "[AST_Node] the `switch` “discriminant”"
  4360. },
  4361. _walk: function(visitor) {
  4362. return visitor._visit(this, function() {
  4363. this.expression._walk(visitor);
  4364. walk_body(this, visitor);
  4365. });
  4366. },
  4367. _children_backwards(push) {
  4368. let i = this.body.length;
  4369. while (i--) push(this.body[i]);
  4370. push(this.expression);
  4371. }
  4372. }, AST_Block);
  4373. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  4374. if (props) {
  4375. this.body = props.body;
  4376. this.block_scope = props.block_scope;
  4377. this.start = props.start;
  4378. this.end = props.end;
  4379. }
  4380. this.flags = 0;
  4381. }, {
  4382. $documentation: "Base class for `switch` branches",
  4383. }, AST_Block);
  4384. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  4385. if (props) {
  4386. this.body = props.body;
  4387. this.block_scope = props.block_scope;
  4388. this.start = props.start;
  4389. this.end = props.end;
  4390. }
  4391. this.flags = 0;
  4392. }, {
  4393. $documentation: "A `default` switch branch",
  4394. }, AST_SwitchBranch);
  4395. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  4396. if (props) {
  4397. this.expression = props.expression;
  4398. this.body = props.body;
  4399. this.block_scope = props.block_scope;
  4400. this.start = props.start;
  4401. this.end = props.end;
  4402. }
  4403. this.flags = 0;
  4404. }, {
  4405. $documentation: "A `case` switch branch",
  4406. $propdoc: {
  4407. expression: "[AST_Node] the `case` expression"
  4408. },
  4409. _walk: function(visitor) {
  4410. return visitor._visit(this, function() {
  4411. this.expression._walk(visitor);
  4412. walk_body(this, visitor);
  4413. });
  4414. },
  4415. _children_backwards(push) {
  4416. let i = this.body.length;
  4417. while (i--) push(this.body[i]);
  4418. push(this.expression);
  4419. },
  4420. }, AST_SwitchBranch);
  4421. /* -----[ EXCEPTIONS ]----- */
  4422. var AST_Try = DEFNODE("Try", "body bcatch bfinally", function AST_Try(props) {
  4423. if (props) {
  4424. this.body = props.body;
  4425. this.bcatch = props.bcatch;
  4426. this.bfinally = props.bfinally;
  4427. this.start = props.start;
  4428. this.end = props.end;
  4429. }
  4430. this.flags = 0;
  4431. }, {
  4432. $documentation: "A `try` statement",
  4433. $propdoc: {
  4434. body: "[AST_TryBlock] the try block",
  4435. bcatch: "[AST_Catch?] the catch block, or null if not present",
  4436. bfinally: "[AST_Finally?] the finally block, or null if not present"
  4437. },
  4438. _walk: function(visitor) {
  4439. return visitor._visit(this, function() {
  4440. this.body._walk(visitor);
  4441. if (this.bcatch) this.bcatch._walk(visitor);
  4442. if (this.bfinally) this.bfinally._walk(visitor);
  4443. });
  4444. },
  4445. _children_backwards(push) {
  4446. if (this.bfinally) push(this.bfinally);
  4447. if (this.bcatch) push(this.bcatch);
  4448. push(this.body);
  4449. },
  4450. }, AST_Statement);
  4451. var AST_TryBlock = DEFNODE("TryBlock", null, function AST_TryBlock(props) {
  4452. if (props) {
  4453. this.body = props.body;
  4454. this.block_scope = props.block_scope;
  4455. this.start = props.start;
  4456. this.end = props.end;
  4457. }
  4458. this.flags = 0;
  4459. }, {
  4460. $documentation: "The `try` block of a try statement"
  4461. }, AST_Block);
  4462. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  4463. if (props) {
  4464. this.argname = props.argname;
  4465. this.body = props.body;
  4466. this.block_scope = props.block_scope;
  4467. this.start = props.start;
  4468. this.end = props.end;
  4469. }
  4470. this.flags = 0;
  4471. }, {
  4472. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  4473. $propdoc: {
  4474. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  4475. },
  4476. _walk: function(visitor) {
  4477. return visitor._visit(this, function() {
  4478. if (this.argname) this.argname._walk(visitor);
  4479. walk_body(this, visitor);
  4480. });
  4481. },
  4482. _children_backwards(push) {
  4483. let i = this.body.length;
  4484. while (i--) push(this.body[i]);
  4485. if (this.argname) push(this.argname);
  4486. },
  4487. }, AST_Block);
  4488. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  4489. if (props) {
  4490. this.body = props.body;
  4491. this.block_scope = props.block_scope;
  4492. this.start = props.start;
  4493. this.end = props.end;
  4494. }
  4495. this.flags = 0;
  4496. }, {
  4497. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  4498. }, AST_Block);
  4499. /* -----[ VAR/CONST ]----- */
  4500. var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
  4501. if (props) {
  4502. this.definitions = props.definitions;
  4503. this.start = props.start;
  4504. this.end = props.end;
  4505. }
  4506. this.flags = 0;
  4507. }, {
  4508. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  4509. $propdoc: {
  4510. definitions: "[AST_VarDef*] array of variable definitions"
  4511. },
  4512. _walk: function(visitor) {
  4513. return visitor._visit(this, function() {
  4514. var definitions = this.definitions;
  4515. for (var i = 0, len = definitions.length; i < len; i++) {
  4516. definitions[i]._walk(visitor);
  4517. }
  4518. });
  4519. },
  4520. _children_backwards(push) {
  4521. let i = this.definitions.length;
  4522. while (i--) push(this.definitions[i]);
  4523. },
  4524. }, AST_Statement);
  4525. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  4526. if (props) {
  4527. this.definitions = props.definitions;
  4528. this.start = props.start;
  4529. this.end = props.end;
  4530. }
  4531. this.flags = 0;
  4532. }, {
  4533. $documentation: "A `var` statement"
  4534. }, AST_Definitions);
  4535. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  4536. if (props) {
  4537. this.definitions = props.definitions;
  4538. this.start = props.start;
  4539. this.end = props.end;
  4540. }
  4541. this.flags = 0;
  4542. }, {
  4543. $documentation: "A `let` statement"
  4544. }, AST_Definitions);
  4545. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  4546. if (props) {
  4547. this.definitions = props.definitions;
  4548. this.start = props.start;
  4549. this.end = props.end;
  4550. }
  4551. this.flags = 0;
  4552. }, {
  4553. $documentation: "A `const` statement"
  4554. }, AST_Definitions);
  4555. var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
  4556. if (props) {
  4557. this.name = props.name;
  4558. this.value = props.value;
  4559. this.start = props.start;
  4560. this.end = props.end;
  4561. }
  4562. this.flags = 0;
  4563. }, {
  4564. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  4565. $propdoc: {
  4566. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  4567. value: "[AST_Node?] initializer, or null of there's no initializer"
  4568. },
  4569. _walk: function(visitor) {
  4570. return visitor._visit(this, function() {
  4571. this.name._walk(visitor);
  4572. if (this.value) this.value._walk(visitor);
  4573. });
  4574. },
  4575. _children_backwards(push) {
  4576. if (this.value) push(this.value);
  4577. push(this.name);
  4578. },
  4579. declarations_as_names() {
  4580. if (this.name instanceof AST_SymbolDeclaration) {
  4581. return [this];
  4582. } else {
  4583. return this.name.all_symbols();
  4584. }
  4585. }
  4586. });
  4587. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  4588. if (props) {
  4589. this.foreign_name = props.foreign_name;
  4590. this.name = props.name;
  4591. this.start = props.start;
  4592. this.end = props.end;
  4593. }
  4594. this.flags = 0;
  4595. }, {
  4596. $documentation: "The part of the export/import statement that declare names from a module.",
  4597. $propdoc: {
  4598. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  4599. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  4600. },
  4601. _walk: function (visitor) {
  4602. return visitor._visit(this, function() {
  4603. this.foreign_name._walk(visitor);
  4604. this.name._walk(visitor);
  4605. });
  4606. },
  4607. _children_backwards(push) {
  4608. push(this.name);
  4609. push(this.foreign_name);
  4610. },
  4611. });
  4612. var AST_Import = DEFNODE(
  4613. "Import",
  4614. "imported_name imported_names module_name attributes",
  4615. function AST_Import(props) {
  4616. if (props) {
  4617. this.imported_name = props.imported_name;
  4618. this.imported_names = props.imported_names;
  4619. this.module_name = props.module_name;
  4620. this.attributes = props.attributes;
  4621. this.start = props.start;
  4622. this.end = props.end;
  4623. }
  4624. this.flags = 0;
  4625. },
  4626. {
  4627. $documentation: "An `import` statement",
  4628. $propdoc: {
  4629. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  4630. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  4631. module_name: "[AST_String] String literal describing where this module came from",
  4632. attributes: "[AST_Object?] The import attributes (with {...})"
  4633. },
  4634. _walk: function(visitor) {
  4635. return visitor._visit(this, function() {
  4636. if (this.imported_name) {
  4637. this.imported_name._walk(visitor);
  4638. }
  4639. if (this.imported_names) {
  4640. this.imported_names.forEach(function(name_import) {
  4641. name_import._walk(visitor);
  4642. });
  4643. }
  4644. this.module_name._walk(visitor);
  4645. });
  4646. },
  4647. _children_backwards(push) {
  4648. push(this.module_name);
  4649. if (this.imported_names) {
  4650. let i = this.imported_names.length;
  4651. while (i--) push(this.imported_names[i]);
  4652. }
  4653. if (this.imported_name) push(this.imported_name);
  4654. },
  4655. }
  4656. );
  4657. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  4658. if (props) {
  4659. this.start = props.start;
  4660. this.end = props.end;
  4661. }
  4662. this.flags = 0;
  4663. }, {
  4664. $documentation: "A reference to import.meta",
  4665. });
  4666. var AST_Export = DEFNODE(
  4667. "Export",
  4668. "exported_definition exported_value is_default exported_names module_name attributes",
  4669. function AST_Export(props) {
  4670. if (props) {
  4671. this.exported_definition = props.exported_definition;
  4672. this.exported_value = props.exported_value;
  4673. this.is_default = props.is_default;
  4674. this.exported_names = props.exported_names;
  4675. this.module_name = props.module_name;
  4676. this.attributes = props.attributes;
  4677. this.start = props.start;
  4678. this.end = props.end;
  4679. }
  4680. this.flags = 0;
  4681. },
  4682. {
  4683. $documentation: "An `export` statement",
  4684. $propdoc: {
  4685. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  4686. exported_value: "[AST_Node?] An exported value",
  4687. exported_names: "[AST_NameMapping*?] List of exported names",
  4688. module_name: "[AST_String?] Name of the file to load exports from",
  4689. is_default: "[Boolean] Whether this is the default exported value of this module",
  4690. attributes: "[AST_Object?] The import attributes"
  4691. },
  4692. _walk: function (visitor) {
  4693. return visitor._visit(this, function () {
  4694. if (this.exported_definition) {
  4695. this.exported_definition._walk(visitor);
  4696. }
  4697. if (this.exported_value) {
  4698. this.exported_value._walk(visitor);
  4699. }
  4700. if (this.exported_names) {
  4701. this.exported_names.forEach(function(name_export) {
  4702. name_export._walk(visitor);
  4703. });
  4704. }
  4705. if (this.module_name) {
  4706. this.module_name._walk(visitor);
  4707. }
  4708. });
  4709. },
  4710. _children_backwards(push) {
  4711. if (this.module_name) push(this.module_name);
  4712. if (this.exported_names) {
  4713. let i = this.exported_names.length;
  4714. while (i--) push(this.exported_names[i]);
  4715. }
  4716. if (this.exported_value) push(this.exported_value);
  4717. if (this.exported_definition) push(this.exported_definition);
  4718. }
  4719. },
  4720. AST_Statement
  4721. );
  4722. /* -----[ OTHER ]----- */
  4723. var AST_Call = DEFNODE(
  4724. "Call",
  4725. "expression args optional _annotations",
  4726. function AST_Call(props) {
  4727. if (props) {
  4728. this.expression = props.expression;
  4729. this.args = props.args;
  4730. this.optional = props.optional;
  4731. this._annotations = props._annotations;
  4732. this.start = props.start;
  4733. this.end = props.end;
  4734. this.initialize();
  4735. }
  4736. this.flags = 0;
  4737. },
  4738. {
  4739. $documentation: "A function call expression",
  4740. $propdoc: {
  4741. expression: "[AST_Node] expression to invoke as function",
  4742. args: "[AST_Node*] array of arguments",
  4743. optional: "[boolean] whether this is an optional call (IE ?.() )",
  4744. _annotations: "[number] bitfield containing information about the call"
  4745. },
  4746. initialize() {
  4747. if (this._annotations == null) this._annotations = 0;
  4748. },
  4749. _walk(visitor) {
  4750. return visitor._visit(this, function() {
  4751. var args = this.args;
  4752. for (var i = 0, len = args.length; i < len; i++) {
  4753. args[i]._walk(visitor);
  4754. }
  4755. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  4756. });
  4757. },
  4758. _children_backwards(push) {
  4759. let i = this.args.length;
  4760. while (i--) push(this.args[i]);
  4761. push(this.expression);
  4762. },
  4763. }
  4764. );
  4765. var AST_New = DEFNODE("New", null, function AST_New(props) {
  4766. if (props) {
  4767. this.expression = props.expression;
  4768. this.args = props.args;
  4769. this.optional = props.optional;
  4770. this._annotations = props._annotations;
  4771. this.start = props.start;
  4772. this.end = props.end;
  4773. this.initialize();
  4774. }
  4775. this.flags = 0;
  4776. }, {
  4777. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  4778. }, AST_Call);
  4779. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  4780. if (props) {
  4781. this.expressions = props.expressions;
  4782. this.start = props.start;
  4783. this.end = props.end;
  4784. }
  4785. this.flags = 0;
  4786. }, {
  4787. $documentation: "A sequence expression (comma-separated expressions)",
  4788. $propdoc: {
  4789. expressions: "[AST_Node*] array of expressions (at least two)"
  4790. },
  4791. _walk: function(visitor) {
  4792. return visitor._visit(this, function() {
  4793. this.expressions.forEach(function(node) {
  4794. node._walk(visitor);
  4795. });
  4796. });
  4797. },
  4798. _children_backwards(push) {
  4799. let i = this.expressions.length;
  4800. while (i--) push(this.expressions[i]);
  4801. },
  4802. });
  4803. var AST_PropAccess = DEFNODE(
  4804. "PropAccess",
  4805. "expression property optional",
  4806. function AST_PropAccess(props) {
  4807. if (props) {
  4808. this.expression = props.expression;
  4809. this.property = props.property;
  4810. this.optional = props.optional;
  4811. this.start = props.start;
  4812. this.end = props.end;
  4813. }
  4814. this.flags = 0;
  4815. },
  4816. {
  4817. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  4818. $propdoc: {
  4819. expression: "[AST_Node] the “container” expression",
  4820. 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",
  4821. optional: "[boolean] whether this is an optional property access (IE ?.)"
  4822. }
  4823. }
  4824. );
  4825. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  4826. if (props) {
  4827. this.quote = props.quote;
  4828. this.expression = props.expression;
  4829. this.property = props.property;
  4830. this.optional = props.optional;
  4831. this._annotations = props._annotations;
  4832. this.start = props.start;
  4833. this.end = props.end;
  4834. }
  4835. this.flags = 0;
  4836. }, {
  4837. $documentation: "A dotted property access expression",
  4838. $propdoc: {
  4839. quote: "[string] the original quote character when transformed from AST_Sub",
  4840. },
  4841. _walk: function(visitor) {
  4842. return visitor._visit(this, function() {
  4843. this.expression._walk(visitor);
  4844. });
  4845. },
  4846. _children_backwards(push) {
  4847. push(this.expression);
  4848. },
  4849. }, AST_PropAccess);
  4850. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  4851. if (props) {
  4852. this.expression = props.expression;
  4853. this.property = props.property;
  4854. this.optional = props.optional;
  4855. this.start = props.start;
  4856. this.end = props.end;
  4857. }
  4858. this.flags = 0;
  4859. }, {
  4860. $documentation: "A dotted property access to a private property",
  4861. _walk: function(visitor) {
  4862. return visitor._visit(this, function() {
  4863. this.expression._walk(visitor);
  4864. });
  4865. },
  4866. _children_backwards(push) {
  4867. push(this.expression);
  4868. },
  4869. }, AST_PropAccess);
  4870. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  4871. if (props) {
  4872. this.expression = props.expression;
  4873. this.property = props.property;
  4874. this.optional = props.optional;
  4875. this._annotations = props._annotations;
  4876. this.start = props.start;
  4877. this.end = props.end;
  4878. }
  4879. this.flags = 0;
  4880. }, {
  4881. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4882. _walk: function(visitor) {
  4883. return visitor._visit(this, function() {
  4884. this.expression._walk(visitor);
  4885. this.property._walk(visitor);
  4886. });
  4887. },
  4888. _children_backwards(push) {
  4889. push(this.property);
  4890. push(this.expression);
  4891. },
  4892. }, AST_PropAccess);
  4893. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  4894. if (props) {
  4895. this.expression = props.expression;
  4896. this.start = props.start;
  4897. this.end = props.end;
  4898. }
  4899. this.flags = 0;
  4900. }, {
  4901. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4902. $propdoc: {
  4903. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  4904. },
  4905. _walk: function (visitor) {
  4906. return visitor._visit(this, function() {
  4907. this.expression._walk(visitor);
  4908. });
  4909. },
  4910. _children_backwards(push) {
  4911. push(this.expression);
  4912. },
  4913. });
  4914. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  4915. if (props) {
  4916. this.operator = props.operator;
  4917. this.expression = props.expression;
  4918. this.start = props.start;
  4919. this.end = props.end;
  4920. }
  4921. this.flags = 0;
  4922. }, {
  4923. $documentation: "Base class for unary expressions",
  4924. $propdoc: {
  4925. operator: "[string] the operator",
  4926. expression: "[AST_Node] expression that this unary operator applies to"
  4927. },
  4928. _walk: function(visitor) {
  4929. return visitor._visit(this, function() {
  4930. this.expression._walk(visitor);
  4931. });
  4932. },
  4933. _children_backwards(push) {
  4934. push(this.expression);
  4935. },
  4936. });
  4937. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  4938. if (props) {
  4939. this.operator = props.operator;
  4940. this.expression = props.expression;
  4941. this.start = props.start;
  4942. this.end = props.end;
  4943. }
  4944. this.flags = 0;
  4945. }, {
  4946. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4947. }, AST_Unary);
  4948. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  4949. if (props) {
  4950. this.operator = props.operator;
  4951. this.expression = props.expression;
  4952. this.start = props.start;
  4953. this.end = props.end;
  4954. }
  4955. this.flags = 0;
  4956. }, {
  4957. $documentation: "Unary postfix expression, i.e. `i++`"
  4958. }, AST_Unary);
  4959. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  4960. if (props) {
  4961. this.operator = props.operator;
  4962. this.left = props.left;
  4963. this.right = props.right;
  4964. this.start = props.start;
  4965. this.end = props.end;
  4966. }
  4967. this.flags = 0;
  4968. }, {
  4969. $documentation: "Binary expression, i.e. `a + b`",
  4970. $propdoc: {
  4971. left: "[AST_Node] left-hand side expression",
  4972. operator: "[string] the operator",
  4973. right: "[AST_Node] right-hand side expression"
  4974. },
  4975. _walk: function(visitor) {
  4976. return visitor._visit(this, function() {
  4977. this.left._walk(visitor);
  4978. this.right._walk(visitor);
  4979. });
  4980. },
  4981. _children_backwards(push) {
  4982. push(this.right);
  4983. push(this.left);
  4984. },
  4985. });
  4986. var AST_Conditional = DEFNODE(
  4987. "Conditional",
  4988. "condition consequent alternative",
  4989. function AST_Conditional(props) {
  4990. if (props) {
  4991. this.condition = props.condition;
  4992. this.consequent = props.consequent;
  4993. this.alternative = props.alternative;
  4994. this.start = props.start;
  4995. this.end = props.end;
  4996. }
  4997. this.flags = 0;
  4998. },
  4999. {
  5000. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  5001. $propdoc: {
  5002. condition: "[AST_Node]",
  5003. consequent: "[AST_Node]",
  5004. alternative: "[AST_Node]"
  5005. },
  5006. _walk: function(visitor) {
  5007. return visitor._visit(this, function() {
  5008. this.condition._walk(visitor);
  5009. this.consequent._walk(visitor);
  5010. this.alternative._walk(visitor);
  5011. });
  5012. },
  5013. _children_backwards(push) {
  5014. push(this.alternative);
  5015. push(this.consequent);
  5016. push(this.condition);
  5017. },
  5018. }
  5019. );
  5020. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  5021. if (props) {
  5022. this.logical = props.logical;
  5023. this.operator = props.operator;
  5024. this.left = props.left;
  5025. this.right = props.right;
  5026. this.start = props.start;
  5027. this.end = props.end;
  5028. }
  5029. this.flags = 0;
  5030. }, {
  5031. $documentation: "An assignment expression — `a = b + 5`",
  5032. $propdoc: {
  5033. logical: "Whether it's a logical assignment"
  5034. }
  5035. }, AST_Binary);
  5036. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  5037. if (props) {
  5038. this.operator = props.operator;
  5039. this.left = props.left;
  5040. this.right = props.right;
  5041. this.start = props.start;
  5042. this.end = props.end;
  5043. }
  5044. this.flags = 0;
  5045. }, {
  5046. $documentation: "A default assignment expression like in `(a = 3) => a`"
  5047. }, AST_Binary);
  5048. /* -----[ LITERALS ]----- */
  5049. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  5050. if (props) {
  5051. this.elements = props.elements;
  5052. this.start = props.start;
  5053. this.end = props.end;
  5054. }
  5055. this.flags = 0;
  5056. }, {
  5057. $documentation: "An array literal",
  5058. $propdoc: {
  5059. elements: "[AST_Node*] array of elements"
  5060. },
  5061. _walk: function(visitor) {
  5062. return visitor._visit(this, function() {
  5063. var elements = this.elements;
  5064. for (var i = 0, len = elements.length; i < len; i++) {
  5065. elements[i]._walk(visitor);
  5066. }
  5067. });
  5068. },
  5069. _children_backwards(push) {
  5070. let i = this.elements.length;
  5071. while (i--) push(this.elements[i]);
  5072. },
  5073. });
  5074. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  5075. if (props) {
  5076. this.properties = props.properties;
  5077. this.start = props.start;
  5078. this.end = props.end;
  5079. }
  5080. this.flags = 0;
  5081. }, {
  5082. $documentation: "An object literal",
  5083. $propdoc: {
  5084. properties: "[AST_ObjectProperty*] array of properties"
  5085. },
  5086. _walk: function(visitor) {
  5087. return visitor._visit(this, function() {
  5088. var properties = this.properties;
  5089. for (var i = 0, len = properties.length; i < len; i++) {
  5090. properties[i]._walk(visitor);
  5091. }
  5092. });
  5093. },
  5094. _children_backwards(push) {
  5095. let i = this.properties.length;
  5096. while (i--) push(this.properties[i]);
  5097. },
  5098. });
  5099. /* -----[ OBJECT/CLASS PROPERTIES ]----- */
  5100. /**
  5101. * Everything inside the curly braces of an object/class is a subclass of AST_ObjectProperty, except for AST_ClassStaticBlock.
  5102. **/
  5103. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  5104. if (props) {
  5105. this.key = props.key;
  5106. this.value = props.value;
  5107. this.start = props.start;
  5108. this.end = props.end;
  5109. this._annotations = props._annotations;
  5110. }
  5111. this.flags = 0;
  5112. }, {
  5113. $documentation: "Base class for literal object properties",
  5114. $propdoc: {
  5115. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  5116. value: "[AST_Node] property value. For getters, setters and methods this is an AST_Accessor."
  5117. },
  5118. _walk: function(visitor) {
  5119. return visitor._visit(this, function() {
  5120. if (this.key instanceof AST_Node)
  5121. this.key._walk(visitor);
  5122. this.value._walk(visitor);
  5123. });
  5124. },
  5125. _children_backwards(push) {
  5126. push(this.value);
  5127. if (this.key instanceof AST_Node) push(this.key);
  5128. },
  5129. });
  5130. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  5131. if (props) {
  5132. this.quote = props.quote;
  5133. this.key = props.key;
  5134. this.value = props.value;
  5135. this.start = props.start;
  5136. this.end = props.end;
  5137. this._annotations = props._annotations;
  5138. }
  5139. this.flags = 0;
  5140. }, {
  5141. $documentation: "A key: value object property",
  5142. $propdoc: {
  5143. quote: "[string] the original quote character"
  5144. },
  5145. computed_key() {
  5146. return this.key instanceof AST_Node;
  5147. }
  5148. }, AST_ObjectProperty);
  5149. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  5150. if (props) {
  5151. this.static = props.static;
  5152. this.key = props.key;
  5153. this.value = props.value;
  5154. this.start = props.start;
  5155. this.end = props.end;
  5156. }
  5157. this.flags = 0;
  5158. }, {
  5159. $propdoc: {
  5160. static: "[boolean] whether this is a static private setter"
  5161. },
  5162. $documentation: "A private setter property",
  5163. computed_key() {
  5164. return false;
  5165. }
  5166. }, AST_ObjectProperty);
  5167. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
  5168. if (props) {
  5169. this.static = props.static;
  5170. this.key = props.key;
  5171. this.value = props.value;
  5172. this.start = props.start;
  5173. this.end = props.end;
  5174. }
  5175. this.flags = 0;
  5176. }, {
  5177. $propdoc: {
  5178. static: "[boolean] whether this is a static private getter"
  5179. },
  5180. $documentation: "A private getter property",
  5181. computed_key() {
  5182. return false;
  5183. }
  5184. }, AST_ObjectProperty);
  5185. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  5186. if (props) {
  5187. this.quote = props.quote;
  5188. this.static = props.static;
  5189. this.key = props.key;
  5190. this.value = props.value;
  5191. this.start = props.start;
  5192. this.end = props.end;
  5193. this._annotations = props._annotations;
  5194. }
  5195. this.flags = 0;
  5196. }, {
  5197. $propdoc: {
  5198. quote: "[string|undefined] the original quote character, if any",
  5199. static: "[boolean] whether this is a static setter (classes only)"
  5200. },
  5201. $documentation: "An object setter property",
  5202. computed_key() {
  5203. return !(this.key instanceof AST_SymbolMethod);
  5204. }
  5205. }, AST_ObjectProperty);
  5206. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  5207. if (props) {
  5208. this.quote = props.quote;
  5209. this.static = props.static;
  5210. this.key = props.key;
  5211. this.value = props.value;
  5212. this.start = props.start;
  5213. this.end = props.end;
  5214. this._annotations = props._annotations;
  5215. }
  5216. this.flags = 0;
  5217. }, {
  5218. $propdoc: {
  5219. quote: "[string|undefined] the original quote character, if any",
  5220. static: "[boolean] whether this is a static getter (classes only)"
  5221. },
  5222. $documentation: "An object getter property",
  5223. computed_key() {
  5224. return !(this.key instanceof AST_SymbolMethod);
  5225. }
  5226. }, AST_ObjectProperty);
  5227. var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static", function AST_ConciseMethod(props) {
  5228. if (props) {
  5229. this.quote = props.quote;
  5230. this.static = props.static;
  5231. this.key = props.key;
  5232. this.value = props.value;
  5233. this.start = props.start;
  5234. this.end = props.end;
  5235. this._annotations = props._annotations;
  5236. }
  5237. this.flags = 0;
  5238. }, {
  5239. $propdoc: {
  5240. quote: "[string|undefined] the original quote character, if any",
  5241. static: "[boolean] is this method static (classes only)",
  5242. },
  5243. $documentation: "An ES6 concise method inside an object or class",
  5244. computed_key() {
  5245. return !(this.key instanceof AST_SymbolMethod);
  5246. }
  5247. }, AST_ObjectProperty);
  5248. var AST_PrivateMethod = DEFNODE("PrivateMethod", "static", function AST_PrivateMethod(props) {
  5249. if (props) {
  5250. this.static = props.static;
  5251. this.key = props.key;
  5252. this.value = props.value;
  5253. this.start = props.start;
  5254. this.end = props.end;
  5255. }
  5256. this.flags = 0;
  5257. }, {
  5258. $documentation: "A private class method inside a class",
  5259. $propdoc: {
  5260. static: "[boolean] is this a static private method",
  5261. },
  5262. computed_key() {
  5263. return false;
  5264. },
  5265. }, AST_ObjectProperty);
  5266. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  5267. if (props) {
  5268. this.name = props.name;
  5269. this.extends = props.extends;
  5270. this.properties = props.properties;
  5271. this.variables = props.variables;
  5272. this.uses_with = props.uses_with;
  5273. this.uses_eval = props.uses_eval;
  5274. this.parent_scope = props.parent_scope;
  5275. this.enclosed = props.enclosed;
  5276. this.cname = props.cname;
  5277. this.body = props.body;
  5278. this.block_scope = props.block_scope;
  5279. this.start = props.start;
  5280. this.end = props.end;
  5281. }
  5282. this.flags = 0;
  5283. }, {
  5284. $propdoc: {
  5285. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  5286. extends: "[AST_Node]? optional parent class",
  5287. properties: "[AST_ObjectProperty|AST_ClassStaticBlock]* array of properties or static blocks"
  5288. },
  5289. $documentation: "An ES6 class",
  5290. _walk: function(visitor) {
  5291. return visitor._visit(this, function() {
  5292. if (this.name) {
  5293. this.name._walk(visitor);
  5294. }
  5295. if (this.extends) {
  5296. this.extends._walk(visitor);
  5297. }
  5298. this.properties.forEach((prop) => prop._walk(visitor));
  5299. });
  5300. },
  5301. _children_backwards(push) {
  5302. let i = this.properties.length;
  5303. while (i--) push(this.properties[i]);
  5304. if (this.extends) push(this.extends);
  5305. if (this.name) push(this.name);
  5306. },
  5307. /** go through the bits that are executed instantly, not when the class is `new`'d. Doesn't walk the name. */
  5308. visit_nondeferred_class_parts(visitor) {
  5309. if (this.extends) {
  5310. this.extends._walk(visitor);
  5311. }
  5312. this.properties.forEach((prop) => {
  5313. if (prop instanceof AST_ClassStaticBlock) {
  5314. prop._walk(visitor);
  5315. return;
  5316. }
  5317. if (prop.computed_key()) {
  5318. visitor.push(prop);
  5319. prop.key._walk(visitor);
  5320. visitor.pop();
  5321. }
  5322. if (
  5323. prop instanceof AST_ClassPrivateProperty && prop.static && prop.value
  5324. || prop instanceof AST_ClassProperty && prop.static && prop.value
  5325. ) {
  5326. visitor.push(prop);
  5327. prop.value._walk(visitor);
  5328. visitor.pop();
  5329. }
  5330. });
  5331. },
  5332. /** go through the bits that are executed later, when the class is `new`'d or a static method is called */
  5333. visit_deferred_class_parts(visitor) {
  5334. this.properties.forEach((prop) => {
  5335. if (
  5336. prop instanceof AST_ConciseMethod
  5337. || prop instanceof AST_PrivateMethod
  5338. ) {
  5339. prop.walk(visitor);
  5340. } else if (
  5341. prop instanceof AST_ClassProperty && !prop.static && prop.value
  5342. || prop instanceof AST_ClassPrivateProperty && !prop.static && prop.value
  5343. ) {
  5344. visitor.push(prop);
  5345. prop.value._walk(visitor);
  5346. visitor.pop();
  5347. }
  5348. });
  5349. },
  5350. is_self_referential: function() {
  5351. const this_id = this.name && this.name.definition().id;
  5352. let found = false;
  5353. let class_this = true;
  5354. this.visit_nondeferred_class_parts(new TreeWalker((node, descend) => {
  5355. if (found) return true;
  5356. if (node instanceof AST_This) return (found = class_this);
  5357. if (node instanceof AST_SymbolRef) return (found = node.definition().id === this_id);
  5358. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  5359. const class_this_save = class_this;
  5360. class_this = false;
  5361. descend();
  5362. class_this = class_this_save;
  5363. return true;
  5364. }
  5365. }));
  5366. return found;
  5367. },
  5368. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  5369. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  5370. if (props) {
  5371. this.static = props.static;
  5372. this.quote = props.quote;
  5373. this.key = props.key;
  5374. this.value = props.value;
  5375. this.start = props.start;
  5376. this.end = props.end;
  5377. this._annotations = props._annotations;
  5378. }
  5379. this.flags = 0;
  5380. }, {
  5381. $documentation: "A class property",
  5382. $propdoc: {
  5383. static: "[boolean] whether this is a static key",
  5384. quote: "[string] which quote is being used"
  5385. },
  5386. _walk: function(visitor) {
  5387. return visitor._visit(this, function() {
  5388. if (this.key instanceof AST_Node)
  5389. this.key._walk(visitor);
  5390. if (this.value instanceof AST_Node)
  5391. this.value._walk(visitor);
  5392. });
  5393. },
  5394. _children_backwards(push) {
  5395. if (this.value instanceof AST_Node) push(this.value);
  5396. if (this.key instanceof AST_Node) push(this.key);
  5397. },
  5398. computed_key() {
  5399. return !(this.key instanceof AST_SymbolClassProperty);
  5400. }
  5401. }, AST_ObjectProperty);
  5402. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  5403. if (props) {
  5404. this.static = props.static;
  5405. this.key = props.key;
  5406. this.value = props.value;
  5407. this.start = props.start;
  5408. this.end = props.end;
  5409. }
  5410. this.flags = 0;
  5411. }, {
  5412. $documentation: "A class property for a private property",
  5413. _walk: function(visitor) {
  5414. return visitor._visit(this, function() {
  5415. if (this.value instanceof AST_Node)
  5416. this.value._walk(visitor);
  5417. });
  5418. },
  5419. _children_backwards(push) {
  5420. if (this.value instanceof AST_Node) push(this.value);
  5421. },
  5422. computed_key() {
  5423. return false;
  5424. },
  5425. }, AST_ObjectProperty);
  5426. var AST_PrivateIn = DEFNODE("PrivateIn", "key value", function AST_PrivateIn(props) {
  5427. if (props) {
  5428. this.key = props.key;
  5429. this.value = props.value;
  5430. this.start = props.start;
  5431. this.end = props.end;
  5432. }
  5433. this.flags = 0;
  5434. }, {
  5435. $documentation: "An `in` binop when the key is private, eg #x in this",
  5436. _walk: function(visitor) {
  5437. return visitor._visit(this, function() {
  5438. this.key._walk(visitor);
  5439. this.value._walk(visitor);
  5440. });
  5441. },
  5442. _children_backwards(push) {
  5443. push(this.value);
  5444. push(this.key);
  5445. },
  5446. });
  5447. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  5448. if (props) {
  5449. this.name = props.name;
  5450. this.extends = props.extends;
  5451. this.properties = props.properties;
  5452. this.variables = props.variables;
  5453. this.uses_with = props.uses_with;
  5454. this.uses_eval = props.uses_eval;
  5455. this.parent_scope = props.parent_scope;
  5456. this.enclosed = props.enclosed;
  5457. this.cname = props.cname;
  5458. this.body = props.body;
  5459. this.block_scope = props.block_scope;
  5460. this.start = props.start;
  5461. this.end = props.end;
  5462. }
  5463. this.flags = 0;
  5464. }, {
  5465. $documentation: "A class definition",
  5466. }, AST_Class);
  5467. var AST_ClassStaticBlock = DEFNODE("ClassStaticBlock", "body block_scope", function AST_ClassStaticBlock (props) {
  5468. this.body = props.body;
  5469. this.block_scope = props.block_scope;
  5470. this.start = props.start;
  5471. this.end = props.end;
  5472. }, {
  5473. $documentation: "A block containing statements to be executed in the context of the class",
  5474. $propdoc: {
  5475. body: "[AST_Statement*] an array of statements",
  5476. },
  5477. _walk: function(visitor) {
  5478. return visitor._visit(this, function() {
  5479. walk_body(this, visitor);
  5480. });
  5481. },
  5482. _children_backwards(push) {
  5483. let i = this.body.length;
  5484. while (i--) push(this.body[i]);
  5485. },
  5486. clone: clone_block_scope,
  5487. computed_key() {
  5488. return false;
  5489. },
  5490. }, AST_Scope);
  5491. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  5492. if (props) {
  5493. this.name = props.name;
  5494. this.extends = props.extends;
  5495. this.properties = props.properties;
  5496. this.variables = props.variables;
  5497. this.uses_with = props.uses_with;
  5498. this.uses_eval = props.uses_eval;
  5499. this.parent_scope = props.parent_scope;
  5500. this.enclosed = props.enclosed;
  5501. this.cname = props.cname;
  5502. this.body = props.body;
  5503. this.block_scope = props.block_scope;
  5504. this.start = props.start;
  5505. this.end = props.end;
  5506. }
  5507. this.flags = 0;
  5508. }, {
  5509. $documentation: "A class expression."
  5510. }, AST_Class);
  5511. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  5512. if (props) {
  5513. this.scope = props.scope;
  5514. this.name = props.name;
  5515. this.thedef = props.thedef;
  5516. this.start = props.start;
  5517. this.end = props.end;
  5518. }
  5519. this.flags = 0;
  5520. }, {
  5521. $propdoc: {
  5522. name: "[string] name of this symbol",
  5523. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  5524. thedef: "[SymbolDef/S] the definition of this symbol"
  5525. },
  5526. $documentation: "Base class for all symbols"
  5527. });
  5528. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  5529. if (props) {
  5530. this.start = props.start;
  5531. this.end = props.end;
  5532. }
  5533. this.flags = 0;
  5534. }, {
  5535. $documentation: "A reference to new.target"
  5536. });
  5537. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  5538. if (props) {
  5539. this.init = props.init;
  5540. this.scope = props.scope;
  5541. this.name = props.name;
  5542. this.thedef = props.thedef;
  5543. this.start = props.start;
  5544. this.end = props.end;
  5545. }
  5546. this.flags = 0;
  5547. }, {
  5548. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  5549. }, AST_Symbol);
  5550. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
  5551. if (props) {
  5552. this.init = props.init;
  5553. this.scope = props.scope;
  5554. this.name = props.name;
  5555. this.thedef = props.thedef;
  5556. this.start = props.start;
  5557. this.end = props.end;
  5558. }
  5559. this.flags = 0;
  5560. }, {
  5561. $documentation: "Symbol defining a variable",
  5562. }, AST_SymbolDeclaration);
  5563. var AST_SymbolBlockDeclaration = DEFNODE(
  5564. "SymbolBlockDeclaration",
  5565. null,
  5566. function AST_SymbolBlockDeclaration(props) {
  5567. if (props) {
  5568. this.init = props.init;
  5569. this.scope = props.scope;
  5570. this.name = props.name;
  5571. this.thedef = props.thedef;
  5572. this.start = props.start;
  5573. this.end = props.end;
  5574. }
  5575. this.flags = 0;
  5576. },
  5577. {
  5578. $documentation: "Base class for block-scoped declaration symbols"
  5579. },
  5580. AST_SymbolDeclaration
  5581. );
  5582. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  5583. if (props) {
  5584. this.init = props.init;
  5585. this.scope = props.scope;
  5586. this.name = props.name;
  5587. this.thedef = props.thedef;
  5588. this.start = props.start;
  5589. this.end = props.end;
  5590. }
  5591. this.flags = 0;
  5592. }, {
  5593. $documentation: "A constant declaration"
  5594. }, AST_SymbolBlockDeclaration);
  5595. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(props) {
  5596. if (props) {
  5597. this.init = props.init;
  5598. this.scope = props.scope;
  5599. this.name = props.name;
  5600. this.thedef = props.thedef;
  5601. this.start = props.start;
  5602. this.end = props.end;
  5603. }
  5604. this.flags = 0;
  5605. }, {
  5606. $documentation: "A block-scoped `let` declaration"
  5607. }, AST_SymbolBlockDeclaration);
  5608. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
  5609. if (props) {
  5610. this.init = props.init;
  5611. this.scope = props.scope;
  5612. this.name = props.name;
  5613. this.thedef = props.thedef;
  5614. this.start = props.start;
  5615. this.end = props.end;
  5616. }
  5617. this.flags = 0;
  5618. }, {
  5619. $documentation: "Symbol naming a function argument",
  5620. }, AST_SymbolVar);
  5621. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
  5622. if (props) {
  5623. this.init = props.init;
  5624. this.scope = props.scope;
  5625. this.name = props.name;
  5626. this.thedef = props.thedef;
  5627. this.start = props.start;
  5628. this.end = props.end;
  5629. }
  5630. this.flags = 0;
  5631. }, {
  5632. $documentation: "Symbol defining a function",
  5633. }, AST_SymbolDeclaration);
  5634. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  5635. if (props) {
  5636. this.scope = props.scope;
  5637. this.name = props.name;
  5638. this.thedef = props.thedef;
  5639. this.start = props.start;
  5640. this.end = props.end;
  5641. }
  5642. this.flags = 0;
  5643. }, {
  5644. $documentation: "Symbol in an object defining a method",
  5645. }, AST_Symbol);
  5646. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  5647. if (props) {
  5648. this.scope = props.scope;
  5649. this.name = props.name;
  5650. this.thedef = props.thedef;
  5651. this.start = props.start;
  5652. this.end = props.end;
  5653. }
  5654. this.flags = 0;
  5655. }, {
  5656. $documentation: "Symbol for a class property",
  5657. }, AST_Symbol);
  5658. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  5659. if (props) {
  5660. this.init = props.init;
  5661. this.scope = props.scope;
  5662. this.name = props.name;
  5663. this.thedef = props.thedef;
  5664. this.start = props.start;
  5665. this.end = props.end;
  5666. }
  5667. this.flags = 0;
  5668. }, {
  5669. $documentation: "Symbol naming a function expression",
  5670. }, AST_SymbolDeclaration);
  5671. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
  5672. if (props) {
  5673. this.init = props.init;
  5674. this.scope = props.scope;
  5675. this.name = props.name;
  5676. this.thedef = props.thedef;
  5677. this.start = props.start;
  5678. this.end = props.end;
  5679. }
  5680. this.flags = 0;
  5681. }, {
  5682. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  5683. }, AST_SymbolBlockDeclaration);
  5684. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
  5685. if (props) {
  5686. this.init = props.init;
  5687. this.scope = props.scope;
  5688. this.name = props.name;
  5689. this.thedef = props.thedef;
  5690. this.start = props.start;
  5691. this.end = props.end;
  5692. }
  5693. this.flags = 0;
  5694. }, {
  5695. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  5696. }, AST_SymbolDeclaration);
  5697. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
  5698. if (props) {
  5699. this.init = props.init;
  5700. this.scope = props.scope;
  5701. this.name = props.name;
  5702. this.thedef = props.thedef;
  5703. this.start = props.start;
  5704. this.end = props.end;
  5705. }
  5706. this.flags = 0;
  5707. }, {
  5708. $documentation: "Symbol naming the exception in catch",
  5709. }, AST_SymbolBlockDeclaration);
  5710. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
  5711. if (props) {
  5712. this.init = props.init;
  5713. this.scope = props.scope;
  5714. this.name = props.name;
  5715. this.thedef = props.thedef;
  5716. this.start = props.start;
  5717. this.end = props.end;
  5718. }
  5719. this.flags = 0;
  5720. }, {
  5721. $documentation: "Symbol referring to an imported name",
  5722. }, AST_SymbolBlockDeclaration);
  5723. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", "quote", function AST_SymbolImportForeign(props) {
  5724. if (props) {
  5725. this.quote = props.quote;
  5726. this.scope = props.scope;
  5727. this.name = props.name;
  5728. this.thedef = props.thedef;
  5729. this.start = props.start;
  5730. this.end = props.end;
  5731. }
  5732. this.flags = 0;
  5733. }, {
  5734. $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",
  5735. }, AST_Symbol);
  5736. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  5737. if (props) {
  5738. this.references = props.references;
  5739. this.scope = props.scope;
  5740. this.name = props.name;
  5741. this.thedef = props.thedef;
  5742. this.start = props.start;
  5743. this.end = props.end;
  5744. this.initialize();
  5745. }
  5746. this.flags = 0;
  5747. }, {
  5748. $documentation: "Symbol naming a label (declaration)",
  5749. $propdoc: {
  5750. references: "[AST_LoopControl*] a list of nodes referring to this label"
  5751. },
  5752. initialize: function() {
  5753. this.references = [];
  5754. this.thedef = this;
  5755. }
  5756. }, AST_Symbol);
  5757. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  5758. if (props) {
  5759. this.scope = props.scope;
  5760. this.name = props.name;
  5761. this.thedef = props.thedef;
  5762. this.start = props.start;
  5763. this.end = props.end;
  5764. }
  5765. this.flags = 0;
  5766. }, {
  5767. $documentation: "Reference to some symbol (not definition/declaration)",
  5768. }, AST_Symbol);
  5769. var AST_SymbolExport = DEFNODE("SymbolExport", "quote", function AST_SymbolExport(props) {
  5770. if (props) {
  5771. this.quote = props.quote;
  5772. this.scope = props.scope;
  5773. this.name = props.name;
  5774. this.thedef = props.thedef;
  5775. this.start = props.start;
  5776. this.end = props.end;
  5777. }
  5778. this.flags = 0;
  5779. }, {
  5780. $documentation: "Symbol referring to a name to export",
  5781. }, AST_SymbolRef);
  5782. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", "quote", function AST_SymbolExportForeign(props) {
  5783. if (props) {
  5784. this.quote = props.quote;
  5785. this.scope = props.scope;
  5786. this.name = props.name;
  5787. this.thedef = props.thedef;
  5788. this.start = props.start;
  5789. this.end = props.end;
  5790. }
  5791. this.flags = 0;
  5792. }, {
  5793. $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",
  5794. }, AST_Symbol);
  5795. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  5796. if (props) {
  5797. this.scope = props.scope;
  5798. this.name = props.name;
  5799. this.thedef = props.thedef;
  5800. this.start = props.start;
  5801. this.end = props.end;
  5802. }
  5803. this.flags = 0;
  5804. }, {
  5805. $documentation: "Reference to a label symbol",
  5806. }, AST_Symbol);
  5807. var AST_SymbolPrivateProperty = DEFNODE("SymbolPrivateProperty", null, function AST_SymbolPrivateProperty(props) {
  5808. if (props) {
  5809. this.scope = props.scope;
  5810. this.name = props.name;
  5811. this.thedef = props.thedef;
  5812. this.start = props.start;
  5813. this.end = props.end;
  5814. }
  5815. this.flags = 0;
  5816. }, {
  5817. $documentation: "A symbol that refers to a private property",
  5818. }, AST_Symbol);
  5819. var AST_This = DEFNODE("This", null, function AST_This(props) {
  5820. if (props) {
  5821. this.scope = props.scope;
  5822. this.name = props.name;
  5823. this.thedef = props.thedef;
  5824. this.start = props.start;
  5825. this.end = props.end;
  5826. }
  5827. this.flags = 0;
  5828. }, {
  5829. $documentation: "The `this` symbol",
  5830. }, AST_Symbol);
  5831. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  5832. if (props) {
  5833. this.scope = props.scope;
  5834. this.name = props.name;
  5835. this.thedef = props.thedef;
  5836. this.start = props.start;
  5837. this.end = props.end;
  5838. }
  5839. this.flags = 0;
  5840. }, {
  5841. $documentation: "The `super` symbol",
  5842. }, AST_This);
  5843. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  5844. if (props) {
  5845. this.start = props.start;
  5846. this.end = props.end;
  5847. }
  5848. this.flags = 0;
  5849. }, {
  5850. $documentation: "Base class for all constants",
  5851. getValue: function() {
  5852. return this.value;
  5853. }
  5854. });
  5855. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  5856. if (props) {
  5857. this.value = props.value;
  5858. this.quote = props.quote;
  5859. this.start = props.start;
  5860. this.end = props.end;
  5861. this._annotations = props._annotations;
  5862. }
  5863. this.flags = 0;
  5864. }, {
  5865. $documentation: "A string literal",
  5866. $propdoc: {
  5867. value: "[string] the contents of this string",
  5868. quote: "[string] the original quote character"
  5869. }
  5870. }, AST_Constant);
  5871. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  5872. if (props) {
  5873. this.value = props.value;
  5874. this.raw = props.raw;
  5875. this.start = props.start;
  5876. this.end = props.end;
  5877. }
  5878. this.flags = 0;
  5879. }, {
  5880. $documentation: "A number literal",
  5881. $propdoc: {
  5882. value: "[number] the numeric value",
  5883. raw: "[string] numeric value as string"
  5884. }
  5885. }, AST_Constant);
  5886. var AST_BigInt = DEFNODE("BigInt", "value raw", function AST_BigInt(props) {
  5887. if (props) {
  5888. this.value = props.value;
  5889. this.raw = props.raw;
  5890. this.start = props.start;
  5891. this.end = props.end;
  5892. }
  5893. this.flags = 0;
  5894. }, {
  5895. $documentation: "A big int literal",
  5896. $propdoc: {
  5897. value: "[string] big int value, represented as a string",
  5898. raw: "[string] the original format preserved"
  5899. }
  5900. }, AST_Constant);
  5901. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  5902. if (props) {
  5903. this.value = props.value;
  5904. this.start = props.start;
  5905. this.end = props.end;
  5906. }
  5907. this.flags = 0;
  5908. }, {
  5909. $documentation: "A regexp literal",
  5910. $propdoc: {
  5911. value: "[RegExp] the actual regexp",
  5912. }
  5913. }, AST_Constant);
  5914. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  5915. if (props) {
  5916. this.start = props.start;
  5917. this.end = props.end;
  5918. }
  5919. this.flags = 0;
  5920. }, {
  5921. $documentation: "Base class for atoms",
  5922. }, AST_Constant);
  5923. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  5924. if (props) {
  5925. this.start = props.start;
  5926. this.end = props.end;
  5927. }
  5928. this.flags = 0;
  5929. }, {
  5930. $documentation: "The `null` atom",
  5931. value: null
  5932. }, AST_Atom);
  5933. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  5934. if (props) {
  5935. this.start = props.start;
  5936. this.end = props.end;
  5937. }
  5938. this.flags = 0;
  5939. }, {
  5940. $documentation: "The impossible value",
  5941. value: 0/0
  5942. }, AST_Atom);
  5943. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  5944. if (props) {
  5945. this.start = props.start;
  5946. this.end = props.end;
  5947. }
  5948. this.flags = 0;
  5949. }, {
  5950. $documentation: "The `undefined` value",
  5951. value: (function() {}())
  5952. }, AST_Atom);
  5953. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  5954. if (props) {
  5955. this.start = props.start;
  5956. this.end = props.end;
  5957. }
  5958. this.flags = 0;
  5959. }, {
  5960. $documentation: "A hole in an array",
  5961. value: (function() {}())
  5962. }, AST_Atom);
  5963. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  5964. if (props) {
  5965. this.start = props.start;
  5966. this.end = props.end;
  5967. }
  5968. this.flags = 0;
  5969. }, {
  5970. $documentation: "The `Infinity` value",
  5971. value: 1/0
  5972. }, AST_Atom);
  5973. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  5974. if (props) {
  5975. this.start = props.start;
  5976. this.end = props.end;
  5977. }
  5978. this.flags = 0;
  5979. }, {
  5980. $documentation: "Base class for booleans",
  5981. }, AST_Atom);
  5982. var AST_False = DEFNODE("False", null, function AST_False(props) {
  5983. if (props) {
  5984. this.start = props.start;
  5985. this.end = props.end;
  5986. }
  5987. this.flags = 0;
  5988. }, {
  5989. $documentation: "The `false` atom",
  5990. value: false
  5991. }, AST_Boolean);
  5992. var AST_True = DEFNODE("True", null, function AST_True(props) {
  5993. if (props) {
  5994. this.start = props.start;
  5995. this.end = props.end;
  5996. }
  5997. this.flags = 0;
  5998. }, {
  5999. $documentation: "The `true` atom",
  6000. value: true
  6001. }, AST_Boolean);
  6002. /* -----[ Walk function ]---- */
  6003. /**
  6004. * Walk nodes in depth-first search fashion.
  6005. * Callback can return `walk_abort` symbol to stop iteration.
  6006. * It can also return `true` to stop iteration just for child nodes.
  6007. * Iteration can be stopped and continued by passing the `to_visit` argument,
  6008. * which is given to the callback in the second argument.
  6009. **/
  6010. function walk(node, cb, to_visit = [node]) {
  6011. const push = to_visit.push.bind(to_visit);
  6012. while (to_visit.length) {
  6013. const node = to_visit.pop();
  6014. const ret = cb(node, to_visit);
  6015. if (ret) {
  6016. if (ret === walk_abort) return true;
  6017. continue;
  6018. }
  6019. node._children_backwards(push);
  6020. }
  6021. return false;
  6022. }
  6023. /**
  6024. * Walks an AST node and its children.
  6025. *
  6026. * {cb} can return `walk_abort` to interrupt the walk.
  6027. *
  6028. * @param node
  6029. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  6030. *
  6031. * @returns {boolean} whether the walk was aborted
  6032. *
  6033. * @example
  6034. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  6035. * if (some_cond(node, parent())) return walk_abort
  6036. * });
  6037. */
  6038. function walk_parent(node, cb, initial_stack) {
  6039. const to_visit = [node];
  6040. const push = to_visit.push.bind(to_visit);
  6041. const stack = initial_stack ? initial_stack.slice() : [];
  6042. const parent_pop_indices = [];
  6043. let current;
  6044. const info = {
  6045. parent: (n = 0) => {
  6046. if (n === -1) {
  6047. return current;
  6048. }
  6049. // [ p1 p0 ] [ 1 0 ]
  6050. if (initial_stack && n >= stack.length) {
  6051. n -= stack.length;
  6052. return initial_stack[
  6053. initial_stack.length - (n + 1)
  6054. ];
  6055. }
  6056. return stack[stack.length - (1 + n)];
  6057. },
  6058. };
  6059. while (to_visit.length) {
  6060. current = to_visit.pop();
  6061. while (
  6062. parent_pop_indices.length &&
  6063. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  6064. ) {
  6065. stack.pop();
  6066. parent_pop_indices.pop();
  6067. }
  6068. const ret = cb(current, info);
  6069. if (ret) {
  6070. if (ret === walk_abort) return true;
  6071. continue;
  6072. }
  6073. const visit_length = to_visit.length;
  6074. current._children_backwards(push);
  6075. // Push only if we're going to traverse the children
  6076. if (to_visit.length > visit_length) {
  6077. stack.push(current);
  6078. parent_pop_indices.push(visit_length - 1);
  6079. }
  6080. }
  6081. return false;
  6082. }
  6083. const walk_abort = Symbol("abort walk");
  6084. /* -----[ TreeWalker ]----- */
  6085. class TreeWalker {
  6086. constructor(callback) {
  6087. this.visit = callback;
  6088. this.stack = [];
  6089. this.directives = Object.create(null);
  6090. }
  6091. _visit(node, descend) {
  6092. this.push(node);
  6093. var ret = this.visit(node, descend ? function() {
  6094. descend.call(node);
  6095. } : noop);
  6096. if (!ret && descend) {
  6097. descend.call(node);
  6098. }
  6099. this.pop();
  6100. return ret;
  6101. }
  6102. parent(n) {
  6103. return this.stack[this.stack.length - 2 - (n || 0)];
  6104. }
  6105. push(node) {
  6106. if (node instanceof AST_Lambda) {
  6107. this.directives = Object.create(this.directives);
  6108. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  6109. this.directives[node.value] = node;
  6110. } else if (node instanceof AST_Class) {
  6111. this.directives = Object.create(this.directives);
  6112. if (!this.directives["use strict"]) {
  6113. this.directives["use strict"] = node;
  6114. }
  6115. }
  6116. this.stack.push(node);
  6117. }
  6118. pop() {
  6119. var node = this.stack.pop();
  6120. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  6121. this.directives = Object.getPrototypeOf(this.directives);
  6122. }
  6123. }
  6124. self() {
  6125. return this.stack[this.stack.length - 1];
  6126. }
  6127. find_parent(type) {
  6128. var stack = this.stack;
  6129. for (var i = stack.length; --i >= 0;) {
  6130. var x = stack[i];
  6131. if (x instanceof type) return x;
  6132. }
  6133. }
  6134. is_within_loop() {
  6135. let i = this.stack.length - 1;
  6136. let child = this.stack[i];
  6137. while (i--) {
  6138. const node = this.stack[i];
  6139. if (node instanceof AST_Lambda) return false;
  6140. if (
  6141. node instanceof AST_IterationStatement
  6142. // exclude for-loop bits that only run once
  6143. && !((node instanceof AST_For) && child === node.init)
  6144. && !((node instanceof AST_ForIn || node instanceof AST_ForOf) && child === node.object)
  6145. ) {
  6146. return true;
  6147. }
  6148. child = node;
  6149. }
  6150. return false;
  6151. }
  6152. find_scope() {
  6153. var stack = this.stack;
  6154. for (var i = stack.length; --i >= 0;) {
  6155. const p = stack[i];
  6156. if (p instanceof AST_Toplevel) return p;
  6157. if (p instanceof AST_Lambda) return p;
  6158. if (p.block_scope) return p.block_scope;
  6159. }
  6160. }
  6161. has_directive(type) {
  6162. var dir = this.directives[type];
  6163. if (dir) return dir;
  6164. var node = this.stack[this.stack.length - 1];
  6165. if (node instanceof AST_Scope && node.body) {
  6166. for (var i = 0; i < node.body.length; ++i) {
  6167. var st = node.body[i];
  6168. if (!(st instanceof AST_Directive)) break;
  6169. if (st.value == type) return st;
  6170. }
  6171. }
  6172. }
  6173. loopcontrol_target(node) {
  6174. var stack = this.stack;
  6175. if (node.label) for (var i = stack.length; --i >= 0;) {
  6176. var x = stack[i];
  6177. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  6178. return x.body;
  6179. } else for (var i = stack.length; --i >= 0;) {
  6180. var x = stack[i];
  6181. if (x instanceof AST_IterationStatement
  6182. || node instanceof AST_Break && x instanceof AST_Switch)
  6183. return x;
  6184. }
  6185. }
  6186. }
  6187. // Tree transformer helpers.
  6188. class TreeTransformer extends TreeWalker {
  6189. constructor(before, after) {
  6190. super();
  6191. this.before = before;
  6192. this.after = after;
  6193. }
  6194. }
  6195. const _PURE = 0b00000001;
  6196. const _INLINE = 0b00000010;
  6197. const _NOINLINE = 0b00000100;
  6198. const _KEY = 0b00001000;
  6199. const _MANGLEPROP = 0b00010000;
  6200. /***********************************************************************
  6201. A JavaScript tokenizer / parser / beautifier / compressor.
  6202. https://github.com/mishoo/UglifyJS2
  6203. -------------------------------- (C) ---------------------------------
  6204. Author: Mihai Bazon
  6205. <mihai.bazon@gmail.com>
  6206. http://mihai.bazon.net/blog
  6207. Distributed under the BSD license:
  6208. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6209. Redistribution and use in source and binary forms, with or without
  6210. modification, are permitted provided that the following conditions
  6211. are met:
  6212. * Redistributions of source code must retain the above
  6213. copyright notice, this list of conditions and the following
  6214. disclaimer.
  6215. * Redistributions in binary form must reproduce the above
  6216. copyright notice, this list of conditions and the following
  6217. disclaimer in the documentation and/or other materials
  6218. provided with the distribution.
  6219. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6220. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6221. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6222. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6223. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6224. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6225. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6226. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6227. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6228. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6229. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6230. SUCH DAMAGE.
  6231. ***********************************************************************/
  6232. function def_transform(node, descend) {
  6233. node.DEFMETHOD("transform", function(tw, in_list) {
  6234. let transformed = undefined;
  6235. tw.push(this);
  6236. if (tw.before) transformed = tw.before(this, descend, in_list);
  6237. if (transformed === undefined) {
  6238. transformed = this;
  6239. descend(transformed, tw);
  6240. if (tw.after) {
  6241. const after_ret = tw.after(transformed, in_list);
  6242. if (after_ret !== undefined) transformed = after_ret;
  6243. }
  6244. }
  6245. tw.pop();
  6246. return transformed;
  6247. });
  6248. }
  6249. def_transform(AST_Node, noop);
  6250. def_transform(AST_LabeledStatement, function(self, tw) {
  6251. self.label = self.label.transform(tw);
  6252. self.body = self.body.transform(tw);
  6253. });
  6254. def_transform(AST_SimpleStatement, function(self, tw) {
  6255. self.body = self.body.transform(tw);
  6256. });
  6257. def_transform(AST_Block, function(self, tw) {
  6258. self.body = MAP(self.body, tw);
  6259. });
  6260. def_transform(AST_Do, function(self, tw) {
  6261. self.body = self.body.transform(tw);
  6262. self.condition = self.condition.transform(tw);
  6263. });
  6264. def_transform(AST_While, function(self, tw) {
  6265. self.condition = self.condition.transform(tw);
  6266. self.body = self.body.transform(tw);
  6267. });
  6268. def_transform(AST_For, function(self, tw) {
  6269. if (self.init) self.init = self.init.transform(tw);
  6270. if (self.condition) self.condition = self.condition.transform(tw);
  6271. if (self.step) self.step = self.step.transform(tw);
  6272. self.body = self.body.transform(tw);
  6273. });
  6274. def_transform(AST_ForIn, function(self, tw) {
  6275. self.init = self.init.transform(tw);
  6276. self.object = self.object.transform(tw);
  6277. self.body = self.body.transform(tw);
  6278. });
  6279. def_transform(AST_With, function(self, tw) {
  6280. self.expression = self.expression.transform(tw);
  6281. self.body = self.body.transform(tw);
  6282. });
  6283. def_transform(AST_Exit, function(self, tw) {
  6284. if (self.value) self.value = self.value.transform(tw);
  6285. });
  6286. def_transform(AST_LoopControl, function(self, tw) {
  6287. if (self.label) self.label = self.label.transform(tw);
  6288. });
  6289. def_transform(AST_If, function(self, tw) {
  6290. self.condition = self.condition.transform(tw);
  6291. self.body = self.body.transform(tw);
  6292. if (self.alternative) self.alternative = self.alternative.transform(tw);
  6293. });
  6294. def_transform(AST_Switch, function(self, tw) {
  6295. self.expression = self.expression.transform(tw);
  6296. self.body = MAP(self.body, tw);
  6297. });
  6298. def_transform(AST_Case, function(self, tw) {
  6299. self.expression = self.expression.transform(tw);
  6300. self.body = MAP(self.body, tw);
  6301. });
  6302. def_transform(AST_Try, function(self, tw) {
  6303. self.body = self.body.transform(tw);
  6304. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  6305. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  6306. });
  6307. def_transform(AST_Catch, function(self, tw) {
  6308. if (self.argname) self.argname = self.argname.transform(tw);
  6309. self.body = MAP(self.body, tw);
  6310. });
  6311. def_transform(AST_Definitions, function(self, tw) {
  6312. self.definitions = MAP(self.definitions, tw);
  6313. });
  6314. def_transform(AST_VarDef, function(self, tw) {
  6315. self.name = self.name.transform(tw);
  6316. if (self.value) self.value = self.value.transform(tw);
  6317. });
  6318. def_transform(AST_Destructuring, function(self, tw) {
  6319. self.names = MAP(self.names, tw);
  6320. });
  6321. def_transform(AST_Lambda, function(self, tw) {
  6322. if (self.name) self.name = self.name.transform(tw);
  6323. self.argnames = MAP(self.argnames, tw, /* allow_splicing */ false);
  6324. if (self.body instanceof AST_Node) {
  6325. self.body = self.body.transform(tw);
  6326. } else {
  6327. self.body = MAP(self.body, tw);
  6328. }
  6329. });
  6330. def_transform(AST_Call, function(self, tw) {
  6331. self.expression = self.expression.transform(tw);
  6332. self.args = MAP(self.args, tw, /* allow_splicing */ false);
  6333. });
  6334. def_transform(AST_Sequence, function(self, tw) {
  6335. const result = MAP(self.expressions, tw);
  6336. self.expressions = result.length
  6337. ? result
  6338. : [new AST_Number({ value: 0 })];
  6339. });
  6340. def_transform(AST_PropAccess, function(self, tw) {
  6341. self.expression = self.expression.transform(tw);
  6342. });
  6343. def_transform(AST_Sub, function(self, tw) {
  6344. self.expression = self.expression.transform(tw);
  6345. self.property = self.property.transform(tw);
  6346. });
  6347. def_transform(AST_Chain, function(self, tw) {
  6348. self.expression = self.expression.transform(tw);
  6349. });
  6350. def_transform(AST_Yield, function(self, tw) {
  6351. if (self.expression) self.expression = self.expression.transform(tw);
  6352. });
  6353. def_transform(AST_Await, function(self, tw) {
  6354. self.expression = self.expression.transform(tw);
  6355. });
  6356. def_transform(AST_Unary, function(self, tw) {
  6357. self.expression = self.expression.transform(tw);
  6358. });
  6359. def_transform(AST_Binary, function(self, tw) {
  6360. self.left = self.left.transform(tw);
  6361. self.right = self.right.transform(tw);
  6362. });
  6363. def_transform(AST_PrivateIn, function(self, tw) {
  6364. self.key = self.key.transform(tw);
  6365. self.value = self.value.transform(tw);
  6366. });
  6367. def_transform(AST_Conditional, function(self, tw) {
  6368. self.condition = self.condition.transform(tw);
  6369. self.consequent = self.consequent.transform(tw);
  6370. self.alternative = self.alternative.transform(tw);
  6371. });
  6372. def_transform(AST_Array, function(self, tw) {
  6373. self.elements = MAP(self.elements, tw);
  6374. });
  6375. def_transform(AST_Object, function(self, tw) {
  6376. self.properties = MAP(self.properties, tw);
  6377. });
  6378. def_transform(AST_ObjectProperty, function(self, tw) {
  6379. if (self.key instanceof AST_Node) {
  6380. self.key = self.key.transform(tw);
  6381. }
  6382. if (self.value) self.value = self.value.transform(tw);
  6383. });
  6384. def_transform(AST_Class, function(self, tw) {
  6385. if (self.name) self.name = self.name.transform(tw);
  6386. if (self.extends) self.extends = self.extends.transform(tw);
  6387. self.properties = MAP(self.properties, tw);
  6388. });
  6389. def_transform(AST_ClassStaticBlock, function(self, tw) {
  6390. self.body = MAP(self.body, tw);
  6391. });
  6392. def_transform(AST_Expansion, function(self, tw) {
  6393. self.expression = self.expression.transform(tw);
  6394. });
  6395. def_transform(AST_NameMapping, function(self, tw) {
  6396. self.foreign_name = self.foreign_name.transform(tw);
  6397. self.name = self.name.transform(tw);
  6398. });
  6399. def_transform(AST_Import, function(self, tw) {
  6400. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  6401. if (self.imported_names) MAP(self.imported_names, tw);
  6402. self.module_name = self.module_name.transform(tw);
  6403. });
  6404. def_transform(AST_Export, function(self, tw) {
  6405. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  6406. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  6407. if (self.exported_names) MAP(self.exported_names, tw);
  6408. if (self.module_name) self.module_name = self.module_name.transform(tw);
  6409. });
  6410. def_transform(AST_TemplateString, function(self, tw) {
  6411. self.segments = MAP(self.segments, tw);
  6412. });
  6413. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  6414. self.prefix = self.prefix.transform(tw);
  6415. self.template_string = self.template_string.transform(tw);
  6416. });
  6417. /***********************************************************************
  6418. A JavaScript tokenizer / parser / beautifier / compressor.
  6419. https://github.com/mishoo/UglifyJS2
  6420. -------------------------------- (C) ---------------------------------
  6421. Author: Mihai Bazon
  6422. <mihai.bazon@gmail.com>
  6423. http://mihai.bazon.net/blog
  6424. Distributed under the BSD license:
  6425. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6426. Redistribution and use in source and binary forms, with or without
  6427. modification, are permitted provided that the following conditions
  6428. are met:
  6429. * Redistributions of source code must retain the above
  6430. copyright notice, this list of conditions and the following
  6431. disclaimer.
  6432. * Redistributions in binary form must reproduce the above
  6433. copyright notice, this list of conditions and the following
  6434. disclaimer in the documentation and/or other materials
  6435. provided with the distribution.
  6436. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6437. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6438. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6439. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6440. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6441. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6442. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6443. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6444. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6445. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6446. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6447. SUCH DAMAGE.
  6448. ***********************************************************************/
  6449. (function() {
  6450. var normalize_directives = function(body) {
  6451. for (var i = 0; i < body.length; i++) {
  6452. if (body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  6453. body[i] = new AST_Directive({
  6454. start: body[i].start,
  6455. end: body[i].end,
  6456. quote: '"',
  6457. value: body[i].body.value
  6458. });
  6459. } else {
  6460. return body;
  6461. }
  6462. }
  6463. return body;
  6464. };
  6465. function import_attributes_from_moz(attributes) {
  6466. if (attributes && attributes.length > 0) {
  6467. return new AST_Object({
  6468. start: my_start_token(attributes),
  6469. end: my_end_token(attributes),
  6470. properties: attributes.map((attr) =>
  6471. new AST_ObjectKeyVal({
  6472. start: my_start_token(attr),
  6473. end: my_end_token(attr),
  6474. key: attr.key.name || attr.key.value,
  6475. value: from_moz(attr.value)
  6476. })
  6477. )
  6478. });
  6479. }
  6480. return null;
  6481. }
  6482. var MOZ_TO_ME = {
  6483. Program: function(M) {
  6484. return new AST_Toplevel({
  6485. start: my_start_token(M),
  6486. end: my_end_token(M),
  6487. body: normalize_directives(M.body.map(from_moz))
  6488. });
  6489. },
  6490. ArrayPattern: function(M) {
  6491. return new AST_Destructuring({
  6492. start: my_start_token(M),
  6493. end: my_end_token(M),
  6494. names: M.elements.map(function(elm) {
  6495. if (elm === null) {
  6496. return new AST_Hole();
  6497. }
  6498. return from_moz(elm);
  6499. }),
  6500. is_array: true
  6501. });
  6502. },
  6503. ObjectPattern: function(M) {
  6504. return new AST_Destructuring({
  6505. start: my_start_token(M),
  6506. end: my_end_token(M),
  6507. names: M.properties.map(from_moz),
  6508. is_array: false
  6509. });
  6510. },
  6511. AssignmentPattern: function(M) {
  6512. return new AST_DefaultAssign({
  6513. start: my_start_token(M),
  6514. end: my_end_token(M),
  6515. left: from_moz(M.left),
  6516. operator: "=",
  6517. right: from_moz(M.right)
  6518. });
  6519. },
  6520. SpreadElement: function(M) {
  6521. return new AST_Expansion({
  6522. start: my_start_token(M),
  6523. end: my_end_token(M),
  6524. expression: from_moz(M.argument)
  6525. });
  6526. },
  6527. RestElement: function(M) {
  6528. return new AST_Expansion({
  6529. start: my_start_token(M),
  6530. end: my_end_token(M),
  6531. expression: from_moz(M.argument)
  6532. });
  6533. },
  6534. TemplateElement: function(M) {
  6535. return new AST_TemplateSegment({
  6536. start: my_start_token(M),
  6537. end: my_end_token(M),
  6538. value: M.value.cooked,
  6539. raw: M.value.raw
  6540. });
  6541. },
  6542. TemplateLiteral: function(M) {
  6543. var segments = [];
  6544. for (var i = 0; i < M.quasis.length; i++) {
  6545. segments.push(from_moz(M.quasis[i]));
  6546. if (M.expressions[i]) {
  6547. segments.push(from_moz(M.expressions[i]));
  6548. }
  6549. }
  6550. return new AST_TemplateString({
  6551. start: my_start_token(M),
  6552. end: my_end_token(M),
  6553. segments: segments
  6554. });
  6555. },
  6556. TaggedTemplateExpression: function(M) {
  6557. return new AST_PrefixedTemplateString({
  6558. start: my_start_token(M),
  6559. end: my_end_token(M),
  6560. template_string: from_moz(M.quasi),
  6561. prefix: from_moz(M.tag)
  6562. });
  6563. },
  6564. FunctionDeclaration: function(M) {
  6565. return new AST_Defun({
  6566. start: my_start_token(M),
  6567. end: my_end_token(M),
  6568. name: M.id && from_moz_symbol(AST_SymbolDefun, M.id),
  6569. argnames: M.params.map(M => from_moz_pattern(M, AST_SymbolFunarg)),
  6570. is_generator: M.generator,
  6571. async: M.async,
  6572. body: normalize_directives(from_moz(M.body).body)
  6573. });
  6574. },
  6575. FunctionExpression: function(M) {
  6576. return from_moz_lambda(M, /*is_method=*/false);
  6577. },
  6578. ArrowFunctionExpression: function(M) {
  6579. const body = M.body.type === "BlockStatement"
  6580. ? from_moz(M.body).body
  6581. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  6582. return new AST_Arrow({
  6583. start: my_start_token(M),
  6584. end: my_end_token(M),
  6585. argnames: M.params.map(p => from_moz_pattern(p, AST_SymbolFunarg)),
  6586. body,
  6587. async: M.async,
  6588. });
  6589. },
  6590. ExpressionStatement: function(M) {
  6591. return new AST_SimpleStatement({
  6592. start: my_start_token(M),
  6593. end: my_end_token(M),
  6594. body: from_moz(M.expression)
  6595. });
  6596. },
  6597. TryStatement: function(M) {
  6598. var handlers = M.handlers || [M.handler];
  6599. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  6600. throw new Error("Multiple catch clauses are not supported.");
  6601. }
  6602. return new AST_Try({
  6603. start : my_start_token(M),
  6604. end : my_end_token(M),
  6605. body : new AST_TryBlock(from_moz(M.block)),
  6606. bcatch : from_moz(handlers[0]),
  6607. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  6608. });
  6609. },
  6610. Property: function(M) {
  6611. if (M.kind == "init" && !M.method) {
  6612. var args = {
  6613. start : my_start_token(M.key || M.value),
  6614. end : my_end_token(M.value),
  6615. key : M.computed
  6616. ? from_moz(M.key)
  6617. : M.key.name || String(M.key.value),
  6618. quote : from_moz_quote(M.key, M.computed),
  6619. static : false, // always an object
  6620. value : from_moz(M.value)
  6621. };
  6622. return new AST_ObjectKeyVal(args);
  6623. } else {
  6624. var value = from_moz_lambda(M.value, /*is_method=*/true);
  6625. var args = {
  6626. start : my_start_token(M.key || M.value),
  6627. end : my_end_token(M.value),
  6628. key : M.computed
  6629. ? from_moz(M.key)
  6630. : from_moz_symbol(AST_SymbolMethod, M.key),
  6631. quote : from_moz_quote(M.key, M.computed),
  6632. static : false, // always an object
  6633. value,
  6634. };
  6635. if (M.kind == "get") return new AST_ObjectGetter(args);
  6636. if (M.kind == "set") return new AST_ObjectSetter(args);
  6637. if (M.method) return new AST_ConciseMethod(args);
  6638. }
  6639. },
  6640. MethodDefinition: function(M) {
  6641. const is_private = M.key.type === "PrivateIdentifier";
  6642. const key = M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || String(M.key.value) });
  6643. var args = {
  6644. start : my_start_token(M),
  6645. end : my_end_token(M),
  6646. key,
  6647. quote : from_moz_quote(M.key, M.computed),
  6648. value : from_moz_lambda(M.value, /*is_method=*/true),
  6649. static : M.static,
  6650. };
  6651. if (M.kind == "get") {
  6652. return new (is_private ? AST_PrivateGetter : AST_ObjectGetter)(args);
  6653. }
  6654. if (M.kind == "set") {
  6655. return new (is_private ? AST_PrivateSetter : AST_ObjectSetter)(args);
  6656. }
  6657. return new (is_private ? AST_PrivateMethod : AST_ConciseMethod)(args);
  6658. },
  6659. FieldDefinition: function(M) {
  6660. let key;
  6661. if (M.computed) {
  6662. key = from_moz(M.key);
  6663. } else {
  6664. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  6665. key = from_moz(M.key);
  6666. }
  6667. return new AST_ClassProperty({
  6668. start : my_start_token(M),
  6669. end : my_end_token(M),
  6670. quote : from_moz_quote(M.key, M.computed),
  6671. key,
  6672. value : from_moz(M.value),
  6673. static : M.static,
  6674. });
  6675. },
  6676. PropertyDefinition: function(M) {
  6677. let key;
  6678. if (M.computed) {
  6679. key = from_moz(M.key);
  6680. } else if (M.key.type === "PrivateIdentifier") {
  6681. return new AST_ClassPrivateProperty({
  6682. start : my_start_token(M),
  6683. end : my_end_token(M),
  6684. key : from_moz(M.key),
  6685. value : from_moz(M.value),
  6686. static : M.static,
  6687. });
  6688. } else {
  6689. key = from_moz_symbol(AST_SymbolClassProperty, M.key);
  6690. }
  6691. return new AST_ClassProperty({
  6692. start : my_start_token(M),
  6693. end : my_end_token(M),
  6694. quote : from_moz_quote(M.key, M.computed),
  6695. key,
  6696. value : from_moz(M.value),
  6697. static : M.static,
  6698. });
  6699. },
  6700. PrivateIdentifier: function (M) {
  6701. return new AST_SymbolPrivateProperty({
  6702. start: my_start_token(M),
  6703. end: my_end_token(M),
  6704. name: M.name
  6705. });
  6706. },
  6707. StaticBlock: function(M) {
  6708. return new AST_ClassStaticBlock({
  6709. start : my_start_token(M),
  6710. end : my_end_token(M),
  6711. body : M.body.map(from_moz),
  6712. });
  6713. },
  6714. ArrayExpression: function(M) {
  6715. return new AST_Array({
  6716. start : my_start_token(M),
  6717. end : my_end_token(M),
  6718. elements : M.elements.map(function(elem) {
  6719. return elem === null ? new AST_Hole() : from_moz(elem);
  6720. })
  6721. });
  6722. },
  6723. ObjectExpression: function(M) {
  6724. return new AST_Object({
  6725. start : my_start_token(M),
  6726. end : my_end_token(M),
  6727. properties : M.properties.map(function(prop) {
  6728. if (prop.type === "SpreadElement") {
  6729. return from_moz(prop);
  6730. }
  6731. prop.type = "Property";
  6732. return from_moz(prop);
  6733. })
  6734. });
  6735. },
  6736. SequenceExpression: function(M) {
  6737. return new AST_Sequence({
  6738. start : my_start_token(M),
  6739. end : my_end_token(M),
  6740. expressions: M.expressions.map(from_moz)
  6741. });
  6742. },
  6743. MemberExpression: function(M) {
  6744. if (M.property.type === "PrivateIdentifier") {
  6745. return new AST_DotHash({
  6746. start : my_start_token(M),
  6747. end : my_end_token(M),
  6748. property : M.property.name,
  6749. expression : from_moz(M.object),
  6750. optional : M.optional || false
  6751. });
  6752. }
  6753. return new (M.computed ? AST_Sub : AST_Dot)({
  6754. start : my_start_token(M),
  6755. end : my_end_token(M),
  6756. property : M.computed ? from_moz(M.property) : M.property.name,
  6757. expression : from_moz(M.object),
  6758. optional : M.optional || false
  6759. });
  6760. },
  6761. ChainExpression: function(M) {
  6762. return new AST_Chain({
  6763. start : my_start_token(M),
  6764. end : my_end_token(M),
  6765. expression : from_moz(M.expression)
  6766. });
  6767. },
  6768. SwitchCase: function(M) {
  6769. return new (M.test ? AST_Case : AST_Default)({
  6770. start : my_start_token(M),
  6771. end : my_end_token(M),
  6772. expression : from_moz(M.test),
  6773. body : M.consequent.map(from_moz)
  6774. });
  6775. },
  6776. VariableDeclaration: function(M) {
  6777. let decl_type;
  6778. let sym_type;
  6779. if (M.kind === "const") {
  6780. decl_type = AST_Const;
  6781. sym_type = AST_SymbolConst;
  6782. } else if (M.kind === "let") {
  6783. decl_type = AST_Let;
  6784. sym_type = AST_SymbolLet;
  6785. } else {
  6786. decl_type = AST_Var;
  6787. sym_type = AST_SymbolVar;
  6788. }
  6789. const definitions = M.declarations.map(M => {
  6790. return new AST_VarDef({
  6791. start: my_start_token(M),
  6792. end: my_end_token(M),
  6793. name: from_moz_pattern(M.id, sym_type),
  6794. value: from_moz(M.init),
  6795. });
  6796. });
  6797. return new decl_type({
  6798. start : my_start_token(M),
  6799. end : my_end_token(M),
  6800. definitions : definitions,
  6801. });
  6802. },
  6803. ImportDeclaration: function(M) {
  6804. var imported_name = null;
  6805. var imported_names = null;
  6806. M.specifiers.forEach(function (specifier) {
  6807. if (specifier.type === "ImportSpecifier" || specifier.type === "ImportNamespaceSpecifier") {
  6808. if (!imported_names) { imported_names = []; }
  6809. imported_names.push(from_moz(specifier));
  6810. } else if (specifier.type === "ImportDefaultSpecifier") {
  6811. imported_name = from_moz(specifier);
  6812. }
  6813. });
  6814. return new AST_Import({
  6815. start : my_start_token(M),
  6816. end : my_end_token(M),
  6817. imported_name: imported_name,
  6818. imported_names : imported_names,
  6819. module_name : from_moz(M.source),
  6820. attributes: import_attributes_from_moz(M.attributes || M.assertions)
  6821. });
  6822. },
  6823. ImportSpecifier: function(M) {
  6824. return new AST_NameMapping({
  6825. start: my_start_token(M),
  6826. end: my_end_token(M),
  6827. foreign_name: from_moz_symbol(AST_SymbolImportForeign, M.imported, M.imported.type === "Literal"),
  6828. name: from_moz_symbol(AST_SymbolImport, M.local)
  6829. });
  6830. },
  6831. ImportDefaultSpecifier: function(M) {
  6832. return from_moz_symbol(AST_SymbolImport, M.local);
  6833. },
  6834. ImportNamespaceSpecifier: function(M) {
  6835. return new AST_NameMapping({
  6836. start: my_start_token(M),
  6837. end: my_end_token(M),
  6838. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  6839. name: from_moz_symbol(AST_SymbolImport, M.local)
  6840. });
  6841. },
  6842. ImportExpression: function(M) {
  6843. const args = [from_moz(M.source)];
  6844. if (M.options) {
  6845. args.push(from_moz(M.options));
  6846. }
  6847. return new AST_Call({
  6848. start: my_start_token(M),
  6849. end: my_end_token(M),
  6850. expression: from_moz({
  6851. type: "Identifier",
  6852. name: "import"
  6853. }),
  6854. optional: false,
  6855. args
  6856. });
  6857. },
  6858. ExportAllDeclaration: function(M) {
  6859. var foreign_name = M.exported == null ?
  6860. new AST_SymbolExportForeign({ name: "*" }) :
  6861. from_moz_symbol(AST_SymbolExportForeign, M.exported, M.exported.type === "Literal");
  6862. return new AST_Export({
  6863. start: my_start_token(M),
  6864. end: my_end_token(M),
  6865. exported_names: [
  6866. new AST_NameMapping({
  6867. start: my_start_token(M),
  6868. end: my_end_token(M),
  6869. name: new AST_SymbolExport({ name: "*" }),
  6870. foreign_name: foreign_name
  6871. })
  6872. ],
  6873. module_name: from_moz(M.source),
  6874. attributes: import_attributes_from_moz(M.attributes || M.assertions)
  6875. });
  6876. },
  6877. ExportNamedDeclaration: function(M) {
  6878. if (M.declaration) {
  6879. // export const, export function, ...
  6880. return new AST_Export({
  6881. start: my_start_token(M),
  6882. end: my_end_token(M),
  6883. exported_definition: from_moz(M.declaration),
  6884. exported_names: null,
  6885. module_name: null,
  6886. attributes: null,
  6887. });
  6888. } else {
  6889. return new AST_Export({
  6890. start: my_start_token(M),
  6891. end: my_end_token(M),
  6892. exported_definition: null,
  6893. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : [],
  6894. module_name: from_moz(M.source),
  6895. attributes: import_attributes_from_moz(M.attributes || M.assertions),
  6896. });
  6897. }
  6898. },
  6899. ExportDefaultDeclaration: function(M) {
  6900. return new AST_Export({
  6901. start: my_start_token(M),
  6902. end: my_end_token(M),
  6903. exported_value: from_moz(M.declaration),
  6904. is_default: true
  6905. });
  6906. },
  6907. ExportSpecifier: function(M) {
  6908. return new AST_NameMapping({
  6909. start: my_start_token(M),
  6910. end: my_end_token(M),
  6911. foreign_name: from_moz_symbol(AST_SymbolExportForeign, M.exported, M.exported.type === "Literal"),
  6912. name: from_moz_symbol(AST_SymbolExport, M.local, M.local.type === "Literal"),
  6913. });
  6914. },
  6915. Literal: function(M) {
  6916. var val = M.value, args = {
  6917. start : my_start_token(M),
  6918. end : my_end_token(M)
  6919. };
  6920. var rx = M.regex;
  6921. if (rx && rx.pattern) {
  6922. // RegExpLiteral as per ESTree AST spec
  6923. args.value = {
  6924. source: rx.pattern,
  6925. flags: rx.flags
  6926. };
  6927. return new AST_RegExp(args);
  6928. } else if (rx) {
  6929. // support legacy RegExp
  6930. const rx_source = M.raw || val;
  6931. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  6932. if (!match) throw new Error("Invalid regex source " + rx_source);
  6933. const [_, source, flags] = match;
  6934. args.value = { source, flags };
  6935. return new AST_RegExp(args);
  6936. }
  6937. const bi = typeof M.value === "bigint" ? M.value.toString() : M.bigint;
  6938. if (typeof bi === "string") {
  6939. args.value = bi;
  6940. args.raw = M.raw;
  6941. return new AST_BigInt(args);
  6942. }
  6943. if (val === null) return new AST_Null(args);
  6944. switch (typeof val) {
  6945. case "string":
  6946. args.quote = "\"";
  6947. args.value = val;
  6948. return new AST_String(args);
  6949. case "number":
  6950. args.value = val;
  6951. args.raw = M.raw || val.toString();
  6952. return new AST_Number(args);
  6953. case "boolean":
  6954. return new (val ? AST_True : AST_False)(args);
  6955. }
  6956. },
  6957. MetaProperty: function(M) {
  6958. if (M.meta.name === "new" && M.property.name === "target") {
  6959. return new AST_NewTarget({
  6960. start: my_start_token(M),
  6961. end: my_end_token(M)
  6962. });
  6963. } else if (M.meta.name === "import" && M.property.name === "meta") {
  6964. return new AST_ImportMeta({
  6965. start: my_start_token(M),
  6966. end: my_end_token(M)
  6967. });
  6968. }
  6969. },
  6970. Identifier: function(M) {
  6971. return new AST_SymbolRef({
  6972. start : my_start_token(M),
  6973. end : my_end_token(M),
  6974. name : M.name
  6975. });
  6976. },
  6977. EmptyStatement: function(M) {
  6978. return new AST_EmptyStatement({
  6979. start: my_start_token(M),
  6980. end: my_end_token(M)
  6981. });
  6982. },
  6983. BlockStatement: function(M) {
  6984. return new AST_BlockStatement({
  6985. start: my_start_token(M),
  6986. end: my_end_token(M),
  6987. body: M.body.map(from_moz)
  6988. });
  6989. },
  6990. IfStatement: function(M) {
  6991. return new AST_If({
  6992. start: my_start_token(M),
  6993. end: my_end_token(M),
  6994. condition: from_moz(M.test),
  6995. body: from_moz(M.consequent),
  6996. alternative: from_moz(M.alternate)
  6997. });
  6998. },
  6999. LabeledStatement: function(M) {
  7000. try {
  7001. const label = from_moz_symbol(AST_Label, M.label);
  7002. FROM_MOZ_LABELS.push(label);
  7003. const stat = new AST_LabeledStatement({
  7004. start: my_start_token(M),
  7005. end: my_end_token(M),
  7006. label,
  7007. body: from_moz(M.body)
  7008. });
  7009. return stat;
  7010. } finally {
  7011. FROM_MOZ_LABELS.pop();
  7012. }
  7013. },
  7014. BreakStatement: function(M) {
  7015. return new AST_Break({
  7016. start: my_start_token(M),
  7017. end: my_end_token(M),
  7018. label: from_moz_label_ref(M.label),
  7019. });
  7020. },
  7021. ContinueStatement: function(M) {
  7022. return new AST_Continue({
  7023. start: my_start_token(M),
  7024. end: my_end_token(M),
  7025. label: from_moz_label_ref(M.label),
  7026. });
  7027. },
  7028. WithStatement: function(M) {
  7029. return new AST_With({
  7030. start: my_start_token(M),
  7031. end: my_end_token(M),
  7032. expression: from_moz(M.object),
  7033. body: from_moz(M.body)
  7034. });
  7035. },
  7036. SwitchStatement: function(M) {
  7037. return new AST_Switch({
  7038. start: my_start_token(M),
  7039. end: my_end_token(M),
  7040. expression: from_moz(M.discriminant),
  7041. body: M.cases.map(from_moz)
  7042. });
  7043. },
  7044. ReturnStatement: function(M) {
  7045. return new AST_Return({
  7046. start: my_start_token(M),
  7047. end: my_end_token(M),
  7048. value: from_moz(M.argument)
  7049. });
  7050. },
  7051. ThrowStatement: function(M) {
  7052. return new AST_Throw({
  7053. start: my_start_token(M),
  7054. end: my_end_token(M),
  7055. value: from_moz(M.argument)
  7056. });
  7057. },
  7058. WhileStatement: function(M) {
  7059. return new AST_While({
  7060. start: my_start_token(M),
  7061. end: my_end_token(M),
  7062. condition: from_moz(M.test),
  7063. body: from_moz(M.body)
  7064. });
  7065. },
  7066. DoWhileStatement: function(M) {
  7067. return new AST_Do({
  7068. start: my_start_token(M),
  7069. end: my_end_token(M),
  7070. condition: from_moz(M.test),
  7071. body: from_moz(M.body)
  7072. });
  7073. },
  7074. ForStatement: function(M) {
  7075. return new AST_For({
  7076. start: my_start_token(M),
  7077. end: my_end_token(M),
  7078. init: from_moz(M.init),
  7079. condition: from_moz(M.test),
  7080. step: from_moz(M.update),
  7081. body: from_moz(M.body)
  7082. });
  7083. },
  7084. ForInStatement: function(M) {
  7085. return new AST_ForIn({
  7086. start: my_start_token(M),
  7087. end: my_end_token(M),
  7088. init: from_moz(M.left),
  7089. object: from_moz(M.right),
  7090. body: from_moz(M.body)
  7091. });
  7092. },
  7093. ForOfStatement: function(M) {
  7094. return new AST_ForOf({
  7095. start: my_start_token(M),
  7096. end: my_end_token(M),
  7097. init: from_moz(M.left),
  7098. object: from_moz(M.right),
  7099. body: from_moz(M.body),
  7100. await: M.await
  7101. });
  7102. },
  7103. AwaitExpression: function(M) {
  7104. return new AST_Await({
  7105. start: my_start_token(M),
  7106. end: my_end_token(M),
  7107. expression: from_moz(M.argument)
  7108. });
  7109. },
  7110. YieldExpression: function(M) {
  7111. return new AST_Yield({
  7112. start: my_start_token(M),
  7113. end: my_end_token(M),
  7114. expression: from_moz(M.argument),
  7115. is_star: M.delegate
  7116. });
  7117. },
  7118. DebuggerStatement: function(M) {
  7119. return new AST_Debugger({
  7120. start: my_start_token(M),
  7121. end: my_end_token(M)
  7122. });
  7123. },
  7124. CatchClause: function(M) {
  7125. return new AST_Catch({
  7126. start: my_start_token(M),
  7127. end: my_end_token(M),
  7128. argname: M.param ? from_moz_pattern(M.param, AST_SymbolCatch) : null,
  7129. body: from_moz(M.body).body
  7130. });
  7131. },
  7132. ThisExpression: function(M) {
  7133. return new AST_This({
  7134. start: my_start_token(M),
  7135. name: "this",
  7136. end: my_end_token(M)
  7137. });
  7138. },
  7139. Super: function(M) {
  7140. return new AST_Super({
  7141. start: my_start_token(M),
  7142. end: my_end_token(M),
  7143. name: "super",
  7144. });
  7145. },
  7146. BinaryExpression: function(M) {
  7147. if (M.left.type === "PrivateIdentifier") {
  7148. return new AST_PrivateIn({
  7149. start: my_start_token(M),
  7150. end: my_end_token(M),
  7151. key: new AST_SymbolPrivateProperty({
  7152. start: my_start_token(M.left),
  7153. end: my_end_token(M.left),
  7154. name: M.left.name
  7155. }),
  7156. value: from_moz(M.right),
  7157. });
  7158. }
  7159. return new AST_Binary({
  7160. start: my_start_token(M),
  7161. end: my_end_token(M),
  7162. operator: M.operator,
  7163. left: from_moz(M.left),
  7164. right: from_moz(M.right)
  7165. });
  7166. },
  7167. LogicalExpression: function(M) {
  7168. return new AST_Binary({
  7169. start: my_start_token(M),
  7170. end: my_end_token(M),
  7171. operator: M.operator,
  7172. left: from_moz(M.left),
  7173. right: from_moz(M.right)
  7174. });
  7175. },
  7176. AssignmentExpression: function(M) {
  7177. return new AST_Assign({
  7178. start: my_start_token(M),
  7179. end: my_end_token(M),
  7180. operator: M.operator,
  7181. logical: M.operator === "??=" || M.operator === "&&=" || M.operator === "||=",
  7182. left: from_moz(M.left),
  7183. right: from_moz(M.right)
  7184. });
  7185. },
  7186. ConditionalExpression: function(M) {
  7187. return new AST_Conditional({
  7188. start: my_start_token(M),
  7189. end: my_end_token(M),
  7190. condition: from_moz(M.test),
  7191. consequent: from_moz(M.consequent),
  7192. alternative: from_moz(M.alternate)
  7193. });
  7194. },
  7195. NewExpression: function(M) {
  7196. return new AST_New({
  7197. start: my_start_token(M),
  7198. end: my_end_token(M),
  7199. expression: from_moz(M.callee),
  7200. args: M.arguments.map(from_moz)
  7201. });
  7202. },
  7203. CallExpression: function(M) {
  7204. return new AST_Call({
  7205. start: my_start_token(M),
  7206. end: my_end_token(M),
  7207. expression: from_moz(M.callee),
  7208. optional: M.optional,
  7209. args: M.arguments.map(from_moz)
  7210. });
  7211. }
  7212. };
  7213. MOZ_TO_ME.UpdateExpression =
  7214. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  7215. var prefix = "prefix" in M ? M.prefix
  7216. : M.type == "UnaryExpression" ? true : false;
  7217. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  7218. start : my_start_token(M),
  7219. end : my_end_token(M),
  7220. operator : M.operator,
  7221. expression : from_moz(M.argument)
  7222. });
  7223. };
  7224. MOZ_TO_ME.ClassDeclaration =
  7225. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  7226. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  7227. start : my_start_token(M),
  7228. end : my_end_token(M),
  7229. name : M.id && from_moz_symbol(M.type === "ClassDeclaration" ? AST_SymbolDefClass : AST_SymbolClass, M.id),
  7230. extends : from_moz(M.superClass),
  7231. properties: M.body.body.map(from_moz)
  7232. });
  7233. };
  7234. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  7235. return {
  7236. type: "EmptyStatement"
  7237. };
  7238. });
  7239. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  7240. return {
  7241. type: "BlockStatement",
  7242. body: M.body.map(to_moz)
  7243. };
  7244. });
  7245. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  7246. return {
  7247. type: "IfStatement",
  7248. test: to_moz(M.condition),
  7249. consequent: to_moz(M.body),
  7250. alternate: to_moz(M.alternative)
  7251. };
  7252. });
  7253. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  7254. return {
  7255. type: "LabeledStatement",
  7256. label: to_moz(M.label),
  7257. body: to_moz(M.body)
  7258. };
  7259. });
  7260. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  7261. return {
  7262. type: "BreakStatement",
  7263. label: to_moz(M.label)
  7264. };
  7265. });
  7266. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  7267. return {
  7268. type: "ContinueStatement",
  7269. label: to_moz(M.label)
  7270. };
  7271. });
  7272. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  7273. return {
  7274. type: "WithStatement",
  7275. object: to_moz(M.expression),
  7276. body: to_moz(M.body)
  7277. };
  7278. });
  7279. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  7280. return {
  7281. type: "SwitchStatement",
  7282. discriminant: to_moz(M.expression),
  7283. cases: M.body.map(to_moz)
  7284. };
  7285. });
  7286. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  7287. return {
  7288. type: "ReturnStatement",
  7289. argument: to_moz(M.value)
  7290. };
  7291. });
  7292. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  7293. return {
  7294. type: "ThrowStatement",
  7295. argument: to_moz(M.value)
  7296. };
  7297. });
  7298. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  7299. return {
  7300. type: "WhileStatement",
  7301. test: to_moz(M.condition),
  7302. body: to_moz(M.body)
  7303. };
  7304. });
  7305. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  7306. return {
  7307. type: "DoWhileStatement",
  7308. test: to_moz(M.condition),
  7309. body: to_moz(M.body)
  7310. };
  7311. });
  7312. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  7313. return {
  7314. type: "ForStatement",
  7315. init: to_moz(M.init),
  7316. test: to_moz(M.condition),
  7317. update: to_moz(M.step),
  7318. body: to_moz(M.body)
  7319. };
  7320. });
  7321. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  7322. return {
  7323. type: "ForInStatement",
  7324. left: to_moz(M.init),
  7325. right: to_moz(M.object),
  7326. body: to_moz(M.body)
  7327. };
  7328. });
  7329. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  7330. return {
  7331. type: "ForOfStatement",
  7332. left: to_moz(M.init),
  7333. right: to_moz(M.object),
  7334. body: to_moz(M.body),
  7335. await: M.await
  7336. };
  7337. });
  7338. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  7339. return {
  7340. type: "AwaitExpression",
  7341. argument: to_moz(M.expression)
  7342. };
  7343. });
  7344. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  7345. return {
  7346. type: "YieldExpression",
  7347. argument: to_moz(M.expression),
  7348. delegate: M.is_star
  7349. };
  7350. });
  7351. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  7352. return {
  7353. type: "DebuggerStatement"
  7354. };
  7355. });
  7356. def_to_moz(AST_VarDef, function To_Moz_VariableDeclarator(M) {
  7357. return {
  7358. type: "VariableDeclarator",
  7359. id: to_moz(M.name),
  7360. init: to_moz(M.value)
  7361. };
  7362. });
  7363. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  7364. return {
  7365. type: "ThisExpression"
  7366. };
  7367. });
  7368. def_to_moz(AST_Super, function To_Moz_Super() {
  7369. return {
  7370. type: "Super"
  7371. };
  7372. });
  7373. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  7374. return {
  7375. type: "ConditionalExpression",
  7376. test: to_moz(M.condition),
  7377. consequent: to_moz(M.consequent),
  7378. alternate: to_moz(M.alternative)
  7379. };
  7380. });
  7381. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  7382. return {
  7383. type: "NewExpression",
  7384. callee: to_moz(M.expression),
  7385. arguments: M.args.map(to_moz)
  7386. };
  7387. });
  7388. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  7389. if (M.expression instanceof AST_SymbolRef && M.expression.name === "import") {
  7390. const [source, options] = M.args.map(to_moz);
  7391. return {
  7392. type: "ImportExpression",
  7393. source,
  7394. options: options || null
  7395. };
  7396. }
  7397. return {
  7398. type: "CallExpression",
  7399. callee: to_moz(M.expression),
  7400. optional: M.optional,
  7401. arguments: M.args.map(to_moz)
  7402. };
  7403. });
  7404. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  7405. return to_moz_scope("Program", M);
  7406. });
  7407. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  7408. return {
  7409. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  7410. argument: to_moz(M.expression)
  7411. };
  7412. });
  7413. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  7414. return {
  7415. type: "TaggedTemplateExpression",
  7416. tag: to_moz(M.prefix),
  7417. quasi: to_moz(M.template_string)
  7418. };
  7419. });
  7420. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  7421. var quasis = [];
  7422. var expressions = [];
  7423. for (var i = 0; i < M.segments.length; i++) {
  7424. if (i % 2 !== 0) {
  7425. expressions.push(to_moz(M.segments[i]));
  7426. } else {
  7427. quasis.push({
  7428. type: "TemplateElement",
  7429. value: {
  7430. raw: M.segments[i].raw,
  7431. cooked: M.segments[i].value
  7432. },
  7433. tail: i === M.segments.length - 1
  7434. });
  7435. }
  7436. }
  7437. return {
  7438. type: "TemplateLiteral",
  7439. quasis: quasis,
  7440. expressions: expressions
  7441. };
  7442. });
  7443. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  7444. return {
  7445. type: "FunctionDeclaration",
  7446. id: to_moz(M.name),
  7447. params: M.argnames.map(to_moz_pattern),
  7448. generator: M.is_generator,
  7449. async: M.async,
  7450. body: to_moz_scope("BlockStatement", M)
  7451. };
  7452. });
  7453. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M) {
  7454. return {
  7455. type: "FunctionExpression",
  7456. id: to_moz(M.name),
  7457. params: M.argnames.map(to_moz_pattern),
  7458. generator: M.is_generator || false,
  7459. async: M.async || false,
  7460. body: to_moz_scope("BlockStatement", M)
  7461. };
  7462. });
  7463. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  7464. var body = M.body.length === 1 && M.body[0] instanceof AST_Return && M.body[0].value
  7465. ? to_moz(M.body[0].value)
  7466. : {
  7467. type: "BlockStatement",
  7468. body: M.body.map(to_moz)
  7469. };
  7470. return {
  7471. type: "ArrowFunctionExpression",
  7472. params: M.argnames.map(to_moz_pattern),
  7473. async: M.async,
  7474. body: body,
  7475. };
  7476. });
  7477. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  7478. if (M.is_array) {
  7479. return {
  7480. type: "ArrayPattern",
  7481. elements: M.names.map(
  7482. M => M instanceof AST_Hole ? null : to_moz_pattern(M)
  7483. ),
  7484. };
  7485. }
  7486. return {
  7487. type: "ObjectPattern",
  7488. properties: M.names.map(M => {
  7489. if (M instanceof AST_ObjectKeyVal) {
  7490. var computed = M.computed_key();
  7491. const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  7492. return {
  7493. type: "Property",
  7494. computed,
  7495. kind: "init",
  7496. key: key,
  7497. method: false,
  7498. shorthand,
  7499. value: to_moz_pattern(M.value)
  7500. };
  7501. } else {
  7502. return to_moz_pattern(M);
  7503. }
  7504. }),
  7505. };
  7506. });
  7507. def_to_moz(AST_DefaultAssign, function To_Moz_AssignmentExpression(M) {
  7508. return {
  7509. type: "AssignmentPattern",
  7510. left: to_moz_pattern(M.left),
  7511. right: to_moz(M.right),
  7512. };
  7513. });
  7514. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  7515. return {
  7516. type: "ExpressionStatement",
  7517. expression: {
  7518. type: "Literal",
  7519. value: M.value,
  7520. raw: M.print_to_string()
  7521. },
  7522. directive: M.value
  7523. };
  7524. });
  7525. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  7526. return {
  7527. type: "ExpressionStatement",
  7528. expression: to_moz(M.body)
  7529. };
  7530. });
  7531. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  7532. return {
  7533. type: "SwitchCase",
  7534. test: to_moz(M.expression),
  7535. consequent: M.body.map(to_moz)
  7536. };
  7537. });
  7538. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  7539. return {
  7540. type: "TryStatement",
  7541. block: to_moz_block(M.body),
  7542. handler: to_moz(M.bcatch),
  7543. guardedHandlers: [],
  7544. finalizer: to_moz(M.bfinally)
  7545. };
  7546. });
  7547. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7548. return {
  7549. type: "CatchClause",
  7550. param: M.argname != null ? to_moz_pattern(M.argname) : null,
  7551. body: to_moz_block(M)
  7552. };
  7553. });
  7554. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  7555. return {
  7556. type: "VariableDeclaration",
  7557. kind:
  7558. M instanceof AST_Const ? "const" :
  7559. M instanceof AST_Let ? "let" : "var",
  7560. declarations: M.definitions.map(to_moz)
  7561. };
  7562. });
  7563. function import_attributes_to_moz(attribute) {
  7564. const import_attributes = [];
  7565. if (attribute) {
  7566. for (const { key, value } of attribute.properties) {
  7567. const key_moz = is_basic_identifier_string(key)
  7568. ? { type: "Identifier", name: key }
  7569. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  7570. import_attributes.push({
  7571. type: "ImportAttribute",
  7572. key: key_moz,
  7573. value: to_moz(value)
  7574. });
  7575. }
  7576. }
  7577. return import_attributes;
  7578. }
  7579. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  7580. if (M.exported_names) {
  7581. var first_exported = M.exported_names[0];
  7582. if (first_exported && first_exported.name.name === "*" && !first_exported.name.quote) {
  7583. var foreign_name = first_exported.foreign_name;
  7584. var exported = foreign_name.name === "*" && !foreign_name.quote
  7585. ? null
  7586. : to_moz(foreign_name);
  7587. return {
  7588. type: "ExportAllDeclaration",
  7589. source: to_moz(M.module_name),
  7590. exported: exported,
  7591. attributes: import_attributes_to_moz(M.attributes)
  7592. };
  7593. }
  7594. return {
  7595. type: "ExportNamedDeclaration",
  7596. specifiers: M.exported_names.map(function (name_mapping) {
  7597. return {
  7598. type: "ExportSpecifier",
  7599. exported: to_moz(name_mapping.foreign_name),
  7600. local: to_moz(name_mapping.name)
  7601. };
  7602. }),
  7603. declaration: to_moz(M.exported_definition),
  7604. source: to_moz(M.module_name),
  7605. attributes: import_attributes_to_moz(M.attributes)
  7606. };
  7607. }
  7608. if (M.is_default) {
  7609. return {
  7610. type: "ExportDefaultDeclaration",
  7611. declaration: to_moz(M.exported_value || M.exported_definition),
  7612. };
  7613. } else {
  7614. return {
  7615. type: "ExportNamedDeclaration",
  7616. declaration: to_moz(M.exported_value || M.exported_definition),
  7617. specifiers: [],
  7618. source: null,
  7619. };
  7620. }
  7621. });
  7622. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  7623. var specifiers = [];
  7624. if (M.imported_name) {
  7625. specifiers.push({
  7626. type: "ImportDefaultSpecifier",
  7627. local: to_moz(M.imported_name)
  7628. });
  7629. }
  7630. if (M.imported_names) {
  7631. var first_imported_foreign_name = M.imported_names[0].foreign_name;
  7632. if (first_imported_foreign_name.name === "*" && !first_imported_foreign_name.quote) {
  7633. specifiers.push({
  7634. type: "ImportNamespaceSpecifier",
  7635. local: to_moz(M.imported_names[0].name)
  7636. });
  7637. } else {
  7638. M.imported_names.forEach(function(name_mapping) {
  7639. specifiers.push({
  7640. type: "ImportSpecifier",
  7641. local: to_moz(name_mapping.name),
  7642. imported: to_moz(name_mapping.foreign_name)
  7643. });
  7644. });
  7645. }
  7646. }
  7647. return {
  7648. type: "ImportDeclaration",
  7649. specifiers: specifiers,
  7650. source: to_moz(M.module_name),
  7651. attributes: import_attributes_to_moz(M.attributes)
  7652. };
  7653. });
  7654. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  7655. return {
  7656. type: "MetaProperty",
  7657. meta: {
  7658. type: "Identifier",
  7659. name: "import"
  7660. },
  7661. property: {
  7662. type: "Identifier",
  7663. name: "meta"
  7664. }
  7665. };
  7666. });
  7667. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  7668. return {
  7669. type: "SequenceExpression",
  7670. expressions: M.expressions.map(to_moz)
  7671. };
  7672. });
  7673. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  7674. return {
  7675. type: "MemberExpression",
  7676. object: to_moz(M.expression),
  7677. computed: false,
  7678. property: {
  7679. type: "PrivateIdentifier",
  7680. name: M.property
  7681. },
  7682. optional: M.optional
  7683. };
  7684. });
  7685. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  7686. var isComputed = M instanceof AST_Sub;
  7687. return {
  7688. type: "MemberExpression",
  7689. object: to_moz(M.expression),
  7690. computed: isComputed,
  7691. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  7692. optional: M.optional
  7693. };
  7694. });
  7695. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  7696. return {
  7697. type: "ChainExpression",
  7698. expression: to_moz(M.expression)
  7699. };
  7700. });
  7701. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  7702. return {
  7703. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  7704. operator: M.operator,
  7705. prefix: M instanceof AST_UnaryPrefix,
  7706. argument: to_moz(M.expression)
  7707. };
  7708. });
  7709. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7710. if (M.operator == "=" && to_moz_in_destructuring()) {
  7711. return {
  7712. type: "AssignmentPattern",
  7713. left: to_moz(M.left),
  7714. right: to_moz(M.right)
  7715. };
  7716. }
  7717. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  7718. ? "LogicalExpression"
  7719. : "BinaryExpression";
  7720. return {
  7721. type,
  7722. left: to_moz(M.left),
  7723. operator: M.operator,
  7724. right: to_moz(M.right)
  7725. };
  7726. });
  7727. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  7728. return {
  7729. type: "AssignmentExpression",
  7730. operator: M.operator,
  7731. left: to_moz(M.left),
  7732. right: to_moz(M.right)
  7733. };
  7734. });
  7735. def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
  7736. return {
  7737. type: "BinaryExpression",
  7738. left: { type: "PrivateIdentifier", name: M.key.name },
  7739. operator: "in",
  7740. right: to_moz(M.value),
  7741. };
  7742. });
  7743. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  7744. return {
  7745. type: "ArrayExpression",
  7746. elements: M.elements.map(to_moz)
  7747. };
  7748. });
  7749. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  7750. return {
  7751. type: "ObjectExpression",
  7752. properties: M.properties.map(to_moz)
  7753. };
  7754. });
  7755. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  7756. var computed = M.computed_key();
  7757. const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  7758. var kind;
  7759. if (M instanceof AST_ObjectGetter) {
  7760. kind = "get";
  7761. } else
  7762. if (M instanceof AST_ObjectSetter) {
  7763. kind = "set";
  7764. }
  7765. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  7766. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  7767. return {
  7768. type: "MethodDefinition",
  7769. computed: false,
  7770. kind: kind,
  7771. static: M.static,
  7772. key: {
  7773. type: "PrivateIdentifier",
  7774. name: M.key.name
  7775. },
  7776. value: to_moz(M.value)
  7777. };
  7778. }
  7779. if (M instanceof AST_ClassPrivateProperty) {
  7780. return {
  7781. type: "PropertyDefinition",
  7782. key: {
  7783. type: "PrivateIdentifier",
  7784. name: M.key.name
  7785. },
  7786. value: to_moz(M.value),
  7787. computed: false,
  7788. static: M.static
  7789. };
  7790. }
  7791. if (M instanceof AST_ClassProperty) {
  7792. return {
  7793. type: "PropertyDefinition",
  7794. key,
  7795. value: to_moz(M.value),
  7796. computed,
  7797. static: M.static
  7798. };
  7799. }
  7800. if (parent instanceof AST_Class) {
  7801. return {
  7802. type: "MethodDefinition",
  7803. computed: computed,
  7804. kind: kind,
  7805. static: M.static,
  7806. key: to_moz(M.key),
  7807. value: to_moz(M.value)
  7808. };
  7809. }
  7810. return {
  7811. type: "Property",
  7812. computed: computed,
  7813. method: false,
  7814. shorthand,
  7815. kind: kind,
  7816. key: key,
  7817. value: to_moz(M.value)
  7818. };
  7819. });
  7820. def_to_moz(AST_ObjectKeyVal, function To_Moz_Property(M) {
  7821. var computed = M.computed_key();
  7822. const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  7823. return {
  7824. type: "Property",
  7825. computed: computed,
  7826. shorthand: shorthand,
  7827. method: false,
  7828. kind: "init",
  7829. key: key,
  7830. value: to_moz(M.value)
  7831. };
  7832. });
  7833. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  7834. const computed = M.computed_key();
  7835. const [_always_false, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
  7836. if (parent instanceof AST_Object) {
  7837. return {
  7838. type: "Property",
  7839. kind: "init",
  7840. computed,
  7841. method: true,
  7842. shorthand: false,
  7843. key,
  7844. value: to_moz(M.value),
  7845. };
  7846. }
  7847. return {
  7848. type: "MethodDefinition",
  7849. kind: !computed && M.key.name === "constructor" ? "constructor" : "method",
  7850. computed,
  7851. key,
  7852. value: to_moz(M.value),
  7853. static: M.static,
  7854. };
  7855. });
  7856. def_to_moz(AST_PrivateMethod, function To_Moz_MethodDefinition(M) {
  7857. return {
  7858. type: "MethodDefinition",
  7859. kind: "method",
  7860. key: { type: "PrivateIdentifier", name: M.key.name },
  7861. value: to_moz(M.value),
  7862. computed: false,
  7863. static: M.static,
  7864. };
  7865. });
  7866. def_to_moz(AST_Class, function To_Moz_Class(M) {
  7867. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  7868. return {
  7869. type: type,
  7870. superClass: to_moz(M.extends),
  7871. id: M.name ? to_moz(M.name) : null,
  7872. body: {
  7873. type: "ClassBody",
  7874. body: M.properties.map(to_moz)
  7875. }
  7876. };
  7877. });
  7878. def_to_moz(AST_ClassStaticBlock, function To_Moz_StaticBlock(M) {
  7879. return {
  7880. type: "StaticBlock",
  7881. body: M.body.map(to_moz),
  7882. };
  7883. });
  7884. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  7885. return {
  7886. type: "MetaProperty",
  7887. meta: {
  7888. type: "Identifier",
  7889. name: "new"
  7890. },
  7891. property: {
  7892. type: "Identifier",
  7893. name: "target"
  7894. }
  7895. };
  7896. });
  7897. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  7898. if (
  7899. (M instanceof AST_SymbolMethod && parent.quote) ||
  7900. ((
  7901. M instanceof AST_SymbolImportForeign ||
  7902. M instanceof AST_SymbolExportForeign ||
  7903. M instanceof AST_SymbolExport
  7904. ) && M.quote)
  7905. ) {
  7906. return {
  7907. type: "Literal",
  7908. value: M.name
  7909. };
  7910. }
  7911. var def = M.definition();
  7912. return {
  7913. type: "Identifier",
  7914. name: def ? def.mangled_name || def.name : M.name
  7915. };
  7916. });
  7917. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  7918. const pattern = M.value.source;
  7919. const flags = M.value.flags;
  7920. return {
  7921. type: "Literal",
  7922. value: null,
  7923. raw: M.print_to_string(),
  7924. regex: { pattern, flags }
  7925. };
  7926. });
  7927. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  7928. var value = M.value;
  7929. return {
  7930. type: "Literal",
  7931. value: value,
  7932. raw: M.raw || M.print_to_string()
  7933. };
  7934. });
  7935. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  7936. return {
  7937. type: "Identifier",
  7938. name: String(M.value)
  7939. };
  7940. });
  7941. def_to_moz(AST_BigInt, M => ({
  7942. type: "Literal",
  7943. // value cannot be represented natively
  7944. // see: https://github.com/estree/estree/blob/master/es2020.md#bigintliteral
  7945. value: null,
  7946. // `M.value` is a string that may be a hex number representation.
  7947. // but "bigint" property should have only decimal digits
  7948. bigint: typeof BigInt === "function" ? BigInt(M.value).toString() : M.value,
  7949. raw: M.raw,
  7950. }));
  7951. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7952. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7953. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  7954. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  7955. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  7956. /* -----[ tools ]----- */
  7957. function my_start_token(moznode) {
  7958. var loc = moznode.loc, start = loc && loc.start;
  7959. var range = moznode.range;
  7960. return new AST_Token(
  7961. "",
  7962. "",
  7963. start && start.line || 0,
  7964. start && start.column || 0,
  7965. range ? range [0] : moznode.start,
  7966. false,
  7967. [],
  7968. [],
  7969. loc && loc.source,
  7970. );
  7971. }
  7972. function my_end_token(moznode) {
  7973. var loc = moznode.loc, end = loc && loc.end;
  7974. var range = moznode.range;
  7975. return new AST_Token(
  7976. "",
  7977. "",
  7978. end && end.line || 0,
  7979. end && end.column || 0,
  7980. range ? range [0] : moznode.end,
  7981. false,
  7982. [],
  7983. [],
  7984. loc && loc.source,
  7985. );
  7986. }
  7987. var FROM_MOZ_LABELS = null;
  7988. function from_moz(node) {
  7989. if (node == null) return null;
  7990. return MOZ_TO_ME[node.type](node);
  7991. }
  7992. function from_moz_quote(moz_key, computed) {
  7993. if (!computed && moz_key.type === "Literal" && typeof moz_key.value === "string") {
  7994. return '"';
  7995. } else {
  7996. return "";
  7997. }
  7998. }
  7999. function from_moz_symbol(symbol_type, M, has_quote) {
  8000. return new symbol_type({
  8001. start: my_start_token(M),
  8002. quote: has_quote ? '"' : undefined,
  8003. name: M.type === "Identifier" ? M.name : String(M.value),
  8004. end: my_end_token(M),
  8005. });
  8006. }
  8007. function from_moz_lambda(M, is_method) {
  8008. return new (is_method ? AST_Accessor : AST_Function)({
  8009. start: my_start_token(M),
  8010. end: my_end_token(M),
  8011. name: M.id && from_moz_symbol(is_method ? AST_SymbolMethod : AST_SymbolLambda, M.id),
  8012. argnames: M.params.map(M => from_moz_pattern(M, AST_SymbolFunarg)),
  8013. is_generator: M.generator,
  8014. async: M.async,
  8015. body: normalize_directives(from_moz(M.body).body)
  8016. });
  8017. }
  8018. function from_moz_pattern(M, sym_type) {
  8019. switch (M.type) {
  8020. case "ObjectPattern":
  8021. return new AST_Destructuring({
  8022. start: my_start_token(M),
  8023. end: my_end_token(M),
  8024. names: M.properties.map(p => from_moz_pattern(p, sym_type)),
  8025. is_array: false
  8026. });
  8027. case "Property":
  8028. var key = M.key;
  8029. var args = {
  8030. start : my_start_token(key || M.value),
  8031. end : my_end_token(M.value),
  8032. key : key.type == "Identifier" ? key.name : String(key.value),
  8033. quote : !M.computed && key.type === "Literal" && typeof key.value === "string"
  8034. ? '"'
  8035. : "",
  8036. value : from_moz_pattern(M.value, sym_type)
  8037. };
  8038. if (M.computed) {
  8039. args.key = from_moz(M.key);
  8040. }
  8041. return new AST_ObjectKeyVal(args);
  8042. case "ArrayPattern":
  8043. return new AST_Destructuring({
  8044. start: my_start_token(M),
  8045. end: my_end_token(M),
  8046. names: M.elements.map(function(elm) {
  8047. if (elm === null) {
  8048. return new AST_Hole();
  8049. }
  8050. return from_moz_pattern(elm, sym_type);
  8051. }),
  8052. is_array: true
  8053. });
  8054. case "SpreadElement":
  8055. case "RestElement":
  8056. return new AST_Expansion({
  8057. start: my_start_token(M),
  8058. end: my_end_token(M),
  8059. expression: from_moz_pattern(M.argument, sym_type),
  8060. });
  8061. case "AssignmentPattern":
  8062. return new AST_DefaultAssign({
  8063. start : my_start_token(M),
  8064. end : my_end_token(M),
  8065. left : from_moz_pattern(M.left, sym_type),
  8066. operator: "=",
  8067. right : from_moz(M.right),
  8068. });
  8069. case "Identifier":
  8070. return new sym_type({
  8071. start : my_start_token(M),
  8072. end : my_end_token(M),
  8073. name : M.name,
  8074. });
  8075. default:
  8076. throw new Error("Invalid node type for destructuring: " + M.type);
  8077. }
  8078. }
  8079. function from_moz_label_ref(m_label) {
  8080. if (!m_label) return null;
  8081. const label = from_moz_symbol(AST_LabelRef, m_label);
  8082. let i = FROM_MOZ_LABELS.length;
  8083. while (i--) {
  8084. const label_origin = FROM_MOZ_LABELS[i];
  8085. if (label.name === label_origin.name) {
  8086. label.thedef = label_origin;
  8087. break;
  8088. }
  8089. }
  8090. return label;
  8091. }
  8092. AST_Node.from_mozilla_ast = function(node) {
  8093. var save_labels = FROM_MOZ_LABELS;
  8094. FROM_MOZ_LABELS = [];
  8095. var ast = from_moz(node);
  8096. FROM_MOZ_LABELS = save_labels;
  8097. return ast;
  8098. };
  8099. function set_moz_loc(mynode, moznode) {
  8100. var start = mynode.start;
  8101. var end = mynode.end;
  8102. if (!(start && end)) {
  8103. return moznode;
  8104. }
  8105. if (start.pos != null && end.endpos != null) {
  8106. moznode.range = [start.pos, end.endpos];
  8107. }
  8108. if (start.line) {
  8109. moznode.loc = {
  8110. start: {line: start.line, column: start.col},
  8111. end: end.endline ? {line: end.endline, column: end.endcol} : null
  8112. };
  8113. if (start.file) {
  8114. moznode.loc.source = start.file;
  8115. }
  8116. }
  8117. return moznode;
  8118. }
  8119. function def_to_moz(mytype, handler) {
  8120. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  8121. return set_moz_loc(this, handler(this, parent));
  8122. });
  8123. }
  8124. var TO_MOZ_STACK = null;
  8125. function to_moz(node) {
  8126. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  8127. TO_MOZ_STACK.push(node);
  8128. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  8129. TO_MOZ_STACK.pop();
  8130. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  8131. return ast;
  8132. }
  8133. /** Object property keys can be number literals, string literals, or raw names. Additionally they can be shorthand. We decide that here. */
  8134. function to_moz_property_key(key, computed = false, quote = false, value = null) {
  8135. if (computed) {
  8136. return [false, to_moz(key)];
  8137. }
  8138. const key_name = typeof key === "string" ? key : key.name;
  8139. let moz_key;
  8140. if (quote) {
  8141. moz_key = { type: "Literal", value: key_name, raw: JSON.stringify(key_name) };
  8142. } else if ("" + +key_name === key_name && +key_name >= 0) {
  8143. // representable as a number
  8144. moz_key = { type: "Literal", value: +key_name, raw: JSON.stringify(+key_name) };
  8145. } else {
  8146. moz_key = { type: "Identifier", name: key_name };
  8147. }
  8148. const shorthand =
  8149. moz_key.type === "Identifier"
  8150. && moz_key.name === key_name
  8151. && (value instanceof AST_Symbol && value.name === key_name
  8152. || value instanceof AST_DefaultAssign && value.left.name === key_name);
  8153. return [shorthand, moz_key];
  8154. }
  8155. function to_moz_pattern(node) {
  8156. if (node instanceof AST_Expansion) {
  8157. return {
  8158. type: "RestElement",
  8159. argument: to_moz_pattern(node.expression),
  8160. };
  8161. }
  8162. if ((
  8163. node instanceof AST_Symbol
  8164. || node instanceof AST_Destructuring
  8165. || node instanceof AST_DefaultAssign
  8166. || node instanceof AST_PropAccess
  8167. )) {
  8168. // Plain translation
  8169. return to_moz(node);
  8170. }
  8171. throw new Error(node.TYPE);
  8172. }
  8173. function to_moz_in_destructuring() {
  8174. var i = TO_MOZ_STACK.length;
  8175. while (i--) {
  8176. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  8177. return true;
  8178. }
  8179. }
  8180. return false;
  8181. }
  8182. function to_moz_block(node) {
  8183. return {
  8184. type: "BlockStatement",
  8185. body: node.body.map(to_moz)
  8186. };
  8187. }
  8188. function to_moz_scope(type, node) {
  8189. var body = node.body.map(to_moz);
  8190. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  8191. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  8192. }
  8193. return {
  8194. type: type,
  8195. body: body
  8196. };
  8197. }
  8198. })();
  8199. // return true if the node at the top of the stack (that means the
  8200. // innermost node in the current output) is lexically the first in
  8201. // a statement.
  8202. function first_in_statement(stack) {
  8203. let node = stack.parent(-1);
  8204. for (let i = 0, p; p = stack.parent(i); i++) {
  8205. if (p instanceof AST_Statement && p.body === node)
  8206. return true;
  8207. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  8208. (p.TYPE === "Call" && p.expression === node) ||
  8209. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  8210. (p instanceof AST_Dot && p.expression === node) ||
  8211. (p instanceof AST_Sub && p.expression === node) ||
  8212. (p instanceof AST_Chain && p.expression === node) ||
  8213. (p instanceof AST_Conditional && p.condition === node) ||
  8214. (p instanceof AST_Binary && p.left === node) ||
  8215. (p instanceof AST_UnaryPostfix && p.expression === node)
  8216. ) {
  8217. node = p;
  8218. } else {
  8219. return false;
  8220. }
  8221. }
  8222. }
  8223. // Returns whether the leftmost item in the expression is an object
  8224. function left_is_object(node) {
  8225. if (node instanceof AST_Object) return true;
  8226. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  8227. if (node.TYPE === "Call") return left_is_object(node.expression);
  8228. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  8229. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  8230. if (node instanceof AST_Chain) return left_is_object(node.expression);
  8231. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  8232. if (node instanceof AST_Binary) return left_is_object(node.left);
  8233. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  8234. return false;
  8235. }
  8236. /***********************************************************************
  8237. A JavaScript tokenizer / parser / beautifier / compressor.
  8238. https://github.com/mishoo/UglifyJS2
  8239. -------------------------------- (C) ---------------------------------
  8240. Author: Mihai Bazon
  8241. <mihai.bazon@gmail.com>
  8242. http://mihai.bazon.net/blog
  8243. Distributed under the BSD license:
  8244. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8245. Redistribution and use in source and binary forms, with or without
  8246. modification, are permitted provided that the following conditions
  8247. are met:
  8248. * Redistributions of source code must retain the above
  8249. copyright notice, this list of conditions and the following
  8250. disclaimer.
  8251. * Redistributions in binary form must reproduce the above
  8252. copyright notice, this list of conditions and the following
  8253. disclaimer in the documentation and/or other materials
  8254. provided with the distribution.
  8255. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8256. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8257. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8258. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8259. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8260. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8261. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8262. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8263. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8264. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8265. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8266. SUCH DAMAGE.
  8267. ***********************************************************************/
  8268. const CODE_LINE_BREAK = 10;
  8269. const CODE_SPACE = 32;
  8270. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/;
  8271. function is_some_comments(comment) {
  8272. // multiline comment
  8273. return (
  8274. (comment.type === "comment2" || comment.type === "comment1")
  8275. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  8276. );
  8277. }
  8278. const ROPE_COMMIT_WHEN = 8 * 1000;
  8279. class Rope {
  8280. constructor() {
  8281. this.committed = "";
  8282. this.current = "";
  8283. }
  8284. append(str) {
  8285. /** When `this.current` is too long, commit it. */
  8286. if (this.current.length > ROPE_COMMIT_WHEN) {
  8287. this.committed += this.current + str;
  8288. this.current = "";
  8289. } else {
  8290. this.current += str;
  8291. }
  8292. }
  8293. insertAt(char, index) {
  8294. const { committed, current } = this;
  8295. if (index < committed.length) {
  8296. this.committed = committed.slice(0, index) + char + committed.slice(index);
  8297. } else if (index === committed.length) {
  8298. this.committed += char;
  8299. } else {
  8300. index -= committed.length;
  8301. this.committed += current.slice(0, index) + char;
  8302. this.current = current.slice(index);
  8303. }
  8304. }
  8305. charAt(index) {
  8306. const { committed } = this;
  8307. if (index < committed.length) return committed[index];
  8308. return this.current[index - committed.length];
  8309. }
  8310. charCodeAt(index) {
  8311. const { committed } = this;
  8312. if (index < committed.length) return committed.charCodeAt(index);
  8313. return this.current.charCodeAt(index - committed.length);
  8314. }
  8315. length() {
  8316. return this.committed.length + this.current.length;
  8317. }
  8318. expectDirective() {
  8319. // /^$|[;{][\s\n]*$/
  8320. let ch, n = this.length();
  8321. if (n <= 0) return true;
  8322. // Skip N whitespace from the end
  8323. while (
  8324. (ch = this.charCodeAt(--n))
  8325. && (ch == CODE_SPACE || ch == CODE_LINE_BREAK)
  8326. );
  8327. // either ";", or "{", or the string ended
  8328. return !ch || ch === 59 || ch === 123;
  8329. }
  8330. hasNLB() {
  8331. let n = this.length() - 1;
  8332. while (n >= 0) {
  8333. const code = this.charCodeAt(n--);
  8334. if (code === CODE_LINE_BREAK) return true;
  8335. if (code !== CODE_SPACE) return false;
  8336. }
  8337. return true;
  8338. }
  8339. toString() {
  8340. return this.committed + this.current;
  8341. }
  8342. }
  8343. function OutputStream(options) {
  8344. var readonly = !options;
  8345. options = defaults(options, {
  8346. ascii_only : false,
  8347. beautify : false,
  8348. braces : false,
  8349. comments : "some",
  8350. ecma : 5,
  8351. ie8 : false,
  8352. indent_level : 4,
  8353. indent_start : 0,
  8354. inline_script : true,
  8355. keep_numbers : false,
  8356. keep_quoted_props : false,
  8357. max_line_len : false,
  8358. preamble : null,
  8359. preserve_annotations : false,
  8360. quote_keys : false,
  8361. quote_style : 0,
  8362. safari10 : false,
  8363. semicolons : true,
  8364. shebang : true,
  8365. shorthand : undefined,
  8366. source_map : null,
  8367. webkit : false,
  8368. width : 80,
  8369. wrap_iife : false,
  8370. wrap_func_args : false,
  8371. _destroy_ast : false
  8372. }, true);
  8373. if (options.shorthand === undefined)
  8374. options.shorthand = options.ecma > 5;
  8375. // Convert comment option to RegExp if necessary and set up comments filter
  8376. var comment_filter = return_false; // Default case, throw all comments away
  8377. if (options.comments) {
  8378. let comments = options.comments;
  8379. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  8380. var regex_pos = options.comments.lastIndexOf("/");
  8381. comments = new RegExp(
  8382. options.comments.substr(1, regex_pos - 1),
  8383. options.comments.substr(regex_pos + 1)
  8384. );
  8385. }
  8386. if (comments instanceof RegExp) {
  8387. comment_filter = function(comment) {
  8388. return comment.type != "comment5" && comments.test(comment.value);
  8389. };
  8390. } else if (typeof comments === "function") {
  8391. comment_filter = function(comment) {
  8392. return comment.type != "comment5" && comments(this, comment);
  8393. };
  8394. } else if (comments === "some") {
  8395. comment_filter = is_some_comments;
  8396. } else { // NOTE includes "all" option
  8397. comment_filter = return_true;
  8398. }
  8399. }
  8400. if (options.preserve_annotations) {
  8401. let prev_comment_filter = comment_filter;
  8402. comment_filter = function (comment) {
  8403. return r_annotation.test(comment.value) || prev_comment_filter.apply(this, arguments);
  8404. };
  8405. }
  8406. var indentation = 0;
  8407. var current_col = 0;
  8408. var current_line = 1;
  8409. var current_pos = 0;
  8410. var OUTPUT = new Rope();
  8411. let printed_comments = new Set();
  8412. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  8413. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  8414. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  8415. var code = get_full_char_code(ch, 0).toString(16);
  8416. return "\\u{" + code + "}";
  8417. });
  8418. }
  8419. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  8420. var code = ch.charCodeAt(0).toString(16);
  8421. if (code.length <= 2 && !identifier) {
  8422. while (code.length < 2) code = "0" + code;
  8423. return "\\x" + code;
  8424. } else {
  8425. while (code.length < 4) code = "0" + code;
  8426. return "\\u" + code;
  8427. }
  8428. });
  8429. } : function(str) {
  8430. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  8431. if (lone) {
  8432. return "\\u" + lone.charCodeAt(0).toString(16);
  8433. }
  8434. return match;
  8435. });
  8436. };
  8437. function make_string(str, quote) {
  8438. var dq = 0, sq = 0;
  8439. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  8440. function(s, i) {
  8441. switch (s) {
  8442. case '"': ++dq; return '"';
  8443. case "'": ++sq; return "'";
  8444. case "\\": return "\\\\";
  8445. case "\n": return "\\n";
  8446. case "\r": return "\\r";
  8447. case "\t": return "\\t";
  8448. case "\b": return "\\b";
  8449. case "\f": return "\\f";
  8450. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  8451. case "\u2028": return "\\u2028";
  8452. case "\u2029": return "\\u2029";
  8453. case "\ufeff": return "\\ufeff";
  8454. case "\0":
  8455. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  8456. }
  8457. return s;
  8458. });
  8459. function quote_single() {
  8460. return "'" + str.replace(/\x27/g, "\\'") + "'";
  8461. }
  8462. function quote_double() {
  8463. return '"' + str.replace(/\x22/g, '\\"') + '"';
  8464. }
  8465. function quote_template() {
  8466. return "`" + str.replace(/`/g, "\\`") + "`";
  8467. }
  8468. str = to_utf8(str);
  8469. if (quote === "`") return quote_template();
  8470. switch (options.quote_style) {
  8471. case 1:
  8472. return quote_single();
  8473. case 2:
  8474. return quote_double();
  8475. case 3:
  8476. return quote == "'" ? quote_single() : quote_double();
  8477. default:
  8478. return dq > sq ? quote_single() : quote_double();
  8479. }
  8480. }
  8481. function encode_string(str, quote) {
  8482. var ret = make_string(str, quote);
  8483. if (options.inline_script) {
  8484. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  8485. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  8486. ret = ret.replace(/--\x3e/g, "--\\x3e");
  8487. }
  8488. return ret;
  8489. }
  8490. function make_name(name) {
  8491. name = name.toString();
  8492. name = to_utf8(name, true);
  8493. return name;
  8494. }
  8495. function make_indent(back) {
  8496. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  8497. }
  8498. /* -----[ beautification/minification ]----- */
  8499. var has_parens = false;
  8500. var might_need_space = false;
  8501. var might_need_semicolon = false;
  8502. var might_add_newline = 0;
  8503. var need_newline_indented = false;
  8504. var need_space = false;
  8505. var newline_insert = -1;
  8506. var last = "";
  8507. var mapping_token, mapping_name, mappings = options.source_map && [];
  8508. var do_add_mapping = mappings ? function() {
  8509. mappings.forEach(function(mapping) {
  8510. try {
  8511. let { name, token } = mapping;
  8512. if (name !== false) {
  8513. if (token.type == "name" || token.type === "privatename") {
  8514. name = token.value;
  8515. } else if (name instanceof AST_Symbol) {
  8516. name = token.type === "string" ? token.value : name.name;
  8517. }
  8518. }
  8519. options.source_map.add(
  8520. mapping.token.file,
  8521. mapping.line, mapping.col,
  8522. mapping.token.line, mapping.token.col,
  8523. is_basic_identifier_string(name) ? name : undefined
  8524. );
  8525. } catch(ex) {
  8526. // Ignore bad mapping
  8527. }
  8528. });
  8529. mappings = [];
  8530. } : noop;
  8531. var ensure_line_len = options.max_line_len ? function() {
  8532. if (current_col > options.max_line_len) {
  8533. if (might_add_newline) {
  8534. OUTPUT.insertAt("\n", might_add_newline);
  8535. const len_after_newline = OUTPUT.length() - might_add_newline - 1;
  8536. if (mappings) {
  8537. var delta = len_after_newline - current_col;
  8538. mappings.forEach(function(mapping) {
  8539. mapping.line++;
  8540. mapping.col += delta;
  8541. });
  8542. }
  8543. current_line++;
  8544. current_pos++;
  8545. current_col = len_after_newline;
  8546. }
  8547. }
  8548. if (might_add_newline) {
  8549. might_add_newline = 0;
  8550. do_add_mapping();
  8551. }
  8552. } : noop;
  8553. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  8554. function print(str) {
  8555. str = String(str);
  8556. var ch = get_full_char(str, 0);
  8557. if (need_newline_indented && ch) {
  8558. need_newline_indented = false;
  8559. if (ch !== "\n") {
  8560. print("\n");
  8561. indent();
  8562. }
  8563. }
  8564. if (need_space && ch) {
  8565. need_space = false;
  8566. if (!/[\s;})]/.test(ch)) {
  8567. space();
  8568. }
  8569. }
  8570. newline_insert = -1;
  8571. var prev = last.charAt(last.length - 1);
  8572. if (might_need_semicolon) {
  8573. might_need_semicolon = false;
  8574. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  8575. if (options.semicolons || requireSemicolonChars.has(ch)) {
  8576. OUTPUT.append(";");
  8577. current_col++;
  8578. current_pos++;
  8579. } else {
  8580. ensure_line_len();
  8581. if (current_col > 0) {
  8582. OUTPUT.append("\n");
  8583. current_pos++;
  8584. current_line++;
  8585. current_col = 0;
  8586. }
  8587. if (/^\s+$/.test(str)) {
  8588. // reset the semicolon flag, since we didn't print one
  8589. // now and might still have to later
  8590. might_need_semicolon = true;
  8591. }
  8592. }
  8593. if (!options.beautify)
  8594. might_need_space = false;
  8595. }
  8596. }
  8597. if (might_need_space) {
  8598. if ((is_identifier_char(prev)
  8599. && (is_identifier_char(ch) || ch == "\\"))
  8600. || (ch == "/" && ch == prev)
  8601. || ((ch == "+" || ch == "-") && ch == last)
  8602. ) {
  8603. OUTPUT.append(" ");
  8604. current_col++;
  8605. current_pos++;
  8606. }
  8607. might_need_space = false;
  8608. }
  8609. if (mapping_token) {
  8610. mappings.push({
  8611. token: mapping_token,
  8612. name: mapping_name,
  8613. line: current_line,
  8614. col: current_col
  8615. });
  8616. mapping_token = false;
  8617. if (!might_add_newline) do_add_mapping();
  8618. }
  8619. OUTPUT.append(str);
  8620. has_parens = str[str.length - 1] == "(";
  8621. current_pos += str.length;
  8622. var a = str.split(/\r?\n/), n = a.length - 1;
  8623. current_line += n;
  8624. current_col += a[0].length;
  8625. if (n > 0) {
  8626. ensure_line_len();
  8627. current_col = a[n].length;
  8628. }
  8629. last = str;
  8630. }
  8631. var star = function() {
  8632. print("*");
  8633. };
  8634. var space = options.beautify ? function() {
  8635. print(" ");
  8636. } : function() {
  8637. might_need_space = true;
  8638. };
  8639. var indent = options.beautify ? function(half) {
  8640. if (options.beautify) {
  8641. print(make_indent(half ? 0.5 : 0));
  8642. }
  8643. } : noop;
  8644. var with_indent = options.beautify ? function(col, cont) {
  8645. if (col === true) col = next_indent();
  8646. var save_indentation = indentation;
  8647. indentation = col;
  8648. var ret = cont();
  8649. indentation = save_indentation;
  8650. return ret;
  8651. } : function(col, cont) { return cont(); };
  8652. var newline = options.beautify ? function() {
  8653. if (newline_insert < 0) return print("\n");
  8654. if (OUTPUT.charAt(newline_insert) != "\n") {
  8655. OUTPUT.insertAt("\n", newline_insert);
  8656. current_pos++;
  8657. current_line++;
  8658. }
  8659. newline_insert++;
  8660. } : options.max_line_len ? function() {
  8661. ensure_line_len();
  8662. might_add_newline = OUTPUT.length();
  8663. } : noop;
  8664. var semicolon = options.beautify ? function() {
  8665. print(";");
  8666. } : function() {
  8667. might_need_semicolon = true;
  8668. };
  8669. function force_semicolon() {
  8670. might_need_semicolon = false;
  8671. print(";");
  8672. }
  8673. function next_indent() {
  8674. return indentation + options.indent_level;
  8675. }
  8676. function with_block(cont) {
  8677. var ret;
  8678. print("{");
  8679. newline();
  8680. with_indent(next_indent(), function() {
  8681. ret = cont();
  8682. });
  8683. indent();
  8684. print("}");
  8685. return ret;
  8686. }
  8687. function with_parens(cont) {
  8688. print("(");
  8689. //XXX: still nice to have that for argument lists
  8690. //var ret = with_indent(current_col, cont);
  8691. var ret = cont();
  8692. print(")");
  8693. return ret;
  8694. }
  8695. function with_square(cont) {
  8696. print("[");
  8697. //var ret = with_indent(current_col, cont);
  8698. var ret = cont();
  8699. print("]");
  8700. return ret;
  8701. }
  8702. function comma() {
  8703. print(",");
  8704. space();
  8705. }
  8706. function colon() {
  8707. print(":");
  8708. space();
  8709. }
  8710. var add_mapping = mappings ? function(token, name) {
  8711. mapping_token = token;
  8712. mapping_name = name;
  8713. } : noop;
  8714. function get() {
  8715. if (might_add_newline) {
  8716. ensure_line_len();
  8717. }
  8718. return OUTPUT.toString();
  8719. }
  8720. function filter_comment(comment) {
  8721. if (!options.preserve_annotations) {
  8722. comment = comment.replace(r_annotation, " ");
  8723. }
  8724. if (/^\s*$/.test(comment)) {
  8725. return "";
  8726. }
  8727. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  8728. }
  8729. function prepend_comments(node) {
  8730. var self = this;
  8731. var start = node.start;
  8732. if (!start) return;
  8733. var printed_comments = self.printed_comments;
  8734. // There cannot be a newline between return/yield and its value.
  8735. const keyword_with_value =
  8736. node instanceof AST_Exit && node.value
  8737. || (node instanceof AST_Await || node instanceof AST_Yield)
  8738. && node.expression;
  8739. if (
  8740. start.comments_before
  8741. && printed_comments.has(start.comments_before)
  8742. ) {
  8743. if (keyword_with_value) {
  8744. start.comments_before = [];
  8745. } else {
  8746. return;
  8747. }
  8748. }
  8749. var comments = start.comments_before;
  8750. if (!comments) {
  8751. comments = start.comments_before = [];
  8752. }
  8753. printed_comments.add(comments);
  8754. if (keyword_with_value) {
  8755. var tw = new TreeWalker(function(node) {
  8756. var parent = tw.parent();
  8757. if (parent instanceof AST_Exit
  8758. || parent instanceof AST_Await
  8759. || parent instanceof AST_Yield
  8760. || parent instanceof AST_Binary && parent.left === node
  8761. || parent.TYPE == "Call" && parent.expression === node
  8762. || parent instanceof AST_Conditional && parent.condition === node
  8763. || parent instanceof AST_Dot && parent.expression === node
  8764. || parent instanceof AST_Sequence && parent.expressions[0] === node
  8765. || parent instanceof AST_Sub && parent.expression === node
  8766. || parent instanceof AST_UnaryPostfix) {
  8767. if (!node.start) return;
  8768. var text = node.start.comments_before;
  8769. if (text && !printed_comments.has(text)) {
  8770. printed_comments.add(text);
  8771. comments = comments.concat(text);
  8772. }
  8773. } else {
  8774. return true;
  8775. }
  8776. });
  8777. tw.push(node);
  8778. keyword_with_value.walk(tw);
  8779. }
  8780. if (current_pos == 0) {
  8781. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  8782. && !printed_comments.has(comments[0])) {
  8783. print("#!" + comments.shift().value + "\n");
  8784. indent();
  8785. }
  8786. var preamble = options.preamble;
  8787. if (preamble) {
  8788. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  8789. }
  8790. }
  8791. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  8792. if (comments.length == 0) return;
  8793. var last_nlb = OUTPUT.hasNLB();
  8794. comments.forEach(function(c, i) {
  8795. printed_comments.add(c);
  8796. if (!last_nlb) {
  8797. if (c.nlb) {
  8798. print("\n");
  8799. indent();
  8800. last_nlb = true;
  8801. } else if (i > 0) {
  8802. space();
  8803. }
  8804. }
  8805. if (/comment[134]/.test(c.type)) {
  8806. var value = filter_comment(c.value);
  8807. if (value) {
  8808. print("//" + value + "\n");
  8809. indent();
  8810. }
  8811. last_nlb = true;
  8812. } else if (c.type == "comment2") {
  8813. var value = filter_comment(c.value);
  8814. if (value) {
  8815. print("/*" + value + "*/");
  8816. }
  8817. last_nlb = false;
  8818. }
  8819. });
  8820. if (!last_nlb) {
  8821. if (start.nlb) {
  8822. print("\n");
  8823. indent();
  8824. } else {
  8825. space();
  8826. }
  8827. }
  8828. }
  8829. function append_comments(node, tail) {
  8830. var self = this;
  8831. var token = node.end;
  8832. if (!token) return;
  8833. var printed_comments = self.printed_comments;
  8834. var comments = token[tail ? "comments_before" : "comments_after"];
  8835. if (!comments || printed_comments.has(comments)) return;
  8836. if (!(node instanceof AST_Statement || comments.every((c) =>
  8837. !/comment[134]/.test(c.type)
  8838. ))) return;
  8839. printed_comments.add(comments);
  8840. var insert = OUTPUT.length();
  8841. comments.filter(comment_filter, node).forEach(function(c, i) {
  8842. if (printed_comments.has(c)) return;
  8843. printed_comments.add(c);
  8844. need_space = false;
  8845. if (need_newline_indented) {
  8846. print("\n");
  8847. indent();
  8848. need_newline_indented = false;
  8849. } else if (c.nlb && (i > 0 || !OUTPUT.hasNLB())) {
  8850. print("\n");
  8851. indent();
  8852. } else if (i > 0 || !tail) {
  8853. space();
  8854. }
  8855. if (/comment[134]/.test(c.type)) {
  8856. const value = filter_comment(c.value);
  8857. if (value) {
  8858. print("//" + value);
  8859. }
  8860. need_newline_indented = true;
  8861. } else if (c.type == "comment2") {
  8862. const value = filter_comment(c.value);
  8863. if (value) {
  8864. print("/*" + value + "*/");
  8865. }
  8866. need_space = true;
  8867. }
  8868. });
  8869. if (OUTPUT.length() > insert) newline_insert = insert;
  8870. }
  8871. /**
  8872. * When output.option("_destroy_ast") is enabled, destroy the function.
  8873. * Call this after printing it.
  8874. */
  8875. const gc_scope =
  8876. options["_destroy_ast"]
  8877. ? function gc_scope(scope) {
  8878. scope.body.length = 0;
  8879. scope.argnames.length = 0;
  8880. }
  8881. : noop;
  8882. var stack = [];
  8883. return {
  8884. get : get,
  8885. toString : get,
  8886. indent : indent,
  8887. in_directive : false,
  8888. use_asm : null,
  8889. active_scope : null,
  8890. indentation : function() { return indentation; },
  8891. current_width : function() { return current_col - indentation; },
  8892. should_break : function() { return options.width && this.current_width() >= options.width; },
  8893. has_parens : function() { return has_parens; },
  8894. newline : newline,
  8895. print : print,
  8896. star : star,
  8897. space : space,
  8898. comma : comma,
  8899. colon : colon,
  8900. last : function() { return last; },
  8901. semicolon : semicolon,
  8902. force_semicolon : force_semicolon,
  8903. to_utf8 : to_utf8,
  8904. print_name : function(name) { print(make_name(name)); },
  8905. print_string : function(str, quote, escape_directive) {
  8906. var encoded = encode_string(str, quote);
  8907. if (escape_directive === true && !encoded.includes("\\")) {
  8908. // Insert semicolons to break directive prologue
  8909. if (!OUTPUT.expectDirective()) {
  8910. force_semicolon();
  8911. }
  8912. force_semicolon();
  8913. }
  8914. print(encoded);
  8915. },
  8916. print_template_string_chars: function(str) {
  8917. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  8918. return print(encoded.substr(1, encoded.length - 2));
  8919. },
  8920. encode_string : encode_string,
  8921. next_indent : next_indent,
  8922. with_indent : with_indent,
  8923. with_block : with_block,
  8924. with_parens : with_parens,
  8925. with_square : with_square,
  8926. add_mapping : add_mapping,
  8927. option : function(opt) { return options[opt]; },
  8928. gc_scope,
  8929. printed_comments: printed_comments,
  8930. prepend_comments: readonly ? noop : prepend_comments,
  8931. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  8932. line : function() { return current_line; },
  8933. col : function() { return current_col; },
  8934. pos : function() { return current_pos; },
  8935. push_node : function(node) { stack.push(node); },
  8936. pop_node : function() { return stack.pop(); },
  8937. parent : function(n) {
  8938. return stack[stack.length - 2 - (n || 0)];
  8939. }
  8940. };
  8941. }
  8942. /* -----[ code generators ]----- */
  8943. (function() {
  8944. /* -----[ utils ]----- */
  8945. function DEFPRINT(nodetype, generator) {
  8946. nodetype.DEFMETHOD("_codegen", generator);
  8947. }
  8948. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  8949. var self = this, generator = self._codegen;
  8950. if (self instanceof AST_Scope) {
  8951. output.active_scope = self;
  8952. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  8953. output.use_asm = output.active_scope;
  8954. }
  8955. function doit() {
  8956. output.prepend_comments(self);
  8957. self.add_source_map(output);
  8958. generator(self, output);
  8959. output.append_comments(self);
  8960. }
  8961. output.push_node(self);
  8962. if (force_parens || self.needs_parens(output)) {
  8963. output.with_parens(doit);
  8964. } else {
  8965. doit();
  8966. }
  8967. output.pop_node();
  8968. if (self === output.use_asm) {
  8969. output.use_asm = null;
  8970. }
  8971. });
  8972. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  8973. AST_Node.DEFMETHOD("print_to_string", function(options) {
  8974. var output = OutputStream(options);
  8975. this.print(output);
  8976. return output.get();
  8977. });
  8978. /* -----[ PARENTHESES ]----- */
  8979. function PARENS(nodetype, func) {
  8980. if (Array.isArray(nodetype)) {
  8981. nodetype.forEach(function(nodetype) {
  8982. PARENS(nodetype, func);
  8983. });
  8984. } else {
  8985. nodetype.DEFMETHOD("needs_parens", func);
  8986. }
  8987. }
  8988. PARENS(AST_Node, return_false);
  8989. // a function expression needs parens around it when it's provably
  8990. // the first token to appear in a statement.
  8991. PARENS(AST_Function, function(output) {
  8992. if (!output.has_parens() && first_in_statement(output)) {
  8993. return true;
  8994. }
  8995. if (output.option("webkit")) {
  8996. var p = output.parent();
  8997. if (p instanceof AST_PropAccess && p.expression === this) {
  8998. return true;
  8999. }
  9000. }
  9001. if (output.option("wrap_iife")) {
  9002. var p = output.parent();
  9003. if (p instanceof AST_Call && p.expression === this) {
  9004. return true;
  9005. }
  9006. }
  9007. if (output.option("wrap_func_args")) {
  9008. var p = output.parent();
  9009. if (p instanceof AST_Call && p.args.includes(this)) {
  9010. return true;
  9011. }
  9012. }
  9013. return false;
  9014. });
  9015. PARENS(AST_Arrow, function(output) {
  9016. var p = output.parent();
  9017. if (
  9018. output.option("wrap_func_args")
  9019. && p instanceof AST_Call
  9020. && p.args.includes(this)
  9021. ) {
  9022. return true;
  9023. }
  9024. return p instanceof AST_PropAccess && p.expression === this
  9025. || p instanceof AST_Conditional && p.condition === this;
  9026. });
  9027. // same goes for an object literal (as in AST_Function), because
  9028. // otherwise {...} would be interpreted as a block of code.
  9029. PARENS(AST_Object, function(output) {
  9030. return !output.has_parens() && first_in_statement(output);
  9031. });
  9032. PARENS(AST_ClassExpression, first_in_statement);
  9033. PARENS(AST_Unary, function(output) {
  9034. var p = output.parent();
  9035. return p instanceof AST_PropAccess && p.expression === this
  9036. || p instanceof AST_Call && p.expression === this
  9037. || p instanceof AST_Binary
  9038. && p.operator === "**"
  9039. && this instanceof AST_UnaryPrefix
  9040. && p.left === this
  9041. && this.operator !== "++"
  9042. && this.operator !== "--";
  9043. });
  9044. PARENS(AST_Await, function(output) {
  9045. var p = output.parent();
  9046. return p instanceof AST_PropAccess && p.expression === this
  9047. || p instanceof AST_Call && p.expression === this
  9048. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  9049. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  9050. });
  9051. PARENS(AST_Sequence, function(output) {
  9052. var p = output.parent();
  9053. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  9054. || p instanceof AST_Unary // !(foo, bar, baz)
  9055. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  9056. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  9057. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  9058. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  9059. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  9060. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  9061. * ==> 20 (side effect, set a := 10 and b := 20) */
  9062. || p instanceof AST_Arrow // x => (x, x)
  9063. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  9064. || p instanceof AST_Expansion // [...(a, b)]
  9065. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  9066. || p instanceof AST_Yield // yield (foo, bar)
  9067. || p instanceof AST_Export // export default (foo, bar)
  9068. ;
  9069. });
  9070. PARENS(AST_Binary, function(output) {
  9071. var p = output.parent();
  9072. // (foo && bar)()
  9073. if (p instanceof AST_Call && p.expression === this)
  9074. return true;
  9075. // typeof (foo && bar)
  9076. if (p instanceof AST_Unary)
  9077. return true;
  9078. // (foo && bar)["prop"], (foo && bar).prop
  9079. if (p instanceof AST_PropAccess && p.expression === this)
  9080. return true;
  9081. // this deals with precedence: 3 * (2 + 1)
  9082. if (p instanceof AST_Binary) {
  9083. const parent_op = p.operator;
  9084. const op = this.operator;
  9085. // It is forbidden for ?? to be used with || or && without parens.
  9086. if (op === "??" && (parent_op === "||" || parent_op === "&&")) {
  9087. return true;
  9088. }
  9089. if (parent_op === "??" && (op === "||" || op === "&&")) {
  9090. return true;
  9091. }
  9092. const pp = PRECEDENCE[parent_op];
  9093. const sp = PRECEDENCE[op];
  9094. if (pp > sp
  9095. || (pp == sp
  9096. && (this === p.right || parent_op == "**"))) {
  9097. return true;
  9098. }
  9099. }
  9100. if (p instanceof AST_PrivateIn) {
  9101. const op = this.operator;
  9102. const pp = PRECEDENCE["in"];
  9103. const sp = PRECEDENCE[op];
  9104. if (pp > sp || (pp == sp && this === p.value)) {
  9105. return true;
  9106. }
  9107. }
  9108. });
  9109. PARENS(AST_PrivateIn, function(output) {
  9110. var p = output.parent();
  9111. // (#x in this)()
  9112. if (p instanceof AST_Call && p.expression === this) {
  9113. return true;
  9114. }
  9115. // typeof (#x in this)
  9116. if (p instanceof AST_Unary) {
  9117. return true;
  9118. }
  9119. // (#x in this)["prop"], (#x in this).prop
  9120. if (p instanceof AST_PropAccess && p.expression === this) {
  9121. return true;
  9122. }
  9123. // same precedence as regular in operator
  9124. if (p instanceof AST_Binary) {
  9125. const parent_op = p.operator;
  9126. const pp = PRECEDENCE[parent_op];
  9127. const sp = PRECEDENCE["in"];
  9128. if (pp > sp
  9129. || (pp == sp
  9130. && (this === p.right || parent_op == "**"))) {
  9131. return true;
  9132. }
  9133. }
  9134. // rules are the same as binary in, but the class differs
  9135. if (p instanceof AST_PrivateIn && this === p.value) {
  9136. return true;
  9137. }
  9138. });
  9139. PARENS(AST_Yield, function(output) {
  9140. var p = output.parent();
  9141. // (yield 1) + (yield 2)
  9142. // a = yield 3
  9143. if (p instanceof AST_Binary && p.operator !== "=")
  9144. return true;
  9145. // (yield 1)()
  9146. // new (yield 1)()
  9147. if (p instanceof AST_Call && p.expression === this)
  9148. return true;
  9149. // (yield 1) ? yield 2 : yield 3
  9150. if (p instanceof AST_Conditional && p.condition === this)
  9151. return true;
  9152. // -(yield 4)
  9153. if (p instanceof AST_Unary)
  9154. return true;
  9155. // (yield x).foo
  9156. // (yield x)['foo']
  9157. if (p instanceof AST_PropAccess && p.expression === this)
  9158. return true;
  9159. });
  9160. PARENS(AST_Chain, function(output) {
  9161. var p = output.parent();
  9162. if (!(p instanceof AST_Call || p instanceof AST_PropAccess)) return false;
  9163. return p.expression === this;
  9164. });
  9165. PARENS(AST_PropAccess, function(output) {
  9166. var p = output.parent();
  9167. if (p instanceof AST_New && p.expression === this) {
  9168. // i.e. new (foo.bar().baz)
  9169. //
  9170. // if there's one call into this subtree, then we need
  9171. // parens around it too, otherwise the call will be
  9172. // interpreted as passing the arguments to the upper New
  9173. // expression.
  9174. return walk(this, node => {
  9175. if (node instanceof AST_Scope) return true;
  9176. if (node instanceof AST_Call) {
  9177. return walk_abort; // makes walk() return true.
  9178. }
  9179. });
  9180. }
  9181. });
  9182. PARENS(AST_Call, function(output) {
  9183. var p = output.parent(), p1;
  9184. if (p instanceof AST_New && p.expression === this
  9185. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  9186. return true;
  9187. // workaround for Safari bug.
  9188. // https://bugs.webkit.org/show_bug.cgi?id=123506
  9189. return this.expression instanceof AST_Function
  9190. && p instanceof AST_PropAccess
  9191. && p.expression === this
  9192. && (p1 = output.parent(1)) instanceof AST_Assign
  9193. && p1.left === p;
  9194. });
  9195. PARENS(AST_New, function(output) {
  9196. var p = output.parent();
  9197. if (this.args.length === 0
  9198. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  9199. || p instanceof AST_Call && p.expression === this
  9200. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  9201. return true;
  9202. });
  9203. PARENS(AST_Number, function(output) {
  9204. var p = output.parent();
  9205. if (p instanceof AST_PropAccess && p.expression === this) {
  9206. var value = this.getValue();
  9207. if (value < 0 || /^0/.test(make_num(value))) {
  9208. return true;
  9209. }
  9210. }
  9211. });
  9212. PARENS(AST_BigInt, function(output) {
  9213. var p = output.parent();
  9214. if (p instanceof AST_PropAccess && p.expression === this) {
  9215. var value = this.getValue();
  9216. if (value.startsWith("-")) {
  9217. return true;
  9218. }
  9219. }
  9220. });
  9221. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  9222. var p = output.parent();
  9223. // !(a = false) → true
  9224. if (p instanceof AST_Unary)
  9225. return true;
  9226. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  9227. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  9228. return true;
  9229. // (a = func)() —or— new (a = Object)()
  9230. if (p instanceof AST_Call && p.expression === this)
  9231. return true;
  9232. // (a = foo) ? bar : baz
  9233. if (p instanceof AST_Conditional && p.condition === this)
  9234. return true;
  9235. // (a = foo)["prop"] —or— (a = foo).prop
  9236. if (p instanceof AST_PropAccess && p.expression === this)
  9237. return true;
  9238. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  9239. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  9240. return true;
  9241. });
  9242. /* -----[ PRINTERS ]----- */
  9243. DEFPRINT(AST_Directive, function(self, output) {
  9244. output.print_string(self.value, self.quote);
  9245. output.semicolon();
  9246. });
  9247. DEFPRINT(AST_Expansion, function (self, output) {
  9248. output.print("...");
  9249. self.expression.print(output);
  9250. });
  9251. DEFPRINT(AST_Destructuring, function (self, output) {
  9252. output.print(self.is_array ? "[" : "{");
  9253. var len = self.names.length;
  9254. self.names.forEach(function (name, i) {
  9255. if (i > 0) output.comma();
  9256. name.print(output);
  9257. // If the final element is a hole, we need to make sure it
  9258. // doesn't look like a trailing comma, by inserting an actual
  9259. // trailing comma.
  9260. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  9261. });
  9262. output.print(self.is_array ? "]" : "}");
  9263. });
  9264. DEFPRINT(AST_Debugger, function(self, output) {
  9265. output.print("debugger");
  9266. output.semicolon();
  9267. });
  9268. /* -----[ statements ]----- */
  9269. function display_body(body, is_toplevel, output, allow_directives) {
  9270. var last = body.length - 1;
  9271. output.in_directive = allow_directives;
  9272. body.forEach(function(stmt, i) {
  9273. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  9274. stmt instanceof AST_EmptyStatement ||
  9275. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  9276. )) {
  9277. output.in_directive = false;
  9278. }
  9279. if (!(stmt instanceof AST_EmptyStatement)) {
  9280. output.indent();
  9281. stmt.print(output);
  9282. if (!(i == last && is_toplevel)) {
  9283. output.newline();
  9284. if (is_toplevel) output.newline();
  9285. }
  9286. }
  9287. if (output.in_directive === true &&
  9288. stmt instanceof AST_SimpleStatement &&
  9289. stmt.body instanceof AST_String
  9290. ) {
  9291. output.in_directive = false;
  9292. }
  9293. });
  9294. output.in_directive = false;
  9295. }
  9296. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  9297. print_maybe_braced_body(this.body, output);
  9298. });
  9299. DEFPRINT(AST_Statement, function(self, output) {
  9300. self.body.print(output);
  9301. output.semicolon();
  9302. });
  9303. DEFPRINT(AST_Toplevel, function(self, output) {
  9304. display_body(self.body, true, output, true);
  9305. output.print("");
  9306. });
  9307. DEFPRINT(AST_LabeledStatement, function(self, output) {
  9308. self.label.print(output);
  9309. output.colon();
  9310. self.body.print(output);
  9311. });
  9312. DEFPRINT(AST_SimpleStatement, function(self, output) {
  9313. self.body.print(output);
  9314. output.semicolon();
  9315. });
  9316. function print_braced_empty(self, output) {
  9317. output.print("{");
  9318. output.with_indent(output.next_indent(), function() {
  9319. output.append_comments(self, true);
  9320. });
  9321. output.add_mapping(self.end);
  9322. output.print("}");
  9323. }
  9324. function print_braced(self, output, allow_directives) {
  9325. if (self.body.length > 0) {
  9326. output.with_block(function() {
  9327. display_body(self.body, false, output, allow_directives);
  9328. output.add_mapping(self.end);
  9329. });
  9330. } else print_braced_empty(self, output);
  9331. }
  9332. DEFPRINT(AST_BlockStatement, function(self, output) {
  9333. print_braced(self, output);
  9334. });
  9335. DEFPRINT(AST_EmptyStatement, function(self, output) {
  9336. output.semicolon();
  9337. });
  9338. DEFPRINT(AST_Do, function(self, output) {
  9339. output.print("do");
  9340. output.space();
  9341. make_block(self.body, output);
  9342. output.space();
  9343. output.print("while");
  9344. output.space();
  9345. output.with_parens(function() {
  9346. self.condition.print(output);
  9347. });
  9348. output.semicolon();
  9349. });
  9350. DEFPRINT(AST_While, function(self, output) {
  9351. output.print("while");
  9352. output.space();
  9353. output.with_parens(function() {
  9354. self.condition.print(output);
  9355. });
  9356. output.space();
  9357. self._do_print_body(output);
  9358. });
  9359. DEFPRINT(AST_For, function(self, output) {
  9360. output.print("for");
  9361. output.space();
  9362. output.with_parens(function() {
  9363. if (self.init) {
  9364. if (self.init instanceof AST_Definitions) {
  9365. self.init.print(output);
  9366. } else {
  9367. parenthesize_for_noin(self.init, output, true);
  9368. }
  9369. output.print(";");
  9370. output.space();
  9371. } else {
  9372. output.print(";");
  9373. }
  9374. if (self.condition) {
  9375. self.condition.print(output);
  9376. output.print(";");
  9377. output.space();
  9378. } else {
  9379. output.print(";");
  9380. }
  9381. if (self.step) {
  9382. self.step.print(output);
  9383. }
  9384. });
  9385. output.space();
  9386. self._do_print_body(output);
  9387. });
  9388. DEFPRINT(AST_ForIn, function(self, output) {
  9389. output.print("for");
  9390. if (self.await) {
  9391. output.space();
  9392. output.print("await");
  9393. }
  9394. output.space();
  9395. output.with_parens(function() {
  9396. self.init.print(output);
  9397. output.space();
  9398. output.print(self instanceof AST_ForOf ? "of" : "in");
  9399. output.space();
  9400. self.object.print(output);
  9401. });
  9402. output.space();
  9403. self._do_print_body(output);
  9404. });
  9405. DEFPRINT(AST_With, function(self, output) {
  9406. output.print("with");
  9407. output.space();
  9408. output.with_parens(function() {
  9409. self.expression.print(output);
  9410. });
  9411. output.space();
  9412. self._do_print_body(output);
  9413. });
  9414. /* -----[ functions ]----- */
  9415. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  9416. var self = this;
  9417. if (!nokeyword) {
  9418. if (self.async) {
  9419. output.print("async");
  9420. output.space();
  9421. }
  9422. output.print("function");
  9423. if (self.is_generator) {
  9424. output.star();
  9425. }
  9426. if (self.name) {
  9427. output.space();
  9428. }
  9429. }
  9430. if (self.name instanceof AST_Symbol) {
  9431. self.name.print(output);
  9432. } else if (nokeyword && self.name instanceof AST_Node) {
  9433. output.with_square(function() {
  9434. self.name.print(output); // Computed method name
  9435. });
  9436. }
  9437. output.with_parens(function() {
  9438. self.argnames.forEach(function(arg, i) {
  9439. if (i) output.comma();
  9440. arg.print(output);
  9441. });
  9442. });
  9443. output.space();
  9444. print_braced(self, output, true);
  9445. });
  9446. DEFPRINT(AST_Lambda, function(self, output) {
  9447. self._do_print(output);
  9448. output.gc_scope(self);
  9449. });
  9450. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  9451. var tag = self.prefix;
  9452. var parenthesize_tag = tag instanceof AST_Lambda
  9453. || tag instanceof AST_Binary
  9454. || tag instanceof AST_Conditional
  9455. || tag instanceof AST_Sequence
  9456. || tag instanceof AST_Unary
  9457. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  9458. if (parenthesize_tag) output.print("(");
  9459. self.prefix.print(output);
  9460. if (parenthesize_tag) output.print(")");
  9461. self.template_string.print(output);
  9462. });
  9463. DEFPRINT(AST_TemplateString, function(self, output) {
  9464. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  9465. output.print("`");
  9466. for (var i = 0; i < self.segments.length; i++) {
  9467. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  9468. output.print("${");
  9469. self.segments[i].print(output);
  9470. output.print("}");
  9471. } else if (is_tagged) {
  9472. output.print(self.segments[i].raw);
  9473. } else {
  9474. output.print_template_string_chars(self.segments[i].value);
  9475. }
  9476. }
  9477. output.print("`");
  9478. });
  9479. DEFPRINT(AST_TemplateSegment, function(self, output) {
  9480. output.print_template_string_chars(self.value);
  9481. });
  9482. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  9483. var self = this;
  9484. var parent = output.parent();
  9485. var needs_parens = (parent instanceof AST_Binary &&
  9486. !(parent instanceof AST_Assign) &&
  9487. !(parent instanceof AST_DefaultAssign)) ||
  9488. parent instanceof AST_Unary ||
  9489. (parent instanceof AST_Call && self === parent.expression);
  9490. if (needs_parens) { output.print("("); }
  9491. if (self.async) {
  9492. output.print("async");
  9493. output.space();
  9494. }
  9495. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  9496. self.argnames[0].print(output);
  9497. } else {
  9498. output.with_parens(function() {
  9499. self.argnames.forEach(function(arg, i) {
  9500. if (i) output.comma();
  9501. arg.print(output);
  9502. });
  9503. });
  9504. }
  9505. output.space();
  9506. output.print("=>");
  9507. output.space();
  9508. const first_statement = self.body[0];
  9509. if (
  9510. self.body.length === 1
  9511. && first_statement instanceof AST_Return
  9512. ) {
  9513. const returned = first_statement.value;
  9514. if (!returned) {
  9515. output.print("{}");
  9516. } else if (left_is_object(returned)) {
  9517. output.print("(");
  9518. returned.print(output);
  9519. output.print(")");
  9520. } else {
  9521. returned.print(output);
  9522. }
  9523. } else {
  9524. print_braced(self, output);
  9525. }
  9526. if (needs_parens) { output.print(")"); }
  9527. output.gc_scope(self);
  9528. });
  9529. /* -----[ exits ]----- */
  9530. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  9531. output.print(kind);
  9532. if (this.value) {
  9533. output.space();
  9534. const comments = this.value.start.comments_before;
  9535. if (comments && comments.length && !output.printed_comments.has(comments)) {
  9536. output.print("(");
  9537. this.value.print(output);
  9538. output.print(")");
  9539. } else {
  9540. this.value.print(output);
  9541. }
  9542. }
  9543. output.semicolon();
  9544. });
  9545. DEFPRINT(AST_Return, function(self, output) {
  9546. self._do_print(output, "return");
  9547. });
  9548. DEFPRINT(AST_Throw, function(self, output) {
  9549. self._do_print(output, "throw");
  9550. });
  9551. /* -----[ yield ]----- */
  9552. DEFPRINT(AST_Yield, function(self, output) {
  9553. var star = self.is_star ? "*" : "";
  9554. output.print("yield" + star);
  9555. if (self.expression) {
  9556. output.space();
  9557. self.expression.print(output);
  9558. }
  9559. });
  9560. DEFPRINT(AST_Await, function(self, output) {
  9561. output.print("await");
  9562. output.space();
  9563. var e = self.expression;
  9564. var parens = !(
  9565. e instanceof AST_Call
  9566. || e instanceof AST_SymbolRef
  9567. || e instanceof AST_PropAccess
  9568. || e instanceof AST_Unary
  9569. || e instanceof AST_Constant
  9570. || e instanceof AST_Await
  9571. || e instanceof AST_Object
  9572. );
  9573. if (parens) output.print("(");
  9574. self.expression.print(output);
  9575. if (parens) output.print(")");
  9576. });
  9577. /* -----[ loop control ]----- */
  9578. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  9579. output.print(kind);
  9580. if (this.label) {
  9581. output.space();
  9582. this.label.print(output);
  9583. }
  9584. output.semicolon();
  9585. });
  9586. DEFPRINT(AST_Break, function(self, output) {
  9587. self._do_print(output, "break");
  9588. });
  9589. DEFPRINT(AST_Continue, function(self, output) {
  9590. self._do_print(output, "continue");
  9591. });
  9592. /* -----[ if ]----- */
  9593. function make_then(self, output) {
  9594. var b = self.body;
  9595. if (output.option("braces")
  9596. || output.option("ie8") && b instanceof AST_Do)
  9597. return make_block(b, output);
  9598. // The squeezer replaces "block"-s that contain only a single
  9599. // statement with the statement itself; technically, the AST
  9600. // is correct, but this can create problems when we output an
  9601. // IF having an ELSE clause where the THEN clause ends in an
  9602. // IF *without* an ELSE block (then the outer ELSE would refer
  9603. // to the inner IF). This function checks for this case and
  9604. // adds the block braces if needed.
  9605. if (!b) return output.force_semicolon();
  9606. while (true) {
  9607. if (b instanceof AST_If) {
  9608. if (!b.alternative) {
  9609. make_block(self.body, output);
  9610. return;
  9611. }
  9612. b = b.alternative;
  9613. } else if (b instanceof AST_StatementWithBody) {
  9614. b = b.body;
  9615. } else break;
  9616. }
  9617. print_maybe_braced_body(self.body, output);
  9618. }
  9619. DEFPRINT(AST_If, function(self, output) {
  9620. output.print("if");
  9621. output.space();
  9622. output.with_parens(function() {
  9623. self.condition.print(output);
  9624. });
  9625. output.space();
  9626. if (self.alternative) {
  9627. make_then(self, output);
  9628. output.space();
  9629. output.print("else");
  9630. output.space();
  9631. if (self.alternative instanceof AST_If)
  9632. self.alternative.print(output);
  9633. else
  9634. print_maybe_braced_body(self.alternative, output);
  9635. } else {
  9636. self._do_print_body(output);
  9637. }
  9638. });
  9639. /* -----[ switch ]----- */
  9640. DEFPRINT(AST_Switch, function(self, output) {
  9641. output.print("switch");
  9642. output.space();
  9643. output.with_parens(function() {
  9644. self.expression.print(output);
  9645. });
  9646. output.space();
  9647. var last = self.body.length - 1;
  9648. if (last < 0) print_braced_empty(self, output);
  9649. else output.with_block(function() {
  9650. self.body.forEach(function(branch, i) {
  9651. output.indent(true);
  9652. branch.print(output);
  9653. if (i < last && branch.body.length > 0)
  9654. output.newline();
  9655. });
  9656. });
  9657. });
  9658. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  9659. output.newline();
  9660. this.body.forEach(function(stmt) {
  9661. output.indent();
  9662. stmt.print(output);
  9663. output.newline();
  9664. });
  9665. });
  9666. DEFPRINT(AST_Default, function(self, output) {
  9667. output.print("default:");
  9668. self._do_print_body(output);
  9669. });
  9670. DEFPRINT(AST_Case, function(self, output) {
  9671. output.print("case");
  9672. output.space();
  9673. self.expression.print(output);
  9674. output.print(":");
  9675. self._do_print_body(output);
  9676. });
  9677. /* -----[ exceptions ]----- */
  9678. DEFPRINT(AST_Try, function(self, output) {
  9679. output.print("try");
  9680. output.space();
  9681. self.body.print(output);
  9682. if (self.bcatch) {
  9683. output.space();
  9684. self.bcatch.print(output);
  9685. }
  9686. if (self.bfinally) {
  9687. output.space();
  9688. self.bfinally.print(output);
  9689. }
  9690. });
  9691. DEFPRINT(AST_TryBlock, function(self, output) {
  9692. print_braced(self, output);
  9693. });
  9694. DEFPRINT(AST_Catch, function(self, output) {
  9695. output.print("catch");
  9696. if (self.argname) {
  9697. output.space();
  9698. output.with_parens(function() {
  9699. self.argname.print(output);
  9700. });
  9701. }
  9702. output.space();
  9703. print_braced(self, output);
  9704. });
  9705. DEFPRINT(AST_Finally, function(self, output) {
  9706. output.print("finally");
  9707. output.space();
  9708. print_braced(self, output);
  9709. });
  9710. /* -----[ var/const ]----- */
  9711. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  9712. output.print(kind);
  9713. output.space();
  9714. this.definitions.forEach(function(def, i) {
  9715. if (i) output.comma();
  9716. def.print(output);
  9717. });
  9718. var p = output.parent();
  9719. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  9720. var output_semicolon = !in_for || p && p.init !== this;
  9721. if (output_semicolon)
  9722. output.semicolon();
  9723. });
  9724. DEFPRINT(AST_Let, function(self, output) {
  9725. self._do_print(output, "let");
  9726. });
  9727. DEFPRINT(AST_Var, function(self, output) {
  9728. self._do_print(output, "var");
  9729. });
  9730. DEFPRINT(AST_Const, function(self, output) {
  9731. self._do_print(output, "const");
  9732. });
  9733. DEFPRINT(AST_Import, function(self, output) {
  9734. output.print("import");
  9735. output.space();
  9736. if (self.imported_name) {
  9737. self.imported_name.print(output);
  9738. }
  9739. if (self.imported_name && self.imported_names) {
  9740. output.print(",");
  9741. output.space();
  9742. }
  9743. if (self.imported_names) {
  9744. if (self.imported_names.length === 1 &&
  9745. self.imported_names[0].foreign_name.name === "*" &&
  9746. !self.imported_names[0].foreign_name.quote) {
  9747. self.imported_names[0].print(output);
  9748. } else {
  9749. output.print("{");
  9750. self.imported_names.forEach(function (name_import, i) {
  9751. output.space();
  9752. name_import.print(output);
  9753. if (i < self.imported_names.length - 1) {
  9754. output.print(",");
  9755. }
  9756. });
  9757. output.space();
  9758. output.print("}");
  9759. }
  9760. }
  9761. if (self.imported_name || self.imported_names) {
  9762. output.space();
  9763. output.print("from");
  9764. output.space();
  9765. }
  9766. self.module_name.print(output);
  9767. if (self.attributes) {
  9768. output.print("with");
  9769. self.attributes.print(output);
  9770. }
  9771. output.semicolon();
  9772. });
  9773. DEFPRINT(AST_ImportMeta, function(self, output) {
  9774. output.print("import.meta");
  9775. });
  9776. DEFPRINT(AST_NameMapping, function(self, output) {
  9777. var is_import = output.parent() instanceof AST_Import;
  9778. var definition = self.name.definition();
  9779. var foreign_name = self.foreign_name;
  9780. var names_are_different =
  9781. (definition && definition.mangled_name || self.name.name) !==
  9782. foreign_name.name;
  9783. if (!names_are_different &&
  9784. foreign_name.name === "*" &&
  9785. !!foreign_name.quote != !!self.name.quote) {
  9786. // export * as "*"
  9787. names_are_different = true;
  9788. }
  9789. var foreign_name_is_name = !foreign_name.quote;
  9790. if (names_are_different) {
  9791. if (is_import) {
  9792. if (foreign_name_is_name) {
  9793. output.print(foreign_name.name);
  9794. } else {
  9795. output.print_string(foreign_name.name, foreign_name.quote);
  9796. }
  9797. } else {
  9798. if (!self.name.quote) {
  9799. self.name.print(output);
  9800. } else {
  9801. output.print_string(self.name.name, self.name.quote);
  9802. }
  9803. }
  9804. output.space();
  9805. output.print("as");
  9806. output.space();
  9807. if (is_import) {
  9808. self.name.print(output);
  9809. } else {
  9810. if (foreign_name_is_name) {
  9811. output.print(foreign_name.name);
  9812. } else {
  9813. output.print_string(foreign_name.name, foreign_name.quote);
  9814. }
  9815. }
  9816. } else {
  9817. if (!self.name.quote) {
  9818. self.name.print(output);
  9819. } else {
  9820. output.print_string(self.name.name, self.name.quote);
  9821. }
  9822. }
  9823. });
  9824. DEFPRINT(AST_Export, function(self, output) {
  9825. output.print("export");
  9826. output.space();
  9827. if (self.is_default) {
  9828. output.print("default");
  9829. output.space();
  9830. }
  9831. if (self.exported_names) {
  9832. if (self.exported_names.length === 1 &&
  9833. self.exported_names[0].name.name === "*" &&
  9834. !self.exported_names[0].name.quote) {
  9835. self.exported_names[0].print(output);
  9836. } else {
  9837. output.print("{");
  9838. self.exported_names.forEach(function(name_export, i) {
  9839. output.space();
  9840. name_export.print(output);
  9841. if (i < self.exported_names.length - 1) {
  9842. output.print(",");
  9843. }
  9844. });
  9845. output.space();
  9846. output.print("}");
  9847. }
  9848. } else if (self.exported_value) {
  9849. self.exported_value.print(output);
  9850. } else if (self.exported_definition) {
  9851. self.exported_definition.print(output);
  9852. if (self.exported_definition instanceof AST_Definitions) return;
  9853. }
  9854. if (self.module_name) {
  9855. output.space();
  9856. output.print("from");
  9857. output.space();
  9858. self.module_name.print(output);
  9859. }
  9860. if (self.attributes) {
  9861. output.print("with");
  9862. self.attributes.print(output);
  9863. }
  9864. if (self.exported_value
  9865. && !(self.exported_value instanceof AST_Defun ||
  9866. self.exported_value instanceof AST_Function ||
  9867. self.exported_value instanceof AST_Class)
  9868. || self.module_name
  9869. || self.exported_names
  9870. ) {
  9871. output.semicolon();
  9872. }
  9873. });
  9874. function parenthesize_for_noin(node, output, noin) {
  9875. var parens = false;
  9876. // need to take some precautions here:
  9877. // https://github.com/mishoo/UglifyJS2/issues/60
  9878. if (noin) {
  9879. parens = walk(node, node => {
  9880. // Don't go into scopes -- except arrow functions:
  9881. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  9882. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  9883. return true;
  9884. }
  9885. if (
  9886. node instanceof AST_Binary && node.operator == "in"
  9887. || node instanceof AST_PrivateIn
  9888. ) {
  9889. return walk_abort; // makes walk() return true
  9890. }
  9891. });
  9892. }
  9893. node.print(output, parens);
  9894. }
  9895. DEFPRINT(AST_VarDef, function(self, output) {
  9896. self.name.print(output);
  9897. if (self.value) {
  9898. output.space();
  9899. output.print("=");
  9900. output.space();
  9901. var p = output.parent(1);
  9902. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  9903. parenthesize_for_noin(self.value, output, noin);
  9904. }
  9905. });
  9906. /* -----[ other expressions ]----- */
  9907. DEFPRINT(AST_Call, function(self, output) {
  9908. self.expression.print(output);
  9909. if (self instanceof AST_New && self.args.length === 0)
  9910. return;
  9911. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  9912. output.add_mapping(self.start);
  9913. }
  9914. if (self.optional) output.print("?.");
  9915. output.with_parens(function() {
  9916. self.args.forEach(function(expr, i) {
  9917. if (i) output.comma();
  9918. expr.print(output);
  9919. });
  9920. });
  9921. });
  9922. DEFPRINT(AST_New, function(self, output) {
  9923. output.print("new");
  9924. output.space();
  9925. AST_Call.prototype._codegen(self, output);
  9926. });
  9927. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  9928. this.expressions.forEach(function(node, index) {
  9929. if (index > 0) {
  9930. output.comma();
  9931. if (output.should_break()) {
  9932. output.newline();
  9933. output.indent();
  9934. }
  9935. }
  9936. node.print(output);
  9937. });
  9938. });
  9939. DEFPRINT(AST_Sequence, function(self, output) {
  9940. self._do_print(output);
  9941. // var p = output.parent();
  9942. // if (p instanceof AST_Statement) {
  9943. // output.with_indent(output.next_indent(), function(){
  9944. // self._do_print(output);
  9945. // });
  9946. // } else {
  9947. // self._do_print(output);
  9948. // }
  9949. });
  9950. DEFPRINT(AST_Dot, function(self, output) {
  9951. var expr = self.expression;
  9952. expr.print(output);
  9953. var prop = self.property;
  9954. var print_computed = ALL_RESERVED_WORDS.has(prop)
  9955. ? output.option("ie8")
  9956. : !is_identifier_string(
  9957. prop,
  9958. output.option("ecma") >= 2015 && !output.option("safari10")
  9959. );
  9960. if (self.optional) output.print("?.");
  9961. if (print_computed) {
  9962. output.print("[");
  9963. output.add_mapping(self.end);
  9964. output.print_string(prop);
  9965. output.print("]");
  9966. } else {
  9967. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  9968. if (!/[xa-f.)]/i.test(output.last())) {
  9969. output.print(".");
  9970. }
  9971. }
  9972. if (!self.optional) output.print(".");
  9973. // the name after dot would be mapped about here.
  9974. output.add_mapping(self.end);
  9975. output.print_name(prop);
  9976. }
  9977. });
  9978. DEFPRINT(AST_DotHash, function(self, output) {
  9979. var expr = self.expression;
  9980. expr.print(output);
  9981. var prop = self.property;
  9982. if (self.optional) output.print("?");
  9983. output.print(".#");
  9984. output.add_mapping(self.end);
  9985. output.print_name(prop);
  9986. });
  9987. DEFPRINT(AST_Sub, function(self, output) {
  9988. self.expression.print(output);
  9989. if (self.optional) output.print("?.");
  9990. output.print("[");
  9991. self.property.print(output);
  9992. output.print("]");
  9993. });
  9994. DEFPRINT(AST_Chain, function(self, output) {
  9995. self.expression.print(output);
  9996. });
  9997. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  9998. var op = self.operator;
  9999. if (op === "--" && output.last().endsWith("!")) {
  10000. // avoid printing "<!--"
  10001. output.print(" ");
  10002. }
  10003. output.print(op);
  10004. if (/^[a-z]/i.test(op)
  10005. || (/[+-]$/.test(op)
  10006. && self.expression instanceof AST_UnaryPrefix
  10007. && /^[+-]/.test(self.expression.operator))) {
  10008. output.space();
  10009. }
  10010. self.expression.print(output);
  10011. });
  10012. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  10013. self.expression.print(output);
  10014. output.print(self.operator);
  10015. });
  10016. DEFPRINT(AST_Binary, function(self, output) {
  10017. var op = self.operator;
  10018. self.left.print(output);
  10019. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  10020. && output.last().endsWith("--")) {
  10021. // space is mandatory to avoid outputting -->
  10022. output.print(" ");
  10023. } else {
  10024. // the space is optional depending on "beautify"
  10025. output.space();
  10026. }
  10027. output.print(op);
  10028. output.space();
  10029. self.right.print(output);
  10030. });
  10031. DEFPRINT(AST_Conditional, function(self, output) {
  10032. self.condition.print(output);
  10033. output.space();
  10034. output.print("?");
  10035. output.space();
  10036. self.consequent.print(output);
  10037. output.space();
  10038. output.colon();
  10039. self.alternative.print(output);
  10040. });
  10041. /* -----[ literals ]----- */
  10042. DEFPRINT(AST_Array, function(self, output) {
  10043. output.with_square(function() {
  10044. var a = self.elements, len = a.length;
  10045. if (len > 0) output.space();
  10046. a.forEach(function(exp, i) {
  10047. if (i) output.comma();
  10048. exp.print(output);
  10049. // If the final element is a hole, we need to make sure it
  10050. // doesn't look like a trailing comma, by inserting an actual
  10051. // trailing comma.
  10052. if (i === len - 1 && exp instanceof AST_Hole)
  10053. output.comma();
  10054. });
  10055. if (len > 0) output.space();
  10056. });
  10057. });
  10058. DEFPRINT(AST_Object, function(self, output) {
  10059. if (self.properties.length > 0) output.with_block(function() {
  10060. self.properties.forEach(function(prop, i) {
  10061. if (i) {
  10062. output.print(",");
  10063. output.newline();
  10064. }
  10065. output.indent();
  10066. prop.print(output);
  10067. });
  10068. output.newline();
  10069. });
  10070. else print_braced_empty(self, output);
  10071. });
  10072. DEFPRINT(AST_Class, function(self, output) {
  10073. output.print("class");
  10074. output.space();
  10075. if (self.name) {
  10076. self.name.print(output);
  10077. output.space();
  10078. }
  10079. if (self.extends) {
  10080. var parens = (
  10081. !(self.extends instanceof AST_SymbolRef)
  10082. && !(self.extends instanceof AST_PropAccess)
  10083. && !(self.extends instanceof AST_ClassExpression)
  10084. && !(self.extends instanceof AST_Function)
  10085. );
  10086. output.print("extends");
  10087. if (parens) {
  10088. output.print("(");
  10089. } else {
  10090. output.space();
  10091. }
  10092. self.extends.print(output);
  10093. if (parens) {
  10094. output.print(")");
  10095. } else {
  10096. output.space();
  10097. }
  10098. }
  10099. if (self.properties.length > 0) output.with_block(function() {
  10100. self.properties.forEach(function(prop, i) {
  10101. if (i) {
  10102. output.newline();
  10103. }
  10104. output.indent();
  10105. prop.print(output);
  10106. });
  10107. output.newline();
  10108. });
  10109. else output.print("{}");
  10110. });
  10111. DEFPRINT(AST_NewTarget, function(self, output) {
  10112. output.print("new.target");
  10113. });
  10114. /** Prints a prop name. Returns whether it can be used as a shorthand. */
  10115. function print_property_name(key, quote, output) {
  10116. if (output.option("quote_keys")) {
  10117. output.print_string(key);
  10118. return false;
  10119. }
  10120. if ("" + +key == key && key >= 0) {
  10121. if (output.option("keep_numbers")) {
  10122. output.print(key);
  10123. return false;
  10124. }
  10125. output.print(make_num(key));
  10126. return false;
  10127. }
  10128. var print_string = ALL_RESERVED_WORDS.has(key)
  10129. ? output.option("ie8")
  10130. : (
  10131. output.option("ecma") < 2015 || output.option("safari10")
  10132. ? !is_basic_identifier_string(key)
  10133. : !is_identifier_string(key, true)
  10134. );
  10135. if (print_string || (quote && output.option("keep_quoted_props"))) {
  10136. output.print_string(key, quote);
  10137. return false;
  10138. }
  10139. output.print_name(key);
  10140. return true;
  10141. }
  10142. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  10143. function get_name(self) {
  10144. var def = self.definition();
  10145. return def ? def.mangled_name || def.name : self.name;
  10146. }
  10147. const try_shorthand = output.option("shorthand") && !(self.key instanceof AST_Node);
  10148. if (
  10149. try_shorthand
  10150. && self.value instanceof AST_Symbol
  10151. && get_name(self.value) === self.key
  10152. && !ALL_RESERVED_WORDS.has(self.key)
  10153. ) {
  10154. const was_shorthand = print_property_name(self.key, self.quote, output);
  10155. if (!was_shorthand) {
  10156. output.colon();
  10157. self.value.print(output);
  10158. }
  10159. } else if (
  10160. try_shorthand
  10161. && self.value instanceof AST_DefaultAssign
  10162. && self.value.left instanceof AST_Symbol
  10163. && get_name(self.value.left) === self.key
  10164. ) {
  10165. const was_shorthand = print_property_name(self.key, self.quote, output);
  10166. if (!was_shorthand) {
  10167. output.colon();
  10168. self.value.left.print(output);
  10169. }
  10170. output.space();
  10171. output.print("=");
  10172. output.space();
  10173. self.value.right.print(output);
  10174. } else {
  10175. if (!(self.key instanceof AST_Node)) {
  10176. print_property_name(self.key, self.quote, output);
  10177. } else {
  10178. output.with_square(function() {
  10179. self.key.print(output);
  10180. });
  10181. }
  10182. output.colon();
  10183. self.value.print(output);
  10184. }
  10185. });
  10186. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  10187. if (self.static) {
  10188. output.print("static");
  10189. output.space();
  10190. }
  10191. output.print("#");
  10192. print_property_name(self.key.name, undefined, output);
  10193. if (self.value) {
  10194. output.print("=");
  10195. self.value.print(output);
  10196. }
  10197. output.semicolon();
  10198. });
  10199. DEFPRINT(AST_ClassProperty, (self, output) => {
  10200. if (self.static) {
  10201. output.print("static");
  10202. output.space();
  10203. }
  10204. if (self.key instanceof AST_SymbolClassProperty) {
  10205. print_property_name(self.key.name, self.quote, output);
  10206. } else {
  10207. output.print("[");
  10208. self.key.print(output);
  10209. output.print("]");
  10210. }
  10211. if (self.value) {
  10212. output.print("=");
  10213. self.value.print(output);
  10214. }
  10215. output.semicolon();
  10216. });
  10217. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  10218. var self = this;
  10219. if (self.static) {
  10220. output.print("static");
  10221. output.space();
  10222. }
  10223. if (type) {
  10224. output.print(type);
  10225. output.space();
  10226. }
  10227. if (self.key instanceof AST_SymbolMethod) {
  10228. if (is_private) output.print("#");
  10229. print_property_name(self.key.name, self.quote, output);
  10230. self.key.add_source_map(output);
  10231. } else {
  10232. output.with_square(function() {
  10233. self.key.print(output);
  10234. });
  10235. }
  10236. self.value._do_print(output, true);
  10237. });
  10238. DEFPRINT(AST_ObjectSetter, function(self, output) {
  10239. self._print_getter_setter("set", false, output);
  10240. });
  10241. DEFPRINT(AST_ObjectGetter, function(self, output) {
  10242. self._print_getter_setter("get", false, output);
  10243. });
  10244. DEFPRINT(AST_PrivateSetter, function(self, output) {
  10245. self._print_getter_setter("set", true, output);
  10246. });
  10247. DEFPRINT(AST_PrivateGetter, function(self, output) {
  10248. self._print_getter_setter("get", true, output);
  10249. });
  10250. DEFPRINT(AST_ConciseMethod, function(self, output) {
  10251. var type;
  10252. if (self.value.is_generator && self.value.async) {
  10253. type = "async*";
  10254. } else if (self.value.is_generator) {
  10255. type = "*";
  10256. } else if (self.value.async) {
  10257. type = "async";
  10258. }
  10259. self._print_getter_setter(type, false, output);
  10260. });
  10261. DEFPRINT(AST_PrivateMethod, function(self, output) {
  10262. var type;
  10263. if (self.value.is_generator && self.value.async) {
  10264. type = "async*";
  10265. } else if (self.value.is_generator) {
  10266. type = "*";
  10267. } else if (self.value.async) {
  10268. type = "async";
  10269. }
  10270. self._print_getter_setter(type, true, output);
  10271. });
  10272. DEFPRINT(AST_PrivateIn, function(self, output) {
  10273. self.key.print(output);
  10274. output.space();
  10275. output.print("in");
  10276. output.space();
  10277. self.value.print(output);
  10278. });
  10279. DEFPRINT(AST_SymbolPrivateProperty, function(self, output) {
  10280. output.print("#" + self.name);
  10281. });
  10282. DEFPRINT(AST_ClassStaticBlock, function (self, output) {
  10283. output.print("static");
  10284. output.space();
  10285. print_braced(self, output);
  10286. });
  10287. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  10288. var def = this.definition();
  10289. output.print_name(def ? def.mangled_name || def.name : this.name);
  10290. });
  10291. DEFPRINT(AST_Symbol, function (self, output) {
  10292. self._do_print(output);
  10293. });
  10294. DEFPRINT(AST_Hole, noop);
  10295. DEFPRINT(AST_This, function(self, output) {
  10296. output.print("this");
  10297. });
  10298. DEFPRINT(AST_Super, function(self, output) {
  10299. output.print("super");
  10300. });
  10301. DEFPRINT(AST_Constant, function(self, output) {
  10302. output.print(self.getValue());
  10303. });
  10304. DEFPRINT(AST_String, function(self, output) {
  10305. output.print_string(self.getValue(), self.quote, output.in_directive);
  10306. });
  10307. DEFPRINT(AST_Number, function(self, output) {
  10308. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  10309. output.print(self.raw);
  10310. } else {
  10311. output.print(make_num(self.getValue()));
  10312. }
  10313. });
  10314. DEFPRINT(AST_BigInt, function(self, output) {
  10315. if (output.option("keep_numbers") && self.raw) {
  10316. output.print(self.raw);
  10317. } else {
  10318. output.print(self.getValue() + "n");
  10319. }
  10320. });
  10321. const r_slash_script = /(<\s*\/\s*script)/i;
  10322. const r_starts_with_script = /^\s*script/i;
  10323. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  10324. DEFPRINT(AST_RegExp, function(self, output) {
  10325. let { source, flags } = self.getValue();
  10326. source = regexp_source_fix(source);
  10327. flags = flags ? sort_regexp_flags(flags) : "";
  10328. // Avoid outputting end of script tag
  10329. source = source.replace(r_slash_script, slash_script_replace);
  10330. if (r_starts_with_script.test(source) && output.last().endsWith("<")) {
  10331. output.print(" ");
  10332. }
  10333. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  10334. const parent = output.parent();
  10335. if (
  10336. parent instanceof AST_Binary
  10337. && /^\w/.test(parent.operator)
  10338. && parent.left === self
  10339. ) {
  10340. output.print(" ");
  10341. }
  10342. });
  10343. /** if, for, while, may or may not have braces surrounding its body */
  10344. function print_maybe_braced_body(stat, output) {
  10345. if (output.option("braces")) {
  10346. make_block(stat, output);
  10347. } else {
  10348. if (!stat || stat instanceof AST_EmptyStatement)
  10349. output.force_semicolon();
  10350. else if (stat instanceof AST_Let || stat instanceof AST_Const || stat instanceof AST_Class)
  10351. make_block(stat, output);
  10352. else
  10353. stat.print(output);
  10354. }
  10355. }
  10356. function best_of(a) {
  10357. var best = a[0], len = best.length;
  10358. for (var i = 1; i < a.length; ++i) {
  10359. if (a[i].length < len) {
  10360. best = a[i];
  10361. len = best.length;
  10362. }
  10363. }
  10364. return best;
  10365. }
  10366. function make_num(num) {
  10367. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  10368. var candidates = [ str ];
  10369. if (Math.floor(num) === num) {
  10370. if (num < 0) {
  10371. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  10372. } else {
  10373. candidates.push("0x" + num.toString(16).toLowerCase());
  10374. }
  10375. }
  10376. var match, len, digits;
  10377. if (match = /^\.0+/.exec(str)) {
  10378. len = match[0].length;
  10379. digits = str.slice(len);
  10380. candidates.push(digits + "e-" + (digits.length + len - 1));
  10381. } else if (match = /0+$/.exec(str)) {
  10382. len = match[0].length;
  10383. candidates.push(str.slice(0, -len) + "e" + len);
  10384. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  10385. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  10386. }
  10387. return best_of(candidates);
  10388. }
  10389. function make_block(stmt, output) {
  10390. if (!stmt || stmt instanceof AST_EmptyStatement)
  10391. output.print("{}");
  10392. else if (stmt instanceof AST_BlockStatement)
  10393. stmt.print(output);
  10394. else output.with_block(function() {
  10395. output.indent();
  10396. stmt.print(output);
  10397. output.newline();
  10398. });
  10399. }
  10400. /* -----[ source map generators ]----- */
  10401. function DEFMAP(nodetype, generator) {
  10402. nodetype.forEach(function(nodetype) {
  10403. nodetype.DEFMETHOD("add_source_map", generator);
  10404. });
  10405. }
  10406. DEFMAP([
  10407. // We could easily add info for ALL nodes, but it seems to me that
  10408. // would be quite wasteful, hence this noop in the base class.
  10409. AST_Node,
  10410. // since the label symbol will mark it
  10411. AST_LabeledStatement,
  10412. AST_Toplevel,
  10413. ], noop);
  10414. // XXX: I'm not exactly sure if we need it for all of these nodes,
  10415. // or if we should add even more.
  10416. DEFMAP([
  10417. AST_Array,
  10418. AST_BlockStatement,
  10419. AST_Catch,
  10420. AST_Class,
  10421. AST_Constant,
  10422. AST_Debugger,
  10423. AST_Definitions,
  10424. AST_Directive,
  10425. AST_Finally,
  10426. AST_Jump,
  10427. AST_Lambda,
  10428. AST_New,
  10429. AST_Object,
  10430. AST_StatementWithBody,
  10431. AST_Symbol,
  10432. AST_Switch,
  10433. AST_SwitchBranch,
  10434. AST_TemplateString,
  10435. AST_TemplateSegment,
  10436. AST_Try,
  10437. ], function(output) {
  10438. output.add_mapping(this.start);
  10439. });
  10440. DEFMAP([
  10441. AST_ObjectGetter,
  10442. AST_ObjectSetter,
  10443. AST_PrivateGetter,
  10444. AST_PrivateSetter,
  10445. AST_ConciseMethod,
  10446. AST_PrivateMethod,
  10447. ], function(output) {
  10448. output.add_mapping(this.start, false /*name handled below*/);
  10449. });
  10450. DEFMAP([
  10451. AST_SymbolMethod,
  10452. AST_SymbolPrivateProperty
  10453. ], function(output) {
  10454. const tok_type = this.end && this.end.type;
  10455. if (tok_type === "name" || tok_type === "privatename") {
  10456. output.add_mapping(this.end, this.name);
  10457. } else {
  10458. output.add_mapping(this.end);
  10459. }
  10460. });
  10461. DEFMAP([ AST_ObjectProperty ], function(output) {
  10462. output.add_mapping(this.start, this.key);
  10463. });
  10464. })();
  10465. const shallow_cmp = (node1, node2) => {
  10466. return (
  10467. node1 === null && node2 === null
  10468. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  10469. );
  10470. };
  10471. const equivalent_to = (tree1, tree2) => {
  10472. if (!shallow_cmp(tree1, tree2)) return false;
  10473. const walk_1_state = [tree1];
  10474. const walk_2_state = [tree2];
  10475. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  10476. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  10477. while (walk_1_state.length && walk_2_state.length) {
  10478. const node_1 = walk_1_state.pop();
  10479. const node_2 = walk_2_state.pop();
  10480. if (!shallow_cmp(node_1, node_2)) return false;
  10481. node_1._children_backwards(walk_1_push);
  10482. node_2._children_backwards(walk_2_push);
  10483. if (walk_1_state.length !== walk_2_state.length) {
  10484. // Different number of children
  10485. return false;
  10486. }
  10487. }
  10488. return walk_1_state.length == 0 && walk_2_state.length == 0;
  10489. };
  10490. const pass_through = () => true;
  10491. AST_Node.prototype.shallow_cmp = function () {
  10492. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  10493. };
  10494. AST_Debugger.prototype.shallow_cmp = pass_through;
  10495. AST_Directive.prototype.shallow_cmp = function(other) {
  10496. return this.value === other.value;
  10497. };
  10498. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  10499. AST_Block.prototype.shallow_cmp = pass_through;
  10500. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  10501. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  10502. return this.label.name === other.label.name;
  10503. };
  10504. AST_Do.prototype.shallow_cmp = pass_through;
  10505. AST_While.prototype.shallow_cmp = pass_through;
  10506. AST_For.prototype.shallow_cmp = function(other) {
  10507. 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);
  10508. };
  10509. AST_ForIn.prototype.shallow_cmp = pass_through;
  10510. AST_ForOf.prototype.shallow_cmp = pass_through;
  10511. AST_With.prototype.shallow_cmp = pass_through;
  10512. AST_Toplevel.prototype.shallow_cmp = pass_through;
  10513. AST_Expansion.prototype.shallow_cmp = pass_through;
  10514. AST_Lambda.prototype.shallow_cmp = function(other) {
  10515. return this.is_generator === other.is_generator && this.async === other.async;
  10516. };
  10517. AST_Destructuring.prototype.shallow_cmp = function(other) {
  10518. return this.is_array === other.is_array;
  10519. };
  10520. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  10521. AST_TemplateString.prototype.shallow_cmp = pass_through;
  10522. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  10523. return this.value === other.value;
  10524. };
  10525. AST_Jump.prototype.shallow_cmp = pass_through;
  10526. AST_LoopControl.prototype.shallow_cmp = pass_through;
  10527. AST_Await.prototype.shallow_cmp = pass_through;
  10528. AST_Yield.prototype.shallow_cmp = function(other) {
  10529. return this.is_star === other.is_star;
  10530. };
  10531. AST_If.prototype.shallow_cmp = function(other) {
  10532. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  10533. };
  10534. AST_Switch.prototype.shallow_cmp = pass_through;
  10535. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  10536. AST_Try.prototype.shallow_cmp = function(other) {
  10537. 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);
  10538. };
  10539. AST_Catch.prototype.shallow_cmp = function(other) {
  10540. return this.argname == null ? other.argname == null : this.argname === other.argname;
  10541. };
  10542. AST_Finally.prototype.shallow_cmp = pass_through;
  10543. AST_Definitions.prototype.shallow_cmp = pass_through;
  10544. AST_VarDef.prototype.shallow_cmp = function(other) {
  10545. return this.value == null ? other.value == null : this.value === other.value;
  10546. };
  10547. AST_NameMapping.prototype.shallow_cmp = pass_through;
  10548. AST_Import.prototype.shallow_cmp = function(other) {
  10549. return (this.imported_name == null ? other.imported_name == null : this.imported_name === other.imported_name) && (this.imported_names == null ? other.imported_names == null : this.imported_names === other.imported_names) && (this.attributes == null ? other.attributes == null : this.attributes === other.attributes);
  10550. };
  10551. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  10552. AST_Export.prototype.shallow_cmp = function(other) {
  10553. 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;
  10554. };
  10555. AST_Call.prototype.shallow_cmp = pass_through;
  10556. AST_Sequence.prototype.shallow_cmp = pass_through;
  10557. AST_PropAccess.prototype.shallow_cmp = pass_through;
  10558. AST_Chain.prototype.shallow_cmp = pass_through;
  10559. AST_Dot.prototype.shallow_cmp = function(other) {
  10560. return this.property === other.property;
  10561. };
  10562. AST_DotHash.prototype.shallow_cmp = function(other) {
  10563. return this.property === other.property;
  10564. };
  10565. AST_Unary.prototype.shallow_cmp = function(other) {
  10566. return this.operator === other.operator;
  10567. };
  10568. AST_Binary.prototype.shallow_cmp = function(other) {
  10569. return this.operator === other.operator;
  10570. };
  10571. AST_PrivateIn.prototype.shallow_cmp = pass_through;
  10572. AST_Conditional.prototype.shallow_cmp = pass_through;
  10573. AST_Array.prototype.shallow_cmp = pass_through;
  10574. AST_Object.prototype.shallow_cmp = pass_through;
  10575. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  10576. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  10577. return this.key === other.key && this.quote === other.quote;
  10578. };
  10579. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  10580. return this.static === other.static;
  10581. };
  10582. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  10583. return this.static === other.static;
  10584. };
  10585. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  10586. return this.static === other.static;
  10587. };
  10588. AST_PrivateMethod.prototype.shallow_cmp = function(other) {
  10589. return this.static === other.static;
  10590. };
  10591. AST_Class.prototype.shallow_cmp = function(other) {
  10592. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  10593. };
  10594. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  10595. return this.static === other.static
  10596. && (typeof this.key === "string"
  10597. ? this.key === other.key
  10598. : true /* AST_Node handled elsewhere */);
  10599. };
  10600. AST_ClassPrivateProperty.prototype.shallow_cmp = function(other) {
  10601. return this.static === other.static;
  10602. };
  10603. AST_Symbol.prototype.shallow_cmp = function(other) {
  10604. return this.name === other.name;
  10605. };
  10606. AST_NewTarget.prototype.shallow_cmp = pass_through;
  10607. AST_This.prototype.shallow_cmp = pass_through;
  10608. AST_Super.prototype.shallow_cmp = pass_through;
  10609. AST_String.prototype.shallow_cmp = function(other) {
  10610. return this.value === other.value;
  10611. };
  10612. AST_Number.prototype.shallow_cmp = function(other) {
  10613. return this.value === other.value;
  10614. };
  10615. AST_BigInt.prototype.shallow_cmp = function(other) {
  10616. return this.value === other.value;
  10617. };
  10618. AST_RegExp.prototype.shallow_cmp = function (other) {
  10619. return (
  10620. this.value.flags === other.value.flags
  10621. && this.value.source === other.value.source
  10622. );
  10623. };
  10624. AST_Atom.prototype.shallow_cmp = pass_through;
  10625. /***********************************************************************
  10626. A JavaScript tokenizer / parser / beautifier / compressor.
  10627. https://github.com/mishoo/UglifyJS2
  10628. -------------------------------- (C) ---------------------------------
  10629. Author: Mihai Bazon
  10630. <mihai.bazon@gmail.com>
  10631. http://mihai.bazon.net/blog
  10632. Distributed under the BSD license:
  10633. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10634. Redistribution and use in source and binary forms, with or without
  10635. modification, are permitted provided that the following conditions
  10636. are met:
  10637. * Redistributions of source code must retain the above
  10638. copyright notice, this list of conditions and the following
  10639. disclaimer.
  10640. * Redistributions in binary form must reproduce the above
  10641. copyright notice, this list of conditions and the following
  10642. disclaimer in the documentation and/or other materials
  10643. provided with the distribution.
  10644. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10645. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10646. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10647. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10648. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10649. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10650. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10651. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10652. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10653. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10654. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10655. SUCH DAMAGE.
  10656. ***********************************************************************/
  10657. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  10658. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  10659. let function_defs = null;
  10660. let unmangleable_names = null;
  10661. /**
  10662. * When defined, there is a function declaration somewhere that's inside of a block.
  10663. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  10664. */
  10665. let scopes_with_block_defuns = null;
  10666. class SymbolDef {
  10667. constructor(scope, orig, init) {
  10668. this.name = orig.name;
  10669. this.orig = [ orig ];
  10670. this.init = init;
  10671. this.eliminated = 0;
  10672. this.assignments = 0;
  10673. this.scope = scope;
  10674. this.replaced = 0;
  10675. this.global = false;
  10676. this.export = 0;
  10677. this.mangled_name = null;
  10678. this.undeclared = false;
  10679. this.id = SymbolDef.next_id++;
  10680. this.chained = false;
  10681. this.direct_access = false;
  10682. this.escaped = 0;
  10683. this.recursive_refs = 0;
  10684. this.references = [];
  10685. this.should_replace = undefined;
  10686. this.single_use = false;
  10687. this.fixed = false;
  10688. Object.seal(this);
  10689. }
  10690. fixed_value() {
  10691. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  10692. return this.fixed();
  10693. }
  10694. unmangleable(options) {
  10695. if (!options) options = {};
  10696. if (
  10697. function_defs &&
  10698. function_defs.has(this.id) &&
  10699. keep_name(options.keep_fnames, this.orig[0].name)
  10700. ) return true;
  10701. return this.global && !options.toplevel
  10702. || (this.export & MASK_EXPORT_DONT_MANGLE)
  10703. || this.undeclared
  10704. || !options.eval && this.scope.pinned()
  10705. || (this.orig[0] instanceof AST_SymbolLambda
  10706. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  10707. || this.orig[0] instanceof AST_SymbolMethod
  10708. || (this.orig[0] instanceof AST_SymbolClass
  10709. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  10710. }
  10711. mangle(options) {
  10712. const cache = options.cache && options.cache.props;
  10713. if (this.global && cache && cache.has(this.name)) {
  10714. this.mangled_name = cache.get(this.name);
  10715. } else if (!this.mangled_name && !this.unmangleable(options)) {
  10716. var s = this.scope;
  10717. var sym = this.orig[0];
  10718. if (options.ie8 && sym instanceof AST_SymbolLambda)
  10719. s = s.parent_scope;
  10720. const redefinition = redefined_catch_def(this);
  10721. this.mangled_name = redefinition
  10722. ? redefinition.mangled_name || redefinition.name
  10723. : s.next_mangled(options, this);
  10724. if (this.global && cache) {
  10725. cache.set(this.name, this.mangled_name);
  10726. }
  10727. }
  10728. }
  10729. }
  10730. SymbolDef.next_id = 1;
  10731. function redefined_catch_def(def) {
  10732. if (def.orig[0] instanceof AST_SymbolCatch
  10733. && def.scope.is_block_scope()
  10734. ) {
  10735. return def.scope.get_defun_scope().variables.get(def.name);
  10736. }
  10737. }
  10738. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = undefined, toplevel = this } = {}) {
  10739. options = defaults(options, {
  10740. cache: null,
  10741. ie8: false,
  10742. safari10: false,
  10743. module: false,
  10744. });
  10745. if (!(toplevel instanceof AST_Toplevel)) {
  10746. throw new Error("Invalid toplevel scope");
  10747. }
  10748. // pass 1: setup scope chaining and handle definitions
  10749. var scope = this.parent_scope = parent_scope;
  10750. var labels = new Map();
  10751. var defun = null;
  10752. var in_destructuring = null;
  10753. var for_scopes = [];
  10754. var tw = new TreeWalker((node, descend) => {
  10755. if (node.is_block_scope()) {
  10756. const save_scope = scope;
  10757. node.block_scope = scope = new AST_Scope(node);
  10758. scope._block_scope = true;
  10759. scope.init_scope_vars(save_scope);
  10760. scope.uses_with = save_scope.uses_with;
  10761. scope.uses_eval = save_scope.uses_eval;
  10762. if (options.safari10) {
  10763. if (node instanceof AST_For || node instanceof AST_ForIn || node instanceof AST_ForOf) {
  10764. for_scopes.push(scope);
  10765. }
  10766. }
  10767. if (node instanceof AST_Switch) {
  10768. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  10769. // AST_Switch has a scope within the body, but it itself "is a block scope"
  10770. // This means the switched expression has to belong to the outer scope
  10771. // while the body inside belongs to the switch itself.
  10772. // This is pretty nasty and warrants an AST change
  10773. const the_block_scope = scope;
  10774. scope = save_scope;
  10775. node.expression.walk(tw);
  10776. scope = the_block_scope;
  10777. for (let i = 0; i < node.body.length; i++) {
  10778. node.body[i].walk(tw);
  10779. }
  10780. } else {
  10781. descend();
  10782. }
  10783. scope = save_scope;
  10784. return true;
  10785. }
  10786. if (node instanceof AST_Destructuring) {
  10787. const save_destructuring = in_destructuring;
  10788. in_destructuring = node;
  10789. descend();
  10790. in_destructuring = save_destructuring;
  10791. return true;
  10792. }
  10793. if (node instanceof AST_Scope) {
  10794. node.init_scope_vars(scope);
  10795. var save_scope = scope;
  10796. var save_defun = defun;
  10797. var save_labels = labels;
  10798. defun = scope = node;
  10799. labels = new Map();
  10800. descend();
  10801. scope = save_scope;
  10802. defun = save_defun;
  10803. labels = save_labels;
  10804. return true; // don't descend again in TreeWalker
  10805. }
  10806. if (node instanceof AST_LabeledStatement) {
  10807. var l = node.label;
  10808. if (labels.has(l.name)) {
  10809. throw new Error(string_template("Label {name} defined twice", l));
  10810. }
  10811. labels.set(l.name, l);
  10812. descend();
  10813. labels.delete(l.name);
  10814. return true; // no descend again
  10815. }
  10816. if (node instanceof AST_With) {
  10817. for (var s = scope; s; s = s.parent_scope)
  10818. s.uses_with = true;
  10819. return;
  10820. }
  10821. if (node instanceof AST_Symbol) {
  10822. node.scope = scope;
  10823. }
  10824. if (node instanceof AST_Label) {
  10825. node.thedef = node;
  10826. node.references = [];
  10827. }
  10828. if (node instanceof AST_SymbolLambda) {
  10829. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  10830. } else if (node instanceof AST_SymbolDefun) {
  10831. // Careful here, the scope where this should be defined is
  10832. // the parent scope. The reason is that we enter a new
  10833. // scope when we encounter the AST_Defun node (which is
  10834. // instanceof AST_Scope) but we get to the symbol a bit
  10835. // later.
  10836. const closest_scope = defun.parent_scope;
  10837. // In strict mode, function definitions are block-scoped
  10838. node.scope = tw.directives["use strict"]
  10839. ? closest_scope
  10840. : closest_scope.get_defun_scope();
  10841. mark_export(node.scope.def_function(node, defun), 1);
  10842. } else if (node instanceof AST_SymbolClass) {
  10843. mark_export(defun.def_variable(node, defun), 1);
  10844. } else if (node instanceof AST_SymbolImport) {
  10845. scope.def_variable(node);
  10846. } else if (node instanceof AST_SymbolDefClass) {
  10847. // This deals with the name of the class being available
  10848. // inside the class.
  10849. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  10850. } else if (
  10851. node instanceof AST_SymbolVar
  10852. || node instanceof AST_SymbolLet
  10853. || node instanceof AST_SymbolConst
  10854. || node instanceof AST_SymbolCatch
  10855. ) {
  10856. var def;
  10857. if (node instanceof AST_SymbolBlockDeclaration) {
  10858. def = scope.def_variable(node, null);
  10859. } else {
  10860. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  10861. }
  10862. if (!def.orig.every((sym) => {
  10863. if (sym === node) return true;
  10864. if (node instanceof AST_SymbolBlockDeclaration) {
  10865. return sym instanceof AST_SymbolLambda;
  10866. }
  10867. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  10868. })) {
  10869. js_error(
  10870. `"${node.name}" is redeclared`,
  10871. node.start.file,
  10872. node.start.line,
  10873. node.start.col,
  10874. node.start.pos
  10875. );
  10876. }
  10877. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  10878. if (defun !== scope) {
  10879. node.mark_enclosed();
  10880. var def = scope.find_variable(node);
  10881. if (node.thedef !== def) {
  10882. node.thedef = def;
  10883. node.reference();
  10884. }
  10885. }
  10886. } else if (node instanceof AST_LabelRef) {
  10887. var sym = labels.get(node.name);
  10888. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  10889. name: node.name,
  10890. line: node.start.line,
  10891. col: node.start.col
  10892. }));
  10893. node.thedef = sym;
  10894. }
  10895. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  10896. js_error(
  10897. `"${node.TYPE}" statement may only appear at the top level`,
  10898. node.start.file,
  10899. node.start.line,
  10900. node.start.col,
  10901. node.start.pos
  10902. );
  10903. }
  10904. });
  10905. if (options.module) {
  10906. tw.directives["use strict"] = true;
  10907. }
  10908. this.walk(tw);
  10909. function mark_export(def, level) {
  10910. if (in_destructuring) {
  10911. var i = 0;
  10912. do {
  10913. level++;
  10914. } while (tw.parent(i++) !== in_destructuring);
  10915. }
  10916. var node = tw.parent(level);
  10917. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  10918. var exported = node.exported_definition;
  10919. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  10920. def.export = MASK_EXPORT_WANT_MANGLE;
  10921. }
  10922. }
  10923. }
  10924. // pass 2: find back references and eval
  10925. const is_toplevel = this instanceof AST_Toplevel;
  10926. if (is_toplevel) {
  10927. this.globals = new Map();
  10928. }
  10929. var tw = new TreeWalker(node => {
  10930. if (node instanceof AST_LoopControl && node.label) {
  10931. node.label.thedef.references.push(node);
  10932. return true;
  10933. }
  10934. if (node instanceof AST_SymbolRef) {
  10935. var name = node.name;
  10936. if (name == "eval" && tw.parent() instanceof AST_Call) {
  10937. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  10938. s.uses_eval = true;
  10939. }
  10940. }
  10941. var sym;
  10942. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  10943. || !(sym = node.scope.find_variable(name))) {
  10944. sym = toplevel.def_global(node);
  10945. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  10946. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  10947. sym.scope.get_defun_scope().uses_arguments = true;
  10948. }
  10949. node.thedef = sym;
  10950. node.reference();
  10951. if (node.scope.is_block_scope()
  10952. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  10953. node.scope = node.scope.get_defun_scope();
  10954. }
  10955. return true;
  10956. }
  10957. // ensure mangling works if catch reuses a scope variable
  10958. var def;
  10959. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  10960. var s = node.scope;
  10961. while (s) {
  10962. push_uniq(s.enclosed, def);
  10963. if (s === def.scope) break;
  10964. s = s.parent_scope;
  10965. }
  10966. }
  10967. });
  10968. this.walk(tw);
  10969. // pass 3: work around IE8 and Safari catch scope bugs
  10970. if (options.ie8 || options.safari10) {
  10971. walk(this, node => {
  10972. if (node instanceof AST_SymbolCatch) {
  10973. var name = node.name;
  10974. var refs = node.thedef.references;
  10975. var scope = node.scope.get_defun_scope();
  10976. var def = scope.find_variable(name)
  10977. || toplevel.globals.get(name)
  10978. || scope.def_variable(node);
  10979. refs.forEach(function(ref) {
  10980. ref.thedef = def;
  10981. ref.reference();
  10982. });
  10983. node.thedef = def;
  10984. node.reference();
  10985. return true;
  10986. }
  10987. });
  10988. }
  10989. // pass 4: add symbol definitions to loop scopes
  10990. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  10991. // https://github.com/mishoo/UglifyJS2/issues/1753
  10992. // https://bugs.webkit.org/show_bug.cgi?id=171041
  10993. if (options.safari10) {
  10994. for (const scope of for_scopes) {
  10995. scope.parent_scope.variables.forEach(function(def) {
  10996. push_uniq(scope.enclosed, def);
  10997. });
  10998. }
  10999. }
  11000. });
  11001. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  11002. var globals = this.globals, name = node.name;
  11003. if (globals.has(name)) {
  11004. return globals.get(name);
  11005. } else {
  11006. var g = new SymbolDef(this, node);
  11007. g.undeclared = true;
  11008. g.global = true;
  11009. globals.set(name, g);
  11010. return g;
  11011. }
  11012. });
  11013. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  11014. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  11015. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  11016. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  11017. this.parent_scope = parent_scope; // the parent scope
  11018. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  11019. this.cname = -1; // the current index for mangling functions/variables
  11020. });
  11021. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  11022. return (
  11023. this.enclosed.find(def => def.name === name)
  11024. || this.variables.has(name)
  11025. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  11026. );
  11027. });
  11028. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  11029. return (
  11030. this.enclosed.find(def => def.name === name)
  11031. || this.variables.has(name)
  11032. );
  11033. });
  11034. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  11035. // `scope` is going to be moved into `this` right now.
  11036. // Update the required scopes' information
  11037. if (scope.parent_scope === this) return;
  11038. scope.parent_scope = this;
  11039. // Propagate to this.uses_arguments from arrow functions
  11040. if ((scope instanceof AST_Arrow) && (this instanceof AST_Lambda && !this.uses_arguments)) {
  11041. this.uses_arguments = walk(scope, node => {
  11042. if (
  11043. node instanceof AST_SymbolRef
  11044. && node.scope instanceof AST_Lambda
  11045. && node.name === "arguments"
  11046. ) {
  11047. return walk_abort;
  11048. }
  11049. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  11050. return true;
  11051. }
  11052. });
  11053. }
  11054. this.uses_with = this.uses_with || scope.uses_with;
  11055. this.uses_eval = this.uses_eval || scope.uses_eval;
  11056. const scope_ancestry = (() => {
  11057. const ancestry = [];
  11058. let cur = this;
  11059. do {
  11060. ancestry.push(cur);
  11061. } while ((cur = cur.parent_scope));
  11062. ancestry.reverse();
  11063. return ancestry;
  11064. })();
  11065. const new_scope_enclosed_set = new Set(scope.enclosed);
  11066. const to_enclose = [];
  11067. for (const scope_topdown of scope_ancestry) {
  11068. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  11069. for (const def of scope_topdown.variables.values()) {
  11070. if (new_scope_enclosed_set.has(def)) {
  11071. push_uniq(to_enclose, def);
  11072. push_uniq(scope_topdown.enclosed, def);
  11073. }
  11074. }
  11075. }
  11076. });
  11077. function find_scopes_visible_from(scopes) {
  11078. const found_scopes = new Set();
  11079. for (const scope of new Set(scopes)) {
  11080. (function bubble_up(scope) {
  11081. if (scope == null || found_scopes.has(scope)) return;
  11082. found_scopes.add(scope);
  11083. bubble_up(scope.parent_scope);
  11084. })(scope);
  11085. }
  11086. return [...found_scopes];
  11087. }
  11088. // Creates a symbol during compression
  11089. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  11090. source,
  11091. tentative_name,
  11092. scope,
  11093. conflict_scopes = [scope],
  11094. init = null
  11095. } = {}) {
  11096. let symbol_name;
  11097. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  11098. if (tentative_name) {
  11099. // Implement hygiene (no new names are conflicting with existing names)
  11100. tentative_name =
  11101. symbol_name =
  11102. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  11103. let i = 0;
  11104. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  11105. symbol_name = tentative_name + "$" + i++;
  11106. }
  11107. }
  11108. if (!symbol_name) {
  11109. throw new Error("No symbol name could be generated in create_symbol()");
  11110. }
  11111. const symbol = make_node(SymClass, source, {
  11112. name: symbol_name,
  11113. scope
  11114. });
  11115. this.def_variable(symbol, init || null);
  11116. symbol.mark_enclosed();
  11117. return symbol;
  11118. });
  11119. AST_Node.DEFMETHOD("is_block_scope", return_false);
  11120. AST_Class.DEFMETHOD("is_block_scope", return_false);
  11121. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  11122. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  11123. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  11124. AST_Block.DEFMETHOD("is_block_scope", return_true);
  11125. AST_Scope.DEFMETHOD("is_block_scope", function () {
  11126. return this._block_scope || false;
  11127. });
  11128. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  11129. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  11130. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  11131. this.uses_arguments = false;
  11132. this.def_variable(new AST_SymbolFunarg({
  11133. name: "arguments",
  11134. start: this.start,
  11135. end: this.end
  11136. }));
  11137. });
  11138. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  11139. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  11140. this.uses_arguments = false;
  11141. });
  11142. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  11143. var def = this.definition();
  11144. var s = this.scope;
  11145. while (s) {
  11146. push_uniq(s.enclosed, def);
  11147. if (s === def.scope) break;
  11148. s = s.parent_scope;
  11149. }
  11150. });
  11151. AST_Symbol.DEFMETHOD("reference", function() {
  11152. this.definition().references.push(this);
  11153. this.mark_enclosed();
  11154. });
  11155. AST_Scope.DEFMETHOD("find_variable", function(name) {
  11156. if (name instanceof AST_Symbol) name = name.name;
  11157. return this.variables.get(name)
  11158. || (this.parent_scope && this.parent_scope.find_variable(name));
  11159. });
  11160. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  11161. var def = this.def_variable(symbol, init);
  11162. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  11163. return def;
  11164. });
  11165. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  11166. var def = this.variables.get(symbol.name);
  11167. if (def) {
  11168. def.orig.push(symbol);
  11169. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  11170. def.init = init;
  11171. }
  11172. } else {
  11173. def = new SymbolDef(this, symbol, init);
  11174. this.variables.set(symbol.name, def);
  11175. def.global = !this.parent_scope;
  11176. }
  11177. return symbol.thedef = def;
  11178. });
  11179. function next_mangled(scope, options) {
  11180. let defun_scope;
  11181. if (
  11182. scopes_with_block_defuns
  11183. && (defun_scope = scope.get_defun_scope())
  11184. && scopes_with_block_defuns.has(defun_scope)
  11185. ) {
  11186. scope = defun_scope;
  11187. }
  11188. var ext = scope.enclosed;
  11189. var nth_identifier = options.nth_identifier;
  11190. out: while (true) {
  11191. var m = nth_identifier.get(++scope.cname);
  11192. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  11193. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  11194. // shadow a name reserved from mangling.
  11195. if (options.reserved.has(m)) continue;
  11196. // Functions with short names might collide with base54 output
  11197. // and therefore cause collisions when keep_fnames is true.
  11198. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  11199. // we must ensure that the mangled name does not shadow a name
  11200. // from some parent scope that is referenced in this or in
  11201. // inner scopes.
  11202. for (let i = ext.length; --i >= 0;) {
  11203. const def = ext[i];
  11204. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  11205. if (m == name) continue out;
  11206. }
  11207. return m;
  11208. }
  11209. }
  11210. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  11211. return next_mangled(this, options);
  11212. });
  11213. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  11214. let name;
  11215. const mangled_names = this.mangled_names;
  11216. do {
  11217. name = next_mangled(this, options);
  11218. } while (mangled_names.has(name));
  11219. return name;
  11220. });
  11221. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  11222. // #179, #326
  11223. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  11224. // a function expression's argument cannot shadow the function expression's name
  11225. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  11226. // the function's mangled_name is null when keep_fnames is true
  11227. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  11228. while (true) {
  11229. var name = next_mangled(this, options);
  11230. if (!tricky_name || tricky_name != name)
  11231. return name;
  11232. }
  11233. });
  11234. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  11235. var def = this.definition();
  11236. return !def || def.unmangleable(options);
  11237. });
  11238. // labels are always mangleable
  11239. AST_Label.DEFMETHOD("unmangleable", return_false);
  11240. AST_Symbol.DEFMETHOD("unreferenced", function() {
  11241. return !this.definition().references.length && !this.scope.pinned();
  11242. });
  11243. AST_Symbol.DEFMETHOD("definition", function() {
  11244. return this.thedef;
  11245. });
  11246. AST_Symbol.DEFMETHOD("global", function() {
  11247. return this.thedef.global;
  11248. });
  11249. /**
  11250. * Format the mangler options (if any) into their appropriate types
  11251. */
  11252. function format_mangler_options(options) {
  11253. options = defaults(options, {
  11254. eval : false,
  11255. nth_identifier : base54,
  11256. ie8 : false,
  11257. keep_classnames: false,
  11258. keep_fnames : false,
  11259. module : false,
  11260. reserved : [],
  11261. toplevel : false,
  11262. });
  11263. if (options.module) options.toplevel = true;
  11264. if (!Array.isArray(options.reserved)
  11265. && !(options.reserved instanceof Set)
  11266. ) {
  11267. options.reserved = [];
  11268. }
  11269. options.reserved = new Set(options.reserved);
  11270. // Never mangle arguments
  11271. options.reserved.add("arguments");
  11272. return options;
  11273. }
  11274. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  11275. options = format_mangler_options(options);
  11276. var nth_identifier = options.nth_identifier;
  11277. // We only need to mangle declaration nodes. Special logic wired
  11278. // into the code generator will display the mangled name if it's
  11279. // present (and for AST_SymbolRef-s it'll use the mangled name of
  11280. // the AST_SymbolDeclaration that it points to).
  11281. var lname = -1;
  11282. var to_mangle = [];
  11283. if (options.keep_fnames) {
  11284. function_defs = new Set();
  11285. }
  11286. const mangled_names = this.mangled_names = new Set();
  11287. unmangleable_names = new Set();
  11288. if (options.cache) {
  11289. this.globals.forEach(collect);
  11290. if (options.cache.props) {
  11291. options.cache.props.forEach(function(mangled_name) {
  11292. mangled_names.add(mangled_name);
  11293. });
  11294. }
  11295. }
  11296. var tw = new TreeWalker(function(node, descend) {
  11297. if (node instanceof AST_LabeledStatement) {
  11298. // lname is incremented when we get to the AST_Label
  11299. var save_nesting = lname;
  11300. descend();
  11301. lname = save_nesting;
  11302. return true; // don't descend again in TreeWalker
  11303. }
  11304. if (
  11305. node instanceof AST_Defun
  11306. && !(tw.parent() instanceof AST_Scope)
  11307. ) {
  11308. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  11309. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  11310. }
  11311. if (node instanceof AST_Scope) {
  11312. node.variables.forEach(collect);
  11313. return;
  11314. }
  11315. if (node.is_block_scope()) {
  11316. node.block_scope.variables.forEach(collect);
  11317. return;
  11318. }
  11319. if (
  11320. function_defs
  11321. && node instanceof AST_VarDef
  11322. && node.value instanceof AST_Lambda
  11323. && !node.value.name
  11324. && keep_name(options.keep_fnames, node.name.name)
  11325. ) {
  11326. function_defs.add(node.name.definition().id);
  11327. return;
  11328. }
  11329. if (node instanceof AST_Label) {
  11330. let name;
  11331. do {
  11332. name = nth_identifier.get(++lname);
  11333. } while (ALL_RESERVED_WORDS.has(name));
  11334. node.mangled_name = name;
  11335. return true;
  11336. }
  11337. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  11338. to_mangle.push(node.definition());
  11339. return;
  11340. }
  11341. });
  11342. this.walk(tw);
  11343. if (options.keep_fnames || options.keep_classnames) {
  11344. // Collect a set of short names which are unmangleable,
  11345. // for use in avoiding collisions in next_mangled.
  11346. to_mangle.forEach(def => {
  11347. if (def.name.length < 6 && def.unmangleable(options)) {
  11348. unmangleable_names.add(def.name);
  11349. }
  11350. });
  11351. }
  11352. to_mangle.forEach(def => { def.mangle(options); });
  11353. function_defs = null;
  11354. unmangleable_names = null;
  11355. scopes_with_block_defuns = null;
  11356. function collect(symbol) {
  11357. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  11358. unmangleable_names.add(symbol.name);
  11359. } else if (!options.reserved.has(symbol.name)) {
  11360. to_mangle.push(symbol);
  11361. }
  11362. }
  11363. });
  11364. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  11365. const cache = options.cache && options.cache.props;
  11366. const avoid = new Set();
  11367. options.reserved.forEach(to_avoid);
  11368. this.globals.forEach(add_def);
  11369. this.walk(new TreeWalker(function(node) {
  11370. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  11371. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  11372. }));
  11373. return avoid;
  11374. function to_avoid(name) {
  11375. avoid.add(name);
  11376. }
  11377. function add_def(def) {
  11378. var name = def.name;
  11379. if (def.global && cache && cache.has(name)) name = cache.get(name);
  11380. else if (!def.unmangleable(options)) return;
  11381. to_avoid(name);
  11382. }
  11383. });
  11384. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  11385. options = format_mangler_options(options);
  11386. var nth_identifier = options.nth_identifier;
  11387. if (nth_identifier.reset && nth_identifier.sort) {
  11388. nth_identifier.reset();
  11389. nth_identifier.sort();
  11390. }
  11391. var avoid = this.find_colliding_names(options);
  11392. var cname = 0;
  11393. this.globals.forEach(rename);
  11394. this.walk(new TreeWalker(function(node) {
  11395. if (node instanceof AST_Scope) node.variables.forEach(rename);
  11396. if (node instanceof AST_SymbolCatch) rename(node.definition());
  11397. }));
  11398. function next_name() {
  11399. var name;
  11400. do {
  11401. name = nth_identifier.get(cname++);
  11402. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  11403. return name;
  11404. }
  11405. function rename(def) {
  11406. if (def.global && options.cache) return;
  11407. if (def.unmangleable(options)) return;
  11408. if (options.reserved.has(def.name)) return;
  11409. const redefinition = redefined_catch_def(def);
  11410. const name = def.name = redefinition ? redefinition.name : next_name();
  11411. def.orig.forEach(function(sym) {
  11412. sym.name = name;
  11413. });
  11414. def.references.forEach(function(sym) {
  11415. sym.name = name;
  11416. });
  11417. }
  11418. });
  11419. AST_Node.DEFMETHOD("tail_node", return_this);
  11420. AST_Sequence.DEFMETHOD("tail_node", function() {
  11421. return this.expressions[this.expressions.length - 1];
  11422. });
  11423. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  11424. options = format_mangler_options(options);
  11425. var nth_identifier = options.nth_identifier;
  11426. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  11427. // If the identifier mangler is invariant, skip computing character frequency.
  11428. return;
  11429. }
  11430. nth_identifier.reset();
  11431. try {
  11432. AST_Node.prototype.print = function(stream, force_parens) {
  11433. this._print(stream, force_parens);
  11434. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  11435. nth_identifier.consider(this.name, -1);
  11436. } else if (options.properties) {
  11437. if (this instanceof AST_DotHash) {
  11438. nth_identifier.consider("#" + this.property, -1);
  11439. } else if (this instanceof AST_Dot) {
  11440. nth_identifier.consider(this.property, -1);
  11441. } else if (this instanceof AST_Sub) {
  11442. skip_string(this.property);
  11443. }
  11444. }
  11445. };
  11446. nth_identifier.consider(this.print_to_string(), 1);
  11447. } finally {
  11448. AST_Node.prototype.print = AST_Node.prototype._print;
  11449. }
  11450. nth_identifier.sort();
  11451. function skip_string(node) {
  11452. if (node instanceof AST_String) {
  11453. nth_identifier.consider(node.value, -1);
  11454. } else if (node instanceof AST_Conditional) {
  11455. skip_string(node.consequent);
  11456. skip_string(node.alternative);
  11457. } else if (node instanceof AST_Sequence) {
  11458. skip_string(node.tail_node());
  11459. }
  11460. }
  11461. });
  11462. const base54 = (() => {
  11463. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  11464. const digits = "0123456789".split("");
  11465. let chars;
  11466. let frequency;
  11467. function reset() {
  11468. frequency = new Map();
  11469. leading.forEach(function(ch) {
  11470. frequency.set(ch, 0);
  11471. });
  11472. digits.forEach(function(ch) {
  11473. frequency.set(ch, 0);
  11474. });
  11475. }
  11476. function consider(str, delta) {
  11477. for (var i = str.length; --i >= 0;) {
  11478. frequency.set(str[i], frequency.get(str[i]) + delta);
  11479. }
  11480. }
  11481. function compare(a, b) {
  11482. return frequency.get(b) - frequency.get(a);
  11483. }
  11484. function sort() {
  11485. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  11486. }
  11487. // Ensure this is in a usable initial state.
  11488. reset();
  11489. sort();
  11490. function base54(num) {
  11491. var ret = "", base = 54;
  11492. num++;
  11493. do {
  11494. num--;
  11495. ret += chars[num % base];
  11496. num = Math.floor(num / base);
  11497. base = 64;
  11498. } while (num > 0);
  11499. return ret;
  11500. }
  11501. return {
  11502. get: base54,
  11503. consider,
  11504. reset,
  11505. sort
  11506. };
  11507. })();
  11508. let mangle_options = undefined;
  11509. AST_Node.prototype.size = function (compressor, stack) {
  11510. mangle_options = compressor && compressor._mangle_options;
  11511. let size = 0;
  11512. walk_parent(this, (node, info) => {
  11513. size += node._size(info);
  11514. // Braceless arrow functions have fake "return" statements
  11515. if (node instanceof AST_Arrow && node.is_braceless()) {
  11516. size += node.body[0].value._size(info);
  11517. return true;
  11518. }
  11519. }, stack || (compressor && compressor.stack));
  11520. // just to save a bit of memory
  11521. mangle_options = undefined;
  11522. return size;
  11523. };
  11524. AST_Node.prototype._size = () => 0;
  11525. AST_Debugger.prototype._size = () => 8;
  11526. AST_Directive.prototype._size = function () {
  11527. // TODO string encoding stuff
  11528. return 2 + this.value.length;
  11529. };
  11530. /** Count commas/semicolons necessary to show a list of expressions/statements */
  11531. const list_overhead = (array) => array.length && array.length - 1;
  11532. AST_Block.prototype._size = function () {
  11533. return 2 + list_overhead(this.body);
  11534. };
  11535. AST_Toplevel.prototype._size = function() {
  11536. return list_overhead(this.body);
  11537. };
  11538. AST_EmptyStatement.prototype._size = () => 1;
  11539. AST_LabeledStatement.prototype._size = () => 2; // x:
  11540. AST_Do.prototype._size = () => 9;
  11541. AST_While.prototype._size = () => 7;
  11542. AST_For.prototype._size = () => 8;
  11543. AST_ForIn.prototype._size = () => 8;
  11544. // AST_ForOf inherits ^
  11545. AST_With.prototype._size = () => 6;
  11546. AST_Expansion.prototype._size = () => 3;
  11547. const lambda_modifiers = func =>
  11548. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  11549. AST_Accessor.prototype._size = function () {
  11550. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  11551. };
  11552. AST_Function.prototype._size = function (info) {
  11553. const first = !!first_in_statement(info);
  11554. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  11555. };
  11556. AST_Defun.prototype._size = function () {
  11557. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  11558. };
  11559. AST_Arrow.prototype._size = function () {
  11560. let args_and_arrow = 2 + list_overhead(this.argnames);
  11561. if (
  11562. !(
  11563. this.argnames.length === 1
  11564. && this.argnames[0] instanceof AST_Symbol
  11565. )
  11566. ) {
  11567. args_and_arrow += 2; // parens around the args
  11568. }
  11569. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  11570. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  11571. };
  11572. AST_Destructuring.prototype._size = () => 2;
  11573. AST_TemplateString.prototype._size = function () {
  11574. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  11575. };
  11576. AST_TemplateSegment.prototype._size = function () {
  11577. return this.value.length;
  11578. };
  11579. AST_Return.prototype._size = function () {
  11580. return this.value ? 7 : 6;
  11581. };
  11582. AST_Throw.prototype._size = () => 6;
  11583. AST_Break.prototype._size = function () {
  11584. return this.label ? 6 : 5;
  11585. };
  11586. AST_Continue.prototype._size = function () {
  11587. return this.label ? 9 : 8;
  11588. };
  11589. AST_If.prototype._size = () => 4;
  11590. AST_Switch.prototype._size = function () {
  11591. return 8 + list_overhead(this.body);
  11592. };
  11593. AST_Case.prototype._size = function () {
  11594. return 5 + list_overhead(this.body);
  11595. };
  11596. AST_Default.prototype._size = function () {
  11597. return 8 + list_overhead(this.body);
  11598. };
  11599. AST_Try.prototype._size = () => 3;
  11600. AST_Catch.prototype._size = function () {
  11601. let size = 7 + list_overhead(this.body);
  11602. if (this.argname) {
  11603. size += 2;
  11604. }
  11605. return size;
  11606. };
  11607. AST_Finally.prototype._size = function () {
  11608. return 7 + list_overhead(this.body);
  11609. };
  11610. AST_Var.prototype._size = function () {
  11611. return 4 + list_overhead(this.definitions);
  11612. };
  11613. AST_Let.prototype._size = function () {
  11614. return 4 + list_overhead(this.definitions);
  11615. };
  11616. AST_Const.prototype._size = function () {
  11617. return 6 + list_overhead(this.definitions);
  11618. };
  11619. AST_VarDef.prototype._size = function () {
  11620. return this.value ? 1 : 0;
  11621. };
  11622. AST_NameMapping.prototype._size = function () {
  11623. // foreign name isn't mangled
  11624. return this.name ? 4 : 0;
  11625. };
  11626. AST_Import.prototype._size = function () {
  11627. // import
  11628. let size = 6;
  11629. if (this.imported_name) size += 1;
  11630. // from
  11631. if (this.imported_name || this.imported_names) size += 5;
  11632. // braces, and the commas
  11633. if (this.imported_names) {
  11634. size += 2 + list_overhead(this.imported_names);
  11635. }
  11636. return size;
  11637. };
  11638. AST_ImportMeta.prototype._size = () => 11;
  11639. AST_Export.prototype._size = function () {
  11640. let size = 7 + (this.is_default ? 8 : 0);
  11641. if (this.exported_value) {
  11642. size += this.exported_value._size();
  11643. }
  11644. if (this.exported_names) {
  11645. // Braces and commas
  11646. size += 2 + list_overhead(this.exported_names);
  11647. }
  11648. if (this.module_name) {
  11649. // "from "
  11650. size += 5;
  11651. }
  11652. return size;
  11653. };
  11654. AST_Call.prototype._size = function () {
  11655. if (this.optional) {
  11656. return 4 + list_overhead(this.args);
  11657. }
  11658. return 2 + list_overhead(this.args);
  11659. };
  11660. AST_New.prototype._size = function () {
  11661. return 6 + list_overhead(this.args);
  11662. };
  11663. AST_Sequence.prototype._size = function () {
  11664. return list_overhead(this.expressions);
  11665. };
  11666. AST_Dot.prototype._size = function () {
  11667. if (this.optional) {
  11668. return this.property.length + 2;
  11669. }
  11670. return this.property.length + 1;
  11671. };
  11672. AST_DotHash.prototype._size = function () {
  11673. if (this.optional) {
  11674. return this.property.length + 3;
  11675. }
  11676. return this.property.length + 2;
  11677. };
  11678. AST_Sub.prototype._size = function () {
  11679. return this.optional ? 4 : 2;
  11680. };
  11681. AST_Unary.prototype._size = function () {
  11682. if (this.operator === "typeof") return 7;
  11683. if (this.operator === "void") return 5;
  11684. return this.operator.length;
  11685. };
  11686. AST_Binary.prototype._size = function (info) {
  11687. if (this.operator === "in") return 4;
  11688. let size = this.operator.length;
  11689. if (
  11690. (this.operator === "+" || this.operator === "-")
  11691. && this.right instanceof AST_Unary && this.right.operator === this.operator
  11692. ) {
  11693. // 1+ +a > needs space between the +
  11694. size += 1;
  11695. }
  11696. if (this.needs_parens(info)) {
  11697. size += 2;
  11698. }
  11699. return size;
  11700. };
  11701. AST_Conditional.prototype._size = () => 3;
  11702. AST_Array.prototype._size = function () {
  11703. return 2 + list_overhead(this.elements);
  11704. };
  11705. AST_Object.prototype._size = function (info) {
  11706. let base = 2;
  11707. if (first_in_statement(info)) {
  11708. base += 2; // parens
  11709. }
  11710. return base + list_overhead(this.properties);
  11711. };
  11712. /*#__INLINE__*/
  11713. const key_size = key =>
  11714. typeof key === "string" ? key.length : 0;
  11715. AST_ObjectKeyVal.prototype._size = function () {
  11716. return key_size(this.key) + 1;
  11717. };
  11718. /*#__INLINE__*/
  11719. const static_size = is_static => is_static ? 7 : 0;
  11720. AST_ObjectGetter.prototype._size = function () {
  11721. return 5 + static_size(this.static) + key_size(this.key);
  11722. };
  11723. AST_ObjectSetter.prototype._size = function () {
  11724. return 5 + static_size(this.static) + key_size(this.key);
  11725. };
  11726. AST_ConciseMethod.prototype._size = function () {
  11727. return static_size(this.static) + key_size(this.key);
  11728. };
  11729. AST_PrivateMethod.prototype._size = function () {
  11730. return AST_ConciseMethod.prototype._size.call(this) + 1;
  11731. };
  11732. AST_PrivateGetter.prototype._size = function () {
  11733. return AST_ConciseMethod.prototype._size.call(this) + 4;
  11734. };
  11735. AST_PrivateSetter.prototype._size = function () {
  11736. return AST_ConciseMethod.prototype._size.call(this) + 4;
  11737. };
  11738. AST_PrivateIn.prototype._size = function () {
  11739. return 5; // "#", and " in "
  11740. };
  11741. AST_Class.prototype._size = function () {
  11742. return (
  11743. (this.name ? 8 : 7)
  11744. + (this.extends ? 8 : 0)
  11745. );
  11746. };
  11747. AST_ClassStaticBlock.prototype._size = function () {
  11748. // "static{}" + semicolons
  11749. return 8 + list_overhead(this.body);
  11750. };
  11751. AST_ClassProperty.prototype._size = function () {
  11752. return (
  11753. static_size(this.static)
  11754. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  11755. + (this.value ? 1 : 0)
  11756. );
  11757. };
  11758. AST_ClassPrivateProperty.prototype._size = function () {
  11759. return AST_ClassProperty.prototype._size.call(this) + 1;
  11760. };
  11761. AST_Symbol.prototype._size = function () {
  11762. if (!(mangle_options && this.thedef && !this.thedef.unmangleable(mangle_options))) {
  11763. return this.name.length;
  11764. } else {
  11765. return 1;
  11766. }
  11767. };
  11768. // TODO take propmangle into account
  11769. AST_SymbolClassProperty.prototype._size = function () {
  11770. return this.name.length;
  11771. };
  11772. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  11773. if (this.name === "arguments") return 9;
  11774. return AST_Symbol.prototype._size.call(this);
  11775. };
  11776. AST_NewTarget.prototype._size = () => 10;
  11777. AST_SymbolImportForeign.prototype._size = function () {
  11778. return this.name.length;
  11779. };
  11780. AST_SymbolExportForeign.prototype._size = function () {
  11781. return this.name.length;
  11782. };
  11783. AST_This.prototype._size = () => 4;
  11784. AST_Super.prototype._size = () => 5;
  11785. AST_String.prototype._size = function () {
  11786. return this.value.length + 2;
  11787. };
  11788. AST_Number.prototype._size = function () {
  11789. const { value } = this;
  11790. if (value === 0) return 1;
  11791. if (value > 0 && Math.floor(value) === value) {
  11792. return Math.floor(Math.log10(value) + 1);
  11793. }
  11794. return value.toString().length;
  11795. };
  11796. AST_BigInt.prototype._size = function () {
  11797. return this.value.length;
  11798. };
  11799. AST_RegExp.prototype._size = function () {
  11800. return this.value.toString().length;
  11801. };
  11802. AST_Null.prototype._size = () => 4;
  11803. AST_NaN.prototype._size = () => 3;
  11804. AST_Undefined.prototype._size = () => 6; // "void 0"
  11805. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  11806. AST_Infinity.prototype._size = () => 8;
  11807. AST_True.prototype._size = () => 4;
  11808. AST_False.prototype._size = () => 5;
  11809. AST_Await.prototype._size = () => 6;
  11810. AST_Yield.prototype._size = () => 6;
  11811. /***********************************************************************
  11812. A JavaScript tokenizer / parser / beautifier / compressor.
  11813. https://github.com/mishoo/UglifyJS2
  11814. -------------------------------- (C) ---------------------------------
  11815. Author: Mihai Bazon
  11816. <mihai.bazon@gmail.com>
  11817. http://mihai.bazon.net/blog
  11818. Distributed under the BSD license:
  11819. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11820. Redistribution and use in source and binary forms, with or without
  11821. modification, are permitted provided that the following conditions
  11822. are met:
  11823. * Redistributions of source code must retain the above
  11824. copyright notice, this list of conditions and the following
  11825. disclaimer.
  11826. * Redistributions in binary form must reproduce the above
  11827. copyright notice, this list of conditions and the following
  11828. disclaimer in the documentation and/or other materials
  11829. provided with the distribution.
  11830. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11831. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11832. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11833. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11834. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11835. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11836. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11837. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11838. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11839. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11840. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11841. SUCH DAMAGE.
  11842. ***********************************************************************/
  11843. // bitfield flags to be stored in node.flags.
  11844. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  11845. const UNUSED = 0b00000001;
  11846. const TRUTHY = 0b00000010;
  11847. const FALSY = 0b00000100;
  11848. const UNDEFINED = 0b00001000;
  11849. const INLINED = 0b00010000;
  11850. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  11851. const WRITE_ONLY = 0b00100000;
  11852. // information specific to a single compression pass
  11853. const SQUEEZED = 0b0000000100000000;
  11854. const OPTIMIZED = 0b0000001000000000;
  11855. const TOP = 0b0000010000000000;
  11856. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  11857. const has_flag = (node, flag) => node.flags & flag;
  11858. const set_flag = (node, flag) => { node.flags |= flag; };
  11859. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  11860. /***********************************************************************
  11861. A JavaScript tokenizer / parser / beautifier / compressor.
  11862. https://github.com/mishoo/UglifyJS2
  11863. -------------------------------- (C) ---------------------------------
  11864. Author: Mihai Bazon
  11865. <mihai.bazon@gmail.com>
  11866. http://mihai.bazon.net/blog
  11867. Distributed under the BSD license:
  11868. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11869. Redistribution and use in source and binary forms, with or without
  11870. modification, are permitted provided that the following conditions
  11871. are met:
  11872. * Redistributions of source code must retain the above
  11873. copyright notice, this list of conditions and the following
  11874. disclaimer.
  11875. * Redistributions in binary form must reproduce the above
  11876. copyright notice, this list of conditions and the following
  11877. disclaimer in the documentation and/or other materials
  11878. provided with the distribution.
  11879. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11880. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11881. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11882. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11883. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11884. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11885. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11886. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11887. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11888. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11889. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11890. SUCH DAMAGE.
  11891. ***********************************************************************/
  11892. function merge_sequence(array, node) {
  11893. if (node instanceof AST_Sequence) {
  11894. array.push(...node.expressions);
  11895. } else {
  11896. array.push(node);
  11897. }
  11898. return array;
  11899. }
  11900. function make_sequence(orig, expressions) {
  11901. if (expressions.length == 1) return expressions[0];
  11902. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  11903. return make_node(AST_Sequence, orig, {
  11904. expressions: expressions.reduce(merge_sequence, [])
  11905. });
  11906. }
  11907. function make_empty_function(self) {
  11908. return make_node(AST_Function, self, {
  11909. uses_arguments: false,
  11910. argnames: [],
  11911. body: [],
  11912. is_generator: false,
  11913. async: false,
  11914. variables: new Map(),
  11915. uses_with: false,
  11916. uses_eval: false,
  11917. parent_scope: null,
  11918. enclosed: [],
  11919. cname: 0,
  11920. block_scope: undefined,
  11921. });
  11922. }
  11923. function make_node_from_constant(val, orig) {
  11924. switch (typeof val) {
  11925. case "string":
  11926. return make_node(AST_String, orig, {
  11927. value: val
  11928. });
  11929. case "number":
  11930. if (isNaN(val)) return make_node(AST_NaN, orig);
  11931. if (isFinite(val)) {
  11932. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11933. operator: "-",
  11934. expression: make_node(AST_Number, orig, { value: -val })
  11935. }) : make_node(AST_Number, orig, { value: val });
  11936. }
  11937. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11938. operator: "-",
  11939. expression: make_node(AST_Infinity, orig)
  11940. }) : make_node(AST_Infinity, orig);
  11941. case "bigint":
  11942. return make_node(AST_BigInt, orig, { value: val.toString() });
  11943. case "boolean":
  11944. return make_node(val ? AST_True : AST_False, orig);
  11945. case "undefined":
  11946. return make_node(AST_Undefined, orig);
  11947. default:
  11948. if (val === null) {
  11949. return make_node(AST_Null, orig, { value: null });
  11950. }
  11951. if (val instanceof RegExp) {
  11952. return make_node(AST_RegExp, orig, {
  11953. value: {
  11954. source: regexp_source_fix(val.source),
  11955. flags: val.flags
  11956. }
  11957. });
  11958. }
  11959. throw new Error(string_template("Can't handle constant of type: {type}", {
  11960. type: typeof val
  11961. }));
  11962. }
  11963. }
  11964. function best_of_expression(ast1, ast2) {
  11965. return ast1.size() > ast2.size() ? ast2 : ast1;
  11966. }
  11967. function best_of_statement(ast1, ast2) {
  11968. return best_of_expression(
  11969. make_node(AST_SimpleStatement, ast1, {
  11970. body: ast1
  11971. }),
  11972. make_node(AST_SimpleStatement, ast2, {
  11973. body: ast2
  11974. })
  11975. ).body;
  11976. }
  11977. /** Find which node is smaller, and return that */
  11978. function best_of(compressor, ast1, ast2) {
  11979. if (first_in_statement(compressor)) {
  11980. return best_of_statement(ast1, ast2);
  11981. } else {
  11982. return best_of_expression(ast1, ast2);
  11983. }
  11984. }
  11985. /** Simplify an object property's key, if possible */
  11986. function get_simple_key(key) {
  11987. if (key instanceof AST_Constant) {
  11988. return key.getValue();
  11989. }
  11990. if (key instanceof AST_UnaryPrefix
  11991. && key.operator == "void"
  11992. && key.expression instanceof AST_Constant) {
  11993. return;
  11994. }
  11995. return key;
  11996. }
  11997. function read_property(obj, key) {
  11998. key = get_simple_key(key);
  11999. if (key instanceof AST_Node) return;
  12000. var value;
  12001. if (obj instanceof AST_Array) {
  12002. var elements = obj.elements;
  12003. if (key == "length") return make_node_from_constant(elements.length, obj);
  12004. if (typeof key == "number" && key in elements) value = elements[key];
  12005. } else if (obj instanceof AST_Object) {
  12006. key = "" + key;
  12007. var props = obj.properties;
  12008. for (var i = props.length; --i >= 0;) {
  12009. var prop = props[i];
  12010. if (!(prop instanceof AST_ObjectKeyVal)) return;
  12011. if (!value && props[i].key === key) value = props[i].value;
  12012. }
  12013. }
  12014. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  12015. }
  12016. function has_break_or_continue(loop, parent) {
  12017. var found = false;
  12018. var tw = new TreeWalker(function(node) {
  12019. if (found || node instanceof AST_Scope) return true;
  12020. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  12021. return found = true;
  12022. }
  12023. });
  12024. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  12025. tw.push(loop);
  12026. loop.body.walk(tw);
  12027. return found;
  12028. }
  12029. // we shouldn't compress (1,func)(something) to
  12030. // func(something) because that changes the meaning of
  12031. // the func (becomes lexical instead of global).
  12032. function maintain_this_binding(parent, orig, val) {
  12033. if (requires_sequence_to_maintain_binding(parent, orig, val)) {
  12034. const zero = make_node(AST_Number, orig, { value: 0 });
  12035. return make_sequence(orig, [ zero, val ]);
  12036. } else {
  12037. return val;
  12038. }
  12039. }
  12040. /** Detect (1, x.noThis)(), (0, eval)(), which need sequences */
  12041. function requires_sequence_to_maintain_binding(parent, orig, val) {
  12042. return (
  12043. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  12044. || parent instanceof AST_Call && parent.expression === orig
  12045. && (
  12046. val instanceof AST_Chain
  12047. || val instanceof AST_PropAccess
  12048. || val instanceof AST_SymbolRef && val.name == "eval"
  12049. )
  12050. );
  12051. }
  12052. function is_func_expr(node) {
  12053. return node instanceof AST_Arrow || node instanceof AST_Function;
  12054. }
  12055. /**
  12056. * Used to determine whether the node can benefit from negation.
  12057. * Not the case with arrow functions (you need an extra set of parens). */
  12058. function is_iife_call(node) {
  12059. if (node.TYPE != "Call") return false;
  12060. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  12061. }
  12062. function is_empty(thing) {
  12063. if (thing === null) return true;
  12064. if (thing instanceof AST_EmptyStatement) return true;
  12065. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  12066. return false;
  12067. }
  12068. const identifier_atom = makePredicate("Infinity NaN undefined");
  12069. function is_identifier_atom(node) {
  12070. return node instanceof AST_Infinity
  12071. || node instanceof AST_NaN
  12072. || node instanceof AST_Undefined;
  12073. }
  12074. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  12075. function is_ref_of(ref, type) {
  12076. if (!(ref instanceof AST_SymbolRef)) return false;
  12077. var orig = ref.definition().orig;
  12078. for (var i = orig.length; --i >= 0;) {
  12079. if (orig[i] instanceof type) return true;
  12080. }
  12081. }
  12082. /**Can we turn { block contents... } into just the block contents ?
  12083. * Not if one of these is inside.
  12084. **/
  12085. function can_be_evicted_from_block(node) {
  12086. return !(
  12087. node instanceof AST_DefClass ||
  12088. node instanceof AST_Defun ||
  12089. node instanceof AST_Let ||
  12090. node instanceof AST_Const ||
  12091. node instanceof AST_Export ||
  12092. node instanceof AST_Import
  12093. );
  12094. }
  12095. function as_statement_array(thing) {
  12096. if (thing === null) return [];
  12097. if (thing instanceof AST_BlockStatement) return thing.body;
  12098. if (thing instanceof AST_EmptyStatement) return [];
  12099. if (thing instanceof AST_Statement) return [ thing ];
  12100. throw new Error("Can't convert thing to statement array");
  12101. }
  12102. function is_reachable(scope_node, defs) {
  12103. const find_ref = node => {
  12104. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  12105. return walk_abort;
  12106. }
  12107. };
  12108. return walk_parent(scope_node, (node, info) => {
  12109. if (node instanceof AST_Scope && node !== scope_node) {
  12110. var parent = info.parent();
  12111. if (
  12112. parent instanceof AST_Call
  12113. && parent.expression === node
  12114. // Async/Generators aren't guaranteed to sync evaluate all of
  12115. // their body steps, so it's possible they close over the variable.
  12116. && !(node.async || node.is_generator)
  12117. ) {
  12118. return;
  12119. }
  12120. if (walk(node, find_ref)) return walk_abort;
  12121. return true;
  12122. }
  12123. });
  12124. }
  12125. /** Check if a ref refers to the name of a function/class it's defined within */
  12126. function is_recursive_ref(tw, def) {
  12127. var node;
  12128. for (var i = 0; node = tw.parent(i); i++) {
  12129. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  12130. var name = node.name;
  12131. if (name && name.definition() === def) {
  12132. return true;
  12133. }
  12134. }
  12135. }
  12136. return false;
  12137. }
  12138. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  12139. function retain_top_func(fn, compressor) {
  12140. return compressor.top_retain
  12141. && fn instanceof AST_Defun
  12142. && has_flag(fn, TOP)
  12143. && fn.name
  12144. && compressor.top_retain(fn.name.definition());
  12145. }
  12146. /***********************************************************************
  12147. A JavaScript tokenizer / parser / beautifier / compressor.
  12148. https://github.com/mishoo/UglifyJS2
  12149. -------------------------------- (C) ---------------------------------
  12150. Author: Mihai Bazon
  12151. <mihai.bazon@gmail.com>
  12152. http://mihai.bazon.net/blog
  12153. Distributed under the BSD license:
  12154. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12155. Redistribution and use in source and binary forms, with or without
  12156. modification, are permitted provided that the following conditions
  12157. are met:
  12158. * Redistributions of source code must retain the above
  12159. copyright notice, this list of conditions and the following
  12160. disclaimer.
  12161. * Redistributions in binary form must reproduce the above
  12162. copyright notice, this list of conditions and the following
  12163. disclaimer in the documentation and/or other materials
  12164. provided with the distribution.
  12165. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12166. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12167. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12168. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12169. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12170. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12171. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12172. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12173. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12174. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12175. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12176. SUCH DAMAGE.
  12177. ***********************************************************************/
  12178. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  12179. // Note: Lots of methods and functions are missing here, in case they aren't pure
  12180. // or not available in all JS environments.
  12181. function make_nested_lookup(obj) {
  12182. const out = new Map();
  12183. for (var key of Object.keys(obj)) {
  12184. out.set(key, makePredicate(obj[key]));
  12185. }
  12186. const does_have = (global_name, fname) => {
  12187. const inner_map = out.get(global_name);
  12188. return inner_map != null && inner_map.has(fname);
  12189. };
  12190. return does_have;
  12191. }
  12192. // Objects which are safe to access without throwing or causing a side effect.
  12193. // Usually we'd check the `unsafe` option first but these are way too common for that
  12194. const pure_prop_access_globals = new Set([
  12195. "Number",
  12196. "String",
  12197. "Array",
  12198. "Object",
  12199. "Function",
  12200. "Promise",
  12201. ]);
  12202. const object_methods = [
  12203. "constructor",
  12204. "toString",
  12205. "valueOf",
  12206. ];
  12207. const is_pure_native_method = make_nested_lookup({
  12208. Array: [
  12209. "at",
  12210. "flat",
  12211. "includes",
  12212. "indexOf",
  12213. "join",
  12214. "lastIndexOf",
  12215. "slice",
  12216. ...object_methods,
  12217. ],
  12218. Boolean: object_methods,
  12219. Function: object_methods,
  12220. Number: [
  12221. "toExponential",
  12222. "toFixed",
  12223. "toPrecision",
  12224. ...object_methods,
  12225. ],
  12226. Object: object_methods,
  12227. RegExp: [
  12228. "test",
  12229. ...object_methods,
  12230. ],
  12231. String: [
  12232. "at",
  12233. "charAt",
  12234. "charCodeAt",
  12235. "charPointAt",
  12236. "concat",
  12237. "endsWith",
  12238. "fromCharCode",
  12239. "fromCodePoint",
  12240. "includes",
  12241. "indexOf",
  12242. "italics",
  12243. "lastIndexOf",
  12244. "localeCompare",
  12245. "match",
  12246. "matchAll",
  12247. "normalize",
  12248. "padStart",
  12249. "padEnd",
  12250. "repeat",
  12251. "replace",
  12252. "replaceAll",
  12253. "search",
  12254. "slice",
  12255. "split",
  12256. "startsWith",
  12257. "substr",
  12258. "substring",
  12259. "repeat",
  12260. "toLocaleLowerCase",
  12261. "toLocaleUpperCase",
  12262. "toLowerCase",
  12263. "toUpperCase",
  12264. "trim",
  12265. "trimEnd",
  12266. "trimStart",
  12267. ...object_methods,
  12268. ],
  12269. });
  12270. const is_pure_native_fn = make_nested_lookup({
  12271. Array: [
  12272. "isArray",
  12273. ],
  12274. Math: [
  12275. "abs",
  12276. "acos",
  12277. "asin",
  12278. "atan",
  12279. "ceil",
  12280. "cos",
  12281. "exp",
  12282. "floor",
  12283. "log",
  12284. "round",
  12285. "sin",
  12286. "sqrt",
  12287. "tan",
  12288. "atan2",
  12289. "pow",
  12290. "max",
  12291. "min",
  12292. ],
  12293. Number: [
  12294. "isFinite",
  12295. "isNaN",
  12296. ],
  12297. Object: [
  12298. "create",
  12299. "getOwnPropertyDescriptor",
  12300. "getOwnPropertyNames",
  12301. "getPrototypeOf",
  12302. "isExtensible",
  12303. "isFrozen",
  12304. "isSealed",
  12305. "hasOwn",
  12306. "keys",
  12307. ],
  12308. String: [
  12309. "fromCharCode",
  12310. ],
  12311. });
  12312. // Known numeric values which come with JS environments
  12313. const is_pure_native_value = make_nested_lookup({
  12314. Math: [
  12315. "E",
  12316. "LN10",
  12317. "LN2",
  12318. "LOG2E",
  12319. "LOG10E",
  12320. "PI",
  12321. "SQRT1_2",
  12322. "SQRT2",
  12323. ],
  12324. Number: [
  12325. "MAX_VALUE",
  12326. "MIN_VALUE",
  12327. "NaN",
  12328. "NEGATIVE_INFINITY",
  12329. "POSITIVE_INFINITY",
  12330. ],
  12331. });
  12332. /***********************************************************************
  12333. A JavaScript tokenizer / parser / beautifier / compressor.
  12334. https://github.com/mishoo/UglifyJS2
  12335. -------------------------------- (C) ---------------------------------
  12336. Author: Mihai Bazon
  12337. <mihai.bazon@gmail.com>
  12338. http://mihai.bazon.net/blog
  12339. Distributed under the BSD license:
  12340. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12341. Redistribution and use in source and binary forms, with or without
  12342. modification, are permitted provided that the following conditions
  12343. are met:
  12344. * Redistributions of source code must retain the above
  12345. copyright notice, this list of conditions and the following
  12346. disclaimer.
  12347. * Redistributions in binary form must reproduce the above
  12348. copyright notice, this list of conditions and the following
  12349. disclaimer in the documentation and/or other materials
  12350. provided with the distribution.
  12351. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12352. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12353. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12354. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12355. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12356. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12357. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12358. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12359. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12360. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12361. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12362. SUCH DAMAGE.
  12363. ***********************************************************************/
  12364. // Functions and methods to infer certain facts about expressions
  12365. // It's not always possible to be 100% sure about something just by static analysis,
  12366. // so `true` means yes, and `false` means maybe
  12367. const is_undeclared_ref = (node) =>
  12368. node instanceof AST_SymbolRef && node.definition().undeclared;
  12369. const bitwise_binop = makePredicate("<<< >> << & | ^ ~");
  12370. const lazy_op = makePredicate("&& || ??");
  12371. const unary_side_effects = makePredicate("delete ++ --");
  12372. // methods to determine whether an expression has a boolean result type
  12373. (function(def_is_boolean) {
  12374. const unary_bool = makePredicate("! delete");
  12375. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  12376. def_is_boolean(AST_Node, return_false);
  12377. def_is_boolean(AST_UnaryPrefix, function() {
  12378. return unary_bool.has(this.operator);
  12379. });
  12380. def_is_boolean(AST_Binary, function() {
  12381. return binary_bool.has(this.operator)
  12382. || lazy_op.has(this.operator)
  12383. && this.left.is_boolean()
  12384. && this.right.is_boolean();
  12385. });
  12386. def_is_boolean(AST_Conditional, function() {
  12387. return this.consequent.is_boolean() && this.alternative.is_boolean();
  12388. });
  12389. def_is_boolean(AST_Assign, function() {
  12390. return this.operator == "=" && this.right.is_boolean();
  12391. });
  12392. def_is_boolean(AST_Sequence, function() {
  12393. return this.tail_node().is_boolean();
  12394. });
  12395. def_is_boolean(AST_True, return_true);
  12396. def_is_boolean(AST_False, return_true);
  12397. })(function(node, func) {
  12398. node.DEFMETHOD("is_boolean", func);
  12399. });
  12400. // methods to determine if an expression has a numeric result type
  12401. (function(def_is_number) {
  12402. def_is_number(AST_Node, return_false);
  12403. def_is_number(AST_Number, return_true);
  12404. const unary = makePredicate("+ - ~ ++ --");
  12405. def_is_number(AST_Unary, function(compressor) {
  12406. return unary.has(this.operator) && this.expression.is_number(compressor);
  12407. });
  12408. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  12409. def_is_number(AST_Binary, function(compressor) {
  12410. if (this.operator === "+") {
  12411. // Both sides need to be `number`. Or one is a `number` and the other is number-ish.
  12412. return this.left.is_number(compressor) && this.right.is_number_or_bigint(compressor)
  12413. || this.right.is_number(compressor) && this.left.is_number_or_bigint(compressor);
  12414. } else if (numeric_ops.has(this.operator)) {
  12415. return this.left.is_number(compressor) || this.right.is_number(compressor);
  12416. } else {
  12417. return false;
  12418. }
  12419. });
  12420. def_is_number(AST_Assign, function(compressor) {
  12421. return (this.operator === "=" || numeric_ops.has(this.operator.slice(0, -1)))
  12422. && this.right.is_number(compressor);
  12423. });
  12424. def_is_number(AST_Sequence, function(compressor) {
  12425. return this.tail_node().is_number(compressor);
  12426. });
  12427. def_is_number(AST_Conditional, function(compressor) {
  12428. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  12429. });
  12430. })(function(node, func) {
  12431. node.DEFMETHOD("is_number", func);
  12432. });
  12433. // methods to determine if an expression returns a BigInt
  12434. (function(def_is_bigint) {
  12435. def_is_bigint(AST_Node, return_false);
  12436. def_is_bigint(AST_BigInt, return_true);
  12437. const unary = makePredicate("+ - ~ ++ --");
  12438. def_is_bigint(AST_Unary, function(compressor) {
  12439. return unary.has(this.operator) && this.expression.is_bigint(compressor);
  12440. });
  12441. const numeric_ops = makePredicate("- * / % & | ^ << >>");
  12442. def_is_bigint(AST_Binary, function(compressor) {
  12443. if (this.operator === "+") {
  12444. return this.left.is_bigint(compressor) && this.right.is_number_or_bigint(compressor)
  12445. || this.right.is_bigint(compressor) && this.left.is_number_or_bigint(compressor);
  12446. } else if (numeric_ops.has(this.operator)) {
  12447. return this.left.is_bigint(compressor) || this.right.is_bigint(compressor);
  12448. } else {
  12449. return false;
  12450. }
  12451. });
  12452. def_is_bigint(AST_Assign, function(compressor) {
  12453. return (numeric_ops.has(this.operator.slice(0, -1)) || this.operator == "=")
  12454. && this.right.is_bigint(compressor);
  12455. });
  12456. def_is_bigint(AST_Sequence, function(compressor) {
  12457. return this.tail_node().is_bigint(compressor);
  12458. });
  12459. def_is_bigint(AST_Conditional, function(compressor) {
  12460. return this.consequent.is_bigint(compressor) && this.alternative.is_bigint(compressor);
  12461. });
  12462. })(function(node, func) {
  12463. node.DEFMETHOD("is_bigint", func);
  12464. });
  12465. // methods to determine if an expression is a number or a bigint
  12466. (function(def_is_number_or_bigint) {
  12467. def_is_number_or_bigint(AST_Node, return_false);
  12468. def_is_number_or_bigint(AST_Number, return_true);
  12469. def_is_number_or_bigint(AST_BigInt, return_true);
  12470. const numeric_unary_ops = makePredicate("+ - ~ ++ --");
  12471. def_is_number_or_bigint(AST_Unary, function(_compressor) {
  12472. return numeric_unary_ops.has(this.operator);
  12473. });
  12474. const numeric_ops = makePredicate("- * / % & | ^ << >>");
  12475. def_is_number_or_bigint(AST_Binary, function(compressor) {
  12476. return this.operator === "+"
  12477. ? this.left.is_number_or_bigint(compressor) && this.right.is_number_or_bigint(compressor)
  12478. : numeric_ops.has(this.operator);
  12479. });
  12480. def_is_number_or_bigint(AST_Assign, function(compressor) {
  12481. return numeric_ops.has(this.operator.slice(0, -1))
  12482. || this.operator == "=" && this.right.is_number_or_bigint(compressor);
  12483. });
  12484. def_is_number_or_bigint(AST_Sequence, function(compressor) {
  12485. return this.tail_node().is_number_or_bigint(compressor);
  12486. });
  12487. def_is_number_or_bigint(AST_Conditional, function(compressor) {
  12488. return this.consequent.is_number_or_bigint(compressor) && this.alternative.is_number_or_bigint(compressor);
  12489. });
  12490. }(function (node, func) {
  12491. node.DEFMETHOD("is_number_or_bigint", func);
  12492. }));
  12493. // 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
  12494. (function(def_is_32_bit_integer) {
  12495. def_is_32_bit_integer(AST_Node, return_false);
  12496. def_is_32_bit_integer(AST_Number, function(_compressor) {
  12497. return this.value === (this.value | 0);
  12498. });
  12499. def_is_32_bit_integer(AST_UnaryPrefix, function(compressor) {
  12500. return this.operator == "~" ? this.expression.is_number(compressor)
  12501. : this.operator === "+" ? this.expression.is_32_bit_integer(compressor)
  12502. : false;
  12503. });
  12504. def_is_32_bit_integer(AST_Binary, function(compressor) {
  12505. return bitwise_binop.has(this.operator)
  12506. && (this.left.is_number(compressor) || this.right.is_number(compressor));
  12507. });
  12508. }(function (node, func) {
  12509. node.DEFMETHOD("is_32_bit_integer", func);
  12510. }));
  12511. // methods to determine if an expression has a string result type
  12512. (function(def_is_string) {
  12513. def_is_string(AST_Node, return_false);
  12514. def_is_string(AST_String, return_true);
  12515. def_is_string(AST_TemplateString, return_true);
  12516. def_is_string(AST_UnaryPrefix, function() {
  12517. return this.operator == "typeof";
  12518. });
  12519. def_is_string(AST_Binary, function(compressor) {
  12520. return this.operator == "+" &&
  12521. (this.left.is_string(compressor) || this.right.is_string(compressor));
  12522. });
  12523. def_is_string(AST_Assign, function(compressor) {
  12524. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  12525. });
  12526. def_is_string(AST_Sequence, function(compressor) {
  12527. return this.tail_node().is_string(compressor);
  12528. });
  12529. def_is_string(AST_Conditional, function(compressor) {
  12530. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  12531. });
  12532. })(function(node, func) {
  12533. node.DEFMETHOD("is_string", func);
  12534. });
  12535. function is_undefined(node, compressor) {
  12536. return (
  12537. has_flag(node, UNDEFINED)
  12538. || node instanceof AST_Undefined
  12539. || node instanceof AST_UnaryPrefix
  12540. && node.operator == "void"
  12541. && !node.expression.has_side_effects(compressor)
  12542. );
  12543. }
  12544. // Is the node explicitly null or undefined.
  12545. function is_null_or_undefined(node, compressor) {
  12546. let fixed;
  12547. return (
  12548. node instanceof AST_Null
  12549. || is_undefined(node, compressor)
  12550. || (
  12551. node instanceof AST_SymbolRef
  12552. && (fixed = node.definition().fixed) instanceof AST_Node
  12553. && is_nullish(fixed, compressor)
  12554. )
  12555. );
  12556. }
  12557. // Find out if this expression is optionally chained from a base-point that we
  12558. // can statically analyze as null or undefined.
  12559. function is_nullish_shortcircuited(node, compressor) {
  12560. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  12561. return (
  12562. (node.optional && is_null_or_undefined(node.expression, compressor))
  12563. || is_nullish_shortcircuited(node.expression, compressor)
  12564. );
  12565. }
  12566. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  12567. return false;
  12568. }
  12569. // Find out if something is == null, or can short circuit into nullish.
  12570. // Used to optimize ?. and ??
  12571. function is_nullish(node, compressor) {
  12572. if (is_null_or_undefined(node, compressor)) return true;
  12573. return is_nullish_shortcircuited(node, compressor);
  12574. }
  12575. // Determine if expression might cause side effects
  12576. // If there's a possibility that a node may change something when it's executed, this returns true
  12577. (function(def_has_side_effects) {
  12578. def_has_side_effects(AST_Node, return_true);
  12579. def_has_side_effects(AST_EmptyStatement, return_false);
  12580. def_has_side_effects(AST_Constant, return_false);
  12581. def_has_side_effects(AST_This, return_false);
  12582. function any(list, compressor) {
  12583. for (var i = list.length; --i >= 0;)
  12584. if (list[i].has_side_effects(compressor))
  12585. return true;
  12586. return false;
  12587. }
  12588. def_has_side_effects(AST_Block, function(compressor) {
  12589. return any(this.body, compressor);
  12590. });
  12591. def_has_side_effects(AST_Call, function(compressor) {
  12592. if (
  12593. !this.is_callee_pure(compressor)
  12594. && (!this.expression.is_call_pure(compressor)
  12595. || this.expression.has_side_effects(compressor))
  12596. ) {
  12597. return true;
  12598. }
  12599. return any(this.args, compressor);
  12600. });
  12601. def_has_side_effects(AST_Switch, function(compressor) {
  12602. return this.expression.has_side_effects(compressor)
  12603. || any(this.body, compressor);
  12604. });
  12605. def_has_side_effects(AST_Case, function(compressor) {
  12606. return this.expression.has_side_effects(compressor)
  12607. || any(this.body, compressor);
  12608. });
  12609. def_has_side_effects(AST_Try, function(compressor) {
  12610. return this.body.has_side_effects(compressor)
  12611. || this.bcatch && this.bcatch.has_side_effects(compressor)
  12612. || this.bfinally && this.bfinally.has_side_effects(compressor);
  12613. });
  12614. def_has_side_effects(AST_If, function(compressor) {
  12615. return this.condition.has_side_effects(compressor)
  12616. || this.body && this.body.has_side_effects(compressor)
  12617. || this.alternative && this.alternative.has_side_effects(compressor);
  12618. });
  12619. def_has_side_effects(AST_ImportMeta, return_false);
  12620. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  12621. return this.body.has_side_effects(compressor);
  12622. });
  12623. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  12624. return this.body.has_side_effects(compressor);
  12625. });
  12626. def_has_side_effects(AST_Lambda, return_false);
  12627. def_has_side_effects(AST_Class, function (compressor) {
  12628. if (this.extends && this.extends.has_side_effects(compressor)) {
  12629. return true;
  12630. }
  12631. return any(this.properties, compressor);
  12632. });
  12633. def_has_side_effects(AST_ClassStaticBlock, function(compressor) {
  12634. return any(this.body, compressor);
  12635. });
  12636. def_has_side_effects(AST_Binary, function(compressor) {
  12637. return this.left.has_side_effects(compressor)
  12638. || this.right.has_side_effects(compressor);
  12639. });
  12640. def_has_side_effects(AST_Assign, return_true);
  12641. def_has_side_effects(AST_Conditional, function(compressor) {
  12642. return this.condition.has_side_effects(compressor)
  12643. || this.consequent.has_side_effects(compressor)
  12644. || this.alternative.has_side_effects(compressor);
  12645. });
  12646. def_has_side_effects(AST_Unary, function(compressor) {
  12647. return unary_side_effects.has(this.operator)
  12648. || this.expression.has_side_effects(compressor);
  12649. });
  12650. def_has_side_effects(AST_SymbolRef, function(compressor) {
  12651. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12652. });
  12653. def_has_side_effects(AST_SymbolClassProperty, return_false);
  12654. def_has_side_effects(AST_SymbolDeclaration, return_false);
  12655. def_has_side_effects(AST_Object, function(compressor) {
  12656. return any(this.properties, compressor);
  12657. });
  12658. def_has_side_effects(AST_ObjectKeyVal, function(compressor) {
  12659. return (
  12660. this.computed_key() && this.key.has_side_effects(compressor)
  12661. || this.value && this.value.has_side_effects(compressor)
  12662. );
  12663. });
  12664. def_has_side_effects([
  12665. AST_ClassProperty,
  12666. AST_ClassPrivateProperty,
  12667. ], function(compressor) {
  12668. return (
  12669. this.computed_key() && this.key.has_side_effects(compressor)
  12670. || this.static && this.value && this.value.has_side_effects(compressor)
  12671. );
  12672. });
  12673. def_has_side_effects([
  12674. AST_PrivateMethod,
  12675. AST_PrivateGetter,
  12676. AST_PrivateSetter,
  12677. AST_ConciseMethod,
  12678. AST_ObjectGetter,
  12679. AST_ObjectSetter,
  12680. ], function(compressor) {
  12681. return this.computed_key() && this.key.has_side_effects(compressor);
  12682. });
  12683. def_has_side_effects(AST_Array, function(compressor) {
  12684. return any(this.elements, compressor);
  12685. });
  12686. def_has_side_effects(AST_Dot, function(compressor) {
  12687. if (is_nullish(this, compressor)) {
  12688. return this.expression.has_side_effects(compressor);
  12689. }
  12690. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  12691. return true;
  12692. }
  12693. return this.expression.has_side_effects(compressor);
  12694. });
  12695. def_has_side_effects(AST_Sub, function(compressor) {
  12696. if (is_nullish(this, compressor)) {
  12697. return this.expression.has_side_effects(compressor);
  12698. }
  12699. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  12700. return true;
  12701. }
  12702. var property = this.property.has_side_effects(compressor);
  12703. if (property && this.optional) return true; // "?." is a condition
  12704. return property || this.expression.has_side_effects(compressor);
  12705. });
  12706. def_has_side_effects(AST_Chain, function (compressor) {
  12707. return this.expression.has_side_effects(compressor);
  12708. });
  12709. def_has_side_effects(AST_Sequence, function(compressor) {
  12710. return any(this.expressions, compressor);
  12711. });
  12712. def_has_side_effects(AST_Definitions, function(compressor) {
  12713. return any(this.definitions, compressor);
  12714. });
  12715. def_has_side_effects(AST_VarDef, function() {
  12716. return this.value != null;
  12717. });
  12718. def_has_side_effects(AST_TemplateSegment, return_false);
  12719. def_has_side_effects(AST_TemplateString, function(compressor) {
  12720. return any(this.segments, compressor);
  12721. });
  12722. })(function(node_or_nodes, func) {
  12723. for (const node of [].concat(node_or_nodes)) {
  12724. node.DEFMETHOD("has_side_effects", func);
  12725. }
  12726. });
  12727. // determine if expression may throw
  12728. (function(def_may_throw) {
  12729. def_may_throw(AST_Node, return_true);
  12730. def_may_throw(AST_Constant, return_false);
  12731. def_may_throw(AST_EmptyStatement, return_false);
  12732. def_may_throw(AST_Lambda, return_false);
  12733. def_may_throw(AST_SymbolDeclaration, return_false);
  12734. def_may_throw(AST_This, return_false);
  12735. def_may_throw(AST_ImportMeta, return_false);
  12736. function any(list, compressor) {
  12737. for (var i = list.length; --i >= 0;)
  12738. if (list[i].may_throw(compressor))
  12739. return true;
  12740. return false;
  12741. }
  12742. def_may_throw(AST_Class, function(compressor) {
  12743. if (this.extends && this.extends.may_throw(compressor)) return true;
  12744. return any(this.properties, compressor);
  12745. });
  12746. def_may_throw(AST_ClassStaticBlock, function (compressor) {
  12747. return any(this.body, compressor);
  12748. });
  12749. def_may_throw(AST_Array, function(compressor) {
  12750. return any(this.elements, compressor);
  12751. });
  12752. def_may_throw(AST_Assign, function(compressor) {
  12753. if (this.right.may_throw(compressor)) return true;
  12754. if (!compressor.has_directive("use strict")
  12755. && this.operator == "="
  12756. && this.left instanceof AST_SymbolRef) {
  12757. return false;
  12758. }
  12759. return this.left.may_throw(compressor);
  12760. });
  12761. def_may_throw(AST_Binary, function(compressor) {
  12762. return this.left.may_throw(compressor)
  12763. || this.right.may_throw(compressor);
  12764. });
  12765. def_may_throw(AST_Block, function(compressor) {
  12766. return any(this.body, compressor);
  12767. });
  12768. def_may_throw(AST_Call, function(compressor) {
  12769. if (is_nullish(this, compressor)) return false;
  12770. if (any(this.args, compressor)) return true;
  12771. if (this.is_callee_pure(compressor)) return false;
  12772. if (this.expression.may_throw(compressor)) return true;
  12773. return !(this.expression instanceof AST_Lambda)
  12774. || any(this.expression.body, compressor);
  12775. });
  12776. def_may_throw(AST_Case, function(compressor) {
  12777. return this.expression.may_throw(compressor)
  12778. || any(this.body, compressor);
  12779. });
  12780. def_may_throw(AST_Conditional, function(compressor) {
  12781. return this.condition.may_throw(compressor)
  12782. || this.consequent.may_throw(compressor)
  12783. || this.alternative.may_throw(compressor);
  12784. });
  12785. def_may_throw(AST_Definitions, function(compressor) {
  12786. return any(this.definitions, compressor);
  12787. });
  12788. def_may_throw(AST_If, function(compressor) {
  12789. return this.condition.may_throw(compressor)
  12790. || this.body && this.body.may_throw(compressor)
  12791. || this.alternative && this.alternative.may_throw(compressor);
  12792. });
  12793. def_may_throw(AST_LabeledStatement, function(compressor) {
  12794. return this.body.may_throw(compressor);
  12795. });
  12796. def_may_throw(AST_Object, function(compressor) {
  12797. return any(this.properties, compressor);
  12798. });
  12799. def_may_throw(AST_ObjectKeyVal, function(compressor) {
  12800. return (
  12801. this.computed_key() && this.key.may_throw(compressor)
  12802. || this.value ? this.value.may_throw(compressor) : false
  12803. );
  12804. });
  12805. def_may_throw([
  12806. AST_ClassProperty,
  12807. AST_ClassPrivateProperty,
  12808. ], function(compressor) {
  12809. return (
  12810. this.computed_key() && this.key.may_throw(compressor)
  12811. || this.static && this.value && this.value.may_throw(compressor)
  12812. );
  12813. });
  12814. def_may_throw([
  12815. AST_ConciseMethod,
  12816. AST_ObjectGetter,
  12817. AST_ObjectSetter,
  12818. ], function(compressor) {
  12819. return this.computed_key() && this.key.may_throw(compressor);
  12820. });
  12821. def_may_throw([
  12822. AST_PrivateMethod,
  12823. AST_PrivateGetter,
  12824. AST_PrivateSetter,
  12825. ], return_false);
  12826. def_may_throw(AST_Return, function(compressor) {
  12827. return this.value && this.value.may_throw(compressor);
  12828. });
  12829. def_may_throw(AST_Sequence, function(compressor) {
  12830. return any(this.expressions, compressor);
  12831. });
  12832. def_may_throw(AST_SimpleStatement, function(compressor) {
  12833. return this.body.may_throw(compressor);
  12834. });
  12835. def_may_throw(AST_Dot, function(compressor) {
  12836. if (is_nullish(this, compressor)) return false;
  12837. return !this.optional && this.expression.may_throw_on_access(compressor)
  12838. || this.expression.may_throw(compressor);
  12839. });
  12840. def_may_throw(AST_Sub, function(compressor) {
  12841. if (is_nullish(this, compressor)) return false;
  12842. return !this.optional && this.expression.may_throw_on_access(compressor)
  12843. || this.expression.may_throw(compressor)
  12844. || this.property.may_throw(compressor);
  12845. });
  12846. def_may_throw(AST_Chain, function(compressor) {
  12847. return this.expression.may_throw(compressor);
  12848. });
  12849. def_may_throw(AST_Switch, function(compressor) {
  12850. return this.expression.may_throw(compressor)
  12851. || any(this.body, compressor);
  12852. });
  12853. def_may_throw(AST_SymbolRef, function(compressor) {
  12854. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12855. });
  12856. def_may_throw(AST_SymbolClassProperty, return_false);
  12857. def_may_throw(AST_Try, function(compressor) {
  12858. return this.bcatch ? this.bcatch.may_throw(compressor) : this.body.may_throw(compressor)
  12859. || this.bfinally && this.bfinally.may_throw(compressor);
  12860. });
  12861. def_may_throw(AST_Unary, function(compressor) {
  12862. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12863. return false;
  12864. return this.expression.may_throw(compressor);
  12865. });
  12866. def_may_throw(AST_VarDef, function(compressor) {
  12867. if (!this.value) return false;
  12868. return this.value.may_throw(compressor);
  12869. });
  12870. })(function(node_or_nodes, func) {
  12871. for (const node of [].concat(node_or_nodes)) {
  12872. node.DEFMETHOD("may_throw", func);
  12873. }
  12874. });
  12875. // determine if expression is constant
  12876. (function(def_is_constant_expression) {
  12877. function all_refs_local(scope) {
  12878. let result = true;
  12879. walk(this, node => {
  12880. if (node instanceof AST_SymbolRef) {
  12881. if (has_flag(this, INLINED)) {
  12882. result = false;
  12883. return walk_abort;
  12884. }
  12885. var def = node.definition();
  12886. if (
  12887. member(def, this.enclosed)
  12888. && !this.variables.has(def.name)
  12889. ) {
  12890. if (scope) {
  12891. var scope_def = scope.find_variable(node);
  12892. if (def.undeclared ? !scope_def : scope_def === def) {
  12893. result = "f";
  12894. return true;
  12895. }
  12896. }
  12897. result = false;
  12898. return walk_abort;
  12899. }
  12900. return true;
  12901. }
  12902. if (node instanceof AST_This && this instanceof AST_Arrow) {
  12903. result = false;
  12904. return walk_abort;
  12905. }
  12906. });
  12907. return result;
  12908. }
  12909. def_is_constant_expression(AST_Node, return_false);
  12910. def_is_constant_expression(AST_Constant, return_true);
  12911. def_is_constant_expression(AST_Class, function(scope) {
  12912. if (this.extends && !this.extends.is_constant_expression(scope)) {
  12913. return false;
  12914. }
  12915. for (const prop of this.properties) {
  12916. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  12917. return false;
  12918. }
  12919. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  12920. return false;
  12921. }
  12922. if (prop instanceof AST_ClassStaticBlock) {
  12923. return false;
  12924. }
  12925. }
  12926. return all_refs_local.call(this, scope);
  12927. });
  12928. def_is_constant_expression(AST_Lambda, all_refs_local);
  12929. def_is_constant_expression(AST_Unary, function() {
  12930. return this.expression.is_constant_expression();
  12931. });
  12932. def_is_constant_expression(AST_Binary, function() {
  12933. return this.left.is_constant_expression()
  12934. && this.right.is_constant_expression();
  12935. });
  12936. def_is_constant_expression(AST_Array, function() {
  12937. return this.elements.every((l) => l.is_constant_expression());
  12938. });
  12939. def_is_constant_expression(AST_Object, function() {
  12940. return this.properties.every((l) => l.is_constant_expression());
  12941. });
  12942. def_is_constant_expression(AST_ObjectProperty, function() {
  12943. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  12944. });
  12945. })(function(node, func) {
  12946. node.DEFMETHOD("is_constant_expression", func);
  12947. });
  12948. // may_throw_on_access()
  12949. // returns true if this node may be null, undefined or contain `AST_Accessor`
  12950. (function(def_may_throw_on_access) {
  12951. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  12952. return !compressor.option("pure_getters")
  12953. || this._dot_throw(compressor);
  12954. });
  12955. function is_strict(compressor) {
  12956. return /strict/.test(compressor.option("pure_getters"));
  12957. }
  12958. def_may_throw_on_access(AST_Node, is_strict);
  12959. def_may_throw_on_access(AST_Null, return_true);
  12960. def_may_throw_on_access(AST_Undefined, return_true);
  12961. def_may_throw_on_access(AST_Constant, return_false);
  12962. def_may_throw_on_access(AST_Array, return_false);
  12963. def_may_throw_on_access(AST_Object, function(compressor) {
  12964. if (!is_strict(compressor)) return false;
  12965. for (var i = this.properties.length; --i >=0;)
  12966. if (this.properties[i]._dot_throw(compressor)) return true;
  12967. return false;
  12968. });
  12969. // Do not be as strict with classes as we are with objects.
  12970. // Hopefully the community is not going to abuse static getters and setters.
  12971. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  12972. def_may_throw_on_access(AST_Class, return_false);
  12973. def_may_throw_on_access(AST_ObjectProperty, return_false);
  12974. def_may_throw_on_access(AST_ObjectGetter, return_true);
  12975. def_may_throw_on_access(AST_Expansion, function(compressor) {
  12976. return this.expression._dot_throw(compressor);
  12977. });
  12978. def_may_throw_on_access(AST_Function, return_false);
  12979. def_may_throw_on_access(AST_Arrow, return_false);
  12980. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  12981. def_may_throw_on_access(AST_UnaryPrefix, function() {
  12982. return this.operator == "void";
  12983. });
  12984. def_may_throw_on_access(AST_Binary, function(compressor) {
  12985. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  12986. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  12987. });
  12988. def_may_throw_on_access(AST_Assign, function(compressor) {
  12989. if (this.logical) return true;
  12990. return this.operator == "="
  12991. && this.right._dot_throw(compressor);
  12992. });
  12993. def_may_throw_on_access(AST_Conditional, function(compressor) {
  12994. return this.consequent._dot_throw(compressor)
  12995. || this.alternative._dot_throw(compressor);
  12996. });
  12997. def_may_throw_on_access(AST_Dot, function(compressor) {
  12998. if (!is_strict(compressor)) return false;
  12999. if (this.property == "prototype") {
  13000. return !(
  13001. this.expression instanceof AST_Function
  13002. || this.expression instanceof AST_Class
  13003. );
  13004. }
  13005. return true;
  13006. });
  13007. def_may_throw_on_access(AST_Chain, function(compressor) {
  13008. return this.expression._dot_throw(compressor);
  13009. });
  13010. def_may_throw_on_access(AST_Sequence, function(compressor) {
  13011. return this.tail_node()._dot_throw(compressor);
  13012. });
  13013. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  13014. if (this.name === "arguments" && this.scope instanceof AST_Lambda) return false;
  13015. if (has_flag(this, UNDEFINED)) return true;
  13016. if (!is_strict(compressor)) return false;
  13017. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  13018. if (this.is_immutable()) return false;
  13019. var fixed = this.fixed_value();
  13020. return !fixed || fixed._dot_throw(compressor);
  13021. });
  13022. })(function(node, func) {
  13023. node.DEFMETHOD("_dot_throw", func);
  13024. });
  13025. function is_lhs(node, parent) {
  13026. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  13027. if (parent instanceof AST_Assign && parent.left === node) return node;
  13028. if (parent instanceof AST_ForIn && parent.init === node) return node;
  13029. }
  13030. // method to negate an expression
  13031. (function(def_negate) {
  13032. function basic_negation(exp) {
  13033. return make_node(AST_UnaryPrefix, exp, {
  13034. operator: "!",
  13035. expression: exp
  13036. });
  13037. }
  13038. function best(orig, alt, first_in_statement) {
  13039. var negated = basic_negation(orig);
  13040. if (first_in_statement) {
  13041. var stat = make_node(AST_SimpleStatement, alt, {
  13042. body: alt
  13043. });
  13044. return best_of_expression(negated, stat) === stat ? alt : negated;
  13045. }
  13046. return best_of_expression(negated, alt);
  13047. }
  13048. def_negate(AST_Node, function() {
  13049. return basic_negation(this);
  13050. });
  13051. def_negate(AST_Statement, function() {
  13052. throw new Error("Cannot negate a statement");
  13053. });
  13054. def_negate(AST_Function, function() {
  13055. return basic_negation(this);
  13056. });
  13057. def_negate(AST_Class, function() {
  13058. return basic_negation(this);
  13059. });
  13060. def_negate(AST_Arrow, function() {
  13061. return basic_negation(this);
  13062. });
  13063. def_negate(AST_UnaryPrefix, function() {
  13064. if (this.operator == "!")
  13065. return this.expression;
  13066. return basic_negation(this);
  13067. });
  13068. def_negate(AST_Sequence, function(compressor) {
  13069. var expressions = this.expressions.slice();
  13070. expressions.push(expressions.pop().negate(compressor));
  13071. return make_sequence(this, expressions);
  13072. });
  13073. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  13074. var self = this.clone();
  13075. self.consequent = self.consequent.negate(compressor);
  13076. self.alternative = self.alternative.negate(compressor);
  13077. return best(this, self, first_in_statement);
  13078. });
  13079. def_negate(AST_Binary, function(compressor, first_in_statement) {
  13080. var self = this.clone(), op = this.operator;
  13081. if (compressor.option("unsafe_comps")) {
  13082. switch (op) {
  13083. case "<=" : self.operator = ">" ; return self;
  13084. case "<" : self.operator = ">=" ; return self;
  13085. case ">=" : self.operator = "<" ; return self;
  13086. case ">" : self.operator = "<=" ; return self;
  13087. }
  13088. }
  13089. switch (op) {
  13090. case "==" : self.operator = "!="; return self;
  13091. case "!=" : self.operator = "=="; return self;
  13092. case "===": self.operator = "!=="; return self;
  13093. case "!==": self.operator = "==="; return self;
  13094. case "&&":
  13095. self.operator = "||";
  13096. self.left = self.left.negate(compressor, first_in_statement);
  13097. self.right = self.right.negate(compressor);
  13098. return best(this, self, first_in_statement);
  13099. case "||":
  13100. self.operator = "&&";
  13101. self.left = self.left.negate(compressor, first_in_statement);
  13102. self.right = self.right.negate(compressor);
  13103. return best(this, self, first_in_statement);
  13104. }
  13105. return basic_negation(this);
  13106. });
  13107. })(function(node, func) {
  13108. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  13109. return func.call(this, compressor, first_in_statement);
  13110. });
  13111. });
  13112. (function (def_bitwise_negate) {
  13113. function basic_bitwise_negation(exp) {
  13114. return make_node(AST_UnaryPrefix, exp, {
  13115. operator: "~",
  13116. expression: exp
  13117. });
  13118. }
  13119. def_bitwise_negate(AST_Node, function(_compressor) {
  13120. return basic_bitwise_negation(this);
  13121. });
  13122. def_bitwise_negate(AST_Number, function(_compressor) {
  13123. const neg = ~this.value;
  13124. if (neg.toString().length > this.value.toString().length) {
  13125. return basic_bitwise_negation(this);
  13126. }
  13127. return make_node(AST_Number, this, { value: neg });
  13128. });
  13129. def_bitwise_negate(AST_UnaryPrefix, function(compressor, in_32_bit_context) {
  13130. if (
  13131. this.operator == "~"
  13132. && (
  13133. this.expression.is_32_bit_integer(compressor) ||
  13134. (in_32_bit_context != null ? in_32_bit_context : compressor.in_32_bit_context())
  13135. )
  13136. ) {
  13137. return this.expression;
  13138. } else {
  13139. return basic_bitwise_negation(this);
  13140. }
  13141. });
  13142. })(function (node, func) {
  13143. node.DEFMETHOD("bitwise_negate", func);
  13144. });
  13145. // Is the callee of this function pure?
  13146. 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");
  13147. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  13148. if (compressor.option("unsafe")) {
  13149. var expr = this.expression;
  13150. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  13151. if (
  13152. expr.expression && expr.expression.name === "hasOwnProperty" &&
  13153. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  13154. ) {
  13155. return false;
  13156. }
  13157. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  13158. if (
  13159. expr instanceof AST_Dot
  13160. && is_undeclared_ref(expr.expression)
  13161. && is_pure_native_fn(expr.expression.name, expr.property)
  13162. ) {
  13163. return true;
  13164. }
  13165. }
  13166. if ((this instanceof AST_New) && compressor.option("pure_new")) {
  13167. return true;
  13168. }
  13169. if (compressor.option("side_effects") && has_annotation(this, _PURE)) {
  13170. return true;
  13171. }
  13172. return !compressor.pure_funcs(this);
  13173. });
  13174. // If I call this, is it a pure function?
  13175. AST_Node.DEFMETHOD("is_call_pure", return_false);
  13176. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  13177. if (!compressor.option("unsafe")) return;
  13178. const expr = this.expression;
  13179. let native_obj;
  13180. if (expr instanceof AST_Array) {
  13181. native_obj = "Array";
  13182. } else if (expr.is_boolean()) {
  13183. native_obj = "Boolean";
  13184. } else if (expr.is_number(compressor)) {
  13185. native_obj = "Number";
  13186. } else if (expr instanceof AST_RegExp) {
  13187. native_obj = "RegExp";
  13188. } else if (expr.is_string(compressor)) {
  13189. native_obj = "String";
  13190. } else if (!this.may_throw_on_access(compressor)) {
  13191. native_obj = "Object";
  13192. }
  13193. return native_obj != null && is_pure_native_method(native_obj, this.property);
  13194. });
  13195. // tell me if a statement aborts
  13196. const aborts = (thing) => thing && thing.aborts();
  13197. (function(def_aborts) {
  13198. def_aborts(AST_Statement, return_null);
  13199. def_aborts(AST_Jump, return_this);
  13200. function block_aborts() {
  13201. for (var i = 0; i < this.body.length; i++) {
  13202. if (aborts(this.body[i])) {
  13203. return this.body[i];
  13204. }
  13205. }
  13206. return null;
  13207. }
  13208. def_aborts(AST_Import, return_null);
  13209. def_aborts(AST_BlockStatement, block_aborts);
  13210. def_aborts(AST_SwitchBranch, block_aborts);
  13211. def_aborts(AST_DefClass, function () {
  13212. for (const prop of this.properties) {
  13213. if (prop instanceof AST_ClassStaticBlock) {
  13214. if (prop.aborts()) return prop;
  13215. }
  13216. }
  13217. return null;
  13218. });
  13219. def_aborts(AST_ClassStaticBlock, block_aborts);
  13220. def_aborts(AST_If, function() {
  13221. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  13222. });
  13223. })(function(node, func) {
  13224. node.DEFMETHOD("aborts", func);
  13225. });
  13226. AST_Node.DEFMETHOD("contains_this", function() {
  13227. return walk(this, node => {
  13228. if (node instanceof AST_This) return walk_abort;
  13229. if (
  13230. node !== this
  13231. && node instanceof AST_Scope
  13232. && !(node instanceof AST_Arrow)
  13233. ) {
  13234. return true;
  13235. }
  13236. });
  13237. });
  13238. function is_modified(compressor, tw, node, value, level, immutable) {
  13239. var parent = tw.parent(level);
  13240. var lhs = is_lhs(node, parent);
  13241. if (lhs) return lhs;
  13242. if (!immutable
  13243. && parent instanceof AST_Call
  13244. && parent.expression === node
  13245. && !(value instanceof AST_Arrow)
  13246. && !(value instanceof AST_Class)
  13247. && !parent.is_callee_pure(compressor)
  13248. && (!(value instanceof AST_Function)
  13249. || !(parent instanceof AST_New) && value.contains_this())) {
  13250. return true;
  13251. }
  13252. if (parent instanceof AST_Array) {
  13253. return is_modified(compressor, tw, parent, parent, level + 1);
  13254. }
  13255. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  13256. var obj = tw.parent(level + 1);
  13257. return is_modified(compressor, tw, obj, obj, level + 2);
  13258. }
  13259. if (parent instanceof AST_PropAccess && parent.expression === node) {
  13260. var prop = read_property(value, parent.property);
  13261. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  13262. }
  13263. }
  13264. /**
  13265. * Check if a node may be used by the expression it's in
  13266. * void (0, 1, {node}, 2) -> false
  13267. * console.log(0, {node}) -> true
  13268. */
  13269. function is_used_in_expression(tw) {
  13270. for (let p = -1, node, parent; node = tw.parent(p), parent = tw.parent(p + 1); p++) {
  13271. if (parent instanceof AST_Sequence) {
  13272. const nth_expression = parent.expressions.indexOf(node);
  13273. if (nth_expression !== parent.expressions.length - 1) {
  13274. // Detect (0, x.noThis)() constructs
  13275. const grandparent = tw.parent(p + 2);
  13276. if (
  13277. parent.expressions.length > 2
  13278. || parent.expressions.length === 1
  13279. || !requires_sequence_to_maintain_binding(grandparent, parent, parent.expressions[1])
  13280. ) {
  13281. return false;
  13282. }
  13283. return true;
  13284. } else {
  13285. continue;
  13286. }
  13287. }
  13288. if (parent instanceof AST_Unary) {
  13289. const op = parent.operator;
  13290. if (op === "void") {
  13291. return false;
  13292. }
  13293. if (op === "typeof" || op === "+" || op === "-" || op === "!" || op === "~") {
  13294. continue;
  13295. }
  13296. }
  13297. if (
  13298. parent instanceof AST_SimpleStatement
  13299. || parent instanceof AST_LabeledStatement
  13300. ) {
  13301. return false;
  13302. }
  13303. if (parent instanceof AST_Scope) {
  13304. return false;
  13305. }
  13306. return true;
  13307. }
  13308. return true;
  13309. }
  13310. /***********************************************************************
  13311. A JavaScript tokenizer / parser / beautifier / compressor.
  13312. https://github.com/mishoo/UglifyJS2
  13313. -------------------------------- (C) ---------------------------------
  13314. Author: Mihai Bazon
  13315. <mihai.bazon@gmail.com>
  13316. http://mihai.bazon.net/blog
  13317. Distributed under the BSD license:
  13318. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13319. Redistribution and use in source and binary forms, with or without
  13320. modification, are permitted provided that the following conditions
  13321. are met:
  13322. * Redistributions of source code must retain the above
  13323. copyright notice, this list of conditions and the following
  13324. disclaimer.
  13325. * Redistributions in binary form must reproduce the above
  13326. copyright notice, this list of conditions and the following
  13327. disclaimer in the documentation and/or other materials
  13328. provided with the distribution.
  13329. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13330. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13331. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13332. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13333. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13334. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13335. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13336. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13337. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13338. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13339. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13340. SUCH DAMAGE.
  13341. ***********************************************************************/
  13342. // methods to evaluate a constant expression
  13343. function def_eval(node, func) {
  13344. node.DEFMETHOD("_eval", func);
  13345. }
  13346. // Used to propagate a nullish short-circuit signal upwards through the chain.
  13347. const nullish = Symbol("This AST_Chain is nullish");
  13348. // If the node has been successfully reduced to a constant,
  13349. // then its value is returned; otherwise the element itself
  13350. // is returned.
  13351. // They can be distinguished as constant value is never a
  13352. // descendant of AST_Node.
  13353. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  13354. if (!compressor.option("evaluate"))
  13355. return this;
  13356. var val = this._eval(compressor, 1);
  13357. if (!val || val instanceof RegExp)
  13358. return val;
  13359. if (typeof val == "function" || typeof val == "object" || val == nullish)
  13360. return this;
  13361. // Evaluated strings can be larger than the original expression
  13362. if (typeof val === "string") {
  13363. const unevaluated_size = this.size(compressor);
  13364. if (val.length + 2 > unevaluated_size) return this;
  13365. }
  13366. return val;
  13367. });
  13368. var unaryPrefix = makePredicate("! ~ - + void");
  13369. AST_Node.DEFMETHOD("is_constant", function () {
  13370. // Accomodate when compress option evaluate=false
  13371. // as well as the common constant expressions !0 and -1
  13372. if (this instanceof AST_Constant) {
  13373. return !(this instanceof AST_RegExp);
  13374. } else {
  13375. return this instanceof AST_UnaryPrefix
  13376. && unaryPrefix.has(this.operator)
  13377. && (
  13378. // `this.expression` may be an `AST_RegExp`,
  13379. // so not only `.is_constant()`.
  13380. this.expression instanceof AST_Constant
  13381. || this.expression.is_constant()
  13382. );
  13383. }
  13384. });
  13385. def_eval(AST_Statement, function () {
  13386. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  13387. });
  13388. def_eval(AST_Lambda, return_this);
  13389. def_eval(AST_Class, return_this);
  13390. def_eval(AST_Node, return_this);
  13391. def_eval(AST_Constant, function () {
  13392. return this.getValue();
  13393. });
  13394. const supports_bigint = typeof BigInt === "function";
  13395. def_eval(AST_BigInt, function () {
  13396. if (supports_bigint) {
  13397. return BigInt(this.value);
  13398. } else {
  13399. return this;
  13400. }
  13401. });
  13402. def_eval(AST_RegExp, function (compressor) {
  13403. let evaluated = compressor.evaluated_regexps.get(this.value);
  13404. if (evaluated === undefined && regexp_is_safe(this.value.source)) {
  13405. try {
  13406. const { source, flags } = this.value;
  13407. evaluated = new RegExp(source, flags);
  13408. } catch (e) {
  13409. evaluated = null;
  13410. }
  13411. compressor.evaluated_regexps.set(this.value, evaluated);
  13412. }
  13413. return evaluated || this;
  13414. });
  13415. def_eval(AST_TemplateString, function () {
  13416. if (this.segments.length !== 1) return this;
  13417. return this.segments[0].value;
  13418. });
  13419. def_eval(AST_Function, function (compressor) {
  13420. if (compressor.option("unsafe")) {
  13421. var fn = function () { };
  13422. fn.node = this;
  13423. fn.toString = () => this.print_to_string();
  13424. return fn;
  13425. }
  13426. return this;
  13427. });
  13428. def_eval(AST_Array, function (compressor, depth) {
  13429. if (compressor.option("unsafe")) {
  13430. var elements = [];
  13431. for (var i = 0, len = this.elements.length; i < len; i++) {
  13432. var element = this.elements[i];
  13433. var value = element._eval(compressor, depth);
  13434. if (element === value)
  13435. return this;
  13436. elements.push(value);
  13437. }
  13438. return elements;
  13439. }
  13440. return this;
  13441. });
  13442. def_eval(AST_Object, function (compressor, depth) {
  13443. if (compressor.option("unsafe")) {
  13444. var val = {};
  13445. for (var i = 0, len = this.properties.length; i < len; i++) {
  13446. var prop = this.properties[i];
  13447. if (prop instanceof AST_Expansion)
  13448. return this;
  13449. var key = prop.key;
  13450. if (key instanceof AST_Symbol) {
  13451. key = key.name;
  13452. } else if (key instanceof AST_Node) {
  13453. key = key._eval(compressor, depth);
  13454. if (key === prop.key)
  13455. return this;
  13456. }
  13457. if (typeof Object.prototype[key] === "function") {
  13458. return this;
  13459. }
  13460. if (prop.value instanceof AST_Function)
  13461. continue;
  13462. val[key] = prop.value._eval(compressor, depth);
  13463. if (val[key] === prop.value)
  13464. return this;
  13465. }
  13466. return val;
  13467. }
  13468. return this;
  13469. });
  13470. var non_converting_unary = makePredicate("! typeof void");
  13471. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  13472. var e = this.expression;
  13473. if (compressor.option("typeofs")
  13474. && this.operator == "typeof") {
  13475. // Function would be evaluated to an array and so typeof would
  13476. // incorrectly return 'object'. Hence making is a special case.
  13477. if (e instanceof AST_Lambda
  13478. || e instanceof AST_SymbolRef
  13479. && e.fixed_value() instanceof AST_Lambda) {
  13480. return typeof function () { };
  13481. }
  13482. if (
  13483. (e instanceof AST_Object
  13484. || e instanceof AST_Array
  13485. || (e instanceof AST_SymbolRef
  13486. && (e.fixed_value() instanceof AST_Object
  13487. || e.fixed_value() instanceof AST_Array)))
  13488. && !e.has_side_effects(compressor)
  13489. ) {
  13490. return typeof {};
  13491. }
  13492. }
  13493. if (!non_converting_unary.has(this.operator))
  13494. depth++;
  13495. e = e._eval(compressor, depth);
  13496. if (e === this.expression)
  13497. return this;
  13498. switch (this.operator) {
  13499. case "!": return !e;
  13500. case "typeof":
  13501. // typeof <RegExp> returns "object" or "function" on different platforms
  13502. // so cannot evaluate reliably
  13503. if (e instanceof RegExp)
  13504. return this;
  13505. return typeof e;
  13506. case "void": return void e;
  13507. case "~": return ~e;
  13508. case "-": return -e;
  13509. case "+": return +e;
  13510. }
  13511. return this;
  13512. });
  13513. var non_converting_binary = makePredicate("&& || ?? === !==");
  13514. const identity_comparison = makePredicate("== != === !==");
  13515. const has_identity = value => typeof value === "object"
  13516. || typeof value === "function"
  13517. || typeof value === "symbol";
  13518. def_eval(AST_Binary, function (compressor, depth) {
  13519. if (!non_converting_binary.has(this.operator))
  13520. depth++;
  13521. var left = this.left._eval(compressor, depth);
  13522. if (left === this.left)
  13523. return this;
  13524. var right = this.right._eval(compressor, depth);
  13525. if (right === this.right)
  13526. return this;
  13527. if (left != null
  13528. && right != null
  13529. && identity_comparison.has(this.operator)
  13530. && has_identity(left)
  13531. && has_identity(right)
  13532. && typeof left === typeof right) {
  13533. // Do not compare by reference
  13534. return this;
  13535. }
  13536. // Do not mix BigInt and Number; Don't use `>>>` on BigInt or `/ 0n`
  13537. if (
  13538. (typeof left === "bigint") !== (typeof right === "bigint")
  13539. || typeof left === "bigint"
  13540. && (this.operator === ">>>"
  13541. || this.operator === "/" && Number(right) === 0)
  13542. ) {
  13543. return this;
  13544. }
  13545. var result;
  13546. switch (this.operator) {
  13547. case "&&": result = left && right; break;
  13548. case "||": result = left || right; break;
  13549. case "??": result = left != null ? left : right; break;
  13550. case "|": result = left | right; break;
  13551. case "&": result = left & right; break;
  13552. case "^": result = left ^ right; break;
  13553. case "+": result = left + right; break;
  13554. case "*": result = left * right; break;
  13555. case "**": result = left ** right; break;
  13556. case "/": result = left / right; break;
  13557. case "%": result = left % right; break;
  13558. case "-": result = left - right; break;
  13559. case "<<": result = left << right; break;
  13560. case ">>": result = left >> right; break;
  13561. case ">>>": result = left >>> right; break;
  13562. case "==": result = left == right; break;
  13563. case "===": result = left === right; break;
  13564. case "!=": result = left != right; break;
  13565. case "!==": result = left !== right; break;
  13566. case "<": result = left < right; break;
  13567. case "<=": result = left <= right; break;
  13568. case ">": result = left > right; break;
  13569. case ">=": result = left >= right; break;
  13570. default:
  13571. return this;
  13572. }
  13573. if (typeof result === "number" && isNaN(result) && compressor.find_parent(AST_With)) {
  13574. // leave original expression as is
  13575. return this;
  13576. }
  13577. return result;
  13578. });
  13579. def_eval(AST_Conditional, function (compressor, depth) {
  13580. var condition = this.condition._eval(compressor, depth);
  13581. if (condition === this.condition)
  13582. return this;
  13583. var node = condition ? this.consequent : this.alternative;
  13584. var value = node._eval(compressor, depth);
  13585. return value === node ? this : value;
  13586. });
  13587. // Set of AST_SymbolRef which are currently being evaluated.
  13588. // Avoids infinite recursion of ._eval()
  13589. const reentrant_ref_eval = new Set();
  13590. def_eval(AST_SymbolRef, function (compressor, depth) {
  13591. if (reentrant_ref_eval.has(this))
  13592. return this;
  13593. var fixed = this.fixed_value();
  13594. if (!fixed)
  13595. return this;
  13596. reentrant_ref_eval.add(this);
  13597. const value = fixed._eval(compressor, depth);
  13598. reentrant_ref_eval.delete(this);
  13599. if (value === fixed)
  13600. return this;
  13601. if (value && typeof value == "object") {
  13602. var escaped = this.definition().escaped;
  13603. if (escaped && depth > escaped)
  13604. return this;
  13605. }
  13606. return value;
  13607. });
  13608. const global_objs = { Array, Math, Number, Object, String };
  13609. const regexp_flags = new Set([
  13610. "dotAll",
  13611. "global",
  13612. "ignoreCase",
  13613. "multiline",
  13614. "sticky",
  13615. "unicode",
  13616. ]);
  13617. def_eval(AST_PropAccess, function (compressor, depth) {
  13618. let obj = this.expression._eval(compressor, depth + 1);
  13619. if (obj === nullish || (this.optional && obj == null)) return nullish;
  13620. // `.length` of strings and arrays is always safe
  13621. if (this.property === "length") {
  13622. if (typeof obj === "string") {
  13623. return obj.length;
  13624. }
  13625. const is_spreadless_array =
  13626. obj instanceof AST_Array
  13627. && obj.elements.every(el => !(el instanceof AST_Expansion));
  13628. if (
  13629. is_spreadless_array
  13630. && obj.elements.every(el => !el.has_side_effects(compressor))
  13631. ) {
  13632. return obj.elements.length;
  13633. }
  13634. }
  13635. if (compressor.option("unsafe")) {
  13636. var key = this.property;
  13637. if (key instanceof AST_Node) {
  13638. key = key._eval(compressor, depth);
  13639. if (key === this.property)
  13640. return this;
  13641. }
  13642. var exp = this.expression;
  13643. if (is_undeclared_ref(exp)) {
  13644. var aa;
  13645. var first_arg = exp.name === "hasOwnProperty"
  13646. && key === "call"
  13647. && (aa = compressor.parent() && compressor.parent().args)
  13648. && (aa && aa[0]
  13649. && aa[0].evaluate(compressor));
  13650. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13651. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  13652. return this.clone();
  13653. }
  13654. if (!is_pure_native_value(exp.name, key))
  13655. return this;
  13656. obj = global_objs[exp.name];
  13657. } else {
  13658. if (obj instanceof RegExp) {
  13659. if (key == "source") {
  13660. return regexp_source_fix(obj.source);
  13661. } else if (key == "flags" || regexp_flags.has(key)) {
  13662. return obj[key];
  13663. }
  13664. }
  13665. if (!obj || obj === exp || !HOP(obj, key))
  13666. return this;
  13667. if (typeof obj == "function")
  13668. switch (key) {
  13669. case "name":
  13670. return obj.node.name ? obj.node.name.name : "";
  13671. case "length":
  13672. return obj.node.length_property();
  13673. default:
  13674. return this;
  13675. }
  13676. }
  13677. return obj[key];
  13678. }
  13679. return this;
  13680. });
  13681. def_eval(AST_Chain, function (compressor, depth) {
  13682. const evaluated = this.expression._eval(compressor, depth);
  13683. return evaluated === nullish
  13684. ? undefined
  13685. : evaluated === this.expression
  13686. ? this
  13687. : evaluated;
  13688. });
  13689. def_eval(AST_Call, function (compressor, depth) {
  13690. var exp = this.expression;
  13691. const callee = exp._eval(compressor, depth);
  13692. if (callee === nullish || (this.optional && callee == null)) return nullish;
  13693. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  13694. var key = exp.property;
  13695. if (key instanceof AST_Node) {
  13696. key = key._eval(compressor, depth);
  13697. if (key === exp.property)
  13698. return this;
  13699. }
  13700. var val;
  13701. var e = exp.expression;
  13702. if (is_undeclared_ref(e)) {
  13703. var first_arg = e.name === "hasOwnProperty" &&
  13704. key === "call" &&
  13705. (this.args[0] && this.args[0].evaluate(compressor));
  13706. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13707. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  13708. return this.clone();
  13709. }
  13710. if (!is_pure_native_fn(e.name, key)) return this;
  13711. val = global_objs[e.name];
  13712. } else {
  13713. val = e._eval(compressor, depth + 1);
  13714. if (val === e || !val)
  13715. return this;
  13716. if (!is_pure_native_method(val.constructor.name, key))
  13717. return this;
  13718. }
  13719. var args = [];
  13720. for (var i = 0, len = this.args.length; i < len; i++) {
  13721. var arg = this.args[i];
  13722. var value = arg._eval(compressor, depth);
  13723. if (arg === value)
  13724. return this;
  13725. if (arg instanceof AST_Lambda)
  13726. return this;
  13727. args.push(value);
  13728. }
  13729. try {
  13730. return val[key].apply(val, args);
  13731. } catch (ex) {
  13732. // We don't really care
  13733. }
  13734. }
  13735. return this;
  13736. });
  13737. // Also a subclass of AST_Call
  13738. def_eval(AST_New, return_this);
  13739. /***********************************************************************
  13740. A JavaScript tokenizer / parser / beautifier / compressor.
  13741. https://github.com/mishoo/UglifyJS2
  13742. -------------------------------- (C) ---------------------------------
  13743. Author: Mihai Bazon
  13744. <mihai.bazon@gmail.com>
  13745. http://mihai.bazon.net/blog
  13746. Distributed under the BSD license:
  13747. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13748. Redistribution and use in source and binary forms, with or without
  13749. modification, are permitted provided that the following conditions
  13750. are met:
  13751. * Redistributions of source code must retain the above
  13752. copyright notice, this list of conditions and the following
  13753. disclaimer.
  13754. * Redistributions in binary form must reproduce the above
  13755. copyright notice, this list of conditions and the following
  13756. disclaimer in the documentation and/or other materials
  13757. provided with the distribution.
  13758. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13759. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13760. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13761. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13762. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13763. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13764. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13765. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13766. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13767. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13768. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13769. SUCH DAMAGE.
  13770. ***********************************************************************/
  13771. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  13772. // only about side effects. We'll be defining this method for each node type in this module
  13773. //
  13774. // Examples:
  13775. // foo++ -> foo++
  13776. // 1 + func() -> func()
  13777. // 10 -> (nothing)
  13778. // knownPureFunc(foo++) -> foo++
  13779. function def_drop_side_effect_free(node_or_nodes, func) {
  13780. for (const node of [].concat(node_or_nodes)) {
  13781. node.DEFMETHOD("drop_side_effect_free", func);
  13782. }
  13783. }
  13784. // Drop side-effect-free elements from an array of expressions.
  13785. // Returns an array of expressions with side-effects or null
  13786. // if all elements were dropped. Note: original array may be
  13787. // returned if nothing changed.
  13788. function trim(nodes, compressor, first_in_statement) {
  13789. var len = nodes.length;
  13790. if (!len) return null;
  13791. var ret = [], changed = false;
  13792. for (var i = 0; i < len; i++) {
  13793. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  13794. changed |= node !== nodes[i];
  13795. if (node) {
  13796. ret.push(node);
  13797. first_in_statement = false;
  13798. }
  13799. }
  13800. return changed ? ret.length ? ret : null : nodes;
  13801. }
  13802. def_drop_side_effect_free(AST_Node, return_this);
  13803. def_drop_side_effect_free(AST_Constant, return_null);
  13804. def_drop_side_effect_free(AST_This, return_null);
  13805. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  13806. if (is_nullish_shortcircuited(this, compressor)) {
  13807. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13808. }
  13809. if (!this.is_callee_pure(compressor)) {
  13810. if (this.expression.is_call_pure(compressor)) {
  13811. var exprs = this.args.slice();
  13812. exprs.unshift(this.expression.expression);
  13813. exprs = trim(exprs, compressor, first_in_statement);
  13814. return exprs && make_sequence(this, exprs);
  13815. }
  13816. if (is_func_expr(this.expression)
  13817. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  13818. var node = this.clone();
  13819. node.expression.process_expression(false, compressor);
  13820. return node;
  13821. }
  13822. return this;
  13823. }
  13824. var args = trim(this.args, compressor, first_in_statement);
  13825. return args && make_sequence(this, args);
  13826. });
  13827. def_drop_side_effect_free(AST_Accessor, return_null);
  13828. def_drop_side_effect_free(AST_Function, return_null);
  13829. def_drop_side_effect_free(AST_Arrow, return_null);
  13830. def_drop_side_effect_free(AST_Class, function (compressor) {
  13831. const with_effects = [];
  13832. if (this.is_self_referential() && this.has_side_effects(compressor)) {
  13833. return this;
  13834. }
  13835. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  13836. if (trimmed_extends) with_effects.push(trimmed_extends);
  13837. for (const prop of this.properties) {
  13838. if (prop instanceof AST_ClassStaticBlock) {
  13839. if (prop.has_side_effects(compressor)) {
  13840. return this; // Be cautious about these
  13841. }
  13842. } else {
  13843. const trimmed_prop = prop.drop_side_effect_free(compressor);
  13844. if (trimmed_prop) with_effects.push(trimmed_prop);
  13845. }
  13846. }
  13847. if (!with_effects.length)
  13848. return null;
  13849. const exprs = make_sequence(this, with_effects);
  13850. if (this instanceof AST_DefClass) {
  13851. // We want a statement
  13852. return make_node(AST_SimpleStatement, this, { body: exprs });
  13853. } else {
  13854. return exprs;
  13855. }
  13856. });
  13857. def_drop_side_effect_free([
  13858. AST_ClassProperty,
  13859. AST_ClassPrivateProperty,
  13860. ], function (compressor) {
  13861. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  13862. const value = this.static && this.value
  13863. && this.value.drop_side_effect_free(compressor);
  13864. if (key && value)
  13865. return make_sequence(this, [key, value]);
  13866. return key || value || null;
  13867. });
  13868. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  13869. var right = this.right.drop_side_effect_free(compressor);
  13870. if (!right)
  13871. return this.left.drop_side_effect_free(compressor, first_in_statement);
  13872. if (lazy_op.has(this.operator)) {
  13873. if (right === this.right)
  13874. return this;
  13875. var node = this.clone();
  13876. node.right = right;
  13877. return node;
  13878. } else {
  13879. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  13880. if (!left)
  13881. return this.right.drop_side_effect_free(compressor, first_in_statement);
  13882. return make_sequence(this, [left, right]);
  13883. }
  13884. });
  13885. def_drop_side_effect_free(AST_Assign, function (compressor) {
  13886. if (this.logical)
  13887. return this;
  13888. var left = this.left;
  13889. if (left.has_side_effects(compressor)
  13890. || compressor.has_directive("use strict")
  13891. && left instanceof AST_PropAccess
  13892. && left.expression.is_constant()) {
  13893. return this;
  13894. }
  13895. set_flag(this, WRITE_ONLY);
  13896. while (left instanceof AST_PropAccess) {
  13897. left = left.expression;
  13898. }
  13899. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  13900. return this.right.drop_side_effect_free(compressor);
  13901. }
  13902. return this;
  13903. });
  13904. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  13905. var consequent = this.consequent.drop_side_effect_free(compressor);
  13906. var alternative = this.alternative.drop_side_effect_free(compressor);
  13907. if (consequent === this.consequent && alternative === this.alternative)
  13908. return this;
  13909. if (!consequent)
  13910. return alternative ? make_node(AST_Binary, this, {
  13911. operator: "||",
  13912. left: this.condition,
  13913. right: alternative
  13914. }) : this.condition.drop_side_effect_free(compressor);
  13915. if (!alternative)
  13916. return make_node(AST_Binary, this, {
  13917. operator: "&&",
  13918. left: this.condition,
  13919. right: consequent
  13920. });
  13921. var node = this.clone();
  13922. node.consequent = consequent;
  13923. node.alternative = alternative;
  13924. return node;
  13925. });
  13926. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  13927. if (unary_side_effects.has(this.operator)) {
  13928. if (!this.expression.has_side_effects(compressor)) {
  13929. set_flag(this, WRITE_ONLY);
  13930. } else {
  13931. clear_flag(this, WRITE_ONLY);
  13932. }
  13933. return this;
  13934. }
  13935. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  13936. return null;
  13937. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13938. if (first_in_statement && expression && is_iife_call(expression)) {
  13939. if (expression === this.expression && this.operator == "!")
  13940. return this;
  13941. return expression.negate(compressor, first_in_statement);
  13942. }
  13943. return expression;
  13944. });
  13945. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  13946. const safe_access = this.is_declared(compressor)
  13947. || pure_prop_access_globals.has(this.name);
  13948. return safe_access ? null : this;
  13949. });
  13950. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  13951. var values = trim(this.properties, compressor, first_in_statement);
  13952. return values && make_sequence(this, values);
  13953. });
  13954. def_drop_side_effect_free(AST_ObjectKeyVal, function (compressor, first_in_statement) {
  13955. const computed_key = this.key instanceof AST_Node;
  13956. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  13957. const value = this.value.drop_side_effect_free(compressor, first_in_statement);
  13958. if (key && value) {
  13959. return make_sequence(this, [key, value]);
  13960. }
  13961. return key || value;
  13962. });
  13963. def_drop_side_effect_free([
  13964. AST_ConciseMethod,
  13965. AST_ObjectGetter,
  13966. AST_ObjectSetter,
  13967. ], function () {
  13968. return this.computed_key() ? this.key : null;
  13969. });
  13970. def_drop_side_effect_free([
  13971. AST_PrivateMethod,
  13972. AST_PrivateGetter,
  13973. AST_PrivateSetter,
  13974. ], function () {
  13975. return null;
  13976. });
  13977. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  13978. var values = trim(this.elements, compressor, first_in_statement);
  13979. return values && make_sequence(this, values);
  13980. });
  13981. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  13982. if (is_nullish_shortcircuited(this, compressor)) {
  13983. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13984. }
  13985. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  13986. return this;
  13987. }
  13988. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13989. });
  13990. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  13991. if (is_nullish_shortcircuited(this, compressor)) {
  13992. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13993. }
  13994. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  13995. return this;
  13996. }
  13997. var property = this.property.drop_side_effect_free(compressor);
  13998. if (property && this.optional) return this;
  13999. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  14000. if (expression && property) return make_sequence(this, [expression, property]);
  14001. return expression || property;
  14002. });
  14003. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  14004. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  14005. });
  14006. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  14007. var last = this.tail_node();
  14008. var expr = last.drop_side_effect_free(compressor);
  14009. if (expr === last)
  14010. return this;
  14011. var expressions = this.expressions.slice(0, -1);
  14012. if (expr)
  14013. expressions.push(expr);
  14014. if (!expressions.length) {
  14015. return make_node(AST_Number, this, { value: 0 });
  14016. }
  14017. return make_sequence(this, expressions);
  14018. });
  14019. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  14020. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  14021. });
  14022. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  14023. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  14024. var values = trim(this.segments, compressor, first_in_statement);
  14025. return values && make_sequence(this, values);
  14026. });
  14027. /***********************************************************************
  14028. A JavaScript tokenizer / parser / beautifier / compressor.
  14029. https://github.com/mishoo/UglifyJS2
  14030. -------------------------------- (C) ---------------------------------
  14031. Author: Mihai Bazon
  14032. <mihai.bazon@gmail.com>
  14033. http://mihai.bazon.net/blog
  14034. Distributed under the BSD license:
  14035. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14036. Redistribution and use in source and binary forms, with or without
  14037. modification, are permitted provided that the following conditions
  14038. are met:
  14039. * Redistributions of source code must retain the above
  14040. copyright notice, this list of conditions and the following
  14041. disclaimer.
  14042. * Redistributions in binary form must reproduce the above
  14043. copyright notice, this list of conditions and the following
  14044. disclaimer in the documentation and/or other materials
  14045. provided with the distribution.
  14046. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14047. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14048. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14049. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14050. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14051. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14052. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14053. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14054. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14055. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14056. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14057. SUCH DAMAGE.
  14058. ***********************************************************************/
  14059. const r_keep_assign = /keep_assign/;
  14060. /** Drop unused variables from this scope */
  14061. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  14062. if (!compressor.option("unused")) return;
  14063. if (compressor.has_directive("use asm")) return;
  14064. if (!this.variables) return; // not really a scope (eg: AST_Class)
  14065. var self = this;
  14066. if (self.pinned()) return;
  14067. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  14068. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  14069. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  14070. if (node instanceof AST_Assign
  14071. && !node.logical
  14072. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  14073. ) {
  14074. return node.left;
  14075. }
  14076. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  14077. return node.expression;
  14078. }
  14079. };
  14080. var in_use_ids = new Map();
  14081. var fixed_ids = new Map();
  14082. if (self instanceof AST_Toplevel && compressor.top_retain) {
  14083. self.variables.forEach(function(def) {
  14084. if (compressor.top_retain(def)) {
  14085. in_use_ids.set(def.id, def);
  14086. }
  14087. });
  14088. }
  14089. var var_defs_by_id = new Map();
  14090. var initializations = new Map();
  14091. // pass 1: find out which symbols are directly used in
  14092. // this scope (not in nested scopes).
  14093. var scope = this;
  14094. var tw = new TreeWalker(function(node, descend) {
  14095. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  14096. node.argnames.forEach(function(argname) {
  14097. if (!(argname instanceof AST_SymbolDeclaration)) return;
  14098. var def = argname.definition();
  14099. in_use_ids.set(def.id, def);
  14100. });
  14101. }
  14102. if (node === self) return;
  14103. if (node instanceof AST_Class && node.has_side_effects(compressor)) {
  14104. if (node.is_self_referential()) {
  14105. descend();
  14106. } else {
  14107. node.visit_nondeferred_class_parts(tw);
  14108. }
  14109. }
  14110. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  14111. var node_def = node.name.definition();
  14112. const in_export = tw.parent() instanceof AST_Export;
  14113. if (in_export || !drop_funcs && scope === self) {
  14114. if (node_def.global) {
  14115. in_use_ids.set(node_def.id, node_def);
  14116. }
  14117. }
  14118. map_add(initializations, node_def.id, node);
  14119. return true; // don't go in nested scopes
  14120. }
  14121. // In the root scope, we drop things. In inner scopes, we just check for uses.
  14122. const in_root_scope = scope === self;
  14123. if (node instanceof AST_SymbolFunarg && in_root_scope) {
  14124. map_add(var_defs_by_id, node.definition().id, node);
  14125. }
  14126. if (node instanceof AST_Definitions && in_root_scope) {
  14127. const in_export = tw.parent() instanceof AST_Export;
  14128. node.definitions.forEach(function(def) {
  14129. if (def.name instanceof AST_SymbolVar) {
  14130. map_add(var_defs_by_id, def.name.definition().id, def);
  14131. }
  14132. if (in_export || !drop_vars) {
  14133. walk(def.name, node => {
  14134. if (node instanceof AST_SymbolDeclaration) {
  14135. const def = node.definition();
  14136. if (def.global) {
  14137. in_use_ids.set(def.id, def);
  14138. }
  14139. }
  14140. });
  14141. }
  14142. if (def.name instanceof AST_Destructuring) {
  14143. def.walk(tw);
  14144. }
  14145. if (def.name instanceof AST_SymbolDeclaration && def.value) {
  14146. var node_def = def.name.definition();
  14147. map_add(initializations, node_def.id, def.value);
  14148. if (!node_def.chained && def.name.fixed_value() === def.value) {
  14149. fixed_ids.set(node_def.id, def);
  14150. }
  14151. if (def.value.has_side_effects(compressor)) {
  14152. def.value.walk(tw);
  14153. }
  14154. }
  14155. });
  14156. return true;
  14157. }
  14158. return scan_ref_scoped(node, descend);
  14159. });
  14160. self.walk(tw);
  14161. // pass 2: for every used symbol we need to walk its
  14162. // initialization code to figure out if it uses other
  14163. // symbols (that may not be in_use).
  14164. tw = new TreeWalker(scan_ref_scoped);
  14165. in_use_ids.forEach(function (def) {
  14166. var init = initializations.get(def.id);
  14167. if (init) init.forEach(function(init) {
  14168. init.walk(tw);
  14169. });
  14170. });
  14171. // pass 3: we should drop declarations not in_use
  14172. var tt = new TreeTransformer(
  14173. function before(node, descend, in_list) {
  14174. var parent = tt.parent();
  14175. if (drop_vars) {
  14176. const sym = assign_as_unused(node);
  14177. if (sym instanceof AST_SymbolRef) {
  14178. var def = sym.definition();
  14179. var in_use = in_use_ids.has(def.id);
  14180. if (node instanceof AST_Assign) {
  14181. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  14182. const assignee = node.right.transform(tt);
  14183. if (!in_use && !assignee.has_side_effects(compressor) && !is_used_in_expression(tt)) {
  14184. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  14185. }
  14186. return maintain_this_binding(parent, node, assignee);
  14187. }
  14188. } else if (!in_use) {
  14189. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  14190. }
  14191. }
  14192. }
  14193. if (scope !== self) return;
  14194. var def;
  14195. if (node.name
  14196. && (node instanceof AST_ClassExpression
  14197. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  14198. || node instanceof AST_Function
  14199. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  14200. // any declarations with same name will overshadow
  14201. // name of this anonymous function and can therefore
  14202. // never be used anywhere
  14203. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  14204. }
  14205. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  14206. var trim =
  14207. !compressor.option("keep_fargs")
  14208. // Is this an IIFE that won't refer to its name?
  14209. || parent instanceof AST_Call
  14210. && parent.expression === node
  14211. && !node.pinned()
  14212. && (!node.name || node.name.unreferenced());
  14213. for (var a = node.argnames, i = a.length; --i >= 0;) {
  14214. var sym = a[i];
  14215. if (sym instanceof AST_Expansion) {
  14216. sym = sym.expression;
  14217. }
  14218. if (sym instanceof AST_DefaultAssign) {
  14219. sym = sym.left;
  14220. }
  14221. // Do not drop destructuring arguments.
  14222. // They constitute a type assertion of sorts
  14223. if (
  14224. !(sym instanceof AST_Destructuring)
  14225. && !in_use_ids.has(sym.definition().id)
  14226. ) {
  14227. set_flag(sym, UNUSED);
  14228. if (trim) {
  14229. a.pop();
  14230. }
  14231. } else {
  14232. trim = false;
  14233. }
  14234. }
  14235. }
  14236. if (node instanceof AST_DefClass && node !== self) {
  14237. const def = node.name.definition();
  14238. descend(node, this);
  14239. const keep_class = def.global && !drop_funcs || in_use_ids.has(def.id);
  14240. if (!keep_class) {
  14241. const kept = node.drop_side_effect_free(compressor);
  14242. if (kept == null) {
  14243. def.eliminated++;
  14244. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  14245. }
  14246. return kept;
  14247. }
  14248. return node;
  14249. }
  14250. if (node instanceof AST_Defun && node !== self) {
  14251. const def = node.name.definition();
  14252. const keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  14253. if (!keep) {
  14254. def.eliminated++;
  14255. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  14256. }
  14257. }
  14258. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  14259. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  14260. // place uninitialized names at the start
  14261. var body = [], head = [], tail = [];
  14262. // for unused names whose initialization has
  14263. // side effects, we can cascade the init. code
  14264. // into the next one, or next statement.
  14265. var side_effects = [];
  14266. node.definitions.forEach(function(def) {
  14267. if (def.value) def.value = def.value.transform(tt);
  14268. var is_destructure = def.name instanceof AST_Destructuring;
  14269. var sym = is_destructure
  14270. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  14271. : def.name.definition();
  14272. if (drop_block && sym.global) return tail.push(def);
  14273. if (!(drop_vars || drop_block)
  14274. || is_destructure
  14275. && (def.name.names.length
  14276. || def.name.is_array
  14277. || compressor.option("pure_getters") != true)
  14278. || in_use_ids.has(sym.id)
  14279. ) {
  14280. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  14281. def.value = def.value.drop_side_effect_free(compressor);
  14282. }
  14283. if (def.name instanceof AST_SymbolVar) {
  14284. var var_defs = var_defs_by_id.get(sym.id);
  14285. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  14286. if (def.value) {
  14287. var ref = make_node(AST_SymbolRef, def.name, def.name);
  14288. sym.references.push(ref);
  14289. var assign = make_node(AST_Assign, def, {
  14290. operator: "=",
  14291. logical: false,
  14292. left: ref,
  14293. right: def.value
  14294. });
  14295. if (fixed_ids.get(sym.id) === def) {
  14296. fixed_ids.set(sym.id, assign);
  14297. }
  14298. side_effects.push(assign.transform(tt));
  14299. }
  14300. remove(var_defs, def);
  14301. sym.eliminated++;
  14302. return;
  14303. }
  14304. }
  14305. if (def.value) {
  14306. if (side_effects.length > 0) {
  14307. if (tail.length > 0) {
  14308. side_effects.push(def.value);
  14309. def.value = make_sequence(def.value, side_effects);
  14310. } else {
  14311. body.push(make_node(AST_SimpleStatement, node, {
  14312. body: make_sequence(node, side_effects)
  14313. }));
  14314. }
  14315. side_effects = [];
  14316. }
  14317. tail.push(def);
  14318. } else {
  14319. head.push(def);
  14320. }
  14321. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  14322. var value = def.value && def.value.drop_side_effect_free(compressor);
  14323. if (value) side_effects.push(value);
  14324. def.value = null;
  14325. head.push(def);
  14326. } else {
  14327. var value = def.value && def.value.drop_side_effect_free(compressor);
  14328. if (value) {
  14329. side_effects.push(value);
  14330. }
  14331. sym.eliminated++;
  14332. }
  14333. });
  14334. if (head.length > 0 || tail.length > 0) {
  14335. node.definitions = head.concat(tail);
  14336. body.push(node);
  14337. }
  14338. if (side_effects.length > 0) {
  14339. body.push(make_node(AST_SimpleStatement, node, {
  14340. body: make_sequence(node, side_effects)
  14341. }));
  14342. }
  14343. switch (body.length) {
  14344. case 0:
  14345. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  14346. case 1:
  14347. return body[0];
  14348. default:
  14349. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, { body });
  14350. }
  14351. }
  14352. // certain combination of unused name + side effect leads to:
  14353. // https://github.com/mishoo/UglifyJS2/issues/44
  14354. // https://github.com/mishoo/UglifyJS2/issues/1830
  14355. // https://github.com/mishoo/UglifyJS2/issues/1838
  14356. // that's an invalid AST.
  14357. // We fix it at this stage by moving the `var` outside the `for`.
  14358. if (node instanceof AST_For) {
  14359. descend(node, this);
  14360. var block;
  14361. if (node.init instanceof AST_BlockStatement) {
  14362. block = node.init;
  14363. node.init = block.body.pop();
  14364. block.body.push(node);
  14365. }
  14366. if (node.init instanceof AST_SimpleStatement) {
  14367. node.init = node.init.body;
  14368. } else if (is_empty(node.init)) {
  14369. node.init = null;
  14370. }
  14371. return !block ? node : in_list ? MAP.splice(block.body) : block;
  14372. }
  14373. if (node instanceof AST_LabeledStatement
  14374. && node.body instanceof AST_For
  14375. ) {
  14376. descend(node, this);
  14377. if (node.body instanceof AST_BlockStatement) {
  14378. var block = node.body;
  14379. node.body = block.body.pop();
  14380. block.body.push(node);
  14381. return in_list ? MAP.splice(block.body) : block;
  14382. }
  14383. return node;
  14384. }
  14385. if (node instanceof AST_BlockStatement) {
  14386. descend(node, this);
  14387. if (in_list && node.body.every(can_be_evicted_from_block)) {
  14388. return MAP.splice(node.body);
  14389. }
  14390. return node;
  14391. }
  14392. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  14393. const save_scope = scope;
  14394. scope = node;
  14395. descend(node, this);
  14396. scope = save_scope;
  14397. return node;
  14398. }
  14399. },
  14400. function after(node, in_list) {
  14401. if (node instanceof AST_Sequence) {
  14402. switch (node.expressions.length) {
  14403. case 0: return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  14404. case 1: return node.expressions[0];
  14405. }
  14406. }
  14407. }
  14408. );
  14409. self.transform(tt);
  14410. function scan_ref_scoped(node, descend) {
  14411. var node_def;
  14412. const sym = assign_as_unused(node);
  14413. if (sym instanceof AST_SymbolRef
  14414. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  14415. && self.variables.get(sym.name) === (node_def = sym.definition())
  14416. ) {
  14417. if (node instanceof AST_Assign) {
  14418. node.right.walk(tw);
  14419. if (!node_def.chained && node.left.fixed_value() === node.right) {
  14420. fixed_ids.set(node_def.id, node);
  14421. }
  14422. }
  14423. return true;
  14424. }
  14425. if (node instanceof AST_SymbolRef) {
  14426. node_def = node.definition();
  14427. if (!in_use_ids.has(node_def.id)) {
  14428. in_use_ids.set(node_def.id, node_def);
  14429. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  14430. const redef = node_def.scope.is_block_scope()
  14431. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  14432. if (redef) in_use_ids.set(redef.id, redef);
  14433. }
  14434. }
  14435. return true;
  14436. }
  14437. if (node instanceof AST_Class) {
  14438. descend();
  14439. return true;
  14440. }
  14441. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  14442. var save_scope = scope;
  14443. scope = node;
  14444. descend();
  14445. scope = save_scope;
  14446. return true;
  14447. }
  14448. }
  14449. });
  14450. /***********************************************************************
  14451. A JavaScript tokenizer / parser / beautifier / compressor.
  14452. https://github.com/mishoo/UglifyJS2
  14453. -------------------------------- (C) ---------------------------------
  14454. Author: Mihai Bazon
  14455. <mihai.bazon@gmail.com>
  14456. http://mihai.bazon.net/blog
  14457. Distributed under the BSD license:
  14458. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14459. Redistribution and use in source and binary forms, with or without
  14460. modification, are permitted provided that the following conditions
  14461. are met:
  14462. * Redistributions of source code must retain the above
  14463. copyright notice, this list of conditions and the following
  14464. disclaimer.
  14465. * Redistributions in binary form must reproduce the above
  14466. copyright notice, this list of conditions and the following
  14467. disclaimer in the documentation and/or other materials
  14468. provided with the distribution.
  14469. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14470. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14471. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14472. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14473. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14474. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14475. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14476. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14477. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14478. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14479. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14480. SUCH DAMAGE.
  14481. ***********************************************************************/
  14482. /**
  14483. * Define the method AST_Node#reduce_vars, which goes through the AST in
  14484. * execution order to perform basic flow analysis
  14485. */
  14486. function def_reduce_vars(node, func) {
  14487. node.DEFMETHOD("reduce_vars", func);
  14488. }
  14489. def_reduce_vars(AST_Node, noop);
  14490. /** Clear definition properties */
  14491. function reset_def(compressor, def) {
  14492. def.assignments = 0;
  14493. def.chained = false;
  14494. def.direct_access = false;
  14495. def.escaped = 0;
  14496. def.recursive_refs = 0;
  14497. def.references = [];
  14498. def.single_use = undefined;
  14499. if (
  14500. def.scope.pinned()
  14501. || (def.orig[0] instanceof AST_SymbolFunarg && def.scope.uses_arguments)
  14502. ) {
  14503. def.fixed = false;
  14504. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  14505. def.fixed = def.init;
  14506. } else {
  14507. def.fixed = false;
  14508. }
  14509. }
  14510. function reset_variables(tw, compressor, node) {
  14511. node.variables.forEach(function(def) {
  14512. reset_def(compressor, def);
  14513. if (def.fixed === null) {
  14514. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  14515. mark(tw, def, true);
  14516. } else if (def.fixed) {
  14517. tw.loop_ids.set(def.id, tw.in_loop);
  14518. mark(tw, def, true);
  14519. }
  14520. });
  14521. }
  14522. function reset_block_variables(compressor, node) {
  14523. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  14524. reset_def(compressor, def);
  14525. });
  14526. }
  14527. function push(tw) {
  14528. tw.safe_ids = Object.create(tw.safe_ids);
  14529. }
  14530. function pop(tw) {
  14531. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  14532. }
  14533. function mark(tw, def, safe) {
  14534. tw.safe_ids[def.id] = safe;
  14535. }
  14536. function safe_to_read(tw, def) {
  14537. if (def.single_use == "m") return false;
  14538. if (tw.safe_ids[def.id]) {
  14539. if (def.fixed == null) {
  14540. var orig = def.orig[0];
  14541. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  14542. def.fixed = make_node(AST_Undefined, orig);
  14543. }
  14544. return true;
  14545. }
  14546. return def.fixed instanceof AST_Defun;
  14547. }
  14548. function safe_to_assign(tw, def, scope, value) {
  14549. if (def.fixed === undefined) return true;
  14550. let def_safe_ids;
  14551. if (def.fixed === null
  14552. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  14553. ) {
  14554. def_safe_ids[def.id] = false;
  14555. tw.defs_to_safe_ids.delete(def.id);
  14556. return true;
  14557. }
  14558. if (!HOP(tw.safe_ids, def.id)) return false;
  14559. if (!safe_to_read(tw, def)) return false;
  14560. if (def.fixed === false) return false;
  14561. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  14562. if (def.fixed instanceof AST_Defun) {
  14563. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  14564. }
  14565. return def.orig.every((sym) => {
  14566. return !(sym instanceof AST_SymbolConst
  14567. || sym instanceof AST_SymbolDefun
  14568. || sym instanceof AST_SymbolLambda);
  14569. });
  14570. }
  14571. function ref_once(tw, compressor, def) {
  14572. return compressor.option("unused")
  14573. && !def.scope.pinned()
  14574. && def.references.length - def.recursive_refs == 1
  14575. && tw.loop_ids.get(def.id) === tw.in_loop;
  14576. }
  14577. function is_immutable(value) {
  14578. if (!value) return false;
  14579. return value.is_constant()
  14580. || value instanceof AST_Lambda
  14581. || value instanceof AST_This;
  14582. }
  14583. // A definition "escapes" when its value can leave the point of use.
  14584. // Example: `a = b || c`
  14585. // In this example, "b" and "c" are escaping, because they're going into "a"
  14586. //
  14587. // def.escaped is != 0 when it escapes.
  14588. //
  14589. // When greater than 1, it means that N chained properties will be read off
  14590. // of that def before an escape occurs. This is useful for evaluating
  14591. // property accesses, where you need to know when to stop.
  14592. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  14593. var parent = tw.parent(level);
  14594. if (value) {
  14595. if (value.is_constant()) return;
  14596. if (value instanceof AST_ClassExpression) return;
  14597. }
  14598. if (
  14599. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  14600. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  14601. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  14602. || parent instanceof AST_VarDef && node === parent.value
  14603. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  14604. ) {
  14605. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  14606. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  14607. return;
  14608. } else if (
  14609. parent instanceof AST_Array
  14610. || parent instanceof AST_Await
  14611. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  14612. || parent instanceof AST_Conditional && node !== parent.condition
  14613. || parent instanceof AST_Expansion
  14614. || parent instanceof AST_Sequence && node === parent.tail_node()
  14615. ) {
  14616. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  14617. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  14618. var obj = tw.parent(level + 1);
  14619. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  14620. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  14621. value = read_property(value, parent.property);
  14622. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  14623. if (value) return;
  14624. }
  14625. if (level > 0) return;
  14626. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  14627. if (parent instanceof AST_SimpleStatement) return;
  14628. d.direct_access = true;
  14629. }
  14630. const suppress = node => walk(node, node => {
  14631. if (!(node instanceof AST_Symbol)) return;
  14632. var d = node.definition();
  14633. if (!d) return;
  14634. if (node instanceof AST_SymbolRef) d.references.push(node);
  14635. d.fixed = false;
  14636. });
  14637. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  14638. push(tw);
  14639. reset_variables(tw, compressor, this);
  14640. descend();
  14641. pop(tw);
  14642. return true;
  14643. });
  14644. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  14645. var node = this;
  14646. if (node.left instanceof AST_Destructuring) {
  14647. suppress(node.left);
  14648. return;
  14649. }
  14650. const finish_walk = () => {
  14651. if (node.logical) {
  14652. node.left.walk(tw);
  14653. push(tw);
  14654. node.right.walk(tw);
  14655. pop(tw);
  14656. return true;
  14657. }
  14658. };
  14659. var sym = node.left;
  14660. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  14661. var def = sym.definition();
  14662. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  14663. def.assignments++;
  14664. if (!safe) return finish_walk();
  14665. var fixed = def.fixed;
  14666. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  14667. var eq = node.operator == "=";
  14668. var value = eq ? node.right : node;
  14669. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  14670. def.references.push(sym);
  14671. if (!node.logical) {
  14672. if (!eq) def.chained = true;
  14673. def.fixed = eq ? function() {
  14674. return node.right;
  14675. } : function() {
  14676. return make_node(AST_Binary, node, {
  14677. operator: node.operator.slice(0, -1),
  14678. left: fixed instanceof AST_Node ? fixed : fixed(),
  14679. right: node.right
  14680. });
  14681. };
  14682. }
  14683. if (node.logical) {
  14684. mark(tw, def, false);
  14685. push(tw);
  14686. node.right.walk(tw);
  14687. pop(tw);
  14688. return true;
  14689. }
  14690. mark(tw, def, false);
  14691. node.right.walk(tw);
  14692. mark(tw, def, true);
  14693. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  14694. return true;
  14695. });
  14696. def_reduce_vars(AST_Binary, function(tw) {
  14697. if (!lazy_op.has(this.operator)) return;
  14698. this.left.walk(tw);
  14699. push(tw);
  14700. this.right.walk(tw);
  14701. pop(tw);
  14702. return true;
  14703. });
  14704. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  14705. reset_block_variables(compressor, this);
  14706. });
  14707. def_reduce_vars(AST_Case, function(tw) {
  14708. push(tw);
  14709. this.expression.walk(tw);
  14710. pop(tw);
  14711. push(tw);
  14712. walk_body(this, tw);
  14713. pop(tw);
  14714. return true;
  14715. });
  14716. def_reduce_vars(AST_Class, function(tw, descend) {
  14717. clear_flag(this, INLINED);
  14718. push(tw);
  14719. descend();
  14720. pop(tw);
  14721. return true;
  14722. });
  14723. def_reduce_vars(AST_ClassStaticBlock, function(tw, descend, compressor) {
  14724. reset_block_variables(compressor, this);
  14725. });
  14726. def_reduce_vars(AST_Conditional, function(tw) {
  14727. this.condition.walk(tw);
  14728. push(tw);
  14729. this.consequent.walk(tw);
  14730. pop(tw);
  14731. push(tw);
  14732. this.alternative.walk(tw);
  14733. pop(tw);
  14734. return true;
  14735. });
  14736. def_reduce_vars(AST_Chain, function(tw, descend) {
  14737. // Chains' conditions apply left-to-right, cumulatively.
  14738. // If we walk normally we don't go in that order because we would pop before pushing again
  14739. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  14740. // Then we pop everything when they are done being walked.
  14741. const safe_ids = tw.safe_ids;
  14742. descend();
  14743. // Unroll back to start
  14744. tw.safe_ids = safe_ids;
  14745. return true;
  14746. });
  14747. def_reduce_vars(AST_Call, function (tw) {
  14748. this.expression.walk(tw);
  14749. if (this.optional) {
  14750. // Never pop -- it's popped at AST_Chain above
  14751. push(tw);
  14752. }
  14753. for (const arg of this.args) arg.walk(tw);
  14754. return true;
  14755. });
  14756. def_reduce_vars(AST_PropAccess, function (tw) {
  14757. if (!this.optional) return;
  14758. this.expression.walk(tw);
  14759. // Never pop -- it's popped at AST_Chain above
  14760. push(tw);
  14761. if (this.property instanceof AST_Node) this.property.walk(tw);
  14762. return true;
  14763. });
  14764. def_reduce_vars(AST_Default, function(tw, descend) {
  14765. push(tw);
  14766. descend();
  14767. pop(tw);
  14768. return true;
  14769. });
  14770. function mark_lambda(tw, descend, compressor) {
  14771. clear_flag(this, INLINED);
  14772. push(tw);
  14773. reset_variables(tw, compressor, this);
  14774. var iife;
  14775. if (!this.name
  14776. && !this.uses_arguments
  14777. && !this.pinned()
  14778. && (iife = tw.parent()) instanceof AST_Call
  14779. && iife.expression === this
  14780. && !iife.args.some(arg => arg instanceof AST_Expansion)
  14781. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  14782. ) {
  14783. // Virtually turn IIFE parameters into variable definitions:
  14784. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  14785. // So existing transformation rules can work on them.
  14786. this.argnames.forEach((arg, i) => {
  14787. if (!arg.definition) return;
  14788. var d = arg.definition();
  14789. // Avoid setting fixed when there's more than one origin for a variable value
  14790. if (d.orig.length > 1) return;
  14791. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  14792. d.fixed = function() {
  14793. return iife.args[i] || make_node(AST_Undefined, iife);
  14794. };
  14795. tw.loop_ids.set(d.id, tw.in_loop);
  14796. mark(tw, d, true);
  14797. } else {
  14798. d.fixed = false;
  14799. }
  14800. });
  14801. }
  14802. descend();
  14803. pop(tw);
  14804. handle_defined_after_hoist(this);
  14805. return true;
  14806. }
  14807. /**
  14808. * It's possible for a hoisted function to use something that's not defined yet. Example:
  14809. *
  14810. * hoisted();
  14811. * var defined_after = true;
  14812. * function hoisted() {
  14813. * // use defined_after
  14814. * }
  14815. *
  14816. * Or even indirectly:
  14817. *
  14818. * B();
  14819. * var defined_after = true;
  14820. * function A() {
  14821. * // use defined_after
  14822. * }
  14823. * function B() {
  14824. * A();
  14825. * }
  14826. *
  14827. * Access a variable before declaration will either throw a ReferenceError
  14828. * (if the variable is declared with `let` or `const`),
  14829. * or get an `undefined` (if the variable is declared with `var`).
  14830. *
  14831. * If the variable is inlined into the function, the behavior will change.
  14832. *
  14833. * This function is called on the parent to disallow inlining of such variables,
  14834. */
  14835. function handle_defined_after_hoist(parent) {
  14836. const defuns = [];
  14837. walk(parent, node => {
  14838. if (node === parent) return;
  14839. if (node instanceof AST_Defun) {
  14840. defuns.push(node);
  14841. return true;
  14842. }
  14843. if (
  14844. node instanceof AST_Scope
  14845. || node instanceof AST_SimpleStatement
  14846. ) return true;
  14847. });
  14848. // `defun` id to array of `defun` it uses
  14849. const defun_dependencies_map = new Map();
  14850. // `defun` id to array of enclosing `def` that are used by the function
  14851. const dependencies_map = new Map();
  14852. // all symbol ids that will be tracked for read/write
  14853. const symbols_of_interest = new Set();
  14854. const defuns_of_interest = new Set();
  14855. for (const defun of defuns) {
  14856. const fname_def = defun.name.definition();
  14857. const enclosing_defs = [];
  14858. for (const def of defun.enclosed) {
  14859. if (
  14860. def.fixed === false
  14861. || def === fname_def
  14862. || def.scope.get_defun_scope() !== parent
  14863. ) {
  14864. continue;
  14865. }
  14866. symbols_of_interest.add(def.id);
  14867. // found a reference to another function
  14868. if (
  14869. def.assignments === 0
  14870. && def.orig.length === 1
  14871. && def.orig[0] instanceof AST_SymbolDefun
  14872. ) {
  14873. defuns_of_interest.add(def.id);
  14874. symbols_of_interest.add(def.id);
  14875. defuns_of_interest.add(fname_def.id);
  14876. symbols_of_interest.add(fname_def.id);
  14877. if (!defun_dependencies_map.has(fname_def.id)) {
  14878. defun_dependencies_map.set(fname_def.id, []);
  14879. }
  14880. defun_dependencies_map.get(fname_def.id).push(def.id);
  14881. continue;
  14882. }
  14883. enclosing_defs.push(def);
  14884. }
  14885. if (enclosing_defs.length) {
  14886. dependencies_map.set(fname_def.id, enclosing_defs);
  14887. defuns_of_interest.add(fname_def.id);
  14888. symbols_of_interest.add(fname_def.id);
  14889. }
  14890. }
  14891. // No defuns use outside constants
  14892. if (!dependencies_map.size) {
  14893. return;
  14894. }
  14895. // Increment to count "symbols of interest" (defuns or defs) that we found.
  14896. // These are tracked in AST order so we can check which is after which.
  14897. let symbol_index = 1;
  14898. // Map a defun ID to its first read (a `symbol_index`)
  14899. const defun_first_read_map = new Map();
  14900. // Map a symbol ID to its last write (a `symbol_index`)
  14901. const symbol_last_write_map = new Map();
  14902. walk_parent(parent, (node, walk_info) => {
  14903. if (node instanceof AST_Symbol && node.thedef) {
  14904. const id = node.definition().id;
  14905. symbol_index++;
  14906. // Track last-writes to symbols
  14907. if (symbols_of_interest.has(id)) {
  14908. if (node instanceof AST_SymbolDeclaration || is_lhs(node, walk_info.parent())) {
  14909. symbol_last_write_map.set(id, symbol_index);
  14910. }
  14911. }
  14912. // Track first-reads of defuns (refined later)
  14913. if (defuns_of_interest.has(id)) {
  14914. if (!defun_first_read_map.has(id) && !is_recursive_ref(walk_info, id)) {
  14915. defun_first_read_map.set(id, symbol_index);
  14916. }
  14917. }
  14918. }
  14919. });
  14920. // Refine `defun_first_read_map` to be as high as possible
  14921. for (const [defun, defun_first_read] of defun_first_read_map) {
  14922. // Update all depdencies of `defun`
  14923. const queue = new Set(defun_dependencies_map.get(defun));
  14924. for (const enclosed_defun of queue) {
  14925. let enclosed_defun_first_read = defun_first_read_map.get(enclosed_defun);
  14926. if (enclosed_defun_first_read != null && enclosed_defun_first_read < defun_first_read) {
  14927. continue;
  14928. }
  14929. defun_first_read_map.set(enclosed_defun, defun_first_read);
  14930. for (const enclosed_enclosed_defun of defun_dependencies_map.get(enclosed_defun) || []) {
  14931. queue.add(enclosed_enclosed_defun);
  14932. }
  14933. }
  14934. }
  14935. // ensure write-then-read order, otherwise clear `fixed`
  14936. // 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.
  14937. for (const [defun, defs] of dependencies_map) {
  14938. const defun_first_read = defun_first_read_map.get(defun);
  14939. if (defun_first_read === undefined) {
  14940. continue;
  14941. }
  14942. for (const def of defs) {
  14943. if (def.fixed === false) {
  14944. continue;
  14945. }
  14946. let def_last_write = symbol_last_write_map.get(def.id) || 0;
  14947. if (defun_first_read < def_last_write) {
  14948. def.fixed = false;
  14949. }
  14950. }
  14951. }
  14952. }
  14953. def_reduce_vars(AST_Lambda, mark_lambda);
  14954. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  14955. reset_block_variables(compressor, this);
  14956. const saved_loop = tw.in_loop;
  14957. tw.in_loop = this;
  14958. push(tw);
  14959. this.body.walk(tw);
  14960. if (has_break_or_continue(this)) {
  14961. pop(tw);
  14962. push(tw);
  14963. }
  14964. this.condition.walk(tw);
  14965. pop(tw);
  14966. tw.in_loop = saved_loop;
  14967. return true;
  14968. });
  14969. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  14970. reset_block_variables(compressor, this);
  14971. if (this.init) this.init.walk(tw);
  14972. const saved_loop = tw.in_loop;
  14973. tw.in_loop = this;
  14974. push(tw);
  14975. if (this.condition) this.condition.walk(tw);
  14976. this.body.walk(tw);
  14977. if (this.step) {
  14978. if (has_break_or_continue(this)) {
  14979. pop(tw);
  14980. push(tw);
  14981. }
  14982. this.step.walk(tw);
  14983. }
  14984. pop(tw);
  14985. tw.in_loop = saved_loop;
  14986. return true;
  14987. });
  14988. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  14989. reset_block_variables(compressor, this);
  14990. suppress(this.init);
  14991. this.object.walk(tw);
  14992. const saved_loop = tw.in_loop;
  14993. tw.in_loop = this;
  14994. push(tw);
  14995. this.body.walk(tw);
  14996. pop(tw);
  14997. tw.in_loop = saved_loop;
  14998. return true;
  14999. });
  15000. def_reduce_vars(AST_If, function(tw) {
  15001. this.condition.walk(tw);
  15002. push(tw);
  15003. this.body.walk(tw);
  15004. pop(tw);
  15005. if (this.alternative) {
  15006. push(tw);
  15007. this.alternative.walk(tw);
  15008. pop(tw);
  15009. }
  15010. return true;
  15011. });
  15012. def_reduce_vars(AST_LabeledStatement, function(tw) {
  15013. push(tw);
  15014. this.body.walk(tw);
  15015. pop(tw);
  15016. return true;
  15017. });
  15018. def_reduce_vars(AST_SymbolCatch, function() {
  15019. this.definition().fixed = false;
  15020. });
  15021. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  15022. var d = this.definition();
  15023. d.references.push(this);
  15024. if (d.references.length == 1
  15025. && !d.fixed
  15026. && d.orig[0] instanceof AST_SymbolDefun) {
  15027. tw.loop_ids.set(d.id, tw.in_loop);
  15028. }
  15029. var fixed_value;
  15030. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  15031. d.fixed = false;
  15032. } else if (d.fixed) {
  15033. fixed_value = this.fixed_value();
  15034. if (
  15035. fixed_value instanceof AST_Lambda
  15036. && is_recursive_ref(tw, d)
  15037. ) {
  15038. d.recursive_refs++;
  15039. } else if (fixed_value
  15040. && !compressor.exposed(d)
  15041. && ref_once(tw, compressor, d)
  15042. ) {
  15043. d.single_use =
  15044. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  15045. || fixed_value instanceof AST_Class
  15046. || d.scope === this.scope && fixed_value.is_constant_expression();
  15047. } else {
  15048. d.single_use = false;
  15049. }
  15050. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  15051. if (d.single_use) {
  15052. d.single_use = "m";
  15053. } else {
  15054. d.fixed = false;
  15055. }
  15056. }
  15057. }
  15058. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  15059. });
  15060. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  15061. this.globals.forEach(function(def) {
  15062. reset_def(compressor, def);
  15063. });
  15064. reset_variables(tw, compressor, this);
  15065. descend();
  15066. handle_defined_after_hoist(this);
  15067. return true;
  15068. });
  15069. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  15070. reset_block_variables(compressor, this);
  15071. push(tw);
  15072. this.body.walk(tw);
  15073. pop(tw);
  15074. if (this.bcatch) {
  15075. push(tw);
  15076. this.bcatch.walk(tw);
  15077. pop(tw);
  15078. }
  15079. if (this.bfinally) this.bfinally.walk(tw);
  15080. return true;
  15081. });
  15082. def_reduce_vars(AST_Unary, function(tw) {
  15083. var node = this;
  15084. if (node.operator !== "++" && node.operator !== "--") return;
  15085. var exp = node.expression;
  15086. if (!(exp instanceof AST_SymbolRef)) return;
  15087. var def = exp.definition();
  15088. var safe = safe_to_assign(tw, def, exp.scope, true);
  15089. def.assignments++;
  15090. if (!safe) return;
  15091. var fixed = def.fixed;
  15092. if (!fixed) return;
  15093. def.references.push(exp);
  15094. def.chained = true;
  15095. def.fixed = function() {
  15096. return make_node(AST_Binary, node, {
  15097. operator: node.operator.slice(0, -1),
  15098. left: make_node(AST_UnaryPrefix, node, {
  15099. operator: "+",
  15100. expression: fixed instanceof AST_Node ? fixed : fixed()
  15101. }),
  15102. right: make_node(AST_Number, node, {
  15103. value: 1
  15104. })
  15105. });
  15106. };
  15107. mark(tw, def, true);
  15108. return true;
  15109. });
  15110. def_reduce_vars(AST_VarDef, function(tw, descend) {
  15111. var node = this;
  15112. if (node.name instanceof AST_Destructuring) {
  15113. suppress(node.name);
  15114. return;
  15115. }
  15116. var d = node.name.definition();
  15117. if (node.value) {
  15118. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  15119. d.fixed = function() {
  15120. return node.value;
  15121. };
  15122. tw.loop_ids.set(d.id, tw.in_loop);
  15123. mark(tw, d, false);
  15124. descend();
  15125. mark(tw, d, true);
  15126. return true;
  15127. } else {
  15128. d.fixed = false;
  15129. }
  15130. }
  15131. });
  15132. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  15133. reset_block_variables(compressor, this);
  15134. const saved_loop = tw.in_loop;
  15135. tw.in_loop = this;
  15136. push(tw);
  15137. descend();
  15138. pop(tw);
  15139. tw.in_loop = saved_loop;
  15140. return true;
  15141. });
  15142. /***********************************************************************
  15143. A JavaScript tokenizer / parser / beautifier / compressor.
  15144. https://github.com/mishoo/UglifyJS2
  15145. -------------------------------- (C) ---------------------------------
  15146. Author: Mihai Bazon
  15147. <mihai.bazon@gmail.com>
  15148. http://mihai.bazon.net/blog
  15149. Distributed under the BSD license:
  15150. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15151. Redistribution and use in source and binary forms, with or without
  15152. modification, are permitted provided that the following conditions
  15153. are met:
  15154. * Redistributions of source code must retain the above
  15155. copyright notice, this list of conditions and the following
  15156. disclaimer.
  15157. * Redistributions in binary form must reproduce the above
  15158. copyright notice, this list of conditions and the following
  15159. disclaimer in the documentation and/or other materials
  15160. provided with the distribution.
  15161. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15162. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15163. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15164. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15165. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15166. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15167. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15168. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15169. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15170. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15171. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15172. SUCH DAMAGE.
  15173. ***********************************************************************/
  15174. function loop_body(x) {
  15175. if (x instanceof AST_IterationStatement) {
  15176. return x.body instanceof AST_BlockStatement ? x.body : x;
  15177. }
  15178. return x;
  15179. }
  15180. function is_lhs_read_only(lhs) {
  15181. if (lhs instanceof AST_This) return true;
  15182. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  15183. if (lhs instanceof AST_PropAccess) {
  15184. lhs = lhs.expression;
  15185. if (lhs instanceof AST_SymbolRef) {
  15186. if (lhs.is_immutable()) return false;
  15187. lhs = lhs.fixed_value();
  15188. }
  15189. if (!lhs) return true;
  15190. if (lhs instanceof AST_RegExp) return false;
  15191. if (lhs instanceof AST_Constant) return true;
  15192. return is_lhs_read_only(lhs);
  15193. }
  15194. return false;
  15195. }
  15196. /** var a = 1 --> var a*/
  15197. function remove_initializers(var_statement) {
  15198. var decls = [];
  15199. var_statement.definitions.forEach(function(def) {
  15200. if (def.name instanceof AST_SymbolDeclaration) {
  15201. def.value = null;
  15202. decls.push(def);
  15203. } else {
  15204. def.declarations_as_names().forEach(name => {
  15205. decls.push(make_node(AST_VarDef, def, {
  15206. name,
  15207. value: null
  15208. }));
  15209. });
  15210. }
  15211. });
  15212. return decls.length ? make_node(AST_Var, var_statement, { definitions: decls }) : null;
  15213. }
  15214. /** Called on code which we know is unreachable, to keep elements that affect outside of it. */
  15215. function trim_unreachable_code(compressor, stat, target) {
  15216. walk(stat, node => {
  15217. if (node instanceof AST_Var) {
  15218. const no_initializers = remove_initializers(node);
  15219. if (no_initializers) target.push(no_initializers);
  15220. return true;
  15221. }
  15222. if (
  15223. node instanceof AST_Defun
  15224. && (node === stat || !compressor.has_directive("use strict"))
  15225. ) {
  15226. target.push(node === stat ? node : make_node(AST_Var, node, {
  15227. definitions: [
  15228. make_node(AST_VarDef, node, {
  15229. name: make_node(AST_SymbolVar, node.name, node.name),
  15230. value: null
  15231. })
  15232. ]
  15233. }));
  15234. return true;
  15235. }
  15236. if (node instanceof AST_Export || node instanceof AST_Import) {
  15237. target.push(node);
  15238. return true;
  15239. }
  15240. if (node instanceof AST_Scope) {
  15241. return true;
  15242. }
  15243. });
  15244. }
  15245. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  15246. function tighten_body(statements, compressor) {
  15247. const nearest_scope = compressor.find_scope();
  15248. const defun_scope = nearest_scope.get_defun_scope();
  15249. const { in_loop, in_try } = find_loop_scope_try();
  15250. var CHANGED, max_iter = 10;
  15251. do {
  15252. CHANGED = false;
  15253. eliminate_spurious_blocks(statements);
  15254. if (compressor.option("dead_code")) {
  15255. eliminate_dead_code(statements, compressor);
  15256. }
  15257. if (compressor.option("if_return")) {
  15258. handle_if_return(statements, compressor);
  15259. }
  15260. if (compressor.sequences_limit > 0) {
  15261. sequencesize(statements, compressor);
  15262. sequencesize_2(statements, compressor);
  15263. }
  15264. if (compressor.option("join_vars")) {
  15265. join_consecutive_vars(statements);
  15266. }
  15267. if (compressor.option("collapse_vars")) {
  15268. collapse(statements, compressor);
  15269. }
  15270. } while (CHANGED && max_iter-- > 0);
  15271. function find_loop_scope_try() {
  15272. var node = compressor.self(), level = 0, in_loop = false, in_try = false;
  15273. do {
  15274. if (node instanceof AST_IterationStatement) {
  15275. in_loop = true;
  15276. } else if (node instanceof AST_Scope) {
  15277. break;
  15278. } else if (node instanceof AST_TryBlock) {
  15279. in_try = true;
  15280. }
  15281. } while (node = compressor.parent(level++));
  15282. return { in_loop, in_try };
  15283. }
  15284. // Search from right to left for assignment-like expressions:
  15285. // - `var a = x;`
  15286. // - `a = x;`
  15287. // - `++a`
  15288. // For each candidate, scan from left to right for first usage, then try
  15289. // to fold assignment into the site for compression.
  15290. // Will not attempt to collapse assignments into or past code blocks
  15291. // which are not sequentially executed, e.g. loops and conditionals.
  15292. function collapse(statements, compressor) {
  15293. if (nearest_scope.pinned() || defun_scope.pinned())
  15294. return statements;
  15295. var args;
  15296. var candidates = [];
  15297. var stat_index = statements.length;
  15298. var scanner = new TreeTransformer(function (node) {
  15299. if (abort)
  15300. return node;
  15301. // Skip nodes before `candidate` as quickly as possible
  15302. if (!hit) {
  15303. if (node !== hit_stack[hit_index])
  15304. return node;
  15305. hit_index++;
  15306. if (hit_index < hit_stack.length)
  15307. return handle_custom_scan_order(node);
  15308. hit = true;
  15309. stop_after = find_stop(node, 0);
  15310. if (stop_after === node)
  15311. abort = true;
  15312. return node;
  15313. }
  15314. // Stop immediately if these node types are encountered
  15315. var parent = scanner.parent();
  15316. if (node instanceof AST_Assign
  15317. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  15318. || node instanceof AST_Await
  15319. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  15320. ||
  15321. (node instanceof AST_Call || node instanceof AST_PropAccess)
  15322. && node.optional
  15323. || node instanceof AST_Debugger
  15324. || node instanceof AST_Destructuring
  15325. || node instanceof AST_Expansion
  15326. && node.expression instanceof AST_Symbol
  15327. && (
  15328. node.expression instanceof AST_This
  15329. || node.expression.definition().references.length > 1
  15330. )
  15331. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  15332. || node instanceof AST_LoopControl
  15333. || node instanceof AST_Try
  15334. || node instanceof AST_With
  15335. || node instanceof AST_Yield
  15336. || node instanceof AST_Export
  15337. || node instanceof AST_Class
  15338. || parent instanceof AST_For && node !== parent.init
  15339. || !replace_all
  15340. && (
  15341. node instanceof AST_SymbolRef
  15342. && !node.is_declared(compressor)
  15343. && !pure_prop_access_globals.has(node)
  15344. )
  15345. || node instanceof AST_SymbolRef
  15346. && parent instanceof AST_Call
  15347. && has_annotation(parent, _NOINLINE)
  15348. || node instanceof AST_ObjectProperty && node.key instanceof AST_Node
  15349. ) {
  15350. abort = true;
  15351. return node;
  15352. }
  15353. // Stop only if candidate is found within conditional branches
  15354. if (!stop_if_hit && (!lhs_local || !replace_all)
  15355. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  15356. || parent instanceof AST_Conditional && parent.condition !== node
  15357. || parent instanceof AST_If && parent.condition !== node)) {
  15358. stop_if_hit = parent;
  15359. }
  15360. // Replace variable with assignment when found
  15361. if (
  15362. can_replace
  15363. && !(node instanceof AST_SymbolDeclaration)
  15364. && lhs.equivalent_to(node)
  15365. && !shadows(scanner.find_scope() || nearest_scope, lvalues)
  15366. ) {
  15367. if (stop_if_hit) {
  15368. abort = true;
  15369. return node;
  15370. }
  15371. if (is_lhs(node, parent)) {
  15372. if (value_def)
  15373. replaced++;
  15374. return node;
  15375. } else {
  15376. replaced++;
  15377. if (value_def && candidate instanceof AST_VarDef)
  15378. return node;
  15379. }
  15380. CHANGED = abort = true;
  15381. if (candidate instanceof AST_UnaryPostfix) {
  15382. return make_node(AST_UnaryPrefix, candidate, candidate);
  15383. }
  15384. if (candidate instanceof AST_VarDef) {
  15385. var def = candidate.name.definition();
  15386. var value = candidate.value;
  15387. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  15388. def.replaced++;
  15389. if (funarg && is_identifier_atom(value)) {
  15390. return value.transform(compressor);
  15391. } else {
  15392. return maintain_this_binding(parent, node, value);
  15393. }
  15394. }
  15395. return make_node(AST_Assign, candidate, {
  15396. operator: "=",
  15397. logical: false,
  15398. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  15399. right: value
  15400. });
  15401. }
  15402. clear_flag(candidate, WRITE_ONLY);
  15403. return candidate;
  15404. }
  15405. // These node types have child nodes that execute sequentially,
  15406. // but are otherwise not safe to scan into or beyond them.
  15407. var sym;
  15408. if (node instanceof AST_Call
  15409. || node instanceof AST_Exit
  15410. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  15411. || node instanceof AST_PropAccess
  15412. && (side_effects || node.expression.may_throw_on_access(compressor))
  15413. || node instanceof AST_SymbolRef
  15414. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  15415. || node instanceof AST_VarDef && node.value
  15416. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  15417. || (sym = is_lhs(node.left, node))
  15418. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  15419. || may_throw
  15420. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  15421. stop_after = node;
  15422. if (node instanceof AST_Scope)
  15423. abort = true;
  15424. }
  15425. return handle_custom_scan_order(node);
  15426. }, function (node) {
  15427. if (abort)
  15428. return;
  15429. if (stop_after === node)
  15430. abort = true;
  15431. if (stop_if_hit === node)
  15432. stop_if_hit = null;
  15433. });
  15434. var multi_replacer = new TreeTransformer(function (node) {
  15435. if (abort)
  15436. return node;
  15437. // Skip nodes before `candidate` as quickly as possible
  15438. if (!hit) {
  15439. if (node !== hit_stack[hit_index])
  15440. return node;
  15441. hit_index++;
  15442. if (hit_index < hit_stack.length)
  15443. return;
  15444. hit = true;
  15445. return node;
  15446. }
  15447. // Replace variable when found
  15448. if (node instanceof AST_SymbolRef
  15449. && node.name == def.name) {
  15450. if (!--replaced)
  15451. abort = true;
  15452. if (is_lhs(node, multi_replacer.parent()))
  15453. return node;
  15454. def.replaced++;
  15455. value_def.replaced--;
  15456. return candidate.value;
  15457. }
  15458. // Skip (non-executed) functions and (leading) default case in switch statements
  15459. if (node instanceof AST_Default || node instanceof AST_Scope)
  15460. return node;
  15461. });
  15462. while (--stat_index >= 0) {
  15463. // Treat parameters as collapsible in IIFE, i.e.
  15464. // function(a, b){ ... }(x());
  15465. // would be translated into equivalent assignments:
  15466. // var a = x(), b = undefined;
  15467. if (stat_index == 0 && compressor.option("unused"))
  15468. extract_args();
  15469. // Find collapsible assignments
  15470. var hit_stack = [];
  15471. extract_candidates(statements[stat_index]);
  15472. while (candidates.length > 0) {
  15473. hit_stack = candidates.pop();
  15474. var hit_index = 0;
  15475. var candidate = hit_stack[hit_stack.length - 1];
  15476. var value_def = null;
  15477. var stop_after = null;
  15478. var stop_if_hit = null;
  15479. var lhs = get_lhs(candidate);
  15480. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  15481. continue;
  15482. // Locate symbols which may execute code outside of scanning range
  15483. var lvalues = get_lvalues(candidate);
  15484. var lhs_local = is_lhs_local(lhs);
  15485. if (lhs instanceof AST_SymbolRef) {
  15486. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  15487. }
  15488. var side_effects = value_has_side_effects(candidate);
  15489. var replace_all = replace_all_symbols();
  15490. var may_throw = candidate.may_throw(compressor);
  15491. var funarg = candidate.name instanceof AST_SymbolFunarg;
  15492. var hit = funarg;
  15493. var abort = false, replaced = 0, can_replace = !args || !hit;
  15494. if (!can_replace) {
  15495. for (
  15496. let j = compressor.self().argnames.lastIndexOf(candidate.name) + 1;
  15497. !abort && j < args.length;
  15498. j++
  15499. ) {
  15500. args[j].transform(scanner);
  15501. }
  15502. can_replace = true;
  15503. }
  15504. for (var i = stat_index; !abort && i < statements.length; i++) {
  15505. statements[i].transform(scanner);
  15506. }
  15507. if (value_def) {
  15508. var def = candidate.name.definition();
  15509. if (abort && def.references.length - def.replaced > replaced)
  15510. replaced = false;
  15511. else {
  15512. abort = false;
  15513. hit_index = 0;
  15514. hit = funarg;
  15515. for (var i = stat_index; !abort && i < statements.length; i++) {
  15516. statements[i].transform(multi_replacer);
  15517. }
  15518. value_def.single_use = false;
  15519. }
  15520. }
  15521. if (replaced && !remove_candidate(candidate))
  15522. statements.splice(stat_index, 1);
  15523. }
  15524. }
  15525. function handle_custom_scan_order(node) {
  15526. // Skip (non-executed) functions
  15527. if (node instanceof AST_Scope)
  15528. return node;
  15529. // Scan case expressions first in a switch statement
  15530. if (node instanceof AST_Switch) {
  15531. node.expression = node.expression.transform(scanner);
  15532. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  15533. var branch = node.body[i];
  15534. if (branch instanceof AST_Case) {
  15535. if (!hit) {
  15536. if (branch !== hit_stack[hit_index])
  15537. continue;
  15538. hit_index++;
  15539. }
  15540. branch.expression = branch.expression.transform(scanner);
  15541. if (!replace_all)
  15542. break;
  15543. }
  15544. }
  15545. abort = true;
  15546. return node;
  15547. }
  15548. }
  15549. function redefined_within_scope(def, scope) {
  15550. if (def.global)
  15551. return false;
  15552. let cur_scope = def.scope;
  15553. while (cur_scope && cur_scope !== scope) {
  15554. if (cur_scope.variables.has(def.name)) {
  15555. return true;
  15556. }
  15557. cur_scope = cur_scope.parent_scope;
  15558. }
  15559. return false;
  15560. }
  15561. function has_overlapping_symbol(fn, arg, fn_strict) {
  15562. var found = false, scan_this = !(fn instanceof AST_Arrow);
  15563. arg.walk(new TreeWalker(function (node, descend) {
  15564. if (found)
  15565. return true;
  15566. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  15567. var s = node.definition().scope;
  15568. if (s !== defun_scope)
  15569. while (s = s.parent_scope) {
  15570. if (s === defun_scope)
  15571. return true;
  15572. }
  15573. return found = true;
  15574. }
  15575. if ((fn_strict || scan_this) && node instanceof AST_This) {
  15576. return found = true;
  15577. }
  15578. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  15579. var prev = scan_this;
  15580. scan_this = false;
  15581. descend();
  15582. scan_this = prev;
  15583. return true;
  15584. }
  15585. }));
  15586. return found;
  15587. }
  15588. function arg_is_injectable(arg) {
  15589. if (arg instanceof AST_Expansion) return false;
  15590. const contains_await = walk(arg, (node) => {
  15591. if (node instanceof AST_Await) return walk_abort;
  15592. });
  15593. if (contains_await) return false;
  15594. return true;
  15595. }
  15596. function extract_args() {
  15597. var iife, fn = compressor.self();
  15598. if (is_func_expr(fn)
  15599. && !fn.name
  15600. && !fn.uses_arguments
  15601. && !fn.pinned()
  15602. && (iife = compressor.parent()) instanceof AST_Call
  15603. && iife.expression === fn
  15604. && iife.args.every(arg_is_injectable)
  15605. ) {
  15606. var fn_strict = compressor.has_directive("use strict");
  15607. if (fn_strict && !member(fn_strict, fn.body))
  15608. fn_strict = false;
  15609. var len = fn.argnames.length;
  15610. args = iife.args.slice(len);
  15611. var names = new Set();
  15612. for (var i = len; --i >= 0;) {
  15613. var sym = fn.argnames[i];
  15614. var arg = iife.args[i];
  15615. // The following two line fix is a duplicate of the fix at
  15616. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  15617. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  15618. // Might be doing the exact same thing.
  15619. const def = sym.definition && sym.definition();
  15620. const is_reassigned = def && def.orig.length > 1;
  15621. if (is_reassigned)
  15622. continue;
  15623. args.unshift(make_node(AST_VarDef, sym, {
  15624. name: sym,
  15625. value: arg
  15626. }));
  15627. if (names.has(sym.name))
  15628. continue;
  15629. names.add(sym.name);
  15630. if (sym instanceof AST_Expansion) {
  15631. var elements = iife.args.slice(i);
  15632. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  15633. )) {
  15634. candidates.unshift([make_node(AST_VarDef, sym, {
  15635. name: sym.expression,
  15636. value: make_node(AST_Array, iife, {
  15637. elements: elements
  15638. })
  15639. })]);
  15640. }
  15641. } else {
  15642. if (!arg) {
  15643. arg = make_node(AST_Undefined, sym).transform(compressor);
  15644. } else if (arg instanceof AST_Lambda && arg.pinned()
  15645. || has_overlapping_symbol(fn, arg, fn_strict)) {
  15646. arg = null;
  15647. }
  15648. if (arg)
  15649. candidates.unshift([make_node(AST_VarDef, sym, {
  15650. name: sym,
  15651. value: arg
  15652. })]);
  15653. }
  15654. }
  15655. }
  15656. }
  15657. function extract_candidates(expr) {
  15658. hit_stack.push(expr);
  15659. if (expr instanceof AST_Assign) {
  15660. if (!expr.left.has_side_effects(compressor)
  15661. && !(expr.right instanceof AST_Chain)) {
  15662. candidates.push(hit_stack.slice());
  15663. }
  15664. extract_candidates(expr.right);
  15665. } else if (expr instanceof AST_Binary) {
  15666. extract_candidates(expr.left);
  15667. extract_candidates(expr.right);
  15668. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  15669. extract_candidates(expr.expression);
  15670. expr.args.forEach(extract_candidates);
  15671. } else if (expr instanceof AST_Case) {
  15672. extract_candidates(expr.expression);
  15673. } else if (expr instanceof AST_Conditional) {
  15674. extract_candidates(expr.condition);
  15675. extract_candidates(expr.consequent);
  15676. extract_candidates(expr.alternative);
  15677. } else if (expr instanceof AST_Definitions) {
  15678. var len = expr.definitions.length;
  15679. // limit number of trailing variable definitions for consideration
  15680. var i = len - 200;
  15681. if (i < 0)
  15682. i = 0;
  15683. for (; i < len; i++) {
  15684. extract_candidates(expr.definitions[i]);
  15685. }
  15686. } else if (expr instanceof AST_DWLoop) {
  15687. extract_candidates(expr.condition);
  15688. if (!(expr.body instanceof AST_Block)) {
  15689. extract_candidates(expr.body);
  15690. }
  15691. } else if (expr instanceof AST_Exit) {
  15692. if (expr.value)
  15693. extract_candidates(expr.value);
  15694. } else if (expr instanceof AST_For) {
  15695. if (expr.init)
  15696. extract_candidates(expr.init);
  15697. if (expr.condition)
  15698. extract_candidates(expr.condition);
  15699. if (expr.step)
  15700. extract_candidates(expr.step);
  15701. if (!(expr.body instanceof AST_Block)) {
  15702. extract_candidates(expr.body);
  15703. }
  15704. } else if (expr instanceof AST_ForIn) {
  15705. extract_candidates(expr.object);
  15706. if (!(expr.body instanceof AST_Block)) {
  15707. extract_candidates(expr.body);
  15708. }
  15709. } else if (expr instanceof AST_If) {
  15710. extract_candidates(expr.condition);
  15711. if (!(expr.body instanceof AST_Block)) {
  15712. extract_candidates(expr.body);
  15713. }
  15714. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  15715. extract_candidates(expr.alternative);
  15716. }
  15717. } else if (expr instanceof AST_Sequence) {
  15718. expr.expressions.forEach(extract_candidates);
  15719. } else if (expr instanceof AST_SimpleStatement) {
  15720. extract_candidates(expr.body);
  15721. } else if (expr instanceof AST_Switch) {
  15722. extract_candidates(expr.expression);
  15723. expr.body.forEach(extract_candidates);
  15724. } else if (expr instanceof AST_Unary) {
  15725. if (expr.operator == "++" || expr.operator == "--") {
  15726. candidates.push(hit_stack.slice());
  15727. }
  15728. } else if (expr instanceof AST_VarDef) {
  15729. if (expr.value && !(expr.value instanceof AST_Chain)) {
  15730. candidates.push(hit_stack.slice());
  15731. extract_candidates(expr.value);
  15732. }
  15733. }
  15734. hit_stack.pop();
  15735. }
  15736. function find_stop(node, level, write_only) {
  15737. var parent = scanner.parent(level);
  15738. if (parent instanceof AST_Assign) {
  15739. if (write_only
  15740. && !parent.logical
  15741. && !(parent.left instanceof AST_PropAccess
  15742. || lvalues.has(parent.left.name))) {
  15743. return find_stop(parent, level + 1, write_only);
  15744. }
  15745. return node;
  15746. }
  15747. if (parent instanceof AST_Binary) {
  15748. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  15749. return find_stop(parent, level + 1, write_only);
  15750. }
  15751. return node;
  15752. }
  15753. if (parent instanceof AST_Call)
  15754. return node;
  15755. if (parent instanceof AST_Case)
  15756. return node;
  15757. if (parent instanceof AST_Conditional) {
  15758. if (write_only && parent.condition === node) {
  15759. return find_stop(parent, level + 1, write_only);
  15760. }
  15761. return node;
  15762. }
  15763. if (parent instanceof AST_Definitions) {
  15764. return find_stop(parent, level + 1, true);
  15765. }
  15766. if (parent instanceof AST_Exit) {
  15767. return write_only ? find_stop(parent, level + 1, write_only) : node;
  15768. }
  15769. if (parent instanceof AST_If) {
  15770. if (write_only && parent.condition === node) {
  15771. return find_stop(parent, level + 1, write_only);
  15772. }
  15773. return node;
  15774. }
  15775. if (parent instanceof AST_IterationStatement)
  15776. return node;
  15777. if (parent instanceof AST_Sequence) {
  15778. return find_stop(parent, level + 1, parent.tail_node() !== node);
  15779. }
  15780. if (parent instanceof AST_SimpleStatement) {
  15781. return find_stop(parent, level + 1, true);
  15782. }
  15783. if (parent instanceof AST_Switch)
  15784. return node;
  15785. if (parent instanceof AST_VarDef)
  15786. return node;
  15787. return null;
  15788. }
  15789. function mangleable_var(var_def) {
  15790. var value = var_def.value;
  15791. if (!(value instanceof AST_SymbolRef))
  15792. return;
  15793. if (value.name == "arguments")
  15794. return;
  15795. var def = value.definition();
  15796. if (def.undeclared)
  15797. return;
  15798. return value_def = def;
  15799. }
  15800. function get_lhs(expr) {
  15801. if (expr instanceof AST_Assign && expr.logical) {
  15802. return false;
  15803. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  15804. var def = expr.name.definition();
  15805. if (!member(expr.name, def.orig))
  15806. return;
  15807. var referenced = def.references.length - def.replaced;
  15808. if (!referenced)
  15809. return;
  15810. var declared = def.orig.length - def.eliminated;
  15811. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  15812. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  15813. return make_node(AST_SymbolRef, expr.name, expr.name);
  15814. }
  15815. } else {
  15816. const lhs = expr instanceof AST_Assign
  15817. ? expr.left
  15818. : expr.expression;
  15819. return !is_ref_of(lhs, AST_SymbolConst)
  15820. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  15821. }
  15822. }
  15823. function get_rvalue(expr) {
  15824. if (expr instanceof AST_Assign) {
  15825. return expr.right;
  15826. } else {
  15827. return expr.value;
  15828. }
  15829. }
  15830. function get_lvalues(expr) {
  15831. var lvalues = new Map();
  15832. if (expr instanceof AST_Unary)
  15833. return lvalues;
  15834. var tw = new TreeWalker(function (node) {
  15835. var sym = node;
  15836. while (sym instanceof AST_PropAccess)
  15837. sym = sym.expression;
  15838. if (sym instanceof AST_SymbolRef) {
  15839. const prev = lvalues.get(sym.name);
  15840. if (!prev || !prev.modified) {
  15841. lvalues.set(sym.name, {
  15842. def: sym.definition(),
  15843. modified: is_modified(compressor, tw, node, node, 0)
  15844. });
  15845. }
  15846. }
  15847. });
  15848. get_rvalue(expr).walk(tw);
  15849. return lvalues;
  15850. }
  15851. function remove_candidate(expr) {
  15852. if (expr.name instanceof AST_SymbolFunarg) {
  15853. var iife = compressor.parent(), argnames = compressor.self().argnames;
  15854. var index = argnames.indexOf(expr.name);
  15855. if (index < 0) {
  15856. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  15857. } else {
  15858. var args = iife.args;
  15859. if (args[index])
  15860. args[index] = make_node(AST_Number, args[index], {
  15861. value: 0
  15862. });
  15863. }
  15864. return true;
  15865. }
  15866. var found = false;
  15867. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  15868. if (found)
  15869. return node;
  15870. if (node === expr || node.body === expr) {
  15871. found = true;
  15872. if (node instanceof AST_VarDef) {
  15873. node.value = node.name instanceof AST_SymbolConst
  15874. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  15875. : null;
  15876. return node;
  15877. }
  15878. return in_list ? MAP.skip : null;
  15879. }
  15880. }, function (node) {
  15881. if (node instanceof AST_Sequence)
  15882. switch (node.expressions.length) {
  15883. case 0: return null;
  15884. case 1: return node.expressions[0];
  15885. }
  15886. }));
  15887. }
  15888. function is_lhs_local(lhs) {
  15889. while (lhs instanceof AST_PropAccess)
  15890. lhs = lhs.expression;
  15891. return lhs instanceof AST_SymbolRef
  15892. && lhs.definition().scope.get_defun_scope() === defun_scope
  15893. && !(in_loop
  15894. && (lvalues.has(lhs.name)
  15895. || candidate instanceof AST_Unary
  15896. || (candidate instanceof AST_Assign
  15897. && !candidate.logical
  15898. && candidate.operator != "=")));
  15899. }
  15900. function value_has_side_effects(expr) {
  15901. if (expr instanceof AST_Unary)
  15902. return unary_side_effects.has(expr.operator);
  15903. return get_rvalue(expr).has_side_effects(compressor);
  15904. }
  15905. function replace_all_symbols() {
  15906. if (side_effects)
  15907. return false;
  15908. if (value_def)
  15909. return true;
  15910. if (lhs instanceof AST_SymbolRef) {
  15911. var def = lhs.definition();
  15912. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  15913. return true;
  15914. }
  15915. }
  15916. return false;
  15917. }
  15918. function may_modify(sym) {
  15919. if (!sym.definition)
  15920. return true; // AST_Destructuring
  15921. var def = sym.definition();
  15922. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  15923. return false;
  15924. if (def.scope.get_defun_scope() !== defun_scope)
  15925. return true;
  15926. return def.references.some((ref) =>
  15927. ref.scope.get_defun_scope() !== defun_scope
  15928. );
  15929. }
  15930. function side_effects_external(node, lhs) {
  15931. if (node instanceof AST_Assign)
  15932. return side_effects_external(node.left, true);
  15933. if (node instanceof AST_Unary)
  15934. return side_effects_external(node.expression, true);
  15935. if (node instanceof AST_VarDef)
  15936. return node.value && side_effects_external(node.value);
  15937. if (lhs) {
  15938. if (node instanceof AST_Dot)
  15939. return side_effects_external(node.expression, true);
  15940. if (node instanceof AST_Sub)
  15941. return side_effects_external(node.expression, true);
  15942. if (node instanceof AST_SymbolRef)
  15943. return node.definition().scope.get_defun_scope() !== defun_scope;
  15944. }
  15945. return false;
  15946. }
  15947. /**
  15948. * Will any of the pulled-in lvalues shadow a variable in newScope or parents?
  15949. * similar to scope_encloses_variables_in_this_scope */
  15950. function shadows(my_scope, lvalues) {
  15951. for (const { def } of lvalues.values()) {
  15952. const looked_up = my_scope.find_variable(def.name);
  15953. if (looked_up) {
  15954. if (looked_up === def) continue;
  15955. return true;
  15956. }
  15957. }
  15958. return false;
  15959. }
  15960. }
  15961. function eliminate_spurious_blocks(statements) {
  15962. var seen_dirs = [];
  15963. for (var i = 0; i < statements.length;) {
  15964. var stat = statements[i];
  15965. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  15966. CHANGED = true;
  15967. eliminate_spurious_blocks(stat.body);
  15968. statements.splice(i, 1, ...stat.body);
  15969. i += stat.body.length;
  15970. } else if (stat instanceof AST_EmptyStatement) {
  15971. CHANGED = true;
  15972. statements.splice(i, 1);
  15973. } else if (stat instanceof AST_Directive) {
  15974. if (seen_dirs.indexOf(stat.value) < 0) {
  15975. i++;
  15976. seen_dirs.push(stat.value);
  15977. } else {
  15978. CHANGED = true;
  15979. statements.splice(i, 1);
  15980. }
  15981. } else
  15982. i++;
  15983. }
  15984. }
  15985. function handle_if_return(statements, compressor) {
  15986. var self = compressor.self();
  15987. var multiple_if_returns = has_multiple_if_returns(statements);
  15988. var in_lambda = self instanceof AST_Lambda;
  15989. // Prevent extremely deep nesting
  15990. // https://github.com/terser/terser/issues/1432
  15991. // https://github.com/webpack/webpack/issues/17548
  15992. const iteration_start = Math.min(statements.length, 500);
  15993. for (var i = iteration_start; --i >= 0;) {
  15994. var stat = statements[i];
  15995. var j = next_index(i);
  15996. var next = statements[j];
  15997. if (in_lambda && !next && stat instanceof AST_Return) {
  15998. if (!stat.value) {
  15999. CHANGED = true;
  16000. statements.splice(i, 1);
  16001. continue;
  16002. }
  16003. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  16004. CHANGED = true;
  16005. statements[i] = make_node(AST_SimpleStatement, stat, {
  16006. body: stat.value.expression
  16007. });
  16008. continue;
  16009. }
  16010. }
  16011. if (stat instanceof AST_If) {
  16012. let ab, new_else;
  16013. ab = aborts(stat.body);
  16014. if (
  16015. can_merge_flow(ab)
  16016. && (new_else = as_statement_array_with_return(stat.body, ab))
  16017. ) {
  16018. if (ab.label) {
  16019. remove(ab.label.thedef.references, ab);
  16020. }
  16021. CHANGED = true;
  16022. stat = stat.clone();
  16023. stat.condition = stat.condition.negate(compressor);
  16024. stat.body = make_node(AST_BlockStatement, stat, {
  16025. body: as_statement_array(stat.alternative).concat(extract_defuns())
  16026. });
  16027. stat.alternative = make_node(AST_BlockStatement, stat, {
  16028. body: new_else
  16029. });
  16030. statements[i] = stat.transform(compressor);
  16031. continue;
  16032. }
  16033. ab = aborts(stat.alternative);
  16034. if (
  16035. can_merge_flow(ab)
  16036. && (new_else = as_statement_array_with_return(stat.alternative, ab))
  16037. ) {
  16038. if (ab.label) {
  16039. remove(ab.label.thedef.references, ab);
  16040. }
  16041. CHANGED = true;
  16042. stat = stat.clone();
  16043. stat.body = make_node(AST_BlockStatement, stat.body, {
  16044. body: as_statement_array(stat.body).concat(extract_defuns())
  16045. });
  16046. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  16047. body: new_else
  16048. });
  16049. statements[i] = stat.transform(compressor);
  16050. continue;
  16051. }
  16052. }
  16053. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  16054. var value = stat.body.value;
  16055. //---
  16056. // pretty silly case, but:
  16057. // if (foo()) return; return; ==> foo(); return;
  16058. if (!value && !stat.alternative
  16059. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  16060. CHANGED = true;
  16061. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  16062. body: stat.condition
  16063. });
  16064. continue;
  16065. }
  16066. //---
  16067. // if (foo()) return x; return y; ==> return foo() ? x : y;
  16068. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  16069. CHANGED = true;
  16070. stat = stat.clone();
  16071. stat.alternative = next;
  16072. statements[i] = stat.transform(compressor);
  16073. statements.splice(j, 1);
  16074. continue;
  16075. }
  16076. //---
  16077. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  16078. if (value && !stat.alternative
  16079. && (!next && in_lambda && multiple_if_returns
  16080. || next instanceof AST_Return)) {
  16081. CHANGED = true;
  16082. stat = stat.clone();
  16083. stat.alternative = next || make_node(AST_Return, stat, {
  16084. value: null
  16085. });
  16086. statements[i] = stat.transform(compressor);
  16087. if (next)
  16088. statements.splice(j, 1);
  16089. continue;
  16090. }
  16091. //---
  16092. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  16093. //
  16094. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  16095. // however, with sequences on this helps producing slightly better output for
  16096. // the example code.
  16097. var prev = statements[prev_index(i)];
  16098. if (compressor.option("sequences") && in_lambda && !stat.alternative
  16099. && prev instanceof AST_If && prev.body instanceof AST_Return
  16100. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  16101. CHANGED = true;
  16102. stat = stat.clone();
  16103. stat.alternative = make_node(AST_BlockStatement, next, {
  16104. body: [
  16105. next,
  16106. make_node(AST_Return, next, {
  16107. value: null
  16108. })
  16109. ]
  16110. });
  16111. statements[i] = stat.transform(compressor);
  16112. statements.splice(j, 1);
  16113. continue;
  16114. }
  16115. }
  16116. }
  16117. function has_multiple_if_returns(statements) {
  16118. var n = 0;
  16119. for (var i = statements.length; --i >= 0;) {
  16120. var stat = statements[i];
  16121. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  16122. if (++n > 1)
  16123. return true;
  16124. }
  16125. }
  16126. return false;
  16127. }
  16128. function is_return_void(value) {
  16129. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  16130. }
  16131. function can_merge_flow(ab) {
  16132. if (!ab)
  16133. return false;
  16134. for (var j = i + 1, len = statements.length; j < len; j++) {
  16135. var stat = statements[j];
  16136. if (stat instanceof AST_Const || stat instanceof AST_Let)
  16137. return false;
  16138. }
  16139. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  16140. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  16141. || ab instanceof AST_Continue && self === loop_body(lct)
  16142. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  16143. }
  16144. function extract_defuns() {
  16145. var tail = statements.slice(i + 1);
  16146. statements.length = i + 1;
  16147. return tail.filter(function (stat) {
  16148. if (stat instanceof AST_Defun) {
  16149. statements.push(stat);
  16150. return false;
  16151. }
  16152. return true;
  16153. });
  16154. }
  16155. function as_statement_array_with_return(node, ab) {
  16156. var body = as_statement_array(node);
  16157. if (ab !== body[body.length - 1]) {
  16158. return undefined;
  16159. }
  16160. body = body.slice(0, -1);
  16161. if (!body.every(stat => can_be_evicted_from_block(stat))) {
  16162. return undefined;
  16163. }
  16164. if (ab.value) {
  16165. body.push(make_node(AST_SimpleStatement, ab.value, {
  16166. body: ab.value.expression
  16167. }));
  16168. }
  16169. return body;
  16170. }
  16171. function next_index(i) {
  16172. for (var j = i + 1, len = statements.length; j < len; j++) {
  16173. var stat = statements[j];
  16174. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  16175. break;
  16176. }
  16177. }
  16178. return j;
  16179. }
  16180. function prev_index(i) {
  16181. for (var j = i; --j >= 0;) {
  16182. var stat = statements[j];
  16183. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  16184. break;
  16185. }
  16186. }
  16187. return j;
  16188. }
  16189. }
  16190. function eliminate_dead_code(statements, compressor) {
  16191. var has_quit;
  16192. var self = compressor.self();
  16193. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  16194. var stat = statements[i];
  16195. if (stat instanceof AST_LoopControl) {
  16196. var lct = compressor.loopcontrol_target(stat);
  16197. if (stat instanceof AST_Break
  16198. && !(lct instanceof AST_IterationStatement)
  16199. && loop_body(lct) === self
  16200. || stat instanceof AST_Continue
  16201. && loop_body(lct) === self) {
  16202. if (stat.label) {
  16203. remove(stat.label.thedef.references, stat);
  16204. }
  16205. } else {
  16206. statements[n++] = stat;
  16207. }
  16208. } else {
  16209. statements[n++] = stat;
  16210. }
  16211. if (aborts(stat)) {
  16212. has_quit = statements.slice(i + 1);
  16213. break;
  16214. }
  16215. }
  16216. statements.length = n;
  16217. CHANGED = n != len;
  16218. if (has_quit)
  16219. has_quit.forEach(function (stat) {
  16220. trim_unreachable_code(compressor, stat, statements);
  16221. });
  16222. }
  16223. function declarations_only(node) {
  16224. return node.definitions.every((var_def) => !var_def.value);
  16225. }
  16226. function sequencesize(statements, compressor) {
  16227. if (statements.length < 2)
  16228. return;
  16229. var seq = [], n = 0;
  16230. function push_seq() {
  16231. if (!seq.length)
  16232. return;
  16233. var body = make_sequence(seq[0], seq);
  16234. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  16235. seq = [];
  16236. }
  16237. for (var i = 0, len = statements.length; i < len; i++) {
  16238. var stat = statements[i];
  16239. if (stat instanceof AST_SimpleStatement) {
  16240. if (seq.length >= compressor.sequences_limit)
  16241. push_seq();
  16242. var body = stat.body;
  16243. if (seq.length > 0)
  16244. body = body.drop_side_effect_free(compressor);
  16245. if (body)
  16246. merge_sequence(seq, body);
  16247. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  16248. || stat instanceof AST_Defun) {
  16249. statements[n++] = stat;
  16250. } else {
  16251. push_seq();
  16252. statements[n++] = stat;
  16253. }
  16254. }
  16255. push_seq();
  16256. statements.length = n;
  16257. if (n != len)
  16258. CHANGED = true;
  16259. }
  16260. function to_simple_statement(block, decls) {
  16261. if (!(block instanceof AST_BlockStatement))
  16262. return block;
  16263. var stat = null;
  16264. for (var i = 0, len = block.body.length; i < len; i++) {
  16265. var line = block.body[i];
  16266. if (line instanceof AST_Var && declarations_only(line)) {
  16267. decls.push(line);
  16268. } else if (stat || line instanceof AST_Const || line instanceof AST_Let) {
  16269. return false;
  16270. } else {
  16271. stat = line;
  16272. }
  16273. }
  16274. return stat;
  16275. }
  16276. function sequencesize_2(statements, compressor) {
  16277. function cons_seq(right) {
  16278. n--;
  16279. CHANGED = true;
  16280. var left = prev.body;
  16281. return make_sequence(left, [left, right]).transform(compressor);
  16282. }
  16283. var n = 0, prev;
  16284. for (var i = 0; i < statements.length; i++) {
  16285. var stat = statements[i];
  16286. if (prev) {
  16287. if (stat instanceof AST_Exit) {
  16288. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  16289. } else if (stat instanceof AST_For) {
  16290. if (!(stat.init instanceof AST_Definitions)) {
  16291. const abort = walk(prev.body, node => {
  16292. if (node instanceof AST_Scope)
  16293. return true;
  16294. if (node instanceof AST_Binary
  16295. && node.operator === "in") {
  16296. return walk_abort;
  16297. }
  16298. });
  16299. if (!abort) {
  16300. if (stat.init)
  16301. stat.init = cons_seq(stat.init);
  16302. else {
  16303. stat.init = prev.body;
  16304. n--;
  16305. CHANGED = true;
  16306. }
  16307. }
  16308. }
  16309. } else if (stat instanceof AST_ForIn) {
  16310. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  16311. stat.object = cons_seq(stat.object);
  16312. }
  16313. } else if (stat instanceof AST_If) {
  16314. stat.condition = cons_seq(stat.condition);
  16315. } else if (stat instanceof AST_Switch) {
  16316. stat.expression = cons_seq(stat.expression);
  16317. } else if (stat instanceof AST_With) {
  16318. stat.expression = cons_seq(stat.expression);
  16319. }
  16320. }
  16321. if (compressor.option("conditionals") && stat instanceof AST_If) {
  16322. var decls = [];
  16323. var body = to_simple_statement(stat.body, decls);
  16324. var alt = to_simple_statement(stat.alternative, decls);
  16325. if (body !== false && alt !== false && decls.length > 0) {
  16326. var len = decls.length;
  16327. decls.push(make_node(AST_If, stat, {
  16328. condition: stat.condition,
  16329. body: body || make_node(AST_EmptyStatement, stat.body),
  16330. alternative: alt
  16331. }));
  16332. decls.unshift(n, 1);
  16333. [].splice.apply(statements, decls);
  16334. i += len;
  16335. n += len + 1;
  16336. prev = null;
  16337. CHANGED = true;
  16338. continue;
  16339. }
  16340. }
  16341. statements[n++] = stat;
  16342. prev = stat instanceof AST_SimpleStatement ? stat : null;
  16343. }
  16344. statements.length = n;
  16345. }
  16346. function join_object_assignments(defn, body) {
  16347. if (!(defn instanceof AST_Definitions))
  16348. return;
  16349. var def = defn.definitions[defn.definitions.length - 1];
  16350. if (!(def.value instanceof AST_Object))
  16351. return;
  16352. var exprs;
  16353. if (body instanceof AST_Assign && !body.logical) {
  16354. exprs = [body];
  16355. } else if (body instanceof AST_Sequence) {
  16356. exprs = body.expressions.slice();
  16357. }
  16358. if (!exprs)
  16359. return;
  16360. var trimmed = false;
  16361. do {
  16362. var node = exprs[0];
  16363. if (!(node instanceof AST_Assign))
  16364. break;
  16365. if (node.operator != "=")
  16366. break;
  16367. if (!(node.left instanceof AST_PropAccess))
  16368. break;
  16369. var sym = node.left.expression;
  16370. if (!(sym instanceof AST_SymbolRef))
  16371. break;
  16372. if (def.name.name != sym.name)
  16373. break;
  16374. if (!node.right.is_constant_expression(nearest_scope))
  16375. break;
  16376. var prop = node.left.property;
  16377. if (prop instanceof AST_Node) {
  16378. prop = prop.evaluate(compressor);
  16379. }
  16380. if (prop instanceof AST_Node)
  16381. break;
  16382. prop = "" + prop;
  16383. var diff = compressor.option("ecma") < 2015
  16384. && compressor.has_directive("use strict") ? function (node) {
  16385. return node.key != prop && (node.key && node.key.name != prop);
  16386. } : function (node) {
  16387. return node.key && node.key.name != prop;
  16388. };
  16389. if (!def.value.properties.every(diff))
  16390. break;
  16391. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  16392. if (!p) {
  16393. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  16394. key: prop,
  16395. value: node.right
  16396. }));
  16397. } else {
  16398. p.value = new AST_Sequence({
  16399. start: p.start,
  16400. expressions: [p.value.clone(), node.right.clone()],
  16401. end: p.end
  16402. });
  16403. }
  16404. exprs.shift();
  16405. trimmed = true;
  16406. } while (exprs.length);
  16407. return trimmed && exprs;
  16408. }
  16409. function join_consecutive_vars(statements) {
  16410. var defs;
  16411. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  16412. var stat = statements[i];
  16413. var prev = statements[j];
  16414. if (stat instanceof AST_Definitions) {
  16415. if (prev && prev.TYPE == stat.TYPE) {
  16416. prev.definitions = prev.definitions.concat(stat.definitions);
  16417. CHANGED = true;
  16418. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  16419. defs.definitions = defs.definitions.concat(stat.definitions);
  16420. CHANGED = true;
  16421. } else {
  16422. statements[++j] = stat;
  16423. defs = stat;
  16424. }
  16425. } else if (stat instanceof AST_Exit) {
  16426. stat.value = extract_object_assignments(stat.value);
  16427. } else if (stat instanceof AST_For) {
  16428. var exprs = join_object_assignments(prev, stat.init);
  16429. if (exprs) {
  16430. CHANGED = true;
  16431. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  16432. statements[++j] = stat;
  16433. } else if (
  16434. prev instanceof AST_Var
  16435. && (!stat.init || stat.init.TYPE == prev.TYPE)
  16436. ) {
  16437. if (stat.init) {
  16438. prev.definitions = prev.definitions.concat(stat.init.definitions);
  16439. }
  16440. stat.init = prev;
  16441. statements[j] = stat;
  16442. CHANGED = true;
  16443. } else if (
  16444. defs instanceof AST_Var
  16445. && stat.init instanceof AST_Var
  16446. && declarations_only(stat.init)
  16447. ) {
  16448. defs.definitions = defs.definitions.concat(stat.init.definitions);
  16449. stat.init = null;
  16450. statements[++j] = stat;
  16451. CHANGED = true;
  16452. } else {
  16453. statements[++j] = stat;
  16454. }
  16455. } else if (stat instanceof AST_ForIn) {
  16456. stat.object = extract_object_assignments(stat.object);
  16457. } else if (stat instanceof AST_If) {
  16458. stat.condition = extract_object_assignments(stat.condition);
  16459. } else if (stat instanceof AST_SimpleStatement) {
  16460. var exprs = join_object_assignments(prev, stat.body);
  16461. if (exprs) {
  16462. CHANGED = true;
  16463. if (!exprs.length)
  16464. continue;
  16465. stat.body = make_sequence(stat.body, exprs);
  16466. }
  16467. statements[++j] = stat;
  16468. } else if (stat instanceof AST_Switch) {
  16469. stat.expression = extract_object_assignments(stat.expression);
  16470. } else if (stat instanceof AST_With) {
  16471. stat.expression = extract_object_assignments(stat.expression);
  16472. } else {
  16473. statements[++j] = stat;
  16474. }
  16475. }
  16476. statements.length = j + 1;
  16477. function extract_object_assignments(value) {
  16478. statements[++j] = stat;
  16479. var exprs = join_object_assignments(prev, value);
  16480. if (exprs) {
  16481. CHANGED = true;
  16482. if (exprs.length) {
  16483. return make_sequence(value, exprs);
  16484. } else if (value instanceof AST_Sequence) {
  16485. return value.tail_node().left;
  16486. } else {
  16487. return value.left;
  16488. }
  16489. }
  16490. return value;
  16491. }
  16492. }
  16493. }
  16494. /***********************************************************************
  16495. A JavaScript tokenizer / parser / beautifier / compressor.
  16496. https://github.com/mishoo/UglifyJS2
  16497. -------------------------------- (C) ---------------------------------
  16498. Author: Mihai Bazon
  16499. <mihai.bazon@gmail.com>
  16500. http://mihai.bazon.net/blog
  16501. Distributed under the BSD license:
  16502. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16503. Redistribution and use in source and binary forms, with or without
  16504. modification, are permitted provided that the following conditions
  16505. are met:
  16506. * Redistributions of source code must retain the above
  16507. copyright notice, this list of conditions and the following
  16508. disclaimer.
  16509. * Redistributions in binary form must reproduce the above
  16510. copyright notice, this list of conditions and the following
  16511. disclaimer in the documentation and/or other materials
  16512. provided with the distribution.
  16513. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16514. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16515. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16516. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16517. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16518. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16519. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16520. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16521. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16522. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16523. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16524. SUCH DAMAGE.
  16525. ***********************************************************************/
  16526. /**
  16527. * Module that contains the inlining logic.
  16528. *
  16529. * @module
  16530. *
  16531. * The stars of the show are `inline_into_symbolref` and `inline_into_call`.
  16532. */
  16533. function within_array_or_object_literal(compressor) {
  16534. var node, level = 0;
  16535. while (node = compressor.parent(level++)) {
  16536. if (node instanceof AST_Statement) return false;
  16537. if (node instanceof AST_Array
  16538. || node instanceof AST_ObjectKeyVal
  16539. || node instanceof AST_Object) {
  16540. return true;
  16541. }
  16542. }
  16543. return false;
  16544. }
  16545. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  16546. for (const enclosed of pulled_scope.enclosed) {
  16547. if (pulled_scope.variables.has(enclosed.name)) {
  16548. continue;
  16549. }
  16550. const looked_up = scope.find_variable(enclosed.name);
  16551. if (looked_up) {
  16552. if (looked_up === enclosed) continue;
  16553. return true;
  16554. }
  16555. }
  16556. return false;
  16557. }
  16558. /**
  16559. * An extra check function for `top_retain` option, compare the length of const identifier
  16560. * and init value length and return true if init value is longer than identifier. for example:
  16561. * ```
  16562. * // top_retain: ["example"]
  16563. * const example = 100
  16564. * ```
  16565. * it will return false because length of "100" is short than identifier "example".
  16566. */
  16567. function is_const_symbol_short_than_init_value(def, fixed_value) {
  16568. if (def.orig.length === 1 && fixed_value) {
  16569. const init_value_length = fixed_value.size();
  16570. const identifer_length = def.name.length;
  16571. return init_value_length > identifer_length;
  16572. }
  16573. return true;
  16574. }
  16575. function inline_into_symbolref(self, compressor) {
  16576. if (compressor.in_computed_key()) return self;
  16577. const parent = compressor.parent();
  16578. const def = self.definition();
  16579. const nearest_scope = compressor.find_scope();
  16580. let fixed = self.fixed_value();
  16581. if (
  16582. compressor.top_retain &&
  16583. def.global &&
  16584. compressor.top_retain(def) &&
  16585. // when identifier is in top_retain option dose not mean we can always inline it.
  16586. // if identifier name is longer then init value, we can replace it.
  16587. is_const_symbol_short_than_init_value(def, fixed)
  16588. ) {
  16589. // keep it
  16590. def.fixed = false;
  16591. def.single_use = false;
  16592. return self;
  16593. }
  16594. if (dont_inline_lambda_in_loop(compressor, fixed)) return self;
  16595. let single_use = def.single_use
  16596. && !(parent instanceof AST_Call
  16597. && (parent.is_callee_pure(compressor))
  16598. || has_annotation(parent, _NOINLINE))
  16599. && !(parent instanceof AST_Export
  16600. && fixed instanceof AST_Lambda
  16601. && fixed.name);
  16602. if (single_use && fixed instanceof AST_Node) {
  16603. single_use =
  16604. !fixed.has_side_effects(compressor)
  16605. && !fixed.may_throw(compressor);
  16606. }
  16607. if (fixed instanceof AST_Class && def.scope !== self.scope) {
  16608. return self;
  16609. }
  16610. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16611. if (retain_top_func(fixed, compressor)) {
  16612. single_use = false;
  16613. } else if (def.scope !== self.scope
  16614. && (def.escaped == 1
  16615. || has_flag(fixed, INLINED)
  16616. || within_array_or_object_literal(compressor)
  16617. || !compressor.option("reduce_funcs"))) {
  16618. single_use = false;
  16619. } else if (is_recursive_ref(compressor, def)) {
  16620. single_use = false;
  16621. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  16622. single_use = fixed.is_constant_expression(self.scope);
  16623. if (single_use == "f") {
  16624. var scope = self.scope;
  16625. do {
  16626. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  16627. set_flag(scope, INLINED);
  16628. }
  16629. } while (scope = scope.parent_scope);
  16630. }
  16631. }
  16632. }
  16633. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16634. single_use =
  16635. def.scope === self.scope
  16636. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16637. || parent instanceof AST_Call
  16638. && parent.expression === self
  16639. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16640. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  16641. }
  16642. if (single_use && fixed) {
  16643. if (fixed instanceof AST_DefClass) {
  16644. set_flag(fixed, SQUEEZED);
  16645. fixed = make_node(AST_ClassExpression, fixed, fixed);
  16646. }
  16647. if (fixed instanceof AST_Defun) {
  16648. set_flag(fixed, SQUEEZED);
  16649. fixed = make_node(AST_Function, fixed, fixed);
  16650. }
  16651. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  16652. const defun_def = fixed.name.definition();
  16653. let lambda_def = fixed.variables.get(fixed.name.name);
  16654. let name = lambda_def && lambda_def.orig[0];
  16655. if (!(name instanceof AST_SymbolLambda)) {
  16656. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  16657. name.scope = fixed;
  16658. fixed.name = name;
  16659. lambda_def = fixed.def_function(name);
  16660. }
  16661. walk(fixed, node => {
  16662. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  16663. node.thedef = lambda_def;
  16664. lambda_def.references.push(node);
  16665. }
  16666. });
  16667. }
  16668. if (
  16669. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  16670. && fixed.parent_scope !== nearest_scope
  16671. ) {
  16672. fixed = fixed.clone(true, compressor.get_toplevel());
  16673. nearest_scope.add_child_scope(fixed);
  16674. }
  16675. return fixed.optimize(compressor);
  16676. }
  16677. // multiple uses
  16678. if (fixed) {
  16679. let replace;
  16680. if (fixed instanceof AST_This) {
  16681. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  16682. && def.references.every((ref) =>
  16683. def.scope === ref.scope
  16684. )) {
  16685. replace = fixed;
  16686. }
  16687. } else {
  16688. var ev = fixed.evaluate(compressor);
  16689. if (
  16690. ev !== fixed
  16691. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  16692. ) {
  16693. replace = make_node_from_constant(ev, fixed);
  16694. }
  16695. }
  16696. if (replace) {
  16697. const name_length = self.size(compressor);
  16698. const replace_size = replace.size(compressor);
  16699. let overhead = 0;
  16700. if (compressor.option("unused") && !compressor.exposed(def)) {
  16701. overhead =
  16702. (name_length + 2 + fixed.size(compressor)) /
  16703. (def.references.length - def.assignments);
  16704. }
  16705. if (replace_size <= name_length + overhead) {
  16706. return replace;
  16707. }
  16708. }
  16709. }
  16710. return self;
  16711. }
  16712. function inline_into_call(self, compressor) {
  16713. if (compressor.in_computed_key()) return self;
  16714. var exp = self.expression;
  16715. var fn = exp;
  16716. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  16717. if (compressor.option("reduce_vars")
  16718. && fn instanceof AST_SymbolRef
  16719. && !has_annotation(self, _NOINLINE)
  16720. ) {
  16721. const fixed = fn.fixed_value();
  16722. if (
  16723. retain_top_func(fixed, compressor)
  16724. || !compressor.toplevel.funcs && exp.definition().global
  16725. ) {
  16726. return self;
  16727. }
  16728. fn = fixed;
  16729. }
  16730. if (
  16731. dont_inline_lambda_in_loop(compressor, fn)
  16732. && !has_annotation(self, _INLINE)
  16733. ) return self;
  16734. var is_func = fn instanceof AST_Lambda;
  16735. var stat = is_func && fn.body[0];
  16736. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  16737. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  16738. if (can_inline && stat instanceof AST_Return) {
  16739. let returned = stat.value;
  16740. if (!returned || returned.is_constant_expression()) {
  16741. if (returned) {
  16742. returned = returned.clone(true);
  16743. } else {
  16744. returned = make_node(AST_Undefined, self);
  16745. }
  16746. const args = self.args.concat(returned);
  16747. return make_sequence(self, args).optimize(compressor);
  16748. }
  16749. // optimize identity function
  16750. if (
  16751. fn.argnames.length === 1
  16752. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  16753. && self.args.length < 2
  16754. && !(self.args[0] instanceof AST_Expansion)
  16755. && returned instanceof AST_SymbolRef
  16756. && returned.name === fn.argnames[0].name
  16757. ) {
  16758. const replacement =
  16759. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  16760. let parent;
  16761. if (
  16762. replacement instanceof AST_PropAccess
  16763. && (parent = compressor.parent()) instanceof AST_Call
  16764. && parent.expression === self
  16765. ) {
  16766. // identity function was being used to remove `this`, like in
  16767. //
  16768. // id(bag.no_this)(...)
  16769. //
  16770. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  16771. return make_sequence(self, [
  16772. make_node(AST_Number, self, { value: 0 }),
  16773. replacement
  16774. ]);
  16775. }
  16776. // replace call with first argument or undefined if none passed
  16777. return replacement;
  16778. }
  16779. }
  16780. if (can_inline) {
  16781. var scope, in_loop, level = -1;
  16782. let def;
  16783. let returned_value;
  16784. let nearest_scope;
  16785. if (simple_args
  16786. && !fn.uses_arguments
  16787. && !(compressor.parent() instanceof AST_Class)
  16788. && !(fn.name && fn instanceof AST_Function)
  16789. && (returned_value = can_flatten_body(stat))
  16790. && (exp === fn
  16791. || has_annotation(self, _INLINE)
  16792. || compressor.option("unused")
  16793. && (def = exp.definition()).references.length == 1
  16794. && !is_recursive_ref(compressor, def)
  16795. && fn.is_constant_expression(exp.scope))
  16796. && !has_annotation(self, _PURE | _NOINLINE)
  16797. && !fn.contains_this()
  16798. && can_inject_symbols()
  16799. && (nearest_scope = compressor.find_scope())
  16800. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  16801. && !(function in_default_assign() {
  16802. // Due to the fact function parameters have their own scope
  16803. // which can't use `var something` in the function body within,
  16804. // we simply don't inline into DefaultAssign.
  16805. let i = 0;
  16806. let p;
  16807. while ((p = compressor.parent(i++))) {
  16808. if (p instanceof AST_DefaultAssign) return true;
  16809. if (p instanceof AST_Block) break;
  16810. }
  16811. return false;
  16812. })()
  16813. && !(scope instanceof AST_Class)
  16814. ) {
  16815. set_flag(fn, SQUEEZED);
  16816. nearest_scope.add_child_scope(fn);
  16817. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  16818. }
  16819. }
  16820. if (can_inline && has_annotation(self, _INLINE)) {
  16821. set_flag(fn, SQUEEZED);
  16822. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  16823. fn = fn.clone(true);
  16824. fn.figure_out_scope({}, {
  16825. parent_scope: compressor.find_scope(),
  16826. toplevel: compressor.get_toplevel()
  16827. });
  16828. return make_node(AST_Call, self, {
  16829. expression: fn,
  16830. args: self.args,
  16831. }).optimize(compressor);
  16832. }
  16833. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  16834. if (can_drop_this_call) {
  16835. var args = self.args.concat(make_node(AST_Undefined, self));
  16836. return make_sequence(self, args).optimize(compressor);
  16837. }
  16838. if (compressor.option("negate_iife")
  16839. && compressor.parent() instanceof AST_SimpleStatement
  16840. && is_iife_call(self)) {
  16841. return self.negate(compressor, true);
  16842. }
  16843. var ev = self.evaluate(compressor);
  16844. if (ev !== self) {
  16845. ev = make_node_from_constant(ev, self).optimize(compressor);
  16846. return best_of(compressor, ev, self);
  16847. }
  16848. return self;
  16849. function return_value(stat) {
  16850. if (!stat) return make_node(AST_Undefined, self);
  16851. if (stat instanceof AST_Return) {
  16852. if (!stat.value) return make_node(AST_Undefined, self);
  16853. return stat.value.clone(true);
  16854. }
  16855. if (stat instanceof AST_SimpleStatement) {
  16856. return make_node(AST_UnaryPrefix, stat, {
  16857. operator: "void",
  16858. expression: stat.body.clone(true)
  16859. });
  16860. }
  16861. }
  16862. function can_flatten_body(stat) {
  16863. var body = fn.body;
  16864. var len = body.length;
  16865. if (compressor.option("inline") < 3) {
  16866. return len == 1 && return_value(stat);
  16867. }
  16868. stat = null;
  16869. for (var i = 0; i < len; i++) {
  16870. var line = body[i];
  16871. if (line instanceof AST_Var) {
  16872. if (stat && !line.definitions.every((var_def) =>
  16873. !var_def.value
  16874. )) {
  16875. return false;
  16876. }
  16877. } else if (stat) {
  16878. return false;
  16879. } else if (!(line instanceof AST_EmptyStatement)) {
  16880. stat = line;
  16881. }
  16882. }
  16883. return return_value(stat);
  16884. }
  16885. function can_inject_args(block_scoped, safe_to_inject) {
  16886. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  16887. var arg = fn.argnames[i];
  16888. if (arg instanceof AST_DefaultAssign) {
  16889. if (has_flag(arg.left, UNUSED)) continue;
  16890. return false;
  16891. }
  16892. if (arg instanceof AST_Destructuring) return false;
  16893. if (arg instanceof AST_Expansion) {
  16894. if (has_flag(arg.expression, UNUSED)) continue;
  16895. return false;
  16896. }
  16897. if (has_flag(arg, UNUSED)) continue;
  16898. if (!safe_to_inject
  16899. || block_scoped.has(arg.name)
  16900. || identifier_atom.has(arg.name)
  16901. || scope.conflicting_def(arg.name)) {
  16902. return false;
  16903. }
  16904. if (in_loop) in_loop.push(arg.definition());
  16905. }
  16906. return true;
  16907. }
  16908. function can_inject_vars(block_scoped, safe_to_inject) {
  16909. var len = fn.body.length;
  16910. for (var i = 0; i < len; i++) {
  16911. var stat = fn.body[i];
  16912. if (!(stat instanceof AST_Var)) continue;
  16913. if (!safe_to_inject) return false;
  16914. for (var j = stat.definitions.length; --j >= 0;) {
  16915. var name = stat.definitions[j].name;
  16916. if (name instanceof AST_Destructuring
  16917. || block_scoped.has(name.name)
  16918. || identifier_atom.has(name.name)
  16919. || scope.conflicting_def(name.name)) {
  16920. return false;
  16921. }
  16922. if (in_loop) in_loop.push(name.definition());
  16923. }
  16924. }
  16925. return true;
  16926. }
  16927. function can_inject_symbols() {
  16928. var block_scoped = new Set();
  16929. do {
  16930. scope = compressor.parent(++level);
  16931. if (scope.is_block_scope() && scope.block_scope) {
  16932. // TODO this is sometimes undefined during compression.
  16933. // But it should always have a value!
  16934. scope.block_scope.variables.forEach(function (variable) {
  16935. block_scoped.add(variable.name);
  16936. });
  16937. }
  16938. if (scope instanceof AST_Catch) {
  16939. // TODO can we delete? AST_Catch is a block scope.
  16940. if (scope.argname) {
  16941. block_scoped.add(scope.argname.name);
  16942. }
  16943. } else if (scope instanceof AST_IterationStatement) {
  16944. in_loop = [];
  16945. } else if (scope instanceof AST_SymbolRef) {
  16946. if (scope.fixed_value() instanceof AST_Scope) return false;
  16947. }
  16948. } while (!(scope instanceof AST_Scope));
  16949. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  16950. var inline = compressor.option("inline");
  16951. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  16952. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  16953. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  16954. }
  16955. function append_var(decls, expressions, name, value) {
  16956. var def = name.definition();
  16957. // Name already exists, only when a function argument had the same name
  16958. const already_appended = scope.variables.has(name.name);
  16959. if (!already_appended) {
  16960. scope.variables.set(name.name, def);
  16961. scope.enclosed.push(def);
  16962. decls.push(make_node(AST_VarDef, name, {
  16963. name: name,
  16964. value: null
  16965. }));
  16966. }
  16967. var sym = make_node(AST_SymbolRef, name, name);
  16968. def.references.push(sym);
  16969. if (value) expressions.push(make_node(AST_Assign, self, {
  16970. operator: "=",
  16971. logical: false,
  16972. left: sym,
  16973. right: value.clone()
  16974. }));
  16975. }
  16976. function flatten_args(decls, expressions) {
  16977. var len = fn.argnames.length;
  16978. for (var i = self.args.length; --i >= len;) {
  16979. expressions.push(self.args[i]);
  16980. }
  16981. for (i = len; --i >= 0;) {
  16982. var name = fn.argnames[i];
  16983. var value = self.args[i];
  16984. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  16985. if (value) expressions.push(value);
  16986. } else {
  16987. var symbol = make_node(AST_SymbolVar, name, name);
  16988. name.definition().orig.push(symbol);
  16989. if (!value && in_loop) value = make_node(AST_Undefined, self);
  16990. append_var(decls, expressions, symbol, value);
  16991. }
  16992. }
  16993. decls.reverse();
  16994. expressions.reverse();
  16995. }
  16996. function flatten_vars(decls, expressions) {
  16997. var pos = expressions.length;
  16998. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  16999. var stat = fn.body[i];
  17000. if (!(stat instanceof AST_Var)) continue;
  17001. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  17002. var var_def = stat.definitions[j];
  17003. var name = var_def.name;
  17004. append_var(decls, expressions, name, var_def.value);
  17005. if (in_loop && fn.argnames.every((argname) =>
  17006. argname.name != name.name
  17007. )) {
  17008. var def = fn.variables.get(name.name);
  17009. var sym = make_node(AST_SymbolRef, name, name);
  17010. def.references.push(sym);
  17011. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  17012. operator: "=",
  17013. logical: false,
  17014. left: sym,
  17015. right: make_node(AST_Undefined, name)
  17016. }));
  17017. }
  17018. }
  17019. }
  17020. }
  17021. function flatten_fn(returned_value) {
  17022. var decls = [];
  17023. var expressions = [];
  17024. flatten_args(decls, expressions);
  17025. flatten_vars(decls, expressions);
  17026. expressions.push(returned_value);
  17027. if (decls.length) {
  17028. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  17029. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  17030. definitions: decls
  17031. }));
  17032. }
  17033. return expressions.map(exp => exp.clone(true));
  17034. }
  17035. }
  17036. /** prevent inlining functions into loops, for performance reasons */
  17037. function dont_inline_lambda_in_loop(compressor, maybe_lambda) {
  17038. return (
  17039. (maybe_lambda instanceof AST_Lambda || maybe_lambda instanceof AST_Class)
  17040. && !!compressor.is_within_loop()
  17041. );
  17042. }
  17043. (function(def_find_defs) {
  17044. function to_node(value, orig) {
  17045. if (value instanceof AST_Node) {
  17046. if (!(value instanceof AST_Constant)) {
  17047. // Value may be a function, an array including functions and even a complex assign / block expression,
  17048. // so it should never be shared in different places.
  17049. // Otherwise wrong information may be used in the compression phase
  17050. value = value.clone(true);
  17051. }
  17052. return make_node(value.CTOR, orig, value);
  17053. }
  17054. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  17055. elements: value.map(function(value) {
  17056. return to_node(value, orig);
  17057. })
  17058. });
  17059. if (value && typeof value == "object") {
  17060. var props = [];
  17061. for (var key in value) if (HOP(value, key)) {
  17062. props.push(make_node(AST_ObjectKeyVal, orig, {
  17063. key: key,
  17064. value: to_node(value[key], orig)
  17065. }));
  17066. }
  17067. return make_node(AST_Object, orig, {
  17068. properties: props
  17069. });
  17070. }
  17071. return make_node_from_constant(value, orig);
  17072. }
  17073. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  17074. if (!compressor.option("global_defs")) return this;
  17075. this.figure_out_scope({ ie8: compressor.option("ie8") });
  17076. return this.transform(new TreeTransformer(function(node) {
  17077. var def = node._find_defs(compressor, "");
  17078. if (!def) return;
  17079. var level = 0, child = node, parent;
  17080. while (parent = this.parent(level++)) {
  17081. if (!(parent instanceof AST_PropAccess)) break;
  17082. if (parent.expression !== child) break;
  17083. child = parent;
  17084. }
  17085. if (is_lhs(child, parent)) {
  17086. return;
  17087. }
  17088. return def;
  17089. }));
  17090. });
  17091. def_find_defs(AST_Node, noop);
  17092. def_find_defs(AST_Chain, function(compressor, suffix) {
  17093. return this.expression._find_defs(compressor, suffix);
  17094. });
  17095. def_find_defs(AST_Dot, function(compressor, suffix) {
  17096. return this.expression._find_defs(compressor, "." + this.property + suffix);
  17097. });
  17098. def_find_defs(AST_SymbolDeclaration, function() {
  17099. if (!this.global()) return;
  17100. });
  17101. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  17102. if (!this.global()) return;
  17103. var defines = compressor.option("global_defs");
  17104. var name = this.name + suffix;
  17105. if (HOP(defines, name)) return to_node(defines[name], this);
  17106. });
  17107. def_find_defs(AST_ImportMeta, function(compressor, suffix) {
  17108. var defines = compressor.option("global_defs");
  17109. var name = "import.meta" + suffix;
  17110. if (HOP(defines, name)) return to_node(defines[name], this);
  17111. });
  17112. })(function(node, func) {
  17113. node.DEFMETHOD("_find_defs", func);
  17114. });
  17115. /***********************************************************************
  17116. A JavaScript tokenizer / parser / beautifier / compressor.
  17117. https://github.com/mishoo/UglifyJS2
  17118. -------------------------------- (C) ---------------------------------
  17119. Author: Mihai Bazon
  17120. <mihai.bazon@gmail.com>
  17121. http://mihai.bazon.net/blog
  17122. Distributed under the BSD license:
  17123. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17124. Redistribution and use in source and binary forms, with or without
  17125. modification, are permitted provided that the following conditions
  17126. are met:
  17127. * Redistributions of source code must retain the above
  17128. copyright notice, this list of conditions and the following
  17129. disclaimer.
  17130. * Redistributions in binary form must reproduce the above
  17131. copyright notice, this list of conditions and the following
  17132. disclaimer in the documentation and/or other materials
  17133. provided with the distribution.
  17134. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17135. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17136. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17137. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17138. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17139. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17140. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17141. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17142. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17143. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17144. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17145. SUCH DAMAGE.
  17146. ***********************************************************************/
  17147. class Compressor extends TreeWalker {
  17148. constructor(options, { false_by_default = false, mangle_options = false }) {
  17149. super();
  17150. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  17151. this.options = defaults(options, {
  17152. arguments : false,
  17153. arrows : !false_by_default,
  17154. booleans : !false_by_default,
  17155. booleans_as_integers : false,
  17156. collapse_vars : !false_by_default,
  17157. comparisons : !false_by_default,
  17158. computed_props: !false_by_default,
  17159. conditionals : !false_by_default,
  17160. dead_code : !false_by_default,
  17161. defaults : true,
  17162. directives : !false_by_default,
  17163. drop_console : false,
  17164. drop_debugger : !false_by_default,
  17165. ecma : 5,
  17166. evaluate : !false_by_default,
  17167. expression : false,
  17168. global_defs : false,
  17169. hoist_funs : false,
  17170. hoist_props : !false_by_default,
  17171. hoist_vars : false,
  17172. ie8 : false,
  17173. if_return : !false_by_default,
  17174. inline : !false_by_default,
  17175. join_vars : !false_by_default,
  17176. keep_classnames: false,
  17177. keep_fargs : true,
  17178. keep_fnames : false,
  17179. keep_infinity : false,
  17180. lhs_constants : !false_by_default,
  17181. loops : !false_by_default,
  17182. module : false,
  17183. negate_iife : !false_by_default,
  17184. passes : 1,
  17185. properties : !false_by_default,
  17186. pure_getters : !false_by_default && "strict",
  17187. pure_funcs : null,
  17188. pure_new : false,
  17189. reduce_funcs : !false_by_default,
  17190. reduce_vars : !false_by_default,
  17191. sequences : !false_by_default,
  17192. side_effects : !false_by_default,
  17193. switches : !false_by_default,
  17194. top_retain : null,
  17195. toplevel : !!(options && options["top_retain"]),
  17196. typeofs : !false_by_default,
  17197. unsafe : false,
  17198. unsafe_arrows : false,
  17199. unsafe_comps : false,
  17200. unsafe_Function: false,
  17201. unsafe_math : false,
  17202. unsafe_symbols: false,
  17203. unsafe_methods: false,
  17204. unsafe_proto : false,
  17205. unsafe_regexp : false,
  17206. unsafe_undefined: false,
  17207. unused : !false_by_default,
  17208. warnings : false // legacy
  17209. }, true);
  17210. var global_defs = this.options["global_defs"];
  17211. if (typeof global_defs == "object") for (var key in global_defs) {
  17212. if (key[0] === "@" && HOP(global_defs, key)) {
  17213. global_defs[key.slice(1)] = parse(global_defs[key], {
  17214. expression: true
  17215. });
  17216. }
  17217. }
  17218. if (this.options["inline"] === true) this.options["inline"] = 3;
  17219. var pure_funcs = this.options["pure_funcs"];
  17220. if (typeof pure_funcs == "function") {
  17221. this.pure_funcs = pure_funcs;
  17222. } else {
  17223. this.pure_funcs = pure_funcs ? function(node) {
  17224. return !pure_funcs.includes(node.expression.print_to_string());
  17225. } : return_true;
  17226. }
  17227. var top_retain = this.options["top_retain"];
  17228. if (top_retain instanceof RegExp) {
  17229. this.top_retain = function(def) {
  17230. return top_retain.test(def.name);
  17231. };
  17232. } else if (typeof top_retain == "function") {
  17233. this.top_retain = top_retain;
  17234. } else if (top_retain) {
  17235. if (typeof top_retain == "string") {
  17236. top_retain = top_retain.split(/,/);
  17237. }
  17238. this.top_retain = function(def) {
  17239. return top_retain.includes(def.name);
  17240. };
  17241. }
  17242. if (this.options["module"]) {
  17243. this.directives["use strict"] = true;
  17244. this.options["toplevel"] = true;
  17245. }
  17246. var toplevel = this.options["toplevel"];
  17247. this.toplevel = typeof toplevel == "string" ? {
  17248. funcs: /funcs/.test(toplevel),
  17249. vars: /vars/.test(toplevel)
  17250. } : {
  17251. funcs: toplevel,
  17252. vars: toplevel
  17253. };
  17254. var sequences = this.options["sequences"];
  17255. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  17256. this.evaluated_regexps = new Map();
  17257. this._toplevel = undefined;
  17258. this._mangle_options = mangle_options
  17259. ? format_mangler_options(mangle_options)
  17260. : mangle_options;
  17261. }
  17262. mangle_options() {
  17263. var nth_identifier = this._mangle_options && this._mangle_options.nth_identifier || base54;
  17264. var module = this._mangle_options && this._mangle_options.module || this.option("module");
  17265. return { ie8: this.option("ie8"), nth_identifier, module };
  17266. }
  17267. option(key) {
  17268. return this.options[key];
  17269. }
  17270. exposed(def) {
  17271. if (def.export) return true;
  17272. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  17273. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  17274. return true;
  17275. return false;
  17276. }
  17277. in_boolean_context() {
  17278. if (!this.option("booleans")) return false;
  17279. var self = this.self();
  17280. for (var i = 0, p; p = this.parent(i); i++) {
  17281. if (p instanceof AST_SimpleStatement
  17282. || p instanceof AST_Conditional && p.condition === self
  17283. || p instanceof AST_DWLoop && p.condition === self
  17284. || p instanceof AST_For && p.condition === self
  17285. || p instanceof AST_If && p.condition === self
  17286. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  17287. return true;
  17288. }
  17289. if (
  17290. p instanceof AST_Binary
  17291. && (
  17292. p.operator == "&&"
  17293. || p.operator == "||"
  17294. || p.operator == "??"
  17295. )
  17296. || p instanceof AST_Conditional
  17297. || p.tail_node() === self
  17298. ) {
  17299. self = p;
  17300. } else {
  17301. return false;
  17302. }
  17303. }
  17304. }
  17305. in_32_bit_context(other_operand_must_be_number) {
  17306. if (!this.option("evaluate")) return false;
  17307. var self = this.self();
  17308. for (var i = 0, p; p = this.parent(i); i++) {
  17309. if (p instanceof AST_Binary && bitwise_binop.has(p.operator)) {
  17310. if (other_operand_must_be_number) {
  17311. return (self === p.left ? p.right : p.left).is_number(this);
  17312. } else {
  17313. return true;
  17314. }
  17315. }
  17316. if (p instanceof AST_UnaryPrefix) {
  17317. return p.operator === "~";
  17318. }
  17319. if (
  17320. p instanceof AST_Binary
  17321. && (
  17322. p.operator == "&&"
  17323. || p.operator == "||"
  17324. || p.operator == "??"
  17325. )
  17326. || p instanceof AST_Conditional && p.condition !== self
  17327. || p.tail_node() === self
  17328. ) {
  17329. self = p;
  17330. } else {
  17331. return false;
  17332. }
  17333. }
  17334. }
  17335. in_computed_key() {
  17336. if (!this.option("evaluate")) return false;
  17337. var self = this.self();
  17338. for (var i = 0, p; p = this.parent(i); i++) {
  17339. if (p instanceof AST_ObjectProperty && p.key === self) {
  17340. return true;
  17341. }
  17342. }
  17343. return false;
  17344. }
  17345. get_toplevel() {
  17346. return this._toplevel;
  17347. }
  17348. compress(toplevel) {
  17349. toplevel = toplevel.resolve_defines(this);
  17350. this._toplevel = toplevel;
  17351. if (this.option("expression")) {
  17352. this._toplevel.process_expression(true);
  17353. }
  17354. var passes = +this.options.passes || 1;
  17355. var min_count = 1 / 0;
  17356. var stopping = false;
  17357. var mangle = this.mangle_options();
  17358. for (var pass = 0; pass < passes; pass++) {
  17359. this._toplevel.figure_out_scope(mangle);
  17360. if (pass === 0 && this.option("drop_console")) {
  17361. // must be run before reduce_vars and compress pass
  17362. this._toplevel = this._toplevel.drop_console(this.option("drop_console"));
  17363. }
  17364. if (pass > 0 || this.option("reduce_vars")) {
  17365. this._toplevel.reset_opt_flags(this);
  17366. }
  17367. this._toplevel = this._toplevel.transform(this);
  17368. if (passes > 1) {
  17369. let count = 0;
  17370. walk(this._toplevel, () => { count++; });
  17371. if (count < min_count) {
  17372. min_count = count;
  17373. stopping = false;
  17374. } else if (stopping) {
  17375. break;
  17376. } else {
  17377. stopping = true;
  17378. }
  17379. }
  17380. }
  17381. if (this.option("expression")) {
  17382. this._toplevel.process_expression(false);
  17383. }
  17384. toplevel = this._toplevel;
  17385. this._toplevel = undefined;
  17386. return toplevel;
  17387. }
  17388. before(node, descend) {
  17389. if (has_flag(node, SQUEEZED)) return node;
  17390. var was_scope = false;
  17391. if (node instanceof AST_Scope) {
  17392. node = node.hoist_properties(this);
  17393. node = node.hoist_declarations(this);
  17394. was_scope = true;
  17395. }
  17396. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  17397. // would call AST_Node.transform() if a different instance of AST_Node is
  17398. // produced after def_optimize().
  17399. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  17400. // Migrate and defer all children's AST_Node.transform() to below, which
  17401. // will now happen after this parent AST_Node has been properly substituted
  17402. // thus gives a consistent AST snapshot.
  17403. descend(node, this);
  17404. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  17405. // following replacement call would result in degraded efficiency of both
  17406. // output and performance.
  17407. descend(node, this);
  17408. var opt = node.optimize(this);
  17409. if (was_scope && opt instanceof AST_Scope) {
  17410. opt.drop_unused(this);
  17411. descend(opt, this);
  17412. }
  17413. if (opt === node) set_flag(opt, SQUEEZED);
  17414. return opt;
  17415. }
  17416. /** Alternative to plain is_lhs() which doesn't work within .optimize() */
  17417. is_lhs() {
  17418. const self = this.stack[this.stack.length - 1];
  17419. const parent = this.stack[this.stack.length - 2];
  17420. return is_lhs(self, parent);
  17421. }
  17422. }
  17423. function def_optimize(node, optimizer) {
  17424. node.DEFMETHOD("optimize", function(compressor) {
  17425. var self = this;
  17426. if (has_flag(self, OPTIMIZED)) return self;
  17427. if (compressor.has_directive("use asm")) return self;
  17428. var opt = optimizer(self, compressor);
  17429. set_flag(opt, OPTIMIZED);
  17430. return opt;
  17431. });
  17432. }
  17433. def_optimize(AST_Node, function(self) {
  17434. return self;
  17435. });
  17436. AST_Toplevel.DEFMETHOD("drop_console", function(options) {
  17437. const isArray = Array.isArray(options);
  17438. const tt = new TreeTransformer(function(self) {
  17439. if (self.TYPE !== "Call") {
  17440. return;
  17441. }
  17442. var exp = self.expression;
  17443. if (!(exp instanceof AST_PropAccess)) {
  17444. return;
  17445. }
  17446. var name = exp.expression;
  17447. var property = exp.property;
  17448. var depth = 2;
  17449. while (name.expression) {
  17450. property = name.property;
  17451. name = name.expression;
  17452. depth++;
  17453. }
  17454. if (isArray && !options.includes(property)) {
  17455. return;
  17456. }
  17457. if (is_undeclared_ref(name) && name.name == "console") {
  17458. if (
  17459. depth === 3
  17460. && !["call", "apply"].includes(exp.property)
  17461. && is_used_in_expression(tt)
  17462. ) {
  17463. // a (used) call to Function.prototype methods (eg: console.log.bind(console))
  17464. // but not .call and .apply which would also return undefined.
  17465. exp.expression = make_empty_function(self);
  17466. set_flag(exp.expression, SQUEEZED);
  17467. self.args = [];
  17468. } else {
  17469. return make_node(AST_Undefined, self);
  17470. }
  17471. }
  17472. });
  17473. return this.transform(tt);
  17474. });
  17475. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  17476. return equivalent_to(this, node);
  17477. });
  17478. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  17479. var self = this;
  17480. var tt = new TreeTransformer(function(node) {
  17481. if (insert && node instanceof AST_SimpleStatement) {
  17482. return make_node(AST_Return, node, {
  17483. value: node.body
  17484. });
  17485. }
  17486. if (!insert && node instanceof AST_Return) {
  17487. if (compressor) {
  17488. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  17489. return value
  17490. ? make_node(AST_SimpleStatement, node, { body: value })
  17491. : make_node(AST_EmptyStatement, node);
  17492. }
  17493. return make_node(AST_SimpleStatement, node, {
  17494. body: node.value || make_node(AST_UnaryPrefix, node, {
  17495. operator: "void",
  17496. expression: make_node(AST_Number, node, {
  17497. value: 0
  17498. })
  17499. })
  17500. });
  17501. }
  17502. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  17503. return node;
  17504. }
  17505. if (node instanceof AST_Block) {
  17506. var index = node.body.length - 1;
  17507. if (index >= 0) {
  17508. node.body[index] = node.body[index].transform(tt);
  17509. }
  17510. } else if (node instanceof AST_If) {
  17511. node.body = node.body.transform(tt);
  17512. if (node.alternative) {
  17513. node.alternative = node.alternative.transform(tt);
  17514. }
  17515. } else if (node instanceof AST_With) {
  17516. node.body = node.body.transform(tt);
  17517. }
  17518. return node;
  17519. });
  17520. self.transform(tt);
  17521. });
  17522. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  17523. const self = this;
  17524. const reduce_vars = compressor.option("reduce_vars");
  17525. const preparation = new TreeWalker(function(node, descend) {
  17526. clear_flag(node, CLEAR_BETWEEN_PASSES);
  17527. if (reduce_vars) {
  17528. if (compressor.top_retain
  17529. && node instanceof AST_Defun // Only functions are retained
  17530. && preparation.parent() === self
  17531. ) {
  17532. set_flag(node, TOP);
  17533. }
  17534. return node.reduce_vars(preparation, descend, compressor);
  17535. }
  17536. });
  17537. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  17538. // properly assigned before use:
  17539. // - `push()` & `pop()` when visiting conditional branches
  17540. preparation.safe_ids = Object.create(null);
  17541. preparation.in_loop = null;
  17542. preparation.loop_ids = new Map();
  17543. preparation.defs_to_safe_ids = new Map();
  17544. self.walk(preparation);
  17545. });
  17546. AST_Symbol.DEFMETHOD("fixed_value", function() {
  17547. var fixed = this.thedef.fixed;
  17548. if (!fixed || fixed instanceof AST_Node) return fixed;
  17549. return fixed();
  17550. });
  17551. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  17552. var orig = this.definition().orig;
  17553. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  17554. });
  17555. function find_variable(compressor, name) {
  17556. var scope, i = 0;
  17557. while (scope = compressor.parent(i++)) {
  17558. if (scope instanceof AST_Scope) break;
  17559. if (scope instanceof AST_Catch && scope.argname) {
  17560. scope = scope.argname.definition().scope;
  17561. break;
  17562. }
  17563. }
  17564. return scope.find_variable(name);
  17565. }
  17566. var global_names = makePredicate("Array Boolean clearInterval clearTimeout console Date decodeURI decodeURIComponent encodeURI encodeURIComponent Error escape eval EvalError Function isFinite isNaN JSON Math Number parseFloat parseInt RangeError ReferenceError RegExp Object setInterval setTimeout String SyntaxError TypeError unescape URIError");
  17567. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  17568. return !this.definition().undeclared
  17569. || compressor.option("unsafe") && global_names.has(this.name);
  17570. });
  17571. /* -----[ optimizers ]----- */
  17572. var directives = new Set(["use asm", "use strict"]);
  17573. def_optimize(AST_Directive, function(self, compressor) {
  17574. if (compressor.option("directives")
  17575. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  17576. return make_node(AST_EmptyStatement, self);
  17577. }
  17578. return self;
  17579. });
  17580. def_optimize(AST_Debugger, function(self, compressor) {
  17581. if (compressor.option("drop_debugger"))
  17582. return make_node(AST_EmptyStatement, self);
  17583. return self;
  17584. });
  17585. def_optimize(AST_LabeledStatement, function(self, compressor) {
  17586. if (self.body instanceof AST_Break
  17587. && compressor.loopcontrol_target(self.body) === self.body) {
  17588. return make_node(AST_EmptyStatement, self);
  17589. }
  17590. return self.label.references.length == 0 ? self.body : self;
  17591. });
  17592. def_optimize(AST_Block, function(self, compressor) {
  17593. tighten_body(self.body, compressor);
  17594. return self;
  17595. });
  17596. function can_be_extracted_from_if_block(node) {
  17597. return !(
  17598. node instanceof AST_Const
  17599. || node instanceof AST_Let
  17600. || node instanceof AST_Class
  17601. );
  17602. }
  17603. def_optimize(AST_BlockStatement, function(self, compressor) {
  17604. tighten_body(self.body, compressor);
  17605. switch (self.body.length) {
  17606. case 1:
  17607. if (!compressor.has_directive("use strict")
  17608. && compressor.parent() instanceof AST_If
  17609. && can_be_extracted_from_if_block(self.body[0])
  17610. || can_be_evicted_from_block(self.body[0])) {
  17611. return self.body[0];
  17612. }
  17613. break;
  17614. case 0: return make_node(AST_EmptyStatement, self);
  17615. }
  17616. return self;
  17617. });
  17618. function opt_AST_Lambda(self, compressor) {
  17619. tighten_body(self.body, compressor);
  17620. if (compressor.option("side_effects")
  17621. && self.body.length == 1
  17622. && self.body[0] === compressor.has_directive("use strict")) {
  17623. self.body.length = 0;
  17624. }
  17625. return self;
  17626. }
  17627. def_optimize(AST_Lambda, opt_AST_Lambda);
  17628. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  17629. var self = this;
  17630. if (compressor.has_directive("use asm")) return self;
  17631. var hoist_funs = compressor.option("hoist_funs");
  17632. var hoist_vars = compressor.option("hoist_vars");
  17633. if (hoist_funs || hoist_vars) {
  17634. var dirs = [];
  17635. var hoisted = [];
  17636. var vars = new Map(), vars_found = 0, var_decl = 0;
  17637. // let's count var_decl first, we seem to waste a lot of
  17638. // space if we hoist `var` when there's only one.
  17639. walk(self, node => {
  17640. if (node instanceof AST_Scope && node !== self)
  17641. return true;
  17642. if (node instanceof AST_Var) {
  17643. ++var_decl;
  17644. return true;
  17645. }
  17646. });
  17647. hoist_vars = hoist_vars && var_decl > 1;
  17648. var tt = new TreeTransformer(
  17649. function before(node) {
  17650. if (node !== self) {
  17651. if (node instanceof AST_Directive) {
  17652. dirs.push(node);
  17653. return make_node(AST_EmptyStatement, node);
  17654. }
  17655. if (hoist_funs && node instanceof AST_Defun
  17656. && !(tt.parent() instanceof AST_Export)
  17657. && tt.parent() === self) {
  17658. hoisted.push(node);
  17659. return make_node(AST_EmptyStatement, node);
  17660. }
  17661. if (
  17662. hoist_vars
  17663. && node instanceof AST_Var
  17664. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  17665. ) {
  17666. node.definitions.forEach(function(def) {
  17667. vars.set(def.name.name, def);
  17668. ++vars_found;
  17669. });
  17670. var seq = node.to_assignments(compressor);
  17671. var p = tt.parent();
  17672. if (p instanceof AST_ForIn && p.init === node) {
  17673. if (seq == null) {
  17674. var def = node.definitions[0].name;
  17675. return make_node(AST_SymbolRef, def, def);
  17676. }
  17677. return seq;
  17678. }
  17679. if (p instanceof AST_For && p.init === node) {
  17680. return seq;
  17681. }
  17682. if (!seq) return make_node(AST_EmptyStatement, node);
  17683. return make_node(AST_SimpleStatement, node, {
  17684. body: seq
  17685. });
  17686. }
  17687. if (node instanceof AST_Scope)
  17688. return node; // to avoid descending in nested scopes
  17689. }
  17690. }
  17691. );
  17692. self = self.transform(tt);
  17693. if (vars_found > 0) {
  17694. // collect only vars which don't show up in self's arguments list
  17695. var defs = [];
  17696. const is_lambda = self instanceof AST_Lambda;
  17697. const args_as_names = is_lambda ? self.args_as_names() : null;
  17698. vars.forEach((def, name) => {
  17699. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  17700. vars.delete(name);
  17701. } else {
  17702. def = def.clone();
  17703. def.value = null;
  17704. defs.push(def);
  17705. vars.set(name, def);
  17706. }
  17707. });
  17708. if (defs.length > 0) {
  17709. // try to merge in assignments
  17710. for (var i = 0; i < self.body.length;) {
  17711. if (self.body[i] instanceof AST_SimpleStatement) {
  17712. var expr = self.body[i].body, sym, assign;
  17713. if (expr instanceof AST_Assign
  17714. && expr.operator == "="
  17715. && (sym = expr.left) instanceof AST_Symbol
  17716. && vars.has(sym.name)
  17717. ) {
  17718. var def = vars.get(sym.name);
  17719. if (def.value) break;
  17720. def.value = expr.right;
  17721. remove(defs, def);
  17722. defs.push(def);
  17723. self.body.splice(i, 1);
  17724. continue;
  17725. }
  17726. if (expr instanceof AST_Sequence
  17727. && (assign = expr.expressions[0]) instanceof AST_Assign
  17728. && assign.operator == "="
  17729. && (sym = assign.left) instanceof AST_Symbol
  17730. && vars.has(sym.name)
  17731. ) {
  17732. var def = vars.get(sym.name);
  17733. if (def.value) break;
  17734. def.value = assign.right;
  17735. remove(defs, def);
  17736. defs.push(def);
  17737. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  17738. continue;
  17739. }
  17740. }
  17741. if (self.body[i] instanceof AST_EmptyStatement) {
  17742. self.body.splice(i, 1);
  17743. continue;
  17744. }
  17745. if (self.body[i] instanceof AST_BlockStatement) {
  17746. self.body.splice(i, 1, ...self.body[i].body);
  17747. continue;
  17748. }
  17749. break;
  17750. }
  17751. defs = make_node(AST_Var, self, {
  17752. definitions: defs
  17753. });
  17754. hoisted.push(defs);
  17755. }
  17756. }
  17757. self.body = dirs.concat(hoisted, self.body);
  17758. }
  17759. return self;
  17760. });
  17761. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  17762. var self = this;
  17763. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  17764. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  17765. var defs_by_id = new Map();
  17766. var hoister = new TreeTransformer(function(node, descend) {
  17767. if (node instanceof AST_VarDef) {
  17768. const sym = node.name;
  17769. let def;
  17770. let value;
  17771. if (sym.scope === self
  17772. && (def = sym.definition()).escaped != 1
  17773. && !def.assignments
  17774. && !def.direct_access
  17775. && !def.single_use
  17776. && !compressor.exposed(def)
  17777. && !top_retain(def)
  17778. && (value = sym.fixed_value()) === node.value
  17779. && value instanceof AST_Object
  17780. && !value.properties.some(prop =>
  17781. prop instanceof AST_Expansion || prop.computed_key()
  17782. )
  17783. ) {
  17784. descend(node, this);
  17785. const defs = new Map();
  17786. const assignments = [];
  17787. value.properties.forEach(({ key, value }) => {
  17788. const scope = hoister.find_scope();
  17789. const symbol = self.create_symbol(sym.CTOR, {
  17790. source: sym,
  17791. scope,
  17792. conflict_scopes: new Set([
  17793. scope,
  17794. ...sym.definition().references.map(ref => ref.scope)
  17795. ]),
  17796. tentative_name: sym.name + "_" + key
  17797. });
  17798. defs.set(String(key), symbol.definition());
  17799. assignments.push(make_node(AST_VarDef, node, {
  17800. name: symbol,
  17801. value
  17802. }));
  17803. });
  17804. defs_by_id.set(def.id, defs);
  17805. return MAP.splice(assignments);
  17806. }
  17807. } else if (node instanceof AST_PropAccess
  17808. && node.expression instanceof AST_SymbolRef
  17809. ) {
  17810. const defs = defs_by_id.get(node.expression.definition().id);
  17811. if (defs) {
  17812. const def = defs.get(String(get_simple_key(node.property)));
  17813. const sym = make_node(AST_SymbolRef, node, {
  17814. name: def.name,
  17815. scope: node.expression.scope,
  17816. thedef: def
  17817. });
  17818. sym.reference({});
  17819. return sym;
  17820. }
  17821. }
  17822. });
  17823. return self.transform(hoister);
  17824. });
  17825. def_optimize(AST_SimpleStatement, function(self, compressor) {
  17826. if (compressor.option("side_effects")) {
  17827. var body = self.body;
  17828. var node = body.drop_side_effect_free(compressor, true);
  17829. if (!node) {
  17830. return make_node(AST_EmptyStatement, self);
  17831. }
  17832. if (node !== body) {
  17833. return make_node(AST_SimpleStatement, self, { body: node });
  17834. }
  17835. }
  17836. return self;
  17837. });
  17838. def_optimize(AST_While, function(self, compressor) {
  17839. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  17840. });
  17841. def_optimize(AST_Do, function(self, compressor) {
  17842. if (!compressor.option("loops")) return self;
  17843. var cond = self.condition.tail_node().evaluate(compressor);
  17844. if (!(cond instanceof AST_Node)) {
  17845. if (cond) return make_node(AST_For, self, {
  17846. body: make_node(AST_BlockStatement, self.body, {
  17847. body: [
  17848. self.body,
  17849. make_node(AST_SimpleStatement, self.condition, {
  17850. body: self.condition
  17851. })
  17852. ]
  17853. })
  17854. }).optimize(compressor);
  17855. if (!has_break_or_continue(self, compressor.parent())) {
  17856. return make_node(AST_BlockStatement, self.body, {
  17857. body: [
  17858. self.body,
  17859. make_node(AST_SimpleStatement, self.condition, {
  17860. body: self.condition
  17861. })
  17862. ]
  17863. }).optimize(compressor);
  17864. }
  17865. }
  17866. return self;
  17867. });
  17868. function if_break_in_loop(self, compressor) {
  17869. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  17870. if (compressor.option("dead_code") && is_break(first)) {
  17871. var body = [];
  17872. if (self.init instanceof AST_Statement) {
  17873. body.push(self.init);
  17874. } else if (self.init) {
  17875. body.push(make_node(AST_SimpleStatement, self.init, {
  17876. body: self.init
  17877. }));
  17878. }
  17879. if (self.condition) {
  17880. body.push(make_node(AST_SimpleStatement, self.condition, {
  17881. body: self.condition
  17882. }));
  17883. }
  17884. trim_unreachable_code(compressor, self.body, body);
  17885. return make_node(AST_BlockStatement, self, {
  17886. body: body
  17887. });
  17888. }
  17889. if (first instanceof AST_If) {
  17890. if (is_break(first.body)) {
  17891. if (self.condition) {
  17892. self.condition = make_node(AST_Binary, self.condition, {
  17893. left: self.condition,
  17894. operator: "&&",
  17895. right: first.condition.negate(compressor),
  17896. });
  17897. } else {
  17898. self.condition = first.condition.negate(compressor);
  17899. }
  17900. drop_it(first.alternative);
  17901. } else if (is_break(first.alternative)) {
  17902. if (self.condition) {
  17903. self.condition = make_node(AST_Binary, self.condition, {
  17904. left: self.condition,
  17905. operator: "&&",
  17906. right: first.condition,
  17907. });
  17908. } else {
  17909. self.condition = first.condition;
  17910. }
  17911. drop_it(first.body);
  17912. }
  17913. }
  17914. return self;
  17915. function is_break(node) {
  17916. return node instanceof AST_Break
  17917. && compressor.loopcontrol_target(node) === compressor.self();
  17918. }
  17919. function drop_it(rest) {
  17920. rest = as_statement_array(rest);
  17921. if (self.body instanceof AST_BlockStatement) {
  17922. self.body = self.body.clone();
  17923. self.body.body = rest.concat(self.body.body.slice(1));
  17924. self.body = self.body.transform(compressor);
  17925. } else {
  17926. self.body = make_node(AST_BlockStatement, self.body, {
  17927. body: rest
  17928. }).transform(compressor);
  17929. }
  17930. self = if_break_in_loop(self, compressor);
  17931. }
  17932. }
  17933. def_optimize(AST_For, function(self, compressor) {
  17934. if (!compressor.option("loops")) return self;
  17935. if (compressor.option("side_effects") && self.init) {
  17936. self.init = self.init.drop_side_effect_free(compressor);
  17937. }
  17938. if (self.condition) {
  17939. var cond = self.condition.evaluate(compressor);
  17940. if (!(cond instanceof AST_Node)) {
  17941. if (cond) self.condition = null;
  17942. else if (!compressor.option("dead_code")) {
  17943. var orig = self.condition;
  17944. self.condition = make_node_from_constant(cond, self.condition);
  17945. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17946. }
  17947. }
  17948. if (compressor.option("dead_code")) {
  17949. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17950. if (!cond) {
  17951. var body = [];
  17952. trim_unreachable_code(compressor, self.body, body);
  17953. if (self.init instanceof AST_Statement) {
  17954. body.push(self.init);
  17955. } else if (self.init) {
  17956. body.push(make_node(AST_SimpleStatement, self.init, {
  17957. body: self.init
  17958. }));
  17959. }
  17960. body.push(make_node(AST_SimpleStatement, self.condition, {
  17961. body: self.condition
  17962. }));
  17963. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17964. }
  17965. }
  17966. }
  17967. return if_break_in_loop(self, compressor);
  17968. });
  17969. def_optimize(AST_If, function(self, compressor) {
  17970. if (is_empty(self.alternative)) self.alternative = null;
  17971. if (!compressor.option("conditionals")) return self;
  17972. // if condition can be statically determined, drop
  17973. // one of the blocks. note, statically determined implies
  17974. // “has no side effects”; also it doesn't work for cases like
  17975. // `x && true`, though it probably should.
  17976. var cond = self.condition.evaluate(compressor);
  17977. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  17978. var orig = self.condition;
  17979. self.condition = make_node_from_constant(cond, orig);
  17980. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17981. }
  17982. if (compressor.option("dead_code")) {
  17983. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17984. if (!cond) {
  17985. var body = [];
  17986. trim_unreachable_code(compressor, self.body, body);
  17987. body.push(make_node(AST_SimpleStatement, self.condition, {
  17988. body: self.condition
  17989. }));
  17990. if (self.alternative) body.push(self.alternative);
  17991. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17992. } else if (!(cond instanceof AST_Node)) {
  17993. var body = [];
  17994. body.push(make_node(AST_SimpleStatement, self.condition, {
  17995. body: self.condition
  17996. }));
  17997. body.push(self.body);
  17998. if (self.alternative) {
  17999. trim_unreachable_code(compressor, self.alternative, body);
  18000. }
  18001. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  18002. }
  18003. }
  18004. var negated = self.condition.negate(compressor);
  18005. var self_condition_length = self.condition.size();
  18006. var negated_length = negated.size();
  18007. var negated_is_best = negated_length < self_condition_length;
  18008. if (self.alternative && negated_is_best) {
  18009. negated_is_best = false; // because we already do the switch here.
  18010. // no need to swap values of self_condition_length and negated_length
  18011. // here because they are only used in an equality comparison later on.
  18012. self.condition = negated;
  18013. var tmp = self.body;
  18014. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  18015. self.alternative = tmp;
  18016. }
  18017. if (is_empty(self.body) && is_empty(self.alternative)) {
  18018. return make_node(AST_SimpleStatement, self.condition, {
  18019. body: self.condition.clone()
  18020. }).optimize(compressor);
  18021. }
  18022. if (self.body instanceof AST_SimpleStatement
  18023. && self.alternative instanceof AST_SimpleStatement) {
  18024. return make_node(AST_SimpleStatement, self, {
  18025. body: make_node(AST_Conditional, self, {
  18026. condition : self.condition,
  18027. consequent : self.body.body,
  18028. alternative : self.alternative.body
  18029. })
  18030. }).optimize(compressor);
  18031. }
  18032. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  18033. if (self_condition_length === negated_length && !negated_is_best
  18034. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  18035. // although the code length of self.condition and negated are the same,
  18036. // negated does not require additional surrounding parentheses.
  18037. // see https://github.com/mishoo/UglifyJS2/issues/979
  18038. negated_is_best = true;
  18039. }
  18040. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  18041. body: make_node(AST_Binary, self, {
  18042. operator : "||",
  18043. left : negated,
  18044. right : self.body.body
  18045. })
  18046. }).optimize(compressor);
  18047. return make_node(AST_SimpleStatement, self, {
  18048. body: make_node(AST_Binary, self, {
  18049. operator : "&&",
  18050. left : self.condition,
  18051. right : self.body.body
  18052. })
  18053. }).optimize(compressor);
  18054. }
  18055. if (self.body instanceof AST_EmptyStatement
  18056. && self.alternative instanceof AST_SimpleStatement) {
  18057. return make_node(AST_SimpleStatement, self, {
  18058. body: make_node(AST_Binary, self, {
  18059. operator : "||",
  18060. left : self.condition,
  18061. right : self.alternative.body
  18062. })
  18063. }).optimize(compressor);
  18064. }
  18065. if (self.body instanceof AST_Exit
  18066. && self.alternative instanceof AST_Exit
  18067. && self.body.TYPE == self.alternative.TYPE) {
  18068. return make_node(self.body.CTOR, self, {
  18069. value: make_node(AST_Conditional, self, {
  18070. condition : self.condition,
  18071. consequent : self.body.value || make_node(AST_Undefined, self.body),
  18072. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  18073. }).transform(compressor)
  18074. }).optimize(compressor);
  18075. }
  18076. if (self.body instanceof AST_If
  18077. && !self.body.alternative
  18078. && !self.alternative) {
  18079. self = make_node(AST_If, self, {
  18080. condition: make_node(AST_Binary, self.condition, {
  18081. operator: "&&",
  18082. left: self.condition,
  18083. right: self.body.condition
  18084. }),
  18085. body: self.body.body,
  18086. alternative: null
  18087. });
  18088. }
  18089. if (aborts(self.body)) {
  18090. if (self.alternative) {
  18091. var alt = self.alternative;
  18092. self.alternative = null;
  18093. return make_node(AST_BlockStatement, self, {
  18094. body: [ self, alt ]
  18095. }).optimize(compressor);
  18096. }
  18097. }
  18098. if (aborts(self.alternative)) {
  18099. var body = self.body;
  18100. self.body = self.alternative;
  18101. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  18102. self.alternative = null;
  18103. return make_node(AST_BlockStatement, self, {
  18104. body: [ self, body ]
  18105. }).optimize(compressor);
  18106. }
  18107. return self;
  18108. });
  18109. def_optimize(AST_Switch, function(self, compressor) {
  18110. if (!compressor.option("switches")) return self;
  18111. var branch;
  18112. var value = self.expression.evaluate(compressor);
  18113. if (!(value instanceof AST_Node)) {
  18114. var orig = self.expression;
  18115. self.expression = make_node_from_constant(value, orig);
  18116. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  18117. }
  18118. if (!compressor.option("dead_code")) return self;
  18119. if (value instanceof AST_Node) {
  18120. value = self.expression.tail_node().evaluate(compressor);
  18121. }
  18122. var decl = [];
  18123. var body = [];
  18124. var default_branch;
  18125. var exact_match;
  18126. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  18127. branch = self.body[i];
  18128. if (branch instanceof AST_Default) {
  18129. if (!default_branch) {
  18130. default_branch = branch;
  18131. } else {
  18132. eliminate_branch(branch, body[body.length - 1]);
  18133. }
  18134. } else if (!(value instanceof AST_Node)) {
  18135. var exp = branch.expression.evaluate(compressor);
  18136. if (!(exp instanceof AST_Node) && exp !== value) {
  18137. eliminate_branch(branch, body[body.length - 1]);
  18138. continue;
  18139. }
  18140. if (exp instanceof AST_Node && !exp.has_side_effects(compressor)) {
  18141. exp = branch.expression.tail_node().evaluate(compressor);
  18142. }
  18143. if (exp === value) {
  18144. exact_match = branch;
  18145. if (default_branch) {
  18146. var default_index = body.indexOf(default_branch);
  18147. body.splice(default_index, 1);
  18148. eliminate_branch(default_branch, body[default_index - 1]);
  18149. default_branch = null;
  18150. }
  18151. }
  18152. }
  18153. body.push(branch);
  18154. }
  18155. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  18156. self.body = body;
  18157. let default_or_exact = default_branch || exact_match;
  18158. default_branch = null;
  18159. exact_match = null;
  18160. // group equivalent branches so they will be located next to each other,
  18161. // that way the next micro-optimization will merge them.
  18162. // ** bail micro-optimization if not a simple switch case with breaks
  18163. if (body.every((branch, i) =>
  18164. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  18165. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  18166. ) {
  18167. for (let i = 0; i < body.length; i++) {
  18168. const branch = body[i];
  18169. for (let j = i + 1; j < body.length; j++) {
  18170. const next = body[j];
  18171. if (next.body.length === 0) continue;
  18172. const last_branch = j === (body.length - 1);
  18173. const equivalentBranch = branches_equivalent(next, branch, false);
  18174. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  18175. if (!equivalentBranch && last_branch) {
  18176. next.body.push(make_node(AST_Break));
  18177. }
  18178. // let's find previous siblings with inert fallthrough...
  18179. let x = j - 1;
  18180. let fallthroughDepth = 0;
  18181. while (x > i) {
  18182. if (is_inert_body(body[x--])) {
  18183. fallthroughDepth++;
  18184. } else {
  18185. break;
  18186. }
  18187. }
  18188. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  18189. body.splice(i + 1, 0, ...plucked);
  18190. i += plucked.length;
  18191. }
  18192. }
  18193. }
  18194. }
  18195. // merge equivalent branches in a row
  18196. for (let i = 0; i < body.length; i++) {
  18197. let branch = body[i];
  18198. if (branch.body.length === 0) continue;
  18199. if (!aborts(branch)) continue;
  18200. for (let j = i + 1; j < body.length; i++, j++) {
  18201. let next = body[j];
  18202. if (next.body.length === 0) continue;
  18203. if (
  18204. branches_equivalent(next, branch, false)
  18205. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  18206. ) {
  18207. branch.body = [];
  18208. branch = next;
  18209. continue;
  18210. }
  18211. break;
  18212. }
  18213. }
  18214. // Prune any empty branches at the end of the switch statement.
  18215. {
  18216. let i = body.length - 1;
  18217. for (; i >= 0; i--) {
  18218. let bbody = body[i].body;
  18219. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  18220. if (!is_inert_body(body[i])) break;
  18221. }
  18222. // i now points to the index of a branch that contains a body. By incrementing, it's
  18223. // pointing to the first branch that's empty.
  18224. i++;
  18225. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  18226. // The default behavior is to do nothing. We can take advantage of that to
  18227. // remove all case expressions that are side-effect free that also do
  18228. // nothing, since they'll default to doing nothing. But we can't remove any
  18229. // case expressions before one that would side-effect, since they may cause
  18230. // the side-effect to be skipped.
  18231. for (let j = body.length - 1; j >= i; j--) {
  18232. let branch = body[j];
  18233. if (branch === default_or_exact) {
  18234. default_or_exact = null;
  18235. body.pop();
  18236. } else if (!branch.expression.has_side_effects(compressor)) {
  18237. body.pop();
  18238. } else {
  18239. break;
  18240. }
  18241. }
  18242. }
  18243. }
  18244. // Prune side-effect free branches that fall into default.
  18245. DEFAULT: if (default_or_exact) {
  18246. let default_index = body.indexOf(default_or_exact);
  18247. let default_body_index = default_index;
  18248. for (; default_body_index < body.length - 1; default_body_index++) {
  18249. if (!is_inert_body(body[default_body_index])) break;
  18250. }
  18251. if (default_body_index < body.length - 1) {
  18252. break DEFAULT;
  18253. }
  18254. let side_effect_index = body.length - 1;
  18255. for (; side_effect_index >= 0; side_effect_index--) {
  18256. let branch = body[side_effect_index];
  18257. if (branch === default_or_exact) continue;
  18258. if (branch.expression.has_side_effects(compressor)) break;
  18259. }
  18260. // If the default behavior comes after any side-effect case expressions,
  18261. // then we can fold all side-effect free cases into the default branch.
  18262. // If the side-effect case is after the default, then any side-effect
  18263. // free cases could prevent the side-effect from occurring.
  18264. if (default_body_index > side_effect_index) {
  18265. let prev_body_index = default_index - 1;
  18266. for (; prev_body_index >= 0; prev_body_index--) {
  18267. if (!is_inert_body(body[prev_body_index])) break;
  18268. }
  18269. let before = Math.max(side_effect_index, prev_body_index) + 1;
  18270. let after = default_index;
  18271. if (side_effect_index > default_index) {
  18272. // If the default falls into the same body as a side-effect
  18273. // case, then we need preserve that case and only prune the
  18274. // cases after it.
  18275. after = side_effect_index;
  18276. body[side_effect_index].body = body[default_body_index].body;
  18277. } else {
  18278. // The default will be the last branch.
  18279. default_or_exact.body = body[default_body_index].body;
  18280. }
  18281. // Prune everything after the default (or last side-effect case)
  18282. // until the next case with a body.
  18283. body.splice(after + 1, default_body_index - after);
  18284. // Prune everything before the default that falls into it.
  18285. body.splice(before, default_index - before);
  18286. }
  18287. }
  18288. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  18289. DEFAULT: if (default_or_exact) {
  18290. let i = body.findIndex(branch => !is_inert_body(branch));
  18291. let caseBody;
  18292. // `i` is equal to one of the following:
  18293. // - `-1`, there is no body in the switch statement.
  18294. // - `body.length - 1`, all cases fall into the same body.
  18295. // - anything else, there are multiple bodies in the switch.
  18296. if (i === body.length - 1) {
  18297. // All cases fall into the case body.
  18298. let branch = body[i];
  18299. if (has_nested_break(self)) break DEFAULT;
  18300. // This is the last case body, and we've already pruned any breaks, so it's
  18301. // safe to hoist.
  18302. caseBody = make_node(AST_BlockStatement, branch, {
  18303. body: branch.body
  18304. });
  18305. branch.body = [];
  18306. } else if (i !== -1) {
  18307. // If there are multiple bodies, then we cannot optimize anything.
  18308. break DEFAULT;
  18309. }
  18310. let sideEffect = body.find(
  18311. branch => branch !== default_or_exact && branch.expression.has_side_effects(compressor)
  18312. );
  18313. // If no cases cause a side-effect, we can eliminate the switch entirely.
  18314. if (!sideEffect) {
  18315. return make_node(AST_BlockStatement, self, {
  18316. body: decl.concat(
  18317. statement(self.expression),
  18318. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  18319. caseBody || []
  18320. )
  18321. }).optimize(compressor);
  18322. }
  18323. // If we're this far, either there was no body or all cases fell into the same body.
  18324. // If there was no body, then we don't need a default branch (because the default is
  18325. // do nothing). If there was a body, we'll extract it to after the switch, so the
  18326. // switch's new default is to do nothing and we can still prune it.
  18327. const default_index = body.indexOf(default_or_exact);
  18328. body.splice(default_index, 1);
  18329. default_or_exact = null;
  18330. if (caseBody) {
  18331. // Recurse into switch statement one more time so that we can append the case body
  18332. // outside of the switch. This recursion will only happen once since we've pruned
  18333. // the default case.
  18334. return make_node(AST_BlockStatement, self, {
  18335. body: decl.concat(self, caseBody)
  18336. }).optimize(compressor);
  18337. }
  18338. // If we fall here, there is a default branch somewhere, there are no case bodies,
  18339. // and there's a side-effect somewhere. Just let the below paths take care of it.
  18340. }
  18341. if (body.length > 0) {
  18342. body[0].body = decl.concat(body[0].body);
  18343. }
  18344. if (body.length == 0) {
  18345. return make_node(AST_BlockStatement, self, {
  18346. body: decl.concat(statement(self.expression))
  18347. }).optimize(compressor);
  18348. }
  18349. if (body.length == 1 && !has_nested_break(self)) {
  18350. // This is the last case body, and we've already pruned any breaks, so it's
  18351. // safe to hoist.
  18352. let branch = body[0];
  18353. return make_node(AST_If, self, {
  18354. condition: make_node(AST_Binary, self, {
  18355. operator: "===",
  18356. left: self.expression,
  18357. right: branch.expression,
  18358. }),
  18359. body: make_node(AST_BlockStatement, branch, {
  18360. body: branch.body
  18361. }),
  18362. alternative: null
  18363. }).optimize(compressor);
  18364. }
  18365. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  18366. let branch = body[0] === default_or_exact ? body[1] : body[0];
  18367. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  18368. if (aborts(body[0])) {
  18369. // Only the first branch body could have a break (at the last statement)
  18370. let first = body[0];
  18371. if (is_break(first.body[first.body.length - 1], compressor)) {
  18372. first.body.pop();
  18373. }
  18374. return make_node(AST_If, self, {
  18375. condition: make_node(AST_Binary, self, {
  18376. operator: "===",
  18377. left: self.expression,
  18378. right: branch.expression,
  18379. }),
  18380. body: make_node(AST_BlockStatement, branch, {
  18381. body: branch.body
  18382. }),
  18383. alternative: make_node(AST_BlockStatement, default_or_exact, {
  18384. body: [].concat(
  18385. exact_exp || [],
  18386. default_or_exact.body
  18387. )
  18388. })
  18389. }).optimize(compressor);
  18390. }
  18391. let operator = "===";
  18392. let consequent = make_node(AST_BlockStatement, branch, {
  18393. body: branch.body,
  18394. });
  18395. let always = make_node(AST_BlockStatement, default_or_exact, {
  18396. body: [].concat(
  18397. exact_exp || [],
  18398. default_or_exact.body
  18399. )
  18400. });
  18401. if (body[0] === default_or_exact) {
  18402. operator = "!==";
  18403. let tmp = always;
  18404. always = consequent;
  18405. consequent = tmp;
  18406. }
  18407. return make_node(AST_BlockStatement, self, {
  18408. body: [
  18409. make_node(AST_If, self, {
  18410. condition: make_node(AST_Binary, self, {
  18411. operator: operator,
  18412. left: self.expression,
  18413. right: branch.expression,
  18414. }),
  18415. body: consequent,
  18416. alternative: null,
  18417. }),
  18418. always,
  18419. ],
  18420. }).optimize(compressor);
  18421. }
  18422. return self;
  18423. function eliminate_branch(branch, prev) {
  18424. if (prev && !aborts(prev)) {
  18425. prev.body = prev.body.concat(branch.body);
  18426. } else {
  18427. trim_unreachable_code(compressor, branch, decl);
  18428. }
  18429. }
  18430. function branches_equivalent(branch, prev, insertBreak) {
  18431. let bbody = branch.body;
  18432. let pbody = prev.body;
  18433. if (insertBreak) {
  18434. bbody = bbody.concat(make_node(AST_Break));
  18435. }
  18436. if (bbody.length !== pbody.length) return false;
  18437. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  18438. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  18439. return bblock.equivalent_to(pblock);
  18440. }
  18441. function statement(body) {
  18442. return make_node(AST_SimpleStatement, body, { body });
  18443. }
  18444. function has_nested_break(root) {
  18445. let has_break = false;
  18446. let tw = new TreeWalker(node => {
  18447. if (has_break) return true;
  18448. if (node instanceof AST_Lambda) return true;
  18449. if (node instanceof AST_SimpleStatement) return true;
  18450. if (!is_break(node, tw)) return;
  18451. let parent = tw.parent();
  18452. if (
  18453. parent instanceof AST_SwitchBranch
  18454. && parent.body[parent.body.length - 1] === node
  18455. ) {
  18456. return;
  18457. }
  18458. has_break = true;
  18459. });
  18460. root.walk(tw);
  18461. return has_break;
  18462. }
  18463. function is_break(node, stack) {
  18464. return node instanceof AST_Break
  18465. && stack.loopcontrol_target(node) === self;
  18466. }
  18467. function is_inert_body(branch) {
  18468. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  18469. body: branch.body
  18470. }).has_side_effects(compressor);
  18471. }
  18472. });
  18473. def_optimize(AST_Try, function(self, compressor) {
  18474. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  18475. if (compressor.option("dead_code") && self.body.body.every(is_empty)) {
  18476. var body = [];
  18477. if (self.bcatch) {
  18478. trim_unreachable_code(compressor, self.bcatch, body);
  18479. }
  18480. if (self.bfinally) body.push(...self.bfinally.body);
  18481. return make_node(AST_BlockStatement, self, {
  18482. body: body
  18483. }).optimize(compressor);
  18484. }
  18485. return self;
  18486. });
  18487. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  18488. var reduce_vars = compressor.option("reduce_vars");
  18489. var assignments = [];
  18490. for (const def of this.definitions) {
  18491. if (def.value) {
  18492. var name = make_node(AST_SymbolRef, def.name, def.name);
  18493. assignments.push(make_node(AST_Assign, def, {
  18494. operator : "=",
  18495. logical: false,
  18496. left : name,
  18497. right : def.value
  18498. }));
  18499. if (reduce_vars) name.definition().fixed = false;
  18500. }
  18501. const thedef = def.name.definition();
  18502. thedef.eliminated++;
  18503. thedef.replaced--;
  18504. }
  18505. if (assignments.length == 0) return null;
  18506. return make_sequence(this, assignments);
  18507. });
  18508. def_optimize(AST_Definitions, function(self) {
  18509. if (self.definitions.length == 0) {
  18510. return make_node(AST_EmptyStatement, self);
  18511. }
  18512. return self;
  18513. });
  18514. def_optimize(AST_VarDef, function(self, compressor) {
  18515. if (
  18516. self.name instanceof AST_SymbolLet
  18517. && self.value != null
  18518. && is_undefined(self.value, compressor)
  18519. ) {
  18520. self.value = null;
  18521. }
  18522. return self;
  18523. });
  18524. def_optimize(AST_Import, function(self) {
  18525. return self;
  18526. });
  18527. def_optimize(AST_Call, function(self, compressor) {
  18528. var exp = self.expression;
  18529. var fn = exp;
  18530. inline_array_like_spread(self.args);
  18531. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  18532. if (compressor.option("reduce_vars") && fn instanceof AST_SymbolRef) {
  18533. fn = fn.fixed_value();
  18534. }
  18535. var is_func = fn instanceof AST_Lambda;
  18536. if (is_func && fn.pinned()) return self;
  18537. if (compressor.option("unused")
  18538. && simple_args
  18539. && is_func
  18540. && !fn.uses_arguments) {
  18541. var pos = 0, last = 0;
  18542. for (var i = 0, len = self.args.length; i < len; i++) {
  18543. if (fn.argnames[i] instanceof AST_Expansion) {
  18544. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  18545. var node = self.args[i++].drop_side_effect_free(compressor);
  18546. if (node) {
  18547. self.args[pos++] = node;
  18548. }
  18549. } else while (i < len) {
  18550. self.args[pos++] = self.args[i++];
  18551. }
  18552. last = pos;
  18553. break;
  18554. }
  18555. var trim = i >= fn.argnames.length;
  18556. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  18557. var node = self.args[i].drop_side_effect_free(compressor);
  18558. if (node) {
  18559. self.args[pos++] = node;
  18560. } else if (!trim) {
  18561. self.args[pos++] = make_node(AST_Number, self.args[i], {
  18562. value: 0
  18563. });
  18564. continue;
  18565. }
  18566. } else {
  18567. self.args[pos++] = self.args[i];
  18568. }
  18569. last = pos;
  18570. }
  18571. self.args.length = last;
  18572. }
  18573. if (
  18574. exp instanceof AST_Dot
  18575. && exp.expression instanceof AST_SymbolRef
  18576. && exp.expression.name === "console"
  18577. && exp.expression.definition().undeclared
  18578. && exp.property === "assert"
  18579. ) {
  18580. const condition = self.args[0];
  18581. if (condition) {
  18582. const value = condition.evaluate(compressor);
  18583. if (value === 1 || value === true) {
  18584. return make_node(AST_Undefined, self);
  18585. }
  18586. }
  18587. }
  18588. if (compressor.option("unsafe") && !exp.contains_optional()) {
  18589. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  18590. const [argument] = self.args;
  18591. if (argument instanceof AST_Array) {
  18592. return make_node(AST_Array, argument, {
  18593. elements: argument.elements
  18594. }).optimize(compressor);
  18595. }
  18596. }
  18597. if (is_undeclared_ref(exp)) switch (exp.name) {
  18598. case "Array":
  18599. if (self.args.length != 1) {
  18600. return make_node(AST_Array, self, {
  18601. elements: self.args
  18602. }).optimize(compressor);
  18603. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  18604. const elements = [];
  18605. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  18606. return new AST_Array({ elements });
  18607. }
  18608. break;
  18609. case "Object":
  18610. if (self.args.length == 0) {
  18611. return make_node(AST_Object, self, {
  18612. properties: []
  18613. });
  18614. }
  18615. break;
  18616. case "String":
  18617. if (self.args.length == 0) return make_node(AST_String, self, {
  18618. value: ""
  18619. });
  18620. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  18621. left: self.args[0],
  18622. operator: "+",
  18623. right: make_node(AST_String, self, { value: "" })
  18624. }).optimize(compressor);
  18625. break;
  18626. case "Number":
  18627. if (self.args.length == 0) return make_node(AST_Number, self, {
  18628. value: 0
  18629. });
  18630. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  18631. return make_node(AST_UnaryPrefix, self, {
  18632. expression: self.args[0],
  18633. operator: "+"
  18634. }).optimize(compressor);
  18635. }
  18636. break;
  18637. case "Symbol":
  18638. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  18639. self.args.length = 0;
  18640. break;
  18641. case "Boolean":
  18642. if (self.args.length == 0) return make_node(AST_False, self);
  18643. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  18644. expression: make_node(AST_UnaryPrefix, self, {
  18645. expression: self.args[0],
  18646. operator: "!"
  18647. }),
  18648. operator: "!"
  18649. }).optimize(compressor);
  18650. break;
  18651. case "RegExp":
  18652. var params = [];
  18653. if (self.args.length >= 1
  18654. && self.args.length <= 2
  18655. && self.args.every((arg) => {
  18656. var value = arg.evaluate(compressor);
  18657. params.push(value);
  18658. return arg !== value;
  18659. })
  18660. && regexp_is_safe(params[0])
  18661. ) {
  18662. let [ source, flags ] = params;
  18663. source = regexp_source_fix(new RegExp(source).source);
  18664. const rx = make_node(AST_RegExp, self, {
  18665. value: { source, flags }
  18666. });
  18667. if (rx._eval(compressor) !== rx) {
  18668. return rx;
  18669. }
  18670. }
  18671. break;
  18672. } else if (exp instanceof AST_Dot) switch(exp.property) {
  18673. case "toString":
  18674. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  18675. return make_node(AST_Binary, self, {
  18676. left: make_node(AST_String, self, { value: "" }),
  18677. operator: "+",
  18678. right: exp.expression
  18679. }).optimize(compressor);
  18680. }
  18681. break;
  18682. case "join":
  18683. if (exp.expression instanceof AST_Array) EXIT: {
  18684. var separator;
  18685. if (self.args.length > 0) {
  18686. separator = self.args[0].evaluate(compressor);
  18687. if (separator === self.args[0]) break EXIT; // not a constant
  18688. }
  18689. var elements = [];
  18690. var consts = [];
  18691. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  18692. var el = exp.expression.elements[i];
  18693. if (el instanceof AST_Expansion) break EXIT;
  18694. var value = el.evaluate(compressor);
  18695. if (value !== el) {
  18696. consts.push(value);
  18697. } else {
  18698. if (consts.length > 0) {
  18699. elements.push(make_node(AST_String, self, {
  18700. value: consts.join(separator)
  18701. }));
  18702. consts.length = 0;
  18703. }
  18704. elements.push(el);
  18705. }
  18706. }
  18707. if (consts.length > 0) {
  18708. elements.push(make_node(AST_String, self, {
  18709. value: consts.join(separator)
  18710. }));
  18711. }
  18712. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  18713. if (elements.length == 1) {
  18714. if (elements[0].is_string(compressor)) {
  18715. return elements[0];
  18716. }
  18717. return make_node(AST_Binary, elements[0], {
  18718. operator : "+",
  18719. left : make_node(AST_String, self, { value: "" }),
  18720. right : elements[0]
  18721. });
  18722. }
  18723. if (separator == "") {
  18724. var first;
  18725. if (elements[0].is_string(compressor)
  18726. || elements[1].is_string(compressor)) {
  18727. first = elements.shift();
  18728. } else {
  18729. first = make_node(AST_String, self, { value: "" });
  18730. }
  18731. return elements.reduce(function(prev, el) {
  18732. return make_node(AST_Binary, el, {
  18733. operator : "+",
  18734. left : prev,
  18735. right : el
  18736. });
  18737. }, first).optimize(compressor);
  18738. }
  18739. // need this awkward cloning to not affect original element
  18740. // best_of will decide which one to get through.
  18741. var node = self.clone();
  18742. node.expression = node.expression.clone();
  18743. node.expression.expression = node.expression.expression.clone();
  18744. node.expression.expression.elements = elements;
  18745. return best_of(compressor, self, node);
  18746. }
  18747. break;
  18748. case "charAt":
  18749. if (exp.expression.is_string(compressor)) {
  18750. var arg = self.args[0];
  18751. var index = arg ? arg.evaluate(compressor) : 0;
  18752. if (index !== arg) {
  18753. return make_node(AST_Sub, exp, {
  18754. expression: exp.expression,
  18755. property: make_node_from_constant(index | 0, arg || exp)
  18756. }).optimize(compressor);
  18757. }
  18758. }
  18759. break;
  18760. case "apply":
  18761. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  18762. var args = self.args[1].elements.slice();
  18763. args.unshift(self.args[0]);
  18764. return make_node(AST_Call, self, {
  18765. expression: make_node(AST_Dot, exp, {
  18766. expression: exp.expression,
  18767. optional: false,
  18768. property: "call"
  18769. }),
  18770. args: args
  18771. }).optimize(compressor);
  18772. }
  18773. break;
  18774. case "call":
  18775. var func = exp.expression;
  18776. if (func instanceof AST_SymbolRef) {
  18777. func = func.fixed_value();
  18778. }
  18779. if (func instanceof AST_Lambda && !func.contains_this()) {
  18780. return (self.args.length ? make_sequence(this, [
  18781. self.args[0],
  18782. make_node(AST_Call, self, {
  18783. expression: exp.expression,
  18784. args: self.args.slice(1)
  18785. })
  18786. ]) : make_node(AST_Call, self, {
  18787. expression: exp.expression,
  18788. args: []
  18789. })).optimize(compressor);
  18790. }
  18791. break;
  18792. }
  18793. }
  18794. if (compressor.option("unsafe_Function")
  18795. && is_undeclared_ref(exp)
  18796. && exp.name == "Function") {
  18797. // new Function() => function(){}
  18798. if (self.args.length == 0) return make_empty_function(self).optimize(compressor);
  18799. if (self.args.every((x) => x instanceof AST_String)) {
  18800. // quite a corner-case, but we can handle it:
  18801. // https://github.com/mishoo/UglifyJS2/issues/203
  18802. // if the code argument is a constant, then we can minify it.
  18803. try {
  18804. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  18805. return arg.value;
  18806. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  18807. var ast = parse(code);
  18808. var mangle = compressor.mangle_options();
  18809. ast.figure_out_scope(mangle);
  18810. var comp = new Compressor(compressor.options, {
  18811. mangle_options: compressor._mangle_options
  18812. });
  18813. ast = ast.transform(comp);
  18814. ast.figure_out_scope(mangle);
  18815. ast.compute_char_frequency(mangle);
  18816. ast.mangle_names(mangle);
  18817. var fun;
  18818. walk(ast, node => {
  18819. if (is_func_expr(node)) {
  18820. fun = node;
  18821. return walk_abort;
  18822. }
  18823. });
  18824. var code = OutputStream();
  18825. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  18826. self.args = [
  18827. make_node(AST_String, self, {
  18828. value: fun.argnames.map(function(arg) {
  18829. return arg.print_to_string();
  18830. }).join(",")
  18831. }),
  18832. make_node(AST_String, self.args[self.args.length - 1], {
  18833. value: code.get().replace(/^{|}$/g, "")
  18834. })
  18835. ];
  18836. return self;
  18837. } catch (ex) {
  18838. if (!(ex instanceof JS_Parse_Error)) {
  18839. throw ex;
  18840. }
  18841. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  18842. }
  18843. }
  18844. }
  18845. return inline_into_call(self, compressor);
  18846. });
  18847. /** Does this node contain optional property access or optional call? */
  18848. AST_Node.DEFMETHOD("contains_optional", function() {
  18849. if (
  18850. this instanceof AST_PropAccess
  18851. || this instanceof AST_Call
  18852. || this instanceof AST_Chain
  18853. ) {
  18854. if (this.optional) {
  18855. return true;
  18856. } else {
  18857. return this.expression.contains_optional();
  18858. }
  18859. } else {
  18860. return false;
  18861. }
  18862. });
  18863. def_optimize(AST_New, function(self, compressor) {
  18864. if (
  18865. compressor.option("unsafe") &&
  18866. is_undeclared_ref(self.expression) &&
  18867. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  18868. ) return make_node(AST_Call, self, self).transform(compressor);
  18869. return self;
  18870. });
  18871. def_optimize(AST_Sequence, function(self, compressor) {
  18872. if (!compressor.option("side_effects")) return self;
  18873. var expressions = [];
  18874. filter_for_side_effects();
  18875. var end = expressions.length - 1;
  18876. trim_right_for_undefined();
  18877. if (end == 0) {
  18878. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  18879. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  18880. return self;
  18881. }
  18882. self.expressions = expressions;
  18883. return self;
  18884. function filter_for_side_effects() {
  18885. var first = first_in_statement(compressor);
  18886. var last = self.expressions.length - 1;
  18887. self.expressions.forEach(function(expr, index) {
  18888. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  18889. if (expr) {
  18890. merge_sequence(expressions, expr);
  18891. first = false;
  18892. }
  18893. });
  18894. }
  18895. function trim_right_for_undefined() {
  18896. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  18897. if (end < expressions.length - 1) {
  18898. expressions[end] = make_node(AST_UnaryPrefix, self, {
  18899. operator : "void",
  18900. expression : expressions[end]
  18901. });
  18902. expressions.length = end + 1;
  18903. }
  18904. }
  18905. });
  18906. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  18907. if (compressor.option("sequences")) {
  18908. if (this.expression instanceof AST_Sequence) {
  18909. var x = this.expression.expressions.slice();
  18910. var e = this.clone();
  18911. e.expression = x.pop();
  18912. x.push(e);
  18913. return make_sequence(this, x).optimize(compressor);
  18914. }
  18915. }
  18916. return this;
  18917. });
  18918. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  18919. return self.lift_sequences(compressor);
  18920. });
  18921. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  18922. var e = self.expression;
  18923. if (
  18924. self.operator == "delete" &&
  18925. !(
  18926. e instanceof AST_SymbolRef ||
  18927. e instanceof AST_PropAccess ||
  18928. e instanceof AST_Chain ||
  18929. is_identifier_atom(e)
  18930. )
  18931. ) {
  18932. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  18933. }
  18934. var seq = self.lift_sequences(compressor);
  18935. if (seq !== self) {
  18936. return seq;
  18937. }
  18938. if (compressor.option("side_effects") && self.operator == "void") {
  18939. e = e.drop_side_effect_free(compressor);
  18940. if (e) {
  18941. self.expression = e;
  18942. return self;
  18943. } else {
  18944. return make_node(AST_Undefined, self).optimize(compressor);
  18945. }
  18946. }
  18947. if (compressor.in_boolean_context()) {
  18948. switch (self.operator) {
  18949. case "!":
  18950. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  18951. // !!foo ==> foo, if we're in boolean context
  18952. return e.expression;
  18953. }
  18954. if (e instanceof AST_Binary) {
  18955. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  18956. }
  18957. break;
  18958. case "typeof":
  18959. // typeof always returns a non-empty string, thus it's
  18960. // always true in booleans
  18961. // And we don't need to check if it's undeclared, because in typeof, that's OK
  18962. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  18963. e,
  18964. make_node(AST_True, self)
  18965. ])).optimize(compressor);
  18966. }
  18967. }
  18968. if (self.operator == "-" && e instanceof AST_Infinity) {
  18969. e = e.transform(compressor);
  18970. }
  18971. if (e instanceof AST_Binary
  18972. && (self.operator == "+" || self.operator == "-")
  18973. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  18974. return make_node(AST_Binary, self, {
  18975. operator: e.operator,
  18976. left: make_node(AST_UnaryPrefix, e.left, {
  18977. operator: self.operator,
  18978. expression: e.left
  18979. }),
  18980. right: e.right
  18981. });
  18982. }
  18983. if (compressor.option("evaluate")) {
  18984. // ~~x => x (in 32-bit context)
  18985. // ~~{32 bit integer} => {32 bit integer}
  18986. if (
  18987. self.operator === "~"
  18988. && self.expression instanceof AST_UnaryPrefix
  18989. && self.expression.operator === "~"
  18990. && (compressor.in_32_bit_context(false) || self.expression.expression.is_32_bit_integer(compressor))
  18991. ) {
  18992. return self.expression.expression;
  18993. }
  18994. // ~(x ^ y) => x ^ ~y
  18995. if (
  18996. self.operator === "~"
  18997. && e instanceof AST_Binary
  18998. && e.operator === "^"
  18999. ) {
  19000. if (e.left instanceof AST_UnaryPrefix && e.left.operator === "~") {
  19001. // ~(~x ^ y) => x ^ y
  19002. e.left = e.left.bitwise_negate(compressor, true);
  19003. } else {
  19004. e.right = e.right.bitwise_negate(compressor, true);
  19005. }
  19006. return e;
  19007. }
  19008. }
  19009. if (
  19010. self.operator != "-"
  19011. // avoid infinite recursion of numerals
  19012. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)
  19013. ) {
  19014. var ev = self.evaluate(compressor);
  19015. if (ev !== self) {
  19016. ev = make_node_from_constant(ev, self).optimize(compressor);
  19017. return best_of(compressor, ev, self);
  19018. }
  19019. }
  19020. return self;
  19021. });
  19022. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  19023. if (compressor.option("sequences")) {
  19024. if (this.left instanceof AST_Sequence) {
  19025. var x = this.left.expressions.slice();
  19026. var e = this.clone();
  19027. e.left = x.pop();
  19028. x.push(e);
  19029. return make_sequence(this, x).optimize(compressor);
  19030. }
  19031. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  19032. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  19033. var x = this.right.expressions;
  19034. var last = x.length - 1;
  19035. for (var i = 0; i < last; i++) {
  19036. if (!assign && x[i].has_side_effects(compressor)) break;
  19037. }
  19038. if (i == last) {
  19039. x = x.slice();
  19040. var e = this.clone();
  19041. e.right = x.pop();
  19042. x.push(e);
  19043. return make_sequence(this, x).optimize(compressor);
  19044. } else if (i > 0) {
  19045. var e = this.clone();
  19046. e.right = make_sequence(this.right, x.slice(i));
  19047. x = x.slice(0, i);
  19048. x.push(e);
  19049. return make_sequence(this, x).optimize(compressor);
  19050. }
  19051. }
  19052. }
  19053. return this;
  19054. });
  19055. var commutativeOperators = makePredicate("== === != !== * & | ^");
  19056. function is_object(node) {
  19057. return node instanceof AST_Array
  19058. || node instanceof AST_Lambda
  19059. || node instanceof AST_Object
  19060. || node instanceof AST_Class;
  19061. }
  19062. def_optimize(AST_Binary, function(self, compressor) {
  19063. function reversible() {
  19064. return self.left.is_constant()
  19065. || self.right.is_constant()
  19066. || !self.left.has_side_effects(compressor)
  19067. && !self.right.has_side_effects(compressor);
  19068. }
  19069. function reverse(op) {
  19070. if (reversible()) {
  19071. if (op) self.operator = op;
  19072. var tmp = self.left;
  19073. self.left = self.right;
  19074. self.right = tmp;
  19075. }
  19076. }
  19077. if (compressor.option("lhs_constants") && commutativeOperators.has(self.operator)) {
  19078. if (self.right.is_constant()
  19079. && !self.left.is_constant()) {
  19080. // if right is a constant, whatever side effects the
  19081. // left side might have could not influence the
  19082. // result. hence, force switch.
  19083. if (!(self.left instanceof AST_Binary
  19084. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  19085. reverse();
  19086. }
  19087. }
  19088. }
  19089. self = self.lift_sequences(compressor);
  19090. if (compressor.option("comparisons")) switch (self.operator) {
  19091. case "===":
  19092. case "!==":
  19093. var is_strict_comparison = true;
  19094. if (
  19095. (self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  19096. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  19097. (self.left.is_bigint(compressor) && self.right.is_bigint(compressor)) ||
  19098. (self.left.is_boolean() && self.right.is_boolean()) ||
  19099. self.left.equivalent_to(self.right)
  19100. ) {
  19101. self.operator = self.operator.substr(0, 2);
  19102. }
  19103. // XXX: intentionally falling down to the next case
  19104. case "==":
  19105. case "!=":
  19106. // void 0 == x => null == x
  19107. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  19108. self.left = make_node(AST_Null, self.left);
  19109. // x == void 0 => x == null
  19110. } else if (!is_strict_comparison && is_undefined(self.right, compressor)) {
  19111. self.right = make_node(AST_Null, self.right);
  19112. } else if (compressor.option("typeofs")
  19113. // "undefined" == typeof x => undefined === x
  19114. && self.left instanceof AST_String
  19115. && self.left.value == "undefined"
  19116. && self.right instanceof AST_UnaryPrefix
  19117. && self.right.operator == "typeof") {
  19118. var expr = self.right.expression;
  19119. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  19120. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  19121. self.right = expr;
  19122. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  19123. if (self.operator.length == 2) self.operator += "=";
  19124. }
  19125. } else if (compressor.option("typeofs")
  19126. // typeof x === "undefined" => x === undefined
  19127. && self.left instanceof AST_UnaryPrefix
  19128. && self.left.operator == "typeof"
  19129. && self.right instanceof AST_String
  19130. && self.right.value == "undefined") {
  19131. var expr = self.left.expression;
  19132. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  19133. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  19134. self.left = expr;
  19135. self.right = make_node(AST_Undefined, self.right).optimize(compressor);
  19136. if (self.operator.length == 2) self.operator += "=";
  19137. }
  19138. } else if (self.left instanceof AST_SymbolRef
  19139. // obj !== obj => false
  19140. && self.right instanceof AST_SymbolRef
  19141. && self.left.definition() === self.right.definition()
  19142. && is_object(self.left.fixed_value())) {
  19143. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  19144. } else if (self.left.is_32_bit_integer(compressor) && self.right.is_32_bit_integer(compressor)) {
  19145. const not = node => make_node(AST_UnaryPrefix, node, {
  19146. operator: "!",
  19147. expression: node
  19148. });
  19149. const booleanify = (node, truthy) => {
  19150. if (truthy) {
  19151. return compressor.in_boolean_context()
  19152. ? node
  19153. : not(not(node));
  19154. } else {
  19155. return not(node);
  19156. }
  19157. };
  19158. // The only falsy 32-bit integer is 0
  19159. if (self.left instanceof AST_Number && self.left.value === 0) {
  19160. return booleanify(self.right, self.operator[0] === "!");
  19161. }
  19162. if (self.right instanceof AST_Number && self.right.value === 0) {
  19163. return booleanify(self.left, self.operator[0] === "!");
  19164. }
  19165. // Mask all-bits check
  19166. // (x & 0xFF) != 0xFF => !(~x & 0xFF)
  19167. let and_op, x, mask;
  19168. if (
  19169. (and_op =
  19170. self.left instanceof AST_Binary ? self.left
  19171. : self.right instanceof AST_Binary ? self.right : null)
  19172. && (mask = and_op === self.left ? self.right : self.left)
  19173. && and_op.operator === "&"
  19174. && mask instanceof AST_Number
  19175. && mask.is_32_bit_integer(compressor)
  19176. && (x =
  19177. and_op.left.equivalent_to(mask) ? and_op.right
  19178. : and_op.right.equivalent_to(mask) ? and_op.left : null)
  19179. ) {
  19180. let optimized = booleanify(make_node(AST_Binary, self, {
  19181. operator: "&",
  19182. left: mask,
  19183. right: make_node(AST_UnaryPrefix, self, {
  19184. operator: "~",
  19185. expression: x
  19186. })
  19187. }), self.operator[0] === "!");
  19188. return best_of(compressor, optimized, self);
  19189. }
  19190. }
  19191. break;
  19192. case "&&":
  19193. case "||":
  19194. var lhs = self.left;
  19195. if (lhs.operator == self.operator) {
  19196. lhs = lhs.right;
  19197. }
  19198. if (lhs instanceof AST_Binary
  19199. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  19200. && self.right instanceof AST_Binary
  19201. && lhs.operator == self.right.operator
  19202. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  19203. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  19204. && !lhs.right.has_side_effects(compressor)
  19205. && lhs.right.equivalent_to(self.right.right)) {
  19206. var combined = make_node(AST_Binary, self, {
  19207. operator: lhs.operator.slice(0, -1),
  19208. left: make_node(AST_Null, self),
  19209. right: lhs.right
  19210. });
  19211. if (lhs !== self.left) {
  19212. combined = make_node(AST_Binary, self, {
  19213. operator: self.operator,
  19214. left: self.left.left,
  19215. right: combined
  19216. });
  19217. }
  19218. return combined;
  19219. }
  19220. break;
  19221. }
  19222. if (self.operator == "+" && compressor.in_boolean_context()) {
  19223. var ll = self.left.evaluate(compressor);
  19224. var rr = self.right.evaluate(compressor);
  19225. if (ll && typeof ll == "string") {
  19226. return make_sequence(self, [
  19227. self.right,
  19228. make_node(AST_True, self)
  19229. ]).optimize(compressor);
  19230. }
  19231. if (rr && typeof rr == "string") {
  19232. return make_sequence(self, [
  19233. self.left,
  19234. make_node(AST_True, self)
  19235. ]).optimize(compressor);
  19236. }
  19237. }
  19238. if (compressor.option("comparisons") && self.is_boolean()) {
  19239. if (!(compressor.parent() instanceof AST_Binary)
  19240. || compressor.parent() instanceof AST_Assign) {
  19241. var negated = make_node(AST_UnaryPrefix, self, {
  19242. operator: "!",
  19243. expression: self.negate(compressor, first_in_statement(compressor))
  19244. });
  19245. self = best_of(compressor, self, negated);
  19246. }
  19247. if (compressor.option("unsafe_comps")) {
  19248. switch (self.operator) {
  19249. case "<": reverse(">"); break;
  19250. case "<=": reverse(">="); break;
  19251. }
  19252. }
  19253. }
  19254. if (self.operator == "+") {
  19255. if (self.right instanceof AST_String
  19256. && self.right.getValue() == ""
  19257. && self.left.is_string(compressor)) {
  19258. return self.left;
  19259. }
  19260. if (self.left instanceof AST_String
  19261. && self.left.getValue() == ""
  19262. && self.right.is_string(compressor)) {
  19263. return self.right;
  19264. }
  19265. if (self.left instanceof AST_Binary
  19266. && self.left.operator == "+"
  19267. && self.left.left instanceof AST_String
  19268. && self.left.left.getValue() == ""
  19269. && self.right.is_string(compressor)) {
  19270. self.left = self.left.right;
  19271. return self;
  19272. }
  19273. }
  19274. if (compressor.option("evaluate")) {
  19275. switch (self.operator) {
  19276. case "&&":
  19277. var ll = has_flag(self.left, TRUTHY)
  19278. ? true
  19279. : has_flag(self.left, FALSY)
  19280. ? false
  19281. : self.left.evaluate(compressor);
  19282. if (!ll) {
  19283. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  19284. } else if (!(ll instanceof AST_Node)) {
  19285. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  19286. }
  19287. var rr = self.right.evaluate(compressor);
  19288. if (!rr) {
  19289. if (compressor.in_boolean_context()) {
  19290. return make_sequence(self, [
  19291. self.left,
  19292. make_node(AST_False, self)
  19293. ]).optimize(compressor);
  19294. } else {
  19295. set_flag(self, FALSY);
  19296. }
  19297. } else if (!(rr instanceof AST_Node)) {
  19298. var parent = compressor.parent();
  19299. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  19300. return self.left.optimize(compressor);
  19301. }
  19302. }
  19303. // x || false && y ---> x ? y : false
  19304. if (self.left.operator == "||") {
  19305. var lr = self.left.right.evaluate(compressor);
  19306. if (!lr) return make_node(AST_Conditional, self, {
  19307. condition: self.left.left,
  19308. consequent: self.right,
  19309. alternative: self.left.right
  19310. }).optimize(compressor);
  19311. }
  19312. break;
  19313. case "||":
  19314. var ll = has_flag(self.left, TRUTHY)
  19315. ? true
  19316. : has_flag(self.left, FALSY)
  19317. ? false
  19318. : self.left.evaluate(compressor);
  19319. if (!ll) {
  19320. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  19321. } else if (!(ll instanceof AST_Node)) {
  19322. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  19323. }
  19324. var rr = self.right.evaluate(compressor);
  19325. if (!rr) {
  19326. var parent = compressor.parent();
  19327. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  19328. return self.left.optimize(compressor);
  19329. }
  19330. } else if (!(rr instanceof AST_Node)) {
  19331. if (compressor.in_boolean_context()) {
  19332. return make_sequence(self, [
  19333. self.left,
  19334. make_node(AST_True, self)
  19335. ]).optimize(compressor);
  19336. } else {
  19337. set_flag(self, TRUTHY);
  19338. }
  19339. }
  19340. if (self.left.operator == "&&") {
  19341. var lr = self.left.right.evaluate(compressor);
  19342. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  19343. condition: self.left.left,
  19344. consequent: self.left.right,
  19345. alternative: self.right
  19346. }).optimize(compressor);
  19347. }
  19348. break;
  19349. case "??":
  19350. if (is_nullish(self.left, compressor)) {
  19351. return self.right;
  19352. }
  19353. var ll = self.left.evaluate(compressor);
  19354. if (!(ll instanceof AST_Node)) {
  19355. // if we know the value for sure we can simply compute right away.
  19356. return ll == null ? self.right : self.left;
  19357. }
  19358. if (compressor.in_boolean_context()) {
  19359. const rr = self.right.evaluate(compressor);
  19360. if (!(rr instanceof AST_Node) && !rr) {
  19361. return self.left;
  19362. }
  19363. }
  19364. }
  19365. var associative = true;
  19366. switch (self.operator) {
  19367. case "+":
  19368. // (x + "foo") + "bar" => x + "foobar"
  19369. if (self.right instanceof AST_Constant
  19370. && self.left instanceof AST_Binary
  19371. && self.left.operator == "+"
  19372. && self.left.is_string(compressor)) {
  19373. var binary = make_node(AST_Binary, self, {
  19374. operator: "+",
  19375. left: self.left.right,
  19376. right: self.right,
  19377. });
  19378. var r = binary.optimize(compressor);
  19379. if (binary !== r) {
  19380. self = make_node(AST_Binary, self, {
  19381. operator: "+",
  19382. left: self.left.left,
  19383. right: r
  19384. });
  19385. }
  19386. }
  19387. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  19388. if (self.left instanceof AST_Binary
  19389. && self.left.operator == "+"
  19390. && self.left.is_string(compressor)
  19391. && self.right instanceof AST_Binary
  19392. && self.right.operator == "+"
  19393. && self.right.is_string(compressor)) {
  19394. var binary = make_node(AST_Binary, self, {
  19395. operator: "+",
  19396. left: self.left.right,
  19397. right: self.right.left,
  19398. });
  19399. var m = binary.optimize(compressor);
  19400. if (binary !== m) {
  19401. self = make_node(AST_Binary, self, {
  19402. operator: "+",
  19403. left: make_node(AST_Binary, self.left, {
  19404. operator: "+",
  19405. left: self.left.left,
  19406. right: m
  19407. }),
  19408. right: self.right.right
  19409. });
  19410. }
  19411. }
  19412. // a + -b => a - b
  19413. if (self.right instanceof AST_UnaryPrefix
  19414. && self.right.operator == "-"
  19415. && self.left.is_number_or_bigint(compressor)) {
  19416. self = make_node(AST_Binary, self, {
  19417. operator: "-",
  19418. left: self.left,
  19419. right: self.right.expression
  19420. });
  19421. break;
  19422. }
  19423. // -a + b => b - a
  19424. if (self.left instanceof AST_UnaryPrefix
  19425. && self.left.operator == "-"
  19426. && reversible()
  19427. && self.right.is_number_or_bigint(compressor)) {
  19428. self = make_node(AST_Binary, self, {
  19429. operator: "-",
  19430. left: self.right,
  19431. right: self.left.expression
  19432. });
  19433. break;
  19434. }
  19435. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  19436. if (self.left instanceof AST_TemplateString) {
  19437. var l = self.left;
  19438. var r = self.right.evaluate(compressor);
  19439. if (r != self.right) {
  19440. l.segments[l.segments.length - 1].value += String(r);
  19441. return l;
  19442. }
  19443. }
  19444. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  19445. if (self.right instanceof AST_TemplateString) {
  19446. var r = self.right;
  19447. var l = self.left.evaluate(compressor);
  19448. if (l != self.left) {
  19449. r.segments[0].value = String(l) + r.segments[0].value;
  19450. return r;
  19451. }
  19452. }
  19453. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  19454. if (self.left instanceof AST_TemplateString
  19455. && self.right instanceof AST_TemplateString) {
  19456. var l = self.left;
  19457. var segments = l.segments;
  19458. var r = self.right;
  19459. segments[segments.length - 1].value += r.segments[0].value;
  19460. for (var i = 1; i < r.segments.length; i++) {
  19461. segments.push(r.segments[i]);
  19462. }
  19463. return l;
  19464. }
  19465. case "*":
  19466. associative = compressor.option("unsafe_math");
  19467. case "&":
  19468. case "|":
  19469. case "^":
  19470. // a + +b => +b + a
  19471. if (
  19472. self.left.is_number_or_bigint(compressor)
  19473. && self.right.is_number_or_bigint(compressor)
  19474. && reversible()
  19475. && !(self.left instanceof AST_Binary
  19476. && self.left.operator != self.operator
  19477. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  19478. var reversed = make_node(AST_Binary, self, {
  19479. operator: self.operator,
  19480. left: self.right,
  19481. right: self.left
  19482. });
  19483. if (self.right instanceof AST_Constant
  19484. && !(self.left instanceof AST_Constant)) {
  19485. self = best_of(compressor, reversed, self);
  19486. } else {
  19487. self = best_of(compressor, self, reversed);
  19488. }
  19489. }
  19490. if (associative && self.is_number_or_bigint(compressor)) {
  19491. // a + (b + c) => (a + b) + c
  19492. if (self.right instanceof AST_Binary
  19493. && self.right.operator == self.operator) {
  19494. self = make_node(AST_Binary, self, {
  19495. operator: self.operator,
  19496. left: make_node(AST_Binary, self.left, {
  19497. operator: self.operator,
  19498. left: self.left,
  19499. right: self.right.left,
  19500. start: self.left.start,
  19501. end: self.right.left.end
  19502. }),
  19503. right: self.right.right
  19504. });
  19505. }
  19506. // (n + 2) + 3 => 5 + n
  19507. // (2 * n) * 3 => 6 + n
  19508. if (self.right instanceof AST_Constant
  19509. && self.left instanceof AST_Binary
  19510. && self.left.operator == self.operator) {
  19511. if (self.left.left instanceof AST_Constant) {
  19512. self = make_node(AST_Binary, self, {
  19513. operator: self.operator,
  19514. left: make_node(AST_Binary, self.left, {
  19515. operator: self.operator,
  19516. left: self.left.left,
  19517. right: self.right,
  19518. start: self.left.left.start,
  19519. end: self.right.end
  19520. }),
  19521. right: self.left.right
  19522. });
  19523. } else if (self.left.right instanceof AST_Constant) {
  19524. self = make_node(AST_Binary, self, {
  19525. operator: self.operator,
  19526. left: make_node(AST_Binary, self.left, {
  19527. operator: self.operator,
  19528. left: self.left.right,
  19529. right: self.right,
  19530. start: self.left.right.start,
  19531. end: self.right.end
  19532. }),
  19533. right: self.left.left
  19534. });
  19535. }
  19536. }
  19537. // (a | 1) | (2 | d) => (3 | a) | b
  19538. if (self.left instanceof AST_Binary
  19539. && self.left.operator == self.operator
  19540. && self.left.right instanceof AST_Constant
  19541. && self.right instanceof AST_Binary
  19542. && self.right.operator == self.operator
  19543. && self.right.left instanceof AST_Constant) {
  19544. self = make_node(AST_Binary, self, {
  19545. operator: self.operator,
  19546. left: make_node(AST_Binary, self.left, {
  19547. operator: self.operator,
  19548. left: make_node(AST_Binary, self.left.left, {
  19549. operator: self.operator,
  19550. left: self.left.right,
  19551. right: self.right.left,
  19552. start: self.left.right.start,
  19553. end: self.right.left.end
  19554. }),
  19555. right: self.left.left
  19556. }),
  19557. right: self.right.right
  19558. });
  19559. }
  19560. }
  19561. }
  19562. // bitwise ops
  19563. if (bitwise_binop.has(self.operator)) {
  19564. // Use De Morgan's laws
  19565. // z & (X | y)
  19566. // => z & X (given y & z === 0)
  19567. // => z & X | {y & z} (given y & z !== 0)
  19568. let y, z, x_node, y_node, z_node = self.left;
  19569. if (
  19570. self.operator === "&"
  19571. && self.right instanceof AST_Binary
  19572. && self.right.operator === "|"
  19573. && typeof (z = self.left.evaluate(compressor)) === "number"
  19574. ) {
  19575. if (typeof (y = self.right.right.evaluate(compressor)) === "number") {
  19576. // z & (X | y)
  19577. x_node = self.right.left;
  19578. y_node = self.right.right;
  19579. } else if (typeof (y = self.right.left.evaluate(compressor)) === "number") {
  19580. // z & (y | X)
  19581. x_node = self.right.right;
  19582. y_node = self.right.left;
  19583. }
  19584. if (x_node && y_node) {
  19585. if ((y & z) === 0) {
  19586. self = make_node(AST_Binary, self, {
  19587. operator: self.operator,
  19588. left: z_node,
  19589. right: x_node
  19590. });
  19591. } else {
  19592. const reordered_ops = make_node(AST_Binary, self, {
  19593. operator: "|",
  19594. left: make_node(AST_Binary, self, {
  19595. operator: "&",
  19596. left: x_node,
  19597. right: z_node
  19598. }),
  19599. right: make_node_from_constant(y & z, y_node),
  19600. });
  19601. self = best_of(compressor, self, reordered_ops);
  19602. }
  19603. }
  19604. }
  19605. // x | x => 0 | x
  19606. // x & x => 0 | x
  19607. if (
  19608. (self.operator === "|" || self.operator === "&")
  19609. && self.left.equivalent_to(self.right)
  19610. && !self.left.has_side_effects(compressor)
  19611. && compressor.in_32_bit_context(true)
  19612. ) {
  19613. self.left = make_node(AST_Number, self, { value: 0 });
  19614. self.operator = "|";
  19615. }
  19616. // ~x ^ ~y => x ^ y
  19617. if (
  19618. self.operator === "^"
  19619. && self.left instanceof AST_UnaryPrefix
  19620. && self.left.operator === "~"
  19621. && self.right instanceof AST_UnaryPrefix
  19622. && self.right.operator === "~"
  19623. ) {
  19624. self = make_node(AST_Binary, self, {
  19625. operator: "^",
  19626. left: self.left.expression,
  19627. right: self.right.expression
  19628. });
  19629. }
  19630. // Shifts that do nothing
  19631. // {anything} >> 0 => {anything} | 0
  19632. // {anything} << 0 => {anything} | 0
  19633. if (
  19634. (self.operator === "<<" || self.operator === ">>")
  19635. && self.right instanceof AST_Number && self.right.value === 0
  19636. ) {
  19637. self.operator = "|";
  19638. }
  19639. // Find useless to-bitwise conversions
  19640. // {32 bit integer} | 0 => {32 bit integer}
  19641. // {32 bit integer} ^ 0 => {32 bit integer}
  19642. const zero_side = self.right instanceof AST_Number && self.right.value === 0 ? self.right
  19643. : self.left instanceof AST_Number && self.left.value === 0 ? self.left
  19644. : null;
  19645. const non_zero_side = zero_side && (zero_side === self.right ? self.left : self.right);
  19646. if (
  19647. zero_side
  19648. && (self.operator === "|" || self.operator === "^")
  19649. && (non_zero_side.is_32_bit_integer(compressor) || compressor.in_32_bit_context(true))
  19650. ) {
  19651. return non_zero_side;
  19652. }
  19653. // {anything} & 0 => 0
  19654. if (
  19655. zero_side
  19656. && self.operator === "&"
  19657. && !non_zero_side.has_side_effects(compressor)
  19658. && non_zero_side.is_32_bit_integer(compressor)
  19659. ) {
  19660. return zero_side;
  19661. }
  19662. // ~0 is all ones, as well as -1.
  19663. // We can ellide some operations with it.
  19664. const is_full_mask = (node) =>
  19665. node instanceof AST_Number && node.value === -1
  19666. ||
  19667. node instanceof AST_UnaryPrefix
  19668. && node.operator === "-"
  19669. && node.expression instanceof AST_Number
  19670. && node.expression.value === 1;
  19671. const full_mask = is_full_mask(self.right) ? self.right
  19672. : is_full_mask(self.left) ? self.left
  19673. : null;
  19674. const other_side = (full_mask === self.right ? self.left : self.right);
  19675. // {32 bit integer} & -1 => {32 bit integer}
  19676. if (
  19677. full_mask
  19678. && self.operator === "&"
  19679. && (
  19680. other_side.is_32_bit_integer(compressor)
  19681. || compressor.in_32_bit_context(true)
  19682. )
  19683. ) {
  19684. return other_side;
  19685. }
  19686. // {anything} ^ -1 => ~{anything}
  19687. if (
  19688. full_mask
  19689. && self.operator === "^"
  19690. && (
  19691. other_side.is_32_bit_integer(compressor)
  19692. || compressor.in_32_bit_context(true)
  19693. )
  19694. ) {
  19695. return other_side.bitwise_negate(compressor);
  19696. }
  19697. }
  19698. }
  19699. // x && (y && z) ==> x && y && z
  19700. // x || (y || z) ==> x || y || z
  19701. // x + ("y" + z) ==> x + "y" + z
  19702. // "x" + (y + "z")==> "x" + y + "z"
  19703. if (self.right instanceof AST_Binary
  19704. && self.right.operator == self.operator
  19705. && (lazy_op.has(self.operator)
  19706. || (self.operator == "+"
  19707. && (self.right.left.is_string(compressor)
  19708. || (self.left.is_string(compressor)
  19709. && self.right.right.is_string(compressor)))))
  19710. ) {
  19711. self.left = make_node(AST_Binary, self.left, {
  19712. operator : self.operator,
  19713. left : self.left.transform(compressor),
  19714. right : self.right.left.transform(compressor)
  19715. });
  19716. self.right = self.right.right.transform(compressor);
  19717. return self.transform(compressor);
  19718. }
  19719. var ev = self.evaluate(compressor);
  19720. if (ev !== self) {
  19721. ev = make_node_from_constant(ev, self).optimize(compressor);
  19722. return best_of(compressor, ev, self);
  19723. }
  19724. return self;
  19725. });
  19726. def_optimize(AST_SymbolExport, function(self) {
  19727. return self;
  19728. });
  19729. def_optimize(AST_SymbolRef, function(self, compressor) {
  19730. if (
  19731. !compressor.option("ie8")
  19732. && is_undeclared_ref(self)
  19733. && !compressor.find_parent(AST_With)
  19734. ) {
  19735. switch (self.name) {
  19736. case "undefined":
  19737. return make_node(AST_Undefined, self).optimize(compressor);
  19738. case "NaN":
  19739. return make_node(AST_NaN, self).optimize(compressor);
  19740. case "Infinity":
  19741. return make_node(AST_Infinity, self).optimize(compressor);
  19742. }
  19743. }
  19744. if (compressor.option("reduce_vars") && !compressor.is_lhs()) {
  19745. return inline_into_symbolref(self, compressor);
  19746. } else {
  19747. return self;
  19748. }
  19749. });
  19750. function is_atomic(lhs, self) {
  19751. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  19752. }
  19753. def_optimize(AST_Undefined, function(self, compressor) {
  19754. if (compressor.option("unsafe_undefined")) {
  19755. var undef = find_variable(compressor, "undefined");
  19756. if (undef) {
  19757. var ref = make_node(AST_SymbolRef, self, {
  19758. name : "undefined",
  19759. scope : undef.scope,
  19760. thedef : undef
  19761. });
  19762. set_flag(ref, UNDEFINED);
  19763. return ref;
  19764. }
  19765. }
  19766. var lhs = compressor.is_lhs();
  19767. if (lhs && is_atomic(lhs, self)) return self;
  19768. return make_node(AST_UnaryPrefix, self, {
  19769. operator: "void",
  19770. expression: make_node(AST_Number, self, {
  19771. value: 0
  19772. })
  19773. });
  19774. });
  19775. def_optimize(AST_Infinity, function(self, compressor) {
  19776. var lhs = compressor.is_lhs();
  19777. if (lhs && is_atomic(lhs, self)) return self;
  19778. if (
  19779. compressor.option("keep_infinity")
  19780. && !(lhs && !is_atomic(lhs, self))
  19781. && !find_variable(compressor, "Infinity")
  19782. ) {
  19783. return self;
  19784. }
  19785. return make_node(AST_Binary, self, {
  19786. operator: "/",
  19787. left: make_node(AST_Number, self, {
  19788. value: 1
  19789. }),
  19790. right: make_node(AST_Number, self, {
  19791. value: 0
  19792. })
  19793. });
  19794. });
  19795. def_optimize(AST_NaN, function(self, compressor) {
  19796. var lhs = compressor.is_lhs();
  19797. if (lhs && !is_atomic(lhs, self)
  19798. || find_variable(compressor, "NaN")) {
  19799. return make_node(AST_Binary, self, {
  19800. operator: "/",
  19801. left: make_node(AST_Number, self, {
  19802. value: 0
  19803. }),
  19804. right: make_node(AST_Number, self, {
  19805. value: 0
  19806. })
  19807. });
  19808. }
  19809. return self;
  19810. });
  19811. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  19812. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  19813. def_optimize(AST_Assign, function(self, compressor) {
  19814. if (self.logical) {
  19815. return self.lift_sequences(compressor);
  19816. }
  19817. var def;
  19818. // x = x ---> x
  19819. if (
  19820. self.operator === "="
  19821. && self.left instanceof AST_SymbolRef
  19822. && self.left.name !== "arguments"
  19823. && !(def = self.left.definition()).undeclared
  19824. && self.right.equivalent_to(self.left)
  19825. ) {
  19826. return self.right;
  19827. }
  19828. if (compressor.option("dead_code")
  19829. && self.left instanceof AST_SymbolRef
  19830. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  19831. var level = 0, node, parent = self;
  19832. do {
  19833. node = parent;
  19834. parent = compressor.parent(level++);
  19835. if (parent instanceof AST_Exit) {
  19836. if (in_try(level, parent)) break;
  19837. if (is_reachable(def.scope, [ def ])) break;
  19838. if (self.operator == "=") return self.right;
  19839. def.fixed = false;
  19840. return make_node(AST_Binary, self, {
  19841. operator: self.operator.slice(0, -1),
  19842. left: self.left,
  19843. right: self.right
  19844. }).optimize(compressor);
  19845. }
  19846. } while (parent instanceof AST_Binary && parent.right === node
  19847. || parent instanceof AST_Sequence && parent.tail_node() === node);
  19848. }
  19849. self = self.lift_sequences(compressor);
  19850. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  19851. // x = expr1 OP expr2
  19852. if (self.right.left instanceof AST_SymbolRef
  19853. && self.right.left.name == self.left.name
  19854. && ASSIGN_OPS.has(self.right.operator)) {
  19855. // x = x - 2 ---> x -= 2
  19856. self.operator = self.right.operator + "=";
  19857. self.right = self.right.right;
  19858. } else if (self.right.right instanceof AST_SymbolRef
  19859. && self.right.right.name == self.left.name
  19860. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  19861. && !self.right.left.has_side_effects(compressor)) {
  19862. // x = 2 & x ---> x &= 2
  19863. self.operator = self.right.operator + "=";
  19864. self.right = self.right.left;
  19865. }
  19866. }
  19867. return self;
  19868. function in_try(level, node) {
  19869. function may_assignment_throw() {
  19870. const right = self.right;
  19871. self.right = make_node(AST_Null, right);
  19872. const may_throw = node.may_throw(compressor);
  19873. self.right = right;
  19874. return may_throw;
  19875. }
  19876. var stop_at = self.left.definition().scope.get_defun_scope();
  19877. var parent;
  19878. while ((parent = compressor.parent(level++)) !== stop_at) {
  19879. if (parent instanceof AST_Try) {
  19880. if (parent.bfinally) return true;
  19881. if (parent.bcatch && may_assignment_throw()) return true;
  19882. }
  19883. }
  19884. }
  19885. });
  19886. def_optimize(AST_DefaultAssign, function(self, compressor) {
  19887. if (!compressor.option("evaluate")) {
  19888. return self;
  19889. }
  19890. var evaluateRight = self.right.evaluate(compressor);
  19891. // `[x = undefined] = foo` ---> `[x] = foo`
  19892. // `(arg = undefined) => ...` ---> `(arg) => ...` (unless `keep_fargs`)
  19893. // `((arg = undefined) => ...)()` ---> `((arg) => ...)()`
  19894. let lambda, iife;
  19895. if (evaluateRight === undefined) {
  19896. if (
  19897. (lambda = compressor.parent()) instanceof AST_Lambda
  19898. ? (
  19899. compressor.option("keep_fargs") === false
  19900. || (iife = compressor.parent(1)).TYPE === "Call"
  19901. && iife.expression === lambda
  19902. )
  19903. : true
  19904. ) {
  19905. self = self.left;
  19906. }
  19907. } else if (evaluateRight !== self.right) {
  19908. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  19909. self.right = best_of_expression(evaluateRight, self.right);
  19910. }
  19911. return self;
  19912. });
  19913. function is_nullish_check(check, check_subject, compressor) {
  19914. if (check_subject.may_throw(compressor)) return false;
  19915. let nullish_side;
  19916. // foo == null
  19917. if (
  19918. check instanceof AST_Binary
  19919. && check.operator === "=="
  19920. // which side is nullish?
  19921. && (
  19922. (nullish_side = is_nullish(check.left, compressor) && check.left)
  19923. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  19924. )
  19925. // is the other side the same as the check_subject
  19926. && (
  19927. nullish_side === check.left
  19928. ? check.right
  19929. : check.left
  19930. ).equivalent_to(check_subject)
  19931. ) {
  19932. return true;
  19933. }
  19934. // foo === null || foo === undefined
  19935. if (check instanceof AST_Binary && check.operator === "||") {
  19936. let null_cmp;
  19937. let undefined_cmp;
  19938. const find_comparison = cmp => {
  19939. if (!(
  19940. cmp instanceof AST_Binary
  19941. && (cmp.operator === "===" || cmp.operator === "==")
  19942. )) {
  19943. return false;
  19944. }
  19945. let found = 0;
  19946. let defined_side;
  19947. if (cmp.left instanceof AST_Null) {
  19948. found++;
  19949. null_cmp = cmp;
  19950. defined_side = cmp.right;
  19951. }
  19952. if (cmp.right instanceof AST_Null) {
  19953. found++;
  19954. null_cmp = cmp;
  19955. defined_side = cmp.left;
  19956. }
  19957. if (is_undefined(cmp.left, compressor)) {
  19958. found++;
  19959. undefined_cmp = cmp;
  19960. defined_side = cmp.right;
  19961. }
  19962. if (is_undefined(cmp.right, compressor)) {
  19963. found++;
  19964. undefined_cmp = cmp;
  19965. defined_side = cmp.left;
  19966. }
  19967. if (found !== 1) {
  19968. return false;
  19969. }
  19970. if (!defined_side.equivalent_to(check_subject)) {
  19971. return false;
  19972. }
  19973. return true;
  19974. };
  19975. if (!find_comparison(check.left)) return false;
  19976. if (!find_comparison(check.right)) return false;
  19977. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  19978. return true;
  19979. }
  19980. }
  19981. return false;
  19982. }
  19983. def_optimize(AST_Conditional, function(self, compressor) {
  19984. if (!compressor.option("conditionals")) return self;
  19985. // This looks like lift_sequences(), should probably be under "sequences"
  19986. if (self.condition instanceof AST_Sequence) {
  19987. var expressions = self.condition.expressions.slice();
  19988. self.condition = expressions.pop();
  19989. expressions.push(self);
  19990. return make_sequence(self, expressions);
  19991. }
  19992. var cond = self.condition.evaluate(compressor);
  19993. if (cond !== self.condition) {
  19994. if (cond) {
  19995. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  19996. } else {
  19997. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  19998. }
  19999. }
  20000. var negated = cond.negate(compressor, first_in_statement(compressor));
  20001. if (best_of(compressor, cond, negated) === negated) {
  20002. self = make_node(AST_Conditional, self, {
  20003. condition: negated,
  20004. consequent: self.alternative,
  20005. alternative: self.consequent
  20006. });
  20007. }
  20008. var condition = self.condition;
  20009. var consequent = self.consequent;
  20010. var alternative = self.alternative;
  20011. // x?x:y --> x||y
  20012. if (condition instanceof AST_SymbolRef
  20013. && consequent instanceof AST_SymbolRef
  20014. && condition.definition() === consequent.definition()) {
  20015. return make_node(AST_Binary, self, {
  20016. operator: "||",
  20017. left: condition,
  20018. right: alternative
  20019. });
  20020. }
  20021. // if (foo) exp = something; else exp = something_else;
  20022. // |
  20023. // v
  20024. // exp = foo ? something : something_else;
  20025. if (
  20026. consequent instanceof AST_Assign
  20027. && alternative instanceof AST_Assign
  20028. && consequent.operator === alternative.operator
  20029. && consequent.logical === alternative.logical
  20030. && consequent.left.equivalent_to(alternative.left)
  20031. && (!self.condition.has_side_effects(compressor)
  20032. || consequent.operator == "="
  20033. && !consequent.left.has_side_effects(compressor))
  20034. ) {
  20035. return make_node(AST_Assign, self, {
  20036. operator: consequent.operator,
  20037. left: consequent.left,
  20038. logical: consequent.logical,
  20039. right: make_node(AST_Conditional, self, {
  20040. condition: self.condition,
  20041. consequent: consequent.right,
  20042. alternative: alternative.right
  20043. })
  20044. });
  20045. }
  20046. // x ? y(a) : y(b) --> y(x ? a : b)
  20047. var arg_index;
  20048. if (consequent instanceof AST_Call
  20049. && alternative.TYPE === consequent.TYPE
  20050. && consequent.args.length > 0
  20051. && consequent.args.length == alternative.args.length
  20052. && consequent.expression.equivalent_to(alternative.expression)
  20053. && !self.condition.has_side_effects(compressor)
  20054. && !consequent.expression.has_side_effects(compressor)
  20055. && typeof (arg_index = single_arg_diff()) == "number") {
  20056. var node = consequent.clone();
  20057. node.args[arg_index] = make_node(AST_Conditional, self, {
  20058. condition: self.condition,
  20059. consequent: consequent.args[arg_index],
  20060. alternative: alternative.args[arg_index]
  20061. });
  20062. return node;
  20063. }
  20064. // a ? b : c ? b : d --> (a || c) ? b : d
  20065. if (alternative instanceof AST_Conditional
  20066. && consequent.equivalent_to(alternative.consequent)) {
  20067. return make_node(AST_Conditional, self, {
  20068. condition: make_node(AST_Binary, self, {
  20069. operator: "||",
  20070. left: condition,
  20071. right: alternative.condition
  20072. }),
  20073. consequent: consequent,
  20074. alternative: alternative.alternative
  20075. }).optimize(compressor);
  20076. }
  20077. // a == null ? b : a -> a ?? b
  20078. if (
  20079. compressor.option("ecma") >= 2020 &&
  20080. is_nullish_check(condition, alternative, compressor)
  20081. ) {
  20082. return make_node(AST_Binary, self, {
  20083. operator: "??",
  20084. left: alternative,
  20085. right: consequent
  20086. }).optimize(compressor);
  20087. }
  20088. // a ? b : (c, b) --> (a || c), b
  20089. if (alternative instanceof AST_Sequence
  20090. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  20091. return make_sequence(self, [
  20092. make_node(AST_Binary, self, {
  20093. operator: "||",
  20094. left: condition,
  20095. right: make_sequence(self, alternative.expressions.slice(0, -1))
  20096. }),
  20097. consequent
  20098. ]).optimize(compressor);
  20099. }
  20100. // a ? b : (c && b) --> (a || c) && b
  20101. if (alternative instanceof AST_Binary
  20102. && alternative.operator == "&&"
  20103. && consequent.equivalent_to(alternative.right)) {
  20104. return make_node(AST_Binary, self, {
  20105. operator: "&&",
  20106. left: make_node(AST_Binary, self, {
  20107. operator: "||",
  20108. left: condition,
  20109. right: alternative.left
  20110. }),
  20111. right: consequent
  20112. }).optimize(compressor);
  20113. }
  20114. // x?y?z:a:a --> x&&y?z:a
  20115. if (consequent instanceof AST_Conditional
  20116. && consequent.alternative.equivalent_to(alternative)) {
  20117. return make_node(AST_Conditional, self, {
  20118. condition: make_node(AST_Binary, self, {
  20119. left: self.condition,
  20120. operator: "&&",
  20121. right: consequent.condition
  20122. }),
  20123. consequent: consequent.consequent,
  20124. alternative: alternative
  20125. });
  20126. }
  20127. // x ? y : y --> x, y
  20128. if (consequent.equivalent_to(alternative)) {
  20129. return make_sequence(self, [
  20130. self.condition,
  20131. consequent
  20132. ]).optimize(compressor);
  20133. }
  20134. // x ? y || z : z --> x && y || z
  20135. if (consequent instanceof AST_Binary
  20136. && consequent.operator == "||"
  20137. && consequent.right.equivalent_to(alternative)) {
  20138. return make_node(AST_Binary, self, {
  20139. operator: "||",
  20140. left: make_node(AST_Binary, self, {
  20141. operator: "&&",
  20142. left: self.condition,
  20143. right: consequent.left
  20144. }),
  20145. right: alternative
  20146. }).optimize(compressor);
  20147. }
  20148. const in_bool = compressor.in_boolean_context();
  20149. if (is_true(self.consequent)) {
  20150. if (is_false(self.alternative)) {
  20151. // c ? true : false ---> !!c
  20152. return booleanize(self.condition);
  20153. }
  20154. // c ? true : x ---> !!c || x
  20155. return make_node(AST_Binary, self, {
  20156. operator: "||",
  20157. left: booleanize(self.condition),
  20158. right: self.alternative
  20159. });
  20160. }
  20161. if (is_false(self.consequent)) {
  20162. if (is_true(self.alternative)) {
  20163. // c ? false : true ---> !c
  20164. return booleanize(self.condition.negate(compressor));
  20165. }
  20166. // c ? false : x ---> !c && x
  20167. return make_node(AST_Binary, self, {
  20168. operator: "&&",
  20169. left: booleanize(self.condition.negate(compressor)),
  20170. right: self.alternative
  20171. });
  20172. }
  20173. if (is_true(self.alternative)) {
  20174. // c ? x : true ---> !c || x
  20175. return make_node(AST_Binary, self, {
  20176. operator: "||",
  20177. left: booleanize(self.condition.negate(compressor)),
  20178. right: self.consequent
  20179. });
  20180. }
  20181. if (is_false(self.alternative)) {
  20182. // c ? x : false ---> !!c && x
  20183. return make_node(AST_Binary, self, {
  20184. operator: "&&",
  20185. left: booleanize(self.condition),
  20186. right: self.consequent
  20187. });
  20188. }
  20189. return self;
  20190. function booleanize(node) {
  20191. if (node.is_boolean()) return node;
  20192. // !!expression
  20193. return make_node(AST_UnaryPrefix, node, {
  20194. operator: "!",
  20195. expression: node.negate(compressor)
  20196. });
  20197. }
  20198. // AST_True or !0
  20199. function is_true(node) {
  20200. return node instanceof AST_True
  20201. || in_bool
  20202. && node instanceof AST_Constant
  20203. && node.getValue()
  20204. || (node instanceof AST_UnaryPrefix
  20205. && node.operator == "!"
  20206. && node.expression instanceof AST_Constant
  20207. && !node.expression.getValue());
  20208. }
  20209. // AST_False or !1
  20210. function is_false(node) {
  20211. return node instanceof AST_False
  20212. || in_bool
  20213. && node instanceof AST_Constant
  20214. && !node.getValue()
  20215. || (node instanceof AST_UnaryPrefix
  20216. && node.operator == "!"
  20217. && node.expression instanceof AST_Constant
  20218. && node.expression.getValue());
  20219. }
  20220. function single_arg_diff() {
  20221. var a = consequent.args;
  20222. var b = alternative.args;
  20223. for (var i = 0, len = a.length; i < len; i++) {
  20224. if (a[i] instanceof AST_Expansion) return;
  20225. if (!a[i].equivalent_to(b[i])) {
  20226. if (b[i] instanceof AST_Expansion) return;
  20227. for (var j = i + 1; j < len; j++) {
  20228. if (a[j] instanceof AST_Expansion) return;
  20229. if (!a[j].equivalent_to(b[j])) return;
  20230. }
  20231. return i;
  20232. }
  20233. }
  20234. }
  20235. });
  20236. def_optimize(AST_Boolean, function(self, compressor) {
  20237. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  20238. value: +self.value
  20239. });
  20240. var p = compressor.parent();
  20241. if (compressor.option("booleans_as_integers")) {
  20242. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  20243. p.operator = p.operator.replace(/=$/, "");
  20244. }
  20245. return make_node(AST_Number, self, {
  20246. value: +self.value
  20247. });
  20248. }
  20249. if (compressor.option("booleans")) {
  20250. if (p instanceof AST_Binary && (p.operator == "=="
  20251. || p.operator == "!=")) {
  20252. return make_node(AST_Number, self, {
  20253. value: +self.value
  20254. });
  20255. }
  20256. return make_node(AST_UnaryPrefix, self, {
  20257. operator: "!",
  20258. expression: make_node(AST_Number, self, {
  20259. value: 1 - self.value
  20260. })
  20261. });
  20262. }
  20263. return self;
  20264. });
  20265. function safe_to_flatten(value, compressor) {
  20266. if (value instanceof AST_SymbolRef) {
  20267. value = value.fixed_value();
  20268. }
  20269. if (!value) return false;
  20270. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  20271. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  20272. return compressor.parent() instanceof AST_New;
  20273. }
  20274. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  20275. if (!compressor.option("properties")) return;
  20276. if (key === "__proto__") return;
  20277. if (this instanceof AST_DotHash) return;
  20278. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  20279. var expr = this.expression;
  20280. if (expr instanceof AST_Object) {
  20281. var props = expr.properties;
  20282. for (var i = props.length; --i >= 0;) {
  20283. var prop = props[i];
  20284. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  20285. const all_props_flattenable = props.every((p) =>
  20286. (p instanceof AST_ObjectKeyVal
  20287. || arrows && p instanceof AST_ConciseMethod && !p.value.is_generator
  20288. )
  20289. && !p.computed_key()
  20290. );
  20291. if (!all_props_flattenable) return;
  20292. if (!safe_to_flatten(prop.value, compressor)) return;
  20293. return make_node(AST_Sub, this, {
  20294. expression: make_node(AST_Array, expr, {
  20295. elements: props.map(function(prop) {
  20296. var v = prop.value;
  20297. if (v instanceof AST_Accessor) {
  20298. v = make_node(AST_Function, v, v);
  20299. }
  20300. var k = prop.key;
  20301. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  20302. return make_sequence(prop, [ k, v ]);
  20303. }
  20304. return v;
  20305. })
  20306. }),
  20307. property: make_node(AST_Number, this, {
  20308. value: i
  20309. })
  20310. });
  20311. }
  20312. }
  20313. }
  20314. });
  20315. def_optimize(AST_Sub, function(self, compressor) {
  20316. var expr = self.expression;
  20317. var prop = self.property;
  20318. if (compressor.option("properties")) {
  20319. var key = prop.evaluate(compressor);
  20320. if (key !== prop) {
  20321. if (typeof key == "string") {
  20322. if (key == "undefined") {
  20323. key = undefined;
  20324. } else {
  20325. var value = parseFloat(key);
  20326. if (value.toString() == key) {
  20327. key = value;
  20328. }
  20329. }
  20330. }
  20331. prop = self.property = best_of_expression(
  20332. prop,
  20333. make_node_from_constant(key, prop).transform(compressor)
  20334. );
  20335. var property = "" + key;
  20336. if (is_basic_identifier_string(property)
  20337. && property.length <= prop.size() + 1) {
  20338. return make_node(AST_Dot, self, {
  20339. expression: expr,
  20340. optional: self.optional,
  20341. property: property,
  20342. quote: prop.quote,
  20343. }).optimize(compressor);
  20344. }
  20345. }
  20346. }
  20347. var fn;
  20348. OPT_ARGUMENTS: if (compressor.option("arguments")
  20349. && expr instanceof AST_SymbolRef
  20350. && expr.name == "arguments"
  20351. && expr.definition().orig.length == 1
  20352. && (fn = expr.scope) instanceof AST_Lambda
  20353. && fn.uses_arguments
  20354. && !(fn instanceof AST_Arrow)
  20355. && prop instanceof AST_Number) {
  20356. var index = prop.getValue();
  20357. var params = new Set();
  20358. var argnames = fn.argnames;
  20359. for (var n = 0; n < argnames.length; n++) {
  20360. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  20361. break OPT_ARGUMENTS; // destructuring parameter - bail
  20362. }
  20363. var param = argnames[n].name;
  20364. if (params.has(param)) {
  20365. break OPT_ARGUMENTS; // duplicate parameter - bail
  20366. }
  20367. params.add(param);
  20368. }
  20369. var argname = fn.argnames[index];
  20370. if (argname && compressor.has_directive("use strict")) {
  20371. var def = argname.definition();
  20372. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  20373. argname = null;
  20374. }
  20375. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  20376. while (index >= fn.argnames.length) {
  20377. argname = fn.create_symbol(AST_SymbolFunarg, {
  20378. source: fn,
  20379. scope: fn,
  20380. tentative_name: "argument_" + fn.argnames.length,
  20381. });
  20382. fn.argnames.push(argname);
  20383. }
  20384. }
  20385. if (argname) {
  20386. var sym = make_node(AST_SymbolRef, self, argname);
  20387. sym.reference({});
  20388. clear_flag(argname, UNUSED);
  20389. return sym;
  20390. }
  20391. }
  20392. if (compressor.is_lhs()) return self;
  20393. if (key !== prop) {
  20394. var sub = self.flatten_object(property, compressor);
  20395. if (sub) {
  20396. expr = self.expression = sub.expression;
  20397. prop = self.property = sub.property;
  20398. }
  20399. }
  20400. if (compressor.option("properties") && compressor.option("side_effects")
  20401. && prop instanceof AST_Number && expr instanceof AST_Array) {
  20402. var index = prop.getValue();
  20403. var elements = expr.elements;
  20404. var retValue = elements[index];
  20405. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  20406. var flatten = true;
  20407. var values = [];
  20408. for (var i = elements.length; --i > index;) {
  20409. var value = elements[i].drop_side_effect_free(compressor);
  20410. if (value) {
  20411. values.unshift(value);
  20412. if (flatten && value.has_side_effects(compressor)) flatten = false;
  20413. }
  20414. }
  20415. if (retValue instanceof AST_Expansion) break FLATTEN;
  20416. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  20417. if (!flatten) values.unshift(retValue);
  20418. while (--i >= 0) {
  20419. var value = elements[i];
  20420. if (value instanceof AST_Expansion) break FLATTEN;
  20421. value = value.drop_side_effect_free(compressor);
  20422. if (value) values.unshift(value);
  20423. else index--;
  20424. }
  20425. if (flatten) {
  20426. values.push(retValue);
  20427. return make_sequence(self, values).optimize(compressor);
  20428. } else return make_node(AST_Sub, self, {
  20429. expression: make_node(AST_Array, expr, {
  20430. elements: values
  20431. }),
  20432. property: make_node(AST_Number, prop, {
  20433. value: index
  20434. })
  20435. });
  20436. }
  20437. }
  20438. var ev = self.evaluate(compressor);
  20439. if (ev !== self) {
  20440. ev = make_node_from_constant(ev, self).optimize(compressor);
  20441. return best_of(compressor, ev, self);
  20442. }
  20443. return self;
  20444. });
  20445. def_optimize(AST_Chain, function (self, compressor) {
  20446. if (is_nullish(self.expression, compressor)) {
  20447. let parent = compressor.parent();
  20448. // It's valid to delete a nullish optional chain, but if we optimized
  20449. // this to `delete undefined` then it would appear to be a syntax error
  20450. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  20451. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  20452. return make_node_from_constant(0, self);
  20453. }
  20454. return make_node(AST_Undefined, self);
  20455. }
  20456. if (
  20457. self.expression instanceof AST_PropAccess
  20458. || self.expression instanceof AST_Call
  20459. ) {
  20460. return self;
  20461. } else {
  20462. // Keep the AST valid, in case the child swapped itself
  20463. return self.expression;
  20464. }
  20465. });
  20466. def_optimize(AST_Dot, function(self, compressor) {
  20467. const parent = compressor.parent();
  20468. if (compressor.is_lhs()) return self;
  20469. if (compressor.option("unsafe_proto")
  20470. && self.expression instanceof AST_Dot
  20471. && self.expression.property == "prototype") {
  20472. var exp = self.expression.expression;
  20473. if (is_undeclared_ref(exp)) switch (exp.name) {
  20474. case "Array":
  20475. self.expression = make_node(AST_Array, self.expression, {
  20476. elements: []
  20477. });
  20478. break;
  20479. case "Function":
  20480. self.expression = make_empty_function(self.expression);
  20481. break;
  20482. case "Number":
  20483. self.expression = make_node(AST_Number, self.expression, {
  20484. value: 0
  20485. });
  20486. break;
  20487. case "Object":
  20488. self.expression = make_node(AST_Object, self.expression, {
  20489. properties: []
  20490. });
  20491. break;
  20492. case "RegExp":
  20493. self.expression = make_node(AST_RegExp, self.expression, {
  20494. value: { source: "t", flags: "" }
  20495. });
  20496. break;
  20497. case "String":
  20498. self.expression = make_node(AST_String, self.expression, {
  20499. value: ""
  20500. });
  20501. break;
  20502. }
  20503. }
  20504. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  20505. const sub = self.flatten_object(self.property, compressor);
  20506. if (sub) return sub.optimize(compressor);
  20507. }
  20508. if (self.expression instanceof AST_PropAccess
  20509. && parent instanceof AST_PropAccess) {
  20510. return self;
  20511. }
  20512. let ev = self.evaluate(compressor);
  20513. if (ev !== self) {
  20514. ev = make_node_from_constant(ev, self).optimize(compressor);
  20515. return best_of(compressor, ev, self);
  20516. }
  20517. return self;
  20518. });
  20519. function literals_in_boolean_context(self, compressor) {
  20520. if (compressor.in_boolean_context()) {
  20521. return best_of(compressor, self, make_sequence(self, [
  20522. self,
  20523. make_node(AST_True, self)
  20524. ]).optimize(compressor));
  20525. }
  20526. return self;
  20527. }
  20528. function inline_array_like_spread(elements) {
  20529. for (var i = 0; i < elements.length; i++) {
  20530. var el = elements[i];
  20531. if (el instanceof AST_Expansion) {
  20532. var expr = el.expression;
  20533. if (
  20534. expr instanceof AST_Array
  20535. && !expr.elements.some(elm => elm instanceof AST_Hole)
  20536. ) {
  20537. elements.splice(i, 1, ...expr.elements);
  20538. // Step back one, as the element at i is now new.
  20539. i--;
  20540. }
  20541. // In array-like spread, spreading a non-iterable value is TypeError.
  20542. // We therefore can’t optimize anything else, unlike with object spread.
  20543. }
  20544. }
  20545. }
  20546. def_optimize(AST_Array, function(self, compressor) {
  20547. var optimized = literals_in_boolean_context(self, compressor);
  20548. if (optimized !== self) {
  20549. return optimized;
  20550. }
  20551. inline_array_like_spread(self.elements);
  20552. return self;
  20553. });
  20554. function inline_object_prop_spread(props) {
  20555. for (var i = 0; i < props.length; i++) {
  20556. var prop = props[i];
  20557. if (prop instanceof AST_Expansion) {
  20558. const expr = prop.expression;
  20559. if (
  20560. expr instanceof AST_Object
  20561. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  20562. ) {
  20563. props.splice(i, 1, ...expr.properties);
  20564. // Step back one, as the property at i is now new.
  20565. i--;
  20566. } else if ((
  20567. // `expr.is_constant()` returns `false` for `AST_RegExp`, so need both.
  20568. expr instanceof AST_Constant
  20569. || expr.is_constant()
  20570. ) && !(expr instanceof AST_String)) {
  20571. // Unlike array-like spread, in object spread, spreading a
  20572. // non-iterable value silently does nothing; it is thus safe
  20573. // to remove. AST_String is the only iterable constant.
  20574. props.splice(i, 1);
  20575. i--;
  20576. }
  20577. }
  20578. }
  20579. }
  20580. def_optimize(AST_Object, function(self, compressor) {
  20581. var optimized = literals_in_boolean_context(self, compressor);
  20582. if (optimized !== self) {
  20583. return optimized;
  20584. }
  20585. inline_object_prop_spread(self.properties);
  20586. return self;
  20587. });
  20588. def_optimize(AST_RegExp, literals_in_boolean_context);
  20589. def_optimize(AST_Return, function(self, compressor) {
  20590. if (self.value && is_undefined(self.value, compressor)) {
  20591. self.value = null;
  20592. }
  20593. return self;
  20594. });
  20595. def_optimize(AST_Arrow, opt_AST_Lambda);
  20596. def_optimize(AST_Function, function(self, compressor) {
  20597. self = opt_AST_Lambda(self, compressor);
  20598. if (compressor.option("unsafe_arrows")
  20599. && compressor.option("ecma") >= 2015
  20600. && !self.name
  20601. && !self.is_generator
  20602. && !self.uses_arguments
  20603. && !self.pinned()) {
  20604. const uses_this = walk(self, node => {
  20605. if (node instanceof AST_This) return walk_abort;
  20606. });
  20607. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  20608. }
  20609. return self;
  20610. });
  20611. def_optimize(AST_Class, function(self) {
  20612. for (let i = 0; i < self.properties.length; i++) {
  20613. const prop = self.properties[i];
  20614. if (prop instanceof AST_ClassStaticBlock && prop.body.length == 0) {
  20615. self.properties.splice(i, 1);
  20616. i--;
  20617. }
  20618. }
  20619. return self;
  20620. });
  20621. def_optimize(AST_ClassStaticBlock, function(self, compressor) {
  20622. tighten_body(self.body, compressor);
  20623. return self;
  20624. });
  20625. def_optimize(AST_Yield, function(self, compressor) {
  20626. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  20627. self.expression = null;
  20628. }
  20629. return self;
  20630. });
  20631. def_optimize(AST_TemplateString, function(self, compressor) {
  20632. if (
  20633. !compressor.option("evaluate")
  20634. || compressor.parent() instanceof AST_PrefixedTemplateString
  20635. ) {
  20636. return self;
  20637. }
  20638. var segments = [];
  20639. for (var i = 0; i < self.segments.length; i++) {
  20640. var segment = self.segments[i];
  20641. if (segment instanceof AST_Node) {
  20642. var result = segment.evaluate(compressor);
  20643. // Evaluate to constant value
  20644. // Constant value shorter than ${segment}
  20645. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  20646. // There should always be a previous and next segment if segment is a node
  20647. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  20648. continue;
  20649. }
  20650. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  20651. // TODO:
  20652. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  20653. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  20654. if (segment instanceof AST_TemplateString) {
  20655. var inners = segment.segments;
  20656. segments[segments.length - 1].value += inners[0].value;
  20657. for (var j = 1; j < inners.length; j++) {
  20658. segment = inners[j];
  20659. segments.push(segment);
  20660. }
  20661. continue;
  20662. }
  20663. }
  20664. segments.push(segment);
  20665. }
  20666. self.segments = segments;
  20667. // `foo` => "foo"
  20668. if (segments.length == 1) {
  20669. return make_node(AST_String, self, segments[0]);
  20670. }
  20671. if (
  20672. segments.length === 3
  20673. && segments[1] instanceof AST_Node
  20674. && (
  20675. segments[1].is_string(compressor)
  20676. || segments[1].is_number_or_bigint(compressor)
  20677. || is_nullish(segments[1], compressor)
  20678. || compressor.option("unsafe")
  20679. )
  20680. ) {
  20681. // `foo${bar}` => "foo" + bar
  20682. if (segments[2].value === "") {
  20683. return make_node(AST_Binary, self, {
  20684. operator: "+",
  20685. left: make_node(AST_String, self, {
  20686. value: segments[0].value,
  20687. }),
  20688. right: segments[1],
  20689. });
  20690. }
  20691. // `${bar}baz` => bar + "baz"
  20692. if (segments[0].value === "") {
  20693. return make_node(AST_Binary, self, {
  20694. operator: "+",
  20695. left: segments[1],
  20696. right: make_node(AST_String, self, {
  20697. value: segments[2].value,
  20698. }),
  20699. });
  20700. }
  20701. }
  20702. return self;
  20703. });
  20704. def_optimize(AST_PrefixedTemplateString, function(self) {
  20705. return self;
  20706. });
  20707. // ["p"]:1 ---> p:1
  20708. // [42]:1 ---> 42:1
  20709. function lift_key(self, compressor) {
  20710. if (!compressor.option("computed_props")) return self;
  20711. // save a comparison in the typical case
  20712. if (!(self.key instanceof AST_Constant)) return self;
  20713. // allow certain acceptable props as not all AST_Constants are true constants
  20714. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  20715. const key = self.key.value.toString();
  20716. if (key === "__proto__") return self;
  20717. if (key == "constructor"
  20718. && compressor.parent() instanceof AST_Class) return self;
  20719. if (self instanceof AST_ObjectKeyVal) {
  20720. self.quote = self.key.quote;
  20721. self.key = key;
  20722. } else if (self instanceof AST_ClassProperty) {
  20723. self.quote = self.key.quote;
  20724. self.key = make_node(AST_SymbolClassProperty, self.key, {
  20725. name: key,
  20726. });
  20727. } else {
  20728. self.quote = self.key.quote;
  20729. self.key = make_node(AST_SymbolMethod, self.key, {
  20730. name: key,
  20731. });
  20732. }
  20733. }
  20734. return self;
  20735. }
  20736. def_optimize(AST_ObjectProperty, lift_key);
  20737. def_optimize(AST_ConciseMethod, function(self, compressor) {
  20738. lift_key(self, compressor);
  20739. // p(){return x;} ---> p:()=>x
  20740. if (compressor.option("arrows")
  20741. && compressor.parent() instanceof AST_Object
  20742. && !self.value.is_generator
  20743. && !self.value.uses_arguments
  20744. && !self.value.pinned()
  20745. && self.value.body.length == 1
  20746. && self.value.body[0] instanceof AST_Return
  20747. && self.value.body[0].value
  20748. && !self.value.contains_this()) {
  20749. var arrow = make_node(AST_Arrow, self.value, self.value);
  20750. arrow.async = self.value.async;
  20751. arrow.is_generator = self.value.is_generator;
  20752. return make_node(AST_ObjectKeyVal, self, {
  20753. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  20754. value: arrow,
  20755. quote: self.quote,
  20756. });
  20757. }
  20758. return self;
  20759. });
  20760. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  20761. lift_key(self, compressor);
  20762. // p:function(){} ---> p(){}
  20763. // p:function*(){} ---> *p(){}
  20764. // p:async function(){} ---> async p(){}
  20765. // p:()=>{} ---> p(){}
  20766. // p:async()=>{} ---> async p(){}
  20767. var unsafe_methods = compressor.option("unsafe_methods");
  20768. if (unsafe_methods
  20769. && compressor.option("ecma") >= 2015
  20770. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  20771. var key = self.key;
  20772. var value = self.value;
  20773. var is_arrow_with_block = value instanceof AST_Arrow
  20774. && Array.isArray(value.body)
  20775. && !value.contains_this();
  20776. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  20777. return make_node(AST_ConciseMethod, self, {
  20778. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  20779. name: key,
  20780. }),
  20781. value: make_node(AST_Accessor, value, value),
  20782. quote: self.quote,
  20783. });
  20784. }
  20785. }
  20786. return self;
  20787. });
  20788. def_optimize(AST_Destructuring, function(self, compressor) {
  20789. if (compressor.option("pure_getters") == true
  20790. && compressor.option("unused")
  20791. && !self.is_array
  20792. && Array.isArray(self.names)
  20793. && !is_destructuring_export_decl(compressor)
  20794. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  20795. var keep = [];
  20796. for (var i = 0; i < self.names.length; i++) {
  20797. var elem = self.names[i];
  20798. if (!(elem instanceof AST_ObjectKeyVal
  20799. && typeof elem.key == "string"
  20800. && elem.value instanceof AST_SymbolDeclaration
  20801. && !should_retain(compressor, elem.value.definition()))) {
  20802. keep.push(elem);
  20803. }
  20804. }
  20805. if (keep.length != self.names.length) {
  20806. self.names = keep;
  20807. }
  20808. }
  20809. return self;
  20810. function is_destructuring_export_decl(compressor) {
  20811. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  20812. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  20813. var parent = compressor.parent(p);
  20814. if (!parent) return false;
  20815. if (a === 0 && parent.TYPE == "Destructuring") continue;
  20816. if (!ancestors[a].test(parent.TYPE)) {
  20817. return false;
  20818. }
  20819. a++;
  20820. }
  20821. return true;
  20822. }
  20823. function should_retain(compressor, def) {
  20824. if (def.references.length) return true;
  20825. if (!def.global) return false;
  20826. if (compressor.toplevel.vars) {
  20827. if (compressor.top_retain) {
  20828. return compressor.top_retain(def);
  20829. }
  20830. return false;
  20831. }
  20832. return true;
  20833. }
  20834. });
  20835. /***********************************************************************
  20836. A JavaScript tokenizer / parser / beautifier / compressor.
  20837. https://github.com/mishoo/UglifyJS2
  20838. -------------------------------- (C) ---------------------------------
  20839. Author: Mihai Bazon
  20840. <mihai.bazon@gmail.com>
  20841. http://mihai.bazon.net/blog
  20842. Distributed under the BSD license:
  20843. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  20844. Redistribution and use in source and binary forms, with or without
  20845. modification, are permitted provided that the following conditions
  20846. are met:
  20847. * Redistributions of source code must retain the above
  20848. copyright notice, this list of conditions and the following
  20849. disclaimer.
  20850. * Redistributions in binary form must reproduce the above
  20851. copyright notice, this list of conditions and the following
  20852. disclaimer in the documentation and/or other materials
  20853. provided with the distribution.
  20854. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  20855. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20856. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20857. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  20858. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  20859. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20860. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20861. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20862. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  20863. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  20864. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  20865. SUCH DAMAGE.
  20866. ***********************************************************************/
  20867. // a small wrapper around source-map and @jridgewell/source-map
  20868. function* SourceMap(options) {
  20869. options = defaults(options, {
  20870. file : null,
  20871. root : null,
  20872. orig : null,
  20873. files: {},
  20874. });
  20875. var orig_map;
  20876. var generator = new sourceMap.SourceMapGenerator({
  20877. file : options.file,
  20878. sourceRoot : options.root
  20879. });
  20880. let sourcesContent = {__proto__: null};
  20881. let files = options.files;
  20882. for (var name in files) if (HOP(files, name)) {
  20883. sourcesContent[name] = files[name];
  20884. }
  20885. if (options.orig) {
  20886. // We support both @jridgewell/source-map (which has a sync
  20887. // SourceMapConsumer) and source-map (which has an async
  20888. // SourceMapConsumer).
  20889. orig_map = yield new sourceMap.SourceMapConsumer(options.orig);
  20890. if (orig_map.sourcesContent) {
  20891. orig_map.sources.forEach(function(source, i) {
  20892. var content = orig_map.sourcesContent[i];
  20893. if (content) {
  20894. sourcesContent[source] = content;
  20895. }
  20896. });
  20897. }
  20898. }
  20899. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  20900. let generatedPos = { line: gen_line, column: gen_col };
  20901. if (orig_map) {
  20902. var info = orig_map.originalPositionFor({
  20903. line: orig_line,
  20904. column: orig_col
  20905. });
  20906. if (info.source === null) {
  20907. generator.addMapping({
  20908. generated: generatedPos,
  20909. original: null,
  20910. source: null,
  20911. name: null
  20912. });
  20913. return;
  20914. }
  20915. source = info.source;
  20916. orig_line = info.line;
  20917. orig_col = info.column;
  20918. name = info.name || name;
  20919. }
  20920. generator.addMapping({
  20921. generated : generatedPos,
  20922. original : { line: orig_line, column: orig_col },
  20923. source : source,
  20924. name : name
  20925. });
  20926. generator.setSourceContent(source, sourcesContent[source]);
  20927. }
  20928. function clean(map) {
  20929. const allNull = map.sourcesContent && map.sourcesContent.every(c => c == null);
  20930. if (allNull) delete map.sourcesContent;
  20931. if (map.file === undefined) delete map.file;
  20932. if (map.sourceRoot === undefined) delete map.sourceRoot;
  20933. return map;
  20934. }
  20935. function getDecoded() {
  20936. if (!generator.toDecodedMap) return null;
  20937. return clean(generator.toDecodedMap());
  20938. }
  20939. function getEncoded() {
  20940. return clean(generator.toJSON());
  20941. }
  20942. function destroy() {
  20943. // @jridgewell/source-map's SourceMapConsumer does not need to be
  20944. // manually freed.
  20945. if (orig_map && orig_map.destroy) orig_map.destroy();
  20946. }
  20947. return {
  20948. add,
  20949. getDecoded,
  20950. getEncoded,
  20951. destroy,
  20952. };
  20953. }
  20954. var domprops = [
  20955. "$&",
  20956. "$'",
  20957. "$*",
  20958. "$+",
  20959. "$1",
  20960. "$2",
  20961. "$3",
  20962. "$4",
  20963. "$5",
  20964. "$6",
  20965. "$7",
  20966. "$8",
  20967. "$9",
  20968. "$_",
  20969. "$`",
  20970. "$input",
  20971. "-moz-animation",
  20972. "-moz-animation-delay",
  20973. "-moz-animation-direction",
  20974. "-moz-animation-duration",
  20975. "-moz-animation-fill-mode",
  20976. "-moz-animation-iteration-count",
  20977. "-moz-animation-name",
  20978. "-moz-animation-play-state",
  20979. "-moz-animation-timing-function",
  20980. "-moz-appearance",
  20981. "-moz-backface-visibility",
  20982. "-moz-border-end",
  20983. "-moz-border-end-color",
  20984. "-moz-border-end-style",
  20985. "-moz-border-end-width",
  20986. "-moz-border-image",
  20987. "-moz-border-start",
  20988. "-moz-border-start-color",
  20989. "-moz-border-start-style",
  20990. "-moz-border-start-width",
  20991. "-moz-box-align",
  20992. "-moz-box-direction",
  20993. "-moz-box-flex",
  20994. "-moz-box-ordinal-group",
  20995. "-moz-box-orient",
  20996. "-moz-box-pack",
  20997. "-moz-box-sizing",
  20998. "-moz-float-edge",
  20999. "-moz-font-feature-settings",
  21000. "-moz-font-language-override",
  21001. "-moz-force-broken-image-icon",
  21002. "-moz-hyphens",
  21003. "-moz-image-region",
  21004. "-moz-margin-end",
  21005. "-moz-margin-start",
  21006. "-moz-orient",
  21007. "-moz-osx-font-smoothing",
  21008. "-moz-outline-radius",
  21009. "-moz-outline-radius-bottomleft",
  21010. "-moz-outline-radius-bottomright",
  21011. "-moz-outline-radius-topleft",
  21012. "-moz-outline-radius-topright",
  21013. "-moz-padding-end",
  21014. "-moz-padding-start",
  21015. "-moz-perspective",
  21016. "-moz-perspective-origin",
  21017. "-moz-tab-size",
  21018. "-moz-text-size-adjust",
  21019. "-moz-transform",
  21020. "-moz-transform-origin",
  21021. "-moz-transform-style",
  21022. "-moz-transition",
  21023. "-moz-transition-delay",
  21024. "-moz-transition-duration",
  21025. "-moz-transition-property",
  21026. "-moz-transition-timing-function",
  21027. "-moz-user-focus",
  21028. "-moz-user-input",
  21029. "-moz-user-modify",
  21030. "-moz-user-select",
  21031. "-moz-window-dragging",
  21032. "-webkit-align-content",
  21033. "-webkit-align-items",
  21034. "-webkit-align-self",
  21035. "-webkit-animation",
  21036. "-webkit-animation-delay",
  21037. "-webkit-animation-direction",
  21038. "-webkit-animation-duration",
  21039. "-webkit-animation-fill-mode",
  21040. "-webkit-animation-iteration-count",
  21041. "-webkit-animation-name",
  21042. "-webkit-animation-play-state",
  21043. "-webkit-animation-timing-function",
  21044. "-webkit-appearance",
  21045. "-webkit-backface-visibility",
  21046. "-webkit-background-clip",
  21047. "-webkit-background-origin",
  21048. "-webkit-background-size",
  21049. "-webkit-border-bottom-left-radius",
  21050. "-webkit-border-bottom-right-radius",
  21051. "-webkit-border-image",
  21052. "-webkit-border-radius",
  21053. "-webkit-border-top-left-radius",
  21054. "-webkit-border-top-right-radius",
  21055. "-webkit-box-align",
  21056. "-webkit-box-direction",
  21057. "-webkit-box-flex",
  21058. "-webkit-box-ordinal-group",
  21059. "-webkit-box-orient",
  21060. "-webkit-box-pack",
  21061. "-webkit-box-shadow",
  21062. "-webkit-box-sizing",
  21063. "-webkit-clip-path",
  21064. "-webkit-filter",
  21065. "-webkit-flex",
  21066. "-webkit-flex-basis",
  21067. "-webkit-flex-direction",
  21068. "-webkit-flex-flow",
  21069. "-webkit-flex-grow",
  21070. "-webkit-flex-shrink",
  21071. "-webkit-flex-wrap",
  21072. "-webkit-font-feature-settings",
  21073. "-webkit-justify-content",
  21074. "-webkit-line-clamp",
  21075. "-webkit-mask",
  21076. "-webkit-mask-clip",
  21077. "-webkit-mask-composite",
  21078. "-webkit-mask-image",
  21079. "-webkit-mask-origin",
  21080. "-webkit-mask-position",
  21081. "-webkit-mask-position-x",
  21082. "-webkit-mask-position-y",
  21083. "-webkit-mask-repeat",
  21084. "-webkit-mask-size",
  21085. "-webkit-order",
  21086. "-webkit-perspective",
  21087. "-webkit-perspective-origin",
  21088. "-webkit-text-fill-color",
  21089. "-webkit-text-security",
  21090. "-webkit-text-size-adjust",
  21091. "-webkit-text-stroke",
  21092. "-webkit-text-stroke-color",
  21093. "-webkit-text-stroke-width",
  21094. "-webkit-transform",
  21095. "-webkit-transform-origin",
  21096. "-webkit-transform-style",
  21097. "-webkit-transition",
  21098. "-webkit-transition-delay",
  21099. "-webkit-transition-duration",
  21100. "-webkit-transition-property",
  21101. "-webkit-transition-timing-function",
  21102. "-webkit-user-select",
  21103. "@@iterator",
  21104. "ABORT_ERR",
  21105. "ACTIVE",
  21106. "ACTIVE_ATTRIBUTES",
  21107. "ACTIVE_TEXTURE",
  21108. "ACTIVE_UNIFORMS",
  21109. "ACTIVE_UNIFORM_BLOCKS",
  21110. "ADDITION",
  21111. "ALIASED_LINE_WIDTH_RANGE",
  21112. "ALIASED_POINT_SIZE_RANGE",
  21113. "ALL",
  21114. "ALLOW_KEYBOARD_INPUT",
  21115. "ALLPASS",
  21116. "ALPHA",
  21117. "ALPHA_BITS",
  21118. "ALREADY_SIGNALED",
  21119. "ALT_MASK",
  21120. "ALWAYS",
  21121. "ANY_SAMPLES_PASSED",
  21122. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  21123. "ANY_TYPE",
  21124. "ANY_UNORDERED_NODE_TYPE",
  21125. "ARRAY_BUFFER",
  21126. "ARRAY_BUFFER_BINDING",
  21127. "ATTACHED_SHADERS",
  21128. "ATTRIBUTE_NODE",
  21129. "AT_TARGET",
  21130. "AbortController",
  21131. "AbortSignal",
  21132. "AbsoluteOrientationSensor",
  21133. "AbstractRange",
  21134. "Accelerometer",
  21135. "AddSearchProvider",
  21136. "AggregateError",
  21137. "AnalyserNode",
  21138. "Animation",
  21139. "AnimationEffect",
  21140. "AnimationEvent",
  21141. "AnimationPlaybackEvent",
  21142. "AnimationTimeline",
  21143. "AnonXMLHttpRequest",
  21144. "Any",
  21145. "AnyPermissions",
  21146. "ApplicationCache",
  21147. "ApplicationCacheErrorEvent",
  21148. "Array",
  21149. "ArrayBuffer",
  21150. "ArrayType",
  21151. "Atomics",
  21152. "Attr",
  21153. "Audio",
  21154. "AudioBuffer",
  21155. "AudioBufferSourceNode",
  21156. "AudioContext",
  21157. "AudioData",
  21158. "AudioDecoder",
  21159. "AudioDestinationNode",
  21160. "AudioEncoder",
  21161. "AudioListener",
  21162. "AudioNode",
  21163. "AudioParam",
  21164. "AudioParamMap",
  21165. "AudioProcessingEvent",
  21166. "AudioScheduledSourceNode",
  21167. "AudioSinkInfo",
  21168. "AudioStreamTrack",
  21169. "AudioWorklet",
  21170. "AudioWorkletNode",
  21171. "AuthenticatorAssertionResponse",
  21172. "AuthenticatorAttestationResponse",
  21173. "AuthenticatorResponse",
  21174. "AutocompleteErrorEvent",
  21175. "BACK",
  21176. "BAD_BOUNDARYPOINTS_ERR",
  21177. "BAD_REQUEST",
  21178. "BANDPASS",
  21179. "BLEND",
  21180. "BLEND_COLOR",
  21181. "BLEND_DST_ALPHA",
  21182. "BLEND_DST_RGB",
  21183. "BLEND_EQUATION",
  21184. "BLEND_EQUATION_ALPHA",
  21185. "BLEND_EQUATION_RGB",
  21186. "BLEND_SRC_ALPHA",
  21187. "BLEND_SRC_RGB",
  21188. "BLUE",
  21189. "BLUE_BITS",
  21190. "BLUR",
  21191. "BOOL",
  21192. "BOOLEAN_TYPE",
  21193. "BOOL_VEC2",
  21194. "BOOL_VEC3",
  21195. "BOOL_VEC4",
  21196. "BOTH",
  21197. "BROWSER_DEFAULT_WEBGL",
  21198. "BUBBLING_PHASE",
  21199. "BUFFER_SIZE",
  21200. "BUFFER_USAGE",
  21201. "BYTE",
  21202. "BYTES_PER_ELEMENT",
  21203. "BackgroundFetchManager",
  21204. "BackgroundFetchRecord",
  21205. "BackgroundFetchRegistration",
  21206. "BarProp",
  21207. "BarcodeDetector",
  21208. "BaseAudioContext",
  21209. "BaseHref",
  21210. "BatteryManager",
  21211. "BeforeInstallPromptEvent",
  21212. "BeforeLoadEvent",
  21213. "BeforeUnloadEvent",
  21214. "BigInt",
  21215. "BigInt64Array",
  21216. "BigUint64Array",
  21217. "BiquadFilterNode",
  21218. "Blob",
  21219. "BlobEvent",
  21220. "Bluetooth",
  21221. "BluetoothCharacteristicProperties",
  21222. "BluetoothDevice",
  21223. "BluetoothRemoteGATTCharacteristic",
  21224. "BluetoothRemoteGATTDescriptor",
  21225. "BluetoothRemoteGATTServer",
  21226. "BluetoothRemoteGATTService",
  21227. "BluetoothUUID",
  21228. "Boolean",
  21229. "BroadcastChannel",
  21230. "BrowserCaptureMediaStreamTrack",
  21231. "BrowserInfo",
  21232. "ByteLengthQueuingStrategy",
  21233. "CAPTURING_PHASE",
  21234. "CCW",
  21235. "CDATASection",
  21236. "CDATA_SECTION_NODE",
  21237. "CHANGE",
  21238. "CHARSET_RULE",
  21239. "CHECKING",
  21240. "CLAMP_TO_EDGE",
  21241. "CLICK",
  21242. "CLOSED",
  21243. "CLOSING",
  21244. "COLOR",
  21245. "COLOR_ATTACHMENT0",
  21246. "COLOR_ATTACHMENT1",
  21247. "COLOR_ATTACHMENT10",
  21248. "COLOR_ATTACHMENT11",
  21249. "COLOR_ATTACHMENT12",
  21250. "COLOR_ATTACHMENT13",
  21251. "COLOR_ATTACHMENT14",
  21252. "COLOR_ATTACHMENT15",
  21253. "COLOR_ATTACHMENT2",
  21254. "COLOR_ATTACHMENT3",
  21255. "COLOR_ATTACHMENT4",
  21256. "COLOR_ATTACHMENT5",
  21257. "COLOR_ATTACHMENT6",
  21258. "COLOR_ATTACHMENT7",
  21259. "COLOR_ATTACHMENT8",
  21260. "COLOR_ATTACHMENT9",
  21261. "COLOR_BUFFER_BIT",
  21262. "COLOR_CLEAR_VALUE",
  21263. "COLOR_WRITEMASK",
  21264. "COMMENT_NODE",
  21265. "COMPARE_REF_TO_TEXTURE",
  21266. "COMPILE_STATUS",
  21267. "COMPLETION_STATUS_KHR",
  21268. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  21269. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  21270. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  21271. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  21272. "COMPRESSED_TEXTURE_FORMATS",
  21273. "COMPUTE",
  21274. "CONDITION_SATISFIED",
  21275. "CONFIGURATION_UNSUPPORTED",
  21276. "CONNECTING",
  21277. "CONSTANT_ALPHA",
  21278. "CONSTANT_COLOR",
  21279. "CONSTRAINT_ERR",
  21280. "CONTEXT_LOST_WEBGL",
  21281. "CONTROL_MASK",
  21282. "COPY_DST",
  21283. "COPY_READ_BUFFER",
  21284. "COPY_READ_BUFFER_BINDING",
  21285. "COPY_SRC",
  21286. "COPY_WRITE_BUFFER",
  21287. "COPY_WRITE_BUFFER_BINDING",
  21288. "COUNTER_STYLE_RULE",
  21289. "CSS",
  21290. "CSS2Properties",
  21291. "CSSAnimation",
  21292. "CSSCharsetRule",
  21293. "CSSConditionRule",
  21294. "CSSContainerRule",
  21295. "CSSCounterStyleRule",
  21296. "CSSFontFaceRule",
  21297. "CSSFontFeatureValuesRule",
  21298. "CSSFontPaletteValuesRule",
  21299. "CSSGroupingRule",
  21300. "CSSImageValue",
  21301. "CSSImportRule",
  21302. "CSSKeyframeRule",
  21303. "CSSKeyframesRule",
  21304. "CSSKeywordValue",
  21305. "CSSLayerBlockRule",
  21306. "CSSLayerStatementRule",
  21307. "CSSMarginRule",
  21308. "CSSMathClamp",
  21309. "CSSMathInvert",
  21310. "CSSMathMax",
  21311. "CSSMathMin",
  21312. "CSSMathNegate",
  21313. "CSSMathProduct",
  21314. "CSSMathSum",
  21315. "CSSMathValue",
  21316. "CSSMatrixComponent",
  21317. "CSSMediaRule",
  21318. "CSSMozDocumentRule",
  21319. "CSSNameSpaceRule",
  21320. "CSSNamespaceRule",
  21321. "CSSNestedDeclarations",
  21322. "CSSNumericArray",
  21323. "CSSNumericValue",
  21324. "CSSPageDescriptors",
  21325. "CSSPageRule",
  21326. "CSSPerspective",
  21327. "CSSPositionTryDescriptors",
  21328. "CSSPositionTryRule",
  21329. "CSSPositionValue",
  21330. "CSSPrimitiveValue",
  21331. "CSSPropertyRule",
  21332. "CSSRotate",
  21333. "CSSRule",
  21334. "CSSRuleList",
  21335. "CSSScale",
  21336. "CSSScopeRule",
  21337. "CSSSkew",
  21338. "CSSSkewX",
  21339. "CSSSkewY",
  21340. "CSSStartingStyleRule",
  21341. "CSSStyleDeclaration",
  21342. "CSSStyleRule",
  21343. "CSSStyleSheet",
  21344. "CSSStyleValue",
  21345. "CSSSupportsRule",
  21346. "CSSTransformComponent",
  21347. "CSSTransformValue",
  21348. "CSSTransition",
  21349. "CSSTranslate",
  21350. "CSSUnitValue",
  21351. "CSSUnknownRule",
  21352. "CSSUnparsedValue",
  21353. "CSSValue",
  21354. "CSSValueList",
  21355. "CSSVariableReferenceValue",
  21356. "CSSVariablesDeclaration",
  21357. "CSSVariablesRule",
  21358. "CSSViewTransitionRule",
  21359. "CSSViewportRule",
  21360. "CSS_ATTR",
  21361. "CSS_CM",
  21362. "CSS_COUNTER",
  21363. "CSS_CUSTOM",
  21364. "CSS_DEG",
  21365. "CSS_DIMENSION",
  21366. "CSS_EMS",
  21367. "CSS_EXS",
  21368. "CSS_FILTER_BLUR",
  21369. "CSS_FILTER_BRIGHTNESS",
  21370. "CSS_FILTER_CONTRAST",
  21371. "CSS_FILTER_CUSTOM",
  21372. "CSS_FILTER_DROP_SHADOW",
  21373. "CSS_FILTER_GRAYSCALE",
  21374. "CSS_FILTER_HUE_ROTATE",
  21375. "CSS_FILTER_INVERT",
  21376. "CSS_FILTER_OPACITY",
  21377. "CSS_FILTER_REFERENCE",
  21378. "CSS_FILTER_SATURATE",
  21379. "CSS_FILTER_SEPIA",
  21380. "CSS_GRAD",
  21381. "CSS_HZ",
  21382. "CSS_IDENT",
  21383. "CSS_IN",
  21384. "CSS_INHERIT",
  21385. "CSS_KHZ",
  21386. "CSS_MATRIX",
  21387. "CSS_MATRIX3D",
  21388. "CSS_MM",
  21389. "CSS_MS",
  21390. "CSS_NUMBER",
  21391. "CSS_PC",
  21392. "CSS_PERCENTAGE",
  21393. "CSS_PERSPECTIVE",
  21394. "CSS_PRIMITIVE_VALUE",
  21395. "CSS_PT",
  21396. "CSS_PX",
  21397. "CSS_RAD",
  21398. "CSS_RECT",
  21399. "CSS_RGBCOLOR",
  21400. "CSS_ROTATE",
  21401. "CSS_ROTATE3D",
  21402. "CSS_ROTATEX",
  21403. "CSS_ROTATEY",
  21404. "CSS_ROTATEZ",
  21405. "CSS_S",
  21406. "CSS_SCALE",
  21407. "CSS_SCALE3D",
  21408. "CSS_SCALEX",
  21409. "CSS_SCALEY",
  21410. "CSS_SCALEZ",
  21411. "CSS_SKEW",
  21412. "CSS_SKEWX",
  21413. "CSS_SKEWY",
  21414. "CSS_STRING",
  21415. "CSS_TRANSLATE",
  21416. "CSS_TRANSLATE3D",
  21417. "CSS_TRANSLATEX",
  21418. "CSS_TRANSLATEY",
  21419. "CSS_TRANSLATEZ",
  21420. "CSS_UNKNOWN",
  21421. "CSS_URI",
  21422. "CSS_VALUE_LIST",
  21423. "CSS_VH",
  21424. "CSS_VMAX",
  21425. "CSS_VMIN",
  21426. "CSS_VW",
  21427. "CULL_FACE",
  21428. "CULL_FACE_MODE",
  21429. "CURRENT_PROGRAM",
  21430. "CURRENT_QUERY",
  21431. "CURRENT_VERTEX_ATTRIB",
  21432. "CUSTOM",
  21433. "CW",
  21434. "Cache",
  21435. "CacheStorage",
  21436. "CanvasCaptureMediaStream",
  21437. "CanvasCaptureMediaStreamTrack",
  21438. "CanvasGradient",
  21439. "CanvasPattern",
  21440. "CanvasRenderingContext2D",
  21441. "CaptureController",
  21442. "CaretPosition",
  21443. "ChannelMergerNode",
  21444. "ChannelSplitterNode",
  21445. "ChapterInformation",
  21446. "CharacterBoundsUpdateEvent",
  21447. "CharacterData",
  21448. "ClientRect",
  21449. "ClientRectList",
  21450. "Clipboard",
  21451. "ClipboardEvent",
  21452. "ClipboardItem",
  21453. "CloseEvent",
  21454. "CloseWatcher",
  21455. "Collator",
  21456. "ColorArray",
  21457. "ColorValue",
  21458. "CommandEvent",
  21459. "Comment",
  21460. "CompileError",
  21461. "CompositionEvent",
  21462. "CompressionStream",
  21463. "Console",
  21464. "ConstantSourceNode",
  21465. "ContentVisibilityAutoStateChangeEvent",
  21466. "ContextFilter",
  21467. "ContextType",
  21468. "Controllers",
  21469. "ConvolverNode",
  21470. "CookieChangeEvent",
  21471. "CookieStore",
  21472. "CookieStoreManager",
  21473. "CountQueuingStrategy",
  21474. "Counter",
  21475. "CreateType",
  21476. "Credential",
  21477. "CredentialsContainer",
  21478. "CropTarget",
  21479. "Crypto",
  21480. "CryptoKey",
  21481. "CustomElementRegistry",
  21482. "CustomEvent",
  21483. "CustomStateSet",
  21484. "DATABASE_ERR",
  21485. "DATA_CLONE_ERR",
  21486. "DATA_ERR",
  21487. "DBLCLICK",
  21488. "DECR",
  21489. "DECR_WRAP",
  21490. "DELETE_STATUS",
  21491. "DEPTH",
  21492. "DEPTH24_STENCIL8",
  21493. "DEPTH32F_STENCIL8",
  21494. "DEPTH_ATTACHMENT",
  21495. "DEPTH_BITS",
  21496. "DEPTH_BUFFER_BIT",
  21497. "DEPTH_CLEAR_VALUE",
  21498. "DEPTH_COMPONENT",
  21499. "DEPTH_COMPONENT16",
  21500. "DEPTH_COMPONENT24",
  21501. "DEPTH_COMPONENT32F",
  21502. "DEPTH_FUNC",
  21503. "DEPTH_RANGE",
  21504. "DEPTH_STENCIL",
  21505. "DEPTH_STENCIL_ATTACHMENT",
  21506. "DEPTH_TEST",
  21507. "DEPTH_WRITEMASK",
  21508. "DEVICE_INELIGIBLE",
  21509. "DIRECTION_DOWN",
  21510. "DIRECTION_LEFT",
  21511. "DIRECTION_RIGHT",
  21512. "DIRECTION_UP",
  21513. "DISABLED",
  21514. "DISPATCH_REQUEST_ERR",
  21515. "DITHER",
  21516. "DOCUMENT_FRAGMENT_NODE",
  21517. "DOCUMENT_NODE",
  21518. "DOCUMENT_POSITION_CONTAINED_BY",
  21519. "DOCUMENT_POSITION_CONTAINS",
  21520. "DOCUMENT_POSITION_DISCONNECTED",
  21521. "DOCUMENT_POSITION_FOLLOWING",
  21522. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  21523. "DOCUMENT_POSITION_PRECEDING",
  21524. "DOCUMENT_TYPE_NODE",
  21525. "DOMCursor",
  21526. "DOMError",
  21527. "DOMException",
  21528. "DOMImplementation",
  21529. "DOMImplementationLS",
  21530. "DOMMatrix",
  21531. "DOMMatrixReadOnly",
  21532. "DOMParser",
  21533. "DOMPoint",
  21534. "DOMPointReadOnly",
  21535. "DOMQuad",
  21536. "DOMRect",
  21537. "DOMRectList",
  21538. "DOMRectReadOnly",
  21539. "DOMRequest",
  21540. "DOMSTRING_SIZE_ERR",
  21541. "DOMSettableTokenList",
  21542. "DOMStringList",
  21543. "DOMStringMap",
  21544. "DOMTokenList",
  21545. "DOMTransactionEvent",
  21546. "DOM_DELTA_LINE",
  21547. "DOM_DELTA_PAGE",
  21548. "DOM_DELTA_PIXEL",
  21549. "DOM_INPUT_METHOD_DROP",
  21550. "DOM_INPUT_METHOD_HANDWRITING",
  21551. "DOM_INPUT_METHOD_IME",
  21552. "DOM_INPUT_METHOD_KEYBOARD",
  21553. "DOM_INPUT_METHOD_MULTIMODAL",
  21554. "DOM_INPUT_METHOD_OPTION",
  21555. "DOM_INPUT_METHOD_PASTE",
  21556. "DOM_INPUT_METHOD_SCRIPT",
  21557. "DOM_INPUT_METHOD_UNKNOWN",
  21558. "DOM_INPUT_METHOD_VOICE",
  21559. "DOM_KEY_LOCATION_JOYSTICK",
  21560. "DOM_KEY_LOCATION_LEFT",
  21561. "DOM_KEY_LOCATION_MOBILE",
  21562. "DOM_KEY_LOCATION_NUMPAD",
  21563. "DOM_KEY_LOCATION_RIGHT",
  21564. "DOM_KEY_LOCATION_STANDARD",
  21565. "DOM_VK_0",
  21566. "DOM_VK_1",
  21567. "DOM_VK_2",
  21568. "DOM_VK_3",
  21569. "DOM_VK_4",
  21570. "DOM_VK_5",
  21571. "DOM_VK_6",
  21572. "DOM_VK_7",
  21573. "DOM_VK_8",
  21574. "DOM_VK_9",
  21575. "DOM_VK_A",
  21576. "DOM_VK_ACCEPT",
  21577. "DOM_VK_ADD",
  21578. "DOM_VK_ALT",
  21579. "DOM_VK_ALTGR",
  21580. "DOM_VK_AMPERSAND",
  21581. "DOM_VK_ASTERISK",
  21582. "DOM_VK_AT",
  21583. "DOM_VK_ATTN",
  21584. "DOM_VK_B",
  21585. "DOM_VK_BACKSPACE",
  21586. "DOM_VK_BACK_QUOTE",
  21587. "DOM_VK_BACK_SLASH",
  21588. "DOM_VK_BACK_SPACE",
  21589. "DOM_VK_C",
  21590. "DOM_VK_CANCEL",
  21591. "DOM_VK_CAPS_LOCK",
  21592. "DOM_VK_CIRCUMFLEX",
  21593. "DOM_VK_CLEAR",
  21594. "DOM_VK_CLOSE_BRACKET",
  21595. "DOM_VK_CLOSE_CURLY_BRACKET",
  21596. "DOM_VK_CLOSE_PAREN",
  21597. "DOM_VK_COLON",
  21598. "DOM_VK_COMMA",
  21599. "DOM_VK_CONTEXT_MENU",
  21600. "DOM_VK_CONTROL",
  21601. "DOM_VK_CONVERT",
  21602. "DOM_VK_CRSEL",
  21603. "DOM_VK_CTRL",
  21604. "DOM_VK_D",
  21605. "DOM_VK_DECIMAL",
  21606. "DOM_VK_DELETE",
  21607. "DOM_VK_DIVIDE",
  21608. "DOM_VK_DOLLAR",
  21609. "DOM_VK_DOUBLE_QUOTE",
  21610. "DOM_VK_DOWN",
  21611. "DOM_VK_E",
  21612. "DOM_VK_EISU",
  21613. "DOM_VK_END",
  21614. "DOM_VK_ENTER",
  21615. "DOM_VK_EQUALS",
  21616. "DOM_VK_EREOF",
  21617. "DOM_VK_ESCAPE",
  21618. "DOM_VK_EXCLAMATION",
  21619. "DOM_VK_EXECUTE",
  21620. "DOM_VK_EXSEL",
  21621. "DOM_VK_F",
  21622. "DOM_VK_F1",
  21623. "DOM_VK_F10",
  21624. "DOM_VK_F11",
  21625. "DOM_VK_F12",
  21626. "DOM_VK_F13",
  21627. "DOM_VK_F14",
  21628. "DOM_VK_F15",
  21629. "DOM_VK_F16",
  21630. "DOM_VK_F17",
  21631. "DOM_VK_F18",
  21632. "DOM_VK_F19",
  21633. "DOM_VK_F2",
  21634. "DOM_VK_F20",
  21635. "DOM_VK_F21",
  21636. "DOM_VK_F22",
  21637. "DOM_VK_F23",
  21638. "DOM_VK_F24",
  21639. "DOM_VK_F25",
  21640. "DOM_VK_F26",
  21641. "DOM_VK_F27",
  21642. "DOM_VK_F28",
  21643. "DOM_VK_F29",
  21644. "DOM_VK_F3",
  21645. "DOM_VK_F30",
  21646. "DOM_VK_F31",
  21647. "DOM_VK_F32",
  21648. "DOM_VK_F33",
  21649. "DOM_VK_F34",
  21650. "DOM_VK_F35",
  21651. "DOM_VK_F36",
  21652. "DOM_VK_F4",
  21653. "DOM_VK_F5",
  21654. "DOM_VK_F6",
  21655. "DOM_VK_F7",
  21656. "DOM_VK_F8",
  21657. "DOM_VK_F9",
  21658. "DOM_VK_FINAL",
  21659. "DOM_VK_FRONT",
  21660. "DOM_VK_G",
  21661. "DOM_VK_GREATER_THAN",
  21662. "DOM_VK_H",
  21663. "DOM_VK_HANGUL",
  21664. "DOM_VK_HANJA",
  21665. "DOM_VK_HASH",
  21666. "DOM_VK_HELP",
  21667. "DOM_VK_HK_TOGGLE",
  21668. "DOM_VK_HOME",
  21669. "DOM_VK_HYPHEN_MINUS",
  21670. "DOM_VK_I",
  21671. "DOM_VK_INSERT",
  21672. "DOM_VK_J",
  21673. "DOM_VK_JUNJA",
  21674. "DOM_VK_K",
  21675. "DOM_VK_KANA",
  21676. "DOM_VK_KANJI",
  21677. "DOM_VK_L",
  21678. "DOM_VK_LEFT",
  21679. "DOM_VK_LEFT_TAB",
  21680. "DOM_VK_LESS_THAN",
  21681. "DOM_VK_M",
  21682. "DOM_VK_META",
  21683. "DOM_VK_MODECHANGE",
  21684. "DOM_VK_MULTIPLY",
  21685. "DOM_VK_N",
  21686. "DOM_VK_NONCONVERT",
  21687. "DOM_VK_NUMPAD0",
  21688. "DOM_VK_NUMPAD1",
  21689. "DOM_VK_NUMPAD2",
  21690. "DOM_VK_NUMPAD3",
  21691. "DOM_VK_NUMPAD4",
  21692. "DOM_VK_NUMPAD5",
  21693. "DOM_VK_NUMPAD6",
  21694. "DOM_VK_NUMPAD7",
  21695. "DOM_VK_NUMPAD8",
  21696. "DOM_VK_NUMPAD9",
  21697. "DOM_VK_NUM_LOCK",
  21698. "DOM_VK_O",
  21699. "DOM_VK_OEM_1",
  21700. "DOM_VK_OEM_102",
  21701. "DOM_VK_OEM_2",
  21702. "DOM_VK_OEM_3",
  21703. "DOM_VK_OEM_4",
  21704. "DOM_VK_OEM_5",
  21705. "DOM_VK_OEM_6",
  21706. "DOM_VK_OEM_7",
  21707. "DOM_VK_OEM_8",
  21708. "DOM_VK_OEM_COMMA",
  21709. "DOM_VK_OEM_MINUS",
  21710. "DOM_VK_OEM_PERIOD",
  21711. "DOM_VK_OEM_PLUS",
  21712. "DOM_VK_OPEN_BRACKET",
  21713. "DOM_VK_OPEN_CURLY_BRACKET",
  21714. "DOM_VK_OPEN_PAREN",
  21715. "DOM_VK_P",
  21716. "DOM_VK_PA1",
  21717. "DOM_VK_PAGEDOWN",
  21718. "DOM_VK_PAGEUP",
  21719. "DOM_VK_PAGE_DOWN",
  21720. "DOM_VK_PAGE_UP",
  21721. "DOM_VK_PAUSE",
  21722. "DOM_VK_PERCENT",
  21723. "DOM_VK_PERIOD",
  21724. "DOM_VK_PIPE",
  21725. "DOM_VK_PLAY",
  21726. "DOM_VK_PLUS",
  21727. "DOM_VK_PRINT",
  21728. "DOM_VK_PRINTSCREEN",
  21729. "DOM_VK_PROCESSKEY",
  21730. "DOM_VK_PROPERITES",
  21731. "DOM_VK_Q",
  21732. "DOM_VK_QUESTION_MARK",
  21733. "DOM_VK_QUOTE",
  21734. "DOM_VK_R",
  21735. "DOM_VK_REDO",
  21736. "DOM_VK_RETURN",
  21737. "DOM_VK_RIGHT",
  21738. "DOM_VK_S",
  21739. "DOM_VK_SCROLL_LOCK",
  21740. "DOM_VK_SELECT",
  21741. "DOM_VK_SEMICOLON",
  21742. "DOM_VK_SEPARATOR",
  21743. "DOM_VK_SHIFT",
  21744. "DOM_VK_SLASH",
  21745. "DOM_VK_SLEEP",
  21746. "DOM_VK_SPACE",
  21747. "DOM_VK_SUBTRACT",
  21748. "DOM_VK_T",
  21749. "DOM_VK_TAB",
  21750. "DOM_VK_TILDE",
  21751. "DOM_VK_U",
  21752. "DOM_VK_UNDERSCORE",
  21753. "DOM_VK_UNDO",
  21754. "DOM_VK_UNICODE",
  21755. "DOM_VK_UP",
  21756. "DOM_VK_V",
  21757. "DOM_VK_VOLUME_DOWN",
  21758. "DOM_VK_VOLUME_MUTE",
  21759. "DOM_VK_VOLUME_UP",
  21760. "DOM_VK_W",
  21761. "DOM_VK_WIN",
  21762. "DOM_VK_WINDOW",
  21763. "DOM_VK_WIN_ICO_00",
  21764. "DOM_VK_WIN_ICO_CLEAR",
  21765. "DOM_VK_WIN_ICO_HELP",
  21766. "DOM_VK_WIN_OEM_ATTN",
  21767. "DOM_VK_WIN_OEM_AUTO",
  21768. "DOM_VK_WIN_OEM_BACKTAB",
  21769. "DOM_VK_WIN_OEM_CLEAR",
  21770. "DOM_VK_WIN_OEM_COPY",
  21771. "DOM_VK_WIN_OEM_CUSEL",
  21772. "DOM_VK_WIN_OEM_ENLW",
  21773. "DOM_VK_WIN_OEM_FINISH",
  21774. "DOM_VK_WIN_OEM_FJ_JISHO",
  21775. "DOM_VK_WIN_OEM_FJ_LOYA",
  21776. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  21777. "DOM_VK_WIN_OEM_FJ_ROYA",
  21778. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  21779. "DOM_VK_WIN_OEM_JUMP",
  21780. "DOM_VK_WIN_OEM_PA1",
  21781. "DOM_VK_WIN_OEM_PA2",
  21782. "DOM_VK_WIN_OEM_PA3",
  21783. "DOM_VK_WIN_OEM_RESET",
  21784. "DOM_VK_WIN_OEM_WSCTRL",
  21785. "DOM_VK_X",
  21786. "DOM_VK_XF86XK_ADD_FAVORITE",
  21787. "DOM_VK_XF86XK_APPLICATION_LEFT",
  21788. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  21789. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  21790. "DOM_VK_XF86XK_AUDIO_FORWARD",
  21791. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  21792. "DOM_VK_XF86XK_AUDIO_MEDIA",
  21793. "DOM_VK_XF86XK_AUDIO_MUTE",
  21794. "DOM_VK_XF86XK_AUDIO_NEXT",
  21795. "DOM_VK_XF86XK_AUDIO_PAUSE",
  21796. "DOM_VK_XF86XK_AUDIO_PLAY",
  21797. "DOM_VK_XF86XK_AUDIO_PREV",
  21798. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  21799. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  21800. "DOM_VK_XF86XK_AUDIO_RECORD",
  21801. "DOM_VK_XF86XK_AUDIO_REPEAT",
  21802. "DOM_VK_XF86XK_AUDIO_REWIND",
  21803. "DOM_VK_XF86XK_AUDIO_STOP",
  21804. "DOM_VK_XF86XK_AWAY",
  21805. "DOM_VK_XF86XK_BACK",
  21806. "DOM_VK_XF86XK_BACK_FORWARD",
  21807. "DOM_VK_XF86XK_BATTERY",
  21808. "DOM_VK_XF86XK_BLUE",
  21809. "DOM_VK_XF86XK_BLUETOOTH",
  21810. "DOM_VK_XF86XK_BOOK",
  21811. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  21812. "DOM_VK_XF86XK_CALCULATOR",
  21813. "DOM_VK_XF86XK_CALENDAR",
  21814. "DOM_VK_XF86XK_CD",
  21815. "DOM_VK_XF86XK_CLOSE",
  21816. "DOM_VK_XF86XK_COMMUNITY",
  21817. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  21818. "DOM_VK_XF86XK_COPY",
  21819. "DOM_VK_XF86XK_CUT",
  21820. "DOM_VK_XF86XK_CYCLE_ANGLE",
  21821. "DOM_VK_XF86XK_DISPLAY",
  21822. "DOM_VK_XF86XK_DOCUMENTS",
  21823. "DOM_VK_XF86XK_DOS",
  21824. "DOM_VK_XF86XK_EJECT",
  21825. "DOM_VK_XF86XK_EXCEL",
  21826. "DOM_VK_XF86XK_EXPLORER",
  21827. "DOM_VK_XF86XK_FAVORITES",
  21828. "DOM_VK_XF86XK_FINANCE",
  21829. "DOM_VK_XF86XK_FORWARD",
  21830. "DOM_VK_XF86XK_FRAME_BACK",
  21831. "DOM_VK_XF86XK_FRAME_FORWARD",
  21832. "DOM_VK_XF86XK_GAME",
  21833. "DOM_VK_XF86XK_GO",
  21834. "DOM_VK_XF86XK_GREEN",
  21835. "DOM_VK_XF86XK_HIBERNATE",
  21836. "DOM_VK_XF86XK_HISTORY",
  21837. "DOM_VK_XF86XK_HOME_PAGE",
  21838. "DOM_VK_XF86XK_HOT_LINKS",
  21839. "DOM_VK_XF86XK_I_TOUCH",
  21840. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  21841. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  21842. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  21843. "DOM_VK_XF86XK_LAUNCH0",
  21844. "DOM_VK_XF86XK_LAUNCH1",
  21845. "DOM_VK_XF86XK_LAUNCH2",
  21846. "DOM_VK_XF86XK_LAUNCH3",
  21847. "DOM_VK_XF86XK_LAUNCH4",
  21848. "DOM_VK_XF86XK_LAUNCH5",
  21849. "DOM_VK_XF86XK_LAUNCH6",
  21850. "DOM_VK_XF86XK_LAUNCH7",
  21851. "DOM_VK_XF86XK_LAUNCH8",
  21852. "DOM_VK_XF86XK_LAUNCH9",
  21853. "DOM_VK_XF86XK_LAUNCH_A",
  21854. "DOM_VK_XF86XK_LAUNCH_B",
  21855. "DOM_VK_XF86XK_LAUNCH_C",
  21856. "DOM_VK_XF86XK_LAUNCH_D",
  21857. "DOM_VK_XF86XK_LAUNCH_E",
  21858. "DOM_VK_XF86XK_LAUNCH_F",
  21859. "DOM_VK_XF86XK_LIGHT_BULB",
  21860. "DOM_VK_XF86XK_LOG_OFF",
  21861. "DOM_VK_XF86XK_MAIL",
  21862. "DOM_VK_XF86XK_MAIL_FORWARD",
  21863. "DOM_VK_XF86XK_MARKET",
  21864. "DOM_VK_XF86XK_MEETING",
  21865. "DOM_VK_XF86XK_MEMO",
  21866. "DOM_VK_XF86XK_MENU_KB",
  21867. "DOM_VK_XF86XK_MENU_PB",
  21868. "DOM_VK_XF86XK_MESSENGER",
  21869. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  21870. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  21871. "DOM_VK_XF86XK_MUSIC",
  21872. "DOM_VK_XF86XK_MY_COMPUTER",
  21873. "DOM_VK_XF86XK_MY_SITES",
  21874. "DOM_VK_XF86XK_NEW",
  21875. "DOM_VK_XF86XK_NEWS",
  21876. "DOM_VK_XF86XK_OFFICE_HOME",
  21877. "DOM_VK_XF86XK_OPEN",
  21878. "DOM_VK_XF86XK_OPEN_URL",
  21879. "DOM_VK_XF86XK_OPTION",
  21880. "DOM_VK_XF86XK_PASTE",
  21881. "DOM_VK_XF86XK_PHONE",
  21882. "DOM_VK_XF86XK_PICTURES",
  21883. "DOM_VK_XF86XK_POWER_DOWN",
  21884. "DOM_VK_XF86XK_POWER_OFF",
  21885. "DOM_VK_XF86XK_RED",
  21886. "DOM_VK_XF86XK_REFRESH",
  21887. "DOM_VK_XF86XK_RELOAD",
  21888. "DOM_VK_XF86XK_REPLY",
  21889. "DOM_VK_XF86XK_ROCKER_DOWN",
  21890. "DOM_VK_XF86XK_ROCKER_ENTER",
  21891. "DOM_VK_XF86XK_ROCKER_UP",
  21892. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  21893. "DOM_VK_XF86XK_ROTATION_KB",
  21894. "DOM_VK_XF86XK_ROTATION_PB",
  21895. "DOM_VK_XF86XK_SAVE",
  21896. "DOM_VK_XF86XK_SCREEN_SAVER",
  21897. "DOM_VK_XF86XK_SCROLL_CLICK",
  21898. "DOM_VK_XF86XK_SCROLL_DOWN",
  21899. "DOM_VK_XF86XK_SCROLL_UP",
  21900. "DOM_VK_XF86XK_SEARCH",
  21901. "DOM_VK_XF86XK_SEND",
  21902. "DOM_VK_XF86XK_SHOP",
  21903. "DOM_VK_XF86XK_SPELL",
  21904. "DOM_VK_XF86XK_SPLIT_SCREEN",
  21905. "DOM_VK_XF86XK_STANDBY",
  21906. "DOM_VK_XF86XK_START",
  21907. "DOM_VK_XF86XK_STOP",
  21908. "DOM_VK_XF86XK_SUBTITLE",
  21909. "DOM_VK_XF86XK_SUPPORT",
  21910. "DOM_VK_XF86XK_SUSPEND",
  21911. "DOM_VK_XF86XK_TASK_PANE",
  21912. "DOM_VK_XF86XK_TERMINAL",
  21913. "DOM_VK_XF86XK_TIME",
  21914. "DOM_VK_XF86XK_TOOLS",
  21915. "DOM_VK_XF86XK_TOP_MENU",
  21916. "DOM_VK_XF86XK_TO_DO_LIST",
  21917. "DOM_VK_XF86XK_TRAVEL",
  21918. "DOM_VK_XF86XK_USER1KB",
  21919. "DOM_VK_XF86XK_USER2KB",
  21920. "DOM_VK_XF86XK_USER_PB",
  21921. "DOM_VK_XF86XK_UWB",
  21922. "DOM_VK_XF86XK_VENDOR_HOME",
  21923. "DOM_VK_XF86XK_VIDEO",
  21924. "DOM_VK_XF86XK_VIEW",
  21925. "DOM_VK_XF86XK_WAKE_UP",
  21926. "DOM_VK_XF86XK_WEB_CAM",
  21927. "DOM_VK_XF86XK_WHEEL_BUTTON",
  21928. "DOM_VK_XF86XK_WLAN",
  21929. "DOM_VK_XF86XK_WORD",
  21930. "DOM_VK_XF86XK_WWW",
  21931. "DOM_VK_XF86XK_XFER",
  21932. "DOM_VK_XF86XK_YELLOW",
  21933. "DOM_VK_XF86XK_ZOOM_IN",
  21934. "DOM_VK_XF86XK_ZOOM_OUT",
  21935. "DOM_VK_Y",
  21936. "DOM_VK_Z",
  21937. "DOM_VK_ZOOM",
  21938. "DONE",
  21939. "DONT_CARE",
  21940. "DOWNLOADING",
  21941. "DRAGDROP",
  21942. "DRAW_BUFFER0",
  21943. "DRAW_BUFFER1",
  21944. "DRAW_BUFFER10",
  21945. "DRAW_BUFFER11",
  21946. "DRAW_BUFFER12",
  21947. "DRAW_BUFFER13",
  21948. "DRAW_BUFFER14",
  21949. "DRAW_BUFFER15",
  21950. "DRAW_BUFFER2",
  21951. "DRAW_BUFFER3",
  21952. "DRAW_BUFFER4",
  21953. "DRAW_BUFFER5",
  21954. "DRAW_BUFFER6",
  21955. "DRAW_BUFFER7",
  21956. "DRAW_BUFFER8",
  21957. "DRAW_BUFFER9",
  21958. "DRAW_FRAMEBUFFER",
  21959. "DRAW_FRAMEBUFFER_BINDING",
  21960. "DST_ALPHA",
  21961. "DST_COLOR",
  21962. "DYNAMIC_COPY",
  21963. "DYNAMIC_DRAW",
  21964. "DYNAMIC_READ",
  21965. "DataChannel",
  21966. "DataTransfer",
  21967. "DataTransferItem",
  21968. "DataTransferItemList",
  21969. "DataView",
  21970. "Date",
  21971. "DateTimeFormat",
  21972. "DecompressionStream",
  21973. "DelayNode",
  21974. "DelegatedInkTrailPresenter",
  21975. "DeprecationReportBody",
  21976. "DesktopNotification",
  21977. "DesktopNotificationCenter",
  21978. "Details",
  21979. "DeviceLightEvent",
  21980. "DeviceMotionEvent",
  21981. "DeviceMotionEventAcceleration",
  21982. "DeviceMotionEventRotationRate",
  21983. "DeviceOrientationEvent",
  21984. "DeviceProximityEvent",
  21985. "DeviceStorage",
  21986. "DeviceStorageChangeEvent",
  21987. "Directory",
  21988. "DisplayNames",
  21989. "Document",
  21990. "DocumentFragment",
  21991. "DocumentPictureInPicture",
  21992. "DocumentPictureInPictureEvent",
  21993. "DocumentTimeline",
  21994. "DocumentType",
  21995. "DragEvent",
  21996. "DurationFormat",
  21997. "DynamicsCompressorNode",
  21998. "E",
  21999. "ELEMENT_ARRAY_BUFFER",
  22000. "ELEMENT_ARRAY_BUFFER_BINDING",
  22001. "ELEMENT_NODE",
  22002. "EMPTY",
  22003. "ENCODING_ERR",
  22004. "ENDED",
  22005. "END_TO_END",
  22006. "END_TO_START",
  22007. "ENTITY_NODE",
  22008. "ENTITY_REFERENCE_NODE",
  22009. "EPSILON",
  22010. "EQUAL",
  22011. "EQUALPOWER",
  22012. "ERROR",
  22013. "EXPONENTIAL_DISTANCE",
  22014. "EditContext",
  22015. "Element",
  22016. "ElementInternals",
  22017. "ElementQuery",
  22018. "EncodedAudioChunk",
  22019. "EncodedVideoChunk",
  22020. "EnterPictureInPictureEvent",
  22021. "Entity",
  22022. "EntityReference",
  22023. "Error",
  22024. "ErrorEvent",
  22025. "EvalError",
  22026. "Event",
  22027. "EventCounts",
  22028. "EventException",
  22029. "EventSource",
  22030. "EventTarget",
  22031. "Exception",
  22032. "ExtensionContext",
  22033. "ExtensionDisabledReason",
  22034. "ExtensionInfo",
  22035. "ExtensionInstallType",
  22036. "ExtensionType",
  22037. "External",
  22038. "EyeDropper",
  22039. "FASTEST",
  22040. "FIDOSDK",
  22041. "FILTER_ACCEPT",
  22042. "FILTER_INTERRUPT",
  22043. "FILTER_REJECT",
  22044. "FILTER_SKIP",
  22045. "FINISHED_STATE",
  22046. "FIRST_ORDERED_NODE_TYPE",
  22047. "FLOAT",
  22048. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  22049. "FLOAT_MAT2",
  22050. "FLOAT_MAT2x3",
  22051. "FLOAT_MAT2x4",
  22052. "FLOAT_MAT3",
  22053. "FLOAT_MAT3x2",
  22054. "FLOAT_MAT3x4",
  22055. "FLOAT_MAT4",
  22056. "FLOAT_MAT4x2",
  22057. "FLOAT_MAT4x3",
  22058. "FLOAT_VEC2",
  22059. "FLOAT_VEC3",
  22060. "FLOAT_VEC4",
  22061. "FOCUS",
  22062. "FONT_FACE_RULE",
  22063. "FONT_FEATURE_VALUES_RULE",
  22064. "FRAGMENT",
  22065. "FRAGMENT_SHADER",
  22066. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  22067. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  22068. "FRAMEBUFFER",
  22069. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  22070. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  22071. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  22072. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  22073. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  22074. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  22075. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  22076. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  22077. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  22078. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  22079. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  22080. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  22081. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  22082. "FRAMEBUFFER_BINDING",
  22083. "FRAMEBUFFER_COMPLETE",
  22084. "FRAMEBUFFER_DEFAULT",
  22085. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  22086. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  22087. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  22088. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  22089. "FRAMEBUFFER_UNSUPPORTED",
  22090. "FRONT",
  22091. "FRONT_AND_BACK",
  22092. "FRONT_FACE",
  22093. "FUNC_ADD",
  22094. "FUNC_REVERSE_SUBTRACT",
  22095. "FUNC_SUBTRACT",
  22096. "FeaturePolicy",
  22097. "FeaturePolicyViolationReportBody",
  22098. "FederatedCredential",
  22099. "Feed",
  22100. "FeedEntry",
  22101. "Fence",
  22102. "FencedFrameConfig",
  22103. "File",
  22104. "FileError",
  22105. "FileList",
  22106. "FileReader",
  22107. "FileSystem",
  22108. "FileSystemDirectoryEntry",
  22109. "FileSystemDirectoryHandle",
  22110. "FileSystemDirectoryReader",
  22111. "FileSystemEntry",
  22112. "FileSystemFileEntry",
  22113. "FileSystemFileHandle",
  22114. "FileSystemHandle",
  22115. "FileSystemWritableFileStream",
  22116. "FinalizationRegistry",
  22117. "FindInPage",
  22118. "Float16Array",
  22119. "Float32Array",
  22120. "Float64Array",
  22121. "FocusEvent",
  22122. "FontData",
  22123. "FontFace",
  22124. "FontFaceSet",
  22125. "FontFaceSetLoadEvent",
  22126. "FormData",
  22127. "FormDataEvent",
  22128. "FragmentDirective",
  22129. "Function",
  22130. "GENERATE_MIPMAP_HINT",
  22131. "GEQUAL",
  22132. "GPU",
  22133. "GPUAdapter",
  22134. "GPUAdapterInfo",
  22135. "GPUBindGroup",
  22136. "GPUBindGroupLayout",
  22137. "GPUBuffer",
  22138. "GPUBufferUsage",
  22139. "GPUCanvasContext",
  22140. "GPUColorWrite",
  22141. "GPUCommandBuffer",
  22142. "GPUCommandEncoder",
  22143. "GPUCompilationInfo",
  22144. "GPUCompilationMessage",
  22145. "GPUComputePassEncoder",
  22146. "GPUComputePipeline",
  22147. "GPUDevice",
  22148. "GPUDeviceLostInfo",
  22149. "GPUError",
  22150. "GPUExternalTexture",
  22151. "GPUInternalError",
  22152. "GPUMapMode",
  22153. "GPUOutOfMemoryError",
  22154. "GPUPipelineError",
  22155. "GPUPipelineLayout",
  22156. "GPUQuerySet",
  22157. "GPUQueue",
  22158. "GPURenderBundle",
  22159. "GPURenderBundleEncoder",
  22160. "GPURenderPassEncoder",
  22161. "GPURenderPipeline",
  22162. "GPUSampler",
  22163. "GPUShaderModule",
  22164. "GPUShaderStage",
  22165. "GPUSupportedFeatures",
  22166. "GPUSupportedLimits",
  22167. "GPUTexture",
  22168. "GPUTextureUsage",
  22169. "GPUTextureView",
  22170. "GPUUncapturedErrorEvent",
  22171. "GPUValidationError",
  22172. "GREATER",
  22173. "GREEN",
  22174. "GREEN_BITS",
  22175. "GainNode",
  22176. "Gamepad",
  22177. "GamepadAxisMoveEvent",
  22178. "GamepadButton",
  22179. "GamepadButtonEvent",
  22180. "GamepadEvent",
  22181. "GamepadHapticActuator",
  22182. "GamepadPose",
  22183. "Geolocation",
  22184. "GeolocationCoordinates",
  22185. "GeolocationPosition",
  22186. "GeolocationPositionError",
  22187. "GestureEvent",
  22188. "GetInfo",
  22189. "Global",
  22190. "GravitySensor",
  22191. "Gyroscope",
  22192. "HALF_FLOAT",
  22193. "HAVE_CURRENT_DATA",
  22194. "HAVE_ENOUGH_DATA",
  22195. "HAVE_FUTURE_DATA",
  22196. "HAVE_METADATA",
  22197. "HAVE_NOTHING",
  22198. "HEADERS_RECEIVED",
  22199. "HID",
  22200. "HIDConnectionEvent",
  22201. "HIDDEN",
  22202. "HIDDevice",
  22203. "HIDInputReportEvent",
  22204. "HIERARCHY_REQUEST_ERR",
  22205. "HIGHPASS",
  22206. "HIGHSHELF",
  22207. "HIGH_FLOAT",
  22208. "HIGH_INT",
  22209. "HORIZONTAL",
  22210. "HORIZONTAL_AXIS",
  22211. "HRTF",
  22212. "HTMLAllCollection",
  22213. "HTMLAnchorElement",
  22214. "HTMLAppletElement",
  22215. "HTMLAreaElement",
  22216. "HTMLAudioElement",
  22217. "HTMLBRElement",
  22218. "HTMLBaseElement",
  22219. "HTMLBaseFontElement",
  22220. "HTMLBlockquoteElement",
  22221. "HTMLBodyElement",
  22222. "HTMLButtonElement",
  22223. "HTMLCanvasElement",
  22224. "HTMLCollection",
  22225. "HTMLCommandElement",
  22226. "HTMLContentElement",
  22227. "HTMLDListElement",
  22228. "HTMLDataElement",
  22229. "HTMLDataListElement",
  22230. "HTMLDetailsElement",
  22231. "HTMLDialogElement",
  22232. "HTMLDirectoryElement",
  22233. "HTMLDivElement",
  22234. "HTMLDocument",
  22235. "HTMLElement",
  22236. "HTMLEmbedElement",
  22237. "HTMLFencedFrameElement",
  22238. "HTMLFieldSetElement",
  22239. "HTMLFontElement",
  22240. "HTMLFormControlsCollection",
  22241. "HTMLFormElement",
  22242. "HTMLFrameElement",
  22243. "HTMLFrameSetElement",
  22244. "HTMLHRElement",
  22245. "HTMLHeadElement",
  22246. "HTMLHeadingElement",
  22247. "HTMLHtmlElement",
  22248. "HTMLIFrameElement",
  22249. "HTMLImageElement",
  22250. "HTMLInputElement",
  22251. "HTMLIsIndexElement",
  22252. "HTMLKeygenElement",
  22253. "HTMLLIElement",
  22254. "HTMLLabelElement",
  22255. "HTMLLegendElement",
  22256. "HTMLLinkElement",
  22257. "HTMLMapElement",
  22258. "HTMLMarqueeElement",
  22259. "HTMLMediaElement",
  22260. "HTMLMenuElement",
  22261. "HTMLMenuItemElement",
  22262. "HTMLMetaElement",
  22263. "HTMLMeterElement",
  22264. "HTMLModElement",
  22265. "HTMLOListElement",
  22266. "HTMLObjectElement",
  22267. "HTMLOptGroupElement",
  22268. "HTMLOptionElement",
  22269. "HTMLOptionsCollection",
  22270. "HTMLOutputElement",
  22271. "HTMLParagraphElement",
  22272. "HTMLParamElement",
  22273. "HTMLPictureElement",
  22274. "HTMLPreElement",
  22275. "HTMLProgressElement",
  22276. "HTMLPropertiesCollection",
  22277. "HTMLQuoteElement",
  22278. "HTMLScriptElement",
  22279. "HTMLSelectElement",
  22280. "HTMLShadowElement",
  22281. "HTMLSlotElement",
  22282. "HTMLSourceElement",
  22283. "HTMLSpanElement",
  22284. "HTMLStyleElement",
  22285. "HTMLTableCaptionElement",
  22286. "HTMLTableCellElement",
  22287. "HTMLTableColElement",
  22288. "HTMLTableElement",
  22289. "HTMLTableRowElement",
  22290. "HTMLTableSectionElement",
  22291. "HTMLTemplateElement",
  22292. "HTMLTextAreaElement",
  22293. "HTMLTimeElement",
  22294. "HTMLTitleElement",
  22295. "HTMLTrackElement",
  22296. "HTMLUListElement",
  22297. "HTMLUnknownElement",
  22298. "HTMLVideoElement",
  22299. "HashChangeEvent",
  22300. "Headers",
  22301. "Highlight",
  22302. "HighlightRegistry",
  22303. "History",
  22304. "Hz",
  22305. "ICE_CHECKING",
  22306. "ICE_CLOSED",
  22307. "ICE_COMPLETED",
  22308. "ICE_CONNECTED",
  22309. "ICE_FAILED",
  22310. "ICE_GATHERING",
  22311. "ICE_WAITING",
  22312. "IDBCursor",
  22313. "IDBCursorWithValue",
  22314. "IDBDatabase",
  22315. "IDBDatabaseException",
  22316. "IDBFactory",
  22317. "IDBFileHandle",
  22318. "IDBFileRequest",
  22319. "IDBIndex",
  22320. "IDBKeyRange",
  22321. "IDBMutableFile",
  22322. "IDBObjectStore",
  22323. "IDBOpenDBRequest",
  22324. "IDBRequest",
  22325. "IDBTransaction",
  22326. "IDBVersionChangeEvent",
  22327. "IDLE",
  22328. "IIRFilterNode",
  22329. "IMPLEMENTATION_COLOR_READ_FORMAT",
  22330. "IMPLEMENTATION_COLOR_READ_TYPE",
  22331. "IMPORT_RULE",
  22332. "INCR",
  22333. "INCR_WRAP",
  22334. "INDEX",
  22335. "INDEX_SIZE_ERR",
  22336. "INDIRECT",
  22337. "INT",
  22338. "INTERLEAVED_ATTRIBS",
  22339. "INT_2_10_10_10_REV",
  22340. "INT_SAMPLER_2D",
  22341. "INT_SAMPLER_2D_ARRAY",
  22342. "INT_SAMPLER_3D",
  22343. "INT_SAMPLER_CUBE",
  22344. "INT_VEC2",
  22345. "INT_VEC3",
  22346. "INT_VEC4",
  22347. "INUSE_ATTRIBUTE_ERR",
  22348. "INVALID_ACCESS_ERR",
  22349. "INVALID_CHARACTER_ERR",
  22350. "INVALID_ENUM",
  22351. "INVALID_EXPRESSION_ERR",
  22352. "INVALID_FRAMEBUFFER_OPERATION",
  22353. "INVALID_INDEX",
  22354. "INVALID_MODIFICATION_ERR",
  22355. "INVALID_NODE_TYPE_ERR",
  22356. "INVALID_OPERATION",
  22357. "INVALID_STATE_ERR",
  22358. "INVALID_VALUE",
  22359. "INVERSE_DISTANCE",
  22360. "INVERT",
  22361. "IceCandidate",
  22362. "IconInfo",
  22363. "IdentityCredential",
  22364. "IdentityCredentialError",
  22365. "IdentityProvider",
  22366. "IdleDeadline",
  22367. "IdleDetector",
  22368. "Image",
  22369. "ImageBitmap",
  22370. "ImageBitmapRenderingContext",
  22371. "ImageCapture",
  22372. "ImageData",
  22373. "ImageDataType",
  22374. "ImageDecoder",
  22375. "ImageTrack",
  22376. "ImageTrackList",
  22377. "Infinity",
  22378. "Ink",
  22379. "InputDeviceCapabilities",
  22380. "InputDeviceInfo",
  22381. "InputEvent",
  22382. "InputMethodContext",
  22383. "InstallTrigger",
  22384. "InstallTriggerImpl",
  22385. "Instance",
  22386. "Int16Array",
  22387. "Int32Array",
  22388. "Int8Array",
  22389. "Intent",
  22390. "InternalError",
  22391. "IntersectionObserver",
  22392. "IntersectionObserverEntry",
  22393. "Intl",
  22394. "IsSearchProviderInstalled",
  22395. "Iterator",
  22396. "JSON",
  22397. "JSTag",
  22398. "KEEP",
  22399. "KEYDOWN",
  22400. "KEYFRAMES_RULE",
  22401. "KEYFRAME_RULE",
  22402. "KEYPRESS",
  22403. "KEYUP",
  22404. "KeyEvent",
  22405. "Keyboard",
  22406. "KeyboardEvent",
  22407. "KeyboardLayoutMap",
  22408. "KeyframeEffect",
  22409. "LENGTHADJUST_SPACING",
  22410. "LENGTHADJUST_SPACINGANDGLYPHS",
  22411. "LENGTHADJUST_UNKNOWN",
  22412. "LEQUAL",
  22413. "LESS",
  22414. "LINEAR",
  22415. "LINEAR_DISTANCE",
  22416. "LINEAR_MIPMAP_LINEAR",
  22417. "LINEAR_MIPMAP_NEAREST",
  22418. "LINES",
  22419. "LINE_LOOP",
  22420. "LINE_STRIP",
  22421. "LINE_WIDTH",
  22422. "LINK_STATUS",
  22423. "LIVE",
  22424. "LN10",
  22425. "LN2",
  22426. "LOADED",
  22427. "LOADING",
  22428. "LOG10E",
  22429. "LOG2E",
  22430. "LOWPASS",
  22431. "LOWSHELF",
  22432. "LOW_FLOAT",
  22433. "LOW_INT",
  22434. "LSException",
  22435. "LSParserFilter",
  22436. "LUMINANCE",
  22437. "LUMINANCE_ALPHA",
  22438. "LanguageCode",
  22439. "LargestContentfulPaint",
  22440. "LaunchParams",
  22441. "LaunchQueue",
  22442. "LaunchType",
  22443. "LayoutShift",
  22444. "LayoutShiftAttribution",
  22445. "LinearAccelerationSensor",
  22446. "LinkError",
  22447. "ListFormat",
  22448. "LocalMediaStream",
  22449. "Locale",
  22450. "Location",
  22451. "Lock",
  22452. "LockManager",
  22453. "MAP_READ",
  22454. "MAP_WRITE",
  22455. "MARGIN_RULE",
  22456. "MAX",
  22457. "MAX_3D_TEXTURE_SIZE",
  22458. "MAX_ARRAY_TEXTURE_LAYERS",
  22459. "MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND",
  22460. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  22461. "MAX_COLOR_ATTACHMENTS",
  22462. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  22463. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  22464. "MAX_COMBINED_UNIFORM_BLOCKS",
  22465. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  22466. "MAX_CUBE_MAP_TEXTURE_SIZE",
  22467. "MAX_DRAW_BUFFERS",
  22468. "MAX_ELEMENTS_INDICES",
  22469. "MAX_ELEMENTS_VERTICES",
  22470. "MAX_ELEMENT_INDEX",
  22471. "MAX_FRAGMENT_INPUT_COMPONENTS",
  22472. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  22473. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  22474. "MAX_FRAGMENT_UNIFORM_VECTORS",
  22475. "MAX_PROGRAM_TEXEL_OFFSET",
  22476. "MAX_RENDERBUFFER_SIZE",
  22477. "MAX_SAFE_INTEGER",
  22478. "MAX_SAMPLES",
  22479. "MAX_SERVER_WAIT_TIMEOUT",
  22480. "MAX_TEXTURE_IMAGE_UNITS",
  22481. "MAX_TEXTURE_LOD_BIAS",
  22482. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  22483. "MAX_TEXTURE_SIZE",
  22484. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  22485. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  22486. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  22487. "MAX_UNIFORM_BLOCK_SIZE",
  22488. "MAX_UNIFORM_BUFFER_BINDINGS",
  22489. "MAX_VALUE",
  22490. "MAX_VARYING_COMPONENTS",
  22491. "MAX_VARYING_VECTORS",
  22492. "MAX_VERTEX_ATTRIBS",
  22493. "MAX_VERTEX_OUTPUT_COMPONENTS",
  22494. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  22495. "MAX_VERTEX_UNIFORM_BLOCKS",
  22496. "MAX_VERTEX_UNIFORM_COMPONENTS",
  22497. "MAX_VERTEX_UNIFORM_VECTORS",
  22498. "MAX_VIEWPORT_DIMS",
  22499. "MEDIA_ERR_ABORTED",
  22500. "MEDIA_ERR_DECODE",
  22501. "MEDIA_ERR_ENCRYPTED",
  22502. "MEDIA_ERR_NETWORK",
  22503. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  22504. "MEDIA_KEYERR_CLIENT",
  22505. "MEDIA_KEYERR_DOMAIN",
  22506. "MEDIA_KEYERR_HARDWARECHANGE",
  22507. "MEDIA_KEYERR_OUTPUT",
  22508. "MEDIA_KEYERR_SERVICE",
  22509. "MEDIA_KEYERR_UNKNOWN",
  22510. "MEDIA_RULE",
  22511. "MEDIUM_FLOAT",
  22512. "MEDIUM_INT",
  22513. "META_MASK",
  22514. "MIDIAccess",
  22515. "MIDIConnectionEvent",
  22516. "MIDIInput",
  22517. "MIDIInputMap",
  22518. "MIDIMessageEvent",
  22519. "MIDIOutput",
  22520. "MIDIOutputMap",
  22521. "MIDIPort",
  22522. "MIN",
  22523. "MIN_PROGRAM_TEXEL_OFFSET",
  22524. "MIN_SAFE_INTEGER",
  22525. "MIN_VALUE",
  22526. "MIRRORED_REPEAT",
  22527. "MODE_ASYNCHRONOUS",
  22528. "MODE_SYNCHRONOUS",
  22529. "MODIFICATION",
  22530. "MOUSEDOWN",
  22531. "MOUSEDRAG",
  22532. "MOUSEMOVE",
  22533. "MOUSEOUT",
  22534. "MOUSEOVER",
  22535. "MOUSEUP",
  22536. "MOZ_KEYFRAMES_RULE",
  22537. "MOZ_KEYFRAME_RULE",
  22538. "MOZ_SOURCE_CURSOR",
  22539. "MOZ_SOURCE_ERASER",
  22540. "MOZ_SOURCE_KEYBOARD",
  22541. "MOZ_SOURCE_MOUSE",
  22542. "MOZ_SOURCE_PEN",
  22543. "MOZ_SOURCE_TOUCH",
  22544. "MOZ_SOURCE_UNKNOWN",
  22545. "MSGESTURE_FLAG_BEGIN",
  22546. "MSGESTURE_FLAG_CANCEL",
  22547. "MSGESTURE_FLAG_END",
  22548. "MSGESTURE_FLAG_INERTIA",
  22549. "MSGESTURE_FLAG_NONE",
  22550. "MSPOINTER_TYPE_MOUSE",
  22551. "MSPOINTER_TYPE_PEN",
  22552. "MSPOINTER_TYPE_TOUCH",
  22553. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  22554. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  22555. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  22556. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  22557. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  22558. "MS_ASYNC_OP_STATUS_CANCELED",
  22559. "MS_ASYNC_OP_STATUS_ERROR",
  22560. "MS_ASYNC_OP_STATUS_SUCCESS",
  22561. "MS_MANIPULATION_STATE_ACTIVE",
  22562. "MS_MANIPULATION_STATE_CANCELLED",
  22563. "MS_MANIPULATION_STATE_COMMITTED",
  22564. "MS_MANIPULATION_STATE_DRAGGING",
  22565. "MS_MANIPULATION_STATE_INERTIA",
  22566. "MS_MANIPULATION_STATE_PRESELECT",
  22567. "MS_MANIPULATION_STATE_SELECTING",
  22568. "MS_MANIPULATION_STATE_STOPPED",
  22569. "MS_MEDIA_ERR_ENCRYPTED",
  22570. "MS_MEDIA_KEYERR_CLIENT",
  22571. "MS_MEDIA_KEYERR_DOMAIN",
  22572. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  22573. "MS_MEDIA_KEYERR_OUTPUT",
  22574. "MS_MEDIA_KEYERR_SERVICE",
  22575. "MS_MEDIA_KEYERR_UNKNOWN",
  22576. "Map",
  22577. "Math",
  22578. "MathMLElement",
  22579. "MediaCapabilities",
  22580. "MediaCapabilitiesInfo",
  22581. "MediaController",
  22582. "MediaDeviceInfo",
  22583. "MediaDevices",
  22584. "MediaElementAudioSourceNode",
  22585. "MediaEncryptedEvent",
  22586. "MediaError",
  22587. "MediaKeyError",
  22588. "MediaKeyEvent",
  22589. "MediaKeyMessageEvent",
  22590. "MediaKeyNeededEvent",
  22591. "MediaKeySession",
  22592. "MediaKeyStatusMap",
  22593. "MediaKeySystemAccess",
  22594. "MediaKeys",
  22595. "MediaList",
  22596. "MediaMetadata",
  22597. "MediaQueryList",
  22598. "MediaQueryListEvent",
  22599. "MediaRecorder",
  22600. "MediaRecorderErrorEvent",
  22601. "MediaSession",
  22602. "MediaSettingsRange",
  22603. "MediaSource",
  22604. "MediaSourceHandle",
  22605. "MediaStream",
  22606. "MediaStreamAudioDestinationNode",
  22607. "MediaStreamAudioSourceNode",
  22608. "MediaStreamEvent",
  22609. "MediaStreamTrack",
  22610. "MediaStreamTrackAudioSourceNode",
  22611. "MediaStreamTrackAudioStats",
  22612. "MediaStreamTrackEvent",
  22613. "MediaStreamTrackGenerator",
  22614. "MediaStreamTrackProcessor",
  22615. "MediaStreamTrackVideoStats",
  22616. "Memory",
  22617. "MessageChannel",
  22618. "MessageEvent",
  22619. "MessagePort",
  22620. "MessageSender",
  22621. "Methods",
  22622. "MimeType",
  22623. "MimeTypeArray",
  22624. "Module",
  22625. "MouseEvent",
  22626. "MouseScrollEvent",
  22627. "MozAnimation",
  22628. "MozAnimationDelay",
  22629. "MozAnimationDirection",
  22630. "MozAnimationDuration",
  22631. "MozAnimationFillMode",
  22632. "MozAnimationIterationCount",
  22633. "MozAnimationName",
  22634. "MozAnimationPlayState",
  22635. "MozAnimationTimingFunction",
  22636. "MozAppearance",
  22637. "MozBackfaceVisibility",
  22638. "MozBinding",
  22639. "MozBorderBottomColors",
  22640. "MozBorderEnd",
  22641. "MozBorderEndColor",
  22642. "MozBorderEndStyle",
  22643. "MozBorderEndWidth",
  22644. "MozBorderImage",
  22645. "MozBorderLeftColors",
  22646. "MozBorderRightColors",
  22647. "MozBorderStart",
  22648. "MozBorderStartColor",
  22649. "MozBorderStartStyle",
  22650. "MozBorderStartWidth",
  22651. "MozBorderTopColors",
  22652. "MozBoxAlign",
  22653. "MozBoxDirection",
  22654. "MozBoxFlex",
  22655. "MozBoxOrdinalGroup",
  22656. "MozBoxOrient",
  22657. "MozBoxPack",
  22658. "MozBoxSizing",
  22659. "MozCSSKeyframeRule",
  22660. "MozCSSKeyframesRule",
  22661. "MozColumnCount",
  22662. "MozColumnFill",
  22663. "MozColumnGap",
  22664. "MozColumnRule",
  22665. "MozColumnRuleColor",
  22666. "MozColumnRuleStyle",
  22667. "MozColumnRuleWidth",
  22668. "MozColumnWidth",
  22669. "MozColumns",
  22670. "MozContactChangeEvent",
  22671. "MozFloatEdge",
  22672. "MozFontFeatureSettings",
  22673. "MozFontLanguageOverride",
  22674. "MozForceBrokenImageIcon",
  22675. "MozHyphens",
  22676. "MozImageRegion",
  22677. "MozMarginEnd",
  22678. "MozMarginStart",
  22679. "MozMmsEvent",
  22680. "MozMmsMessage",
  22681. "MozMobileMessageThread",
  22682. "MozOSXFontSmoothing",
  22683. "MozOrient",
  22684. "MozOsxFontSmoothing",
  22685. "MozOutlineRadius",
  22686. "MozOutlineRadiusBottomleft",
  22687. "MozOutlineRadiusBottomright",
  22688. "MozOutlineRadiusTopleft",
  22689. "MozOutlineRadiusTopright",
  22690. "MozPaddingEnd",
  22691. "MozPaddingStart",
  22692. "MozPerspective",
  22693. "MozPerspectiveOrigin",
  22694. "MozPowerManager",
  22695. "MozSettingsEvent",
  22696. "MozSmsEvent",
  22697. "MozSmsMessage",
  22698. "MozStackSizing",
  22699. "MozTabSize",
  22700. "MozTextAlignLast",
  22701. "MozTextDecorationColor",
  22702. "MozTextDecorationLine",
  22703. "MozTextDecorationStyle",
  22704. "MozTextSizeAdjust",
  22705. "MozTransform",
  22706. "MozTransformOrigin",
  22707. "MozTransformStyle",
  22708. "MozTransition",
  22709. "MozTransitionDelay",
  22710. "MozTransitionDuration",
  22711. "MozTransitionProperty",
  22712. "MozTransitionTimingFunction",
  22713. "MozUserFocus",
  22714. "MozUserInput",
  22715. "MozUserModify",
  22716. "MozUserSelect",
  22717. "MozWindowDragging",
  22718. "MozWindowShadow",
  22719. "MutationEvent",
  22720. "MutationObserver",
  22721. "MutationRecord",
  22722. "MutedInfo",
  22723. "MutedInfoReason",
  22724. "NAMESPACE_ERR",
  22725. "NAMESPACE_RULE",
  22726. "NEAREST",
  22727. "NEAREST_MIPMAP_LINEAR",
  22728. "NEAREST_MIPMAP_NEAREST",
  22729. "NEGATIVE_INFINITY",
  22730. "NETWORK_EMPTY",
  22731. "NETWORK_ERR",
  22732. "NETWORK_IDLE",
  22733. "NETWORK_LOADED",
  22734. "NETWORK_LOADING",
  22735. "NETWORK_NO_SOURCE",
  22736. "NEVER",
  22737. "NEW",
  22738. "NEXT",
  22739. "NEXT_NO_DUPLICATE",
  22740. "NICEST",
  22741. "NODE_AFTER",
  22742. "NODE_BEFORE",
  22743. "NODE_BEFORE_AND_AFTER",
  22744. "NODE_INSIDE",
  22745. "NONE",
  22746. "NON_TRANSIENT_ERR",
  22747. "NOTATION_NODE",
  22748. "NOTCH",
  22749. "NOTEQUAL",
  22750. "NOT_ALLOWED_ERR",
  22751. "NOT_FOUND_ERR",
  22752. "NOT_READABLE_ERR",
  22753. "NOT_SUPPORTED_ERR",
  22754. "NO_DATA_ALLOWED_ERR",
  22755. "NO_ERR",
  22756. "NO_ERROR",
  22757. "NO_MODIFICATION_ALLOWED_ERR",
  22758. "NUMBER_TYPE",
  22759. "NUM_COMPRESSED_TEXTURE_FORMATS",
  22760. "NaN",
  22761. "NamedNodeMap",
  22762. "NavigateEvent",
  22763. "Navigation",
  22764. "NavigationActivation",
  22765. "NavigationCurrentEntryChangeEvent",
  22766. "NavigationDestination",
  22767. "NavigationHistoryEntry",
  22768. "NavigationPreloadManager",
  22769. "NavigationTransition",
  22770. "Navigator",
  22771. "NavigatorLogin",
  22772. "NavigatorManagedData",
  22773. "NavigatorUAData",
  22774. "NearbyLinks",
  22775. "NetworkInformation",
  22776. "Node",
  22777. "NodeFilter",
  22778. "NodeIterator",
  22779. "NodeList",
  22780. "NotRestoredReasonDetails",
  22781. "NotRestoredReasons",
  22782. "Notation",
  22783. "Notification",
  22784. "NotifyPaintEvent",
  22785. "Number",
  22786. "NumberFormat",
  22787. "OBJECT_TYPE",
  22788. "OBSOLETE",
  22789. "OK",
  22790. "ONE",
  22791. "ONE_MINUS_CONSTANT_ALPHA",
  22792. "ONE_MINUS_CONSTANT_COLOR",
  22793. "ONE_MINUS_DST_ALPHA",
  22794. "ONE_MINUS_DST_COLOR",
  22795. "ONE_MINUS_SRC_ALPHA",
  22796. "ONE_MINUS_SRC_COLOR",
  22797. "OPEN",
  22798. "OPENED",
  22799. "OPENING",
  22800. "ORDERED_NODE_ITERATOR_TYPE",
  22801. "ORDERED_NODE_SNAPSHOT_TYPE",
  22802. "OTHER_ERROR",
  22803. "OTPCredential",
  22804. "OUT_OF_MEMORY",
  22805. "Object",
  22806. "OfflineAudioCompletionEvent",
  22807. "OfflineAudioContext",
  22808. "OfflineResourceList",
  22809. "OffscreenCanvas",
  22810. "OffscreenCanvasRenderingContext2D",
  22811. "OnClickData",
  22812. "OnInstalledReason",
  22813. "OnPerformanceWarningCategory",
  22814. "OnPerformanceWarningSeverity",
  22815. "OnRestartRequiredReason",
  22816. "Option",
  22817. "OrientationSensor",
  22818. "OscillatorNode",
  22819. "OverconstrainedError",
  22820. "OverflowEvent",
  22821. "PACK_ALIGNMENT",
  22822. "PACK_ROW_LENGTH",
  22823. "PACK_SKIP_PIXELS",
  22824. "PACK_SKIP_ROWS",
  22825. "PAGE_RULE",
  22826. "PARSE_ERR",
  22827. "PATHSEG_ARC_ABS",
  22828. "PATHSEG_ARC_REL",
  22829. "PATHSEG_CLOSEPATH",
  22830. "PATHSEG_CURVETO_CUBIC_ABS",
  22831. "PATHSEG_CURVETO_CUBIC_REL",
  22832. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  22833. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  22834. "PATHSEG_CURVETO_QUADRATIC_ABS",
  22835. "PATHSEG_CURVETO_QUADRATIC_REL",
  22836. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  22837. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  22838. "PATHSEG_LINETO_ABS",
  22839. "PATHSEG_LINETO_HORIZONTAL_ABS",
  22840. "PATHSEG_LINETO_HORIZONTAL_REL",
  22841. "PATHSEG_LINETO_REL",
  22842. "PATHSEG_LINETO_VERTICAL_ABS",
  22843. "PATHSEG_LINETO_VERTICAL_REL",
  22844. "PATHSEG_MOVETO_ABS",
  22845. "PATHSEG_MOVETO_REL",
  22846. "PATHSEG_UNKNOWN",
  22847. "PATH_EXISTS_ERR",
  22848. "PEAKING",
  22849. "PERMISSION_DENIED",
  22850. "PERSISTENT",
  22851. "PI",
  22852. "PIXEL_PACK_BUFFER",
  22853. "PIXEL_PACK_BUFFER_BINDING",
  22854. "PIXEL_UNPACK_BUFFER",
  22855. "PIXEL_UNPACK_BUFFER_BINDING",
  22856. "PLAYING_STATE",
  22857. "POINTS",
  22858. "POLYGON_OFFSET_FACTOR",
  22859. "POLYGON_OFFSET_FILL",
  22860. "POLYGON_OFFSET_UNITS",
  22861. "POSITION_UNAVAILABLE",
  22862. "POSITIVE_INFINITY",
  22863. "PREV",
  22864. "PREV_NO_DUPLICATE",
  22865. "PROCESSING_INSTRUCTION_NODE",
  22866. "PageChangeEvent",
  22867. "PageRevealEvent",
  22868. "PageSettings",
  22869. "PageSwapEvent",
  22870. "PageTransitionEvent",
  22871. "PaintRequest",
  22872. "PaintRequestList",
  22873. "PannerNode",
  22874. "PasswordCredential",
  22875. "Path2D",
  22876. "PaymentAddress",
  22877. "PaymentInstruments",
  22878. "PaymentManager",
  22879. "PaymentMethodChangeEvent",
  22880. "PaymentRequest",
  22881. "PaymentRequestUpdateEvent",
  22882. "PaymentResponse",
  22883. "Performance",
  22884. "PerformanceElementTiming",
  22885. "PerformanceEntry",
  22886. "PerformanceEventTiming",
  22887. "PerformanceLongAnimationFrameTiming",
  22888. "PerformanceLongTaskTiming",
  22889. "PerformanceMark",
  22890. "PerformanceMeasure",
  22891. "PerformanceNavigation",
  22892. "PerformanceNavigationTiming",
  22893. "PerformanceObserver",
  22894. "PerformanceObserverEntryList",
  22895. "PerformancePaintTiming",
  22896. "PerformanceResourceTiming",
  22897. "PerformanceScriptTiming",
  22898. "PerformanceServerTiming",
  22899. "PerformanceTiming",
  22900. "PeriodicSyncManager",
  22901. "PeriodicWave",
  22902. "PermissionStatus",
  22903. "Permissions",
  22904. "PhotoCapabilities",
  22905. "PictureInPictureEvent",
  22906. "PictureInPictureWindow",
  22907. "PlatformArch",
  22908. "PlatformInfo",
  22909. "PlatformNaclArch",
  22910. "PlatformOs",
  22911. "Plugin",
  22912. "PluginArray",
  22913. "PluralRules",
  22914. "PointerEvent",
  22915. "PopStateEvent",
  22916. "PopupBlockedEvent",
  22917. "Port",
  22918. "Presentation",
  22919. "PresentationAvailability",
  22920. "PresentationConnection",
  22921. "PresentationConnectionAvailableEvent",
  22922. "PresentationConnectionCloseEvent",
  22923. "PresentationConnectionList",
  22924. "PresentationReceiver",
  22925. "PresentationRequest",
  22926. "PressureObserver",
  22927. "PressureRecord",
  22928. "ProcessingInstruction",
  22929. "Profiler",
  22930. "ProgressEvent",
  22931. "Promise",
  22932. "PromiseRejectionEvent",
  22933. "PropertyNodeList",
  22934. "ProtectedAudience",
  22935. "Proxy",
  22936. "PublicKeyCredential",
  22937. "PushManager",
  22938. "PushSubscription",
  22939. "PushSubscriptionOptions",
  22940. "Q",
  22941. "QUERY_RESOLVE",
  22942. "QUERY_RESULT",
  22943. "QUERY_RESULT_AVAILABLE",
  22944. "QUOTA_ERR",
  22945. "QUOTA_EXCEEDED_ERR",
  22946. "QueryInterface",
  22947. "R11F_G11F_B10F",
  22948. "R16F",
  22949. "R16I",
  22950. "R16UI",
  22951. "R32F",
  22952. "R32I",
  22953. "R32UI",
  22954. "R8",
  22955. "R8I",
  22956. "R8UI",
  22957. "R8_SNORM",
  22958. "RASTERIZER_DISCARD",
  22959. "READ",
  22960. "READ_BUFFER",
  22961. "READ_FRAMEBUFFER",
  22962. "READ_FRAMEBUFFER_BINDING",
  22963. "READ_ONLY",
  22964. "READ_ONLY_ERR",
  22965. "READ_WRITE",
  22966. "RED",
  22967. "RED_BITS",
  22968. "RED_INTEGER",
  22969. "REMOVAL",
  22970. "RENDERBUFFER",
  22971. "RENDERBUFFER_ALPHA_SIZE",
  22972. "RENDERBUFFER_BINDING",
  22973. "RENDERBUFFER_BLUE_SIZE",
  22974. "RENDERBUFFER_DEPTH_SIZE",
  22975. "RENDERBUFFER_GREEN_SIZE",
  22976. "RENDERBUFFER_HEIGHT",
  22977. "RENDERBUFFER_INTERNAL_FORMAT",
  22978. "RENDERBUFFER_RED_SIZE",
  22979. "RENDERBUFFER_SAMPLES",
  22980. "RENDERBUFFER_STENCIL_SIZE",
  22981. "RENDERBUFFER_WIDTH",
  22982. "RENDERER",
  22983. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  22984. "RENDERING_INTENT_AUTO",
  22985. "RENDERING_INTENT_PERCEPTUAL",
  22986. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  22987. "RENDERING_INTENT_SATURATION",
  22988. "RENDERING_INTENT_UNKNOWN",
  22989. "RENDER_ATTACHMENT",
  22990. "REPEAT",
  22991. "REPLACE",
  22992. "RG",
  22993. "RG16F",
  22994. "RG16I",
  22995. "RG16UI",
  22996. "RG32F",
  22997. "RG32I",
  22998. "RG32UI",
  22999. "RG8",
  23000. "RG8I",
  23001. "RG8UI",
  23002. "RG8_SNORM",
  23003. "RGB",
  23004. "RGB10_A2",
  23005. "RGB10_A2UI",
  23006. "RGB16F",
  23007. "RGB16I",
  23008. "RGB16UI",
  23009. "RGB32F",
  23010. "RGB32I",
  23011. "RGB32UI",
  23012. "RGB565",
  23013. "RGB5_A1",
  23014. "RGB8",
  23015. "RGB8I",
  23016. "RGB8UI",
  23017. "RGB8_SNORM",
  23018. "RGB9_E5",
  23019. "RGBA",
  23020. "RGBA16F",
  23021. "RGBA16I",
  23022. "RGBA16UI",
  23023. "RGBA32F",
  23024. "RGBA32I",
  23025. "RGBA32UI",
  23026. "RGBA4",
  23027. "RGBA8",
  23028. "RGBA8I",
  23029. "RGBA8UI",
  23030. "RGBA8_SNORM",
  23031. "RGBA_INTEGER",
  23032. "RGBColor",
  23033. "RGB_INTEGER",
  23034. "RG_INTEGER",
  23035. "ROTATION_CLOCKWISE",
  23036. "ROTATION_COUNTERCLOCKWISE",
  23037. "RTCCertificate",
  23038. "RTCDTMFSender",
  23039. "RTCDTMFToneChangeEvent",
  23040. "RTCDataChannel",
  23041. "RTCDataChannelEvent",
  23042. "RTCDtlsTransport",
  23043. "RTCEncodedAudioFrame",
  23044. "RTCEncodedVideoFrame",
  23045. "RTCError",
  23046. "RTCErrorEvent",
  23047. "RTCIceCandidate",
  23048. "RTCIceTransport",
  23049. "RTCPeerConnection",
  23050. "RTCPeerConnectionIceErrorEvent",
  23051. "RTCPeerConnectionIceEvent",
  23052. "RTCRtpReceiver",
  23053. "RTCRtpScriptTransform",
  23054. "RTCRtpSender",
  23055. "RTCRtpTransceiver",
  23056. "RTCSctpTransport",
  23057. "RTCSessionDescription",
  23058. "RTCStatsReport",
  23059. "RTCTrackEvent",
  23060. "RadioNodeList",
  23061. "Range",
  23062. "RangeError",
  23063. "RangeException",
  23064. "ReadableByteStreamController",
  23065. "ReadableStream",
  23066. "ReadableStreamBYOBReader",
  23067. "ReadableStreamBYOBRequest",
  23068. "ReadableStreamDefaultController",
  23069. "ReadableStreamDefaultReader",
  23070. "RecordErrorEvent",
  23071. "Rect",
  23072. "ReferenceError",
  23073. "Reflect",
  23074. "RegExp",
  23075. "RelativeOrientationSensor",
  23076. "RelativeTimeFormat",
  23077. "RemotePlayback",
  23078. "Report",
  23079. "ReportBody",
  23080. "ReportingObserver",
  23081. "Request",
  23082. "RequestUpdateCheckStatus",
  23083. "ResizeObserver",
  23084. "ResizeObserverEntry",
  23085. "ResizeObserverSize",
  23086. "Response",
  23087. "RuntimeError",
  23088. "SAMPLER_2D",
  23089. "SAMPLER_2D_ARRAY",
  23090. "SAMPLER_2D_ARRAY_SHADOW",
  23091. "SAMPLER_2D_SHADOW",
  23092. "SAMPLER_3D",
  23093. "SAMPLER_BINDING",
  23094. "SAMPLER_CUBE",
  23095. "SAMPLER_CUBE_SHADOW",
  23096. "SAMPLES",
  23097. "SAMPLE_ALPHA_TO_COVERAGE",
  23098. "SAMPLE_BUFFERS",
  23099. "SAMPLE_COVERAGE",
  23100. "SAMPLE_COVERAGE_INVERT",
  23101. "SAMPLE_COVERAGE_VALUE",
  23102. "SAWTOOTH",
  23103. "SCHEDULED_STATE",
  23104. "SCISSOR_BOX",
  23105. "SCISSOR_TEST",
  23106. "SCROLL_PAGE_DOWN",
  23107. "SCROLL_PAGE_UP",
  23108. "SDP_ANSWER",
  23109. "SDP_OFFER",
  23110. "SDP_PRANSWER",
  23111. "SECURITY_ERR",
  23112. "SELECT",
  23113. "SEPARATE_ATTRIBS",
  23114. "SERIALIZE_ERR",
  23115. "SEVERITY_ERROR",
  23116. "SEVERITY_FATAL_ERROR",
  23117. "SEVERITY_WARNING",
  23118. "SHADER_COMPILER",
  23119. "SHADER_TYPE",
  23120. "SHADING_LANGUAGE_VERSION",
  23121. "SHIFT_MASK",
  23122. "SHORT",
  23123. "SHOWING",
  23124. "SHOW_ALL",
  23125. "SHOW_ATTRIBUTE",
  23126. "SHOW_CDATA_SECTION",
  23127. "SHOW_COMMENT",
  23128. "SHOW_DOCUMENT",
  23129. "SHOW_DOCUMENT_FRAGMENT",
  23130. "SHOW_DOCUMENT_TYPE",
  23131. "SHOW_ELEMENT",
  23132. "SHOW_ENTITY",
  23133. "SHOW_ENTITY_REFERENCE",
  23134. "SHOW_NOTATION",
  23135. "SHOW_PROCESSING_INSTRUCTION",
  23136. "SHOW_TEXT",
  23137. "SIGNALED",
  23138. "SIGNED_NORMALIZED",
  23139. "SINE",
  23140. "SOUNDFIELD",
  23141. "SQLException",
  23142. "SQRT1_2",
  23143. "SQRT2",
  23144. "SQUARE",
  23145. "SRC_ALPHA",
  23146. "SRC_ALPHA_SATURATE",
  23147. "SRC_COLOR",
  23148. "SRGB",
  23149. "SRGB8",
  23150. "SRGB8_ALPHA8",
  23151. "START_TO_END",
  23152. "START_TO_START",
  23153. "STATIC_COPY",
  23154. "STATIC_DRAW",
  23155. "STATIC_READ",
  23156. "STENCIL",
  23157. "STENCIL_ATTACHMENT",
  23158. "STENCIL_BACK_FAIL",
  23159. "STENCIL_BACK_FUNC",
  23160. "STENCIL_BACK_PASS_DEPTH_FAIL",
  23161. "STENCIL_BACK_PASS_DEPTH_PASS",
  23162. "STENCIL_BACK_REF",
  23163. "STENCIL_BACK_VALUE_MASK",
  23164. "STENCIL_BACK_WRITEMASK",
  23165. "STENCIL_BITS",
  23166. "STENCIL_BUFFER_BIT",
  23167. "STENCIL_CLEAR_VALUE",
  23168. "STENCIL_FAIL",
  23169. "STENCIL_FUNC",
  23170. "STENCIL_INDEX",
  23171. "STENCIL_INDEX8",
  23172. "STENCIL_PASS_DEPTH_FAIL",
  23173. "STENCIL_PASS_DEPTH_PASS",
  23174. "STENCIL_REF",
  23175. "STENCIL_TEST",
  23176. "STENCIL_VALUE_MASK",
  23177. "STENCIL_WRITEMASK",
  23178. "STORAGE",
  23179. "STORAGE_BINDING",
  23180. "STREAM_COPY",
  23181. "STREAM_DRAW",
  23182. "STREAM_READ",
  23183. "STRING_TYPE",
  23184. "STYLE_RULE",
  23185. "SUBPIXEL_BITS",
  23186. "SUPPORTS_RULE",
  23187. "SVGAElement",
  23188. "SVGAltGlyphDefElement",
  23189. "SVGAltGlyphElement",
  23190. "SVGAltGlyphItemElement",
  23191. "SVGAngle",
  23192. "SVGAnimateColorElement",
  23193. "SVGAnimateElement",
  23194. "SVGAnimateMotionElement",
  23195. "SVGAnimateTransformElement",
  23196. "SVGAnimatedAngle",
  23197. "SVGAnimatedBoolean",
  23198. "SVGAnimatedEnumeration",
  23199. "SVGAnimatedInteger",
  23200. "SVGAnimatedLength",
  23201. "SVGAnimatedLengthList",
  23202. "SVGAnimatedNumber",
  23203. "SVGAnimatedNumberList",
  23204. "SVGAnimatedPreserveAspectRatio",
  23205. "SVGAnimatedRect",
  23206. "SVGAnimatedString",
  23207. "SVGAnimatedTransformList",
  23208. "SVGAnimationElement",
  23209. "SVGCircleElement",
  23210. "SVGClipPathElement",
  23211. "SVGColor",
  23212. "SVGComponentTransferFunctionElement",
  23213. "SVGCursorElement",
  23214. "SVGDefsElement",
  23215. "SVGDescElement",
  23216. "SVGDiscardElement",
  23217. "SVGDocument",
  23218. "SVGElement",
  23219. "SVGElementInstance",
  23220. "SVGElementInstanceList",
  23221. "SVGEllipseElement",
  23222. "SVGException",
  23223. "SVGFEBlendElement",
  23224. "SVGFEColorMatrixElement",
  23225. "SVGFEComponentTransferElement",
  23226. "SVGFECompositeElement",
  23227. "SVGFEConvolveMatrixElement",
  23228. "SVGFEDiffuseLightingElement",
  23229. "SVGFEDisplacementMapElement",
  23230. "SVGFEDistantLightElement",
  23231. "SVGFEDropShadowElement",
  23232. "SVGFEFloodElement",
  23233. "SVGFEFuncAElement",
  23234. "SVGFEFuncBElement",
  23235. "SVGFEFuncGElement",
  23236. "SVGFEFuncRElement",
  23237. "SVGFEGaussianBlurElement",
  23238. "SVGFEImageElement",
  23239. "SVGFEMergeElement",
  23240. "SVGFEMergeNodeElement",
  23241. "SVGFEMorphologyElement",
  23242. "SVGFEOffsetElement",
  23243. "SVGFEPointLightElement",
  23244. "SVGFESpecularLightingElement",
  23245. "SVGFESpotLightElement",
  23246. "SVGFETileElement",
  23247. "SVGFETurbulenceElement",
  23248. "SVGFilterElement",
  23249. "SVGFontElement",
  23250. "SVGFontFaceElement",
  23251. "SVGFontFaceFormatElement",
  23252. "SVGFontFaceNameElement",
  23253. "SVGFontFaceSrcElement",
  23254. "SVGFontFaceUriElement",
  23255. "SVGForeignObjectElement",
  23256. "SVGGElement",
  23257. "SVGGeometryElement",
  23258. "SVGGlyphElement",
  23259. "SVGGlyphRefElement",
  23260. "SVGGradientElement",
  23261. "SVGGraphicsElement",
  23262. "SVGHKernElement",
  23263. "SVGImageElement",
  23264. "SVGLength",
  23265. "SVGLengthList",
  23266. "SVGLineElement",
  23267. "SVGLinearGradientElement",
  23268. "SVGMPathElement",
  23269. "SVGMarkerElement",
  23270. "SVGMaskElement",
  23271. "SVGMatrix",
  23272. "SVGMetadataElement",
  23273. "SVGMissingGlyphElement",
  23274. "SVGNumber",
  23275. "SVGNumberList",
  23276. "SVGPaint",
  23277. "SVGPathElement",
  23278. "SVGPathSeg",
  23279. "SVGPathSegArcAbs",
  23280. "SVGPathSegArcRel",
  23281. "SVGPathSegClosePath",
  23282. "SVGPathSegCurvetoCubicAbs",
  23283. "SVGPathSegCurvetoCubicRel",
  23284. "SVGPathSegCurvetoCubicSmoothAbs",
  23285. "SVGPathSegCurvetoCubicSmoothRel",
  23286. "SVGPathSegCurvetoQuadraticAbs",
  23287. "SVGPathSegCurvetoQuadraticRel",
  23288. "SVGPathSegCurvetoQuadraticSmoothAbs",
  23289. "SVGPathSegCurvetoQuadraticSmoothRel",
  23290. "SVGPathSegLinetoAbs",
  23291. "SVGPathSegLinetoHorizontalAbs",
  23292. "SVGPathSegLinetoHorizontalRel",
  23293. "SVGPathSegLinetoRel",
  23294. "SVGPathSegLinetoVerticalAbs",
  23295. "SVGPathSegLinetoVerticalRel",
  23296. "SVGPathSegList",
  23297. "SVGPathSegMovetoAbs",
  23298. "SVGPathSegMovetoRel",
  23299. "SVGPatternElement",
  23300. "SVGPoint",
  23301. "SVGPointList",
  23302. "SVGPolygonElement",
  23303. "SVGPolylineElement",
  23304. "SVGPreserveAspectRatio",
  23305. "SVGRadialGradientElement",
  23306. "SVGRect",
  23307. "SVGRectElement",
  23308. "SVGRenderingIntent",
  23309. "SVGSVGElement",
  23310. "SVGScriptElement",
  23311. "SVGSetElement",
  23312. "SVGStopElement",
  23313. "SVGStringList",
  23314. "SVGStyleElement",
  23315. "SVGSwitchElement",
  23316. "SVGSymbolElement",
  23317. "SVGTRefElement",
  23318. "SVGTSpanElement",
  23319. "SVGTextContentElement",
  23320. "SVGTextElement",
  23321. "SVGTextPathElement",
  23322. "SVGTextPositioningElement",
  23323. "SVGTitleElement",
  23324. "SVGTransform",
  23325. "SVGTransformList",
  23326. "SVGUnitTypes",
  23327. "SVGUseElement",
  23328. "SVGVKernElement",
  23329. "SVGViewElement",
  23330. "SVGViewSpec",
  23331. "SVGZoomAndPan",
  23332. "SVGZoomEvent",
  23333. "SVG_ANGLETYPE_DEG",
  23334. "SVG_ANGLETYPE_GRAD",
  23335. "SVG_ANGLETYPE_RAD",
  23336. "SVG_ANGLETYPE_UNKNOWN",
  23337. "SVG_ANGLETYPE_UNSPECIFIED",
  23338. "SVG_CHANNEL_A",
  23339. "SVG_CHANNEL_B",
  23340. "SVG_CHANNEL_G",
  23341. "SVG_CHANNEL_R",
  23342. "SVG_CHANNEL_UNKNOWN",
  23343. "SVG_COLORTYPE_CURRENTCOLOR",
  23344. "SVG_COLORTYPE_RGBCOLOR",
  23345. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  23346. "SVG_COLORTYPE_UNKNOWN",
  23347. "SVG_EDGEMODE_DUPLICATE",
  23348. "SVG_EDGEMODE_NONE",
  23349. "SVG_EDGEMODE_UNKNOWN",
  23350. "SVG_EDGEMODE_WRAP",
  23351. "SVG_FEBLEND_MODE_COLOR",
  23352. "SVG_FEBLEND_MODE_COLOR_BURN",
  23353. "SVG_FEBLEND_MODE_COLOR_DODGE",
  23354. "SVG_FEBLEND_MODE_DARKEN",
  23355. "SVG_FEBLEND_MODE_DIFFERENCE",
  23356. "SVG_FEBLEND_MODE_EXCLUSION",
  23357. "SVG_FEBLEND_MODE_HARD_LIGHT",
  23358. "SVG_FEBLEND_MODE_HUE",
  23359. "SVG_FEBLEND_MODE_LIGHTEN",
  23360. "SVG_FEBLEND_MODE_LUMINOSITY",
  23361. "SVG_FEBLEND_MODE_MULTIPLY",
  23362. "SVG_FEBLEND_MODE_NORMAL",
  23363. "SVG_FEBLEND_MODE_OVERLAY",
  23364. "SVG_FEBLEND_MODE_SATURATION",
  23365. "SVG_FEBLEND_MODE_SCREEN",
  23366. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  23367. "SVG_FEBLEND_MODE_UNKNOWN",
  23368. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  23369. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  23370. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  23371. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  23372. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  23373. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  23374. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  23375. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  23376. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  23377. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  23378. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  23379. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  23380. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  23381. "SVG_FECOMPOSITE_OPERATOR_IN",
  23382. "SVG_FECOMPOSITE_OPERATOR_LIGHTER",
  23383. "SVG_FECOMPOSITE_OPERATOR_OUT",
  23384. "SVG_FECOMPOSITE_OPERATOR_OVER",
  23385. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  23386. "SVG_FECOMPOSITE_OPERATOR_XOR",
  23387. "SVG_INVALID_VALUE_ERR",
  23388. "SVG_LENGTHTYPE_CM",
  23389. "SVG_LENGTHTYPE_EMS",
  23390. "SVG_LENGTHTYPE_EXS",
  23391. "SVG_LENGTHTYPE_IN",
  23392. "SVG_LENGTHTYPE_MM",
  23393. "SVG_LENGTHTYPE_NUMBER",
  23394. "SVG_LENGTHTYPE_PC",
  23395. "SVG_LENGTHTYPE_PERCENTAGE",
  23396. "SVG_LENGTHTYPE_PT",
  23397. "SVG_LENGTHTYPE_PX",
  23398. "SVG_LENGTHTYPE_UNKNOWN",
  23399. "SVG_MARKERUNITS_STROKEWIDTH",
  23400. "SVG_MARKERUNITS_UNKNOWN",
  23401. "SVG_MARKERUNITS_USERSPACEONUSE",
  23402. "SVG_MARKER_ORIENT_ANGLE",
  23403. "SVG_MARKER_ORIENT_AUTO",
  23404. "SVG_MARKER_ORIENT_AUTO_START_REVERSE",
  23405. "SVG_MARKER_ORIENT_UNKNOWN",
  23406. "SVG_MASKTYPE_ALPHA",
  23407. "SVG_MASKTYPE_LUMINANCE",
  23408. "SVG_MATRIX_NOT_INVERTABLE",
  23409. "SVG_MEETORSLICE_MEET",
  23410. "SVG_MEETORSLICE_SLICE",
  23411. "SVG_MEETORSLICE_UNKNOWN",
  23412. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  23413. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  23414. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  23415. "SVG_PAINTTYPE_CURRENTCOLOR",
  23416. "SVG_PAINTTYPE_NONE",
  23417. "SVG_PAINTTYPE_RGBCOLOR",
  23418. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  23419. "SVG_PAINTTYPE_UNKNOWN",
  23420. "SVG_PAINTTYPE_URI",
  23421. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  23422. "SVG_PAINTTYPE_URI_NONE",
  23423. "SVG_PAINTTYPE_URI_RGBCOLOR",
  23424. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  23425. "SVG_PRESERVEASPECTRATIO_NONE",
  23426. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  23427. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  23428. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  23429. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  23430. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  23431. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  23432. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  23433. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  23434. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  23435. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  23436. "SVG_SPREADMETHOD_PAD",
  23437. "SVG_SPREADMETHOD_REFLECT",
  23438. "SVG_SPREADMETHOD_REPEAT",
  23439. "SVG_SPREADMETHOD_UNKNOWN",
  23440. "SVG_STITCHTYPE_NOSTITCH",
  23441. "SVG_STITCHTYPE_STITCH",
  23442. "SVG_STITCHTYPE_UNKNOWN",
  23443. "SVG_TRANSFORM_MATRIX",
  23444. "SVG_TRANSFORM_ROTATE",
  23445. "SVG_TRANSFORM_SCALE",
  23446. "SVG_TRANSFORM_SKEWX",
  23447. "SVG_TRANSFORM_SKEWY",
  23448. "SVG_TRANSFORM_TRANSLATE",
  23449. "SVG_TRANSFORM_UNKNOWN",
  23450. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  23451. "SVG_TURBULENCE_TYPE_TURBULENCE",
  23452. "SVG_TURBULENCE_TYPE_UNKNOWN",
  23453. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  23454. "SVG_UNIT_TYPE_UNKNOWN",
  23455. "SVG_UNIT_TYPE_USERSPACEONUSE",
  23456. "SVG_WRONG_TYPE_ERR",
  23457. "SVG_ZOOMANDPAN_DISABLE",
  23458. "SVG_ZOOMANDPAN_MAGNIFY",
  23459. "SVG_ZOOMANDPAN_UNKNOWN",
  23460. "SYNC_CONDITION",
  23461. "SYNC_FENCE",
  23462. "SYNC_FLAGS",
  23463. "SYNC_FLUSH_COMMANDS_BIT",
  23464. "SYNC_GPU_COMMANDS_COMPLETE",
  23465. "SYNC_STATUS",
  23466. "SYNTAX_ERR",
  23467. "SavedPages",
  23468. "Scheduler",
  23469. "Scheduling",
  23470. "Screen",
  23471. "ScreenDetailed",
  23472. "ScreenDetails",
  23473. "ScreenOrientation",
  23474. "Script",
  23475. "ScriptProcessorNode",
  23476. "ScrollAreaEvent",
  23477. "ScrollTimeline",
  23478. "SecurityPolicyViolationEvent",
  23479. "Segmenter",
  23480. "Selection",
  23481. "Sensor",
  23482. "SensorErrorEvent",
  23483. "Serial",
  23484. "SerialPort",
  23485. "ServiceWorker",
  23486. "ServiceWorkerContainer",
  23487. "ServiceWorkerRegistration",
  23488. "SessionDescription",
  23489. "Set",
  23490. "ShadowRoot",
  23491. "SharedArrayBuffer",
  23492. "SharedStorage",
  23493. "SharedStorageWorklet",
  23494. "SharedWorker",
  23495. "SharingState",
  23496. "SimpleGestureEvent",
  23497. "SnapEvent",
  23498. "SourceBuffer",
  23499. "SourceBufferList",
  23500. "SpeechSynthesis",
  23501. "SpeechSynthesisErrorEvent",
  23502. "SpeechSynthesisEvent",
  23503. "SpeechSynthesisUtterance",
  23504. "SpeechSynthesisVoice",
  23505. "StaticRange",
  23506. "StereoPannerNode",
  23507. "StopIteration",
  23508. "Storage",
  23509. "StorageBucket",
  23510. "StorageBucketManager",
  23511. "StorageEvent",
  23512. "StorageManager",
  23513. "String",
  23514. "StructType",
  23515. "StylePropertyMap",
  23516. "StylePropertyMapReadOnly",
  23517. "StyleSheet",
  23518. "StyleSheetList",
  23519. "SubmitEvent",
  23520. "SubtleCrypto",
  23521. "Symbol",
  23522. "SyncManager",
  23523. "SyntaxError",
  23524. "TAB_ID_NONE",
  23525. "TAB_INDEX_NONE",
  23526. "TEMPORARY",
  23527. "TEXTPATH_METHODTYPE_ALIGN",
  23528. "TEXTPATH_METHODTYPE_STRETCH",
  23529. "TEXTPATH_METHODTYPE_UNKNOWN",
  23530. "TEXTPATH_SPACINGTYPE_AUTO",
  23531. "TEXTPATH_SPACINGTYPE_EXACT",
  23532. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  23533. "TEXTURE",
  23534. "TEXTURE0",
  23535. "TEXTURE1",
  23536. "TEXTURE10",
  23537. "TEXTURE11",
  23538. "TEXTURE12",
  23539. "TEXTURE13",
  23540. "TEXTURE14",
  23541. "TEXTURE15",
  23542. "TEXTURE16",
  23543. "TEXTURE17",
  23544. "TEXTURE18",
  23545. "TEXTURE19",
  23546. "TEXTURE2",
  23547. "TEXTURE20",
  23548. "TEXTURE21",
  23549. "TEXTURE22",
  23550. "TEXTURE23",
  23551. "TEXTURE24",
  23552. "TEXTURE25",
  23553. "TEXTURE26",
  23554. "TEXTURE27",
  23555. "TEXTURE28",
  23556. "TEXTURE29",
  23557. "TEXTURE3",
  23558. "TEXTURE30",
  23559. "TEXTURE31",
  23560. "TEXTURE4",
  23561. "TEXTURE5",
  23562. "TEXTURE6",
  23563. "TEXTURE7",
  23564. "TEXTURE8",
  23565. "TEXTURE9",
  23566. "TEXTURE_2D",
  23567. "TEXTURE_2D_ARRAY",
  23568. "TEXTURE_3D",
  23569. "TEXTURE_BASE_LEVEL",
  23570. "TEXTURE_BINDING",
  23571. "TEXTURE_BINDING_2D",
  23572. "TEXTURE_BINDING_2D_ARRAY",
  23573. "TEXTURE_BINDING_3D",
  23574. "TEXTURE_BINDING_CUBE_MAP",
  23575. "TEXTURE_COMPARE_FUNC",
  23576. "TEXTURE_COMPARE_MODE",
  23577. "TEXTURE_CUBE_MAP",
  23578. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  23579. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  23580. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  23581. "TEXTURE_CUBE_MAP_POSITIVE_X",
  23582. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  23583. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  23584. "TEXTURE_IMMUTABLE_FORMAT",
  23585. "TEXTURE_IMMUTABLE_LEVELS",
  23586. "TEXTURE_MAG_FILTER",
  23587. "TEXTURE_MAX_ANISOTROPY_EXT",
  23588. "TEXTURE_MAX_LEVEL",
  23589. "TEXTURE_MAX_LOD",
  23590. "TEXTURE_MIN_FILTER",
  23591. "TEXTURE_MIN_LOD",
  23592. "TEXTURE_WRAP_R",
  23593. "TEXTURE_WRAP_S",
  23594. "TEXTURE_WRAP_T",
  23595. "TEXT_NODE",
  23596. "TIMEOUT",
  23597. "TIMEOUT_ERR",
  23598. "TIMEOUT_EXPIRED",
  23599. "TIMEOUT_IGNORED",
  23600. "TOO_LARGE_ERR",
  23601. "TRANSACTION_INACTIVE_ERR",
  23602. "TRANSFORM_FEEDBACK",
  23603. "TRANSFORM_FEEDBACK_ACTIVE",
  23604. "TRANSFORM_FEEDBACK_BINDING",
  23605. "TRANSFORM_FEEDBACK_BUFFER",
  23606. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  23607. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  23608. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  23609. "TRANSFORM_FEEDBACK_BUFFER_START",
  23610. "TRANSFORM_FEEDBACK_PAUSED",
  23611. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  23612. "TRANSFORM_FEEDBACK_VARYINGS",
  23613. "TRIANGLE",
  23614. "TRIANGLES",
  23615. "TRIANGLE_FAN",
  23616. "TRIANGLE_STRIP",
  23617. "TYPE_BACK_FORWARD",
  23618. "TYPE_ERR",
  23619. "TYPE_MISMATCH_ERR",
  23620. "TYPE_NAVIGATE",
  23621. "TYPE_RELOAD",
  23622. "TYPE_RESERVED",
  23623. "Tab",
  23624. "TabStatus",
  23625. "Table",
  23626. "Tag",
  23627. "TaskAttributionTiming",
  23628. "TaskController",
  23629. "TaskPriorityChangeEvent",
  23630. "TaskSignal",
  23631. "Text",
  23632. "TextDecoder",
  23633. "TextDecoderStream",
  23634. "TextEncoder",
  23635. "TextEncoderStream",
  23636. "TextEvent",
  23637. "TextFormat",
  23638. "TextFormatUpdateEvent",
  23639. "TextMetrics",
  23640. "TextTrack",
  23641. "TextTrackCue",
  23642. "TextTrackCueList",
  23643. "TextTrackList",
  23644. "TextUpdateEvent",
  23645. "TimeEvent",
  23646. "TimeRanges",
  23647. "ToggleEvent",
  23648. "Touch",
  23649. "TouchEvent",
  23650. "TouchList",
  23651. "TrackEvent",
  23652. "TransformStream",
  23653. "TransformStreamDefaultController",
  23654. "TransitionEvent",
  23655. "TreeWalker",
  23656. "TrustedHTML",
  23657. "TrustedScript",
  23658. "TrustedScriptURL",
  23659. "TrustedTypePolicy",
  23660. "TrustedTypePolicyFactory",
  23661. "TypeError",
  23662. "TypedObject",
  23663. "U2F",
  23664. "UIEvent",
  23665. "UNCACHED",
  23666. "UNIFORM",
  23667. "UNIFORM_ARRAY_STRIDE",
  23668. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  23669. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  23670. "UNIFORM_BLOCK_BINDING",
  23671. "UNIFORM_BLOCK_DATA_SIZE",
  23672. "UNIFORM_BLOCK_INDEX",
  23673. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  23674. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  23675. "UNIFORM_BUFFER",
  23676. "UNIFORM_BUFFER_BINDING",
  23677. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  23678. "UNIFORM_BUFFER_SIZE",
  23679. "UNIFORM_BUFFER_START",
  23680. "UNIFORM_IS_ROW_MAJOR",
  23681. "UNIFORM_MATRIX_STRIDE",
  23682. "UNIFORM_OFFSET",
  23683. "UNIFORM_SIZE",
  23684. "UNIFORM_TYPE",
  23685. "UNKNOWN_ERR",
  23686. "UNKNOWN_RULE",
  23687. "UNMASKED_RENDERER_WEBGL",
  23688. "UNMASKED_VENDOR_WEBGL",
  23689. "UNORDERED_NODE_ITERATOR_TYPE",
  23690. "UNORDERED_NODE_SNAPSHOT_TYPE",
  23691. "UNPACK_ALIGNMENT",
  23692. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  23693. "UNPACK_FLIP_Y_WEBGL",
  23694. "UNPACK_IMAGE_HEIGHT",
  23695. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  23696. "UNPACK_ROW_LENGTH",
  23697. "UNPACK_SKIP_IMAGES",
  23698. "UNPACK_SKIP_PIXELS",
  23699. "UNPACK_SKIP_ROWS",
  23700. "UNSCHEDULED_STATE",
  23701. "UNSENT",
  23702. "UNSIGNALED",
  23703. "UNSIGNED_BYTE",
  23704. "UNSIGNED_INT",
  23705. "UNSIGNED_INT_10F_11F_11F_REV",
  23706. "UNSIGNED_INT_24_8",
  23707. "UNSIGNED_INT_2_10_10_10_REV",
  23708. "UNSIGNED_INT_5_9_9_9_REV",
  23709. "UNSIGNED_INT_SAMPLER_2D",
  23710. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  23711. "UNSIGNED_INT_SAMPLER_3D",
  23712. "UNSIGNED_INT_SAMPLER_CUBE",
  23713. "UNSIGNED_INT_VEC2",
  23714. "UNSIGNED_INT_VEC3",
  23715. "UNSIGNED_INT_VEC4",
  23716. "UNSIGNED_NORMALIZED",
  23717. "UNSIGNED_SHORT",
  23718. "UNSIGNED_SHORT_4_4_4_4",
  23719. "UNSIGNED_SHORT_5_5_5_1",
  23720. "UNSIGNED_SHORT_5_6_5",
  23721. "UNSPECIFIED_EVENT_TYPE_ERR",
  23722. "UPDATEREADY",
  23723. "URIError",
  23724. "URL",
  23725. "URLPattern",
  23726. "URLSearchParams",
  23727. "URLUnencoded",
  23728. "URL_MISMATCH_ERR",
  23729. "USB",
  23730. "USBAlternateInterface",
  23731. "USBConfiguration",
  23732. "USBConnectionEvent",
  23733. "USBDevice",
  23734. "USBEndpoint",
  23735. "USBInTransferResult",
  23736. "USBInterface",
  23737. "USBIsochronousInTransferPacket",
  23738. "USBIsochronousInTransferResult",
  23739. "USBIsochronousOutTransferPacket",
  23740. "USBIsochronousOutTransferResult",
  23741. "USBOutTransferResult",
  23742. "UTC",
  23743. "Uint16Array",
  23744. "Uint32Array",
  23745. "Uint8Array",
  23746. "Uint8ClampedArray",
  23747. "UpdateFilter",
  23748. "UpdatePropertyName",
  23749. "UserActivation",
  23750. "UserMessageHandler",
  23751. "UserMessageHandlersNamespace",
  23752. "UserProximityEvent",
  23753. "VALIDATE_STATUS",
  23754. "VALIDATION_ERR",
  23755. "VARIABLES_RULE",
  23756. "VENDOR",
  23757. "VERSION",
  23758. "VERSION_CHANGE",
  23759. "VERSION_ERR",
  23760. "VERTEX",
  23761. "VERTEX_ARRAY_BINDING",
  23762. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  23763. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  23764. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  23765. "VERTEX_ATTRIB_ARRAY_ENABLED",
  23766. "VERTEX_ATTRIB_ARRAY_INTEGER",
  23767. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  23768. "VERTEX_ATTRIB_ARRAY_POINTER",
  23769. "VERTEX_ATTRIB_ARRAY_SIZE",
  23770. "VERTEX_ATTRIB_ARRAY_STRIDE",
  23771. "VERTEX_ATTRIB_ARRAY_TYPE",
  23772. "VERTEX_SHADER",
  23773. "VERTICAL",
  23774. "VERTICAL_AXIS",
  23775. "VER_ERR",
  23776. "VIEWPORT",
  23777. "VIEWPORT_RULE",
  23778. "VRDisplay",
  23779. "VRDisplayCapabilities",
  23780. "VRDisplayEvent",
  23781. "VREyeParameters",
  23782. "VRFieldOfView",
  23783. "VRFrameData",
  23784. "VRPose",
  23785. "VRStageParameters",
  23786. "VTTCue",
  23787. "VTTRegion",
  23788. "ValidityState",
  23789. "VideoColorSpace",
  23790. "VideoDecoder",
  23791. "VideoEncoder",
  23792. "VideoFrame",
  23793. "VideoPlaybackQuality",
  23794. "VideoStreamTrack",
  23795. "ViewTimeline",
  23796. "ViewTransition",
  23797. "ViewTransitionTypeSet",
  23798. "ViewType",
  23799. "VirtualKeyboard",
  23800. "VirtualKeyboardGeometryChangeEvent",
  23801. "VisibilityStateEntry",
  23802. "VisualViewport",
  23803. "WAIT_FAILED",
  23804. "WEBKIT_FILTER_RULE",
  23805. "WEBKIT_KEYFRAMES_RULE",
  23806. "WEBKIT_KEYFRAME_RULE",
  23807. "WEBKIT_REGION_RULE",
  23808. "WGSLLanguageFeatures",
  23809. "WINDOW_ID_CURRENT",
  23810. "WINDOW_ID_NONE",
  23811. "WRITE",
  23812. "WRONG_DOCUMENT_ERR",
  23813. "WakeLock",
  23814. "WakeLockSentinel",
  23815. "WasmAnyRef",
  23816. "WaveShaperNode",
  23817. "WeakMap",
  23818. "WeakRef",
  23819. "WeakSet",
  23820. "WebAssembly",
  23821. "WebGL2RenderingContext",
  23822. "WebGLActiveInfo",
  23823. "WebGLBuffer",
  23824. "WebGLContextEvent",
  23825. "WebGLFramebuffer",
  23826. "WebGLObject",
  23827. "WebGLProgram",
  23828. "WebGLQuery",
  23829. "WebGLRenderbuffer",
  23830. "WebGLRenderingContext",
  23831. "WebGLSampler",
  23832. "WebGLShader",
  23833. "WebGLShaderPrecisionFormat",
  23834. "WebGLSync",
  23835. "WebGLTexture",
  23836. "WebGLTransformFeedback",
  23837. "WebGLUniformLocation",
  23838. "WebGLVertexArray",
  23839. "WebGLVertexArrayObject",
  23840. "WebKitAnimationEvent",
  23841. "WebKitBlobBuilder",
  23842. "WebKitCSSFilterRule",
  23843. "WebKitCSSFilterValue",
  23844. "WebKitCSSKeyframeRule",
  23845. "WebKitCSSKeyframesRule",
  23846. "WebKitCSSMatrix",
  23847. "WebKitCSSRegionRule",
  23848. "WebKitCSSTransformValue",
  23849. "WebKitDataCue",
  23850. "WebKitGamepad",
  23851. "WebKitMediaKeyError",
  23852. "WebKitMediaKeyMessageEvent",
  23853. "WebKitMediaKeySession",
  23854. "WebKitMediaKeys",
  23855. "WebKitMediaSource",
  23856. "WebKitMutationObserver",
  23857. "WebKitNamespace",
  23858. "WebKitPlaybackTargetAvailabilityEvent",
  23859. "WebKitPoint",
  23860. "WebKitShadowRoot",
  23861. "WebKitSourceBuffer",
  23862. "WebKitSourceBufferList",
  23863. "WebKitTransitionEvent",
  23864. "WebSocket",
  23865. "WebSocketError",
  23866. "WebSocketStream",
  23867. "WebTransport",
  23868. "WebTransportBidirectionalStream",
  23869. "WebTransportDatagramDuplexStream",
  23870. "WebTransportError",
  23871. "WebTransportReceiveStream",
  23872. "WebTransportSendStream",
  23873. "WebkitAlignContent",
  23874. "WebkitAlignItems",
  23875. "WebkitAlignSelf",
  23876. "WebkitAnimation",
  23877. "WebkitAnimationDelay",
  23878. "WebkitAnimationDirection",
  23879. "WebkitAnimationDuration",
  23880. "WebkitAnimationFillMode",
  23881. "WebkitAnimationIterationCount",
  23882. "WebkitAnimationName",
  23883. "WebkitAnimationPlayState",
  23884. "WebkitAnimationTimingFunction",
  23885. "WebkitAppearance",
  23886. "WebkitBackfaceVisibility",
  23887. "WebkitBackgroundClip",
  23888. "WebkitBackgroundOrigin",
  23889. "WebkitBackgroundSize",
  23890. "WebkitBorderBottomLeftRadius",
  23891. "WebkitBorderBottomRightRadius",
  23892. "WebkitBorderImage",
  23893. "WebkitBorderRadius",
  23894. "WebkitBorderTopLeftRadius",
  23895. "WebkitBorderTopRightRadius",
  23896. "WebkitBoxAlign",
  23897. "WebkitBoxDirection",
  23898. "WebkitBoxFlex",
  23899. "WebkitBoxOrdinalGroup",
  23900. "WebkitBoxOrient",
  23901. "WebkitBoxPack",
  23902. "WebkitBoxShadow",
  23903. "WebkitBoxSizing",
  23904. "WebkitClipPath",
  23905. "WebkitFilter",
  23906. "WebkitFlex",
  23907. "WebkitFlexBasis",
  23908. "WebkitFlexDirection",
  23909. "WebkitFlexFlow",
  23910. "WebkitFlexGrow",
  23911. "WebkitFlexShrink",
  23912. "WebkitFlexWrap",
  23913. "WebkitFontFeatureSettings",
  23914. "WebkitJustifyContent",
  23915. "WebkitLineClamp",
  23916. "WebkitMask",
  23917. "WebkitMaskClip",
  23918. "WebkitMaskComposite",
  23919. "WebkitMaskImage",
  23920. "WebkitMaskOrigin",
  23921. "WebkitMaskPosition",
  23922. "WebkitMaskPositionX",
  23923. "WebkitMaskPositionY",
  23924. "WebkitMaskRepeat",
  23925. "WebkitMaskSize",
  23926. "WebkitOrder",
  23927. "WebkitPerspective",
  23928. "WebkitPerspectiveOrigin",
  23929. "WebkitTextFillColor",
  23930. "WebkitTextSecurity",
  23931. "WebkitTextSizeAdjust",
  23932. "WebkitTextStroke",
  23933. "WebkitTextStrokeColor",
  23934. "WebkitTextStrokeWidth",
  23935. "WebkitTransform",
  23936. "WebkitTransformOrigin",
  23937. "WebkitTransformStyle",
  23938. "WebkitTransition",
  23939. "WebkitTransitionDelay",
  23940. "WebkitTransitionDuration",
  23941. "WebkitTransitionProperty",
  23942. "WebkitTransitionTimingFunction",
  23943. "WebkitUserSelect",
  23944. "WheelEvent",
  23945. "Window",
  23946. "WindowControlsOverlay",
  23947. "WindowControlsOverlayGeometryChangeEvent",
  23948. "WindowState",
  23949. "WindowType",
  23950. "Worker",
  23951. "Worklet",
  23952. "WritableStream",
  23953. "WritableStreamDefaultController",
  23954. "WritableStreamDefaultWriter",
  23955. "XMLDocument",
  23956. "XMLHttpRequest",
  23957. "XMLHttpRequestEventTarget",
  23958. "XMLHttpRequestException",
  23959. "XMLHttpRequestProgressEvent",
  23960. "XMLHttpRequestUpload",
  23961. "XMLSerializer",
  23962. "XMLStylesheetProcessingInstruction",
  23963. "XPathEvaluator",
  23964. "XPathException",
  23965. "XPathExpression",
  23966. "XPathNSResolver",
  23967. "XPathResult",
  23968. "XRAnchor",
  23969. "XRAnchorSet",
  23970. "XRBoundedReferenceSpace",
  23971. "XRCPUDepthInformation",
  23972. "XRCamera",
  23973. "XRDOMOverlayState",
  23974. "XRDepthInformation",
  23975. "XRFrame",
  23976. "XRHand",
  23977. "XRHitTestResult",
  23978. "XRHitTestSource",
  23979. "XRInputSource",
  23980. "XRInputSourceArray",
  23981. "XRInputSourceEvent",
  23982. "XRInputSourcesChangeEvent",
  23983. "XRJointPose",
  23984. "XRJointSpace",
  23985. "XRLayer",
  23986. "XRLightEstimate",
  23987. "XRLightProbe",
  23988. "XRPose",
  23989. "XRRay",
  23990. "XRReferenceSpace",
  23991. "XRReferenceSpaceEvent",
  23992. "XRRenderState",
  23993. "XRRigidTransform",
  23994. "XRSession",
  23995. "XRSessionEvent",
  23996. "XRSpace",
  23997. "XRSystem",
  23998. "XRTransientInputHitTestResult",
  23999. "XRTransientInputHitTestSource",
  24000. "XRView",
  24001. "XRViewerPose",
  24002. "XRViewport",
  24003. "XRWebGLBinding",
  24004. "XRWebGLDepthInformation",
  24005. "XRWebGLLayer",
  24006. "XSLTProcessor",
  24007. "ZERO",
  24008. "ZoomSettings",
  24009. "ZoomSettingsMode",
  24010. "ZoomSettingsScope",
  24011. "_XD0M_",
  24012. "_YD0M_",
  24013. "__REACT_DEVTOOLS_GLOBAL_HOOK__",
  24014. "__brand",
  24015. "__defineGetter__",
  24016. "__defineSetter__",
  24017. "__lookupGetter__",
  24018. "__lookupSetter__",
  24019. "__opera",
  24020. "__proto__",
  24021. "_browserjsran",
  24022. "a",
  24023. "aLink",
  24024. "abbr",
  24025. "abort",
  24026. "aborted",
  24027. "aboutConfigPrefs",
  24028. "abs",
  24029. "absolute",
  24030. "acceleration",
  24031. "accelerationIncludingGravity",
  24032. "accelerator",
  24033. "accent-color",
  24034. "accentColor",
  24035. "accept",
  24036. "acceptCharset",
  24037. "acceptNode",
  24038. "access",
  24039. "accessKey",
  24040. "accessKeyLabel",
  24041. "accuracy",
  24042. "acos",
  24043. "acosh",
  24044. "action",
  24045. "actionURL",
  24046. "actions",
  24047. "activated",
  24048. "activation",
  24049. "activationStart",
  24050. "active",
  24051. "activeCues",
  24052. "activeElement",
  24053. "activeSourceBuffers",
  24054. "activeSourceCount",
  24055. "activeTexture",
  24056. "activeVRDisplays",
  24057. "activityLog",
  24058. "actualBoundingBoxAscent",
  24059. "actualBoundingBoxDescent",
  24060. "actualBoundingBoxLeft",
  24061. "actualBoundingBoxRight",
  24062. "adAuctionComponents",
  24063. "adAuctionHeaders",
  24064. "add",
  24065. "addAll",
  24066. "addBehavior",
  24067. "addCandidate",
  24068. "addColorStop",
  24069. "addCue",
  24070. "addElement",
  24071. "addEventListener",
  24072. "addFilter",
  24073. "addFromString",
  24074. "addFromUri",
  24075. "addIceCandidate",
  24076. "addImport",
  24077. "addListener",
  24078. "addModule",
  24079. "addNamed",
  24080. "addPageRule",
  24081. "addPath",
  24082. "addPointer",
  24083. "addRange",
  24084. "addRegion",
  24085. "addRule",
  24086. "addSearchEngine",
  24087. "addSourceBuffer",
  24088. "addStream",
  24089. "addTextTrack",
  24090. "addTrack",
  24091. "addTransceiver",
  24092. "addWakeLockListener",
  24093. "added",
  24094. "addedNodes",
  24095. "additionalName",
  24096. "additiveSymbols",
  24097. "addons",
  24098. "address",
  24099. "addressLine",
  24100. "addressModeU",
  24101. "addressModeV",
  24102. "addressModeW",
  24103. "adoptNode",
  24104. "adoptedCallback",
  24105. "adoptedStyleSheets",
  24106. "adr",
  24107. "advance",
  24108. "after",
  24109. "alarms",
  24110. "album",
  24111. "alert",
  24112. "algorithm",
  24113. "align",
  24114. "align-content",
  24115. "align-items",
  24116. "align-self",
  24117. "alignContent",
  24118. "alignItems",
  24119. "alignSelf",
  24120. "alignmentBaseline",
  24121. "alinkColor",
  24122. "all",
  24123. "allSettled",
  24124. "allocationSize",
  24125. "allow",
  24126. "allowFullscreen",
  24127. "allowPaymentRequest",
  24128. "allowedDirections",
  24129. "allowedFeatures",
  24130. "allowedToPlay",
  24131. "allowsFeature",
  24132. "alpha",
  24133. "alphaMode",
  24134. "alphaToCoverageEnabled",
  24135. "alphabeticBaseline",
  24136. "alt",
  24137. "altGraphKey",
  24138. "altHtml",
  24139. "altKey",
  24140. "altLeft",
  24141. "alternate",
  24142. "alternateSetting",
  24143. "alternates",
  24144. "altitude",
  24145. "altitudeAccuracy",
  24146. "altitudeAngle",
  24147. "amplitude",
  24148. "ancestorOrigins",
  24149. "anchor",
  24150. "anchorNode",
  24151. "anchorOffset",
  24152. "anchorSpace",
  24153. "anchors",
  24154. "and",
  24155. "angle",
  24156. "angularAcceleration",
  24157. "angularVelocity",
  24158. "animVal",
  24159. "animate",
  24160. "animated",
  24161. "animatedInstanceRoot",
  24162. "animatedNormalizedPathSegList",
  24163. "animatedPathSegList",
  24164. "animatedPoints",
  24165. "animation",
  24166. "animation-composition",
  24167. "animation-delay",
  24168. "animation-direction",
  24169. "animation-duration",
  24170. "animation-fill-mode",
  24171. "animation-iteration-count",
  24172. "animation-name",
  24173. "animation-play-state",
  24174. "animation-timing-function",
  24175. "animationComposition",
  24176. "animationDelay",
  24177. "animationDirection",
  24178. "animationDuration",
  24179. "animationFillMode",
  24180. "animationIterationCount",
  24181. "animationName",
  24182. "animationPlayState",
  24183. "animationStartTime",
  24184. "animationTimingFunction",
  24185. "animationsPaused",
  24186. "anniversary",
  24187. "antialias",
  24188. "anticipatedRemoval",
  24189. "any",
  24190. "app",
  24191. "appCodeName",
  24192. "appMinorVersion",
  24193. "appName",
  24194. "appNotifications",
  24195. "appVersion",
  24196. "appearance",
  24197. "append",
  24198. "appendBuffer",
  24199. "appendChild",
  24200. "appendData",
  24201. "appendItem",
  24202. "appendMedium",
  24203. "appendNamed",
  24204. "appendRule",
  24205. "appendStream",
  24206. "appendWindowEnd",
  24207. "appendWindowStart",
  24208. "applets",
  24209. "applicationCache",
  24210. "applicationServerKey",
  24211. "apply",
  24212. "applyConstraints",
  24213. "applyElement",
  24214. "arc",
  24215. "arcTo",
  24216. "arch",
  24217. "architecture",
  24218. "archive",
  24219. "areas",
  24220. "arguments",
  24221. "ariaAtomic",
  24222. "ariaAutoComplete",
  24223. "ariaBrailleLabel",
  24224. "ariaBrailleRoleDescription",
  24225. "ariaBusy",
  24226. "ariaChecked",
  24227. "ariaColCount",
  24228. "ariaColIndex",
  24229. "ariaColIndexText",
  24230. "ariaColSpan",
  24231. "ariaCurrent",
  24232. "ariaDescription",
  24233. "ariaDisabled",
  24234. "ariaExpanded",
  24235. "ariaHasPopup",
  24236. "ariaHidden",
  24237. "ariaInvalid",
  24238. "ariaKeyShortcuts",
  24239. "ariaLabel",
  24240. "ariaLevel",
  24241. "ariaLive",
  24242. "ariaModal",
  24243. "ariaMultiLine",
  24244. "ariaMultiSelectable",
  24245. "ariaOrientation",
  24246. "ariaPlaceholder",
  24247. "ariaPosInSet",
  24248. "ariaPressed",
  24249. "ariaReadOnly",
  24250. "ariaRelevant",
  24251. "ariaRequired",
  24252. "ariaRoleDescription",
  24253. "ariaRowCount",
  24254. "ariaRowIndex",
  24255. "ariaRowIndexText",
  24256. "ariaRowSpan",
  24257. "ariaSelected",
  24258. "ariaSetSize",
  24259. "ariaSort",
  24260. "ariaValueMax",
  24261. "ariaValueMin",
  24262. "ariaValueNow",
  24263. "ariaValueText",
  24264. "arrayBuffer",
  24265. "arrayLayerCount",
  24266. "arrayStride",
  24267. "artist",
  24268. "artwork",
  24269. "as",
  24270. "asIntN",
  24271. "asUintN",
  24272. "ascentOverride",
  24273. "asin",
  24274. "asinh",
  24275. "aspect",
  24276. "aspect-ratio",
  24277. "aspectRatio",
  24278. "assert",
  24279. "assign",
  24280. "assignedElements",
  24281. "assignedNodes",
  24282. "assignedSlot",
  24283. "async",
  24284. "asyncDispose",
  24285. "asyncIterator",
  24286. "at",
  24287. "atEnd",
  24288. "atan",
  24289. "atan2",
  24290. "atanh",
  24291. "atob",
  24292. "attachEvent",
  24293. "attachInternals",
  24294. "attachShader",
  24295. "attachShadow",
  24296. "attachedElements",
  24297. "attachments",
  24298. "attack",
  24299. "attestationObject",
  24300. "attrChange",
  24301. "attrName",
  24302. "attributeChangedCallback",
  24303. "attributeFilter",
  24304. "attributeName",
  24305. "attributeNamespace",
  24306. "attributeOldValue",
  24307. "attributeStyleMap",
  24308. "attributes",
  24309. "attribution",
  24310. "attributionSrc",
  24311. "audioBitrateMode",
  24312. "audioBitsPerSecond",
  24313. "audioTracks",
  24314. "audioWorklet",
  24315. "authenticatedSignedWrites",
  24316. "authenticatorAttachment",
  24317. "authenticatorData",
  24318. "autoIncrement",
  24319. "autobuffer",
  24320. "autocapitalize",
  24321. "autocomplete",
  24322. "autocorrect",
  24323. "autofocus",
  24324. "automationRate",
  24325. "autoplay",
  24326. "availHeight",
  24327. "availLeft",
  24328. "availTop",
  24329. "availWidth",
  24330. "availability",
  24331. "available",
  24332. "averageLatency",
  24333. "aversion",
  24334. "ax",
  24335. "axes",
  24336. "axis",
  24337. "ay",
  24338. "azimuth",
  24339. "azimuthAngle",
  24340. "b",
  24341. "back",
  24342. "backdrop-filter",
  24343. "backdropFilter",
  24344. "backends",
  24345. "backface-visibility",
  24346. "backfaceVisibility",
  24347. "background",
  24348. "background-attachment",
  24349. "background-blend-mode",
  24350. "background-clip",
  24351. "background-color",
  24352. "background-image",
  24353. "background-origin",
  24354. "background-position",
  24355. "background-position-x",
  24356. "background-position-y",
  24357. "background-repeat",
  24358. "background-size",
  24359. "backgroundAttachment",
  24360. "backgroundBlendMode",
  24361. "backgroundClip",
  24362. "backgroundColor",
  24363. "backgroundFetch",
  24364. "backgroundImage",
  24365. "backgroundOrigin",
  24366. "backgroundPosition",
  24367. "backgroundPositionX",
  24368. "backgroundPositionY",
  24369. "backgroundRepeat",
  24370. "backgroundSize",
  24371. "badInput",
  24372. "badge",
  24373. "balance",
  24374. "baseArrayLayer",
  24375. "baseFrequencyX",
  24376. "baseFrequencyY",
  24377. "baseLatency",
  24378. "baseLayer",
  24379. "baseMipLevel",
  24380. "baseNode",
  24381. "baseOffset",
  24382. "basePalette",
  24383. "baseURI",
  24384. "baseVal",
  24385. "baseline-source",
  24386. "baselineShift",
  24387. "baselineSource",
  24388. "battery",
  24389. "bday",
  24390. "before",
  24391. "beginComputePass",
  24392. "beginElement",
  24393. "beginElementAt",
  24394. "beginOcclusionQuery",
  24395. "beginPath",
  24396. "beginQuery",
  24397. "beginRenderPass",
  24398. "beginTransformFeedback",
  24399. "beginningOfPassWriteIndex",
  24400. "behavior",
  24401. "behaviorCookie",
  24402. "behaviorPart",
  24403. "behaviorUrns",
  24404. "beta",
  24405. "bezierCurveTo",
  24406. "bgColor",
  24407. "bgProperties",
  24408. "bias",
  24409. "big",
  24410. "bigint64",
  24411. "biguint64",
  24412. "binaryType",
  24413. "bind",
  24414. "bindAttribLocation",
  24415. "bindBuffer",
  24416. "bindBufferBase",
  24417. "bindBufferRange",
  24418. "bindFramebuffer",
  24419. "bindGroupLayouts",
  24420. "bindRenderbuffer",
  24421. "bindSampler",
  24422. "bindTexture",
  24423. "bindTransformFeedback",
  24424. "bindVertexArray",
  24425. "binding",
  24426. "bitness",
  24427. "blend",
  24428. "blendColor",
  24429. "blendEquation",
  24430. "blendEquationSeparate",
  24431. "blendFunc",
  24432. "blendFuncSeparate",
  24433. "blink",
  24434. "blitFramebuffer",
  24435. "blob",
  24436. "block-size",
  24437. "blockDirection",
  24438. "blockSize",
  24439. "blockedURI",
  24440. "blocking",
  24441. "blockingDuration",
  24442. "blue",
  24443. "bluetooth",
  24444. "blur",
  24445. "body",
  24446. "bodyUsed",
  24447. "bold",
  24448. "bookmarks",
  24449. "booleanValue",
  24450. "border",
  24451. "border-block",
  24452. "border-block-color",
  24453. "border-block-end",
  24454. "border-block-end-color",
  24455. "border-block-end-style",
  24456. "border-block-end-width",
  24457. "border-block-start",
  24458. "border-block-start-color",
  24459. "border-block-start-style",
  24460. "border-block-start-width",
  24461. "border-block-style",
  24462. "border-block-width",
  24463. "border-bottom",
  24464. "border-bottom-color",
  24465. "border-bottom-left-radius",
  24466. "border-bottom-right-radius",
  24467. "border-bottom-style",
  24468. "border-bottom-width",
  24469. "border-collapse",
  24470. "border-color",
  24471. "border-end-end-radius",
  24472. "border-end-start-radius",
  24473. "border-image",
  24474. "border-image-outset",
  24475. "border-image-repeat",
  24476. "border-image-slice",
  24477. "border-image-source",
  24478. "border-image-width",
  24479. "border-inline",
  24480. "border-inline-color",
  24481. "border-inline-end",
  24482. "border-inline-end-color",
  24483. "border-inline-end-style",
  24484. "border-inline-end-width",
  24485. "border-inline-start",
  24486. "border-inline-start-color",
  24487. "border-inline-start-style",
  24488. "border-inline-start-width",
  24489. "border-inline-style",
  24490. "border-inline-width",
  24491. "border-left",
  24492. "border-left-color",
  24493. "border-left-style",
  24494. "border-left-width",
  24495. "border-radius",
  24496. "border-right",
  24497. "border-right-color",
  24498. "border-right-style",
  24499. "border-right-width",
  24500. "border-spacing",
  24501. "border-start-end-radius",
  24502. "border-start-start-radius",
  24503. "border-style",
  24504. "border-top",
  24505. "border-top-color",
  24506. "border-top-left-radius",
  24507. "border-top-right-radius",
  24508. "border-top-style",
  24509. "border-top-width",
  24510. "border-width",
  24511. "borderBlock",
  24512. "borderBlockColor",
  24513. "borderBlockEnd",
  24514. "borderBlockEndColor",
  24515. "borderBlockEndStyle",
  24516. "borderBlockEndWidth",
  24517. "borderBlockStart",
  24518. "borderBlockStartColor",
  24519. "borderBlockStartStyle",
  24520. "borderBlockStartWidth",
  24521. "borderBlockStyle",
  24522. "borderBlockWidth",
  24523. "borderBottom",
  24524. "borderBottomColor",
  24525. "borderBottomLeftRadius",
  24526. "borderBottomRightRadius",
  24527. "borderBottomStyle",
  24528. "borderBottomWidth",
  24529. "borderBoxSize",
  24530. "borderCollapse",
  24531. "borderColor",
  24532. "borderColorDark",
  24533. "borderColorLight",
  24534. "borderEndEndRadius",
  24535. "borderEndStartRadius",
  24536. "borderImage",
  24537. "borderImageOutset",
  24538. "borderImageRepeat",
  24539. "borderImageSlice",
  24540. "borderImageSource",
  24541. "borderImageWidth",
  24542. "borderInline",
  24543. "borderInlineColor",
  24544. "borderInlineEnd",
  24545. "borderInlineEndColor",
  24546. "borderInlineEndStyle",
  24547. "borderInlineEndWidth",
  24548. "borderInlineStart",
  24549. "borderInlineStartColor",
  24550. "borderInlineStartStyle",
  24551. "borderInlineStartWidth",
  24552. "borderInlineStyle",
  24553. "borderInlineWidth",
  24554. "borderLeft",
  24555. "borderLeftColor",
  24556. "borderLeftStyle",
  24557. "borderLeftWidth",
  24558. "borderRadius",
  24559. "borderRight",
  24560. "borderRightColor",
  24561. "borderRightStyle",
  24562. "borderRightWidth",
  24563. "borderSpacing",
  24564. "borderStartEndRadius",
  24565. "borderStartStartRadius",
  24566. "borderStyle",
  24567. "borderTop",
  24568. "borderTopColor",
  24569. "borderTopLeftRadius",
  24570. "borderTopRightRadius",
  24571. "borderTopStyle",
  24572. "borderTopWidth",
  24573. "borderWidth",
  24574. "bottom",
  24575. "bottomMargin",
  24576. "bound",
  24577. "boundElements",
  24578. "boundingClientRect",
  24579. "boundingHeight",
  24580. "boundingLeft",
  24581. "boundingRect",
  24582. "boundingTop",
  24583. "boundingWidth",
  24584. "bounds",
  24585. "boundsGeometry",
  24586. "box-decoration-break",
  24587. "box-shadow",
  24588. "box-sizing",
  24589. "boxDecorationBreak",
  24590. "boxShadow",
  24591. "boxSizing",
  24592. "brand",
  24593. "brands",
  24594. "break-after",
  24595. "break-before",
  24596. "break-inside",
  24597. "breakAfter",
  24598. "breakBefore",
  24599. "breakInside",
  24600. "broadcast",
  24601. "browser",
  24602. "browserLanguage",
  24603. "browserSettings",
  24604. "browsingData",
  24605. "browsingTopics",
  24606. "btoa",
  24607. "bubbles",
  24608. "buffer",
  24609. "bufferData",
  24610. "bufferDepth",
  24611. "bufferSize",
  24612. "bufferSubData",
  24613. "buffered",
  24614. "bufferedAmount",
  24615. "bufferedAmountLowThreshold",
  24616. "buffers",
  24617. "buildID",
  24618. "buildNumber",
  24619. "button",
  24620. "buttonID",
  24621. "buttons",
  24622. "byobRequest",
  24623. "byteLength",
  24624. "byteOffset",
  24625. "bytes",
  24626. "bytesPerRow",
  24627. "bytesWritten",
  24628. "c",
  24629. "cache",
  24630. "caches",
  24631. "call",
  24632. "caller",
  24633. "camera",
  24634. "canBeFormatted",
  24635. "canBeMounted",
  24636. "canBeShared",
  24637. "canConstructInDedicatedWorker",
  24638. "canGoBack",
  24639. "canGoForward",
  24640. "canHaveChildren",
  24641. "canHaveHTML",
  24642. "canInsertDTMF",
  24643. "canIntercept",
  24644. "canLoadAdAuctionFencedFrame",
  24645. "canLoadOpaqueURL",
  24646. "canMakePayment",
  24647. "canParse",
  24648. "canPlayType",
  24649. "canPresent",
  24650. "canShare",
  24651. "canTransition",
  24652. "canTrickleIceCandidates",
  24653. "cancel",
  24654. "cancelAndHoldAtTime",
  24655. "cancelAnimationFrame",
  24656. "cancelBubble",
  24657. "cancelIdleCallback",
  24658. "cancelScheduledValues",
  24659. "cancelVideoFrameCallback",
  24660. "cancelWatchAvailability",
  24661. "cancelable",
  24662. "candidate",
  24663. "canonicalUUID",
  24664. "canvas",
  24665. "cap",
  24666. "capabilities",
  24667. "caption",
  24668. "caption-side",
  24669. "captionSide",
  24670. "captivePortal",
  24671. "capture",
  24672. "captureEvents",
  24673. "captureStackTrace",
  24674. "captureStream",
  24675. "captureTab",
  24676. "captureVisibleTab",
  24677. "caret-color",
  24678. "caretBidiLevel",
  24679. "caretColor",
  24680. "caretPositionFromPoint",
  24681. "caretRangeFromPoint",
  24682. "cast",
  24683. "catch",
  24684. "category",
  24685. "cbrt",
  24686. "cd",
  24687. "ceil",
  24688. "cellIndex",
  24689. "cellPadding",
  24690. "cellSpacing",
  24691. "cells",
  24692. "ch",
  24693. "chOff",
  24694. "chain",
  24695. "challenge",
  24696. "changeType",
  24697. "changed",
  24698. "changedTouches",
  24699. "channel",
  24700. "channelCount",
  24701. "channelCountMode",
  24702. "channelInterpretation",
  24703. "chapterInfo",
  24704. "char",
  24705. "charAt",
  24706. "charCode",
  24707. "charCodeAt",
  24708. "charIndex",
  24709. "charLength",
  24710. "characterBounds",
  24711. "characterBoundsRangeStart",
  24712. "characterData",
  24713. "characterDataOldValue",
  24714. "characterSet",
  24715. "characteristic",
  24716. "charging",
  24717. "chargingTime",
  24718. "charset",
  24719. "check",
  24720. "checkDCE",
  24721. "checkEnclosure",
  24722. "checkFramebufferStatus",
  24723. "checkIntersection",
  24724. "checkValidity",
  24725. "checkVisibility",
  24726. "checked",
  24727. "childElementCount",
  24728. "childList",
  24729. "childNodes",
  24730. "children",
  24731. "chrome",
  24732. "ciphertext",
  24733. "cite",
  24734. "city",
  24735. "claimInterface",
  24736. "claimed",
  24737. "classList",
  24738. "className",
  24739. "classid",
  24740. "clear",
  24741. "clearAppBadge",
  24742. "clearAttributes",
  24743. "clearBuffer",
  24744. "clearBufferfi",
  24745. "clearBufferfv",
  24746. "clearBufferiv",
  24747. "clearBufferuiv",
  24748. "clearColor",
  24749. "clearData",
  24750. "clearDepth",
  24751. "clearHalt",
  24752. "clearImmediate",
  24753. "clearInterval",
  24754. "clearLiveSeekableRange",
  24755. "clearMarks",
  24756. "clearMaxGCPauseAccumulator",
  24757. "clearMeasures",
  24758. "clearOriginJoinedAdInterestGroups",
  24759. "clearParameters",
  24760. "clearRect",
  24761. "clearResourceTimings",
  24762. "clearShadow",
  24763. "clearStencil",
  24764. "clearTimeout",
  24765. "clearValue",
  24766. "clearWatch",
  24767. "click",
  24768. "clickCount",
  24769. "clientDataJSON",
  24770. "clientHeight",
  24771. "clientInformation",
  24772. "clientLeft",
  24773. "clientRect",
  24774. "clientRects",
  24775. "clientTop",
  24776. "clientWaitSync",
  24777. "clientWidth",
  24778. "clientX",
  24779. "clientY",
  24780. "clip",
  24781. "clip-path",
  24782. "clip-rule",
  24783. "clipBottom",
  24784. "clipLeft",
  24785. "clipPath",
  24786. "clipPathUnits",
  24787. "clipRight",
  24788. "clipRule",
  24789. "clipTop",
  24790. "clipboard",
  24791. "clipboardData",
  24792. "clonable",
  24793. "clone",
  24794. "cloneContents",
  24795. "cloneNode",
  24796. "cloneRange",
  24797. "close",
  24798. "closeCode",
  24799. "closePath",
  24800. "closed",
  24801. "closest",
  24802. "clz",
  24803. "clz32",
  24804. "cm",
  24805. "cmp",
  24806. "code",
  24807. "codeBase",
  24808. "codePointAt",
  24809. "codeType",
  24810. "codedHeight",
  24811. "codedRect",
  24812. "codedWidth",
  24813. "colSpan",
  24814. "collapse",
  24815. "collapseToEnd",
  24816. "collapseToStart",
  24817. "collapsed",
  24818. "collect",
  24819. "collections",
  24820. "colno",
  24821. "color",
  24822. "color-adjust",
  24823. "color-interpolation",
  24824. "color-interpolation-filters",
  24825. "color-scheme",
  24826. "colorAdjust",
  24827. "colorAttachments",
  24828. "colorDepth",
  24829. "colorFormats",
  24830. "colorInterpolation",
  24831. "colorInterpolationFilters",
  24832. "colorMask",
  24833. "colorScheme",
  24834. "colorSpace",
  24835. "colorType",
  24836. "cols",
  24837. "column-count",
  24838. "column-fill",
  24839. "column-gap",
  24840. "column-rule",
  24841. "column-rule-color",
  24842. "column-rule-style",
  24843. "column-rule-width",
  24844. "column-span",
  24845. "column-width",
  24846. "columnCount",
  24847. "columnFill",
  24848. "columnGap",
  24849. "columnNumber",
  24850. "columnRule",
  24851. "columnRuleColor",
  24852. "columnRuleStyle",
  24853. "columnRuleWidth",
  24854. "columnSpan",
  24855. "columnWidth",
  24856. "columns",
  24857. "command",
  24858. "commands",
  24859. "commit",
  24860. "commitLoadTime",
  24861. "commitPreferences",
  24862. "commitStyles",
  24863. "commonAncestorContainer",
  24864. "compact",
  24865. "compare",
  24866. "compareBoundaryPoints",
  24867. "compareDocumentPosition",
  24868. "compareEndPoints",
  24869. "compareExchange",
  24870. "compareNode",
  24871. "comparePoint",
  24872. "compatMode",
  24873. "compatible",
  24874. "compile",
  24875. "compileShader",
  24876. "compileStreaming",
  24877. "complete",
  24878. "completed",
  24879. "component",
  24880. "componentFromPoint",
  24881. "composed",
  24882. "composedPath",
  24883. "composite",
  24884. "compositionEndOffset",
  24885. "compositionStartOffset",
  24886. "compressedTexImage2D",
  24887. "compressedTexImage3D",
  24888. "compressedTexSubImage2D",
  24889. "compressedTexSubImage3D",
  24890. "compute",
  24891. "computedStyleMap",
  24892. "concat",
  24893. "conditionText",
  24894. "coneInnerAngle",
  24895. "coneOuterAngle",
  24896. "coneOuterGain",
  24897. "config",
  24898. "configurable",
  24899. "configuration",
  24900. "configurationName",
  24901. "configurationValue",
  24902. "configurations",
  24903. "configure",
  24904. "confirm",
  24905. "confirmComposition",
  24906. "confirmSiteSpecificTrackingException",
  24907. "confirmWebWideTrackingException",
  24908. "congestionControl",
  24909. "connect",
  24910. "connectEnd",
  24911. "connectNative",
  24912. "connectShark",
  24913. "connectStart",
  24914. "connected",
  24915. "connectedCallback",
  24916. "connection",
  24917. "connectionInfo",
  24918. "connectionList",
  24919. "connectionSpeed",
  24920. "connectionState",
  24921. "connections",
  24922. "console",
  24923. "consolidate",
  24924. "constants",
  24925. "constraint",
  24926. "constrictionActive",
  24927. "construct",
  24928. "constructor",
  24929. "contactID",
  24930. "contain",
  24931. "contain-intrinsic-block-size",
  24932. "contain-intrinsic-height",
  24933. "contain-intrinsic-inline-size",
  24934. "contain-intrinsic-size",
  24935. "contain-intrinsic-width",
  24936. "containIntrinsicBlockSize",
  24937. "containIntrinsicHeight",
  24938. "containIntrinsicInlineSize",
  24939. "containIntrinsicSize",
  24940. "containIntrinsicWidth",
  24941. "container",
  24942. "container-name",
  24943. "container-type",
  24944. "containerId",
  24945. "containerName",
  24946. "containerQuery",
  24947. "containerSrc",
  24948. "containerType",
  24949. "contains",
  24950. "containsNode",
  24951. "content",
  24952. "content-visibility",
  24953. "contentBoxSize",
  24954. "contentDocument",
  24955. "contentEditable",
  24956. "contentHint",
  24957. "contentOverflow",
  24958. "contentRect",
  24959. "contentScriptType",
  24960. "contentStyleType",
  24961. "contentType",
  24962. "contentVisibility",
  24963. "contentWindow",
  24964. "context",
  24965. "contextId",
  24966. "contextIds",
  24967. "contextMenu",
  24968. "contextMenus",
  24969. "contextType",
  24970. "contextTypes",
  24971. "contextmenu",
  24972. "contextualIdentities",
  24973. "continue",
  24974. "continuePrimaryKey",
  24975. "continuous",
  24976. "control",
  24977. "controlTransferIn",
  24978. "controlTransferOut",
  24979. "controller",
  24980. "controls",
  24981. "controlsList",
  24982. "convertPointFromNode",
  24983. "convertQuadFromNode",
  24984. "convertRectFromNode",
  24985. "convertToBlob",
  24986. "convertToSpecifiedUnits",
  24987. "cookie",
  24988. "cookieEnabled",
  24989. "cookieStore",
  24990. "cookies",
  24991. "coords",
  24992. "copyBufferSubData",
  24993. "copyBufferToBuffer",
  24994. "copyBufferToTexture",
  24995. "copyExternalImageToTexture",
  24996. "copyFromChannel",
  24997. "copyTexImage2D",
  24998. "copyTexSubImage2D",
  24999. "copyTexSubImage3D",
  25000. "copyTextureToBuffer",
  25001. "copyTextureToTexture",
  25002. "copyTo",
  25003. "copyToChannel",
  25004. "copyWithin",
  25005. "correspondingElement",
  25006. "correspondingUseElement",
  25007. "corruptedVideoFrames",
  25008. "cos",
  25009. "cosh",
  25010. "count",
  25011. "countReset",
  25012. "counter-increment",
  25013. "counter-reset",
  25014. "counter-set",
  25015. "counterIncrement",
  25016. "counterReset",
  25017. "counterSet",
  25018. "country",
  25019. "cpuClass",
  25020. "cpuSleepAllowed",
  25021. "cqb",
  25022. "cqh",
  25023. "cqi",
  25024. "cqmax",
  25025. "cqmin",
  25026. "cqw",
  25027. "create",
  25028. "createAnalyser",
  25029. "createAnchor",
  25030. "createAnswer",
  25031. "createAttribute",
  25032. "createAttributeNS",
  25033. "createAuctionNonce",
  25034. "createBidirectionalStream",
  25035. "createBindGroup",
  25036. "createBindGroupLayout",
  25037. "createBiquadFilter",
  25038. "createBuffer",
  25039. "createBufferSource",
  25040. "createCDATASection",
  25041. "createCSSStyleSheet",
  25042. "createCaption",
  25043. "createChannelMerger",
  25044. "createChannelSplitter",
  25045. "createCommandEncoder",
  25046. "createComment",
  25047. "createComputePipeline",
  25048. "createComputePipelineAsync",
  25049. "createConicGradient",
  25050. "createConstantSource",
  25051. "createContextualFragment",
  25052. "createControlRange",
  25053. "createConvolver",
  25054. "createDTMFSender",
  25055. "createDataChannel",
  25056. "createDelay",
  25057. "createDelayNode",
  25058. "createDocument",
  25059. "createDocumentFragment",
  25060. "createDocumentType",
  25061. "createDynamicsCompressor",
  25062. "createElement",
  25063. "createElementNS",
  25064. "createEncodedStreams",
  25065. "createEntityReference",
  25066. "createEvent",
  25067. "createEventObject",
  25068. "createExpression",
  25069. "createFramebuffer",
  25070. "createFunction",
  25071. "createGain",
  25072. "createGainNode",
  25073. "createHTML",
  25074. "createHTMLDocument",
  25075. "createIIRFilter",
  25076. "createImageBitmap",
  25077. "createImageData",
  25078. "createIndex",
  25079. "createJavaScriptNode",
  25080. "createLinearGradient",
  25081. "createMediaElementSource",
  25082. "createMediaKeys",
  25083. "createMediaStreamDestination",
  25084. "createMediaStreamSource",
  25085. "createMediaStreamTrackSource",
  25086. "createMutableFile",
  25087. "createNSResolver",
  25088. "createNodeIterator",
  25089. "createNotification",
  25090. "createObjectStore",
  25091. "createObjectURL",
  25092. "createOffer",
  25093. "createOscillator",
  25094. "createPanner",
  25095. "createPattern",
  25096. "createPeriodicWave",
  25097. "createPipelineLayout",
  25098. "createPolicy",
  25099. "createPopup",
  25100. "createProcessingInstruction",
  25101. "createProgram",
  25102. "createQuery",
  25103. "createQuerySet",
  25104. "createRadialGradient",
  25105. "createRange",
  25106. "createRangeCollection",
  25107. "createReader",
  25108. "createRenderBundleEncoder",
  25109. "createRenderPipeline",
  25110. "createRenderPipelineAsync",
  25111. "createRenderbuffer",
  25112. "createSVGAngle",
  25113. "createSVGLength",
  25114. "createSVGMatrix",
  25115. "createSVGNumber",
  25116. "createSVGPathSegArcAbs",
  25117. "createSVGPathSegArcRel",
  25118. "createSVGPathSegClosePath",
  25119. "createSVGPathSegCurvetoCubicAbs",
  25120. "createSVGPathSegCurvetoCubicRel",
  25121. "createSVGPathSegCurvetoCubicSmoothAbs",
  25122. "createSVGPathSegCurvetoCubicSmoothRel",
  25123. "createSVGPathSegCurvetoQuadraticAbs",
  25124. "createSVGPathSegCurvetoQuadraticRel",
  25125. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  25126. "createSVGPathSegCurvetoQuadraticSmoothRel",
  25127. "createSVGPathSegLinetoAbs",
  25128. "createSVGPathSegLinetoHorizontalAbs",
  25129. "createSVGPathSegLinetoHorizontalRel",
  25130. "createSVGPathSegLinetoRel",
  25131. "createSVGPathSegLinetoVerticalAbs",
  25132. "createSVGPathSegLinetoVerticalRel",
  25133. "createSVGPathSegMovetoAbs",
  25134. "createSVGPathSegMovetoRel",
  25135. "createSVGPoint",
  25136. "createSVGRect",
  25137. "createSVGTransform",
  25138. "createSVGTransformFromMatrix",
  25139. "createSampler",
  25140. "createScript",
  25141. "createScriptProcessor",
  25142. "createScriptURL",
  25143. "createSession",
  25144. "createShader",
  25145. "createShaderModule",
  25146. "createShadowRoot",
  25147. "createStereoPanner",
  25148. "createStyleSheet",
  25149. "createTBody",
  25150. "createTFoot",
  25151. "createTHead",
  25152. "createTask",
  25153. "createTextNode",
  25154. "createTextRange",
  25155. "createTexture",
  25156. "createTouch",
  25157. "createTouchList",
  25158. "createTransformFeedback",
  25159. "createTreeWalker",
  25160. "createUnidirectionalStream",
  25161. "createVertexArray",
  25162. "createView",
  25163. "createWaveShaper",
  25164. "createWorklet",
  25165. "createWritable",
  25166. "creationTime",
  25167. "credentialless",
  25168. "credentials",
  25169. "criticalCHRestart",
  25170. "cropTo",
  25171. "crossOrigin",
  25172. "crossOriginIsolated",
  25173. "crypto",
  25174. "csi",
  25175. "csp",
  25176. "cssFloat",
  25177. "cssRules",
  25178. "cssText",
  25179. "cssValueType",
  25180. "ctrlKey",
  25181. "ctrlLeft",
  25182. "cues",
  25183. "cullFace",
  25184. "cullMode",
  25185. "currentCSSZoom",
  25186. "currentDirection",
  25187. "currentEntry",
  25188. "currentLocalDescription",
  25189. "currentNode",
  25190. "currentPage",
  25191. "currentRect",
  25192. "currentRemoteDescription",
  25193. "currentScale",
  25194. "currentScreen",
  25195. "currentScript",
  25196. "currentSrc",
  25197. "currentState",
  25198. "currentStyle",
  25199. "currentTarget",
  25200. "currentTime",
  25201. "currentTranslate",
  25202. "currentView",
  25203. "cursor",
  25204. "curve",
  25205. "customElements",
  25206. "customError",
  25207. "cx",
  25208. "cy",
  25209. "d",
  25210. "data",
  25211. "dataFld",
  25212. "dataFormatAs",
  25213. "dataLoss",
  25214. "dataLossMessage",
  25215. "dataPageSize",
  25216. "dataSrc",
  25217. "dataTransfer",
  25218. "database",
  25219. "databases",
  25220. "datagrams",
  25221. "dataset",
  25222. "dateTime",
  25223. "db",
  25224. "debug",
  25225. "debuggerEnabled",
  25226. "declarativeNetRequest",
  25227. "declare",
  25228. "decode",
  25229. "decodeAudioData",
  25230. "decodeQueueSize",
  25231. "decodeURI",
  25232. "decodeURIComponent",
  25233. "decodedBodySize",
  25234. "decoding",
  25235. "decodingInfo",
  25236. "decrypt",
  25237. "default",
  25238. "defaultCharset",
  25239. "defaultChecked",
  25240. "defaultMuted",
  25241. "defaultPlaybackRate",
  25242. "defaultPolicy",
  25243. "defaultPrevented",
  25244. "defaultQueue",
  25245. "defaultRequest",
  25246. "defaultSelected",
  25247. "defaultStatus",
  25248. "defaultURL",
  25249. "defaultValue",
  25250. "defaultView",
  25251. "defaultstatus",
  25252. "defer",
  25253. "define",
  25254. "defineMagicFunction",
  25255. "defineMagicVariable",
  25256. "defineProperties",
  25257. "defineProperty",
  25258. "deg",
  25259. "delay",
  25260. "delayTime",
  25261. "delegatesFocus",
  25262. "delete",
  25263. "deleteBuffer",
  25264. "deleteCaption",
  25265. "deleteCell",
  25266. "deleteContents",
  25267. "deleteData",
  25268. "deleteDatabase",
  25269. "deleteFramebuffer",
  25270. "deleteFromDocument",
  25271. "deleteIndex",
  25272. "deleteMedium",
  25273. "deleteObjectStore",
  25274. "deleteProgram",
  25275. "deleteProperty",
  25276. "deleteQuery",
  25277. "deleteRenderbuffer",
  25278. "deleteRow",
  25279. "deleteRule",
  25280. "deleteSampler",
  25281. "deleteShader",
  25282. "deleteSync",
  25283. "deleteTFoot",
  25284. "deleteTHead",
  25285. "deleteTexture",
  25286. "deleteTransformFeedback",
  25287. "deleteVertexArray",
  25288. "deleted",
  25289. "deliverChangeRecords",
  25290. "deliveredFrames",
  25291. "deliveredFramesDuration",
  25292. "delivery",
  25293. "deliveryInfo",
  25294. "deliveryStatus",
  25295. "deliveryTimestamp",
  25296. "deliveryType",
  25297. "delta",
  25298. "deltaMode",
  25299. "deltaX",
  25300. "deltaY",
  25301. "deltaZ",
  25302. "dependentLocality",
  25303. "deprecatedReplaceInURN",
  25304. "deprecatedRunAdAuctionEnforcesKAnonymity",
  25305. "deprecatedURNToURL",
  25306. "depthBias",
  25307. "depthBiasClamp",
  25308. "depthBiasSlopeScale",
  25309. "depthClearValue",
  25310. "depthCompare",
  25311. "depthDataFormat",
  25312. "depthFailOp",
  25313. "depthFar",
  25314. "depthFunc",
  25315. "depthLoadOp",
  25316. "depthMask",
  25317. "depthNear",
  25318. "depthOrArrayLayers",
  25319. "depthRange",
  25320. "depthReadOnly",
  25321. "depthStencil",
  25322. "depthStencilAttachment",
  25323. "depthStencilFormat",
  25324. "depthStoreOp",
  25325. "depthUsage",
  25326. "depthWriteEnabled",
  25327. "deref",
  25328. "deriveBits",
  25329. "deriveKey",
  25330. "descentOverride",
  25331. "description",
  25332. "deselectAll",
  25333. "designMode",
  25334. "desiredSize",
  25335. "destination",
  25336. "destinationURL",
  25337. "destroy",
  25338. "detach",
  25339. "detachEvent",
  25340. "detachShader",
  25341. "detached",
  25342. "detail",
  25343. "details",
  25344. "detect",
  25345. "detectLanguage",
  25346. "detune",
  25347. "device",
  25348. "deviceClass",
  25349. "deviceId",
  25350. "deviceMemory",
  25351. "devicePixelContentBoxSize",
  25352. "devicePixelRatio",
  25353. "deviceProtocol",
  25354. "deviceSubclass",
  25355. "deviceVersionMajor",
  25356. "deviceVersionMinor",
  25357. "deviceVersionSubminor",
  25358. "deviceXDPI",
  25359. "deviceYDPI",
  25360. "devtools",
  25361. "devtools_panels",
  25362. "didTimeout",
  25363. "difference",
  25364. "diffuseConstant",
  25365. "digest",
  25366. "dimension",
  25367. "dimensions",
  25368. "dir",
  25369. "dirName",
  25370. "direction",
  25371. "dirxml",
  25372. "disable",
  25373. "disablePictureInPicture",
  25374. "disableRemotePlayback",
  25375. "disableVertexAttribArray",
  25376. "disabled",
  25377. "discard",
  25378. "discardedFrames",
  25379. "dischargingTime",
  25380. "disconnect",
  25381. "disconnectShark",
  25382. "disconnectedCallback",
  25383. "dispatchEvent",
  25384. "dispatchWorkgroups",
  25385. "dispatchWorkgroupsIndirect",
  25386. "display",
  25387. "displayHeight",
  25388. "displayId",
  25389. "displayName",
  25390. "displayWidth",
  25391. "dispose",
  25392. "disposition",
  25393. "distanceModel",
  25394. "div",
  25395. "divisor",
  25396. "djsapi",
  25397. "djsproxy",
  25398. "dns",
  25399. "doImport",
  25400. "doNotTrack",
  25401. "doScroll",
  25402. "doctype",
  25403. "document",
  25404. "documentElement",
  25405. "documentId",
  25406. "documentIds",
  25407. "documentLifecycle",
  25408. "documentMode",
  25409. "documentOrigin",
  25410. "documentOrigins",
  25411. "documentPictureInPicture",
  25412. "documentURI",
  25413. "documentUrl",
  25414. "documentUrls",
  25415. "dolphin",
  25416. "dolphinGameCenter",
  25417. "dolphininfo",
  25418. "dolphinmeta",
  25419. "dom",
  25420. "domComplete",
  25421. "domContentLoadedEventEnd",
  25422. "domContentLoadedEventStart",
  25423. "domInteractive",
  25424. "domLoading",
  25425. "domOverlayState",
  25426. "domain",
  25427. "domainLookupEnd",
  25428. "domainLookupStart",
  25429. "dominant-baseline",
  25430. "dominantBaseline",
  25431. "done",
  25432. "dopplerFactor",
  25433. "dotAll",
  25434. "downDegrees",
  25435. "downlink",
  25436. "download",
  25437. "downloadRequest",
  25438. "downloadTotal",
  25439. "downloaded",
  25440. "downloads",
  25441. "dpcm",
  25442. "dpi",
  25443. "dppx",
  25444. "dragDrop",
  25445. "draggable",
  25446. "draw",
  25447. "drawArrays",
  25448. "drawArraysInstanced",
  25449. "drawArraysInstancedANGLE",
  25450. "drawBuffers",
  25451. "drawCustomFocusRing",
  25452. "drawElements",
  25453. "drawElementsInstanced",
  25454. "drawElementsInstancedANGLE",
  25455. "drawFocusIfNeeded",
  25456. "drawImage",
  25457. "drawImageFromRect",
  25458. "drawIndexed",
  25459. "drawIndexedIndirect",
  25460. "drawIndirect",
  25461. "drawRangeElements",
  25462. "drawSystemFocusRing",
  25463. "drawingBufferColorSpace",
  25464. "drawingBufferFormat",
  25465. "drawingBufferHeight",
  25466. "drawingBufferStorage",
  25467. "drawingBufferWidth",
  25468. "drop",
  25469. "dropEffect",
  25470. "droppedVideoFrames",
  25471. "dropzone",
  25472. "dstFactor",
  25473. "dtmf",
  25474. "dump",
  25475. "dumpProfile",
  25476. "duplex",
  25477. "duplicate",
  25478. "durability",
  25479. "duration",
  25480. "dvb",
  25481. "dvh",
  25482. "dvi",
  25483. "dvmax",
  25484. "dvmin",
  25485. "dvname",
  25486. "dvnum",
  25487. "dvw",
  25488. "dx",
  25489. "dy",
  25490. "dynamicId",
  25491. "dynsrc",
  25492. "e",
  25493. "edgeMode",
  25494. "editContext",
  25495. "effect",
  25496. "effectAllowed",
  25497. "effectiveDirective",
  25498. "effectiveType",
  25499. "effects",
  25500. "elapsedTime",
  25501. "element",
  25502. "elementFromPoint",
  25503. "elementTiming",
  25504. "elements",
  25505. "elementsFromPoint",
  25506. "elevation",
  25507. "ellipse",
  25508. "em",
  25509. "emHeightAscent",
  25510. "emHeightDescent",
  25511. "email",
  25512. "embeds",
  25513. "emit",
  25514. "emma",
  25515. "empty",
  25516. "empty-cells",
  25517. "emptyCells",
  25518. "emptyHTML",
  25519. "emptyScript",
  25520. "emulatedPosition",
  25521. "enable",
  25522. "enableBackground",
  25523. "enableDelegations",
  25524. "enableStyleSheetsForSet",
  25525. "enableVertexAttribArray",
  25526. "enabled",
  25527. "enabledFeatures",
  25528. "enabledPlugin",
  25529. "encode",
  25530. "encodeInto",
  25531. "encodeQueueSize",
  25532. "encodeURI",
  25533. "encodeURIComponent",
  25534. "encodedBodySize",
  25535. "encoding",
  25536. "encodingInfo",
  25537. "encrypt",
  25538. "enctype",
  25539. "end",
  25540. "endContainer",
  25541. "endElement",
  25542. "endElementAt",
  25543. "endOcclusionQuery",
  25544. "endOfPassWriteIndex",
  25545. "endOfStream",
  25546. "endOffset",
  25547. "endQuery",
  25548. "endTime",
  25549. "endTransformFeedback",
  25550. "ended",
  25551. "endpoint",
  25552. "endpointNumber",
  25553. "endpoints",
  25554. "endsWith",
  25555. "enqueue",
  25556. "enterKeyHint",
  25557. "entities",
  25558. "entries",
  25559. "entry",
  25560. "entryPoint",
  25561. "entryType",
  25562. "enumerable",
  25563. "enumerate",
  25564. "enumerateDevices",
  25565. "enumerateEditable",
  25566. "environmentBlendMode",
  25567. "equals",
  25568. "error",
  25569. "errorCode",
  25570. "errorDetail",
  25571. "errorText",
  25572. "escape",
  25573. "estimate",
  25574. "eval",
  25575. "evaluate",
  25576. "event",
  25577. "eventCounts",
  25578. "eventPhase",
  25579. "events",
  25580. "every",
  25581. "ex",
  25582. "exception",
  25583. "exchange",
  25584. "exec",
  25585. "execCommand",
  25586. "execCommandShowHelp",
  25587. "execScript",
  25588. "executeBundles",
  25589. "executionStart",
  25590. "exitFullscreen",
  25591. "exitPictureInPicture",
  25592. "exitPointerLock",
  25593. "exitPresent",
  25594. "exp",
  25595. "expand",
  25596. "expandEntityReferences",
  25597. "expando",
  25598. "expansion",
  25599. "expectedImprovement",
  25600. "experiments",
  25601. "expiration",
  25602. "expirationTime",
  25603. "expires",
  25604. "expiryDate",
  25605. "explicitOriginalTarget",
  25606. "expm1",
  25607. "exponent",
  25608. "exponentialRampToValueAtTime",
  25609. "exportKey",
  25610. "exports",
  25611. "extend",
  25612. "extension",
  25613. "extensionTypes",
  25614. "extensions",
  25615. "extentNode",
  25616. "extentOffset",
  25617. "external",
  25618. "externalResourcesRequired",
  25619. "externalTexture",
  25620. "extractContents",
  25621. "extractable",
  25622. "eye",
  25623. "f",
  25624. "f16round",
  25625. "face",
  25626. "factoryReset",
  25627. "failOp",
  25628. "failureReason",
  25629. "fallback",
  25630. "family",
  25631. "familyName",
  25632. "farthestViewportElement",
  25633. "fastSeek",
  25634. "fatal",
  25635. "featureId",
  25636. "featurePolicy",
  25637. "featureSettings",
  25638. "features",
  25639. "fence",
  25640. "fenceSync",
  25641. "fetch",
  25642. "fetchPriority",
  25643. "fetchStart",
  25644. "fftSize",
  25645. "fgColor",
  25646. "fieldOfView",
  25647. "file",
  25648. "fileCreatedDate",
  25649. "fileHandle",
  25650. "fileModifiedDate",
  25651. "fileName",
  25652. "fileSize",
  25653. "fileUpdatedDate",
  25654. "filename",
  25655. "files",
  25656. "filesystem",
  25657. "fill",
  25658. "fill-opacity",
  25659. "fill-rule",
  25660. "fillJointRadii",
  25661. "fillLightMode",
  25662. "fillOpacity",
  25663. "fillPoses",
  25664. "fillRect",
  25665. "fillRule",
  25666. "fillStyle",
  25667. "fillText",
  25668. "filter",
  25669. "filterResX",
  25670. "filterResY",
  25671. "filterUnits",
  25672. "filters",
  25673. "finally",
  25674. "find",
  25675. "findIndex",
  25676. "findLast",
  25677. "findLastIndex",
  25678. "findRule",
  25679. "findText",
  25680. "finish",
  25681. "finishDocumentLoadTime",
  25682. "finishLoadTime",
  25683. "finished",
  25684. "fireEvent",
  25685. "firesTouchEvents",
  25686. "firstChild",
  25687. "firstElementChild",
  25688. "firstInterimResponseStart",
  25689. "firstPage",
  25690. "firstPaintAfterLoadTime",
  25691. "firstPaintTime",
  25692. "firstUIEventTimestamp",
  25693. "fixed",
  25694. "flags",
  25695. "flat",
  25696. "flatMap",
  25697. "flex",
  25698. "flex-basis",
  25699. "flex-direction",
  25700. "flex-flow",
  25701. "flex-grow",
  25702. "flex-shrink",
  25703. "flex-wrap",
  25704. "flexBasis",
  25705. "flexDirection",
  25706. "flexFlow",
  25707. "flexGrow",
  25708. "flexShrink",
  25709. "flexWrap",
  25710. "flipX",
  25711. "flipY",
  25712. "float",
  25713. "float32",
  25714. "float64",
  25715. "flood-color",
  25716. "flood-opacity",
  25717. "floodColor",
  25718. "floodOpacity",
  25719. "floor",
  25720. "flush",
  25721. "focus",
  25722. "focusNode",
  25723. "focusOffset",
  25724. "font",
  25725. "font-family",
  25726. "font-feature-settings",
  25727. "font-kerning",
  25728. "font-language-override",
  25729. "font-optical-sizing",
  25730. "font-palette",
  25731. "font-size",
  25732. "font-size-adjust",
  25733. "font-stretch",
  25734. "font-style",
  25735. "font-synthesis",
  25736. "font-synthesis-position",
  25737. "font-synthesis-small-caps",
  25738. "font-synthesis-style",
  25739. "font-synthesis-weight",
  25740. "font-variant",
  25741. "font-variant-alternates",
  25742. "font-variant-caps",
  25743. "font-variant-east-asian",
  25744. "font-variant-ligatures",
  25745. "font-variant-numeric",
  25746. "font-variant-position",
  25747. "font-variation-settings",
  25748. "font-weight",
  25749. "fontBoundingBoxAscent",
  25750. "fontBoundingBoxDescent",
  25751. "fontFamily",
  25752. "fontFeatureSettings",
  25753. "fontKerning",
  25754. "fontLanguageOverride",
  25755. "fontOpticalSizing",
  25756. "fontPalette",
  25757. "fontSize",
  25758. "fontSizeAdjust",
  25759. "fontSmoothingEnabled",
  25760. "fontStretch",
  25761. "fontStyle",
  25762. "fontSynthesis",
  25763. "fontSynthesisPosition",
  25764. "fontSynthesisSmallCaps",
  25765. "fontSynthesisStyle",
  25766. "fontSynthesisWeight",
  25767. "fontVariant",
  25768. "fontVariantAlternates",
  25769. "fontVariantCaps",
  25770. "fontVariantEastAsian",
  25771. "fontVariantLigatures",
  25772. "fontVariantNumeric",
  25773. "fontVariantPosition",
  25774. "fontVariationSettings",
  25775. "fontWeight",
  25776. "fontcolor",
  25777. "fontfaces",
  25778. "fonts",
  25779. "fontsize",
  25780. "for",
  25781. "forEach",
  25782. "force",
  25783. "forceFallbackAdapter",
  25784. "forceRedraw",
  25785. "forced-color-adjust",
  25786. "forcedColorAdjust",
  25787. "forcedStyleAndLayoutDuration",
  25788. "forget",
  25789. "form",
  25790. "formAction",
  25791. "formData",
  25792. "formEnctype",
  25793. "formMethod",
  25794. "formNoValidate",
  25795. "formTarget",
  25796. "format",
  25797. "formatToParts",
  25798. "forms",
  25799. "forward",
  25800. "forwardX",
  25801. "forwardY",
  25802. "forwardZ",
  25803. "foundation",
  25804. "fr",
  25805. "fragment",
  25806. "fragmentDirective",
  25807. "frame",
  25808. "frameBorder",
  25809. "frameCount",
  25810. "frameElement",
  25811. "frameId",
  25812. "frameIds",
  25813. "frameSpacing",
  25814. "framebuffer",
  25815. "framebufferHeight",
  25816. "framebufferRenderbuffer",
  25817. "framebufferTexture2D",
  25818. "framebufferTextureLayer",
  25819. "framebufferWidth",
  25820. "frames",
  25821. "freeSpace",
  25822. "freeze",
  25823. "frequency",
  25824. "frequencyBinCount",
  25825. "from",
  25826. "fromAsync",
  25827. "fromBase64",
  25828. "fromCharCode",
  25829. "fromCodePoint",
  25830. "fromElement",
  25831. "fromEntries",
  25832. "fromFloat32Array",
  25833. "fromFloat64Array",
  25834. "fromHex",
  25835. "fromMatrix",
  25836. "fromPoint",
  25837. "fromQuad",
  25838. "fromRect",
  25839. "frontFace",
  25840. "fround",
  25841. "fullName",
  25842. "fullPath",
  25843. "fullRange",
  25844. "fullScreen",
  25845. "fullVersionList",
  25846. "fullscreen",
  25847. "fullscreenElement",
  25848. "fullscreenEnabled",
  25849. "fx",
  25850. "fy",
  25851. "g",
  25852. "gain",
  25853. "gamepad",
  25854. "gamma",
  25855. "gap",
  25856. "gatheringState",
  25857. "gatt",
  25858. "geckoProfiler",
  25859. "genderIdentity",
  25860. "generateCertificate",
  25861. "generateKey",
  25862. "generateMipmap",
  25863. "generateRequest",
  25864. "geolocation",
  25865. "gestureObject",
  25866. "get",
  25867. "getAcceptLanguages",
  25868. "getActiveAttrib",
  25869. "getActiveUniform",
  25870. "getActiveUniformBlockName",
  25871. "getActiveUniformBlockParameter",
  25872. "getActiveUniforms",
  25873. "getAdjacentText",
  25874. "getAll",
  25875. "getAllKeys",
  25876. "getAllResponseHeaders",
  25877. "getAllowlistForFeature",
  25878. "getAnimations",
  25879. "getAsFile",
  25880. "getAsFileSystemHandle",
  25881. "getAsString",
  25882. "getAttachedShaders",
  25883. "getAttribLocation",
  25884. "getAttribute",
  25885. "getAttributeNS",
  25886. "getAttributeNames",
  25887. "getAttributeNode",
  25888. "getAttributeNodeNS",
  25889. "getAttributeType",
  25890. "getAudioTracks",
  25891. "getAuthenticatorData",
  25892. "getAutoplayPolicy",
  25893. "getAvailability",
  25894. "getBBox",
  25895. "getBackgroundPage",
  25896. "getBadgeBackgroundColor",
  25897. "getBadgeText",
  25898. "getBadgeTextColor",
  25899. "getBattery",
  25900. "getBigInt64",
  25901. "getBigUint64",
  25902. "getBindGroupLayout",
  25903. "getBlob",
  25904. "getBookmark",
  25905. "getBoundingClientRect",
  25906. "getBounds",
  25907. "getBoxQuads",
  25908. "getBrowserInfo",
  25909. "getBufferParameter",
  25910. "getBufferSubData",
  25911. "getByteFrequencyData",
  25912. "getByteTimeDomainData",
  25913. "getCSSCanvasContext",
  25914. "getCTM",
  25915. "getCameraImage",
  25916. "getCandidateWindowClientRect",
  25917. "getCanonicalLocales",
  25918. "getCapabilities",
  25919. "getCaptureHandle",
  25920. "getChannelData",
  25921. "getCharNumAtPosition",
  25922. "getCharacteristic",
  25923. "getCharacteristics",
  25924. "getClientExtensionResults",
  25925. "getClientRect",
  25926. "getClientRects",
  25927. "getCoalescedEvents",
  25928. "getCompilationInfo",
  25929. "getCompositionAlternatives",
  25930. "getComputedStyle",
  25931. "getComputedTextLength",
  25932. "getComputedTiming",
  25933. "getConfiguration",
  25934. "getConstraints",
  25935. "getContext",
  25936. "getContextAttributes",
  25937. "getContexts",
  25938. "getContributingSources",
  25939. "getCounterValue",
  25940. "getCueAsHTML",
  25941. "getCueById",
  25942. "getCurrent",
  25943. "getCurrentPosition",
  25944. "getCurrentTexture",
  25945. "getCurrentTime",
  25946. "getData",
  25947. "getDatabaseNames",
  25948. "getDate",
  25949. "getDay",
  25950. "getDefaultComputedStyle",
  25951. "getDepthInMeters",
  25952. "getDepthInformation",
  25953. "getDescriptor",
  25954. "getDescriptors",
  25955. "getDestinationInsertionPoints",
  25956. "getDevices",
  25957. "getDirectory",
  25958. "getDirectoryHandle",
  25959. "getDisplayMedia",
  25960. "getDistributedNodes",
  25961. "getEditable",
  25962. "getElementById",
  25963. "getElementsByClassName",
  25964. "getElementsByName",
  25965. "getElementsByTagName",
  25966. "getElementsByTagNameNS",
  25967. "getEnclosureList",
  25968. "getEndPositionOfChar",
  25969. "getEntries",
  25970. "getEntriesByName",
  25971. "getEntriesByType",
  25972. "getError",
  25973. "getExtension",
  25974. "getExtentOfChar",
  25975. "getEyeParameters",
  25976. "getFeature",
  25977. "getFiberRoots",
  25978. "getFile",
  25979. "getFileHandle",
  25980. "getFiles",
  25981. "getFilesAndDirectories",
  25982. "getFingerprints",
  25983. "getFloat16",
  25984. "getFloat32",
  25985. "getFloat64",
  25986. "getFloatFrequencyData",
  25987. "getFloatTimeDomainData",
  25988. "getFloatValue",
  25989. "getFragDataLocation",
  25990. "getFrameData",
  25991. "getFrameId",
  25992. "getFramebufferAttachmentParameter",
  25993. "getFrequencyResponse",
  25994. "getFullYear",
  25995. "getGamepads",
  25996. "getHTML",
  25997. "getHeaderExtensionsToNegotiate",
  25998. "getHighEntropyValues",
  25999. "getHitTestResults",
  26000. "getHitTestResultsForTransientInput",
  26001. "getHours",
  26002. "getIdentityAssertion",
  26003. "getIds",
  26004. "getImageData",
  26005. "getIndexedParameter",
  26006. "getInfo",
  26007. "getInnerHTML",
  26008. "getInstalledRelatedApps",
  26009. "getInt16",
  26010. "getInt32",
  26011. "getInt8",
  26012. "getInterestGroupAdAuctionData",
  26013. "getInternalModuleRanges",
  26014. "getInternalformatParameter",
  26015. "getIntersectionList",
  26016. "getItem",
  26017. "getItems",
  26018. "getJointPose",
  26019. "getKey",
  26020. "getKeyframes",
  26021. "getLastFocused",
  26022. "getLayers",
  26023. "getLayoutMap",
  26024. "getLightEstimate",
  26025. "getLineDash",
  26026. "getLocalCandidates",
  26027. "getLocalParameters",
  26028. "getLocalStreams",
  26029. "getManagedConfiguration",
  26030. "getManifest",
  26031. "getMappedRange",
  26032. "getMarks",
  26033. "getMatchedCSSRules",
  26034. "getMaxGCPauseSinceClear",
  26035. "getMeasures",
  26036. "getMessage",
  26037. "getMetadata",
  26038. "getMilliseconds",
  26039. "getMinutes",
  26040. "getModifierState",
  26041. "getMonth",
  26042. "getName",
  26043. "getNamedItem",
  26044. "getNamedItemNS",
  26045. "getNativeFramebufferScaleFactor",
  26046. "getNegotiatedHeaderExtensions",
  26047. "getNestedConfigs",
  26048. "getNotifications",
  26049. "getNotifier",
  26050. "getNumberOfChars",
  26051. "getOffsetReferenceSpace",
  26052. "getOutputTimestamp",
  26053. "getOverrideHistoryNavigationMode",
  26054. "getOverrideStyle",
  26055. "getOwnPropertyDescriptor",
  26056. "getOwnPropertyDescriptors",
  26057. "getOwnPropertyNames",
  26058. "getOwnPropertySymbols",
  26059. "getPackageDirectoryEntry",
  26060. "getParameter",
  26061. "getParameters",
  26062. "getParent",
  26063. "getPathSegAtLength",
  26064. "getPermissionWarningsByManifest",
  26065. "getPhotoCapabilities",
  26066. "getPhotoSettings",
  26067. "getPlatformInfo",
  26068. "getPointAtLength",
  26069. "getPopup",
  26070. "getPorts",
  26071. "getPose",
  26072. "getPredictedEvents",
  26073. "getPreference",
  26074. "getPreferenceDefault",
  26075. "getPreferredCanvasFormat",
  26076. "getPresentationAttribute",
  26077. "getPreventDefault",
  26078. "getPrimaryService",
  26079. "getPrimaryServices",
  26080. "getProgramInfoLog",
  26081. "getProgramParameter",
  26082. "getPropertyCSSValue",
  26083. "getPropertyPriority",
  26084. "getPropertyShorthand",
  26085. "getPropertyType",
  26086. "getPropertyValue",
  26087. "getPrototypeOf",
  26088. "getPublicKey",
  26089. "getPublicKeyAlgorithm",
  26090. "getQuery",
  26091. "getQueryParameter",
  26092. "getRGBColorValue",
  26093. "getRandomValues",
  26094. "getRangeAt",
  26095. "getReader",
  26096. "getReceivers",
  26097. "getRectValue",
  26098. "getReflectionCubeMap",
  26099. "getRegistration",
  26100. "getRegistrations",
  26101. "getRemoteCandidates",
  26102. "getRemoteCertificates",
  26103. "getRemoteParameters",
  26104. "getRemoteStreams",
  26105. "getRenderbufferParameter",
  26106. "getResponseHeader",
  26107. "getRoot",
  26108. "getRootNode",
  26109. "getRotationOfChar",
  26110. "getSVGDocument",
  26111. "getSamplerParameter",
  26112. "getScreenCTM",
  26113. "getScreenDetails",
  26114. "getSeconds",
  26115. "getSelectedCandidatePair",
  26116. "getSelection",
  26117. "getSelf",
  26118. "getSenders",
  26119. "getService",
  26120. "getSetCookie",
  26121. "getSettings",
  26122. "getShaderInfoLog",
  26123. "getShaderParameter",
  26124. "getShaderPrecisionFormat",
  26125. "getShaderSource",
  26126. "getSignals",
  26127. "getSimpleDuration",
  26128. "getSiteIcons",
  26129. "getSources",
  26130. "getSpeculativeParserUrls",
  26131. "getStartPositionOfChar",
  26132. "getStartTime",
  26133. "getState",
  26134. "getStats",
  26135. "getStatusForPolicy",
  26136. "getStorageUpdates",
  26137. "getStreamById",
  26138. "getStringValue",
  26139. "getSubStringLength",
  26140. "getSubscription",
  26141. "getSubscriptions",
  26142. "getSupportedConstraints",
  26143. "getSupportedExtensions",
  26144. "getSupportedFormats",
  26145. "getSyncParameter",
  26146. "getSynchronizationSources",
  26147. "getTags",
  26148. "getTargetRanges",
  26149. "getTexParameter",
  26150. "getTextFormats",
  26151. "getTime",
  26152. "getTimezoneOffset",
  26153. "getTiming",
  26154. "getTitle",
  26155. "getTitlebarAreaRect",
  26156. "getTotalLength",
  26157. "getTrackById",
  26158. "getTracks",
  26159. "getTransceivers",
  26160. "getTransform",
  26161. "getTransformFeedbackVarying",
  26162. "getTransformToElement",
  26163. "getTransports",
  26164. "getType",
  26165. "getTypeMapping",
  26166. "getUILanguage",
  26167. "getURL",
  26168. "getUTCDate",
  26169. "getUTCDay",
  26170. "getUTCFullYear",
  26171. "getUTCHours",
  26172. "getUTCMilliseconds",
  26173. "getUTCMinutes",
  26174. "getUTCMonth",
  26175. "getUTCSeconds",
  26176. "getUint16",
  26177. "getUint32",
  26178. "getUint8",
  26179. "getUniform",
  26180. "getUniformBlockIndex",
  26181. "getUniformIndices",
  26182. "getUniformLocation",
  26183. "getUserInfo",
  26184. "getUserMedia",
  26185. "getUserSettings",
  26186. "getVRDisplays",
  26187. "getValues",
  26188. "getVarDate",
  26189. "getVariableValue",
  26190. "getVertexAttrib",
  26191. "getVertexAttribOffset",
  26192. "getVideoPlaybackQuality",
  26193. "getVideoTracks",
  26194. "getViewerPose",
  26195. "getViewport",
  26196. "getViews",
  26197. "getVoices",
  26198. "getWakeLockState",
  26199. "getWriter",
  26200. "getYear",
  26201. "getZoom",
  26202. "getZoomSettings",
  26203. "givenName",
  26204. "global",
  26205. "globalAlpha",
  26206. "globalCompositeOperation",
  26207. "globalPrivacyControl",
  26208. "globalThis",
  26209. "glyphOrientationHorizontal",
  26210. "glyphOrientationVertical",
  26211. "glyphRef",
  26212. "go",
  26213. "goBack",
  26214. "goForward",
  26215. "gpu",
  26216. "grabFrame",
  26217. "grad",
  26218. "gradientTransform",
  26219. "gradientUnits",
  26220. "grammars",
  26221. "green",
  26222. "grid",
  26223. "grid-area",
  26224. "grid-auto-columns",
  26225. "grid-auto-flow",
  26226. "grid-auto-rows",
  26227. "grid-column",
  26228. "grid-column-end",
  26229. "grid-column-gap",
  26230. "grid-column-start",
  26231. "grid-gap",
  26232. "grid-row",
  26233. "grid-row-end",
  26234. "grid-row-gap",
  26235. "grid-row-start",
  26236. "grid-template",
  26237. "grid-template-areas",
  26238. "grid-template-columns",
  26239. "grid-template-rows",
  26240. "gridArea",
  26241. "gridAutoColumns",
  26242. "gridAutoFlow",
  26243. "gridAutoRows",
  26244. "gridColumn",
  26245. "gridColumnEnd",
  26246. "gridColumnGap",
  26247. "gridColumnStart",
  26248. "gridGap",
  26249. "gridRow",
  26250. "gridRowEnd",
  26251. "gridRowGap",
  26252. "gridRowStart",
  26253. "gridTemplate",
  26254. "gridTemplateAreas",
  26255. "gridTemplateColumns",
  26256. "gridTemplateRows",
  26257. "gripSpace",
  26258. "group",
  26259. "groupBy",
  26260. "groupCollapsed",
  26261. "groupEnd",
  26262. "groupId",
  26263. "groups",
  26264. "grow",
  26265. "growable",
  26266. "guestProcessId",
  26267. "guestRenderFrameRoutingId",
  26268. "hadRecentInput",
  26269. "hand",
  26270. "handedness",
  26271. "hangingBaseline",
  26272. "hapticActuators",
  26273. "hardwareConcurrency",
  26274. "has",
  26275. "hasAttribute",
  26276. "hasAttributeNS",
  26277. "hasAttributes",
  26278. "hasBeenActive",
  26279. "hasChildNodes",
  26280. "hasComposition",
  26281. "hasDynamicOffset",
  26282. "hasEnrolledInstrument",
  26283. "hasExtension",
  26284. "hasExternalDisplay",
  26285. "hasFeature",
  26286. "hasFocus",
  26287. "hasIndices",
  26288. "hasInstance",
  26289. "hasLayout",
  26290. "hasOrientation",
  26291. "hasOwn",
  26292. "hasOwnProperty",
  26293. "hasPointerCapture",
  26294. "hasPosition",
  26295. "hasPrivateToken",
  26296. "hasReading",
  26297. "hasRedemptionRecord",
  26298. "hasRegExpGroups",
  26299. "hasStorageAccess",
  26300. "hasUAVisualTransition",
  26301. "hasUnpartitionedCookieAccess",
  26302. "hash",
  26303. "hashChange",
  26304. "head",
  26305. "headers",
  26306. "heading",
  26307. "height",
  26308. "hid",
  26309. "hidden",
  26310. "hide",
  26311. "hideFocus",
  26312. "hidePopover",
  26313. "high",
  26314. "highWaterMark",
  26315. "highlight",
  26316. "highlights",
  26317. "hint",
  26318. "hints",
  26319. "history",
  26320. "honorificPrefix",
  26321. "honorificSuffix",
  26322. "horizontalOverflow",
  26323. "host",
  26324. "hostCandidate",
  26325. "hostname",
  26326. "href",
  26327. "hrefTranslate",
  26328. "hreflang",
  26329. "hspace",
  26330. "html5TagCheckInerface",
  26331. "htmlFor",
  26332. "htmlText",
  26333. "httpEquiv",
  26334. "httpRequestStatusCode",
  26335. "hwTimestamp",
  26336. "hyphenate-character",
  26337. "hyphenateCharacter",
  26338. "hyphens",
  26339. "hypot",
  26340. "i18n",
  26341. "ic",
  26342. "iccId",
  26343. "iceConnectionState",
  26344. "iceGatheringState",
  26345. "iceTransport",
  26346. "icon",
  26347. "iconURL",
  26348. "id",
  26349. "identifier",
  26350. "identity",
  26351. "ideographicBaseline",
  26352. "idle",
  26353. "idpLoginUrl",
  26354. "ignoreBOM",
  26355. "ignoreCase",
  26356. "ignoreDepthValues",
  26357. "image",
  26358. "image-orientation",
  26359. "image-rendering",
  26360. "imageHeight",
  26361. "imageOrientation",
  26362. "imageRendering",
  26363. "imageSizes",
  26364. "imageSmoothingEnabled",
  26365. "imageSmoothingQuality",
  26366. "imageSrcset",
  26367. "imageWidth",
  26368. "images",
  26369. "ime-mode",
  26370. "imeMode",
  26371. "implementation",
  26372. "importExternalTexture",
  26373. "importKey",
  26374. "importNode",
  26375. "importStylesheet",
  26376. "imports",
  26377. "impp",
  26378. "imul",
  26379. "in",
  26380. "in1",
  26381. "in2",
  26382. "inBandMetadataTrackDispatchType",
  26383. "inIncognitoContext",
  26384. "inRange",
  26385. "includes",
  26386. "incognito",
  26387. "incomingBidirectionalStreams",
  26388. "incomingHighWaterMark",
  26389. "incomingMaxAge",
  26390. "incomingUnidirectionalStreams",
  26391. "incremental",
  26392. "indeterminate",
  26393. "index",
  26394. "indexNames",
  26395. "indexOf",
  26396. "indexedDB",
  26397. "indicate",
  26398. "indices",
  26399. "inert",
  26400. "inertiaDestinationX",
  26401. "inertiaDestinationY",
  26402. "info",
  26403. "inherits",
  26404. "init",
  26405. "initAnimationEvent",
  26406. "initBeforeLoadEvent",
  26407. "initClipboardEvent",
  26408. "initCloseEvent",
  26409. "initCommandEvent",
  26410. "initCompositionEvent",
  26411. "initCustomEvent",
  26412. "initData",
  26413. "initDataType",
  26414. "initDeviceMotionEvent",
  26415. "initDeviceOrientationEvent",
  26416. "initDragEvent",
  26417. "initErrorEvent",
  26418. "initEvent",
  26419. "initFocusEvent",
  26420. "initGestureEvent",
  26421. "initHashChangeEvent",
  26422. "initKeyEvent",
  26423. "initKeyboardEvent",
  26424. "initMSManipulationEvent",
  26425. "initMessageEvent",
  26426. "initMouseEvent",
  26427. "initMouseScrollEvent",
  26428. "initMouseWheelEvent",
  26429. "initMutationEvent",
  26430. "initNSMouseEvent",
  26431. "initOverflowEvent",
  26432. "initPageEvent",
  26433. "initPageTransitionEvent",
  26434. "initPointerEvent",
  26435. "initPopStateEvent",
  26436. "initProgressEvent",
  26437. "initScrollAreaEvent",
  26438. "initSimpleGestureEvent",
  26439. "initStorageEvent",
  26440. "initTextEvent",
  26441. "initTimeEvent",
  26442. "initTouchEvent",
  26443. "initTransitionEvent",
  26444. "initUIEvent",
  26445. "initWebKitAnimationEvent",
  26446. "initWebKitTransitionEvent",
  26447. "initWebKitWheelEvent",
  26448. "initWheelEvent",
  26449. "initialTime",
  26450. "initialValue",
  26451. "initialize",
  26452. "initiatorType",
  26453. "inject",
  26454. "ink",
  26455. "inline-size",
  26456. "inlineSize",
  26457. "inlineVerticalFieldOfView",
  26458. "inner",
  26459. "innerHTML",
  26460. "innerHeight",
  26461. "innerText",
  26462. "innerWidth",
  26463. "input",
  26464. "inputBuffer",
  26465. "inputEncoding",
  26466. "inputMethod",
  26467. "inputMode",
  26468. "inputSource",
  26469. "inputSources",
  26470. "inputType",
  26471. "inputs",
  26472. "insertAdjacentElement",
  26473. "insertAdjacentHTML",
  26474. "insertAdjacentText",
  26475. "insertBefore",
  26476. "insertCell",
  26477. "insertDTMF",
  26478. "insertData",
  26479. "insertDebugMarker",
  26480. "insertItemBefore",
  26481. "insertNode",
  26482. "insertRow",
  26483. "insertRule",
  26484. "inset",
  26485. "inset-block",
  26486. "inset-block-end",
  26487. "inset-block-start",
  26488. "inset-inline",
  26489. "inset-inline-end",
  26490. "inset-inline-start",
  26491. "insetBlock",
  26492. "insetBlockEnd",
  26493. "insetBlockStart",
  26494. "insetInline",
  26495. "insetInlineEnd",
  26496. "insetInlineStart",
  26497. "install",
  26498. "installing",
  26499. "instanceRoot",
  26500. "instantiate",
  26501. "instantiateStreaming",
  26502. "instruments",
  26503. "int16",
  26504. "int32",
  26505. "int8",
  26506. "integrity",
  26507. "interactionId",
  26508. "interactionMode",
  26509. "intercept",
  26510. "interfaceClass",
  26511. "interfaceName",
  26512. "interfaceNumber",
  26513. "interfaceProtocol",
  26514. "interfaceSubclass",
  26515. "interfaces",
  26516. "interimResults",
  26517. "internalSubset",
  26518. "interpretation",
  26519. "intersection",
  26520. "intersectionRatio",
  26521. "intersectionRect",
  26522. "intersectsNode",
  26523. "interval",
  26524. "invalidIteratorState",
  26525. "invalidateFramebuffer",
  26526. "invalidateSubFramebuffer",
  26527. "inverse",
  26528. "invertSelf",
  26529. "invoker",
  26530. "invokerType",
  26531. "is",
  26532. "is2D",
  26533. "isActive",
  26534. "isAllowedFileSchemeAccess",
  26535. "isAllowedIncognitoAccess",
  26536. "isAlternate",
  26537. "isArray",
  26538. "isAutoSelected",
  26539. "isBingCurrentSearchDefault",
  26540. "isBuffer",
  26541. "isCandidateWindowVisible",
  26542. "isChar",
  26543. "isCollapsed",
  26544. "isComposing",
  26545. "isConcatSpreadable",
  26546. "isConditionalMediationAvailable",
  26547. "isConfigSupported",
  26548. "isConnected",
  26549. "isContentEditable",
  26550. "isContentHandlerRegistered",
  26551. "isContextLost",
  26552. "isDefaultNamespace",
  26553. "isDirectory",
  26554. "isDisabled",
  26555. "isDisjointFrom",
  26556. "isEnabled",
  26557. "isEqual",
  26558. "isEqualNode",
  26559. "isExtended",
  26560. "isExtensible",
  26561. "isExternalCTAP2SecurityKeySupported",
  26562. "isFallbackAdapter",
  26563. "isFile",
  26564. "isFinite",
  26565. "isFirstPersonObserver",
  26566. "isFramebuffer",
  26567. "isFrozen",
  26568. "isGenerator",
  26569. "isHTML",
  26570. "isHistoryNavigation",
  26571. "isId",
  26572. "isIdentity",
  26573. "isInjected",
  26574. "isInputPending",
  26575. "isInteger",
  26576. "isInternal",
  26577. "isIntersecting",
  26578. "isLockFree",
  26579. "isMap",
  26580. "isMultiLine",
  26581. "isNaN",
  26582. "isOpen",
  26583. "isPointInFill",
  26584. "isPointInPath",
  26585. "isPointInRange",
  26586. "isPointInStroke",
  26587. "isPrefAlternate",
  26588. "isPresenting",
  26589. "isPrimary",
  26590. "isProgram",
  26591. "isPropertyImplicit",
  26592. "isProtocolHandlerRegistered",
  26593. "isPrototypeOf",
  26594. "isQuery",
  26595. "isRawJSON",
  26596. "isRenderbuffer",
  26597. "isSafeInteger",
  26598. "isSameEntry",
  26599. "isSameNode",
  26600. "isSampler",
  26601. "isScript",
  26602. "isScriptURL",
  26603. "isSealed",
  26604. "isSecureContext",
  26605. "isSessionSupported",
  26606. "isShader",
  26607. "isSubsetOf",
  26608. "isSupersetOf",
  26609. "isSupported",
  26610. "isSync",
  26611. "isTextEdit",
  26612. "isTexture",
  26613. "isTransformFeedback",
  26614. "isTrusted",
  26615. "isTypeSupported",
  26616. "isUserVerifyingPlatformAuthenticatorAvailable",
  26617. "isVertexArray",
  26618. "isView",
  26619. "isVisible",
  26620. "isWellFormed",
  26621. "isochronousTransferIn",
  26622. "isochronousTransferOut",
  26623. "isolation",
  26624. "italics",
  26625. "item",
  26626. "itemId",
  26627. "itemProp",
  26628. "itemRef",
  26629. "itemScope",
  26630. "itemType",
  26631. "itemValue",
  26632. "items",
  26633. "iterateNext",
  26634. "iterationComposite",
  26635. "iterator",
  26636. "javaEnabled",
  26637. "jitterBufferTarget",
  26638. "jobTitle",
  26639. "join",
  26640. "joinAdInterestGroup",
  26641. "jointName",
  26642. "json",
  26643. "justify-content",
  26644. "justify-items",
  26645. "justify-self",
  26646. "justifyContent",
  26647. "justifyItems",
  26648. "justifySelf",
  26649. "k1",
  26650. "k2",
  26651. "k3",
  26652. "k4",
  26653. "kHz",
  26654. "keepalive",
  26655. "kernelMatrix",
  26656. "kernelUnitLengthX",
  26657. "kernelUnitLengthY",
  26658. "kerning",
  26659. "key",
  26660. "keyCode",
  26661. "keyFor",
  26662. "keyIdentifier",
  26663. "keyLightEnabled",
  26664. "keyLocation",
  26665. "keyPath",
  26666. "keyStatuses",
  26667. "keySystem",
  26668. "keyText",
  26669. "keyUsage",
  26670. "keyboard",
  26671. "keys",
  26672. "keytype",
  26673. "kind",
  26674. "knee",
  26675. "knownSources",
  26676. "label",
  26677. "labels",
  26678. "lang",
  26679. "language",
  26680. "languages",
  26681. "largeArcFlag",
  26682. "lastChild",
  26683. "lastElementChild",
  26684. "lastError",
  26685. "lastEventId",
  26686. "lastIndex",
  26687. "lastIndexOf",
  26688. "lastInputTime",
  26689. "lastMatch",
  26690. "lastMessageSubject",
  26691. "lastMessageType",
  26692. "lastModified",
  26693. "lastModifiedDate",
  26694. "lastPage",
  26695. "lastParen",
  26696. "lastState",
  26697. "lastStyleSheetSet",
  26698. "latency",
  26699. "latitude",
  26700. "launchQueue",
  26701. "layerName",
  26702. "layerX",
  26703. "layerY",
  26704. "layout",
  26705. "layoutFlow",
  26706. "layoutGrid",
  26707. "layoutGridChar",
  26708. "layoutGridLine",
  26709. "layoutGridMode",
  26710. "layoutGridType",
  26711. "lbound",
  26712. "leaveAdInterestGroup",
  26713. "left",
  26714. "leftContext",
  26715. "leftDegrees",
  26716. "leftMargin",
  26717. "leftProjectionMatrix",
  26718. "leftViewMatrix",
  26719. "length",
  26720. "lengthAdjust",
  26721. "lengthComputable",
  26722. "letter-spacing",
  26723. "letterSpacing",
  26724. "level",
  26725. "lh",
  26726. "lighting-color",
  26727. "lightingColor",
  26728. "limitingConeAngle",
  26729. "limits",
  26730. "line",
  26731. "line-break",
  26732. "line-height",
  26733. "lineAlign",
  26734. "lineBreak",
  26735. "lineCap",
  26736. "lineDashOffset",
  26737. "lineGapOverride",
  26738. "lineHeight",
  26739. "lineJoin",
  26740. "lineNum",
  26741. "lineNumber",
  26742. "linePos",
  26743. "lineTo",
  26744. "lineWidth",
  26745. "linearAcceleration",
  26746. "linearRampToValueAtTime",
  26747. "linearVelocity",
  26748. "lineno",
  26749. "lines",
  26750. "link",
  26751. "linkColor",
  26752. "linkProgram",
  26753. "links",
  26754. "list",
  26755. "list-style",
  26756. "list-style-image",
  26757. "list-style-position",
  26758. "list-style-type",
  26759. "listStyle",
  26760. "listStyleImage",
  26761. "listStylePosition",
  26762. "listStyleType",
  26763. "listener",
  26764. "listeners",
  26765. "load",
  26766. "loadEventEnd",
  26767. "loadEventStart",
  26768. "loadOp",
  26769. "loadTime",
  26770. "loadTimes",
  26771. "loaded",
  26772. "loading",
  26773. "localDescription",
  26774. "localName",
  26775. "localService",
  26776. "localStorage",
  26777. "locale",
  26778. "localeCompare",
  26779. "location",
  26780. "locationbar",
  26781. "lock",
  26782. "locked",
  26783. "lockedFile",
  26784. "locks",
  26785. "lodMaxClamp",
  26786. "lodMinClamp",
  26787. "log",
  26788. "log10",
  26789. "log1p",
  26790. "log2",
  26791. "logicalXDPI",
  26792. "logicalYDPI",
  26793. "login",
  26794. "loglevel",
  26795. "longDesc",
  26796. "longitude",
  26797. "lookupNamespaceURI",
  26798. "lookupPrefix",
  26799. "loop",
  26800. "loopEnd",
  26801. "loopStart",
  26802. "looping",
  26803. "lost",
  26804. "low",
  26805. "lower",
  26806. "lowerBound",
  26807. "lowerOpen",
  26808. "lowsrc",
  26809. "lvb",
  26810. "lvh",
  26811. "lvi",
  26812. "lvmax",
  26813. "lvmin",
  26814. "lvw",
  26815. "m11",
  26816. "m12",
  26817. "m13",
  26818. "m14",
  26819. "m21",
  26820. "m22",
  26821. "m23",
  26822. "m24",
  26823. "m31",
  26824. "m32",
  26825. "m33",
  26826. "m34",
  26827. "m41",
  26828. "m42",
  26829. "m43",
  26830. "m44",
  26831. "magFilter",
  26832. "makeXRCompatible",
  26833. "managed",
  26834. "management",
  26835. "manifest",
  26836. "manufacturer",
  26837. "manufacturerName",
  26838. "map",
  26839. "mapAsync",
  26840. "mapState",
  26841. "mappedAtCreation",
  26842. "mapping",
  26843. "margin",
  26844. "margin-block",
  26845. "margin-block-end",
  26846. "margin-block-start",
  26847. "margin-bottom",
  26848. "margin-inline",
  26849. "margin-inline-end",
  26850. "margin-inline-start",
  26851. "margin-left",
  26852. "margin-right",
  26853. "margin-top",
  26854. "marginBlock",
  26855. "marginBlockEnd",
  26856. "marginBlockStart",
  26857. "marginBottom",
  26858. "marginHeight",
  26859. "marginInline",
  26860. "marginInlineEnd",
  26861. "marginInlineStart",
  26862. "marginLeft",
  26863. "marginRight",
  26864. "marginTop",
  26865. "marginWidth",
  26866. "mark",
  26867. "marker",
  26868. "marker-end",
  26869. "marker-mid",
  26870. "marker-offset",
  26871. "marker-start",
  26872. "markerEnd",
  26873. "markerHeight",
  26874. "markerMid",
  26875. "markerOffset",
  26876. "markerStart",
  26877. "markerUnits",
  26878. "markerWidth",
  26879. "marks",
  26880. "mask",
  26881. "mask-clip",
  26882. "mask-composite",
  26883. "mask-image",
  26884. "mask-mode",
  26885. "mask-origin",
  26886. "mask-position",
  26887. "mask-position-x",
  26888. "mask-position-y",
  26889. "mask-repeat",
  26890. "mask-size",
  26891. "mask-type",
  26892. "maskClip",
  26893. "maskComposite",
  26894. "maskContentUnits",
  26895. "maskImage",
  26896. "maskMode",
  26897. "maskOrigin",
  26898. "maskPosition",
  26899. "maskPositionX",
  26900. "maskPositionY",
  26901. "maskRepeat",
  26902. "maskSize",
  26903. "maskType",
  26904. "maskUnits",
  26905. "match",
  26906. "matchAll",
  26907. "matchMedia",
  26908. "matchMedium",
  26909. "matchPatterns",
  26910. "matches",
  26911. "math-depth",
  26912. "math-style",
  26913. "mathDepth",
  26914. "mathStyle",
  26915. "matrix",
  26916. "matrixTransform",
  26917. "max",
  26918. "max-block-size",
  26919. "max-height",
  26920. "max-inline-size",
  26921. "max-width",
  26922. "maxActions",
  26923. "maxAlternatives",
  26924. "maxAnisotropy",
  26925. "maxBindGroups",
  26926. "maxBindGroupsPlusVertexBuffers",
  26927. "maxBindingsPerBindGroup",
  26928. "maxBlockSize",
  26929. "maxBufferSize",
  26930. "maxByteLength",
  26931. "maxChannelCount",
  26932. "maxChannels",
  26933. "maxColorAttachmentBytesPerSample",
  26934. "maxColorAttachments",
  26935. "maxComputeInvocationsPerWorkgroup",
  26936. "maxComputeWorkgroupSizeX",
  26937. "maxComputeWorkgroupSizeY",
  26938. "maxComputeWorkgroupSizeZ",
  26939. "maxComputeWorkgroupStorageSize",
  26940. "maxComputeWorkgroupsPerDimension",
  26941. "maxConnectionsPerServer",
  26942. "maxDatagramSize",
  26943. "maxDecibels",
  26944. "maxDistance",
  26945. "maxDrawCount",
  26946. "maxDynamicStorageBuffersPerPipelineLayout",
  26947. "maxDynamicUniformBuffersPerPipelineLayout",
  26948. "maxHeight",
  26949. "maxInlineSize",
  26950. "maxInterStageShaderComponents",
  26951. "maxInterStageShaderVariables",
  26952. "maxLayers",
  26953. "maxLength",
  26954. "maxMessageSize",
  26955. "maxPacketLifeTime",
  26956. "maxRetransmits",
  26957. "maxSampledTexturesPerShaderStage",
  26958. "maxSamplersPerShaderStage",
  26959. "maxStorageBufferBindingSize",
  26960. "maxStorageBuffersPerShaderStage",
  26961. "maxStorageTexturesPerShaderStage",
  26962. "maxTextureArrayLayers",
  26963. "maxTextureDimension1D",
  26964. "maxTextureDimension2D",
  26965. "maxTextureDimension3D",
  26966. "maxTouchPoints",
  26967. "maxUniformBufferBindingSize",
  26968. "maxUniformBuffersPerShaderStage",
  26969. "maxValue",
  26970. "maxVertexAttributes",
  26971. "maxVertexBufferArrayStride",
  26972. "maxVertexBuffers",
  26973. "maxWidth",
  26974. "maximumLatency",
  26975. "measure",
  26976. "measureText",
  26977. "media",
  26978. "mediaCapabilities",
  26979. "mediaDevices",
  26980. "mediaElement",
  26981. "mediaGroup",
  26982. "mediaKeys",
  26983. "mediaSession",
  26984. "mediaStream",
  26985. "mediaText",
  26986. "meetOrSlice",
  26987. "memory",
  26988. "menubar",
  26989. "menus",
  26990. "menusChild",
  26991. "menusInternal",
  26992. "mergeAttributes",
  26993. "message",
  26994. "messageClass",
  26995. "messageHandlers",
  26996. "messageType",
  26997. "messages",
  26998. "metaKey",
  26999. "metadata",
  27000. "method",
  27001. "methodDetails",
  27002. "methodName",
  27003. "mid",
  27004. "mimeType",
  27005. "mimeTypes",
  27006. "min",
  27007. "min-block-size",
  27008. "min-height",
  27009. "min-inline-size",
  27010. "min-width",
  27011. "minBindingSize",
  27012. "minBlockSize",
  27013. "minDecibels",
  27014. "minFilter",
  27015. "minHeight",
  27016. "minInlineSize",
  27017. "minLength",
  27018. "minStorageBufferOffsetAlignment",
  27019. "minUniformBufferOffsetAlignment",
  27020. "minValue",
  27021. "minWidth",
  27022. "minimumLatency",
  27023. "mipLevel",
  27024. "mipLevelCount",
  27025. "mipmapFilter",
  27026. "miterLimit",
  27027. "mix-blend-mode",
  27028. "mixBlendMode",
  27029. "mm",
  27030. "mobile",
  27031. "mode",
  27032. "model",
  27033. "modify",
  27034. "module",
  27035. "mount",
  27036. "move",
  27037. "moveBy",
  27038. "moveEnd",
  27039. "moveFirst",
  27040. "moveFocusDown",
  27041. "moveFocusLeft",
  27042. "moveFocusRight",
  27043. "moveFocusUp",
  27044. "moveInSuccession",
  27045. "moveNext",
  27046. "moveRow",
  27047. "moveStart",
  27048. "moveTo",
  27049. "moveToBookmark",
  27050. "moveToElementText",
  27051. "moveToPoint",
  27052. "movementX",
  27053. "movementY",
  27054. "mozAdd",
  27055. "mozAnimationStartTime",
  27056. "mozAnon",
  27057. "mozApps",
  27058. "mozAudioCaptured",
  27059. "mozAudioChannelType",
  27060. "mozAutoplayEnabled",
  27061. "mozCancelAnimationFrame",
  27062. "mozCancelFullScreen",
  27063. "mozCancelRequestAnimationFrame",
  27064. "mozCaptureStream",
  27065. "mozCaptureStreamUntilEnded",
  27066. "mozClearDataAt",
  27067. "mozContact",
  27068. "mozContacts",
  27069. "mozCreateFileHandle",
  27070. "mozCurrentTransform",
  27071. "mozCurrentTransformInverse",
  27072. "mozCursor",
  27073. "mozDash",
  27074. "mozDashOffset",
  27075. "mozDecodedFrames",
  27076. "mozExitPointerLock",
  27077. "mozFillRule",
  27078. "mozFragmentEnd",
  27079. "mozFrameDelay",
  27080. "mozFullScreen",
  27081. "mozFullScreenElement",
  27082. "mozFullScreenEnabled",
  27083. "mozGetAll",
  27084. "mozGetAllKeys",
  27085. "mozGetAsFile",
  27086. "mozGetDataAt",
  27087. "mozGetMetadata",
  27088. "mozGetUserMedia",
  27089. "mozHasAudio",
  27090. "mozHasItem",
  27091. "mozHidden",
  27092. "mozImageSmoothingEnabled",
  27093. "mozIndexedDB",
  27094. "mozInnerScreenX",
  27095. "mozInnerScreenY",
  27096. "mozInputSource",
  27097. "mozIsTextField",
  27098. "mozItem",
  27099. "mozItemCount",
  27100. "mozItems",
  27101. "mozLength",
  27102. "mozLockOrientation",
  27103. "mozMatchesSelector",
  27104. "mozMovementX",
  27105. "mozMovementY",
  27106. "mozOpaque",
  27107. "mozOrientation",
  27108. "mozPaintCount",
  27109. "mozPaintedFrames",
  27110. "mozParsedFrames",
  27111. "mozPay",
  27112. "mozPointerLockElement",
  27113. "mozPresentedFrames",
  27114. "mozPreservesPitch",
  27115. "mozPressure",
  27116. "mozPrintCallback",
  27117. "mozRTCIceCandidate",
  27118. "mozRTCPeerConnection",
  27119. "mozRTCSessionDescription",
  27120. "mozRemove",
  27121. "mozRequestAnimationFrame",
  27122. "mozRequestFullScreen",
  27123. "mozRequestPointerLock",
  27124. "mozSetDataAt",
  27125. "mozSetImageElement",
  27126. "mozSourceNode",
  27127. "mozSrcObject",
  27128. "mozSystem",
  27129. "mozTCPSocket",
  27130. "mozTextStyle",
  27131. "mozTypesAt",
  27132. "mozUnlockOrientation",
  27133. "mozUserCancelled",
  27134. "mozVisibilityState",
  27135. "ms",
  27136. "msAnimation",
  27137. "msAnimationDelay",
  27138. "msAnimationDirection",
  27139. "msAnimationDuration",
  27140. "msAnimationFillMode",
  27141. "msAnimationIterationCount",
  27142. "msAnimationName",
  27143. "msAnimationPlayState",
  27144. "msAnimationStartTime",
  27145. "msAnimationTimingFunction",
  27146. "msBackfaceVisibility",
  27147. "msBlockProgression",
  27148. "msCSSOMElementFloatMetrics",
  27149. "msCaching",
  27150. "msCachingEnabled",
  27151. "msCancelRequestAnimationFrame",
  27152. "msCapsLockWarningOff",
  27153. "msClearImmediate",
  27154. "msClose",
  27155. "msContentZoomChaining",
  27156. "msContentZoomFactor",
  27157. "msContentZoomLimit",
  27158. "msContentZoomLimitMax",
  27159. "msContentZoomLimitMin",
  27160. "msContentZoomSnap",
  27161. "msContentZoomSnapPoints",
  27162. "msContentZoomSnapType",
  27163. "msContentZooming",
  27164. "msConvertURL",
  27165. "msCrypto",
  27166. "msDoNotTrack",
  27167. "msElementsFromPoint",
  27168. "msElementsFromRect",
  27169. "msExitFullscreen",
  27170. "msExtendedCode",
  27171. "msFillRule",
  27172. "msFirstPaint",
  27173. "msFlex",
  27174. "msFlexAlign",
  27175. "msFlexDirection",
  27176. "msFlexFlow",
  27177. "msFlexItemAlign",
  27178. "msFlexLinePack",
  27179. "msFlexNegative",
  27180. "msFlexOrder",
  27181. "msFlexPack",
  27182. "msFlexPositive",
  27183. "msFlexPreferredSize",
  27184. "msFlexWrap",
  27185. "msFlowFrom",
  27186. "msFlowInto",
  27187. "msFontFeatureSettings",
  27188. "msFullscreenElement",
  27189. "msFullscreenEnabled",
  27190. "msGetInputContext",
  27191. "msGetRegionContent",
  27192. "msGetUntransformedBounds",
  27193. "msGraphicsTrustStatus",
  27194. "msGridColumn",
  27195. "msGridColumnAlign",
  27196. "msGridColumnSpan",
  27197. "msGridColumns",
  27198. "msGridRow",
  27199. "msGridRowAlign",
  27200. "msGridRowSpan",
  27201. "msGridRows",
  27202. "msHidden",
  27203. "msHighContrastAdjust",
  27204. "msHyphenateLimitChars",
  27205. "msHyphenateLimitLines",
  27206. "msHyphenateLimitZone",
  27207. "msHyphens",
  27208. "msImageSmoothingEnabled",
  27209. "msImeAlign",
  27210. "msIndexedDB",
  27211. "msInterpolationMode",
  27212. "msIsStaticHTML",
  27213. "msKeySystem",
  27214. "msKeys",
  27215. "msLaunchUri",
  27216. "msLockOrientation",
  27217. "msManipulationViewsEnabled",
  27218. "msMatchMedia",
  27219. "msMatchesSelector",
  27220. "msMaxTouchPoints",
  27221. "msOrientation",
  27222. "msOverflowStyle",
  27223. "msPerspective",
  27224. "msPerspectiveOrigin",
  27225. "msPlayToDisabled",
  27226. "msPlayToPreferredSourceUri",
  27227. "msPlayToPrimary",
  27228. "msPointerEnabled",
  27229. "msRegionOverflow",
  27230. "msReleasePointerCapture",
  27231. "msRequestAnimationFrame",
  27232. "msRequestFullscreen",
  27233. "msSaveBlob",
  27234. "msSaveOrOpenBlob",
  27235. "msScrollChaining",
  27236. "msScrollLimit",
  27237. "msScrollLimitXMax",
  27238. "msScrollLimitXMin",
  27239. "msScrollLimitYMax",
  27240. "msScrollLimitYMin",
  27241. "msScrollRails",
  27242. "msScrollSnapPointsX",
  27243. "msScrollSnapPointsY",
  27244. "msScrollSnapType",
  27245. "msScrollSnapX",
  27246. "msScrollSnapY",
  27247. "msScrollTranslation",
  27248. "msSetImmediate",
  27249. "msSetMediaKeys",
  27250. "msSetPointerCapture",
  27251. "msTextCombineHorizontal",
  27252. "msTextSizeAdjust",
  27253. "msToBlob",
  27254. "msTouchAction",
  27255. "msTouchSelect",
  27256. "msTraceAsyncCallbackCompleted",
  27257. "msTraceAsyncCallbackStarting",
  27258. "msTraceAsyncOperationCompleted",
  27259. "msTraceAsyncOperationStarting",
  27260. "msTransform",
  27261. "msTransformOrigin",
  27262. "msTransformStyle",
  27263. "msTransition",
  27264. "msTransitionDelay",
  27265. "msTransitionDuration",
  27266. "msTransitionProperty",
  27267. "msTransitionTimingFunction",
  27268. "msUnlockOrientation",
  27269. "msUpdateAsyncCallbackRelation",
  27270. "msUserSelect",
  27271. "msVisibilityState",
  27272. "msWrapFlow",
  27273. "msWrapMargin",
  27274. "msWrapThrough",
  27275. "msWriteProfilerMark",
  27276. "msZoom",
  27277. "msZoomTo",
  27278. "mt",
  27279. "mul",
  27280. "multiEntry",
  27281. "multiSelectionObj",
  27282. "multiline",
  27283. "multiple",
  27284. "multiply",
  27285. "multiplySelf",
  27286. "multisample",
  27287. "multisampled",
  27288. "mutableFile",
  27289. "muted",
  27290. "n",
  27291. "nacl_arch",
  27292. "name",
  27293. "nameList",
  27294. "nameProp",
  27295. "namedItem",
  27296. "namedRecordset",
  27297. "names",
  27298. "namespaceURI",
  27299. "namespaces",
  27300. "nativeApplication",
  27301. "nativeMap",
  27302. "nativeObjectCreate",
  27303. "nativeSet",
  27304. "nativeWeakMap",
  27305. "naturalHeight",
  27306. "naturalWidth",
  27307. "navigate",
  27308. "navigation",
  27309. "navigationMode",
  27310. "navigationPreload",
  27311. "navigationStart",
  27312. "navigationType",
  27313. "navigator",
  27314. "near",
  27315. "nearestViewportElement",
  27316. "negative",
  27317. "negotiated",
  27318. "netscape",
  27319. "networkState",
  27320. "networkStatus",
  27321. "newScale",
  27322. "newState",
  27323. "newTranslate",
  27324. "newURL",
  27325. "newValue",
  27326. "newValueSpecifiedUnits",
  27327. "newVersion",
  27328. "newhome",
  27329. "next",
  27330. "nextElementSibling",
  27331. "nextHopProtocol",
  27332. "nextNode",
  27333. "nextPage",
  27334. "nextSibling",
  27335. "nickname",
  27336. "noHref",
  27337. "noModule",
  27338. "noResize",
  27339. "noShade",
  27340. "noValidate",
  27341. "noWrap",
  27342. "node",
  27343. "nodeName",
  27344. "nodeType",
  27345. "nodeValue",
  27346. "nonce",
  27347. "normDepthBufferFromNormView",
  27348. "normalize",
  27349. "normalizedPathSegList",
  27350. "normandyAddonStudy",
  27351. "notRestoredReasons",
  27352. "notationName",
  27353. "notations",
  27354. "note",
  27355. "noteGrainOn",
  27356. "noteOff",
  27357. "noteOn",
  27358. "notifications",
  27359. "notify",
  27360. "now",
  27361. "npnNegotiatedProtocol",
  27362. "numOctaves",
  27363. "number",
  27364. "numberOfChannels",
  27365. "numberOfFrames",
  27366. "numberOfInputs",
  27367. "numberOfItems",
  27368. "numberOfOutputs",
  27369. "numberValue",
  27370. "oMatchesSelector",
  27371. "object",
  27372. "object-fit",
  27373. "object-position",
  27374. "objectFit",
  27375. "objectPosition",
  27376. "objectStore",
  27377. "objectStoreNames",
  27378. "objectType",
  27379. "observe",
  27380. "occlusionQuerySet",
  27381. "of",
  27382. "off",
  27383. "offscreenBuffering",
  27384. "offset",
  27385. "offset-anchor",
  27386. "offset-distance",
  27387. "offset-path",
  27388. "offset-position",
  27389. "offset-rotate",
  27390. "offsetAnchor",
  27391. "offsetDistance",
  27392. "offsetHeight",
  27393. "offsetLeft",
  27394. "offsetNode",
  27395. "offsetParent",
  27396. "offsetPath",
  27397. "offsetPosition",
  27398. "offsetRotate",
  27399. "offsetTop",
  27400. "offsetWidth",
  27401. "offsetX",
  27402. "offsetY",
  27403. "ok",
  27404. "oldState",
  27405. "oldURL",
  27406. "oldValue",
  27407. "oldVersion",
  27408. "olderShadowRoot",
  27409. "omnibox",
  27410. "on",
  27411. "onActivated",
  27412. "onAdded",
  27413. "onAttached",
  27414. "onBoundsChanged",
  27415. "onBrowserUpdateAvailable",
  27416. "onClicked",
  27417. "onCommitFiberRoot",
  27418. "onCommitFiberUnmount",
  27419. "onConnect",
  27420. "onConnectExternal",
  27421. "onConnectNative",
  27422. "onCreated",
  27423. "onDetached",
  27424. "onDisabled",
  27425. "onEnabled",
  27426. "onFocusChanged",
  27427. "onHighlighted",
  27428. "onInstalled",
  27429. "onLine",
  27430. "onMessage",
  27431. "onMessageExternal",
  27432. "onMoved",
  27433. "onPerformanceWarning",
  27434. "onPostCommitFiberRoot",
  27435. "onRemoved",
  27436. "onReplaced",
  27437. "onRestartRequired",
  27438. "onStartup",
  27439. "onSubmittedWorkDone",
  27440. "onSuspend",
  27441. "onSuspendCanceled",
  27442. "onUninstalled",
  27443. "onUpdateAvailable",
  27444. "onUpdated",
  27445. "onUserScriptConnect",
  27446. "onUserScriptMessage",
  27447. "onUserSettingsChanged",
  27448. "onZoomChange",
  27449. "onabort",
  27450. "onabsolutedeviceorientation",
  27451. "onactivate",
  27452. "onactive",
  27453. "onaddsourcebuffer",
  27454. "onaddstream",
  27455. "onaddtrack",
  27456. "onafterprint",
  27457. "onafterscriptexecute",
  27458. "onafterupdate",
  27459. "onanimationcancel",
  27460. "onanimationend",
  27461. "onanimationiteration",
  27462. "onanimationstart",
  27463. "onappinstalled",
  27464. "onaudioend",
  27465. "onaudioprocess",
  27466. "onaudiostart",
  27467. "onautocomplete",
  27468. "onautocompleteerror",
  27469. "onauxclick",
  27470. "onbeforeactivate",
  27471. "onbeforecopy",
  27472. "onbeforecut",
  27473. "onbeforedeactivate",
  27474. "onbeforeeditfocus",
  27475. "onbeforeinput",
  27476. "onbeforeinstallprompt",
  27477. "onbeforematch",
  27478. "onbeforepaste",
  27479. "onbeforeprint",
  27480. "onbeforescriptexecute",
  27481. "onbeforetoggle",
  27482. "onbeforeunload",
  27483. "onbeforeupdate",
  27484. "onbeforexrselect",
  27485. "onbegin",
  27486. "onblocked",
  27487. "onblur",
  27488. "onbounce",
  27489. "onboundary",
  27490. "onbufferedamountlow",
  27491. "oncached",
  27492. "oncancel",
  27493. "oncandidatewindowhide",
  27494. "oncandidatewindowshow",
  27495. "oncandidatewindowupdate",
  27496. "oncanplay",
  27497. "oncanplaythrough",
  27498. "oncapturehandlechange",
  27499. "once",
  27500. "oncellchange",
  27501. "onchange",
  27502. "oncharacterboundsupdate",
  27503. "oncharacteristicvaluechanged",
  27504. "onchargingchange",
  27505. "onchargingtimechange",
  27506. "onchecking",
  27507. "onclick",
  27508. "onclose",
  27509. "onclosing",
  27510. "oncompassneedscalibration",
  27511. "oncomplete",
  27512. "oncompositionend",
  27513. "oncompositionstart",
  27514. "onconnect",
  27515. "onconnecting",
  27516. "onconnectionavailable",
  27517. "onconnectionstatechange",
  27518. "oncontentvisibilityautostatechange",
  27519. "oncontextlost",
  27520. "oncontextmenu",
  27521. "oncontextrestored",
  27522. "oncontrollerchange",
  27523. "oncontrolselect",
  27524. "oncopy",
  27525. "oncuechange",
  27526. "oncurrententrychange",
  27527. "oncurrentscreenchange",
  27528. "oncut",
  27529. "ondataavailable",
  27530. "ondatachannel",
  27531. "ondatasetchanged",
  27532. "ondatasetcomplete",
  27533. "ondblclick",
  27534. "ondeactivate",
  27535. "ondequeue",
  27536. "ondevicechange",
  27537. "ondevicelight",
  27538. "ondevicemotion",
  27539. "ondeviceorientation",
  27540. "ondeviceorientationabsolute",
  27541. "ondeviceproximity",
  27542. "ondischargingtimechange",
  27543. "ondisconnect",
  27544. "ondisplay",
  27545. "ondispose",
  27546. "ondownloading",
  27547. "ondrag",
  27548. "ondragend",
  27549. "ondragenter",
  27550. "ondragexit",
  27551. "ondragleave",
  27552. "ondragover",
  27553. "ondragstart",
  27554. "ondrop",
  27555. "ondurationchange",
  27556. "onemptied",
  27557. "onencrypted",
  27558. "onend",
  27559. "onended",
  27560. "onenter",
  27561. "onenterpictureinpicture",
  27562. "onerror",
  27563. "onerrorupdate",
  27564. "onexit",
  27565. "onfencedtreeclick",
  27566. "onfilterchange",
  27567. "onfinish",
  27568. "onfocus",
  27569. "onfocusin",
  27570. "onfocusout",
  27571. "onformdata",
  27572. "onfreeze",
  27573. "onfullscreenchange",
  27574. "onfullscreenerror",
  27575. "ongamepadconnected",
  27576. "ongamepaddisconnected",
  27577. "ongatheringstatechange",
  27578. "ongattserverdisconnected",
  27579. "ongeometrychange",
  27580. "ongesturechange",
  27581. "ongestureend",
  27582. "ongesturestart",
  27583. "ongotpointercapture",
  27584. "onhashchange",
  27585. "onhelp",
  27586. "onicecandidate",
  27587. "onicecandidateerror",
  27588. "oniceconnectionstatechange",
  27589. "onicegatheringstatechange",
  27590. "oninactive",
  27591. "oninput",
  27592. "oninputreport",
  27593. "oninputsourceschange",
  27594. "oninvalid",
  27595. "onkeydown",
  27596. "onkeypress",
  27597. "onkeystatuseschange",
  27598. "onkeyup",
  27599. "onlanguagechange",
  27600. "onlayoutcomplete",
  27601. "onleavepictureinpicture",
  27602. "onlevelchange",
  27603. "onload",
  27604. "onloadT",
  27605. "onloadeddata",
  27606. "onloadedmetadata",
  27607. "onloadend",
  27608. "onloading",
  27609. "onloadingdone",
  27610. "onloadingerror",
  27611. "onloadstart",
  27612. "onlosecapture",
  27613. "onlostpointercapture",
  27614. "only",
  27615. "onmanagedconfigurationchange",
  27616. "onmark",
  27617. "onmessage",
  27618. "onmessageerror",
  27619. "onmidimessage",
  27620. "onmousedown",
  27621. "onmouseenter",
  27622. "onmouseleave",
  27623. "onmousemove",
  27624. "onmouseout",
  27625. "onmouseover",
  27626. "onmouseup",
  27627. "onmousewheel",
  27628. "onmove",
  27629. "onmoveend",
  27630. "onmovestart",
  27631. "onmozfullscreenchange",
  27632. "onmozfullscreenerror",
  27633. "onmozorientationchange",
  27634. "onmozpointerlockchange",
  27635. "onmozpointerlockerror",
  27636. "onmscontentzoom",
  27637. "onmsfullscreenchange",
  27638. "onmsfullscreenerror",
  27639. "onmsgesturechange",
  27640. "onmsgesturedoubletap",
  27641. "onmsgestureend",
  27642. "onmsgesturehold",
  27643. "onmsgesturestart",
  27644. "onmsgesturetap",
  27645. "onmsgotpointercapture",
  27646. "onmsinertiastart",
  27647. "onmslostpointercapture",
  27648. "onmsmanipulationstatechanged",
  27649. "onmsneedkey",
  27650. "onmsorientationchange",
  27651. "onmspointercancel",
  27652. "onmspointerdown",
  27653. "onmspointerenter",
  27654. "onmspointerhover",
  27655. "onmspointerleave",
  27656. "onmspointermove",
  27657. "onmspointerout",
  27658. "onmspointerover",
  27659. "onmspointerup",
  27660. "onmssitemodejumplistitemremoved",
  27661. "onmsthumbnailclick",
  27662. "onmute",
  27663. "onnavigate",
  27664. "onnavigateerror",
  27665. "onnavigatesuccess",
  27666. "onnegotiationneeded",
  27667. "onnomatch",
  27668. "onnoupdate",
  27669. "onobsolete",
  27670. "onoffline",
  27671. "ononline",
  27672. "onopen",
  27673. "onorientationchange",
  27674. "onpagechange",
  27675. "onpagehide",
  27676. "onpagereveal",
  27677. "onpageshow",
  27678. "onpageswap",
  27679. "onpaste",
  27680. "onpause",
  27681. "onpayerdetailchange",
  27682. "onpaymentmethodchange",
  27683. "onplay",
  27684. "onplaying",
  27685. "onpluginstreamstart",
  27686. "onpointercancel",
  27687. "onpointerdown",
  27688. "onpointerenter",
  27689. "onpointerleave",
  27690. "onpointerlockchange",
  27691. "onpointerlockerror",
  27692. "onpointermove",
  27693. "onpointerout",
  27694. "onpointerover",
  27695. "onpointerrawupdate",
  27696. "onpointerup",
  27697. "onpopstate",
  27698. "onprerenderingchange",
  27699. "onprioritychange",
  27700. "onprocessorerror",
  27701. "onprogress",
  27702. "onpropertychange",
  27703. "onratechange",
  27704. "onreading",
  27705. "onreadystatechange",
  27706. "onreflectionchange",
  27707. "onrejectionhandled",
  27708. "onrelease",
  27709. "onremove",
  27710. "onremovesourcebuffer",
  27711. "onremovestream",
  27712. "onremovetrack",
  27713. "onrepeat",
  27714. "onreset",
  27715. "onresize",
  27716. "onresizeend",
  27717. "onresizestart",
  27718. "onresourcetimingbufferfull",
  27719. "onresult",
  27720. "onresume",
  27721. "onrowenter",
  27722. "onrowexit",
  27723. "onrowsdelete",
  27724. "onrowsinserted",
  27725. "onscreenschange",
  27726. "onscroll",
  27727. "onscrollend",
  27728. "onscrollsnapchange",
  27729. "onscrollsnapchanging",
  27730. "onsearch",
  27731. "onsecuritypolicyviolation",
  27732. "onseeked",
  27733. "onseeking",
  27734. "onselect",
  27735. "onselectedcandidatepairchange",
  27736. "onselectend",
  27737. "onselectionchange",
  27738. "onselectstart",
  27739. "onshippingaddresschange",
  27740. "onshippingoptionchange",
  27741. "onshow",
  27742. "onsignalingstatechange",
  27743. "onsinkchange",
  27744. "onslotchange",
  27745. "onsoundend",
  27746. "onsoundstart",
  27747. "onsourceclose",
  27748. "onsourceclosed",
  27749. "onsourceended",
  27750. "onsourceopen",
  27751. "onspeechend",
  27752. "onspeechstart",
  27753. "onsqueeze",
  27754. "onsqueezeend",
  27755. "onsqueezestart",
  27756. "onstalled",
  27757. "onstart",
  27758. "onstatechange",
  27759. "onstop",
  27760. "onstorage",
  27761. "onstoragecommit",
  27762. "onsubmit",
  27763. "onsuccess",
  27764. "onsuspend",
  27765. "onterminate",
  27766. "ontextformatupdate",
  27767. "ontextinput",
  27768. "ontextupdate",
  27769. "ontimeout",
  27770. "ontimeupdate",
  27771. "ontoggle",
  27772. "ontonechange",
  27773. "ontouchcancel",
  27774. "ontouchend",
  27775. "ontouchmove",
  27776. "ontouchstart",
  27777. "ontrack",
  27778. "ontransitioncancel",
  27779. "ontransitionend",
  27780. "ontransitionrun",
  27781. "ontransitionstart",
  27782. "onuncapturederror",
  27783. "onunhandledrejection",
  27784. "onunload",
  27785. "onunmute",
  27786. "onupdate",
  27787. "onupdateend",
  27788. "onupdatefound",
  27789. "onupdateready",
  27790. "onupdatestart",
  27791. "onupgradeneeded",
  27792. "onuserproximity",
  27793. "onversionchange",
  27794. "onvisibilitychange",
  27795. "onvoiceschanged",
  27796. "onvolumechange",
  27797. "onvrdisplayactivate",
  27798. "onvrdisplayconnect",
  27799. "onvrdisplaydeactivate",
  27800. "onvrdisplaydisconnect",
  27801. "onvrdisplaypresentchange",
  27802. "onwaiting",
  27803. "onwaitingforkey",
  27804. "onwarning",
  27805. "onwebkitanimationend",
  27806. "onwebkitanimationiteration",
  27807. "onwebkitanimationstart",
  27808. "onwebkitcurrentplaybacktargetiswirelesschanged",
  27809. "onwebkitfullscreenchange",
  27810. "onwebkitfullscreenerror",
  27811. "onwebkitkeyadded",
  27812. "onwebkitkeyerror",
  27813. "onwebkitkeymessage",
  27814. "onwebkitneedkey",
  27815. "onwebkitorientationchange",
  27816. "onwebkitplaybacktargetavailabilitychanged",
  27817. "onwebkitpointerlockchange",
  27818. "onwebkitpointerlockerror",
  27819. "onwebkitresourcetimingbufferfull",
  27820. "onwebkittransitionend",
  27821. "onwheel",
  27822. "onzoom",
  27823. "opacity",
  27824. "open",
  27825. "openCursor",
  27826. "openDatabase",
  27827. "openKeyCursor",
  27828. "openOptionsPage",
  27829. "openOrClosedShadowRoot",
  27830. "openPopup",
  27831. "opened",
  27832. "opener",
  27833. "opera",
  27834. "operation",
  27835. "operationType",
  27836. "operator",
  27837. "opr",
  27838. "optimum",
  27839. "options",
  27840. "or",
  27841. "order",
  27842. "orderX",
  27843. "orderY",
  27844. "ordered",
  27845. "org",
  27846. "organization",
  27847. "orient",
  27848. "orientAngle",
  27849. "orientType",
  27850. "orientation",
  27851. "orientationX",
  27852. "orientationY",
  27853. "orientationZ",
  27854. "origin",
  27855. "originAgentCluster",
  27856. "originalPolicy",
  27857. "originalTarget",
  27858. "orphans",
  27859. "os",
  27860. "oscpu",
  27861. "outerHTML",
  27862. "outerHeight",
  27863. "outerText",
  27864. "outerWidth",
  27865. "outgoingHighWaterMark",
  27866. "outgoingMaxAge",
  27867. "outline",
  27868. "outline-color",
  27869. "outline-offset",
  27870. "outline-style",
  27871. "outline-width",
  27872. "outlineColor",
  27873. "outlineOffset",
  27874. "outlineStyle",
  27875. "outlineWidth",
  27876. "outputBuffer",
  27877. "outputChannelCount",
  27878. "outputLatency",
  27879. "outputs",
  27880. "overflow",
  27881. "overflow-anchor",
  27882. "overflow-block",
  27883. "overflow-clip-margin",
  27884. "overflow-inline",
  27885. "overflow-wrap",
  27886. "overflow-x",
  27887. "overflow-y",
  27888. "overflowAnchor",
  27889. "overflowBlock",
  27890. "overflowClipMargin",
  27891. "overflowInline",
  27892. "overflowWrap",
  27893. "overflowX",
  27894. "overflowY",
  27895. "overlaysContent",
  27896. "overrideColors",
  27897. "overrideMimeType",
  27898. "oversample",
  27899. "overscroll-behavior",
  27900. "overscroll-behavior-block",
  27901. "overscroll-behavior-inline",
  27902. "overscroll-behavior-x",
  27903. "overscroll-behavior-y",
  27904. "overscrollBehavior",
  27905. "overscrollBehaviorBlock",
  27906. "overscrollBehaviorInline",
  27907. "overscrollBehaviorX",
  27908. "overscrollBehaviorY",
  27909. "ownKeys",
  27910. "ownerDocument",
  27911. "ownerElement",
  27912. "ownerNode",
  27913. "ownerRule",
  27914. "ownerSVGElement",
  27915. "owningElement",
  27916. "p1",
  27917. "p2",
  27918. "p3",
  27919. "p4",
  27920. "packetSize",
  27921. "packets",
  27922. "pad",
  27923. "padEnd",
  27924. "padStart",
  27925. "padding",
  27926. "padding-block",
  27927. "padding-block-end",
  27928. "padding-block-start",
  27929. "padding-bottom",
  27930. "padding-inline",
  27931. "padding-inline-end",
  27932. "padding-inline-start",
  27933. "padding-left",
  27934. "padding-right",
  27935. "padding-top",
  27936. "paddingBlock",
  27937. "paddingBlockEnd",
  27938. "paddingBlockStart",
  27939. "paddingBottom",
  27940. "paddingInline",
  27941. "paddingInlineEnd",
  27942. "paddingInlineStart",
  27943. "paddingLeft",
  27944. "paddingRight",
  27945. "paddingTop",
  27946. "page",
  27947. "page-break-after",
  27948. "page-break-before",
  27949. "page-break-inside",
  27950. "page-orientation",
  27951. "pageAction",
  27952. "pageBreakAfter",
  27953. "pageBreakBefore",
  27954. "pageBreakInside",
  27955. "pageCount",
  27956. "pageLeft",
  27957. "pageOrientation",
  27958. "pageT",
  27959. "pageTop",
  27960. "pageX",
  27961. "pageXOffset",
  27962. "pageY",
  27963. "pageYOffset",
  27964. "pages",
  27965. "paint-order",
  27966. "paintOrder",
  27967. "paintRequests",
  27968. "paintType",
  27969. "paintWorklet",
  27970. "palette",
  27971. "pan",
  27972. "panningModel",
  27973. "parameterData",
  27974. "parameters",
  27975. "parent",
  27976. "parentElement",
  27977. "parentNode",
  27978. "parentRule",
  27979. "parentStyleSheet",
  27980. "parentTextEdit",
  27981. "parentWindow",
  27982. "parse",
  27983. "parseAll",
  27984. "parseCreationOptionsFromJSON",
  27985. "parseFloat",
  27986. "parseFromString",
  27987. "parseHTMLUnsafe",
  27988. "parseInt",
  27989. "parseRequestOptionsFromJSON",
  27990. "part",
  27991. "participants",
  27992. "passOp",
  27993. "passive",
  27994. "password",
  27995. "pasteHTML",
  27996. "path",
  27997. "pathLength",
  27998. "pathSegList",
  27999. "pathSegType",
  28000. "pathSegTypeAsLetter",
  28001. "pathname",
  28002. "pattern",
  28003. "patternContentUnits",
  28004. "patternMismatch",
  28005. "patternTransform",
  28006. "patternUnits",
  28007. "pause",
  28008. "pauseAnimations",
  28009. "pauseDuration",
  28010. "pauseOnExit",
  28011. "pauseProfilers",
  28012. "pauseTransformFeedback",
  28013. "paused",
  28014. "payerEmail",
  28015. "payerName",
  28016. "payerPhone",
  28017. "paymentManager",
  28018. "pc",
  28019. "pdfViewerEnabled",
  28020. "peerIdentity",
  28021. "pending",
  28022. "pendingLocalDescription",
  28023. "pendingRemoteDescription",
  28024. "percent",
  28025. "performance",
  28026. "periodicSync",
  28027. "permission",
  28028. "permissionState",
  28029. "permissions",
  28030. "persist",
  28031. "persisted",
  28032. "persistentDeviceId",
  28033. "personalbar",
  28034. "perspective",
  28035. "perspective-origin",
  28036. "perspectiveOrigin",
  28037. "phone",
  28038. "phoneticFamilyName",
  28039. "phoneticGivenName",
  28040. "photo",
  28041. "pictureInPictureChild",
  28042. "pictureInPictureElement",
  28043. "pictureInPictureEnabled",
  28044. "pictureInPictureWindow",
  28045. "ping",
  28046. "pipeThrough",
  28047. "pipeTo",
  28048. "pitch",
  28049. "pixelBottom",
  28050. "pixelDepth",
  28051. "pixelHeight",
  28052. "pixelLeft",
  28053. "pixelRight",
  28054. "pixelStorei",
  28055. "pixelTop",
  28056. "pixelUnitToMillimeterX",
  28057. "pixelUnitToMillimeterY",
  28058. "pixelWidth",
  28059. "pkcs11",
  28060. "place-content",
  28061. "place-items",
  28062. "place-self",
  28063. "placeContent",
  28064. "placeItems",
  28065. "placeSelf",
  28066. "placeholder",
  28067. "platform",
  28068. "platformVersion",
  28069. "platforms",
  28070. "play",
  28071. "playEffect",
  28072. "playState",
  28073. "playbackRate",
  28074. "playbackState",
  28075. "playbackTime",
  28076. "played",
  28077. "playoutDelayHint",
  28078. "playsInline",
  28079. "plugins",
  28080. "pluginspage",
  28081. "pname",
  28082. "pointer-events",
  28083. "pointerBeforeReferenceNode",
  28084. "pointerEnabled",
  28085. "pointerEvents",
  28086. "pointerId",
  28087. "pointerLockElement",
  28088. "pointerType",
  28089. "points",
  28090. "pointsAtX",
  28091. "pointsAtY",
  28092. "pointsAtZ",
  28093. "polygonOffset",
  28094. "pop",
  28095. "popDebugGroup",
  28096. "popErrorScope",
  28097. "popover",
  28098. "popoverTargetAction",
  28099. "popoverTargetElement",
  28100. "populateMatrix",
  28101. "popupWindowFeatures",
  28102. "popupWindowName",
  28103. "popupWindowURI",
  28104. "port",
  28105. "port1",
  28106. "port2",
  28107. "ports",
  28108. "posBottom",
  28109. "posHeight",
  28110. "posLeft",
  28111. "posRight",
  28112. "posTop",
  28113. "posWidth",
  28114. "pose",
  28115. "position",
  28116. "position-anchor",
  28117. "position-area",
  28118. "positionAlign",
  28119. "positionAnchor",
  28120. "positionArea",
  28121. "positionX",
  28122. "positionY",
  28123. "positionZ",
  28124. "postError",
  28125. "postMessage",
  28126. "postTask",
  28127. "postalCode",
  28128. "poster",
  28129. "postscriptName",
  28130. "pow",
  28131. "powerEfficient",
  28132. "powerOff",
  28133. "powerPreference",
  28134. "preMultiplySelf",
  28135. "precision",
  28136. "preferredReflectionFormat",
  28137. "preferredStyleSheetSet",
  28138. "preferredStylesheetSet",
  28139. "prefix",
  28140. "preload",
  28141. "premultipliedAlpha",
  28142. "prepend",
  28143. "prerendering",
  28144. "presentation",
  28145. "presentationArea",
  28146. "presentationStyle",
  28147. "preserveAlpha",
  28148. "preserveAspectRatio",
  28149. "preserveAspectRatioString",
  28150. "preservesPitch",
  28151. "pressed",
  28152. "pressure",
  28153. "prevValue",
  28154. "preventDefault",
  28155. "preventExtensions",
  28156. "preventSilentAccess",
  28157. "previousElementSibling",
  28158. "previousNode",
  28159. "previousPage",
  28160. "previousPriority",
  28161. "previousRect",
  28162. "previousScale",
  28163. "previousSibling",
  28164. "previousTranslate",
  28165. "primaries",
  28166. "primaryKey",
  28167. "primaryLightDirection",
  28168. "primaryLightIntensity",
  28169. "primitive",
  28170. "primitiveType",
  28171. "primitiveUnits",
  28172. "principals",
  28173. "print",
  28174. "print-color-adjust",
  28175. "printColorAdjust",
  28176. "printPreview",
  28177. "priority",
  28178. "privacy",
  28179. "privateKey",
  28180. "privateToken",
  28181. "probablySupportsContext",
  28182. "probeSpace",
  28183. "process",
  28184. "processIceMessage",
  28185. "processingEnd",
  28186. "processingStart",
  28187. "processorOptions",
  28188. "product",
  28189. "productId",
  28190. "productName",
  28191. "productSub",
  28192. "profile",
  28193. "profileEnd",
  28194. "profiles",
  28195. "projectionMatrix",
  28196. "promise",
  28197. "prompt",
  28198. "properties",
  28199. "propertyIsEnumerable",
  28200. "propertyName",
  28201. "protectedAudience",
  28202. "protocol",
  28203. "protocolLong",
  28204. "prototype",
  28205. "provider",
  28206. "proxy",
  28207. "pseudoClass",
  28208. "pseudoElement",
  28209. "pt",
  28210. "publicId",
  28211. "publicKey",
  28212. "published",
  28213. "pulse",
  28214. "push",
  28215. "pushDebugGroup",
  28216. "pushErrorScope",
  28217. "pushManager",
  28218. "pushNotification",
  28219. "pushState",
  28220. "put",
  28221. "putImageData",
  28222. "px",
  28223. "quadraticCurveTo",
  28224. "qualifier",
  28225. "quaternion",
  28226. "query",
  28227. "queryCommandEnabled",
  28228. "queryCommandIndeterm",
  28229. "queryCommandState",
  28230. "queryCommandSupported",
  28231. "queryCommandText",
  28232. "queryCommandValue",
  28233. "queryFeatureSupport",
  28234. "queryLocalFonts",
  28235. "queryPermission",
  28236. "querySelector",
  28237. "querySelectorAll",
  28238. "querySet",
  28239. "queue",
  28240. "queueMicrotask",
  28241. "quote",
  28242. "quotes",
  28243. "r",
  28244. "r1",
  28245. "r2",
  28246. "race",
  28247. "rad",
  28248. "radiogroup",
  28249. "radius",
  28250. "radiusX",
  28251. "radiusY",
  28252. "random",
  28253. "randomUUID",
  28254. "range",
  28255. "rangeCount",
  28256. "rangeEnd",
  28257. "rangeMax",
  28258. "rangeMin",
  28259. "rangeOffset",
  28260. "rangeOverflow",
  28261. "rangeParent",
  28262. "rangeStart",
  28263. "rangeUnderflow",
  28264. "rate",
  28265. "ratio",
  28266. "raw",
  28267. "rawId",
  28268. "rawJSON",
  28269. "rawValueToMeters",
  28270. "rcap",
  28271. "rch",
  28272. "read",
  28273. "readAsArrayBuffer",
  28274. "readAsBinaryString",
  28275. "readAsBlob",
  28276. "readAsDataURL",
  28277. "readAsText",
  28278. "readBuffer",
  28279. "readEntries",
  28280. "readOnly",
  28281. "readPixels",
  28282. "readReportRequested",
  28283. "readText",
  28284. "readValue",
  28285. "readable",
  28286. "ready",
  28287. "readyState",
  28288. "reason",
  28289. "reasons",
  28290. "reboot",
  28291. "receiveFeatureReport",
  28292. "receivedAlert",
  28293. "receiver",
  28294. "receivers",
  28295. "recipient",
  28296. "recommendedViewportScale",
  28297. "reconnect",
  28298. "recordNumber",
  28299. "recordsAvailable",
  28300. "recordset",
  28301. "rect",
  28302. "red",
  28303. "redEyeReduction",
  28304. "redirect",
  28305. "redirectCount",
  28306. "redirectEnd",
  28307. "redirectStart",
  28308. "redirected",
  28309. "reduce",
  28310. "reduceRight",
  28311. "reduction",
  28312. "refDistance",
  28313. "refX",
  28314. "refY",
  28315. "referenceNode",
  28316. "referenceSpace",
  28317. "referrer",
  28318. "referrerPolicy",
  28319. "refresh",
  28320. "region",
  28321. "regionAnchorX",
  28322. "regionAnchorY",
  28323. "regionId",
  28324. "regions",
  28325. "register",
  28326. "registerContentHandler",
  28327. "registerElement",
  28328. "registerInternalModuleStart",
  28329. "registerInternalModuleStop",
  28330. "registerProperty",
  28331. "registerProtocolHandler",
  28332. "reject",
  28333. "rel",
  28334. "relList",
  28335. "relatedAddress",
  28336. "relatedNode",
  28337. "relatedPort",
  28338. "relatedTarget",
  28339. "relayProtocol",
  28340. "release",
  28341. "releaseCapture",
  28342. "releaseEvents",
  28343. "releaseInterface",
  28344. "releaseLock",
  28345. "releasePointerCapture",
  28346. "releaseShaderCompiler",
  28347. "released",
  28348. "reliability",
  28349. "reliable",
  28350. "reliableWrite",
  28351. "reload",
  28352. "rem",
  28353. "remainingSpace",
  28354. "remote",
  28355. "remoteDescription",
  28356. "remove",
  28357. "removeAllRanges",
  28358. "removeAttribute",
  28359. "removeAttributeNS",
  28360. "removeAttributeNode",
  28361. "removeBehavior",
  28362. "removeChild",
  28363. "removeCue",
  28364. "removeEntry",
  28365. "removeEventListener",
  28366. "removeFilter",
  28367. "removeImport",
  28368. "removeItem",
  28369. "removeListener",
  28370. "removeNamedItem",
  28371. "removeNamedItemNS",
  28372. "removeNode",
  28373. "removeParameter",
  28374. "removeProperty",
  28375. "removeRange",
  28376. "removeRegion",
  28377. "removeRule",
  28378. "removeSiteSpecificTrackingException",
  28379. "removeSourceBuffer",
  28380. "removeStream",
  28381. "removeTrack",
  28382. "removeVariable",
  28383. "removeWakeLockListener",
  28384. "removeWebWideTrackingException",
  28385. "removed",
  28386. "removedNodes",
  28387. "renderBlockingStatus",
  28388. "renderHeight",
  28389. "renderStart",
  28390. "renderState",
  28391. "renderTime",
  28392. "renderWidth",
  28393. "renderbufferStorage",
  28394. "renderbufferStorageMultisample",
  28395. "renderedBuffer",
  28396. "rendererInterfaces",
  28397. "renderers",
  28398. "renderingMode",
  28399. "renotify",
  28400. "repeat",
  28401. "repetitionCount",
  28402. "replace",
  28403. "replaceAdjacentText",
  28404. "replaceAll",
  28405. "replaceChild",
  28406. "replaceChildren",
  28407. "replaceData",
  28408. "replaceId",
  28409. "replaceItem",
  28410. "replaceNode",
  28411. "replaceState",
  28412. "replaceSync",
  28413. "replaceTrack",
  28414. "replaceWholeText",
  28415. "replaceWith",
  28416. "reportError",
  28417. "reportEvent",
  28418. "reportId",
  28419. "reportValidity",
  28420. "request",
  28421. "requestAdapter",
  28422. "requestAdapterInfo",
  28423. "requestAnimationFrame",
  28424. "requestAutocomplete",
  28425. "requestClose",
  28426. "requestData",
  28427. "requestDevice",
  28428. "requestFrame",
  28429. "requestFullscreen",
  28430. "requestHitTestSource",
  28431. "requestHitTestSourceForTransientInput",
  28432. "requestId",
  28433. "requestIdleCallback",
  28434. "requestLightProbe",
  28435. "requestMIDIAccess",
  28436. "requestMediaKeySystemAccess",
  28437. "requestPermission",
  28438. "requestPictureInPicture",
  28439. "requestPointerLock",
  28440. "requestPort",
  28441. "requestPresent",
  28442. "requestPresenter",
  28443. "requestReferenceSpace",
  28444. "requestSession",
  28445. "requestStart",
  28446. "requestStorageAccess",
  28447. "requestStorageAccessFor",
  28448. "requestSubmit",
  28449. "requestTime",
  28450. "requestUpdateCheck",
  28451. "requestVideoFrameCallback",
  28452. "requestViewportScale",
  28453. "requestWindow",
  28454. "requestingWindow",
  28455. "requireInteraction",
  28456. "required",
  28457. "requiredExtensions",
  28458. "requiredFeatures",
  28459. "requiredLimits",
  28460. "reset",
  28461. "resetLatency",
  28462. "resetPose",
  28463. "resetTransform",
  28464. "resizable",
  28465. "resize",
  28466. "resizeBy",
  28467. "resizeTo",
  28468. "resolve",
  28469. "resolveQuerySet",
  28470. "resolveTarget",
  28471. "resource",
  28472. "respond",
  28473. "respondWithNewView",
  28474. "response",
  28475. "responseBody",
  28476. "responseEnd",
  28477. "responseReady",
  28478. "responseStart",
  28479. "responseStatus",
  28480. "responseText",
  28481. "responseType",
  28482. "responseURL",
  28483. "responseXML",
  28484. "restart",
  28485. "restartAfterDelay",
  28486. "restartIce",
  28487. "restore",
  28488. "result",
  28489. "resultIndex",
  28490. "resultType",
  28491. "results",
  28492. "resume",
  28493. "resumeProfilers",
  28494. "resumeTransformFeedback",
  28495. "retry",
  28496. "returnValue",
  28497. "rev",
  28498. "reverse",
  28499. "reversed",
  28500. "revocable",
  28501. "revokeObjectURL",
  28502. "rex",
  28503. "rgbColor",
  28504. "ric",
  28505. "right",
  28506. "rightContext",
  28507. "rightDegrees",
  28508. "rightMargin",
  28509. "rightProjectionMatrix",
  28510. "rightViewMatrix",
  28511. "rlh",
  28512. "role",
  28513. "rolloffFactor",
  28514. "root",
  28515. "rootBounds",
  28516. "rootElement",
  28517. "rootMargin",
  28518. "rotate",
  28519. "rotateAxisAngle",
  28520. "rotateAxisAngleSelf",
  28521. "rotateFromVector",
  28522. "rotateFromVectorSelf",
  28523. "rotateSelf",
  28524. "rotation",
  28525. "rotationAngle",
  28526. "rotationRate",
  28527. "round",
  28528. "roundRect",
  28529. "row-gap",
  28530. "rowGap",
  28531. "rowIndex",
  28532. "rowSpan",
  28533. "rows",
  28534. "rowsPerImage",
  28535. "rtcpTransport",
  28536. "rtt",
  28537. "ruby-align",
  28538. "ruby-position",
  28539. "rubyAlign",
  28540. "rubyOverhang",
  28541. "rubyPosition",
  28542. "rules",
  28543. "run",
  28544. "runAdAuction",
  28545. "runtime",
  28546. "runtimeStyle",
  28547. "rx",
  28548. "ry",
  28549. "s",
  28550. "safari",
  28551. "sameDocument",
  28552. "sample",
  28553. "sampleCount",
  28554. "sampleCoverage",
  28555. "sampleInterval",
  28556. "sampleRate",
  28557. "sampleType",
  28558. "sampler",
  28559. "samplerParameterf",
  28560. "samplerParameteri",
  28561. "sandbox",
  28562. "save",
  28563. "saveAsPDF",
  28564. "saveData",
  28565. "scale",
  28566. "scale3d",
  28567. "scale3dSelf",
  28568. "scaleNonUniform",
  28569. "scaleNonUniformSelf",
  28570. "scaleSelf",
  28571. "scheduler",
  28572. "scheduling",
  28573. "scheme",
  28574. "scissor",
  28575. "scope",
  28576. "scopeName",
  28577. "scoped",
  28578. "screen",
  28579. "screenBrightness",
  28580. "screenEnabled",
  28581. "screenLeft",
  28582. "screenPixelToMillimeterX",
  28583. "screenPixelToMillimeterY",
  28584. "screenState",
  28585. "screenTop",
  28586. "screenX",
  28587. "screenY",
  28588. "screens",
  28589. "scriptURL",
  28590. "scripting",
  28591. "scripts",
  28592. "scroll",
  28593. "scroll-behavior",
  28594. "scroll-margin",
  28595. "scroll-margin-block",
  28596. "scroll-margin-block-end",
  28597. "scroll-margin-block-start",
  28598. "scroll-margin-bottom",
  28599. "scroll-margin-inline",
  28600. "scroll-margin-inline-end",
  28601. "scroll-margin-inline-start",
  28602. "scroll-margin-left",
  28603. "scroll-margin-right",
  28604. "scroll-margin-top",
  28605. "scroll-padding",
  28606. "scroll-padding-block",
  28607. "scroll-padding-block-end",
  28608. "scroll-padding-block-start",
  28609. "scroll-padding-bottom",
  28610. "scroll-padding-inline",
  28611. "scroll-padding-inline-end",
  28612. "scroll-padding-inline-start",
  28613. "scroll-padding-left",
  28614. "scroll-padding-right",
  28615. "scroll-padding-top",
  28616. "scroll-snap-align",
  28617. "scroll-snap-stop",
  28618. "scroll-snap-type",
  28619. "scrollAmount",
  28620. "scrollBehavior",
  28621. "scrollBy",
  28622. "scrollByLines",
  28623. "scrollByPages",
  28624. "scrollDelay",
  28625. "scrollHeight",
  28626. "scrollIntoView",
  28627. "scrollIntoViewIfNeeded",
  28628. "scrollLeft",
  28629. "scrollLeftMax",
  28630. "scrollMargin",
  28631. "scrollMarginBlock",
  28632. "scrollMarginBlockEnd",
  28633. "scrollMarginBlockStart",
  28634. "scrollMarginBottom",
  28635. "scrollMarginInline",
  28636. "scrollMarginInlineEnd",
  28637. "scrollMarginInlineStart",
  28638. "scrollMarginLeft",
  28639. "scrollMarginRight",
  28640. "scrollMarginTop",
  28641. "scrollMaxX",
  28642. "scrollMaxY",
  28643. "scrollPadding",
  28644. "scrollPaddingBlock",
  28645. "scrollPaddingBlockEnd",
  28646. "scrollPaddingBlockStart",
  28647. "scrollPaddingBottom",
  28648. "scrollPaddingInline",
  28649. "scrollPaddingInlineEnd",
  28650. "scrollPaddingInlineStart",
  28651. "scrollPaddingLeft",
  28652. "scrollPaddingRight",
  28653. "scrollPaddingTop",
  28654. "scrollRestoration",
  28655. "scrollSnapAlign",
  28656. "scrollSnapStop",
  28657. "scrollSnapType",
  28658. "scrollTo",
  28659. "scrollTop",
  28660. "scrollTopMax",
  28661. "scrollWidth",
  28662. "scrollX",
  28663. "scrollY",
  28664. "scrollbar-color",
  28665. "scrollbar-gutter",
  28666. "scrollbar-width",
  28667. "scrollbar3dLightColor",
  28668. "scrollbarArrowColor",
  28669. "scrollbarBaseColor",
  28670. "scrollbarColor",
  28671. "scrollbarDarkShadowColor",
  28672. "scrollbarFaceColor",
  28673. "scrollbarGutter",
  28674. "scrollbarHighlightColor",
  28675. "scrollbarShadowColor",
  28676. "scrollbarTrackColor",
  28677. "scrollbarWidth",
  28678. "scrollbars",
  28679. "scrolling",
  28680. "scrollingElement",
  28681. "sctp",
  28682. "sctpCauseCode",
  28683. "sdp",
  28684. "sdpLineNumber",
  28685. "sdpMLineIndex",
  28686. "sdpMid",
  28687. "seal",
  28688. "search",
  28689. "searchBox",
  28690. "searchBoxJavaBridge_",
  28691. "searchParams",
  28692. "sectionRowIndex",
  28693. "secureConnectionStart",
  28694. "security",
  28695. "seed",
  28696. "seek",
  28697. "seekToNextFrame",
  28698. "seekable",
  28699. "seeking",
  28700. "select",
  28701. "selectAllChildren",
  28702. "selectAlternateInterface",
  28703. "selectAudioOutput",
  28704. "selectConfiguration",
  28705. "selectNode",
  28706. "selectNodeContents",
  28707. "selectNodes",
  28708. "selectSingleNode",
  28709. "selectSubString",
  28710. "selectURL",
  28711. "selected",
  28712. "selectedIndex",
  28713. "selectedOptions",
  28714. "selectedStyleSheetSet",
  28715. "selectedStylesheetSet",
  28716. "selectedTrack",
  28717. "selection",
  28718. "selectionDirection",
  28719. "selectionEnd",
  28720. "selectionStart",
  28721. "selector",
  28722. "selectorText",
  28723. "self",
  28724. "send",
  28725. "sendAsBinary",
  28726. "sendBeacon",
  28727. "sendFeatureReport",
  28728. "sendMessage",
  28729. "sendNativeMessage",
  28730. "sendOrder",
  28731. "sendReport",
  28732. "sender",
  28733. "sentAlert",
  28734. "sentTimestamp",
  28735. "separator",
  28736. "serial",
  28737. "serialNumber",
  28738. "serializable",
  28739. "serializeToString",
  28740. "serverTiming",
  28741. "service",
  28742. "serviceWorker",
  28743. "session",
  28744. "sessionId",
  28745. "sessionStorage",
  28746. "sessions",
  28747. "set",
  28748. "setActionHandler",
  28749. "setActive",
  28750. "setAlpha",
  28751. "setAppBadge",
  28752. "setAttribute",
  28753. "setAttributeNS",
  28754. "setAttributeNode",
  28755. "setAttributeNodeNS",
  28756. "setAttributionReporting",
  28757. "setBadgeBackgroundColor",
  28758. "setBadgeText",
  28759. "setBadgeTextColor",
  28760. "setBaseAndExtent",
  28761. "setBigInt64",
  28762. "setBigUint64",
  28763. "setBindGroup",
  28764. "setBingCurrentSearchDefault",
  28765. "setBlendConstant",
  28766. "setCameraActive",
  28767. "setCapture",
  28768. "setCaptureHandleConfig",
  28769. "setCodecPreferences",
  28770. "setColor",
  28771. "setCompositeOperation",
  28772. "setConfiguration",
  28773. "setConsumer",
  28774. "setCurrentTime",
  28775. "setCustomValidity",
  28776. "setData",
  28777. "setDate",
  28778. "setDragImage",
  28779. "setEnabled",
  28780. "setEnd",
  28781. "setEndAfter",
  28782. "setEndBefore",
  28783. "setEndPoint",
  28784. "setExpires",
  28785. "setFillColor",
  28786. "setFilterRes",
  28787. "setFloat16",
  28788. "setFloat32",
  28789. "setFloat64",
  28790. "setFloatValue",
  28791. "setFocusBehavior",
  28792. "setFormValue",
  28793. "setFromBase64",
  28794. "setFromHex",
  28795. "setFullYear",
  28796. "setHTMLUnsafe",
  28797. "setHeaderExtensionsToNegotiate",
  28798. "setHeaderValue",
  28799. "setHours",
  28800. "setIcon",
  28801. "setIdentityProvider",
  28802. "setImmediate",
  28803. "setIndexBuffer",
  28804. "setInt16",
  28805. "setInt32",
  28806. "setInt8",
  28807. "setInterval",
  28808. "setItem",
  28809. "setKeyframes",
  28810. "setLineCap",
  28811. "setLineDash",
  28812. "setLineJoin",
  28813. "setLineWidth",
  28814. "setLiveSeekableRange",
  28815. "setLocalDescription",
  28816. "setMatrix",
  28817. "setMatrixValue",
  28818. "setMediaKeys",
  28819. "setMicrophoneActive",
  28820. "setMilliseconds",
  28821. "setMinutes",
  28822. "setMiterLimit",
  28823. "setMonth",
  28824. "setNamedItem",
  28825. "setNamedItemNS",
  28826. "setNonUserCodeExceptions",
  28827. "setOrientToAngle",
  28828. "setOrientToAuto",
  28829. "setOrientation",
  28830. "setOverrideHistoryNavigationMode",
  28831. "setPaint",
  28832. "setParameter",
  28833. "setParameters",
  28834. "setPeriodicWave",
  28835. "setPipeline",
  28836. "setPointerCapture",
  28837. "setPopup",
  28838. "setPosition",
  28839. "setPositionState",
  28840. "setPreference",
  28841. "setPriority",
  28842. "setPrivateToken",
  28843. "setProperty",
  28844. "setPrototypeOf",
  28845. "setRGBColor",
  28846. "setRGBColorICCColor",
  28847. "setRadius",
  28848. "setRangeText",
  28849. "setRemoteDescription",
  28850. "setReportEventDataForAutomaticBeacons",
  28851. "setRequestHeader",
  28852. "setResizable",
  28853. "setResourceTimingBufferSize",
  28854. "setRotate",
  28855. "setScale",
  28856. "setScissorRect",
  28857. "setSeconds",
  28858. "setSelectionRange",
  28859. "setServerCertificate",
  28860. "setShadow",
  28861. "setSharedStorageContext",
  28862. "setSignals",
  28863. "setSinkId",
  28864. "setSkewX",
  28865. "setSkewY",
  28866. "setStart",
  28867. "setStartAfter",
  28868. "setStartBefore",
  28869. "setStatus",
  28870. "setStdDeviation",
  28871. "setStencilReference",
  28872. "setStreams",
  28873. "setStrictMode",
  28874. "setStringValue",
  28875. "setStrokeColor",
  28876. "setSuggestResult",
  28877. "setTargetAtTime",
  28878. "setTargetValueAtTime",
  28879. "setTime",
  28880. "setTimeout",
  28881. "setTitle",
  28882. "setTransform",
  28883. "setTranslate",
  28884. "setUTCDate",
  28885. "setUTCFullYear",
  28886. "setUTCHours",
  28887. "setUTCMilliseconds",
  28888. "setUTCMinutes",
  28889. "setUTCMonth",
  28890. "setUTCSeconds",
  28891. "setUint16",
  28892. "setUint32",
  28893. "setUint8",
  28894. "setUninstallURL",
  28895. "setUpdateUrlData",
  28896. "setUri",
  28897. "setValidity",
  28898. "setValueAtTime",
  28899. "setValueCurveAtTime",
  28900. "setVariable",
  28901. "setVelocity",
  28902. "setVersion",
  28903. "setVertexBuffer",
  28904. "setViewport",
  28905. "setYear",
  28906. "setZoom",
  28907. "setZoomSettings",
  28908. "settingName",
  28909. "settingValue",
  28910. "sex",
  28911. "shaderLocation",
  28912. "shaderSource",
  28913. "shadowBlur",
  28914. "shadowColor",
  28915. "shadowOffsetX",
  28916. "shadowOffsetY",
  28917. "shadowRoot",
  28918. "shadowRootClonable",
  28919. "shadowRootDelegatesFocus",
  28920. "shadowRootMode",
  28921. "shadowRootSerializable",
  28922. "shape",
  28923. "shape-image-threshold",
  28924. "shape-margin",
  28925. "shape-outside",
  28926. "shape-rendering",
  28927. "shapeImageThreshold",
  28928. "shapeMargin",
  28929. "shapeOutside",
  28930. "shapeRendering",
  28931. "share",
  28932. "sharedStorage",
  28933. "sharedStorageWritable",
  28934. "sheet",
  28935. "shift",
  28936. "shiftKey",
  28937. "shiftLeft",
  28938. "shippingAddress",
  28939. "shippingOption",
  28940. "shippingType",
  28941. "show",
  28942. "showDirectoryPicker",
  28943. "showHelp",
  28944. "showModal",
  28945. "showModalDialog",
  28946. "showModelessDialog",
  28947. "showNotification",
  28948. "showOpenFilePicker",
  28949. "showPicker",
  28950. "showPopover",
  28951. "showSaveFilePicker",
  28952. "sidebar",
  28953. "sidebarAction",
  28954. "sign",
  28955. "signal",
  28956. "signalingState",
  28957. "signature",
  28958. "silent",
  28959. "sin",
  28960. "singleNodeValue",
  28961. "sinh",
  28962. "sinkId",
  28963. "sittingToStandingTransform",
  28964. "size",
  28965. "sizeAdjust",
  28966. "sizeToContent",
  28967. "sizeX",
  28968. "sizeZ",
  28969. "sizes",
  28970. "skewX",
  28971. "skewXSelf",
  28972. "skewY",
  28973. "skewYSelf",
  28974. "skipTransition",
  28975. "skipped",
  28976. "slice",
  28977. "slope",
  28978. "slot",
  28979. "slotAssignment",
  28980. "small",
  28981. "smil",
  28982. "smooth",
  28983. "smoothingTimeConstant",
  28984. "snapTargetBlock",
  28985. "snapTargetInline",
  28986. "snapToLines",
  28987. "snapshotItem",
  28988. "snapshotLength",
  28989. "some",
  28990. "sort",
  28991. "sortingCode",
  28992. "source",
  28993. "sourceBuffer",
  28994. "sourceBuffers",
  28995. "sourceCapabilities",
  28996. "sourceCharPosition",
  28997. "sourceFile",
  28998. "sourceFunctionName",
  28999. "sourceIndex",
  29000. "sourceMap",
  29001. "sourceURL",
  29002. "sources",
  29003. "spacing",
  29004. "span",
  29005. "speak",
  29006. "speakAs",
  29007. "speaking",
  29008. "species",
  29009. "specified",
  29010. "specularConstant",
  29011. "specularExponent",
  29012. "speechSynthesis",
  29013. "speed",
  29014. "speedOfSound",
  29015. "spellcheck",
  29016. "sphericalHarmonicsCoefficients",
  29017. "splice",
  29018. "split",
  29019. "splitText",
  29020. "spreadMethod",
  29021. "sqrt",
  29022. "src",
  29023. "srcElement",
  29024. "srcFactor",
  29025. "srcFilter",
  29026. "srcObject",
  29027. "srcUrn",
  29028. "srcdoc",
  29029. "srclang",
  29030. "srcset",
  29031. "stack",
  29032. "stackTraceLimit",
  29033. "stacktrace",
  29034. "stageParameters",
  29035. "standalone",
  29036. "standby",
  29037. "start",
  29038. "startContainer",
  29039. "startE",
  29040. "startIce",
  29041. "startLoadTime",
  29042. "startMessages",
  29043. "startNotifications",
  29044. "startOffset",
  29045. "startProfiling",
  29046. "startRendering",
  29047. "startShark",
  29048. "startTime",
  29049. "startViewTransition",
  29050. "startsWith",
  29051. "state",
  29052. "states",
  29053. "stats",
  29054. "status",
  29055. "statusCode",
  29056. "statusMessage",
  29057. "statusText",
  29058. "statusbar",
  29059. "stdDeviationX",
  29060. "stdDeviationY",
  29061. "stencilBack",
  29062. "stencilClearValue",
  29063. "stencilFront",
  29064. "stencilFunc",
  29065. "stencilFuncSeparate",
  29066. "stencilLoadOp",
  29067. "stencilMask",
  29068. "stencilMaskSeparate",
  29069. "stencilOp",
  29070. "stencilOpSeparate",
  29071. "stencilReadMask",
  29072. "stencilReadOnly",
  29073. "stencilStoreOp",
  29074. "stencilWriteMask",
  29075. "step",
  29076. "stepDown",
  29077. "stepMismatch",
  29078. "stepMode",
  29079. "stepUp",
  29080. "sticky",
  29081. "stitchTiles",
  29082. "stop",
  29083. "stop-color",
  29084. "stop-opacity",
  29085. "stopColor",
  29086. "stopImmediatePropagation",
  29087. "stopNotifications",
  29088. "stopOpacity",
  29089. "stopProfiling",
  29090. "stopPropagation",
  29091. "stopShark",
  29092. "stopped",
  29093. "storage",
  29094. "storageArea",
  29095. "storageBuckets",
  29096. "storageName",
  29097. "storageStatus",
  29098. "storageTexture",
  29099. "store",
  29100. "storeOp",
  29101. "storeSiteSpecificTrackingException",
  29102. "storeWebWideTrackingException",
  29103. "stpVersion",
  29104. "stream",
  29105. "streamErrorCode",
  29106. "streams",
  29107. "stretch",
  29108. "strike",
  29109. "string",
  29110. "stringValue",
  29111. "stringify",
  29112. "stripIndexFormat",
  29113. "stroke",
  29114. "stroke-dasharray",
  29115. "stroke-dashoffset",
  29116. "stroke-linecap",
  29117. "stroke-linejoin",
  29118. "stroke-miterlimit",
  29119. "stroke-opacity",
  29120. "stroke-width",
  29121. "strokeDasharray",
  29122. "strokeDashoffset",
  29123. "strokeLinecap",
  29124. "strokeLinejoin",
  29125. "strokeMiterlimit",
  29126. "strokeOpacity",
  29127. "strokeRect",
  29128. "strokeStyle",
  29129. "strokeText",
  29130. "strokeWidth",
  29131. "structuredClone",
  29132. "style",
  29133. "styleAndLayoutStart",
  29134. "styleFloat",
  29135. "styleMap",
  29136. "styleMedia",
  29137. "styleSheet",
  29138. "styleSheetSets",
  29139. "styleSheets",
  29140. "sub",
  29141. "subarray",
  29142. "subject",
  29143. "submit",
  29144. "submitFrame",
  29145. "submitter",
  29146. "subscribe",
  29147. "substr",
  29148. "substring",
  29149. "substringData",
  29150. "subtle",
  29151. "subtree",
  29152. "suffix",
  29153. "suffixes",
  29154. "summary",
  29155. "sup",
  29156. "supported",
  29157. "supportedContentEncodings",
  29158. "supportedEntryTypes",
  29159. "supportedValuesOf",
  29160. "supports",
  29161. "supportsFiber",
  29162. "supportsSession",
  29163. "supportsText",
  29164. "surfaceScale",
  29165. "surroundContents",
  29166. "suspend",
  29167. "suspendRedraw",
  29168. "svb",
  29169. "svh",
  29170. "svi",
  29171. "svmax",
  29172. "svmin",
  29173. "svw",
  29174. "swapCache",
  29175. "swapNode",
  29176. "sweepFlag",
  29177. "symbols",
  29178. "symmetricDifference",
  29179. "sync",
  29180. "syntax",
  29181. "sysexEnabled",
  29182. "system",
  29183. "systemCode",
  29184. "systemId",
  29185. "systemLanguage",
  29186. "systemXDPI",
  29187. "systemYDPI",
  29188. "tBodies",
  29189. "tFoot",
  29190. "tHead",
  29191. "tab",
  29192. "tab-size",
  29193. "tabId",
  29194. "tabIds",
  29195. "tabIndex",
  29196. "tabSize",
  29197. "table",
  29198. "table-layout",
  29199. "tableLayout",
  29200. "tableValues",
  29201. "tabs",
  29202. "tag",
  29203. "tagName",
  29204. "tagUrn",
  29205. "tags",
  29206. "taintEnabled",
  29207. "take",
  29208. "takePhoto",
  29209. "takeRecords",
  29210. "tan",
  29211. "tangentialPressure",
  29212. "tanh",
  29213. "target",
  29214. "targetAddressSpace",
  29215. "targetElement",
  29216. "targetRayMode",
  29217. "targetRaySpace",
  29218. "targetTouches",
  29219. "targetURL",
  29220. "targetX",
  29221. "targetY",
  29222. "targets",
  29223. "tcpType",
  29224. "tee",
  29225. "tel",
  29226. "telemetry",
  29227. "terminate",
  29228. "test",
  29229. "texImage2D",
  29230. "texImage3D",
  29231. "texParameterf",
  29232. "texParameteri",
  29233. "texStorage2D",
  29234. "texStorage3D",
  29235. "texSubImage2D",
  29236. "texSubImage3D",
  29237. "text",
  29238. "text-align",
  29239. "text-align-last",
  29240. "text-anchor",
  29241. "text-combine-upright",
  29242. "text-decoration",
  29243. "text-decoration-color",
  29244. "text-decoration-line",
  29245. "text-decoration-skip-ink",
  29246. "text-decoration-style",
  29247. "text-decoration-thickness",
  29248. "text-emphasis",
  29249. "text-emphasis-color",
  29250. "text-emphasis-position",
  29251. "text-emphasis-style",
  29252. "text-indent",
  29253. "text-justify",
  29254. "text-orientation",
  29255. "text-overflow",
  29256. "text-rendering",
  29257. "text-shadow",
  29258. "text-transform",
  29259. "text-underline-offset",
  29260. "text-underline-position",
  29261. "text-wrap",
  29262. "text-wrap-mode",
  29263. "text-wrap-style",
  29264. "textAlign",
  29265. "textAlignLast",
  29266. "textAnchor",
  29267. "textAutospace",
  29268. "textBaseline",
  29269. "textCombineUpright",
  29270. "textContent",
  29271. "textDecoration",
  29272. "textDecorationBlink",
  29273. "textDecorationColor",
  29274. "textDecorationLine",
  29275. "textDecorationLineThrough",
  29276. "textDecorationNone",
  29277. "textDecorationOverline",
  29278. "textDecorationSkipInk",
  29279. "textDecorationStyle",
  29280. "textDecorationThickness",
  29281. "textDecorationUnderline",
  29282. "textEmphasis",
  29283. "textEmphasisColor",
  29284. "textEmphasisPosition",
  29285. "textEmphasisStyle",
  29286. "textIndent",
  29287. "textJustify",
  29288. "textJustifyTrim",
  29289. "textKashida",
  29290. "textKashidaSpace",
  29291. "textLength",
  29292. "textOrientation",
  29293. "textOverflow",
  29294. "textRendering",
  29295. "textShadow",
  29296. "textTracks",
  29297. "textTransform",
  29298. "textUnderlineOffset",
  29299. "textUnderlinePosition",
  29300. "textWrap",
  29301. "textWrapMode",
  29302. "textWrapStyle",
  29303. "texture",
  29304. "theme",
  29305. "then",
  29306. "threadId",
  29307. "threshold",
  29308. "thresholds",
  29309. "throwIfAborted",
  29310. "tiltX",
  29311. "tiltY",
  29312. "time",
  29313. "timeEnd",
  29314. "timeLog",
  29315. "timeOrigin",
  29316. "timeRemaining",
  29317. "timeStamp",
  29318. "timecode",
  29319. "timeline",
  29320. "timelineTime",
  29321. "timeout",
  29322. "timestamp",
  29323. "timestampOffset",
  29324. "timestampWrites",
  29325. "timing",
  29326. "title",
  29327. "titlebarAreaRect",
  29328. "tlsChannelId",
  29329. "to",
  29330. "toArray",
  29331. "toBase64",
  29332. "toBlob",
  29333. "toDataURL",
  29334. "toDateString",
  29335. "toElement",
  29336. "toExponential",
  29337. "toFixed",
  29338. "toFloat32Array",
  29339. "toFloat64Array",
  29340. "toGMTString",
  29341. "toHex",
  29342. "toISOString",
  29343. "toJSON",
  29344. "toLocaleDateString",
  29345. "toLocaleFormat",
  29346. "toLocaleLowerCase",
  29347. "toLocaleString",
  29348. "toLocaleTimeString",
  29349. "toLocaleUpperCase",
  29350. "toLowerCase",
  29351. "toMatrix",
  29352. "toMethod",
  29353. "toPrecision",
  29354. "toPrimitive",
  29355. "toReversed",
  29356. "toSdp",
  29357. "toSorted",
  29358. "toSource",
  29359. "toSpliced",
  29360. "toStaticHTML",
  29361. "toString",
  29362. "toStringTag",
  29363. "toSum",
  29364. "toTimeString",
  29365. "toUTCString",
  29366. "toUpperCase",
  29367. "toWellFormed",
  29368. "toggle",
  29369. "toggleAttribute",
  29370. "toggleLongPressEnabled",
  29371. "togglePopover",
  29372. "toggleReaderMode",
  29373. "token",
  29374. "tone",
  29375. "toneBuffer",
  29376. "tooLong",
  29377. "tooShort",
  29378. "toolbar",
  29379. "top",
  29380. "topMargin",
  29381. "topSites",
  29382. "topology",
  29383. "total",
  29384. "totalFrameDelay",
  29385. "totalFrames",
  29386. "totalFramesDuration",
  29387. "totalVideoFrames",
  29388. "touch-action",
  29389. "touchAction",
  29390. "touched",
  29391. "touches",
  29392. "trace",
  29393. "track",
  29394. "trackVisibility",
  29395. "trackedAnchors",
  29396. "tracks",
  29397. "tran",
  29398. "transaction",
  29399. "transactions",
  29400. "transceiver",
  29401. "transfer",
  29402. "transferControlToOffscreen",
  29403. "transferFromImageBitmap",
  29404. "transferImageBitmap",
  29405. "transferIn",
  29406. "transferOut",
  29407. "transferSize",
  29408. "transferToFixedLength",
  29409. "transferToImageBitmap",
  29410. "transform",
  29411. "transform-box",
  29412. "transform-origin",
  29413. "transform-style",
  29414. "transformBox",
  29415. "transformFeedbackVaryings",
  29416. "transformOrigin",
  29417. "transformPoint",
  29418. "transformString",
  29419. "transformStyle",
  29420. "transformToDocument",
  29421. "transformToFragment",
  29422. "transition",
  29423. "transition-behavior",
  29424. "transition-delay",
  29425. "transition-duration",
  29426. "transition-property",
  29427. "transition-timing-function",
  29428. "transitionBehavior",
  29429. "transitionDelay",
  29430. "transitionDuration",
  29431. "transitionProperty",
  29432. "transitionTimingFunction",
  29433. "translate",
  29434. "translateSelf",
  29435. "translationX",
  29436. "translationY",
  29437. "transport",
  29438. "traverseTo",
  29439. "trim",
  29440. "trimEnd",
  29441. "trimLeft",
  29442. "trimRight",
  29443. "trimStart",
  29444. "trueSpeed",
  29445. "trunc",
  29446. "truncate",
  29447. "trustedTypes",
  29448. "try",
  29449. "turn",
  29450. "twist",
  29451. "type",
  29452. "typeDetail",
  29453. "typeMismatch",
  29454. "typeMustMatch",
  29455. "types",
  29456. "u2f",
  29457. "ubound",
  29458. "uint16",
  29459. "uint32",
  29460. "uint8",
  29461. "uint8Clamped",
  29462. "unadjustedMovement",
  29463. "unclippedDepth",
  29464. "unconfigure",
  29465. "undefined",
  29466. "underlineStyle",
  29467. "underlineThickness",
  29468. "unescape",
  29469. "uneval",
  29470. "ungroup",
  29471. "unicode",
  29472. "unicode-bidi",
  29473. "unicodeBidi",
  29474. "unicodeRange",
  29475. "unicodeSets",
  29476. "uniform1f",
  29477. "uniform1fv",
  29478. "uniform1i",
  29479. "uniform1iv",
  29480. "uniform1ui",
  29481. "uniform1uiv",
  29482. "uniform2f",
  29483. "uniform2fv",
  29484. "uniform2i",
  29485. "uniform2iv",
  29486. "uniform2ui",
  29487. "uniform2uiv",
  29488. "uniform3f",
  29489. "uniform3fv",
  29490. "uniform3i",
  29491. "uniform3iv",
  29492. "uniform3ui",
  29493. "uniform3uiv",
  29494. "uniform4f",
  29495. "uniform4fv",
  29496. "uniform4i",
  29497. "uniform4iv",
  29498. "uniform4ui",
  29499. "uniform4uiv",
  29500. "uniformBlockBinding",
  29501. "uniformMatrix2fv",
  29502. "uniformMatrix2x3fv",
  29503. "uniformMatrix2x4fv",
  29504. "uniformMatrix3fv",
  29505. "uniformMatrix3x2fv",
  29506. "uniformMatrix3x4fv",
  29507. "uniformMatrix4fv",
  29508. "uniformMatrix4x2fv",
  29509. "uniformMatrix4x3fv",
  29510. "uninstallSelf",
  29511. "union",
  29512. "unique",
  29513. "uniqueID",
  29514. "uniqueNumber",
  29515. "unit",
  29516. "unitType",
  29517. "units",
  29518. "unloadEventEnd",
  29519. "unloadEventStart",
  29520. "unlock",
  29521. "unmap",
  29522. "unmount",
  29523. "unobserve",
  29524. "unpackColorSpace",
  29525. "unpause",
  29526. "unpauseAnimations",
  29527. "unreadCount",
  29528. "unregister",
  29529. "unregisterContentHandler",
  29530. "unregisterProtocolHandler",
  29531. "unscopables",
  29532. "unselectable",
  29533. "unshift",
  29534. "unsubscribe",
  29535. "unsuspendRedraw",
  29536. "unsuspendRedrawAll",
  29537. "unwatch",
  29538. "unwrapKey",
  29539. "upDegrees",
  29540. "upX",
  29541. "upY",
  29542. "upZ",
  29543. "update",
  29544. "updateAdInterestGroups",
  29545. "updateCallbackDone",
  29546. "updateCharacterBounds",
  29547. "updateCommands",
  29548. "updateControlBounds",
  29549. "updateCurrentEntry",
  29550. "updateIce",
  29551. "updateInkTrailStartPoint",
  29552. "updateInterval",
  29553. "updatePlaybackRate",
  29554. "updateRangeEnd",
  29555. "updateRangeStart",
  29556. "updateRenderState",
  29557. "updateSelection",
  29558. "updateSelectionBounds",
  29559. "updateSettings",
  29560. "updateText",
  29561. "updateTiming",
  29562. "updateViaCache",
  29563. "updateWith",
  29564. "updated",
  29565. "updating",
  29566. "upgrade",
  29567. "upload",
  29568. "uploadTotal",
  29569. "uploaded",
  29570. "upper",
  29571. "upperBound",
  29572. "upperOpen",
  29573. "uri",
  29574. "url",
  29575. "urn",
  29576. "urns",
  29577. "usage",
  29578. "usages",
  29579. "usb",
  29580. "usbVersionMajor",
  29581. "usbVersionMinor",
  29582. "usbVersionSubminor",
  29583. "useCurrentView",
  29584. "useMap",
  29585. "useProgram",
  29586. "usedSpace",
  29587. "user-select",
  29588. "userActivation",
  29589. "userAgent",
  29590. "userAgentData",
  29591. "userChoice",
  29592. "userHandle",
  29593. "userHint",
  29594. "userInitiated",
  29595. "userLanguage",
  29596. "userSelect",
  29597. "userState",
  29598. "userVisibleOnly",
  29599. "username",
  29600. "usernameFragment",
  29601. "utterance",
  29602. "uuid",
  29603. "v8BreakIterator",
  29604. "vAlign",
  29605. "vLink",
  29606. "valid",
  29607. "validate",
  29608. "validateProgram",
  29609. "validationMessage",
  29610. "validity",
  29611. "value",
  29612. "valueAsDate",
  29613. "valueAsNumber",
  29614. "valueAsString",
  29615. "valueInSpecifiedUnits",
  29616. "valueMissing",
  29617. "valueOf",
  29618. "valueText",
  29619. "valueType",
  29620. "values",
  29621. "variable",
  29622. "variant",
  29623. "variationSettings",
  29624. "vb",
  29625. "vector-effect",
  29626. "vectorEffect",
  29627. "velocityAngular",
  29628. "velocityExpansion",
  29629. "velocityX",
  29630. "velocityY",
  29631. "vendor",
  29632. "vendorId",
  29633. "vendorSub",
  29634. "verify",
  29635. "version",
  29636. "vertex",
  29637. "vertexAttrib1f",
  29638. "vertexAttrib1fv",
  29639. "vertexAttrib2f",
  29640. "vertexAttrib2fv",
  29641. "vertexAttrib3f",
  29642. "vertexAttrib3fv",
  29643. "vertexAttrib4f",
  29644. "vertexAttrib4fv",
  29645. "vertexAttribDivisor",
  29646. "vertexAttribDivisorANGLE",
  29647. "vertexAttribI4i",
  29648. "vertexAttribI4iv",
  29649. "vertexAttribI4ui",
  29650. "vertexAttribI4uiv",
  29651. "vertexAttribIPointer",
  29652. "vertexAttribPointer",
  29653. "vertical",
  29654. "vertical-align",
  29655. "verticalAlign",
  29656. "verticalOverflow",
  29657. "vh",
  29658. "vi",
  29659. "vibrate",
  29660. "vibrationActuator",
  29661. "videoBitsPerSecond",
  29662. "videoHeight",
  29663. "videoTracks",
  29664. "videoWidth",
  29665. "view",
  29666. "viewBox",
  29667. "viewBoxString",
  29668. "viewDimension",
  29669. "viewFormats",
  29670. "viewTarget",
  29671. "viewTargetString",
  29672. "viewTransition",
  29673. "viewport",
  29674. "viewportAnchorX",
  29675. "viewportAnchorY",
  29676. "viewportElement",
  29677. "views",
  29678. "violatedDirective",
  29679. "virtualKeyboard",
  29680. "virtualKeyboardPolicy",
  29681. "visibility",
  29682. "visibilityState",
  29683. "visible",
  29684. "visibleRect",
  29685. "visualViewport",
  29686. "vlinkColor",
  29687. "vmax",
  29688. "vmin",
  29689. "voice",
  29690. "voiceURI",
  29691. "volume",
  29692. "vrml",
  29693. "vspace",
  29694. "vw",
  29695. "w",
  29696. "wait",
  29697. "waitAsync",
  29698. "waitSync",
  29699. "waiting",
  29700. "wake",
  29701. "wakeLock",
  29702. "wand",
  29703. "warmup",
  29704. "warn",
  29705. "wasAlternateProtocolAvailable",
  29706. "wasClean",
  29707. "wasDiscarded",
  29708. "wasFetchedViaSpdy",
  29709. "wasNpnNegotiated",
  29710. "watch",
  29711. "watchAvailability",
  29712. "watchPosition",
  29713. "webNavigation",
  29714. "webRequest",
  29715. "webdriver",
  29716. "webkitAddKey",
  29717. "webkitAlignContent",
  29718. "webkitAlignItems",
  29719. "webkitAlignSelf",
  29720. "webkitAnimation",
  29721. "webkitAnimationDelay",
  29722. "webkitAnimationDirection",
  29723. "webkitAnimationDuration",
  29724. "webkitAnimationFillMode",
  29725. "webkitAnimationIterationCount",
  29726. "webkitAnimationName",
  29727. "webkitAnimationPlayState",
  29728. "webkitAnimationTimingFunction",
  29729. "webkitAppearance",
  29730. "webkitAudioContext",
  29731. "webkitAudioDecodedByteCount",
  29732. "webkitAudioPannerNode",
  29733. "webkitBackfaceVisibility",
  29734. "webkitBackground",
  29735. "webkitBackgroundAttachment",
  29736. "webkitBackgroundClip",
  29737. "webkitBackgroundColor",
  29738. "webkitBackgroundImage",
  29739. "webkitBackgroundOrigin",
  29740. "webkitBackgroundPosition",
  29741. "webkitBackgroundPositionX",
  29742. "webkitBackgroundPositionY",
  29743. "webkitBackgroundRepeat",
  29744. "webkitBackgroundSize",
  29745. "webkitBackingStorePixelRatio",
  29746. "webkitBorderBottomLeftRadius",
  29747. "webkitBorderBottomRightRadius",
  29748. "webkitBorderImage",
  29749. "webkitBorderImageOutset",
  29750. "webkitBorderImageRepeat",
  29751. "webkitBorderImageSlice",
  29752. "webkitBorderImageSource",
  29753. "webkitBorderImageWidth",
  29754. "webkitBorderRadius",
  29755. "webkitBorderTopLeftRadius",
  29756. "webkitBorderTopRightRadius",
  29757. "webkitBoxAlign",
  29758. "webkitBoxDirection",
  29759. "webkitBoxFlex",
  29760. "webkitBoxOrdinalGroup",
  29761. "webkitBoxOrient",
  29762. "webkitBoxPack",
  29763. "webkitBoxShadow",
  29764. "webkitBoxSizing",
  29765. "webkitCancelAnimationFrame",
  29766. "webkitCancelFullScreen",
  29767. "webkitCancelKeyRequest",
  29768. "webkitCancelRequestAnimationFrame",
  29769. "webkitClearResourceTimings",
  29770. "webkitClipPath",
  29771. "webkitClosedCaptionsVisible",
  29772. "webkitConvertPointFromNodeToPage",
  29773. "webkitConvertPointFromPageToNode",
  29774. "webkitCreateShadowRoot",
  29775. "webkitCurrentFullScreenElement",
  29776. "webkitCurrentPlaybackTargetIsWireless",
  29777. "webkitDecodedFrameCount",
  29778. "webkitDirectionInvertedFromDevice",
  29779. "webkitDisplayingFullscreen",
  29780. "webkitDroppedFrameCount",
  29781. "webkitEnterFullScreen",
  29782. "webkitEnterFullscreen",
  29783. "webkitEntries",
  29784. "webkitExitFullScreen",
  29785. "webkitExitFullscreen",
  29786. "webkitExitPointerLock",
  29787. "webkitFilter",
  29788. "webkitFlex",
  29789. "webkitFlexBasis",
  29790. "webkitFlexDirection",
  29791. "webkitFlexFlow",
  29792. "webkitFlexGrow",
  29793. "webkitFlexShrink",
  29794. "webkitFlexWrap",
  29795. "webkitFontFeatureSettings",
  29796. "webkitFullScreenKeyboardInputAllowed",
  29797. "webkitFullscreenElement",
  29798. "webkitFullscreenEnabled",
  29799. "webkitGenerateKeyRequest",
  29800. "webkitGetAsEntry",
  29801. "webkitGetDatabaseNames",
  29802. "webkitGetEntries",
  29803. "webkitGetEntriesByName",
  29804. "webkitGetEntriesByType",
  29805. "webkitGetFlowByName",
  29806. "webkitGetGamepads",
  29807. "webkitGetImageDataHD",
  29808. "webkitGetNamedFlows",
  29809. "webkitGetRegionFlowRanges",
  29810. "webkitGetUserMedia",
  29811. "webkitHasClosedCaptions",
  29812. "webkitHidden",
  29813. "webkitIDBCursor",
  29814. "webkitIDBDatabase",
  29815. "webkitIDBDatabaseError",
  29816. "webkitIDBDatabaseException",
  29817. "webkitIDBFactory",
  29818. "webkitIDBIndex",
  29819. "webkitIDBKeyRange",
  29820. "webkitIDBObjectStore",
  29821. "webkitIDBRequest",
  29822. "webkitIDBTransaction",
  29823. "webkitImageSmoothingEnabled",
  29824. "webkitIndexedDB",
  29825. "webkitInitMessageEvent",
  29826. "webkitIsFullScreen",
  29827. "webkitJustifyContent",
  29828. "webkitKeys",
  29829. "webkitLineClamp",
  29830. "webkitLineDashOffset",
  29831. "webkitLockOrientation",
  29832. "webkitMask",
  29833. "webkitMaskClip",
  29834. "webkitMaskComposite",
  29835. "webkitMaskImage",
  29836. "webkitMaskOrigin",
  29837. "webkitMaskPosition",
  29838. "webkitMaskPositionX",
  29839. "webkitMaskPositionY",
  29840. "webkitMaskRepeat",
  29841. "webkitMaskSize",
  29842. "webkitMatchesSelector",
  29843. "webkitMediaStream",
  29844. "webkitNotifications",
  29845. "webkitOfflineAudioContext",
  29846. "webkitOrder",
  29847. "webkitOrientation",
  29848. "webkitPeerConnection00",
  29849. "webkitPersistentStorage",
  29850. "webkitPerspective",
  29851. "webkitPerspectiveOrigin",
  29852. "webkitPointerLockElement",
  29853. "webkitPostMessage",
  29854. "webkitPreservesPitch",
  29855. "webkitPutImageDataHD",
  29856. "webkitRTCPeerConnection",
  29857. "webkitRegionOverset",
  29858. "webkitRelativePath",
  29859. "webkitRequestAnimationFrame",
  29860. "webkitRequestFileSystem",
  29861. "webkitRequestFullScreen",
  29862. "webkitRequestFullscreen",
  29863. "webkitRequestPointerLock",
  29864. "webkitResolveLocalFileSystemURL",
  29865. "webkitSetMediaKeys",
  29866. "webkitSetResourceTimingBufferSize",
  29867. "webkitShadowRoot",
  29868. "webkitShowPlaybackTargetPicker",
  29869. "webkitSlice",
  29870. "webkitSpeechGrammar",
  29871. "webkitSpeechGrammarList",
  29872. "webkitSpeechRecognition",
  29873. "webkitSpeechRecognitionError",
  29874. "webkitSpeechRecognitionEvent",
  29875. "webkitStorageInfo",
  29876. "webkitSupportsFullscreen",
  29877. "webkitTemporaryStorage",
  29878. "webkitTextFillColor",
  29879. "webkitTextSecurity",
  29880. "webkitTextSizeAdjust",
  29881. "webkitTextStroke",
  29882. "webkitTextStrokeColor",
  29883. "webkitTextStrokeWidth",
  29884. "webkitTransform",
  29885. "webkitTransformOrigin",
  29886. "webkitTransformStyle",
  29887. "webkitTransition",
  29888. "webkitTransitionDelay",
  29889. "webkitTransitionDuration",
  29890. "webkitTransitionProperty",
  29891. "webkitTransitionTimingFunction",
  29892. "webkitURL",
  29893. "webkitUnlockOrientation",
  29894. "webkitUserSelect",
  29895. "webkitVideoDecodedByteCount",
  29896. "webkitVisibilityState",
  29897. "webkitWirelessVideoPlaybackDisabled",
  29898. "webkitdirectory",
  29899. "webkitdropzone",
  29900. "webstore",
  29901. "weight",
  29902. "wgslLanguageFeatures",
  29903. "whatToShow",
  29904. "wheelDelta",
  29905. "wheelDeltaX",
  29906. "wheelDeltaY",
  29907. "whenDefined",
  29908. "which",
  29909. "white-space",
  29910. "white-space-collapse",
  29911. "whiteSpace",
  29912. "whiteSpaceCollapse",
  29913. "wholeText",
  29914. "widows",
  29915. "width",
  29916. "will-change",
  29917. "willChange",
  29918. "willValidate",
  29919. "window",
  29920. "windowAttribution",
  29921. "windowControlsOverlay",
  29922. "windowId",
  29923. "windowIds",
  29924. "windows",
  29925. "with",
  29926. "withCredentials",
  29927. "withResolvers",
  29928. "word-break",
  29929. "word-spacing",
  29930. "word-wrap",
  29931. "wordBreak",
  29932. "wordSpacing",
  29933. "wordWrap",
  29934. "workerStart",
  29935. "worklet",
  29936. "wow64",
  29937. "wrap",
  29938. "wrapKey",
  29939. "writable",
  29940. "writableAuxiliaries",
  29941. "write",
  29942. "writeBuffer",
  29943. "writeMask",
  29944. "writeText",
  29945. "writeTexture",
  29946. "writeTimestamp",
  29947. "writeValue",
  29948. "writeValueWithResponse",
  29949. "writeValueWithoutResponse",
  29950. "writeWithoutResponse",
  29951. "writeln",
  29952. "writing-mode",
  29953. "writingMode",
  29954. "writingSuggestions",
  29955. "x",
  29956. "x1",
  29957. "x2",
  29958. "xChannelSelector",
  29959. "xmlEncoding",
  29960. "xmlStandalone",
  29961. "xmlVersion",
  29962. "xmlbase",
  29963. "xmllang",
  29964. "xmlspace",
  29965. "xor",
  29966. "xr",
  29967. "y",
  29968. "y1",
  29969. "y2",
  29970. "yChannelSelector",
  29971. "yandex",
  29972. "yield",
  29973. "z",
  29974. "z-index",
  29975. "zIndex",
  29976. "zoom",
  29977. "zoomAndPan",
  29978. "zoomRectScreen",
  29979. ];
  29980. /***********************************************************************
  29981. A JavaScript tokenizer / parser / beautifier / compressor.
  29982. https://github.com/mishoo/UglifyJS2
  29983. -------------------------------- (C) ---------------------------------
  29984. Author: Mihai Bazon
  29985. <mihai.bazon@gmail.com>
  29986. http://mihai.bazon.net/blog
  29987. Distributed under the BSD license:
  29988. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  29989. Redistribution and use in source and binary forms, with or without
  29990. modification, are permitted provided that the following conditions
  29991. are met:
  29992. * Redistributions of source code must retain the above
  29993. copyright notice, this list of conditions and the following
  29994. disclaimer.
  29995. * Redistributions in binary form must reproduce the above
  29996. copyright notice, this list of conditions and the following
  29997. disclaimer in the documentation and/or other materials
  29998. provided with the distribution.
  29999. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  30000. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30001. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30002. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  30003. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30004. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  30005. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30006. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30007. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  30008. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  30009. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30010. SUCH DAMAGE.
  30011. ***********************************************************************/
  30012. function find_builtins(reserved) {
  30013. domprops.forEach(add);
  30014. // Compatibility fix for some standard defined globals not defined on every js environment
  30015. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  30016. var objects = {};
  30017. var global_ref = typeof global === "object" ? global : self;
  30018. new_globals.forEach(function (new_global) {
  30019. objects[new_global] = global_ref[new_global] || function() {};
  30020. });
  30021. [
  30022. "null",
  30023. "true",
  30024. "false",
  30025. "NaN",
  30026. "Infinity",
  30027. "-Infinity",
  30028. "undefined",
  30029. ].forEach(add);
  30030. [ Object, Array, Function, Number,
  30031. String, Boolean, Error, Math,
  30032. Date, RegExp, objects.Symbol, ArrayBuffer,
  30033. DataView, decodeURI, decodeURIComponent,
  30034. encodeURI, encodeURIComponent, eval, EvalError,
  30035. Float32Array, Float64Array, Int8Array, Int16Array,
  30036. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  30037. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  30038. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  30039. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  30040. objects.WeakMap, objects.WeakSet
  30041. ].forEach(function(ctor) {
  30042. Object.getOwnPropertyNames(ctor).map(add);
  30043. if (ctor.prototype) {
  30044. Object.getOwnPropertyNames(ctor.prototype).map(add);
  30045. }
  30046. });
  30047. function add(name) {
  30048. reserved.add(name);
  30049. }
  30050. }
  30051. function reserve_quoted_keys(ast, reserved) {
  30052. function add(name) {
  30053. push_uniq(reserved, name);
  30054. }
  30055. ast.walk(new TreeWalker(function(node) {
  30056. if (node instanceof AST_ObjectKeyVal && node.quote) {
  30057. add(node.key);
  30058. } else if (node instanceof AST_ObjectProperty && node.quote) {
  30059. add(node.key.name);
  30060. } else if (node instanceof AST_Sub) {
  30061. addStrings(node.property, add);
  30062. }
  30063. }));
  30064. }
  30065. function addStrings(node, add) {
  30066. node.walk(new TreeWalker(function(node) {
  30067. if (node instanceof AST_Sequence) {
  30068. addStrings(node.tail_node(), add);
  30069. } else if (node instanceof AST_String) {
  30070. add(node.value);
  30071. } else if (node instanceof AST_Conditional) {
  30072. addStrings(node.consequent, add);
  30073. addStrings(node.alternative, add);
  30074. }
  30075. return true;
  30076. }));
  30077. }
  30078. function mangle_private_properties(ast, options) {
  30079. var cprivate = -1;
  30080. var private_cache = new Map();
  30081. var nth_identifier = options.nth_identifier || base54;
  30082. ast = ast.transform(new TreeTransformer(function(node) {
  30083. if (
  30084. node instanceof AST_ClassPrivateProperty
  30085. || node instanceof AST_PrivateMethod
  30086. || node instanceof AST_PrivateGetter
  30087. || node instanceof AST_PrivateSetter
  30088. || node instanceof AST_PrivateIn
  30089. ) {
  30090. node.key.name = mangle_private(node.key.name);
  30091. } else if (node instanceof AST_DotHash) {
  30092. node.property = mangle_private(node.property);
  30093. }
  30094. }));
  30095. return ast;
  30096. function mangle_private(name) {
  30097. let mangled = private_cache.get(name);
  30098. if (!mangled) {
  30099. mangled = nth_identifier.get(++cprivate);
  30100. private_cache.set(name, mangled);
  30101. }
  30102. return mangled;
  30103. }
  30104. }
  30105. function find_annotated_props(ast) {
  30106. var annotated_props = new Set();
  30107. walk(ast, node => {
  30108. if (
  30109. node instanceof AST_ClassPrivateProperty
  30110. || node instanceof AST_PrivateMethod
  30111. || node instanceof AST_PrivateGetter
  30112. || node instanceof AST_PrivateSetter
  30113. || node instanceof AST_DotHash
  30114. ) ; else if (node instanceof AST_ObjectKeyVal) {
  30115. if (typeof node.key == "string" && has_annotation(node, _MANGLEPROP)) {
  30116. annotated_props.add(node.key);
  30117. }
  30118. } else if (node instanceof AST_ObjectProperty) {
  30119. // setter or getter, since KeyVal is handled above
  30120. if (has_annotation(node, _MANGLEPROP)) {
  30121. annotated_props.add(node.key.name);
  30122. }
  30123. } else if (node instanceof AST_Dot) {
  30124. if (has_annotation(node, _MANGLEPROP)) {
  30125. annotated_props.add(node.property);
  30126. }
  30127. } else if (node instanceof AST_Sub) {
  30128. if (node.property instanceof AST_String && has_annotation(node, _MANGLEPROP)) {
  30129. annotated_props.add(node.property.value);
  30130. }
  30131. }
  30132. });
  30133. return annotated_props;
  30134. }
  30135. function mangle_properties(ast, options, annotated_props = find_annotated_props(ast)) {
  30136. options = defaults(options, {
  30137. builtins: false,
  30138. cache: null,
  30139. debug: false,
  30140. keep_quoted: false,
  30141. nth_identifier: base54,
  30142. only_cache: false,
  30143. regex: null,
  30144. reserved: null,
  30145. undeclared: false,
  30146. only_annotated: false,
  30147. }, true);
  30148. var nth_identifier = options.nth_identifier;
  30149. var reserved_option = options.reserved;
  30150. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  30151. var reserved = new Set(reserved_option);
  30152. if (!options.builtins) find_builtins(reserved);
  30153. var cname = -1;
  30154. var cache;
  30155. if (options.cache) {
  30156. cache = options.cache.props;
  30157. } else {
  30158. cache = new Map();
  30159. }
  30160. var only_annotated = options.only_annotated;
  30161. var regex = options.regex && new RegExp(options.regex);
  30162. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  30163. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  30164. // the same as passing an empty string.
  30165. var debug = options.debug !== false;
  30166. var debug_name_suffix;
  30167. if (debug) {
  30168. debug_name_suffix = (options.debug === true ? "" : options.debug);
  30169. }
  30170. var names_to_mangle = new Set();
  30171. var unmangleable = new Set();
  30172. // Track each already-mangled name to prevent nth_identifier from generating
  30173. // the same name.
  30174. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  30175. var keep_quoted = !!options.keep_quoted;
  30176. // step 1: find candidates to mangle
  30177. ast.walk(new TreeWalker(function(node) {
  30178. if (
  30179. node instanceof AST_ClassPrivateProperty
  30180. || node instanceof AST_PrivateMethod
  30181. || node instanceof AST_PrivateGetter
  30182. || node instanceof AST_PrivateSetter
  30183. || node instanceof AST_DotHash
  30184. ) ; else if (node instanceof AST_ObjectKeyVal) {
  30185. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  30186. add(node.key);
  30187. }
  30188. } else if (node instanceof AST_ObjectProperty) {
  30189. // setter or getter, since KeyVal is handled above
  30190. if (!keep_quoted || !node.quote) {
  30191. add(node.key.name);
  30192. }
  30193. } else if (node instanceof AST_Dot) {
  30194. var declared = !!options.undeclared;
  30195. if (!declared) {
  30196. var root = node;
  30197. while (root.expression) {
  30198. root = root.expression;
  30199. }
  30200. declared = !(root.thedef && root.thedef.undeclared);
  30201. }
  30202. if (declared &&
  30203. (!keep_quoted || !node.quote)) {
  30204. add(node.property);
  30205. }
  30206. } else if (node instanceof AST_Sub) {
  30207. if (!keep_quoted) {
  30208. addStrings(node.property, add);
  30209. }
  30210. } else if (node instanceof AST_Call
  30211. && node.expression.print_to_string() == "Object.defineProperty") {
  30212. addStrings(node.args[1], add);
  30213. } else if (node instanceof AST_Binary && node.operator === "in") {
  30214. addStrings(node.left, add);
  30215. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  30216. add(node.value);
  30217. }
  30218. }));
  30219. // step 2: transform the tree, renaming properties
  30220. return ast.transform(new TreeTransformer(function(node) {
  30221. if (
  30222. node instanceof AST_ClassPrivateProperty
  30223. || node instanceof AST_PrivateMethod
  30224. || node instanceof AST_PrivateGetter
  30225. || node instanceof AST_PrivateSetter
  30226. || node instanceof AST_DotHash
  30227. ) ; else if (node instanceof AST_ObjectKeyVal) {
  30228. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  30229. node.key = mangle(node.key);
  30230. }
  30231. } else if (node instanceof AST_ObjectProperty) {
  30232. // setter, getter, method or class field
  30233. if (!keep_quoted || !node.quote) {
  30234. if (!node.computed_key()) {
  30235. node.key.name = mangle(node.key.name);
  30236. }
  30237. }
  30238. } else if (node instanceof AST_Dot) {
  30239. if (!keep_quoted || !node.quote) {
  30240. node.property = mangle(node.property);
  30241. }
  30242. } else if (!keep_quoted && node instanceof AST_Sub) {
  30243. node.property = mangleStrings(node.property);
  30244. } else if (node instanceof AST_Call
  30245. && node.expression.print_to_string() == "Object.defineProperty") {
  30246. node.args[1] = mangleStrings(node.args[1]);
  30247. } else if (node instanceof AST_Binary && node.operator === "in") {
  30248. node.left = mangleStrings(node.left);
  30249. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  30250. // Clear _KEY annotation to prevent double mangling
  30251. clear_annotation(node, _KEY);
  30252. node.value = mangle(node.value);
  30253. }
  30254. }));
  30255. // only function declarations after this line
  30256. function can_mangle(name) {
  30257. if (unmangleable.has(name)) return false;
  30258. if (reserved.has(name)) return false;
  30259. if (options.only_cache) {
  30260. return cache.has(name);
  30261. }
  30262. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  30263. return true;
  30264. }
  30265. function should_mangle(name) {
  30266. if (only_annotated && !annotated_props.has(name)) return false;
  30267. if (regex && !regex.test(name)) {
  30268. return annotated_props.has(name);
  30269. }
  30270. if (reserved.has(name)) return false;
  30271. return cache.has(name)
  30272. || names_to_mangle.has(name);
  30273. }
  30274. function add(name) {
  30275. if (can_mangle(name)) {
  30276. names_to_mangle.add(name);
  30277. }
  30278. if (!should_mangle(name)) {
  30279. unmangleable.add(name);
  30280. }
  30281. }
  30282. function mangle(name) {
  30283. if (!should_mangle(name)) {
  30284. return name;
  30285. }
  30286. var mangled = cache.get(name);
  30287. if (!mangled) {
  30288. if (debug) {
  30289. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  30290. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  30291. if (can_mangle(debug_mangled)) {
  30292. mangled = debug_mangled;
  30293. }
  30294. }
  30295. // either debug mode is off, or it is on and we could not use the mangled name
  30296. if (!mangled) {
  30297. do {
  30298. mangled = nth_identifier.get(++cname);
  30299. } while (!can_mangle(mangled));
  30300. }
  30301. cache.set(name, mangled);
  30302. }
  30303. return mangled;
  30304. }
  30305. function mangleStrings(node) {
  30306. return node.transform(new TreeTransformer(function(node) {
  30307. if (node instanceof AST_Sequence) {
  30308. var last = node.expressions.length - 1;
  30309. node.expressions[last] = mangleStrings(node.expressions[last]);
  30310. } else if (node instanceof AST_String) {
  30311. // Clear _KEY annotation to prevent double mangling
  30312. clear_annotation(node, _KEY);
  30313. node.value = mangle(node.value);
  30314. } else if (node instanceof AST_Conditional) {
  30315. node.consequent = mangleStrings(node.consequent);
  30316. node.alternative = mangleStrings(node.alternative);
  30317. }
  30318. return node;
  30319. }));
  30320. }
  30321. }
  30322. // to/from base64 functions
  30323. // Prefer built-in Buffer, if available, then use hack
  30324. // https://developer.mozilla.org/en-US/docs/Glossary/Base64#The_Unicode_Problem
  30325. var to_ascii = typeof Buffer !== "undefined"
  30326. ? (b64) => Buffer.from(b64, "base64").toString()
  30327. : (b64) => decodeURIComponent(escape(atob(b64)));
  30328. var to_base64 = typeof Buffer !== "undefined"
  30329. ? (str) => Buffer.from(str).toString("base64")
  30330. : (str) => btoa(unescape(encodeURIComponent(str)));
  30331. function read_source_map(code) {
  30332. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  30333. if (!match) {
  30334. console.warn("inline source map not found");
  30335. return null;
  30336. }
  30337. return to_ascii(match[2]);
  30338. }
  30339. function set_shorthand(name, options, keys) {
  30340. if (options[name]) {
  30341. keys.forEach(function(key) {
  30342. if (options[key]) {
  30343. if (typeof options[key] != "object") options[key] = {};
  30344. if (!(name in options[key])) options[key][name] = options[name];
  30345. }
  30346. });
  30347. }
  30348. }
  30349. function init_cache(cache) {
  30350. if (!cache) return;
  30351. if (!("props" in cache)) {
  30352. cache.props = new Map();
  30353. } else if (!(cache.props instanceof Map)) {
  30354. cache.props = map_from_object(cache.props);
  30355. }
  30356. }
  30357. function cache_to_json(cache) {
  30358. return {
  30359. props: map_to_object(cache.props)
  30360. };
  30361. }
  30362. function log_input(files, options, fs, debug_folder) {
  30363. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  30364. return;
  30365. }
  30366. try {
  30367. fs.mkdirSync(debug_folder);
  30368. } catch (e) {
  30369. if (e.code !== "EEXIST") throw e;
  30370. }
  30371. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  30372. options = options || {};
  30373. const options_str = JSON.stringify(options, (_key, thing) => {
  30374. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  30375. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  30376. return thing;
  30377. }, 4);
  30378. const files_str = (file) => {
  30379. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  30380. return JSON.stringify(file, null, 2);
  30381. } else if (typeof file === "object") {
  30382. return Object.keys(file)
  30383. .map((key) => key + ": " + files_str(file[key]))
  30384. .join("\n\n");
  30385. } else if (typeof file === "string") {
  30386. return "```\n" + file + "\n```";
  30387. } else {
  30388. return file; // What do?
  30389. }
  30390. };
  30391. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  30392. }
  30393. function* minify_sync_or_async(files, options, _fs_module) {
  30394. if (
  30395. _fs_module
  30396. && typeof process === "object"
  30397. && process.env
  30398. && typeof process.env.TERSER_DEBUG_DIR === "string"
  30399. ) {
  30400. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  30401. }
  30402. options = defaults(options, {
  30403. compress: {},
  30404. ecma: undefined,
  30405. enclose: false,
  30406. ie8: false,
  30407. keep_classnames: undefined,
  30408. keep_fnames: false,
  30409. mangle: {},
  30410. module: false,
  30411. nameCache: null,
  30412. output: null,
  30413. format: null,
  30414. parse: {},
  30415. rename: undefined,
  30416. safari10: false,
  30417. sourceMap: false,
  30418. spidermonkey: false,
  30419. timings: false,
  30420. toplevel: false,
  30421. warnings: false,
  30422. wrap: false,
  30423. }, true);
  30424. var timings = options.timings && {
  30425. start: Date.now()
  30426. };
  30427. if (options.keep_classnames === undefined) {
  30428. options.keep_classnames = options.keep_fnames;
  30429. }
  30430. if (options.rename === undefined) {
  30431. options.rename = options.compress && options.mangle;
  30432. }
  30433. if (options.output && options.format) {
  30434. throw new Error("Please only specify either output or format option, preferrably format.");
  30435. }
  30436. options.format = options.format || options.output || {};
  30437. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  30438. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  30439. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  30440. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  30441. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  30442. set_shorthand("safari10", options, [ "mangle", "format" ]);
  30443. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  30444. set_shorthand("warnings", options, [ "compress" ]); // legacy
  30445. var quoted_props;
  30446. if (options.mangle) {
  30447. options.mangle = defaults(options.mangle, {
  30448. cache: options.nameCache && (options.nameCache.vars || {}),
  30449. eval: false,
  30450. ie8: false,
  30451. keep_classnames: false,
  30452. keep_fnames: false,
  30453. module: false,
  30454. nth_identifier: base54,
  30455. properties: false,
  30456. reserved: [],
  30457. safari10: false,
  30458. toplevel: false,
  30459. }, true);
  30460. if (options.mangle.properties) {
  30461. if (typeof options.mangle.properties != "object") {
  30462. options.mangle.properties = {};
  30463. }
  30464. if (options.mangle.properties.keep_quoted) {
  30465. quoted_props = options.mangle.properties.reserved;
  30466. if (!Array.isArray(quoted_props)) quoted_props = [];
  30467. options.mangle.properties.reserved = quoted_props;
  30468. }
  30469. if (options.nameCache && !("cache" in options.mangle.properties)) {
  30470. options.mangle.properties.cache = options.nameCache.props || {};
  30471. }
  30472. }
  30473. init_cache(options.mangle.cache);
  30474. init_cache(options.mangle.properties.cache);
  30475. }
  30476. if (options.sourceMap) {
  30477. options.sourceMap = defaults(options.sourceMap, {
  30478. asObject: false,
  30479. content: null,
  30480. filename: null,
  30481. includeSources: false,
  30482. root: null,
  30483. url: null,
  30484. }, true);
  30485. }
  30486. // -- Parse phase --
  30487. if (timings) timings.parse = Date.now();
  30488. var toplevel;
  30489. if (files instanceof AST_Toplevel) {
  30490. toplevel = files;
  30491. } else {
  30492. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  30493. files = [ files ];
  30494. }
  30495. options.parse = options.parse || {};
  30496. options.parse.toplevel = null;
  30497. if (options.parse.spidermonkey) {
  30498. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  30499. if (!toplevel) return files[name];
  30500. toplevel.body = toplevel.body.concat(files[name].body);
  30501. return toplevel;
  30502. }, null));
  30503. } else {
  30504. delete options.parse.spidermonkey;
  30505. for (var name in files) if (HOP(files, name)) {
  30506. options.parse.filename = name;
  30507. options.parse.toplevel = parse(files[name], options.parse);
  30508. if (options.sourceMap && options.sourceMap.content == "inline") {
  30509. if (Object.keys(files).length > 1)
  30510. throw new Error("inline source map only works with singular input");
  30511. options.sourceMap.content = read_source_map(files[name]);
  30512. }
  30513. }
  30514. }
  30515. if (options.parse.toplevel === null) {
  30516. throw new Error("no source file given");
  30517. }
  30518. toplevel = options.parse.toplevel;
  30519. }
  30520. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  30521. reserve_quoted_keys(toplevel, quoted_props);
  30522. }
  30523. var annotated_props;
  30524. if (options.mangle && options.mangle.properties) {
  30525. annotated_props = find_annotated_props(toplevel);
  30526. }
  30527. if (options.wrap) {
  30528. toplevel = toplevel.wrap_commonjs(options.wrap);
  30529. }
  30530. if (options.enclose) {
  30531. toplevel = toplevel.wrap_enclose(options.enclose);
  30532. }
  30533. if (timings) timings.rename = Date.now();
  30534. // -- Compress phase --
  30535. if (timings) timings.compress = Date.now();
  30536. if (options.compress) {
  30537. toplevel = new Compressor(options.compress, {
  30538. mangle_options: options.mangle
  30539. }).compress(toplevel);
  30540. }
  30541. // -- Mangle phase --
  30542. if (timings) timings.scope = Date.now();
  30543. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  30544. if (timings) timings.mangle = Date.now();
  30545. if (options.mangle) {
  30546. toplevel.compute_char_frequency(options.mangle);
  30547. toplevel.mangle_names(options.mangle);
  30548. toplevel = mangle_private_properties(toplevel, options.mangle);
  30549. }
  30550. if (timings) timings.properties = Date.now();
  30551. if (options.mangle && options.mangle.properties) {
  30552. toplevel = mangle_properties(toplevel, options.mangle.properties, annotated_props);
  30553. }
  30554. // Format phase
  30555. if (timings) timings.format = Date.now();
  30556. var result = {};
  30557. if (options.format.ast) {
  30558. result.ast = toplevel;
  30559. }
  30560. if (options.format.spidermonkey) {
  30561. result.ast = toplevel.to_mozilla_ast();
  30562. }
  30563. let format_options;
  30564. if (!HOP(options.format, "code") || options.format.code) {
  30565. // Make a shallow copy so that we can modify without mutating the user's input.
  30566. format_options = {...options.format};
  30567. if (!format_options.ast) {
  30568. // Destroy stuff to save RAM. (unless the deprecated `ast` option is on)
  30569. format_options._destroy_ast = true;
  30570. walk(toplevel, node => {
  30571. if (node instanceof AST_Scope) {
  30572. node.variables = undefined;
  30573. node.enclosed = undefined;
  30574. node.parent_scope = undefined;
  30575. }
  30576. if (node.block_scope) {
  30577. node.block_scope.variables = undefined;
  30578. node.block_scope.enclosed = undefined;
  30579. node.block_scope.parent_scope = undefined;
  30580. }
  30581. });
  30582. }
  30583. if (options.sourceMap) {
  30584. if (options.sourceMap.includeSources && files instanceof AST_Toplevel) {
  30585. throw new Error("original source content unavailable");
  30586. }
  30587. format_options.source_map = yield* SourceMap({
  30588. file: options.sourceMap.filename,
  30589. orig: options.sourceMap.content,
  30590. root: options.sourceMap.root,
  30591. files: options.sourceMap.includeSources ? files : null,
  30592. });
  30593. }
  30594. delete format_options.ast;
  30595. delete format_options.code;
  30596. delete format_options.spidermonkey;
  30597. var stream = OutputStream(format_options);
  30598. toplevel.print(stream);
  30599. result.code = stream.get();
  30600. if (options.sourceMap) {
  30601. Object.defineProperty(result, "map", {
  30602. configurable: true,
  30603. enumerable: true,
  30604. get() {
  30605. const map = format_options.source_map.getEncoded();
  30606. return (result.map = options.sourceMap.asObject ? map : JSON.stringify(map));
  30607. },
  30608. set(value) {
  30609. Object.defineProperty(result, "map", {
  30610. value,
  30611. writable: true,
  30612. });
  30613. }
  30614. });
  30615. result.decoded_map = format_options.source_map.getDecoded();
  30616. if (options.sourceMap.url == "inline") {
  30617. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  30618. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  30619. } else if (options.sourceMap.url) {
  30620. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  30621. }
  30622. }
  30623. }
  30624. if (options.nameCache && options.mangle) {
  30625. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  30626. if (options.mangle.properties && options.mangle.properties.cache) {
  30627. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  30628. }
  30629. }
  30630. if (format_options && format_options.source_map) {
  30631. format_options.source_map.destroy();
  30632. }
  30633. if (timings) {
  30634. timings.end = Date.now();
  30635. result.timings = {
  30636. parse: 1e-3 * (timings.rename - timings.parse),
  30637. rename: 1e-3 * (timings.compress - timings.rename),
  30638. compress: 1e-3 * (timings.scope - timings.compress),
  30639. scope: 1e-3 * (timings.mangle - timings.scope),
  30640. mangle: 1e-3 * (timings.properties - timings.mangle),
  30641. properties: 1e-3 * (timings.format - timings.properties),
  30642. format: 1e-3 * (timings.end - timings.format),
  30643. total: 1e-3 * (timings.end - timings.start)
  30644. };
  30645. }
  30646. return result;
  30647. }
  30648. async function minify(files, options, _fs_module) {
  30649. const gen = minify_sync_or_async(files, options, _fs_module);
  30650. let yielded;
  30651. let val;
  30652. do {
  30653. val = gen.next(await yielded);
  30654. yielded = val.value;
  30655. } while (!val.done);
  30656. return val.value;
  30657. }
  30658. function minify_sync(files, options, _fs_module) {
  30659. const gen = minify_sync_or_async(files, options, _fs_module);
  30660. let yielded;
  30661. let val;
  30662. do {
  30663. if (yielded && typeof yielded.then === "function") {
  30664. throw new Error("minify_sync cannot be used with the legacy source-map module");
  30665. }
  30666. val = gen.next(yielded);
  30667. yielded = val.value;
  30668. } while (!val.done);
  30669. return val.value;
  30670. }
  30671. async function run_cli({ program, packageJson, fs, path }) {
  30672. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  30673. var files = {};
  30674. var options = {
  30675. compress: false,
  30676. mangle: false
  30677. };
  30678. const default_options = await _default_options();
  30679. program.version(packageJson.name + " " + packageJson.version);
  30680. program.parseArgv = program.parse;
  30681. program.parse = undefined;
  30682. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  30683. else if (process.argv.includes("options")) program.helpInformation = function() {
  30684. var text = [];
  30685. for (var option in default_options) {
  30686. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  30687. text.push(format_object(default_options[option]));
  30688. text.push("");
  30689. }
  30690. return text.join("\n");
  30691. };
  30692. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  30693. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  30694. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  30695. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  30696. program.option("-f, --format [options]", "Format options.", parse_js());
  30697. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  30698. program.option("-o, --output <file>", "Output file (default STDOUT).");
  30699. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  30700. program.option("--config-file <file>", "Read minify() options from JSON file.");
  30701. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  30702. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  30703. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  30704. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  30705. program.option("--keep-classnames", "Do not mangle/drop class names.");
  30706. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  30707. program.option("--module", "Input is an ES6 module");
  30708. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  30709. program.option("--rename", "Force symbol expansion.");
  30710. program.option("--no-rename", "Disable symbol expansion.");
  30711. program.option("--safari10", "Support non-standard Safari 10.");
  30712. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  30713. program.option("--timings", "Display operations run time on STDERR.");
  30714. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  30715. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  30716. program.arguments("[files...]").parseArgv(process.argv);
  30717. if (program.configFile) {
  30718. options = JSON.parse(read_file(program.configFile));
  30719. }
  30720. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  30721. fatal("ERROR: cannot write source map to STDOUT");
  30722. }
  30723. [
  30724. "compress",
  30725. "enclose",
  30726. "ie8",
  30727. "mangle",
  30728. "module",
  30729. "safari10",
  30730. "sourceMap",
  30731. "toplevel",
  30732. "wrap"
  30733. ].forEach(function(name) {
  30734. if (name in program) {
  30735. options[name] = program[name];
  30736. }
  30737. });
  30738. if ("ecma" in program) {
  30739. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  30740. const ecma = program.ecma | 0;
  30741. if (ecma > 5 && ecma < 2015)
  30742. options.ecma = ecma + 2009;
  30743. else
  30744. options.ecma = ecma;
  30745. }
  30746. if (program.format || program.beautify) {
  30747. const chosenOption = program.format || program.beautify;
  30748. options.format = typeof chosenOption === "object" ? chosenOption : {};
  30749. }
  30750. if (program.comments) {
  30751. if (typeof options.format != "object") options.format = {};
  30752. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  30753. }
  30754. if (program.define) {
  30755. if (typeof options.compress != "object") options.compress = {};
  30756. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  30757. for (var expr in program.define) {
  30758. options.compress.global_defs[expr] = program.define[expr];
  30759. }
  30760. }
  30761. if (program.keepClassnames) {
  30762. options.keep_classnames = true;
  30763. }
  30764. if (program.keepFnames) {
  30765. options.keep_fnames = true;
  30766. }
  30767. if (program.mangleProps) {
  30768. if (program.mangleProps.domprops) {
  30769. delete program.mangleProps.domprops;
  30770. } else {
  30771. if (typeof program.mangleProps != "object") program.mangleProps = {};
  30772. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  30773. }
  30774. if (typeof options.mangle != "object") options.mangle = {};
  30775. options.mangle.properties = program.mangleProps;
  30776. }
  30777. if (program.nameCache) {
  30778. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  30779. }
  30780. if (program.output == "ast") {
  30781. options.format = {
  30782. ast: true,
  30783. code: false
  30784. };
  30785. }
  30786. if (program.parse) {
  30787. if (!program.parse.acorn && !program.parse.spidermonkey) {
  30788. options.parse = program.parse;
  30789. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  30790. fatal("ERROR: inline source map only works with built-in parser");
  30791. }
  30792. }
  30793. if (~program.rawArgs.indexOf("--rename")) {
  30794. options.rename = true;
  30795. } else if (!program.rename) {
  30796. options.rename = false;
  30797. }
  30798. let convert_path = name => name;
  30799. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  30800. convert_path = function() {
  30801. var base = program.sourceMap.base;
  30802. delete options.sourceMap.base;
  30803. return function(name) {
  30804. return path.relative(base, name);
  30805. };
  30806. }();
  30807. }
  30808. let filesList;
  30809. if (options.files && options.files.length) {
  30810. filesList = options.files;
  30811. delete options.files;
  30812. } else if (program.args.length) {
  30813. filesList = program.args;
  30814. }
  30815. if (filesList) {
  30816. simple_glob(filesList).forEach(function(name) {
  30817. files[convert_path(name)] = read_file(name);
  30818. });
  30819. } else {
  30820. await new Promise((resolve) => {
  30821. var chunks = [];
  30822. process.stdin.setEncoding("utf8");
  30823. process.stdin.on("data", function(chunk) {
  30824. chunks.push(chunk);
  30825. }).on("end", function() {
  30826. files = [ chunks.join("") ];
  30827. resolve();
  30828. });
  30829. process.stdin.resume();
  30830. });
  30831. }
  30832. await run_cli();
  30833. function convert_ast(fn) {
  30834. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  30835. }
  30836. async function run_cli() {
  30837. var content = program.sourceMap && program.sourceMap.content;
  30838. if (content && content !== "inline") {
  30839. options.sourceMap.content = read_file(content, content);
  30840. }
  30841. if (program.timings) options.timings = true;
  30842. try {
  30843. if (program.parse) {
  30844. if (program.parse.acorn) {
  30845. files = convert_ast(function(toplevel, name) {
  30846. return require("acorn").parse(files[name], {
  30847. ecmaVersion: 2024,
  30848. locations: true,
  30849. program: toplevel,
  30850. sourceFile: name,
  30851. sourceType: options.module || program.parse.module ? "module" : "script"
  30852. });
  30853. });
  30854. } else if (program.parse.spidermonkey) {
  30855. files = convert_ast(function(toplevel, name) {
  30856. var obj = JSON.parse(files[name]);
  30857. if (!toplevel) return obj;
  30858. toplevel.body = toplevel.body.concat(obj.body);
  30859. return toplevel;
  30860. });
  30861. }
  30862. }
  30863. } catch (ex) {
  30864. fatal(ex);
  30865. }
  30866. let result;
  30867. try {
  30868. result = await minify(files, options, fs);
  30869. } catch (ex) {
  30870. if (ex.name == "SyntaxError") {
  30871. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  30872. var col = ex.col;
  30873. var lines = files[ex.filename].split(/\r?\n/);
  30874. var line = lines[ex.line - 1];
  30875. if (!line && !col) {
  30876. line = lines[ex.line - 2];
  30877. col = line.length;
  30878. }
  30879. if (line) {
  30880. var limit = 70;
  30881. if (col > limit) {
  30882. line = line.slice(col - limit);
  30883. col = limit;
  30884. }
  30885. print_error(line.slice(0, 80));
  30886. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  30887. }
  30888. }
  30889. if (ex.defs) {
  30890. print_error("Supported options:");
  30891. print_error(format_object(ex.defs));
  30892. }
  30893. fatal(ex);
  30894. return;
  30895. }
  30896. if (program.output == "ast") {
  30897. if (!options.compress && !options.mangle) {
  30898. result.ast.figure_out_scope({});
  30899. }
  30900. console.log(JSON.stringify(result.ast, function(key, value) {
  30901. if (value) switch (key) {
  30902. case "thedef":
  30903. return symdef(value);
  30904. case "enclosed":
  30905. return value.length ? value.map(symdef) : undefined;
  30906. case "variables":
  30907. case "globals":
  30908. return value.size ? collect_from_map(value, symdef) : undefined;
  30909. }
  30910. if (skip_keys.has(key)) return;
  30911. if (value instanceof AST_Token) return;
  30912. if (value instanceof Map) return;
  30913. if (value instanceof AST_Node) {
  30914. var result = {
  30915. _class: "AST_" + value.TYPE
  30916. };
  30917. if (value.block_scope) {
  30918. result.variables = value.block_scope.variables;
  30919. result.enclosed = value.block_scope.enclosed;
  30920. }
  30921. value.CTOR.PROPS.forEach(function(prop) {
  30922. if (prop !== "block_scope") {
  30923. result[prop] = value[prop];
  30924. }
  30925. });
  30926. return result;
  30927. }
  30928. return value;
  30929. }, 2));
  30930. } else if (program.output == "spidermonkey") {
  30931. try {
  30932. const minified = await minify(
  30933. result.code,
  30934. {
  30935. compress: false,
  30936. mangle: false,
  30937. format: {
  30938. ast: true,
  30939. code: false
  30940. }
  30941. },
  30942. fs
  30943. );
  30944. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  30945. } catch (ex) {
  30946. fatal(ex);
  30947. return;
  30948. }
  30949. } else if (program.output) {
  30950. fs.mkdirSync(path.dirname(program.output), { recursive: true });
  30951. fs.writeFileSync(program.output, result.code);
  30952. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  30953. fs.writeFileSync(program.output + ".map", result.map);
  30954. }
  30955. } else {
  30956. console.log(result.code);
  30957. }
  30958. if (program.nameCache) {
  30959. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  30960. }
  30961. if (result.timings) for (var phase in result.timings) {
  30962. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  30963. }
  30964. }
  30965. function fatal(message) {
  30966. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  30967. print_error(message);
  30968. process.exit(1);
  30969. }
  30970. // A file glob function that only supports "*" and "?" wildcards in the basename.
  30971. // Example: "foo/bar/*baz??.*.js"
  30972. // Argument `glob` may be a string or an array of strings.
  30973. // Returns an array of strings. Garbage in, garbage out.
  30974. function simple_glob(glob) {
  30975. if (Array.isArray(glob)) {
  30976. return [].concat.apply([], glob.map(simple_glob));
  30977. }
  30978. if (glob && glob.match(/[*?]/)) {
  30979. var dir = path.dirname(glob);
  30980. try {
  30981. var entries = fs.readdirSync(dir);
  30982. } catch (ex) {}
  30983. if (entries) {
  30984. var pattern = "^" + path.basename(glob)
  30985. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  30986. .replace(/\*/g, "[^/\\\\]*")
  30987. .replace(/\?/g, "[^/\\\\]") + "$";
  30988. var mod = process.platform === "win32" ? "i" : "";
  30989. var rx = new RegExp(pattern, mod);
  30990. var results = entries.filter(function(name) {
  30991. return rx.test(name);
  30992. }).map(function(name) {
  30993. return path.join(dir, name);
  30994. });
  30995. if (results.length) return results;
  30996. }
  30997. }
  30998. return [ glob ];
  30999. }
  31000. function read_file(path, default_value) {
  31001. try {
  31002. return fs.readFileSync(path, "utf8");
  31003. } catch (ex) {
  31004. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  31005. fatal(ex);
  31006. }
  31007. }
  31008. function parse_js(flag) {
  31009. return function(value, options) {
  31010. options = options || {};
  31011. try {
  31012. walk(parse(value, { expression: true }), node => {
  31013. if (node instanceof AST_Assign) {
  31014. var name = node.left.print_to_string();
  31015. var value = node.right;
  31016. if (flag) {
  31017. options[name] = value;
  31018. } else if (value instanceof AST_Array) {
  31019. options[name] = value.elements.map(to_string);
  31020. } else if (value instanceof AST_RegExp) {
  31021. value = value.value;
  31022. options[name] = new RegExp(value.source, value.flags);
  31023. } else {
  31024. options[name] = to_string(value);
  31025. }
  31026. return true;
  31027. }
  31028. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  31029. var name = node.print_to_string();
  31030. options[name] = true;
  31031. return true;
  31032. }
  31033. if (!(node instanceof AST_Sequence)) throw node;
  31034. function to_string(value) {
  31035. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  31036. quote_keys: true
  31037. });
  31038. }
  31039. });
  31040. } catch(ex) {
  31041. if (flag) {
  31042. fatal("Error parsing arguments for '" + flag + "': " + value);
  31043. } else {
  31044. options[value] = null;
  31045. }
  31046. }
  31047. return options;
  31048. };
  31049. }
  31050. function symdef(def) {
  31051. var ret = (1e6 + def.id) + " " + def.name;
  31052. if (def.mangled_name) ret += " " + def.mangled_name;
  31053. return ret;
  31054. }
  31055. function collect_from_map(map, callback) {
  31056. var result = [];
  31057. map.forEach(function (def) {
  31058. result.push(callback(def));
  31059. });
  31060. return result;
  31061. }
  31062. function format_object(obj) {
  31063. var lines = [];
  31064. var padding = "";
  31065. Object.keys(obj).map(function(name) {
  31066. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  31067. return [ name, JSON.stringify(obj[name]) ];
  31068. }).forEach(function(tokens) {
  31069. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  31070. });
  31071. return lines.join("\n");
  31072. }
  31073. function print_error(msg) {
  31074. process.stderr.write(msg);
  31075. process.stderr.write("\n");
  31076. }
  31077. function describe_ast() {
  31078. var out = OutputStream({ beautify: true });
  31079. function doitem(ctor) {
  31080. out.print("AST_" + ctor.TYPE);
  31081. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  31082. if (props.length > 0) {
  31083. out.space();
  31084. out.with_parens(function() {
  31085. props.forEach(function(prop, i) {
  31086. if (i) out.space();
  31087. out.print(prop);
  31088. });
  31089. });
  31090. }
  31091. if (ctor.documentation) {
  31092. out.space();
  31093. out.print_string(ctor.documentation);
  31094. }
  31095. if (ctor.SUBCLASSES.length > 0) {
  31096. out.space();
  31097. out.with_block(function() {
  31098. ctor.SUBCLASSES.forEach(function(ctor) {
  31099. out.indent();
  31100. doitem(ctor);
  31101. out.newline();
  31102. });
  31103. });
  31104. }
  31105. }
  31106. doitem(AST_Node);
  31107. return out + "\n";
  31108. }
  31109. }
  31110. async function _default_options() {
  31111. const defs = {};
  31112. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  31113. const options = infer_options({
  31114. [component]: {0: 0}
  31115. });
  31116. if (options) defs[component] = options;
  31117. });
  31118. return defs;
  31119. }
  31120. async function infer_options(options) {
  31121. try {
  31122. await minify("", options);
  31123. } catch (error) {
  31124. return error.defs;
  31125. }
  31126. }
  31127. exports._default_options = _default_options;
  31128. exports._run_cli = run_cli;
  31129. exports.minify = minify;
  31130. exports.minify_sync = minify_sync;
  31131. }));