bundle.min.js 1017 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/source-map')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/source-map'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
  5. })(this, (function (exports, sourceMap) { 'use strict';
  6. /***********************************************************************
  7. A JavaScript tokenizer / parser / beautifier / compressor.
  8. https://github.com/mishoo/UglifyJS2
  9. -------------------------------- (C) ---------------------------------
  10. Author: Mihai Bazon
  11. <mihai.bazon@gmail.com>
  12. http://mihai.bazon.net/blog
  13. Distributed under the BSD license:
  14. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15. Redistribution and use in source and binary forms, with or without
  16. modification, are permitted provided that the following conditions
  17. are met:
  18. * Redistributions of source code must retain the above
  19. copyright notice, this list of conditions and the following
  20. disclaimer.
  21. * Redistributions in binary form must reproduce the above
  22. copyright notice, this list of conditions and the following
  23. disclaimer in the documentation and/or other materials
  24. provided with the distribution.
  25. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  26. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  28. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  31. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  32. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  35. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. SUCH DAMAGE.
  37. ***********************************************************************/
  38. function characters(str) {
  39. return str.split("");
  40. }
  41. function member(name, array) {
  42. return array.includes(name);
  43. }
  44. class DefaultsError extends Error {
  45. constructor(msg, defs) {
  46. super();
  47. this.name = "DefaultsError";
  48. this.message = msg;
  49. this.defs = defs;
  50. }
  51. }
  52. function defaults(args, defs, croak) {
  53. if (args === true) {
  54. args = {};
  55. } else if (args != null && typeof args === "object") {
  56. args = {...args};
  57. }
  58. const ret = args || {};
  59. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  60. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  61. }
  62. for (const i in defs) if (HOP(defs, i)) {
  63. if (!args || !HOP(args, i)) {
  64. ret[i] = defs[i];
  65. } else if (i === "ecma") {
  66. let ecma = args[i] | 0;
  67. if (ecma > 5 && ecma < 2015) ecma += 2009;
  68. ret[i] = ecma;
  69. } else {
  70. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  71. }
  72. }
  73. return ret;
  74. }
  75. function noop() {}
  76. function return_false() { return false; }
  77. function return_true() { return true; }
  78. function return_this() { return this; }
  79. function return_null() { return null; }
  80. var MAP = (function() {
  81. function MAP(a, tw, allow_splicing = true) {
  82. const new_a = [];
  83. for (let i = 0; i < a.length; ++i) {
  84. let item = a[i];
  85. let ret = item.transform(tw, allow_splicing);
  86. if (ret instanceof AST_Node) {
  87. new_a.push(ret);
  88. } else if (ret instanceof Splice) {
  89. new_a.push(...ret.v);
  90. }
  91. }
  92. return new_a;
  93. }
  94. MAP.splice = function(val) { return new Splice(val); };
  95. MAP.skip = {};
  96. function Splice(val) { this.v = val; }
  97. return MAP;
  98. })();
  99. function make_node(ctor, orig, props) {
  100. if (!props) props = {};
  101. if (orig) {
  102. if (!props.start) props.start = orig.start;
  103. if (!props.end) props.end = orig.end;
  104. }
  105. return new ctor(props);
  106. }
  107. function push_uniq(array, el) {
  108. if (!array.includes(el))
  109. array.push(el);
  110. }
  111. function string_template(text, props) {
  112. return text.replace(/{(.+?)}/g, function(str, p) {
  113. return props && props[p];
  114. });
  115. }
  116. function remove(array, el) {
  117. for (var i = array.length; --i >= 0;) {
  118. if (array[i] === el) array.splice(i, 1);
  119. }
  120. }
  121. function mergeSort(array, cmp) {
  122. if (array.length < 2) return array.slice();
  123. function merge(a, b) {
  124. var r = [], ai = 0, bi = 0, i = 0;
  125. while (ai < a.length && bi < b.length) {
  126. cmp(a[ai], b[bi]) <= 0
  127. ? r[i++] = a[ai++]
  128. : r[i++] = b[bi++];
  129. }
  130. if (ai < a.length) r.push.apply(r, a.slice(ai));
  131. if (bi < b.length) r.push.apply(r, b.slice(bi));
  132. return r;
  133. }
  134. function _ms(a) {
  135. if (a.length <= 1)
  136. return a;
  137. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  138. left = _ms(left);
  139. right = _ms(right);
  140. return merge(left, right);
  141. }
  142. return _ms(array);
  143. }
  144. function makePredicate(words) {
  145. if (!Array.isArray(words)) words = words.split(" ");
  146. return new Set(words.sort());
  147. }
  148. function map_add(map, key, value) {
  149. if (map.has(key)) {
  150. map.get(key).push(value);
  151. } else {
  152. map.set(key, [ value ]);
  153. }
  154. }
  155. function map_from_object(obj) {
  156. var map = new Map();
  157. for (var key in obj) {
  158. if (HOP(obj, key) && key.charAt(0) === "$") {
  159. map.set(key.substr(1), obj[key]);
  160. }
  161. }
  162. return map;
  163. }
  164. function map_to_object(map) {
  165. var obj = Object.create(null);
  166. map.forEach(function (value, key) {
  167. obj["$" + key] = value;
  168. });
  169. return obj;
  170. }
  171. function HOP(obj, prop) {
  172. return Object.prototype.hasOwnProperty.call(obj, prop);
  173. }
  174. function keep_name(keep_setting, name) {
  175. return keep_setting === true
  176. || (keep_setting instanceof RegExp && keep_setting.test(name));
  177. }
  178. var lineTerminatorEscape = {
  179. "\0": "0",
  180. "\n": "n",
  181. "\r": "r",
  182. "\u2028": "u2028",
  183. "\u2029": "u2029",
  184. };
  185. function regexp_source_fix(source) {
  186. // V8 does not escape line terminators in regexp patterns in node 12
  187. // We'll also remove literal \0
  188. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  189. var escaped = source[offset - 1] == "\\"
  190. && (source[offset - 2] != "\\"
  191. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  192. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  193. });
  194. }
  195. // Subset of regexps that is not going to cause regexp based DDOS
  196. // https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
  197. const re_safe_regexp = /^[\\/|\0\s\w^$.[\]()]*$/;
  198. /** Check if the regexp is safe for Terser to create without risking a RegExp DOS */
  199. const regexp_is_safe = (source) => re_safe_regexp.test(source);
  200. const all_flags = "dgimsuyv";
  201. function sort_regexp_flags(flags) {
  202. const existing_flags = new Set(flags.split(""));
  203. let out = "";
  204. for (const flag of all_flags) {
  205. if (existing_flags.has(flag)) {
  206. out += flag;
  207. existing_flags.delete(flag);
  208. }
  209. }
  210. if (existing_flags.size) {
  211. // Flags Terser doesn't know about
  212. existing_flags.forEach(flag => { out += flag; });
  213. }
  214. return out;
  215. }
  216. function has_annotation(node, annotation) {
  217. return node._annotations & annotation;
  218. }
  219. function set_annotation(node, annotation) {
  220. node._annotations |= annotation;
  221. }
  222. function clear_annotation(node, annotation) {
  223. node._annotations &= ~annotation;
  224. }
  225. /***********************************************************************
  226. A JavaScript tokenizer / parser / beautifier / compressor.
  227. https://github.com/mishoo/UglifyJS2
  228. -------------------------------- (C) ---------------------------------
  229. Author: Mihai Bazon
  230. <mihai.bazon@gmail.com>
  231. http://mihai.bazon.net/blog
  232. Distributed under the BSD license:
  233. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  234. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  235. Redistribution and use in source and binary forms, with or without
  236. modification, are permitted provided that the following conditions
  237. are met:
  238. * Redistributions of source code must retain the above
  239. copyright notice, this list of conditions and the following
  240. disclaimer.
  241. * Redistributions in binary form must reproduce the above
  242. copyright notice, this list of conditions and the following
  243. disclaimer in the documentation and/or other materials
  244. provided with the distribution.
  245. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  246. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  247. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  248. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  249. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  250. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  251. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  252. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  253. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  254. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  255. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  256. SUCH DAMAGE.
  257. ***********************************************************************/
  258. var LATEST_RAW = ""; // Only used for numbers and template strings
  259. var TEMPLATE_RAWS = new Map(); // Raw template strings
  260. var KEYWORDS = "break case catch class const continue debugger default delete do else export extends finally for function if in instanceof let new return switch throw try typeof var void while with";
  261. var KEYWORDS_ATOM = "false null true";
  262. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  263. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  264. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  265. KEYWORDS = makePredicate(KEYWORDS);
  266. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  267. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  268. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  269. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  270. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  271. var RE_NUM_LITERAL = /[0-9a-f]/i;
  272. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  273. var RE_OCT_NUMBER = /^0[0-7]+$/;
  274. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  275. var RE_BIN_NUMBER = /^0b[01]+$/i;
  276. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  277. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  278. var OPERATORS = makePredicate([
  279. "in",
  280. "instanceof",
  281. "typeof",
  282. "new",
  283. "void",
  284. "delete",
  285. "++",
  286. "--",
  287. "+",
  288. "-",
  289. "!",
  290. "~",
  291. "&",
  292. "|",
  293. "^",
  294. "*",
  295. "**",
  296. "/",
  297. "%",
  298. ">>",
  299. "<<",
  300. ">>>",
  301. "<",
  302. ">",
  303. "<=",
  304. ">=",
  305. "==",
  306. "===",
  307. "!=",
  308. "!==",
  309. "?",
  310. "=",
  311. "+=",
  312. "-=",
  313. "||=",
  314. "&&=",
  315. "??=",
  316. "/=",
  317. "*=",
  318. "**=",
  319. "%=",
  320. ">>=",
  321. "<<=",
  322. ">>>=",
  323. "|=",
  324. "^=",
  325. "&=",
  326. "&&",
  327. "??",
  328. "||",
  329. ]);
  330. var WHITESPACE_CHARS = makePredicate(characters(" \u00a0\n\r\t\f\u000b\u200b\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\uFEFF"));
  331. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  332. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  333. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  334. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  335. /* -----[ Tokenizer ]----- */
  336. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  337. var UNICODE = {
  338. ID_Start: /[$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
  339. ID_Continue: /(?:[$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF])+/,
  340. };
  341. function get_full_char(str, pos) {
  342. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  343. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  344. return str.charAt(pos) + str.charAt(pos + 1);
  345. }
  346. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  347. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  348. return str.charAt(pos - 1) + str.charAt(pos);
  349. }
  350. }
  351. return str.charAt(pos);
  352. }
  353. function get_full_char_code(str, pos) {
  354. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  355. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  356. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  357. }
  358. return str.charCodeAt(pos);
  359. }
  360. function get_full_char_length(str) {
  361. var surrogates = 0;
  362. for (var i = 0; i < str.length; i++) {
  363. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  364. surrogates++;
  365. i++;
  366. }
  367. }
  368. return str.length - surrogates;
  369. }
  370. function from_char_code(code) {
  371. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  372. if (code > 0xFFFF) {
  373. code -= 0x10000;
  374. return (String.fromCharCode((code >> 10) + 0xD800) +
  375. String.fromCharCode((code % 0x400) + 0xDC00));
  376. }
  377. return String.fromCharCode(code);
  378. }
  379. function is_surrogate_pair_head(code) {
  380. return code >= 0xd800 && code <= 0xdbff;
  381. }
  382. function is_surrogate_pair_tail(code) {
  383. return code >= 0xdc00 && code <= 0xdfff;
  384. }
  385. function is_digit(code) {
  386. return code >= 48 && code <= 57;
  387. }
  388. function is_identifier_start(ch) {
  389. return UNICODE.ID_Start.test(ch);
  390. }
  391. function is_identifier_char(ch) {
  392. return UNICODE.ID_Continue.test(ch);
  393. }
  394. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  395. function is_basic_identifier_string(str) {
  396. return BASIC_IDENT.test(str);
  397. }
  398. function is_identifier_string(str, allow_surrogates) {
  399. if (BASIC_IDENT.test(str)) {
  400. return true;
  401. }
  402. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  403. return false;
  404. }
  405. var match = UNICODE.ID_Start.exec(str);
  406. if (!match || match.index !== 0) {
  407. return false;
  408. }
  409. str = str.slice(match[0].length);
  410. if (!str) {
  411. return true;
  412. }
  413. match = UNICODE.ID_Continue.exec(str);
  414. return !!match && match[0].length === str.length;
  415. }
  416. function parse_js_number(num, allow_e = true) {
  417. if (!allow_e && num.includes("e")) {
  418. return NaN;
  419. }
  420. if (RE_HEX_NUMBER.test(num)) {
  421. return parseInt(num.substr(2), 16);
  422. } else if (RE_OCT_NUMBER.test(num)) {
  423. return parseInt(num.substr(1), 8);
  424. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  425. return parseInt(num.substr(2), 8);
  426. } else if (RE_BIN_NUMBER.test(num)) {
  427. return parseInt(num.substr(2), 2);
  428. } else if (RE_DEC_NUMBER.test(num)) {
  429. return parseFloat(num);
  430. } else {
  431. var val = parseFloat(num);
  432. if (val == num) return val;
  433. }
  434. }
  435. class JS_Parse_Error extends Error {
  436. constructor(message, filename, line, col, pos) {
  437. super();
  438. this.name = "SyntaxError";
  439. this.message = message;
  440. this.filename = filename;
  441. this.line = line;
  442. this.col = col;
  443. this.pos = pos;
  444. }
  445. }
  446. function js_error(message, filename, line, col, pos) {
  447. throw new JS_Parse_Error(message, filename, line, col, pos);
  448. }
  449. function is_token(token, type, val) {
  450. return token.type == type && (val == null || token.value == val);
  451. }
  452. var EX_EOF = {};
  453. function tokenizer($TEXT, filename, html5_comments, shebang) {
  454. var S = {
  455. text : $TEXT,
  456. filename : filename,
  457. pos : 0,
  458. tokpos : 0,
  459. line : 1,
  460. tokline : 0,
  461. col : 0,
  462. tokcol : 0,
  463. newline_before : false,
  464. regex_allowed : false,
  465. brace_counter : 0,
  466. template_braces : [],
  467. comments_before : [],
  468. directives : {},
  469. directive_stack : []
  470. };
  471. function peek() { return get_full_char(S.text, S.pos); }
  472. // Used because parsing ?. involves a lookahead for a digit
  473. function is_option_chain_op() {
  474. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  475. if (!must_be_dot) return false;
  476. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  477. return cannot_be_digit < 48 || cannot_be_digit > 57;
  478. }
  479. function next(signal_eof, in_string) {
  480. var ch = get_full_char(S.text, S.pos++);
  481. if (signal_eof && !ch)
  482. throw EX_EOF;
  483. if (NEWLINE_CHARS.has(ch)) {
  484. S.newline_before = S.newline_before || !in_string;
  485. ++S.line;
  486. S.col = 0;
  487. if (ch == "\r" && peek() == "\n") {
  488. // treat a \r\n sequence as a single \n
  489. ++S.pos;
  490. ch = "\n";
  491. }
  492. } else {
  493. if (ch.length > 1) {
  494. ++S.pos;
  495. ++S.col;
  496. }
  497. ++S.col;
  498. }
  499. return ch;
  500. }
  501. function forward(i) {
  502. while (i--) next();
  503. }
  504. function looking_at(str) {
  505. return S.text.substr(S.pos, str.length) == str;
  506. }
  507. function find_eol() {
  508. var text = S.text;
  509. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  510. var ch = text[i];
  511. if (NEWLINE_CHARS.has(ch))
  512. return i;
  513. }
  514. return -1;
  515. }
  516. function find(what, signal_eof) {
  517. var pos = S.text.indexOf(what, S.pos);
  518. if (signal_eof && pos == -1) throw EX_EOF;
  519. return pos;
  520. }
  521. function start_token() {
  522. S.tokline = S.line;
  523. S.tokcol = S.col;
  524. S.tokpos = S.pos;
  525. }
  526. var prev_was_dot = false;
  527. var previous_token = null;
  528. function token(type, value, is_comment) {
  529. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  530. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  531. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  532. (type == "arrow");
  533. if (type == "punc" && (value == "." || value == "?.")) {
  534. prev_was_dot = true;
  535. } else if (!is_comment) {
  536. prev_was_dot = false;
  537. }
  538. const line = S.tokline;
  539. const col = S.tokcol;
  540. const pos = S.tokpos;
  541. const nlb = S.newline_before;
  542. const file = filename;
  543. let comments_before = [];
  544. let comments_after = [];
  545. if (!is_comment) {
  546. comments_before = S.comments_before;
  547. comments_after = S.comments_before = [];
  548. }
  549. S.newline_before = false;
  550. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  551. if (!is_comment) previous_token = tok;
  552. return tok;
  553. }
  554. function skip_whitespace() {
  555. while (WHITESPACE_CHARS.has(peek()))
  556. next();
  557. }
  558. function read_while(pred) {
  559. var ret = "", ch, i = 0;
  560. while ((ch = peek()) && pred(ch, i++))
  561. ret += next();
  562. return ret;
  563. }
  564. function parse_error(err) {
  565. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  566. }
  567. function read_num(prefix) {
  568. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  569. var num = read_while(function(ch, i) {
  570. if (is_big_int) return false;
  571. var code = ch.charCodeAt(0);
  572. switch (code) {
  573. case 95: // _
  574. return (numeric_separator = true);
  575. case 98: case 66: // bB
  576. return (has_x = true); // Can occur in hex sequence, don't return false yet
  577. case 111: case 79: // oO
  578. case 120: case 88: // xX
  579. return has_x ? false : (has_x = true);
  580. case 101: case 69: // eE
  581. return has_x ? true : has_e ? false : (has_e = after_e = true);
  582. case 45: // -
  583. return after_e || (i == 0 && !prefix);
  584. case 43: // +
  585. return after_e;
  586. case (after_e = false, 46): // .
  587. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  588. }
  589. if (ch === "n") {
  590. is_big_int = true;
  591. return true;
  592. }
  593. return RE_NUM_LITERAL.test(ch);
  594. });
  595. if (prefix) num = prefix + num;
  596. LATEST_RAW = num;
  597. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  598. parse_error("Legacy octal literals are not allowed in strict mode");
  599. }
  600. if (numeric_separator) {
  601. if (num.endsWith("_")) {
  602. parse_error("Numeric separators are not allowed at the end of numeric literals");
  603. } else if (num.includes("__")) {
  604. parse_error("Only one underscore is allowed as numeric separator");
  605. }
  606. num = num.replace(/_/g, "");
  607. }
  608. if (num.endsWith("n")) {
  609. const without_n = num.slice(0, -1);
  610. const allow_e = RE_HEX_NUMBER.test(without_n);
  611. const valid = parse_js_number(without_n, allow_e);
  612. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  613. return token("big_int", without_n);
  614. parse_error("Invalid or unexpected token");
  615. }
  616. var valid = parse_js_number(num);
  617. if (!isNaN(valid)) {
  618. return token("num", valid);
  619. } else {
  620. parse_error("Invalid syntax: " + num);
  621. }
  622. }
  623. function is_octal(ch) {
  624. return ch >= "0" && ch <= "7";
  625. }
  626. function read_escaped_char(in_string, strict_hex, template_string) {
  627. var ch = next(true, in_string);
  628. switch (ch.charCodeAt(0)) {
  629. case 110 : return "\n";
  630. case 114 : return "\r";
  631. case 116 : return "\t";
  632. case 98 : return "\b";
  633. case 118 : return "\u000b"; // \v
  634. case 102 : return "\f";
  635. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  636. case 117 : // \u
  637. if (peek() == "{") {
  638. next(true);
  639. if (peek() === "}")
  640. parse_error("Expecting hex-character between {}");
  641. while (peek() == "0") next(true); // No significance
  642. var result, length = find("}", true) - S.pos;
  643. // Avoid 32 bit integer overflow (1 << 32 === 1)
  644. // We know first character isn't 0 and thus out of range anyway
  645. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  646. parse_error("Unicode reference out of bounds");
  647. }
  648. next(true);
  649. return from_char_code(result);
  650. }
  651. return String.fromCharCode(hex_bytes(4, strict_hex));
  652. case 10 : return ""; // newline
  653. case 13 : // \r
  654. if (peek() == "\n") { // DOS newline
  655. next(true, in_string);
  656. return "";
  657. }
  658. }
  659. if (is_octal(ch)) {
  660. if (template_string && strict_hex) {
  661. const represents_null_character = ch === "0" && !is_octal(peek());
  662. if (!represents_null_character) {
  663. parse_error("Octal escape sequences are not allowed in template strings");
  664. }
  665. }
  666. return read_octal_escape_sequence(ch, strict_hex);
  667. }
  668. return ch;
  669. }
  670. function read_octal_escape_sequence(ch, strict_octal) {
  671. // Read
  672. var p = peek();
  673. if (p >= "0" && p <= "7") {
  674. ch += next(true);
  675. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  676. ch += next(true);
  677. }
  678. // Parse
  679. if (ch === "0") return "\0";
  680. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  681. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  682. return String.fromCharCode(parseInt(ch, 8));
  683. }
  684. function hex_bytes(n, strict_hex) {
  685. var num = 0;
  686. for (; n > 0; --n) {
  687. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  688. return parseInt(num, 16) || "";
  689. }
  690. var digit = next(true);
  691. if (isNaN(parseInt(digit, 16)))
  692. parse_error("Invalid hex-character pattern in string");
  693. num += digit;
  694. }
  695. return parseInt(num, 16);
  696. }
  697. var read_string = with_eof_error("Unterminated string constant", function() {
  698. const start_pos = S.pos;
  699. var quote = next(), ret = [];
  700. for (;;) {
  701. var ch = next(true, true);
  702. if (ch == "\\") ch = read_escaped_char(true, true);
  703. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  704. else if (ch == quote) break;
  705. ret.push(ch);
  706. }
  707. var tok = token("string", ret.join(""));
  708. LATEST_RAW = S.text.slice(start_pos, S.pos);
  709. tok.quote = quote;
  710. return tok;
  711. });
  712. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  713. if (begin) {
  714. S.template_braces.push(S.brace_counter);
  715. }
  716. var content = "", raw = "", ch, tok;
  717. next(true, true);
  718. while ((ch = next(true, true)) != "`") {
  719. if (ch == "\r") {
  720. if (peek() == "\n") ++S.pos;
  721. ch = "\n";
  722. } else if (ch == "$" && peek() == "{") {
  723. next(true, true);
  724. S.brace_counter++;
  725. tok = token(begin ? "template_head" : "template_substitution", content);
  726. TEMPLATE_RAWS.set(tok, raw);
  727. tok.template_end = false;
  728. return tok;
  729. }
  730. raw += ch;
  731. if (ch == "\\") {
  732. var tmp = S.pos;
  733. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  734. ch = read_escaped_char(true, !prev_is_tag, true);
  735. raw += S.text.substr(tmp, S.pos - tmp);
  736. }
  737. content += ch;
  738. }
  739. S.template_braces.pop();
  740. tok = token(begin ? "template_head" : "template_substitution", content);
  741. TEMPLATE_RAWS.set(tok, raw);
  742. tok.template_end = true;
  743. return tok;
  744. });
  745. function skip_line_comment(type) {
  746. var regex_allowed = S.regex_allowed;
  747. var i = find_eol(), ret;
  748. if (i == -1) {
  749. ret = S.text.substr(S.pos);
  750. S.pos = S.text.length;
  751. } else {
  752. ret = S.text.substring(S.pos, i);
  753. S.pos = i;
  754. }
  755. S.col = S.tokcol + (S.pos - S.tokpos);
  756. S.comments_before.push(token(type, ret, true));
  757. S.regex_allowed = regex_allowed;
  758. return next_token;
  759. }
  760. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  761. var regex_allowed = S.regex_allowed;
  762. var i = find("*/", true);
  763. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  764. // update stream position
  765. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  766. S.comments_before.push(token("comment2", text, true));
  767. S.newline_before = S.newline_before || text.includes("\n");
  768. S.regex_allowed = regex_allowed;
  769. return next_token;
  770. });
  771. var read_name = with_eof_error("Unterminated identifier name", function() {
  772. var name = [], ch, escaped = false;
  773. var read_escaped_identifier_char = function() {
  774. escaped = true;
  775. next();
  776. if (peek() !== "u") {
  777. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  778. }
  779. return read_escaped_char(false, true);
  780. };
  781. // Read first character (ID_Start)
  782. if ((ch = peek()) === "\\") {
  783. ch = read_escaped_identifier_char();
  784. if (!is_identifier_start(ch)) {
  785. parse_error("First identifier char is an invalid identifier char");
  786. }
  787. } else if (is_identifier_start(ch)) {
  788. next();
  789. } else {
  790. return "";
  791. }
  792. name.push(ch);
  793. // Read ID_Continue
  794. while ((ch = peek()) != null) {
  795. if ((ch = peek()) === "\\") {
  796. ch = read_escaped_identifier_char();
  797. if (!is_identifier_char(ch)) {
  798. parse_error("Invalid escaped identifier char");
  799. }
  800. } else {
  801. if (!is_identifier_char(ch)) {
  802. break;
  803. }
  804. next();
  805. }
  806. name.push(ch);
  807. }
  808. const name_str = name.join("");
  809. if (RESERVED_WORDS.has(name_str) && escaped) {
  810. parse_error("Escaped characters are not allowed in keywords");
  811. }
  812. return name_str;
  813. });
  814. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  815. var prev_backslash = false, ch, in_class = false;
  816. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  817. parse_error("Unexpected line terminator");
  818. } else if (prev_backslash) {
  819. if (/^[\u0000-\u007F]$/.test(ch)) {
  820. source += "\\" + ch;
  821. } else {
  822. // Remove the useless slash before the escape, but only for characters that won't be added to regexp syntax
  823. source += ch;
  824. }
  825. prev_backslash = false;
  826. } else if (ch == "[") {
  827. in_class = true;
  828. source += ch;
  829. } else if (ch == "]" && in_class) {
  830. in_class = false;
  831. source += ch;
  832. } else if (ch == "/" && !in_class) {
  833. break;
  834. } else if (ch == "\\") {
  835. prev_backslash = true;
  836. } else {
  837. source += ch;
  838. }
  839. const flags = read_name();
  840. return token("regexp", "/" + source + "/" + flags);
  841. });
  842. function read_operator(prefix) {
  843. function grow(op) {
  844. if (!peek()) return op;
  845. var bigger = op + peek();
  846. if (OPERATORS.has(bigger)) {
  847. next();
  848. return grow(bigger);
  849. } else {
  850. return op;
  851. }
  852. }
  853. return token("operator", grow(prefix || next()));
  854. }
  855. function handle_slash() {
  856. next();
  857. switch (peek()) {
  858. case "/":
  859. next();
  860. return skip_line_comment("comment1");
  861. case "*":
  862. next();
  863. return skip_multiline_comment();
  864. }
  865. return S.regex_allowed ? read_regexp("") : read_operator("/");
  866. }
  867. function handle_eq_sign() {
  868. next();
  869. if (peek() === ">") {
  870. next();
  871. return token("arrow", "=>");
  872. } else {
  873. return read_operator("=");
  874. }
  875. }
  876. function handle_dot() {
  877. next();
  878. if (is_digit(peek().charCodeAt(0))) {
  879. return read_num(".");
  880. }
  881. if (peek() === ".") {
  882. next(); // Consume second dot
  883. next(); // Consume third dot
  884. return token("expand", "...");
  885. }
  886. return token("punc", ".");
  887. }
  888. function read_word() {
  889. var word = read_name();
  890. if (prev_was_dot) return token("name", word);
  891. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  892. : !KEYWORDS.has(word) ? token("name", word)
  893. : OPERATORS.has(word) ? token("operator", word)
  894. : token("keyword", word);
  895. }
  896. function read_private_word() {
  897. next();
  898. return token("privatename", read_name());
  899. }
  900. function with_eof_error(eof_error, cont) {
  901. return function(x) {
  902. try {
  903. return cont(x);
  904. } catch(ex) {
  905. if (ex === EX_EOF) parse_error(eof_error);
  906. else throw ex;
  907. }
  908. };
  909. }
  910. function next_token(force_regexp) {
  911. if (force_regexp != null)
  912. return read_regexp(force_regexp);
  913. if (shebang && S.pos == 0 && looking_at("#!")) {
  914. start_token();
  915. forward(2);
  916. skip_line_comment("comment5");
  917. }
  918. for (;;) {
  919. skip_whitespace();
  920. start_token();
  921. if (html5_comments) {
  922. if (looking_at("<!--")) {
  923. forward(4);
  924. skip_line_comment("comment3");
  925. continue;
  926. }
  927. if (looking_at("-->") && S.newline_before) {
  928. forward(3);
  929. skip_line_comment("comment4");
  930. continue;
  931. }
  932. }
  933. var ch = peek();
  934. if (!ch) return token("eof");
  935. var code = ch.charCodeAt(0);
  936. switch (code) {
  937. case 34: case 39: return read_string();
  938. case 46: return handle_dot();
  939. case 47: {
  940. var tok = handle_slash();
  941. if (tok === next_token) continue;
  942. return tok;
  943. }
  944. case 61: return handle_eq_sign();
  945. case 63: {
  946. if (!is_option_chain_op()) break; // Handled below
  947. next(); // ?
  948. next(); // .
  949. return token("punc", "?.");
  950. }
  951. case 96: return read_template_characters(true);
  952. case 123:
  953. S.brace_counter++;
  954. break;
  955. case 125:
  956. S.brace_counter--;
  957. if (S.template_braces.length > 0
  958. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  959. return read_template_characters(false);
  960. break;
  961. }
  962. if (is_digit(code)) return read_num();
  963. if (PUNC_CHARS.has(ch)) return token("punc", next());
  964. if (OPERATOR_CHARS.has(ch)) return read_operator();
  965. if (code == 92 || is_identifier_start(ch)) return read_word();
  966. if (code == 35) return read_private_word();
  967. break;
  968. }
  969. parse_error("Unexpected character '" + ch + "'");
  970. }
  971. next_token.next = next;
  972. next_token.peek = peek;
  973. next_token.context = function(nc) {
  974. if (nc) S = nc;
  975. return S;
  976. };
  977. next_token.add_directive = function(directive) {
  978. S.directive_stack[S.directive_stack.length - 1].push(directive);
  979. if (S.directives[directive] === undefined) {
  980. S.directives[directive] = 1;
  981. } else {
  982. S.directives[directive]++;
  983. }
  984. };
  985. next_token.push_directives_stack = function() {
  986. S.directive_stack.push([]);
  987. };
  988. next_token.pop_directives_stack = function() {
  989. var directives = S.directive_stack[S.directive_stack.length - 1];
  990. for (var i = 0; i < directives.length; i++) {
  991. S.directives[directives[i]]--;
  992. }
  993. S.directive_stack.pop();
  994. };
  995. next_token.has_directive = function(directive) {
  996. return S.directives[directive] > 0;
  997. };
  998. return next_token;
  999. }
  1000. /* -----[ Parser (constants) ]----- */
  1001. var UNARY_PREFIX = makePredicate([
  1002. "typeof",
  1003. "void",
  1004. "delete",
  1005. "--",
  1006. "++",
  1007. "!",
  1008. "~",
  1009. "-",
  1010. "+"
  1011. ]);
  1012. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  1013. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  1014. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  1015. var PRECEDENCE = (function(a, ret) {
  1016. for (var i = 0; i < a.length; ++i) {
  1017. for (const op of a[i]) {
  1018. ret[op] = i + 1;
  1019. }
  1020. }
  1021. return ret;
  1022. })(
  1023. [
  1024. ["||"],
  1025. ["??"],
  1026. ["&&"],
  1027. ["|"],
  1028. ["^"],
  1029. ["&"],
  1030. ["==", "===", "!=", "!=="],
  1031. ["<", ">", "<=", ">=", "in", "instanceof"],
  1032. [">>", "<<", ">>>"],
  1033. ["+", "-"],
  1034. ["*", "/", "%"],
  1035. ["**"]
  1036. ],
  1037. {}
  1038. );
  1039. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name"]);
  1040. /* -----[ Parser ]----- */
  1041. function parse($TEXT, options) {
  1042. // maps start tokens to count of comments found outside of their parens
  1043. // Example: /* I count */ ( /* I don't */ foo() )
  1044. // Useful because comments_before property of call with parens outside
  1045. // contains both comments inside and outside these parens. Used to find the
  1046. const outer_comments_before_counts = new WeakMap();
  1047. options = defaults(options, {
  1048. bare_returns : false,
  1049. ecma : null, // Legacy
  1050. expression : false,
  1051. filename : null,
  1052. html5_comments : true,
  1053. module : false,
  1054. shebang : true,
  1055. strict : false,
  1056. toplevel : null,
  1057. }, true);
  1058. var S = {
  1059. input : (typeof $TEXT == "string"
  1060. ? tokenizer($TEXT, options.filename,
  1061. options.html5_comments, options.shebang)
  1062. : $TEXT),
  1063. token : null,
  1064. prev : null,
  1065. peeked : null,
  1066. in_function : 0,
  1067. in_async : -1,
  1068. in_generator : -1,
  1069. in_directives : true,
  1070. in_loop : 0,
  1071. labels : []
  1072. };
  1073. S.token = next();
  1074. function is(type, value) {
  1075. return is_token(S.token, type, value);
  1076. }
  1077. function peek() { return S.peeked || (S.peeked = S.input()); }
  1078. function next() {
  1079. S.prev = S.token;
  1080. if (!S.peeked) peek();
  1081. S.token = S.peeked;
  1082. S.peeked = null;
  1083. S.in_directives = S.in_directives && (
  1084. S.token.type == "string" || is("punc", ";")
  1085. );
  1086. return S.token;
  1087. }
  1088. function prev() {
  1089. return S.prev;
  1090. }
  1091. function croak(msg, line, col, pos) {
  1092. var ctx = S.input.context();
  1093. js_error(msg,
  1094. ctx.filename,
  1095. line != null ? line : ctx.tokline,
  1096. col != null ? col : ctx.tokcol,
  1097. pos != null ? pos : ctx.tokpos);
  1098. }
  1099. function token_error(token, msg) {
  1100. croak(msg, token.line, token.col);
  1101. }
  1102. function unexpected(token) {
  1103. if (token == null)
  1104. token = S.token;
  1105. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  1106. }
  1107. function expect_token(type, val) {
  1108. if (is(type, val)) {
  1109. return next();
  1110. }
  1111. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  1112. }
  1113. function expect(punc) { return expect_token("punc", punc); }
  1114. function has_newline_before(token) {
  1115. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  1116. }
  1117. function can_insert_semicolon() {
  1118. return !options.strict
  1119. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  1120. }
  1121. function is_in_generator() {
  1122. return S.in_generator === S.in_function;
  1123. }
  1124. function is_in_async() {
  1125. return S.in_async === S.in_function;
  1126. }
  1127. function can_await() {
  1128. return (
  1129. S.in_async === S.in_function
  1130. || S.in_function === 0 && S.input.has_directive("use strict")
  1131. );
  1132. }
  1133. function semicolon(optional) {
  1134. if (is("punc", ";")) next();
  1135. else if (!optional && !can_insert_semicolon()) unexpected();
  1136. }
  1137. function parenthesised() {
  1138. expect("(");
  1139. var exp = expression(true);
  1140. expect(")");
  1141. return exp;
  1142. }
  1143. function embed_tokens(parser) {
  1144. return function _embed_tokens_wrapper(...args) {
  1145. const start = S.token;
  1146. const expr = parser(...args);
  1147. expr.start = start;
  1148. expr.end = prev();
  1149. return expr;
  1150. };
  1151. }
  1152. function handle_regexp() {
  1153. if (is("operator", "/") || is("operator", "/=")) {
  1154. S.peeked = null;
  1155. S.token = S.input(S.token.value.substr(1)); // force regexp
  1156. }
  1157. }
  1158. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  1159. handle_regexp();
  1160. switch (S.token.type) {
  1161. case "string":
  1162. if (S.in_directives) {
  1163. var token = peek();
  1164. if (!LATEST_RAW.includes("\\")
  1165. && (is_token(token, "punc", ";")
  1166. || is_token(token, "punc", "}")
  1167. || has_newline_before(token)
  1168. || is_token(token, "eof"))) {
  1169. S.input.add_directive(S.token.value);
  1170. } else {
  1171. S.in_directives = false;
  1172. }
  1173. }
  1174. var dir = S.in_directives, stat = simple_statement();
  1175. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  1176. case "template_head":
  1177. case "num":
  1178. case "big_int":
  1179. case "regexp":
  1180. case "operator":
  1181. case "atom":
  1182. return simple_statement();
  1183. case "name":
  1184. case "privatename":
  1185. if(is("privatename") && !S.in_class)
  1186. croak("Private field must be used in an enclosing class");
  1187. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  1188. next();
  1189. next();
  1190. if (is_for_body) {
  1191. croak("functions are not allowed as the body of a loop");
  1192. }
  1193. return function_(AST_Defun, false, true, is_export_default);
  1194. }
  1195. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  1196. next();
  1197. var node = import_statement();
  1198. semicolon();
  1199. return node;
  1200. }
  1201. return is_token(peek(), "punc", ":")
  1202. ? labeled_statement()
  1203. : simple_statement();
  1204. case "punc":
  1205. switch (S.token.value) {
  1206. case "{":
  1207. return new AST_BlockStatement({
  1208. start : S.token,
  1209. body : block_(),
  1210. end : prev()
  1211. });
  1212. case "[":
  1213. case "(":
  1214. return simple_statement();
  1215. case ";":
  1216. S.in_directives = false;
  1217. next();
  1218. return new AST_EmptyStatement();
  1219. default:
  1220. unexpected();
  1221. }
  1222. case "keyword":
  1223. switch (S.token.value) {
  1224. case "break":
  1225. next();
  1226. return break_cont(AST_Break);
  1227. case "continue":
  1228. next();
  1229. return break_cont(AST_Continue);
  1230. case "debugger":
  1231. next();
  1232. semicolon();
  1233. return new AST_Debugger();
  1234. case "do":
  1235. next();
  1236. var body = in_loop(statement);
  1237. expect_token("keyword", "while");
  1238. var condition = parenthesised();
  1239. semicolon(true);
  1240. return new AST_Do({
  1241. body : body,
  1242. condition : condition
  1243. });
  1244. case "while":
  1245. next();
  1246. return new AST_While({
  1247. condition : parenthesised(),
  1248. body : in_loop(function() { return statement(false, true); })
  1249. });
  1250. case "for":
  1251. next();
  1252. return for_();
  1253. case "class":
  1254. next();
  1255. if (is_for_body) {
  1256. croak("classes are not allowed as the body of a loop");
  1257. }
  1258. if (is_if_body) {
  1259. croak("classes are not allowed as the body of an if");
  1260. }
  1261. return class_(AST_DefClass, is_export_default);
  1262. case "function":
  1263. next();
  1264. if (is_for_body) {
  1265. croak("functions are not allowed as the body of a loop");
  1266. }
  1267. return function_(AST_Defun, false, false, is_export_default);
  1268. case "if":
  1269. next();
  1270. return if_();
  1271. case "return":
  1272. if (S.in_function == 0 && !options.bare_returns)
  1273. croak("'return' outside of function");
  1274. next();
  1275. var value = null;
  1276. if (is("punc", ";")) {
  1277. next();
  1278. } else if (!can_insert_semicolon()) {
  1279. value = expression(true);
  1280. semicolon();
  1281. }
  1282. return new AST_Return({
  1283. value: value
  1284. });
  1285. case "switch":
  1286. next();
  1287. return new AST_Switch({
  1288. expression : parenthesised(),
  1289. body : in_loop(switch_body_)
  1290. });
  1291. case "throw":
  1292. next();
  1293. if (has_newline_before(S.token))
  1294. croak("Illegal newline after 'throw'");
  1295. var value = expression(true);
  1296. semicolon();
  1297. return new AST_Throw({
  1298. value: value
  1299. });
  1300. case "try":
  1301. next();
  1302. return try_();
  1303. case "var":
  1304. next();
  1305. var node = var_();
  1306. semicolon();
  1307. return node;
  1308. case "let":
  1309. next();
  1310. var node = let_();
  1311. semicolon();
  1312. return node;
  1313. case "const":
  1314. next();
  1315. var node = const_();
  1316. semicolon();
  1317. return node;
  1318. case "with":
  1319. if (S.input.has_directive("use strict")) {
  1320. croak("Strict mode may not include a with statement");
  1321. }
  1322. next();
  1323. return new AST_With({
  1324. expression : parenthesised(),
  1325. body : statement()
  1326. });
  1327. case "export":
  1328. if (!is_token(peek(), "punc", "(")) {
  1329. next();
  1330. var node = export_statement();
  1331. if (is("punc", ";")) semicolon();
  1332. return node;
  1333. }
  1334. }
  1335. }
  1336. unexpected();
  1337. });
  1338. function labeled_statement() {
  1339. var label = as_symbol(AST_Label);
  1340. if (label.name === "await" && is_in_async()) {
  1341. token_error(S.prev, "await cannot be used as label inside async function");
  1342. }
  1343. if (S.labels.some((l) => l.name === label.name)) {
  1344. // ECMA-262, 12.12: An ECMAScript program is considered
  1345. // syntactically incorrect if it contains a
  1346. // LabelledStatement that is enclosed by a
  1347. // LabelledStatement with the same Identifier as label.
  1348. croak("Label " + label.name + " defined twice");
  1349. }
  1350. expect(":");
  1351. S.labels.push(label);
  1352. var stat = statement();
  1353. S.labels.pop();
  1354. if (!(stat instanceof AST_IterationStatement)) {
  1355. // check for `continue` that refers to this label.
  1356. // those should be reported as syntax errors.
  1357. // https://github.com/mishoo/UglifyJS2/issues/287
  1358. label.references.forEach(function(ref) {
  1359. if (ref instanceof AST_Continue) {
  1360. ref = ref.label.start;
  1361. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  1362. ref.line, ref.col, ref.pos);
  1363. }
  1364. });
  1365. }
  1366. return new AST_LabeledStatement({ body: stat, label: label });
  1367. }
  1368. function simple_statement(tmp) {
  1369. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  1370. }
  1371. function break_cont(type) {
  1372. var label = null, ldef;
  1373. if (!can_insert_semicolon()) {
  1374. label = as_symbol(AST_LabelRef, true);
  1375. }
  1376. if (label != null) {
  1377. ldef = S.labels.find((l) => l.name === label.name);
  1378. if (!ldef)
  1379. croak("Undefined label " + label.name);
  1380. label.thedef = ldef;
  1381. } else if (S.in_loop == 0)
  1382. croak(type.TYPE + " not inside a loop or switch");
  1383. semicolon();
  1384. var stat = new type({ label: label });
  1385. if (ldef) ldef.references.push(stat);
  1386. return stat;
  1387. }
  1388. function for_() {
  1389. var for_await_error = "`for await` invalid in this context";
  1390. var await_tok = S.token;
  1391. if (await_tok.type == "name" && await_tok.value == "await") {
  1392. if (!can_await()) {
  1393. token_error(await_tok, for_await_error);
  1394. }
  1395. next();
  1396. } else {
  1397. await_tok = false;
  1398. }
  1399. expect("(");
  1400. var init = null;
  1401. if (!is("punc", ";")) {
  1402. init =
  1403. is("keyword", "var") ? (next(), var_(true)) :
  1404. is("keyword", "let") ? (next(), let_(true)) :
  1405. is("keyword", "const") ? (next(), const_(true)) :
  1406. expression(true, true);
  1407. var is_in = is("operator", "in");
  1408. var is_of = is("name", "of");
  1409. if (await_tok && !is_of) {
  1410. token_error(await_tok, for_await_error);
  1411. }
  1412. if (is_in || is_of) {
  1413. if (init instanceof AST_Definitions) {
  1414. if (init.definitions.length > 1)
  1415. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  1416. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  1417. token_error(init.start, "Invalid left-hand side in for..in loop");
  1418. }
  1419. next();
  1420. if (is_in) {
  1421. return for_in(init);
  1422. } else {
  1423. return for_of(init, !!await_tok);
  1424. }
  1425. }
  1426. } else if (await_tok) {
  1427. token_error(await_tok, for_await_error);
  1428. }
  1429. return regular_for(init);
  1430. }
  1431. function regular_for(init) {
  1432. expect(";");
  1433. var test = is("punc", ";") ? null : expression(true);
  1434. expect(";");
  1435. var step = is("punc", ")") ? null : expression(true);
  1436. expect(")");
  1437. return new AST_For({
  1438. init : init,
  1439. condition : test,
  1440. step : step,
  1441. body : in_loop(function() { return statement(false, true); })
  1442. });
  1443. }
  1444. function for_of(init, is_await) {
  1445. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  1446. var obj = expression(true);
  1447. expect(")");
  1448. return new AST_ForOf({
  1449. await : is_await,
  1450. init : init,
  1451. name : lhs,
  1452. object : obj,
  1453. body : in_loop(function() { return statement(false, true); })
  1454. });
  1455. }
  1456. function for_in(init) {
  1457. var obj = expression(true);
  1458. expect(")");
  1459. return new AST_ForIn({
  1460. init : init,
  1461. object : obj,
  1462. body : in_loop(function() { return statement(false, true); })
  1463. });
  1464. }
  1465. var arrow_function = function(start, argnames, is_async) {
  1466. if (has_newline_before(S.token)) {
  1467. croak("Unexpected newline before arrow (=>)");
  1468. }
  1469. expect_token("arrow", "=>");
  1470. var body = _function_body(is("punc", "{"), false, is_async);
  1471. var end =
  1472. body instanceof Array && body.length ? body[body.length - 1].end :
  1473. body instanceof Array ? start :
  1474. body.end;
  1475. return new AST_Arrow({
  1476. start : start,
  1477. end : end,
  1478. async : is_async,
  1479. argnames : argnames,
  1480. body : body
  1481. });
  1482. };
  1483. var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
  1484. var in_statement = ctor === AST_Defun;
  1485. var is_generator = is("operator", "*");
  1486. if (is_generator) {
  1487. next();
  1488. }
  1489. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  1490. if (in_statement && !name) {
  1491. if (is_export_default) {
  1492. ctor = AST_Function;
  1493. } else {
  1494. unexpected();
  1495. }
  1496. }
  1497. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  1498. unexpected(prev());
  1499. var args = [];
  1500. var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
  1501. return new ctor({
  1502. start : args.start,
  1503. end : body.end,
  1504. is_generator: is_generator,
  1505. async : is_async,
  1506. name : name,
  1507. argnames: args,
  1508. body : body
  1509. });
  1510. };
  1511. class UsedParametersTracker {
  1512. constructor(is_parameter, strict, duplicates_ok = false) {
  1513. this.is_parameter = is_parameter;
  1514. this.duplicates_ok = duplicates_ok;
  1515. this.parameters = new Set();
  1516. this.duplicate = null;
  1517. this.default_assignment = false;
  1518. this.spread = false;
  1519. this.strict_mode = !!strict;
  1520. }
  1521. add_parameter(token) {
  1522. if (this.parameters.has(token.value)) {
  1523. if (this.duplicate === null) {
  1524. this.duplicate = token;
  1525. }
  1526. this.check_strict();
  1527. } else {
  1528. this.parameters.add(token.value);
  1529. if (this.is_parameter) {
  1530. switch (token.value) {
  1531. case "arguments":
  1532. case "eval":
  1533. case "yield":
  1534. if (this.strict_mode) {
  1535. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1536. }
  1537. break;
  1538. default:
  1539. if (RESERVED_WORDS.has(token.value)) {
  1540. unexpected();
  1541. }
  1542. }
  1543. }
  1544. }
  1545. }
  1546. mark_default_assignment(token) {
  1547. if (this.default_assignment === false) {
  1548. this.default_assignment = token;
  1549. }
  1550. }
  1551. mark_spread(token) {
  1552. if (this.spread === false) {
  1553. this.spread = token;
  1554. }
  1555. }
  1556. mark_strict_mode() {
  1557. this.strict_mode = true;
  1558. }
  1559. is_strict() {
  1560. return this.default_assignment !== false || this.spread !== false || this.strict_mode;
  1561. }
  1562. check_strict() {
  1563. if (this.is_strict() && this.duplicate !== null && !this.duplicates_ok) {
  1564. token_error(this.duplicate, "Parameter " + this.duplicate.value + " was used already");
  1565. }
  1566. }
  1567. }
  1568. function parameters(params) {
  1569. var used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1570. expect("(");
  1571. while (!is("punc", ")")) {
  1572. var param = parameter(used_parameters);
  1573. params.push(param);
  1574. if (!is("punc", ")")) {
  1575. expect(",");
  1576. }
  1577. if (param instanceof AST_Expansion) {
  1578. break;
  1579. }
  1580. }
  1581. next();
  1582. }
  1583. function parameter(used_parameters, symbol_type) {
  1584. var param;
  1585. var expand = false;
  1586. if (used_parameters === undefined) {
  1587. used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1588. }
  1589. if (is("expand", "...")) {
  1590. expand = S.token;
  1591. used_parameters.mark_spread(S.token);
  1592. next();
  1593. }
  1594. param = binding_element(used_parameters, symbol_type);
  1595. if (is("operator", "=") && expand === false) {
  1596. used_parameters.mark_default_assignment(S.token);
  1597. next();
  1598. param = new AST_DefaultAssign({
  1599. start: param.start,
  1600. left: param,
  1601. operator: "=",
  1602. right: expression(false),
  1603. end: S.token
  1604. });
  1605. }
  1606. if (expand !== false) {
  1607. if (!is("punc", ")")) {
  1608. unexpected();
  1609. }
  1610. param = new AST_Expansion({
  1611. start: expand,
  1612. expression: param,
  1613. end: expand
  1614. });
  1615. }
  1616. used_parameters.check_strict();
  1617. return param;
  1618. }
  1619. function binding_element(used_parameters, symbol_type) {
  1620. var elements = [];
  1621. var first = true;
  1622. var is_expand = false;
  1623. var expand_token;
  1624. var first_token = S.token;
  1625. if (used_parameters === undefined) {
  1626. const strict = S.input.has_directive("use strict");
  1627. const duplicates_ok = symbol_type === AST_SymbolVar;
  1628. used_parameters = new UsedParametersTracker(false, strict, duplicates_ok);
  1629. }
  1630. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1631. if (is("punc", "[")) {
  1632. next();
  1633. while (!is("punc", "]")) {
  1634. if (first) {
  1635. first = false;
  1636. } else {
  1637. expect(",");
  1638. }
  1639. if (is("expand", "...")) {
  1640. is_expand = true;
  1641. expand_token = S.token;
  1642. used_parameters.mark_spread(S.token);
  1643. next();
  1644. }
  1645. if (is("punc")) {
  1646. switch (S.token.value) {
  1647. case ",":
  1648. elements.push(new AST_Hole({
  1649. start: S.token,
  1650. end: S.token
  1651. }));
  1652. continue;
  1653. case "]": // Trailing comma after last element
  1654. break;
  1655. case "[":
  1656. case "{":
  1657. elements.push(binding_element(used_parameters, symbol_type));
  1658. break;
  1659. default:
  1660. unexpected();
  1661. }
  1662. } else if (is("name")) {
  1663. used_parameters.add_parameter(S.token);
  1664. elements.push(as_symbol(symbol_type));
  1665. } else {
  1666. croak("Invalid function parameter");
  1667. }
  1668. if (is("operator", "=") && is_expand === false) {
  1669. used_parameters.mark_default_assignment(S.token);
  1670. next();
  1671. elements[elements.length - 1] = new AST_DefaultAssign({
  1672. start: elements[elements.length - 1].start,
  1673. left: elements[elements.length - 1],
  1674. operator: "=",
  1675. right: expression(false),
  1676. end: S.token
  1677. });
  1678. }
  1679. if (is_expand) {
  1680. if (!is("punc", "]")) {
  1681. croak("Rest element must be last element");
  1682. }
  1683. elements[elements.length - 1] = new AST_Expansion({
  1684. start: expand_token,
  1685. expression: elements[elements.length - 1],
  1686. end: expand_token
  1687. });
  1688. }
  1689. }
  1690. expect("]");
  1691. used_parameters.check_strict();
  1692. return new AST_Destructuring({
  1693. start: first_token,
  1694. names: elements,
  1695. is_array: true,
  1696. end: prev()
  1697. });
  1698. } else if (is("punc", "{")) {
  1699. next();
  1700. while (!is("punc", "}")) {
  1701. if (first) {
  1702. first = false;
  1703. } else {
  1704. expect(",");
  1705. }
  1706. if (is("expand", "...")) {
  1707. is_expand = true;
  1708. expand_token = S.token;
  1709. used_parameters.mark_spread(S.token);
  1710. next();
  1711. }
  1712. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1713. used_parameters.add_parameter(S.token);
  1714. var start = prev();
  1715. var value = as_symbol(symbol_type);
  1716. if (is_expand) {
  1717. elements.push(new AST_Expansion({
  1718. start: expand_token,
  1719. expression: value,
  1720. end: value.end,
  1721. }));
  1722. } else {
  1723. elements.push(new AST_ObjectKeyVal({
  1724. start: start,
  1725. key: value.name,
  1726. value: value,
  1727. end: value.end,
  1728. }));
  1729. }
  1730. } else if (is("punc", "}")) {
  1731. continue; // Allow trailing hole
  1732. } else {
  1733. var property_token = S.token;
  1734. var property = as_property_name();
  1735. if (property === null) {
  1736. unexpected(prev());
  1737. } else if (prev().type === "name" && !is("punc", ":")) {
  1738. elements.push(new AST_ObjectKeyVal({
  1739. start: prev(),
  1740. key: property,
  1741. value: new symbol_type({
  1742. start: prev(),
  1743. name: property,
  1744. end: prev()
  1745. }),
  1746. end: prev()
  1747. }));
  1748. } else {
  1749. expect(":");
  1750. elements.push(new AST_ObjectKeyVal({
  1751. start: property_token,
  1752. quote: property_token.quote,
  1753. key: property,
  1754. value: binding_element(used_parameters, symbol_type),
  1755. end: prev()
  1756. }));
  1757. }
  1758. }
  1759. if (is_expand) {
  1760. if (!is("punc", "}")) {
  1761. croak("Rest element must be last element");
  1762. }
  1763. } else if (is("operator", "=")) {
  1764. used_parameters.mark_default_assignment(S.token);
  1765. next();
  1766. elements[elements.length - 1].value = new AST_DefaultAssign({
  1767. start: elements[elements.length - 1].value.start,
  1768. left: elements[elements.length - 1].value,
  1769. operator: "=",
  1770. right: expression(false),
  1771. end: S.token
  1772. });
  1773. }
  1774. }
  1775. expect("}");
  1776. used_parameters.check_strict();
  1777. return new AST_Destructuring({
  1778. start: first_token,
  1779. names: elements,
  1780. is_array: false,
  1781. end: prev()
  1782. });
  1783. } else if (is("name")) {
  1784. used_parameters.add_parameter(S.token);
  1785. return as_symbol(symbol_type);
  1786. } else {
  1787. croak("Invalid function parameter");
  1788. }
  1789. }
  1790. function params_or_seq_(allow_arrows, maybe_sequence) {
  1791. var spread_token;
  1792. var invalid_sequence;
  1793. var trailing_comma;
  1794. var a = [];
  1795. expect("(");
  1796. while (!is("punc", ")")) {
  1797. if (spread_token) unexpected(spread_token);
  1798. if (is("expand", "...")) {
  1799. spread_token = S.token;
  1800. if (maybe_sequence) invalid_sequence = S.token;
  1801. next();
  1802. a.push(new AST_Expansion({
  1803. start: prev(),
  1804. expression: expression(),
  1805. end: S.token,
  1806. }));
  1807. } else {
  1808. a.push(expression());
  1809. }
  1810. if (!is("punc", ")")) {
  1811. expect(",");
  1812. if (is("punc", ")")) {
  1813. trailing_comma = prev();
  1814. if (maybe_sequence) invalid_sequence = trailing_comma;
  1815. }
  1816. }
  1817. }
  1818. expect(")");
  1819. if (allow_arrows && is("arrow", "=>")) {
  1820. if (spread_token && trailing_comma) unexpected(trailing_comma);
  1821. } else if (invalid_sequence) {
  1822. unexpected(invalid_sequence);
  1823. }
  1824. return a;
  1825. }
  1826. function _function_body(block, generator, is_async, name, args) {
  1827. var loop = S.in_loop;
  1828. var labels = S.labels;
  1829. var current_generator = S.in_generator;
  1830. var current_async = S.in_async;
  1831. ++S.in_function;
  1832. if (generator)
  1833. S.in_generator = S.in_function;
  1834. if (is_async)
  1835. S.in_async = S.in_function;
  1836. if (args) parameters(args);
  1837. if (block)
  1838. S.in_directives = true;
  1839. S.in_loop = 0;
  1840. S.labels = [];
  1841. if (block) {
  1842. S.input.push_directives_stack();
  1843. var a = block_();
  1844. if (name) _verify_symbol(name);
  1845. if (args) args.forEach(_verify_symbol);
  1846. S.input.pop_directives_stack();
  1847. } else {
  1848. var a = [new AST_Return({
  1849. start: S.token,
  1850. value: expression(false),
  1851. end: S.token
  1852. })];
  1853. }
  1854. --S.in_function;
  1855. S.in_loop = loop;
  1856. S.labels = labels;
  1857. S.in_generator = current_generator;
  1858. S.in_async = current_async;
  1859. return a;
  1860. }
  1861. function _await_expression() {
  1862. // Previous token must be "await" and not be interpreted as an identifier
  1863. if (!can_await()) {
  1864. croak("Unexpected await expression outside async function",
  1865. S.prev.line, S.prev.col, S.prev.pos);
  1866. }
  1867. // the await expression is parsed as a unary expression in Babel
  1868. return new AST_Await({
  1869. start: prev(),
  1870. end: S.token,
  1871. expression : maybe_unary(true),
  1872. });
  1873. }
  1874. function _yield_expression() {
  1875. // Previous token must be keyword yield and not be interpret as an identifier
  1876. if (!is_in_generator()) {
  1877. croak("Unexpected yield expression outside generator function",
  1878. S.prev.line, S.prev.col, S.prev.pos);
  1879. }
  1880. var start = S.token;
  1881. var star = false;
  1882. var has_expression = true;
  1883. // Attempt to get expression or star (and then the mandatory expression)
  1884. // behind yield on the same line.
  1885. //
  1886. // If nothing follows on the same line of the yieldExpression,
  1887. // it should default to the value `undefined` for yield to return.
  1888. // In that case, the `undefined` stored as `null` in ast.
  1889. //
  1890. // Note 1: It isn't allowed for yield* to close without an expression
  1891. // Note 2: If there is a nlb between yield and star, it is interpret as
  1892. // yield <explicit undefined> <inserted automatic semicolon> *
  1893. if (can_insert_semicolon() ||
  1894. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  1895. has_expression = false;
  1896. } else if (is("operator", "*")) {
  1897. star = true;
  1898. next();
  1899. }
  1900. return new AST_Yield({
  1901. start : start,
  1902. is_star : star,
  1903. expression : has_expression ? expression() : null,
  1904. end : prev()
  1905. });
  1906. }
  1907. function if_() {
  1908. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  1909. if (is("keyword", "else")) {
  1910. next();
  1911. belse = statement(false, false, true);
  1912. }
  1913. return new AST_If({
  1914. condition : cond,
  1915. body : body,
  1916. alternative : belse
  1917. });
  1918. }
  1919. function block_() {
  1920. expect("{");
  1921. var a = [];
  1922. while (!is("punc", "}")) {
  1923. if (is("eof")) unexpected();
  1924. a.push(statement());
  1925. }
  1926. next();
  1927. return a;
  1928. }
  1929. function switch_body_() {
  1930. expect("{");
  1931. var a = [], cur = null, branch = null, tmp;
  1932. while (!is("punc", "}")) {
  1933. if (is("eof")) unexpected();
  1934. if (is("keyword", "case")) {
  1935. if (branch) branch.end = prev();
  1936. cur = [];
  1937. branch = new AST_Case({
  1938. start : (tmp = S.token, next(), tmp),
  1939. expression : expression(true),
  1940. body : cur
  1941. });
  1942. a.push(branch);
  1943. expect(":");
  1944. } else if (is("keyword", "default")) {
  1945. if (branch) branch.end = prev();
  1946. cur = [];
  1947. branch = new AST_Default({
  1948. start : (tmp = S.token, next(), expect(":"), tmp),
  1949. body : cur
  1950. });
  1951. a.push(branch);
  1952. } else {
  1953. if (!cur) unexpected();
  1954. cur.push(statement());
  1955. }
  1956. }
  1957. if (branch) branch.end = prev();
  1958. next();
  1959. return a;
  1960. }
  1961. function try_() {
  1962. var body, bcatch = null, bfinally = null;
  1963. body = new AST_TryBlock({
  1964. start : S.token,
  1965. body : block_(),
  1966. end : prev(),
  1967. });
  1968. if (is("keyword", "catch")) {
  1969. var start = S.token;
  1970. next();
  1971. if (is("punc", "{")) {
  1972. var name = null;
  1973. } else {
  1974. expect("(");
  1975. var name = parameter(undefined, AST_SymbolCatch);
  1976. expect(")");
  1977. }
  1978. bcatch = new AST_Catch({
  1979. start : start,
  1980. argname : name,
  1981. body : block_(),
  1982. end : prev()
  1983. });
  1984. }
  1985. if (is("keyword", "finally")) {
  1986. var start = S.token;
  1987. next();
  1988. bfinally = new AST_Finally({
  1989. start : start,
  1990. body : block_(),
  1991. end : prev()
  1992. });
  1993. }
  1994. if (!bcatch && !bfinally)
  1995. croak("Missing catch/finally blocks");
  1996. return new AST_Try({
  1997. body : body,
  1998. bcatch : bcatch,
  1999. bfinally : bfinally
  2000. });
  2001. }
  2002. /**
  2003. * var
  2004. * vardef1 = 2,
  2005. * vardef2 = 3;
  2006. */
  2007. function vardefs(no_in, kind) {
  2008. var var_defs = [];
  2009. var def;
  2010. for (;;) {
  2011. var sym_type =
  2012. kind === "var" ? AST_SymbolVar :
  2013. kind === "const" ? AST_SymbolConst :
  2014. kind === "let" ? AST_SymbolLet : null;
  2015. // var { a } = b
  2016. if (is("punc", "{") || is("punc", "[")) {
  2017. def = new AST_VarDef({
  2018. start: S.token,
  2019. name: binding_element(undefined, sym_type),
  2020. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  2021. end: prev()
  2022. });
  2023. } else {
  2024. def = new AST_VarDef({
  2025. start : S.token,
  2026. name : as_symbol(sym_type),
  2027. value : is("operator", "=")
  2028. ? (next(), expression(false, no_in))
  2029. : !no_in && kind === "const"
  2030. ? croak("Missing initializer in const declaration") : null,
  2031. end : prev()
  2032. });
  2033. if (def.name.name == "import") croak("Unexpected token: import");
  2034. }
  2035. var_defs.push(def);
  2036. if (!is("punc", ","))
  2037. break;
  2038. next();
  2039. }
  2040. return var_defs;
  2041. }
  2042. var var_ = function(no_in) {
  2043. return new AST_Var({
  2044. start : prev(),
  2045. definitions : vardefs(no_in, "var"),
  2046. end : prev()
  2047. });
  2048. };
  2049. var let_ = function(no_in) {
  2050. return new AST_Let({
  2051. start : prev(),
  2052. definitions : vardefs(no_in, "let"),
  2053. end : prev()
  2054. });
  2055. };
  2056. var const_ = function(no_in) {
  2057. return new AST_Const({
  2058. start : prev(),
  2059. definitions : vardefs(no_in, "const"),
  2060. end : prev()
  2061. });
  2062. };
  2063. var new_ = function(allow_calls) {
  2064. var start = S.token;
  2065. expect_token("operator", "new");
  2066. if (is("punc", ".")) {
  2067. next();
  2068. expect_token("name", "target");
  2069. return subscripts(new AST_NewTarget({
  2070. start : start,
  2071. end : prev()
  2072. }), allow_calls);
  2073. }
  2074. var newexp = expr_atom(false), args;
  2075. if (is("punc", "(")) {
  2076. next();
  2077. args = expr_list(")", true);
  2078. } else {
  2079. args = [];
  2080. }
  2081. var call = new AST_New({
  2082. start : start,
  2083. expression : newexp,
  2084. args : args,
  2085. end : prev()
  2086. });
  2087. annotate(call);
  2088. return subscripts(call, allow_calls);
  2089. };
  2090. function as_atom_node() {
  2091. var tok = S.token, ret;
  2092. switch (tok.type) {
  2093. case "name":
  2094. ret = _make_symbol(AST_SymbolRef);
  2095. break;
  2096. case "num":
  2097. ret = new AST_Number({
  2098. start: tok,
  2099. end: tok,
  2100. value: tok.value,
  2101. raw: LATEST_RAW
  2102. });
  2103. break;
  2104. case "big_int":
  2105. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  2106. break;
  2107. case "string":
  2108. ret = new AST_String({
  2109. start : tok,
  2110. end : tok,
  2111. value : tok.value,
  2112. quote : tok.quote
  2113. });
  2114. annotate(ret);
  2115. break;
  2116. case "regexp":
  2117. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  2118. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  2119. break;
  2120. case "atom":
  2121. switch (tok.value) {
  2122. case "false":
  2123. ret = new AST_False({ start: tok, end: tok });
  2124. break;
  2125. case "true":
  2126. ret = new AST_True({ start: tok, end: tok });
  2127. break;
  2128. case "null":
  2129. ret = new AST_Null({ start: tok, end: tok });
  2130. break;
  2131. }
  2132. break;
  2133. }
  2134. next();
  2135. return ret;
  2136. }
  2137. function to_fun_args(ex, default_seen_above) {
  2138. var insert_default = function(ex, default_value) {
  2139. if (default_value) {
  2140. return new AST_DefaultAssign({
  2141. start: ex.start,
  2142. left: ex,
  2143. operator: "=",
  2144. right: default_value,
  2145. end: default_value.end
  2146. });
  2147. }
  2148. return ex;
  2149. };
  2150. if (ex instanceof AST_Object) {
  2151. return insert_default(new AST_Destructuring({
  2152. start: ex.start,
  2153. end: ex.end,
  2154. is_array: false,
  2155. names: ex.properties.map(prop => to_fun_args(prop))
  2156. }), default_seen_above);
  2157. } else if (ex instanceof AST_ObjectKeyVal) {
  2158. ex.value = to_fun_args(ex.value);
  2159. return insert_default(ex, default_seen_above);
  2160. } else if (ex instanceof AST_Hole) {
  2161. return ex;
  2162. } else if (ex instanceof AST_Destructuring) {
  2163. ex.names = ex.names.map(name => to_fun_args(name));
  2164. return insert_default(ex, default_seen_above);
  2165. } else if (ex instanceof AST_SymbolRef) {
  2166. return insert_default(new AST_SymbolFunarg({
  2167. name: ex.name,
  2168. start: ex.start,
  2169. end: ex.end
  2170. }), default_seen_above);
  2171. } else if (ex instanceof AST_Expansion) {
  2172. ex.expression = to_fun_args(ex.expression);
  2173. return insert_default(ex, default_seen_above);
  2174. } else if (ex instanceof AST_Array) {
  2175. return insert_default(new AST_Destructuring({
  2176. start: ex.start,
  2177. end: ex.end,
  2178. is_array: true,
  2179. names: ex.elements.map(elm => to_fun_args(elm))
  2180. }), default_seen_above);
  2181. } else if (ex instanceof AST_Assign) {
  2182. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2183. } else if (ex instanceof AST_DefaultAssign) {
  2184. ex.left = to_fun_args(ex.left);
  2185. return ex;
  2186. } else {
  2187. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2188. }
  2189. }
  2190. var expr_atom = function(allow_calls, allow_arrows) {
  2191. if (is("operator", "new")) {
  2192. return new_(allow_calls);
  2193. }
  2194. if (is("name", "import") && is_token(peek(), "punc", ".")) {
  2195. return import_meta(allow_calls);
  2196. }
  2197. var start = S.token;
  2198. var peeked;
  2199. var async = is("name", "async")
  2200. && (peeked = peek()).value != "["
  2201. && peeked.type != "arrow"
  2202. && as_atom_node();
  2203. if (is("punc")) {
  2204. switch (S.token.value) {
  2205. case "(":
  2206. if (async && !allow_calls) break;
  2207. var exprs = params_or_seq_(allow_arrows, !async);
  2208. if (allow_arrows && is("arrow", "=>")) {
  2209. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2210. }
  2211. var ex = async ? new AST_Call({
  2212. expression: async,
  2213. args: exprs
  2214. }) : to_expr_or_sequence(start, exprs);
  2215. if (ex.start) {
  2216. const outer_comments_before = start.comments_before.length;
  2217. outer_comments_before_counts.set(start, outer_comments_before);
  2218. ex.start.comments_before.unshift(...start.comments_before);
  2219. start.comments_before = ex.start.comments_before;
  2220. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2221. var comment = start.comments_before[0];
  2222. if (!comment.nlb) {
  2223. comment.nlb = start.nlb;
  2224. start.nlb = false;
  2225. }
  2226. }
  2227. start.comments_after = ex.start.comments_after;
  2228. }
  2229. ex.start = start;
  2230. var end = prev();
  2231. if (ex.end) {
  2232. end.comments_before = ex.end.comments_before;
  2233. ex.end.comments_after.push(...end.comments_after);
  2234. end.comments_after = ex.end.comments_after;
  2235. }
  2236. ex.end = end;
  2237. if (ex instanceof AST_Call) annotate(ex);
  2238. return subscripts(ex, allow_calls);
  2239. case "[":
  2240. return subscripts(array_(), allow_calls);
  2241. case "{":
  2242. return subscripts(object_or_destructuring_(), allow_calls);
  2243. }
  2244. if (!async) unexpected();
  2245. }
  2246. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2247. var param = new AST_SymbolFunarg({
  2248. name: S.token.value,
  2249. start: start,
  2250. end: start,
  2251. });
  2252. next();
  2253. return arrow_function(start, [param], !!async);
  2254. }
  2255. if (is("keyword", "function")) {
  2256. next();
  2257. var func = function_(AST_Function, false, !!async);
  2258. func.start = start;
  2259. func.end = prev();
  2260. return subscripts(func, allow_calls);
  2261. }
  2262. if (async) return subscripts(async, allow_calls);
  2263. if (is("keyword", "class")) {
  2264. next();
  2265. var cls = class_(AST_ClassExpression);
  2266. cls.start = start;
  2267. cls.end = prev();
  2268. return subscripts(cls, allow_calls);
  2269. }
  2270. if (is("template_head")) {
  2271. return subscripts(template_string(), allow_calls);
  2272. }
  2273. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2274. return subscripts(as_atom_node(), allow_calls);
  2275. }
  2276. unexpected();
  2277. };
  2278. function template_string() {
  2279. var segments = [], start = S.token;
  2280. segments.push(new AST_TemplateSegment({
  2281. start: S.token,
  2282. raw: TEMPLATE_RAWS.get(S.token),
  2283. value: S.token.value,
  2284. end: S.token
  2285. }));
  2286. while (!S.token.template_end) {
  2287. next();
  2288. handle_regexp();
  2289. segments.push(expression(true));
  2290. segments.push(new AST_TemplateSegment({
  2291. start: S.token,
  2292. raw: TEMPLATE_RAWS.get(S.token),
  2293. value: S.token.value,
  2294. end: S.token
  2295. }));
  2296. }
  2297. next();
  2298. return new AST_TemplateString({
  2299. start: start,
  2300. segments: segments,
  2301. end: S.token
  2302. });
  2303. }
  2304. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2305. var first = true, a = [];
  2306. while (!is("punc", closing)) {
  2307. if (first) first = false; else expect(",");
  2308. if (allow_trailing_comma && is("punc", closing)) break;
  2309. if (is("punc", ",") && allow_empty) {
  2310. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2311. } else if (is("expand", "...")) {
  2312. next();
  2313. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2314. } else {
  2315. a.push(expression(false));
  2316. }
  2317. }
  2318. next();
  2319. return a;
  2320. }
  2321. var array_ = embed_tokens(function() {
  2322. expect("[");
  2323. return new AST_Array({
  2324. elements: expr_list("]", !options.strict, true)
  2325. });
  2326. });
  2327. var create_accessor = embed_tokens((is_generator, is_async) => {
  2328. return function_(AST_Accessor, is_generator, is_async);
  2329. });
  2330. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2331. var start = S.token, first = true, a = [];
  2332. expect("{");
  2333. while (!is("punc", "}")) {
  2334. if (first) first = false; else expect(",");
  2335. if (!options.strict && is("punc", "}"))
  2336. // allow trailing comma
  2337. break;
  2338. start = S.token;
  2339. if (start.type == "expand") {
  2340. next();
  2341. a.push(new AST_Expansion({
  2342. start: start,
  2343. expression: expression(false),
  2344. end: prev(),
  2345. }));
  2346. continue;
  2347. }
  2348. if(is("privatename")) {
  2349. croak("private fields are not allowed in an object");
  2350. }
  2351. var name = as_property_name();
  2352. var value;
  2353. // Check property and fetch value
  2354. if (!is("punc", ":")) {
  2355. var concise = concise_method_or_getset(name, start);
  2356. if (concise) {
  2357. a.push(concise);
  2358. continue;
  2359. }
  2360. value = new AST_SymbolRef({
  2361. start: prev(),
  2362. name: name,
  2363. end: prev()
  2364. });
  2365. } else if (name === null) {
  2366. unexpected(prev());
  2367. } else {
  2368. next(); // `:` - see first condition
  2369. value = expression(false);
  2370. }
  2371. // Check for default value and alter value accordingly if necessary
  2372. if (is("operator", "=")) {
  2373. next();
  2374. value = new AST_Assign({
  2375. start: start,
  2376. left: value,
  2377. operator: "=",
  2378. right: expression(false),
  2379. logical: false,
  2380. end: prev()
  2381. });
  2382. }
  2383. // Create property
  2384. const kv = new AST_ObjectKeyVal({
  2385. start: start,
  2386. quote: start.quote,
  2387. key: name instanceof AST_Node ? name : "" + name,
  2388. value: value,
  2389. end: prev()
  2390. });
  2391. a.push(annotate(kv));
  2392. }
  2393. next();
  2394. return new AST_Object({ properties: a });
  2395. });
  2396. function class_(KindOfClass, is_export_default) {
  2397. var start, method, class_name, extends_, a = [];
  2398. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2399. S.input.add_directive("use strict");
  2400. if (S.token.type == "name" && S.token.value != "extends") {
  2401. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2402. }
  2403. if (KindOfClass === AST_DefClass && !class_name) {
  2404. if (is_export_default) {
  2405. KindOfClass = AST_ClassExpression;
  2406. } else {
  2407. unexpected();
  2408. }
  2409. }
  2410. if (S.token.value == "extends") {
  2411. next();
  2412. extends_ = expression(true);
  2413. }
  2414. expect("{");
  2415. // mark in class feild,
  2416. const save_in_class = S.in_class;
  2417. S.in_class = true;
  2418. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2419. while (!is("punc", "}")) {
  2420. start = S.token;
  2421. method = concise_method_or_getset(as_property_name(), start, true);
  2422. if (!method) { unexpected(); }
  2423. a.push(method);
  2424. while (is("punc", ";")) { next(); }
  2425. }
  2426. // mark in class feild,
  2427. S.in_class = save_in_class;
  2428. S.input.pop_directives_stack();
  2429. next();
  2430. return new KindOfClass({
  2431. start: start,
  2432. name: class_name,
  2433. extends: extends_,
  2434. properties: a,
  2435. end: prev(),
  2436. });
  2437. }
  2438. function concise_method_or_getset(name, start, is_class) {
  2439. const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
  2440. if (typeof name === "string" || typeof name === "number") {
  2441. return new SymbolClass({
  2442. start,
  2443. name: "" + name,
  2444. end: prev()
  2445. });
  2446. } else if (name === null) {
  2447. unexpected();
  2448. }
  2449. return name;
  2450. };
  2451. const is_not_method_start = () =>
  2452. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=");
  2453. var is_async = false;
  2454. var is_static = false;
  2455. var is_generator = false;
  2456. var is_private = false;
  2457. var accessor_type = null;
  2458. if (is_class && name === "static" && is_not_method_start()) {
  2459. const static_block = class_static_block();
  2460. if (static_block != null) {
  2461. return static_block;
  2462. }
  2463. is_static = true;
  2464. name = as_property_name();
  2465. }
  2466. if (name === "async" && is_not_method_start()) {
  2467. is_async = true;
  2468. name = as_property_name();
  2469. }
  2470. if (prev().type === "operator" && prev().value === "*") {
  2471. is_generator = true;
  2472. name = as_property_name();
  2473. }
  2474. if ((name === "get" || name === "set") && is_not_method_start()) {
  2475. accessor_type = name;
  2476. name = as_property_name();
  2477. }
  2478. if (prev().type === "privatename") {
  2479. is_private = true;
  2480. }
  2481. const property_token = prev();
  2482. if (accessor_type != null) {
  2483. if (!is_private) {
  2484. const AccessorClass = accessor_type === "get"
  2485. ? AST_ObjectGetter
  2486. : AST_ObjectSetter;
  2487. name = get_symbol_ast(name);
  2488. return annotate(new AccessorClass({
  2489. start,
  2490. static: is_static,
  2491. key: name,
  2492. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  2493. value: create_accessor(),
  2494. end: prev()
  2495. }));
  2496. } else {
  2497. const AccessorClass = accessor_type === "get"
  2498. ? AST_PrivateGetter
  2499. : AST_PrivateSetter;
  2500. return annotate(new AccessorClass({
  2501. start,
  2502. static: is_static,
  2503. key: get_symbol_ast(name),
  2504. value: create_accessor(),
  2505. end: prev(),
  2506. }));
  2507. }
  2508. }
  2509. if (is("punc", "(")) {
  2510. name = get_symbol_ast(name);
  2511. const AST_MethodVariant = is_private
  2512. ? AST_PrivateMethod
  2513. : AST_ConciseMethod;
  2514. var node = new AST_MethodVariant({
  2515. start : start,
  2516. static : is_static,
  2517. is_generator: is_generator,
  2518. async : is_async,
  2519. key : name,
  2520. quote : name instanceof AST_SymbolMethod ?
  2521. property_token.quote : undefined,
  2522. value : create_accessor(is_generator, is_async),
  2523. end : prev()
  2524. });
  2525. return annotate(node);
  2526. }
  2527. if (is_class) {
  2528. const key = get_symbol_ast(name, AST_SymbolClassProperty);
  2529. const quote = key instanceof AST_SymbolClassProperty
  2530. ? property_token.quote
  2531. : undefined;
  2532. const AST_ClassPropertyVariant = is_private
  2533. ? AST_ClassPrivateProperty
  2534. : AST_ClassProperty;
  2535. if (is("operator", "=")) {
  2536. next();
  2537. return annotate(
  2538. new AST_ClassPropertyVariant({
  2539. start,
  2540. static: is_static,
  2541. quote,
  2542. key,
  2543. value: expression(false),
  2544. end: prev()
  2545. })
  2546. );
  2547. } else if (
  2548. is("name")
  2549. || is("privatename")
  2550. || is("punc", "[")
  2551. || is("operator", "*")
  2552. || is("punc", ";")
  2553. || is("punc", "}")
  2554. ) {
  2555. return annotate(
  2556. new AST_ClassPropertyVariant({
  2557. start,
  2558. static: is_static,
  2559. quote,
  2560. key,
  2561. end: prev()
  2562. })
  2563. );
  2564. }
  2565. }
  2566. }
  2567. function class_static_block() {
  2568. if (!is("punc", "{")) {
  2569. return null;
  2570. }
  2571. const start = S.token;
  2572. const body = [];
  2573. next();
  2574. while (!is("punc", "}")) {
  2575. body.push(statement());
  2576. }
  2577. next();
  2578. return new AST_ClassStaticBlock({ start, body, end: prev() });
  2579. }
  2580. function maybe_import_attributes() {
  2581. if (
  2582. (is("keyword", "with") || is("name", "assert"))
  2583. && !has_newline_before(S.token)
  2584. ) {
  2585. next();
  2586. return object_or_destructuring_();
  2587. }
  2588. return null;
  2589. }
  2590. function import_statement() {
  2591. var start = prev();
  2592. var imported_name;
  2593. var imported_names;
  2594. if (is("name")) {
  2595. imported_name = as_symbol(AST_SymbolImport);
  2596. }
  2597. if (is("punc", ",")) {
  2598. next();
  2599. }
  2600. imported_names = map_names(true);
  2601. if (imported_names || imported_name) {
  2602. expect_token("name", "from");
  2603. }
  2604. var mod_str = S.token;
  2605. if (mod_str.type !== "string") {
  2606. unexpected();
  2607. }
  2608. next();
  2609. const attributes = maybe_import_attributes();
  2610. return new AST_Import({
  2611. start,
  2612. imported_name,
  2613. imported_names,
  2614. module_name: new AST_String({
  2615. start: mod_str,
  2616. value: mod_str.value,
  2617. quote: mod_str.quote,
  2618. end: mod_str,
  2619. }),
  2620. attributes,
  2621. end: S.token,
  2622. });
  2623. }
  2624. function import_meta(allow_calls) {
  2625. var start = S.token;
  2626. expect_token("name", "import");
  2627. expect_token("punc", ".");
  2628. expect_token("name", "meta");
  2629. return subscripts(new AST_ImportMeta({
  2630. start: start,
  2631. end: prev()
  2632. }), allow_calls);
  2633. }
  2634. function map_name(is_import) {
  2635. function make_symbol(type, quote) {
  2636. return new type({
  2637. name: as_property_name(),
  2638. quote: quote || undefined,
  2639. start: prev(),
  2640. end: prev()
  2641. });
  2642. }
  2643. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2644. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2645. var start = S.token;
  2646. var foreign_name;
  2647. var name;
  2648. if (is_import) {
  2649. foreign_name = make_symbol(foreign_type, start.quote);
  2650. } else {
  2651. name = make_symbol(type, start.quote);
  2652. }
  2653. if (is("name", "as")) {
  2654. next(); // The "as" word
  2655. if (is_import) {
  2656. name = make_symbol(type);
  2657. } else {
  2658. foreign_name = make_symbol(foreign_type, S.token.quote);
  2659. }
  2660. } else if (is_import) {
  2661. name = new type(foreign_name);
  2662. } else {
  2663. foreign_name = new foreign_type(name);
  2664. }
  2665. return new AST_NameMapping({
  2666. start: start,
  2667. foreign_name: foreign_name,
  2668. name: name,
  2669. end: prev(),
  2670. });
  2671. }
  2672. function map_nameAsterisk(is_import, import_or_export_foreign_name) {
  2673. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2674. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2675. var start = S.token;
  2676. var name, foreign_name;
  2677. var end = prev();
  2678. if (is_import) {
  2679. name = import_or_export_foreign_name;
  2680. } else {
  2681. foreign_name = import_or_export_foreign_name;
  2682. }
  2683. name = name || new type({
  2684. start: start,
  2685. name: "*",
  2686. end: end,
  2687. });
  2688. foreign_name = foreign_name || new foreign_type({
  2689. start: start,
  2690. name: "*",
  2691. end: end,
  2692. });
  2693. return new AST_NameMapping({
  2694. start: start,
  2695. foreign_name: foreign_name,
  2696. name: name,
  2697. end: end,
  2698. });
  2699. }
  2700. function map_names(is_import) {
  2701. var names;
  2702. if (is("punc", "{")) {
  2703. next();
  2704. names = [];
  2705. while (!is("punc", "}")) {
  2706. names.push(map_name(is_import));
  2707. if (is("punc", ",")) {
  2708. next();
  2709. }
  2710. }
  2711. next();
  2712. } else if (is("operator", "*")) {
  2713. var name;
  2714. next();
  2715. if (is("name", "as")) {
  2716. next(); // The "as" word
  2717. name = is_import ? as_symbol(AST_SymbolImport) : as_symbol_or_string(AST_SymbolExportForeign);
  2718. }
  2719. names = [map_nameAsterisk(is_import, name)];
  2720. }
  2721. return names;
  2722. }
  2723. function export_statement() {
  2724. var start = S.token;
  2725. var is_default;
  2726. var exported_names;
  2727. if (is("keyword", "default")) {
  2728. is_default = true;
  2729. next();
  2730. } else if (exported_names = map_names(false)) {
  2731. if (is("name", "from")) {
  2732. next();
  2733. var mod_str = S.token;
  2734. if (mod_str.type !== "string") {
  2735. unexpected();
  2736. }
  2737. next();
  2738. const attributes = maybe_import_attributes();
  2739. return new AST_Export({
  2740. start: start,
  2741. is_default: is_default,
  2742. exported_names: exported_names,
  2743. module_name: new AST_String({
  2744. start: mod_str,
  2745. value: mod_str.value,
  2746. quote: mod_str.quote,
  2747. end: mod_str,
  2748. }),
  2749. end: prev(),
  2750. attributes
  2751. });
  2752. } else {
  2753. return new AST_Export({
  2754. start: start,
  2755. is_default: is_default,
  2756. exported_names: exported_names,
  2757. end: prev(),
  2758. });
  2759. }
  2760. }
  2761. var node;
  2762. var exported_value;
  2763. var exported_definition;
  2764. if (is("punc", "{")
  2765. || is_default
  2766. && (is("keyword", "class") || is("keyword", "function"))
  2767. && is_token(peek(), "punc")) {
  2768. exported_value = expression(false);
  2769. semicolon();
  2770. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2771. unexpected(node.start);
  2772. } else if (
  2773. node instanceof AST_Definitions
  2774. || node instanceof AST_Defun
  2775. || node instanceof AST_DefClass
  2776. ) {
  2777. exported_definition = node;
  2778. } else if (
  2779. node instanceof AST_ClassExpression
  2780. || node instanceof AST_Function
  2781. ) {
  2782. exported_value = node;
  2783. } else if (node instanceof AST_SimpleStatement) {
  2784. exported_value = node.body;
  2785. } else {
  2786. unexpected(node.start);
  2787. }
  2788. return new AST_Export({
  2789. start: start,
  2790. is_default: is_default,
  2791. exported_value: exported_value,
  2792. exported_definition: exported_definition,
  2793. end: prev(),
  2794. attributes: null
  2795. });
  2796. }
  2797. function as_property_name() {
  2798. var tmp = S.token;
  2799. switch (tmp.type) {
  2800. case "punc":
  2801. if (tmp.value === "[") {
  2802. next();
  2803. var ex = expression(false);
  2804. expect("]");
  2805. return ex;
  2806. } else unexpected(tmp);
  2807. case "operator":
  2808. if (tmp.value === "*") {
  2809. next();
  2810. return null;
  2811. }
  2812. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2813. unexpected(tmp);
  2814. }
  2815. /* falls through */
  2816. case "name":
  2817. case "privatename":
  2818. case "string":
  2819. case "num":
  2820. case "big_int":
  2821. case "keyword":
  2822. case "atom":
  2823. next();
  2824. return tmp.value;
  2825. default:
  2826. unexpected(tmp);
  2827. }
  2828. }
  2829. function as_name() {
  2830. var tmp = S.token;
  2831. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  2832. next();
  2833. return tmp.value;
  2834. }
  2835. function _make_symbol(type) {
  2836. var name = S.token.value;
  2837. return new (name == "this" ? AST_This :
  2838. name == "super" ? AST_Super :
  2839. type)({
  2840. name : String(name),
  2841. start : S.token,
  2842. end : S.token
  2843. });
  2844. }
  2845. function _verify_symbol(sym) {
  2846. var name = sym.name;
  2847. if (is_in_generator() && name == "yield") {
  2848. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2849. }
  2850. if (S.input.has_directive("use strict")) {
  2851. if (name == "yield") {
  2852. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2853. }
  2854. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2855. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2856. }
  2857. }
  2858. }
  2859. function as_symbol(type, noerror) {
  2860. if (!is("name")) {
  2861. if (!noerror) croak("Name expected");
  2862. return null;
  2863. }
  2864. var sym = _make_symbol(type);
  2865. _verify_symbol(sym);
  2866. next();
  2867. return sym;
  2868. }
  2869. function as_symbol_or_string(type) {
  2870. if (!is("name")) {
  2871. if (!is("string")) {
  2872. croak("Name or string expected");
  2873. }
  2874. var tok = S.token;
  2875. var ret = new type({
  2876. start : tok,
  2877. end : tok,
  2878. name : tok.value,
  2879. quote : tok.quote
  2880. });
  2881. next();
  2882. return ret;
  2883. }
  2884. var sym = _make_symbol(type);
  2885. _verify_symbol(sym);
  2886. next();
  2887. return sym;
  2888. }
  2889. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2890. function annotate(node, before_token = node.start) {
  2891. var comments = before_token.comments_before;
  2892. const comments_outside_parens = outer_comments_before_counts.get(before_token);
  2893. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2894. while (--i >= 0) {
  2895. var comment = comments[i];
  2896. if (/[@#]__/.test(comment.value)) {
  2897. if (/[@#]__PURE__/.test(comment.value)) {
  2898. set_annotation(node, _PURE);
  2899. break;
  2900. }
  2901. if (/[@#]__INLINE__/.test(comment.value)) {
  2902. set_annotation(node, _INLINE);
  2903. break;
  2904. }
  2905. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2906. set_annotation(node, _NOINLINE);
  2907. break;
  2908. }
  2909. if (/[@#]__KEY__/.test(comment.value)) {
  2910. set_annotation(node, _KEY);
  2911. break;
  2912. }
  2913. if (/[@#]__MANGLE_PROP__/.test(comment.value)) {
  2914. set_annotation(node, _MANGLEPROP);
  2915. break;
  2916. }
  2917. }
  2918. }
  2919. return node;
  2920. }
  2921. var subscripts = function(expr, allow_calls, is_chain) {
  2922. var start = expr.start;
  2923. if (is("punc", ".")) {
  2924. next();
  2925. if(is("privatename") && !S.in_class)
  2926. croak("Private field must be used in an enclosing class");
  2927. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2928. return annotate(subscripts(new AST_DotVariant({
  2929. start : start,
  2930. expression : expr,
  2931. optional : false,
  2932. property : as_name(),
  2933. end : prev()
  2934. }), allow_calls, is_chain));
  2935. }
  2936. if (is("punc", "[")) {
  2937. next();
  2938. var prop = expression(true);
  2939. expect("]");
  2940. return annotate(subscripts(new AST_Sub({
  2941. start : start,
  2942. expression : expr,
  2943. optional : false,
  2944. property : prop,
  2945. end : prev()
  2946. }), allow_calls, is_chain));
  2947. }
  2948. if (allow_calls && is("punc", "(")) {
  2949. next();
  2950. var call = new AST_Call({
  2951. start : start,
  2952. expression : expr,
  2953. optional : false,
  2954. args : call_args(),
  2955. end : prev()
  2956. });
  2957. annotate(call);
  2958. return subscripts(call, true, is_chain);
  2959. }
  2960. // Optional chain
  2961. if (is("punc", "?.")) {
  2962. next();
  2963. let chain_contents;
  2964. if (allow_calls && is("punc", "(")) {
  2965. next();
  2966. const call = new AST_Call({
  2967. start,
  2968. optional: true,
  2969. expression: expr,
  2970. args: call_args(),
  2971. end: prev()
  2972. });
  2973. annotate(call);
  2974. chain_contents = subscripts(call, true, true);
  2975. } else if (is("name") || is("privatename")) {
  2976. if(is("privatename") && !S.in_class)
  2977. croak("Private field must be used in an enclosing class");
  2978. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2979. chain_contents = annotate(subscripts(new AST_DotVariant({
  2980. start,
  2981. expression: expr,
  2982. optional: true,
  2983. property: as_name(),
  2984. end: prev()
  2985. }), allow_calls, true));
  2986. } else if (is("punc", "[")) {
  2987. next();
  2988. const property = expression(true);
  2989. expect("]");
  2990. chain_contents = annotate(subscripts(new AST_Sub({
  2991. start,
  2992. expression: expr,
  2993. optional: true,
  2994. property,
  2995. end: prev()
  2996. }), allow_calls, true));
  2997. }
  2998. if (!chain_contents) unexpected();
  2999. if (chain_contents instanceof AST_Chain) return chain_contents;
  3000. return new AST_Chain({
  3001. start,
  3002. expression: chain_contents,
  3003. end: prev()
  3004. });
  3005. }
  3006. if (is("template_head")) {
  3007. if (is_chain) {
  3008. // a?.b`c` is a syntax error
  3009. unexpected();
  3010. }
  3011. return subscripts(new AST_PrefixedTemplateString({
  3012. start: start,
  3013. prefix: expr,
  3014. template_string: template_string(),
  3015. end: prev()
  3016. }), allow_calls);
  3017. }
  3018. return expr;
  3019. };
  3020. function call_args() {
  3021. var args = [];
  3022. while (!is("punc", ")")) {
  3023. if (is("expand", "...")) {
  3024. next();
  3025. args.push(new AST_Expansion({
  3026. start: prev(),
  3027. expression: expression(false),
  3028. end: prev()
  3029. }));
  3030. } else {
  3031. args.push(expression(false));
  3032. }
  3033. if (!is("punc", ")")) {
  3034. expect(",");
  3035. }
  3036. }
  3037. next();
  3038. return args;
  3039. }
  3040. var maybe_unary = function(allow_calls, allow_arrows) {
  3041. var start = S.token;
  3042. if (start.type == "name" && start.value == "await" && can_await()) {
  3043. next();
  3044. return _await_expression();
  3045. }
  3046. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  3047. next();
  3048. handle_regexp();
  3049. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  3050. ex.start = start;
  3051. ex.end = prev();
  3052. return ex;
  3053. }
  3054. var val = expr_atom(allow_calls, allow_arrows);
  3055. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  3056. if (val instanceof AST_Arrow) unexpected();
  3057. val = make_unary(AST_UnaryPostfix, S.token, val);
  3058. val.start = start;
  3059. val.end = S.token;
  3060. next();
  3061. }
  3062. return val;
  3063. };
  3064. function make_unary(ctor, token, expr) {
  3065. var op = token.value;
  3066. switch (op) {
  3067. case "++":
  3068. case "--":
  3069. if (!is_assignable(expr))
  3070. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  3071. break;
  3072. case "delete":
  3073. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3074. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3075. break;
  3076. }
  3077. return new ctor({ operator: op, expression: expr });
  3078. }
  3079. var expr_op = function(left, min_prec, no_in) {
  3080. var op = is("operator") ? S.token.value : null;
  3081. if (op == "in" && no_in) op = null;
  3082. if (op == "**" && left instanceof AST_UnaryPrefix
  3083. /* unary token in front not allowed - parenthesis required */
  3084. && !is_token(left.start, "punc", "(")
  3085. && left.operator !== "--" && left.operator !== "++")
  3086. unexpected(left.start);
  3087. var prec = op != null ? PRECEDENCE[op] : null;
  3088. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3089. next();
  3090. var right = expr_ops(no_in, prec, true);
  3091. return expr_op(new AST_Binary({
  3092. start : left.start,
  3093. left : left,
  3094. operator : op,
  3095. right : right,
  3096. end : right.end
  3097. }), min_prec, no_in);
  3098. }
  3099. return left;
  3100. };
  3101. function expr_ops(no_in, min_prec, allow_calls, allow_arrows) {
  3102. // maybe_unary won't return us a AST_SymbolPrivateProperty
  3103. if (!no_in && min_prec < PRECEDENCE["in"] && is("privatename")) {
  3104. if(!S.in_class) {
  3105. croak("Private field must be used in an enclosing class");
  3106. }
  3107. const start = S.token;
  3108. const key = new AST_SymbolPrivateProperty({
  3109. start,
  3110. name: start.value,
  3111. end: start
  3112. });
  3113. next();
  3114. expect_token("operator", "in");
  3115. const private_in = new AST_PrivateIn({
  3116. start,
  3117. key,
  3118. value: expr_ops(no_in, PRECEDENCE["in"], true),
  3119. end: prev()
  3120. });
  3121. return expr_op(private_in, 0, no_in);
  3122. } else {
  3123. return expr_op(maybe_unary(allow_calls, allow_arrows), min_prec, no_in);
  3124. }
  3125. }
  3126. var maybe_conditional = function(no_in) {
  3127. var start = S.token;
  3128. var expr = expr_ops(no_in, 0, true, true);
  3129. if (is("operator", "?")) {
  3130. next();
  3131. var yes = expression(false);
  3132. expect(":");
  3133. return new AST_Conditional({
  3134. start : start,
  3135. condition : expr,
  3136. consequent : yes,
  3137. alternative : expression(false, no_in),
  3138. end : prev()
  3139. });
  3140. }
  3141. return expr;
  3142. };
  3143. function is_assignable(expr) {
  3144. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3145. }
  3146. function to_destructuring(node) {
  3147. if (node instanceof AST_Object) {
  3148. node = new AST_Destructuring({
  3149. start: node.start,
  3150. names: node.properties.map(to_destructuring),
  3151. is_array: false,
  3152. end: node.end
  3153. });
  3154. } else if (node instanceof AST_Array) {
  3155. var names = [];
  3156. for (var i = 0; i < node.elements.length; i++) {
  3157. // Only allow expansion as last element
  3158. if (node.elements[i] instanceof AST_Expansion) {
  3159. if (i + 1 !== node.elements.length) {
  3160. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3161. }
  3162. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3163. }
  3164. names.push(to_destructuring(node.elements[i]));
  3165. }
  3166. node = new AST_Destructuring({
  3167. start: node.start,
  3168. names: names,
  3169. is_array: true,
  3170. end: node.end
  3171. });
  3172. } else if (node instanceof AST_ObjectProperty) {
  3173. node.value = to_destructuring(node.value);
  3174. } else if (node instanceof AST_Assign) {
  3175. node = new AST_DefaultAssign({
  3176. start: node.start,
  3177. left: node.left,
  3178. operator: "=",
  3179. right: node.right,
  3180. end: node.end
  3181. });
  3182. }
  3183. return node;
  3184. }
  3185. // In ES6, AssignmentExpression can also be an ArrowFunction
  3186. var maybe_assign = function(no_in) {
  3187. handle_regexp();
  3188. var start = S.token;
  3189. if (start.type == "name" && start.value == "yield") {
  3190. if (is_in_generator()) {
  3191. next();
  3192. return _yield_expression();
  3193. } else if (S.input.has_directive("use strict")) {
  3194. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3195. }
  3196. }
  3197. var left = maybe_conditional(no_in);
  3198. var val = S.token.value;
  3199. if (is("operator") && ASSIGNMENT.has(val)) {
  3200. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3201. next();
  3202. return new AST_Assign({
  3203. start : start,
  3204. left : left,
  3205. operator : val,
  3206. right : maybe_assign(no_in),
  3207. logical : LOGICAL_ASSIGNMENT.has(val),
  3208. end : prev()
  3209. });
  3210. }
  3211. croak("Invalid assignment");
  3212. }
  3213. return left;
  3214. };
  3215. var to_expr_or_sequence = function(start, exprs) {
  3216. if (exprs.length === 1) {
  3217. return exprs[0];
  3218. } else if (exprs.length > 1) {
  3219. return new AST_Sequence({ start, expressions: exprs, end: peek() });
  3220. } else {
  3221. croak("Invalid parenthesized expression");
  3222. }
  3223. };
  3224. var expression = function(commas, no_in) {
  3225. var start = S.token;
  3226. var exprs = [];
  3227. while (true) {
  3228. exprs.push(maybe_assign(no_in));
  3229. if (!commas || !is("punc", ",")) break;
  3230. next();
  3231. commas = true;
  3232. }
  3233. return to_expr_or_sequence(start, exprs);
  3234. };
  3235. function in_loop(cont) {
  3236. ++S.in_loop;
  3237. var ret = cont();
  3238. --S.in_loop;
  3239. return ret;
  3240. }
  3241. if (options.expression) {
  3242. return expression(true);
  3243. }
  3244. return (function parse_toplevel() {
  3245. var start = S.token;
  3246. var body = [];
  3247. S.input.push_directives_stack();
  3248. if (options.module) S.input.add_directive("use strict");
  3249. while (!is("eof")) {
  3250. body.push(statement());
  3251. }
  3252. S.input.pop_directives_stack();
  3253. var end = prev();
  3254. var toplevel = options.toplevel;
  3255. if (toplevel) {
  3256. toplevel.body = toplevel.body.concat(body);
  3257. toplevel.end = end;
  3258. } else {
  3259. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3260. }
  3261. TEMPLATE_RAWS = new Map();
  3262. return toplevel;
  3263. })();
  3264. }
  3265. /***********************************************************************
  3266. A JavaScript tokenizer / parser / beautifier / compressor.
  3267. https://github.com/mishoo/UglifyJS2
  3268. -------------------------------- (C) ---------------------------------
  3269. Author: Mihai Bazon
  3270. <mihai.bazon@gmail.com>
  3271. http://mihai.bazon.net/blog
  3272. Distributed under the BSD license:
  3273. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3274. Redistribution and use in source and binary forms, with or without
  3275. modification, are permitted provided that the following conditions
  3276. are met:
  3277. * Redistributions of source code must retain the above
  3278. copyright notice, this list of conditions and the following
  3279. disclaimer.
  3280. * Redistributions in binary form must reproduce the above
  3281. copyright notice, this list of conditions and the following
  3282. disclaimer in the documentation and/or other materials
  3283. provided with the distribution.
  3284. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3285. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3286. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3287. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3288. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3289. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3290. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3291. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3292. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3293. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3294. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3295. SUCH DAMAGE.
  3296. ***********************************************************************/
  3297. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  3298. if (!props) props = [];
  3299. else props = props.split(/\s+/);
  3300. var self_props = props;
  3301. if (base && base.PROPS)
  3302. props = props.concat(base.PROPS);
  3303. const proto = base && Object.create(base.prototype);
  3304. if (proto) {
  3305. ctor.prototype = proto;
  3306. ctor.BASE = base;
  3307. }
  3308. if (base) base.SUBCLASSES.push(ctor);
  3309. ctor.prototype.CTOR = ctor;
  3310. ctor.prototype.constructor = ctor;
  3311. ctor.PROPS = props || null;
  3312. ctor.SELF_PROPS = self_props;
  3313. ctor.SUBCLASSES = [];
  3314. if (type) {
  3315. ctor.prototype.TYPE = ctor.TYPE = type;
  3316. }
  3317. if (methods) for (let i in methods) if (HOP(methods, i)) {
  3318. if (i[0] === "$") {
  3319. ctor[i.substr(1)] = methods[i];
  3320. } else {
  3321. ctor.prototype[i] = methods[i];
  3322. }
  3323. }
  3324. ctor.DEFMETHOD = function(name, method) {
  3325. this.prototype[name] = method;
  3326. };
  3327. return ctor;
  3328. }
  3329. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  3330. const set_tok_flag = (tok, flag, truth) => {
  3331. if (truth) {
  3332. tok.flags |= flag;
  3333. } else {
  3334. tok.flags &= ~flag;
  3335. }
  3336. };
  3337. const TOK_FLAG_NLB = 0b0001;
  3338. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  3339. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  3340. const TOK_FLAG_TEMPLATE_END = 0b1000;
  3341. class AST_Token {
  3342. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  3343. this.flags = (nlb ? 1 : 0);
  3344. this.type = type;
  3345. this.value = value;
  3346. this.line = line;
  3347. this.col = col;
  3348. this.pos = pos;
  3349. this.comments_before = comments_before;
  3350. this.comments_after = comments_after;
  3351. this.file = file;
  3352. Object.seal(this);
  3353. }
  3354. // Return a string summary of the token for node.js console.log
  3355. [Symbol.for("nodejs.util.inspect.custom")](_depth, options) {
  3356. const special = str => options.stylize(str, "special");
  3357. const quote = typeof this.value === "string" && this.value.includes("`") ? "'" : "`";
  3358. const value = `${quote}${this.value}${quote}`;
  3359. return `${special("[AST_Token")} ${value} at ${this.line}:${this.col}${special("]")}`;
  3360. }
  3361. get nlb() {
  3362. return has_tok_flag(this, TOK_FLAG_NLB);
  3363. }
  3364. set nlb(new_nlb) {
  3365. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  3366. }
  3367. get quote() {
  3368. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  3369. ? ""
  3370. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  3371. }
  3372. set quote(quote_type) {
  3373. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  3374. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  3375. }
  3376. get template_end() {
  3377. return has_tok_flag(this, TOK_FLAG_TEMPLATE_END);
  3378. }
  3379. set template_end(new_template_end) {
  3380. set_tok_flag(this, TOK_FLAG_TEMPLATE_END, new_template_end);
  3381. }
  3382. }
  3383. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  3384. if (props) {
  3385. this.start = props.start;
  3386. this.end = props.end;
  3387. }
  3388. this.flags = 0;
  3389. }, {
  3390. _clone: function(deep) {
  3391. if (deep) {
  3392. var self = this.clone();
  3393. return self.transform(new TreeTransformer(function(node) {
  3394. if (node !== self) {
  3395. return node.clone(true);
  3396. }
  3397. }));
  3398. }
  3399. return new this.CTOR(this);
  3400. },
  3401. clone: function(deep) {
  3402. return this._clone(deep);
  3403. },
  3404. $documentation: "Base class of all AST nodes",
  3405. $propdoc: {
  3406. start: "[AST_Token] The first token of this node",
  3407. end: "[AST_Token] The last token of this node"
  3408. },
  3409. _walk: function(visitor) {
  3410. return visitor._visit(this);
  3411. },
  3412. walk: function(visitor) {
  3413. return this._walk(visitor); // not sure the indirection will be any help
  3414. },
  3415. _children_backwards: () => {}
  3416. }, null);
  3417. /* -----[ statements ]----- */
  3418. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  3419. if (props) {
  3420. this.start = props.start;
  3421. this.end = props.end;
  3422. }
  3423. this.flags = 0;
  3424. }, {
  3425. $documentation: "Base class of all statements",
  3426. });
  3427. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  3428. if (props) {
  3429. this.start = props.start;
  3430. this.end = props.end;
  3431. }
  3432. this.flags = 0;
  3433. }, {
  3434. $documentation: "Represents a debugger statement",
  3435. }, AST_Statement);
  3436. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  3437. if (props) {
  3438. this.value = props.value;
  3439. this.quote = props.quote;
  3440. this.start = props.start;
  3441. this.end = props.end;
  3442. }
  3443. this.flags = 0;
  3444. }, {
  3445. $documentation: "Represents a directive, like \"use strict\";",
  3446. $propdoc: {
  3447. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3448. quote: "[string] the original quote character"
  3449. },
  3450. }, AST_Statement);
  3451. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  3452. if (props) {
  3453. this.body = props.body;
  3454. this.start = props.start;
  3455. this.end = props.end;
  3456. }
  3457. this.flags = 0;
  3458. }, {
  3459. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3460. $propdoc: {
  3461. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3462. },
  3463. _walk: function(visitor) {
  3464. return visitor._visit(this, function() {
  3465. this.body._walk(visitor);
  3466. });
  3467. },
  3468. _children_backwards(push) {
  3469. push(this.body);
  3470. }
  3471. }, AST_Statement);
  3472. function walk_body(node, visitor) {
  3473. const body = node.body;
  3474. for (var i = 0, len = body.length; i < len; i++) {
  3475. body[i]._walk(visitor);
  3476. }
  3477. }
  3478. function clone_block_scope(deep) {
  3479. var clone = this._clone(deep);
  3480. if (this.block_scope) {
  3481. clone.block_scope = this.block_scope.clone();
  3482. }
  3483. return clone;
  3484. }
  3485. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  3486. if (props) {
  3487. this.body = props.body;
  3488. this.block_scope = props.block_scope;
  3489. this.start = props.start;
  3490. this.end = props.end;
  3491. }
  3492. this.flags = 0;
  3493. }, {
  3494. $documentation: "A body of statements (usually braced)",
  3495. $propdoc: {
  3496. body: "[AST_Statement*] an array of statements",
  3497. block_scope: "[AST_Scope] the block scope"
  3498. },
  3499. _walk: function(visitor) {
  3500. return visitor._visit(this, function() {
  3501. walk_body(this, visitor);
  3502. });
  3503. },
  3504. _children_backwards(push) {
  3505. let i = this.body.length;
  3506. while (i--) push(this.body[i]);
  3507. },
  3508. clone: clone_block_scope
  3509. }, AST_Statement);
  3510. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  3511. if (props) {
  3512. this.body = props.body;
  3513. this.block_scope = props.block_scope;
  3514. this.start = props.start;
  3515. this.end = props.end;
  3516. }
  3517. this.flags = 0;
  3518. }, {
  3519. $documentation: "A block statement",
  3520. }, AST_Block);
  3521. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  3522. if (props) {
  3523. this.start = props.start;
  3524. this.end = props.end;
  3525. }
  3526. this.flags = 0;
  3527. }, {
  3528. $documentation: "The empty statement (empty block or simply a semicolon)"
  3529. }, AST_Statement);
  3530. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  3531. if (props) {
  3532. this.body = props.body;
  3533. this.start = props.start;
  3534. this.end = props.end;
  3535. }
  3536. this.flags = 0;
  3537. }, {
  3538. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3539. $propdoc: {
  3540. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3541. }
  3542. }, AST_Statement);
  3543. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  3544. if (props) {
  3545. this.label = props.label;
  3546. this.body = props.body;
  3547. this.start = props.start;
  3548. this.end = props.end;
  3549. }
  3550. this.flags = 0;
  3551. }, {
  3552. $documentation: "Statement with a label",
  3553. $propdoc: {
  3554. label: "[AST_Label] a label definition"
  3555. },
  3556. _walk: function(visitor) {
  3557. return visitor._visit(this, function() {
  3558. this.label._walk(visitor);
  3559. this.body._walk(visitor);
  3560. });
  3561. },
  3562. _children_backwards(push) {
  3563. push(this.body);
  3564. push(this.label);
  3565. },
  3566. clone: function(deep) {
  3567. var node = this._clone(deep);
  3568. if (deep) {
  3569. var label = node.label;
  3570. var def = this.label;
  3571. node.walk(new TreeWalker(function(node) {
  3572. if (node instanceof AST_LoopControl
  3573. && node.label && node.label.thedef === def) {
  3574. node.label.thedef = label;
  3575. label.references.push(node);
  3576. }
  3577. }));
  3578. }
  3579. return node;
  3580. }
  3581. }, AST_StatementWithBody);
  3582. var AST_IterationStatement = DEFNODE(
  3583. "IterationStatement",
  3584. "block_scope",
  3585. function AST_IterationStatement(props) {
  3586. if (props) {
  3587. this.block_scope = props.block_scope;
  3588. this.body = props.body;
  3589. this.start = props.start;
  3590. this.end = props.end;
  3591. }
  3592. this.flags = 0;
  3593. },
  3594. {
  3595. $documentation: "Internal class. All loops inherit from it.",
  3596. $propdoc: {
  3597. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3598. },
  3599. clone: clone_block_scope
  3600. },
  3601. AST_StatementWithBody
  3602. );
  3603. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  3604. if (props) {
  3605. this.condition = props.condition;
  3606. this.block_scope = props.block_scope;
  3607. this.body = props.body;
  3608. this.start = props.start;
  3609. this.end = props.end;
  3610. }
  3611. this.flags = 0;
  3612. }, {
  3613. $documentation: "Base class for do/while statements",
  3614. $propdoc: {
  3615. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3616. }
  3617. }, AST_IterationStatement);
  3618. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  3619. if (props) {
  3620. this.condition = props.condition;
  3621. this.block_scope = props.block_scope;
  3622. this.body = props.body;
  3623. this.start = props.start;
  3624. this.end = props.end;
  3625. }
  3626. this.flags = 0;
  3627. }, {
  3628. $documentation: "A `do` statement",
  3629. _walk: function(visitor) {
  3630. return visitor._visit(this, function() {
  3631. this.body._walk(visitor);
  3632. this.condition._walk(visitor);
  3633. });
  3634. },
  3635. _children_backwards(push) {
  3636. push(this.condition);
  3637. push(this.body);
  3638. }
  3639. }, AST_DWLoop);
  3640. var AST_While = DEFNODE("While", null, function AST_While(props) {
  3641. if (props) {
  3642. this.condition = props.condition;
  3643. this.block_scope = props.block_scope;
  3644. this.body = props.body;
  3645. this.start = props.start;
  3646. this.end = props.end;
  3647. }
  3648. this.flags = 0;
  3649. }, {
  3650. $documentation: "A `while` statement",
  3651. _walk: function(visitor) {
  3652. return visitor._visit(this, function() {
  3653. this.condition._walk(visitor);
  3654. this.body._walk(visitor);
  3655. });
  3656. },
  3657. _children_backwards(push) {
  3658. push(this.body);
  3659. push(this.condition);
  3660. },
  3661. }, AST_DWLoop);
  3662. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  3663. if (props) {
  3664. this.init = props.init;
  3665. this.condition = props.condition;
  3666. this.step = props.step;
  3667. this.block_scope = props.block_scope;
  3668. this.body = props.body;
  3669. this.start = props.start;
  3670. this.end = props.end;
  3671. }
  3672. this.flags = 0;
  3673. }, {
  3674. $documentation: "A `for` statement",
  3675. $propdoc: {
  3676. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3677. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3678. step: "[AST_Node?] the `for` update clause, or null if empty"
  3679. },
  3680. _walk: function(visitor) {
  3681. return visitor._visit(this, function() {
  3682. if (this.init) this.init._walk(visitor);
  3683. if (this.condition) this.condition._walk(visitor);
  3684. if (this.step) this.step._walk(visitor);
  3685. this.body._walk(visitor);
  3686. });
  3687. },
  3688. _children_backwards(push) {
  3689. push(this.body);
  3690. if (this.step) push(this.step);
  3691. if (this.condition) push(this.condition);
  3692. if (this.init) push(this.init);
  3693. },
  3694. }, AST_IterationStatement);
  3695. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  3696. if (props) {
  3697. this.init = props.init;
  3698. this.object = props.object;
  3699. this.block_scope = props.block_scope;
  3700. this.body = props.body;
  3701. this.start = props.start;
  3702. this.end = props.end;
  3703. }
  3704. this.flags = 0;
  3705. }, {
  3706. $documentation: "A `for ... in` statement",
  3707. $propdoc: {
  3708. init: "[AST_Node] the `for/in` initialization code",
  3709. object: "[AST_Node] the object that we're looping through"
  3710. },
  3711. _walk: function(visitor) {
  3712. return visitor._visit(this, function() {
  3713. this.init._walk(visitor);
  3714. this.object._walk(visitor);
  3715. this.body._walk(visitor);
  3716. });
  3717. },
  3718. _children_backwards(push) {
  3719. push(this.body);
  3720. if (this.object) push(this.object);
  3721. if (this.init) push(this.init);
  3722. },
  3723. }, AST_IterationStatement);
  3724. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  3725. if (props) {
  3726. this.await = props.await;
  3727. this.init = props.init;
  3728. this.object = props.object;
  3729. this.block_scope = props.block_scope;
  3730. this.body = props.body;
  3731. this.start = props.start;
  3732. this.end = props.end;
  3733. }
  3734. this.flags = 0;
  3735. }, {
  3736. $documentation: "A `for ... of` statement",
  3737. }, AST_ForIn);
  3738. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  3739. if (props) {
  3740. this.expression = props.expression;
  3741. this.body = props.body;
  3742. this.start = props.start;
  3743. this.end = props.end;
  3744. }
  3745. this.flags = 0;
  3746. }, {
  3747. $documentation: "A `with` statement",
  3748. $propdoc: {
  3749. expression: "[AST_Node] the `with` expression"
  3750. },
  3751. _walk: function(visitor) {
  3752. return visitor._visit(this, function() {
  3753. this.expression._walk(visitor);
  3754. this.body._walk(visitor);
  3755. });
  3756. },
  3757. _children_backwards(push) {
  3758. push(this.body);
  3759. push(this.expression);
  3760. },
  3761. }, AST_StatementWithBody);
  3762. /* -----[ scope and functions ]----- */
  3763. var AST_Scope = DEFNODE(
  3764. "Scope",
  3765. "variables uses_with uses_eval parent_scope enclosed cname",
  3766. function AST_Scope(props) {
  3767. if (props) {
  3768. this.variables = props.variables;
  3769. this.uses_with = props.uses_with;
  3770. this.uses_eval = props.uses_eval;
  3771. this.parent_scope = props.parent_scope;
  3772. this.enclosed = props.enclosed;
  3773. this.cname = props.cname;
  3774. this.body = props.body;
  3775. this.block_scope = props.block_scope;
  3776. this.start = props.start;
  3777. this.end = props.end;
  3778. }
  3779. this.flags = 0;
  3780. },
  3781. {
  3782. $documentation: "Base class for all statements introducing a lexical scope",
  3783. $propdoc: {
  3784. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3785. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3786. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3787. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3788. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3789. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3790. },
  3791. get_defun_scope: function() {
  3792. var self = this;
  3793. while (self.is_block_scope()) {
  3794. self = self.parent_scope;
  3795. }
  3796. return self;
  3797. },
  3798. clone: function(deep, toplevel) {
  3799. var node = this._clone(deep);
  3800. if (deep && this.variables && toplevel && !this._block_scope) {
  3801. node.figure_out_scope({}, {
  3802. toplevel: toplevel,
  3803. parent_scope: this.parent_scope
  3804. });
  3805. } else {
  3806. if (this.variables) node.variables = new Map(this.variables);
  3807. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3808. if (this._block_scope) node._block_scope = this._block_scope;
  3809. }
  3810. return node;
  3811. },
  3812. pinned: function() {
  3813. return this.uses_eval || this.uses_with;
  3814. }
  3815. },
  3816. AST_Block
  3817. );
  3818. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  3819. if (props) {
  3820. this.globals = props.globals;
  3821. this.variables = props.variables;
  3822. this.uses_with = props.uses_with;
  3823. this.uses_eval = props.uses_eval;
  3824. this.parent_scope = props.parent_scope;
  3825. this.enclosed = props.enclosed;
  3826. this.cname = props.cname;
  3827. this.body = props.body;
  3828. this.block_scope = props.block_scope;
  3829. this.start = props.start;
  3830. this.end = props.end;
  3831. }
  3832. this.flags = 0;
  3833. }, {
  3834. $documentation: "The toplevel scope",
  3835. $propdoc: {
  3836. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3837. },
  3838. wrap_commonjs: function(name) {
  3839. var body = this.body;
  3840. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3841. wrapped_tl = parse(wrapped_tl);
  3842. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3843. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3844. return MAP.splice(body);
  3845. }
  3846. }));
  3847. return wrapped_tl;
  3848. },
  3849. wrap_enclose: function(args_values) {
  3850. if (typeof args_values != "string") args_values = "";
  3851. var index = args_values.indexOf(":");
  3852. if (index < 0) index = args_values.length;
  3853. var body = this.body;
  3854. return parse([
  3855. "(function(",
  3856. args_values.slice(0, index),
  3857. '){"$ORIG"})(',
  3858. args_values.slice(index + 1),
  3859. ")"
  3860. ].join("")).transform(new TreeTransformer(function(node) {
  3861. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3862. return MAP.splice(body);
  3863. }
  3864. }));
  3865. }
  3866. }, AST_Scope);
  3867. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  3868. if (props) {
  3869. this.expression = props.expression;
  3870. this.start = props.start;
  3871. this.end = props.end;
  3872. }
  3873. this.flags = 0;
  3874. }, {
  3875. $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",
  3876. $propdoc: {
  3877. expression: "[AST_Node] the thing to be expanded"
  3878. },
  3879. _walk: function(visitor) {
  3880. return visitor._visit(this, function() {
  3881. this.expression.walk(visitor);
  3882. });
  3883. },
  3884. _children_backwards(push) {
  3885. push(this.expression);
  3886. },
  3887. });
  3888. var AST_Lambda = DEFNODE(
  3889. "Lambda",
  3890. "name argnames uses_arguments is_generator async",
  3891. function AST_Lambda(props) {
  3892. if (props) {
  3893. this.name = props.name;
  3894. this.argnames = props.argnames;
  3895. this.uses_arguments = props.uses_arguments;
  3896. this.is_generator = props.is_generator;
  3897. this.async = props.async;
  3898. this.variables = props.variables;
  3899. this.uses_with = props.uses_with;
  3900. this.uses_eval = props.uses_eval;
  3901. this.parent_scope = props.parent_scope;
  3902. this.enclosed = props.enclosed;
  3903. this.cname = props.cname;
  3904. this.body = props.body;
  3905. this.block_scope = props.block_scope;
  3906. this.start = props.start;
  3907. this.end = props.end;
  3908. }
  3909. this.flags = 0;
  3910. },
  3911. {
  3912. $documentation: "Base class for functions",
  3913. $propdoc: {
  3914. name: "[AST_SymbolDeclaration?] the name of this function",
  3915. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3916. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3917. is_generator: "[boolean] is this a generator method",
  3918. async: "[boolean] is this method async",
  3919. },
  3920. args_as_names: function () {
  3921. var out = [];
  3922. for (var i = 0; i < this.argnames.length; i++) {
  3923. if (this.argnames[i] instanceof AST_Destructuring) {
  3924. out.push(...this.argnames[i].all_symbols());
  3925. } else {
  3926. out.push(this.argnames[i]);
  3927. }
  3928. }
  3929. return out;
  3930. },
  3931. _walk: function(visitor) {
  3932. return visitor._visit(this, function() {
  3933. if (this.name) this.name._walk(visitor);
  3934. var argnames = this.argnames;
  3935. for (var i = 0, len = argnames.length; i < len; i++) {
  3936. argnames[i]._walk(visitor);
  3937. }
  3938. walk_body(this, visitor);
  3939. });
  3940. },
  3941. _children_backwards(push) {
  3942. let i = this.body.length;
  3943. while (i--) push(this.body[i]);
  3944. i = this.argnames.length;
  3945. while (i--) push(this.argnames[i]);
  3946. if (this.name) push(this.name);
  3947. },
  3948. is_braceless() {
  3949. return this.body[0] instanceof AST_Return && this.body[0].value;
  3950. },
  3951. // Default args and expansion don't count, so .argnames.length doesn't cut it
  3952. length_property() {
  3953. let length = 0;
  3954. for (const arg of this.argnames) {
  3955. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  3956. length++;
  3957. }
  3958. }
  3959. return length;
  3960. }
  3961. },
  3962. AST_Scope
  3963. );
  3964. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  3965. if (props) {
  3966. this.name = props.name;
  3967. this.argnames = props.argnames;
  3968. this.uses_arguments = props.uses_arguments;
  3969. this.is_generator = props.is_generator;
  3970. this.async = props.async;
  3971. this.variables = props.variables;
  3972. this.uses_with = props.uses_with;
  3973. this.uses_eval = props.uses_eval;
  3974. this.parent_scope = props.parent_scope;
  3975. this.enclosed = props.enclosed;
  3976. this.cname = props.cname;
  3977. this.body = props.body;
  3978. this.block_scope = props.block_scope;
  3979. this.start = props.start;
  3980. this.end = props.end;
  3981. }
  3982. this.flags = 0;
  3983. }, {
  3984. $documentation: "A setter/getter function. The `name` property is always null."
  3985. }, AST_Lambda);
  3986. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  3987. if (props) {
  3988. this.name = props.name;
  3989. this.argnames = props.argnames;
  3990. this.uses_arguments = props.uses_arguments;
  3991. this.is_generator = props.is_generator;
  3992. this.async = props.async;
  3993. this.variables = props.variables;
  3994. this.uses_with = props.uses_with;
  3995. this.uses_eval = props.uses_eval;
  3996. this.parent_scope = props.parent_scope;
  3997. this.enclosed = props.enclosed;
  3998. this.cname = props.cname;
  3999. this.body = props.body;
  4000. this.block_scope = props.block_scope;
  4001. this.start = props.start;
  4002. this.end = props.end;
  4003. }
  4004. this.flags = 0;
  4005. }, {
  4006. $documentation: "A function expression"
  4007. }, AST_Lambda);
  4008. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  4009. if (props) {
  4010. this.name = props.name;
  4011. this.argnames = props.argnames;
  4012. this.uses_arguments = props.uses_arguments;
  4013. this.is_generator = props.is_generator;
  4014. this.async = props.async;
  4015. this.variables = props.variables;
  4016. this.uses_with = props.uses_with;
  4017. this.uses_eval = props.uses_eval;
  4018. this.parent_scope = props.parent_scope;
  4019. this.enclosed = props.enclosed;
  4020. this.cname = props.cname;
  4021. this.body = props.body;
  4022. this.block_scope = props.block_scope;
  4023. this.start = props.start;
  4024. this.end = props.end;
  4025. }
  4026. this.flags = 0;
  4027. }, {
  4028. $documentation: "An ES6 Arrow function ((a) => b)"
  4029. }, AST_Lambda);
  4030. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  4031. if (props) {
  4032. this.name = props.name;
  4033. this.argnames = props.argnames;
  4034. this.uses_arguments = props.uses_arguments;
  4035. this.is_generator = props.is_generator;
  4036. this.async = props.async;
  4037. this.variables = props.variables;
  4038. this.uses_with = props.uses_with;
  4039. this.uses_eval = props.uses_eval;
  4040. this.parent_scope = props.parent_scope;
  4041. this.enclosed = props.enclosed;
  4042. this.cname = props.cname;
  4043. this.body = props.body;
  4044. this.block_scope = props.block_scope;
  4045. this.start = props.start;
  4046. this.end = props.end;
  4047. }
  4048. this.flags = 0;
  4049. }, {
  4050. $documentation: "A function definition"
  4051. }, AST_Lambda);
  4052. /* -----[ DESTRUCTURING ]----- */
  4053. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  4054. if (props) {
  4055. this.names = props.names;
  4056. this.is_array = props.is_array;
  4057. this.start = props.start;
  4058. this.end = props.end;
  4059. }
  4060. this.flags = 0;
  4061. }, {
  4062. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  4063. $propdoc: {
  4064. "names": "[AST_Node*] Array of properties or elements",
  4065. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  4066. },
  4067. _walk: function(visitor) {
  4068. return visitor._visit(this, function() {
  4069. this.names.forEach(function(name) {
  4070. name._walk(visitor);
  4071. });
  4072. });
  4073. },
  4074. _children_backwards(push) {
  4075. let i = this.names.length;
  4076. while (i--) push(this.names[i]);
  4077. },
  4078. all_symbols: function() {
  4079. var out = [];
  4080. walk(this, node => {
  4081. if (node instanceof AST_SymbolDeclaration) {
  4082. out.push(node);
  4083. }
  4084. if (node instanceof AST_Lambda) {
  4085. return true;
  4086. }
  4087. });
  4088. return out;
  4089. }
  4090. });
  4091. var AST_PrefixedTemplateString = DEFNODE(
  4092. "PrefixedTemplateString",
  4093. "template_string prefix",
  4094. function AST_PrefixedTemplateString(props) {
  4095. if (props) {
  4096. this.template_string = props.template_string;
  4097. this.prefix = props.prefix;
  4098. this.start = props.start;
  4099. this.end = props.end;
  4100. }
  4101. this.flags = 0;
  4102. },
  4103. {
  4104. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  4105. $propdoc: {
  4106. template_string: "[AST_TemplateString] The template string",
  4107. prefix: "[AST_Node] The prefix, which will get called."
  4108. },
  4109. _walk: function(visitor) {
  4110. return visitor._visit(this, function () {
  4111. this.prefix._walk(visitor);
  4112. this.template_string._walk(visitor);
  4113. });
  4114. },
  4115. _children_backwards(push) {
  4116. push(this.template_string);
  4117. push(this.prefix);
  4118. },
  4119. }
  4120. );
  4121. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  4122. if (props) {
  4123. this.segments = props.segments;
  4124. this.start = props.start;
  4125. this.end = props.end;
  4126. }
  4127. this.flags = 0;
  4128. }, {
  4129. $documentation: "A template string literal",
  4130. $propdoc: {
  4131. 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."
  4132. },
  4133. _walk: function(visitor) {
  4134. return visitor._visit(this, function() {
  4135. this.segments.forEach(function(seg) {
  4136. seg._walk(visitor);
  4137. });
  4138. });
  4139. },
  4140. _children_backwards(push) {
  4141. let i = this.segments.length;
  4142. while (i--) push(this.segments[i]);
  4143. }
  4144. });
  4145. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  4146. if (props) {
  4147. this.value = props.value;
  4148. this.raw = props.raw;
  4149. this.start = props.start;
  4150. this.end = props.end;
  4151. }
  4152. this.flags = 0;
  4153. }, {
  4154. $documentation: "A segment of a template string literal",
  4155. $propdoc: {
  4156. value: "Content of the segment",
  4157. raw: "Raw source of the segment",
  4158. }
  4159. });
  4160. /* -----[ JUMPS ]----- */
  4161. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  4162. if (props) {
  4163. this.start = props.start;
  4164. this.end = props.end;
  4165. }
  4166. this.flags = 0;
  4167. }, {
  4168. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  4169. }, AST_Statement);
  4170. /** Base class for “exits” (`return` and `throw`) */
  4171. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  4172. if (props) {
  4173. this.value = props.value;
  4174. this.start = props.start;
  4175. this.end = props.end;
  4176. }
  4177. this.flags = 0;
  4178. }, {
  4179. $documentation: "Base class for “exits” (`return` and `throw`)",
  4180. $propdoc: {
  4181. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  4182. },
  4183. _walk: function(visitor) {
  4184. return visitor._visit(this, this.value && function() {
  4185. this.value._walk(visitor);
  4186. });
  4187. },
  4188. _children_backwards(push) {
  4189. if (this.value) push(this.value);
  4190. },
  4191. }, AST_Jump);
  4192. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  4193. if (props) {
  4194. this.value = props.value;
  4195. this.start = props.start;
  4196. this.end = props.end;
  4197. }
  4198. this.flags = 0;
  4199. }, {
  4200. $documentation: "A `return` statement"
  4201. }, AST_Exit);
  4202. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  4203. if (props) {
  4204. this.value = props.value;
  4205. this.start = props.start;
  4206. this.end = props.end;
  4207. }
  4208. this.flags = 0;
  4209. }, {
  4210. $documentation: "A `throw` statement"
  4211. }, AST_Exit);
  4212. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  4213. if (props) {
  4214. this.label = props.label;
  4215. this.start = props.start;
  4216. this.end = props.end;
  4217. }
  4218. this.flags = 0;
  4219. }, {
  4220. $documentation: "Base class for loop control statements (`break` and `continue`)",
  4221. $propdoc: {
  4222. label: "[AST_LabelRef?] the label, or null if none",
  4223. },
  4224. _walk: function(visitor) {
  4225. return visitor._visit(this, this.label && function() {
  4226. this.label._walk(visitor);
  4227. });
  4228. },
  4229. _children_backwards(push) {
  4230. if (this.label) push(this.label);
  4231. },
  4232. }, AST_Jump);
  4233. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  4234. if (props) {
  4235. this.label = props.label;
  4236. this.start = props.start;
  4237. this.end = props.end;
  4238. }
  4239. this.flags = 0;
  4240. }, {
  4241. $documentation: "A `break` statement"
  4242. }, AST_LoopControl);
  4243. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  4244. if (props) {
  4245. this.label = props.label;
  4246. this.start = props.start;
  4247. this.end = props.end;
  4248. }
  4249. this.flags = 0;
  4250. }, {
  4251. $documentation: "A `continue` statement"
  4252. }, AST_LoopControl);
  4253. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  4254. if (props) {
  4255. this.expression = props.expression;
  4256. this.start = props.start;
  4257. this.end = props.end;
  4258. }
  4259. this.flags = 0;
  4260. }, {
  4261. $documentation: "An `await` statement",
  4262. $propdoc: {
  4263. expression: "[AST_Node] the mandatory expression being awaited",
  4264. },
  4265. _walk: function(visitor) {
  4266. return visitor._visit(this, function() {
  4267. this.expression._walk(visitor);
  4268. });
  4269. },
  4270. _children_backwards(push) {
  4271. push(this.expression);
  4272. },
  4273. });
  4274. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  4275. if (props) {
  4276. this.expression = props.expression;
  4277. this.is_star = props.is_star;
  4278. this.start = props.start;
  4279. this.end = props.end;
  4280. }
  4281. this.flags = 0;
  4282. }, {
  4283. $documentation: "A `yield` statement",
  4284. $propdoc: {
  4285. 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",
  4286. is_star: "[Boolean] Whether this is a yield or yield* statement"
  4287. },
  4288. _walk: function(visitor) {
  4289. return visitor._visit(this, this.expression && function() {
  4290. this.expression._walk(visitor);
  4291. });
  4292. },
  4293. _children_backwards(push) {
  4294. if (this.expression) push(this.expression);
  4295. }
  4296. });
  4297. /* -----[ IF ]----- */
  4298. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  4299. if (props) {
  4300. this.condition = props.condition;
  4301. this.alternative = props.alternative;
  4302. this.body = props.body;
  4303. this.start = props.start;
  4304. this.end = props.end;
  4305. }
  4306. this.flags = 0;
  4307. }, {
  4308. $documentation: "A `if` statement",
  4309. $propdoc: {
  4310. condition: "[AST_Node] the `if` condition",
  4311. alternative: "[AST_Statement?] the `else` part, or null if not present"
  4312. },
  4313. _walk: function(visitor) {
  4314. return visitor._visit(this, function() {
  4315. this.condition._walk(visitor);
  4316. this.body._walk(visitor);
  4317. if (this.alternative) this.alternative._walk(visitor);
  4318. });
  4319. },
  4320. _children_backwards(push) {
  4321. if (this.alternative) {
  4322. push(this.alternative);
  4323. }
  4324. push(this.body);
  4325. push(this.condition);
  4326. }
  4327. }, AST_StatementWithBody);
  4328. /* -----[ SWITCH ]----- */
  4329. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  4330. if (props) {
  4331. this.expression = props.expression;
  4332. this.body = props.body;
  4333. this.block_scope = props.block_scope;
  4334. this.start = props.start;
  4335. this.end = props.end;
  4336. }
  4337. this.flags = 0;
  4338. }, {
  4339. $documentation: "A `switch` statement",
  4340. $propdoc: {
  4341. expression: "[AST_Node] the `switch` “discriminant”"
  4342. },
  4343. _walk: function(visitor) {
  4344. return visitor._visit(this, function() {
  4345. this.expression._walk(visitor);
  4346. walk_body(this, visitor);
  4347. });
  4348. },
  4349. _children_backwards(push) {
  4350. let i = this.body.length;
  4351. while (i--) push(this.body[i]);
  4352. push(this.expression);
  4353. }
  4354. }, AST_Block);
  4355. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  4356. if (props) {
  4357. this.body = props.body;
  4358. this.block_scope = props.block_scope;
  4359. this.start = props.start;
  4360. this.end = props.end;
  4361. }
  4362. this.flags = 0;
  4363. }, {
  4364. $documentation: "Base class for `switch` branches",
  4365. }, AST_Block);
  4366. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  4367. if (props) {
  4368. this.body = props.body;
  4369. this.block_scope = props.block_scope;
  4370. this.start = props.start;
  4371. this.end = props.end;
  4372. }
  4373. this.flags = 0;
  4374. }, {
  4375. $documentation: "A `default` switch branch",
  4376. }, AST_SwitchBranch);
  4377. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  4378. if (props) {
  4379. this.expression = props.expression;
  4380. this.body = props.body;
  4381. this.block_scope = props.block_scope;
  4382. this.start = props.start;
  4383. this.end = props.end;
  4384. }
  4385. this.flags = 0;
  4386. }, {
  4387. $documentation: "A `case` switch branch",
  4388. $propdoc: {
  4389. expression: "[AST_Node] the `case` expression"
  4390. },
  4391. _walk: function(visitor) {
  4392. return visitor._visit(this, function() {
  4393. this.expression._walk(visitor);
  4394. walk_body(this, visitor);
  4395. });
  4396. },
  4397. _children_backwards(push) {
  4398. let i = this.body.length;
  4399. while (i--) push(this.body[i]);
  4400. push(this.expression);
  4401. },
  4402. }, AST_SwitchBranch);
  4403. /* -----[ EXCEPTIONS ]----- */
  4404. var AST_Try = DEFNODE("Try", "body bcatch bfinally", function AST_Try(props) {
  4405. if (props) {
  4406. this.body = props.body;
  4407. this.bcatch = props.bcatch;
  4408. this.bfinally = props.bfinally;
  4409. this.start = props.start;
  4410. this.end = props.end;
  4411. }
  4412. this.flags = 0;
  4413. }, {
  4414. $documentation: "A `try` statement",
  4415. $propdoc: {
  4416. body: "[AST_TryBlock] the try block",
  4417. bcatch: "[AST_Catch?] the catch block, or null if not present",
  4418. bfinally: "[AST_Finally?] the finally block, or null if not present"
  4419. },
  4420. _walk: function(visitor) {
  4421. return visitor._visit(this, function() {
  4422. this.body._walk(visitor);
  4423. if (this.bcatch) this.bcatch._walk(visitor);
  4424. if (this.bfinally) this.bfinally._walk(visitor);
  4425. });
  4426. },
  4427. _children_backwards(push) {
  4428. if (this.bfinally) push(this.bfinally);
  4429. if (this.bcatch) push(this.bcatch);
  4430. push(this.body);
  4431. },
  4432. }, AST_Statement);
  4433. var AST_TryBlock = DEFNODE("TryBlock", null, function AST_TryBlock(props) {
  4434. if (props) {
  4435. this.body = props.body;
  4436. this.block_scope = props.block_scope;
  4437. this.start = props.start;
  4438. this.end = props.end;
  4439. }
  4440. this.flags = 0;
  4441. }, {
  4442. $documentation: "The `try` block of a try statement"
  4443. }, AST_Block);
  4444. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  4445. if (props) {
  4446. this.argname = props.argname;
  4447. this.body = props.body;
  4448. this.block_scope = props.block_scope;
  4449. this.start = props.start;
  4450. this.end = props.end;
  4451. }
  4452. this.flags = 0;
  4453. }, {
  4454. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  4455. $propdoc: {
  4456. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  4457. },
  4458. _walk: function(visitor) {
  4459. return visitor._visit(this, function() {
  4460. if (this.argname) this.argname._walk(visitor);
  4461. walk_body(this, visitor);
  4462. });
  4463. },
  4464. _children_backwards(push) {
  4465. let i = this.body.length;
  4466. while (i--) push(this.body[i]);
  4467. if (this.argname) push(this.argname);
  4468. },
  4469. }, AST_Block);
  4470. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  4471. if (props) {
  4472. this.body = props.body;
  4473. this.block_scope = props.block_scope;
  4474. this.start = props.start;
  4475. this.end = props.end;
  4476. }
  4477. this.flags = 0;
  4478. }, {
  4479. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  4480. }, AST_Block);
  4481. /* -----[ VAR/CONST ]----- */
  4482. var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
  4483. if (props) {
  4484. this.definitions = props.definitions;
  4485. this.start = props.start;
  4486. this.end = props.end;
  4487. }
  4488. this.flags = 0;
  4489. }, {
  4490. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  4491. $propdoc: {
  4492. definitions: "[AST_VarDef*] array of variable definitions"
  4493. },
  4494. _walk: function(visitor) {
  4495. return visitor._visit(this, function() {
  4496. var definitions = this.definitions;
  4497. for (var i = 0, len = definitions.length; i < len; i++) {
  4498. definitions[i]._walk(visitor);
  4499. }
  4500. });
  4501. },
  4502. _children_backwards(push) {
  4503. let i = this.definitions.length;
  4504. while (i--) push(this.definitions[i]);
  4505. },
  4506. }, AST_Statement);
  4507. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  4508. if (props) {
  4509. this.definitions = props.definitions;
  4510. this.start = props.start;
  4511. this.end = props.end;
  4512. }
  4513. this.flags = 0;
  4514. }, {
  4515. $documentation: "A `var` statement"
  4516. }, AST_Definitions);
  4517. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  4518. if (props) {
  4519. this.definitions = props.definitions;
  4520. this.start = props.start;
  4521. this.end = props.end;
  4522. }
  4523. this.flags = 0;
  4524. }, {
  4525. $documentation: "A `let` statement"
  4526. }, AST_Definitions);
  4527. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  4528. if (props) {
  4529. this.definitions = props.definitions;
  4530. this.start = props.start;
  4531. this.end = props.end;
  4532. }
  4533. this.flags = 0;
  4534. }, {
  4535. $documentation: "A `const` statement"
  4536. }, AST_Definitions);
  4537. var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
  4538. if (props) {
  4539. this.name = props.name;
  4540. this.value = props.value;
  4541. this.start = props.start;
  4542. this.end = props.end;
  4543. }
  4544. this.flags = 0;
  4545. }, {
  4546. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  4547. $propdoc: {
  4548. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  4549. value: "[AST_Node?] initializer, or null of there's no initializer"
  4550. },
  4551. _walk: function(visitor) {
  4552. return visitor._visit(this, function() {
  4553. this.name._walk(visitor);
  4554. if (this.value) this.value._walk(visitor);
  4555. });
  4556. },
  4557. _children_backwards(push) {
  4558. if (this.value) push(this.value);
  4559. push(this.name);
  4560. },
  4561. declarations_as_names() {
  4562. if (this.name instanceof AST_SymbolDeclaration) {
  4563. return [this];
  4564. } else {
  4565. return this.name.all_symbols();
  4566. }
  4567. }
  4568. });
  4569. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  4570. if (props) {
  4571. this.foreign_name = props.foreign_name;
  4572. this.name = props.name;
  4573. this.start = props.start;
  4574. this.end = props.end;
  4575. }
  4576. this.flags = 0;
  4577. }, {
  4578. $documentation: "The part of the export/import statement that declare names from a module.",
  4579. $propdoc: {
  4580. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  4581. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  4582. },
  4583. _walk: function (visitor) {
  4584. return visitor._visit(this, function() {
  4585. this.foreign_name._walk(visitor);
  4586. this.name._walk(visitor);
  4587. });
  4588. },
  4589. _children_backwards(push) {
  4590. push(this.name);
  4591. push(this.foreign_name);
  4592. },
  4593. });
  4594. var AST_Import = DEFNODE(
  4595. "Import",
  4596. "imported_name imported_names module_name attributes",
  4597. function AST_Import(props) {
  4598. if (props) {
  4599. this.imported_name = props.imported_name;
  4600. this.imported_names = props.imported_names;
  4601. this.module_name = props.module_name;
  4602. this.attributes = props.attributes;
  4603. this.start = props.start;
  4604. this.end = props.end;
  4605. }
  4606. this.flags = 0;
  4607. },
  4608. {
  4609. $documentation: "An `import` statement",
  4610. $propdoc: {
  4611. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  4612. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  4613. module_name: "[AST_String] String literal describing where this module came from",
  4614. attributes: "[AST_Object?] The import attributes (with {...})"
  4615. },
  4616. _walk: function(visitor) {
  4617. return visitor._visit(this, function() {
  4618. if (this.imported_name) {
  4619. this.imported_name._walk(visitor);
  4620. }
  4621. if (this.imported_names) {
  4622. this.imported_names.forEach(function(name_import) {
  4623. name_import._walk(visitor);
  4624. });
  4625. }
  4626. this.module_name._walk(visitor);
  4627. });
  4628. },
  4629. _children_backwards(push) {
  4630. push(this.module_name);
  4631. if (this.imported_names) {
  4632. let i = this.imported_names.length;
  4633. while (i--) push(this.imported_names[i]);
  4634. }
  4635. if (this.imported_name) push(this.imported_name);
  4636. },
  4637. }
  4638. );
  4639. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  4640. if (props) {
  4641. this.start = props.start;
  4642. this.end = props.end;
  4643. }
  4644. this.flags = 0;
  4645. }, {
  4646. $documentation: "A reference to import.meta",
  4647. });
  4648. var AST_Export = DEFNODE(
  4649. "Export",
  4650. "exported_definition exported_value is_default exported_names module_name attributes",
  4651. function AST_Export(props) {
  4652. if (props) {
  4653. this.exported_definition = props.exported_definition;
  4654. this.exported_value = props.exported_value;
  4655. this.is_default = props.is_default;
  4656. this.exported_names = props.exported_names;
  4657. this.module_name = props.module_name;
  4658. this.attributes = props.attributes;
  4659. this.start = props.start;
  4660. this.end = props.end;
  4661. }
  4662. this.flags = 0;
  4663. },
  4664. {
  4665. $documentation: "An `export` statement",
  4666. $propdoc: {
  4667. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  4668. exported_value: "[AST_Node?] An exported value",
  4669. exported_names: "[AST_NameMapping*?] List of exported names",
  4670. module_name: "[AST_String?] Name of the file to load exports from",
  4671. is_default: "[Boolean] Whether this is the default exported value of this module",
  4672. attributes: "[AST_Object?] The import attributes"
  4673. },
  4674. _walk: function (visitor) {
  4675. return visitor._visit(this, function () {
  4676. if (this.exported_definition) {
  4677. this.exported_definition._walk(visitor);
  4678. }
  4679. if (this.exported_value) {
  4680. this.exported_value._walk(visitor);
  4681. }
  4682. if (this.exported_names) {
  4683. this.exported_names.forEach(function(name_export) {
  4684. name_export._walk(visitor);
  4685. });
  4686. }
  4687. if (this.module_name) {
  4688. this.module_name._walk(visitor);
  4689. }
  4690. });
  4691. },
  4692. _children_backwards(push) {
  4693. if (this.module_name) push(this.module_name);
  4694. if (this.exported_names) {
  4695. let i = this.exported_names.length;
  4696. while (i--) push(this.exported_names[i]);
  4697. }
  4698. if (this.exported_value) push(this.exported_value);
  4699. if (this.exported_definition) push(this.exported_definition);
  4700. }
  4701. },
  4702. AST_Statement
  4703. );
  4704. /* -----[ OTHER ]----- */
  4705. var AST_Call = DEFNODE(
  4706. "Call",
  4707. "expression args optional _annotations",
  4708. function AST_Call(props) {
  4709. if (props) {
  4710. this.expression = props.expression;
  4711. this.args = props.args;
  4712. this.optional = props.optional;
  4713. this._annotations = props._annotations;
  4714. this.start = props.start;
  4715. this.end = props.end;
  4716. this.initialize();
  4717. }
  4718. this.flags = 0;
  4719. },
  4720. {
  4721. $documentation: "A function call expression",
  4722. $propdoc: {
  4723. expression: "[AST_Node] expression to invoke as function",
  4724. args: "[AST_Node*] array of arguments",
  4725. optional: "[boolean] whether this is an optional call (IE ?.() )",
  4726. _annotations: "[number] bitfield containing information about the call"
  4727. },
  4728. initialize() {
  4729. if (this._annotations == null) this._annotations = 0;
  4730. },
  4731. _walk(visitor) {
  4732. return visitor._visit(this, function() {
  4733. var args = this.args;
  4734. for (var i = 0, len = args.length; i < len; i++) {
  4735. args[i]._walk(visitor);
  4736. }
  4737. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  4738. });
  4739. },
  4740. _children_backwards(push) {
  4741. let i = this.args.length;
  4742. while (i--) push(this.args[i]);
  4743. push(this.expression);
  4744. },
  4745. }
  4746. );
  4747. var AST_New = DEFNODE("New", null, function AST_New(props) {
  4748. if (props) {
  4749. this.expression = props.expression;
  4750. this.args = props.args;
  4751. this.optional = props.optional;
  4752. this._annotations = props._annotations;
  4753. this.start = props.start;
  4754. this.end = props.end;
  4755. this.initialize();
  4756. }
  4757. this.flags = 0;
  4758. }, {
  4759. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  4760. }, AST_Call);
  4761. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  4762. if (props) {
  4763. this.expressions = props.expressions;
  4764. this.start = props.start;
  4765. this.end = props.end;
  4766. }
  4767. this.flags = 0;
  4768. }, {
  4769. $documentation: "A sequence expression (comma-separated expressions)",
  4770. $propdoc: {
  4771. expressions: "[AST_Node*] array of expressions (at least two)"
  4772. },
  4773. _walk: function(visitor) {
  4774. return visitor._visit(this, function() {
  4775. this.expressions.forEach(function(node) {
  4776. node._walk(visitor);
  4777. });
  4778. });
  4779. },
  4780. _children_backwards(push) {
  4781. let i = this.expressions.length;
  4782. while (i--) push(this.expressions[i]);
  4783. },
  4784. });
  4785. var AST_PropAccess = DEFNODE(
  4786. "PropAccess",
  4787. "expression property optional",
  4788. function AST_PropAccess(props) {
  4789. if (props) {
  4790. this.expression = props.expression;
  4791. this.property = props.property;
  4792. this.optional = props.optional;
  4793. this.start = props.start;
  4794. this.end = props.end;
  4795. }
  4796. this.flags = 0;
  4797. },
  4798. {
  4799. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  4800. $propdoc: {
  4801. expression: "[AST_Node] the “container” expression",
  4802. 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",
  4803. optional: "[boolean] whether this is an optional property access (IE ?.)"
  4804. }
  4805. }
  4806. );
  4807. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  4808. if (props) {
  4809. this.quote = props.quote;
  4810. this.expression = props.expression;
  4811. this.property = props.property;
  4812. this.optional = props.optional;
  4813. this._annotations = props._annotations;
  4814. this.start = props.start;
  4815. this.end = props.end;
  4816. }
  4817. this.flags = 0;
  4818. }, {
  4819. $documentation: "A dotted property access expression",
  4820. $propdoc: {
  4821. quote: "[string] the original quote character when transformed from AST_Sub",
  4822. },
  4823. _walk: function(visitor) {
  4824. return visitor._visit(this, function() {
  4825. this.expression._walk(visitor);
  4826. });
  4827. },
  4828. _children_backwards(push) {
  4829. push(this.expression);
  4830. },
  4831. }, AST_PropAccess);
  4832. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  4833. if (props) {
  4834. this.expression = props.expression;
  4835. this.property = props.property;
  4836. this.optional = props.optional;
  4837. this.start = props.start;
  4838. this.end = props.end;
  4839. }
  4840. this.flags = 0;
  4841. }, {
  4842. $documentation: "A dotted property access to a private property",
  4843. _walk: function(visitor) {
  4844. return visitor._visit(this, function() {
  4845. this.expression._walk(visitor);
  4846. });
  4847. },
  4848. _children_backwards(push) {
  4849. push(this.expression);
  4850. },
  4851. }, AST_PropAccess);
  4852. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  4853. if (props) {
  4854. this.expression = props.expression;
  4855. this.property = props.property;
  4856. this.optional = props.optional;
  4857. this._annotations = props._annotations;
  4858. this.start = props.start;
  4859. this.end = props.end;
  4860. }
  4861. this.flags = 0;
  4862. }, {
  4863. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4864. _walk: function(visitor) {
  4865. return visitor._visit(this, function() {
  4866. this.expression._walk(visitor);
  4867. this.property._walk(visitor);
  4868. });
  4869. },
  4870. _children_backwards(push) {
  4871. push(this.property);
  4872. push(this.expression);
  4873. },
  4874. }, AST_PropAccess);
  4875. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  4876. if (props) {
  4877. this.expression = props.expression;
  4878. this.start = props.start;
  4879. this.end = props.end;
  4880. }
  4881. this.flags = 0;
  4882. }, {
  4883. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4884. $propdoc: {
  4885. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  4886. },
  4887. _walk: function (visitor) {
  4888. return visitor._visit(this, function() {
  4889. this.expression._walk(visitor);
  4890. });
  4891. },
  4892. _children_backwards(push) {
  4893. push(this.expression);
  4894. },
  4895. });
  4896. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  4897. if (props) {
  4898. this.operator = props.operator;
  4899. this.expression = props.expression;
  4900. this.start = props.start;
  4901. this.end = props.end;
  4902. }
  4903. this.flags = 0;
  4904. }, {
  4905. $documentation: "Base class for unary expressions",
  4906. $propdoc: {
  4907. operator: "[string] the operator",
  4908. expression: "[AST_Node] expression that this unary operator applies to"
  4909. },
  4910. _walk: function(visitor) {
  4911. return visitor._visit(this, function() {
  4912. this.expression._walk(visitor);
  4913. });
  4914. },
  4915. _children_backwards(push) {
  4916. push(this.expression);
  4917. },
  4918. });
  4919. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  4920. if (props) {
  4921. this.operator = props.operator;
  4922. this.expression = props.expression;
  4923. this.start = props.start;
  4924. this.end = props.end;
  4925. }
  4926. this.flags = 0;
  4927. }, {
  4928. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4929. }, AST_Unary);
  4930. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  4931. if (props) {
  4932. this.operator = props.operator;
  4933. this.expression = props.expression;
  4934. this.start = props.start;
  4935. this.end = props.end;
  4936. }
  4937. this.flags = 0;
  4938. }, {
  4939. $documentation: "Unary postfix expression, i.e. `i++`"
  4940. }, AST_Unary);
  4941. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  4942. if (props) {
  4943. this.operator = props.operator;
  4944. this.left = props.left;
  4945. this.right = props.right;
  4946. this.start = props.start;
  4947. this.end = props.end;
  4948. }
  4949. this.flags = 0;
  4950. }, {
  4951. $documentation: "Binary expression, i.e. `a + b`",
  4952. $propdoc: {
  4953. left: "[AST_Node] left-hand side expression",
  4954. operator: "[string] the operator",
  4955. right: "[AST_Node] right-hand side expression"
  4956. },
  4957. _walk: function(visitor) {
  4958. return visitor._visit(this, function() {
  4959. this.left._walk(visitor);
  4960. this.right._walk(visitor);
  4961. });
  4962. },
  4963. _children_backwards(push) {
  4964. push(this.right);
  4965. push(this.left);
  4966. },
  4967. });
  4968. var AST_Conditional = DEFNODE(
  4969. "Conditional",
  4970. "condition consequent alternative",
  4971. function AST_Conditional(props) {
  4972. if (props) {
  4973. this.condition = props.condition;
  4974. this.consequent = props.consequent;
  4975. this.alternative = props.alternative;
  4976. this.start = props.start;
  4977. this.end = props.end;
  4978. }
  4979. this.flags = 0;
  4980. },
  4981. {
  4982. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  4983. $propdoc: {
  4984. condition: "[AST_Node]",
  4985. consequent: "[AST_Node]",
  4986. alternative: "[AST_Node]"
  4987. },
  4988. _walk: function(visitor) {
  4989. return visitor._visit(this, function() {
  4990. this.condition._walk(visitor);
  4991. this.consequent._walk(visitor);
  4992. this.alternative._walk(visitor);
  4993. });
  4994. },
  4995. _children_backwards(push) {
  4996. push(this.alternative);
  4997. push(this.consequent);
  4998. push(this.condition);
  4999. },
  5000. }
  5001. );
  5002. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  5003. if (props) {
  5004. this.logical = props.logical;
  5005. this.operator = props.operator;
  5006. this.left = props.left;
  5007. this.right = props.right;
  5008. this.start = props.start;
  5009. this.end = props.end;
  5010. }
  5011. this.flags = 0;
  5012. }, {
  5013. $documentation: "An assignment expression — `a = b + 5`",
  5014. $propdoc: {
  5015. logical: "Whether it's a logical assignment"
  5016. }
  5017. }, AST_Binary);
  5018. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  5019. if (props) {
  5020. this.operator = props.operator;
  5021. this.left = props.left;
  5022. this.right = props.right;
  5023. this.start = props.start;
  5024. this.end = props.end;
  5025. }
  5026. this.flags = 0;
  5027. }, {
  5028. $documentation: "A default assignment expression like in `(a = 3) => a`"
  5029. }, AST_Binary);
  5030. /* -----[ LITERALS ]----- */
  5031. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  5032. if (props) {
  5033. this.elements = props.elements;
  5034. this.start = props.start;
  5035. this.end = props.end;
  5036. }
  5037. this.flags = 0;
  5038. }, {
  5039. $documentation: "An array literal",
  5040. $propdoc: {
  5041. elements: "[AST_Node*] array of elements"
  5042. },
  5043. _walk: function(visitor) {
  5044. return visitor._visit(this, function() {
  5045. var elements = this.elements;
  5046. for (var i = 0, len = elements.length; i < len; i++) {
  5047. elements[i]._walk(visitor);
  5048. }
  5049. });
  5050. },
  5051. _children_backwards(push) {
  5052. let i = this.elements.length;
  5053. while (i--) push(this.elements[i]);
  5054. },
  5055. });
  5056. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  5057. if (props) {
  5058. this.properties = props.properties;
  5059. this.start = props.start;
  5060. this.end = props.end;
  5061. }
  5062. this.flags = 0;
  5063. }, {
  5064. $documentation: "An object literal",
  5065. $propdoc: {
  5066. properties: "[AST_ObjectProperty*] array of properties"
  5067. },
  5068. _walk: function(visitor) {
  5069. return visitor._visit(this, function() {
  5070. var properties = this.properties;
  5071. for (var i = 0, len = properties.length; i < len; i++) {
  5072. properties[i]._walk(visitor);
  5073. }
  5074. });
  5075. },
  5076. _children_backwards(push) {
  5077. let i = this.properties.length;
  5078. while (i--) push(this.properties[i]);
  5079. },
  5080. });
  5081. /* -----[ OBJECT/CLASS PROPERTIES ]----- */
  5082. /**
  5083. * Everything inside the curly braces of an object/class is a subclass of AST_ObjectProperty, except for AST_ClassStaticBlock.
  5084. **/
  5085. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  5086. if (props) {
  5087. this.key = props.key;
  5088. this.value = props.value;
  5089. this.start = props.start;
  5090. this.end = props.end;
  5091. this._annotations = props._annotations;
  5092. }
  5093. this.flags = 0;
  5094. }, {
  5095. $documentation: "Base class for literal object properties",
  5096. $propdoc: {
  5097. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  5098. value: "[AST_Node] property value. For getters, setters and methods this is an AST_Accessor."
  5099. },
  5100. _walk: function(visitor) {
  5101. return visitor._visit(this, function() {
  5102. if (this.key instanceof AST_Node)
  5103. this.key._walk(visitor);
  5104. this.value._walk(visitor);
  5105. });
  5106. },
  5107. _children_backwards(push) {
  5108. push(this.value);
  5109. if (this.key instanceof AST_Node) push(this.key);
  5110. },
  5111. });
  5112. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  5113. if (props) {
  5114. this.quote = props.quote;
  5115. this.key = props.key;
  5116. this.value = props.value;
  5117. this.start = props.start;
  5118. this.end = props.end;
  5119. this._annotations = props._annotations;
  5120. }
  5121. this.flags = 0;
  5122. }, {
  5123. $documentation: "A key: value object property",
  5124. $propdoc: {
  5125. quote: "[string] the original quote character"
  5126. },
  5127. computed_key() {
  5128. return this.key instanceof AST_Node;
  5129. }
  5130. }, AST_ObjectProperty);
  5131. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  5132. if (props) {
  5133. this.static = props.static;
  5134. this.key = props.key;
  5135. this.value = props.value;
  5136. this.start = props.start;
  5137. this.end = props.end;
  5138. }
  5139. this.flags = 0;
  5140. }, {
  5141. $propdoc: {
  5142. static: "[boolean] whether this is a static private setter"
  5143. },
  5144. $documentation: "A private setter property",
  5145. computed_key() {
  5146. return false;
  5147. }
  5148. }, AST_ObjectProperty);
  5149. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(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 getter"
  5161. },
  5162. $documentation: "A private getter property",
  5163. computed_key() {
  5164. return false;
  5165. }
  5166. }, AST_ObjectProperty);
  5167. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  5168. if (props) {
  5169. this.quote = props.quote;
  5170. this.static = props.static;
  5171. this.key = props.key;
  5172. this.value = props.value;
  5173. this.start = props.start;
  5174. this.end = props.end;
  5175. this._annotations = props._annotations;
  5176. }
  5177. this.flags = 0;
  5178. }, {
  5179. $propdoc: {
  5180. quote: "[string|undefined] the original quote character, if any",
  5181. static: "[boolean] whether this is a static setter (classes only)"
  5182. },
  5183. $documentation: "An object setter property",
  5184. computed_key() {
  5185. return !(this.key instanceof AST_SymbolMethod);
  5186. }
  5187. }, AST_ObjectProperty);
  5188. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  5189. if (props) {
  5190. this.quote = props.quote;
  5191. this.static = props.static;
  5192. this.key = props.key;
  5193. this.value = props.value;
  5194. this.start = props.start;
  5195. this.end = props.end;
  5196. this._annotations = props._annotations;
  5197. }
  5198. this.flags = 0;
  5199. }, {
  5200. $propdoc: {
  5201. quote: "[string|undefined] the original quote character, if any",
  5202. static: "[boolean] whether this is a static getter (classes only)"
  5203. },
  5204. $documentation: "An object getter property",
  5205. computed_key() {
  5206. return !(this.key instanceof AST_SymbolMethod);
  5207. }
  5208. }, AST_ObjectProperty);
  5209. var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator async", function AST_ConciseMethod(props) {
  5210. if (props) {
  5211. this.quote = props.quote;
  5212. this.static = props.static;
  5213. this.is_generator = props.is_generator;
  5214. this.async = props.async;
  5215. this.key = props.key;
  5216. this.value = props.value;
  5217. this.start = props.start;
  5218. this.end = props.end;
  5219. this._annotations = props._annotations;
  5220. }
  5221. this.flags = 0;
  5222. }, {
  5223. $propdoc: {
  5224. quote: "[string|undefined] the original quote character, if any",
  5225. static: "[boolean] is this method static (classes only)",
  5226. is_generator: "[boolean] is this a generator method",
  5227. async: "[boolean] is this method async",
  5228. },
  5229. $documentation: "An ES6 concise method inside an object or class",
  5230. computed_key() {
  5231. return !(this.key instanceof AST_SymbolMethod);
  5232. }
  5233. }, AST_ObjectProperty);
  5234. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
  5235. if (props) {
  5236. this.quote = props.quote;
  5237. this.static = props.static;
  5238. this.is_generator = props.is_generator;
  5239. this.async = props.async;
  5240. this.key = props.key;
  5241. this.value = props.value;
  5242. this.start = props.start;
  5243. this.end = props.end;
  5244. }
  5245. this.flags = 0;
  5246. }, {
  5247. $documentation: "A private class method inside a class",
  5248. computed_key() {
  5249. return false;
  5250. },
  5251. }, AST_ObjectProperty);
  5252. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  5253. if (props) {
  5254. this.name = props.name;
  5255. this.extends = props.extends;
  5256. this.properties = props.properties;
  5257. this.variables = props.variables;
  5258. this.uses_with = props.uses_with;
  5259. this.uses_eval = props.uses_eval;
  5260. this.parent_scope = props.parent_scope;
  5261. this.enclosed = props.enclosed;
  5262. this.cname = props.cname;
  5263. this.body = props.body;
  5264. this.block_scope = props.block_scope;
  5265. this.start = props.start;
  5266. this.end = props.end;
  5267. }
  5268. this.flags = 0;
  5269. }, {
  5270. $propdoc: {
  5271. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  5272. extends: "[AST_Node]? optional parent class",
  5273. properties: "[AST_ObjectProperty|AST_ClassStaticBlock]* array of properties or static blocks"
  5274. },
  5275. $documentation: "An ES6 class",
  5276. _walk: function(visitor) {
  5277. return visitor._visit(this, function() {
  5278. if (this.name) {
  5279. this.name._walk(visitor);
  5280. }
  5281. if (this.extends) {
  5282. this.extends._walk(visitor);
  5283. }
  5284. this.properties.forEach((prop) => prop._walk(visitor));
  5285. });
  5286. },
  5287. _children_backwards(push) {
  5288. let i = this.properties.length;
  5289. while (i--) push(this.properties[i]);
  5290. if (this.extends) push(this.extends);
  5291. if (this.name) push(this.name);
  5292. },
  5293. /** go through the bits that are executed instantly, not when the class is `new`'d. Doesn't walk the name. */
  5294. visit_nondeferred_class_parts(visitor) {
  5295. if (this.extends) {
  5296. this.extends._walk(visitor);
  5297. }
  5298. this.properties.forEach((prop) => {
  5299. if (prop instanceof AST_ClassStaticBlock) {
  5300. prop._walk(visitor);
  5301. return;
  5302. }
  5303. if (prop.computed_key()) {
  5304. visitor.push(prop);
  5305. prop.key._walk(visitor);
  5306. visitor.pop();
  5307. }
  5308. if (
  5309. prop instanceof AST_ClassPrivateProperty && prop.static && prop.value
  5310. || prop instanceof AST_ClassProperty && prop.static && prop.value
  5311. ) {
  5312. visitor.push(prop);
  5313. prop.value._walk(visitor);
  5314. visitor.pop();
  5315. }
  5316. });
  5317. },
  5318. /** go through the bits that are executed later, when the class is `new`'d or a static method is called */
  5319. visit_deferred_class_parts(visitor) {
  5320. this.properties.forEach((prop) => {
  5321. if (
  5322. prop instanceof AST_ConciseMethod
  5323. || prop instanceof AST_PrivateMethod
  5324. ) {
  5325. prop.walk(visitor);
  5326. } else if (
  5327. prop instanceof AST_ClassProperty && !prop.static && prop.value
  5328. || prop instanceof AST_ClassPrivateProperty && !prop.static && prop.value
  5329. ) {
  5330. visitor.push(prop);
  5331. prop.value._walk(visitor);
  5332. visitor.pop();
  5333. }
  5334. });
  5335. },
  5336. is_self_referential: function() {
  5337. const this_id = this.name && this.name.definition().id;
  5338. let found = false;
  5339. let class_this = true;
  5340. this.visit_nondeferred_class_parts(new TreeWalker((node, descend) => {
  5341. if (found) return true;
  5342. if (node instanceof AST_This) return (found = class_this);
  5343. if (node instanceof AST_SymbolRef) return (found = node.definition().id === this_id);
  5344. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  5345. const class_this_save = class_this;
  5346. class_this = false;
  5347. descend();
  5348. class_this = class_this_save;
  5349. return true;
  5350. }
  5351. }));
  5352. return found;
  5353. },
  5354. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  5355. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  5356. if (props) {
  5357. this.static = props.static;
  5358. this.quote = props.quote;
  5359. this.key = props.key;
  5360. this.value = props.value;
  5361. this.start = props.start;
  5362. this.end = props.end;
  5363. this._annotations = props._annotations;
  5364. }
  5365. this.flags = 0;
  5366. }, {
  5367. $documentation: "A class property",
  5368. $propdoc: {
  5369. static: "[boolean] whether this is a static key",
  5370. quote: "[string] which quote is being used"
  5371. },
  5372. _walk: function(visitor) {
  5373. return visitor._visit(this, function() {
  5374. if (this.key instanceof AST_Node)
  5375. this.key._walk(visitor);
  5376. if (this.value instanceof AST_Node)
  5377. this.value._walk(visitor);
  5378. });
  5379. },
  5380. _children_backwards(push) {
  5381. if (this.value instanceof AST_Node) push(this.value);
  5382. if (this.key instanceof AST_Node) push(this.key);
  5383. },
  5384. computed_key() {
  5385. return !(this.key instanceof AST_SymbolClassProperty);
  5386. }
  5387. }, AST_ObjectProperty);
  5388. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  5389. if (props) {
  5390. this.static = props.static;
  5391. this.quote = props.quote;
  5392. this.key = props.key;
  5393. this.value = props.value;
  5394. this.start = props.start;
  5395. this.end = props.end;
  5396. }
  5397. this.flags = 0;
  5398. }, {
  5399. $documentation: "A class property for a private property",
  5400. _walk: function(visitor) {
  5401. return visitor._visit(this, function() {
  5402. if (this.value instanceof AST_Node)
  5403. this.value._walk(visitor);
  5404. });
  5405. },
  5406. _children_backwards(push) {
  5407. if (this.value instanceof AST_Node) push(this.value);
  5408. },
  5409. computed_key() {
  5410. return false;
  5411. },
  5412. }, AST_ObjectProperty);
  5413. var AST_PrivateIn = DEFNODE("PrivateIn", "key value", function AST_PrivateIn(props) {
  5414. if (props) {
  5415. this.key = props.key;
  5416. this.value = props.value;
  5417. this.start = props.start;
  5418. this.end = props.end;
  5419. }
  5420. this.flags = 0;
  5421. }, {
  5422. $documentation: "An `in` binop when the key is private, eg #x in this",
  5423. _walk: function(visitor) {
  5424. return visitor._visit(this, function() {
  5425. this.key._walk(visitor);
  5426. this.value._walk(visitor);
  5427. });
  5428. },
  5429. _children_backwards(push) {
  5430. push(this.value);
  5431. push(this.key);
  5432. },
  5433. });
  5434. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  5435. if (props) {
  5436. this.name = props.name;
  5437. this.extends = props.extends;
  5438. this.properties = props.properties;
  5439. this.variables = props.variables;
  5440. this.uses_with = props.uses_with;
  5441. this.uses_eval = props.uses_eval;
  5442. this.parent_scope = props.parent_scope;
  5443. this.enclosed = props.enclosed;
  5444. this.cname = props.cname;
  5445. this.body = props.body;
  5446. this.block_scope = props.block_scope;
  5447. this.start = props.start;
  5448. this.end = props.end;
  5449. }
  5450. this.flags = 0;
  5451. }, {
  5452. $documentation: "A class definition",
  5453. }, AST_Class);
  5454. var AST_ClassStaticBlock = DEFNODE("ClassStaticBlock", "body block_scope", function AST_ClassStaticBlock (props) {
  5455. this.body = props.body;
  5456. this.block_scope = props.block_scope;
  5457. this.start = props.start;
  5458. this.end = props.end;
  5459. }, {
  5460. $documentation: "A block containing statements to be executed in the context of the class",
  5461. $propdoc: {
  5462. body: "[AST_Statement*] an array of statements",
  5463. },
  5464. _walk: function(visitor) {
  5465. return visitor._visit(this, function() {
  5466. walk_body(this, visitor);
  5467. });
  5468. },
  5469. _children_backwards(push) {
  5470. let i = this.body.length;
  5471. while (i--) push(this.body[i]);
  5472. },
  5473. clone: clone_block_scope,
  5474. computed_key() {
  5475. return false;
  5476. },
  5477. }, AST_Scope);
  5478. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  5479. if (props) {
  5480. this.name = props.name;
  5481. this.extends = props.extends;
  5482. this.properties = props.properties;
  5483. this.variables = props.variables;
  5484. this.uses_with = props.uses_with;
  5485. this.uses_eval = props.uses_eval;
  5486. this.parent_scope = props.parent_scope;
  5487. this.enclosed = props.enclosed;
  5488. this.cname = props.cname;
  5489. this.body = props.body;
  5490. this.block_scope = props.block_scope;
  5491. this.start = props.start;
  5492. this.end = props.end;
  5493. }
  5494. this.flags = 0;
  5495. }, {
  5496. $documentation: "A class expression."
  5497. }, AST_Class);
  5498. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  5499. if (props) {
  5500. this.scope = props.scope;
  5501. this.name = props.name;
  5502. this.thedef = props.thedef;
  5503. this.start = props.start;
  5504. this.end = props.end;
  5505. }
  5506. this.flags = 0;
  5507. }, {
  5508. $propdoc: {
  5509. name: "[string] name of this symbol",
  5510. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  5511. thedef: "[SymbolDef/S] the definition of this symbol"
  5512. },
  5513. $documentation: "Base class for all symbols"
  5514. });
  5515. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  5516. if (props) {
  5517. this.start = props.start;
  5518. this.end = props.end;
  5519. }
  5520. this.flags = 0;
  5521. }, {
  5522. $documentation: "A reference to new.target"
  5523. });
  5524. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  5525. if (props) {
  5526. this.init = props.init;
  5527. this.scope = props.scope;
  5528. this.name = props.name;
  5529. this.thedef = props.thedef;
  5530. this.start = props.start;
  5531. this.end = props.end;
  5532. }
  5533. this.flags = 0;
  5534. }, {
  5535. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  5536. }, AST_Symbol);
  5537. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(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: "Symbol defining a variable",
  5549. }, AST_SymbolDeclaration);
  5550. var AST_SymbolBlockDeclaration = DEFNODE(
  5551. "SymbolBlockDeclaration",
  5552. null,
  5553. function AST_SymbolBlockDeclaration(props) {
  5554. if (props) {
  5555. this.init = props.init;
  5556. this.scope = props.scope;
  5557. this.name = props.name;
  5558. this.thedef = props.thedef;
  5559. this.start = props.start;
  5560. this.end = props.end;
  5561. }
  5562. this.flags = 0;
  5563. },
  5564. {
  5565. $documentation: "Base class for block-scoped declaration symbols"
  5566. },
  5567. AST_SymbolDeclaration
  5568. );
  5569. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  5570. if (props) {
  5571. this.init = props.init;
  5572. this.scope = props.scope;
  5573. this.name = props.name;
  5574. this.thedef = props.thedef;
  5575. this.start = props.start;
  5576. this.end = props.end;
  5577. }
  5578. this.flags = 0;
  5579. }, {
  5580. $documentation: "A constant declaration"
  5581. }, AST_SymbolBlockDeclaration);
  5582. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(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 block-scoped `let` declaration"
  5594. }, AST_SymbolBlockDeclaration);
  5595. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(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: "Symbol naming a function argument",
  5607. }, AST_SymbolVar);
  5608. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(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 defining a function",
  5620. }, AST_SymbolDeclaration);
  5621. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  5622. if (props) {
  5623. this.scope = props.scope;
  5624. this.name = props.name;
  5625. this.thedef = props.thedef;
  5626. this.start = props.start;
  5627. this.end = props.end;
  5628. }
  5629. this.flags = 0;
  5630. }, {
  5631. $documentation: "Symbol in an object defining a method",
  5632. }, AST_Symbol);
  5633. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  5634. if (props) {
  5635. this.scope = props.scope;
  5636. this.name = props.name;
  5637. this.thedef = props.thedef;
  5638. this.start = props.start;
  5639. this.end = props.end;
  5640. }
  5641. this.flags = 0;
  5642. }, {
  5643. $documentation: "Symbol for a class property",
  5644. }, AST_Symbol);
  5645. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  5646. if (props) {
  5647. this.init = props.init;
  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 naming a function expression",
  5657. }, AST_SymbolDeclaration);
  5658. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(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 class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  5670. }, AST_SymbolBlockDeclaration);
  5671. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(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. Lexically scoped to the class."
  5683. }, AST_SymbolDeclaration);
  5684. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(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 the exception in catch",
  5696. }, AST_SymbolBlockDeclaration);
  5697. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(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 referring to an imported name",
  5709. }, AST_SymbolBlockDeclaration);
  5710. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
  5711. if (props) {
  5712. this.scope = props.scope;
  5713. this.name = props.name;
  5714. this.thedef = props.thedef;
  5715. this.quote = props.quote;
  5716. this.start = props.start;
  5717. this.end = props.end;
  5718. }
  5719. this.flags = 0;
  5720. }, {
  5721. $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",
  5722. }, AST_Symbol);
  5723. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  5724. if (props) {
  5725. this.references = props.references;
  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. this.initialize();
  5732. }
  5733. this.flags = 0;
  5734. }, {
  5735. $documentation: "Symbol naming a label (declaration)",
  5736. $propdoc: {
  5737. references: "[AST_LoopControl*] a list of nodes referring to this label"
  5738. },
  5739. initialize: function() {
  5740. this.references = [];
  5741. this.thedef = this;
  5742. }
  5743. }, AST_Symbol);
  5744. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  5745. if (props) {
  5746. this.scope = props.scope;
  5747. this.name = props.name;
  5748. this.thedef = props.thedef;
  5749. this.start = props.start;
  5750. this.end = props.end;
  5751. }
  5752. this.flags = 0;
  5753. }, {
  5754. $documentation: "Reference to some symbol (not definition/declaration)",
  5755. }, AST_Symbol);
  5756. var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
  5757. if (props) {
  5758. this.scope = props.scope;
  5759. this.name = props.name;
  5760. this.thedef = props.thedef;
  5761. this.quote = props.quote;
  5762. this.start = props.start;
  5763. this.end = props.end;
  5764. }
  5765. this.flags = 0;
  5766. }, {
  5767. $documentation: "Symbol referring to a name to export",
  5768. }, AST_SymbolRef);
  5769. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
  5770. if (props) {
  5771. this.scope = props.scope;
  5772. this.name = props.name;
  5773. this.thedef = props.thedef;
  5774. this.quote = props.quote;
  5775. this.start = props.start;
  5776. this.end = props.end;
  5777. }
  5778. this.flags = 0;
  5779. }, {
  5780. $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",
  5781. }, AST_Symbol);
  5782. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  5783. if (props) {
  5784. this.scope = props.scope;
  5785. this.name = props.name;
  5786. this.thedef = props.thedef;
  5787. this.start = props.start;
  5788. this.end = props.end;
  5789. }
  5790. this.flags = 0;
  5791. }, {
  5792. $documentation: "Reference to a label symbol",
  5793. }, AST_Symbol);
  5794. var AST_SymbolPrivateProperty = DEFNODE("SymbolPrivateProperty", null, function AST_SymbolPrivateProperty(props) {
  5795. if (props) {
  5796. this.scope = props.scope;
  5797. this.name = props.name;
  5798. this.thedef = props.thedef;
  5799. this.start = props.start;
  5800. this.end = props.end;
  5801. }
  5802. this.flags = 0;
  5803. }, {
  5804. $documentation: "A symbol that refers to a private property",
  5805. }, AST_Symbol);
  5806. var AST_This = DEFNODE("This", null, function AST_This(props) {
  5807. if (props) {
  5808. this.scope = props.scope;
  5809. this.name = props.name;
  5810. this.thedef = props.thedef;
  5811. this.start = props.start;
  5812. this.end = props.end;
  5813. }
  5814. this.flags = 0;
  5815. }, {
  5816. $documentation: "The `this` symbol",
  5817. }, AST_Symbol);
  5818. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  5819. if (props) {
  5820. this.scope = props.scope;
  5821. this.name = props.name;
  5822. this.thedef = props.thedef;
  5823. this.start = props.start;
  5824. this.end = props.end;
  5825. }
  5826. this.flags = 0;
  5827. }, {
  5828. $documentation: "The `super` symbol",
  5829. }, AST_This);
  5830. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  5831. if (props) {
  5832. this.start = props.start;
  5833. this.end = props.end;
  5834. }
  5835. this.flags = 0;
  5836. }, {
  5837. $documentation: "Base class for all constants",
  5838. getValue: function() {
  5839. return this.value;
  5840. }
  5841. });
  5842. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  5843. if (props) {
  5844. this.value = props.value;
  5845. this.quote = props.quote;
  5846. this.start = props.start;
  5847. this.end = props.end;
  5848. this._annotations = props._annotations;
  5849. }
  5850. this.flags = 0;
  5851. }, {
  5852. $documentation: "A string literal",
  5853. $propdoc: {
  5854. value: "[string] the contents of this string",
  5855. quote: "[string] the original quote character"
  5856. }
  5857. }, AST_Constant);
  5858. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  5859. if (props) {
  5860. this.value = props.value;
  5861. this.raw = props.raw;
  5862. this.start = props.start;
  5863. this.end = props.end;
  5864. }
  5865. this.flags = 0;
  5866. }, {
  5867. $documentation: "A number literal",
  5868. $propdoc: {
  5869. value: "[number] the numeric value",
  5870. raw: "[string] numeric value as string"
  5871. }
  5872. }, AST_Constant);
  5873. var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
  5874. if (props) {
  5875. this.value = props.value;
  5876. this.start = props.start;
  5877. this.end = props.end;
  5878. }
  5879. this.flags = 0;
  5880. }, {
  5881. $documentation: "A big int literal",
  5882. $propdoc: {
  5883. value: "[string] big int value"
  5884. }
  5885. }, AST_Constant);
  5886. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  5887. if (props) {
  5888. this.value = props.value;
  5889. this.start = props.start;
  5890. this.end = props.end;
  5891. }
  5892. this.flags = 0;
  5893. }, {
  5894. $documentation: "A regexp literal",
  5895. $propdoc: {
  5896. value: "[RegExp] the actual regexp",
  5897. }
  5898. }, AST_Constant);
  5899. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  5900. if (props) {
  5901. this.start = props.start;
  5902. this.end = props.end;
  5903. }
  5904. this.flags = 0;
  5905. }, {
  5906. $documentation: "Base class for atoms",
  5907. }, AST_Constant);
  5908. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  5909. if (props) {
  5910. this.start = props.start;
  5911. this.end = props.end;
  5912. }
  5913. this.flags = 0;
  5914. }, {
  5915. $documentation: "The `null` atom",
  5916. value: null
  5917. }, AST_Atom);
  5918. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  5919. if (props) {
  5920. this.start = props.start;
  5921. this.end = props.end;
  5922. }
  5923. this.flags = 0;
  5924. }, {
  5925. $documentation: "The impossible value",
  5926. value: 0/0
  5927. }, AST_Atom);
  5928. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  5929. if (props) {
  5930. this.start = props.start;
  5931. this.end = props.end;
  5932. }
  5933. this.flags = 0;
  5934. }, {
  5935. $documentation: "The `undefined` value",
  5936. value: (function() {}())
  5937. }, AST_Atom);
  5938. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  5939. if (props) {
  5940. this.start = props.start;
  5941. this.end = props.end;
  5942. }
  5943. this.flags = 0;
  5944. }, {
  5945. $documentation: "A hole in an array",
  5946. value: (function() {}())
  5947. }, AST_Atom);
  5948. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  5949. if (props) {
  5950. this.start = props.start;
  5951. this.end = props.end;
  5952. }
  5953. this.flags = 0;
  5954. }, {
  5955. $documentation: "The `Infinity` value",
  5956. value: 1/0
  5957. }, AST_Atom);
  5958. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  5959. if (props) {
  5960. this.start = props.start;
  5961. this.end = props.end;
  5962. }
  5963. this.flags = 0;
  5964. }, {
  5965. $documentation: "Base class for booleans",
  5966. }, AST_Atom);
  5967. var AST_False = DEFNODE("False", null, function AST_False(props) {
  5968. if (props) {
  5969. this.start = props.start;
  5970. this.end = props.end;
  5971. }
  5972. this.flags = 0;
  5973. }, {
  5974. $documentation: "The `false` atom",
  5975. value: false
  5976. }, AST_Boolean);
  5977. var AST_True = DEFNODE("True", null, function AST_True(props) {
  5978. if (props) {
  5979. this.start = props.start;
  5980. this.end = props.end;
  5981. }
  5982. this.flags = 0;
  5983. }, {
  5984. $documentation: "The `true` atom",
  5985. value: true
  5986. }, AST_Boolean);
  5987. /* -----[ Walk function ]---- */
  5988. /**
  5989. * Walk nodes in depth-first search fashion.
  5990. * Callback can return `walk_abort` symbol to stop iteration.
  5991. * It can also return `true` to stop iteration just for child nodes.
  5992. * Iteration can be stopped and continued by passing the `to_visit` argument,
  5993. * which is given to the callback in the second argument.
  5994. **/
  5995. function walk(node, cb, to_visit = [node]) {
  5996. const push = to_visit.push.bind(to_visit);
  5997. while (to_visit.length) {
  5998. const node = to_visit.pop();
  5999. const ret = cb(node, to_visit);
  6000. if (ret) {
  6001. if (ret === walk_abort) return true;
  6002. continue;
  6003. }
  6004. node._children_backwards(push);
  6005. }
  6006. return false;
  6007. }
  6008. /**
  6009. * Walks an AST node and its children.
  6010. *
  6011. * {cb} can return `walk_abort` to interrupt the walk.
  6012. *
  6013. * @param node
  6014. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  6015. *
  6016. * @returns {boolean} whether the walk was aborted
  6017. *
  6018. * @example
  6019. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  6020. * if (some_cond(node, parent())) return walk_abort
  6021. * });
  6022. */
  6023. function walk_parent(node, cb, initial_stack) {
  6024. const to_visit = [node];
  6025. const push = to_visit.push.bind(to_visit);
  6026. const stack = initial_stack ? initial_stack.slice() : [];
  6027. const parent_pop_indices = [];
  6028. let current;
  6029. const info = {
  6030. parent: (n = 0) => {
  6031. if (n === -1) {
  6032. return current;
  6033. }
  6034. // [ p1 p0 ] [ 1 0 ]
  6035. if (initial_stack && n >= stack.length) {
  6036. n -= stack.length;
  6037. return initial_stack[
  6038. initial_stack.length - (n + 1)
  6039. ];
  6040. }
  6041. return stack[stack.length - (1 + n)];
  6042. },
  6043. };
  6044. while (to_visit.length) {
  6045. current = to_visit.pop();
  6046. while (
  6047. parent_pop_indices.length &&
  6048. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  6049. ) {
  6050. stack.pop();
  6051. parent_pop_indices.pop();
  6052. }
  6053. const ret = cb(current, info);
  6054. if (ret) {
  6055. if (ret === walk_abort) return true;
  6056. continue;
  6057. }
  6058. const visit_length = to_visit.length;
  6059. current._children_backwards(push);
  6060. // Push only if we're going to traverse the children
  6061. if (to_visit.length > visit_length) {
  6062. stack.push(current);
  6063. parent_pop_indices.push(visit_length - 1);
  6064. }
  6065. }
  6066. return false;
  6067. }
  6068. const walk_abort = Symbol("abort walk");
  6069. /* -----[ TreeWalker ]----- */
  6070. class TreeWalker {
  6071. constructor(callback) {
  6072. this.visit = callback;
  6073. this.stack = [];
  6074. this.directives = Object.create(null);
  6075. }
  6076. _visit(node, descend) {
  6077. this.push(node);
  6078. var ret = this.visit(node, descend ? function() {
  6079. descend.call(node);
  6080. } : noop);
  6081. if (!ret && descend) {
  6082. descend.call(node);
  6083. }
  6084. this.pop();
  6085. return ret;
  6086. }
  6087. parent(n) {
  6088. return this.stack[this.stack.length - 2 - (n || 0)];
  6089. }
  6090. push(node) {
  6091. if (node instanceof AST_Lambda) {
  6092. this.directives = Object.create(this.directives);
  6093. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  6094. this.directives[node.value] = node;
  6095. } else if (node instanceof AST_Class) {
  6096. this.directives = Object.create(this.directives);
  6097. if (!this.directives["use strict"]) {
  6098. this.directives["use strict"] = node;
  6099. }
  6100. }
  6101. this.stack.push(node);
  6102. }
  6103. pop() {
  6104. var node = this.stack.pop();
  6105. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  6106. this.directives = Object.getPrototypeOf(this.directives);
  6107. }
  6108. }
  6109. self() {
  6110. return this.stack[this.stack.length - 1];
  6111. }
  6112. find_parent(type) {
  6113. var stack = this.stack;
  6114. for (var i = stack.length; --i >= 0;) {
  6115. var x = stack[i];
  6116. if (x instanceof type) return x;
  6117. }
  6118. }
  6119. find_scope() {
  6120. var stack = this.stack;
  6121. for (var i = stack.length; --i >= 0;) {
  6122. const p = stack[i];
  6123. if (p instanceof AST_Toplevel) return p;
  6124. if (p instanceof AST_Lambda) return p;
  6125. if (p.block_scope) return p.block_scope;
  6126. }
  6127. }
  6128. has_directive(type) {
  6129. var dir = this.directives[type];
  6130. if (dir) return dir;
  6131. var node = this.stack[this.stack.length - 1];
  6132. if (node instanceof AST_Scope && node.body) {
  6133. for (var i = 0; i < node.body.length; ++i) {
  6134. var st = node.body[i];
  6135. if (!(st instanceof AST_Directive)) break;
  6136. if (st.value == type) return st;
  6137. }
  6138. }
  6139. }
  6140. loopcontrol_target(node) {
  6141. var stack = this.stack;
  6142. if (node.label) for (var i = stack.length; --i >= 0;) {
  6143. var x = stack[i];
  6144. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  6145. return x.body;
  6146. } else for (var i = stack.length; --i >= 0;) {
  6147. var x = stack[i];
  6148. if (x instanceof AST_IterationStatement
  6149. || node instanceof AST_Break && x instanceof AST_Switch)
  6150. return x;
  6151. }
  6152. }
  6153. }
  6154. // Tree transformer helpers.
  6155. class TreeTransformer extends TreeWalker {
  6156. constructor(before, after) {
  6157. super();
  6158. this.before = before;
  6159. this.after = after;
  6160. }
  6161. }
  6162. const _PURE = 0b00000001;
  6163. const _INLINE = 0b00000010;
  6164. const _NOINLINE = 0b00000100;
  6165. const _KEY = 0b00001000;
  6166. const _MANGLEPROP = 0b00010000;
  6167. /***********************************************************************
  6168. A JavaScript tokenizer / parser / beautifier / compressor.
  6169. https://github.com/mishoo/UglifyJS2
  6170. -------------------------------- (C) ---------------------------------
  6171. Author: Mihai Bazon
  6172. <mihai.bazon@gmail.com>
  6173. http://mihai.bazon.net/blog
  6174. Distributed under the BSD license:
  6175. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6176. Redistribution and use in source and binary forms, with or without
  6177. modification, are permitted provided that the following conditions
  6178. are met:
  6179. * Redistributions of source code must retain the above
  6180. copyright notice, this list of conditions and the following
  6181. disclaimer.
  6182. * Redistributions in binary form must reproduce the above
  6183. copyright notice, this list of conditions and the following
  6184. disclaimer in the documentation and/or other materials
  6185. provided with the distribution.
  6186. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6187. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6188. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6189. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6190. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6191. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6192. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6193. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6194. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6195. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6196. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6197. SUCH DAMAGE.
  6198. ***********************************************************************/
  6199. function def_transform(node, descend) {
  6200. node.DEFMETHOD("transform", function(tw, in_list) {
  6201. let transformed = undefined;
  6202. tw.push(this);
  6203. if (tw.before) transformed = tw.before(this, descend, in_list);
  6204. if (transformed === undefined) {
  6205. transformed = this;
  6206. descend(transformed, tw);
  6207. if (tw.after) {
  6208. const after_ret = tw.after(transformed, in_list);
  6209. if (after_ret !== undefined) transformed = after_ret;
  6210. }
  6211. }
  6212. tw.pop();
  6213. return transformed;
  6214. });
  6215. }
  6216. def_transform(AST_Node, noop);
  6217. def_transform(AST_LabeledStatement, function(self, tw) {
  6218. self.label = self.label.transform(tw);
  6219. self.body = self.body.transform(tw);
  6220. });
  6221. def_transform(AST_SimpleStatement, function(self, tw) {
  6222. self.body = self.body.transform(tw);
  6223. });
  6224. def_transform(AST_Block, function(self, tw) {
  6225. self.body = MAP(self.body, tw);
  6226. });
  6227. def_transform(AST_Do, function(self, tw) {
  6228. self.body = self.body.transform(tw);
  6229. self.condition = self.condition.transform(tw);
  6230. });
  6231. def_transform(AST_While, function(self, tw) {
  6232. self.condition = self.condition.transform(tw);
  6233. self.body = self.body.transform(tw);
  6234. });
  6235. def_transform(AST_For, function(self, tw) {
  6236. if (self.init) self.init = self.init.transform(tw);
  6237. if (self.condition) self.condition = self.condition.transform(tw);
  6238. if (self.step) self.step = self.step.transform(tw);
  6239. self.body = self.body.transform(tw);
  6240. });
  6241. def_transform(AST_ForIn, function(self, tw) {
  6242. self.init = self.init.transform(tw);
  6243. self.object = self.object.transform(tw);
  6244. self.body = self.body.transform(tw);
  6245. });
  6246. def_transform(AST_With, function(self, tw) {
  6247. self.expression = self.expression.transform(tw);
  6248. self.body = self.body.transform(tw);
  6249. });
  6250. def_transform(AST_Exit, function(self, tw) {
  6251. if (self.value) self.value = self.value.transform(tw);
  6252. });
  6253. def_transform(AST_LoopControl, function(self, tw) {
  6254. if (self.label) self.label = self.label.transform(tw);
  6255. });
  6256. def_transform(AST_If, function(self, tw) {
  6257. self.condition = self.condition.transform(tw);
  6258. self.body = self.body.transform(tw);
  6259. if (self.alternative) self.alternative = self.alternative.transform(tw);
  6260. });
  6261. def_transform(AST_Switch, function(self, tw) {
  6262. self.expression = self.expression.transform(tw);
  6263. self.body = MAP(self.body, tw);
  6264. });
  6265. def_transform(AST_Case, function(self, tw) {
  6266. self.expression = self.expression.transform(tw);
  6267. self.body = MAP(self.body, tw);
  6268. });
  6269. def_transform(AST_Try, function(self, tw) {
  6270. self.body = self.body.transform(tw);
  6271. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  6272. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  6273. });
  6274. def_transform(AST_Catch, function(self, tw) {
  6275. if (self.argname) self.argname = self.argname.transform(tw);
  6276. self.body = MAP(self.body, tw);
  6277. });
  6278. def_transform(AST_Definitions, function(self, tw) {
  6279. self.definitions = MAP(self.definitions, tw);
  6280. });
  6281. def_transform(AST_VarDef, function(self, tw) {
  6282. self.name = self.name.transform(tw);
  6283. if (self.value) self.value = self.value.transform(tw);
  6284. });
  6285. def_transform(AST_Destructuring, function(self, tw) {
  6286. self.names = MAP(self.names, tw);
  6287. });
  6288. def_transform(AST_Lambda, function(self, tw) {
  6289. if (self.name) self.name = self.name.transform(tw);
  6290. self.argnames = MAP(self.argnames, tw, /* allow_splicing */ false);
  6291. if (self.body instanceof AST_Node) {
  6292. self.body = self.body.transform(tw);
  6293. } else {
  6294. self.body = MAP(self.body, tw);
  6295. }
  6296. });
  6297. def_transform(AST_Call, function(self, tw) {
  6298. self.expression = self.expression.transform(tw);
  6299. self.args = MAP(self.args, tw, /* allow_splicing */ false);
  6300. });
  6301. def_transform(AST_Sequence, function(self, tw) {
  6302. const result = MAP(self.expressions, tw);
  6303. self.expressions = result.length
  6304. ? result
  6305. : [new AST_Number({ value: 0 })];
  6306. });
  6307. def_transform(AST_PropAccess, function(self, tw) {
  6308. self.expression = self.expression.transform(tw);
  6309. });
  6310. def_transform(AST_Sub, function(self, tw) {
  6311. self.expression = self.expression.transform(tw);
  6312. self.property = self.property.transform(tw);
  6313. });
  6314. def_transform(AST_Chain, function(self, tw) {
  6315. self.expression = self.expression.transform(tw);
  6316. });
  6317. def_transform(AST_Yield, function(self, tw) {
  6318. if (self.expression) self.expression = self.expression.transform(tw);
  6319. });
  6320. def_transform(AST_Await, function(self, tw) {
  6321. self.expression = self.expression.transform(tw);
  6322. });
  6323. def_transform(AST_Unary, function(self, tw) {
  6324. self.expression = self.expression.transform(tw);
  6325. });
  6326. def_transform(AST_Binary, function(self, tw) {
  6327. self.left = self.left.transform(tw);
  6328. self.right = self.right.transform(tw);
  6329. });
  6330. def_transform(AST_PrivateIn, function(self, tw) {
  6331. self.key = self.key.transform(tw);
  6332. self.value = self.value.transform(tw);
  6333. });
  6334. def_transform(AST_Conditional, function(self, tw) {
  6335. self.condition = self.condition.transform(tw);
  6336. self.consequent = self.consequent.transform(tw);
  6337. self.alternative = self.alternative.transform(tw);
  6338. });
  6339. def_transform(AST_Array, function(self, tw) {
  6340. self.elements = MAP(self.elements, tw);
  6341. });
  6342. def_transform(AST_Object, function(self, tw) {
  6343. self.properties = MAP(self.properties, tw);
  6344. });
  6345. def_transform(AST_ObjectProperty, function(self, tw) {
  6346. if (self.key instanceof AST_Node) {
  6347. self.key = self.key.transform(tw);
  6348. }
  6349. if (self.value) self.value = self.value.transform(tw);
  6350. });
  6351. def_transform(AST_Class, function(self, tw) {
  6352. if (self.name) self.name = self.name.transform(tw);
  6353. if (self.extends) self.extends = self.extends.transform(tw);
  6354. self.properties = MAP(self.properties, tw);
  6355. });
  6356. def_transform(AST_ClassStaticBlock, function(self, tw) {
  6357. self.body = MAP(self.body, tw);
  6358. });
  6359. def_transform(AST_Expansion, function(self, tw) {
  6360. self.expression = self.expression.transform(tw);
  6361. });
  6362. def_transform(AST_NameMapping, function(self, tw) {
  6363. self.foreign_name = self.foreign_name.transform(tw);
  6364. self.name = self.name.transform(tw);
  6365. });
  6366. def_transform(AST_Import, function(self, tw) {
  6367. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  6368. if (self.imported_names) MAP(self.imported_names, tw);
  6369. self.module_name = self.module_name.transform(tw);
  6370. });
  6371. def_transform(AST_Export, function(self, tw) {
  6372. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  6373. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  6374. if (self.exported_names) MAP(self.exported_names, tw);
  6375. if (self.module_name) self.module_name = self.module_name.transform(tw);
  6376. });
  6377. def_transform(AST_TemplateString, function(self, tw) {
  6378. self.segments = MAP(self.segments, tw);
  6379. });
  6380. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  6381. self.prefix = self.prefix.transform(tw);
  6382. self.template_string = self.template_string.transform(tw);
  6383. });
  6384. /***********************************************************************
  6385. A JavaScript tokenizer / parser / beautifier / compressor.
  6386. https://github.com/mishoo/UglifyJS2
  6387. -------------------------------- (C) ---------------------------------
  6388. Author: Mihai Bazon
  6389. <mihai.bazon@gmail.com>
  6390. http://mihai.bazon.net/blog
  6391. Distributed under the BSD license:
  6392. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6393. Redistribution and use in source and binary forms, with or without
  6394. modification, are permitted provided that the following conditions
  6395. are met:
  6396. * Redistributions of source code must retain the above
  6397. copyright notice, this list of conditions and the following
  6398. disclaimer.
  6399. * Redistributions in binary form must reproduce the above
  6400. copyright notice, this list of conditions and the following
  6401. disclaimer in the documentation and/or other materials
  6402. provided with the distribution.
  6403. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6404. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6405. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6406. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6407. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6408. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6409. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6410. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6411. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6412. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6413. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6414. SUCH DAMAGE.
  6415. ***********************************************************************/
  6416. (function() {
  6417. var normalize_directives = function(body) {
  6418. for (var i = 0; i < body.length; i++) {
  6419. if (body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  6420. body[i] = new AST_Directive({
  6421. start: body[i].start,
  6422. end: body[i].end,
  6423. value: body[i].body.value
  6424. });
  6425. } else {
  6426. return body;
  6427. }
  6428. }
  6429. return body;
  6430. };
  6431. function import_attributes_from_moz(attributes) {
  6432. if (attributes && attributes.length > 0) {
  6433. return new AST_Object({
  6434. start: my_start_token(attributes),
  6435. end: my_end_token(attributes),
  6436. properties: attributes.map((attr) =>
  6437. new AST_ObjectKeyVal({
  6438. start: my_start_token(attr),
  6439. end: my_end_token(attr),
  6440. key: attr.key.name || attr.key.value,
  6441. value: from_moz(attr.value)
  6442. })
  6443. )
  6444. });
  6445. }
  6446. return null;
  6447. }
  6448. var MOZ_TO_ME = {
  6449. Program: function(M) {
  6450. return new AST_Toplevel({
  6451. start: my_start_token(M),
  6452. end: my_end_token(M),
  6453. body: normalize_directives(M.body.map(from_moz))
  6454. });
  6455. },
  6456. ArrayPattern: function(M) {
  6457. return new AST_Destructuring({
  6458. start: my_start_token(M),
  6459. end: my_end_token(M),
  6460. names: M.elements.map(function(elm) {
  6461. if (elm === null) {
  6462. return new AST_Hole();
  6463. }
  6464. return from_moz(elm);
  6465. }),
  6466. is_array: true
  6467. });
  6468. },
  6469. ObjectPattern: function(M) {
  6470. return new AST_Destructuring({
  6471. start: my_start_token(M),
  6472. end: my_end_token(M),
  6473. names: M.properties.map(from_moz),
  6474. is_array: false
  6475. });
  6476. },
  6477. AssignmentPattern: function(M) {
  6478. return new AST_DefaultAssign({
  6479. start: my_start_token(M),
  6480. end: my_end_token(M),
  6481. left: from_moz(M.left),
  6482. operator: "=",
  6483. right: from_moz(M.right)
  6484. });
  6485. },
  6486. SpreadElement: function(M) {
  6487. return new AST_Expansion({
  6488. start: my_start_token(M),
  6489. end: my_end_token(M),
  6490. expression: from_moz(M.argument)
  6491. });
  6492. },
  6493. RestElement: function(M) {
  6494. return new AST_Expansion({
  6495. start: my_start_token(M),
  6496. end: my_end_token(M),
  6497. expression: from_moz(M.argument)
  6498. });
  6499. },
  6500. TemplateElement: function(M) {
  6501. return new AST_TemplateSegment({
  6502. start: my_start_token(M),
  6503. end: my_end_token(M),
  6504. value: M.value.cooked,
  6505. raw: M.value.raw
  6506. });
  6507. },
  6508. TemplateLiteral: function(M) {
  6509. var segments = [];
  6510. for (var i = 0; i < M.quasis.length; i++) {
  6511. segments.push(from_moz(M.quasis[i]));
  6512. if (M.expressions[i]) {
  6513. segments.push(from_moz(M.expressions[i]));
  6514. }
  6515. }
  6516. return new AST_TemplateString({
  6517. start: my_start_token(M),
  6518. end: my_end_token(M),
  6519. segments: segments
  6520. });
  6521. },
  6522. TaggedTemplateExpression: function(M) {
  6523. return new AST_PrefixedTemplateString({
  6524. start: my_start_token(M),
  6525. end: my_end_token(M),
  6526. template_string: from_moz(M.quasi),
  6527. prefix: from_moz(M.tag)
  6528. });
  6529. },
  6530. FunctionDeclaration: function(M) {
  6531. return new AST_Defun({
  6532. start: my_start_token(M),
  6533. end: my_end_token(M),
  6534. name: from_moz(M.id),
  6535. argnames: M.params.map(from_moz),
  6536. is_generator: M.generator,
  6537. async: M.async,
  6538. body: normalize_directives(from_moz(M.body).body)
  6539. });
  6540. },
  6541. FunctionExpression: function(M) {
  6542. return new AST_Function({
  6543. start: my_start_token(M),
  6544. end: my_end_token(M),
  6545. name: from_moz(M.id),
  6546. argnames: M.params.map(from_moz),
  6547. is_generator: M.generator,
  6548. async: M.async,
  6549. body: normalize_directives(from_moz(M.body).body)
  6550. });
  6551. },
  6552. ArrowFunctionExpression: function(M) {
  6553. const body = M.body.type === "BlockStatement"
  6554. ? from_moz(M.body).body
  6555. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  6556. return new AST_Arrow({
  6557. start: my_start_token(M),
  6558. end: my_end_token(M),
  6559. argnames: M.params.map(from_moz),
  6560. body,
  6561. async: M.async,
  6562. });
  6563. },
  6564. ExpressionStatement: function(M) {
  6565. return new AST_SimpleStatement({
  6566. start: my_start_token(M),
  6567. end: my_end_token(M),
  6568. body: from_moz(M.expression)
  6569. });
  6570. },
  6571. TryStatement: function(M) {
  6572. var handlers = M.handlers || [M.handler];
  6573. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  6574. throw new Error("Multiple catch clauses are not supported.");
  6575. }
  6576. return new AST_Try({
  6577. start : my_start_token(M),
  6578. end : my_end_token(M),
  6579. body : new AST_TryBlock(from_moz(M.block)),
  6580. bcatch : from_moz(handlers[0]),
  6581. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  6582. });
  6583. },
  6584. Property: function(M) {
  6585. var key = M.key;
  6586. var args = {
  6587. start : my_start_token(key || M.value),
  6588. end : my_end_token(M.value),
  6589. key : key.type == "Identifier" ? key.name : key.value,
  6590. value : from_moz(M.value)
  6591. };
  6592. if (M.computed) {
  6593. args.key = from_moz(M.key);
  6594. }
  6595. if (M.method) {
  6596. args.is_generator = M.value.generator;
  6597. args.async = M.value.async;
  6598. if (!M.computed) {
  6599. args.key = new AST_SymbolMethod({ name: args.key });
  6600. } else {
  6601. args.key = from_moz(M.key);
  6602. }
  6603. return new AST_ConciseMethod(args);
  6604. }
  6605. if (M.kind == "init") {
  6606. if (key.type != "Identifier" && key.type != "Literal") {
  6607. args.key = from_moz(key);
  6608. }
  6609. return new AST_ObjectKeyVal(args);
  6610. }
  6611. if (typeof args.key === "string" || typeof args.key === "number") {
  6612. args.key = new AST_SymbolMethod({
  6613. name: args.key
  6614. });
  6615. }
  6616. args.value = new AST_Accessor(args.value);
  6617. if (M.kind == "get") return new AST_ObjectGetter(args);
  6618. if (M.kind == "set") return new AST_ObjectSetter(args);
  6619. if (M.kind == "method") {
  6620. args.async = M.value.async;
  6621. args.is_generator = M.value.generator;
  6622. args.quote = M.computed ? "\"" : null;
  6623. return new AST_ConciseMethod(args);
  6624. }
  6625. },
  6626. MethodDefinition: function(M) {
  6627. const is_private = M.key.type === "PrivateIdentifier";
  6628. const key = M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value });
  6629. var args = {
  6630. start : my_start_token(M),
  6631. end : my_end_token(M),
  6632. key,
  6633. value : from_moz(M.value),
  6634. static : M.static,
  6635. };
  6636. if (M.kind == "get") {
  6637. return new (is_private ? AST_PrivateGetter : AST_ObjectGetter)(args);
  6638. }
  6639. if (M.kind == "set") {
  6640. return new (is_private ? AST_PrivateSetter : AST_ObjectSetter)(args);
  6641. }
  6642. args.is_generator = M.value.generator;
  6643. args.async = M.value.async;
  6644. return new (is_private ? AST_PrivateMethod : AST_ConciseMethod)(args);
  6645. },
  6646. FieldDefinition: function(M) {
  6647. let key;
  6648. if (M.computed) {
  6649. key = from_moz(M.key);
  6650. } else {
  6651. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  6652. key = from_moz(M.key);
  6653. }
  6654. return new AST_ClassProperty({
  6655. start : my_start_token(M),
  6656. end : my_end_token(M),
  6657. key,
  6658. value : from_moz(M.value),
  6659. static : M.static,
  6660. });
  6661. },
  6662. PropertyDefinition: function(M) {
  6663. let key;
  6664. if (M.computed) {
  6665. key = from_moz(M.key);
  6666. } else if (M.key.type === "PrivateIdentifier") {
  6667. return new AST_ClassPrivateProperty({
  6668. start : my_start_token(M),
  6669. end : my_end_token(M),
  6670. key : from_moz(M.key),
  6671. value : from_moz(M.value),
  6672. static : M.static,
  6673. });
  6674. } else {
  6675. if (M.key.type !== "Identifier") {
  6676. throw new Error("Non-Identifier key in PropertyDefinition");
  6677. }
  6678. key = from_moz(M.key);
  6679. }
  6680. return new AST_ClassProperty({
  6681. start : my_start_token(M),
  6682. end : my_end_token(M),
  6683. key,
  6684. value : from_moz(M.value),
  6685. static : M.static,
  6686. });
  6687. },
  6688. PrivateIdentifier: function (M) {
  6689. return new AST_SymbolPrivateProperty({
  6690. start: my_start_token(M),
  6691. end: my_end_token(M),
  6692. name: M.name
  6693. });
  6694. },
  6695. StaticBlock: function(M) {
  6696. return new AST_ClassStaticBlock({
  6697. start : my_start_token(M),
  6698. end : my_end_token(M),
  6699. body : M.body.map(from_moz),
  6700. });
  6701. },
  6702. ArrayExpression: function(M) {
  6703. return new AST_Array({
  6704. start : my_start_token(M),
  6705. end : my_end_token(M),
  6706. elements : M.elements.map(function(elem) {
  6707. return elem === null ? new AST_Hole() : from_moz(elem);
  6708. })
  6709. });
  6710. },
  6711. ObjectExpression: function(M) {
  6712. return new AST_Object({
  6713. start : my_start_token(M),
  6714. end : my_end_token(M),
  6715. properties : M.properties.map(function(prop) {
  6716. if (prop.type === "SpreadElement") {
  6717. return from_moz(prop);
  6718. }
  6719. prop.type = "Property";
  6720. return from_moz(prop);
  6721. })
  6722. });
  6723. },
  6724. SequenceExpression: function(M) {
  6725. return new AST_Sequence({
  6726. start : my_start_token(M),
  6727. end : my_end_token(M),
  6728. expressions: M.expressions.map(from_moz)
  6729. });
  6730. },
  6731. MemberExpression: function(M) {
  6732. if (M.property.type === "PrivateIdentifier") {
  6733. return new AST_DotHash({
  6734. start : my_start_token(M),
  6735. end : my_end_token(M),
  6736. property : M.property.name,
  6737. expression : from_moz(M.object),
  6738. optional : M.optional || false
  6739. });
  6740. }
  6741. return new (M.computed ? AST_Sub : AST_Dot)({
  6742. start : my_start_token(M),
  6743. end : my_end_token(M),
  6744. property : M.computed ? from_moz(M.property) : M.property.name,
  6745. expression : from_moz(M.object),
  6746. optional : M.optional || false
  6747. });
  6748. },
  6749. ChainExpression: function(M) {
  6750. return new AST_Chain({
  6751. start : my_start_token(M),
  6752. end : my_end_token(M),
  6753. expression : from_moz(M.expression)
  6754. });
  6755. },
  6756. SwitchCase: function(M) {
  6757. return new (M.test ? AST_Case : AST_Default)({
  6758. start : my_start_token(M),
  6759. end : my_end_token(M),
  6760. expression : from_moz(M.test),
  6761. body : M.consequent.map(from_moz)
  6762. });
  6763. },
  6764. VariableDeclaration: function(M) {
  6765. return new (M.kind === "const" ? AST_Const :
  6766. M.kind === "let" ? AST_Let : AST_Var)({
  6767. start : my_start_token(M),
  6768. end : my_end_token(M),
  6769. definitions : M.declarations.map(from_moz)
  6770. });
  6771. },
  6772. ImportDeclaration: function(M) {
  6773. var imported_name = null;
  6774. var imported_names = null;
  6775. M.specifiers.forEach(function (specifier) {
  6776. if (specifier.type === "ImportSpecifier" || specifier.type === "ImportNamespaceSpecifier") {
  6777. if (!imported_names) { imported_names = []; }
  6778. imported_names.push(from_moz(specifier));
  6779. } else if (specifier.type === "ImportDefaultSpecifier") {
  6780. imported_name = from_moz(specifier);
  6781. }
  6782. });
  6783. return new AST_Import({
  6784. start : my_start_token(M),
  6785. end : my_end_token(M),
  6786. imported_name: imported_name,
  6787. imported_names : imported_names,
  6788. module_name : from_moz(M.source),
  6789. attributes: import_attributes_from_moz(M.attributes || M.assertions)
  6790. });
  6791. },
  6792. ImportSpecifier: function(M) {
  6793. return new AST_NameMapping({
  6794. start: my_start_token(M),
  6795. end: my_end_token(M),
  6796. foreign_name: from_moz(M.imported),
  6797. name: from_moz(M.local)
  6798. });
  6799. },
  6800. ImportDefaultSpecifier: function(M) {
  6801. return from_moz(M.local);
  6802. },
  6803. ImportNamespaceSpecifier: function(M) {
  6804. return new AST_NameMapping({
  6805. start: my_start_token(M),
  6806. end: my_end_token(M),
  6807. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  6808. name: from_moz(M.local)
  6809. });
  6810. },
  6811. ImportExpression: function(M) {
  6812. const args = [from_moz(M.source)];
  6813. if (M.options) {
  6814. args.push(from_moz(M.options));
  6815. }
  6816. return new AST_Call({
  6817. start: my_start_token(M),
  6818. end: my_end_token(M),
  6819. expression: from_moz({
  6820. type: "Identifier",
  6821. name: "import"
  6822. }),
  6823. optional: false,
  6824. args
  6825. });
  6826. },
  6827. ExportAllDeclaration: function(M) {
  6828. var foreign_name = M.exported == null ?
  6829. new AST_SymbolExportForeign({ name: "*" }) :
  6830. from_moz(M.exported);
  6831. return new AST_Export({
  6832. start: my_start_token(M),
  6833. end: my_end_token(M),
  6834. exported_names: [
  6835. new AST_NameMapping({
  6836. name: new AST_SymbolExportForeign({ name: "*" }),
  6837. foreign_name: foreign_name
  6838. })
  6839. ],
  6840. module_name: from_moz(M.source),
  6841. attributes: import_attributes_from_moz(M.attributes || M.assertions)
  6842. });
  6843. },
  6844. ExportNamedDeclaration: function(M) {
  6845. return new AST_Export({
  6846. start: my_start_token(M),
  6847. end: my_end_token(M),
  6848. exported_definition: from_moz(M.declaration),
  6849. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : null,
  6850. module_name: from_moz(M.source),
  6851. attributes: import_attributes_from_moz(M.attributes || M.assertions)
  6852. });
  6853. },
  6854. ExportDefaultDeclaration: function(M) {
  6855. return new AST_Export({
  6856. start: my_start_token(M),
  6857. end: my_end_token(M),
  6858. exported_value: from_moz(M.declaration),
  6859. is_default: true
  6860. });
  6861. },
  6862. ExportSpecifier: function(M) {
  6863. return new AST_NameMapping({
  6864. foreign_name: from_moz(M.exported),
  6865. name: from_moz(M.local)
  6866. });
  6867. },
  6868. Literal: function(M) {
  6869. var val = M.value, args = {
  6870. start : my_start_token(M),
  6871. end : my_end_token(M)
  6872. };
  6873. var rx = M.regex;
  6874. if (rx && rx.pattern) {
  6875. // RegExpLiteral as per ESTree AST spec
  6876. args.value = {
  6877. source: rx.pattern,
  6878. flags: rx.flags
  6879. };
  6880. return new AST_RegExp(args);
  6881. } else if (rx) {
  6882. // support legacy RegExp
  6883. const rx_source = M.raw || val;
  6884. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  6885. if (!match) throw new Error("Invalid regex source " + rx_source);
  6886. const [_, source, flags] = match;
  6887. args.value = { source, flags };
  6888. return new AST_RegExp(args);
  6889. }
  6890. const bi = typeof M.value === "bigint" ? M.value.toString() : M.bigint;
  6891. if (typeof bi === "string") {
  6892. args.value = bi;
  6893. return new AST_BigInt(args);
  6894. }
  6895. if (val === null) return new AST_Null(args);
  6896. switch (typeof val) {
  6897. case "string":
  6898. args.quote = "\"";
  6899. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6900. if (p.type == "ImportSpecifier") {
  6901. args.name = val;
  6902. return new AST_SymbolImportForeign(args);
  6903. } else if (p.type == "ExportSpecifier") {
  6904. args.name = val;
  6905. if (M == p.exported) {
  6906. return new AST_SymbolExportForeign(args);
  6907. } else {
  6908. return new AST_SymbolExport(args);
  6909. }
  6910. } else if (p.type == "ExportAllDeclaration" && M == p.exported) {
  6911. args.name = val;
  6912. return new AST_SymbolExportForeign(args);
  6913. }
  6914. args.value = val;
  6915. return new AST_String(args);
  6916. case "number":
  6917. args.value = val;
  6918. args.raw = M.raw || val.toString();
  6919. return new AST_Number(args);
  6920. case "boolean":
  6921. return new (val ? AST_True : AST_False)(args);
  6922. }
  6923. },
  6924. MetaProperty: function(M) {
  6925. if (M.meta.name === "new" && M.property.name === "target") {
  6926. return new AST_NewTarget({
  6927. start: my_start_token(M),
  6928. end: my_end_token(M)
  6929. });
  6930. } else if (M.meta.name === "import" && M.property.name === "meta") {
  6931. return new AST_ImportMeta({
  6932. start: my_start_token(M),
  6933. end: my_end_token(M)
  6934. });
  6935. }
  6936. },
  6937. Identifier: function(M) {
  6938. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6939. return new ( p.type == "LabeledStatement" ? AST_Label
  6940. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  6941. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  6942. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  6943. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  6944. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  6945. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  6946. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  6947. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  6948. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  6949. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  6950. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  6951. : p.type == "CatchClause" ? AST_SymbolCatch
  6952. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  6953. : AST_SymbolRef)({
  6954. start : my_start_token(M),
  6955. end : my_end_token(M),
  6956. name : M.name
  6957. });
  6958. },
  6959. EmptyStatement: function(M) {
  6960. return new AST_EmptyStatement({
  6961. start: my_start_token(M),
  6962. end: my_end_token(M)
  6963. });
  6964. },
  6965. BlockStatement: function(M) {
  6966. return new AST_BlockStatement({
  6967. start: my_start_token(M),
  6968. end: my_end_token(M),
  6969. body: M.body.map(from_moz)
  6970. });
  6971. },
  6972. IfStatement: function(M) {
  6973. return new AST_If({
  6974. start: my_start_token(M),
  6975. end: my_end_token(M),
  6976. condition: from_moz(M.test),
  6977. body: from_moz(M.consequent),
  6978. alternative: from_moz(M.alternate)
  6979. });
  6980. },
  6981. LabeledStatement: function(M) {
  6982. return new AST_LabeledStatement({
  6983. start: my_start_token(M),
  6984. end: my_end_token(M),
  6985. label: from_moz(M.label),
  6986. body: from_moz(M.body)
  6987. });
  6988. },
  6989. BreakStatement: function(M) {
  6990. return new AST_Break({
  6991. start: my_start_token(M),
  6992. end: my_end_token(M),
  6993. label: from_moz(M.label)
  6994. });
  6995. },
  6996. ContinueStatement: function(M) {
  6997. return new AST_Continue({
  6998. start: my_start_token(M),
  6999. end: my_end_token(M),
  7000. label: from_moz(M.label)
  7001. });
  7002. },
  7003. WithStatement: function(M) {
  7004. return new AST_With({
  7005. start: my_start_token(M),
  7006. end: my_end_token(M),
  7007. expression: from_moz(M.object),
  7008. body: from_moz(M.body)
  7009. });
  7010. },
  7011. SwitchStatement: function(M) {
  7012. return new AST_Switch({
  7013. start: my_start_token(M),
  7014. end: my_end_token(M),
  7015. expression: from_moz(M.discriminant),
  7016. body: M.cases.map(from_moz)
  7017. });
  7018. },
  7019. ReturnStatement: function(M) {
  7020. return new AST_Return({
  7021. start: my_start_token(M),
  7022. end: my_end_token(M),
  7023. value: from_moz(M.argument)
  7024. });
  7025. },
  7026. ThrowStatement: function(M) {
  7027. return new AST_Throw({
  7028. start: my_start_token(M),
  7029. end: my_end_token(M),
  7030. value: from_moz(M.argument)
  7031. });
  7032. },
  7033. WhileStatement: function(M) {
  7034. return new AST_While({
  7035. start: my_start_token(M),
  7036. end: my_end_token(M),
  7037. condition: from_moz(M.test),
  7038. body: from_moz(M.body)
  7039. });
  7040. },
  7041. DoWhileStatement: function(M) {
  7042. return new AST_Do({
  7043. start: my_start_token(M),
  7044. end: my_end_token(M),
  7045. condition: from_moz(M.test),
  7046. body: from_moz(M.body)
  7047. });
  7048. },
  7049. ForStatement: function(M) {
  7050. return new AST_For({
  7051. start: my_start_token(M),
  7052. end: my_end_token(M),
  7053. init: from_moz(M.init),
  7054. condition: from_moz(M.test),
  7055. step: from_moz(M.update),
  7056. body: from_moz(M.body)
  7057. });
  7058. },
  7059. ForInStatement: function(M) {
  7060. return new AST_ForIn({
  7061. start: my_start_token(M),
  7062. end: my_end_token(M),
  7063. init: from_moz(M.left),
  7064. object: from_moz(M.right),
  7065. body: from_moz(M.body)
  7066. });
  7067. },
  7068. ForOfStatement: function(M) {
  7069. return new AST_ForOf({
  7070. start: my_start_token(M),
  7071. end: my_end_token(M),
  7072. init: from_moz(M.left),
  7073. object: from_moz(M.right),
  7074. body: from_moz(M.body),
  7075. await: M.await
  7076. });
  7077. },
  7078. AwaitExpression: function(M) {
  7079. return new AST_Await({
  7080. start: my_start_token(M),
  7081. end: my_end_token(M),
  7082. expression: from_moz(M.argument)
  7083. });
  7084. },
  7085. YieldExpression: function(M) {
  7086. return new AST_Yield({
  7087. start: my_start_token(M),
  7088. end: my_end_token(M),
  7089. expression: from_moz(M.argument),
  7090. is_star: M.delegate
  7091. });
  7092. },
  7093. DebuggerStatement: function(M) {
  7094. return new AST_Debugger({
  7095. start: my_start_token(M),
  7096. end: my_end_token(M)
  7097. });
  7098. },
  7099. VariableDeclarator: function(M) {
  7100. return new AST_VarDef({
  7101. start: my_start_token(M),
  7102. end: my_end_token(M),
  7103. name: from_moz(M.id),
  7104. value: from_moz(M.init)
  7105. });
  7106. },
  7107. CatchClause: function(M) {
  7108. return new AST_Catch({
  7109. start: my_start_token(M),
  7110. end: my_end_token(M),
  7111. argname: from_moz(M.param),
  7112. body: from_moz(M.body).body
  7113. });
  7114. },
  7115. ThisExpression: function(M) {
  7116. return new AST_This({
  7117. start: my_start_token(M),
  7118. end: my_end_token(M)
  7119. });
  7120. },
  7121. Super: function(M) {
  7122. return new AST_Super({
  7123. start: my_start_token(M),
  7124. end: my_end_token(M)
  7125. });
  7126. },
  7127. BinaryExpression: function(M) {
  7128. if (M.left.type === "PrivateIdentifier") {
  7129. return new AST_PrivateIn({
  7130. start: my_start_token(M),
  7131. end: my_end_token(M),
  7132. key: new AST_SymbolPrivateProperty({
  7133. start: my_start_token(M.left),
  7134. end: my_end_token(M.left),
  7135. name: M.left.name
  7136. }),
  7137. value: from_moz(M.right),
  7138. });
  7139. }
  7140. return new AST_Binary({
  7141. start: my_start_token(M),
  7142. end: my_end_token(M),
  7143. operator: M.operator,
  7144. left: from_moz(M.left),
  7145. right: from_moz(M.right)
  7146. });
  7147. },
  7148. LogicalExpression: function(M) {
  7149. return new AST_Binary({
  7150. start: my_start_token(M),
  7151. end: my_end_token(M),
  7152. operator: M.operator,
  7153. left: from_moz(M.left),
  7154. right: from_moz(M.right)
  7155. });
  7156. },
  7157. AssignmentExpression: function(M) {
  7158. return new AST_Assign({
  7159. start: my_start_token(M),
  7160. end: my_end_token(M),
  7161. operator: M.operator,
  7162. left: from_moz(M.left),
  7163. right: from_moz(M.right)
  7164. });
  7165. },
  7166. ConditionalExpression: function(M) {
  7167. return new AST_Conditional({
  7168. start: my_start_token(M),
  7169. end: my_end_token(M),
  7170. condition: from_moz(M.test),
  7171. consequent: from_moz(M.consequent),
  7172. alternative: from_moz(M.alternate)
  7173. });
  7174. },
  7175. NewExpression: function(M) {
  7176. return new AST_New({
  7177. start: my_start_token(M),
  7178. end: my_end_token(M),
  7179. expression: from_moz(M.callee),
  7180. args: M.arguments.map(from_moz)
  7181. });
  7182. },
  7183. CallExpression: function(M) {
  7184. return new AST_Call({
  7185. start: my_start_token(M),
  7186. end: my_end_token(M),
  7187. expression: from_moz(M.callee),
  7188. optional: M.optional,
  7189. args: M.arguments.map(from_moz)
  7190. });
  7191. }
  7192. };
  7193. MOZ_TO_ME.UpdateExpression =
  7194. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  7195. var prefix = "prefix" in M ? M.prefix
  7196. : M.type == "UnaryExpression" ? true : false;
  7197. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  7198. start : my_start_token(M),
  7199. end : my_end_token(M),
  7200. operator : M.operator,
  7201. expression : from_moz(M.argument)
  7202. });
  7203. };
  7204. MOZ_TO_ME.ClassDeclaration =
  7205. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  7206. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  7207. start : my_start_token(M),
  7208. end : my_end_token(M),
  7209. name : from_moz(M.id),
  7210. extends : from_moz(M.superClass),
  7211. properties: M.body.body.map(from_moz)
  7212. });
  7213. };
  7214. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  7215. return {
  7216. type: "EmptyStatement"
  7217. };
  7218. });
  7219. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  7220. return {
  7221. type: "BlockStatement",
  7222. body: M.body.map(to_moz)
  7223. };
  7224. });
  7225. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  7226. return {
  7227. type: "IfStatement",
  7228. test: to_moz(M.condition),
  7229. consequent: to_moz(M.body),
  7230. alternate: to_moz(M.alternative)
  7231. };
  7232. });
  7233. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  7234. return {
  7235. type: "LabeledStatement",
  7236. label: to_moz(M.label),
  7237. body: to_moz(M.body)
  7238. };
  7239. });
  7240. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  7241. return {
  7242. type: "BreakStatement",
  7243. label: to_moz(M.label)
  7244. };
  7245. });
  7246. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  7247. return {
  7248. type: "ContinueStatement",
  7249. label: to_moz(M.label)
  7250. };
  7251. });
  7252. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  7253. return {
  7254. type: "WithStatement",
  7255. object: to_moz(M.expression),
  7256. body: to_moz(M.body)
  7257. };
  7258. });
  7259. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  7260. return {
  7261. type: "SwitchStatement",
  7262. discriminant: to_moz(M.expression),
  7263. cases: M.body.map(to_moz)
  7264. };
  7265. });
  7266. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  7267. return {
  7268. type: "ReturnStatement",
  7269. argument: to_moz(M.value)
  7270. };
  7271. });
  7272. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  7273. return {
  7274. type: "ThrowStatement",
  7275. argument: to_moz(M.value)
  7276. };
  7277. });
  7278. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  7279. return {
  7280. type: "WhileStatement",
  7281. test: to_moz(M.condition),
  7282. body: to_moz(M.body)
  7283. };
  7284. });
  7285. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  7286. return {
  7287. type: "DoWhileStatement",
  7288. test: to_moz(M.condition),
  7289. body: to_moz(M.body)
  7290. };
  7291. });
  7292. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  7293. return {
  7294. type: "ForStatement",
  7295. init: to_moz(M.init),
  7296. test: to_moz(M.condition),
  7297. update: to_moz(M.step),
  7298. body: to_moz(M.body)
  7299. };
  7300. });
  7301. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  7302. return {
  7303. type: "ForInStatement",
  7304. left: to_moz(M.init),
  7305. right: to_moz(M.object),
  7306. body: to_moz(M.body)
  7307. };
  7308. });
  7309. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  7310. return {
  7311. type: "ForOfStatement",
  7312. left: to_moz(M.init),
  7313. right: to_moz(M.object),
  7314. body: to_moz(M.body),
  7315. await: M.await
  7316. };
  7317. });
  7318. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  7319. return {
  7320. type: "AwaitExpression",
  7321. argument: to_moz(M.expression)
  7322. };
  7323. });
  7324. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  7325. return {
  7326. type: "YieldExpression",
  7327. argument: to_moz(M.expression),
  7328. delegate: M.is_star
  7329. };
  7330. });
  7331. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  7332. return {
  7333. type: "DebuggerStatement"
  7334. };
  7335. });
  7336. def_to_moz(AST_VarDef, function To_Moz_VariableDeclarator(M) {
  7337. return {
  7338. type: "VariableDeclarator",
  7339. id: to_moz(M.name),
  7340. init: to_moz(M.value)
  7341. };
  7342. });
  7343. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7344. return {
  7345. type: "CatchClause",
  7346. param: to_moz(M.argname),
  7347. body: to_moz_block(M)
  7348. };
  7349. });
  7350. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  7351. return {
  7352. type: "ThisExpression"
  7353. };
  7354. });
  7355. def_to_moz(AST_Super, function To_Moz_Super() {
  7356. return {
  7357. type: "Super"
  7358. };
  7359. });
  7360. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7361. return {
  7362. type: "BinaryExpression",
  7363. operator: M.operator,
  7364. left: to_moz(M.left),
  7365. right: to_moz(M.right)
  7366. };
  7367. });
  7368. def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
  7369. return {
  7370. type: "LogicalExpression",
  7371. operator: M.operator,
  7372. left: to_moz(M.left),
  7373. right: to_moz(M.right)
  7374. };
  7375. });
  7376. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  7377. return {
  7378. type: "AssignmentExpression",
  7379. operator: M.operator,
  7380. left: to_moz(M.left),
  7381. right: to_moz(M.right)
  7382. };
  7383. });
  7384. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  7385. return {
  7386. type: "ConditionalExpression",
  7387. test: to_moz(M.condition),
  7388. consequent: to_moz(M.consequent),
  7389. alternate: to_moz(M.alternative)
  7390. };
  7391. });
  7392. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  7393. return {
  7394. type: "NewExpression",
  7395. callee: to_moz(M.expression),
  7396. arguments: M.args.map(to_moz)
  7397. };
  7398. });
  7399. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  7400. if (M.expression instanceof AST_SymbolRef && M.expression.name === "import") {
  7401. const [source, options] = M.args.map(to_moz);
  7402. return {
  7403. type: "ImportExpression",
  7404. source,
  7405. options
  7406. };
  7407. }
  7408. return {
  7409. type: "CallExpression",
  7410. callee: to_moz(M.expression),
  7411. optional: M.optional,
  7412. arguments: M.args.map(to_moz)
  7413. };
  7414. });
  7415. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  7416. return to_moz_scope("Program", M);
  7417. });
  7418. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  7419. return {
  7420. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  7421. argument: to_moz(M.expression)
  7422. };
  7423. });
  7424. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  7425. return {
  7426. type: "TaggedTemplateExpression",
  7427. tag: to_moz(M.prefix),
  7428. quasi: to_moz(M.template_string)
  7429. };
  7430. });
  7431. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  7432. var quasis = [];
  7433. var expressions = [];
  7434. for (var i = 0; i < M.segments.length; i++) {
  7435. if (i % 2 !== 0) {
  7436. expressions.push(to_moz(M.segments[i]));
  7437. } else {
  7438. quasis.push({
  7439. type: "TemplateElement",
  7440. value: {
  7441. raw: M.segments[i].raw,
  7442. cooked: M.segments[i].value
  7443. },
  7444. tail: i === M.segments.length - 1
  7445. });
  7446. }
  7447. }
  7448. return {
  7449. type: "TemplateLiteral",
  7450. quasis: quasis,
  7451. expressions: expressions
  7452. };
  7453. });
  7454. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  7455. return {
  7456. type: "FunctionDeclaration",
  7457. id: to_moz(M.name),
  7458. params: M.argnames.map(to_moz),
  7459. generator: M.is_generator,
  7460. async: M.async,
  7461. body: to_moz_scope("BlockStatement", M)
  7462. };
  7463. });
  7464. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  7465. var is_generator = parent.is_generator !== undefined ?
  7466. parent.is_generator : M.is_generator;
  7467. return {
  7468. type: "FunctionExpression",
  7469. id: to_moz(M.name),
  7470. params: M.argnames.map(to_moz),
  7471. generator: is_generator,
  7472. async: M.async,
  7473. body: to_moz_scope("BlockStatement", M)
  7474. };
  7475. });
  7476. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  7477. var body = {
  7478. type: "BlockStatement",
  7479. body: M.body.map(to_moz)
  7480. };
  7481. return {
  7482. type: "ArrowFunctionExpression",
  7483. params: M.argnames.map(to_moz),
  7484. async: M.async,
  7485. body: body
  7486. };
  7487. });
  7488. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  7489. if (M.is_array) {
  7490. return {
  7491. type: "ArrayPattern",
  7492. elements: M.names.map(to_moz)
  7493. };
  7494. }
  7495. return {
  7496. type: "ObjectPattern",
  7497. properties: M.names.map(to_moz)
  7498. };
  7499. });
  7500. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  7501. return {
  7502. type: "ExpressionStatement",
  7503. expression: {
  7504. type: "Literal",
  7505. value: M.value,
  7506. raw: M.print_to_string()
  7507. },
  7508. directive: M.value
  7509. };
  7510. });
  7511. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  7512. return {
  7513. type: "ExpressionStatement",
  7514. expression: to_moz(M.body)
  7515. };
  7516. });
  7517. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  7518. return {
  7519. type: "SwitchCase",
  7520. test: to_moz(M.expression),
  7521. consequent: M.body.map(to_moz)
  7522. };
  7523. });
  7524. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  7525. return {
  7526. type: "TryStatement",
  7527. block: to_moz_block(M.body),
  7528. handler: to_moz(M.bcatch),
  7529. guardedHandlers: [],
  7530. finalizer: to_moz(M.bfinally)
  7531. };
  7532. });
  7533. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7534. return {
  7535. type: "CatchClause",
  7536. param: to_moz(M.argname),
  7537. guard: null,
  7538. body: to_moz_block(M)
  7539. };
  7540. });
  7541. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  7542. return {
  7543. type: "VariableDeclaration",
  7544. kind:
  7545. M instanceof AST_Const ? "const" :
  7546. M instanceof AST_Let ? "let" : "var",
  7547. declarations: M.definitions.map(to_moz)
  7548. };
  7549. });
  7550. function import_attributes_to_moz(attribute) {
  7551. const import_attributes = [];
  7552. if (attribute) {
  7553. for (const { key, value } of attribute.properties) {
  7554. const key_moz = is_basic_identifier_string(key)
  7555. ? { type: "Identifier", name: key }
  7556. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  7557. import_attributes.push({
  7558. type: "ImportAttribute",
  7559. key: key_moz,
  7560. value: to_moz(value)
  7561. });
  7562. }
  7563. }
  7564. return import_attributes;
  7565. }
  7566. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  7567. if (M.exported_names) {
  7568. var first_exported = M.exported_names[0];
  7569. var first_exported_name = first_exported.name;
  7570. if (first_exported_name.name === "*" && !first_exported_name.quote) {
  7571. var foreign_name = first_exported.foreign_name;
  7572. var exported = foreign_name.name === "*" && !foreign_name.quote
  7573. ? null
  7574. : to_moz(foreign_name);
  7575. return {
  7576. type: "ExportAllDeclaration",
  7577. source: to_moz(M.module_name),
  7578. exported: exported,
  7579. attributes: import_attributes_to_moz(M.attributes)
  7580. };
  7581. }
  7582. return {
  7583. type: "ExportNamedDeclaration",
  7584. specifiers: M.exported_names.map(function (name_mapping) {
  7585. return {
  7586. type: "ExportSpecifier",
  7587. exported: to_moz(name_mapping.foreign_name),
  7588. local: to_moz(name_mapping.name)
  7589. };
  7590. }),
  7591. declaration: to_moz(M.exported_definition),
  7592. source: to_moz(M.module_name),
  7593. attributes: import_attributes_to_moz(M.attributes)
  7594. };
  7595. }
  7596. return {
  7597. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  7598. declaration: to_moz(M.exported_value || M.exported_definition)
  7599. };
  7600. });
  7601. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  7602. var specifiers = [];
  7603. if (M.imported_name) {
  7604. specifiers.push({
  7605. type: "ImportDefaultSpecifier",
  7606. local: to_moz(M.imported_name)
  7607. });
  7608. }
  7609. if (M.imported_names) {
  7610. var first_imported_foreign_name = M.imported_names[0].foreign_name;
  7611. if (first_imported_foreign_name.name === "*" && !first_imported_foreign_name.quote) {
  7612. specifiers.push({
  7613. type: "ImportNamespaceSpecifier",
  7614. local: to_moz(M.imported_names[0].name)
  7615. });
  7616. } else {
  7617. M.imported_names.forEach(function(name_mapping) {
  7618. specifiers.push({
  7619. type: "ImportSpecifier",
  7620. local: to_moz(name_mapping.name),
  7621. imported: to_moz(name_mapping.foreign_name)
  7622. });
  7623. });
  7624. }
  7625. }
  7626. return {
  7627. type: "ImportDeclaration",
  7628. specifiers: specifiers,
  7629. source: to_moz(M.module_name),
  7630. attributes: import_attributes_to_moz(M.attributes)
  7631. };
  7632. });
  7633. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  7634. return {
  7635. type: "MetaProperty",
  7636. meta: {
  7637. type: "Identifier",
  7638. name: "import"
  7639. },
  7640. property: {
  7641. type: "Identifier",
  7642. name: "meta"
  7643. }
  7644. };
  7645. });
  7646. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  7647. return {
  7648. type: "SequenceExpression",
  7649. expressions: M.expressions.map(to_moz)
  7650. };
  7651. });
  7652. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  7653. return {
  7654. type: "MemberExpression",
  7655. object: to_moz(M.expression),
  7656. computed: false,
  7657. property: {
  7658. type: "PrivateIdentifier",
  7659. name: M.property
  7660. },
  7661. optional: M.optional
  7662. };
  7663. });
  7664. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  7665. var isComputed = M instanceof AST_Sub;
  7666. return {
  7667. type: "MemberExpression",
  7668. object: to_moz(M.expression),
  7669. computed: isComputed,
  7670. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  7671. optional: M.optional
  7672. };
  7673. });
  7674. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  7675. return {
  7676. type: "ChainExpression",
  7677. expression: to_moz(M.expression)
  7678. };
  7679. });
  7680. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  7681. return {
  7682. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  7683. operator: M.operator,
  7684. prefix: M instanceof AST_UnaryPrefix,
  7685. argument: to_moz(M.expression)
  7686. };
  7687. });
  7688. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7689. if (M.operator == "=" && to_moz_in_destructuring()) {
  7690. return {
  7691. type: "AssignmentPattern",
  7692. left: to_moz(M.left),
  7693. right: to_moz(M.right)
  7694. };
  7695. }
  7696. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  7697. ? "LogicalExpression"
  7698. : "BinaryExpression";
  7699. return {
  7700. type,
  7701. left: to_moz(M.left),
  7702. operator: M.operator,
  7703. right: to_moz(M.right)
  7704. };
  7705. });
  7706. def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
  7707. return {
  7708. type: "BinaryExpression",
  7709. left: { type: "PrivateIdentifier", name: M.key.name },
  7710. operator: "in",
  7711. right: to_moz(M.value),
  7712. };
  7713. });
  7714. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  7715. return {
  7716. type: "ArrayExpression",
  7717. elements: M.elements.map(to_moz)
  7718. };
  7719. });
  7720. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  7721. return {
  7722. type: "ObjectExpression",
  7723. properties: M.properties.map(to_moz)
  7724. };
  7725. });
  7726. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  7727. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  7728. type: "Identifier",
  7729. value: M.key
  7730. };
  7731. if (typeof M.key === "number") {
  7732. key = {
  7733. type: "Literal",
  7734. value: Number(M.key)
  7735. };
  7736. }
  7737. if (typeof M.key === "string") {
  7738. key = {
  7739. type: "Identifier",
  7740. name: M.key
  7741. };
  7742. }
  7743. var kind;
  7744. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  7745. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  7746. if (M instanceof AST_ObjectKeyVal) {
  7747. kind = "init";
  7748. computed = !string_or_num;
  7749. } else
  7750. if (M instanceof AST_ObjectGetter) {
  7751. kind = "get";
  7752. } else
  7753. if (M instanceof AST_ObjectSetter) {
  7754. kind = "set";
  7755. }
  7756. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  7757. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  7758. return {
  7759. type: "MethodDefinition",
  7760. computed: false,
  7761. kind: kind,
  7762. static: M.static,
  7763. key: {
  7764. type: "PrivateIdentifier",
  7765. name: M.key.name
  7766. },
  7767. value: to_moz(M.value)
  7768. };
  7769. }
  7770. if (M instanceof AST_ClassPrivateProperty) {
  7771. return {
  7772. type: "PropertyDefinition",
  7773. key: {
  7774. type: "PrivateIdentifier",
  7775. name: M.key.name
  7776. },
  7777. value: to_moz(M.value),
  7778. computed: false,
  7779. static: M.static
  7780. };
  7781. }
  7782. if (M instanceof AST_ClassProperty) {
  7783. return {
  7784. type: "PropertyDefinition",
  7785. key,
  7786. value: to_moz(M.value),
  7787. computed,
  7788. static: M.static
  7789. };
  7790. }
  7791. if (parent instanceof AST_Class) {
  7792. return {
  7793. type: "MethodDefinition",
  7794. computed: computed,
  7795. kind: kind,
  7796. static: M.static,
  7797. key: to_moz(M.key),
  7798. value: to_moz(M.value)
  7799. };
  7800. }
  7801. return {
  7802. type: "Property",
  7803. computed: computed,
  7804. kind: kind,
  7805. key: key,
  7806. value: to_moz(M.value)
  7807. };
  7808. });
  7809. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  7810. if (parent instanceof AST_Object) {
  7811. return {
  7812. type: "Property",
  7813. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7814. kind: "init",
  7815. method: true,
  7816. shorthand: false,
  7817. key: to_moz(M.key),
  7818. value: to_moz(M.value)
  7819. };
  7820. }
  7821. return {
  7822. type: "MethodDefinition",
  7823. kind: M.key === "constructor" ? "constructor" : "method",
  7824. key: to_moz(M.key),
  7825. value: to_moz(M.value),
  7826. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7827. static: M.static,
  7828. };
  7829. });
  7830. def_to_moz(AST_PrivateMethod, function To_Moz_MethodDefinition(M) {
  7831. return {
  7832. type: "MethodDefinition",
  7833. kind: "method",
  7834. key: { type: "PrivateIdentifier", name: M.key.name },
  7835. value: to_moz(M.value),
  7836. computed: false,
  7837. static: M.static,
  7838. };
  7839. });
  7840. def_to_moz(AST_Class, function To_Moz_Class(M) {
  7841. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  7842. return {
  7843. type: type,
  7844. superClass: to_moz(M.extends),
  7845. id: M.name ? to_moz(M.name) : null,
  7846. body: {
  7847. type: "ClassBody",
  7848. body: M.properties.map(to_moz)
  7849. }
  7850. };
  7851. });
  7852. def_to_moz(AST_ClassStaticBlock, function To_Moz_StaticBlock(M) {
  7853. return {
  7854. type: "StaticBlock",
  7855. body: M.body.map(to_moz),
  7856. };
  7857. });
  7858. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  7859. return {
  7860. type: "MetaProperty",
  7861. meta: {
  7862. type: "Identifier",
  7863. name: "new"
  7864. },
  7865. property: {
  7866. type: "Identifier",
  7867. name: "target"
  7868. }
  7869. };
  7870. });
  7871. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  7872. if (
  7873. (M instanceof AST_SymbolMethod && parent.quote) ||
  7874. ((
  7875. M instanceof AST_SymbolImportForeign ||
  7876. M instanceof AST_SymbolExportForeign ||
  7877. M instanceof AST_SymbolExport
  7878. ) && M.quote)
  7879. ) {
  7880. return {
  7881. type: "Literal",
  7882. value: M.name
  7883. };
  7884. }
  7885. var def = M.definition();
  7886. return {
  7887. type: "Identifier",
  7888. name: def ? def.mangled_name || def.name : M.name
  7889. };
  7890. });
  7891. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  7892. const pattern = M.value.source;
  7893. const flags = M.value.flags;
  7894. return {
  7895. type: "Literal",
  7896. value: null,
  7897. raw: M.print_to_string(),
  7898. regex: { pattern, flags }
  7899. };
  7900. });
  7901. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  7902. var value = M.value;
  7903. return {
  7904. type: "Literal",
  7905. value: value,
  7906. raw: M.raw || M.print_to_string()
  7907. };
  7908. });
  7909. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  7910. return {
  7911. type: "Identifier",
  7912. name: String(M.value)
  7913. };
  7914. });
  7915. def_to_moz(AST_BigInt, M => ({
  7916. type: "Literal",
  7917. // value cannot be represented natively
  7918. // see: https://github.com/estree/estree/blob/master/es2020.md#bigintliteral
  7919. value: null,
  7920. // `M.value` is a string that may be a hex number representation.
  7921. // but "bigint" property should have only decimal digits
  7922. bigint: typeof BigInt === "function" ? BigInt(M.value).toString() : M.value,
  7923. }));
  7924. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7925. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7926. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  7927. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  7928. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  7929. /* -----[ tools ]----- */
  7930. function my_start_token(moznode) {
  7931. var loc = moznode.loc, start = loc && loc.start;
  7932. var range = moznode.range;
  7933. return new AST_Token(
  7934. "",
  7935. "",
  7936. start && start.line || 0,
  7937. start && start.column || 0,
  7938. range ? range [0] : moznode.start,
  7939. false,
  7940. [],
  7941. [],
  7942. loc && loc.source,
  7943. );
  7944. }
  7945. function my_end_token(moznode) {
  7946. var loc = moznode.loc, end = loc && loc.end;
  7947. var range = moznode.range;
  7948. return new AST_Token(
  7949. "",
  7950. "",
  7951. end && end.line || 0,
  7952. end && end.column || 0,
  7953. range ? range [0] : moznode.end,
  7954. false,
  7955. [],
  7956. [],
  7957. loc && loc.source,
  7958. );
  7959. }
  7960. var FROM_MOZ_STACK = null;
  7961. function from_moz(node) {
  7962. FROM_MOZ_STACK.push(node);
  7963. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  7964. FROM_MOZ_STACK.pop();
  7965. return ret;
  7966. }
  7967. AST_Node.from_mozilla_ast = function(node) {
  7968. var save_stack = FROM_MOZ_STACK;
  7969. FROM_MOZ_STACK = [];
  7970. var ast = from_moz(node);
  7971. FROM_MOZ_STACK = save_stack;
  7972. return ast;
  7973. };
  7974. function set_moz_loc(mynode, moznode) {
  7975. var start = mynode.start;
  7976. var end = mynode.end;
  7977. if (!(start && end)) {
  7978. return moznode;
  7979. }
  7980. if (start.pos != null && end.endpos != null) {
  7981. moznode.range = [start.pos, end.endpos];
  7982. }
  7983. if (start.line) {
  7984. moznode.loc = {
  7985. start: {line: start.line, column: start.col},
  7986. end: end.endline ? {line: end.endline, column: end.endcol} : null
  7987. };
  7988. if (start.file) {
  7989. moznode.loc.source = start.file;
  7990. }
  7991. }
  7992. return moznode;
  7993. }
  7994. function def_to_moz(mytype, handler) {
  7995. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  7996. return set_moz_loc(this, handler(this, parent));
  7997. });
  7998. }
  7999. var TO_MOZ_STACK = null;
  8000. function to_moz(node) {
  8001. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  8002. TO_MOZ_STACK.push(node);
  8003. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  8004. TO_MOZ_STACK.pop();
  8005. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  8006. return ast;
  8007. }
  8008. function to_moz_in_destructuring() {
  8009. var i = TO_MOZ_STACK.length;
  8010. while (i--) {
  8011. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  8012. return true;
  8013. }
  8014. }
  8015. return false;
  8016. }
  8017. function to_moz_block(node) {
  8018. return {
  8019. type: "BlockStatement",
  8020. body: node.body.map(to_moz)
  8021. };
  8022. }
  8023. function to_moz_scope(type, node) {
  8024. var body = node.body.map(to_moz);
  8025. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  8026. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  8027. }
  8028. return {
  8029. type: type,
  8030. body: body
  8031. };
  8032. }
  8033. })();
  8034. // return true if the node at the top of the stack (that means the
  8035. // innermost node in the current output) is lexically the first in
  8036. // a statement.
  8037. function first_in_statement(stack) {
  8038. let node = stack.parent(-1);
  8039. for (let i = 0, p; p = stack.parent(i); i++) {
  8040. if (p instanceof AST_Statement && p.body === node)
  8041. return true;
  8042. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  8043. (p.TYPE === "Call" && p.expression === node) ||
  8044. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  8045. (p instanceof AST_Dot && p.expression === node) ||
  8046. (p instanceof AST_Sub && p.expression === node) ||
  8047. (p instanceof AST_Chain && p.expression === node) ||
  8048. (p instanceof AST_Conditional && p.condition === node) ||
  8049. (p instanceof AST_Binary && p.left === node) ||
  8050. (p instanceof AST_UnaryPostfix && p.expression === node)
  8051. ) {
  8052. node = p;
  8053. } else {
  8054. return false;
  8055. }
  8056. }
  8057. }
  8058. // Returns whether the leftmost item in the expression is an object
  8059. function left_is_object(node) {
  8060. if (node instanceof AST_Object) return true;
  8061. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  8062. if (node.TYPE === "Call") return left_is_object(node.expression);
  8063. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  8064. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  8065. if (node instanceof AST_Chain) return left_is_object(node.expression);
  8066. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  8067. if (node instanceof AST_Binary) return left_is_object(node.left);
  8068. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  8069. return false;
  8070. }
  8071. /***********************************************************************
  8072. A JavaScript tokenizer / parser / beautifier / compressor.
  8073. https://github.com/mishoo/UglifyJS2
  8074. -------------------------------- (C) ---------------------------------
  8075. Author: Mihai Bazon
  8076. <mihai.bazon@gmail.com>
  8077. http://mihai.bazon.net/blog
  8078. Distributed under the BSD license:
  8079. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8080. Redistribution and use in source and binary forms, with or without
  8081. modification, are permitted provided that the following conditions
  8082. are met:
  8083. * Redistributions of source code must retain the above
  8084. copyright notice, this list of conditions and the following
  8085. disclaimer.
  8086. * Redistributions in binary form must reproduce the above
  8087. copyright notice, this list of conditions and the following
  8088. disclaimer in the documentation and/or other materials
  8089. provided with the distribution.
  8090. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8091. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8092. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8093. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8094. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8095. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8096. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8097. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8098. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8099. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8100. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8101. SUCH DAMAGE.
  8102. ***********************************************************************/
  8103. const CODE_LINE_BREAK = 10;
  8104. const CODE_SPACE = 32;
  8105. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/;
  8106. function is_some_comments(comment) {
  8107. // multiline comment
  8108. return (
  8109. (comment.type === "comment2" || comment.type === "comment1")
  8110. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  8111. );
  8112. }
  8113. const ROPE_COMMIT_WHEN = 8 * 1000;
  8114. class Rope {
  8115. constructor() {
  8116. this.committed = "";
  8117. this.current = "";
  8118. }
  8119. append(str) {
  8120. /** When `this.current` is too long, commit it. */
  8121. if (this.current.length > ROPE_COMMIT_WHEN) {
  8122. this.committed += this.current + str;
  8123. this.current = "";
  8124. } else {
  8125. this.current += str;
  8126. }
  8127. }
  8128. insertAt(char, index) {
  8129. const { committed, current } = this;
  8130. if (index < committed.length) {
  8131. this.committed = committed.slice(0, index) + char + committed.slice(index);
  8132. } else if (index === committed.length) {
  8133. this.committed += char;
  8134. } else {
  8135. index -= committed.length;
  8136. this.committed += current.slice(0, index) + char;
  8137. this.current = current.slice(index);
  8138. }
  8139. }
  8140. charAt(index) {
  8141. const { committed } = this;
  8142. if (index < committed.length) return committed[index];
  8143. return this.current[index - committed.length];
  8144. }
  8145. charCodeAt(index) {
  8146. const { committed } = this;
  8147. if (index < committed.length) return committed.charCodeAt(index);
  8148. return this.current.charCodeAt(index - committed.length);
  8149. }
  8150. length() {
  8151. return this.committed.length + this.current.length;
  8152. }
  8153. expectDirective() {
  8154. // /^$|[;{][\s\n]*$/
  8155. let ch, n = this.length();
  8156. if (n <= 0) return true;
  8157. // Skip N whitespace from the end
  8158. while (
  8159. (ch = this.charCodeAt(--n))
  8160. && (ch == CODE_SPACE || ch == CODE_LINE_BREAK)
  8161. );
  8162. // either ";", or "{", or the string ended
  8163. return !ch || ch === 59 || ch === 123;
  8164. }
  8165. hasNLB() {
  8166. let n = this.length() - 1;
  8167. while (n >= 0) {
  8168. const code = this.charCodeAt(n--);
  8169. if (code === CODE_LINE_BREAK) return true;
  8170. if (code !== CODE_SPACE) return false;
  8171. }
  8172. return true;
  8173. }
  8174. toString() {
  8175. return this.committed + this.current;
  8176. }
  8177. }
  8178. function OutputStream(options) {
  8179. var readonly = !options;
  8180. options = defaults(options, {
  8181. ascii_only : false,
  8182. beautify : false,
  8183. braces : false,
  8184. comments : "some",
  8185. ecma : 5,
  8186. ie8 : false,
  8187. indent_level : 4,
  8188. indent_start : 0,
  8189. inline_script : true,
  8190. keep_numbers : false,
  8191. keep_quoted_props : false,
  8192. max_line_len : false,
  8193. preamble : null,
  8194. preserve_annotations : false,
  8195. quote_keys : false,
  8196. quote_style : 0,
  8197. safari10 : false,
  8198. semicolons : true,
  8199. shebang : true,
  8200. shorthand : undefined,
  8201. source_map : null,
  8202. webkit : false,
  8203. width : 80,
  8204. wrap_iife : false,
  8205. wrap_func_args : true,
  8206. _destroy_ast : false
  8207. }, true);
  8208. if (options.shorthand === undefined)
  8209. options.shorthand = options.ecma > 5;
  8210. // Convert comment option to RegExp if necessary and set up comments filter
  8211. var comment_filter = return_false; // Default case, throw all comments away
  8212. if (options.comments) {
  8213. let comments = options.comments;
  8214. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  8215. var regex_pos = options.comments.lastIndexOf("/");
  8216. comments = new RegExp(
  8217. options.comments.substr(1, regex_pos - 1),
  8218. options.comments.substr(regex_pos + 1)
  8219. );
  8220. }
  8221. if (comments instanceof RegExp) {
  8222. comment_filter = function(comment) {
  8223. return comment.type != "comment5" && comments.test(comment.value);
  8224. };
  8225. } else if (typeof comments === "function") {
  8226. comment_filter = function(comment) {
  8227. return comment.type != "comment5" && comments(this, comment);
  8228. };
  8229. } else if (comments === "some") {
  8230. comment_filter = is_some_comments;
  8231. } else { // NOTE includes "all" option
  8232. comment_filter = return_true;
  8233. }
  8234. }
  8235. if (options.preserve_annotations) {
  8236. let prev_comment_filter = comment_filter;
  8237. comment_filter = function (comment) {
  8238. return r_annotation.test(comment.value) || prev_comment_filter.apply(this, arguments);
  8239. };
  8240. }
  8241. var indentation = 0;
  8242. var current_col = 0;
  8243. var current_line = 1;
  8244. var current_pos = 0;
  8245. var OUTPUT = new Rope();
  8246. let printed_comments = new Set();
  8247. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  8248. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  8249. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  8250. var code = get_full_char_code(ch, 0).toString(16);
  8251. return "\\u{" + code + "}";
  8252. });
  8253. }
  8254. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  8255. var code = ch.charCodeAt(0).toString(16);
  8256. if (code.length <= 2 && !identifier) {
  8257. while (code.length < 2) code = "0" + code;
  8258. return "\\x" + code;
  8259. } else {
  8260. while (code.length < 4) code = "0" + code;
  8261. return "\\u" + code;
  8262. }
  8263. });
  8264. } : function(str) {
  8265. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  8266. if (lone) {
  8267. return "\\u" + lone.charCodeAt(0).toString(16);
  8268. }
  8269. return match;
  8270. });
  8271. };
  8272. function make_string(str, quote) {
  8273. var dq = 0, sq = 0;
  8274. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  8275. function(s, i) {
  8276. switch (s) {
  8277. case '"': ++dq; return '"';
  8278. case "'": ++sq; return "'";
  8279. case "\\": return "\\\\";
  8280. case "\n": return "\\n";
  8281. case "\r": return "\\r";
  8282. case "\t": return "\\t";
  8283. case "\b": return "\\b";
  8284. case "\f": return "\\f";
  8285. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  8286. case "\u2028": return "\\u2028";
  8287. case "\u2029": return "\\u2029";
  8288. case "\ufeff": return "\\ufeff";
  8289. case "\0":
  8290. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  8291. }
  8292. return s;
  8293. });
  8294. function quote_single() {
  8295. return "'" + str.replace(/\x27/g, "\\'") + "'";
  8296. }
  8297. function quote_double() {
  8298. return '"' + str.replace(/\x22/g, '\\"') + '"';
  8299. }
  8300. function quote_template() {
  8301. return "`" + str.replace(/`/g, "\\`") + "`";
  8302. }
  8303. str = to_utf8(str);
  8304. if (quote === "`") return quote_template();
  8305. switch (options.quote_style) {
  8306. case 1:
  8307. return quote_single();
  8308. case 2:
  8309. return quote_double();
  8310. case 3:
  8311. return quote == "'" ? quote_single() : quote_double();
  8312. default:
  8313. return dq > sq ? quote_single() : quote_double();
  8314. }
  8315. }
  8316. function encode_string(str, quote) {
  8317. var ret = make_string(str, quote);
  8318. if (options.inline_script) {
  8319. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  8320. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  8321. ret = ret.replace(/--\x3e/g, "--\\x3e");
  8322. }
  8323. return ret;
  8324. }
  8325. function make_name(name) {
  8326. name = name.toString();
  8327. name = to_utf8(name, true);
  8328. return name;
  8329. }
  8330. function make_indent(back) {
  8331. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  8332. }
  8333. /* -----[ beautification/minification ]----- */
  8334. var has_parens = false;
  8335. var might_need_space = false;
  8336. var might_need_semicolon = false;
  8337. var might_add_newline = 0;
  8338. var need_newline_indented = false;
  8339. var need_space = false;
  8340. var newline_insert = -1;
  8341. var last = "";
  8342. var mapping_token, mapping_name, mappings = options.source_map && [];
  8343. var do_add_mapping = mappings ? function() {
  8344. mappings.forEach(function(mapping) {
  8345. try {
  8346. let { name, token } = mapping;
  8347. if (name !== false) {
  8348. if (token.type == "name" || token.type === "privatename") {
  8349. name = token.value;
  8350. } else if (name instanceof AST_Symbol) {
  8351. name = token.type === "string" ? token.value : name.name;
  8352. }
  8353. }
  8354. options.source_map.add(
  8355. mapping.token.file,
  8356. mapping.line, mapping.col,
  8357. mapping.token.line, mapping.token.col,
  8358. is_basic_identifier_string(name) ? name : undefined
  8359. );
  8360. } catch(ex) {
  8361. // Ignore bad mapping
  8362. }
  8363. });
  8364. mappings = [];
  8365. } : noop;
  8366. var ensure_line_len = options.max_line_len ? function() {
  8367. if (current_col > options.max_line_len) {
  8368. if (might_add_newline) {
  8369. OUTPUT.insertAt("\n", might_add_newline);
  8370. const len_after_newline = OUTPUT.length() - might_add_newline - 1;
  8371. if (mappings) {
  8372. var delta = len_after_newline - current_col;
  8373. mappings.forEach(function(mapping) {
  8374. mapping.line++;
  8375. mapping.col += delta;
  8376. });
  8377. }
  8378. current_line++;
  8379. current_pos++;
  8380. current_col = len_after_newline;
  8381. }
  8382. }
  8383. if (might_add_newline) {
  8384. might_add_newline = 0;
  8385. do_add_mapping();
  8386. }
  8387. } : noop;
  8388. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  8389. function print(str) {
  8390. str = String(str);
  8391. var ch = get_full_char(str, 0);
  8392. if (need_newline_indented && ch) {
  8393. need_newline_indented = false;
  8394. if (ch !== "\n") {
  8395. print("\n");
  8396. indent();
  8397. }
  8398. }
  8399. if (need_space && ch) {
  8400. need_space = false;
  8401. if (!/[\s;})]/.test(ch)) {
  8402. space();
  8403. }
  8404. }
  8405. newline_insert = -1;
  8406. var prev = last.charAt(last.length - 1);
  8407. if (might_need_semicolon) {
  8408. might_need_semicolon = false;
  8409. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  8410. if (options.semicolons || requireSemicolonChars.has(ch)) {
  8411. OUTPUT.append(";");
  8412. current_col++;
  8413. current_pos++;
  8414. } else {
  8415. ensure_line_len();
  8416. if (current_col > 0) {
  8417. OUTPUT.append("\n");
  8418. current_pos++;
  8419. current_line++;
  8420. current_col = 0;
  8421. }
  8422. if (/^\s+$/.test(str)) {
  8423. // reset the semicolon flag, since we didn't print one
  8424. // now and might still have to later
  8425. might_need_semicolon = true;
  8426. }
  8427. }
  8428. if (!options.beautify)
  8429. might_need_space = false;
  8430. }
  8431. }
  8432. if (might_need_space) {
  8433. if ((is_identifier_char(prev)
  8434. && (is_identifier_char(ch) || ch == "\\"))
  8435. || (ch == "/" && ch == prev)
  8436. || ((ch == "+" || ch == "-") && ch == last)
  8437. ) {
  8438. OUTPUT.append(" ");
  8439. current_col++;
  8440. current_pos++;
  8441. }
  8442. might_need_space = false;
  8443. }
  8444. if (mapping_token) {
  8445. mappings.push({
  8446. token: mapping_token,
  8447. name: mapping_name,
  8448. line: current_line,
  8449. col: current_col
  8450. });
  8451. mapping_token = false;
  8452. if (!might_add_newline) do_add_mapping();
  8453. }
  8454. OUTPUT.append(str);
  8455. has_parens = str[str.length - 1] == "(";
  8456. current_pos += str.length;
  8457. var a = str.split(/\r?\n/), n = a.length - 1;
  8458. current_line += n;
  8459. current_col += a[0].length;
  8460. if (n > 0) {
  8461. ensure_line_len();
  8462. current_col = a[n].length;
  8463. }
  8464. last = str;
  8465. }
  8466. var star = function() {
  8467. print("*");
  8468. };
  8469. var space = options.beautify ? function() {
  8470. print(" ");
  8471. } : function() {
  8472. might_need_space = true;
  8473. };
  8474. var indent = options.beautify ? function(half) {
  8475. if (options.beautify) {
  8476. print(make_indent(half ? 0.5 : 0));
  8477. }
  8478. } : noop;
  8479. var with_indent = options.beautify ? function(col, cont) {
  8480. if (col === true) col = next_indent();
  8481. var save_indentation = indentation;
  8482. indentation = col;
  8483. var ret = cont();
  8484. indentation = save_indentation;
  8485. return ret;
  8486. } : function(col, cont) { return cont(); };
  8487. var newline = options.beautify ? function() {
  8488. if (newline_insert < 0) return print("\n");
  8489. if (OUTPUT.charAt(newline_insert) != "\n") {
  8490. OUTPUT.insertAt("\n", newline_insert);
  8491. current_pos++;
  8492. current_line++;
  8493. }
  8494. newline_insert++;
  8495. } : options.max_line_len ? function() {
  8496. ensure_line_len();
  8497. might_add_newline = OUTPUT.length();
  8498. } : noop;
  8499. var semicolon = options.beautify ? function() {
  8500. print(";");
  8501. } : function() {
  8502. might_need_semicolon = true;
  8503. };
  8504. function force_semicolon() {
  8505. might_need_semicolon = false;
  8506. print(";");
  8507. }
  8508. function next_indent() {
  8509. return indentation + options.indent_level;
  8510. }
  8511. function with_block(cont) {
  8512. var ret;
  8513. print("{");
  8514. newline();
  8515. with_indent(next_indent(), function() {
  8516. ret = cont();
  8517. });
  8518. indent();
  8519. print("}");
  8520. return ret;
  8521. }
  8522. function with_parens(cont) {
  8523. print("(");
  8524. //XXX: still nice to have that for argument lists
  8525. //var ret = with_indent(current_col, cont);
  8526. var ret = cont();
  8527. print(")");
  8528. return ret;
  8529. }
  8530. function with_square(cont) {
  8531. print("[");
  8532. //var ret = with_indent(current_col, cont);
  8533. var ret = cont();
  8534. print("]");
  8535. return ret;
  8536. }
  8537. function comma() {
  8538. print(",");
  8539. space();
  8540. }
  8541. function colon() {
  8542. print(":");
  8543. space();
  8544. }
  8545. var add_mapping = mappings ? function(token, name) {
  8546. mapping_token = token;
  8547. mapping_name = name;
  8548. } : noop;
  8549. function get() {
  8550. if (might_add_newline) {
  8551. ensure_line_len();
  8552. }
  8553. return OUTPUT.toString();
  8554. }
  8555. function filter_comment(comment) {
  8556. if (!options.preserve_annotations) {
  8557. comment = comment.replace(r_annotation, " ");
  8558. }
  8559. if (/^\s*$/.test(comment)) {
  8560. return "";
  8561. }
  8562. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  8563. }
  8564. function prepend_comments(node) {
  8565. var self = this;
  8566. var start = node.start;
  8567. if (!start) return;
  8568. var printed_comments = self.printed_comments;
  8569. // There cannot be a newline between return/yield and its value.
  8570. const keyword_with_value =
  8571. node instanceof AST_Exit && node.value
  8572. || (node instanceof AST_Await || node instanceof AST_Yield)
  8573. && node.expression;
  8574. if (
  8575. start.comments_before
  8576. && printed_comments.has(start.comments_before)
  8577. ) {
  8578. if (keyword_with_value) {
  8579. start.comments_before = [];
  8580. } else {
  8581. return;
  8582. }
  8583. }
  8584. var comments = start.comments_before;
  8585. if (!comments) {
  8586. comments = start.comments_before = [];
  8587. }
  8588. printed_comments.add(comments);
  8589. if (keyword_with_value) {
  8590. var tw = new TreeWalker(function(node) {
  8591. var parent = tw.parent();
  8592. if (parent instanceof AST_Exit
  8593. || parent instanceof AST_Await
  8594. || parent instanceof AST_Yield
  8595. || parent instanceof AST_Binary && parent.left === node
  8596. || parent.TYPE == "Call" && parent.expression === node
  8597. || parent instanceof AST_Conditional && parent.condition === node
  8598. || parent instanceof AST_Dot && parent.expression === node
  8599. || parent instanceof AST_Sequence && parent.expressions[0] === node
  8600. || parent instanceof AST_Sub && parent.expression === node
  8601. || parent instanceof AST_UnaryPostfix) {
  8602. if (!node.start) return;
  8603. var text = node.start.comments_before;
  8604. if (text && !printed_comments.has(text)) {
  8605. printed_comments.add(text);
  8606. comments = comments.concat(text);
  8607. }
  8608. } else {
  8609. return true;
  8610. }
  8611. });
  8612. tw.push(node);
  8613. keyword_with_value.walk(tw);
  8614. }
  8615. if (current_pos == 0) {
  8616. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  8617. && !printed_comments.has(comments[0])) {
  8618. print("#!" + comments.shift().value + "\n");
  8619. indent();
  8620. }
  8621. var preamble = options.preamble;
  8622. if (preamble) {
  8623. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  8624. }
  8625. }
  8626. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  8627. if (comments.length == 0) return;
  8628. var last_nlb = OUTPUT.hasNLB();
  8629. comments.forEach(function(c, i) {
  8630. printed_comments.add(c);
  8631. if (!last_nlb) {
  8632. if (c.nlb) {
  8633. print("\n");
  8634. indent();
  8635. last_nlb = true;
  8636. } else if (i > 0) {
  8637. space();
  8638. }
  8639. }
  8640. if (/comment[134]/.test(c.type)) {
  8641. var value = filter_comment(c.value);
  8642. if (value) {
  8643. print("//" + value + "\n");
  8644. indent();
  8645. }
  8646. last_nlb = true;
  8647. } else if (c.type == "comment2") {
  8648. var value = filter_comment(c.value);
  8649. if (value) {
  8650. print("/*" + value + "*/");
  8651. }
  8652. last_nlb = false;
  8653. }
  8654. });
  8655. if (!last_nlb) {
  8656. if (start.nlb) {
  8657. print("\n");
  8658. indent();
  8659. } else {
  8660. space();
  8661. }
  8662. }
  8663. }
  8664. function append_comments(node, tail) {
  8665. var self = this;
  8666. var token = node.end;
  8667. if (!token) return;
  8668. var printed_comments = self.printed_comments;
  8669. var comments = token[tail ? "comments_before" : "comments_after"];
  8670. if (!comments || printed_comments.has(comments)) return;
  8671. if (!(node instanceof AST_Statement || comments.every((c) =>
  8672. !/comment[134]/.test(c.type)
  8673. ))) return;
  8674. printed_comments.add(comments);
  8675. var insert = OUTPUT.length();
  8676. comments.filter(comment_filter, node).forEach(function(c, i) {
  8677. if (printed_comments.has(c)) return;
  8678. printed_comments.add(c);
  8679. need_space = false;
  8680. if (need_newline_indented) {
  8681. print("\n");
  8682. indent();
  8683. need_newline_indented = false;
  8684. } else if (c.nlb && (i > 0 || !OUTPUT.hasNLB())) {
  8685. print("\n");
  8686. indent();
  8687. } else if (i > 0 || !tail) {
  8688. space();
  8689. }
  8690. if (/comment[134]/.test(c.type)) {
  8691. const value = filter_comment(c.value);
  8692. if (value) {
  8693. print("//" + value);
  8694. }
  8695. need_newline_indented = true;
  8696. } else if (c.type == "comment2") {
  8697. const value = filter_comment(c.value);
  8698. if (value) {
  8699. print("/*" + value + "*/");
  8700. }
  8701. need_space = true;
  8702. }
  8703. });
  8704. if (OUTPUT.length() > insert) newline_insert = insert;
  8705. }
  8706. /**
  8707. * When output.option("_destroy_ast") is enabled, destroy the function.
  8708. * Call this after printing it.
  8709. */
  8710. const gc_scope =
  8711. options["_destroy_ast"]
  8712. ? function gc_scope(scope) {
  8713. scope.body.length = 0;
  8714. scope.argnames.length = 0;
  8715. }
  8716. : noop;
  8717. var stack = [];
  8718. return {
  8719. get : get,
  8720. toString : get,
  8721. indent : indent,
  8722. in_directive : false,
  8723. use_asm : null,
  8724. active_scope : null,
  8725. indentation : function() { return indentation; },
  8726. current_width : function() { return current_col - indentation; },
  8727. should_break : function() { return options.width && this.current_width() >= options.width; },
  8728. has_parens : function() { return has_parens; },
  8729. newline : newline,
  8730. print : print,
  8731. star : star,
  8732. space : space,
  8733. comma : comma,
  8734. colon : colon,
  8735. last : function() { return last; },
  8736. semicolon : semicolon,
  8737. force_semicolon : force_semicolon,
  8738. to_utf8 : to_utf8,
  8739. print_name : function(name) { print(make_name(name)); },
  8740. print_string : function(str, quote, escape_directive) {
  8741. var encoded = encode_string(str, quote);
  8742. if (escape_directive === true && !encoded.includes("\\")) {
  8743. // Insert semicolons to break directive prologue
  8744. if (!OUTPUT.expectDirective()) {
  8745. force_semicolon();
  8746. }
  8747. force_semicolon();
  8748. }
  8749. print(encoded);
  8750. },
  8751. print_template_string_chars: function(str) {
  8752. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  8753. return print(encoded.substr(1, encoded.length - 2));
  8754. },
  8755. encode_string : encode_string,
  8756. next_indent : next_indent,
  8757. with_indent : with_indent,
  8758. with_block : with_block,
  8759. with_parens : with_parens,
  8760. with_square : with_square,
  8761. add_mapping : add_mapping,
  8762. option : function(opt) { return options[opt]; },
  8763. gc_scope,
  8764. printed_comments: printed_comments,
  8765. prepend_comments: readonly ? noop : prepend_comments,
  8766. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  8767. line : function() { return current_line; },
  8768. col : function() { return current_col; },
  8769. pos : function() { return current_pos; },
  8770. push_node : function(node) { stack.push(node); },
  8771. pop_node : function() { return stack.pop(); },
  8772. parent : function(n) {
  8773. return stack[stack.length - 2 - (n || 0)];
  8774. }
  8775. };
  8776. }
  8777. /* -----[ code generators ]----- */
  8778. (function() {
  8779. /* -----[ utils ]----- */
  8780. function DEFPRINT(nodetype, generator) {
  8781. nodetype.DEFMETHOD("_codegen", generator);
  8782. }
  8783. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  8784. var self = this, generator = self._codegen;
  8785. if (self instanceof AST_Scope) {
  8786. output.active_scope = self;
  8787. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  8788. output.use_asm = output.active_scope;
  8789. }
  8790. function doit() {
  8791. output.prepend_comments(self);
  8792. self.add_source_map(output);
  8793. generator(self, output);
  8794. output.append_comments(self);
  8795. }
  8796. output.push_node(self);
  8797. if (force_parens || self.needs_parens(output)) {
  8798. output.with_parens(doit);
  8799. } else {
  8800. doit();
  8801. }
  8802. output.pop_node();
  8803. if (self === output.use_asm) {
  8804. output.use_asm = null;
  8805. }
  8806. });
  8807. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  8808. AST_Node.DEFMETHOD("print_to_string", function(options) {
  8809. var output = OutputStream(options);
  8810. this.print(output);
  8811. return output.get();
  8812. });
  8813. /* -----[ PARENTHESES ]----- */
  8814. function PARENS(nodetype, func) {
  8815. if (Array.isArray(nodetype)) {
  8816. nodetype.forEach(function(nodetype) {
  8817. PARENS(nodetype, func);
  8818. });
  8819. } else {
  8820. nodetype.DEFMETHOD("needs_parens", func);
  8821. }
  8822. }
  8823. PARENS(AST_Node, return_false);
  8824. // a function expression needs parens around it when it's provably
  8825. // the first token to appear in a statement.
  8826. PARENS(AST_Function, function(output) {
  8827. if (!output.has_parens() && first_in_statement(output)) {
  8828. return true;
  8829. }
  8830. if (output.option("webkit")) {
  8831. var p = output.parent();
  8832. if (p instanceof AST_PropAccess && p.expression === this) {
  8833. return true;
  8834. }
  8835. }
  8836. if (output.option("wrap_iife")) {
  8837. var p = output.parent();
  8838. if (p instanceof AST_Call && p.expression === this) {
  8839. return true;
  8840. }
  8841. }
  8842. if (output.option("wrap_func_args")) {
  8843. var p = output.parent();
  8844. if (p instanceof AST_Call && p.args.includes(this)) {
  8845. return true;
  8846. }
  8847. }
  8848. return false;
  8849. });
  8850. PARENS(AST_Arrow, function(output) {
  8851. var p = output.parent();
  8852. if (
  8853. output.option("wrap_func_args")
  8854. && p instanceof AST_Call
  8855. && p.args.includes(this)
  8856. ) {
  8857. return true;
  8858. }
  8859. return p instanceof AST_PropAccess && p.expression === this
  8860. || p instanceof AST_Conditional && p.condition === this;
  8861. });
  8862. // same goes for an object literal (as in AST_Function), because
  8863. // otherwise {...} would be interpreted as a block of code.
  8864. PARENS(AST_Object, function(output) {
  8865. return !output.has_parens() && first_in_statement(output);
  8866. });
  8867. PARENS(AST_ClassExpression, first_in_statement);
  8868. PARENS(AST_Unary, function(output) {
  8869. var p = output.parent();
  8870. return p instanceof AST_PropAccess && p.expression === this
  8871. || p instanceof AST_Call && p.expression === this
  8872. || p instanceof AST_Binary
  8873. && p.operator === "**"
  8874. && this instanceof AST_UnaryPrefix
  8875. && p.left === this
  8876. && this.operator !== "++"
  8877. && this.operator !== "--";
  8878. });
  8879. PARENS(AST_Await, function(output) {
  8880. var p = output.parent();
  8881. return p instanceof AST_PropAccess && p.expression === this
  8882. || p instanceof AST_Call && p.expression === this
  8883. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  8884. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  8885. });
  8886. PARENS(AST_Sequence, function(output) {
  8887. var p = output.parent();
  8888. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  8889. || p instanceof AST_Unary // !(foo, bar, baz)
  8890. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  8891. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  8892. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  8893. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  8894. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  8895. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  8896. * ==> 20 (side effect, set a := 10 and b := 20) */
  8897. || p instanceof AST_Arrow // x => (x, x)
  8898. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  8899. || p instanceof AST_Expansion // [...(a, b)]
  8900. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  8901. || p instanceof AST_Yield // yield (foo, bar)
  8902. || p instanceof AST_Export // export default (foo, bar)
  8903. ;
  8904. });
  8905. PARENS(AST_Binary, function(output) {
  8906. var p = output.parent();
  8907. // (foo && bar)()
  8908. if (p instanceof AST_Call && p.expression === this)
  8909. return true;
  8910. // typeof (foo && bar)
  8911. if (p instanceof AST_Unary)
  8912. return true;
  8913. // (foo && bar)["prop"], (foo && bar).prop
  8914. if (p instanceof AST_PropAccess && p.expression === this)
  8915. return true;
  8916. // this deals with precedence: 3 * (2 + 1)
  8917. if (p instanceof AST_Binary) {
  8918. const parent_op = p.operator;
  8919. const op = this.operator;
  8920. // It is forbidden for ?? to be used with || or && without parens.
  8921. if (op === "??" && (parent_op === "||" || parent_op === "&&")) {
  8922. return true;
  8923. }
  8924. if (parent_op === "??" && (op === "||" || op === "&&")) {
  8925. return true;
  8926. }
  8927. const pp = PRECEDENCE[parent_op];
  8928. const sp = PRECEDENCE[op];
  8929. if (pp > sp
  8930. || (pp == sp
  8931. && (this === p.right || parent_op == "**"))) {
  8932. return true;
  8933. }
  8934. }
  8935. if (p instanceof AST_PrivateIn) {
  8936. const op = this.operator;
  8937. const pp = PRECEDENCE["in"];
  8938. const sp = PRECEDENCE[op];
  8939. if (pp > sp || (pp == sp && this === p.value)) {
  8940. return true;
  8941. }
  8942. }
  8943. });
  8944. PARENS(AST_PrivateIn, function(output) {
  8945. var p = output.parent();
  8946. // (#x in this)()
  8947. if (p instanceof AST_Call && p.expression === this) {
  8948. return true;
  8949. }
  8950. // typeof (#x in this)
  8951. if (p instanceof AST_Unary) {
  8952. return true;
  8953. }
  8954. // (#x in this)["prop"], (#x in this).prop
  8955. if (p instanceof AST_PropAccess && p.expression === this) {
  8956. return true;
  8957. }
  8958. // same precedence as regular in operator
  8959. if (p instanceof AST_Binary) {
  8960. const parent_op = p.operator;
  8961. const pp = PRECEDENCE[parent_op];
  8962. const sp = PRECEDENCE["in"];
  8963. if (pp > sp
  8964. || (pp == sp
  8965. && (this === p.right || parent_op == "**"))) {
  8966. return true;
  8967. }
  8968. }
  8969. // rules are the same as binary in, but the class differs
  8970. if (p instanceof AST_PrivateIn && this === p.value) {
  8971. return true;
  8972. }
  8973. });
  8974. PARENS(AST_Yield, function(output) {
  8975. var p = output.parent();
  8976. // (yield 1) + (yield 2)
  8977. // a = yield 3
  8978. if (p instanceof AST_Binary && p.operator !== "=")
  8979. return true;
  8980. // (yield 1)()
  8981. // new (yield 1)()
  8982. if (p instanceof AST_Call && p.expression === this)
  8983. return true;
  8984. // (yield 1) ? yield 2 : yield 3
  8985. if (p instanceof AST_Conditional && p.condition === this)
  8986. return true;
  8987. // -(yield 4)
  8988. if (p instanceof AST_Unary)
  8989. return true;
  8990. // (yield x).foo
  8991. // (yield x)['foo']
  8992. if (p instanceof AST_PropAccess && p.expression === this)
  8993. return true;
  8994. });
  8995. PARENS(AST_Chain, function(output) {
  8996. var p = output.parent();
  8997. if (!(p instanceof AST_Call || p instanceof AST_PropAccess)) return false;
  8998. return p.expression === this;
  8999. });
  9000. PARENS(AST_PropAccess, function(output) {
  9001. var p = output.parent();
  9002. if (p instanceof AST_New && p.expression === this) {
  9003. // i.e. new (foo.bar().baz)
  9004. //
  9005. // if there's one call into this subtree, then we need
  9006. // parens around it too, otherwise the call will be
  9007. // interpreted as passing the arguments to the upper New
  9008. // expression.
  9009. return walk(this, node => {
  9010. if (node instanceof AST_Scope) return true;
  9011. if (node instanceof AST_Call) {
  9012. return walk_abort; // makes walk() return true.
  9013. }
  9014. });
  9015. }
  9016. });
  9017. PARENS(AST_Call, function(output) {
  9018. var p = output.parent(), p1;
  9019. if (p instanceof AST_New && p.expression === this
  9020. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  9021. return true;
  9022. // workaround for Safari bug.
  9023. // https://bugs.webkit.org/show_bug.cgi?id=123506
  9024. return this.expression instanceof AST_Function
  9025. && p instanceof AST_PropAccess
  9026. && p.expression === this
  9027. && (p1 = output.parent(1)) instanceof AST_Assign
  9028. && p1.left === p;
  9029. });
  9030. PARENS(AST_New, function(output) {
  9031. var p = output.parent();
  9032. if (this.args.length === 0
  9033. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  9034. || p instanceof AST_Call && p.expression === this
  9035. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  9036. return true;
  9037. });
  9038. PARENS(AST_Number, function(output) {
  9039. var p = output.parent();
  9040. if (p instanceof AST_PropAccess && p.expression === this) {
  9041. var value = this.getValue();
  9042. if (value < 0 || /^0/.test(make_num(value))) {
  9043. return true;
  9044. }
  9045. }
  9046. });
  9047. PARENS(AST_BigInt, function(output) {
  9048. var p = output.parent();
  9049. if (p instanceof AST_PropAccess && p.expression === this) {
  9050. var value = this.getValue();
  9051. if (value.startsWith("-")) {
  9052. return true;
  9053. }
  9054. }
  9055. });
  9056. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  9057. var p = output.parent();
  9058. // !(a = false) → true
  9059. if (p instanceof AST_Unary)
  9060. return true;
  9061. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  9062. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  9063. return true;
  9064. // (a = func)() —or— new (a = Object)()
  9065. if (p instanceof AST_Call && p.expression === this)
  9066. return true;
  9067. // (a = foo) ? bar : baz
  9068. if (p instanceof AST_Conditional && p.condition === this)
  9069. return true;
  9070. // (a = foo)["prop"] —or— (a = foo).prop
  9071. if (p instanceof AST_PropAccess && p.expression === this)
  9072. return true;
  9073. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  9074. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  9075. return true;
  9076. });
  9077. /* -----[ PRINTERS ]----- */
  9078. DEFPRINT(AST_Directive, function(self, output) {
  9079. output.print_string(self.value, self.quote);
  9080. output.semicolon();
  9081. });
  9082. DEFPRINT(AST_Expansion, function (self, output) {
  9083. output.print("...");
  9084. self.expression.print(output);
  9085. });
  9086. DEFPRINT(AST_Destructuring, function (self, output) {
  9087. output.print(self.is_array ? "[" : "{");
  9088. var len = self.names.length;
  9089. self.names.forEach(function (name, i) {
  9090. if (i > 0) output.comma();
  9091. name.print(output);
  9092. // If the final element is a hole, we need to make sure it
  9093. // doesn't look like a trailing comma, by inserting an actual
  9094. // trailing comma.
  9095. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  9096. });
  9097. output.print(self.is_array ? "]" : "}");
  9098. });
  9099. DEFPRINT(AST_Debugger, function(self, output) {
  9100. output.print("debugger");
  9101. output.semicolon();
  9102. });
  9103. /* -----[ statements ]----- */
  9104. function display_body(body, is_toplevel, output, allow_directives) {
  9105. var last = body.length - 1;
  9106. output.in_directive = allow_directives;
  9107. body.forEach(function(stmt, i) {
  9108. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  9109. stmt instanceof AST_EmptyStatement ||
  9110. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  9111. )) {
  9112. output.in_directive = false;
  9113. }
  9114. if (!(stmt instanceof AST_EmptyStatement)) {
  9115. output.indent();
  9116. stmt.print(output);
  9117. if (!(i == last && is_toplevel)) {
  9118. output.newline();
  9119. if (is_toplevel) output.newline();
  9120. }
  9121. }
  9122. if (output.in_directive === true &&
  9123. stmt instanceof AST_SimpleStatement &&
  9124. stmt.body instanceof AST_String
  9125. ) {
  9126. output.in_directive = false;
  9127. }
  9128. });
  9129. output.in_directive = false;
  9130. }
  9131. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  9132. print_maybe_braced_body(this.body, output);
  9133. });
  9134. DEFPRINT(AST_Statement, function(self, output) {
  9135. self.body.print(output);
  9136. output.semicolon();
  9137. });
  9138. DEFPRINT(AST_Toplevel, function(self, output) {
  9139. display_body(self.body, true, output, true);
  9140. output.print("");
  9141. });
  9142. DEFPRINT(AST_LabeledStatement, function(self, output) {
  9143. self.label.print(output);
  9144. output.colon();
  9145. self.body.print(output);
  9146. });
  9147. DEFPRINT(AST_SimpleStatement, function(self, output) {
  9148. self.body.print(output);
  9149. output.semicolon();
  9150. });
  9151. function print_braced_empty(self, output) {
  9152. output.print("{");
  9153. output.with_indent(output.next_indent(), function() {
  9154. output.append_comments(self, true);
  9155. });
  9156. output.add_mapping(self.end);
  9157. output.print("}");
  9158. }
  9159. function print_braced(self, output, allow_directives) {
  9160. if (self.body.length > 0) {
  9161. output.with_block(function() {
  9162. display_body(self.body, false, output, allow_directives);
  9163. output.add_mapping(self.end);
  9164. });
  9165. } else print_braced_empty(self, output);
  9166. }
  9167. DEFPRINT(AST_BlockStatement, function(self, output) {
  9168. print_braced(self, output);
  9169. });
  9170. DEFPRINT(AST_EmptyStatement, function(self, output) {
  9171. output.semicolon();
  9172. });
  9173. DEFPRINT(AST_Do, function(self, output) {
  9174. output.print("do");
  9175. output.space();
  9176. make_block(self.body, output);
  9177. output.space();
  9178. output.print("while");
  9179. output.space();
  9180. output.with_parens(function() {
  9181. self.condition.print(output);
  9182. });
  9183. output.semicolon();
  9184. });
  9185. DEFPRINT(AST_While, function(self, output) {
  9186. output.print("while");
  9187. output.space();
  9188. output.with_parens(function() {
  9189. self.condition.print(output);
  9190. });
  9191. output.space();
  9192. self._do_print_body(output);
  9193. });
  9194. DEFPRINT(AST_For, function(self, output) {
  9195. output.print("for");
  9196. output.space();
  9197. output.with_parens(function() {
  9198. if (self.init) {
  9199. if (self.init instanceof AST_Definitions) {
  9200. self.init.print(output);
  9201. } else {
  9202. parenthesize_for_noin(self.init, output, true);
  9203. }
  9204. output.print(";");
  9205. output.space();
  9206. } else {
  9207. output.print(";");
  9208. }
  9209. if (self.condition) {
  9210. self.condition.print(output);
  9211. output.print(";");
  9212. output.space();
  9213. } else {
  9214. output.print(";");
  9215. }
  9216. if (self.step) {
  9217. self.step.print(output);
  9218. }
  9219. });
  9220. output.space();
  9221. self._do_print_body(output);
  9222. });
  9223. DEFPRINT(AST_ForIn, function(self, output) {
  9224. output.print("for");
  9225. if (self.await) {
  9226. output.space();
  9227. output.print("await");
  9228. }
  9229. output.space();
  9230. output.with_parens(function() {
  9231. self.init.print(output);
  9232. output.space();
  9233. output.print(self instanceof AST_ForOf ? "of" : "in");
  9234. output.space();
  9235. self.object.print(output);
  9236. });
  9237. output.space();
  9238. self._do_print_body(output);
  9239. });
  9240. DEFPRINT(AST_With, function(self, output) {
  9241. output.print("with");
  9242. output.space();
  9243. output.with_parens(function() {
  9244. self.expression.print(output);
  9245. });
  9246. output.space();
  9247. self._do_print_body(output);
  9248. });
  9249. /* -----[ functions ]----- */
  9250. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  9251. var self = this;
  9252. if (!nokeyword) {
  9253. if (self.async) {
  9254. output.print("async");
  9255. output.space();
  9256. }
  9257. output.print("function");
  9258. if (self.is_generator) {
  9259. output.star();
  9260. }
  9261. if (self.name) {
  9262. output.space();
  9263. }
  9264. }
  9265. if (self.name instanceof AST_Symbol) {
  9266. self.name.print(output);
  9267. } else if (nokeyword && self.name instanceof AST_Node) {
  9268. output.with_square(function() {
  9269. self.name.print(output); // Computed method name
  9270. });
  9271. }
  9272. output.with_parens(function() {
  9273. self.argnames.forEach(function(arg, i) {
  9274. if (i) output.comma();
  9275. arg.print(output);
  9276. });
  9277. });
  9278. output.space();
  9279. print_braced(self, output, true);
  9280. });
  9281. DEFPRINT(AST_Lambda, function(self, output) {
  9282. self._do_print(output);
  9283. output.gc_scope(self);
  9284. });
  9285. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  9286. var tag = self.prefix;
  9287. var parenthesize_tag = tag instanceof AST_Lambda
  9288. || tag instanceof AST_Binary
  9289. || tag instanceof AST_Conditional
  9290. || tag instanceof AST_Sequence
  9291. || tag instanceof AST_Unary
  9292. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  9293. if (parenthesize_tag) output.print("(");
  9294. self.prefix.print(output);
  9295. if (parenthesize_tag) output.print(")");
  9296. self.template_string.print(output);
  9297. });
  9298. DEFPRINT(AST_TemplateString, function(self, output) {
  9299. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  9300. output.print("`");
  9301. for (var i = 0; i < self.segments.length; i++) {
  9302. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  9303. output.print("${");
  9304. self.segments[i].print(output);
  9305. output.print("}");
  9306. } else if (is_tagged) {
  9307. output.print(self.segments[i].raw);
  9308. } else {
  9309. output.print_template_string_chars(self.segments[i].value);
  9310. }
  9311. }
  9312. output.print("`");
  9313. });
  9314. DEFPRINT(AST_TemplateSegment, function(self, output) {
  9315. output.print_template_string_chars(self.value);
  9316. });
  9317. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  9318. var self = this;
  9319. var parent = output.parent();
  9320. var needs_parens = (parent instanceof AST_Binary &&
  9321. !(parent instanceof AST_Assign) &&
  9322. !(parent instanceof AST_DefaultAssign)) ||
  9323. parent instanceof AST_Unary ||
  9324. (parent instanceof AST_Call && self === parent.expression);
  9325. if (needs_parens) { output.print("("); }
  9326. if (self.async) {
  9327. output.print("async");
  9328. output.space();
  9329. }
  9330. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  9331. self.argnames[0].print(output);
  9332. } else {
  9333. output.with_parens(function() {
  9334. self.argnames.forEach(function(arg, i) {
  9335. if (i) output.comma();
  9336. arg.print(output);
  9337. });
  9338. });
  9339. }
  9340. output.space();
  9341. output.print("=>");
  9342. output.space();
  9343. const first_statement = self.body[0];
  9344. if (
  9345. self.body.length === 1
  9346. && first_statement instanceof AST_Return
  9347. ) {
  9348. const returned = first_statement.value;
  9349. if (!returned) {
  9350. output.print("{}");
  9351. } else if (left_is_object(returned)) {
  9352. output.print("(");
  9353. returned.print(output);
  9354. output.print(")");
  9355. } else {
  9356. returned.print(output);
  9357. }
  9358. } else {
  9359. print_braced(self, output);
  9360. }
  9361. if (needs_parens) { output.print(")"); }
  9362. output.gc_scope(self);
  9363. });
  9364. /* -----[ exits ]----- */
  9365. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  9366. output.print(kind);
  9367. if (this.value) {
  9368. output.space();
  9369. const comments = this.value.start.comments_before;
  9370. if (comments && comments.length && !output.printed_comments.has(comments)) {
  9371. output.print("(");
  9372. this.value.print(output);
  9373. output.print(")");
  9374. } else {
  9375. this.value.print(output);
  9376. }
  9377. }
  9378. output.semicolon();
  9379. });
  9380. DEFPRINT(AST_Return, function(self, output) {
  9381. self._do_print(output, "return");
  9382. });
  9383. DEFPRINT(AST_Throw, function(self, output) {
  9384. self._do_print(output, "throw");
  9385. });
  9386. /* -----[ yield ]----- */
  9387. DEFPRINT(AST_Yield, function(self, output) {
  9388. var star = self.is_star ? "*" : "";
  9389. output.print("yield" + star);
  9390. if (self.expression) {
  9391. output.space();
  9392. self.expression.print(output);
  9393. }
  9394. });
  9395. DEFPRINT(AST_Await, function(self, output) {
  9396. output.print("await");
  9397. output.space();
  9398. var e = self.expression;
  9399. var parens = !(
  9400. e instanceof AST_Call
  9401. || e instanceof AST_SymbolRef
  9402. || e instanceof AST_PropAccess
  9403. || e instanceof AST_Unary
  9404. || e instanceof AST_Constant
  9405. || e instanceof AST_Await
  9406. || e instanceof AST_Object
  9407. );
  9408. if (parens) output.print("(");
  9409. self.expression.print(output);
  9410. if (parens) output.print(")");
  9411. });
  9412. /* -----[ loop control ]----- */
  9413. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  9414. output.print(kind);
  9415. if (this.label) {
  9416. output.space();
  9417. this.label.print(output);
  9418. }
  9419. output.semicolon();
  9420. });
  9421. DEFPRINT(AST_Break, function(self, output) {
  9422. self._do_print(output, "break");
  9423. });
  9424. DEFPRINT(AST_Continue, function(self, output) {
  9425. self._do_print(output, "continue");
  9426. });
  9427. /* -----[ if ]----- */
  9428. function make_then(self, output) {
  9429. var b = self.body;
  9430. if (output.option("braces")
  9431. || output.option("ie8") && b instanceof AST_Do)
  9432. return make_block(b, output);
  9433. // The squeezer replaces "block"-s that contain only a single
  9434. // statement with the statement itself; technically, the AST
  9435. // is correct, but this can create problems when we output an
  9436. // IF having an ELSE clause where the THEN clause ends in an
  9437. // IF *without* an ELSE block (then the outer ELSE would refer
  9438. // to the inner IF). This function checks for this case and
  9439. // adds the block braces if needed.
  9440. if (!b) return output.force_semicolon();
  9441. while (true) {
  9442. if (b instanceof AST_If) {
  9443. if (!b.alternative) {
  9444. make_block(self.body, output);
  9445. return;
  9446. }
  9447. b = b.alternative;
  9448. } else if (b instanceof AST_StatementWithBody) {
  9449. b = b.body;
  9450. } else break;
  9451. }
  9452. print_maybe_braced_body(self.body, output);
  9453. }
  9454. DEFPRINT(AST_If, function(self, output) {
  9455. output.print("if");
  9456. output.space();
  9457. output.with_parens(function() {
  9458. self.condition.print(output);
  9459. });
  9460. output.space();
  9461. if (self.alternative) {
  9462. make_then(self, output);
  9463. output.space();
  9464. output.print("else");
  9465. output.space();
  9466. if (self.alternative instanceof AST_If)
  9467. self.alternative.print(output);
  9468. else
  9469. print_maybe_braced_body(self.alternative, output);
  9470. } else {
  9471. self._do_print_body(output);
  9472. }
  9473. });
  9474. /* -----[ switch ]----- */
  9475. DEFPRINT(AST_Switch, function(self, output) {
  9476. output.print("switch");
  9477. output.space();
  9478. output.with_parens(function() {
  9479. self.expression.print(output);
  9480. });
  9481. output.space();
  9482. var last = self.body.length - 1;
  9483. if (last < 0) print_braced_empty(self, output);
  9484. else output.with_block(function() {
  9485. self.body.forEach(function(branch, i) {
  9486. output.indent(true);
  9487. branch.print(output);
  9488. if (i < last && branch.body.length > 0)
  9489. output.newline();
  9490. });
  9491. });
  9492. });
  9493. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  9494. output.newline();
  9495. this.body.forEach(function(stmt) {
  9496. output.indent();
  9497. stmt.print(output);
  9498. output.newline();
  9499. });
  9500. });
  9501. DEFPRINT(AST_Default, function(self, output) {
  9502. output.print("default:");
  9503. self._do_print_body(output);
  9504. });
  9505. DEFPRINT(AST_Case, function(self, output) {
  9506. output.print("case");
  9507. output.space();
  9508. self.expression.print(output);
  9509. output.print(":");
  9510. self._do_print_body(output);
  9511. });
  9512. /* -----[ exceptions ]----- */
  9513. DEFPRINT(AST_Try, function(self, output) {
  9514. output.print("try");
  9515. output.space();
  9516. self.body.print(output);
  9517. if (self.bcatch) {
  9518. output.space();
  9519. self.bcatch.print(output);
  9520. }
  9521. if (self.bfinally) {
  9522. output.space();
  9523. self.bfinally.print(output);
  9524. }
  9525. });
  9526. DEFPRINT(AST_TryBlock, function(self, output) {
  9527. print_braced(self, output);
  9528. });
  9529. DEFPRINT(AST_Catch, function(self, output) {
  9530. output.print("catch");
  9531. if (self.argname) {
  9532. output.space();
  9533. output.with_parens(function() {
  9534. self.argname.print(output);
  9535. });
  9536. }
  9537. output.space();
  9538. print_braced(self, output);
  9539. });
  9540. DEFPRINT(AST_Finally, function(self, output) {
  9541. output.print("finally");
  9542. output.space();
  9543. print_braced(self, output);
  9544. });
  9545. /* -----[ var/const ]----- */
  9546. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  9547. output.print(kind);
  9548. output.space();
  9549. this.definitions.forEach(function(def, i) {
  9550. if (i) output.comma();
  9551. def.print(output);
  9552. });
  9553. var p = output.parent();
  9554. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  9555. var output_semicolon = !in_for || p && p.init !== this;
  9556. if (output_semicolon)
  9557. output.semicolon();
  9558. });
  9559. DEFPRINT(AST_Let, function(self, output) {
  9560. self._do_print(output, "let");
  9561. });
  9562. DEFPRINT(AST_Var, function(self, output) {
  9563. self._do_print(output, "var");
  9564. });
  9565. DEFPRINT(AST_Const, function(self, output) {
  9566. self._do_print(output, "const");
  9567. });
  9568. DEFPRINT(AST_Import, function(self, output) {
  9569. output.print("import");
  9570. output.space();
  9571. if (self.imported_name) {
  9572. self.imported_name.print(output);
  9573. }
  9574. if (self.imported_name && self.imported_names) {
  9575. output.print(",");
  9576. output.space();
  9577. }
  9578. if (self.imported_names) {
  9579. if (self.imported_names.length === 1 &&
  9580. self.imported_names[0].foreign_name.name === "*" &&
  9581. !self.imported_names[0].foreign_name.quote) {
  9582. self.imported_names[0].print(output);
  9583. } else {
  9584. output.print("{");
  9585. self.imported_names.forEach(function (name_import, i) {
  9586. output.space();
  9587. name_import.print(output);
  9588. if (i < self.imported_names.length - 1) {
  9589. output.print(",");
  9590. }
  9591. });
  9592. output.space();
  9593. output.print("}");
  9594. }
  9595. }
  9596. if (self.imported_name || self.imported_names) {
  9597. output.space();
  9598. output.print("from");
  9599. output.space();
  9600. }
  9601. self.module_name.print(output);
  9602. if (self.attributes) {
  9603. output.print("with");
  9604. self.attributes.print(output);
  9605. }
  9606. output.semicolon();
  9607. });
  9608. DEFPRINT(AST_ImportMeta, function(self, output) {
  9609. output.print("import.meta");
  9610. });
  9611. DEFPRINT(AST_NameMapping, function(self, output) {
  9612. var is_import = output.parent() instanceof AST_Import;
  9613. var definition = self.name.definition();
  9614. var foreign_name = self.foreign_name;
  9615. var names_are_different =
  9616. (definition && definition.mangled_name || self.name.name) !==
  9617. foreign_name.name;
  9618. if (!names_are_different &&
  9619. foreign_name.name === "*" &&
  9620. foreign_name.quote != self.name.quote) {
  9621. // export * as "*"
  9622. names_are_different = true;
  9623. }
  9624. var foreign_name_is_name = foreign_name.quote == null;
  9625. if (names_are_different) {
  9626. if (is_import) {
  9627. if (foreign_name_is_name) {
  9628. output.print(foreign_name.name);
  9629. } else {
  9630. output.print_string(foreign_name.name, foreign_name.quote);
  9631. }
  9632. } else {
  9633. if (self.name.quote == null) {
  9634. self.name.print(output);
  9635. } else {
  9636. output.print_string(self.name.name, self.name.quote);
  9637. }
  9638. }
  9639. output.space();
  9640. output.print("as");
  9641. output.space();
  9642. if (is_import) {
  9643. self.name.print(output);
  9644. } else {
  9645. if (foreign_name_is_name) {
  9646. output.print(foreign_name.name);
  9647. } else {
  9648. output.print_string(foreign_name.name, foreign_name.quote);
  9649. }
  9650. }
  9651. } else {
  9652. if (self.name.quote == null) {
  9653. self.name.print(output);
  9654. } else {
  9655. output.print_string(self.name.name, self.name.quote);
  9656. }
  9657. }
  9658. });
  9659. DEFPRINT(AST_Export, function(self, output) {
  9660. output.print("export");
  9661. output.space();
  9662. if (self.is_default) {
  9663. output.print("default");
  9664. output.space();
  9665. }
  9666. if (self.exported_names) {
  9667. if (self.exported_names.length === 1 &&
  9668. self.exported_names[0].name.name === "*" &&
  9669. !self.exported_names[0].name.quote) {
  9670. self.exported_names[0].print(output);
  9671. } else {
  9672. output.print("{");
  9673. self.exported_names.forEach(function(name_export, i) {
  9674. output.space();
  9675. name_export.print(output);
  9676. if (i < self.exported_names.length - 1) {
  9677. output.print(",");
  9678. }
  9679. });
  9680. output.space();
  9681. output.print("}");
  9682. }
  9683. } else if (self.exported_value) {
  9684. self.exported_value.print(output);
  9685. } else if (self.exported_definition) {
  9686. self.exported_definition.print(output);
  9687. if (self.exported_definition instanceof AST_Definitions) return;
  9688. }
  9689. if (self.module_name) {
  9690. output.space();
  9691. output.print("from");
  9692. output.space();
  9693. self.module_name.print(output);
  9694. }
  9695. if (self.attributes) {
  9696. output.print("with");
  9697. self.attributes.print(output);
  9698. }
  9699. if (self.exported_value
  9700. && !(self.exported_value instanceof AST_Defun ||
  9701. self.exported_value instanceof AST_Function ||
  9702. self.exported_value instanceof AST_Class)
  9703. || self.module_name
  9704. || self.exported_names
  9705. ) {
  9706. output.semicolon();
  9707. }
  9708. });
  9709. function parenthesize_for_noin(node, output, noin) {
  9710. var parens = false;
  9711. // need to take some precautions here:
  9712. // https://github.com/mishoo/UglifyJS2/issues/60
  9713. if (noin) {
  9714. parens = walk(node, node => {
  9715. // Don't go into scopes -- except arrow functions:
  9716. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  9717. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  9718. return true;
  9719. }
  9720. if (
  9721. node instanceof AST_Binary && node.operator == "in"
  9722. || node instanceof AST_PrivateIn
  9723. ) {
  9724. return walk_abort; // makes walk() return true
  9725. }
  9726. });
  9727. }
  9728. node.print(output, parens);
  9729. }
  9730. DEFPRINT(AST_VarDef, function(self, output) {
  9731. self.name.print(output);
  9732. if (self.value) {
  9733. output.space();
  9734. output.print("=");
  9735. output.space();
  9736. var p = output.parent(1);
  9737. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  9738. parenthesize_for_noin(self.value, output, noin);
  9739. }
  9740. });
  9741. /* -----[ other expressions ]----- */
  9742. DEFPRINT(AST_Call, function(self, output) {
  9743. self.expression.print(output);
  9744. if (self instanceof AST_New && self.args.length === 0)
  9745. return;
  9746. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  9747. output.add_mapping(self.start);
  9748. }
  9749. if (self.optional) output.print("?.");
  9750. output.with_parens(function() {
  9751. self.args.forEach(function(expr, i) {
  9752. if (i) output.comma();
  9753. expr.print(output);
  9754. });
  9755. });
  9756. });
  9757. DEFPRINT(AST_New, function(self, output) {
  9758. output.print("new");
  9759. output.space();
  9760. AST_Call.prototype._codegen(self, output);
  9761. });
  9762. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  9763. this.expressions.forEach(function(node, index) {
  9764. if (index > 0) {
  9765. output.comma();
  9766. if (output.should_break()) {
  9767. output.newline();
  9768. output.indent();
  9769. }
  9770. }
  9771. node.print(output);
  9772. });
  9773. });
  9774. DEFPRINT(AST_Sequence, function(self, output) {
  9775. self._do_print(output);
  9776. // var p = output.parent();
  9777. // if (p instanceof AST_Statement) {
  9778. // output.with_indent(output.next_indent(), function(){
  9779. // self._do_print(output);
  9780. // });
  9781. // } else {
  9782. // self._do_print(output);
  9783. // }
  9784. });
  9785. DEFPRINT(AST_Dot, function(self, output) {
  9786. var expr = self.expression;
  9787. expr.print(output);
  9788. var prop = self.property;
  9789. var print_computed = ALL_RESERVED_WORDS.has(prop)
  9790. ? output.option("ie8")
  9791. : !is_identifier_string(
  9792. prop,
  9793. output.option("ecma") >= 2015 && !output.option("safari10")
  9794. );
  9795. if (self.optional) output.print("?.");
  9796. if (print_computed) {
  9797. output.print("[");
  9798. output.add_mapping(self.end);
  9799. output.print_string(prop);
  9800. output.print("]");
  9801. } else {
  9802. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  9803. if (!/[xa-f.)]/i.test(output.last())) {
  9804. output.print(".");
  9805. }
  9806. }
  9807. if (!self.optional) output.print(".");
  9808. // the name after dot would be mapped about here.
  9809. output.add_mapping(self.end);
  9810. output.print_name(prop);
  9811. }
  9812. });
  9813. DEFPRINT(AST_DotHash, function(self, output) {
  9814. var expr = self.expression;
  9815. expr.print(output);
  9816. var prop = self.property;
  9817. if (self.optional) output.print("?");
  9818. output.print(".#");
  9819. output.add_mapping(self.end);
  9820. output.print_name(prop);
  9821. });
  9822. DEFPRINT(AST_Sub, function(self, output) {
  9823. self.expression.print(output);
  9824. if (self.optional) output.print("?.");
  9825. output.print("[");
  9826. self.property.print(output);
  9827. output.print("]");
  9828. });
  9829. DEFPRINT(AST_Chain, function(self, output) {
  9830. self.expression.print(output);
  9831. });
  9832. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  9833. var op = self.operator;
  9834. if (op === "--" && output.last().endsWith("!")) {
  9835. // avoid printing "<!--"
  9836. output.print(" ");
  9837. }
  9838. output.print(op);
  9839. if (/^[a-z]/i.test(op)
  9840. || (/[+-]$/.test(op)
  9841. && self.expression instanceof AST_UnaryPrefix
  9842. && /^[+-]/.test(self.expression.operator))) {
  9843. output.space();
  9844. }
  9845. self.expression.print(output);
  9846. });
  9847. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  9848. self.expression.print(output);
  9849. output.print(self.operator);
  9850. });
  9851. DEFPRINT(AST_Binary, function(self, output) {
  9852. var op = self.operator;
  9853. self.left.print(output);
  9854. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  9855. && output.last().endsWith("--")) {
  9856. // space is mandatory to avoid outputting -->
  9857. output.print(" ");
  9858. } else {
  9859. // the space is optional depending on "beautify"
  9860. output.space();
  9861. }
  9862. output.print(op);
  9863. output.space();
  9864. self.right.print(output);
  9865. });
  9866. DEFPRINT(AST_Conditional, function(self, output) {
  9867. self.condition.print(output);
  9868. output.space();
  9869. output.print("?");
  9870. output.space();
  9871. self.consequent.print(output);
  9872. output.space();
  9873. output.colon();
  9874. self.alternative.print(output);
  9875. });
  9876. /* -----[ literals ]----- */
  9877. DEFPRINT(AST_Array, function(self, output) {
  9878. output.with_square(function() {
  9879. var a = self.elements, len = a.length;
  9880. if (len > 0) output.space();
  9881. a.forEach(function(exp, i) {
  9882. if (i) output.comma();
  9883. exp.print(output);
  9884. // If the final element is a hole, we need to make sure it
  9885. // doesn't look like a trailing comma, by inserting an actual
  9886. // trailing comma.
  9887. if (i === len - 1 && exp instanceof AST_Hole)
  9888. output.comma();
  9889. });
  9890. if (len > 0) output.space();
  9891. });
  9892. });
  9893. DEFPRINT(AST_Object, function(self, output) {
  9894. if (self.properties.length > 0) output.with_block(function() {
  9895. self.properties.forEach(function(prop, i) {
  9896. if (i) {
  9897. output.print(",");
  9898. output.newline();
  9899. }
  9900. output.indent();
  9901. prop.print(output);
  9902. });
  9903. output.newline();
  9904. });
  9905. else print_braced_empty(self, output);
  9906. });
  9907. DEFPRINT(AST_Class, function(self, output) {
  9908. output.print("class");
  9909. output.space();
  9910. if (self.name) {
  9911. self.name.print(output);
  9912. output.space();
  9913. }
  9914. if (self.extends) {
  9915. var parens = (
  9916. !(self.extends instanceof AST_SymbolRef)
  9917. && !(self.extends instanceof AST_PropAccess)
  9918. && !(self.extends instanceof AST_ClassExpression)
  9919. && !(self.extends instanceof AST_Function)
  9920. );
  9921. output.print("extends");
  9922. if (parens) {
  9923. output.print("(");
  9924. } else {
  9925. output.space();
  9926. }
  9927. self.extends.print(output);
  9928. if (parens) {
  9929. output.print(")");
  9930. } else {
  9931. output.space();
  9932. }
  9933. }
  9934. if (self.properties.length > 0) output.with_block(function() {
  9935. self.properties.forEach(function(prop, i) {
  9936. if (i) {
  9937. output.newline();
  9938. }
  9939. output.indent();
  9940. prop.print(output);
  9941. });
  9942. output.newline();
  9943. });
  9944. else output.print("{}");
  9945. });
  9946. DEFPRINT(AST_NewTarget, function(self, output) {
  9947. output.print("new.target");
  9948. });
  9949. /** Prints a prop name. Returns whether it can be used as a shorthand. */
  9950. function print_property_name(key, quote, output) {
  9951. if (output.option("quote_keys")) {
  9952. output.print_string(key);
  9953. return false;
  9954. }
  9955. if ("" + +key == key && key >= 0) {
  9956. if (output.option("keep_numbers")) {
  9957. output.print(key);
  9958. return false;
  9959. }
  9960. output.print(make_num(key));
  9961. return false;
  9962. }
  9963. var print_string = ALL_RESERVED_WORDS.has(key)
  9964. ? output.option("ie8")
  9965. : (
  9966. output.option("ecma") < 2015 || output.option("safari10")
  9967. ? !is_basic_identifier_string(key)
  9968. : !is_identifier_string(key, true)
  9969. );
  9970. if (print_string || (quote && output.option("keep_quoted_props"))) {
  9971. output.print_string(key, quote);
  9972. return false;
  9973. }
  9974. output.print_name(key);
  9975. return true;
  9976. }
  9977. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  9978. function get_name(self) {
  9979. var def = self.definition();
  9980. return def ? def.mangled_name || def.name : self.name;
  9981. }
  9982. const try_shorthand = output.option("shorthand") && !(self.key instanceof AST_Node);
  9983. if (
  9984. try_shorthand
  9985. && self.value instanceof AST_Symbol
  9986. && get_name(self.value) === self.key
  9987. && !ALL_RESERVED_WORDS.has(self.key)
  9988. ) {
  9989. const was_shorthand = print_property_name(self.key, self.quote, output);
  9990. if (!was_shorthand) {
  9991. output.colon();
  9992. self.value.print(output);
  9993. }
  9994. } else if (
  9995. try_shorthand
  9996. && self.value instanceof AST_DefaultAssign
  9997. && self.value.left instanceof AST_Symbol
  9998. && get_name(self.value.left) === self.key
  9999. ) {
  10000. const was_shorthand = print_property_name(self.key, self.quote, output);
  10001. if (!was_shorthand) {
  10002. output.colon();
  10003. self.value.left.print(output);
  10004. }
  10005. output.space();
  10006. output.print("=");
  10007. output.space();
  10008. self.value.right.print(output);
  10009. } else {
  10010. if (!(self.key instanceof AST_Node)) {
  10011. print_property_name(self.key, self.quote, output);
  10012. } else {
  10013. output.with_square(function() {
  10014. self.key.print(output);
  10015. });
  10016. }
  10017. output.colon();
  10018. self.value.print(output);
  10019. }
  10020. });
  10021. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  10022. if (self.static) {
  10023. output.print("static");
  10024. output.space();
  10025. }
  10026. output.print("#");
  10027. print_property_name(self.key.name, self.quote, output);
  10028. if (self.value) {
  10029. output.print("=");
  10030. self.value.print(output);
  10031. }
  10032. output.semicolon();
  10033. });
  10034. DEFPRINT(AST_ClassProperty, (self, output) => {
  10035. if (self.static) {
  10036. output.print("static");
  10037. output.space();
  10038. }
  10039. if (self.key instanceof AST_SymbolClassProperty) {
  10040. print_property_name(self.key.name, self.quote, output);
  10041. } else {
  10042. output.print("[");
  10043. self.key.print(output);
  10044. output.print("]");
  10045. }
  10046. if (self.value) {
  10047. output.print("=");
  10048. self.value.print(output);
  10049. }
  10050. output.semicolon();
  10051. });
  10052. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  10053. var self = this;
  10054. if (self.static) {
  10055. output.print("static");
  10056. output.space();
  10057. }
  10058. if (type) {
  10059. output.print(type);
  10060. output.space();
  10061. }
  10062. if (self.key instanceof AST_SymbolMethod) {
  10063. if (is_private) output.print("#");
  10064. print_property_name(self.key.name, self.quote, output);
  10065. self.key.add_source_map(output);
  10066. } else {
  10067. output.with_square(function() {
  10068. self.key.print(output);
  10069. });
  10070. }
  10071. self.value._do_print(output, true);
  10072. });
  10073. DEFPRINT(AST_ObjectSetter, function(self, output) {
  10074. self._print_getter_setter("set", false, output);
  10075. });
  10076. DEFPRINT(AST_ObjectGetter, function(self, output) {
  10077. self._print_getter_setter("get", false, output);
  10078. });
  10079. DEFPRINT(AST_PrivateSetter, function(self, output) {
  10080. self._print_getter_setter("set", true, output);
  10081. });
  10082. DEFPRINT(AST_PrivateGetter, function(self, output) {
  10083. self._print_getter_setter("get", true, output);
  10084. });
  10085. DEFPRINT(AST_ConciseMethod, function(self, output) {
  10086. var type;
  10087. if (self.is_generator && self.async) {
  10088. type = "async*";
  10089. } else if (self.is_generator) {
  10090. type = "*";
  10091. } else if (self.async) {
  10092. type = "async";
  10093. }
  10094. self._print_getter_setter(type, false, output);
  10095. });
  10096. DEFPRINT(AST_PrivateMethod, function(self, output) {
  10097. var type;
  10098. if (self.is_generator && self.async) {
  10099. type = "async*";
  10100. } else if (self.is_generator) {
  10101. type = "*";
  10102. } else if (self.async) {
  10103. type = "async";
  10104. }
  10105. self._print_getter_setter(type, true, output);
  10106. });
  10107. DEFPRINT(AST_PrivateIn, function(self, output) {
  10108. self.key.print(output);
  10109. output.space();
  10110. output.print("in");
  10111. output.space();
  10112. self.value.print(output);
  10113. });
  10114. DEFPRINT(AST_SymbolPrivateProperty, function(self, output) {
  10115. output.print("#" + self.name);
  10116. });
  10117. DEFPRINT(AST_ClassStaticBlock, function (self, output) {
  10118. output.print("static");
  10119. output.space();
  10120. print_braced(self, output);
  10121. });
  10122. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  10123. var def = this.definition();
  10124. output.print_name(def ? def.mangled_name || def.name : this.name);
  10125. });
  10126. DEFPRINT(AST_Symbol, function (self, output) {
  10127. self._do_print(output);
  10128. });
  10129. DEFPRINT(AST_Hole, noop);
  10130. DEFPRINT(AST_This, function(self, output) {
  10131. output.print("this");
  10132. });
  10133. DEFPRINT(AST_Super, function(self, output) {
  10134. output.print("super");
  10135. });
  10136. DEFPRINT(AST_Constant, function(self, output) {
  10137. output.print(self.getValue());
  10138. });
  10139. DEFPRINT(AST_String, function(self, output) {
  10140. output.print_string(self.getValue(), self.quote, output.in_directive);
  10141. });
  10142. DEFPRINT(AST_Number, function(self, output) {
  10143. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  10144. output.print(self.raw);
  10145. } else {
  10146. output.print(make_num(self.getValue()));
  10147. }
  10148. });
  10149. DEFPRINT(AST_BigInt, function(self, output) {
  10150. output.print(self.getValue() + "n");
  10151. });
  10152. const r_slash_script = /(<\s*\/\s*script)/i;
  10153. const r_starts_with_script = /^\s*script/i;
  10154. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  10155. DEFPRINT(AST_RegExp, function(self, output) {
  10156. let { source, flags } = self.getValue();
  10157. source = regexp_source_fix(source);
  10158. flags = flags ? sort_regexp_flags(flags) : "";
  10159. // Avoid outputting end of script tag
  10160. source = source.replace(r_slash_script, slash_script_replace);
  10161. if (r_starts_with_script.test(source) && output.last().endsWith("<")) {
  10162. output.print(" ");
  10163. }
  10164. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  10165. const parent = output.parent();
  10166. if (
  10167. parent instanceof AST_Binary
  10168. && /^\w/.test(parent.operator)
  10169. && parent.left === self
  10170. ) {
  10171. output.print(" ");
  10172. }
  10173. });
  10174. /** if, for, while, may or may not have braces surrounding its body */
  10175. function print_maybe_braced_body(stat, output) {
  10176. if (output.option("braces")) {
  10177. make_block(stat, output);
  10178. } else {
  10179. if (!stat || stat instanceof AST_EmptyStatement)
  10180. output.force_semicolon();
  10181. else if (stat instanceof AST_Let || stat instanceof AST_Const || stat instanceof AST_Class)
  10182. make_block(stat, output);
  10183. else
  10184. stat.print(output);
  10185. }
  10186. }
  10187. function best_of(a) {
  10188. var best = a[0], len = best.length;
  10189. for (var i = 1; i < a.length; ++i) {
  10190. if (a[i].length < len) {
  10191. best = a[i];
  10192. len = best.length;
  10193. }
  10194. }
  10195. return best;
  10196. }
  10197. function make_num(num) {
  10198. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  10199. var candidates = [ str ];
  10200. if (Math.floor(num) === num) {
  10201. if (num < 0) {
  10202. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  10203. } else {
  10204. candidates.push("0x" + num.toString(16).toLowerCase());
  10205. }
  10206. }
  10207. var match, len, digits;
  10208. if (match = /^\.0+/.exec(str)) {
  10209. len = match[0].length;
  10210. digits = str.slice(len);
  10211. candidates.push(digits + "e-" + (digits.length + len - 1));
  10212. } else if (match = /0+$/.exec(str)) {
  10213. len = match[0].length;
  10214. candidates.push(str.slice(0, -len) + "e" + len);
  10215. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  10216. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  10217. }
  10218. return best_of(candidates);
  10219. }
  10220. function make_block(stmt, output) {
  10221. if (!stmt || stmt instanceof AST_EmptyStatement)
  10222. output.print("{}");
  10223. else if (stmt instanceof AST_BlockStatement)
  10224. stmt.print(output);
  10225. else output.with_block(function() {
  10226. output.indent();
  10227. stmt.print(output);
  10228. output.newline();
  10229. });
  10230. }
  10231. /* -----[ source map generators ]----- */
  10232. function DEFMAP(nodetype, generator) {
  10233. nodetype.forEach(function(nodetype) {
  10234. nodetype.DEFMETHOD("add_source_map", generator);
  10235. });
  10236. }
  10237. DEFMAP([
  10238. // We could easily add info for ALL nodes, but it seems to me that
  10239. // would be quite wasteful, hence this noop in the base class.
  10240. AST_Node,
  10241. // since the label symbol will mark it
  10242. AST_LabeledStatement,
  10243. AST_Toplevel,
  10244. ], noop);
  10245. // XXX: I'm not exactly sure if we need it for all of these nodes,
  10246. // or if we should add even more.
  10247. DEFMAP([
  10248. AST_Array,
  10249. AST_BlockStatement,
  10250. AST_Catch,
  10251. AST_Class,
  10252. AST_Constant,
  10253. AST_Debugger,
  10254. AST_Definitions,
  10255. AST_Directive,
  10256. AST_Finally,
  10257. AST_Jump,
  10258. AST_Lambda,
  10259. AST_New,
  10260. AST_Object,
  10261. AST_StatementWithBody,
  10262. AST_Symbol,
  10263. AST_Switch,
  10264. AST_SwitchBranch,
  10265. AST_TemplateString,
  10266. AST_TemplateSegment,
  10267. AST_Try,
  10268. ], function(output) {
  10269. output.add_mapping(this.start);
  10270. });
  10271. DEFMAP([
  10272. AST_ObjectGetter,
  10273. AST_ObjectSetter,
  10274. AST_PrivateGetter,
  10275. AST_PrivateSetter,
  10276. AST_ConciseMethod,
  10277. AST_PrivateMethod,
  10278. ], function(output) {
  10279. output.add_mapping(this.start, false /*name handled below*/);
  10280. });
  10281. DEFMAP([
  10282. AST_SymbolMethod,
  10283. AST_SymbolPrivateProperty
  10284. ], function(output) {
  10285. const tok_type = this.end && this.end.type;
  10286. if (tok_type === "name" || tok_type === "privatename") {
  10287. output.add_mapping(this.end, this.name);
  10288. } else {
  10289. output.add_mapping(this.end);
  10290. }
  10291. });
  10292. DEFMAP([ AST_ObjectProperty ], function(output) {
  10293. output.add_mapping(this.start, this.key);
  10294. });
  10295. })();
  10296. const shallow_cmp = (node1, node2) => {
  10297. return (
  10298. node1 === null && node2 === null
  10299. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  10300. );
  10301. };
  10302. const equivalent_to = (tree1, tree2) => {
  10303. if (!shallow_cmp(tree1, tree2)) return false;
  10304. const walk_1_state = [tree1];
  10305. const walk_2_state = [tree2];
  10306. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  10307. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  10308. while (walk_1_state.length && walk_2_state.length) {
  10309. const node_1 = walk_1_state.pop();
  10310. const node_2 = walk_2_state.pop();
  10311. if (!shallow_cmp(node_1, node_2)) return false;
  10312. node_1._children_backwards(walk_1_push);
  10313. node_2._children_backwards(walk_2_push);
  10314. if (walk_1_state.length !== walk_2_state.length) {
  10315. // Different number of children
  10316. return false;
  10317. }
  10318. }
  10319. return walk_1_state.length == 0 && walk_2_state.length == 0;
  10320. };
  10321. const pass_through = () => true;
  10322. AST_Node.prototype.shallow_cmp = function () {
  10323. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  10324. };
  10325. AST_Debugger.prototype.shallow_cmp = pass_through;
  10326. AST_Directive.prototype.shallow_cmp = function(other) {
  10327. return this.value === other.value;
  10328. };
  10329. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  10330. AST_Block.prototype.shallow_cmp = pass_through;
  10331. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  10332. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  10333. return this.label.name === other.label.name;
  10334. };
  10335. AST_Do.prototype.shallow_cmp = pass_through;
  10336. AST_While.prototype.shallow_cmp = pass_through;
  10337. AST_For.prototype.shallow_cmp = function(other) {
  10338. 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);
  10339. };
  10340. AST_ForIn.prototype.shallow_cmp = pass_through;
  10341. AST_ForOf.prototype.shallow_cmp = pass_through;
  10342. AST_With.prototype.shallow_cmp = pass_through;
  10343. AST_Toplevel.prototype.shallow_cmp = pass_through;
  10344. AST_Expansion.prototype.shallow_cmp = pass_through;
  10345. AST_Lambda.prototype.shallow_cmp = function(other) {
  10346. return this.is_generator === other.is_generator && this.async === other.async;
  10347. };
  10348. AST_Destructuring.prototype.shallow_cmp = function(other) {
  10349. return this.is_array === other.is_array;
  10350. };
  10351. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  10352. AST_TemplateString.prototype.shallow_cmp = pass_through;
  10353. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  10354. return this.value === other.value;
  10355. };
  10356. AST_Jump.prototype.shallow_cmp = pass_through;
  10357. AST_LoopControl.prototype.shallow_cmp = pass_through;
  10358. AST_Await.prototype.shallow_cmp = pass_through;
  10359. AST_Yield.prototype.shallow_cmp = function(other) {
  10360. return this.is_star === other.is_star;
  10361. };
  10362. AST_If.prototype.shallow_cmp = function(other) {
  10363. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  10364. };
  10365. AST_Switch.prototype.shallow_cmp = pass_through;
  10366. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  10367. AST_Try.prototype.shallow_cmp = function(other) {
  10368. 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);
  10369. };
  10370. AST_Catch.prototype.shallow_cmp = function(other) {
  10371. return this.argname == null ? other.argname == null : this.argname === other.argname;
  10372. };
  10373. AST_Finally.prototype.shallow_cmp = pass_through;
  10374. AST_Definitions.prototype.shallow_cmp = pass_through;
  10375. AST_VarDef.prototype.shallow_cmp = function(other) {
  10376. return this.value == null ? other.value == null : this.value === other.value;
  10377. };
  10378. AST_NameMapping.prototype.shallow_cmp = pass_through;
  10379. AST_Import.prototype.shallow_cmp = function(other) {
  10380. 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);
  10381. };
  10382. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  10383. AST_Export.prototype.shallow_cmp = function(other) {
  10384. return (this.exported_definition == null ? other.exported_definition == null : this.exported_definition === other.exported_definition) && (this.exported_value == null ? other.exported_value == null : this.exported_value === other.exported_value) && (this.exported_names == null ? other.exported_names == null : this.exported_names === other.exported_names) && this.module_name === other.module_name && this.is_default === other.is_default;
  10385. };
  10386. AST_Call.prototype.shallow_cmp = pass_through;
  10387. AST_Sequence.prototype.shallow_cmp = pass_through;
  10388. AST_PropAccess.prototype.shallow_cmp = pass_through;
  10389. AST_Chain.prototype.shallow_cmp = pass_through;
  10390. AST_Dot.prototype.shallow_cmp = function(other) {
  10391. return this.property === other.property;
  10392. };
  10393. AST_DotHash.prototype.shallow_cmp = function(other) {
  10394. return this.property === other.property;
  10395. };
  10396. AST_Unary.prototype.shallow_cmp = function(other) {
  10397. return this.operator === other.operator;
  10398. };
  10399. AST_Binary.prototype.shallow_cmp = function(other) {
  10400. return this.operator === other.operator;
  10401. };
  10402. AST_Conditional.prototype.shallow_cmp = pass_through;
  10403. AST_Array.prototype.shallow_cmp = pass_through;
  10404. AST_Object.prototype.shallow_cmp = pass_through;
  10405. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  10406. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  10407. return this.key === other.key;
  10408. };
  10409. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  10410. return this.static === other.static;
  10411. };
  10412. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  10413. return this.static === other.static;
  10414. };
  10415. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  10416. return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
  10417. };
  10418. AST_PrivateMethod.prototype.shallow_cmp = function(other) {
  10419. return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
  10420. };
  10421. AST_Class.prototype.shallow_cmp = function(other) {
  10422. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  10423. };
  10424. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  10425. return this.static === other.static
  10426. && (typeof this.key === "string"
  10427. ? this.key === other.key
  10428. : true /* AST_Node handled elsewhere */);
  10429. };
  10430. AST_ClassPrivateProperty.prototype.shallow_cmp = function(other) {
  10431. return this.static === other.static;
  10432. };
  10433. AST_Symbol.prototype.shallow_cmp = function(other) {
  10434. return this.name === other.name;
  10435. };
  10436. AST_NewTarget.prototype.shallow_cmp = pass_through;
  10437. AST_This.prototype.shallow_cmp = pass_through;
  10438. AST_Super.prototype.shallow_cmp = pass_through;
  10439. AST_String.prototype.shallow_cmp = function(other) {
  10440. return this.value === other.value;
  10441. };
  10442. AST_Number.prototype.shallow_cmp = function(other) {
  10443. return this.value === other.value;
  10444. };
  10445. AST_BigInt.prototype.shallow_cmp = function(other) {
  10446. return this.value === other.value;
  10447. };
  10448. AST_RegExp.prototype.shallow_cmp = function (other) {
  10449. return (
  10450. this.value.flags === other.value.flags
  10451. && this.value.source === other.value.source
  10452. );
  10453. };
  10454. AST_Atom.prototype.shallow_cmp = pass_through;
  10455. /***********************************************************************
  10456. A JavaScript tokenizer / parser / beautifier / compressor.
  10457. https://github.com/mishoo/UglifyJS2
  10458. -------------------------------- (C) ---------------------------------
  10459. Author: Mihai Bazon
  10460. <mihai.bazon@gmail.com>
  10461. http://mihai.bazon.net/blog
  10462. Distributed under the BSD license:
  10463. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10464. Redistribution and use in source and binary forms, with or without
  10465. modification, are permitted provided that the following conditions
  10466. are met:
  10467. * Redistributions of source code must retain the above
  10468. copyright notice, this list of conditions and the following
  10469. disclaimer.
  10470. * Redistributions in binary form must reproduce the above
  10471. copyright notice, this list of conditions and the following
  10472. disclaimer in the documentation and/or other materials
  10473. provided with the distribution.
  10474. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10475. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10476. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10477. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10478. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10479. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10480. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10481. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10482. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10483. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10484. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10485. SUCH DAMAGE.
  10486. ***********************************************************************/
  10487. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  10488. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  10489. let function_defs = null;
  10490. let unmangleable_names = null;
  10491. /**
  10492. * When defined, there is a function declaration somewhere that's inside of a block.
  10493. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  10494. */
  10495. let scopes_with_block_defuns = null;
  10496. class SymbolDef {
  10497. constructor(scope, orig, init) {
  10498. this.name = orig.name;
  10499. this.orig = [ orig ];
  10500. this.init = init;
  10501. this.eliminated = 0;
  10502. this.assignments = 0;
  10503. this.scope = scope;
  10504. this.replaced = 0;
  10505. this.global = false;
  10506. this.export = 0;
  10507. this.mangled_name = null;
  10508. this.undeclared = false;
  10509. this.id = SymbolDef.next_id++;
  10510. this.chained = false;
  10511. this.direct_access = false;
  10512. this.escaped = 0;
  10513. this.recursive_refs = 0;
  10514. this.references = [];
  10515. this.should_replace = undefined;
  10516. this.single_use = false;
  10517. this.fixed = false;
  10518. Object.seal(this);
  10519. }
  10520. fixed_value() {
  10521. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  10522. return this.fixed();
  10523. }
  10524. unmangleable(options) {
  10525. if (!options) options = {};
  10526. if (
  10527. function_defs &&
  10528. function_defs.has(this.id) &&
  10529. keep_name(options.keep_fnames, this.orig[0].name)
  10530. ) return true;
  10531. return this.global && !options.toplevel
  10532. || (this.export & MASK_EXPORT_DONT_MANGLE)
  10533. || this.undeclared
  10534. || !options.eval && this.scope.pinned()
  10535. || (this.orig[0] instanceof AST_SymbolLambda
  10536. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  10537. || this.orig[0] instanceof AST_SymbolMethod
  10538. || (this.orig[0] instanceof AST_SymbolClass
  10539. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  10540. }
  10541. mangle(options) {
  10542. const cache = options.cache && options.cache.props;
  10543. if (this.global && cache && cache.has(this.name)) {
  10544. this.mangled_name = cache.get(this.name);
  10545. } else if (!this.mangled_name && !this.unmangleable(options)) {
  10546. var s = this.scope;
  10547. var sym = this.orig[0];
  10548. if (options.ie8 && sym instanceof AST_SymbolLambda)
  10549. s = s.parent_scope;
  10550. const redefinition = redefined_catch_def(this);
  10551. this.mangled_name = redefinition
  10552. ? redefinition.mangled_name || redefinition.name
  10553. : s.next_mangled(options, this);
  10554. if (this.global && cache) {
  10555. cache.set(this.name, this.mangled_name);
  10556. }
  10557. }
  10558. }
  10559. }
  10560. SymbolDef.next_id = 1;
  10561. function redefined_catch_def(def) {
  10562. if (def.orig[0] instanceof AST_SymbolCatch
  10563. && def.scope.is_block_scope()
  10564. ) {
  10565. return def.scope.get_defun_scope().variables.get(def.name);
  10566. }
  10567. }
  10568. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = undefined, toplevel = this } = {}) {
  10569. options = defaults(options, {
  10570. cache: null,
  10571. ie8: false,
  10572. safari10: false,
  10573. module: false,
  10574. });
  10575. if (!(toplevel instanceof AST_Toplevel)) {
  10576. throw new Error("Invalid toplevel scope");
  10577. }
  10578. // pass 1: setup scope chaining and handle definitions
  10579. var scope = this.parent_scope = parent_scope;
  10580. var labels = new Map();
  10581. var defun = null;
  10582. var in_destructuring = null;
  10583. var for_scopes = [];
  10584. var tw = new TreeWalker((node, descend) => {
  10585. if (node.is_block_scope()) {
  10586. const save_scope = scope;
  10587. node.block_scope = scope = new AST_Scope(node);
  10588. scope._block_scope = true;
  10589. scope.init_scope_vars(save_scope);
  10590. scope.uses_with = save_scope.uses_with;
  10591. scope.uses_eval = save_scope.uses_eval;
  10592. if (options.safari10) {
  10593. if (node instanceof AST_For || node instanceof AST_ForIn || node instanceof AST_ForOf) {
  10594. for_scopes.push(scope);
  10595. }
  10596. }
  10597. if (node instanceof AST_Switch) {
  10598. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  10599. // AST_Switch has a scope within the body, but it itself "is a block scope"
  10600. // This means the switched expression has to belong to the outer scope
  10601. // while the body inside belongs to the switch itself.
  10602. // This is pretty nasty and warrants an AST change
  10603. const the_block_scope = scope;
  10604. scope = save_scope;
  10605. node.expression.walk(tw);
  10606. scope = the_block_scope;
  10607. for (let i = 0; i < node.body.length; i++) {
  10608. node.body[i].walk(tw);
  10609. }
  10610. } else {
  10611. descend();
  10612. }
  10613. scope = save_scope;
  10614. return true;
  10615. }
  10616. if (node instanceof AST_Destructuring) {
  10617. const save_destructuring = in_destructuring;
  10618. in_destructuring = node;
  10619. descend();
  10620. in_destructuring = save_destructuring;
  10621. return true;
  10622. }
  10623. if (node instanceof AST_Scope) {
  10624. node.init_scope_vars(scope);
  10625. var save_scope = scope;
  10626. var save_defun = defun;
  10627. var save_labels = labels;
  10628. defun = scope = node;
  10629. labels = new Map();
  10630. descend();
  10631. scope = save_scope;
  10632. defun = save_defun;
  10633. labels = save_labels;
  10634. return true; // don't descend again in TreeWalker
  10635. }
  10636. if (node instanceof AST_LabeledStatement) {
  10637. var l = node.label;
  10638. if (labels.has(l.name)) {
  10639. throw new Error(string_template("Label {name} defined twice", l));
  10640. }
  10641. labels.set(l.name, l);
  10642. descend();
  10643. labels.delete(l.name);
  10644. return true; // no descend again
  10645. }
  10646. if (node instanceof AST_With) {
  10647. for (var s = scope; s; s = s.parent_scope)
  10648. s.uses_with = true;
  10649. return;
  10650. }
  10651. if (node instanceof AST_Symbol) {
  10652. node.scope = scope;
  10653. }
  10654. if (node instanceof AST_Label) {
  10655. node.thedef = node;
  10656. node.references = [];
  10657. }
  10658. if (node instanceof AST_SymbolLambda) {
  10659. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  10660. } else if (node instanceof AST_SymbolDefun) {
  10661. // Careful here, the scope where this should be defined is
  10662. // the parent scope. The reason is that we enter a new
  10663. // scope when we encounter the AST_Defun node (which is
  10664. // instanceof AST_Scope) but we get to the symbol a bit
  10665. // later.
  10666. const closest_scope = defun.parent_scope;
  10667. // In strict mode, function definitions are block-scoped
  10668. node.scope = tw.directives["use strict"]
  10669. ? closest_scope
  10670. : closest_scope.get_defun_scope();
  10671. mark_export(node.scope.def_function(node, defun), 1);
  10672. } else if (node instanceof AST_SymbolClass) {
  10673. mark_export(defun.def_variable(node, defun), 1);
  10674. } else if (node instanceof AST_SymbolImport) {
  10675. scope.def_variable(node);
  10676. } else if (node instanceof AST_SymbolDefClass) {
  10677. // This deals with the name of the class being available
  10678. // inside the class.
  10679. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  10680. } else if (
  10681. node instanceof AST_SymbolVar
  10682. || node instanceof AST_SymbolLet
  10683. || node instanceof AST_SymbolConst
  10684. || node instanceof AST_SymbolCatch
  10685. ) {
  10686. var def;
  10687. if (node instanceof AST_SymbolBlockDeclaration) {
  10688. def = scope.def_variable(node, null);
  10689. } else {
  10690. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  10691. }
  10692. if (!def.orig.every((sym) => {
  10693. if (sym === node) return true;
  10694. if (node instanceof AST_SymbolBlockDeclaration) {
  10695. return sym instanceof AST_SymbolLambda;
  10696. }
  10697. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  10698. })) {
  10699. js_error(
  10700. `"${node.name}" is redeclared`,
  10701. node.start.file,
  10702. node.start.line,
  10703. node.start.col,
  10704. node.start.pos
  10705. );
  10706. }
  10707. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  10708. if (defun !== scope) {
  10709. node.mark_enclosed();
  10710. var def = scope.find_variable(node);
  10711. if (node.thedef !== def) {
  10712. node.thedef = def;
  10713. node.reference();
  10714. }
  10715. }
  10716. } else if (node instanceof AST_LabelRef) {
  10717. var sym = labels.get(node.name);
  10718. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  10719. name: node.name,
  10720. line: node.start.line,
  10721. col: node.start.col
  10722. }));
  10723. node.thedef = sym;
  10724. }
  10725. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  10726. js_error(
  10727. `"${node.TYPE}" statement may only appear at the top level`,
  10728. node.start.file,
  10729. node.start.line,
  10730. node.start.col,
  10731. node.start.pos
  10732. );
  10733. }
  10734. });
  10735. if (options.module) {
  10736. tw.directives["use strict"] = true;
  10737. }
  10738. this.walk(tw);
  10739. function mark_export(def, level) {
  10740. if (in_destructuring) {
  10741. var i = 0;
  10742. do {
  10743. level++;
  10744. } while (tw.parent(i++) !== in_destructuring);
  10745. }
  10746. var node = tw.parent(level);
  10747. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  10748. var exported = node.exported_definition;
  10749. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  10750. def.export = MASK_EXPORT_WANT_MANGLE;
  10751. }
  10752. }
  10753. }
  10754. // pass 2: find back references and eval
  10755. const is_toplevel = this instanceof AST_Toplevel;
  10756. if (is_toplevel) {
  10757. this.globals = new Map();
  10758. }
  10759. var tw = new TreeWalker(node => {
  10760. if (node instanceof AST_LoopControl && node.label) {
  10761. node.label.thedef.references.push(node);
  10762. return true;
  10763. }
  10764. if (node instanceof AST_SymbolRef) {
  10765. var name = node.name;
  10766. if (name == "eval" && tw.parent() instanceof AST_Call) {
  10767. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  10768. s.uses_eval = true;
  10769. }
  10770. }
  10771. var sym;
  10772. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  10773. || !(sym = node.scope.find_variable(name))) {
  10774. sym = toplevel.def_global(node);
  10775. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  10776. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  10777. sym.scope.get_defun_scope().uses_arguments = true;
  10778. }
  10779. node.thedef = sym;
  10780. node.reference();
  10781. if (node.scope.is_block_scope()
  10782. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  10783. node.scope = node.scope.get_defun_scope();
  10784. }
  10785. return true;
  10786. }
  10787. // ensure mangling works if catch reuses a scope variable
  10788. var def;
  10789. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  10790. var s = node.scope;
  10791. while (s) {
  10792. push_uniq(s.enclosed, def);
  10793. if (s === def.scope) break;
  10794. s = s.parent_scope;
  10795. }
  10796. }
  10797. });
  10798. this.walk(tw);
  10799. // pass 3: work around IE8 and Safari catch scope bugs
  10800. if (options.ie8 || options.safari10) {
  10801. walk(this, node => {
  10802. if (node instanceof AST_SymbolCatch) {
  10803. var name = node.name;
  10804. var refs = node.thedef.references;
  10805. var scope = node.scope.get_defun_scope();
  10806. var def = scope.find_variable(name)
  10807. || toplevel.globals.get(name)
  10808. || scope.def_variable(node);
  10809. refs.forEach(function(ref) {
  10810. ref.thedef = def;
  10811. ref.reference();
  10812. });
  10813. node.thedef = def;
  10814. node.reference();
  10815. return true;
  10816. }
  10817. });
  10818. }
  10819. // pass 4: add symbol definitions to loop scopes
  10820. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  10821. // https://github.com/mishoo/UglifyJS2/issues/1753
  10822. // https://bugs.webkit.org/show_bug.cgi?id=171041
  10823. if (options.safari10) {
  10824. for (const scope of for_scopes) {
  10825. scope.parent_scope.variables.forEach(function(def) {
  10826. push_uniq(scope.enclosed, def);
  10827. });
  10828. }
  10829. }
  10830. });
  10831. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  10832. var globals = this.globals, name = node.name;
  10833. if (globals.has(name)) {
  10834. return globals.get(name);
  10835. } else {
  10836. var g = new SymbolDef(this, node);
  10837. g.undeclared = true;
  10838. g.global = true;
  10839. globals.set(name, g);
  10840. return g;
  10841. }
  10842. });
  10843. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  10844. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  10845. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  10846. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  10847. this.parent_scope = parent_scope; // the parent scope
  10848. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  10849. this.cname = -1; // the current index for mangling functions/variables
  10850. });
  10851. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  10852. return (
  10853. this.enclosed.find(def => def.name === name)
  10854. || this.variables.has(name)
  10855. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  10856. );
  10857. });
  10858. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  10859. return (
  10860. this.enclosed.find(def => def.name === name)
  10861. || this.variables.has(name)
  10862. );
  10863. });
  10864. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  10865. // `scope` is going to be moved into `this` right now.
  10866. // Update the required scopes' information
  10867. if (scope.parent_scope === this) return;
  10868. scope.parent_scope = this;
  10869. // Propagate to this.uses_arguments from arrow functions
  10870. if ((scope instanceof AST_Arrow) && (this instanceof AST_Lambda && !this.uses_arguments)) {
  10871. this.uses_arguments = walk(scope, node => {
  10872. if (
  10873. node instanceof AST_SymbolRef
  10874. && node.scope instanceof AST_Lambda
  10875. && node.name === "arguments"
  10876. ) {
  10877. return walk_abort;
  10878. }
  10879. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  10880. return true;
  10881. }
  10882. });
  10883. }
  10884. this.uses_with = this.uses_with || scope.uses_with;
  10885. this.uses_eval = this.uses_eval || scope.uses_eval;
  10886. const scope_ancestry = (() => {
  10887. const ancestry = [];
  10888. let cur = this;
  10889. do {
  10890. ancestry.push(cur);
  10891. } while ((cur = cur.parent_scope));
  10892. ancestry.reverse();
  10893. return ancestry;
  10894. })();
  10895. const new_scope_enclosed_set = new Set(scope.enclosed);
  10896. const to_enclose = [];
  10897. for (const scope_topdown of scope_ancestry) {
  10898. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  10899. for (const def of scope_topdown.variables.values()) {
  10900. if (new_scope_enclosed_set.has(def)) {
  10901. push_uniq(to_enclose, def);
  10902. push_uniq(scope_topdown.enclosed, def);
  10903. }
  10904. }
  10905. }
  10906. });
  10907. function find_scopes_visible_from(scopes) {
  10908. const found_scopes = new Set();
  10909. for (const scope of new Set(scopes)) {
  10910. (function bubble_up(scope) {
  10911. if (scope == null || found_scopes.has(scope)) return;
  10912. found_scopes.add(scope);
  10913. bubble_up(scope.parent_scope);
  10914. })(scope);
  10915. }
  10916. return [...found_scopes];
  10917. }
  10918. // Creates a symbol during compression
  10919. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  10920. source,
  10921. tentative_name,
  10922. scope,
  10923. conflict_scopes = [scope],
  10924. init = null
  10925. } = {}) {
  10926. let symbol_name;
  10927. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  10928. if (tentative_name) {
  10929. // Implement hygiene (no new names are conflicting with existing names)
  10930. tentative_name =
  10931. symbol_name =
  10932. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  10933. let i = 0;
  10934. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  10935. symbol_name = tentative_name + "$" + i++;
  10936. }
  10937. }
  10938. if (!symbol_name) {
  10939. throw new Error("No symbol name could be generated in create_symbol()");
  10940. }
  10941. const symbol = make_node(SymClass, source, {
  10942. name: symbol_name,
  10943. scope
  10944. });
  10945. this.def_variable(symbol, init || null);
  10946. symbol.mark_enclosed();
  10947. return symbol;
  10948. });
  10949. AST_Node.DEFMETHOD("is_block_scope", return_false);
  10950. AST_Class.DEFMETHOD("is_block_scope", return_false);
  10951. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  10952. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  10953. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  10954. AST_Block.DEFMETHOD("is_block_scope", return_true);
  10955. AST_Scope.DEFMETHOD("is_block_scope", function () {
  10956. return this._block_scope || false;
  10957. });
  10958. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  10959. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  10960. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10961. this.uses_arguments = false;
  10962. this.def_variable(new AST_SymbolFunarg({
  10963. name: "arguments",
  10964. start: this.start,
  10965. end: this.end
  10966. }));
  10967. });
  10968. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  10969. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10970. this.uses_arguments = false;
  10971. });
  10972. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  10973. var def = this.definition();
  10974. var s = this.scope;
  10975. while (s) {
  10976. push_uniq(s.enclosed, def);
  10977. if (s === def.scope) break;
  10978. s = s.parent_scope;
  10979. }
  10980. });
  10981. AST_Symbol.DEFMETHOD("reference", function() {
  10982. this.definition().references.push(this);
  10983. this.mark_enclosed();
  10984. });
  10985. AST_Scope.DEFMETHOD("find_variable", function(name) {
  10986. if (name instanceof AST_Symbol) name = name.name;
  10987. return this.variables.get(name)
  10988. || (this.parent_scope && this.parent_scope.find_variable(name));
  10989. });
  10990. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  10991. var def = this.def_variable(symbol, init);
  10992. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  10993. return def;
  10994. });
  10995. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  10996. var def = this.variables.get(symbol.name);
  10997. if (def) {
  10998. def.orig.push(symbol);
  10999. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  11000. def.init = init;
  11001. }
  11002. } else {
  11003. def = new SymbolDef(this, symbol, init);
  11004. this.variables.set(symbol.name, def);
  11005. def.global = !this.parent_scope;
  11006. }
  11007. return symbol.thedef = def;
  11008. });
  11009. function next_mangled(scope, options) {
  11010. let defun_scope;
  11011. if (
  11012. scopes_with_block_defuns
  11013. && (defun_scope = scope.get_defun_scope())
  11014. && scopes_with_block_defuns.has(defun_scope)
  11015. ) {
  11016. scope = defun_scope;
  11017. }
  11018. var ext = scope.enclosed;
  11019. var nth_identifier = options.nth_identifier;
  11020. out: while (true) {
  11021. var m = nth_identifier.get(++scope.cname);
  11022. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  11023. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  11024. // shadow a name reserved from mangling.
  11025. if (options.reserved.has(m)) continue;
  11026. // Functions with short names might collide with base54 output
  11027. // and therefore cause collisions when keep_fnames is true.
  11028. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  11029. // we must ensure that the mangled name does not shadow a name
  11030. // from some parent scope that is referenced in this or in
  11031. // inner scopes.
  11032. for (let i = ext.length; --i >= 0;) {
  11033. const def = ext[i];
  11034. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  11035. if (m == name) continue out;
  11036. }
  11037. return m;
  11038. }
  11039. }
  11040. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  11041. return next_mangled(this, options);
  11042. });
  11043. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  11044. let name;
  11045. const mangled_names = this.mangled_names;
  11046. do {
  11047. name = next_mangled(this, options);
  11048. } while (mangled_names.has(name));
  11049. return name;
  11050. });
  11051. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  11052. // #179, #326
  11053. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  11054. // a function expression's argument cannot shadow the function expression's name
  11055. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  11056. // the function's mangled_name is null when keep_fnames is true
  11057. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  11058. while (true) {
  11059. var name = next_mangled(this, options);
  11060. if (!tricky_name || tricky_name != name)
  11061. return name;
  11062. }
  11063. });
  11064. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  11065. var def = this.definition();
  11066. return !def || def.unmangleable(options);
  11067. });
  11068. // labels are always mangleable
  11069. AST_Label.DEFMETHOD("unmangleable", return_false);
  11070. AST_Symbol.DEFMETHOD("unreferenced", function() {
  11071. return !this.definition().references.length && !this.scope.pinned();
  11072. });
  11073. AST_Symbol.DEFMETHOD("definition", function() {
  11074. return this.thedef;
  11075. });
  11076. AST_Symbol.DEFMETHOD("global", function() {
  11077. return this.thedef.global;
  11078. });
  11079. /**
  11080. * Format the mangler options (if any) into their appropriate types
  11081. */
  11082. function format_mangler_options(options) {
  11083. options = defaults(options, {
  11084. eval : false,
  11085. nth_identifier : base54,
  11086. ie8 : false,
  11087. keep_classnames: false,
  11088. keep_fnames : false,
  11089. module : false,
  11090. reserved : [],
  11091. toplevel : false,
  11092. });
  11093. if (options.module) options.toplevel = true;
  11094. if (!Array.isArray(options.reserved)
  11095. && !(options.reserved instanceof Set)
  11096. ) {
  11097. options.reserved = [];
  11098. }
  11099. options.reserved = new Set(options.reserved);
  11100. // Never mangle arguments
  11101. options.reserved.add("arguments");
  11102. return options;
  11103. }
  11104. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  11105. options = format_mangler_options(options);
  11106. var nth_identifier = options.nth_identifier;
  11107. // We only need to mangle declaration nodes. Special logic wired
  11108. // into the code generator will display the mangled name if it's
  11109. // present (and for AST_SymbolRef-s it'll use the mangled name of
  11110. // the AST_SymbolDeclaration that it points to).
  11111. var lname = -1;
  11112. var to_mangle = [];
  11113. if (options.keep_fnames) {
  11114. function_defs = new Set();
  11115. }
  11116. const mangled_names = this.mangled_names = new Set();
  11117. unmangleable_names = new Set();
  11118. if (options.cache) {
  11119. this.globals.forEach(collect);
  11120. if (options.cache.props) {
  11121. options.cache.props.forEach(function(mangled_name) {
  11122. mangled_names.add(mangled_name);
  11123. });
  11124. }
  11125. }
  11126. var tw = new TreeWalker(function(node, descend) {
  11127. if (node instanceof AST_LabeledStatement) {
  11128. // lname is incremented when we get to the AST_Label
  11129. var save_nesting = lname;
  11130. descend();
  11131. lname = save_nesting;
  11132. return true; // don't descend again in TreeWalker
  11133. }
  11134. if (
  11135. node instanceof AST_Defun
  11136. && !(tw.parent() instanceof AST_Scope)
  11137. ) {
  11138. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  11139. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  11140. }
  11141. if (node instanceof AST_Scope) {
  11142. node.variables.forEach(collect);
  11143. return;
  11144. }
  11145. if (node.is_block_scope()) {
  11146. node.block_scope.variables.forEach(collect);
  11147. return;
  11148. }
  11149. if (
  11150. function_defs
  11151. && node instanceof AST_VarDef
  11152. && node.value instanceof AST_Lambda
  11153. && !node.value.name
  11154. && keep_name(options.keep_fnames, node.name.name)
  11155. ) {
  11156. function_defs.add(node.name.definition().id);
  11157. return;
  11158. }
  11159. if (node instanceof AST_Label) {
  11160. let name;
  11161. do {
  11162. name = nth_identifier.get(++lname);
  11163. } while (ALL_RESERVED_WORDS.has(name));
  11164. node.mangled_name = name;
  11165. return true;
  11166. }
  11167. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  11168. to_mangle.push(node.definition());
  11169. return;
  11170. }
  11171. });
  11172. this.walk(tw);
  11173. if (options.keep_fnames || options.keep_classnames) {
  11174. // Collect a set of short names which are unmangleable,
  11175. // for use in avoiding collisions in next_mangled.
  11176. to_mangle.forEach(def => {
  11177. if (def.name.length < 6 && def.unmangleable(options)) {
  11178. unmangleable_names.add(def.name);
  11179. }
  11180. });
  11181. }
  11182. to_mangle.forEach(def => { def.mangle(options); });
  11183. function_defs = null;
  11184. unmangleable_names = null;
  11185. scopes_with_block_defuns = null;
  11186. function collect(symbol) {
  11187. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  11188. unmangleable_names.add(symbol.name);
  11189. } else if (!options.reserved.has(symbol.name)) {
  11190. to_mangle.push(symbol);
  11191. }
  11192. }
  11193. });
  11194. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  11195. const cache = options.cache && options.cache.props;
  11196. const avoid = new Set();
  11197. options.reserved.forEach(to_avoid);
  11198. this.globals.forEach(add_def);
  11199. this.walk(new TreeWalker(function(node) {
  11200. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  11201. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  11202. }));
  11203. return avoid;
  11204. function to_avoid(name) {
  11205. avoid.add(name);
  11206. }
  11207. function add_def(def) {
  11208. var name = def.name;
  11209. if (def.global && cache && cache.has(name)) name = cache.get(name);
  11210. else if (!def.unmangleable(options)) return;
  11211. to_avoid(name);
  11212. }
  11213. });
  11214. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  11215. options = format_mangler_options(options);
  11216. var nth_identifier = options.nth_identifier;
  11217. if (nth_identifier.reset && nth_identifier.sort) {
  11218. nth_identifier.reset();
  11219. nth_identifier.sort();
  11220. }
  11221. var avoid = this.find_colliding_names(options);
  11222. var cname = 0;
  11223. this.globals.forEach(rename);
  11224. this.walk(new TreeWalker(function(node) {
  11225. if (node instanceof AST_Scope) node.variables.forEach(rename);
  11226. if (node instanceof AST_SymbolCatch) rename(node.definition());
  11227. }));
  11228. function next_name() {
  11229. var name;
  11230. do {
  11231. name = nth_identifier.get(cname++);
  11232. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  11233. return name;
  11234. }
  11235. function rename(def) {
  11236. if (def.global && options.cache) return;
  11237. if (def.unmangleable(options)) return;
  11238. if (options.reserved.has(def.name)) return;
  11239. const redefinition = redefined_catch_def(def);
  11240. const name = def.name = redefinition ? redefinition.name : next_name();
  11241. def.orig.forEach(function(sym) {
  11242. sym.name = name;
  11243. });
  11244. def.references.forEach(function(sym) {
  11245. sym.name = name;
  11246. });
  11247. }
  11248. });
  11249. AST_Node.DEFMETHOD("tail_node", return_this);
  11250. AST_Sequence.DEFMETHOD("tail_node", function() {
  11251. return this.expressions[this.expressions.length - 1];
  11252. });
  11253. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  11254. options = format_mangler_options(options);
  11255. var nth_identifier = options.nth_identifier;
  11256. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  11257. // If the identifier mangler is invariant, skip computing character frequency.
  11258. return;
  11259. }
  11260. nth_identifier.reset();
  11261. try {
  11262. AST_Node.prototype.print = function(stream, force_parens) {
  11263. this._print(stream, force_parens);
  11264. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  11265. nth_identifier.consider(this.name, -1);
  11266. } else if (options.properties) {
  11267. if (this instanceof AST_DotHash) {
  11268. nth_identifier.consider("#" + this.property, -1);
  11269. } else if (this instanceof AST_Dot) {
  11270. nth_identifier.consider(this.property, -1);
  11271. } else if (this instanceof AST_Sub) {
  11272. skip_string(this.property);
  11273. }
  11274. }
  11275. };
  11276. nth_identifier.consider(this.print_to_string(), 1);
  11277. } finally {
  11278. AST_Node.prototype.print = AST_Node.prototype._print;
  11279. }
  11280. nth_identifier.sort();
  11281. function skip_string(node) {
  11282. if (node instanceof AST_String) {
  11283. nth_identifier.consider(node.value, -1);
  11284. } else if (node instanceof AST_Conditional) {
  11285. skip_string(node.consequent);
  11286. skip_string(node.alternative);
  11287. } else if (node instanceof AST_Sequence) {
  11288. skip_string(node.tail_node());
  11289. }
  11290. }
  11291. });
  11292. const base54 = (() => {
  11293. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  11294. const digits = "0123456789".split("");
  11295. let chars;
  11296. let frequency;
  11297. function reset() {
  11298. frequency = new Map();
  11299. leading.forEach(function(ch) {
  11300. frequency.set(ch, 0);
  11301. });
  11302. digits.forEach(function(ch) {
  11303. frequency.set(ch, 0);
  11304. });
  11305. }
  11306. function consider(str, delta) {
  11307. for (var i = str.length; --i >= 0;) {
  11308. frequency.set(str[i], frequency.get(str[i]) + delta);
  11309. }
  11310. }
  11311. function compare(a, b) {
  11312. return frequency.get(b) - frequency.get(a);
  11313. }
  11314. function sort() {
  11315. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  11316. }
  11317. // Ensure this is in a usable initial state.
  11318. reset();
  11319. sort();
  11320. function base54(num) {
  11321. var ret = "", base = 54;
  11322. num++;
  11323. do {
  11324. num--;
  11325. ret += chars[num % base];
  11326. num = Math.floor(num / base);
  11327. base = 64;
  11328. } while (num > 0);
  11329. return ret;
  11330. }
  11331. return {
  11332. get: base54,
  11333. consider,
  11334. reset,
  11335. sort
  11336. };
  11337. })();
  11338. let mangle_options = undefined;
  11339. AST_Node.prototype.size = function (compressor, stack) {
  11340. mangle_options = compressor && compressor._mangle_options;
  11341. let size = 0;
  11342. walk_parent(this, (node, info) => {
  11343. size += node._size(info);
  11344. // Braceless arrow functions have fake "return" statements
  11345. if (node instanceof AST_Arrow && node.is_braceless()) {
  11346. size += node.body[0].value._size(info);
  11347. return true;
  11348. }
  11349. }, stack || (compressor && compressor.stack));
  11350. // just to save a bit of memory
  11351. mangle_options = undefined;
  11352. return size;
  11353. };
  11354. AST_Node.prototype._size = () => 0;
  11355. AST_Debugger.prototype._size = () => 8;
  11356. AST_Directive.prototype._size = function () {
  11357. // TODO string encoding stuff
  11358. return 2 + this.value.length;
  11359. };
  11360. /** Count commas/semicolons necessary to show a list of expressions/statements */
  11361. const list_overhead = (array) => array.length && array.length - 1;
  11362. AST_Block.prototype._size = function () {
  11363. return 2 + list_overhead(this.body);
  11364. };
  11365. AST_Toplevel.prototype._size = function() {
  11366. return list_overhead(this.body);
  11367. };
  11368. AST_EmptyStatement.prototype._size = () => 1;
  11369. AST_LabeledStatement.prototype._size = () => 2; // x:
  11370. AST_Do.prototype._size = () => 9;
  11371. AST_While.prototype._size = () => 7;
  11372. AST_For.prototype._size = () => 8;
  11373. AST_ForIn.prototype._size = () => 8;
  11374. // AST_ForOf inherits ^
  11375. AST_With.prototype._size = () => 6;
  11376. AST_Expansion.prototype._size = () => 3;
  11377. const lambda_modifiers = func =>
  11378. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  11379. AST_Accessor.prototype._size = function () {
  11380. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  11381. };
  11382. AST_Function.prototype._size = function (info) {
  11383. const first = !!first_in_statement(info);
  11384. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  11385. };
  11386. AST_Defun.prototype._size = function () {
  11387. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  11388. };
  11389. AST_Arrow.prototype._size = function () {
  11390. let args_and_arrow = 2 + list_overhead(this.argnames);
  11391. if (
  11392. !(
  11393. this.argnames.length === 1
  11394. && this.argnames[0] instanceof AST_Symbol
  11395. )
  11396. ) {
  11397. args_and_arrow += 2; // parens around the args
  11398. }
  11399. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  11400. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  11401. };
  11402. AST_Destructuring.prototype._size = () => 2;
  11403. AST_TemplateString.prototype._size = function () {
  11404. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  11405. };
  11406. AST_TemplateSegment.prototype._size = function () {
  11407. return this.value.length;
  11408. };
  11409. AST_Return.prototype._size = function () {
  11410. return this.value ? 7 : 6;
  11411. };
  11412. AST_Throw.prototype._size = () => 6;
  11413. AST_Break.prototype._size = function () {
  11414. return this.label ? 6 : 5;
  11415. };
  11416. AST_Continue.prototype._size = function () {
  11417. return this.label ? 9 : 8;
  11418. };
  11419. AST_If.prototype._size = () => 4;
  11420. AST_Switch.prototype._size = function () {
  11421. return 8 + list_overhead(this.body);
  11422. };
  11423. AST_Case.prototype._size = function () {
  11424. return 5 + list_overhead(this.body);
  11425. };
  11426. AST_Default.prototype._size = function () {
  11427. return 8 + list_overhead(this.body);
  11428. };
  11429. AST_Try.prototype._size = () => 3;
  11430. AST_Catch.prototype._size = function () {
  11431. let size = 7 + list_overhead(this.body);
  11432. if (this.argname) {
  11433. size += 2;
  11434. }
  11435. return size;
  11436. };
  11437. AST_Finally.prototype._size = function () {
  11438. return 7 + list_overhead(this.body);
  11439. };
  11440. AST_Var.prototype._size = function () {
  11441. return 4 + list_overhead(this.definitions);
  11442. };
  11443. AST_Let.prototype._size = function () {
  11444. return 4 + list_overhead(this.definitions);
  11445. };
  11446. AST_Const.prototype._size = function () {
  11447. return 6 + list_overhead(this.definitions);
  11448. };
  11449. AST_VarDef.prototype._size = function () {
  11450. return this.value ? 1 : 0;
  11451. };
  11452. AST_NameMapping.prototype._size = function () {
  11453. // foreign name isn't mangled
  11454. return this.name ? 4 : 0;
  11455. };
  11456. AST_Import.prototype._size = function () {
  11457. // import
  11458. let size = 6;
  11459. if (this.imported_name) size += 1;
  11460. // from
  11461. if (this.imported_name || this.imported_names) size += 5;
  11462. // braces, and the commas
  11463. if (this.imported_names) {
  11464. size += 2 + list_overhead(this.imported_names);
  11465. }
  11466. return size;
  11467. };
  11468. AST_ImportMeta.prototype._size = () => 11;
  11469. AST_Export.prototype._size = function () {
  11470. let size = 7 + (this.is_default ? 8 : 0);
  11471. if (this.exported_value) {
  11472. size += this.exported_value._size();
  11473. }
  11474. if (this.exported_names) {
  11475. // Braces and commas
  11476. size += 2 + list_overhead(this.exported_names);
  11477. }
  11478. if (this.module_name) {
  11479. // "from "
  11480. size += 5;
  11481. }
  11482. return size;
  11483. };
  11484. AST_Call.prototype._size = function () {
  11485. if (this.optional) {
  11486. return 4 + list_overhead(this.args);
  11487. }
  11488. return 2 + list_overhead(this.args);
  11489. };
  11490. AST_New.prototype._size = function () {
  11491. return 6 + list_overhead(this.args);
  11492. };
  11493. AST_Sequence.prototype._size = function () {
  11494. return list_overhead(this.expressions);
  11495. };
  11496. AST_Dot.prototype._size = function () {
  11497. if (this.optional) {
  11498. return this.property.length + 2;
  11499. }
  11500. return this.property.length + 1;
  11501. };
  11502. AST_DotHash.prototype._size = function () {
  11503. if (this.optional) {
  11504. return this.property.length + 3;
  11505. }
  11506. return this.property.length + 2;
  11507. };
  11508. AST_Sub.prototype._size = function () {
  11509. return this.optional ? 4 : 2;
  11510. };
  11511. AST_Unary.prototype._size = function () {
  11512. if (this.operator === "typeof") return 7;
  11513. if (this.operator === "void") return 5;
  11514. return this.operator.length;
  11515. };
  11516. AST_Binary.prototype._size = function (info) {
  11517. if (this.operator === "in") return 4;
  11518. let size = this.operator.length;
  11519. if (
  11520. (this.operator === "+" || this.operator === "-")
  11521. && this.right instanceof AST_Unary && this.right.operator === this.operator
  11522. ) {
  11523. // 1+ +a > needs space between the +
  11524. size += 1;
  11525. }
  11526. if (this.needs_parens(info)) {
  11527. size += 2;
  11528. }
  11529. return size;
  11530. };
  11531. AST_Conditional.prototype._size = () => 3;
  11532. AST_Array.prototype._size = function () {
  11533. return 2 + list_overhead(this.elements);
  11534. };
  11535. AST_Object.prototype._size = function (info) {
  11536. let base = 2;
  11537. if (first_in_statement(info)) {
  11538. base += 2; // parens
  11539. }
  11540. return base + list_overhead(this.properties);
  11541. };
  11542. /*#__INLINE__*/
  11543. const key_size = key =>
  11544. typeof key === "string" ? key.length : 0;
  11545. AST_ObjectKeyVal.prototype._size = function () {
  11546. return key_size(this.key) + 1;
  11547. };
  11548. /*#__INLINE__*/
  11549. const static_size = is_static => is_static ? 7 : 0;
  11550. AST_ObjectGetter.prototype._size = function () {
  11551. return 5 + static_size(this.static) + key_size(this.key);
  11552. };
  11553. AST_ObjectSetter.prototype._size = function () {
  11554. return 5 + static_size(this.static) + key_size(this.key);
  11555. };
  11556. AST_ConciseMethod.prototype._size = function () {
  11557. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  11558. };
  11559. AST_PrivateMethod.prototype._size = function () {
  11560. return AST_ConciseMethod.prototype._size.call(this) + 1;
  11561. };
  11562. AST_PrivateGetter.prototype._size = function () {
  11563. return AST_ConciseMethod.prototype._size.call(this) + 4;
  11564. };
  11565. AST_PrivateSetter.prototype._size = function () {
  11566. return AST_ConciseMethod.prototype._size.call(this) + 4;
  11567. };
  11568. AST_PrivateIn.prototype._size = function () {
  11569. return 5; // "#", and " in "
  11570. };
  11571. AST_Class.prototype._size = function () {
  11572. return (
  11573. (this.name ? 8 : 7)
  11574. + (this.extends ? 8 : 0)
  11575. );
  11576. };
  11577. AST_ClassStaticBlock.prototype._size = function () {
  11578. // "static{}" + semicolons
  11579. return 8 + list_overhead(this.body);
  11580. };
  11581. AST_ClassProperty.prototype._size = function () {
  11582. return (
  11583. static_size(this.static)
  11584. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  11585. + (this.value ? 1 : 0)
  11586. );
  11587. };
  11588. AST_ClassPrivateProperty.prototype._size = function () {
  11589. return AST_ClassProperty.prototype._size.call(this) + 1;
  11590. };
  11591. AST_Symbol.prototype._size = function () {
  11592. if (!(mangle_options && this.thedef && !this.thedef.unmangleable(mangle_options))) {
  11593. return this.name.length;
  11594. } else {
  11595. return 1;
  11596. }
  11597. };
  11598. // TODO take propmangle into account
  11599. AST_SymbolClassProperty.prototype._size = function () {
  11600. return this.name.length;
  11601. };
  11602. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  11603. if (this.name === "arguments") return 9;
  11604. return AST_Symbol.prototype._size.call(this);
  11605. };
  11606. AST_NewTarget.prototype._size = () => 10;
  11607. AST_SymbolImportForeign.prototype._size = function () {
  11608. return this.name.length;
  11609. };
  11610. AST_SymbolExportForeign.prototype._size = function () {
  11611. return this.name.length;
  11612. };
  11613. AST_This.prototype._size = () => 4;
  11614. AST_Super.prototype._size = () => 5;
  11615. AST_String.prototype._size = function () {
  11616. return this.value.length + 2;
  11617. };
  11618. AST_Number.prototype._size = function () {
  11619. const { value } = this;
  11620. if (value === 0) return 1;
  11621. if (value > 0 && Math.floor(value) === value) {
  11622. return Math.floor(Math.log10(value) + 1);
  11623. }
  11624. return value.toString().length;
  11625. };
  11626. AST_BigInt.prototype._size = function () {
  11627. return this.value.length;
  11628. };
  11629. AST_RegExp.prototype._size = function () {
  11630. return this.value.toString().length;
  11631. };
  11632. AST_Null.prototype._size = () => 4;
  11633. AST_NaN.prototype._size = () => 3;
  11634. AST_Undefined.prototype._size = () => 6; // "void 0"
  11635. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  11636. AST_Infinity.prototype._size = () => 8;
  11637. AST_True.prototype._size = () => 4;
  11638. AST_False.prototype._size = () => 5;
  11639. AST_Await.prototype._size = () => 6;
  11640. AST_Yield.prototype._size = () => 6;
  11641. /***********************************************************************
  11642. A JavaScript tokenizer / parser / beautifier / compressor.
  11643. https://github.com/mishoo/UglifyJS2
  11644. -------------------------------- (C) ---------------------------------
  11645. Author: Mihai Bazon
  11646. <mihai.bazon@gmail.com>
  11647. http://mihai.bazon.net/blog
  11648. Distributed under the BSD license:
  11649. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11650. Redistribution and use in source and binary forms, with or without
  11651. modification, are permitted provided that the following conditions
  11652. are met:
  11653. * Redistributions of source code must retain the above
  11654. copyright notice, this list of conditions and the following
  11655. disclaimer.
  11656. * Redistributions in binary form must reproduce the above
  11657. copyright notice, this list of conditions and the following
  11658. disclaimer in the documentation and/or other materials
  11659. provided with the distribution.
  11660. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11661. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11662. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11663. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11664. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11665. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11666. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11667. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11668. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11669. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11670. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11671. SUCH DAMAGE.
  11672. ***********************************************************************/
  11673. // bitfield flags to be stored in node.flags.
  11674. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  11675. const UNUSED = 0b00000001;
  11676. const TRUTHY = 0b00000010;
  11677. const FALSY = 0b00000100;
  11678. const UNDEFINED = 0b00001000;
  11679. const INLINED = 0b00010000;
  11680. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  11681. const WRITE_ONLY = 0b00100000;
  11682. // information specific to a single compression pass
  11683. const SQUEEZED = 0b0000000100000000;
  11684. const OPTIMIZED = 0b0000001000000000;
  11685. const TOP = 0b0000010000000000;
  11686. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  11687. const has_flag = (node, flag) => node.flags & flag;
  11688. const set_flag = (node, flag) => { node.flags |= flag; };
  11689. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  11690. /***********************************************************************
  11691. A JavaScript tokenizer / parser / beautifier / compressor.
  11692. https://github.com/mishoo/UglifyJS2
  11693. -------------------------------- (C) ---------------------------------
  11694. Author: Mihai Bazon
  11695. <mihai.bazon@gmail.com>
  11696. http://mihai.bazon.net/blog
  11697. Distributed under the BSD license:
  11698. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11699. Redistribution and use in source and binary forms, with or without
  11700. modification, are permitted provided that the following conditions
  11701. are met:
  11702. * Redistributions of source code must retain the above
  11703. copyright notice, this list of conditions and the following
  11704. disclaimer.
  11705. * Redistributions in binary form must reproduce the above
  11706. copyright notice, this list of conditions and the following
  11707. disclaimer in the documentation and/or other materials
  11708. provided with the distribution.
  11709. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11710. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11711. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11712. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11713. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11714. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11715. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11716. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11717. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11718. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11719. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11720. SUCH DAMAGE.
  11721. ***********************************************************************/
  11722. function merge_sequence(array, node) {
  11723. if (node instanceof AST_Sequence) {
  11724. array.push(...node.expressions);
  11725. } else {
  11726. array.push(node);
  11727. }
  11728. return array;
  11729. }
  11730. function make_sequence(orig, expressions) {
  11731. if (expressions.length == 1) return expressions[0];
  11732. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  11733. return make_node(AST_Sequence, orig, {
  11734. expressions: expressions.reduce(merge_sequence, [])
  11735. });
  11736. }
  11737. function make_empty_function(self) {
  11738. return make_node(AST_Function, self, {
  11739. uses_arguments: false,
  11740. argnames: [],
  11741. body: [],
  11742. is_generator: false,
  11743. async: false,
  11744. variables: new Map(),
  11745. uses_with: false,
  11746. uses_eval: false,
  11747. parent_scope: null,
  11748. enclosed: [],
  11749. cname: 0,
  11750. block_scope: undefined,
  11751. });
  11752. }
  11753. function make_node_from_constant(val, orig) {
  11754. switch (typeof val) {
  11755. case "string":
  11756. return make_node(AST_String, orig, {
  11757. value: val
  11758. });
  11759. case "number":
  11760. if (isNaN(val)) return make_node(AST_NaN, orig);
  11761. if (isFinite(val)) {
  11762. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11763. operator: "-",
  11764. expression: make_node(AST_Number, orig, { value: -val })
  11765. }) : make_node(AST_Number, orig, { value: val });
  11766. }
  11767. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11768. operator: "-",
  11769. expression: make_node(AST_Infinity, orig)
  11770. }) : make_node(AST_Infinity, orig);
  11771. case "bigint":
  11772. return make_node(AST_BigInt, orig, { value: val.toString() });
  11773. case "boolean":
  11774. return make_node(val ? AST_True : AST_False, orig);
  11775. case "undefined":
  11776. return make_node(AST_Undefined, orig);
  11777. default:
  11778. if (val === null) {
  11779. return make_node(AST_Null, orig, { value: null });
  11780. }
  11781. if (val instanceof RegExp) {
  11782. return make_node(AST_RegExp, orig, {
  11783. value: {
  11784. source: regexp_source_fix(val.source),
  11785. flags: val.flags
  11786. }
  11787. });
  11788. }
  11789. throw new Error(string_template("Can't handle constant of type: {type}", {
  11790. type: typeof val
  11791. }));
  11792. }
  11793. }
  11794. function best_of_expression(ast1, ast2) {
  11795. return ast1.size() > ast2.size() ? ast2 : ast1;
  11796. }
  11797. function best_of_statement(ast1, ast2) {
  11798. return best_of_expression(
  11799. make_node(AST_SimpleStatement, ast1, {
  11800. body: ast1
  11801. }),
  11802. make_node(AST_SimpleStatement, ast2, {
  11803. body: ast2
  11804. })
  11805. ).body;
  11806. }
  11807. /** Find which node is smaller, and return that */
  11808. function best_of(compressor, ast1, ast2) {
  11809. if (first_in_statement(compressor)) {
  11810. return best_of_statement(ast1, ast2);
  11811. } else {
  11812. return best_of_expression(ast1, ast2);
  11813. }
  11814. }
  11815. /** Simplify an object property's key, if possible */
  11816. function get_simple_key(key) {
  11817. if (key instanceof AST_Constant) {
  11818. return key.getValue();
  11819. }
  11820. if (key instanceof AST_UnaryPrefix
  11821. && key.operator == "void"
  11822. && key.expression instanceof AST_Constant) {
  11823. return;
  11824. }
  11825. return key;
  11826. }
  11827. function read_property(obj, key) {
  11828. key = get_simple_key(key);
  11829. if (key instanceof AST_Node) return;
  11830. var value;
  11831. if (obj instanceof AST_Array) {
  11832. var elements = obj.elements;
  11833. if (key == "length") return make_node_from_constant(elements.length, obj);
  11834. if (typeof key == "number" && key in elements) value = elements[key];
  11835. } else if (obj instanceof AST_Object) {
  11836. key = "" + key;
  11837. var props = obj.properties;
  11838. for (var i = props.length; --i >= 0;) {
  11839. var prop = props[i];
  11840. if (!(prop instanceof AST_ObjectKeyVal)) return;
  11841. if (!value && props[i].key === key) value = props[i].value;
  11842. }
  11843. }
  11844. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  11845. }
  11846. function has_break_or_continue(loop, parent) {
  11847. var found = false;
  11848. var tw = new TreeWalker(function(node) {
  11849. if (found || node instanceof AST_Scope) return true;
  11850. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  11851. return found = true;
  11852. }
  11853. });
  11854. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  11855. tw.push(loop);
  11856. loop.body.walk(tw);
  11857. return found;
  11858. }
  11859. // we shouldn't compress (1,func)(something) to
  11860. // func(something) because that changes the meaning of
  11861. // the func (becomes lexical instead of global).
  11862. function maintain_this_binding(parent, orig, val) {
  11863. if (requires_sequence_to_maintain_binding(parent, orig, val)) {
  11864. const zero = make_node(AST_Number, orig, { value: 0 });
  11865. return make_sequence(orig, [ zero, val ]);
  11866. } else {
  11867. return val;
  11868. }
  11869. }
  11870. /** Detect (1, x.noThis)(), (0, eval)(), which need sequences */
  11871. function requires_sequence_to_maintain_binding(parent, orig, val) {
  11872. return (
  11873. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  11874. || parent instanceof AST_Call && parent.expression === orig
  11875. && (
  11876. val instanceof AST_Chain
  11877. || val instanceof AST_PropAccess
  11878. || val instanceof AST_SymbolRef && val.name == "eval"
  11879. )
  11880. );
  11881. }
  11882. function is_func_expr(node) {
  11883. return node instanceof AST_Arrow || node instanceof AST_Function;
  11884. }
  11885. /**
  11886. * Used to determine whether the node can benefit from negation.
  11887. * Not the case with arrow functions (you need an extra set of parens). */
  11888. function is_iife_call(node) {
  11889. if (node.TYPE != "Call") return false;
  11890. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  11891. }
  11892. function is_empty(thing) {
  11893. if (thing === null) return true;
  11894. if (thing instanceof AST_EmptyStatement) return true;
  11895. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  11896. return false;
  11897. }
  11898. const identifier_atom = makePredicate("Infinity NaN undefined");
  11899. function is_identifier_atom(node) {
  11900. return node instanceof AST_Infinity
  11901. || node instanceof AST_NaN
  11902. || node instanceof AST_Undefined;
  11903. }
  11904. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  11905. function is_ref_of(ref, type) {
  11906. if (!(ref instanceof AST_SymbolRef)) return false;
  11907. var orig = ref.definition().orig;
  11908. for (var i = orig.length; --i >= 0;) {
  11909. if (orig[i] instanceof type) return true;
  11910. }
  11911. }
  11912. /**Can we turn { block contents... } into just the block contents ?
  11913. * Not if one of these is inside.
  11914. **/
  11915. function can_be_evicted_from_block(node) {
  11916. return !(
  11917. node instanceof AST_DefClass ||
  11918. node instanceof AST_Defun ||
  11919. node instanceof AST_Let ||
  11920. node instanceof AST_Const ||
  11921. node instanceof AST_Export ||
  11922. node instanceof AST_Import
  11923. );
  11924. }
  11925. function as_statement_array(thing) {
  11926. if (thing === null) return [];
  11927. if (thing instanceof AST_BlockStatement) return thing.body;
  11928. if (thing instanceof AST_EmptyStatement) return [];
  11929. if (thing instanceof AST_Statement) return [ thing ];
  11930. throw new Error("Can't convert thing to statement array");
  11931. }
  11932. function is_reachable(scope_node, defs) {
  11933. const find_ref = node => {
  11934. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  11935. return walk_abort;
  11936. }
  11937. };
  11938. return walk_parent(scope_node, (node, info) => {
  11939. if (node instanceof AST_Scope && node !== scope_node) {
  11940. var parent = info.parent();
  11941. if (
  11942. parent instanceof AST_Call
  11943. && parent.expression === node
  11944. // Async/Generators aren't guaranteed to sync evaluate all of
  11945. // their body steps, so it's possible they close over the variable.
  11946. && !(node.async || node.is_generator)
  11947. ) {
  11948. return;
  11949. }
  11950. if (walk(node, find_ref)) return walk_abort;
  11951. return true;
  11952. }
  11953. });
  11954. }
  11955. /** Check if a ref refers to the name of a function/class it's defined within */
  11956. function is_recursive_ref(tw, def) {
  11957. var node;
  11958. for (var i = 0; node = tw.parent(i); i++) {
  11959. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  11960. var name = node.name;
  11961. if (name && name.definition() === def) {
  11962. return true;
  11963. }
  11964. }
  11965. }
  11966. return false;
  11967. }
  11968. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  11969. function retain_top_func(fn, compressor) {
  11970. return compressor.top_retain
  11971. && fn instanceof AST_Defun
  11972. && has_flag(fn, TOP)
  11973. && fn.name
  11974. && compressor.top_retain(fn.name.definition());
  11975. }
  11976. /***********************************************************************
  11977. A JavaScript tokenizer / parser / beautifier / compressor.
  11978. https://github.com/mishoo/UglifyJS2
  11979. -------------------------------- (C) ---------------------------------
  11980. Author: Mihai Bazon
  11981. <mihai.bazon@gmail.com>
  11982. http://mihai.bazon.net/blog
  11983. Distributed under the BSD license:
  11984. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11985. Redistribution and use in source and binary forms, with or without
  11986. modification, are permitted provided that the following conditions
  11987. are met:
  11988. * Redistributions of source code must retain the above
  11989. copyright notice, this list of conditions and the following
  11990. disclaimer.
  11991. * Redistributions in binary form must reproduce the above
  11992. copyright notice, this list of conditions and the following
  11993. disclaimer in the documentation and/or other materials
  11994. provided with the distribution.
  11995. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11996. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11997. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11998. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11999. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12000. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12001. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12002. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12003. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12004. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12005. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12006. SUCH DAMAGE.
  12007. ***********************************************************************/
  12008. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  12009. // Note: Lots of methods and functions are missing here, in case they aren't pure
  12010. // or not available in all JS environments.
  12011. function make_nested_lookup(obj) {
  12012. const out = new Map();
  12013. for (var key of Object.keys(obj)) {
  12014. out.set(key, makePredicate(obj[key]));
  12015. }
  12016. const does_have = (global_name, fname) => {
  12017. const inner_map = out.get(global_name);
  12018. return inner_map != null && inner_map.has(fname);
  12019. };
  12020. return does_have;
  12021. }
  12022. // Objects which are safe to access without throwing or causing a side effect.
  12023. // Usually we'd check the `unsafe` option first but these are way too common for that
  12024. const pure_prop_access_globals = new Set([
  12025. "Number",
  12026. "String",
  12027. "Array",
  12028. "Object",
  12029. "Function",
  12030. "Promise",
  12031. ]);
  12032. const object_methods = [
  12033. "constructor",
  12034. "toString",
  12035. "valueOf",
  12036. ];
  12037. const is_pure_native_method = make_nested_lookup({
  12038. Array: [
  12039. "at",
  12040. "flat",
  12041. "includes",
  12042. "indexOf",
  12043. "join",
  12044. "lastIndexOf",
  12045. "slice",
  12046. ...object_methods,
  12047. ],
  12048. Boolean: object_methods,
  12049. Function: object_methods,
  12050. Number: [
  12051. "toExponential",
  12052. "toFixed",
  12053. "toPrecision",
  12054. ...object_methods,
  12055. ],
  12056. Object: object_methods,
  12057. RegExp: [
  12058. "test",
  12059. ...object_methods,
  12060. ],
  12061. String: [
  12062. "at",
  12063. "charAt",
  12064. "charCodeAt",
  12065. "charPointAt",
  12066. "concat",
  12067. "endsWith",
  12068. "fromCharCode",
  12069. "fromCodePoint",
  12070. "includes",
  12071. "indexOf",
  12072. "italics",
  12073. "lastIndexOf",
  12074. "localeCompare",
  12075. "match",
  12076. "matchAll",
  12077. "normalize",
  12078. "padStart",
  12079. "padEnd",
  12080. "repeat",
  12081. "replace",
  12082. "replaceAll",
  12083. "search",
  12084. "slice",
  12085. "split",
  12086. "startsWith",
  12087. "substr",
  12088. "substring",
  12089. "repeat",
  12090. "toLocaleLowerCase",
  12091. "toLocaleUpperCase",
  12092. "toLowerCase",
  12093. "toUpperCase",
  12094. "trim",
  12095. "trimEnd",
  12096. "trimStart",
  12097. ...object_methods,
  12098. ],
  12099. });
  12100. const is_pure_native_fn = make_nested_lookup({
  12101. Array: [
  12102. "isArray",
  12103. ],
  12104. Math: [
  12105. "abs",
  12106. "acos",
  12107. "asin",
  12108. "atan",
  12109. "ceil",
  12110. "cos",
  12111. "exp",
  12112. "floor",
  12113. "log",
  12114. "round",
  12115. "sin",
  12116. "sqrt",
  12117. "tan",
  12118. "atan2",
  12119. "pow",
  12120. "max",
  12121. "min",
  12122. ],
  12123. Number: [
  12124. "isFinite",
  12125. "isNaN",
  12126. ],
  12127. Object: [
  12128. "create",
  12129. "getOwnPropertyDescriptor",
  12130. "getOwnPropertyNames",
  12131. "getPrototypeOf",
  12132. "isExtensible",
  12133. "isFrozen",
  12134. "isSealed",
  12135. "hasOwn",
  12136. "keys",
  12137. ],
  12138. String: [
  12139. "fromCharCode",
  12140. ],
  12141. });
  12142. // Known numeric values which come with JS environments
  12143. const is_pure_native_value = make_nested_lookup({
  12144. Math: [
  12145. "E",
  12146. "LN10",
  12147. "LN2",
  12148. "LOG2E",
  12149. "LOG10E",
  12150. "PI",
  12151. "SQRT1_2",
  12152. "SQRT2",
  12153. ],
  12154. Number: [
  12155. "MAX_VALUE",
  12156. "MIN_VALUE",
  12157. "NaN",
  12158. "NEGATIVE_INFINITY",
  12159. "POSITIVE_INFINITY",
  12160. ],
  12161. });
  12162. /***********************************************************************
  12163. A JavaScript tokenizer / parser / beautifier / compressor.
  12164. https://github.com/mishoo/UglifyJS2
  12165. -------------------------------- (C) ---------------------------------
  12166. Author: Mihai Bazon
  12167. <mihai.bazon@gmail.com>
  12168. http://mihai.bazon.net/blog
  12169. Distributed under the BSD license:
  12170. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12171. Redistribution and use in source and binary forms, with or without
  12172. modification, are permitted provided that the following conditions
  12173. are met:
  12174. * Redistributions of source code must retain the above
  12175. copyright notice, this list of conditions and the following
  12176. disclaimer.
  12177. * Redistributions in binary form must reproduce the above
  12178. copyright notice, this list of conditions and the following
  12179. disclaimer in the documentation and/or other materials
  12180. provided with the distribution.
  12181. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12182. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12183. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12184. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12185. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12186. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12187. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12188. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12189. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12190. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12191. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12192. SUCH DAMAGE.
  12193. ***********************************************************************/
  12194. // Functions and methods to infer certain facts about expressions
  12195. // It's not always possible to be 100% sure about something just by static analysis,
  12196. // so `true` means yes, and `false` means maybe
  12197. const is_undeclared_ref = (node) =>
  12198. node instanceof AST_SymbolRef && node.definition().undeclared;
  12199. const bitwise_binop = makePredicate("<<< >> << & | ^ ~");
  12200. const lazy_op = makePredicate("&& || ??");
  12201. const unary_side_effects = makePredicate("delete ++ --");
  12202. // methods to determine whether an expression has a boolean result type
  12203. (function(def_is_boolean) {
  12204. const unary_bool = makePredicate("! delete");
  12205. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  12206. def_is_boolean(AST_Node, return_false);
  12207. def_is_boolean(AST_UnaryPrefix, function() {
  12208. return unary_bool.has(this.operator);
  12209. });
  12210. def_is_boolean(AST_Binary, function() {
  12211. return binary_bool.has(this.operator)
  12212. || lazy_op.has(this.operator)
  12213. && this.left.is_boolean()
  12214. && this.right.is_boolean();
  12215. });
  12216. def_is_boolean(AST_Conditional, function() {
  12217. return this.consequent.is_boolean() && this.alternative.is_boolean();
  12218. });
  12219. def_is_boolean(AST_Assign, function() {
  12220. return this.operator == "=" && this.right.is_boolean();
  12221. });
  12222. def_is_boolean(AST_Sequence, function() {
  12223. return this.tail_node().is_boolean();
  12224. });
  12225. def_is_boolean(AST_True, return_true);
  12226. def_is_boolean(AST_False, return_true);
  12227. })(function(node, func) {
  12228. node.DEFMETHOD("is_boolean", func);
  12229. });
  12230. // methods to determine if an expression has a numeric result type
  12231. (function(def_is_number) {
  12232. def_is_number(AST_Node, return_false);
  12233. def_is_number(AST_Number, return_true);
  12234. const unary = makePredicate("+ - ~ ++ --");
  12235. def_is_number(AST_Unary, function() {
  12236. return unary.has(this.operator) && !(this.expression instanceof AST_BigInt);
  12237. });
  12238. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  12239. def_is_number(AST_Binary, function(compressor) {
  12240. return numeric_ops.has(this.operator) || this.operator == "+"
  12241. && this.left.is_number(compressor)
  12242. && this.right.is_number(compressor);
  12243. });
  12244. def_is_number(AST_Assign, function(compressor) {
  12245. return numeric_ops.has(this.operator.slice(0, -1))
  12246. || this.operator == "=" && this.right.is_number(compressor);
  12247. });
  12248. def_is_number(AST_Sequence, function(compressor) {
  12249. return this.tail_node().is_number(compressor);
  12250. });
  12251. def_is_number(AST_Conditional, function(compressor) {
  12252. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  12253. });
  12254. })(function(node, func) {
  12255. node.DEFMETHOD("is_number", func);
  12256. });
  12257. // 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
  12258. (function(def_is_32_bit_integer) {
  12259. def_is_32_bit_integer(AST_Node, return_false);
  12260. def_is_32_bit_integer(AST_Number, function() {
  12261. return this.value === (this.value | 0);
  12262. });
  12263. def_is_32_bit_integer(AST_UnaryPrefix, function() {
  12264. return this.operator == "~" ? this.expression.is_number()
  12265. : this.operator === "+" ? this.expression.is_32_bit_integer()
  12266. : false;
  12267. });
  12268. def_is_32_bit_integer(AST_Binary, function() {
  12269. return bitwise_binop.has(this.operator);
  12270. });
  12271. }(function (node, func) {
  12272. node.DEFMETHOD("is_32_bit_integer", func);
  12273. }));
  12274. // methods to determine if an expression has a string result type
  12275. (function(def_is_string) {
  12276. def_is_string(AST_Node, return_false);
  12277. def_is_string(AST_String, return_true);
  12278. def_is_string(AST_TemplateString, return_true);
  12279. def_is_string(AST_UnaryPrefix, function() {
  12280. return this.operator == "typeof";
  12281. });
  12282. def_is_string(AST_Binary, function(compressor) {
  12283. return this.operator == "+" &&
  12284. (this.left.is_string(compressor) || this.right.is_string(compressor));
  12285. });
  12286. def_is_string(AST_Assign, function(compressor) {
  12287. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  12288. });
  12289. def_is_string(AST_Sequence, function(compressor) {
  12290. return this.tail_node().is_string(compressor);
  12291. });
  12292. def_is_string(AST_Conditional, function(compressor) {
  12293. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  12294. });
  12295. })(function(node, func) {
  12296. node.DEFMETHOD("is_string", func);
  12297. });
  12298. function is_undefined(node, compressor) {
  12299. return (
  12300. has_flag(node, UNDEFINED)
  12301. || node instanceof AST_Undefined
  12302. || node instanceof AST_UnaryPrefix
  12303. && node.operator == "void"
  12304. && !node.expression.has_side_effects(compressor)
  12305. );
  12306. }
  12307. // Is the node explicitly null or undefined.
  12308. function is_null_or_undefined(node, compressor) {
  12309. let fixed;
  12310. return (
  12311. node instanceof AST_Null
  12312. || is_undefined(node, compressor)
  12313. || (
  12314. node instanceof AST_SymbolRef
  12315. && (fixed = node.definition().fixed) instanceof AST_Node
  12316. && is_nullish(fixed, compressor)
  12317. )
  12318. );
  12319. }
  12320. // Find out if this expression is optionally chained from a base-point that we
  12321. // can statically analyze as null or undefined.
  12322. function is_nullish_shortcircuited(node, compressor) {
  12323. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  12324. return (
  12325. (node.optional && is_null_or_undefined(node.expression, compressor))
  12326. || is_nullish_shortcircuited(node.expression, compressor)
  12327. );
  12328. }
  12329. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  12330. return false;
  12331. }
  12332. // Find out if something is == null, or can short circuit into nullish.
  12333. // Used to optimize ?. and ??
  12334. function is_nullish(node, compressor) {
  12335. if (is_null_or_undefined(node, compressor)) return true;
  12336. return is_nullish_shortcircuited(node, compressor);
  12337. }
  12338. // Determine if expression might cause side effects
  12339. // If there's a possibility that a node may change something when it's executed, this returns true
  12340. (function(def_has_side_effects) {
  12341. def_has_side_effects(AST_Node, return_true);
  12342. def_has_side_effects(AST_EmptyStatement, return_false);
  12343. def_has_side_effects(AST_Constant, return_false);
  12344. def_has_side_effects(AST_This, return_false);
  12345. function any(list, compressor) {
  12346. for (var i = list.length; --i >= 0;)
  12347. if (list[i].has_side_effects(compressor))
  12348. return true;
  12349. return false;
  12350. }
  12351. def_has_side_effects(AST_Block, function(compressor) {
  12352. return any(this.body, compressor);
  12353. });
  12354. def_has_side_effects(AST_Call, function(compressor) {
  12355. if (
  12356. !this.is_callee_pure(compressor)
  12357. && (!this.expression.is_call_pure(compressor)
  12358. || this.expression.has_side_effects(compressor))
  12359. ) {
  12360. return true;
  12361. }
  12362. return any(this.args, compressor);
  12363. });
  12364. def_has_side_effects(AST_Switch, function(compressor) {
  12365. return this.expression.has_side_effects(compressor)
  12366. || any(this.body, compressor);
  12367. });
  12368. def_has_side_effects(AST_Case, function(compressor) {
  12369. return this.expression.has_side_effects(compressor)
  12370. || any(this.body, compressor);
  12371. });
  12372. def_has_side_effects(AST_Try, function(compressor) {
  12373. return this.body.has_side_effects(compressor)
  12374. || this.bcatch && this.bcatch.has_side_effects(compressor)
  12375. || this.bfinally && this.bfinally.has_side_effects(compressor);
  12376. });
  12377. def_has_side_effects(AST_If, function(compressor) {
  12378. return this.condition.has_side_effects(compressor)
  12379. || this.body && this.body.has_side_effects(compressor)
  12380. || this.alternative && this.alternative.has_side_effects(compressor);
  12381. });
  12382. def_has_side_effects(AST_ImportMeta, return_false);
  12383. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  12384. return this.body.has_side_effects(compressor);
  12385. });
  12386. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  12387. return this.body.has_side_effects(compressor);
  12388. });
  12389. def_has_side_effects(AST_Lambda, return_false);
  12390. def_has_side_effects(AST_Class, function (compressor) {
  12391. if (this.extends && this.extends.has_side_effects(compressor)) {
  12392. return true;
  12393. }
  12394. return any(this.properties, compressor);
  12395. });
  12396. def_has_side_effects(AST_ClassStaticBlock, function(compressor) {
  12397. return any(this.body, compressor);
  12398. });
  12399. def_has_side_effects(AST_Binary, function(compressor) {
  12400. return this.left.has_side_effects(compressor)
  12401. || this.right.has_side_effects(compressor);
  12402. });
  12403. def_has_side_effects(AST_Assign, return_true);
  12404. def_has_side_effects(AST_Conditional, function(compressor) {
  12405. return this.condition.has_side_effects(compressor)
  12406. || this.consequent.has_side_effects(compressor)
  12407. || this.alternative.has_side_effects(compressor);
  12408. });
  12409. def_has_side_effects(AST_Unary, function(compressor) {
  12410. return unary_side_effects.has(this.operator)
  12411. || this.expression.has_side_effects(compressor);
  12412. });
  12413. def_has_side_effects(AST_SymbolRef, function(compressor) {
  12414. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12415. });
  12416. def_has_side_effects(AST_SymbolClassProperty, return_false);
  12417. def_has_side_effects(AST_SymbolDeclaration, return_false);
  12418. def_has_side_effects(AST_Object, function(compressor) {
  12419. return any(this.properties, compressor);
  12420. });
  12421. def_has_side_effects(AST_ObjectKeyVal, function(compressor) {
  12422. return (
  12423. this.computed_key() && this.key.has_side_effects(compressor)
  12424. || this.value && this.value.has_side_effects(compressor)
  12425. );
  12426. });
  12427. def_has_side_effects([
  12428. AST_ClassProperty,
  12429. AST_ClassPrivateProperty,
  12430. ], function(compressor) {
  12431. return (
  12432. this.computed_key() && this.key.has_side_effects(compressor)
  12433. || this.static && this.value && this.value.has_side_effects(compressor)
  12434. );
  12435. });
  12436. def_has_side_effects([
  12437. AST_PrivateMethod,
  12438. AST_PrivateGetter,
  12439. AST_PrivateSetter,
  12440. AST_ConciseMethod,
  12441. AST_ObjectGetter,
  12442. AST_ObjectSetter,
  12443. ], function(compressor) {
  12444. return this.computed_key() && this.key.has_side_effects(compressor);
  12445. });
  12446. def_has_side_effects(AST_Array, function(compressor) {
  12447. return any(this.elements, compressor);
  12448. });
  12449. def_has_side_effects(AST_Dot, function(compressor) {
  12450. if (is_nullish(this, compressor)) {
  12451. return this.expression.has_side_effects(compressor);
  12452. }
  12453. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  12454. return true;
  12455. }
  12456. return this.expression.has_side_effects(compressor);
  12457. });
  12458. def_has_side_effects(AST_Sub, function(compressor) {
  12459. if (is_nullish(this, compressor)) {
  12460. return this.expression.has_side_effects(compressor);
  12461. }
  12462. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  12463. return true;
  12464. }
  12465. var property = this.property.has_side_effects(compressor);
  12466. if (property && this.optional) return true; // "?." is a condition
  12467. return property || this.expression.has_side_effects(compressor);
  12468. });
  12469. def_has_side_effects(AST_Chain, function (compressor) {
  12470. return this.expression.has_side_effects(compressor);
  12471. });
  12472. def_has_side_effects(AST_Sequence, function(compressor) {
  12473. return any(this.expressions, compressor);
  12474. });
  12475. def_has_side_effects(AST_Definitions, function(compressor) {
  12476. return any(this.definitions, compressor);
  12477. });
  12478. def_has_side_effects(AST_VarDef, function() {
  12479. return this.value != null;
  12480. });
  12481. def_has_side_effects(AST_TemplateSegment, return_false);
  12482. def_has_side_effects(AST_TemplateString, function(compressor) {
  12483. return any(this.segments, compressor);
  12484. });
  12485. })(function(node_or_nodes, func) {
  12486. for (const node of [].concat(node_or_nodes)) {
  12487. node.DEFMETHOD("has_side_effects", func);
  12488. }
  12489. });
  12490. // determine if expression may throw
  12491. (function(def_may_throw) {
  12492. def_may_throw(AST_Node, return_true);
  12493. def_may_throw(AST_Constant, return_false);
  12494. def_may_throw(AST_EmptyStatement, return_false);
  12495. def_may_throw(AST_Lambda, return_false);
  12496. def_may_throw(AST_SymbolDeclaration, return_false);
  12497. def_may_throw(AST_This, return_false);
  12498. def_may_throw(AST_ImportMeta, return_false);
  12499. function any(list, compressor) {
  12500. for (var i = list.length; --i >= 0;)
  12501. if (list[i].may_throw(compressor))
  12502. return true;
  12503. return false;
  12504. }
  12505. def_may_throw(AST_Class, function(compressor) {
  12506. if (this.extends && this.extends.may_throw(compressor)) return true;
  12507. return any(this.properties, compressor);
  12508. });
  12509. def_may_throw(AST_ClassStaticBlock, function (compressor) {
  12510. return any(this.body, compressor);
  12511. });
  12512. def_may_throw(AST_Array, function(compressor) {
  12513. return any(this.elements, compressor);
  12514. });
  12515. def_may_throw(AST_Assign, function(compressor) {
  12516. if (this.right.may_throw(compressor)) return true;
  12517. if (!compressor.has_directive("use strict")
  12518. && this.operator == "="
  12519. && this.left instanceof AST_SymbolRef) {
  12520. return false;
  12521. }
  12522. return this.left.may_throw(compressor);
  12523. });
  12524. def_may_throw(AST_Binary, function(compressor) {
  12525. return this.left.may_throw(compressor)
  12526. || this.right.may_throw(compressor);
  12527. });
  12528. def_may_throw(AST_Block, function(compressor) {
  12529. return any(this.body, compressor);
  12530. });
  12531. def_may_throw(AST_Call, function(compressor) {
  12532. if (is_nullish(this, compressor)) return false;
  12533. if (any(this.args, compressor)) return true;
  12534. if (this.is_callee_pure(compressor)) return false;
  12535. if (this.expression.may_throw(compressor)) return true;
  12536. return !(this.expression instanceof AST_Lambda)
  12537. || any(this.expression.body, compressor);
  12538. });
  12539. def_may_throw(AST_Case, function(compressor) {
  12540. return this.expression.may_throw(compressor)
  12541. || any(this.body, compressor);
  12542. });
  12543. def_may_throw(AST_Conditional, function(compressor) {
  12544. return this.condition.may_throw(compressor)
  12545. || this.consequent.may_throw(compressor)
  12546. || this.alternative.may_throw(compressor);
  12547. });
  12548. def_may_throw(AST_Definitions, function(compressor) {
  12549. return any(this.definitions, compressor);
  12550. });
  12551. def_may_throw(AST_If, function(compressor) {
  12552. return this.condition.may_throw(compressor)
  12553. || this.body && this.body.may_throw(compressor)
  12554. || this.alternative && this.alternative.may_throw(compressor);
  12555. });
  12556. def_may_throw(AST_LabeledStatement, function(compressor) {
  12557. return this.body.may_throw(compressor);
  12558. });
  12559. def_may_throw(AST_Object, function(compressor) {
  12560. return any(this.properties, compressor);
  12561. });
  12562. def_may_throw(AST_ObjectKeyVal, function(compressor) {
  12563. return (
  12564. this.computed_key() && this.key.may_throw(compressor)
  12565. || this.value ? this.value.may_throw(compressor) : false
  12566. );
  12567. });
  12568. def_may_throw([
  12569. AST_ClassProperty,
  12570. AST_ClassPrivateProperty,
  12571. ], function(compressor) {
  12572. return (
  12573. this.computed_key() && this.key.may_throw(compressor)
  12574. || this.static && this.value && this.value.may_throw(compressor)
  12575. );
  12576. });
  12577. def_may_throw([
  12578. AST_ConciseMethod,
  12579. AST_ObjectGetter,
  12580. AST_ObjectSetter,
  12581. ], function(compressor) {
  12582. return this.computed_key() && this.key.may_throw(compressor);
  12583. });
  12584. def_may_throw([
  12585. AST_PrivateMethod,
  12586. AST_PrivateGetter,
  12587. AST_PrivateSetter,
  12588. ], return_false);
  12589. def_may_throw(AST_Return, function(compressor) {
  12590. return this.value && this.value.may_throw(compressor);
  12591. });
  12592. def_may_throw(AST_Sequence, function(compressor) {
  12593. return any(this.expressions, compressor);
  12594. });
  12595. def_may_throw(AST_SimpleStatement, function(compressor) {
  12596. return this.body.may_throw(compressor);
  12597. });
  12598. def_may_throw(AST_Dot, function(compressor) {
  12599. if (is_nullish(this, compressor)) return false;
  12600. return !this.optional && this.expression.may_throw_on_access(compressor)
  12601. || this.expression.may_throw(compressor);
  12602. });
  12603. def_may_throw(AST_Sub, function(compressor) {
  12604. if (is_nullish(this, compressor)) return false;
  12605. return !this.optional && this.expression.may_throw_on_access(compressor)
  12606. || this.expression.may_throw(compressor)
  12607. || this.property.may_throw(compressor);
  12608. });
  12609. def_may_throw(AST_Chain, function(compressor) {
  12610. return this.expression.may_throw(compressor);
  12611. });
  12612. def_may_throw(AST_Switch, function(compressor) {
  12613. return this.expression.may_throw(compressor)
  12614. || any(this.body, compressor);
  12615. });
  12616. def_may_throw(AST_SymbolRef, function(compressor) {
  12617. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12618. });
  12619. def_may_throw(AST_SymbolClassProperty, return_false);
  12620. def_may_throw(AST_Try, function(compressor) {
  12621. return this.bcatch ? this.bcatch.may_throw(compressor) : this.body.may_throw(compressor)
  12622. || this.bfinally && this.bfinally.may_throw(compressor);
  12623. });
  12624. def_may_throw(AST_Unary, function(compressor) {
  12625. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12626. return false;
  12627. return this.expression.may_throw(compressor);
  12628. });
  12629. def_may_throw(AST_VarDef, function(compressor) {
  12630. if (!this.value) return false;
  12631. return this.value.may_throw(compressor);
  12632. });
  12633. })(function(node_or_nodes, func) {
  12634. for (const node of [].concat(node_or_nodes)) {
  12635. node.DEFMETHOD("may_throw", func);
  12636. }
  12637. });
  12638. // determine if expression is constant
  12639. (function(def_is_constant_expression) {
  12640. function all_refs_local(scope) {
  12641. let result = true;
  12642. walk(this, node => {
  12643. if (node instanceof AST_SymbolRef) {
  12644. if (has_flag(this, INLINED)) {
  12645. result = false;
  12646. return walk_abort;
  12647. }
  12648. var def = node.definition();
  12649. if (
  12650. member(def, this.enclosed)
  12651. && !this.variables.has(def.name)
  12652. ) {
  12653. if (scope) {
  12654. var scope_def = scope.find_variable(node);
  12655. if (def.undeclared ? !scope_def : scope_def === def) {
  12656. result = "f";
  12657. return true;
  12658. }
  12659. }
  12660. result = false;
  12661. return walk_abort;
  12662. }
  12663. return true;
  12664. }
  12665. if (node instanceof AST_This && this instanceof AST_Arrow) {
  12666. result = false;
  12667. return walk_abort;
  12668. }
  12669. });
  12670. return result;
  12671. }
  12672. def_is_constant_expression(AST_Node, return_false);
  12673. def_is_constant_expression(AST_Constant, return_true);
  12674. def_is_constant_expression(AST_Class, function(scope) {
  12675. if (this.extends && !this.extends.is_constant_expression(scope)) {
  12676. return false;
  12677. }
  12678. for (const prop of this.properties) {
  12679. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  12680. return false;
  12681. }
  12682. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  12683. return false;
  12684. }
  12685. if (prop instanceof AST_ClassStaticBlock) {
  12686. return false;
  12687. }
  12688. }
  12689. return all_refs_local.call(this, scope);
  12690. });
  12691. def_is_constant_expression(AST_Lambda, all_refs_local);
  12692. def_is_constant_expression(AST_Unary, function() {
  12693. return this.expression.is_constant_expression();
  12694. });
  12695. def_is_constant_expression(AST_Binary, function() {
  12696. return this.left.is_constant_expression()
  12697. && this.right.is_constant_expression();
  12698. });
  12699. def_is_constant_expression(AST_Array, function() {
  12700. return this.elements.every((l) => l.is_constant_expression());
  12701. });
  12702. def_is_constant_expression(AST_Object, function() {
  12703. return this.properties.every((l) => l.is_constant_expression());
  12704. });
  12705. def_is_constant_expression(AST_ObjectProperty, function() {
  12706. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  12707. });
  12708. })(function(node, func) {
  12709. node.DEFMETHOD("is_constant_expression", func);
  12710. });
  12711. // may_throw_on_access()
  12712. // returns true if this node may be null, undefined or contain `AST_Accessor`
  12713. (function(def_may_throw_on_access) {
  12714. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  12715. return !compressor.option("pure_getters")
  12716. || this._dot_throw(compressor);
  12717. });
  12718. function is_strict(compressor) {
  12719. return /strict/.test(compressor.option("pure_getters"));
  12720. }
  12721. def_may_throw_on_access(AST_Node, is_strict);
  12722. def_may_throw_on_access(AST_Null, return_true);
  12723. def_may_throw_on_access(AST_Undefined, return_true);
  12724. def_may_throw_on_access(AST_Constant, return_false);
  12725. def_may_throw_on_access(AST_Array, return_false);
  12726. def_may_throw_on_access(AST_Object, function(compressor) {
  12727. if (!is_strict(compressor)) return false;
  12728. for (var i = this.properties.length; --i >=0;)
  12729. if (this.properties[i]._dot_throw(compressor)) return true;
  12730. return false;
  12731. });
  12732. // Do not be as strict with classes as we are with objects.
  12733. // Hopefully the community is not going to abuse static getters and setters.
  12734. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  12735. def_may_throw_on_access(AST_Class, return_false);
  12736. def_may_throw_on_access(AST_ObjectProperty, return_false);
  12737. def_may_throw_on_access(AST_ObjectGetter, return_true);
  12738. def_may_throw_on_access(AST_Expansion, function(compressor) {
  12739. return this.expression._dot_throw(compressor);
  12740. });
  12741. def_may_throw_on_access(AST_Function, return_false);
  12742. def_may_throw_on_access(AST_Arrow, return_false);
  12743. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  12744. def_may_throw_on_access(AST_UnaryPrefix, function() {
  12745. return this.operator == "void";
  12746. });
  12747. def_may_throw_on_access(AST_Binary, function(compressor) {
  12748. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  12749. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  12750. });
  12751. def_may_throw_on_access(AST_Assign, function(compressor) {
  12752. if (this.logical) return true;
  12753. return this.operator == "="
  12754. && this.right._dot_throw(compressor);
  12755. });
  12756. def_may_throw_on_access(AST_Conditional, function(compressor) {
  12757. return this.consequent._dot_throw(compressor)
  12758. || this.alternative._dot_throw(compressor);
  12759. });
  12760. def_may_throw_on_access(AST_Dot, function(compressor) {
  12761. if (!is_strict(compressor)) return false;
  12762. if (this.property == "prototype") {
  12763. return !(
  12764. this.expression instanceof AST_Function
  12765. || this.expression instanceof AST_Class
  12766. );
  12767. }
  12768. return true;
  12769. });
  12770. def_may_throw_on_access(AST_Chain, function(compressor) {
  12771. return this.expression._dot_throw(compressor);
  12772. });
  12773. def_may_throw_on_access(AST_Sequence, function(compressor) {
  12774. return this.tail_node()._dot_throw(compressor);
  12775. });
  12776. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  12777. if (this.name === "arguments" && this.scope instanceof AST_Lambda) return false;
  12778. if (has_flag(this, UNDEFINED)) return true;
  12779. if (!is_strict(compressor)) return false;
  12780. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  12781. if (this.is_immutable()) return false;
  12782. var fixed = this.fixed_value();
  12783. return !fixed || fixed._dot_throw(compressor);
  12784. });
  12785. })(function(node, func) {
  12786. node.DEFMETHOD("_dot_throw", func);
  12787. });
  12788. function is_lhs(node, parent) {
  12789. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  12790. if (parent instanceof AST_Assign && parent.left === node) return node;
  12791. if (parent instanceof AST_ForIn && parent.init === node) return node;
  12792. }
  12793. // method to negate an expression
  12794. (function(def_negate) {
  12795. function basic_negation(exp) {
  12796. return make_node(AST_UnaryPrefix, exp, {
  12797. operator: "!",
  12798. expression: exp
  12799. });
  12800. }
  12801. function best(orig, alt, first_in_statement) {
  12802. var negated = basic_negation(orig);
  12803. if (first_in_statement) {
  12804. var stat = make_node(AST_SimpleStatement, alt, {
  12805. body: alt
  12806. });
  12807. return best_of_expression(negated, stat) === stat ? alt : negated;
  12808. }
  12809. return best_of_expression(negated, alt);
  12810. }
  12811. def_negate(AST_Node, function() {
  12812. return basic_negation(this);
  12813. });
  12814. def_negate(AST_Statement, function() {
  12815. throw new Error("Cannot negate a statement");
  12816. });
  12817. def_negate(AST_Function, function() {
  12818. return basic_negation(this);
  12819. });
  12820. def_negate(AST_Class, function() {
  12821. return basic_negation(this);
  12822. });
  12823. def_negate(AST_Arrow, function() {
  12824. return basic_negation(this);
  12825. });
  12826. def_negate(AST_UnaryPrefix, function() {
  12827. if (this.operator == "!")
  12828. return this.expression;
  12829. return basic_negation(this);
  12830. });
  12831. def_negate(AST_Sequence, function(compressor) {
  12832. var expressions = this.expressions.slice();
  12833. expressions.push(expressions.pop().negate(compressor));
  12834. return make_sequence(this, expressions);
  12835. });
  12836. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  12837. var self = this.clone();
  12838. self.consequent = self.consequent.negate(compressor);
  12839. self.alternative = self.alternative.negate(compressor);
  12840. return best(this, self, first_in_statement);
  12841. });
  12842. def_negate(AST_Binary, function(compressor, first_in_statement) {
  12843. var self = this.clone(), op = this.operator;
  12844. if (compressor.option("unsafe_comps")) {
  12845. switch (op) {
  12846. case "<=" : self.operator = ">" ; return self;
  12847. case "<" : self.operator = ">=" ; return self;
  12848. case ">=" : self.operator = "<" ; return self;
  12849. case ">" : self.operator = "<=" ; return self;
  12850. }
  12851. }
  12852. switch (op) {
  12853. case "==" : self.operator = "!="; return self;
  12854. case "!=" : self.operator = "=="; return self;
  12855. case "===": self.operator = "!=="; return self;
  12856. case "!==": self.operator = "==="; return self;
  12857. case "&&":
  12858. self.operator = "||";
  12859. self.left = self.left.negate(compressor, first_in_statement);
  12860. self.right = self.right.negate(compressor);
  12861. return best(this, self, first_in_statement);
  12862. case "||":
  12863. self.operator = "&&";
  12864. self.left = self.left.negate(compressor, first_in_statement);
  12865. self.right = self.right.negate(compressor);
  12866. return best(this, self, first_in_statement);
  12867. }
  12868. return basic_negation(this);
  12869. });
  12870. })(function(node, func) {
  12871. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  12872. return func.call(this, compressor, first_in_statement);
  12873. });
  12874. });
  12875. (function (def_bitwise_negate) {
  12876. function basic_negation(exp) {
  12877. return make_node(AST_UnaryPrefix, exp, {
  12878. operator: "~",
  12879. expression: exp
  12880. });
  12881. }
  12882. def_bitwise_negate(AST_Node, function() {
  12883. return basic_negation(this);
  12884. });
  12885. def_bitwise_negate(AST_Number, function() {
  12886. const neg = ~this.value;
  12887. if (neg.toString().length > this.value.toString().length) {
  12888. return basic_negation(this);
  12889. }
  12890. return make_node(AST_Number, this, { value: neg });
  12891. });
  12892. def_bitwise_negate(AST_UnaryPrefix, function(in_32_bit_context) {
  12893. if (this.operator == "~" && (in_32_bit_context || this.expression.is_32_bit_integer())) {
  12894. return this.expression;
  12895. } else {
  12896. return basic_negation(this);
  12897. }
  12898. });
  12899. })(function (node, func) {
  12900. node.DEFMETHOD("bitwise_negate", func);
  12901. });
  12902. // Is the callee of this function pure?
  12903. 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");
  12904. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  12905. if (compressor.option("unsafe")) {
  12906. var expr = this.expression;
  12907. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  12908. if (
  12909. expr.expression && expr.expression.name === "hasOwnProperty" &&
  12910. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  12911. ) {
  12912. return false;
  12913. }
  12914. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  12915. if (
  12916. expr instanceof AST_Dot
  12917. && is_undeclared_ref(expr.expression)
  12918. && is_pure_native_fn(expr.expression.name, expr.property)
  12919. ) {
  12920. return true;
  12921. }
  12922. }
  12923. if ((this instanceof AST_New) && compressor.option("pure_new")) {
  12924. return true;
  12925. }
  12926. if (compressor.option("side_effects") && has_annotation(this, _PURE)) {
  12927. return true;
  12928. }
  12929. return !compressor.pure_funcs(this);
  12930. });
  12931. // If I call this, is it a pure function?
  12932. AST_Node.DEFMETHOD("is_call_pure", return_false);
  12933. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  12934. if (!compressor.option("unsafe")) return;
  12935. const expr = this.expression;
  12936. let native_obj;
  12937. if (expr instanceof AST_Array) {
  12938. native_obj = "Array";
  12939. } else if (expr.is_boolean()) {
  12940. native_obj = "Boolean";
  12941. } else if (expr.is_number(compressor)) {
  12942. native_obj = "Number";
  12943. } else if (expr instanceof AST_RegExp) {
  12944. native_obj = "RegExp";
  12945. } else if (expr.is_string(compressor)) {
  12946. native_obj = "String";
  12947. } else if (!this.may_throw_on_access(compressor)) {
  12948. native_obj = "Object";
  12949. }
  12950. return native_obj != null && is_pure_native_method(native_obj, this.property);
  12951. });
  12952. // tell me if a statement aborts
  12953. const aborts = (thing) => thing && thing.aborts();
  12954. (function(def_aborts) {
  12955. def_aborts(AST_Statement, return_null);
  12956. def_aborts(AST_Jump, return_this);
  12957. function block_aborts() {
  12958. for (var i = 0; i < this.body.length; i++) {
  12959. if (aborts(this.body[i])) {
  12960. return this.body[i];
  12961. }
  12962. }
  12963. return null;
  12964. }
  12965. def_aborts(AST_Import, return_null);
  12966. def_aborts(AST_BlockStatement, block_aborts);
  12967. def_aborts(AST_SwitchBranch, block_aborts);
  12968. def_aborts(AST_DefClass, function () {
  12969. for (const prop of this.properties) {
  12970. if (prop instanceof AST_ClassStaticBlock) {
  12971. if (prop.aborts()) return prop;
  12972. }
  12973. }
  12974. return null;
  12975. });
  12976. def_aborts(AST_ClassStaticBlock, block_aborts);
  12977. def_aborts(AST_If, function() {
  12978. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  12979. });
  12980. })(function(node, func) {
  12981. node.DEFMETHOD("aborts", func);
  12982. });
  12983. AST_Node.DEFMETHOD("contains_this", function() {
  12984. return walk(this, node => {
  12985. if (node instanceof AST_This) return walk_abort;
  12986. if (
  12987. node !== this
  12988. && node instanceof AST_Scope
  12989. && !(node instanceof AST_Arrow)
  12990. ) {
  12991. return true;
  12992. }
  12993. });
  12994. });
  12995. function is_modified(compressor, tw, node, value, level, immutable) {
  12996. var parent = tw.parent(level);
  12997. var lhs = is_lhs(node, parent);
  12998. if (lhs) return lhs;
  12999. if (!immutable
  13000. && parent instanceof AST_Call
  13001. && parent.expression === node
  13002. && !(value instanceof AST_Arrow)
  13003. && !(value instanceof AST_Class)
  13004. && !parent.is_callee_pure(compressor)
  13005. && (!(value instanceof AST_Function)
  13006. || !(parent instanceof AST_New) && value.contains_this())) {
  13007. return true;
  13008. }
  13009. if (parent instanceof AST_Array) {
  13010. return is_modified(compressor, tw, parent, parent, level + 1);
  13011. }
  13012. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  13013. var obj = tw.parent(level + 1);
  13014. return is_modified(compressor, tw, obj, obj, level + 2);
  13015. }
  13016. if (parent instanceof AST_PropAccess && parent.expression === node) {
  13017. var prop = read_property(value, parent.property);
  13018. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  13019. }
  13020. }
  13021. /**
  13022. * Check if a node may be used by the expression it's in
  13023. * void (0, 1, {node}, 2) -> false
  13024. * console.log(0, {node}) -> true
  13025. */
  13026. function is_used_in_expression(tw) {
  13027. for (let p = -1, node, parent; node = tw.parent(p), parent = tw.parent(p + 1); p++) {
  13028. if (parent instanceof AST_Sequence) {
  13029. const nth_expression = parent.expressions.indexOf(node);
  13030. if (nth_expression !== parent.expressions.length - 1) {
  13031. // Detect (0, x.noThis)() constructs
  13032. const grandparent = tw.parent(p + 2);
  13033. if (
  13034. parent.expressions.length > 2
  13035. || parent.expressions.length === 1
  13036. || !requires_sequence_to_maintain_binding(grandparent, parent, parent.expressions[1])
  13037. ) {
  13038. return false;
  13039. }
  13040. return true;
  13041. } else {
  13042. continue;
  13043. }
  13044. }
  13045. if (parent instanceof AST_Unary) {
  13046. const op = parent.operator;
  13047. if (op === "void") {
  13048. return false;
  13049. }
  13050. if (op === "typeof" || op === "+" || op === "-" || op === "!" || op === "~") {
  13051. continue;
  13052. }
  13053. }
  13054. if (
  13055. parent instanceof AST_SimpleStatement
  13056. || parent instanceof AST_LabeledStatement
  13057. ) {
  13058. return false;
  13059. }
  13060. if (parent instanceof AST_Scope) {
  13061. return false;
  13062. }
  13063. return true;
  13064. }
  13065. return true;
  13066. }
  13067. /***********************************************************************
  13068. A JavaScript tokenizer / parser / beautifier / compressor.
  13069. https://github.com/mishoo/UglifyJS2
  13070. -------------------------------- (C) ---------------------------------
  13071. Author: Mihai Bazon
  13072. <mihai.bazon@gmail.com>
  13073. http://mihai.bazon.net/blog
  13074. Distributed under the BSD license:
  13075. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13076. Redistribution and use in source and binary forms, with or without
  13077. modification, are permitted provided that the following conditions
  13078. are met:
  13079. * Redistributions of source code must retain the above
  13080. copyright notice, this list of conditions and the following
  13081. disclaimer.
  13082. * Redistributions in binary form must reproduce the above
  13083. copyright notice, this list of conditions and the following
  13084. disclaimer in the documentation and/or other materials
  13085. provided with the distribution.
  13086. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13087. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13088. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13089. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13090. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13091. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13092. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13093. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13094. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13095. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13096. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13097. SUCH DAMAGE.
  13098. ***********************************************************************/
  13099. // methods to evaluate a constant expression
  13100. function def_eval(node, func) {
  13101. node.DEFMETHOD("_eval", func);
  13102. }
  13103. // Used to propagate a nullish short-circuit signal upwards through the chain.
  13104. const nullish = Symbol("This AST_Chain is nullish");
  13105. // If the node has been successfully reduced to a constant,
  13106. // then its value is returned; otherwise the element itself
  13107. // is returned.
  13108. // They can be distinguished as constant value is never a
  13109. // descendant of AST_Node.
  13110. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  13111. if (!compressor.option("evaluate"))
  13112. return this;
  13113. var val = this._eval(compressor, 1);
  13114. if (!val || val instanceof RegExp)
  13115. return val;
  13116. if (typeof val == "function" || typeof val == "object" || val == nullish)
  13117. return this;
  13118. // Evaluated strings can be larger than the original expression
  13119. if (typeof val === "string") {
  13120. const unevaluated_size = this.size(compressor);
  13121. if (val.length + 2 > unevaluated_size) return this;
  13122. }
  13123. return val;
  13124. });
  13125. var unaryPrefix = makePredicate("! ~ - + void");
  13126. AST_Node.DEFMETHOD("is_constant", function () {
  13127. // Accomodate when compress option evaluate=false
  13128. // as well as the common constant expressions !0 and -1
  13129. if (this instanceof AST_Constant) {
  13130. return !(this instanceof AST_RegExp);
  13131. } else {
  13132. return this instanceof AST_UnaryPrefix
  13133. && unaryPrefix.has(this.operator)
  13134. && (
  13135. // `this.expression` may be an `AST_RegExp`,
  13136. // so not only `.is_constant()`.
  13137. this.expression instanceof AST_Constant
  13138. || this.expression.is_constant()
  13139. );
  13140. }
  13141. });
  13142. def_eval(AST_Statement, function () {
  13143. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  13144. });
  13145. def_eval(AST_Lambda, return_this);
  13146. def_eval(AST_Class, return_this);
  13147. def_eval(AST_Node, return_this);
  13148. def_eval(AST_Constant, function () {
  13149. return this.getValue();
  13150. });
  13151. const supports_bigint = typeof BigInt === "function";
  13152. def_eval(AST_BigInt, function () {
  13153. if (supports_bigint) {
  13154. return BigInt(this.value);
  13155. } else {
  13156. return this;
  13157. }
  13158. });
  13159. def_eval(AST_RegExp, function (compressor) {
  13160. let evaluated = compressor.evaluated_regexps.get(this.value);
  13161. if (evaluated === undefined && regexp_is_safe(this.value.source)) {
  13162. try {
  13163. const { source, flags } = this.value;
  13164. evaluated = new RegExp(source, flags);
  13165. } catch (e) {
  13166. evaluated = null;
  13167. }
  13168. compressor.evaluated_regexps.set(this.value, evaluated);
  13169. }
  13170. return evaluated || this;
  13171. });
  13172. def_eval(AST_TemplateString, function () {
  13173. if (this.segments.length !== 1) return this;
  13174. return this.segments[0].value;
  13175. });
  13176. def_eval(AST_Function, function (compressor) {
  13177. if (compressor.option("unsafe")) {
  13178. var fn = function () { };
  13179. fn.node = this;
  13180. fn.toString = () => this.print_to_string();
  13181. return fn;
  13182. }
  13183. return this;
  13184. });
  13185. def_eval(AST_Array, function (compressor, depth) {
  13186. if (compressor.option("unsafe")) {
  13187. var elements = [];
  13188. for (var i = 0, len = this.elements.length; i < len; i++) {
  13189. var element = this.elements[i];
  13190. var value = element._eval(compressor, depth);
  13191. if (element === value)
  13192. return this;
  13193. elements.push(value);
  13194. }
  13195. return elements;
  13196. }
  13197. return this;
  13198. });
  13199. def_eval(AST_Object, function (compressor, depth) {
  13200. if (compressor.option("unsafe")) {
  13201. var val = {};
  13202. for (var i = 0, len = this.properties.length; i < len; i++) {
  13203. var prop = this.properties[i];
  13204. if (prop instanceof AST_Expansion)
  13205. return this;
  13206. var key = prop.key;
  13207. if (key instanceof AST_Symbol) {
  13208. key = key.name;
  13209. } else if (key instanceof AST_Node) {
  13210. key = key._eval(compressor, depth);
  13211. if (key === prop.key)
  13212. return this;
  13213. }
  13214. if (typeof Object.prototype[key] === "function") {
  13215. return this;
  13216. }
  13217. if (prop.value instanceof AST_Function)
  13218. continue;
  13219. val[key] = prop.value._eval(compressor, depth);
  13220. if (val[key] === prop.value)
  13221. return this;
  13222. }
  13223. return val;
  13224. }
  13225. return this;
  13226. });
  13227. var non_converting_unary = makePredicate("! typeof void");
  13228. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  13229. var e = this.expression;
  13230. if (compressor.option("typeofs")
  13231. && this.operator == "typeof") {
  13232. // Function would be evaluated to an array and so typeof would
  13233. // incorrectly return 'object'. Hence making is a special case.
  13234. if (e instanceof AST_Lambda
  13235. || e instanceof AST_SymbolRef
  13236. && e.fixed_value() instanceof AST_Lambda) {
  13237. return typeof function () { };
  13238. }
  13239. if (
  13240. (e instanceof AST_Object
  13241. || e instanceof AST_Array
  13242. || (e instanceof AST_SymbolRef
  13243. && (e.fixed_value() instanceof AST_Object
  13244. || e.fixed_value() instanceof AST_Array)))
  13245. && !e.has_side_effects(compressor)
  13246. ) {
  13247. return typeof {};
  13248. }
  13249. }
  13250. if (!non_converting_unary.has(this.operator))
  13251. depth++;
  13252. e = e._eval(compressor, depth);
  13253. if (e === this.expression)
  13254. return this;
  13255. switch (this.operator) {
  13256. case "!": return !e;
  13257. case "typeof":
  13258. // typeof <RegExp> returns "object" or "function" on different platforms
  13259. // so cannot evaluate reliably
  13260. if (e instanceof RegExp)
  13261. return this;
  13262. return typeof e;
  13263. case "void": return void e;
  13264. case "~": return ~e;
  13265. case "-": return -e;
  13266. case "+": return +e;
  13267. }
  13268. return this;
  13269. });
  13270. var non_converting_binary = makePredicate("&& || ?? === !==");
  13271. const identity_comparison = makePredicate("== != === !==");
  13272. const has_identity = value => typeof value === "object"
  13273. || typeof value === "function"
  13274. || typeof value === "symbol";
  13275. def_eval(AST_Binary, function (compressor, depth) {
  13276. if (!non_converting_binary.has(this.operator))
  13277. depth++;
  13278. var left = this.left._eval(compressor, depth);
  13279. if (left === this.left)
  13280. return this;
  13281. var right = this.right._eval(compressor, depth);
  13282. if (right === this.right)
  13283. return this;
  13284. if (left != null
  13285. && right != null
  13286. && identity_comparison.has(this.operator)
  13287. && has_identity(left)
  13288. && has_identity(right)
  13289. && typeof left === typeof right) {
  13290. // Do not compare by reference
  13291. return this;
  13292. }
  13293. // Do not mix BigInt and Number; Don't use `>>>` on BigInt or `/ 0n`
  13294. if (
  13295. (typeof left === "bigint") !== (typeof right === "bigint")
  13296. || typeof left === "bigint"
  13297. && (this.operator === ">>>"
  13298. || this.operator === "/" && Number(right) === 0)
  13299. ) {
  13300. return this;
  13301. }
  13302. var result;
  13303. switch (this.operator) {
  13304. case "&&": result = left && right; break;
  13305. case "||": result = left || right; break;
  13306. case "??": result = left != null ? left : right; break;
  13307. case "|": result = left | right; break;
  13308. case "&": result = left & right; break;
  13309. case "^": result = left ^ right; break;
  13310. case "+": result = left + right; break;
  13311. case "*": result = left * right; break;
  13312. case "**": result = left ** right; break;
  13313. case "/": result = left / right; break;
  13314. case "%": result = left % right; break;
  13315. case "-": result = left - right; break;
  13316. case "<<": result = left << right; break;
  13317. case ">>": result = left >> right; break;
  13318. case ">>>": result = left >>> right; break;
  13319. case "==": result = left == right; break;
  13320. case "===": result = left === right; break;
  13321. case "!=": result = left != right; break;
  13322. case "!==": result = left !== right; break;
  13323. case "<": result = left < right; break;
  13324. case "<=": result = left <= right; break;
  13325. case ">": result = left > right; break;
  13326. case ">=": result = left >= right; break;
  13327. default:
  13328. return this;
  13329. }
  13330. if (typeof result === "number" && isNaN(result) && compressor.find_parent(AST_With)) {
  13331. // leave original expression as is
  13332. return this;
  13333. }
  13334. return result;
  13335. });
  13336. def_eval(AST_Conditional, function (compressor, depth) {
  13337. var condition = this.condition._eval(compressor, depth);
  13338. if (condition === this.condition)
  13339. return this;
  13340. var node = condition ? this.consequent : this.alternative;
  13341. var value = node._eval(compressor, depth);
  13342. return value === node ? this : value;
  13343. });
  13344. // Set of AST_SymbolRef which are currently being evaluated.
  13345. // Avoids infinite recursion of ._eval()
  13346. const reentrant_ref_eval = new Set();
  13347. def_eval(AST_SymbolRef, function (compressor, depth) {
  13348. if (reentrant_ref_eval.has(this))
  13349. return this;
  13350. var fixed = this.fixed_value();
  13351. if (!fixed)
  13352. return this;
  13353. reentrant_ref_eval.add(this);
  13354. const value = fixed._eval(compressor, depth);
  13355. reentrant_ref_eval.delete(this);
  13356. if (value === fixed)
  13357. return this;
  13358. if (value && typeof value == "object") {
  13359. var escaped = this.definition().escaped;
  13360. if (escaped && depth > escaped)
  13361. return this;
  13362. }
  13363. return value;
  13364. });
  13365. const global_objs = { Array, Math, Number, Object, String };
  13366. const regexp_flags = new Set([
  13367. "dotAll",
  13368. "global",
  13369. "ignoreCase",
  13370. "multiline",
  13371. "sticky",
  13372. "unicode",
  13373. ]);
  13374. def_eval(AST_PropAccess, function (compressor, depth) {
  13375. let obj = this.expression._eval(compressor, depth + 1);
  13376. if (obj === nullish || (this.optional && obj == null)) return nullish;
  13377. // `.length` of strings and arrays is always safe
  13378. if (this.property === "length") {
  13379. if (typeof obj === "string") {
  13380. return obj.length;
  13381. }
  13382. const is_spreadless_array =
  13383. obj instanceof AST_Array
  13384. && obj.elements.every(el => !(el instanceof AST_Expansion));
  13385. if (
  13386. is_spreadless_array
  13387. && obj.elements.every(el => !el.has_side_effects(compressor))
  13388. ) {
  13389. return obj.elements.length;
  13390. }
  13391. }
  13392. if (compressor.option("unsafe")) {
  13393. var key = this.property;
  13394. if (key instanceof AST_Node) {
  13395. key = key._eval(compressor, depth);
  13396. if (key === this.property)
  13397. return this;
  13398. }
  13399. var exp = this.expression;
  13400. if (is_undeclared_ref(exp)) {
  13401. var aa;
  13402. var first_arg = exp.name === "hasOwnProperty"
  13403. && key === "call"
  13404. && (aa = compressor.parent() && compressor.parent().args)
  13405. && (aa && aa[0]
  13406. && aa[0].evaluate(compressor));
  13407. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13408. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  13409. return this.clone();
  13410. }
  13411. if (!is_pure_native_value(exp.name, key))
  13412. return this;
  13413. obj = global_objs[exp.name];
  13414. } else {
  13415. if (obj instanceof RegExp) {
  13416. if (key == "source") {
  13417. return regexp_source_fix(obj.source);
  13418. } else if (key == "flags" || regexp_flags.has(key)) {
  13419. return obj[key];
  13420. }
  13421. }
  13422. if (!obj || obj === exp || !HOP(obj, key))
  13423. return this;
  13424. if (typeof obj == "function")
  13425. switch (key) {
  13426. case "name":
  13427. return obj.node.name ? obj.node.name.name : "";
  13428. case "length":
  13429. return obj.node.length_property();
  13430. default:
  13431. return this;
  13432. }
  13433. }
  13434. return obj[key];
  13435. }
  13436. return this;
  13437. });
  13438. def_eval(AST_Chain, function (compressor, depth) {
  13439. const evaluated = this.expression._eval(compressor, depth);
  13440. return evaluated === nullish
  13441. ? undefined
  13442. : evaluated === this.expression
  13443. ? this
  13444. : evaluated;
  13445. });
  13446. def_eval(AST_Call, function (compressor, depth) {
  13447. var exp = this.expression;
  13448. const callee = exp._eval(compressor, depth);
  13449. if (callee === nullish || (this.optional && callee == null)) return nullish;
  13450. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  13451. var key = exp.property;
  13452. if (key instanceof AST_Node) {
  13453. key = key._eval(compressor, depth);
  13454. if (key === exp.property)
  13455. return this;
  13456. }
  13457. var val;
  13458. var e = exp.expression;
  13459. if (is_undeclared_ref(e)) {
  13460. var first_arg = e.name === "hasOwnProperty" &&
  13461. key === "call" &&
  13462. (this.args[0] && this.args[0].evaluate(compressor));
  13463. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13464. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  13465. return this.clone();
  13466. }
  13467. if (!is_pure_native_fn(e.name, key)) return this;
  13468. val = global_objs[e.name];
  13469. } else {
  13470. val = e._eval(compressor, depth + 1);
  13471. if (val === e || !val)
  13472. return this;
  13473. if (!is_pure_native_method(val.constructor.name, key))
  13474. return this;
  13475. }
  13476. var args = [];
  13477. for (var i = 0, len = this.args.length; i < len; i++) {
  13478. var arg = this.args[i];
  13479. var value = arg._eval(compressor, depth);
  13480. if (arg === value)
  13481. return this;
  13482. if (arg instanceof AST_Lambda)
  13483. return this;
  13484. args.push(value);
  13485. }
  13486. try {
  13487. return val[key].apply(val, args);
  13488. } catch (ex) {
  13489. // We don't really care
  13490. }
  13491. }
  13492. return this;
  13493. });
  13494. // Also a subclass of AST_Call
  13495. def_eval(AST_New, return_this);
  13496. /***********************************************************************
  13497. A JavaScript tokenizer / parser / beautifier / compressor.
  13498. https://github.com/mishoo/UglifyJS2
  13499. -------------------------------- (C) ---------------------------------
  13500. Author: Mihai Bazon
  13501. <mihai.bazon@gmail.com>
  13502. http://mihai.bazon.net/blog
  13503. Distributed under the BSD license:
  13504. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13505. Redistribution and use in source and binary forms, with or without
  13506. modification, are permitted provided that the following conditions
  13507. are met:
  13508. * Redistributions of source code must retain the above
  13509. copyright notice, this list of conditions and the following
  13510. disclaimer.
  13511. * Redistributions in binary form must reproduce the above
  13512. copyright notice, this list of conditions and the following
  13513. disclaimer in the documentation and/or other materials
  13514. provided with the distribution.
  13515. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13516. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13517. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13518. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13519. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13520. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13521. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13522. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13523. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13524. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13525. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13526. SUCH DAMAGE.
  13527. ***********************************************************************/
  13528. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  13529. // only about side effects. We'll be defining this method for each node type in this module
  13530. //
  13531. // Examples:
  13532. // foo++ -> foo++
  13533. // 1 + func() -> func()
  13534. // 10 -> (nothing)
  13535. // knownPureFunc(foo++) -> foo++
  13536. function def_drop_side_effect_free(node_or_nodes, func) {
  13537. for (const node of [].concat(node_or_nodes)) {
  13538. node.DEFMETHOD("drop_side_effect_free", func);
  13539. }
  13540. }
  13541. // Drop side-effect-free elements from an array of expressions.
  13542. // Returns an array of expressions with side-effects or null
  13543. // if all elements were dropped. Note: original array may be
  13544. // returned if nothing changed.
  13545. function trim(nodes, compressor, first_in_statement) {
  13546. var len = nodes.length;
  13547. if (!len) return null;
  13548. var ret = [], changed = false;
  13549. for (var i = 0; i < len; i++) {
  13550. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  13551. changed |= node !== nodes[i];
  13552. if (node) {
  13553. ret.push(node);
  13554. first_in_statement = false;
  13555. }
  13556. }
  13557. return changed ? ret.length ? ret : null : nodes;
  13558. }
  13559. def_drop_side_effect_free(AST_Node, return_this);
  13560. def_drop_side_effect_free(AST_Constant, return_null);
  13561. def_drop_side_effect_free(AST_This, return_null);
  13562. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  13563. if (is_nullish_shortcircuited(this, compressor)) {
  13564. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13565. }
  13566. if (!this.is_callee_pure(compressor)) {
  13567. if (this.expression.is_call_pure(compressor)) {
  13568. var exprs = this.args.slice();
  13569. exprs.unshift(this.expression.expression);
  13570. exprs = trim(exprs, compressor, first_in_statement);
  13571. return exprs && make_sequence(this, exprs);
  13572. }
  13573. if (is_func_expr(this.expression)
  13574. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  13575. var node = this.clone();
  13576. node.expression.process_expression(false, compressor);
  13577. return node;
  13578. }
  13579. return this;
  13580. }
  13581. var args = trim(this.args, compressor, first_in_statement);
  13582. return args && make_sequence(this, args);
  13583. });
  13584. def_drop_side_effect_free(AST_Accessor, return_null);
  13585. def_drop_side_effect_free(AST_Function, return_null);
  13586. def_drop_side_effect_free(AST_Arrow, return_null);
  13587. def_drop_side_effect_free(AST_Class, function (compressor) {
  13588. const with_effects = [];
  13589. if (this.is_self_referential() && this.has_side_effects(compressor)) {
  13590. return this;
  13591. }
  13592. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  13593. if (trimmed_extends) with_effects.push(trimmed_extends);
  13594. for (const prop of this.properties) {
  13595. if (prop instanceof AST_ClassStaticBlock) {
  13596. if (prop.has_side_effects(compressor)) {
  13597. return this; // Be cautious about these
  13598. }
  13599. } else {
  13600. const trimmed_prop = prop.drop_side_effect_free(compressor);
  13601. if (trimmed_prop) with_effects.push(trimmed_prop);
  13602. }
  13603. }
  13604. if (!with_effects.length)
  13605. return null;
  13606. const exprs = make_sequence(this, with_effects);
  13607. if (this instanceof AST_DefClass) {
  13608. // We want a statement
  13609. return make_node(AST_SimpleStatement, this, { body: exprs });
  13610. } else {
  13611. return exprs;
  13612. }
  13613. });
  13614. def_drop_side_effect_free([
  13615. AST_ClassProperty,
  13616. AST_ClassPrivateProperty,
  13617. ], function (compressor) {
  13618. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  13619. const value = this.static && this.value
  13620. && this.value.drop_side_effect_free(compressor);
  13621. if (key && value)
  13622. return make_sequence(this, [key, value]);
  13623. return key || value || null;
  13624. });
  13625. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  13626. var right = this.right.drop_side_effect_free(compressor);
  13627. if (!right)
  13628. return this.left.drop_side_effect_free(compressor, first_in_statement);
  13629. if (lazy_op.has(this.operator)) {
  13630. if (right === this.right)
  13631. return this;
  13632. var node = this.clone();
  13633. node.right = right;
  13634. return node;
  13635. } else {
  13636. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  13637. if (!left)
  13638. return this.right.drop_side_effect_free(compressor, first_in_statement);
  13639. return make_sequence(this, [left, right]);
  13640. }
  13641. });
  13642. def_drop_side_effect_free(AST_Assign, function (compressor) {
  13643. if (this.logical)
  13644. return this;
  13645. var left = this.left;
  13646. if (left.has_side_effects(compressor)
  13647. || compressor.has_directive("use strict")
  13648. && left instanceof AST_PropAccess
  13649. && left.expression.is_constant()) {
  13650. return this;
  13651. }
  13652. set_flag(this, WRITE_ONLY);
  13653. while (left instanceof AST_PropAccess) {
  13654. left = left.expression;
  13655. }
  13656. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  13657. return this.right.drop_side_effect_free(compressor);
  13658. }
  13659. return this;
  13660. });
  13661. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  13662. var consequent = this.consequent.drop_side_effect_free(compressor);
  13663. var alternative = this.alternative.drop_side_effect_free(compressor);
  13664. if (consequent === this.consequent && alternative === this.alternative)
  13665. return this;
  13666. if (!consequent)
  13667. return alternative ? make_node(AST_Binary, this, {
  13668. operator: "||",
  13669. left: this.condition,
  13670. right: alternative
  13671. }) : this.condition.drop_side_effect_free(compressor);
  13672. if (!alternative)
  13673. return make_node(AST_Binary, this, {
  13674. operator: "&&",
  13675. left: this.condition,
  13676. right: consequent
  13677. });
  13678. var node = this.clone();
  13679. node.consequent = consequent;
  13680. node.alternative = alternative;
  13681. return node;
  13682. });
  13683. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  13684. if (unary_side_effects.has(this.operator)) {
  13685. if (!this.expression.has_side_effects(compressor)) {
  13686. set_flag(this, WRITE_ONLY);
  13687. } else {
  13688. clear_flag(this, WRITE_ONLY);
  13689. }
  13690. return this;
  13691. }
  13692. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  13693. return null;
  13694. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13695. if (first_in_statement && expression && is_iife_call(expression)) {
  13696. if (expression === this.expression && this.operator == "!")
  13697. return this;
  13698. return expression.negate(compressor, first_in_statement);
  13699. }
  13700. return expression;
  13701. });
  13702. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  13703. const safe_access = this.is_declared(compressor)
  13704. || pure_prop_access_globals.has(this.name);
  13705. return safe_access ? null : this;
  13706. });
  13707. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  13708. var values = trim(this.properties, compressor, first_in_statement);
  13709. return values && make_sequence(this, values);
  13710. });
  13711. def_drop_side_effect_free(AST_ObjectKeyVal, function (compressor, first_in_statement) {
  13712. const computed_key = this.key instanceof AST_Node;
  13713. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  13714. const value = this.value.drop_side_effect_free(compressor, first_in_statement);
  13715. if (key && value) {
  13716. return make_sequence(this, [key, value]);
  13717. }
  13718. return key || value;
  13719. });
  13720. def_drop_side_effect_free([
  13721. AST_ConciseMethod,
  13722. AST_ObjectGetter,
  13723. AST_ObjectSetter,
  13724. ], function () {
  13725. return this.computed_key() ? this.key : null;
  13726. });
  13727. def_drop_side_effect_free([
  13728. AST_PrivateMethod,
  13729. AST_PrivateGetter,
  13730. AST_PrivateSetter,
  13731. ], function () {
  13732. return null;
  13733. });
  13734. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  13735. var values = trim(this.elements, compressor, first_in_statement);
  13736. return values && make_sequence(this, values);
  13737. });
  13738. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  13739. if (is_nullish_shortcircuited(this, compressor)) {
  13740. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13741. }
  13742. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  13743. return this;
  13744. }
  13745. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13746. });
  13747. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  13748. if (is_nullish_shortcircuited(this, compressor)) {
  13749. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13750. }
  13751. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  13752. return this;
  13753. }
  13754. var property = this.property.drop_side_effect_free(compressor);
  13755. if (property && this.optional) return this;
  13756. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13757. if (expression && property) return make_sequence(this, [expression, property]);
  13758. return expression || property;
  13759. });
  13760. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  13761. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13762. });
  13763. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  13764. var last = this.tail_node();
  13765. var expr = last.drop_side_effect_free(compressor);
  13766. if (expr === last)
  13767. return this;
  13768. var expressions = this.expressions.slice(0, -1);
  13769. if (expr)
  13770. expressions.push(expr);
  13771. if (!expressions.length) {
  13772. return make_node(AST_Number, this, { value: 0 });
  13773. }
  13774. return make_sequence(this, expressions);
  13775. });
  13776. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  13777. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13778. });
  13779. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  13780. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  13781. var values = trim(this.segments, compressor, first_in_statement);
  13782. return values && make_sequence(this, values);
  13783. });
  13784. /***********************************************************************
  13785. A JavaScript tokenizer / parser / beautifier / compressor.
  13786. https://github.com/mishoo/UglifyJS2
  13787. -------------------------------- (C) ---------------------------------
  13788. Author: Mihai Bazon
  13789. <mihai.bazon@gmail.com>
  13790. http://mihai.bazon.net/blog
  13791. Distributed under the BSD license:
  13792. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13793. Redistribution and use in source and binary forms, with or without
  13794. modification, are permitted provided that the following conditions
  13795. are met:
  13796. * Redistributions of source code must retain the above
  13797. copyright notice, this list of conditions and the following
  13798. disclaimer.
  13799. * Redistributions in binary form must reproduce the above
  13800. copyright notice, this list of conditions and the following
  13801. disclaimer in the documentation and/or other materials
  13802. provided with the distribution.
  13803. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13804. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13805. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13806. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13807. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13808. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13809. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13810. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13811. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13812. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13813. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13814. SUCH DAMAGE.
  13815. ***********************************************************************/
  13816. const r_keep_assign = /keep_assign/;
  13817. /** Drop unused variables from this scope */
  13818. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  13819. if (!compressor.option("unused")) return;
  13820. if (compressor.has_directive("use asm")) return;
  13821. if (!this.variables) return; // not really a scope (eg: AST_Class)
  13822. var self = this;
  13823. if (self.pinned()) return;
  13824. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  13825. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  13826. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  13827. if (node instanceof AST_Assign
  13828. && !node.logical
  13829. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  13830. ) {
  13831. return node.left;
  13832. }
  13833. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  13834. return node.expression;
  13835. }
  13836. };
  13837. var in_use_ids = new Map();
  13838. var fixed_ids = new Map();
  13839. if (self instanceof AST_Toplevel && compressor.top_retain) {
  13840. self.variables.forEach(function(def) {
  13841. if (compressor.top_retain(def)) {
  13842. in_use_ids.set(def.id, def);
  13843. }
  13844. });
  13845. }
  13846. var var_defs_by_id = new Map();
  13847. var initializations = new Map();
  13848. // pass 1: find out which symbols are directly used in
  13849. // this scope (not in nested scopes).
  13850. var scope = this;
  13851. var tw = new TreeWalker(function(node, descend) {
  13852. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  13853. node.argnames.forEach(function(argname) {
  13854. if (!(argname instanceof AST_SymbolDeclaration)) return;
  13855. var def = argname.definition();
  13856. in_use_ids.set(def.id, def);
  13857. });
  13858. }
  13859. if (node === self) return;
  13860. if (node instanceof AST_Class && node.has_side_effects(compressor)) {
  13861. if (node.is_self_referential()) {
  13862. descend();
  13863. } else {
  13864. node.visit_nondeferred_class_parts(tw);
  13865. }
  13866. }
  13867. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  13868. var node_def = node.name.definition();
  13869. const in_export = tw.parent() instanceof AST_Export;
  13870. if (in_export || !drop_funcs && scope === self) {
  13871. if (node_def.global) {
  13872. in_use_ids.set(node_def.id, node_def);
  13873. }
  13874. }
  13875. map_add(initializations, node_def.id, node);
  13876. return true; // don't go in nested scopes
  13877. }
  13878. // In the root scope, we drop things. In inner scopes, we just check for uses.
  13879. const in_root_scope = scope === self;
  13880. if (node instanceof AST_SymbolFunarg && in_root_scope) {
  13881. map_add(var_defs_by_id, node.definition().id, node);
  13882. }
  13883. if (node instanceof AST_Definitions && in_root_scope) {
  13884. const in_export = tw.parent() instanceof AST_Export;
  13885. node.definitions.forEach(function(def) {
  13886. if (def.name instanceof AST_SymbolVar) {
  13887. map_add(var_defs_by_id, def.name.definition().id, def);
  13888. }
  13889. if (in_export || !drop_vars) {
  13890. walk(def.name, node => {
  13891. if (node instanceof AST_SymbolDeclaration) {
  13892. const def = node.definition();
  13893. if (def.global) {
  13894. in_use_ids.set(def.id, def);
  13895. }
  13896. }
  13897. });
  13898. }
  13899. if (def.name instanceof AST_Destructuring) {
  13900. def.walk(tw);
  13901. }
  13902. if (def.name instanceof AST_SymbolDeclaration && def.value) {
  13903. var node_def = def.name.definition();
  13904. map_add(initializations, node_def.id, def.value);
  13905. if (!node_def.chained && def.name.fixed_value() === def.value) {
  13906. fixed_ids.set(node_def.id, def);
  13907. }
  13908. if (def.value.has_side_effects(compressor)) {
  13909. def.value.walk(tw);
  13910. }
  13911. }
  13912. });
  13913. return true;
  13914. }
  13915. return scan_ref_scoped(node, descend);
  13916. });
  13917. self.walk(tw);
  13918. // pass 2: for every used symbol we need to walk its
  13919. // initialization code to figure out if it uses other
  13920. // symbols (that may not be in_use).
  13921. tw = new TreeWalker(scan_ref_scoped);
  13922. in_use_ids.forEach(function (def) {
  13923. var init = initializations.get(def.id);
  13924. if (init) init.forEach(function(init) {
  13925. init.walk(tw);
  13926. });
  13927. });
  13928. // pass 3: we should drop declarations not in_use
  13929. var tt = new TreeTransformer(
  13930. function before(node, descend, in_list) {
  13931. var parent = tt.parent();
  13932. if (drop_vars) {
  13933. const sym = assign_as_unused(node);
  13934. if (sym instanceof AST_SymbolRef) {
  13935. var def = sym.definition();
  13936. var in_use = in_use_ids.has(def.id);
  13937. if (node instanceof AST_Assign) {
  13938. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  13939. const assignee = node.right.transform(tt);
  13940. if (!in_use && !assignee.has_side_effects(compressor) && !is_used_in_expression(tt)) {
  13941. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  13942. }
  13943. return maintain_this_binding(parent, node, assignee);
  13944. }
  13945. } else if (!in_use) {
  13946. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  13947. }
  13948. }
  13949. }
  13950. if (scope !== self) return;
  13951. var def;
  13952. if (node.name
  13953. && (node instanceof AST_ClassExpression
  13954. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  13955. || node instanceof AST_Function
  13956. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  13957. // any declarations with same name will overshadow
  13958. // name of this anonymous function and can therefore
  13959. // never be used anywhere
  13960. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  13961. }
  13962. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  13963. var trim =
  13964. !compressor.option("keep_fargs")
  13965. // Is this an IIFE that won't refer to its name?
  13966. || parent instanceof AST_Call
  13967. && parent.expression === node
  13968. && !node.pinned()
  13969. && (!node.name || node.name.unreferenced());
  13970. for (var a = node.argnames, i = a.length; --i >= 0;) {
  13971. var sym = a[i];
  13972. if (sym instanceof AST_Expansion) {
  13973. sym = sym.expression;
  13974. }
  13975. if (sym instanceof AST_DefaultAssign) {
  13976. sym = sym.left;
  13977. }
  13978. // Do not drop destructuring arguments.
  13979. // They constitute a type assertion of sorts
  13980. if (
  13981. !(sym instanceof AST_Destructuring)
  13982. && !in_use_ids.has(sym.definition().id)
  13983. ) {
  13984. set_flag(sym, UNUSED);
  13985. if (trim) {
  13986. a.pop();
  13987. }
  13988. } else {
  13989. trim = false;
  13990. }
  13991. }
  13992. }
  13993. if (node instanceof AST_DefClass && node !== self) {
  13994. const def = node.name.definition();
  13995. descend(node, this);
  13996. const keep_class = def.global && !drop_funcs || in_use_ids.has(def.id);
  13997. if (!keep_class) {
  13998. const kept = node.drop_side_effect_free(compressor);
  13999. if (kept == null) {
  14000. def.eliminated++;
  14001. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  14002. }
  14003. return kept;
  14004. }
  14005. return node;
  14006. }
  14007. if (node instanceof AST_Defun && node !== self) {
  14008. const def = node.name.definition();
  14009. const keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  14010. if (!keep) {
  14011. def.eliminated++;
  14012. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  14013. }
  14014. }
  14015. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  14016. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  14017. // place uninitialized names at the start
  14018. var body = [], head = [], tail = [];
  14019. // for unused names whose initialization has
  14020. // side effects, we can cascade the init. code
  14021. // into the next one, or next statement.
  14022. var side_effects = [];
  14023. node.definitions.forEach(function(def) {
  14024. if (def.value) def.value = def.value.transform(tt);
  14025. var is_destructure = def.name instanceof AST_Destructuring;
  14026. var sym = is_destructure
  14027. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  14028. : def.name.definition();
  14029. if (drop_block && sym.global) return tail.push(def);
  14030. if (!(drop_vars || drop_block)
  14031. || is_destructure
  14032. && (def.name.names.length
  14033. || def.name.is_array
  14034. || compressor.option("pure_getters") != true)
  14035. || in_use_ids.has(sym.id)
  14036. ) {
  14037. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  14038. def.value = def.value.drop_side_effect_free(compressor);
  14039. }
  14040. if (def.name instanceof AST_SymbolVar) {
  14041. var var_defs = var_defs_by_id.get(sym.id);
  14042. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  14043. if (def.value) {
  14044. var ref = make_node(AST_SymbolRef, def.name, def.name);
  14045. sym.references.push(ref);
  14046. var assign = make_node(AST_Assign, def, {
  14047. operator: "=",
  14048. logical: false,
  14049. left: ref,
  14050. right: def.value
  14051. });
  14052. if (fixed_ids.get(sym.id) === def) {
  14053. fixed_ids.set(sym.id, assign);
  14054. }
  14055. side_effects.push(assign.transform(tt));
  14056. }
  14057. remove(var_defs, def);
  14058. sym.eliminated++;
  14059. return;
  14060. }
  14061. }
  14062. if (def.value) {
  14063. if (side_effects.length > 0) {
  14064. if (tail.length > 0) {
  14065. side_effects.push(def.value);
  14066. def.value = make_sequence(def.value, side_effects);
  14067. } else {
  14068. body.push(make_node(AST_SimpleStatement, node, {
  14069. body: make_sequence(node, side_effects)
  14070. }));
  14071. }
  14072. side_effects = [];
  14073. }
  14074. tail.push(def);
  14075. } else {
  14076. head.push(def);
  14077. }
  14078. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  14079. var value = def.value && def.value.drop_side_effect_free(compressor);
  14080. if (value) side_effects.push(value);
  14081. def.value = null;
  14082. head.push(def);
  14083. } else {
  14084. var value = def.value && def.value.drop_side_effect_free(compressor);
  14085. if (value) {
  14086. side_effects.push(value);
  14087. }
  14088. sym.eliminated++;
  14089. }
  14090. });
  14091. if (head.length > 0 || tail.length > 0) {
  14092. node.definitions = head.concat(tail);
  14093. body.push(node);
  14094. }
  14095. if (side_effects.length > 0) {
  14096. body.push(make_node(AST_SimpleStatement, node, {
  14097. body: make_sequence(node, side_effects)
  14098. }));
  14099. }
  14100. switch (body.length) {
  14101. case 0:
  14102. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  14103. case 1:
  14104. return body[0];
  14105. default:
  14106. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, { body });
  14107. }
  14108. }
  14109. // certain combination of unused name + side effect leads to:
  14110. // https://github.com/mishoo/UglifyJS2/issues/44
  14111. // https://github.com/mishoo/UglifyJS2/issues/1830
  14112. // https://github.com/mishoo/UglifyJS2/issues/1838
  14113. // that's an invalid AST.
  14114. // We fix it at this stage by moving the `var` outside the `for`.
  14115. if (node instanceof AST_For) {
  14116. descend(node, this);
  14117. var block;
  14118. if (node.init instanceof AST_BlockStatement) {
  14119. block = node.init;
  14120. node.init = block.body.pop();
  14121. block.body.push(node);
  14122. }
  14123. if (node.init instanceof AST_SimpleStatement) {
  14124. node.init = node.init.body;
  14125. } else if (is_empty(node.init)) {
  14126. node.init = null;
  14127. }
  14128. return !block ? node : in_list ? MAP.splice(block.body) : block;
  14129. }
  14130. if (node instanceof AST_LabeledStatement
  14131. && node.body instanceof AST_For
  14132. ) {
  14133. descend(node, this);
  14134. if (node.body instanceof AST_BlockStatement) {
  14135. var block = node.body;
  14136. node.body = block.body.pop();
  14137. block.body.push(node);
  14138. return in_list ? MAP.splice(block.body) : block;
  14139. }
  14140. return node;
  14141. }
  14142. if (node instanceof AST_BlockStatement) {
  14143. descend(node, this);
  14144. if (in_list && node.body.every(can_be_evicted_from_block)) {
  14145. return MAP.splice(node.body);
  14146. }
  14147. return node;
  14148. }
  14149. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  14150. const save_scope = scope;
  14151. scope = node;
  14152. descend(node, this);
  14153. scope = save_scope;
  14154. return node;
  14155. }
  14156. },
  14157. function after(node, in_list) {
  14158. if (node instanceof AST_Sequence) {
  14159. switch (node.expressions.length) {
  14160. case 0: return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  14161. case 1: return node.expressions[0];
  14162. }
  14163. }
  14164. }
  14165. );
  14166. self.transform(tt);
  14167. function scan_ref_scoped(node, descend) {
  14168. var node_def;
  14169. const sym = assign_as_unused(node);
  14170. if (sym instanceof AST_SymbolRef
  14171. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  14172. && self.variables.get(sym.name) === (node_def = sym.definition())
  14173. ) {
  14174. if (node instanceof AST_Assign) {
  14175. node.right.walk(tw);
  14176. if (!node_def.chained && node.left.fixed_value() === node.right) {
  14177. fixed_ids.set(node_def.id, node);
  14178. }
  14179. }
  14180. return true;
  14181. }
  14182. if (node instanceof AST_SymbolRef) {
  14183. node_def = node.definition();
  14184. if (!in_use_ids.has(node_def.id)) {
  14185. in_use_ids.set(node_def.id, node_def);
  14186. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  14187. const redef = node_def.scope.is_block_scope()
  14188. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  14189. if (redef) in_use_ids.set(redef.id, redef);
  14190. }
  14191. }
  14192. return true;
  14193. }
  14194. if (node instanceof AST_Class) {
  14195. descend();
  14196. return true;
  14197. }
  14198. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  14199. var save_scope = scope;
  14200. scope = node;
  14201. descend();
  14202. scope = save_scope;
  14203. return true;
  14204. }
  14205. }
  14206. });
  14207. /***********************************************************************
  14208. A JavaScript tokenizer / parser / beautifier / compressor.
  14209. https://github.com/mishoo/UglifyJS2
  14210. -------------------------------- (C) ---------------------------------
  14211. Author: Mihai Bazon
  14212. <mihai.bazon@gmail.com>
  14213. http://mihai.bazon.net/blog
  14214. Distributed under the BSD license:
  14215. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14216. Redistribution and use in source and binary forms, with or without
  14217. modification, are permitted provided that the following conditions
  14218. are met:
  14219. * Redistributions of source code must retain the above
  14220. copyright notice, this list of conditions and the following
  14221. disclaimer.
  14222. * Redistributions in binary form must reproduce the above
  14223. copyright notice, this list of conditions and the following
  14224. disclaimer in the documentation and/or other materials
  14225. provided with the distribution.
  14226. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14227. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14228. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14229. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14230. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14231. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14232. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14233. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14234. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14235. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14236. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14237. SUCH DAMAGE.
  14238. ***********************************************************************/
  14239. /**
  14240. * Define the method AST_Node#reduce_vars, which goes through the AST in
  14241. * execution order to perform basic flow analysis
  14242. */
  14243. function def_reduce_vars(node, func) {
  14244. node.DEFMETHOD("reduce_vars", func);
  14245. }
  14246. def_reduce_vars(AST_Node, noop);
  14247. /** Clear definition properties */
  14248. function reset_def(compressor, def) {
  14249. def.assignments = 0;
  14250. def.chained = false;
  14251. def.direct_access = false;
  14252. def.escaped = 0;
  14253. def.recursive_refs = 0;
  14254. def.references = [];
  14255. def.single_use = undefined;
  14256. if (
  14257. def.scope.pinned()
  14258. || (def.orig[0] instanceof AST_SymbolFunarg && def.scope.uses_arguments)
  14259. ) {
  14260. def.fixed = false;
  14261. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  14262. def.fixed = def.init;
  14263. } else {
  14264. def.fixed = false;
  14265. }
  14266. }
  14267. function reset_variables(tw, compressor, node) {
  14268. node.variables.forEach(function(def) {
  14269. reset_def(compressor, def);
  14270. if (def.fixed === null) {
  14271. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  14272. mark(tw, def, true);
  14273. } else if (def.fixed) {
  14274. tw.loop_ids.set(def.id, tw.in_loop);
  14275. mark(tw, def, true);
  14276. }
  14277. });
  14278. }
  14279. function reset_block_variables(compressor, node) {
  14280. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  14281. reset_def(compressor, def);
  14282. });
  14283. }
  14284. function push(tw) {
  14285. tw.safe_ids = Object.create(tw.safe_ids);
  14286. }
  14287. function pop(tw) {
  14288. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  14289. }
  14290. function mark(tw, def, safe) {
  14291. tw.safe_ids[def.id] = safe;
  14292. }
  14293. function safe_to_read(tw, def) {
  14294. if (def.single_use == "m") return false;
  14295. if (tw.safe_ids[def.id]) {
  14296. if (def.fixed == null) {
  14297. var orig = def.orig[0];
  14298. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  14299. def.fixed = make_node(AST_Undefined, orig);
  14300. }
  14301. return true;
  14302. }
  14303. return def.fixed instanceof AST_Defun;
  14304. }
  14305. function safe_to_assign(tw, def, scope, value) {
  14306. if (def.fixed === undefined) return true;
  14307. let def_safe_ids;
  14308. if (def.fixed === null
  14309. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  14310. ) {
  14311. def_safe_ids[def.id] = false;
  14312. tw.defs_to_safe_ids.delete(def.id);
  14313. return true;
  14314. }
  14315. if (!HOP(tw.safe_ids, def.id)) return false;
  14316. if (!safe_to_read(tw, def)) return false;
  14317. if (def.fixed === false) return false;
  14318. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  14319. if (def.fixed instanceof AST_Defun) {
  14320. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  14321. }
  14322. return def.orig.every((sym) => {
  14323. return !(sym instanceof AST_SymbolConst
  14324. || sym instanceof AST_SymbolDefun
  14325. || sym instanceof AST_SymbolLambda);
  14326. });
  14327. }
  14328. function ref_once(tw, compressor, def) {
  14329. return compressor.option("unused")
  14330. && !def.scope.pinned()
  14331. && def.references.length - def.recursive_refs == 1
  14332. && tw.loop_ids.get(def.id) === tw.in_loop;
  14333. }
  14334. function is_immutable(value) {
  14335. if (!value) return false;
  14336. return value.is_constant()
  14337. || value instanceof AST_Lambda
  14338. || value instanceof AST_This;
  14339. }
  14340. // A definition "escapes" when its value can leave the point of use.
  14341. // Example: `a = b || c`
  14342. // In this example, "b" and "c" are escaping, because they're going into "a"
  14343. //
  14344. // def.escaped is != 0 when it escapes.
  14345. //
  14346. // When greater than 1, it means that N chained properties will be read off
  14347. // of that def before an escape occurs. This is useful for evaluating
  14348. // property accesses, where you need to know when to stop.
  14349. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  14350. var parent = tw.parent(level);
  14351. if (value) {
  14352. if (value.is_constant()) return;
  14353. if (value instanceof AST_ClassExpression) return;
  14354. }
  14355. if (
  14356. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  14357. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  14358. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  14359. || parent instanceof AST_VarDef && node === parent.value
  14360. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  14361. ) {
  14362. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  14363. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  14364. return;
  14365. } else if (
  14366. parent instanceof AST_Array
  14367. || parent instanceof AST_Await
  14368. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  14369. || parent instanceof AST_Conditional && node !== parent.condition
  14370. || parent instanceof AST_Expansion
  14371. || parent instanceof AST_Sequence && node === parent.tail_node()
  14372. ) {
  14373. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  14374. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  14375. var obj = tw.parent(level + 1);
  14376. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  14377. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  14378. value = read_property(value, parent.property);
  14379. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  14380. if (value) return;
  14381. }
  14382. if (level > 0) return;
  14383. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  14384. if (parent instanceof AST_SimpleStatement) return;
  14385. d.direct_access = true;
  14386. }
  14387. const suppress = node => walk(node, node => {
  14388. if (!(node instanceof AST_Symbol)) return;
  14389. var d = node.definition();
  14390. if (!d) return;
  14391. if (node instanceof AST_SymbolRef) d.references.push(node);
  14392. d.fixed = false;
  14393. });
  14394. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  14395. push(tw);
  14396. reset_variables(tw, compressor, this);
  14397. descend();
  14398. pop(tw);
  14399. return true;
  14400. });
  14401. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  14402. var node = this;
  14403. if (node.left instanceof AST_Destructuring) {
  14404. suppress(node.left);
  14405. return;
  14406. }
  14407. const finish_walk = () => {
  14408. if (node.logical) {
  14409. node.left.walk(tw);
  14410. push(tw);
  14411. node.right.walk(tw);
  14412. pop(tw);
  14413. return true;
  14414. }
  14415. };
  14416. var sym = node.left;
  14417. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  14418. var def = sym.definition();
  14419. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  14420. def.assignments++;
  14421. if (!safe) return finish_walk();
  14422. var fixed = def.fixed;
  14423. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  14424. var eq = node.operator == "=";
  14425. var value = eq ? node.right : node;
  14426. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  14427. def.references.push(sym);
  14428. if (!node.logical) {
  14429. if (!eq) def.chained = true;
  14430. def.fixed = eq ? function() {
  14431. return node.right;
  14432. } : function() {
  14433. return make_node(AST_Binary, node, {
  14434. operator: node.operator.slice(0, -1),
  14435. left: fixed instanceof AST_Node ? fixed : fixed(),
  14436. right: node.right
  14437. });
  14438. };
  14439. }
  14440. if (node.logical) {
  14441. mark(tw, def, false);
  14442. push(tw);
  14443. node.right.walk(tw);
  14444. pop(tw);
  14445. return true;
  14446. }
  14447. mark(tw, def, false);
  14448. node.right.walk(tw);
  14449. mark(tw, def, true);
  14450. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  14451. return true;
  14452. });
  14453. def_reduce_vars(AST_Binary, function(tw) {
  14454. if (!lazy_op.has(this.operator)) return;
  14455. this.left.walk(tw);
  14456. push(tw);
  14457. this.right.walk(tw);
  14458. pop(tw);
  14459. return true;
  14460. });
  14461. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  14462. reset_block_variables(compressor, this);
  14463. });
  14464. def_reduce_vars(AST_Case, function(tw) {
  14465. push(tw);
  14466. this.expression.walk(tw);
  14467. pop(tw);
  14468. push(tw);
  14469. walk_body(this, tw);
  14470. pop(tw);
  14471. return true;
  14472. });
  14473. def_reduce_vars(AST_Class, function(tw, descend) {
  14474. clear_flag(this, INLINED);
  14475. push(tw);
  14476. descend();
  14477. pop(tw);
  14478. return true;
  14479. });
  14480. def_reduce_vars(AST_ClassStaticBlock, function(tw, descend, compressor) {
  14481. reset_block_variables(compressor, this);
  14482. });
  14483. def_reduce_vars(AST_Conditional, function(tw) {
  14484. this.condition.walk(tw);
  14485. push(tw);
  14486. this.consequent.walk(tw);
  14487. pop(tw);
  14488. push(tw);
  14489. this.alternative.walk(tw);
  14490. pop(tw);
  14491. return true;
  14492. });
  14493. def_reduce_vars(AST_Chain, function(tw, descend) {
  14494. // Chains' conditions apply left-to-right, cumulatively.
  14495. // If we walk normally we don't go in that order because we would pop before pushing again
  14496. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  14497. // Then we pop everything when they are done being walked.
  14498. const safe_ids = tw.safe_ids;
  14499. descend();
  14500. // Unroll back to start
  14501. tw.safe_ids = safe_ids;
  14502. return true;
  14503. });
  14504. def_reduce_vars(AST_Call, function (tw) {
  14505. this.expression.walk(tw);
  14506. if (this.optional) {
  14507. // Never pop -- it's popped at AST_Chain above
  14508. push(tw);
  14509. }
  14510. for (const arg of this.args) arg.walk(tw);
  14511. return true;
  14512. });
  14513. def_reduce_vars(AST_PropAccess, function (tw) {
  14514. if (!this.optional) return;
  14515. this.expression.walk(tw);
  14516. // Never pop -- it's popped at AST_Chain above
  14517. push(tw);
  14518. if (this.property instanceof AST_Node) this.property.walk(tw);
  14519. return true;
  14520. });
  14521. def_reduce_vars(AST_Default, function(tw, descend) {
  14522. push(tw);
  14523. descend();
  14524. pop(tw);
  14525. return true;
  14526. });
  14527. function mark_lambda(tw, descend, compressor) {
  14528. clear_flag(this, INLINED);
  14529. push(tw);
  14530. reset_variables(tw, compressor, this);
  14531. var iife;
  14532. if (!this.name
  14533. && !this.uses_arguments
  14534. && !this.pinned()
  14535. && (iife = tw.parent()) instanceof AST_Call
  14536. && iife.expression === this
  14537. && !iife.args.some(arg => arg instanceof AST_Expansion)
  14538. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  14539. ) {
  14540. // Virtually turn IIFE parameters into variable definitions:
  14541. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  14542. // So existing transformation rules can work on them.
  14543. this.argnames.forEach((arg, i) => {
  14544. if (!arg.definition) return;
  14545. var d = arg.definition();
  14546. // Avoid setting fixed when there's more than one origin for a variable value
  14547. if (d.orig.length > 1) return;
  14548. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  14549. d.fixed = function() {
  14550. return iife.args[i] || make_node(AST_Undefined, iife);
  14551. };
  14552. tw.loop_ids.set(d.id, tw.in_loop);
  14553. mark(tw, d, true);
  14554. } else {
  14555. d.fixed = false;
  14556. }
  14557. });
  14558. }
  14559. descend();
  14560. pop(tw);
  14561. handle_defined_after_hoist(this);
  14562. return true;
  14563. }
  14564. /**
  14565. * It's possible for a hoisted function to use something that's not defined yet. Example:
  14566. *
  14567. * hoisted();
  14568. * var defined_after = true;
  14569. * function hoisted() {
  14570. * // use defined_after
  14571. * }
  14572. *
  14573. * Or even indirectly:
  14574. *
  14575. * B();
  14576. * var defined_after = true;
  14577. * function A() {
  14578. * // use defined_after
  14579. * }
  14580. * function B() {
  14581. * A();
  14582. * }
  14583. *
  14584. * Access a variable before declaration will either throw a ReferenceError
  14585. * (if the variable is declared with `let` or `const`),
  14586. * or get an `undefined` (if the variable is declared with `var`).
  14587. *
  14588. * If the variable is inlined into the function, the behavior will change.
  14589. *
  14590. * This function is called on the parent to disallow inlining of such variables,
  14591. */
  14592. function handle_defined_after_hoist(parent) {
  14593. const defuns = [];
  14594. walk(parent, node => {
  14595. if (node === parent) return;
  14596. if (node instanceof AST_Defun) {
  14597. defuns.push(node);
  14598. return true;
  14599. }
  14600. if (
  14601. node instanceof AST_Scope
  14602. || node instanceof AST_SimpleStatement
  14603. ) return true;
  14604. });
  14605. // `defun` id to array of `defun` it uses
  14606. const defun_dependencies_map = new Map();
  14607. // `defun` id to array of enclosing `def` that are used by the function
  14608. const dependencies_map = new Map();
  14609. // all symbol ids that will be tracked for read/write
  14610. const symbols_of_interest = new Set();
  14611. const defuns_of_interest = new Set();
  14612. for (const defun of defuns) {
  14613. const fname_def = defun.name.definition();
  14614. const enclosing_defs = [];
  14615. for (const def of defun.enclosed) {
  14616. if (
  14617. def.fixed === false
  14618. || def === fname_def
  14619. || def.scope.get_defun_scope() !== parent
  14620. ) {
  14621. continue;
  14622. }
  14623. symbols_of_interest.add(def.id);
  14624. // found a reference to another function
  14625. if (
  14626. def.assignments === 0
  14627. && def.orig.length === 1
  14628. && def.orig[0] instanceof AST_SymbolDefun
  14629. ) {
  14630. defuns_of_interest.add(def.id);
  14631. symbols_of_interest.add(def.id);
  14632. defuns_of_interest.add(fname_def.id);
  14633. symbols_of_interest.add(fname_def.id);
  14634. if (!defun_dependencies_map.has(fname_def.id)) {
  14635. defun_dependencies_map.set(fname_def.id, []);
  14636. }
  14637. defun_dependencies_map.get(fname_def.id).push(def.id);
  14638. continue;
  14639. }
  14640. enclosing_defs.push(def);
  14641. }
  14642. if (enclosing_defs.length) {
  14643. dependencies_map.set(fname_def.id, enclosing_defs);
  14644. defuns_of_interest.add(fname_def.id);
  14645. symbols_of_interest.add(fname_def.id);
  14646. }
  14647. }
  14648. // No defuns use outside constants
  14649. if (!dependencies_map.size) {
  14650. return;
  14651. }
  14652. // Increment to count "symbols of interest" (defuns or defs) that we found.
  14653. // These are tracked in AST order so we can check which is after which.
  14654. let symbol_index = 1;
  14655. // Map a defun ID to its first read (a `symbol_index`)
  14656. const defun_first_read_map = new Map();
  14657. // Map a symbol ID to its last write (a `symbol_index`)
  14658. const symbol_last_write_map = new Map();
  14659. walk_parent(parent, (node, walk_info) => {
  14660. if (node instanceof AST_Symbol && node.thedef) {
  14661. const id = node.definition().id;
  14662. symbol_index++;
  14663. // Track last-writes to symbols
  14664. if (symbols_of_interest.has(id)) {
  14665. if (node instanceof AST_SymbolDeclaration || is_lhs(node, walk_info.parent())) {
  14666. symbol_last_write_map.set(id, symbol_index);
  14667. }
  14668. }
  14669. // Track first-reads of defuns (refined later)
  14670. if (defuns_of_interest.has(id)) {
  14671. if (!defun_first_read_map.has(id) && !is_recursive_ref(walk_info, id)) {
  14672. defun_first_read_map.set(id, symbol_index);
  14673. }
  14674. }
  14675. }
  14676. });
  14677. // Refine `defun_first_read_map` to be as high as possible
  14678. for (const [defun, defun_first_read] of defun_first_read_map) {
  14679. // Update all depdencies of `defun`
  14680. const queue = new Set(defun_dependencies_map.get(defun));
  14681. for (const enclosed_defun of queue) {
  14682. let enclosed_defun_first_read = defun_first_read_map.get(enclosed_defun);
  14683. if (enclosed_defun_first_read != null && enclosed_defun_first_read < defun_first_read) {
  14684. continue;
  14685. }
  14686. defun_first_read_map.set(enclosed_defun, defun_first_read);
  14687. for (const enclosed_enclosed_defun of defun_dependencies_map.get(enclosed_defun) || []) {
  14688. queue.add(enclosed_enclosed_defun);
  14689. }
  14690. }
  14691. }
  14692. // ensure write-then-read order, otherwise clear `fixed`
  14693. // 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.
  14694. for (const [defun, defs] of dependencies_map) {
  14695. const defun_first_read = defun_first_read_map.get(defun);
  14696. if (defun_first_read === undefined) {
  14697. continue;
  14698. }
  14699. for (const def of defs) {
  14700. if (def.fixed === false) {
  14701. continue;
  14702. }
  14703. let def_last_write = symbol_last_write_map.get(def.id) || 0;
  14704. if (defun_first_read < def_last_write) {
  14705. def.fixed = false;
  14706. }
  14707. }
  14708. }
  14709. }
  14710. def_reduce_vars(AST_Lambda, mark_lambda);
  14711. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  14712. reset_block_variables(compressor, this);
  14713. const saved_loop = tw.in_loop;
  14714. tw.in_loop = this;
  14715. push(tw);
  14716. this.body.walk(tw);
  14717. if (has_break_or_continue(this)) {
  14718. pop(tw);
  14719. push(tw);
  14720. }
  14721. this.condition.walk(tw);
  14722. pop(tw);
  14723. tw.in_loop = saved_loop;
  14724. return true;
  14725. });
  14726. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  14727. reset_block_variables(compressor, this);
  14728. if (this.init) this.init.walk(tw);
  14729. const saved_loop = tw.in_loop;
  14730. tw.in_loop = this;
  14731. push(tw);
  14732. if (this.condition) this.condition.walk(tw);
  14733. this.body.walk(tw);
  14734. if (this.step) {
  14735. if (has_break_or_continue(this)) {
  14736. pop(tw);
  14737. push(tw);
  14738. }
  14739. this.step.walk(tw);
  14740. }
  14741. pop(tw);
  14742. tw.in_loop = saved_loop;
  14743. return true;
  14744. });
  14745. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  14746. reset_block_variables(compressor, this);
  14747. suppress(this.init);
  14748. this.object.walk(tw);
  14749. const saved_loop = tw.in_loop;
  14750. tw.in_loop = this;
  14751. push(tw);
  14752. this.body.walk(tw);
  14753. pop(tw);
  14754. tw.in_loop = saved_loop;
  14755. return true;
  14756. });
  14757. def_reduce_vars(AST_If, function(tw) {
  14758. this.condition.walk(tw);
  14759. push(tw);
  14760. this.body.walk(tw);
  14761. pop(tw);
  14762. if (this.alternative) {
  14763. push(tw);
  14764. this.alternative.walk(tw);
  14765. pop(tw);
  14766. }
  14767. return true;
  14768. });
  14769. def_reduce_vars(AST_LabeledStatement, function(tw) {
  14770. push(tw);
  14771. this.body.walk(tw);
  14772. pop(tw);
  14773. return true;
  14774. });
  14775. def_reduce_vars(AST_SymbolCatch, function() {
  14776. this.definition().fixed = false;
  14777. });
  14778. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  14779. var d = this.definition();
  14780. d.references.push(this);
  14781. if (d.references.length == 1
  14782. && !d.fixed
  14783. && d.orig[0] instanceof AST_SymbolDefun) {
  14784. tw.loop_ids.set(d.id, tw.in_loop);
  14785. }
  14786. var fixed_value;
  14787. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  14788. d.fixed = false;
  14789. } else if (d.fixed) {
  14790. fixed_value = this.fixed_value();
  14791. if (
  14792. fixed_value instanceof AST_Lambda
  14793. && is_recursive_ref(tw, d)
  14794. ) {
  14795. d.recursive_refs++;
  14796. } else if (fixed_value
  14797. && !compressor.exposed(d)
  14798. && ref_once(tw, compressor, d)
  14799. ) {
  14800. d.single_use =
  14801. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  14802. || fixed_value instanceof AST_Class
  14803. || d.scope === this.scope && fixed_value.is_constant_expression();
  14804. } else {
  14805. d.single_use = false;
  14806. }
  14807. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  14808. if (d.single_use) {
  14809. d.single_use = "m";
  14810. } else {
  14811. d.fixed = false;
  14812. }
  14813. }
  14814. }
  14815. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  14816. });
  14817. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  14818. this.globals.forEach(function(def) {
  14819. reset_def(compressor, def);
  14820. });
  14821. reset_variables(tw, compressor, this);
  14822. descend();
  14823. handle_defined_after_hoist(this);
  14824. return true;
  14825. });
  14826. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  14827. reset_block_variables(compressor, this);
  14828. push(tw);
  14829. this.body.walk(tw);
  14830. pop(tw);
  14831. if (this.bcatch) {
  14832. push(tw);
  14833. this.bcatch.walk(tw);
  14834. pop(tw);
  14835. }
  14836. if (this.bfinally) this.bfinally.walk(tw);
  14837. return true;
  14838. });
  14839. def_reduce_vars(AST_Unary, function(tw) {
  14840. var node = this;
  14841. if (node.operator !== "++" && node.operator !== "--") return;
  14842. var exp = node.expression;
  14843. if (!(exp instanceof AST_SymbolRef)) return;
  14844. var def = exp.definition();
  14845. var safe = safe_to_assign(tw, def, exp.scope, true);
  14846. def.assignments++;
  14847. if (!safe) return;
  14848. var fixed = def.fixed;
  14849. if (!fixed) return;
  14850. def.references.push(exp);
  14851. def.chained = true;
  14852. def.fixed = function() {
  14853. return make_node(AST_Binary, node, {
  14854. operator: node.operator.slice(0, -1),
  14855. left: make_node(AST_UnaryPrefix, node, {
  14856. operator: "+",
  14857. expression: fixed instanceof AST_Node ? fixed : fixed()
  14858. }),
  14859. right: make_node(AST_Number, node, {
  14860. value: 1
  14861. })
  14862. });
  14863. };
  14864. mark(tw, def, true);
  14865. return true;
  14866. });
  14867. def_reduce_vars(AST_VarDef, function(tw, descend) {
  14868. var node = this;
  14869. if (node.name instanceof AST_Destructuring) {
  14870. suppress(node.name);
  14871. return;
  14872. }
  14873. var d = node.name.definition();
  14874. if (node.value) {
  14875. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  14876. d.fixed = function() {
  14877. return node.value;
  14878. };
  14879. tw.loop_ids.set(d.id, tw.in_loop);
  14880. mark(tw, d, false);
  14881. descend();
  14882. mark(tw, d, true);
  14883. return true;
  14884. } else {
  14885. d.fixed = false;
  14886. }
  14887. }
  14888. });
  14889. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  14890. reset_block_variables(compressor, this);
  14891. const saved_loop = tw.in_loop;
  14892. tw.in_loop = this;
  14893. push(tw);
  14894. descend();
  14895. pop(tw);
  14896. tw.in_loop = saved_loop;
  14897. return true;
  14898. });
  14899. /***********************************************************************
  14900. A JavaScript tokenizer / parser / beautifier / compressor.
  14901. https://github.com/mishoo/UglifyJS2
  14902. -------------------------------- (C) ---------------------------------
  14903. Author: Mihai Bazon
  14904. <mihai.bazon@gmail.com>
  14905. http://mihai.bazon.net/blog
  14906. Distributed under the BSD license:
  14907. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14908. Redistribution and use in source and binary forms, with or without
  14909. modification, are permitted provided that the following conditions
  14910. are met:
  14911. * Redistributions of source code must retain the above
  14912. copyright notice, this list of conditions and the following
  14913. disclaimer.
  14914. * Redistributions in binary form must reproduce the above
  14915. copyright notice, this list of conditions and the following
  14916. disclaimer in the documentation and/or other materials
  14917. provided with the distribution.
  14918. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14919. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14920. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14921. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14922. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14923. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14924. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14925. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14926. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14927. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14928. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14929. SUCH DAMAGE.
  14930. ***********************************************************************/
  14931. function loop_body(x) {
  14932. if (x instanceof AST_IterationStatement) {
  14933. return x.body instanceof AST_BlockStatement ? x.body : x;
  14934. }
  14935. return x;
  14936. }
  14937. function is_lhs_read_only(lhs) {
  14938. if (lhs instanceof AST_This) return true;
  14939. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  14940. if (lhs instanceof AST_PropAccess) {
  14941. lhs = lhs.expression;
  14942. if (lhs instanceof AST_SymbolRef) {
  14943. if (lhs.is_immutable()) return false;
  14944. lhs = lhs.fixed_value();
  14945. }
  14946. if (!lhs) return true;
  14947. if (lhs instanceof AST_RegExp) return false;
  14948. if (lhs instanceof AST_Constant) return true;
  14949. return is_lhs_read_only(lhs);
  14950. }
  14951. return false;
  14952. }
  14953. /** var a = 1 --> var a*/
  14954. function remove_initializers(var_statement) {
  14955. var decls = [];
  14956. var_statement.definitions.forEach(function(def) {
  14957. if (def.name instanceof AST_SymbolDeclaration) {
  14958. def.value = null;
  14959. decls.push(def);
  14960. } else {
  14961. def.declarations_as_names().forEach(name => {
  14962. decls.push(make_node(AST_VarDef, def, {
  14963. name,
  14964. value: null
  14965. }));
  14966. });
  14967. }
  14968. });
  14969. return decls.length ? make_node(AST_Var, var_statement, { definitions: decls }) : null;
  14970. }
  14971. /** Called on code which we know is unreachable, to keep elements that affect outside of it. */
  14972. function trim_unreachable_code(compressor, stat, target) {
  14973. walk(stat, node => {
  14974. if (node instanceof AST_Var) {
  14975. const no_initializers = remove_initializers(node);
  14976. if (no_initializers) target.push(no_initializers);
  14977. return true;
  14978. }
  14979. if (
  14980. node instanceof AST_Defun
  14981. && (node === stat || !compressor.has_directive("use strict"))
  14982. ) {
  14983. target.push(node === stat ? node : make_node(AST_Var, node, {
  14984. definitions: [
  14985. make_node(AST_VarDef, node, {
  14986. name: make_node(AST_SymbolVar, node.name, node.name),
  14987. value: null
  14988. })
  14989. ]
  14990. }));
  14991. return true;
  14992. }
  14993. if (node instanceof AST_Export || node instanceof AST_Import) {
  14994. target.push(node);
  14995. return true;
  14996. }
  14997. if (node instanceof AST_Scope) {
  14998. return true;
  14999. }
  15000. });
  15001. }
  15002. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  15003. function tighten_body(statements, compressor) {
  15004. const nearest_scope = compressor.find_scope();
  15005. const defun_scope = nearest_scope.get_defun_scope();
  15006. const { in_loop, in_try } = find_loop_scope_try();
  15007. var CHANGED, max_iter = 10;
  15008. do {
  15009. CHANGED = false;
  15010. eliminate_spurious_blocks(statements);
  15011. if (compressor.option("dead_code")) {
  15012. eliminate_dead_code(statements, compressor);
  15013. }
  15014. if (compressor.option("if_return")) {
  15015. handle_if_return(statements, compressor);
  15016. }
  15017. if (compressor.sequences_limit > 0) {
  15018. sequencesize(statements, compressor);
  15019. sequencesize_2(statements, compressor);
  15020. }
  15021. if (compressor.option("join_vars")) {
  15022. join_consecutive_vars(statements);
  15023. }
  15024. if (compressor.option("collapse_vars")) {
  15025. collapse(statements, compressor);
  15026. }
  15027. } while (CHANGED && max_iter-- > 0);
  15028. function find_loop_scope_try() {
  15029. var node = compressor.self(), level = 0, in_loop = false, in_try = false;
  15030. do {
  15031. if (node instanceof AST_IterationStatement) {
  15032. in_loop = true;
  15033. } else if (node instanceof AST_Scope) {
  15034. break;
  15035. } else if (node instanceof AST_TryBlock) {
  15036. in_try = true;
  15037. }
  15038. } while (node = compressor.parent(level++));
  15039. return { in_loop, in_try };
  15040. }
  15041. // Search from right to left for assignment-like expressions:
  15042. // - `var a = x;`
  15043. // - `a = x;`
  15044. // - `++a`
  15045. // For each candidate, scan from left to right for first usage, then try
  15046. // to fold assignment into the site for compression.
  15047. // Will not attempt to collapse assignments into or past code blocks
  15048. // which are not sequentially executed, e.g. loops and conditionals.
  15049. function collapse(statements, compressor) {
  15050. if (nearest_scope.pinned() || defun_scope.pinned())
  15051. return statements;
  15052. var args;
  15053. var candidates = [];
  15054. var stat_index = statements.length;
  15055. var scanner = new TreeTransformer(function (node) {
  15056. if (abort)
  15057. return node;
  15058. // Skip nodes before `candidate` as quickly as possible
  15059. if (!hit) {
  15060. if (node !== hit_stack[hit_index])
  15061. return node;
  15062. hit_index++;
  15063. if (hit_index < hit_stack.length)
  15064. return handle_custom_scan_order(node);
  15065. hit = true;
  15066. stop_after = find_stop(node, 0);
  15067. if (stop_after === node)
  15068. abort = true;
  15069. return node;
  15070. }
  15071. // Stop immediately if these node types are encountered
  15072. var parent = scanner.parent();
  15073. if (node instanceof AST_Assign
  15074. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  15075. || node instanceof AST_Await
  15076. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  15077. ||
  15078. (node instanceof AST_Call || node instanceof AST_PropAccess)
  15079. && node.optional
  15080. || node instanceof AST_Debugger
  15081. || node instanceof AST_Destructuring
  15082. || node instanceof AST_Expansion
  15083. && node.expression instanceof AST_Symbol
  15084. && (
  15085. node.expression instanceof AST_This
  15086. || node.expression.definition().references.length > 1
  15087. )
  15088. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  15089. || node instanceof AST_LoopControl
  15090. || node instanceof AST_Try
  15091. || node instanceof AST_With
  15092. || node instanceof AST_Yield
  15093. || node instanceof AST_Export
  15094. || node instanceof AST_Class
  15095. || parent instanceof AST_For && node !== parent.init
  15096. || !replace_all
  15097. && (
  15098. node instanceof AST_SymbolRef
  15099. && !node.is_declared(compressor)
  15100. && !pure_prop_access_globals.has(node)
  15101. )
  15102. || node instanceof AST_SymbolRef
  15103. && parent instanceof AST_Call
  15104. && has_annotation(parent, _NOINLINE)
  15105. || node instanceof AST_ObjectProperty && node.key instanceof AST_Node
  15106. ) {
  15107. abort = true;
  15108. return node;
  15109. }
  15110. // Stop only if candidate is found within conditional branches
  15111. if (!stop_if_hit && (!lhs_local || !replace_all)
  15112. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  15113. || parent instanceof AST_Conditional && parent.condition !== node
  15114. || parent instanceof AST_If && parent.condition !== node)) {
  15115. stop_if_hit = parent;
  15116. }
  15117. // Replace variable with assignment when found
  15118. if (
  15119. can_replace
  15120. && !(node instanceof AST_SymbolDeclaration)
  15121. && lhs.equivalent_to(node)
  15122. && !shadows(scanner.find_scope() || nearest_scope, lvalues)
  15123. ) {
  15124. if (stop_if_hit) {
  15125. abort = true;
  15126. return node;
  15127. }
  15128. if (is_lhs(node, parent)) {
  15129. if (value_def)
  15130. replaced++;
  15131. return node;
  15132. } else {
  15133. replaced++;
  15134. if (value_def && candidate instanceof AST_VarDef)
  15135. return node;
  15136. }
  15137. CHANGED = abort = true;
  15138. if (candidate instanceof AST_UnaryPostfix) {
  15139. return make_node(AST_UnaryPrefix, candidate, candidate);
  15140. }
  15141. if (candidate instanceof AST_VarDef) {
  15142. var def = candidate.name.definition();
  15143. var value = candidate.value;
  15144. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  15145. def.replaced++;
  15146. if (funarg && is_identifier_atom(value)) {
  15147. return value.transform(compressor);
  15148. } else {
  15149. return maintain_this_binding(parent, node, value);
  15150. }
  15151. }
  15152. return make_node(AST_Assign, candidate, {
  15153. operator: "=",
  15154. logical: false,
  15155. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  15156. right: value
  15157. });
  15158. }
  15159. clear_flag(candidate, WRITE_ONLY);
  15160. return candidate;
  15161. }
  15162. // These node types have child nodes that execute sequentially,
  15163. // but are otherwise not safe to scan into or beyond them.
  15164. var sym;
  15165. if (node instanceof AST_Call
  15166. || node instanceof AST_Exit
  15167. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  15168. || node instanceof AST_PropAccess
  15169. && (side_effects || node.expression.may_throw_on_access(compressor))
  15170. || node instanceof AST_SymbolRef
  15171. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  15172. || node instanceof AST_VarDef && node.value
  15173. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  15174. || (sym = is_lhs(node.left, node))
  15175. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  15176. || may_throw
  15177. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  15178. stop_after = node;
  15179. if (node instanceof AST_Scope)
  15180. abort = true;
  15181. }
  15182. return handle_custom_scan_order(node);
  15183. }, function (node) {
  15184. if (abort)
  15185. return;
  15186. if (stop_after === node)
  15187. abort = true;
  15188. if (stop_if_hit === node)
  15189. stop_if_hit = null;
  15190. });
  15191. var multi_replacer = new TreeTransformer(function (node) {
  15192. if (abort)
  15193. return node;
  15194. // Skip nodes before `candidate` as quickly as possible
  15195. if (!hit) {
  15196. if (node !== hit_stack[hit_index])
  15197. return node;
  15198. hit_index++;
  15199. if (hit_index < hit_stack.length)
  15200. return;
  15201. hit = true;
  15202. return node;
  15203. }
  15204. // Replace variable when found
  15205. if (node instanceof AST_SymbolRef
  15206. && node.name == def.name) {
  15207. if (!--replaced)
  15208. abort = true;
  15209. if (is_lhs(node, multi_replacer.parent()))
  15210. return node;
  15211. def.replaced++;
  15212. value_def.replaced--;
  15213. return candidate.value;
  15214. }
  15215. // Skip (non-executed) functions and (leading) default case in switch statements
  15216. if (node instanceof AST_Default || node instanceof AST_Scope)
  15217. return node;
  15218. });
  15219. while (--stat_index >= 0) {
  15220. // Treat parameters as collapsible in IIFE, i.e.
  15221. // function(a, b){ ... }(x());
  15222. // would be translated into equivalent assignments:
  15223. // var a = x(), b = undefined;
  15224. if (stat_index == 0 && compressor.option("unused"))
  15225. extract_args();
  15226. // Find collapsible assignments
  15227. var hit_stack = [];
  15228. extract_candidates(statements[stat_index]);
  15229. while (candidates.length > 0) {
  15230. hit_stack = candidates.pop();
  15231. var hit_index = 0;
  15232. var candidate = hit_stack[hit_stack.length - 1];
  15233. var value_def = null;
  15234. var stop_after = null;
  15235. var stop_if_hit = null;
  15236. var lhs = get_lhs(candidate);
  15237. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  15238. continue;
  15239. // Locate symbols which may execute code outside of scanning range
  15240. var lvalues = get_lvalues(candidate);
  15241. var lhs_local = is_lhs_local(lhs);
  15242. if (lhs instanceof AST_SymbolRef) {
  15243. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  15244. }
  15245. var side_effects = value_has_side_effects(candidate);
  15246. var replace_all = replace_all_symbols();
  15247. var may_throw = candidate.may_throw(compressor);
  15248. var funarg = candidate.name instanceof AST_SymbolFunarg;
  15249. var hit = funarg;
  15250. var abort = false, replaced = 0, can_replace = !args || !hit;
  15251. if (!can_replace) {
  15252. for (
  15253. let j = compressor.self().argnames.lastIndexOf(candidate.name) + 1;
  15254. !abort && j < args.length;
  15255. j++
  15256. ) {
  15257. args[j].transform(scanner);
  15258. }
  15259. can_replace = true;
  15260. }
  15261. for (var i = stat_index; !abort && i < statements.length; i++) {
  15262. statements[i].transform(scanner);
  15263. }
  15264. if (value_def) {
  15265. var def = candidate.name.definition();
  15266. if (abort && def.references.length - def.replaced > replaced)
  15267. replaced = false;
  15268. else {
  15269. abort = false;
  15270. hit_index = 0;
  15271. hit = funarg;
  15272. for (var i = stat_index; !abort && i < statements.length; i++) {
  15273. statements[i].transform(multi_replacer);
  15274. }
  15275. value_def.single_use = false;
  15276. }
  15277. }
  15278. if (replaced && !remove_candidate(candidate))
  15279. statements.splice(stat_index, 1);
  15280. }
  15281. }
  15282. function handle_custom_scan_order(node) {
  15283. // Skip (non-executed) functions
  15284. if (node instanceof AST_Scope)
  15285. return node;
  15286. // Scan case expressions first in a switch statement
  15287. if (node instanceof AST_Switch) {
  15288. node.expression = node.expression.transform(scanner);
  15289. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  15290. var branch = node.body[i];
  15291. if (branch instanceof AST_Case) {
  15292. if (!hit) {
  15293. if (branch !== hit_stack[hit_index])
  15294. continue;
  15295. hit_index++;
  15296. }
  15297. branch.expression = branch.expression.transform(scanner);
  15298. if (!replace_all)
  15299. break;
  15300. }
  15301. }
  15302. abort = true;
  15303. return node;
  15304. }
  15305. }
  15306. function redefined_within_scope(def, scope) {
  15307. if (def.global)
  15308. return false;
  15309. let cur_scope = def.scope;
  15310. while (cur_scope && cur_scope !== scope) {
  15311. if (cur_scope.variables.has(def.name)) {
  15312. return true;
  15313. }
  15314. cur_scope = cur_scope.parent_scope;
  15315. }
  15316. return false;
  15317. }
  15318. function has_overlapping_symbol(fn, arg, fn_strict) {
  15319. var found = false, scan_this = !(fn instanceof AST_Arrow);
  15320. arg.walk(new TreeWalker(function (node, descend) {
  15321. if (found)
  15322. return true;
  15323. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  15324. var s = node.definition().scope;
  15325. if (s !== defun_scope)
  15326. while (s = s.parent_scope) {
  15327. if (s === defun_scope)
  15328. return true;
  15329. }
  15330. return found = true;
  15331. }
  15332. if ((fn_strict || scan_this) && node instanceof AST_This) {
  15333. return found = true;
  15334. }
  15335. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  15336. var prev = scan_this;
  15337. scan_this = false;
  15338. descend();
  15339. scan_this = prev;
  15340. return true;
  15341. }
  15342. }));
  15343. return found;
  15344. }
  15345. function arg_is_injectable(arg) {
  15346. if (arg instanceof AST_Expansion) return false;
  15347. const contains_await = walk(arg, (node) => {
  15348. if (node instanceof AST_Await) return walk_abort;
  15349. });
  15350. if (contains_await) return false;
  15351. return true;
  15352. }
  15353. function extract_args() {
  15354. var iife, fn = compressor.self();
  15355. if (is_func_expr(fn)
  15356. && !fn.name
  15357. && !fn.uses_arguments
  15358. && !fn.pinned()
  15359. && (iife = compressor.parent()) instanceof AST_Call
  15360. && iife.expression === fn
  15361. && iife.args.every(arg_is_injectable)
  15362. ) {
  15363. var fn_strict = compressor.has_directive("use strict");
  15364. if (fn_strict && !member(fn_strict, fn.body))
  15365. fn_strict = false;
  15366. var len = fn.argnames.length;
  15367. args = iife.args.slice(len);
  15368. var names = new Set();
  15369. for (var i = len; --i >= 0;) {
  15370. var sym = fn.argnames[i];
  15371. var arg = iife.args[i];
  15372. // The following two line fix is a duplicate of the fix at
  15373. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  15374. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  15375. // Might be doing the exact same thing.
  15376. const def = sym.definition && sym.definition();
  15377. const is_reassigned = def && def.orig.length > 1;
  15378. if (is_reassigned)
  15379. continue;
  15380. args.unshift(make_node(AST_VarDef, sym, {
  15381. name: sym,
  15382. value: arg
  15383. }));
  15384. if (names.has(sym.name))
  15385. continue;
  15386. names.add(sym.name);
  15387. if (sym instanceof AST_Expansion) {
  15388. var elements = iife.args.slice(i);
  15389. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  15390. )) {
  15391. candidates.unshift([make_node(AST_VarDef, sym, {
  15392. name: sym.expression,
  15393. value: make_node(AST_Array, iife, {
  15394. elements: elements
  15395. })
  15396. })]);
  15397. }
  15398. } else {
  15399. if (!arg) {
  15400. arg = make_node(AST_Undefined, sym).transform(compressor);
  15401. } else if (arg instanceof AST_Lambda && arg.pinned()
  15402. || has_overlapping_symbol(fn, arg, fn_strict)) {
  15403. arg = null;
  15404. }
  15405. if (arg)
  15406. candidates.unshift([make_node(AST_VarDef, sym, {
  15407. name: sym,
  15408. value: arg
  15409. })]);
  15410. }
  15411. }
  15412. }
  15413. }
  15414. function extract_candidates(expr) {
  15415. hit_stack.push(expr);
  15416. if (expr instanceof AST_Assign) {
  15417. if (!expr.left.has_side_effects(compressor)
  15418. && !(expr.right instanceof AST_Chain)) {
  15419. candidates.push(hit_stack.slice());
  15420. }
  15421. extract_candidates(expr.right);
  15422. } else if (expr instanceof AST_Binary) {
  15423. extract_candidates(expr.left);
  15424. extract_candidates(expr.right);
  15425. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  15426. extract_candidates(expr.expression);
  15427. expr.args.forEach(extract_candidates);
  15428. } else if (expr instanceof AST_Case) {
  15429. extract_candidates(expr.expression);
  15430. } else if (expr instanceof AST_Conditional) {
  15431. extract_candidates(expr.condition);
  15432. extract_candidates(expr.consequent);
  15433. extract_candidates(expr.alternative);
  15434. } else if (expr instanceof AST_Definitions) {
  15435. var len = expr.definitions.length;
  15436. // limit number of trailing variable definitions for consideration
  15437. var i = len - 200;
  15438. if (i < 0)
  15439. i = 0;
  15440. for (; i < len; i++) {
  15441. extract_candidates(expr.definitions[i]);
  15442. }
  15443. } else if (expr instanceof AST_DWLoop) {
  15444. extract_candidates(expr.condition);
  15445. if (!(expr.body instanceof AST_Block)) {
  15446. extract_candidates(expr.body);
  15447. }
  15448. } else if (expr instanceof AST_Exit) {
  15449. if (expr.value)
  15450. extract_candidates(expr.value);
  15451. } else if (expr instanceof AST_For) {
  15452. if (expr.init)
  15453. extract_candidates(expr.init);
  15454. if (expr.condition)
  15455. extract_candidates(expr.condition);
  15456. if (expr.step)
  15457. extract_candidates(expr.step);
  15458. if (!(expr.body instanceof AST_Block)) {
  15459. extract_candidates(expr.body);
  15460. }
  15461. } else if (expr instanceof AST_ForIn) {
  15462. extract_candidates(expr.object);
  15463. if (!(expr.body instanceof AST_Block)) {
  15464. extract_candidates(expr.body);
  15465. }
  15466. } else if (expr instanceof AST_If) {
  15467. extract_candidates(expr.condition);
  15468. if (!(expr.body instanceof AST_Block)) {
  15469. extract_candidates(expr.body);
  15470. }
  15471. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  15472. extract_candidates(expr.alternative);
  15473. }
  15474. } else if (expr instanceof AST_Sequence) {
  15475. expr.expressions.forEach(extract_candidates);
  15476. } else if (expr instanceof AST_SimpleStatement) {
  15477. extract_candidates(expr.body);
  15478. } else if (expr instanceof AST_Switch) {
  15479. extract_candidates(expr.expression);
  15480. expr.body.forEach(extract_candidates);
  15481. } else if (expr instanceof AST_Unary) {
  15482. if (expr.operator == "++" || expr.operator == "--") {
  15483. candidates.push(hit_stack.slice());
  15484. }
  15485. } else if (expr instanceof AST_VarDef) {
  15486. if (expr.value && !(expr.value instanceof AST_Chain)) {
  15487. candidates.push(hit_stack.slice());
  15488. extract_candidates(expr.value);
  15489. }
  15490. }
  15491. hit_stack.pop();
  15492. }
  15493. function find_stop(node, level, write_only) {
  15494. var parent = scanner.parent(level);
  15495. if (parent instanceof AST_Assign) {
  15496. if (write_only
  15497. && !parent.logical
  15498. && !(parent.left instanceof AST_PropAccess
  15499. || lvalues.has(parent.left.name))) {
  15500. return find_stop(parent, level + 1, write_only);
  15501. }
  15502. return node;
  15503. }
  15504. if (parent instanceof AST_Binary) {
  15505. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  15506. return find_stop(parent, level + 1, write_only);
  15507. }
  15508. return node;
  15509. }
  15510. if (parent instanceof AST_Call)
  15511. return node;
  15512. if (parent instanceof AST_Case)
  15513. return node;
  15514. if (parent instanceof AST_Conditional) {
  15515. if (write_only && parent.condition === node) {
  15516. return find_stop(parent, level + 1, write_only);
  15517. }
  15518. return node;
  15519. }
  15520. if (parent instanceof AST_Definitions) {
  15521. return find_stop(parent, level + 1, true);
  15522. }
  15523. if (parent instanceof AST_Exit) {
  15524. return write_only ? find_stop(parent, level + 1, write_only) : node;
  15525. }
  15526. if (parent instanceof AST_If) {
  15527. if (write_only && parent.condition === node) {
  15528. return find_stop(parent, level + 1, write_only);
  15529. }
  15530. return node;
  15531. }
  15532. if (parent instanceof AST_IterationStatement)
  15533. return node;
  15534. if (parent instanceof AST_Sequence) {
  15535. return find_stop(parent, level + 1, parent.tail_node() !== node);
  15536. }
  15537. if (parent instanceof AST_SimpleStatement) {
  15538. return find_stop(parent, level + 1, true);
  15539. }
  15540. if (parent instanceof AST_Switch)
  15541. return node;
  15542. if (parent instanceof AST_VarDef)
  15543. return node;
  15544. return null;
  15545. }
  15546. function mangleable_var(var_def) {
  15547. var value = var_def.value;
  15548. if (!(value instanceof AST_SymbolRef))
  15549. return;
  15550. if (value.name == "arguments")
  15551. return;
  15552. var def = value.definition();
  15553. if (def.undeclared)
  15554. return;
  15555. return value_def = def;
  15556. }
  15557. function get_lhs(expr) {
  15558. if (expr instanceof AST_Assign && expr.logical) {
  15559. return false;
  15560. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  15561. var def = expr.name.definition();
  15562. if (!member(expr.name, def.orig))
  15563. return;
  15564. var referenced = def.references.length - def.replaced;
  15565. if (!referenced)
  15566. return;
  15567. var declared = def.orig.length - def.eliminated;
  15568. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  15569. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  15570. return make_node(AST_SymbolRef, expr.name, expr.name);
  15571. }
  15572. } else {
  15573. const lhs = expr instanceof AST_Assign
  15574. ? expr.left
  15575. : expr.expression;
  15576. return !is_ref_of(lhs, AST_SymbolConst)
  15577. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  15578. }
  15579. }
  15580. function get_rvalue(expr) {
  15581. if (expr instanceof AST_Assign) {
  15582. return expr.right;
  15583. } else {
  15584. return expr.value;
  15585. }
  15586. }
  15587. function get_lvalues(expr) {
  15588. var lvalues = new Map();
  15589. if (expr instanceof AST_Unary)
  15590. return lvalues;
  15591. var tw = new TreeWalker(function (node) {
  15592. var sym = node;
  15593. while (sym instanceof AST_PropAccess)
  15594. sym = sym.expression;
  15595. if (sym instanceof AST_SymbolRef) {
  15596. const prev = lvalues.get(sym.name);
  15597. if (!prev || !prev.modified) {
  15598. lvalues.set(sym.name, {
  15599. def: sym.definition(),
  15600. modified: is_modified(compressor, tw, node, node, 0)
  15601. });
  15602. }
  15603. }
  15604. });
  15605. get_rvalue(expr).walk(tw);
  15606. return lvalues;
  15607. }
  15608. function remove_candidate(expr) {
  15609. if (expr.name instanceof AST_SymbolFunarg) {
  15610. var iife = compressor.parent(), argnames = compressor.self().argnames;
  15611. var index = argnames.indexOf(expr.name);
  15612. if (index < 0) {
  15613. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  15614. } else {
  15615. var args = iife.args;
  15616. if (args[index])
  15617. args[index] = make_node(AST_Number, args[index], {
  15618. value: 0
  15619. });
  15620. }
  15621. return true;
  15622. }
  15623. var found = false;
  15624. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  15625. if (found)
  15626. return node;
  15627. if (node === expr || node.body === expr) {
  15628. found = true;
  15629. if (node instanceof AST_VarDef) {
  15630. node.value = node.name instanceof AST_SymbolConst
  15631. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  15632. : null;
  15633. return node;
  15634. }
  15635. return in_list ? MAP.skip : null;
  15636. }
  15637. }, function (node) {
  15638. if (node instanceof AST_Sequence)
  15639. switch (node.expressions.length) {
  15640. case 0: return null;
  15641. case 1: return node.expressions[0];
  15642. }
  15643. }));
  15644. }
  15645. function is_lhs_local(lhs) {
  15646. while (lhs instanceof AST_PropAccess)
  15647. lhs = lhs.expression;
  15648. return lhs instanceof AST_SymbolRef
  15649. && lhs.definition().scope.get_defun_scope() === defun_scope
  15650. && !(in_loop
  15651. && (lvalues.has(lhs.name)
  15652. || candidate instanceof AST_Unary
  15653. || (candidate instanceof AST_Assign
  15654. && !candidate.logical
  15655. && candidate.operator != "=")));
  15656. }
  15657. function value_has_side_effects(expr) {
  15658. if (expr instanceof AST_Unary)
  15659. return unary_side_effects.has(expr.operator);
  15660. return get_rvalue(expr).has_side_effects(compressor);
  15661. }
  15662. function replace_all_symbols() {
  15663. if (side_effects)
  15664. return false;
  15665. if (value_def)
  15666. return true;
  15667. if (lhs instanceof AST_SymbolRef) {
  15668. var def = lhs.definition();
  15669. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  15670. return true;
  15671. }
  15672. }
  15673. return false;
  15674. }
  15675. function may_modify(sym) {
  15676. if (!sym.definition)
  15677. return true; // AST_Destructuring
  15678. var def = sym.definition();
  15679. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  15680. return false;
  15681. if (def.scope.get_defun_scope() !== defun_scope)
  15682. return true;
  15683. return def.references.some((ref) =>
  15684. ref.scope.get_defun_scope() !== defun_scope
  15685. );
  15686. }
  15687. function side_effects_external(node, lhs) {
  15688. if (node instanceof AST_Assign)
  15689. return side_effects_external(node.left, true);
  15690. if (node instanceof AST_Unary)
  15691. return side_effects_external(node.expression, true);
  15692. if (node instanceof AST_VarDef)
  15693. return node.value && side_effects_external(node.value);
  15694. if (lhs) {
  15695. if (node instanceof AST_Dot)
  15696. return side_effects_external(node.expression, true);
  15697. if (node instanceof AST_Sub)
  15698. return side_effects_external(node.expression, true);
  15699. if (node instanceof AST_SymbolRef)
  15700. return node.definition().scope.get_defun_scope() !== defun_scope;
  15701. }
  15702. return false;
  15703. }
  15704. /**
  15705. * Will any of the pulled-in lvalues shadow a variable in newScope or parents?
  15706. * similar to scope_encloses_variables_in_this_scope */
  15707. function shadows(my_scope, lvalues) {
  15708. for (const { def } of lvalues.values()) {
  15709. const looked_up = my_scope.find_variable(def.name);
  15710. if (looked_up) {
  15711. if (looked_up === def) continue;
  15712. return true;
  15713. }
  15714. }
  15715. return false;
  15716. }
  15717. }
  15718. function eliminate_spurious_blocks(statements) {
  15719. var seen_dirs = [];
  15720. for (var i = 0; i < statements.length;) {
  15721. var stat = statements[i];
  15722. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  15723. CHANGED = true;
  15724. eliminate_spurious_blocks(stat.body);
  15725. statements.splice(i, 1, ...stat.body);
  15726. i += stat.body.length;
  15727. } else if (stat instanceof AST_EmptyStatement) {
  15728. CHANGED = true;
  15729. statements.splice(i, 1);
  15730. } else if (stat instanceof AST_Directive) {
  15731. if (seen_dirs.indexOf(stat.value) < 0) {
  15732. i++;
  15733. seen_dirs.push(stat.value);
  15734. } else {
  15735. CHANGED = true;
  15736. statements.splice(i, 1);
  15737. }
  15738. } else
  15739. i++;
  15740. }
  15741. }
  15742. function handle_if_return(statements, compressor) {
  15743. var self = compressor.self();
  15744. var multiple_if_returns = has_multiple_if_returns(statements);
  15745. var in_lambda = self instanceof AST_Lambda;
  15746. // Prevent extremely deep nesting
  15747. // https://github.com/terser/terser/issues/1432
  15748. // https://github.com/webpack/webpack/issues/17548
  15749. const iteration_start = Math.min(statements.length, 500);
  15750. for (var i = iteration_start; --i >= 0;) {
  15751. var stat = statements[i];
  15752. var j = next_index(i);
  15753. var next = statements[j];
  15754. if (in_lambda && !next && stat instanceof AST_Return) {
  15755. if (!stat.value) {
  15756. CHANGED = true;
  15757. statements.splice(i, 1);
  15758. continue;
  15759. }
  15760. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  15761. CHANGED = true;
  15762. statements[i] = make_node(AST_SimpleStatement, stat, {
  15763. body: stat.value.expression
  15764. });
  15765. continue;
  15766. }
  15767. }
  15768. if (stat instanceof AST_If) {
  15769. let ab, new_else;
  15770. ab = aborts(stat.body);
  15771. if (
  15772. can_merge_flow(ab)
  15773. && (new_else = as_statement_array_with_return(stat.body, ab))
  15774. ) {
  15775. if (ab.label) {
  15776. remove(ab.label.thedef.references, ab);
  15777. }
  15778. CHANGED = true;
  15779. stat = stat.clone();
  15780. stat.condition = stat.condition.negate(compressor);
  15781. stat.body = make_node(AST_BlockStatement, stat, {
  15782. body: as_statement_array(stat.alternative).concat(extract_functions())
  15783. });
  15784. stat.alternative = make_node(AST_BlockStatement, stat, {
  15785. body: new_else
  15786. });
  15787. statements[i] = stat.transform(compressor);
  15788. continue;
  15789. }
  15790. ab = aborts(stat.alternative);
  15791. if (
  15792. can_merge_flow(ab)
  15793. && (new_else = as_statement_array_with_return(stat.alternative, ab))
  15794. ) {
  15795. if (ab.label) {
  15796. remove(ab.label.thedef.references, ab);
  15797. }
  15798. CHANGED = true;
  15799. stat = stat.clone();
  15800. stat.body = make_node(AST_BlockStatement, stat.body, {
  15801. body: as_statement_array(stat.body).concat(extract_functions())
  15802. });
  15803. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  15804. body: new_else
  15805. });
  15806. statements[i] = stat.transform(compressor);
  15807. continue;
  15808. }
  15809. }
  15810. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  15811. var value = stat.body.value;
  15812. //---
  15813. // pretty silly case, but:
  15814. // if (foo()) return; return; ==> foo(); return;
  15815. if (!value && !stat.alternative
  15816. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  15817. CHANGED = true;
  15818. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  15819. body: stat.condition
  15820. });
  15821. continue;
  15822. }
  15823. //---
  15824. // if (foo()) return x; return y; ==> return foo() ? x : y;
  15825. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  15826. CHANGED = true;
  15827. stat = stat.clone();
  15828. stat.alternative = next;
  15829. statements[i] = stat.transform(compressor);
  15830. statements.splice(j, 1);
  15831. continue;
  15832. }
  15833. //---
  15834. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  15835. if (value && !stat.alternative
  15836. && (!next && in_lambda && multiple_if_returns
  15837. || next instanceof AST_Return)) {
  15838. CHANGED = true;
  15839. stat = stat.clone();
  15840. stat.alternative = next || make_node(AST_Return, stat, {
  15841. value: null
  15842. });
  15843. statements[i] = stat.transform(compressor);
  15844. if (next)
  15845. statements.splice(j, 1);
  15846. continue;
  15847. }
  15848. //---
  15849. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  15850. //
  15851. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  15852. // however, with sequences on this helps producing slightly better output for
  15853. // the example code.
  15854. var prev = statements[prev_index(i)];
  15855. if (compressor.option("sequences") && in_lambda && !stat.alternative
  15856. && prev instanceof AST_If && prev.body instanceof AST_Return
  15857. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  15858. CHANGED = true;
  15859. stat = stat.clone();
  15860. stat.alternative = make_node(AST_BlockStatement, next, {
  15861. body: [
  15862. next,
  15863. make_node(AST_Return, next, {
  15864. value: null
  15865. })
  15866. ]
  15867. });
  15868. statements[i] = stat.transform(compressor);
  15869. statements.splice(j, 1);
  15870. continue;
  15871. }
  15872. }
  15873. }
  15874. function has_multiple_if_returns(statements) {
  15875. var n = 0;
  15876. for (var i = statements.length; --i >= 0;) {
  15877. var stat = statements[i];
  15878. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  15879. if (++n > 1)
  15880. return true;
  15881. }
  15882. }
  15883. return false;
  15884. }
  15885. function is_return_void(value) {
  15886. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  15887. }
  15888. function can_merge_flow(ab) {
  15889. if (!ab)
  15890. return false;
  15891. for (var j = i + 1, len = statements.length; j < len; j++) {
  15892. var stat = statements[j];
  15893. if (stat instanceof AST_Const || stat instanceof AST_Let)
  15894. return false;
  15895. }
  15896. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  15897. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  15898. || ab instanceof AST_Continue && self === loop_body(lct)
  15899. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  15900. }
  15901. function extract_functions() {
  15902. var tail = statements.slice(i + 1);
  15903. statements.length = i + 1;
  15904. return tail.filter(function (stat) {
  15905. if (stat instanceof AST_Defun) {
  15906. statements.push(stat);
  15907. return false;
  15908. }
  15909. return true;
  15910. });
  15911. }
  15912. function as_statement_array_with_return(node, ab) {
  15913. var body = as_statement_array(node);
  15914. if (ab !== body[body.length - 1]) {
  15915. return undefined;
  15916. }
  15917. body = body.slice(0, -1);
  15918. if (ab.value) {
  15919. body.push(make_node(AST_SimpleStatement, ab.value, {
  15920. body: ab.value.expression
  15921. }));
  15922. }
  15923. return body;
  15924. }
  15925. function next_index(i) {
  15926. for (var j = i + 1, len = statements.length; j < len; j++) {
  15927. var stat = statements[j];
  15928. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  15929. break;
  15930. }
  15931. }
  15932. return j;
  15933. }
  15934. function prev_index(i) {
  15935. for (var j = i; --j >= 0;) {
  15936. var stat = statements[j];
  15937. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  15938. break;
  15939. }
  15940. }
  15941. return j;
  15942. }
  15943. }
  15944. function eliminate_dead_code(statements, compressor) {
  15945. var has_quit;
  15946. var self = compressor.self();
  15947. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  15948. var stat = statements[i];
  15949. if (stat instanceof AST_LoopControl) {
  15950. var lct = compressor.loopcontrol_target(stat);
  15951. if (stat instanceof AST_Break
  15952. && !(lct instanceof AST_IterationStatement)
  15953. && loop_body(lct) === self
  15954. || stat instanceof AST_Continue
  15955. && loop_body(lct) === self) {
  15956. if (stat.label) {
  15957. remove(stat.label.thedef.references, stat);
  15958. }
  15959. } else {
  15960. statements[n++] = stat;
  15961. }
  15962. } else {
  15963. statements[n++] = stat;
  15964. }
  15965. if (aborts(stat)) {
  15966. has_quit = statements.slice(i + 1);
  15967. break;
  15968. }
  15969. }
  15970. statements.length = n;
  15971. CHANGED = n != len;
  15972. if (has_quit)
  15973. has_quit.forEach(function (stat) {
  15974. trim_unreachable_code(compressor, stat, statements);
  15975. });
  15976. }
  15977. function declarations_only(node) {
  15978. return node.definitions.every((var_def) => !var_def.value);
  15979. }
  15980. function sequencesize(statements, compressor) {
  15981. if (statements.length < 2)
  15982. return;
  15983. var seq = [], n = 0;
  15984. function push_seq() {
  15985. if (!seq.length)
  15986. return;
  15987. var body = make_sequence(seq[0], seq);
  15988. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  15989. seq = [];
  15990. }
  15991. for (var i = 0, len = statements.length; i < len; i++) {
  15992. var stat = statements[i];
  15993. if (stat instanceof AST_SimpleStatement) {
  15994. if (seq.length >= compressor.sequences_limit)
  15995. push_seq();
  15996. var body = stat.body;
  15997. if (seq.length > 0)
  15998. body = body.drop_side_effect_free(compressor);
  15999. if (body)
  16000. merge_sequence(seq, body);
  16001. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  16002. || stat instanceof AST_Defun) {
  16003. statements[n++] = stat;
  16004. } else {
  16005. push_seq();
  16006. statements[n++] = stat;
  16007. }
  16008. }
  16009. push_seq();
  16010. statements.length = n;
  16011. if (n != len)
  16012. CHANGED = true;
  16013. }
  16014. function to_simple_statement(block, decls) {
  16015. if (!(block instanceof AST_BlockStatement))
  16016. return block;
  16017. var stat = null;
  16018. for (var i = 0, len = block.body.length; i < len; i++) {
  16019. var line = block.body[i];
  16020. if (line instanceof AST_Var && declarations_only(line)) {
  16021. decls.push(line);
  16022. } else if (stat || line instanceof AST_Const || line instanceof AST_Let) {
  16023. return false;
  16024. } else {
  16025. stat = line;
  16026. }
  16027. }
  16028. return stat;
  16029. }
  16030. function sequencesize_2(statements, compressor) {
  16031. function cons_seq(right) {
  16032. n--;
  16033. CHANGED = true;
  16034. var left = prev.body;
  16035. return make_sequence(left, [left, right]).transform(compressor);
  16036. }
  16037. var n = 0, prev;
  16038. for (var i = 0; i < statements.length; i++) {
  16039. var stat = statements[i];
  16040. if (prev) {
  16041. if (stat instanceof AST_Exit) {
  16042. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  16043. } else if (stat instanceof AST_For) {
  16044. if (!(stat.init instanceof AST_Definitions)) {
  16045. const abort = walk(prev.body, node => {
  16046. if (node instanceof AST_Scope)
  16047. return true;
  16048. if (node instanceof AST_Binary
  16049. && node.operator === "in") {
  16050. return walk_abort;
  16051. }
  16052. });
  16053. if (!abort) {
  16054. if (stat.init)
  16055. stat.init = cons_seq(stat.init);
  16056. else {
  16057. stat.init = prev.body;
  16058. n--;
  16059. CHANGED = true;
  16060. }
  16061. }
  16062. }
  16063. } else if (stat instanceof AST_ForIn) {
  16064. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  16065. stat.object = cons_seq(stat.object);
  16066. }
  16067. } else if (stat instanceof AST_If) {
  16068. stat.condition = cons_seq(stat.condition);
  16069. } else if (stat instanceof AST_Switch) {
  16070. stat.expression = cons_seq(stat.expression);
  16071. } else if (stat instanceof AST_With) {
  16072. stat.expression = cons_seq(stat.expression);
  16073. }
  16074. }
  16075. if (compressor.option("conditionals") && stat instanceof AST_If) {
  16076. var decls = [];
  16077. var body = to_simple_statement(stat.body, decls);
  16078. var alt = to_simple_statement(stat.alternative, decls);
  16079. if (body !== false && alt !== false && decls.length > 0) {
  16080. var len = decls.length;
  16081. decls.push(make_node(AST_If, stat, {
  16082. condition: stat.condition,
  16083. body: body || make_node(AST_EmptyStatement, stat.body),
  16084. alternative: alt
  16085. }));
  16086. decls.unshift(n, 1);
  16087. [].splice.apply(statements, decls);
  16088. i += len;
  16089. n += len + 1;
  16090. prev = null;
  16091. CHANGED = true;
  16092. continue;
  16093. }
  16094. }
  16095. statements[n++] = stat;
  16096. prev = stat instanceof AST_SimpleStatement ? stat : null;
  16097. }
  16098. statements.length = n;
  16099. }
  16100. function join_object_assignments(defn, body) {
  16101. if (!(defn instanceof AST_Definitions))
  16102. return;
  16103. var def = defn.definitions[defn.definitions.length - 1];
  16104. if (!(def.value instanceof AST_Object))
  16105. return;
  16106. var exprs;
  16107. if (body instanceof AST_Assign && !body.logical) {
  16108. exprs = [body];
  16109. } else if (body instanceof AST_Sequence) {
  16110. exprs = body.expressions.slice();
  16111. }
  16112. if (!exprs)
  16113. return;
  16114. var trimmed = false;
  16115. do {
  16116. var node = exprs[0];
  16117. if (!(node instanceof AST_Assign))
  16118. break;
  16119. if (node.operator != "=")
  16120. break;
  16121. if (!(node.left instanceof AST_PropAccess))
  16122. break;
  16123. var sym = node.left.expression;
  16124. if (!(sym instanceof AST_SymbolRef))
  16125. break;
  16126. if (def.name.name != sym.name)
  16127. break;
  16128. if (!node.right.is_constant_expression(nearest_scope))
  16129. break;
  16130. var prop = node.left.property;
  16131. if (prop instanceof AST_Node) {
  16132. prop = prop.evaluate(compressor);
  16133. }
  16134. if (prop instanceof AST_Node)
  16135. break;
  16136. prop = "" + prop;
  16137. var diff = compressor.option("ecma") < 2015
  16138. && compressor.has_directive("use strict") ? function (node) {
  16139. return node.key != prop && (node.key && node.key.name != prop);
  16140. } : function (node) {
  16141. return node.key && node.key.name != prop;
  16142. };
  16143. if (!def.value.properties.every(diff))
  16144. break;
  16145. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  16146. if (!p) {
  16147. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  16148. key: prop,
  16149. value: node.right
  16150. }));
  16151. } else {
  16152. p.value = new AST_Sequence({
  16153. start: p.start,
  16154. expressions: [p.value.clone(), node.right.clone()],
  16155. end: p.end
  16156. });
  16157. }
  16158. exprs.shift();
  16159. trimmed = true;
  16160. } while (exprs.length);
  16161. return trimmed && exprs;
  16162. }
  16163. function join_consecutive_vars(statements) {
  16164. var defs;
  16165. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  16166. var stat = statements[i];
  16167. var prev = statements[j];
  16168. if (stat instanceof AST_Definitions) {
  16169. if (prev && prev.TYPE == stat.TYPE) {
  16170. prev.definitions = prev.definitions.concat(stat.definitions);
  16171. CHANGED = true;
  16172. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  16173. defs.definitions = defs.definitions.concat(stat.definitions);
  16174. CHANGED = true;
  16175. } else {
  16176. statements[++j] = stat;
  16177. defs = stat;
  16178. }
  16179. } else if (stat instanceof AST_Exit) {
  16180. stat.value = extract_object_assignments(stat.value);
  16181. } else if (stat instanceof AST_For) {
  16182. var exprs = join_object_assignments(prev, stat.init);
  16183. if (exprs) {
  16184. CHANGED = true;
  16185. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  16186. statements[++j] = stat;
  16187. } else if (
  16188. prev instanceof AST_Var
  16189. && (!stat.init || stat.init.TYPE == prev.TYPE)
  16190. ) {
  16191. if (stat.init) {
  16192. prev.definitions = prev.definitions.concat(stat.init.definitions);
  16193. }
  16194. stat.init = prev;
  16195. statements[j] = stat;
  16196. CHANGED = true;
  16197. } else if (
  16198. defs instanceof AST_Var
  16199. && stat.init instanceof AST_Var
  16200. && declarations_only(stat.init)
  16201. ) {
  16202. defs.definitions = defs.definitions.concat(stat.init.definitions);
  16203. stat.init = null;
  16204. statements[++j] = stat;
  16205. CHANGED = true;
  16206. } else {
  16207. statements[++j] = stat;
  16208. }
  16209. } else if (stat instanceof AST_ForIn) {
  16210. stat.object = extract_object_assignments(stat.object);
  16211. } else if (stat instanceof AST_If) {
  16212. stat.condition = extract_object_assignments(stat.condition);
  16213. } else if (stat instanceof AST_SimpleStatement) {
  16214. var exprs = join_object_assignments(prev, stat.body);
  16215. if (exprs) {
  16216. CHANGED = true;
  16217. if (!exprs.length)
  16218. continue;
  16219. stat.body = make_sequence(stat.body, exprs);
  16220. }
  16221. statements[++j] = stat;
  16222. } else if (stat instanceof AST_Switch) {
  16223. stat.expression = extract_object_assignments(stat.expression);
  16224. } else if (stat instanceof AST_With) {
  16225. stat.expression = extract_object_assignments(stat.expression);
  16226. } else {
  16227. statements[++j] = stat;
  16228. }
  16229. }
  16230. statements.length = j + 1;
  16231. function extract_object_assignments(value) {
  16232. statements[++j] = stat;
  16233. var exprs = join_object_assignments(prev, value);
  16234. if (exprs) {
  16235. CHANGED = true;
  16236. if (exprs.length) {
  16237. return make_sequence(value, exprs);
  16238. } else if (value instanceof AST_Sequence) {
  16239. return value.tail_node().left;
  16240. } else {
  16241. return value.left;
  16242. }
  16243. }
  16244. return value;
  16245. }
  16246. }
  16247. }
  16248. /***********************************************************************
  16249. A JavaScript tokenizer / parser / beautifier / compressor.
  16250. https://github.com/mishoo/UglifyJS2
  16251. -------------------------------- (C) ---------------------------------
  16252. Author: Mihai Bazon
  16253. <mihai.bazon@gmail.com>
  16254. http://mihai.bazon.net/blog
  16255. Distributed under the BSD license:
  16256. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16257. Redistribution and use in source and binary forms, with or without
  16258. modification, are permitted provided that the following conditions
  16259. are met:
  16260. * Redistributions of source code must retain the above
  16261. copyright notice, this list of conditions and the following
  16262. disclaimer.
  16263. * Redistributions in binary form must reproduce the above
  16264. copyright notice, this list of conditions and the following
  16265. disclaimer in the documentation and/or other materials
  16266. provided with the distribution.
  16267. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16268. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16269. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16270. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16271. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16272. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16273. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16274. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16275. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16276. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16277. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16278. SUCH DAMAGE.
  16279. ***********************************************************************/
  16280. /**
  16281. * Module that contains the inlining logic.
  16282. *
  16283. * @module
  16284. *
  16285. * The stars of the show are `inline_into_symbolref` and `inline_into_call`.
  16286. */
  16287. function within_array_or_object_literal(compressor) {
  16288. var node, level = 0;
  16289. while (node = compressor.parent(level++)) {
  16290. if (node instanceof AST_Statement) return false;
  16291. if (node instanceof AST_Array
  16292. || node instanceof AST_ObjectKeyVal
  16293. || node instanceof AST_Object) {
  16294. return true;
  16295. }
  16296. }
  16297. return false;
  16298. }
  16299. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  16300. for (const enclosed of pulled_scope.enclosed) {
  16301. if (pulled_scope.variables.has(enclosed.name)) {
  16302. continue;
  16303. }
  16304. const looked_up = scope.find_variable(enclosed.name);
  16305. if (looked_up) {
  16306. if (looked_up === enclosed) continue;
  16307. return true;
  16308. }
  16309. }
  16310. return false;
  16311. }
  16312. /**
  16313. * An extra check function for `top_retain` option, compare the length of const identifier
  16314. * and init value length and return true if init value is longer than identifier. for example:
  16315. * ```
  16316. * // top_retain: ["example"]
  16317. * const example = 100
  16318. * ```
  16319. * it will return false because length of "100" is short than identifier "example".
  16320. */
  16321. function is_const_symbol_short_than_init_value(def, fixed_value) {
  16322. if (def.orig.length === 1 && fixed_value) {
  16323. const init_value_length = fixed_value.size();
  16324. const identifer_length = def.name.length;
  16325. return init_value_length > identifer_length;
  16326. }
  16327. return true;
  16328. }
  16329. function inline_into_symbolref(self, compressor) {
  16330. if (compressor.in_computed_key()) return self;
  16331. const parent = compressor.parent();
  16332. const def = self.definition();
  16333. const nearest_scope = compressor.find_scope();
  16334. let fixed = self.fixed_value();
  16335. if (
  16336. compressor.top_retain &&
  16337. def.global &&
  16338. compressor.top_retain(def) &&
  16339. // when identifier is in top_retain option dose not mean we can always inline it.
  16340. // if identifier name is longer then init value, we can replace it.
  16341. is_const_symbol_short_than_init_value(def, fixed)
  16342. ) {
  16343. // keep it
  16344. def.fixed = false;
  16345. def.single_use = false;
  16346. return self;
  16347. }
  16348. let single_use = def.single_use
  16349. && !(parent instanceof AST_Call
  16350. && (parent.is_callee_pure(compressor))
  16351. || has_annotation(parent, _NOINLINE))
  16352. && !(parent instanceof AST_Export
  16353. && fixed instanceof AST_Lambda
  16354. && fixed.name);
  16355. if (single_use && fixed instanceof AST_Node) {
  16356. single_use =
  16357. !fixed.has_side_effects(compressor)
  16358. && !fixed.may_throw(compressor);
  16359. }
  16360. if (fixed instanceof AST_Class && def.scope !== self.scope) {
  16361. return self;
  16362. }
  16363. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16364. if (retain_top_func(fixed, compressor)) {
  16365. single_use = false;
  16366. } else if (def.scope !== self.scope
  16367. && (def.escaped == 1
  16368. || has_flag(fixed, INLINED)
  16369. || within_array_or_object_literal(compressor)
  16370. || !compressor.option("reduce_funcs"))) {
  16371. single_use = false;
  16372. } else if (is_recursive_ref(compressor, def)) {
  16373. single_use = false;
  16374. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  16375. single_use = fixed.is_constant_expression(self.scope);
  16376. if (single_use == "f") {
  16377. var scope = self.scope;
  16378. do {
  16379. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  16380. set_flag(scope, INLINED);
  16381. }
  16382. } while (scope = scope.parent_scope);
  16383. }
  16384. }
  16385. }
  16386. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16387. single_use =
  16388. def.scope === self.scope
  16389. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16390. || parent instanceof AST_Call
  16391. && parent.expression === self
  16392. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16393. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  16394. }
  16395. if (single_use && fixed) {
  16396. if (fixed instanceof AST_DefClass) {
  16397. set_flag(fixed, SQUEEZED);
  16398. fixed = make_node(AST_ClassExpression, fixed, fixed);
  16399. }
  16400. if (fixed instanceof AST_Defun) {
  16401. set_flag(fixed, SQUEEZED);
  16402. fixed = make_node(AST_Function, fixed, fixed);
  16403. }
  16404. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  16405. const defun_def = fixed.name.definition();
  16406. let lambda_def = fixed.variables.get(fixed.name.name);
  16407. let name = lambda_def && lambda_def.orig[0];
  16408. if (!(name instanceof AST_SymbolLambda)) {
  16409. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  16410. name.scope = fixed;
  16411. fixed.name = name;
  16412. lambda_def = fixed.def_function(name);
  16413. }
  16414. walk(fixed, node => {
  16415. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  16416. node.thedef = lambda_def;
  16417. lambda_def.references.push(node);
  16418. }
  16419. });
  16420. }
  16421. if (
  16422. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  16423. && fixed.parent_scope !== nearest_scope
  16424. ) {
  16425. fixed = fixed.clone(true, compressor.get_toplevel());
  16426. nearest_scope.add_child_scope(fixed);
  16427. }
  16428. return fixed.optimize(compressor);
  16429. }
  16430. // multiple uses
  16431. if (fixed) {
  16432. let replace;
  16433. if (fixed instanceof AST_This) {
  16434. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  16435. && def.references.every((ref) =>
  16436. def.scope === ref.scope
  16437. )) {
  16438. replace = fixed;
  16439. }
  16440. } else {
  16441. var ev = fixed.evaluate(compressor);
  16442. if (
  16443. ev !== fixed
  16444. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  16445. ) {
  16446. replace = make_node_from_constant(ev, fixed);
  16447. }
  16448. }
  16449. if (replace) {
  16450. const name_length = self.size(compressor);
  16451. const replace_size = replace.size(compressor);
  16452. let overhead = 0;
  16453. if (compressor.option("unused") && !compressor.exposed(def)) {
  16454. overhead =
  16455. (name_length + 2 + fixed.size(compressor)) /
  16456. (def.references.length - def.assignments);
  16457. }
  16458. if (replace_size <= name_length + overhead) {
  16459. return replace;
  16460. }
  16461. }
  16462. }
  16463. return self;
  16464. }
  16465. function inline_into_call(self, compressor) {
  16466. if (compressor.in_computed_key()) return self;
  16467. var exp = self.expression;
  16468. var fn = exp;
  16469. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  16470. if (compressor.option("reduce_vars")
  16471. && fn instanceof AST_SymbolRef
  16472. && !has_annotation(self, _NOINLINE)
  16473. ) {
  16474. const fixed = fn.fixed_value();
  16475. if (
  16476. retain_top_func(fixed, compressor)
  16477. || !compressor.toplevel.funcs && exp.definition().global
  16478. ) {
  16479. return self;
  16480. }
  16481. fn = fixed;
  16482. }
  16483. var is_func = fn instanceof AST_Lambda;
  16484. var stat = is_func && fn.body[0];
  16485. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  16486. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  16487. if (can_inline && stat instanceof AST_Return) {
  16488. let returned = stat.value;
  16489. if (!returned || returned.is_constant_expression()) {
  16490. if (returned) {
  16491. returned = returned.clone(true);
  16492. } else {
  16493. returned = make_node(AST_Undefined, self);
  16494. }
  16495. const args = self.args.concat(returned);
  16496. return make_sequence(self, args).optimize(compressor);
  16497. }
  16498. // optimize identity function
  16499. if (
  16500. fn.argnames.length === 1
  16501. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  16502. && self.args.length < 2
  16503. && !(self.args[0] instanceof AST_Expansion)
  16504. && returned instanceof AST_SymbolRef
  16505. && returned.name === fn.argnames[0].name
  16506. ) {
  16507. const replacement =
  16508. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  16509. let parent;
  16510. if (
  16511. replacement instanceof AST_PropAccess
  16512. && (parent = compressor.parent()) instanceof AST_Call
  16513. && parent.expression === self
  16514. ) {
  16515. // identity function was being used to remove `this`, like in
  16516. //
  16517. // id(bag.no_this)(...)
  16518. //
  16519. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  16520. return make_sequence(self, [
  16521. make_node(AST_Number, self, { value: 0 }),
  16522. replacement
  16523. ]);
  16524. }
  16525. // replace call with first argument or undefined if none passed
  16526. return replacement;
  16527. }
  16528. }
  16529. if (can_inline) {
  16530. var scope, in_loop, level = -1;
  16531. let def;
  16532. let returned_value;
  16533. let nearest_scope;
  16534. if (simple_args
  16535. && !fn.uses_arguments
  16536. && !(compressor.parent() instanceof AST_Class)
  16537. && !(fn.name && fn instanceof AST_Function)
  16538. && (returned_value = can_flatten_body(stat))
  16539. && (exp === fn
  16540. || has_annotation(self, _INLINE)
  16541. || compressor.option("unused")
  16542. && (def = exp.definition()).references.length == 1
  16543. && !is_recursive_ref(compressor, def)
  16544. && fn.is_constant_expression(exp.scope))
  16545. && !has_annotation(self, _PURE | _NOINLINE)
  16546. && !fn.contains_this()
  16547. && can_inject_symbols()
  16548. && (nearest_scope = compressor.find_scope())
  16549. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  16550. && !(function in_default_assign() {
  16551. // Due to the fact function parameters have their own scope
  16552. // which can't use `var something` in the function body within,
  16553. // we simply don't inline into DefaultAssign.
  16554. let i = 0;
  16555. let p;
  16556. while ((p = compressor.parent(i++))) {
  16557. if (p instanceof AST_DefaultAssign) return true;
  16558. if (p instanceof AST_Block) break;
  16559. }
  16560. return false;
  16561. })()
  16562. && !(scope instanceof AST_Class)
  16563. ) {
  16564. set_flag(fn, SQUEEZED);
  16565. nearest_scope.add_child_scope(fn);
  16566. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  16567. }
  16568. }
  16569. if (can_inline && has_annotation(self, _INLINE)) {
  16570. set_flag(fn, SQUEEZED);
  16571. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  16572. fn = fn.clone(true);
  16573. fn.figure_out_scope({}, {
  16574. parent_scope: compressor.find_scope(),
  16575. toplevel: compressor.get_toplevel()
  16576. });
  16577. return make_node(AST_Call, self, {
  16578. expression: fn,
  16579. args: self.args,
  16580. }).optimize(compressor);
  16581. }
  16582. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  16583. if (can_drop_this_call) {
  16584. var args = self.args.concat(make_node(AST_Undefined, self));
  16585. return make_sequence(self, args).optimize(compressor);
  16586. }
  16587. if (compressor.option("negate_iife")
  16588. && compressor.parent() instanceof AST_SimpleStatement
  16589. && is_iife_call(self)) {
  16590. return self.negate(compressor, true);
  16591. }
  16592. var ev = self.evaluate(compressor);
  16593. if (ev !== self) {
  16594. ev = make_node_from_constant(ev, self).optimize(compressor);
  16595. return best_of(compressor, ev, self);
  16596. }
  16597. return self;
  16598. function return_value(stat) {
  16599. if (!stat) return make_node(AST_Undefined, self);
  16600. if (stat instanceof AST_Return) {
  16601. if (!stat.value) return make_node(AST_Undefined, self);
  16602. return stat.value.clone(true);
  16603. }
  16604. if (stat instanceof AST_SimpleStatement) {
  16605. return make_node(AST_UnaryPrefix, stat, {
  16606. operator: "void",
  16607. expression: stat.body.clone(true)
  16608. });
  16609. }
  16610. }
  16611. function can_flatten_body(stat) {
  16612. var body = fn.body;
  16613. var len = body.length;
  16614. if (compressor.option("inline") < 3) {
  16615. return len == 1 && return_value(stat);
  16616. }
  16617. stat = null;
  16618. for (var i = 0; i < len; i++) {
  16619. var line = body[i];
  16620. if (line instanceof AST_Var) {
  16621. if (stat && !line.definitions.every((var_def) =>
  16622. !var_def.value
  16623. )) {
  16624. return false;
  16625. }
  16626. } else if (stat) {
  16627. return false;
  16628. } else if (!(line instanceof AST_EmptyStatement)) {
  16629. stat = line;
  16630. }
  16631. }
  16632. return return_value(stat);
  16633. }
  16634. function can_inject_args(block_scoped, safe_to_inject) {
  16635. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  16636. var arg = fn.argnames[i];
  16637. if (arg instanceof AST_DefaultAssign) {
  16638. if (has_flag(arg.left, UNUSED)) continue;
  16639. return false;
  16640. }
  16641. if (arg instanceof AST_Destructuring) return false;
  16642. if (arg instanceof AST_Expansion) {
  16643. if (has_flag(arg.expression, UNUSED)) continue;
  16644. return false;
  16645. }
  16646. if (has_flag(arg, UNUSED)) continue;
  16647. if (!safe_to_inject
  16648. || block_scoped.has(arg.name)
  16649. || identifier_atom.has(arg.name)
  16650. || scope.conflicting_def(arg.name)) {
  16651. return false;
  16652. }
  16653. if (in_loop) in_loop.push(arg.definition());
  16654. }
  16655. return true;
  16656. }
  16657. function can_inject_vars(block_scoped, safe_to_inject) {
  16658. var len = fn.body.length;
  16659. for (var i = 0; i < len; i++) {
  16660. var stat = fn.body[i];
  16661. if (!(stat instanceof AST_Var)) continue;
  16662. if (!safe_to_inject) return false;
  16663. for (var j = stat.definitions.length; --j >= 0;) {
  16664. var name = stat.definitions[j].name;
  16665. if (name instanceof AST_Destructuring
  16666. || block_scoped.has(name.name)
  16667. || identifier_atom.has(name.name)
  16668. || scope.conflicting_def(name.name)) {
  16669. return false;
  16670. }
  16671. if (in_loop) in_loop.push(name.definition());
  16672. }
  16673. }
  16674. return true;
  16675. }
  16676. function can_inject_symbols() {
  16677. var block_scoped = new Set();
  16678. do {
  16679. scope = compressor.parent(++level);
  16680. if (scope.is_block_scope() && scope.block_scope) {
  16681. // TODO this is sometimes undefined during compression.
  16682. // But it should always have a value!
  16683. scope.block_scope.variables.forEach(function (variable) {
  16684. block_scoped.add(variable.name);
  16685. });
  16686. }
  16687. if (scope instanceof AST_Catch) {
  16688. // TODO can we delete? AST_Catch is a block scope.
  16689. if (scope.argname) {
  16690. block_scoped.add(scope.argname.name);
  16691. }
  16692. } else if (scope instanceof AST_IterationStatement) {
  16693. in_loop = [];
  16694. } else if (scope instanceof AST_SymbolRef) {
  16695. if (scope.fixed_value() instanceof AST_Scope) return false;
  16696. }
  16697. } while (!(scope instanceof AST_Scope));
  16698. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  16699. var inline = compressor.option("inline");
  16700. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  16701. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  16702. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  16703. }
  16704. function append_var(decls, expressions, name, value) {
  16705. var def = name.definition();
  16706. // Name already exists, only when a function argument had the same name
  16707. const already_appended = scope.variables.has(name.name);
  16708. if (!already_appended) {
  16709. scope.variables.set(name.name, def);
  16710. scope.enclosed.push(def);
  16711. decls.push(make_node(AST_VarDef, name, {
  16712. name: name,
  16713. value: null
  16714. }));
  16715. }
  16716. var sym = make_node(AST_SymbolRef, name, name);
  16717. def.references.push(sym);
  16718. if (value) expressions.push(make_node(AST_Assign, self, {
  16719. operator: "=",
  16720. logical: false,
  16721. left: sym,
  16722. right: value.clone()
  16723. }));
  16724. }
  16725. function flatten_args(decls, expressions) {
  16726. var len = fn.argnames.length;
  16727. for (var i = self.args.length; --i >= len;) {
  16728. expressions.push(self.args[i]);
  16729. }
  16730. for (i = len; --i >= 0;) {
  16731. var name = fn.argnames[i];
  16732. var value = self.args[i];
  16733. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  16734. if (value) expressions.push(value);
  16735. } else {
  16736. var symbol = make_node(AST_SymbolVar, name, name);
  16737. name.definition().orig.push(symbol);
  16738. if (!value && in_loop) value = make_node(AST_Undefined, self);
  16739. append_var(decls, expressions, symbol, value);
  16740. }
  16741. }
  16742. decls.reverse();
  16743. expressions.reverse();
  16744. }
  16745. function flatten_vars(decls, expressions) {
  16746. var pos = expressions.length;
  16747. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  16748. var stat = fn.body[i];
  16749. if (!(stat instanceof AST_Var)) continue;
  16750. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  16751. var var_def = stat.definitions[j];
  16752. var name = var_def.name;
  16753. append_var(decls, expressions, name, var_def.value);
  16754. if (in_loop && fn.argnames.every((argname) =>
  16755. argname.name != name.name
  16756. )) {
  16757. var def = fn.variables.get(name.name);
  16758. var sym = make_node(AST_SymbolRef, name, name);
  16759. def.references.push(sym);
  16760. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  16761. operator: "=",
  16762. logical: false,
  16763. left: sym,
  16764. right: make_node(AST_Undefined, name)
  16765. }));
  16766. }
  16767. }
  16768. }
  16769. }
  16770. function flatten_fn(returned_value) {
  16771. var decls = [];
  16772. var expressions = [];
  16773. flatten_args(decls, expressions);
  16774. flatten_vars(decls, expressions);
  16775. expressions.push(returned_value);
  16776. if (decls.length) {
  16777. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  16778. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  16779. definitions: decls
  16780. }));
  16781. }
  16782. return expressions.map(exp => exp.clone(true));
  16783. }
  16784. }
  16785. (function(def_find_defs) {
  16786. function to_node(value, orig) {
  16787. if (value instanceof AST_Node) {
  16788. if (!(value instanceof AST_Constant)) {
  16789. // Value may be a function, an array including functions and even a complex assign / block expression,
  16790. // so it should never be shared in different places.
  16791. // Otherwise wrong information may be used in the compression phase
  16792. value = value.clone(true);
  16793. }
  16794. return make_node(value.CTOR, orig, value);
  16795. }
  16796. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  16797. elements: value.map(function(value) {
  16798. return to_node(value, orig);
  16799. })
  16800. });
  16801. if (value && typeof value == "object") {
  16802. var props = [];
  16803. for (var key in value) if (HOP(value, key)) {
  16804. props.push(make_node(AST_ObjectKeyVal, orig, {
  16805. key: key,
  16806. value: to_node(value[key], orig)
  16807. }));
  16808. }
  16809. return make_node(AST_Object, orig, {
  16810. properties: props
  16811. });
  16812. }
  16813. return make_node_from_constant(value, orig);
  16814. }
  16815. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  16816. if (!compressor.option("global_defs")) return this;
  16817. this.figure_out_scope({ ie8: compressor.option("ie8") });
  16818. return this.transform(new TreeTransformer(function(node) {
  16819. var def = node._find_defs(compressor, "");
  16820. if (!def) return;
  16821. var level = 0, child = node, parent;
  16822. while (parent = this.parent(level++)) {
  16823. if (!(parent instanceof AST_PropAccess)) break;
  16824. if (parent.expression !== child) break;
  16825. child = parent;
  16826. }
  16827. if (is_lhs(child, parent)) {
  16828. return;
  16829. }
  16830. return def;
  16831. }));
  16832. });
  16833. def_find_defs(AST_Node, noop);
  16834. def_find_defs(AST_Chain, function(compressor, suffix) {
  16835. return this.expression._find_defs(compressor, suffix);
  16836. });
  16837. def_find_defs(AST_Dot, function(compressor, suffix) {
  16838. return this.expression._find_defs(compressor, "." + this.property + suffix);
  16839. });
  16840. def_find_defs(AST_SymbolDeclaration, function() {
  16841. if (!this.global()) return;
  16842. });
  16843. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  16844. if (!this.global()) return;
  16845. var defines = compressor.option("global_defs");
  16846. var name = this.name + suffix;
  16847. if (HOP(defines, name)) return to_node(defines[name], this);
  16848. });
  16849. def_find_defs(AST_ImportMeta, function(compressor, suffix) {
  16850. var defines = compressor.option("global_defs");
  16851. var name = "import.meta" + suffix;
  16852. if (HOP(defines, name)) return to_node(defines[name], this);
  16853. });
  16854. })(function(node, func) {
  16855. node.DEFMETHOD("_find_defs", func);
  16856. });
  16857. /***********************************************************************
  16858. A JavaScript tokenizer / parser / beautifier / compressor.
  16859. https://github.com/mishoo/UglifyJS2
  16860. -------------------------------- (C) ---------------------------------
  16861. Author: Mihai Bazon
  16862. <mihai.bazon@gmail.com>
  16863. http://mihai.bazon.net/blog
  16864. Distributed under the BSD license:
  16865. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16866. Redistribution and use in source and binary forms, with or without
  16867. modification, are permitted provided that the following conditions
  16868. are met:
  16869. * Redistributions of source code must retain the above
  16870. copyright notice, this list of conditions and the following
  16871. disclaimer.
  16872. * Redistributions in binary form must reproduce the above
  16873. copyright notice, this list of conditions and the following
  16874. disclaimer in the documentation and/or other materials
  16875. provided with the distribution.
  16876. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16877. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16878. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16879. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16880. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16881. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16882. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16883. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16884. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16885. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16886. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16887. SUCH DAMAGE.
  16888. ***********************************************************************/
  16889. class Compressor extends TreeWalker {
  16890. constructor(options, { false_by_default = false, mangle_options = false }) {
  16891. super();
  16892. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  16893. this.options = defaults(options, {
  16894. arguments : false,
  16895. arrows : !false_by_default,
  16896. booleans : !false_by_default,
  16897. booleans_as_integers : false,
  16898. collapse_vars : !false_by_default,
  16899. comparisons : !false_by_default,
  16900. computed_props: !false_by_default,
  16901. conditionals : !false_by_default,
  16902. dead_code : !false_by_default,
  16903. defaults : true,
  16904. directives : !false_by_default,
  16905. drop_console : false,
  16906. drop_debugger : !false_by_default,
  16907. ecma : 5,
  16908. evaluate : !false_by_default,
  16909. expression : false,
  16910. global_defs : false,
  16911. hoist_funs : false,
  16912. hoist_props : !false_by_default,
  16913. hoist_vars : false,
  16914. ie8 : false,
  16915. if_return : !false_by_default,
  16916. inline : !false_by_default,
  16917. join_vars : !false_by_default,
  16918. keep_classnames: false,
  16919. keep_fargs : true,
  16920. keep_fnames : false,
  16921. keep_infinity : false,
  16922. lhs_constants : !false_by_default,
  16923. loops : !false_by_default,
  16924. module : false,
  16925. negate_iife : !false_by_default,
  16926. passes : 1,
  16927. properties : !false_by_default,
  16928. pure_getters : !false_by_default && "strict",
  16929. pure_funcs : null,
  16930. pure_new : false,
  16931. reduce_funcs : !false_by_default,
  16932. reduce_vars : !false_by_default,
  16933. sequences : !false_by_default,
  16934. side_effects : !false_by_default,
  16935. switches : !false_by_default,
  16936. top_retain : null,
  16937. toplevel : !!(options && options["top_retain"]),
  16938. typeofs : !false_by_default,
  16939. unsafe : false,
  16940. unsafe_arrows : false,
  16941. unsafe_comps : false,
  16942. unsafe_Function: false,
  16943. unsafe_math : false,
  16944. unsafe_symbols: false,
  16945. unsafe_methods: false,
  16946. unsafe_proto : false,
  16947. unsafe_regexp : false,
  16948. unsafe_undefined: false,
  16949. unused : !false_by_default,
  16950. warnings : false // legacy
  16951. }, true);
  16952. var global_defs = this.options["global_defs"];
  16953. if (typeof global_defs == "object") for (var key in global_defs) {
  16954. if (key[0] === "@" && HOP(global_defs, key)) {
  16955. global_defs[key.slice(1)] = parse(global_defs[key], {
  16956. expression: true
  16957. });
  16958. }
  16959. }
  16960. if (this.options["inline"] === true) this.options["inline"] = 3;
  16961. var pure_funcs = this.options["pure_funcs"];
  16962. if (typeof pure_funcs == "function") {
  16963. this.pure_funcs = pure_funcs;
  16964. } else {
  16965. this.pure_funcs = pure_funcs ? function(node) {
  16966. return !pure_funcs.includes(node.expression.print_to_string());
  16967. } : return_true;
  16968. }
  16969. var top_retain = this.options["top_retain"];
  16970. if (top_retain instanceof RegExp) {
  16971. this.top_retain = function(def) {
  16972. return top_retain.test(def.name);
  16973. };
  16974. } else if (typeof top_retain == "function") {
  16975. this.top_retain = top_retain;
  16976. } else if (top_retain) {
  16977. if (typeof top_retain == "string") {
  16978. top_retain = top_retain.split(/,/);
  16979. }
  16980. this.top_retain = function(def) {
  16981. return top_retain.includes(def.name);
  16982. };
  16983. }
  16984. if (this.options["module"]) {
  16985. this.directives["use strict"] = true;
  16986. this.options["toplevel"] = true;
  16987. }
  16988. var toplevel = this.options["toplevel"];
  16989. this.toplevel = typeof toplevel == "string" ? {
  16990. funcs: /funcs/.test(toplevel),
  16991. vars: /vars/.test(toplevel)
  16992. } : {
  16993. funcs: toplevel,
  16994. vars: toplevel
  16995. };
  16996. var sequences = this.options["sequences"];
  16997. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  16998. this.evaluated_regexps = new Map();
  16999. this._toplevel = undefined;
  17000. this._mangle_options = mangle_options
  17001. ? format_mangler_options(mangle_options)
  17002. : mangle_options;
  17003. }
  17004. mangle_options() {
  17005. var nth_identifier = this._mangle_options && this._mangle_options.nth_identifier || base54;
  17006. var module = this._mangle_options && this._mangle_options.module || this.option("module");
  17007. return { ie8: this.option("ie8"), nth_identifier, module };
  17008. }
  17009. option(key) {
  17010. return this.options[key];
  17011. }
  17012. exposed(def) {
  17013. if (def.export) return true;
  17014. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  17015. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  17016. return true;
  17017. return false;
  17018. }
  17019. in_boolean_context() {
  17020. if (!this.option("booleans")) return false;
  17021. var self = this.self();
  17022. for (var i = 0, p; p = this.parent(i); i++) {
  17023. if (p instanceof AST_SimpleStatement
  17024. || p instanceof AST_Conditional && p.condition === self
  17025. || p instanceof AST_DWLoop && p.condition === self
  17026. || p instanceof AST_For && p.condition === self
  17027. || p instanceof AST_If && p.condition === self
  17028. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  17029. return true;
  17030. }
  17031. if (
  17032. p instanceof AST_Binary
  17033. && (
  17034. p.operator == "&&"
  17035. || p.operator == "||"
  17036. || p.operator == "??"
  17037. )
  17038. || p instanceof AST_Conditional
  17039. || p.tail_node() === self
  17040. ) {
  17041. self = p;
  17042. } else {
  17043. return false;
  17044. }
  17045. }
  17046. }
  17047. in_32_bit_context() {
  17048. if (!this.option("evaluate")) return false;
  17049. var self = this.self();
  17050. for (var i = 0, p; p = this.parent(i); i++) {
  17051. if (p instanceof AST_Binary && bitwise_binop.has(p.operator)) {
  17052. return true;
  17053. }
  17054. if (p instanceof AST_UnaryPrefix) {
  17055. return p.operator === "~";
  17056. }
  17057. if (
  17058. p instanceof AST_Binary
  17059. && (
  17060. p.operator == "&&"
  17061. || p.operator == "||"
  17062. || p.operator == "??"
  17063. )
  17064. || p instanceof AST_Conditional && p.condition !== self
  17065. || p.tail_node() === self
  17066. ) {
  17067. self = p;
  17068. } else {
  17069. return false;
  17070. }
  17071. }
  17072. }
  17073. in_computed_key() {
  17074. if (!this.option("evaluate")) return false;
  17075. var self = this.self();
  17076. for (var i = 0, p; p = this.parent(i); i++) {
  17077. if (p instanceof AST_ObjectProperty && p.key === self) {
  17078. return true;
  17079. }
  17080. }
  17081. return false;
  17082. }
  17083. get_toplevel() {
  17084. return this._toplevel;
  17085. }
  17086. compress(toplevel) {
  17087. toplevel = toplevel.resolve_defines(this);
  17088. this._toplevel = toplevel;
  17089. if (this.option("expression")) {
  17090. this._toplevel.process_expression(true);
  17091. }
  17092. var passes = +this.options.passes || 1;
  17093. var min_count = 1 / 0;
  17094. var stopping = false;
  17095. var mangle = this.mangle_options();
  17096. for (var pass = 0; pass < passes; pass++) {
  17097. this._toplevel.figure_out_scope(mangle);
  17098. if (pass === 0 && this.option("drop_console")) {
  17099. // must be run before reduce_vars and compress pass
  17100. this._toplevel = this._toplevel.drop_console(this.option("drop_console"));
  17101. }
  17102. if (pass > 0 || this.option("reduce_vars")) {
  17103. this._toplevel.reset_opt_flags(this);
  17104. }
  17105. this._toplevel = this._toplevel.transform(this);
  17106. if (passes > 1) {
  17107. let count = 0;
  17108. walk(this._toplevel, () => { count++; });
  17109. if (count < min_count) {
  17110. min_count = count;
  17111. stopping = false;
  17112. } else if (stopping) {
  17113. break;
  17114. } else {
  17115. stopping = true;
  17116. }
  17117. }
  17118. }
  17119. if (this.option("expression")) {
  17120. this._toplevel.process_expression(false);
  17121. }
  17122. toplevel = this._toplevel;
  17123. this._toplevel = undefined;
  17124. return toplevel;
  17125. }
  17126. before(node, descend) {
  17127. if (has_flag(node, SQUEEZED)) return node;
  17128. var was_scope = false;
  17129. if (node instanceof AST_Scope) {
  17130. node = node.hoist_properties(this);
  17131. node = node.hoist_declarations(this);
  17132. was_scope = true;
  17133. }
  17134. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  17135. // would call AST_Node.transform() if a different instance of AST_Node is
  17136. // produced after def_optimize().
  17137. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  17138. // Migrate and defer all children's AST_Node.transform() to below, which
  17139. // will now happen after this parent AST_Node has been properly substituted
  17140. // thus gives a consistent AST snapshot.
  17141. descend(node, this);
  17142. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  17143. // following replacement call would result in degraded efficiency of both
  17144. // output and performance.
  17145. descend(node, this);
  17146. var opt = node.optimize(this);
  17147. if (was_scope && opt instanceof AST_Scope) {
  17148. opt.drop_unused(this);
  17149. descend(opt, this);
  17150. }
  17151. if (opt === node) set_flag(opt, SQUEEZED);
  17152. return opt;
  17153. }
  17154. /** Alternative to plain is_lhs() which doesn't work within .optimize() */
  17155. is_lhs() {
  17156. const self = this.stack[this.stack.length - 1];
  17157. const parent = this.stack[this.stack.length - 2];
  17158. return is_lhs(self, parent);
  17159. }
  17160. }
  17161. function def_optimize(node, optimizer) {
  17162. node.DEFMETHOD("optimize", function(compressor) {
  17163. var self = this;
  17164. if (has_flag(self, OPTIMIZED)) return self;
  17165. if (compressor.has_directive("use asm")) return self;
  17166. var opt = optimizer(self, compressor);
  17167. set_flag(opt, OPTIMIZED);
  17168. return opt;
  17169. });
  17170. }
  17171. def_optimize(AST_Node, function(self) {
  17172. return self;
  17173. });
  17174. AST_Toplevel.DEFMETHOD("drop_console", function(options) {
  17175. const isArray = Array.isArray(options);
  17176. const tt = new TreeTransformer(function(self) {
  17177. if (self.TYPE !== "Call") {
  17178. return;
  17179. }
  17180. var exp = self.expression;
  17181. if (!(exp instanceof AST_PropAccess)) {
  17182. return;
  17183. }
  17184. var name = exp.expression;
  17185. var property = exp.property;
  17186. var depth = 2;
  17187. while (name.expression) {
  17188. property = name.property;
  17189. name = name.expression;
  17190. depth++;
  17191. }
  17192. if (isArray && !options.includes(property)) {
  17193. return;
  17194. }
  17195. if (is_undeclared_ref(name) && name.name == "console") {
  17196. if (
  17197. depth === 3
  17198. && !["call", "apply"].includes(exp.property)
  17199. && is_used_in_expression(tt)
  17200. ) {
  17201. // a (used) call to Function.prototype methods (eg: console.log.bind(console))
  17202. // but not .call and .apply which would also return undefined.
  17203. exp.expression = make_empty_function(self);
  17204. set_flag(exp.expression, SQUEEZED);
  17205. self.args = [];
  17206. } else {
  17207. return make_node(AST_Undefined, self);
  17208. }
  17209. }
  17210. });
  17211. return this.transform(tt);
  17212. });
  17213. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  17214. return equivalent_to(this, node);
  17215. });
  17216. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  17217. var self = this;
  17218. var tt = new TreeTransformer(function(node) {
  17219. if (insert && node instanceof AST_SimpleStatement) {
  17220. return make_node(AST_Return, node, {
  17221. value: node.body
  17222. });
  17223. }
  17224. if (!insert && node instanceof AST_Return) {
  17225. if (compressor) {
  17226. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  17227. return value
  17228. ? make_node(AST_SimpleStatement, node, { body: value })
  17229. : make_node(AST_EmptyStatement, node);
  17230. }
  17231. return make_node(AST_SimpleStatement, node, {
  17232. body: node.value || make_node(AST_UnaryPrefix, node, {
  17233. operator: "void",
  17234. expression: make_node(AST_Number, node, {
  17235. value: 0
  17236. })
  17237. })
  17238. });
  17239. }
  17240. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  17241. return node;
  17242. }
  17243. if (node instanceof AST_Block) {
  17244. var index = node.body.length - 1;
  17245. if (index >= 0) {
  17246. node.body[index] = node.body[index].transform(tt);
  17247. }
  17248. } else if (node instanceof AST_If) {
  17249. node.body = node.body.transform(tt);
  17250. if (node.alternative) {
  17251. node.alternative = node.alternative.transform(tt);
  17252. }
  17253. } else if (node instanceof AST_With) {
  17254. node.body = node.body.transform(tt);
  17255. }
  17256. return node;
  17257. });
  17258. self.transform(tt);
  17259. });
  17260. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  17261. const self = this;
  17262. const reduce_vars = compressor.option("reduce_vars");
  17263. const preparation = new TreeWalker(function(node, descend) {
  17264. clear_flag(node, CLEAR_BETWEEN_PASSES);
  17265. if (reduce_vars) {
  17266. if (compressor.top_retain
  17267. && node instanceof AST_Defun // Only functions are retained
  17268. && preparation.parent() === self
  17269. ) {
  17270. set_flag(node, TOP);
  17271. }
  17272. return node.reduce_vars(preparation, descend, compressor);
  17273. }
  17274. });
  17275. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  17276. // properly assigned before use:
  17277. // - `push()` & `pop()` when visiting conditional branches
  17278. preparation.safe_ids = Object.create(null);
  17279. preparation.in_loop = null;
  17280. preparation.loop_ids = new Map();
  17281. preparation.defs_to_safe_ids = new Map();
  17282. self.walk(preparation);
  17283. });
  17284. AST_Symbol.DEFMETHOD("fixed_value", function() {
  17285. var fixed = this.thedef.fixed;
  17286. if (!fixed || fixed instanceof AST_Node) return fixed;
  17287. return fixed();
  17288. });
  17289. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  17290. var orig = this.definition().orig;
  17291. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  17292. });
  17293. function find_variable(compressor, name) {
  17294. var scope, i = 0;
  17295. while (scope = compressor.parent(i++)) {
  17296. if (scope instanceof AST_Scope) break;
  17297. if (scope instanceof AST_Catch && scope.argname) {
  17298. scope = scope.argname.definition().scope;
  17299. break;
  17300. }
  17301. }
  17302. return scope.find_variable(name);
  17303. }
  17304. 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");
  17305. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  17306. return !this.definition().undeclared
  17307. || compressor.option("unsafe") && global_names.has(this.name);
  17308. });
  17309. /* -----[ optimizers ]----- */
  17310. var directives = new Set(["use asm", "use strict"]);
  17311. def_optimize(AST_Directive, function(self, compressor) {
  17312. if (compressor.option("directives")
  17313. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  17314. return make_node(AST_EmptyStatement, self);
  17315. }
  17316. return self;
  17317. });
  17318. def_optimize(AST_Debugger, function(self, compressor) {
  17319. if (compressor.option("drop_debugger"))
  17320. return make_node(AST_EmptyStatement, self);
  17321. return self;
  17322. });
  17323. def_optimize(AST_LabeledStatement, function(self, compressor) {
  17324. if (self.body instanceof AST_Break
  17325. && compressor.loopcontrol_target(self.body) === self.body) {
  17326. return make_node(AST_EmptyStatement, self);
  17327. }
  17328. return self.label.references.length == 0 ? self.body : self;
  17329. });
  17330. def_optimize(AST_Block, function(self, compressor) {
  17331. tighten_body(self.body, compressor);
  17332. return self;
  17333. });
  17334. function can_be_extracted_from_if_block(node) {
  17335. return !(
  17336. node instanceof AST_Const
  17337. || node instanceof AST_Let
  17338. || node instanceof AST_Class
  17339. );
  17340. }
  17341. def_optimize(AST_BlockStatement, function(self, compressor) {
  17342. tighten_body(self.body, compressor);
  17343. switch (self.body.length) {
  17344. case 1:
  17345. if (!compressor.has_directive("use strict")
  17346. && compressor.parent() instanceof AST_If
  17347. && can_be_extracted_from_if_block(self.body[0])
  17348. || can_be_evicted_from_block(self.body[0])) {
  17349. return self.body[0];
  17350. }
  17351. break;
  17352. case 0: return make_node(AST_EmptyStatement, self);
  17353. }
  17354. return self;
  17355. });
  17356. function opt_AST_Lambda(self, compressor) {
  17357. tighten_body(self.body, compressor);
  17358. if (compressor.option("side_effects")
  17359. && self.body.length == 1
  17360. && self.body[0] === compressor.has_directive("use strict")) {
  17361. self.body.length = 0;
  17362. }
  17363. return self;
  17364. }
  17365. def_optimize(AST_Lambda, opt_AST_Lambda);
  17366. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  17367. var self = this;
  17368. if (compressor.has_directive("use asm")) return self;
  17369. var hoist_funs = compressor.option("hoist_funs");
  17370. var hoist_vars = compressor.option("hoist_vars");
  17371. if (hoist_funs || hoist_vars) {
  17372. var dirs = [];
  17373. var hoisted = [];
  17374. var vars = new Map(), vars_found = 0, var_decl = 0;
  17375. // let's count var_decl first, we seem to waste a lot of
  17376. // space if we hoist `var` when there's only one.
  17377. walk(self, node => {
  17378. if (node instanceof AST_Scope && node !== self)
  17379. return true;
  17380. if (node instanceof AST_Var) {
  17381. ++var_decl;
  17382. return true;
  17383. }
  17384. });
  17385. hoist_vars = hoist_vars && var_decl > 1;
  17386. var tt = new TreeTransformer(
  17387. function before(node) {
  17388. if (node !== self) {
  17389. if (node instanceof AST_Directive) {
  17390. dirs.push(node);
  17391. return make_node(AST_EmptyStatement, node);
  17392. }
  17393. if (hoist_funs && node instanceof AST_Defun
  17394. && !(tt.parent() instanceof AST_Export)
  17395. && tt.parent() === self) {
  17396. hoisted.push(node);
  17397. return make_node(AST_EmptyStatement, node);
  17398. }
  17399. if (
  17400. hoist_vars
  17401. && node instanceof AST_Var
  17402. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  17403. ) {
  17404. node.definitions.forEach(function(def) {
  17405. vars.set(def.name.name, def);
  17406. ++vars_found;
  17407. });
  17408. var seq = node.to_assignments(compressor);
  17409. var p = tt.parent();
  17410. if (p instanceof AST_ForIn && p.init === node) {
  17411. if (seq == null) {
  17412. var def = node.definitions[0].name;
  17413. return make_node(AST_SymbolRef, def, def);
  17414. }
  17415. return seq;
  17416. }
  17417. if (p instanceof AST_For && p.init === node) {
  17418. return seq;
  17419. }
  17420. if (!seq) return make_node(AST_EmptyStatement, node);
  17421. return make_node(AST_SimpleStatement, node, {
  17422. body: seq
  17423. });
  17424. }
  17425. if (node instanceof AST_Scope)
  17426. return node; // to avoid descending in nested scopes
  17427. }
  17428. }
  17429. );
  17430. self = self.transform(tt);
  17431. if (vars_found > 0) {
  17432. // collect only vars which don't show up in self's arguments list
  17433. var defs = [];
  17434. const is_lambda = self instanceof AST_Lambda;
  17435. const args_as_names = is_lambda ? self.args_as_names() : null;
  17436. vars.forEach((def, name) => {
  17437. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  17438. vars.delete(name);
  17439. } else {
  17440. def = def.clone();
  17441. def.value = null;
  17442. defs.push(def);
  17443. vars.set(name, def);
  17444. }
  17445. });
  17446. if (defs.length > 0) {
  17447. // try to merge in assignments
  17448. for (var i = 0; i < self.body.length;) {
  17449. if (self.body[i] instanceof AST_SimpleStatement) {
  17450. var expr = self.body[i].body, sym, assign;
  17451. if (expr instanceof AST_Assign
  17452. && expr.operator == "="
  17453. && (sym = expr.left) instanceof AST_Symbol
  17454. && vars.has(sym.name)
  17455. ) {
  17456. var def = vars.get(sym.name);
  17457. if (def.value) break;
  17458. def.value = expr.right;
  17459. remove(defs, def);
  17460. defs.push(def);
  17461. self.body.splice(i, 1);
  17462. continue;
  17463. }
  17464. if (expr instanceof AST_Sequence
  17465. && (assign = expr.expressions[0]) instanceof AST_Assign
  17466. && assign.operator == "="
  17467. && (sym = assign.left) instanceof AST_Symbol
  17468. && vars.has(sym.name)
  17469. ) {
  17470. var def = vars.get(sym.name);
  17471. if (def.value) break;
  17472. def.value = assign.right;
  17473. remove(defs, def);
  17474. defs.push(def);
  17475. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  17476. continue;
  17477. }
  17478. }
  17479. if (self.body[i] instanceof AST_EmptyStatement) {
  17480. self.body.splice(i, 1);
  17481. continue;
  17482. }
  17483. if (self.body[i] instanceof AST_BlockStatement) {
  17484. self.body.splice(i, 1, ...self.body[i].body);
  17485. continue;
  17486. }
  17487. break;
  17488. }
  17489. defs = make_node(AST_Var, self, {
  17490. definitions: defs
  17491. });
  17492. hoisted.push(defs);
  17493. }
  17494. }
  17495. self.body = dirs.concat(hoisted, self.body);
  17496. }
  17497. return self;
  17498. });
  17499. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  17500. var self = this;
  17501. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  17502. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  17503. var defs_by_id = new Map();
  17504. var hoister = new TreeTransformer(function(node, descend) {
  17505. if (node instanceof AST_VarDef) {
  17506. const sym = node.name;
  17507. let def;
  17508. let value;
  17509. if (sym.scope === self
  17510. && (def = sym.definition()).escaped != 1
  17511. && !def.assignments
  17512. && !def.direct_access
  17513. && !def.single_use
  17514. && !compressor.exposed(def)
  17515. && !top_retain(def)
  17516. && (value = sym.fixed_value()) === node.value
  17517. && value instanceof AST_Object
  17518. && !value.properties.some(prop =>
  17519. prop instanceof AST_Expansion || prop.computed_key()
  17520. )
  17521. ) {
  17522. descend(node, this);
  17523. const defs = new Map();
  17524. const assignments = [];
  17525. value.properties.forEach(({ key, value }) => {
  17526. const scope = hoister.find_scope();
  17527. const symbol = self.create_symbol(sym.CTOR, {
  17528. source: sym,
  17529. scope,
  17530. conflict_scopes: new Set([
  17531. scope,
  17532. ...sym.definition().references.map(ref => ref.scope)
  17533. ]),
  17534. tentative_name: sym.name + "_" + key
  17535. });
  17536. defs.set(String(key), symbol.definition());
  17537. assignments.push(make_node(AST_VarDef, node, {
  17538. name: symbol,
  17539. value
  17540. }));
  17541. });
  17542. defs_by_id.set(def.id, defs);
  17543. return MAP.splice(assignments);
  17544. }
  17545. } else if (node instanceof AST_PropAccess
  17546. && node.expression instanceof AST_SymbolRef
  17547. ) {
  17548. const defs = defs_by_id.get(node.expression.definition().id);
  17549. if (defs) {
  17550. const def = defs.get(String(get_simple_key(node.property)));
  17551. const sym = make_node(AST_SymbolRef, node, {
  17552. name: def.name,
  17553. scope: node.expression.scope,
  17554. thedef: def
  17555. });
  17556. sym.reference({});
  17557. return sym;
  17558. }
  17559. }
  17560. });
  17561. return self.transform(hoister);
  17562. });
  17563. def_optimize(AST_SimpleStatement, function(self, compressor) {
  17564. if (compressor.option("side_effects")) {
  17565. var body = self.body;
  17566. var node = body.drop_side_effect_free(compressor, true);
  17567. if (!node) {
  17568. return make_node(AST_EmptyStatement, self);
  17569. }
  17570. if (node !== body) {
  17571. return make_node(AST_SimpleStatement, self, { body: node });
  17572. }
  17573. }
  17574. return self;
  17575. });
  17576. def_optimize(AST_While, function(self, compressor) {
  17577. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  17578. });
  17579. def_optimize(AST_Do, function(self, compressor) {
  17580. if (!compressor.option("loops")) return self;
  17581. var cond = self.condition.tail_node().evaluate(compressor);
  17582. if (!(cond instanceof AST_Node)) {
  17583. if (cond) return make_node(AST_For, self, {
  17584. body: make_node(AST_BlockStatement, self.body, {
  17585. body: [
  17586. self.body,
  17587. make_node(AST_SimpleStatement, self.condition, {
  17588. body: self.condition
  17589. })
  17590. ]
  17591. })
  17592. }).optimize(compressor);
  17593. if (!has_break_or_continue(self, compressor.parent())) {
  17594. return make_node(AST_BlockStatement, self.body, {
  17595. body: [
  17596. self.body,
  17597. make_node(AST_SimpleStatement, self.condition, {
  17598. body: self.condition
  17599. })
  17600. ]
  17601. }).optimize(compressor);
  17602. }
  17603. }
  17604. return self;
  17605. });
  17606. function if_break_in_loop(self, compressor) {
  17607. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  17608. if (compressor.option("dead_code") && is_break(first)) {
  17609. var body = [];
  17610. if (self.init instanceof AST_Statement) {
  17611. body.push(self.init);
  17612. } else if (self.init) {
  17613. body.push(make_node(AST_SimpleStatement, self.init, {
  17614. body: self.init
  17615. }));
  17616. }
  17617. if (self.condition) {
  17618. body.push(make_node(AST_SimpleStatement, self.condition, {
  17619. body: self.condition
  17620. }));
  17621. }
  17622. trim_unreachable_code(compressor, self.body, body);
  17623. return make_node(AST_BlockStatement, self, {
  17624. body: body
  17625. });
  17626. }
  17627. if (first instanceof AST_If) {
  17628. if (is_break(first.body)) {
  17629. if (self.condition) {
  17630. self.condition = make_node(AST_Binary, self.condition, {
  17631. left: self.condition,
  17632. operator: "&&",
  17633. right: first.condition.negate(compressor),
  17634. });
  17635. } else {
  17636. self.condition = first.condition.negate(compressor);
  17637. }
  17638. drop_it(first.alternative);
  17639. } else if (is_break(first.alternative)) {
  17640. if (self.condition) {
  17641. self.condition = make_node(AST_Binary, self.condition, {
  17642. left: self.condition,
  17643. operator: "&&",
  17644. right: first.condition,
  17645. });
  17646. } else {
  17647. self.condition = first.condition;
  17648. }
  17649. drop_it(first.body);
  17650. }
  17651. }
  17652. return self;
  17653. function is_break(node) {
  17654. return node instanceof AST_Break
  17655. && compressor.loopcontrol_target(node) === compressor.self();
  17656. }
  17657. function drop_it(rest) {
  17658. rest = as_statement_array(rest);
  17659. if (self.body instanceof AST_BlockStatement) {
  17660. self.body = self.body.clone();
  17661. self.body.body = rest.concat(self.body.body.slice(1));
  17662. self.body = self.body.transform(compressor);
  17663. } else {
  17664. self.body = make_node(AST_BlockStatement, self.body, {
  17665. body: rest
  17666. }).transform(compressor);
  17667. }
  17668. self = if_break_in_loop(self, compressor);
  17669. }
  17670. }
  17671. def_optimize(AST_For, function(self, compressor) {
  17672. if (!compressor.option("loops")) return self;
  17673. if (compressor.option("side_effects") && self.init) {
  17674. self.init = self.init.drop_side_effect_free(compressor);
  17675. }
  17676. if (self.condition) {
  17677. var cond = self.condition.evaluate(compressor);
  17678. if (!(cond instanceof AST_Node)) {
  17679. if (cond) self.condition = null;
  17680. else if (!compressor.option("dead_code")) {
  17681. var orig = self.condition;
  17682. self.condition = make_node_from_constant(cond, self.condition);
  17683. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17684. }
  17685. }
  17686. if (compressor.option("dead_code")) {
  17687. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17688. if (!cond) {
  17689. var body = [];
  17690. trim_unreachable_code(compressor, self.body, body);
  17691. if (self.init instanceof AST_Statement) {
  17692. body.push(self.init);
  17693. } else if (self.init) {
  17694. body.push(make_node(AST_SimpleStatement, self.init, {
  17695. body: self.init
  17696. }));
  17697. }
  17698. body.push(make_node(AST_SimpleStatement, self.condition, {
  17699. body: self.condition
  17700. }));
  17701. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17702. }
  17703. }
  17704. }
  17705. return if_break_in_loop(self, compressor);
  17706. });
  17707. def_optimize(AST_If, function(self, compressor) {
  17708. if (is_empty(self.alternative)) self.alternative = null;
  17709. if (!compressor.option("conditionals")) return self;
  17710. // if condition can be statically determined, drop
  17711. // one of the blocks. note, statically determined implies
  17712. // “has no side effects”; also it doesn't work for cases like
  17713. // `x && true`, though it probably should.
  17714. var cond = self.condition.evaluate(compressor);
  17715. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  17716. var orig = self.condition;
  17717. self.condition = make_node_from_constant(cond, orig);
  17718. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17719. }
  17720. if (compressor.option("dead_code")) {
  17721. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17722. if (!cond) {
  17723. var body = [];
  17724. trim_unreachable_code(compressor, self.body, body);
  17725. body.push(make_node(AST_SimpleStatement, self.condition, {
  17726. body: self.condition
  17727. }));
  17728. if (self.alternative) body.push(self.alternative);
  17729. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17730. } else if (!(cond instanceof AST_Node)) {
  17731. var body = [];
  17732. body.push(make_node(AST_SimpleStatement, self.condition, {
  17733. body: self.condition
  17734. }));
  17735. body.push(self.body);
  17736. if (self.alternative) {
  17737. trim_unreachable_code(compressor, self.alternative, body);
  17738. }
  17739. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17740. }
  17741. }
  17742. var negated = self.condition.negate(compressor);
  17743. var self_condition_length = self.condition.size();
  17744. var negated_length = negated.size();
  17745. var negated_is_best = negated_length < self_condition_length;
  17746. if (self.alternative && negated_is_best) {
  17747. negated_is_best = false; // because we already do the switch here.
  17748. // no need to swap values of self_condition_length and negated_length
  17749. // here because they are only used in an equality comparison later on.
  17750. self.condition = negated;
  17751. var tmp = self.body;
  17752. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  17753. self.alternative = tmp;
  17754. }
  17755. if (is_empty(self.body) && is_empty(self.alternative)) {
  17756. return make_node(AST_SimpleStatement, self.condition, {
  17757. body: self.condition.clone()
  17758. }).optimize(compressor);
  17759. }
  17760. if (self.body instanceof AST_SimpleStatement
  17761. && self.alternative instanceof AST_SimpleStatement) {
  17762. return make_node(AST_SimpleStatement, self, {
  17763. body: make_node(AST_Conditional, self, {
  17764. condition : self.condition,
  17765. consequent : self.body.body,
  17766. alternative : self.alternative.body
  17767. })
  17768. }).optimize(compressor);
  17769. }
  17770. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  17771. if (self_condition_length === negated_length && !negated_is_best
  17772. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  17773. // although the code length of self.condition and negated are the same,
  17774. // negated does not require additional surrounding parentheses.
  17775. // see https://github.com/mishoo/UglifyJS2/issues/979
  17776. negated_is_best = true;
  17777. }
  17778. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  17779. body: make_node(AST_Binary, self, {
  17780. operator : "||",
  17781. left : negated,
  17782. right : self.body.body
  17783. })
  17784. }).optimize(compressor);
  17785. return make_node(AST_SimpleStatement, self, {
  17786. body: make_node(AST_Binary, self, {
  17787. operator : "&&",
  17788. left : self.condition,
  17789. right : self.body.body
  17790. })
  17791. }).optimize(compressor);
  17792. }
  17793. if (self.body instanceof AST_EmptyStatement
  17794. && self.alternative instanceof AST_SimpleStatement) {
  17795. return make_node(AST_SimpleStatement, self, {
  17796. body: make_node(AST_Binary, self, {
  17797. operator : "||",
  17798. left : self.condition,
  17799. right : self.alternative.body
  17800. })
  17801. }).optimize(compressor);
  17802. }
  17803. if (self.body instanceof AST_Exit
  17804. && self.alternative instanceof AST_Exit
  17805. && self.body.TYPE == self.alternative.TYPE) {
  17806. return make_node(self.body.CTOR, self, {
  17807. value: make_node(AST_Conditional, self, {
  17808. condition : self.condition,
  17809. consequent : self.body.value || make_node(AST_Undefined, self.body),
  17810. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  17811. }).transform(compressor)
  17812. }).optimize(compressor);
  17813. }
  17814. if (self.body instanceof AST_If
  17815. && !self.body.alternative
  17816. && !self.alternative) {
  17817. self = make_node(AST_If, self, {
  17818. condition: make_node(AST_Binary, self.condition, {
  17819. operator: "&&",
  17820. left: self.condition,
  17821. right: self.body.condition
  17822. }),
  17823. body: self.body.body,
  17824. alternative: null
  17825. });
  17826. }
  17827. if (aborts(self.body)) {
  17828. if (self.alternative) {
  17829. var alt = self.alternative;
  17830. self.alternative = null;
  17831. return make_node(AST_BlockStatement, self, {
  17832. body: [ self, alt ]
  17833. }).optimize(compressor);
  17834. }
  17835. }
  17836. if (aborts(self.alternative)) {
  17837. var body = self.body;
  17838. self.body = self.alternative;
  17839. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  17840. self.alternative = null;
  17841. return make_node(AST_BlockStatement, self, {
  17842. body: [ self, body ]
  17843. }).optimize(compressor);
  17844. }
  17845. return self;
  17846. });
  17847. def_optimize(AST_Switch, function(self, compressor) {
  17848. if (!compressor.option("switches")) return self;
  17849. var branch;
  17850. var value = self.expression.evaluate(compressor);
  17851. if (!(value instanceof AST_Node)) {
  17852. var orig = self.expression;
  17853. self.expression = make_node_from_constant(value, orig);
  17854. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  17855. }
  17856. if (!compressor.option("dead_code")) return self;
  17857. if (value instanceof AST_Node) {
  17858. value = self.expression.tail_node().evaluate(compressor);
  17859. }
  17860. var decl = [];
  17861. var body = [];
  17862. var default_branch;
  17863. var exact_match;
  17864. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  17865. branch = self.body[i];
  17866. if (branch instanceof AST_Default) {
  17867. if (!default_branch) {
  17868. default_branch = branch;
  17869. } else {
  17870. eliminate_branch(branch, body[body.length - 1]);
  17871. }
  17872. } else if (!(value instanceof AST_Node)) {
  17873. var exp = branch.expression.evaluate(compressor);
  17874. if (!(exp instanceof AST_Node) && exp !== value) {
  17875. eliminate_branch(branch, body[body.length - 1]);
  17876. continue;
  17877. }
  17878. if (exp instanceof AST_Node && !exp.has_side_effects(compressor)) {
  17879. exp = branch.expression.tail_node().evaluate(compressor);
  17880. }
  17881. if (exp === value) {
  17882. exact_match = branch;
  17883. if (default_branch) {
  17884. var default_index = body.indexOf(default_branch);
  17885. body.splice(default_index, 1);
  17886. eliminate_branch(default_branch, body[default_index - 1]);
  17887. default_branch = null;
  17888. }
  17889. }
  17890. }
  17891. body.push(branch);
  17892. }
  17893. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  17894. self.body = body;
  17895. let default_or_exact = default_branch || exact_match;
  17896. default_branch = null;
  17897. exact_match = null;
  17898. // group equivalent branches so they will be located next to each other,
  17899. // that way the next micro-optimization will merge them.
  17900. // ** bail micro-optimization if not a simple switch case with breaks
  17901. if (body.every((branch, i) =>
  17902. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  17903. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  17904. ) {
  17905. for (let i = 0; i < body.length; i++) {
  17906. const branch = body[i];
  17907. for (let j = i + 1; j < body.length; j++) {
  17908. const next = body[j];
  17909. if (next.body.length === 0) continue;
  17910. const last_branch = j === (body.length - 1);
  17911. const equivalentBranch = branches_equivalent(next, branch, false);
  17912. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  17913. if (!equivalentBranch && last_branch) {
  17914. next.body.push(make_node(AST_Break));
  17915. }
  17916. // let's find previous siblings with inert fallthrough...
  17917. let x = j - 1;
  17918. let fallthroughDepth = 0;
  17919. while (x > i) {
  17920. if (is_inert_body(body[x--])) {
  17921. fallthroughDepth++;
  17922. } else {
  17923. break;
  17924. }
  17925. }
  17926. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  17927. body.splice(i + 1, 0, ...plucked);
  17928. i += plucked.length;
  17929. }
  17930. }
  17931. }
  17932. }
  17933. // merge equivalent branches in a row
  17934. for (let i = 0; i < body.length; i++) {
  17935. let branch = body[i];
  17936. if (branch.body.length === 0) continue;
  17937. if (!aborts(branch)) continue;
  17938. for (let j = i + 1; j < body.length; i++, j++) {
  17939. let next = body[j];
  17940. if (next.body.length === 0) continue;
  17941. if (
  17942. branches_equivalent(next, branch, false)
  17943. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  17944. ) {
  17945. branch.body = [];
  17946. branch = next;
  17947. continue;
  17948. }
  17949. break;
  17950. }
  17951. }
  17952. // Prune any empty branches at the end of the switch statement.
  17953. {
  17954. let i = body.length - 1;
  17955. for (; i >= 0; i--) {
  17956. let bbody = body[i].body;
  17957. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  17958. if (!is_inert_body(body[i])) break;
  17959. }
  17960. // i now points to the index of a branch that contains a body. By incrementing, it's
  17961. // pointing to the first branch that's empty.
  17962. i++;
  17963. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  17964. // The default behavior is to do nothing. We can take advantage of that to
  17965. // remove all case expressions that are side-effect free that also do
  17966. // nothing, since they'll default to doing nothing. But we can't remove any
  17967. // case expressions before one that would side-effect, since they may cause
  17968. // the side-effect to be skipped.
  17969. for (let j = body.length - 1; j >= i; j--) {
  17970. let branch = body[j];
  17971. if (branch === default_or_exact) {
  17972. default_or_exact = null;
  17973. body.pop();
  17974. } else if (!branch.expression.has_side_effects(compressor)) {
  17975. body.pop();
  17976. } else {
  17977. break;
  17978. }
  17979. }
  17980. }
  17981. }
  17982. // Prune side-effect free branches that fall into default.
  17983. DEFAULT: if (default_or_exact) {
  17984. let default_index = body.indexOf(default_or_exact);
  17985. let default_body_index = default_index;
  17986. for (; default_body_index < body.length - 1; default_body_index++) {
  17987. if (!is_inert_body(body[default_body_index])) break;
  17988. }
  17989. if (default_body_index < body.length - 1) {
  17990. break DEFAULT;
  17991. }
  17992. let side_effect_index = body.length - 1;
  17993. for (; side_effect_index >= 0; side_effect_index--) {
  17994. let branch = body[side_effect_index];
  17995. if (branch === default_or_exact) continue;
  17996. if (branch.expression.has_side_effects(compressor)) break;
  17997. }
  17998. // If the default behavior comes after any side-effect case expressions,
  17999. // then we can fold all side-effect free cases into the default branch.
  18000. // If the side-effect case is after the default, then any side-effect
  18001. // free cases could prevent the side-effect from occurring.
  18002. if (default_body_index > side_effect_index) {
  18003. let prev_body_index = default_index - 1;
  18004. for (; prev_body_index >= 0; prev_body_index--) {
  18005. if (!is_inert_body(body[prev_body_index])) break;
  18006. }
  18007. let before = Math.max(side_effect_index, prev_body_index) + 1;
  18008. let after = default_index;
  18009. if (side_effect_index > default_index) {
  18010. // If the default falls into the same body as a side-effect
  18011. // case, then we need preserve that case and only prune the
  18012. // cases after it.
  18013. after = side_effect_index;
  18014. body[side_effect_index].body = body[default_body_index].body;
  18015. } else {
  18016. // The default will be the last branch.
  18017. default_or_exact.body = body[default_body_index].body;
  18018. }
  18019. // Prune everything after the default (or last side-effect case)
  18020. // until the next case with a body.
  18021. body.splice(after + 1, default_body_index - after);
  18022. // Prune everything before the default that falls into it.
  18023. body.splice(before, default_index - before);
  18024. }
  18025. }
  18026. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  18027. DEFAULT: if (default_or_exact) {
  18028. let i = body.findIndex(branch => !is_inert_body(branch));
  18029. let caseBody;
  18030. // `i` is equal to one of the following:
  18031. // - `-1`, there is no body in the switch statement.
  18032. // - `body.length - 1`, all cases fall into the same body.
  18033. // - anything else, there are multiple bodies in the switch.
  18034. if (i === body.length - 1) {
  18035. // All cases fall into the case body.
  18036. let branch = body[i];
  18037. if (has_nested_break(self)) break DEFAULT;
  18038. // This is the last case body, and we've already pruned any breaks, so it's
  18039. // safe to hoist.
  18040. caseBody = make_node(AST_BlockStatement, branch, {
  18041. body: branch.body
  18042. });
  18043. branch.body = [];
  18044. } else if (i !== -1) {
  18045. // If there are multiple bodies, then we cannot optimize anything.
  18046. break DEFAULT;
  18047. }
  18048. let sideEffect = body.find(
  18049. branch => branch !== default_or_exact && branch.expression.has_side_effects(compressor)
  18050. );
  18051. // If no cases cause a side-effect, we can eliminate the switch entirely.
  18052. if (!sideEffect) {
  18053. return make_node(AST_BlockStatement, self, {
  18054. body: decl.concat(
  18055. statement(self.expression),
  18056. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  18057. caseBody || []
  18058. )
  18059. }).optimize(compressor);
  18060. }
  18061. // If we're this far, either there was no body or all cases fell into the same body.
  18062. // If there was no body, then we don't need a default branch (because the default is
  18063. // do nothing). If there was a body, we'll extract it to after the switch, so the
  18064. // switch's new default is to do nothing and we can still prune it.
  18065. const default_index = body.indexOf(default_or_exact);
  18066. body.splice(default_index, 1);
  18067. default_or_exact = null;
  18068. if (caseBody) {
  18069. // Recurse into switch statement one more time so that we can append the case body
  18070. // outside of the switch. This recursion will only happen once since we've pruned
  18071. // the default case.
  18072. return make_node(AST_BlockStatement, self, {
  18073. body: decl.concat(self, caseBody)
  18074. }).optimize(compressor);
  18075. }
  18076. // If we fall here, there is a default branch somewhere, there are no case bodies,
  18077. // and there's a side-effect somewhere. Just let the below paths take care of it.
  18078. }
  18079. if (body.length > 0) {
  18080. body[0].body = decl.concat(body[0].body);
  18081. }
  18082. if (body.length == 0) {
  18083. return make_node(AST_BlockStatement, self, {
  18084. body: decl.concat(statement(self.expression))
  18085. }).optimize(compressor);
  18086. }
  18087. if (body.length == 1 && !has_nested_break(self)) {
  18088. // This is the last case body, and we've already pruned any breaks, so it's
  18089. // safe to hoist.
  18090. let branch = body[0];
  18091. return make_node(AST_If, self, {
  18092. condition: make_node(AST_Binary, self, {
  18093. operator: "===",
  18094. left: self.expression,
  18095. right: branch.expression,
  18096. }),
  18097. body: make_node(AST_BlockStatement, branch, {
  18098. body: branch.body
  18099. }),
  18100. alternative: null
  18101. }).optimize(compressor);
  18102. }
  18103. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  18104. let branch = body[0] === default_or_exact ? body[1] : body[0];
  18105. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  18106. if (aborts(body[0])) {
  18107. // Only the first branch body could have a break (at the last statement)
  18108. let first = body[0];
  18109. if (is_break(first.body[first.body.length - 1], compressor)) {
  18110. first.body.pop();
  18111. }
  18112. return make_node(AST_If, self, {
  18113. condition: make_node(AST_Binary, self, {
  18114. operator: "===",
  18115. left: self.expression,
  18116. right: branch.expression,
  18117. }),
  18118. body: make_node(AST_BlockStatement, branch, {
  18119. body: branch.body
  18120. }),
  18121. alternative: make_node(AST_BlockStatement, default_or_exact, {
  18122. body: [].concat(
  18123. exact_exp || [],
  18124. default_or_exact.body
  18125. )
  18126. })
  18127. }).optimize(compressor);
  18128. }
  18129. let operator = "===";
  18130. let consequent = make_node(AST_BlockStatement, branch, {
  18131. body: branch.body,
  18132. });
  18133. let always = make_node(AST_BlockStatement, default_or_exact, {
  18134. body: [].concat(
  18135. exact_exp || [],
  18136. default_or_exact.body
  18137. )
  18138. });
  18139. if (body[0] === default_or_exact) {
  18140. operator = "!==";
  18141. let tmp = always;
  18142. always = consequent;
  18143. consequent = tmp;
  18144. }
  18145. return make_node(AST_BlockStatement, self, {
  18146. body: [
  18147. make_node(AST_If, self, {
  18148. condition: make_node(AST_Binary, self, {
  18149. operator: operator,
  18150. left: self.expression,
  18151. right: branch.expression,
  18152. }),
  18153. body: consequent,
  18154. alternative: null,
  18155. }),
  18156. always,
  18157. ],
  18158. }).optimize(compressor);
  18159. }
  18160. return self;
  18161. function eliminate_branch(branch, prev) {
  18162. if (prev && !aborts(prev)) {
  18163. prev.body = prev.body.concat(branch.body);
  18164. } else {
  18165. trim_unreachable_code(compressor, branch, decl);
  18166. }
  18167. }
  18168. function branches_equivalent(branch, prev, insertBreak) {
  18169. let bbody = branch.body;
  18170. let pbody = prev.body;
  18171. if (insertBreak) {
  18172. bbody = bbody.concat(make_node(AST_Break));
  18173. }
  18174. if (bbody.length !== pbody.length) return false;
  18175. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  18176. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  18177. return bblock.equivalent_to(pblock);
  18178. }
  18179. function statement(body) {
  18180. return make_node(AST_SimpleStatement, body, { body });
  18181. }
  18182. function has_nested_break(root) {
  18183. let has_break = false;
  18184. let tw = new TreeWalker(node => {
  18185. if (has_break) return true;
  18186. if (node instanceof AST_Lambda) return true;
  18187. if (node instanceof AST_SimpleStatement) return true;
  18188. if (!is_break(node, tw)) return;
  18189. let parent = tw.parent();
  18190. if (
  18191. parent instanceof AST_SwitchBranch
  18192. && parent.body[parent.body.length - 1] === node
  18193. ) {
  18194. return;
  18195. }
  18196. has_break = true;
  18197. });
  18198. root.walk(tw);
  18199. return has_break;
  18200. }
  18201. function is_break(node, stack) {
  18202. return node instanceof AST_Break
  18203. && stack.loopcontrol_target(node) === self;
  18204. }
  18205. function is_inert_body(branch) {
  18206. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  18207. body: branch.body
  18208. }).has_side_effects(compressor);
  18209. }
  18210. });
  18211. def_optimize(AST_Try, function(self, compressor) {
  18212. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  18213. if (compressor.option("dead_code") && self.body.body.every(is_empty)) {
  18214. var body = [];
  18215. if (self.bcatch) {
  18216. trim_unreachable_code(compressor, self.bcatch, body);
  18217. }
  18218. if (self.bfinally) body.push(...self.bfinally.body);
  18219. return make_node(AST_BlockStatement, self, {
  18220. body: body
  18221. }).optimize(compressor);
  18222. }
  18223. return self;
  18224. });
  18225. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  18226. var reduce_vars = compressor.option("reduce_vars");
  18227. var assignments = [];
  18228. for (const def of this.definitions) {
  18229. if (def.value) {
  18230. var name = make_node(AST_SymbolRef, def.name, def.name);
  18231. assignments.push(make_node(AST_Assign, def, {
  18232. operator : "=",
  18233. logical: false,
  18234. left : name,
  18235. right : def.value
  18236. }));
  18237. if (reduce_vars) name.definition().fixed = false;
  18238. }
  18239. const thedef = def.name.definition();
  18240. thedef.eliminated++;
  18241. thedef.replaced--;
  18242. }
  18243. if (assignments.length == 0) return null;
  18244. return make_sequence(this, assignments);
  18245. });
  18246. def_optimize(AST_Definitions, function(self) {
  18247. if (self.definitions.length == 0) {
  18248. return make_node(AST_EmptyStatement, self);
  18249. }
  18250. return self;
  18251. });
  18252. def_optimize(AST_VarDef, function(self, compressor) {
  18253. if (
  18254. self.name instanceof AST_SymbolLet
  18255. && self.value != null
  18256. && is_undefined(self.value, compressor)
  18257. ) {
  18258. self.value = null;
  18259. }
  18260. return self;
  18261. });
  18262. def_optimize(AST_Import, function(self) {
  18263. return self;
  18264. });
  18265. def_optimize(AST_Call, function(self, compressor) {
  18266. var exp = self.expression;
  18267. var fn = exp;
  18268. inline_array_like_spread(self.args);
  18269. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  18270. if (compressor.option("reduce_vars") && fn instanceof AST_SymbolRef) {
  18271. fn = fn.fixed_value();
  18272. }
  18273. var is_func = fn instanceof AST_Lambda;
  18274. if (is_func && fn.pinned()) return self;
  18275. if (compressor.option("unused")
  18276. && simple_args
  18277. && is_func
  18278. && !fn.uses_arguments) {
  18279. var pos = 0, last = 0;
  18280. for (var i = 0, len = self.args.length; i < len; i++) {
  18281. if (fn.argnames[i] instanceof AST_Expansion) {
  18282. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  18283. var node = self.args[i++].drop_side_effect_free(compressor);
  18284. if (node) {
  18285. self.args[pos++] = node;
  18286. }
  18287. } else while (i < len) {
  18288. self.args[pos++] = self.args[i++];
  18289. }
  18290. last = pos;
  18291. break;
  18292. }
  18293. var trim = i >= fn.argnames.length;
  18294. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  18295. var node = self.args[i].drop_side_effect_free(compressor);
  18296. if (node) {
  18297. self.args[pos++] = node;
  18298. } else if (!trim) {
  18299. self.args[pos++] = make_node(AST_Number, self.args[i], {
  18300. value: 0
  18301. });
  18302. continue;
  18303. }
  18304. } else {
  18305. self.args[pos++] = self.args[i];
  18306. }
  18307. last = pos;
  18308. }
  18309. self.args.length = last;
  18310. }
  18311. if (
  18312. exp instanceof AST_Dot
  18313. && exp.expression instanceof AST_SymbolRef
  18314. && exp.expression.name === "console"
  18315. && exp.expression.definition().undeclared
  18316. && exp.property === "assert"
  18317. ) {
  18318. const condition = self.args[0];
  18319. if (condition) {
  18320. const value = condition.evaluate(compressor);
  18321. if (value === 1 || value === true) {
  18322. return make_node(AST_Undefined, self);
  18323. }
  18324. }
  18325. }
  18326. if (compressor.option("unsafe") && !exp.contains_optional()) {
  18327. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  18328. const [argument] = self.args;
  18329. if (argument instanceof AST_Array) {
  18330. return make_node(AST_Array, argument, {
  18331. elements: argument.elements
  18332. }).optimize(compressor);
  18333. }
  18334. }
  18335. if (is_undeclared_ref(exp)) switch (exp.name) {
  18336. case "Array":
  18337. if (self.args.length != 1) {
  18338. return make_node(AST_Array, self, {
  18339. elements: self.args
  18340. }).optimize(compressor);
  18341. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  18342. const elements = [];
  18343. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  18344. return new AST_Array({ elements });
  18345. }
  18346. break;
  18347. case "Object":
  18348. if (self.args.length == 0) {
  18349. return make_node(AST_Object, self, {
  18350. properties: []
  18351. });
  18352. }
  18353. break;
  18354. case "String":
  18355. if (self.args.length == 0) return make_node(AST_String, self, {
  18356. value: ""
  18357. });
  18358. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  18359. left: self.args[0],
  18360. operator: "+",
  18361. right: make_node(AST_String, self, { value: "" })
  18362. }).optimize(compressor);
  18363. break;
  18364. case "Number":
  18365. if (self.args.length == 0) return make_node(AST_Number, self, {
  18366. value: 0
  18367. });
  18368. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  18369. return make_node(AST_UnaryPrefix, self, {
  18370. expression: self.args[0],
  18371. operator: "+"
  18372. }).optimize(compressor);
  18373. }
  18374. break;
  18375. case "Symbol":
  18376. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  18377. self.args.length = 0;
  18378. break;
  18379. case "Boolean":
  18380. if (self.args.length == 0) return make_node(AST_False, self);
  18381. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  18382. expression: make_node(AST_UnaryPrefix, self, {
  18383. expression: self.args[0],
  18384. operator: "!"
  18385. }),
  18386. operator: "!"
  18387. }).optimize(compressor);
  18388. break;
  18389. case "RegExp":
  18390. var params = [];
  18391. if (self.args.length >= 1
  18392. && self.args.length <= 2
  18393. && self.args.every((arg) => {
  18394. var value = arg.evaluate(compressor);
  18395. params.push(value);
  18396. return arg !== value;
  18397. })
  18398. && regexp_is_safe(params[0])
  18399. ) {
  18400. let [ source, flags ] = params;
  18401. source = regexp_source_fix(new RegExp(source).source);
  18402. const rx = make_node(AST_RegExp, self, {
  18403. value: { source, flags }
  18404. });
  18405. if (rx._eval(compressor) !== rx) {
  18406. return rx;
  18407. }
  18408. }
  18409. break;
  18410. } else if (exp instanceof AST_Dot) switch(exp.property) {
  18411. case "toString":
  18412. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  18413. return make_node(AST_Binary, self, {
  18414. left: make_node(AST_String, self, { value: "" }),
  18415. operator: "+",
  18416. right: exp.expression
  18417. }).optimize(compressor);
  18418. }
  18419. break;
  18420. case "join":
  18421. if (exp.expression instanceof AST_Array) EXIT: {
  18422. var separator;
  18423. if (self.args.length > 0) {
  18424. separator = self.args[0].evaluate(compressor);
  18425. if (separator === self.args[0]) break EXIT; // not a constant
  18426. }
  18427. var elements = [];
  18428. var consts = [];
  18429. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  18430. var el = exp.expression.elements[i];
  18431. if (el instanceof AST_Expansion) break EXIT;
  18432. var value = el.evaluate(compressor);
  18433. if (value !== el) {
  18434. consts.push(value);
  18435. } else {
  18436. if (consts.length > 0) {
  18437. elements.push(make_node(AST_String, self, {
  18438. value: consts.join(separator)
  18439. }));
  18440. consts.length = 0;
  18441. }
  18442. elements.push(el);
  18443. }
  18444. }
  18445. if (consts.length > 0) {
  18446. elements.push(make_node(AST_String, self, {
  18447. value: consts.join(separator)
  18448. }));
  18449. }
  18450. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  18451. if (elements.length == 1) {
  18452. if (elements[0].is_string(compressor)) {
  18453. return elements[0];
  18454. }
  18455. return make_node(AST_Binary, elements[0], {
  18456. operator : "+",
  18457. left : make_node(AST_String, self, { value: "" }),
  18458. right : elements[0]
  18459. });
  18460. }
  18461. if (separator == "") {
  18462. var first;
  18463. if (elements[0].is_string(compressor)
  18464. || elements[1].is_string(compressor)) {
  18465. first = elements.shift();
  18466. } else {
  18467. first = make_node(AST_String, self, { value: "" });
  18468. }
  18469. return elements.reduce(function(prev, el) {
  18470. return make_node(AST_Binary, el, {
  18471. operator : "+",
  18472. left : prev,
  18473. right : el
  18474. });
  18475. }, first).optimize(compressor);
  18476. }
  18477. // need this awkward cloning to not affect original element
  18478. // best_of will decide which one to get through.
  18479. var node = self.clone();
  18480. node.expression = node.expression.clone();
  18481. node.expression.expression = node.expression.expression.clone();
  18482. node.expression.expression.elements = elements;
  18483. return best_of(compressor, self, node);
  18484. }
  18485. break;
  18486. case "charAt":
  18487. if (exp.expression.is_string(compressor)) {
  18488. var arg = self.args[0];
  18489. var index = arg ? arg.evaluate(compressor) : 0;
  18490. if (index !== arg) {
  18491. return make_node(AST_Sub, exp, {
  18492. expression: exp.expression,
  18493. property: make_node_from_constant(index | 0, arg || exp)
  18494. }).optimize(compressor);
  18495. }
  18496. }
  18497. break;
  18498. case "apply":
  18499. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  18500. var args = self.args[1].elements.slice();
  18501. args.unshift(self.args[0]);
  18502. return make_node(AST_Call, self, {
  18503. expression: make_node(AST_Dot, exp, {
  18504. expression: exp.expression,
  18505. optional: false,
  18506. property: "call"
  18507. }),
  18508. args: args
  18509. }).optimize(compressor);
  18510. }
  18511. break;
  18512. case "call":
  18513. var func = exp.expression;
  18514. if (func instanceof AST_SymbolRef) {
  18515. func = func.fixed_value();
  18516. }
  18517. if (func instanceof AST_Lambda && !func.contains_this()) {
  18518. return (self.args.length ? make_sequence(this, [
  18519. self.args[0],
  18520. make_node(AST_Call, self, {
  18521. expression: exp.expression,
  18522. args: self.args.slice(1)
  18523. })
  18524. ]) : make_node(AST_Call, self, {
  18525. expression: exp.expression,
  18526. args: []
  18527. })).optimize(compressor);
  18528. }
  18529. break;
  18530. }
  18531. }
  18532. if (compressor.option("unsafe_Function")
  18533. && is_undeclared_ref(exp)
  18534. && exp.name == "Function") {
  18535. // new Function() => function(){}
  18536. if (self.args.length == 0) return make_empty_function(self).optimize(compressor);
  18537. if (self.args.every((x) => x instanceof AST_String)) {
  18538. // quite a corner-case, but we can handle it:
  18539. // https://github.com/mishoo/UglifyJS2/issues/203
  18540. // if the code argument is a constant, then we can minify it.
  18541. try {
  18542. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  18543. return arg.value;
  18544. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  18545. var ast = parse(code);
  18546. var mangle = compressor.mangle_options();
  18547. ast.figure_out_scope(mangle);
  18548. var comp = new Compressor(compressor.options, {
  18549. mangle_options: compressor._mangle_options
  18550. });
  18551. ast = ast.transform(comp);
  18552. ast.figure_out_scope(mangle);
  18553. ast.compute_char_frequency(mangle);
  18554. ast.mangle_names(mangle);
  18555. var fun;
  18556. walk(ast, node => {
  18557. if (is_func_expr(node)) {
  18558. fun = node;
  18559. return walk_abort;
  18560. }
  18561. });
  18562. var code = OutputStream();
  18563. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  18564. self.args = [
  18565. make_node(AST_String, self, {
  18566. value: fun.argnames.map(function(arg) {
  18567. return arg.print_to_string();
  18568. }).join(",")
  18569. }),
  18570. make_node(AST_String, self.args[self.args.length - 1], {
  18571. value: code.get().replace(/^{|}$/g, "")
  18572. })
  18573. ];
  18574. return self;
  18575. } catch (ex) {
  18576. if (!(ex instanceof JS_Parse_Error)) {
  18577. throw ex;
  18578. }
  18579. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  18580. }
  18581. }
  18582. }
  18583. return inline_into_call(self, compressor);
  18584. });
  18585. /** Does this node contain optional property access or optional call? */
  18586. AST_Node.DEFMETHOD("contains_optional", function() {
  18587. if (
  18588. this instanceof AST_PropAccess
  18589. || this instanceof AST_Call
  18590. || this instanceof AST_Chain
  18591. ) {
  18592. if (this.optional) {
  18593. return true;
  18594. } else {
  18595. return this.expression.contains_optional();
  18596. }
  18597. } else {
  18598. return false;
  18599. }
  18600. });
  18601. def_optimize(AST_New, function(self, compressor) {
  18602. if (
  18603. compressor.option("unsafe") &&
  18604. is_undeclared_ref(self.expression) &&
  18605. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  18606. ) return make_node(AST_Call, self, self).transform(compressor);
  18607. return self;
  18608. });
  18609. def_optimize(AST_Sequence, function(self, compressor) {
  18610. if (!compressor.option("side_effects")) return self;
  18611. var expressions = [];
  18612. filter_for_side_effects();
  18613. var end = expressions.length - 1;
  18614. trim_right_for_undefined();
  18615. if (end == 0) {
  18616. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  18617. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  18618. return self;
  18619. }
  18620. self.expressions = expressions;
  18621. return self;
  18622. function filter_for_side_effects() {
  18623. var first = first_in_statement(compressor);
  18624. var last = self.expressions.length - 1;
  18625. self.expressions.forEach(function(expr, index) {
  18626. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  18627. if (expr) {
  18628. merge_sequence(expressions, expr);
  18629. first = false;
  18630. }
  18631. });
  18632. }
  18633. function trim_right_for_undefined() {
  18634. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  18635. if (end < expressions.length - 1) {
  18636. expressions[end] = make_node(AST_UnaryPrefix, self, {
  18637. operator : "void",
  18638. expression : expressions[end]
  18639. });
  18640. expressions.length = end + 1;
  18641. }
  18642. }
  18643. });
  18644. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  18645. if (compressor.option("sequences")) {
  18646. if (this.expression instanceof AST_Sequence) {
  18647. var x = this.expression.expressions.slice();
  18648. var e = this.clone();
  18649. e.expression = x.pop();
  18650. x.push(e);
  18651. return make_sequence(this, x).optimize(compressor);
  18652. }
  18653. }
  18654. return this;
  18655. });
  18656. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  18657. return self.lift_sequences(compressor);
  18658. });
  18659. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  18660. var e = self.expression;
  18661. if (
  18662. self.operator == "delete" &&
  18663. !(
  18664. e instanceof AST_SymbolRef ||
  18665. e instanceof AST_PropAccess ||
  18666. e instanceof AST_Chain ||
  18667. is_identifier_atom(e)
  18668. )
  18669. ) {
  18670. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  18671. }
  18672. var seq = self.lift_sequences(compressor);
  18673. if (seq !== self) {
  18674. return seq;
  18675. }
  18676. if (compressor.option("side_effects") && self.operator == "void") {
  18677. e = e.drop_side_effect_free(compressor);
  18678. if (e) {
  18679. self.expression = e;
  18680. return self;
  18681. } else {
  18682. return make_node(AST_Undefined, self).optimize(compressor);
  18683. }
  18684. }
  18685. if (compressor.in_boolean_context()) {
  18686. switch (self.operator) {
  18687. case "!":
  18688. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  18689. // !!foo ==> foo, if we're in boolean context
  18690. return e.expression;
  18691. }
  18692. if (e instanceof AST_Binary) {
  18693. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  18694. }
  18695. break;
  18696. case "typeof":
  18697. // typeof always returns a non-empty string, thus it's
  18698. // always true in booleans
  18699. // And we don't need to check if it's undeclared, because in typeof, that's OK
  18700. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  18701. e,
  18702. make_node(AST_True, self)
  18703. ])).optimize(compressor);
  18704. }
  18705. }
  18706. if (self.operator == "-" && e instanceof AST_Infinity) {
  18707. e = e.transform(compressor);
  18708. }
  18709. if (e instanceof AST_Binary
  18710. && (self.operator == "+" || self.operator == "-")
  18711. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  18712. return make_node(AST_Binary, self, {
  18713. operator: e.operator,
  18714. left: make_node(AST_UnaryPrefix, e.left, {
  18715. operator: self.operator,
  18716. expression: e.left
  18717. }),
  18718. right: e.right
  18719. });
  18720. }
  18721. if (compressor.option("evaluate")) {
  18722. // ~~x => x (in 32-bit context)
  18723. // ~~{32 bit integer} => {32 bit integer}
  18724. if (
  18725. self.operator === "~"
  18726. && self.expression instanceof AST_UnaryPrefix
  18727. && self.expression.operator === "~"
  18728. && (compressor.in_32_bit_context() || self.expression.expression.is_32_bit_integer())
  18729. ) {
  18730. return self.expression.expression;
  18731. }
  18732. // ~(x ^ y) => x ^ ~y
  18733. if (
  18734. self.operator === "~"
  18735. && e instanceof AST_Binary
  18736. && e.operator === "^"
  18737. ) {
  18738. if (e.left instanceof AST_UnaryPrefix && e.left.operator === "~") {
  18739. // ~(~x ^ y) => x ^ y
  18740. e.left = e.left.bitwise_negate(true);
  18741. } else {
  18742. e.right = e.right.bitwise_negate(true);
  18743. }
  18744. return e;
  18745. }
  18746. }
  18747. if (
  18748. self.operator != "-"
  18749. // avoid infinite recursion of numerals
  18750. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)
  18751. ) {
  18752. var ev = self.evaluate(compressor);
  18753. if (ev !== self) {
  18754. ev = make_node_from_constant(ev, self).optimize(compressor);
  18755. return best_of(compressor, ev, self);
  18756. }
  18757. }
  18758. return self;
  18759. });
  18760. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  18761. if (compressor.option("sequences")) {
  18762. if (this.left instanceof AST_Sequence) {
  18763. var x = this.left.expressions.slice();
  18764. var e = this.clone();
  18765. e.left = x.pop();
  18766. x.push(e);
  18767. return make_sequence(this, x).optimize(compressor);
  18768. }
  18769. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  18770. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  18771. var x = this.right.expressions;
  18772. var last = x.length - 1;
  18773. for (var i = 0; i < last; i++) {
  18774. if (!assign && x[i].has_side_effects(compressor)) break;
  18775. }
  18776. if (i == last) {
  18777. x = x.slice();
  18778. var e = this.clone();
  18779. e.right = x.pop();
  18780. x.push(e);
  18781. return make_sequence(this, x).optimize(compressor);
  18782. } else if (i > 0) {
  18783. var e = this.clone();
  18784. e.right = make_sequence(this.right, x.slice(i));
  18785. x = x.slice(0, i);
  18786. x.push(e);
  18787. return make_sequence(this, x).optimize(compressor);
  18788. }
  18789. }
  18790. }
  18791. return this;
  18792. });
  18793. var commutativeOperators = makePredicate("== === != !== * & | ^");
  18794. function is_object(node) {
  18795. return node instanceof AST_Array
  18796. || node instanceof AST_Lambda
  18797. || node instanceof AST_Object
  18798. || node instanceof AST_Class;
  18799. }
  18800. def_optimize(AST_Binary, function(self, compressor) {
  18801. function reversible() {
  18802. return self.left.is_constant()
  18803. || self.right.is_constant()
  18804. || !self.left.has_side_effects(compressor)
  18805. && !self.right.has_side_effects(compressor);
  18806. }
  18807. function reverse(op) {
  18808. if (reversible()) {
  18809. if (op) self.operator = op;
  18810. var tmp = self.left;
  18811. self.left = self.right;
  18812. self.right = tmp;
  18813. }
  18814. }
  18815. if (compressor.option("lhs_constants") && commutativeOperators.has(self.operator)) {
  18816. if (self.right.is_constant()
  18817. && !self.left.is_constant()) {
  18818. // if right is a constant, whatever side effects the
  18819. // left side might have could not influence the
  18820. // result. hence, force switch.
  18821. if (!(self.left instanceof AST_Binary
  18822. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  18823. reverse();
  18824. }
  18825. }
  18826. }
  18827. self = self.lift_sequences(compressor);
  18828. if (compressor.option("comparisons")) switch (self.operator) {
  18829. case "===":
  18830. case "!==":
  18831. var is_strict_comparison = true;
  18832. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  18833. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  18834. (self.left.is_boolean() && self.right.is_boolean()) ||
  18835. self.left.equivalent_to(self.right)) {
  18836. self.operator = self.operator.substr(0, 2);
  18837. }
  18838. // XXX: intentionally falling down to the next case
  18839. case "==":
  18840. case "!=":
  18841. // void 0 == x => null == x
  18842. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  18843. self.left = make_node(AST_Null, self.left);
  18844. // x == void 0 => x == null
  18845. } else if (!is_strict_comparison && is_undefined(self.right, compressor)) {
  18846. self.right = make_node(AST_Null, self.right);
  18847. } else if (compressor.option("typeofs")
  18848. // "undefined" == typeof x => undefined === x
  18849. && self.left instanceof AST_String
  18850. && self.left.value == "undefined"
  18851. && self.right instanceof AST_UnaryPrefix
  18852. && self.right.operator == "typeof") {
  18853. var expr = self.right.expression;
  18854. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  18855. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  18856. self.right = expr;
  18857. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  18858. if (self.operator.length == 2) self.operator += "=";
  18859. }
  18860. } else if (compressor.option("typeofs")
  18861. // typeof x === "undefined" => x === undefined
  18862. && self.left instanceof AST_UnaryPrefix
  18863. && self.left.operator == "typeof"
  18864. && self.right instanceof AST_String
  18865. && self.right.value == "undefined") {
  18866. var expr = self.left.expression;
  18867. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  18868. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  18869. self.left = expr;
  18870. self.right = make_node(AST_Undefined, self.right).optimize(compressor);
  18871. if (self.operator.length == 2) self.operator += "=";
  18872. }
  18873. } else if (self.left instanceof AST_SymbolRef
  18874. // obj !== obj => false
  18875. && self.right instanceof AST_SymbolRef
  18876. && self.left.definition() === self.right.definition()
  18877. && is_object(self.left.fixed_value())) {
  18878. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  18879. } else if (self.left.is_32_bit_integer() && self.right.is_32_bit_integer()) {
  18880. const not = node => make_node(AST_UnaryPrefix, node, {
  18881. operator: "!",
  18882. expression: node
  18883. });
  18884. const booleanify = (node, truthy) => {
  18885. if (truthy) {
  18886. return compressor.in_boolean_context()
  18887. ? node
  18888. : not(not(node));
  18889. } else {
  18890. return not(node);
  18891. }
  18892. };
  18893. // The only falsy 32-bit integer is 0
  18894. if (self.left instanceof AST_Number && self.left.value === 0) {
  18895. return booleanify(self.right, self.operator[0] === "!");
  18896. }
  18897. if (self.right instanceof AST_Number && self.right.value === 0) {
  18898. return booleanify(self.left, self.operator[0] === "!");
  18899. }
  18900. // Mask all-bits check
  18901. // (x & 0xFF) != 0xFF => !(~x & 0xFF)
  18902. let and_op, x, mask;
  18903. if (
  18904. (and_op =
  18905. self.left instanceof AST_Binary ? self.left
  18906. : self.right instanceof AST_Binary ? self.right : null)
  18907. && (mask = and_op === self.left ? self.right : self.left)
  18908. && and_op.operator === "&"
  18909. && mask instanceof AST_Number
  18910. && mask.is_32_bit_integer()
  18911. && (x =
  18912. and_op.left.equivalent_to(mask) ? and_op.right
  18913. : and_op.right.equivalent_to(mask) ? and_op.left : null)
  18914. ) {
  18915. let optimized = booleanify(make_node(AST_Binary, self, {
  18916. operator: "&",
  18917. left: mask,
  18918. right: make_node(AST_UnaryPrefix, self, {
  18919. operator: "~",
  18920. expression: x
  18921. })
  18922. }), self.operator[0] === "!");
  18923. return best_of(compressor, optimized, self);
  18924. }
  18925. }
  18926. break;
  18927. case "&&":
  18928. case "||":
  18929. var lhs = self.left;
  18930. if (lhs.operator == self.operator) {
  18931. lhs = lhs.right;
  18932. }
  18933. if (lhs instanceof AST_Binary
  18934. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  18935. && self.right instanceof AST_Binary
  18936. && lhs.operator == self.right.operator
  18937. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  18938. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  18939. && !lhs.right.has_side_effects(compressor)
  18940. && lhs.right.equivalent_to(self.right.right)) {
  18941. var combined = make_node(AST_Binary, self, {
  18942. operator: lhs.operator.slice(0, -1),
  18943. left: make_node(AST_Null, self),
  18944. right: lhs.right
  18945. });
  18946. if (lhs !== self.left) {
  18947. combined = make_node(AST_Binary, self, {
  18948. operator: self.operator,
  18949. left: self.left.left,
  18950. right: combined
  18951. });
  18952. }
  18953. return combined;
  18954. }
  18955. break;
  18956. }
  18957. if (self.operator == "+" && compressor.in_boolean_context()) {
  18958. var ll = self.left.evaluate(compressor);
  18959. var rr = self.right.evaluate(compressor);
  18960. if (ll && typeof ll == "string") {
  18961. return make_sequence(self, [
  18962. self.right,
  18963. make_node(AST_True, self)
  18964. ]).optimize(compressor);
  18965. }
  18966. if (rr && typeof rr == "string") {
  18967. return make_sequence(self, [
  18968. self.left,
  18969. make_node(AST_True, self)
  18970. ]).optimize(compressor);
  18971. }
  18972. }
  18973. if (compressor.option("comparisons") && self.is_boolean()) {
  18974. if (!(compressor.parent() instanceof AST_Binary)
  18975. || compressor.parent() instanceof AST_Assign) {
  18976. var negated = make_node(AST_UnaryPrefix, self, {
  18977. operator: "!",
  18978. expression: self.negate(compressor, first_in_statement(compressor))
  18979. });
  18980. self = best_of(compressor, self, negated);
  18981. }
  18982. if (compressor.option("unsafe_comps")) {
  18983. switch (self.operator) {
  18984. case "<": reverse(">"); break;
  18985. case "<=": reverse(">="); break;
  18986. }
  18987. }
  18988. }
  18989. if (self.operator == "+") {
  18990. if (self.right instanceof AST_String
  18991. && self.right.getValue() == ""
  18992. && self.left.is_string(compressor)) {
  18993. return self.left;
  18994. }
  18995. if (self.left instanceof AST_String
  18996. && self.left.getValue() == ""
  18997. && self.right.is_string(compressor)) {
  18998. return self.right;
  18999. }
  19000. if (self.left instanceof AST_Binary
  19001. && self.left.operator == "+"
  19002. && self.left.left instanceof AST_String
  19003. && self.left.left.getValue() == ""
  19004. && self.right.is_string(compressor)) {
  19005. self.left = self.left.right;
  19006. return self;
  19007. }
  19008. }
  19009. if (compressor.option("evaluate")) {
  19010. switch (self.operator) {
  19011. case "&&":
  19012. var ll = has_flag(self.left, TRUTHY)
  19013. ? true
  19014. : has_flag(self.left, FALSY)
  19015. ? false
  19016. : self.left.evaluate(compressor);
  19017. if (!ll) {
  19018. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  19019. } else if (!(ll instanceof AST_Node)) {
  19020. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  19021. }
  19022. var rr = self.right.evaluate(compressor);
  19023. if (!rr) {
  19024. if (compressor.in_boolean_context()) {
  19025. return make_sequence(self, [
  19026. self.left,
  19027. make_node(AST_False, self)
  19028. ]).optimize(compressor);
  19029. } else {
  19030. set_flag(self, FALSY);
  19031. }
  19032. } else if (!(rr instanceof AST_Node)) {
  19033. var parent = compressor.parent();
  19034. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  19035. return self.left.optimize(compressor);
  19036. }
  19037. }
  19038. // x || false && y ---> x ? y : false
  19039. if (self.left.operator == "||") {
  19040. var lr = self.left.right.evaluate(compressor);
  19041. if (!lr) return make_node(AST_Conditional, self, {
  19042. condition: self.left.left,
  19043. consequent: self.right,
  19044. alternative: self.left.right
  19045. }).optimize(compressor);
  19046. }
  19047. break;
  19048. case "||":
  19049. var ll = has_flag(self.left, TRUTHY)
  19050. ? true
  19051. : has_flag(self.left, FALSY)
  19052. ? false
  19053. : self.left.evaluate(compressor);
  19054. if (!ll) {
  19055. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  19056. } else if (!(ll instanceof AST_Node)) {
  19057. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  19058. }
  19059. var rr = self.right.evaluate(compressor);
  19060. if (!rr) {
  19061. var parent = compressor.parent();
  19062. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  19063. return self.left.optimize(compressor);
  19064. }
  19065. } else if (!(rr instanceof AST_Node)) {
  19066. if (compressor.in_boolean_context()) {
  19067. return make_sequence(self, [
  19068. self.left,
  19069. make_node(AST_True, self)
  19070. ]).optimize(compressor);
  19071. } else {
  19072. set_flag(self, TRUTHY);
  19073. }
  19074. }
  19075. if (self.left.operator == "&&") {
  19076. var lr = self.left.right.evaluate(compressor);
  19077. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  19078. condition: self.left.left,
  19079. consequent: self.left.right,
  19080. alternative: self.right
  19081. }).optimize(compressor);
  19082. }
  19083. break;
  19084. case "??":
  19085. if (is_nullish(self.left, compressor)) {
  19086. return self.right;
  19087. }
  19088. var ll = self.left.evaluate(compressor);
  19089. if (!(ll instanceof AST_Node)) {
  19090. // if we know the value for sure we can simply compute right away.
  19091. return ll == null ? self.right : self.left;
  19092. }
  19093. if (compressor.in_boolean_context()) {
  19094. const rr = self.right.evaluate(compressor);
  19095. if (!(rr instanceof AST_Node) && !rr) {
  19096. return self.left;
  19097. }
  19098. }
  19099. }
  19100. var associative = true;
  19101. switch (self.operator) {
  19102. case "+":
  19103. // (x + "foo") + "bar" => x + "foobar"
  19104. if (self.right instanceof AST_Constant
  19105. && self.left instanceof AST_Binary
  19106. && self.left.operator == "+"
  19107. && self.left.is_string(compressor)) {
  19108. var binary = make_node(AST_Binary, self, {
  19109. operator: "+",
  19110. left: self.left.right,
  19111. right: self.right,
  19112. });
  19113. var r = binary.optimize(compressor);
  19114. if (binary !== r) {
  19115. self = make_node(AST_Binary, self, {
  19116. operator: "+",
  19117. left: self.left.left,
  19118. right: r
  19119. });
  19120. }
  19121. }
  19122. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  19123. if (self.left instanceof AST_Binary
  19124. && self.left.operator == "+"
  19125. && self.left.is_string(compressor)
  19126. && self.right instanceof AST_Binary
  19127. && self.right.operator == "+"
  19128. && self.right.is_string(compressor)) {
  19129. var binary = make_node(AST_Binary, self, {
  19130. operator: "+",
  19131. left: self.left.right,
  19132. right: self.right.left,
  19133. });
  19134. var m = binary.optimize(compressor);
  19135. if (binary !== m) {
  19136. self = make_node(AST_Binary, self, {
  19137. operator: "+",
  19138. left: make_node(AST_Binary, self.left, {
  19139. operator: "+",
  19140. left: self.left.left,
  19141. right: m
  19142. }),
  19143. right: self.right.right
  19144. });
  19145. }
  19146. }
  19147. // a + -b => a - b
  19148. if (self.right instanceof AST_UnaryPrefix
  19149. && self.right.operator == "-"
  19150. && self.left.is_number(compressor)) {
  19151. self = make_node(AST_Binary, self, {
  19152. operator: "-",
  19153. left: self.left,
  19154. right: self.right.expression
  19155. });
  19156. break;
  19157. }
  19158. // -a + b => b - a
  19159. if (self.left instanceof AST_UnaryPrefix
  19160. && self.left.operator == "-"
  19161. && reversible()
  19162. && self.right.is_number(compressor)) {
  19163. self = make_node(AST_Binary, self, {
  19164. operator: "-",
  19165. left: self.right,
  19166. right: self.left.expression
  19167. });
  19168. break;
  19169. }
  19170. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  19171. if (self.left instanceof AST_TemplateString) {
  19172. var l = self.left;
  19173. var r = self.right.evaluate(compressor);
  19174. if (r != self.right) {
  19175. l.segments[l.segments.length - 1].value += String(r);
  19176. return l;
  19177. }
  19178. }
  19179. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  19180. if (self.right instanceof AST_TemplateString) {
  19181. var r = self.right;
  19182. var l = self.left.evaluate(compressor);
  19183. if (l != self.left) {
  19184. r.segments[0].value = String(l) + r.segments[0].value;
  19185. return r;
  19186. }
  19187. }
  19188. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  19189. if (self.left instanceof AST_TemplateString
  19190. && self.right instanceof AST_TemplateString) {
  19191. var l = self.left;
  19192. var segments = l.segments;
  19193. var r = self.right;
  19194. segments[segments.length - 1].value += r.segments[0].value;
  19195. for (var i = 1; i < r.segments.length; i++) {
  19196. segments.push(r.segments[i]);
  19197. }
  19198. return l;
  19199. }
  19200. case "*":
  19201. associative = compressor.option("unsafe_math");
  19202. case "&":
  19203. case "|":
  19204. case "^":
  19205. // a + +b => +b + a
  19206. if (self.left.is_number(compressor)
  19207. && self.right.is_number(compressor)
  19208. && reversible()
  19209. && !(self.left instanceof AST_Binary
  19210. && self.left.operator != self.operator
  19211. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  19212. var reversed = make_node(AST_Binary, self, {
  19213. operator: self.operator,
  19214. left: self.right,
  19215. right: self.left
  19216. });
  19217. if (self.right instanceof AST_Constant
  19218. && !(self.left instanceof AST_Constant)) {
  19219. self = best_of(compressor, reversed, self);
  19220. } else {
  19221. self = best_of(compressor, self, reversed);
  19222. }
  19223. }
  19224. if (associative && self.is_number(compressor)) {
  19225. // a + (b + c) => (a + b) + c
  19226. if (self.right instanceof AST_Binary
  19227. && self.right.operator == self.operator) {
  19228. self = make_node(AST_Binary, self, {
  19229. operator: self.operator,
  19230. left: make_node(AST_Binary, self.left, {
  19231. operator: self.operator,
  19232. left: self.left,
  19233. right: self.right.left,
  19234. start: self.left.start,
  19235. end: self.right.left.end
  19236. }),
  19237. right: self.right.right
  19238. });
  19239. }
  19240. // (n + 2) + 3 => 5 + n
  19241. // (2 * n) * 3 => 6 + n
  19242. if (self.right instanceof AST_Constant
  19243. && self.left instanceof AST_Binary
  19244. && self.left.operator == self.operator) {
  19245. if (self.left.left instanceof AST_Constant) {
  19246. self = make_node(AST_Binary, self, {
  19247. operator: self.operator,
  19248. left: make_node(AST_Binary, self.left, {
  19249. operator: self.operator,
  19250. left: self.left.left,
  19251. right: self.right,
  19252. start: self.left.left.start,
  19253. end: self.right.end
  19254. }),
  19255. right: self.left.right
  19256. });
  19257. } else if (self.left.right instanceof AST_Constant) {
  19258. self = make_node(AST_Binary, self, {
  19259. operator: self.operator,
  19260. left: make_node(AST_Binary, self.left, {
  19261. operator: self.operator,
  19262. left: self.left.right,
  19263. right: self.right,
  19264. start: self.left.right.start,
  19265. end: self.right.end
  19266. }),
  19267. right: self.left.left
  19268. });
  19269. }
  19270. }
  19271. // (a | 1) | (2 | d) => (3 | a) | b
  19272. if (self.left instanceof AST_Binary
  19273. && self.left.operator == self.operator
  19274. && self.left.right instanceof AST_Constant
  19275. && self.right instanceof AST_Binary
  19276. && self.right.operator == self.operator
  19277. && self.right.left instanceof AST_Constant) {
  19278. self = make_node(AST_Binary, self, {
  19279. operator: self.operator,
  19280. left: make_node(AST_Binary, self.left, {
  19281. operator: self.operator,
  19282. left: make_node(AST_Binary, self.left.left, {
  19283. operator: self.operator,
  19284. left: self.left.right,
  19285. right: self.right.left,
  19286. start: self.left.right.start,
  19287. end: self.right.left.end
  19288. }),
  19289. right: self.left.left
  19290. }),
  19291. right: self.right.right
  19292. });
  19293. }
  19294. }
  19295. }
  19296. // bitwise ops
  19297. if (bitwise_binop.has(self.operator)) {
  19298. // Use De Morgan's laws
  19299. // z & (X | y)
  19300. // => z & X (given y & z === 0)
  19301. // => z & X | {y & z} (given y & z !== 0)
  19302. let y, z, x_node, y_node, z_node = self.left;
  19303. if (
  19304. self.operator === "&"
  19305. && self.right instanceof AST_Binary
  19306. && self.right.operator === "|"
  19307. && typeof (z = self.left.evaluate(compressor)) === "number"
  19308. ) {
  19309. if (typeof (y = self.right.right.evaluate(compressor)) === "number") {
  19310. // z & (X | y)
  19311. x_node = self.right.left;
  19312. y_node = self.right.right;
  19313. } else if (typeof (y = self.right.left.evaluate(compressor)) === "number") {
  19314. // z & (y | X)
  19315. x_node = self.right.right;
  19316. y_node = self.right.left;
  19317. }
  19318. if (x_node && y_node) {
  19319. if ((y & z) === 0) {
  19320. self = make_node(AST_Binary, self, {
  19321. operator: self.operator,
  19322. left: z_node,
  19323. right: x_node
  19324. });
  19325. } else {
  19326. const reordered_ops = make_node(AST_Binary, self, {
  19327. operator: "|",
  19328. left: make_node(AST_Binary, self, {
  19329. operator: "&",
  19330. left: x_node,
  19331. right: z_node
  19332. }),
  19333. right: make_node_from_constant(y & z, y_node),
  19334. });
  19335. self = best_of(compressor, self, reordered_ops);
  19336. }
  19337. }
  19338. }
  19339. // x ^ x => 0
  19340. // x | x => 0 | x
  19341. // x & x => 0 | x
  19342. const same_operands = self.left.equivalent_to(self.right) && !self.left.has_side_effects(compressor);
  19343. if (same_operands) {
  19344. if (self.operator === "^") {
  19345. return make_node(AST_Number, self, { value: 0 });
  19346. }
  19347. if (self.operator === "|" || self.operator === "&") {
  19348. self.left = make_node(AST_Number, self, { value: 0 });
  19349. self.operator = "|";
  19350. }
  19351. }
  19352. // Shifts that do nothing
  19353. // {anything} >> 0 => {anything} | 0
  19354. // {anything} << 0 => {anything} | 0
  19355. if (
  19356. (self.operator === "<<" || self.operator === ">>")
  19357. && self.right instanceof AST_Number && self.right.value === 0
  19358. ) {
  19359. self.operator = "|";
  19360. }
  19361. // Find useless to-bitwise conversions
  19362. // {32 bit integer} | 0 => {32 bit integer}
  19363. // {32 bit integer} ^ 0 => {32 bit integer}
  19364. const zero_side = self.right instanceof AST_Number && self.right.value === 0 ? self.right
  19365. : self.left instanceof AST_Number && self.left.value === 0 ? self.left
  19366. : null;
  19367. const non_zero_side = zero_side && (zero_side === self.right ? self.left : self.right);
  19368. if (
  19369. zero_side
  19370. && (self.operator === "|" || self.operator === "^")
  19371. && (non_zero_side.is_32_bit_integer() || compressor.in_32_bit_context())
  19372. ) {
  19373. return non_zero_side;
  19374. }
  19375. // {anything} & 0 => 0
  19376. if (
  19377. zero_side
  19378. && self.operator === "&"
  19379. && !non_zero_side.has_side_effects(compressor)
  19380. ) {
  19381. return zero_side;
  19382. }
  19383. const is_full_mask = (node) =>
  19384. node instanceof AST_Number && node.value === -1
  19385. ||
  19386. node instanceof AST_UnaryPrefix && (
  19387. node.operator === "-"
  19388. && node.expression instanceof AST_Number
  19389. && node.expression.value === 1
  19390. || node.operator === "~"
  19391. && node.expression instanceof AST_Number
  19392. && node.expression.value === 0);
  19393. const full_mask = is_full_mask(self.right) ? self.right
  19394. : is_full_mask(self.left) ? self.left
  19395. : null;
  19396. const non_full_mask_side = full_mask && (full_mask === self.right ? self.left : self.right);
  19397. switch (self.operator) {
  19398. case "|":
  19399. // {anything} | -1 => -1
  19400. if (full_mask && !non_full_mask_side.has_side_effects(compressor)) {
  19401. return full_mask;
  19402. }
  19403. break;
  19404. case "&":
  19405. // {32 bit integer} & -1 => {32 bit integer}
  19406. if (
  19407. full_mask
  19408. && (non_full_mask_side.is_32_bit_integer() || compressor.in_32_bit_context())
  19409. ) {
  19410. return non_full_mask_side;
  19411. }
  19412. break;
  19413. case "^":
  19414. // {anything} ^ -1 => ~{anything}
  19415. if (full_mask) {
  19416. return non_full_mask_side.bitwise_negate(compressor.in_32_bit_context());
  19417. }
  19418. // ~x ^ ~y => x ^ y
  19419. if (
  19420. self.left instanceof AST_UnaryPrefix
  19421. && self.left.operator === "~"
  19422. && self.right instanceof AST_UnaryPrefix
  19423. && self.right.operator === "~"
  19424. ) {
  19425. self = make_node(AST_Binary, self, {
  19426. operator: "^",
  19427. left: self.left.expression,
  19428. right: self.right.expression
  19429. });
  19430. }
  19431. break;
  19432. }
  19433. }
  19434. }
  19435. // x && (y && z) ==> x && y && z
  19436. // x || (y || z) ==> x || y || z
  19437. // x + ("y" + z) ==> x + "y" + z
  19438. // "x" + (y + "z")==> "x" + y + "z"
  19439. if (self.right instanceof AST_Binary
  19440. && self.right.operator == self.operator
  19441. && (lazy_op.has(self.operator)
  19442. || (self.operator == "+"
  19443. && (self.right.left.is_string(compressor)
  19444. || (self.left.is_string(compressor)
  19445. && self.right.right.is_string(compressor)))))
  19446. ) {
  19447. self.left = make_node(AST_Binary, self.left, {
  19448. operator : self.operator,
  19449. left : self.left.transform(compressor),
  19450. right : self.right.left.transform(compressor)
  19451. });
  19452. self.right = self.right.right.transform(compressor);
  19453. return self.transform(compressor);
  19454. }
  19455. var ev = self.evaluate(compressor);
  19456. if (ev !== self) {
  19457. ev = make_node_from_constant(ev, self).optimize(compressor);
  19458. return best_of(compressor, ev, self);
  19459. }
  19460. return self;
  19461. });
  19462. def_optimize(AST_SymbolExport, function(self) {
  19463. return self;
  19464. });
  19465. def_optimize(AST_SymbolRef, function(self, compressor) {
  19466. if (
  19467. !compressor.option("ie8")
  19468. && is_undeclared_ref(self)
  19469. && !compressor.find_parent(AST_With)
  19470. ) {
  19471. switch (self.name) {
  19472. case "undefined":
  19473. return make_node(AST_Undefined, self).optimize(compressor);
  19474. case "NaN":
  19475. return make_node(AST_NaN, self).optimize(compressor);
  19476. case "Infinity":
  19477. return make_node(AST_Infinity, self).optimize(compressor);
  19478. }
  19479. }
  19480. if (compressor.option("reduce_vars") && !compressor.is_lhs()) {
  19481. return inline_into_symbolref(self, compressor);
  19482. } else {
  19483. return self;
  19484. }
  19485. });
  19486. function is_atomic(lhs, self) {
  19487. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  19488. }
  19489. def_optimize(AST_Undefined, function(self, compressor) {
  19490. if (compressor.option("unsafe_undefined")) {
  19491. var undef = find_variable(compressor, "undefined");
  19492. if (undef) {
  19493. var ref = make_node(AST_SymbolRef, self, {
  19494. name : "undefined",
  19495. scope : undef.scope,
  19496. thedef : undef
  19497. });
  19498. set_flag(ref, UNDEFINED);
  19499. return ref;
  19500. }
  19501. }
  19502. var lhs = compressor.is_lhs();
  19503. if (lhs && is_atomic(lhs, self)) return self;
  19504. return make_node(AST_UnaryPrefix, self, {
  19505. operator: "void",
  19506. expression: make_node(AST_Number, self, {
  19507. value: 0
  19508. })
  19509. });
  19510. });
  19511. def_optimize(AST_Infinity, function(self, compressor) {
  19512. var lhs = compressor.is_lhs();
  19513. if (lhs && is_atomic(lhs, self)) return self;
  19514. if (
  19515. compressor.option("keep_infinity")
  19516. && !(lhs && !is_atomic(lhs, self))
  19517. && !find_variable(compressor, "Infinity")
  19518. ) {
  19519. return self;
  19520. }
  19521. return make_node(AST_Binary, self, {
  19522. operator: "/",
  19523. left: make_node(AST_Number, self, {
  19524. value: 1
  19525. }),
  19526. right: make_node(AST_Number, self, {
  19527. value: 0
  19528. })
  19529. });
  19530. });
  19531. def_optimize(AST_NaN, function(self, compressor) {
  19532. var lhs = compressor.is_lhs();
  19533. if (lhs && !is_atomic(lhs, self)
  19534. || find_variable(compressor, "NaN")) {
  19535. return make_node(AST_Binary, self, {
  19536. operator: "/",
  19537. left: make_node(AST_Number, self, {
  19538. value: 0
  19539. }),
  19540. right: make_node(AST_Number, self, {
  19541. value: 0
  19542. })
  19543. });
  19544. }
  19545. return self;
  19546. });
  19547. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  19548. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  19549. def_optimize(AST_Assign, function(self, compressor) {
  19550. if (self.logical) {
  19551. return self.lift_sequences(compressor);
  19552. }
  19553. var def;
  19554. // x = x ---> x
  19555. if (
  19556. self.operator === "="
  19557. && self.left instanceof AST_SymbolRef
  19558. && self.left.name !== "arguments"
  19559. && !(def = self.left.definition()).undeclared
  19560. && self.right.equivalent_to(self.left)
  19561. ) {
  19562. return self.right;
  19563. }
  19564. if (compressor.option("dead_code")
  19565. && self.left instanceof AST_SymbolRef
  19566. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  19567. var level = 0, node, parent = self;
  19568. do {
  19569. node = parent;
  19570. parent = compressor.parent(level++);
  19571. if (parent instanceof AST_Exit) {
  19572. if (in_try(level, parent)) break;
  19573. if (is_reachable(def.scope, [ def ])) break;
  19574. if (self.operator == "=") return self.right;
  19575. def.fixed = false;
  19576. return make_node(AST_Binary, self, {
  19577. operator: self.operator.slice(0, -1),
  19578. left: self.left,
  19579. right: self.right
  19580. }).optimize(compressor);
  19581. }
  19582. } while (parent instanceof AST_Binary && parent.right === node
  19583. || parent instanceof AST_Sequence && parent.tail_node() === node);
  19584. }
  19585. self = self.lift_sequences(compressor);
  19586. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  19587. // x = expr1 OP expr2
  19588. if (self.right.left instanceof AST_SymbolRef
  19589. && self.right.left.name == self.left.name
  19590. && ASSIGN_OPS.has(self.right.operator)) {
  19591. // x = x - 2 ---> x -= 2
  19592. self.operator = self.right.operator + "=";
  19593. self.right = self.right.right;
  19594. } else if (self.right.right instanceof AST_SymbolRef
  19595. && self.right.right.name == self.left.name
  19596. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  19597. && !self.right.left.has_side_effects(compressor)) {
  19598. // x = 2 & x ---> x &= 2
  19599. self.operator = self.right.operator + "=";
  19600. self.right = self.right.left;
  19601. }
  19602. }
  19603. return self;
  19604. function in_try(level, node) {
  19605. function may_assignment_throw() {
  19606. const right = self.right;
  19607. self.right = make_node(AST_Null, right);
  19608. const may_throw = node.may_throw(compressor);
  19609. self.right = right;
  19610. return may_throw;
  19611. }
  19612. var stop_at = self.left.definition().scope.get_defun_scope();
  19613. var parent;
  19614. while ((parent = compressor.parent(level++)) !== stop_at) {
  19615. if (parent instanceof AST_Try) {
  19616. if (parent.bfinally) return true;
  19617. if (parent.bcatch && may_assignment_throw()) return true;
  19618. }
  19619. }
  19620. }
  19621. });
  19622. def_optimize(AST_DefaultAssign, function(self, compressor) {
  19623. if (!compressor.option("evaluate")) {
  19624. return self;
  19625. }
  19626. var evaluateRight = self.right.evaluate(compressor);
  19627. // `[x = undefined] = foo` ---> `[x] = foo`
  19628. // `(arg = undefined) => ...` ---> `(arg) => ...` (unless `keep_fargs`)
  19629. // `((arg = undefined) => ...)()` ---> `((arg) => ...)()`
  19630. let lambda, iife;
  19631. if (evaluateRight === undefined) {
  19632. if (
  19633. (lambda = compressor.parent()) instanceof AST_Lambda
  19634. ? (
  19635. compressor.option("keep_fargs") === false
  19636. || (iife = compressor.parent(1)).TYPE === "Call"
  19637. && iife.expression === lambda
  19638. )
  19639. : true
  19640. ) {
  19641. self = self.left;
  19642. }
  19643. } else if (evaluateRight !== self.right) {
  19644. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  19645. self.right = best_of_expression(evaluateRight, self.right);
  19646. }
  19647. return self;
  19648. });
  19649. function is_nullish_check(check, check_subject, compressor) {
  19650. if (check_subject.may_throw(compressor)) return false;
  19651. let nullish_side;
  19652. // foo == null
  19653. if (
  19654. check instanceof AST_Binary
  19655. && check.operator === "=="
  19656. // which side is nullish?
  19657. && (
  19658. (nullish_side = is_nullish(check.left, compressor) && check.left)
  19659. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  19660. )
  19661. // is the other side the same as the check_subject
  19662. && (
  19663. nullish_side === check.left
  19664. ? check.right
  19665. : check.left
  19666. ).equivalent_to(check_subject)
  19667. ) {
  19668. return true;
  19669. }
  19670. // foo === null || foo === undefined
  19671. if (check instanceof AST_Binary && check.operator === "||") {
  19672. let null_cmp;
  19673. let undefined_cmp;
  19674. const find_comparison = cmp => {
  19675. if (!(
  19676. cmp instanceof AST_Binary
  19677. && (cmp.operator === "===" || cmp.operator === "==")
  19678. )) {
  19679. return false;
  19680. }
  19681. let found = 0;
  19682. let defined_side;
  19683. if (cmp.left instanceof AST_Null) {
  19684. found++;
  19685. null_cmp = cmp;
  19686. defined_side = cmp.right;
  19687. }
  19688. if (cmp.right instanceof AST_Null) {
  19689. found++;
  19690. null_cmp = cmp;
  19691. defined_side = cmp.left;
  19692. }
  19693. if (is_undefined(cmp.left, compressor)) {
  19694. found++;
  19695. undefined_cmp = cmp;
  19696. defined_side = cmp.right;
  19697. }
  19698. if (is_undefined(cmp.right, compressor)) {
  19699. found++;
  19700. undefined_cmp = cmp;
  19701. defined_side = cmp.left;
  19702. }
  19703. if (found !== 1) {
  19704. return false;
  19705. }
  19706. if (!defined_side.equivalent_to(check_subject)) {
  19707. return false;
  19708. }
  19709. return true;
  19710. };
  19711. if (!find_comparison(check.left)) return false;
  19712. if (!find_comparison(check.right)) return false;
  19713. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  19714. return true;
  19715. }
  19716. }
  19717. return false;
  19718. }
  19719. def_optimize(AST_Conditional, function(self, compressor) {
  19720. if (!compressor.option("conditionals")) return self;
  19721. // This looks like lift_sequences(), should probably be under "sequences"
  19722. if (self.condition instanceof AST_Sequence) {
  19723. var expressions = self.condition.expressions.slice();
  19724. self.condition = expressions.pop();
  19725. expressions.push(self);
  19726. return make_sequence(self, expressions);
  19727. }
  19728. var cond = self.condition.evaluate(compressor);
  19729. if (cond !== self.condition) {
  19730. if (cond) {
  19731. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  19732. } else {
  19733. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  19734. }
  19735. }
  19736. var negated = cond.negate(compressor, first_in_statement(compressor));
  19737. if (best_of(compressor, cond, negated) === negated) {
  19738. self = make_node(AST_Conditional, self, {
  19739. condition: negated,
  19740. consequent: self.alternative,
  19741. alternative: self.consequent
  19742. });
  19743. }
  19744. var condition = self.condition;
  19745. var consequent = self.consequent;
  19746. var alternative = self.alternative;
  19747. // x?x:y --> x||y
  19748. if (condition instanceof AST_SymbolRef
  19749. && consequent instanceof AST_SymbolRef
  19750. && condition.definition() === consequent.definition()) {
  19751. return make_node(AST_Binary, self, {
  19752. operator: "||",
  19753. left: condition,
  19754. right: alternative
  19755. });
  19756. }
  19757. // if (foo) exp = something; else exp = something_else;
  19758. // |
  19759. // v
  19760. // exp = foo ? something : something_else;
  19761. if (
  19762. consequent instanceof AST_Assign
  19763. && alternative instanceof AST_Assign
  19764. && consequent.operator === alternative.operator
  19765. && consequent.logical === alternative.logical
  19766. && consequent.left.equivalent_to(alternative.left)
  19767. && (!self.condition.has_side_effects(compressor)
  19768. || consequent.operator == "="
  19769. && !consequent.left.has_side_effects(compressor))
  19770. ) {
  19771. return make_node(AST_Assign, self, {
  19772. operator: consequent.operator,
  19773. left: consequent.left,
  19774. logical: consequent.logical,
  19775. right: make_node(AST_Conditional, self, {
  19776. condition: self.condition,
  19777. consequent: consequent.right,
  19778. alternative: alternative.right
  19779. })
  19780. });
  19781. }
  19782. // x ? y(a) : y(b) --> y(x ? a : b)
  19783. var arg_index;
  19784. if (consequent instanceof AST_Call
  19785. && alternative.TYPE === consequent.TYPE
  19786. && consequent.args.length > 0
  19787. && consequent.args.length == alternative.args.length
  19788. && consequent.expression.equivalent_to(alternative.expression)
  19789. && !self.condition.has_side_effects(compressor)
  19790. && !consequent.expression.has_side_effects(compressor)
  19791. && typeof (arg_index = single_arg_diff()) == "number") {
  19792. var node = consequent.clone();
  19793. node.args[arg_index] = make_node(AST_Conditional, self, {
  19794. condition: self.condition,
  19795. consequent: consequent.args[arg_index],
  19796. alternative: alternative.args[arg_index]
  19797. });
  19798. return node;
  19799. }
  19800. // a ? b : c ? b : d --> (a || c) ? b : d
  19801. if (alternative instanceof AST_Conditional
  19802. && consequent.equivalent_to(alternative.consequent)) {
  19803. return make_node(AST_Conditional, self, {
  19804. condition: make_node(AST_Binary, self, {
  19805. operator: "||",
  19806. left: condition,
  19807. right: alternative.condition
  19808. }),
  19809. consequent: consequent,
  19810. alternative: alternative.alternative
  19811. }).optimize(compressor);
  19812. }
  19813. // a == null ? b : a -> a ?? b
  19814. if (
  19815. compressor.option("ecma") >= 2020 &&
  19816. is_nullish_check(condition, alternative, compressor)
  19817. ) {
  19818. return make_node(AST_Binary, self, {
  19819. operator: "??",
  19820. left: alternative,
  19821. right: consequent
  19822. }).optimize(compressor);
  19823. }
  19824. // a ? b : (c, b) --> (a || c), b
  19825. if (alternative instanceof AST_Sequence
  19826. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  19827. return make_sequence(self, [
  19828. make_node(AST_Binary, self, {
  19829. operator: "||",
  19830. left: condition,
  19831. right: make_sequence(self, alternative.expressions.slice(0, -1))
  19832. }),
  19833. consequent
  19834. ]).optimize(compressor);
  19835. }
  19836. // a ? b : (c && b) --> (a || c) && b
  19837. if (alternative instanceof AST_Binary
  19838. && alternative.operator == "&&"
  19839. && consequent.equivalent_to(alternative.right)) {
  19840. return make_node(AST_Binary, self, {
  19841. operator: "&&",
  19842. left: make_node(AST_Binary, self, {
  19843. operator: "||",
  19844. left: condition,
  19845. right: alternative.left
  19846. }),
  19847. right: consequent
  19848. }).optimize(compressor);
  19849. }
  19850. // x?y?z:a:a --> x&&y?z:a
  19851. if (consequent instanceof AST_Conditional
  19852. && consequent.alternative.equivalent_to(alternative)) {
  19853. return make_node(AST_Conditional, self, {
  19854. condition: make_node(AST_Binary, self, {
  19855. left: self.condition,
  19856. operator: "&&",
  19857. right: consequent.condition
  19858. }),
  19859. consequent: consequent.consequent,
  19860. alternative: alternative
  19861. });
  19862. }
  19863. // x ? y : y --> x, y
  19864. if (consequent.equivalent_to(alternative)) {
  19865. return make_sequence(self, [
  19866. self.condition,
  19867. consequent
  19868. ]).optimize(compressor);
  19869. }
  19870. // x ? y || z : z --> x && y || z
  19871. if (consequent instanceof AST_Binary
  19872. && consequent.operator == "||"
  19873. && consequent.right.equivalent_to(alternative)) {
  19874. return make_node(AST_Binary, self, {
  19875. operator: "||",
  19876. left: make_node(AST_Binary, self, {
  19877. operator: "&&",
  19878. left: self.condition,
  19879. right: consequent.left
  19880. }),
  19881. right: alternative
  19882. }).optimize(compressor);
  19883. }
  19884. const in_bool = compressor.in_boolean_context();
  19885. if (is_true(self.consequent)) {
  19886. if (is_false(self.alternative)) {
  19887. // c ? true : false ---> !!c
  19888. return booleanize(self.condition);
  19889. }
  19890. // c ? true : x ---> !!c || x
  19891. return make_node(AST_Binary, self, {
  19892. operator: "||",
  19893. left: booleanize(self.condition),
  19894. right: self.alternative
  19895. });
  19896. }
  19897. if (is_false(self.consequent)) {
  19898. if (is_true(self.alternative)) {
  19899. // c ? false : true ---> !c
  19900. return booleanize(self.condition.negate(compressor));
  19901. }
  19902. // c ? false : x ---> !c && x
  19903. return make_node(AST_Binary, self, {
  19904. operator: "&&",
  19905. left: booleanize(self.condition.negate(compressor)),
  19906. right: self.alternative
  19907. });
  19908. }
  19909. if (is_true(self.alternative)) {
  19910. // c ? x : true ---> !c || x
  19911. return make_node(AST_Binary, self, {
  19912. operator: "||",
  19913. left: booleanize(self.condition.negate(compressor)),
  19914. right: self.consequent
  19915. });
  19916. }
  19917. if (is_false(self.alternative)) {
  19918. // c ? x : false ---> !!c && x
  19919. return make_node(AST_Binary, self, {
  19920. operator: "&&",
  19921. left: booleanize(self.condition),
  19922. right: self.consequent
  19923. });
  19924. }
  19925. return self;
  19926. function booleanize(node) {
  19927. if (node.is_boolean()) return node;
  19928. // !!expression
  19929. return make_node(AST_UnaryPrefix, node, {
  19930. operator: "!",
  19931. expression: node.negate(compressor)
  19932. });
  19933. }
  19934. // AST_True or !0
  19935. function is_true(node) {
  19936. return node instanceof AST_True
  19937. || in_bool
  19938. && node instanceof AST_Constant
  19939. && node.getValue()
  19940. || (node instanceof AST_UnaryPrefix
  19941. && node.operator == "!"
  19942. && node.expression instanceof AST_Constant
  19943. && !node.expression.getValue());
  19944. }
  19945. // AST_False or !1
  19946. function is_false(node) {
  19947. return node instanceof AST_False
  19948. || in_bool
  19949. && node instanceof AST_Constant
  19950. && !node.getValue()
  19951. || (node instanceof AST_UnaryPrefix
  19952. && node.operator == "!"
  19953. && node.expression instanceof AST_Constant
  19954. && node.expression.getValue());
  19955. }
  19956. function single_arg_diff() {
  19957. var a = consequent.args;
  19958. var b = alternative.args;
  19959. for (var i = 0, len = a.length; i < len; i++) {
  19960. if (a[i] instanceof AST_Expansion) return;
  19961. if (!a[i].equivalent_to(b[i])) {
  19962. if (b[i] instanceof AST_Expansion) return;
  19963. for (var j = i + 1; j < len; j++) {
  19964. if (a[j] instanceof AST_Expansion) return;
  19965. if (!a[j].equivalent_to(b[j])) return;
  19966. }
  19967. return i;
  19968. }
  19969. }
  19970. }
  19971. });
  19972. def_optimize(AST_Boolean, function(self, compressor) {
  19973. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  19974. value: +self.value
  19975. });
  19976. var p = compressor.parent();
  19977. if (compressor.option("booleans_as_integers")) {
  19978. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  19979. p.operator = p.operator.replace(/=$/, "");
  19980. }
  19981. return make_node(AST_Number, self, {
  19982. value: +self.value
  19983. });
  19984. }
  19985. if (compressor.option("booleans")) {
  19986. if (p instanceof AST_Binary && (p.operator == "=="
  19987. || p.operator == "!=")) {
  19988. return make_node(AST_Number, self, {
  19989. value: +self.value
  19990. });
  19991. }
  19992. return make_node(AST_UnaryPrefix, self, {
  19993. operator: "!",
  19994. expression: make_node(AST_Number, self, {
  19995. value: 1 - self.value
  19996. })
  19997. });
  19998. }
  19999. return self;
  20000. });
  20001. function safe_to_flatten(value, compressor) {
  20002. if (value instanceof AST_SymbolRef) {
  20003. value = value.fixed_value();
  20004. }
  20005. if (!value) return false;
  20006. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  20007. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  20008. return compressor.parent() instanceof AST_New;
  20009. }
  20010. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  20011. if (!compressor.option("properties")) return;
  20012. if (key === "__proto__") return;
  20013. if (this instanceof AST_DotHash) return;
  20014. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  20015. var expr = this.expression;
  20016. if (expr instanceof AST_Object) {
  20017. var props = expr.properties;
  20018. for (var i = props.length; --i >= 0;) {
  20019. var prop = props[i];
  20020. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  20021. const all_props_flattenable = props.every((p) =>
  20022. (p instanceof AST_ObjectKeyVal
  20023. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  20024. )
  20025. && !p.computed_key()
  20026. );
  20027. if (!all_props_flattenable) return;
  20028. if (!safe_to_flatten(prop.value, compressor)) return;
  20029. return make_node(AST_Sub, this, {
  20030. expression: make_node(AST_Array, expr, {
  20031. elements: props.map(function(prop) {
  20032. var v = prop.value;
  20033. if (v instanceof AST_Accessor) {
  20034. v = make_node(AST_Function, v, v);
  20035. }
  20036. var k = prop.key;
  20037. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  20038. return make_sequence(prop, [ k, v ]);
  20039. }
  20040. return v;
  20041. })
  20042. }),
  20043. property: make_node(AST_Number, this, {
  20044. value: i
  20045. })
  20046. });
  20047. }
  20048. }
  20049. }
  20050. });
  20051. def_optimize(AST_Sub, function(self, compressor) {
  20052. var expr = self.expression;
  20053. var prop = self.property;
  20054. if (compressor.option("properties")) {
  20055. var key = prop.evaluate(compressor);
  20056. if (key !== prop) {
  20057. if (typeof key == "string") {
  20058. if (key == "undefined") {
  20059. key = undefined;
  20060. } else {
  20061. var value = parseFloat(key);
  20062. if (value.toString() == key) {
  20063. key = value;
  20064. }
  20065. }
  20066. }
  20067. prop = self.property = best_of_expression(
  20068. prop,
  20069. make_node_from_constant(key, prop).transform(compressor)
  20070. );
  20071. var property = "" + key;
  20072. if (is_basic_identifier_string(property)
  20073. && property.length <= prop.size() + 1) {
  20074. return make_node(AST_Dot, self, {
  20075. expression: expr,
  20076. optional: self.optional,
  20077. property: property,
  20078. quote: prop.quote,
  20079. }).optimize(compressor);
  20080. }
  20081. }
  20082. }
  20083. var fn;
  20084. OPT_ARGUMENTS: if (compressor.option("arguments")
  20085. && expr instanceof AST_SymbolRef
  20086. && expr.name == "arguments"
  20087. && expr.definition().orig.length == 1
  20088. && (fn = expr.scope) instanceof AST_Lambda
  20089. && fn.uses_arguments
  20090. && !(fn instanceof AST_Arrow)
  20091. && prop instanceof AST_Number) {
  20092. var index = prop.getValue();
  20093. var params = new Set();
  20094. var argnames = fn.argnames;
  20095. for (var n = 0; n < argnames.length; n++) {
  20096. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  20097. break OPT_ARGUMENTS; // destructuring parameter - bail
  20098. }
  20099. var param = argnames[n].name;
  20100. if (params.has(param)) {
  20101. break OPT_ARGUMENTS; // duplicate parameter - bail
  20102. }
  20103. params.add(param);
  20104. }
  20105. var argname = fn.argnames[index];
  20106. if (argname && compressor.has_directive("use strict")) {
  20107. var def = argname.definition();
  20108. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  20109. argname = null;
  20110. }
  20111. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  20112. while (index >= fn.argnames.length) {
  20113. argname = fn.create_symbol(AST_SymbolFunarg, {
  20114. source: fn,
  20115. scope: fn,
  20116. tentative_name: "argument_" + fn.argnames.length,
  20117. });
  20118. fn.argnames.push(argname);
  20119. }
  20120. }
  20121. if (argname) {
  20122. var sym = make_node(AST_SymbolRef, self, argname);
  20123. sym.reference({});
  20124. clear_flag(argname, UNUSED);
  20125. return sym;
  20126. }
  20127. }
  20128. if (compressor.is_lhs()) return self;
  20129. if (key !== prop) {
  20130. var sub = self.flatten_object(property, compressor);
  20131. if (sub) {
  20132. expr = self.expression = sub.expression;
  20133. prop = self.property = sub.property;
  20134. }
  20135. }
  20136. if (compressor.option("properties") && compressor.option("side_effects")
  20137. && prop instanceof AST_Number && expr instanceof AST_Array) {
  20138. var index = prop.getValue();
  20139. var elements = expr.elements;
  20140. var retValue = elements[index];
  20141. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  20142. var flatten = true;
  20143. var values = [];
  20144. for (var i = elements.length; --i > index;) {
  20145. var value = elements[i].drop_side_effect_free(compressor);
  20146. if (value) {
  20147. values.unshift(value);
  20148. if (flatten && value.has_side_effects(compressor)) flatten = false;
  20149. }
  20150. }
  20151. if (retValue instanceof AST_Expansion) break FLATTEN;
  20152. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  20153. if (!flatten) values.unshift(retValue);
  20154. while (--i >= 0) {
  20155. var value = elements[i];
  20156. if (value instanceof AST_Expansion) break FLATTEN;
  20157. value = value.drop_side_effect_free(compressor);
  20158. if (value) values.unshift(value);
  20159. else index--;
  20160. }
  20161. if (flatten) {
  20162. values.push(retValue);
  20163. return make_sequence(self, values).optimize(compressor);
  20164. } else return make_node(AST_Sub, self, {
  20165. expression: make_node(AST_Array, expr, {
  20166. elements: values
  20167. }),
  20168. property: make_node(AST_Number, prop, {
  20169. value: index
  20170. })
  20171. });
  20172. }
  20173. }
  20174. var ev = self.evaluate(compressor);
  20175. if (ev !== self) {
  20176. ev = make_node_from_constant(ev, self).optimize(compressor);
  20177. return best_of(compressor, ev, self);
  20178. }
  20179. return self;
  20180. });
  20181. def_optimize(AST_Chain, function (self, compressor) {
  20182. if (is_nullish(self.expression, compressor)) {
  20183. let parent = compressor.parent();
  20184. // It's valid to delete a nullish optional chain, but if we optimized
  20185. // this to `delete undefined` then it would appear to be a syntax error
  20186. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  20187. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  20188. return make_node_from_constant(0, self);
  20189. }
  20190. return make_node(AST_Undefined, self);
  20191. }
  20192. if (
  20193. self.expression instanceof AST_PropAccess
  20194. || self.expression instanceof AST_Call
  20195. ) {
  20196. return self;
  20197. } else {
  20198. // Keep the AST valid, in case the child swapped itself
  20199. return self.expression;
  20200. }
  20201. });
  20202. def_optimize(AST_Dot, function(self, compressor) {
  20203. const parent = compressor.parent();
  20204. if (compressor.is_lhs()) return self;
  20205. if (compressor.option("unsafe_proto")
  20206. && self.expression instanceof AST_Dot
  20207. && self.expression.property == "prototype") {
  20208. var exp = self.expression.expression;
  20209. if (is_undeclared_ref(exp)) switch (exp.name) {
  20210. case "Array":
  20211. self.expression = make_node(AST_Array, self.expression, {
  20212. elements: []
  20213. });
  20214. break;
  20215. case "Function":
  20216. self.expression = make_empty_function(self.expression);
  20217. break;
  20218. case "Number":
  20219. self.expression = make_node(AST_Number, self.expression, {
  20220. value: 0
  20221. });
  20222. break;
  20223. case "Object":
  20224. self.expression = make_node(AST_Object, self.expression, {
  20225. properties: []
  20226. });
  20227. break;
  20228. case "RegExp":
  20229. self.expression = make_node(AST_RegExp, self.expression, {
  20230. value: { source: "t", flags: "" }
  20231. });
  20232. break;
  20233. case "String":
  20234. self.expression = make_node(AST_String, self.expression, {
  20235. value: ""
  20236. });
  20237. break;
  20238. }
  20239. }
  20240. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  20241. const sub = self.flatten_object(self.property, compressor);
  20242. if (sub) return sub.optimize(compressor);
  20243. }
  20244. if (self.expression instanceof AST_PropAccess
  20245. && parent instanceof AST_PropAccess) {
  20246. return self;
  20247. }
  20248. let ev = self.evaluate(compressor);
  20249. if (ev !== self) {
  20250. ev = make_node_from_constant(ev, self).optimize(compressor);
  20251. return best_of(compressor, ev, self);
  20252. }
  20253. return self;
  20254. });
  20255. function literals_in_boolean_context(self, compressor) {
  20256. if (compressor.in_boolean_context()) {
  20257. return best_of(compressor, self, make_sequence(self, [
  20258. self,
  20259. make_node(AST_True, self)
  20260. ]).optimize(compressor));
  20261. }
  20262. return self;
  20263. }
  20264. function inline_array_like_spread(elements) {
  20265. for (var i = 0; i < elements.length; i++) {
  20266. var el = elements[i];
  20267. if (el instanceof AST_Expansion) {
  20268. var expr = el.expression;
  20269. if (
  20270. expr instanceof AST_Array
  20271. && !expr.elements.some(elm => elm instanceof AST_Hole)
  20272. ) {
  20273. elements.splice(i, 1, ...expr.elements);
  20274. // Step back one, as the element at i is now new.
  20275. i--;
  20276. }
  20277. // In array-like spread, spreading a non-iterable value is TypeError.
  20278. // We therefore can’t optimize anything else, unlike with object spread.
  20279. }
  20280. }
  20281. }
  20282. def_optimize(AST_Array, function(self, compressor) {
  20283. var optimized = literals_in_boolean_context(self, compressor);
  20284. if (optimized !== self) {
  20285. return optimized;
  20286. }
  20287. inline_array_like_spread(self.elements);
  20288. return self;
  20289. });
  20290. function inline_object_prop_spread(props) {
  20291. for (var i = 0; i < props.length; i++) {
  20292. var prop = props[i];
  20293. if (prop instanceof AST_Expansion) {
  20294. const expr = prop.expression;
  20295. if (
  20296. expr instanceof AST_Object
  20297. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  20298. ) {
  20299. props.splice(i, 1, ...expr.properties);
  20300. // Step back one, as the property at i is now new.
  20301. i--;
  20302. } else if ((
  20303. // `expr.is_constant()` returns `false` for `AST_RegExp`, so need both.
  20304. expr instanceof AST_Constant
  20305. || expr.is_constant()
  20306. ) && !(expr instanceof AST_String)) {
  20307. // Unlike array-like spread, in object spread, spreading a
  20308. // non-iterable value silently does nothing; it is thus safe
  20309. // to remove. AST_String is the only iterable constant.
  20310. props.splice(i, 1);
  20311. i--;
  20312. }
  20313. }
  20314. }
  20315. }
  20316. def_optimize(AST_Object, function(self, compressor) {
  20317. var optimized = literals_in_boolean_context(self, compressor);
  20318. if (optimized !== self) {
  20319. return optimized;
  20320. }
  20321. inline_object_prop_spread(self.properties);
  20322. return self;
  20323. });
  20324. def_optimize(AST_RegExp, literals_in_boolean_context);
  20325. def_optimize(AST_Return, function(self, compressor) {
  20326. if (self.value && is_undefined(self.value, compressor)) {
  20327. self.value = null;
  20328. }
  20329. return self;
  20330. });
  20331. def_optimize(AST_Arrow, opt_AST_Lambda);
  20332. def_optimize(AST_Function, function(self, compressor) {
  20333. self = opt_AST_Lambda(self, compressor);
  20334. if (compressor.option("unsafe_arrows")
  20335. && compressor.option("ecma") >= 2015
  20336. && !self.name
  20337. && !self.is_generator
  20338. && !self.uses_arguments
  20339. && !self.pinned()) {
  20340. const uses_this = walk(self, node => {
  20341. if (node instanceof AST_This) return walk_abort;
  20342. });
  20343. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  20344. }
  20345. return self;
  20346. });
  20347. def_optimize(AST_Class, function(self) {
  20348. for (let i = 0; i < self.properties.length; i++) {
  20349. const prop = self.properties[i];
  20350. if (prop instanceof AST_ClassStaticBlock && prop.body.length == 0) {
  20351. self.properties.splice(i, 1);
  20352. i--;
  20353. }
  20354. }
  20355. return self;
  20356. });
  20357. def_optimize(AST_ClassStaticBlock, function(self, compressor) {
  20358. tighten_body(self.body, compressor);
  20359. return self;
  20360. });
  20361. def_optimize(AST_Yield, function(self, compressor) {
  20362. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  20363. self.expression = null;
  20364. }
  20365. return self;
  20366. });
  20367. def_optimize(AST_TemplateString, function(self, compressor) {
  20368. if (
  20369. !compressor.option("evaluate")
  20370. || compressor.parent() instanceof AST_PrefixedTemplateString
  20371. ) {
  20372. return self;
  20373. }
  20374. var segments = [];
  20375. for (var i = 0; i < self.segments.length; i++) {
  20376. var segment = self.segments[i];
  20377. if (segment instanceof AST_Node) {
  20378. var result = segment.evaluate(compressor);
  20379. // Evaluate to constant value
  20380. // Constant value shorter than ${segment}
  20381. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  20382. // There should always be a previous and next segment if segment is a node
  20383. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  20384. continue;
  20385. }
  20386. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  20387. // TODO:
  20388. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  20389. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  20390. if (segment instanceof AST_TemplateString) {
  20391. var inners = segment.segments;
  20392. segments[segments.length - 1].value += inners[0].value;
  20393. for (var j = 1; j < inners.length; j++) {
  20394. segment = inners[j];
  20395. segments.push(segment);
  20396. }
  20397. continue;
  20398. }
  20399. }
  20400. segments.push(segment);
  20401. }
  20402. self.segments = segments;
  20403. // `foo` => "foo"
  20404. if (segments.length == 1) {
  20405. return make_node(AST_String, self, segments[0]);
  20406. }
  20407. if (
  20408. segments.length === 3
  20409. && segments[1] instanceof AST_Node
  20410. && (
  20411. segments[1].is_string(compressor)
  20412. || segments[1].is_number(compressor)
  20413. || is_nullish(segments[1], compressor)
  20414. || compressor.option("unsafe")
  20415. )
  20416. ) {
  20417. // `foo${bar}` => "foo" + bar
  20418. if (segments[2].value === "") {
  20419. return make_node(AST_Binary, self, {
  20420. operator: "+",
  20421. left: make_node(AST_String, self, {
  20422. value: segments[0].value,
  20423. }),
  20424. right: segments[1],
  20425. });
  20426. }
  20427. // `${bar}baz` => bar + "baz"
  20428. if (segments[0].value === "") {
  20429. return make_node(AST_Binary, self, {
  20430. operator: "+",
  20431. left: segments[1],
  20432. right: make_node(AST_String, self, {
  20433. value: segments[2].value,
  20434. }),
  20435. });
  20436. }
  20437. }
  20438. return self;
  20439. });
  20440. def_optimize(AST_PrefixedTemplateString, function(self) {
  20441. return self;
  20442. });
  20443. // ["p"]:1 ---> p:1
  20444. // [42]:1 ---> 42:1
  20445. function lift_key(self, compressor) {
  20446. if (!compressor.option("computed_props")) return self;
  20447. // save a comparison in the typical case
  20448. if (!(self.key instanceof AST_Constant)) return self;
  20449. // allow certain acceptable props as not all AST_Constants are true constants
  20450. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  20451. const key = self.key.value.toString();
  20452. if (key === "__proto__") return self;
  20453. if (key == "constructor"
  20454. && compressor.parent() instanceof AST_Class) return self;
  20455. if (self instanceof AST_ObjectKeyVal) {
  20456. self.quote = self.key.quote;
  20457. self.key = key;
  20458. } else if (self instanceof AST_ClassProperty) {
  20459. self.quote = self.key.quote;
  20460. self.key = make_node(AST_SymbolClassProperty, self.key, {
  20461. name: key,
  20462. });
  20463. } else {
  20464. self.quote = self.key.quote;
  20465. self.key = make_node(AST_SymbolMethod, self.key, {
  20466. name: key,
  20467. });
  20468. }
  20469. }
  20470. return self;
  20471. }
  20472. def_optimize(AST_ObjectProperty, lift_key);
  20473. def_optimize(AST_ConciseMethod, function(self, compressor) {
  20474. lift_key(self, compressor);
  20475. // p(){return x;} ---> p:()=>x
  20476. if (compressor.option("arrows")
  20477. && compressor.parent() instanceof AST_Object
  20478. && !self.is_generator
  20479. && !self.value.uses_arguments
  20480. && !self.value.pinned()
  20481. && self.value.body.length == 1
  20482. && self.value.body[0] instanceof AST_Return
  20483. && self.value.body[0].value
  20484. && !self.value.contains_this()) {
  20485. var arrow = make_node(AST_Arrow, self.value, self.value);
  20486. arrow.async = self.async;
  20487. arrow.is_generator = self.is_generator;
  20488. return make_node(AST_ObjectKeyVal, self, {
  20489. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  20490. value: arrow,
  20491. quote: self.quote,
  20492. });
  20493. }
  20494. return self;
  20495. });
  20496. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  20497. lift_key(self, compressor);
  20498. // p:function(){} ---> p(){}
  20499. // p:function*(){} ---> *p(){}
  20500. // p:async function(){} ---> async p(){}
  20501. // p:()=>{} ---> p(){}
  20502. // p:async()=>{} ---> async p(){}
  20503. var unsafe_methods = compressor.option("unsafe_methods");
  20504. if (unsafe_methods
  20505. && compressor.option("ecma") >= 2015
  20506. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  20507. var key = self.key;
  20508. var value = self.value;
  20509. var is_arrow_with_block = value instanceof AST_Arrow
  20510. && Array.isArray(value.body)
  20511. && !value.contains_this();
  20512. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  20513. return make_node(AST_ConciseMethod, self, {
  20514. async: value.async,
  20515. is_generator: value.is_generator,
  20516. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  20517. name: key,
  20518. }),
  20519. value: make_node(AST_Accessor, value, value),
  20520. quote: self.quote,
  20521. });
  20522. }
  20523. }
  20524. return self;
  20525. });
  20526. def_optimize(AST_Destructuring, function(self, compressor) {
  20527. if (compressor.option("pure_getters") == true
  20528. && compressor.option("unused")
  20529. && !self.is_array
  20530. && Array.isArray(self.names)
  20531. && !is_destructuring_export_decl(compressor)
  20532. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  20533. var keep = [];
  20534. for (var i = 0; i < self.names.length; i++) {
  20535. var elem = self.names[i];
  20536. if (!(elem instanceof AST_ObjectKeyVal
  20537. && typeof elem.key == "string"
  20538. && elem.value instanceof AST_SymbolDeclaration
  20539. && !should_retain(compressor, elem.value.definition()))) {
  20540. keep.push(elem);
  20541. }
  20542. }
  20543. if (keep.length != self.names.length) {
  20544. self.names = keep;
  20545. }
  20546. }
  20547. return self;
  20548. function is_destructuring_export_decl(compressor) {
  20549. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  20550. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  20551. var parent = compressor.parent(p);
  20552. if (!parent) return false;
  20553. if (a === 0 && parent.TYPE == "Destructuring") continue;
  20554. if (!ancestors[a].test(parent.TYPE)) {
  20555. return false;
  20556. }
  20557. a++;
  20558. }
  20559. return true;
  20560. }
  20561. function should_retain(compressor, def) {
  20562. if (def.references.length) return true;
  20563. if (!def.global) return false;
  20564. if (compressor.toplevel.vars) {
  20565. if (compressor.top_retain) {
  20566. return compressor.top_retain(def);
  20567. }
  20568. return false;
  20569. }
  20570. return true;
  20571. }
  20572. });
  20573. /***********************************************************************
  20574. A JavaScript tokenizer / parser / beautifier / compressor.
  20575. https://github.com/mishoo/UglifyJS2
  20576. -------------------------------- (C) ---------------------------------
  20577. Author: Mihai Bazon
  20578. <mihai.bazon@gmail.com>
  20579. http://mihai.bazon.net/blog
  20580. Distributed under the BSD license:
  20581. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  20582. Redistribution and use in source and binary forms, with or without
  20583. modification, are permitted provided that the following conditions
  20584. are met:
  20585. * Redistributions of source code must retain the above
  20586. copyright notice, this list of conditions and the following
  20587. disclaimer.
  20588. * Redistributions in binary form must reproduce the above
  20589. copyright notice, this list of conditions and the following
  20590. disclaimer in the documentation and/or other materials
  20591. provided with the distribution.
  20592. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  20593. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20594. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20595. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  20596. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  20597. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20598. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20599. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20600. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  20601. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  20602. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  20603. SUCH DAMAGE.
  20604. ***********************************************************************/
  20605. // a small wrapper around source-map and @jridgewell/source-map
  20606. function* SourceMap(options) {
  20607. options = defaults(options, {
  20608. file : null,
  20609. root : null,
  20610. orig : null,
  20611. files: {},
  20612. });
  20613. var orig_map;
  20614. var generator = new sourceMap.SourceMapGenerator({
  20615. file : options.file,
  20616. sourceRoot : options.root
  20617. });
  20618. let sourcesContent = {__proto__: null};
  20619. let files = options.files;
  20620. for (var name in files) if (HOP(files, name)) {
  20621. sourcesContent[name] = files[name];
  20622. }
  20623. if (options.orig) {
  20624. // We support both @jridgewell/source-map (which has a sync
  20625. // SourceMapConsumer) and source-map (which has an async
  20626. // SourceMapConsumer).
  20627. orig_map = yield new sourceMap.SourceMapConsumer(options.orig);
  20628. if (orig_map.sourcesContent) {
  20629. orig_map.sources.forEach(function(source, i) {
  20630. var content = orig_map.sourcesContent[i];
  20631. if (content) {
  20632. sourcesContent[source] = content;
  20633. }
  20634. });
  20635. }
  20636. }
  20637. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  20638. let generatedPos = { line: gen_line, column: gen_col };
  20639. if (orig_map) {
  20640. var info = orig_map.originalPositionFor({
  20641. line: orig_line,
  20642. column: orig_col
  20643. });
  20644. if (info.source === null) {
  20645. generator.addMapping({
  20646. generated: generatedPos,
  20647. original: null,
  20648. source: null,
  20649. name: null
  20650. });
  20651. return;
  20652. }
  20653. source = info.source;
  20654. orig_line = info.line;
  20655. orig_col = info.column;
  20656. name = info.name || name;
  20657. }
  20658. generator.addMapping({
  20659. generated : generatedPos,
  20660. original : { line: orig_line, column: orig_col },
  20661. source : source,
  20662. name : name
  20663. });
  20664. generator.setSourceContent(source, sourcesContent[source]);
  20665. }
  20666. function clean(map) {
  20667. const allNull = map.sourcesContent && map.sourcesContent.every(c => c == null);
  20668. if (allNull) delete map.sourcesContent;
  20669. if (map.file === undefined) delete map.file;
  20670. if (map.sourceRoot === undefined) delete map.sourceRoot;
  20671. return map;
  20672. }
  20673. function getDecoded() {
  20674. if (!generator.toDecodedMap) return null;
  20675. return clean(generator.toDecodedMap());
  20676. }
  20677. function getEncoded() {
  20678. return clean(generator.toJSON());
  20679. }
  20680. function destroy() {
  20681. // @jridgewell/source-map's SourceMapConsumer does not need to be
  20682. // manually freed.
  20683. if (orig_map && orig_map.destroy) orig_map.destroy();
  20684. }
  20685. return {
  20686. add,
  20687. getDecoded,
  20688. getEncoded,
  20689. destroy,
  20690. };
  20691. }
  20692. var domprops = [
  20693. "$&",
  20694. "$'",
  20695. "$*",
  20696. "$+",
  20697. "$1",
  20698. "$2",
  20699. "$3",
  20700. "$4",
  20701. "$5",
  20702. "$6",
  20703. "$7",
  20704. "$8",
  20705. "$9",
  20706. "$_",
  20707. "$`",
  20708. "$input",
  20709. "-moz-animation",
  20710. "-moz-animation-delay",
  20711. "-moz-animation-direction",
  20712. "-moz-animation-duration",
  20713. "-moz-animation-fill-mode",
  20714. "-moz-animation-iteration-count",
  20715. "-moz-animation-name",
  20716. "-moz-animation-play-state",
  20717. "-moz-animation-timing-function",
  20718. "-moz-appearance",
  20719. "-moz-backface-visibility",
  20720. "-moz-border-end",
  20721. "-moz-border-end-color",
  20722. "-moz-border-end-style",
  20723. "-moz-border-end-width",
  20724. "-moz-border-image",
  20725. "-moz-border-start",
  20726. "-moz-border-start-color",
  20727. "-moz-border-start-style",
  20728. "-moz-border-start-width",
  20729. "-moz-box-align",
  20730. "-moz-box-direction",
  20731. "-moz-box-flex",
  20732. "-moz-box-ordinal-group",
  20733. "-moz-box-orient",
  20734. "-moz-box-pack",
  20735. "-moz-box-sizing",
  20736. "-moz-float-edge",
  20737. "-moz-font-feature-settings",
  20738. "-moz-font-language-override",
  20739. "-moz-force-broken-image-icon",
  20740. "-moz-hyphens",
  20741. "-moz-image-region",
  20742. "-moz-margin-end",
  20743. "-moz-margin-start",
  20744. "-moz-orient",
  20745. "-moz-osx-font-smoothing",
  20746. "-moz-outline-radius",
  20747. "-moz-outline-radius-bottomleft",
  20748. "-moz-outline-radius-bottomright",
  20749. "-moz-outline-radius-topleft",
  20750. "-moz-outline-radius-topright",
  20751. "-moz-padding-end",
  20752. "-moz-padding-start",
  20753. "-moz-perspective",
  20754. "-moz-perspective-origin",
  20755. "-moz-tab-size",
  20756. "-moz-text-size-adjust",
  20757. "-moz-transform",
  20758. "-moz-transform-origin",
  20759. "-moz-transform-style",
  20760. "-moz-transition",
  20761. "-moz-transition-delay",
  20762. "-moz-transition-duration",
  20763. "-moz-transition-property",
  20764. "-moz-transition-timing-function",
  20765. "-moz-user-focus",
  20766. "-moz-user-input",
  20767. "-moz-user-modify",
  20768. "-moz-user-select",
  20769. "-moz-window-dragging",
  20770. "-webkit-align-content",
  20771. "-webkit-align-items",
  20772. "-webkit-align-self",
  20773. "-webkit-animation",
  20774. "-webkit-animation-delay",
  20775. "-webkit-animation-direction",
  20776. "-webkit-animation-duration",
  20777. "-webkit-animation-fill-mode",
  20778. "-webkit-animation-iteration-count",
  20779. "-webkit-animation-name",
  20780. "-webkit-animation-play-state",
  20781. "-webkit-animation-timing-function",
  20782. "-webkit-appearance",
  20783. "-webkit-backface-visibility",
  20784. "-webkit-background-clip",
  20785. "-webkit-background-origin",
  20786. "-webkit-background-size",
  20787. "-webkit-border-bottom-left-radius",
  20788. "-webkit-border-bottom-right-radius",
  20789. "-webkit-border-image",
  20790. "-webkit-border-radius",
  20791. "-webkit-border-top-left-radius",
  20792. "-webkit-border-top-right-radius",
  20793. "-webkit-box-align",
  20794. "-webkit-box-direction",
  20795. "-webkit-box-flex",
  20796. "-webkit-box-ordinal-group",
  20797. "-webkit-box-orient",
  20798. "-webkit-box-pack",
  20799. "-webkit-box-shadow",
  20800. "-webkit-box-sizing",
  20801. "-webkit-clip-path",
  20802. "-webkit-filter",
  20803. "-webkit-flex",
  20804. "-webkit-flex-basis",
  20805. "-webkit-flex-direction",
  20806. "-webkit-flex-flow",
  20807. "-webkit-flex-grow",
  20808. "-webkit-flex-shrink",
  20809. "-webkit-flex-wrap",
  20810. "-webkit-font-feature-settings",
  20811. "-webkit-justify-content",
  20812. "-webkit-line-clamp",
  20813. "-webkit-mask",
  20814. "-webkit-mask-clip",
  20815. "-webkit-mask-composite",
  20816. "-webkit-mask-image",
  20817. "-webkit-mask-origin",
  20818. "-webkit-mask-position",
  20819. "-webkit-mask-position-x",
  20820. "-webkit-mask-position-y",
  20821. "-webkit-mask-repeat",
  20822. "-webkit-mask-size",
  20823. "-webkit-order",
  20824. "-webkit-perspective",
  20825. "-webkit-perspective-origin",
  20826. "-webkit-text-fill-color",
  20827. "-webkit-text-security",
  20828. "-webkit-text-size-adjust",
  20829. "-webkit-text-stroke",
  20830. "-webkit-text-stroke-color",
  20831. "-webkit-text-stroke-width",
  20832. "-webkit-transform",
  20833. "-webkit-transform-origin",
  20834. "-webkit-transform-style",
  20835. "-webkit-transition",
  20836. "-webkit-transition-delay",
  20837. "-webkit-transition-duration",
  20838. "-webkit-transition-property",
  20839. "-webkit-transition-timing-function",
  20840. "-webkit-user-select",
  20841. "@@iterator",
  20842. "ABORT_ERR",
  20843. "ACTIVE",
  20844. "ACTIVE_ATTRIBUTES",
  20845. "ACTIVE_TEXTURE",
  20846. "ACTIVE_UNIFORMS",
  20847. "ACTIVE_UNIFORM_BLOCKS",
  20848. "ADDITION",
  20849. "ALIASED_LINE_WIDTH_RANGE",
  20850. "ALIASED_POINT_SIZE_RANGE",
  20851. "ALL",
  20852. "ALLOW_KEYBOARD_INPUT",
  20853. "ALLPASS",
  20854. "ALPHA",
  20855. "ALPHA_BITS",
  20856. "ALREADY_SIGNALED",
  20857. "ALT_MASK",
  20858. "ALWAYS",
  20859. "ANY_SAMPLES_PASSED",
  20860. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  20861. "ANY_TYPE",
  20862. "ANY_UNORDERED_NODE_TYPE",
  20863. "ARRAY_BUFFER",
  20864. "ARRAY_BUFFER_BINDING",
  20865. "ATTACHED_SHADERS",
  20866. "ATTRIBUTE_NODE",
  20867. "AT_TARGET",
  20868. "AbortController",
  20869. "AbortSignal",
  20870. "AbsoluteOrientationSensor",
  20871. "AbstractRange",
  20872. "Accelerometer",
  20873. "AddSearchProvider",
  20874. "AggregateError",
  20875. "AnalyserNode",
  20876. "Animation",
  20877. "AnimationEffect",
  20878. "AnimationEvent",
  20879. "AnimationPlaybackEvent",
  20880. "AnimationTimeline",
  20881. "AnonXMLHttpRequest",
  20882. "Any",
  20883. "AnyPermissions",
  20884. "ApplicationCache",
  20885. "ApplicationCacheErrorEvent",
  20886. "Array",
  20887. "ArrayBuffer",
  20888. "ArrayType",
  20889. "Atomics",
  20890. "Attr",
  20891. "Audio",
  20892. "AudioBuffer",
  20893. "AudioBufferSourceNode",
  20894. "AudioContext",
  20895. "AudioData",
  20896. "AudioDecoder",
  20897. "AudioDestinationNode",
  20898. "AudioEncoder",
  20899. "AudioListener",
  20900. "AudioNode",
  20901. "AudioParam",
  20902. "AudioParamMap",
  20903. "AudioProcessingEvent",
  20904. "AudioScheduledSourceNode",
  20905. "AudioSinkInfo",
  20906. "AudioStreamTrack",
  20907. "AudioWorklet",
  20908. "AudioWorkletNode",
  20909. "AuthenticatorAssertionResponse",
  20910. "AuthenticatorAttestationResponse",
  20911. "AuthenticatorResponse",
  20912. "AutocompleteErrorEvent",
  20913. "BACK",
  20914. "BAD_BOUNDARYPOINTS_ERR",
  20915. "BAD_REQUEST",
  20916. "BANDPASS",
  20917. "BLEND",
  20918. "BLEND_COLOR",
  20919. "BLEND_DST_ALPHA",
  20920. "BLEND_DST_RGB",
  20921. "BLEND_EQUATION",
  20922. "BLEND_EQUATION_ALPHA",
  20923. "BLEND_EQUATION_RGB",
  20924. "BLEND_SRC_ALPHA",
  20925. "BLEND_SRC_RGB",
  20926. "BLUE",
  20927. "BLUE_BITS",
  20928. "BLUR",
  20929. "BOOL",
  20930. "BOOLEAN_TYPE",
  20931. "BOOL_VEC2",
  20932. "BOOL_VEC3",
  20933. "BOOL_VEC4",
  20934. "BOTH",
  20935. "BROWSER_DEFAULT_WEBGL",
  20936. "BUBBLING_PHASE",
  20937. "BUFFER_SIZE",
  20938. "BUFFER_USAGE",
  20939. "BYTE",
  20940. "BYTES_PER_ELEMENT",
  20941. "BackgroundFetchManager",
  20942. "BackgroundFetchRecord",
  20943. "BackgroundFetchRegistration",
  20944. "BarProp",
  20945. "BarcodeDetector",
  20946. "BaseAudioContext",
  20947. "BaseHref",
  20948. "BatteryManager",
  20949. "BeforeInstallPromptEvent",
  20950. "BeforeLoadEvent",
  20951. "BeforeUnloadEvent",
  20952. "BigInt",
  20953. "BigInt64Array",
  20954. "BigUint64Array",
  20955. "BiquadFilterNode",
  20956. "Blob",
  20957. "BlobEvent",
  20958. "Bluetooth",
  20959. "BluetoothCharacteristicProperties",
  20960. "BluetoothDevice",
  20961. "BluetoothRemoteGATTCharacteristic",
  20962. "BluetoothRemoteGATTDescriptor",
  20963. "BluetoothRemoteGATTServer",
  20964. "BluetoothRemoteGATTService",
  20965. "BluetoothUUID",
  20966. "Boolean",
  20967. "BroadcastChannel",
  20968. "BrowserCaptureMediaStreamTrack",
  20969. "BrowserInfo",
  20970. "ByteLengthQueuingStrategy",
  20971. "CAPTURING_PHASE",
  20972. "CCW",
  20973. "CDATASection",
  20974. "CDATA_SECTION_NODE",
  20975. "CHANGE",
  20976. "CHARSET_RULE",
  20977. "CHECKING",
  20978. "CLAMP_TO_EDGE",
  20979. "CLICK",
  20980. "CLOSED",
  20981. "CLOSING",
  20982. "COLOR",
  20983. "COLOR_ATTACHMENT0",
  20984. "COLOR_ATTACHMENT1",
  20985. "COLOR_ATTACHMENT10",
  20986. "COLOR_ATTACHMENT11",
  20987. "COLOR_ATTACHMENT12",
  20988. "COLOR_ATTACHMENT13",
  20989. "COLOR_ATTACHMENT14",
  20990. "COLOR_ATTACHMENT15",
  20991. "COLOR_ATTACHMENT2",
  20992. "COLOR_ATTACHMENT3",
  20993. "COLOR_ATTACHMENT4",
  20994. "COLOR_ATTACHMENT5",
  20995. "COLOR_ATTACHMENT6",
  20996. "COLOR_ATTACHMENT7",
  20997. "COLOR_ATTACHMENT8",
  20998. "COLOR_ATTACHMENT9",
  20999. "COLOR_BUFFER_BIT",
  21000. "COLOR_CLEAR_VALUE",
  21001. "COLOR_WRITEMASK",
  21002. "COMMENT_NODE",
  21003. "COMPARE_REF_TO_TEXTURE",
  21004. "COMPILE_STATUS",
  21005. "COMPLETION_STATUS_KHR",
  21006. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  21007. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  21008. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  21009. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  21010. "COMPRESSED_TEXTURE_FORMATS",
  21011. "COMPUTE",
  21012. "CONDITION_SATISFIED",
  21013. "CONFIGURATION_UNSUPPORTED",
  21014. "CONNECTING",
  21015. "CONSTANT_ALPHA",
  21016. "CONSTANT_COLOR",
  21017. "CONSTRAINT_ERR",
  21018. "CONTEXT_LOST_WEBGL",
  21019. "CONTROL_MASK",
  21020. "COPY_DST",
  21021. "COPY_READ_BUFFER",
  21022. "COPY_READ_BUFFER_BINDING",
  21023. "COPY_SRC",
  21024. "COPY_WRITE_BUFFER",
  21025. "COPY_WRITE_BUFFER_BINDING",
  21026. "COUNTER_STYLE_RULE",
  21027. "CSS",
  21028. "CSS2Properties",
  21029. "CSSAnimation",
  21030. "CSSCharsetRule",
  21031. "CSSConditionRule",
  21032. "CSSContainerRule",
  21033. "CSSCounterStyleRule",
  21034. "CSSFontFaceRule",
  21035. "CSSFontFeatureValuesRule",
  21036. "CSSFontPaletteValuesRule",
  21037. "CSSGroupingRule",
  21038. "CSSImageValue",
  21039. "CSSImportRule",
  21040. "CSSKeyframeRule",
  21041. "CSSKeyframesRule",
  21042. "CSSKeywordValue",
  21043. "CSSLayerBlockRule",
  21044. "CSSLayerStatementRule",
  21045. "CSSMarginRule",
  21046. "CSSMathClamp",
  21047. "CSSMathInvert",
  21048. "CSSMathMax",
  21049. "CSSMathMin",
  21050. "CSSMathNegate",
  21051. "CSSMathProduct",
  21052. "CSSMathSum",
  21053. "CSSMathValue",
  21054. "CSSMatrixComponent",
  21055. "CSSMediaRule",
  21056. "CSSMozDocumentRule",
  21057. "CSSNameSpaceRule",
  21058. "CSSNamespaceRule",
  21059. "CSSNestedDeclarations",
  21060. "CSSNumericArray",
  21061. "CSSNumericValue",
  21062. "CSSPageDescriptors",
  21063. "CSSPageRule",
  21064. "CSSPerspective",
  21065. "CSSPositionTryDescriptors",
  21066. "CSSPositionTryRule",
  21067. "CSSPositionValue",
  21068. "CSSPrimitiveValue",
  21069. "CSSPropertyRule",
  21070. "CSSRotate",
  21071. "CSSRule",
  21072. "CSSRuleList",
  21073. "CSSScale",
  21074. "CSSScopeRule",
  21075. "CSSSkew",
  21076. "CSSSkewX",
  21077. "CSSSkewY",
  21078. "CSSStartingStyleRule",
  21079. "CSSStyleDeclaration",
  21080. "CSSStyleRule",
  21081. "CSSStyleSheet",
  21082. "CSSStyleValue",
  21083. "CSSSupportsRule",
  21084. "CSSTransformComponent",
  21085. "CSSTransformValue",
  21086. "CSSTransition",
  21087. "CSSTranslate",
  21088. "CSSUnitValue",
  21089. "CSSUnknownRule",
  21090. "CSSUnparsedValue",
  21091. "CSSValue",
  21092. "CSSValueList",
  21093. "CSSVariableReferenceValue",
  21094. "CSSVariablesDeclaration",
  21095. "CSSVariablesRule",
  21096. "CSSViewTransitionRule",
  21097. "CSSViewportRule",
  21098. "CSS_ATTR",
  21099. "CSS_CM",
  21100. "CSS_COUNTER",
  21101. "CSS_CUSTOM",
  21102. "CSS_DEG",
  21103. "CSS_DIMENSION",
  21104. "CSS_EMS",
  21105. "CSS_EXS",
  21106. "CSS_FILTER_BLUR",
  21107. "CSS_FILTER_BRIGHTNESS",
  21108. "CSS_FILTER_CONTRAST",
  21109. "CSS_FILTER_CUSTOM",
  21110. "CSS_FILTER_DROP_SHADOW",
  21111. "CSS_FILTER_GRAYSCALE",
  21112. "CSS_FILTER_HUE_ROTATE",
  21113. "CSS_FILTER_INVERT",
  21114. "CSS_FILTER_OPACITY",
  21115. "CSS_FILTER_REFERENCE",
  21116. "CSS_FILTER_SATURATE",
  21117. "CSS_FILTER_SEPIA",
  21118. "CSS_GRAD",
  21119. "CSS_HZ",
  21120. "CSS_IDENT",
  21121. "CSS_IN",
  21122. "CSS_INHERIT",
  21123. "CSS_KHZ",
  21124. "CSS_MATRIX",
  21125. "CSS_MATRIX3D",
  21126. "CSS_MM",
  21127. "CSS_MS",
  21128. "CSS_NUMBER",
  21129. "CSS_PC",
  21130. "CSS_PERCENTAGE",
  21131. "CSS_PERSPECTIVE",
  21132. "CSS_PRIMITIVE_VALUE",
  21133. "CSS_PT",
  21134. "CSS_PX",
  21135. "CSS_RAD",
  21136. "CSS_RECT",
  21137. "CSS_RGBCOLOR",
  21138. "CSS_ROTATE",
  21139. "CSS_ROTATE3D",
  21140. "CSS_ROTATEX",
  21141. "CSS_ROTATEY",
  21142. "CSS_ROTATEZ",
  21143. "CSS_S",
  21144. "CSS_SCALE",
  21145. "CSS_SCALE3D",
  21146. "CSS_SCALEX",
  21147. "CSS_SCALEY",
  21148. "CSS_SCALEZ",
  21149. "CSS_SKEW",
  21150. "CSS_SKEWX",
  21151. "CSS_SKEWY",
  21152. "CSS_STRING",
  21153. "CSS_TRANSLATE",
  21154. "CSS_TRANSLATE3D",
  21155. "CSS_TRANSLATEX",
  21156. "CSS_TRANSLATEY",
  21157. "CSS_TRANSLATEZ",
  21158. "CSS_UNKNOWN",
  21159. "CSS_URI",
  21160. "CSS_VALUE_LIST",
  21161. "CSS_VH",
  21162. "CSS_VMAX",
  21163. "CSS_VMIN",
  21164. "CSS_VW",
  21165. "CULL_FACE",
  21166. "CULL_FACE_MODE",
  21167. "CURRENT_PROGRAM",
  21168. "CURRENT_QUERY",
  21169. "CURRENT_VERTEX_ATTRIB",
  21170. "CUSTOM",
  21171. "CW",
  21172. "Cache",
  21173. "CacheStorage",
  21174. "CanvasCaptureMediaStream",
  21175. "CanvasCaptureMediaStreamTrack",
  21176. "CanvasGradient",
  21177. "CanvasPattern",
  21178. "CanvasRenderingContext2D",
  21179. "CaptureController",
  21180. "CaretPosition",
  21181. "ChannelMergerNode",
  21182. "ChannelSplitterNode",
  21183. "ChapterInformation",
  21184. "CharacterBoundsUpdateEvent",
  21185. "CharacterData",
  21186. "ClientRect",
  21187. "ClientRectList",
  21188. "Clipboard",
  21189. "ClipboardEvent",
  21190. "ClipboardItem",
  21191. "CloseEvent",
  21192. "CloseWatcher",
  21193. "Collator",
  21194. "ColorArray",
  21195. "ColorValue",
  21196. "CommandEvent",
  21197. "Comment",
  21198. "CompileError",
  21199. "CompositionEvent",
  21200. "CompressionStream",
  21201. "Console",
  21202. "ConstantSourceNode",
  21203. "ContentVisibilityAutoStateChangeEvent",
  21204. "ContextFilter",
  21205. "ContextType",
  21206. "Controllers",
  21207. "ConvolverNode",
  21208. "CookieChangeEvent",
  21209. "CookieStore",
  21210. "CookieStoreManager",
  21211. "CountQueuingStrategy",
  21212. "Counter",
  21213. "CreateType",
  21214. "Credential",
  21215. "CredentialsContainer",
  21216. "CropTarget",
  21217. "Crypto",
  21218. "CryptoKey",
  21219. "CustomElementRegistry",
  21220. "CustomEvent",
  21221. "CustomStateSet",
  21222. "DATABASE_ERR",
  21223. "DATA_CLONE_ERR",
  21224. "DATA_ERR",
  21225. "DBLCLICK",
  21226. "DECR",
  21227. "DECR_WRAP",
  21228. "DELETE_STATUS",
  21229. "DEPTH",
  21230. "DEPTH24_STENCIL8",
  21231. "DEPTH32F_STENCIL8",
  21232. "DEPTH_ATTACHMENT",
  21233. "DEPTH_BITS",
  21234. "DEPTH_BUFFER_BIT",
  21235. "DEPTH_CLEAR_VALUE",
  21236. "DEPTH_COMPONENT",
  21237. "DEPTH_COMPONENT16",
  21238. "DEPTH_COMPONENT24",
  21239. "DEPTH_COMPONENT32F",
  21240. "DEPTH_FUNC",
  21241. "DEPTH_RANGE",
  21242. "DEPTH_STENCIL",
  21243. "DEPTH_STENCIL_ATTACHMENT",
  21244. "DEPTH_TEST",
  21245. "DEPTH_WRITEMASK",
  21246. "DEVICE_INELIGIBLE",
  21247. "DIRECTION_DOWN",
  21248. "DIRECTION_LEFT",
  21249. "DIRECTION_RIGHT",
  21250. "DIRECTION_UP",
  21251. "DISABLED",
  21252. "DISPATCH_REQUEST_ERR",
  21253. "DITHER",
  21254. "DOCUMENT_FRAGMENT_NODE",
  21255. "DOCUMENT_NODE",
  21256. "DOCUMENT_POSITION_CONTAINED_BY",
  21257. "DOCUMENT_POSITION_CONTAINS",
  21258. "DOCUMENT_POSITION_DISCONNECTED",
  21259. "DOCUMENT_POSITION_FOLLOWING",
  21260. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  21261. "DOCUMENT_POSITION_PRECEDING",
  21262. "DOCUMENT_TYPE_NODE",
  21263. "DOMCursor",
  21264. "DOMError",
  21265. "DOMException",
  21266. "DOMImplementation",
  21267. "DOMImplementationLS",
  21268. "DOMMatrix",
  21269. "DOMMatrixReadOnly",
  21270. "DOMParser",
  21271. "DOMPoint",
  21272. "DOMPointReadOnly",
  21273. "DOMQuad",
  21274. "DOMRect",
  21275. "DOMRectList",
  21276. "DOMRectReadOnly",
  21277. "DOMRequest",
  21278. "DOMSTRING_SIZE_ERR",
  21279. "DOMSettableTokenList",
  21280. "DOMStringList",
  21281. "DOMStringMap",
  21282. "DOMTokenList",
  21283. "DOMTransactionEvent",
  21284. "DOM_DELTA_LINE",
  21285. "DOM_DELTA_PAGE",
  21286. "DOM_DELTA_PIXEL",
  21287. "DOM_INPUT_METHOD_DROP",
  21288. "DOM_INPUT_METHOD_HANDWRITING",
  21289. "DOM_INPUT_METHOD_IME",
  21290. "DOM_INPUT_METHOD_KEYBOARD",
  21291. "DOM_INPUT_METHOD_MULTIMODAL",
  21292. "DOM_INPUT_METHOD_OPTION",
  21293. "DOM_INPUT_METHOD_PASTE",
  21294. "DOM_INPUT_METHOD_SCRIPT",
  21295. "DOM_INPUT_METHOD_UNKNOWN",
  21296. "DOM_INPUT_METHOD_VOICE",
  21297. "DOM_KEY_LOCATION_JOYSTICK",
  21298. "DOM_KEY_LOCATION_LEFT",
  21299. "DOM_KEY_LOCATION_MOBILE",
  21300. "DOM_KEY_LOCATION_NUMPAD",
  21301. "DOM_KEY_LOCATION_RIGHT",
  21302. "DOM_KEY_LOCATION_STANDARD",
  21303. "DOM_VK_0",
  21304. "DOM_VK_1",
  21305. "DOM_VK_2",
  21306. "DOM_VK_3",
  21307. "DOM_VK_4",
  21308. "DOM_VK_5",
  21309. "DOM_VK_6",
  21310. "DOM_VK_7",
  21311. "DOM_VK_8",
  21312. "DOM_VK_9",
  21313. "DOM_VK_A",
  21314. "DOM_VK_ACCEPT",
  21315. "DOM_VK_ADD",
  21316. "DOM_VK_ALT",
  21317. "DOM_VK_ALTGR",
  21318. "DOM_VK_AMPERSAND",
  21319. "DOM_VK_ASTERISK",
  21320. "DOM_VK_AT",
  21321. "DOM_VK_ATTN",
  21322. "DOM_VK_B",
  21323. "DOM_VK_BACKSPACE",
  21324. "DOM_VK_BACK_QUOTE",
  21325. "DOM_VK_BACK_SLASH",
  21326. "DOM_VK_BACK_SPACE",
  21327. "DOM_VK_C",
  21328. "DOM_VK_CANCEL",
  21329. "DOM_VK_CAPS_LOCK",
  21330. "DOM_VK_CIRCUMFLEX",
  21331. "DOM_VK_CLEAR",
  21332. "DOM_VK_CLOSE_BRACKET",
  21333. "DOM_VK_CLOSE_CURLY_BRACKET",
  21334. "DOM_VK_CLOSE_PAREN",
  21335. "DOM_VK_COLON",
  21336. "DOM_VK_COMMA",
  21337. "DOM_VK_CONTEXT_MENU",
  21338. "DOM_VK_CONTROL",
  21339. "DOM_VK_CONVERT",
  21340. "DOM_VK_CRSEL",
  21341. "DOM_VK_CTRL",
  21342. "DOM_VK_D",
  21343. "DOM_VK_DECIMAL",
  21344. "DOM_VK_DELETE",
  21345. "DOM_VK_DIVIDE",
  21346. "DOM_VK_DOLLAR",
  21347. "DOM_VK_DOUBLE_QUOTE",
  21348. "DOM_VK_DOWN",
  21349. "DOM_VK_E",
  21350. "DOM_VK_EISU",
  21351. "DOM_VK_END",
  21352. "DOM_VK_ENTER",
  21353. "DOM_VK_EQUALS",
  21354. "DOM_VK_EREOF",
  21355. "DOM_VK_ESCAPE",
  21356. "DOM_VK_EXCLAMATION",
  21357. "DOM_VK_EXECUTE",
  21358. "DOM_VK_EXSEL",
  21359. "DOM_VK_F",
  21360. "DOM_VK_F1",
  21361. "DOM_VK_F10",
  21362. "DOM_VK_F11",
  21363. "DOM_VK_F12",
  21364. "DOM_VK_F13",
  21365. "DOM_VK_F14",
  21366. "DOM_VK_F15",
  21367. "DOM_VK_F16",
  21368. "DOM_VK_F17",
  21369. "DOM_VK_F18",
  21370. "DOM_VK_F19",
  21371. "DOM_VK_F2",
  21372. "DOM_VK_F20",
  21373. "DOM_VK_F21",
  21374. "DOM_VK_F22",
  21375. "DOM_VK_F23",
  21376. "DOM_VK_F24",
  21377. "DOM_VK_F25",
  21378. "DOM_VK_F26",
  21379. "DOM_VK_F27",
  21380. "DOM_VK_F28",
  21381. "DOM_VK_F29",
  21382. "DOM_VK_F3",
  21383. "DOM_VK_F30",
  21384. "DOM_VK_F31",
  21385. "DOM_VK_F32",
  21386. "DOM_VK_F33",
  21387. "DOM_VK_F34",
  21388. "DOM_VK_F35",
  21389. "DOM_VK_F36",
  21390. "DOM_VK_F4",
  21391. "DOM_VK_F5",
  21392. "DOM_VK_F6",
  21393. "DOM_VK_F7",
  21394. "DOM_VK_F8",
  21395. "DOM_VK_F9",
  21396. "DOM_VK_FINAL",
  21397. "DOM_VK_FRONT",
  21398. "DOM_VK_G",
  21399. "DOM_VK_GREATER_THAN",
  21400. "DOM_VK_H",
  21401. "DOM_VK_HANGUL",
  21402. "DOM_VK_HANJA",
  21403. "DOM_VK_HASH",
  21404. "DOM_VK_HELP",
  21405. "DOM_VK_HK_TOGGLE",
  21406. "DOM_VK_HOME",
  21407. "DOM_VK_HYPHEN_MINUS",
  21408. "DOM_VK_I",
  21409. "DOM_VK_INSERT",
  21410. "DOM_VK_J",
  21411. "DOM_VK_JUNJA",
  21412. "DOM_VK_K",
  21413. "DOM_VK_KANA",
  21414. "DOM_VK_KANJI",
  21415. "DOM_VK_L",
  21416. "DOM_VK_LEFT",
  21417. "DOM_VK_LEFT_TAB",
  21418. "DOM_VK_LESS_THAN",
  21419. "DOM_VK_M",
  21420. "DOM_VK_META",
  21421. "DOM_VK_MODECHANGE",
  21422. "DOM_VK_MULTIPLY",
  21423. "DOM_VK_N",
  21424. "DOM_VK_NONCONVERT",
  21425. "DOM_VK_NUMPAD0",
  21426. "DOM_VK_NUMPAD1",
  21427. "DOM_VK_NUMPAD2",
  21428. "DOM_VK_NUMPAD3",
  21429. "DOM_VK_NUMPAD4",
  21430. "DOM_VK_NUMPAD5",
  21431. "DOM_VK_NUMPAD6",
  21432. "DOM_VK_NUMPAD7",
  21433. "DOM_VK_NUMPAD8",
  21434. "DOM_VK_NUMPAD9",
  21435. "DOM_VK_NUM_LOCK",
  21436. "DOM_VK_O",
  21437. "DOM_VK_OEM_1",
  21438. "DOM_VK_OEM_102",
  21439. "DOM_VK_OEM_2",
  21440. "DOM_VK_OEM_3",
  21441. "DOM_VK_OEM_4",
  21442. "DOM_VK_OEM_5",
  21443. "DOM_VK_OEM_6",
  21444. "DOM_VK_OEM_7",
  21445. "DOM_VK_OEM_8",
  21446. "DOM_VK_OEM_COMMA",
  21447. "DOM_VK_OEM_MINUS",
  21448. "DOM_VK_OEM_PERIOD",
  21449. "DOM_VK_OEM_PLUS",
  21450. "DOM_VK_OPEN_BRACKET",
  21451. "DOM_VK_OPEN_CURLY_BRACKET",
  21452. "DOM_VK_OPEN_PAREN",
  21453. "DOM_VK_P",
  21454. "DOM_VK_PA1",
  21455. "DOM_VK_PAGEDOWN",
  21456. "DOM_VK_PAGEUP",
  21457. "DOM_VK_PAGE_DOWN",
  21458. "DOM_VK_PAGE_UP",
  21459. "DOM_VK_PAUSE",
  21460. "DOM_VK_PERCENT",
  21461. "DOM_VK_PERIOD",
  21462. "DOM_VK_PIPE",
  21463. "DOM_VK_PLAY",
  21464. "DOM_VK_PLUS",
  21465. "DOM_VK_PRINT",
  21466. "DOM_VK_PRINTSCREEN",
  21467. "DOM_VK_PROCESSKEY",
  21468. "DOM_VK_PROPERITES",
  21469. "DOM_VK_Q",
  21470. "DOM_VK_QUESTION_MARK",
  21471. "DOM_VK_QUOTE",
  21472. "DOM_VK_R",
  21473. "DOM_VK_REDO",
  21474. "DOM_VK_RETURN",
  21475. "DOM_VK_RIGHT",
  21476. "DOM_VK_S",
  21477. "DOM_VK_SCROLL_LOCK",
  21478. "DOM_VK_SELECT",
  21479. "DOM_VK_SEMICOLON",
  21480. "DOM_VK_SEPARATOR",
  21481. "DOM_VK_SHIFT",
  21482. "DOM_VK_SLASH",
  21483. "DOM_VK_SLEEP",
  21484. "DOM_VK_SPACE",
  21485. "DOM_VK_SUBTRACT",
  21486. "DOM_VK_T",
  21487. "DOM_VK_TAB",
  21488. "DOM_VK_TILDE",
  21489. "DOM_VK_U",
  21490. "DOM_VK_UNDERSCORE",
  21491. "DOM_VK_UNDO",
  21492. "DOM_VK_UNICODE",
  21493. "DOM_VK_UP",
  21494. "DOM_VK_V",
  21495. "DOM_VK_VOLUME_DOWN",
  21496. "DOM_VK_VOLUME_MUTE",
  21497. "DOM_VK_VOLUME_UP",
  21498. "DOM_VK_W",
  21499. "DOM_VK_WIN",
  21500. "DOM_VK_WINDOW",
  21501. "DOM_VK_WIN_ICO_00",
  21502. "DOM_VK_WIN_ICO_CLEAR",
  21503. "DOM_VK_WIN_ICO_HELP",
  21504. "DOM_VK_WIN_OEM_ATTN",
  21505. "DOM_VK_WIN_OEM_AUTO",
  21506. "DOM_VK_WIN_OEM_BACKTAB",
  21507. "DOM_VK_WIN_OEM_CLEAR",
  21508. "DOM_VK_WIN_OEM_COPY",
  21509. "DOM_VK_WIN_OEM_CUSEL",
  21510. "DOM_VK_WIN_OEM_ENLW",
  21511. "DOM_VK_WIN_OEM_FINISH",
  21512. "DOM_VK_WIN_OEM_FJ_JISHO",
  21513. "DOM_VK_WIN_OEM_FJ_LOYA",
  21514. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  21515. "DOM_VK_WIN_OEM_FJ_ROYA",
  21516. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  21517. "DOM_VK_WIN_OEM_JUMP",
  21518. "DOM_VK_WIN_OEM_PA1",
  21519. "DOM_VK_WIN_OEM_PA2",
  21520. "DOM_VK_WIN_OEM_PA3",
  21521. "DOM_VK_WIN_OEM_RESET",
  21522. "DOM_VK_WIN_OEM_WSCTRL",
  21523. "DOM_VK_X",
  21524. "DOM_VK_XF86XK_ADD_FAVORITE",
  21525. "DOM_VK_XF86XK_APPLICATION_LEFT",
  21526. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  21527. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  21528. "DOM_VK_XF86XK_AUDIO_FORWARD",
  21529. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  21530. "DOM_VK_XF86XK_AUDIO_MEDIA",
  21531. "DOM_VK_XF86XK_AUDIO_MUTE",
  21532. "DOM_VK_XF86XK_AUDIO_NEXT",
  21533. "DOM_VK_XF86XK_AUDIO_PAUSE",
  21534. "DOM_VK_XF86XK_AUDIO_PLAY",
  21535. "DOM_VK_XF86XK_AUDIO_PREV",
  21536. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  21537. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  21538. "DOM_VK_XF86XK_AUDIO_RECORD",
  21539. "DOM_VK_XF86XK_AUDIO_REPEAT",
  21540. "DOM_VK_XF86XK_AUDIO_REWIND",
  21541. "DOM_VK_XF86XK_AUDIO_STOP",
  21542. "DOM_VK_XF86XK_AWAY",
  21543. "DOM_VK_XF86XK_BACK",
  21544. "DOM_VK_XF86XK_BACK_FORWARD",
  21545. "DOM_VK_XF86XK_BATTERY",
  21546. "DOM_VK_XF86XK_BLUE",
  21547. "DOM_VK_XF86XK_BLUETOOTH",
  21548. "DOM_VK_XF86XK_BOOK",
  21549. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  21550. "DOM_VK_XF86XK_CALCULATOR",
  21551. "DOM_VK_XF86XK_CALENDAR",
  21552. "DOM_VK_XF86XK_CD",
  21553. "DOM_VK_XF86XK_CLOSE",
  21554. "DOM_VK_XF86XK_COMMUNITY",
  21555. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  21556. "DOM_VK_XF86XK_COPY",
  21557. "DOM_VK_XF86XK_CUT",
  21558. "DOM_VK_XF86XK_CYCLE_ANGLE",
  21559. "DOM_VK_XF86XK_DISPLAY",
  21560. "DOM_VK_XF86XK_DOCUMENTS",
  21561. "DOM_VK_XF86XK_DOS",
  21562. "DOM_VK_XF86XK_EJECT",
  21563. "DOM_VK_XF86XK_EXCEL",
  21564. "DOM_VK_XF86XK_EXPLORER",
  21565. "DOM_VK_XF86XK_FAVORITES",
  21566. "DOM_VK_XF86XK_FINANCE",
  21567. "DOM_VK_XF86XK_FORWARD",
  21568. "DOM_VK_XF86XK_FRAME_BACK",
  21569. "DOM_VK_XF86XK_FRAME_FORWARD",
  21570. "DOM_VK_XF86XK_GAME",
  21571. "DOM_VK_XF86XK_GO",
  21572. "DOM_VK_XF86XK_GREEN",
  21573. "DOM_VK_XF86XK_HIBERNATE",
  21574. "DOM_VK_XF86XK_HISTORY",
  21575. "DOM_VK_XF86XK_HOME_PAGE",
  21576. "DOM_VK_XF86XK_HOT_LINKS",
  21577. "DOM_VK_XF86XK_I_TOUCH",
  21578. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  21579. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  21580. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  21581. "DOM_VK_XF86XK_LAUNCH0",
  21582. "DOM_VK_XF86XK_LAUNCH1",
  21583. "DOM_VK_XF86XK_LAUNCH2",
  21584. "DOM_VK_XF86XK_LAUNCH3",
  21585. "DOM_VK_XF86XK_LAUNCH4",
  21586. "DOM_VK_XF86XK_LAUNCH5",
  21587. "DOM_VK_XF86XK_LAUNCH6",
  21588. "DOM_VK_XF86XK_LAUNCH7",
  21589. "DOM_VK_XF86XK_LAUNCH8",
  21590. "DOM_VK_XF86XK_LAUNCH9",
  21591. "DOM_VK_XF86XK_LAUNCH_A",
  21592. "DOM_VK_XF86XK_LAUNCH_B",
  21593. "DOM_VK_XF86XK_LAUNCH_C",
  21594. "DOM_VK_XF86XK_LAUNCH_D",
  21595. "DOM_VK_XF86XK_LAUNCH_E",
  21596. "DOM_VK_XF86XK_LAUNCH_F",
  21597. "DOM_VK_XF86XK_LIGHT_BULB",
  21598. "DOM_VK_XF86XK_LOG_OFF",
  21599. "DOM_VK_XF86XK_MAIL",
  21600. "DOM_VK_XF86XK_MAIL_FORWARD",
  21601. "DOM_VK_XF86XK_MARKET",
  21602. "DOM_VK_XF86XK_MEETING",
  21603. "DOM_VK_XF86XK_MEMO",
  21604. "DOM_VK_XF86XK_MENU_KB",
  21605. "DOM_VK_XF86XK_MENU_PB",
  21606. "DOM_VK_XF86XK_MESSENGER",
  21607. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  21608. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  21609. "DOM_VK_XF86XK_MUSIC",
  21610. "DOM_VK_XF86XK_MY_COMPUTER",
  21611. "DOM_VK_XF86XK_MY_SITES",
  21612. "DOM_VK_XF86XK_NEW",
  21613. "DOM_VK_XF86XK_NEWS",
  21614. "DOM_VK_XF86XK_OFFICE_HOME",
  21615. "DOM_VK_XF86XK_OPEN",
  21616. "DOM_VK_XF86XK_OPEN_URL",
  21617. "DOM_VK_XF86XK_OPTION",
  21618. "DOM_VK_XF86XK_PASTE",
  21619. "DOM_VK_XF86XK_PHONE",
  21620. "DOM_VK_XF86XK_PICTURES",
  21621. "DOM_VK_XF86XK_POWER_DOWN",
  21622. "DOM_VK_XF86XK_POWER_OFF",
  21623. "DOM_VK_XF86XK_RED",
  21624. "DOM_VK_XF86XK_REFRESH",
  21625. "DOM_VK_XF86XK_RELOAD",
  21626. "DOM_VK_XF86XK_REPLY",
  21627. "DOM_VK_XF86XK_ROCKER_DOWN",
  21628. "DOM_VK_XF86XK_ROCKER_ENTER",
  21629. "DOM_VK_XF86XK_ROCKER_UP",
  21630. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  21631. "DOM_VK_XF86XK_ROTATION_KB",
  21632. "DOM_VK_XF86XK_ROTATION_PB",
  21633. "DOM_VK_XF86XK_SAVE",
  21634. "DOM_VK_XF86XK_SCREEN_SAVER",
  21635. "DOM_VK_XF86XK_SCROLL_CLICK",
  21636. "DOM_VK_XF86XK_SCROLL_DOWN",
  21637. "DOM_VK_XF86XK_SCROLL_UP",
  21638. "DOM_VK_XF86XK_SEARCH",
  21639. "DOM_VK_XF86XK_SEND",
  21640. "DOM_VK_XF86XK_SHOP",
  21641. "DOM_VK_XF86XK_SPELL",
  21642. "DOM_VK_XF86XK_SPLIT_SCREEN",
  21643. "DOM_VK_XF86XK_STANDBY",
  21644. "DOM_VK_XF86XK_START",
  21645. "DOM_VK_XF86XK_STOP",
  21646. "DOM_VK_XF86XK_SUBTITLE",
  21647. "DOM_VK_XF86XK_SUPPORT",
  21648. "DOM_VK_XF86XK_SUSPEND",
  21649. "DOM_VK_XF86XK_TASK_PANE",
  21650. "DOM_VK_XF86XK_TERMINAL",
  21651. "DOM_VK_XF86XK_TIME",
  21652. "DOM_VK_XF86XK_TOOLS",
  21653. "DOM_VK_XF86XK_TOP_MENU",
  21654. "DOM_VK_XF86XK_TO_DO_LIST",
  21655. "DOM_VK_XF86XK_TRAVEL",
  21656. "DOM_VK_XF86XK_USER1KB",
  21657. "DOM_VK_XF86XK_USER2KB",
  21658. "DOM_VK_XF86XK_USER_PB",
  21659. "DOM_VK_XF86XK_UWB",
  21660. "DOM_VK_XF86XK_VENDOR_HOME",
  21661. "DOM_VK_XF86XK_VIDEO",
  21662. "DOM_VK_XF86XK_VIEW",
  21663. "DOM_VK_XF86XK_WAKE_UP",
  21664. "DOM_VK_XF86XK_WEB_CAM",
  21665. "DOM_VK_XF86XK_WHEEL_BUTTON",
  21666. "DOM_VK_XF86XK_WLAN",
  21667. "DOM_VK_XF86XK_WORD",
  21668. "DOM_VK_XF86XK_WWW",
  21669. "DOM_VK_XF86XK_XFER",
  21670. "DOM_VK_XF86XK_YELLOW",
  21671. "DOM_VK_XF86XK_ZOOM_IN",
  21672. "DOM_VK_XF86XK_ZOOM_OUT",
  21673. "DOM_VK_Y",
  21674. "DOM_VK_Z",
  21675. "DOM_VK_ZOOM",
  21676. "DONE",
  21677. "DONT_CARE",
  21678. "DOWNLOADING",
  21679. "DRAGDROP",
  21680. "DRAW_BUFFER0",
  21681. "DRAW_BUFFER1",
  21682. "DRAW_BUFFER10",
  21683. "DRAW_BUFFER11",
  21684. "DRAW_BUFFER12",
  21685. "DRAW_BUFFER13",
  21686. "DRAW_BUFFER14",
  21687. "DRAW_BUFFER15",
  21688. "DRAW_BUFFER2",
  21689. "DRAW_BUFFER3",
  21690. "DRAW_BUFFER4",
  21691. "DRAW_BUFFER5",
  21692. "DRAW_BUFFER6",
  21693. "DRAW_BUFFER7",
  21694. "DRAW_BUFFER8",
  21695. "DRAW_BUFFER9",
  21696. "DRAW_FRAMEBUFFER",
  21697. "DRAW_FRAMEBUFFER_BINDING",
  21698. "DST_ALPHA",
  21699. "DST_COLOR",
  21700. "DYNAMIC_COPY",
  21701. "DYNAMIC_DRAW",
  21702. "DYNAMIC_READ",
  21703. "DataChannel",
  21704. "DataTransfer",
  21705. "DataTransferItem",
  21706. "DataTransferItemList",
  21707. "DataView",
  21708. "Date",
  21709. "DateTimeFormat",
  21710. "DecompressionStream",
  21711. "DelayNode",
  21712. "DelegatedInkTrailPresenter",
  21713. "DeprecationReportBody",
  21714. "DesktopNotification",
  21715. "DesktopNotificationCenter",
  21716. "Details",
  21717. "DeviceLightEvent",
  21718. "DeviceMotionEvent",
  21719. "DeviceMotionEventAcceleration",
  21720. "DeviceMotionEventRotationRate",
  21721. "DeviceOrientationEvent",
  21722. "DeviceProximityEvent",
  21723. "DeviceStorage",
  21724. "DeviceStorageChangeEvent",
  21725. "Directory",
  21726. "DisplayNames",
  21727. "Document",
  21728. "DocumentFragment",
  21729. "DocumentPictureInPicture",
  21730. "DocumentPictureInPictureEvent",
  21731. "DocumentTimeline",
  21732. "DocumentType",
  21733. "DragEvent",
  21734. "DurationFormat",
  21735. "DynamicsCompressorNode",
  21736. "E",
  21737. "ELEMENT_ARRAY_BUFFER",
  21738. "ELEMENT_ARRAY_BUFFER_BINDING",
  21739. "ELEMENT_NODE",
  21740. "EMPTY",
  21741. "ENCODING_ERR",
  21742. "ENDED",
  21743. "END_TO_END",
  21744. "END_TO_START",
  21745. "ENTITY_NODE",
  21746. "ENTITY_REFERENCE_NODE",
  21747. "EPSILON",
  21748. "EQUAL",
  21749. "EQUALPOWER",
  21750. "ERROR",
  21751. "EXPONENTIAL_DISTANCE",
  21752. "EditContext",
  21753. "Element",
  21754. "ElementInternals",
  21755. "ElementQuery",
  21756. "EncodedAudioChunk",
  21757. "EncodedVideoChunk",
  21758. "EnterPictureInPictureEvent",
  21759. "Entity",
  21760. "EntityReference",
  21761. "Error",
  21762. "ErrorEvent",
  21763. "EvalError",
  21764. "Event",
  21765. "EventCounts",
  21766. "EventException",
  21767. "EventSource",
  21768. "EventTarget",
  21769. "Exception",
  21770. "ExtensionContext",
  21771. "ExtensionDisabledReason",
  21772. "ExtensionInfo",
  21773. "ExtensionInstallType",
  21774. "ExtensionType",
  21775. "External",
  21776. "EyeDropper",
  21777. "FASTEST",
  21778. "FIDOSDK",
  21779. "FILTER_ACCEPT",
  21780. "FILTER_INTERRUPT",
  21781. "FILTER_REJECT",
  21782. "FILTER_SKIP",
  21783. "FINISHED_STATE",
  21784. "FIRST_ORDERED_NODE_TYPE",
  21785. "FLOAT",
  21786. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  21787. "FLOAT_MAT2",
  21788. "FLOAT_MAT2x3",
  21789. "FLOAT_MAT2x4",
  21790. "FLOAT_MAT3",
  21791. "FLOAT_MAT3x2",
  21792. "FLOAT_MAT3x4",
  21793. "FLOAT_MAT4",
  21794. "FLOAT_MAT4x2",
  21795. "FLOAT_MAT4x3",
  21796. "FLOAT_VEC2",
  21797. "FLOAT_VEC3",
  21798. "FLOAT_VEC4",
  21799. "FOCUS",
  21800. "FONT_FACE_RULE",
  21801. "FONT_FEATURE_VALUES_RULE",
  21802. "FRAGMENT",
  21803. "FRAGMENT_SHADER",
  21804. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  21805. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  21806. "FRAMEBUFFER",
  21807. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  21808. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  21809. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  21810. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  21811. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  21812. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  21813. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  21814. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  21815. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  21816. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  21817. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  21818. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  21819. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  21820. "FRAMEBUFFER_BINDING",
  21821. "FRAMEBUFFER_COMPLETE",
  21822. "FRAMEBUFFER_DEFAULT",
  21823. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  21824. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  21825. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  21826. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  21827. "FRAMEBUFFER_UNSUPPORTED",
  21828. "FRONT",
  21829. "FRONT_AND_BACK",
  21830. "FRONT_FACE",
  21831. "FUNC_ADD",
  21832. "FUNC_REVERSE_SUBTRACT",
  21833. "FUNC_SUBTRACT",
  21834. "FeaturePolicy",
  21835. "FeaturePolicyViolationReportBody",
  21836. "FederatedCredential",
  21837. "Feed",
  21838. "FeedEntry",
  21839. "Fence",
  21840. "FencedFrameConfig",
  21841. "File",
  21842. "FileError",
  21843. "FileList",
  21844. "FileReader",
  21845. "FileSystem",
  21846. "FileSystemDirectoryEntry",
  21847. "FileSystemDirectoryHandle",
  21848. "FileSystemDirectoryReader",
  21849. "FileSystemEntry",
  21850. "FileSystemFileEntry",
  21851. "FileSystemFileHandle",
  21852. "FileSystemHandle",
  21853. "FileSystemWritableFileStream",
  21854. "FinalizationRegistry",
  21855. "FindInPage",
  21856. "Float16Array",
  21857. "Float32Array",
  21858. "Float64Array",
  21859. "FocusEvent",
  21860. "FontData",
  21861. "FontFace",
  21862. "FontFaceSet",
  21863. "FontFaceSetLoadEvent",
  21864. "FormData",
  21865. "FormDataEvent",
  21866. "FragmentDirective",
  21867. "Function",
  21868. "GENERATE_MIPMAP_HINT",
  21869. "GEQUAL",
  21870. "GPU",
  21871. "GPUAdapter",
  21872. "GPUAdapterInfo",
  21873. "GPUBindGroup",
  21874. "GPUBindGroupLayout",
  21875. "GPUBuffer",
  21876. "GPUBufferUsage",
  21877. "GPUCanvasContext",
  21878. "GPUColorWrite",
  21879. "GPUCommandBuffer",
  21880. "GPUCommandEncoder",
  21881. "GPUCompilationInfo",
  21882. "GPUCompilationMessage",
  21883. "GPUComputePassEncoder",
  21884. "GPUComputePipeline",
  21885. "GPUDevice",
  21886. "GPUDeviceLostInfo",
  21887. "GPUError",
  21888. "GPUExternalTexture",
  21889. "GPUInternalError",
  21890. "GPUMapMode",
  21891. "GPUOutOfMemoryError",
  21892. "GPUPipelineError",
  21893. "GPUPipelineLayout",
  21894. "GPUQuerySet",
  21895. "GPUQueue",
  21896. "GPURenderBundle",
  21897. "GPURenderBundleEncoder",
  21898. "GPURenderPassEncoder",
  21899. "GPURenderPipeline",
  21900. "GPUSampler",
  21901. "GPUShaderModule",
  21902. "GPUShaderStage",
  21903. "GPUSupportedFeatures",
  21904. "GPUSupportedLimits",
  21905. "GPUTexture",
  21906. "GPUTextureUsage",
  21907. "GPUTextureView",
  21908. "GPUUncapturedErrorEvent",
  21909. "GPUValidationError",
  21910. "GREATER",
  21911. "GREEN",
  21912. "GREEN_BITS",
  21913. "GainNode",
  21914. "Gamepad",
  21915. "GamepadAxisMoveEvent",
  21916. "GamepadButton",
  21917. "GamepadButtonEvent",
  21918. "GamepadEvent",
  21919. "GamepadHapticActuator",
  21920. "GamepadPose",
  21921. "Geolocation",
  21922. "GeolocationCoordinates",
  21923. "GeolocationPosition",
  21924. "GeolocationPositionError",
  21925. "GestureEvent",
  21926. "GetInfo",
  21927. "Global",
  21928. "GravitySensor",
  21929. "Gyroscope",
  21930. "HALF_FLOAT",
  21931. "HAVE_CURRENT_DATA",
  21932. "HAVE_ENOUGH_DATA",
  21933. "HAVE_FUTURE_DATA",
  21934. "HAVE_METADATA",
  21935. "HAVE_NOTHING",
  21936. "HEADERS_RECEIVED",
  21937. "HID",
  21938. "HIDConnectionEvent",
  21939. "HIDDEN",
  21940. "HIDDevice",
  21941. "HIDInputReportEvent",
  21942. "HIERARCHY_REQUEST_ERR",
  21943. "HIGHPASS",
  21944. "HIGHSHELF",
  21945. "HIGH_FLOAT",
  21946. "HIGH_INT",
  21947. "HORIZONTAL",
  21948. "HORIZONTAL_AXIS",
  21949. "HRTF",
  21950. "HTMLAllCollection",
  21951. "HTMLAnchorElement",
  21952. "HTMLAppletElement",
  21953. "HTMLAreaElement",
  21954. "HTMLAudioElement",
  21955. "HTMLBRElement",
  21956. "HTMLBaseElement",
  21957. "HTMLBaseFontElement",
  21958. "HTMLBlockquoteElement",
  21959. "HTMLBodyElement",
  21960. "HTMLButtonElement",
  21961. "HTMLCanvasElement",
  21962. "HTMLCollection",
  21963. "HTMLCommandElement",
  21964. "HTMLContentElement",
  21965. "HTMLDListElement",
  21966. "HTMLDataElement",
  21967. "HTMLDataListElement",
  21968. "HTMLDetailsElement",
  21969. "HTMLDialogElement",
  21970. "HTMLDirectoryElement",
  21971. "HTMLDivElement",
  21972. "HTMLDocument",
  21973. "HTMLElement",
  21974. "HTMLEmbedElement",
  21975. "HTMLFencedFrameElement",
  21976. "HTMLFieldSetElement",
  21977. "HTMLFontElement",
  21978. "HTMLFormControlsCollection",
  21979. "HTMLFormElement",
  21980. "HTMLFrameElement",
  21981. "HTMLFrameSetElement",
  21982. "HTMLHRElement",
  21983. "HTMLHeadElement",
  21984. "HTMLHeadingElement",
  21985. "HTMLHtmlElement",
  21986. "HTMLIFrameElement",
  21987. "HTMLImageElement",
  21988. "HTMLInputElement",
  21989. "HTMLIsIndexElement",
  21990. "HTMLKeygenElement",
  21991. "HTMLLIElement",
  21992. "HTMLLabelElement",
  21993. "HTMLLegendElement",
  21994. "HTMLLinkElement",
  21995. "HTMLMapElement",
  21996. "HTMLMarqueeElement",
  21997. "HTMLMediaElement",
  21998. "HTMLMenuElement",
  21999. "HTMLMenuItemElement",
  22000. "HTMLMetaElement",
  22001. "HTMLMeterElement",
  22002. "HTMLModElement",
  22003. "HTMLOListElement",
  22004. "HTMLObjectElement",
  22005. "HTMLOptGroupElement",
  22006. "HTMLOptionElement",
  22007. "HTMLOptionsCollection",
  22008. "HTMLOutputElement",
  22009. "HTMLParagraphElement",
  22010. "HTMLParamElement",
  22011. "HTMLPictureElement",
  22012. "HTMLPreElement",
  22013. "HTMLProgressElement",
  22014. "HTMLPropertiesCollection",
  22015. "HTMLQuoteElement",
  22016. "HTMLScriptElement",
  22017. "HTMLSelectElement",
  22018. "HTMLShadowElement",
  22019. "HTMLSlotElement",
  22020. "HTMLSourceElement",
  22021. "HTMLSpanElement",
  22022. "HTMLStyleElement",
  22023. "HTMLTableCaptionElement",
  22024. "HTMLTableCellElement",
  22025. "HTMLTableColElement",
  22026. "HTMLTableElement",
  22027. "HTMLTableRowElement",
  22028. "HTMLTableSectionElement",
  22029. "HTMLTemplateElement",
  22030. "HTMLTextAreaElement",
  22031. "HTMLTimeElement",
  22032. "HTMLTitleElement",
  22033. "HTMLTrackElement",
  22034. "HTMLUListElement",
  22035. "HTMLUnknownElement",
  22036. "HTMLVideoElement",
  22037. "HashChangeEvent",
  22038. "Headers",
  22039. "Highlight",
  22040. "HighlightRegistry",
  22041. "History",
  22042. "Hz",
  22043. "ICE_CHECKING",
  22044. "ICE_CLOSED",
  22045. "ICE_COMPLETED",
  22046. "ICE_CONNECTED",
  22047. "ICE_FAILED",
  22048. "ICE_GATHERING",
  22049. "ICE_WAITING",
  22050. "IDBCursor",
  22051. "IDBCursorWithValue",
  22052. "IDBDatabase",
  22053. "IDBDatabaseException",
  22054. "IDBFactory",
  22055. "IDBFileHandle",
  22056. "IDBFileRequest",
  22057. "IDBIndex",
  22058. "IDBKeyRange",
  22059. "IDBMutableFile",
  22060. "IDBObjectStore",
  22061. "IDBOpenDBRequest",
  22062. "IDBRequest",
  22063. "IDBTransaction",
  22064. "IDBVersionChangeEvent",
  22065. "IDLE",
  22066. "IIRFilterNode",
  22067. "IMPLEMENTATION_COLOR_READ_FORMAT",
  22068. "IMPLEMENTATION_COLOR_READ_TYPE",
  22069. "IMPORT_RULE",
  22070. "INCR",
  22071. "INCR_WRAP",
  22072. "INDEX",
  22073. "INDEX_SIZE_ERR",
  22074. "INDIRECT",
  22075. "INT",
  22076. "INTERLEAVED_ATTRIBS",
  22077. "INT_2_10_10_10_REV",
  22078. "INT_SAMPLER_2D",
  22079. "INT_SAMPLER_2D_ARRAY",
  22080. "INT_SAMPLER_3D",
  22081. "INT_SAMPLER_CUBE",
  22082. "INT_VEC2",
  22083. "INT_VEC3",
  22084. "INT_VEC4",
  22085. "INUSE_ATTRIBUTE_ERR",
  22086. "INVALID_ACCESS_ERR",
  22087. "INVALID_CHARACTER_ERR",
  22088. "INVALID_ENUM",
  22089. "INVALID_EXPRESSION_ERR",
  22090. "INVALID_FRAMEBUFFER_OPERATION",
  22091. "INVALID_INDEX",
  22092. "INVALID_MODIFICATION_ERR",
  22093. "INVALID_NODE_TYPE_ERR",
  22094. "INVALID_OPERATION",
  22095. "INVALID_STATE_ERR",
  22096. "INVALID_VALUE",
  22097. "INVERSE_DISTANCE",
  22098. "INVERT",
  22099. "IceCandidate",
  22100. "IconInfo",
  22101. "IdentityCredential",
  22102. "IdentityCredentialError",
  22103. "IdentityProvider",
  22104. "IdleDeadline",
  22105. "IdleDetector",
  22106. "Image",
  22107. "ImageBitmap",
  22108. "ImageBitmapRenderingContext",
  22109. "ImageCapture",
  22110. "ImageData",
  22111. "ImageDataType",
  22112. "ImageDecoder",
  22113. "ImageTrack",
  22114. "ImageTrackList",
  22115. "Infinity",
  22116. "Ink",
  22117. "InputDeviceCapabilities",
  22118. "InputDeviceInfo",
  22119. "InputEvent",
  22120. "InputMethodContext",
  22121. "InstallTrigger",
  22122. "InstallTriggerImpl",
  22123. "Instance",
  22124. "Int16Array",
  22125. "Int32Array",
  22126. "Int8Array",
  22127. "Intent",
  22128. "InternalError",
  22129. "IntersectionObserver",
  22130. "IntersectionObserverEntry",
  22131. "Intl",
  22132. "IsSearchProviderInstalled",
  22133. "Iterator",
  22134. "JSON",
  22135. "JSTag",
  22136. "KEEP",
  22137. "KEYDOWN",
  22138. "KEYFRAMES_RULE",
  22139. "KEYFRAME_RULE",
  22140. "KEYPRESS",
  22141. "KEYUP",
  22142. "KeyEvent",
  22143. "Keyboard",
  22144. "KeyboardEvent",
  22145. "KeyboardLayoutMap",
  22146. "KeyframeEffect",
  22147. "LENGTHADJUST_SPACING",
  22148. "LENGTHADJUST_SPACINGANDGLYPHS",
  22149. "LENGTHADJUST_UNKNOWN",
  22150. "LEQUAL",
  22151. "LESS",
  22152. "LINEAR",
  22153. "LINEAR_DISTANCE",
  22154. "LINEAR_MIPMAP_LINEAR",
  22155. "LINEAR_MIPMAP_NEAREST",
  22156. "LINES",
  22157. "LINE_LOOP",
  22158. "LINE_STRIP",
  22159. "LINE_WIDTH",
  22160. "LINK_STATUS",
  22161. "LIVE",
  22162. "LN10",
  22163. "LN2",
  22164. "LOADED",
  22165. "LOADING",
  22166. "LOG10E",
  22167. "LOG2E",
  22168. "LOWPASS",
  22169. "LOWSHELF",
  22170. "LOW_FLOAT",
  22171. "LOW_INT",
  22172. "LSException",
  22173. "LSParserFilter",
  22174. "LUMINANCE",
  22175. "LUMINANCE_ALPHA",
  22176. "LanguageCode",
  22177. "LargestContentfulPaint",
  22178. "LaunchParams",
  22179. "LaunchQueue",
  22180. "LaunchType",
  22181. "LayoutShift",
  22182. "LayoutShiftAttribution",
  22183. "LinearAccelerationSensor",
  22184. "LinkError",
  22185. "ListFormat",
  22186. "LocalMediaStream",
  22187. "Locale",
  22188. "Location",
  22189. "Lock",
  22190. "LockManager",
  22191. "MAP_READ",
  22192. "MAP_WRITE",
  22193. "MARGIN_RULE",
  22194. "MAX",
  22195. "MAX_3D_TEXTURE_SIZE",
  22196. "MAX_ARRAY_TEXTURE_LAYERS",
  22197. "MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND",
  22198. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  22199. "MAX_COLOR_ATTACHMENTS",
  22200. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  22201. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  22202. "MAX_COMBINED_UNIFORM_BLOCKS",
  22203. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  22204. "MAX_CUBE_MAP_TEXTURE_SIZE",
  22205. "MAX_DRAW_BUFFERS",
  22206. "MAX_ELEMENTS_INDICES",
  22207. "MAX_ELEMENTS_VERTICES",
  22208. "MAX_ELEMENT_INDEX",
  22209. "MAX_FRAGMENT_INPUT_COMPONENTS",
  22210. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  22211. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  22212. "MAX_FRAGMENT_UNIFORM_VECTORS",
  22213. "MAX_PROGRAM_TEXEL_OFFSET",
  22214. "MAX_RENDERBUFFER_SIZE",
  22215. "MAX_SAFE_INTEGER",
  22216. "MAX_SAMPLES",
  22217. "MAX_SERVER_WAIT_TIMEOUT",
  22218. "MAX_TEXTURE_IMAGE_UNITS",
  22219. "MAX_TEXTURE_LOD_BIAS",
  22220. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  22221. "MAX_TEXTURE_SIZE",
  22222. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  22223. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  22224. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  22225. "MAX_UNIFORM_BLOCK_SIZE",
  22226. "MAX_UNIFORM_BUFFER_BINDINGS",
  22227. "MAX_VALUE",
  22228. "MAX_VARYING_COMPONENTS",
  22229. "MAX_VARYING_VECTORS",
  22230. "MAX_VERTEX_ATTRIBS",
  22231. "MAX_VERTEX_OUTPUT_COMPONENTS",
  22232. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  22233. "MAX_VERTEX_UNIFORM_BLOCKS",
  22234. "MAX_VERTEX_UNIFORM_COMPONENTS",
  22235. "MAX_VERTEX_UNIFORM_VECTORS",
  22236. "MAX_VIEWPORT_DIMS",
  22237. "MEDIA_ERR_ABORTED",
  22238. "MEDIA_ERR_DECODE",
  22239. "MEDIA_ERR_ENCRYPTED",
  22240. "MEDIA_ERR_NETWORK",
  22241. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  22242. "MEDIA_KEYERR_CLIENT",
  22243. "MEDIA_KEYERR_DOMAIN",
  22244. "MEDIA_KEYERR_HARDWARECHANGE",
  22245. "MEDIA_KEYERR_OUTPUT",
  22246. "MEDIA_KEYERR_SERVICE",
  22247. "MEDIA_KEYERR_UNKNOWN",
  22248. "MEDIA_RULE",
  22249. "MEDIUM_FLOAT",
  22250. "MEDIUM_INT",
  22251. "META_MASK",
  22252. "MIDIAccess",
  22253. "MIDIConnectionEvent",
  22254. "MIDIInput",
  22255. "MIDIInputMap",
  22256. "MIDIMessageEvent",
  22257. "MIDIOutput",
  22258. "MIDIOutputMap",
  22259. "MIDIPort",
  22260. "MIN",
  22261. "MIN_PROGRAM_TEXEL_OFFSET",
  22262. "MIN_SAFE_INTEGER",
  22263. "MIN_VALUE",
  22264. "MIRRORED_REPEAT",
  22265. "MODE_ASYNCHRONOUS",
  22266. "MODE_SYNCHRONOUS",
  22267. "MODIFICATION",
  22268. "MOUSEDOWN",
  22269. "MOUSEDRAG",
  22270. "MOUSEMOVE",
  22271. "MOUSEOUT",
  22272. "MOUSEOVER",
  22273. "MOUSEUP",
  22274. "MOZ_KEYFRAMES_RULE",
  22275. "MOZ_KEYFRAME_RULE",
  22276. "MOZ_SOURCE_CURSOR",
  22277. "MOZ_SOURCE_ERASER",
  22278. "MOZ_SOURCE_KEYBOARD",
  22279. "MOZ_SOURCE_MOUSE",
  22280. "MOZ_SOURCE_PEN",
  22281. "MOZ_SOURCE_TOUCH",
  22282. "MOZ_SOURCE_UNKNOWN",
  22283. "MSGESTURE_FLAG_BEGIN",
  22284. "MSGESTURE_FLAG_CANCEL",
  22285. "MSGESTURE_FLAG_END",
  22286. "MSGESTURE_FLAG_INERTIA",
  22287. "MSGESTURE_FLAG_NONE",
  22288. "MSPOINTER_TYPE_MOUSE",
  22289. "MSPOINTER_TYPE_PEN",
  22290. "MSPOINTER_TYPE_TOUCH",
  22291. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  22292. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  22293. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  22294. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  22295. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  22296. "MS_ASYNC_OP_STATUS_CANCELED",
  22297. "MS_ASYNC_OP_STATUS_ERROR",
  22298. "MS_ASYNC_OP_STATUS_SUCCESS",
  22299. "MS_MANIPULATION_STATE_ACTIVE",
  22300. "MS_MANIPULATION_STATE_CANCELLED",
  22301. "MS_MANIPULATION_STATE_COMMITTED",
  22302. "MS_MANIPULATION_STATE_DRAGGING",
  22303. "MS_MANIPULATION_STATE_INERTIA",
  22304. "MS_MANIPULATION_STATE_PRESELECT",
  22305. "MS_MANIPULATION_STATE_SELECTING",
  22306. "MS_MANIPULATION_STATE_STOPPED",
  22307. "MS_MEDIA_ERR_ENCRYPTED",
  22308. "MS_MEDIA_KEYERR_CLIENT",
  22309. "MS_MEDIA_KEYERR_DOMAIN",
  22310. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  22311. "MS_MEDIA_KEYERR_OUTPUT",
  22312. "MS_MEDIA_KEYERR_SERVICE",
  22313. "MS_MEDIA_KEYERR_UNKNOWN",
  22314. "Map",
  22315. "Math",
  22316. "MathMLElement",
  22317. "MediaCapabilities",
  22318. "MediaCapabilitiesInfo",
  22319. "MediaController",
  22320. "MediaDeviceInfo",
  22321. "MediaDevices",
  22322. "MediaElementAudioSourceNode",
  22323. "MediaEncryptedEvent",
  22324. "MediaError",
  22325. "MediaKeyError",
  22326. "MediaKeyEvent",
  22327. "MediaKeyMessageEvent",
  22328. "MediaKeyNeededEvent",
  22329. "MediaKeySession",
  22330. "MediaKeyStatusMap",
  22331. "MediaKeySystemAccess",
  22332. "MediaKeys",
  22333. "MediaList",
  22334. "MediaMetadata",
  22335. "MediaQueryList",
  22336. "MediaQueryListEvent",
  22337. "MediaRecorder",
  22338. "MediaRecorderErrorEvent",
  22339. "MediaSession",
  22340. "MediaSettingsRange",
  22341. "MediaSource",
  22342. "MediaSourceHandle",
  22343. "MediaStream",
  22344. "MediaStreamAudioDestinationNode",
  22345. "MediaStreamAudioSourceNode",
  22346. "MediaStreamEvent",
  22347. "MediaStreamTrack",
  22348. "MediaStreamTrackAudioSourceNode",
  22349. "MediaStreamTrackAudioStats",
  22350. "MediaStreamTrackEvent",
  22351. "MediaStreamTrackGenerator",
  22352. "MediaStreamTrackProcessor",
  22353. "MediaStreamTrackVideoStats",
  22354. "Memory",
  22355. "MessageChannel",
  22356. "MessageEvent",
  22357. "MessagePort",
  22358. "MessageSender",
  22359. "Methods",
  22360. "MimeType",
  22361. "MimeTypeArray",
  22362. "Module",
  22363. "MouseEvent",
  22364. "MouseScrollEvent",
  22365. "MozAnimation",
  22366. "MozAnimationDelay",
  22367. "MozAnimationDirection",
  22368. "MozAnimationDuration",
  22369. "MozAnimationFillMode",
  22370. "MozAnimationIterationCount",
  22371. "MozAnimationName",
  22372. "MozAnimationPlayState",
  22373. "MozAnimationTimingFunction",
  22374. "MozAppearance",
  22375. "MozBackfaceVisibility",
  22376. "MozBinding",
  22377. "MozBorderBottomColors",
  22378. "MozBorderEnd",
  22379. "MozBorderEndColor",
  22380. "MozBorderEndStyle",
  22381. "MozBorderEndWidth",
  22382. "MozBorderImage",
  22383. "MozBorderLeftColors",
  22384. "MozBorderRightColors",
  22385. "MozBorderStart",
  22386. "MozBorderStartColor",
  22387. "MozBorderStartStyle",
  22388. "MozBorderStartWidth",
  22389. "MozBorderTopColors",
  22390. "MozBoxAlign",
  22391. "MozBoxDirection",
  22392. "MozBoxFlex",
  22393. "MozBoxOrdinalGroup",
  22394. "MozBoxOrient",
  22395. "MozBoxPack",
  22396. "MozBoxSizing",
  22397. "MozCSSKeyframeRule",
  22398. "MozCSSKeyframesRule",
  22399. "MozColumnCount",
  22400. "MozColumnFill",
  22401. "MozColumnGap",
  22402. "MozColumnRule",
  22403. "MozColumnRuleColor",
  22404. "MozColumnRuleStyle",
  22405. "MozColumnRuleWidth",
  22406. "MozColumnWidth",
  22407. "MozColumns",
  22408. "MozContactChangeEvent",
  22409. "MozFloatEdge",
  22410. "MozFontFeatureSettings",
  22411. "MozFontLanguageOverride",
  22412. "MozForceBrokenImageIcon",
  22413. "MozHyphens",
  22414. "MozImageRegion",
  22415. "MozMarginEnd",
  22416. "MozMarginStart",
  22417. "MozMmsEvent",
  22418. "MozMmsMessage",
  22419. "MozMobileMessageThread",
  22420. "MozOSXFontSmoothing",
  22421. "MozOrient",
  22422. "MozOsxFontSmoothing",
  22423. "MozOutlineRadius",
  22424. "MozOutlineRadiusBottomleft",
  22425. "MozOutlineRadiusBottomright",
  22426. "MozOutlineRadiusTopleft",
  22427. "MozOutlineRadiusTopright",
  22428. "MozPaddingEnd",
  22429. "MozPaddingStart",
  22430. "MozPerspective",
  22431. "MozPerspectiveOrigin",
  22432. "MozPowerManager",
  22433. "MozSettingsEvent",
  22434. "MozSmsEvent",
  22435. "MozSmsMessage",
  22436. "MozStackSizing",
  22437. "MozTabSize",
  22438. "MozTextAlignLast",
  22439. "MozTextDecorationColor",
  22440. "MozTextDecorationLine",
  22441. "MozTextDecorationStyle",
  22442. "MozTextSizeAdjust",
  22443. "MozTransform",
  22444. "MozTransformOrigin",
  22445. "MozTransformStyle",
  22446. "MozTransition",
  22447. "MozTransitionDelay",
  22448. "MozTransitionDuration",
  22449. "MozTransitionProperty",
  22450. "MozTransitionTimingFunction",
  22451. "MozUserFocus",
  22452. "MozUserInput",
  22453. "MozUserModify",
  22454. "MozUserSelect",
  22455. "MozWindowDragging",
  22456. "MozWindowShadow",
  22457. "MutationEvent",
  22458. "MutationObserver",
  22459. "MutationRecord",
  22460. "MutedInfo",
  22461. "MutedInfoReason",
  22462. "NAMESPACE_ERR",
  22463. "NAMESPACE_RULE",
  22464. "NEAREST",
  22465. "NEAREST_MIPMAP_LINEAR",
  22466. "NEAREST_MIPMAP_NEAREST",
  22467. "NEGATIVE_INFINITY",
  22468. "NETWORK_EMPTY",
  22469. "NETWORK_ERR",
  22470. "NETWORK_IDLE",
  22471. "NETWORK_LOADED",
  22472. "NETWORK_LOADING",
  22473. "NETWORK_NO_SOURCE",
  22474. "NEVER",
  22475. "NEW",
  22476. "NEXT",
  22477. "NEXT_NO_DUPLICATE",
  22478. "NICEST",
  22479. "NODE_AFTER",
  22480. "NODE_BEFORE",
  22481. "NODE_BEFORE_AND_AFTER",
  22482. "NODE_INSIDE",
  22483. "NONE",
  22484. "NON_TRANSIENT_ERR",
  22485. "NOTATION_NODE",
  22486. "NOTCH",
  22487. "NOTEQUAL",
  22488. "NOT_ALLOWED_ERR",
  22489. "NOT_FOUND_ERR",
  22490. "NOT_READABLE_ERR",
  22491. "NOT_SUPPORTED_ERR",
  22492. "NO_DATA_ALLOWED_ERR",
  22493. "NO_ERR",
  22494. "NO_ERROR",
  22495. "NO_MODIFICATION_ALLOWED_ERR",
  22496. "NUMBER_TYPE",
  22497. "NUM_COMPRESSED_TEXTURE_FORMATS",
  22498. "NaN",
  22499. "NamedNodeMap",
  22500. "NavigateEvent",
  22501. "Navigation",
  22502. "NavigationActivation",
  22503. "NavigationCurrentEntryChangeEvent",
  22504. "NavigationDestination",
  22505. "NavigationHistoryEntry",
  22506. "NavigationPreloadManager",
  22507. "NavigationTransition",
  22508. "Navigator",
  22509. "NavigatorLogin",
  22510. "NavigatorManagedData",
  22511. "NavigatorUAData",
  22512. "NearbyLinks",
  22513. "NetworkInformation",
  22514. "Node",
  22515. "NodeFilter",
  22516. "NodeIterator",
  22517. "NodeList",
  22518. "NotRestoredReasonDetails",
  22519. "NotRestoredReasons",
  22520. "Notation",
  22521. "Notification",
  22522. "NotifyPaintEvent",
  22523. "Number",
  22524. "NumberFormat",
  22525. "OBJECT_TYPE",
  22526. "OBSOLETE",
  22527. "OK",
  22528. "ONE",
  22529. "ONE_MINUS_CONSTANT_ALPHA",
  22530. "ONE_MINUS_CONSTANT_COLOR",
  22531. "ONE_MINUS_DST_ALPHA",
  22532. "ONE_MINUS_DST_COLOR",
  22533. "ONE_MINUS_SRC_ALPHA",
  22534. "ONE_MINUS_SRC_COLOR",
  22535. "OPEN",
  22536. "OPENED",
  22537. "OPENING",
  22538. "ORDERED_NODE_ITERATOR_TYPE",
  22539. "ORDERED_NODE_SNAPSHOT_TYPE",
  22540. "OTHER_ERROR",
  22541. "OTPCredential",
  22542. "OUT_OF_MEMORY",
  22543. "Object",
  22544. "OfflineAudioCompletionEvent",
  22545. "OfflineAudioContext",
  22546. "OfflineResourceList",
  22547. "OffscreenCanvas",
  22548. "OffscreenCanvasRenderingContext2D",
  22549. "OnClickData",
  22550. "OnInstalledReason",
  22551. "OnPerformanceWarningCategory",
  22552. "OnPerformanceWarningSeverity",
  22553. "OnRestartRequiredReason",
  22554. "Option",
  22555. "OrientationSensor",
  22556. "OscillatorNode",
  22557. "OverconstrainedError",
  22558. "OverflowEvent",
  22559. "PACK_ALIGNMENT",
  22560. "PACK_ROW_LENGTH",
  22561. "PACK_SKIP_PIXELS",
  22562. "PACK_SKIP_ROWS",
  22563. "PAGE_RULE",
  22564. "PARSE_ERR",
  22565. "PATHSEG_ARC_ABS",
  22566. "PATHSEG_ARC_REL",
  22567. "PATHSEG_CLOSEPATH",
  22568. "PATHSEG_CURVETO_CUBIC_ABS",
  22569. "PATHSEG_CURVETO_CUBIC_REL",
  22570. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  22571. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  22572. "PATHSEG_CURVETO_QUADRATIC_ABS",
  22573. "PATHSEG_CURVETO_QUADRATIC_REL",
  22574. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  22575. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  22576. "PATHSEG_LINETO_ABS",
  22577. "PATHSEG_LINETO_HORIZONTAL_ABS",
  22578. "PATHSEG_LINETO_HORIZONTAL_REL",
  22579. "PATHSEG_LINETO_REL",
  22580. "PATHSEG_LINETO_VERTICAL_ABS",
  22581. "PATHSEG_LINETO_VERTICAL_REL",
  22582. "PATHSEG_MOVETO_ABS",
  22583. "PATHSEG_MOVETO_REL",
  22584. "PATHSEG_UNKNOWN",
  22585. "PATH_EXISTS_ERR",
  22586. "PEAKING",
  22587. "PERMISSION_DENIED",
  22588. "PERSISTENT",
  22589. "PI",
  22590. "PIXEL_PACK_BUFFER",
  22591. "PIXEL_PACK_BUFFER_BINDING",
  22592. "PIXEL_UNPACK_BUFFER",
  22593. "PIXEL_UNPACK_BUFFER_BINDING",
  22594. "PLAYING_STATE",
  22595. "POINTS",
  22596. "POLYGON_OFFSET_FACTOR",
  22597. "POLYGON_OFFSET_FILL",
  22598. "POLYGON_OFFSET_UNITS",
  22599. "POSITION_UNAVAILABLE",
  22600. "POSITIVE_INFINITY",
  22601. "PREV",
  22602. "PREV_NO_DUPLICATE",
  22603. "PROCESSING_INSTRUCTION_NODE",
  22604. "PageChangeEvent",
  22605. "PageRevealEvent",
  22606. "PageSettings",
  22607. "PageSwapEvent",
  22608. "PageTransitionEvent",
  22609. "PaintRequest",
  22610. "PaintRequestList",
  22611. "PannerNode",
  22612. "PasswordCredential",
  22613. "Path2D",
  22614. "PaymentAddress",
  22615. "PaymentInstruments",
  22616. "PaymentManager",
  22617. "PaymentMethodChangeEvent",
  22618. "PaymentRequest",
  22619. "PaymentRequestUpdateEvent",
  22620. "PaymentResponse",
  22621. "Performance",
  22622. "PerformanceElementTiming",
  22623. "PerformanceEntry",
  22624. "PerformanceEventTiming",
  22625. "PerformanceLongAnimationFrameTiming",
  22626. "PerformanceLongTaskTiming",
  22627. "PerformanceMark",
  22628. "PerformanceMeasure",
  22629. "PerformanceNavigation",
  22630. "PerformanceNavigationTiming",
  22631. "PerformanceObserver",
  22632. "PerformanceObserverEntryList",
  22633. "PerformancePaintTiming",
  22634. "PerformanceResourceTiming",
  22635. "PerformanceScriptTiming",
  22636. "PerformanceServerTiming",
  22637. "PerformanceTiming",
  22638. "PeriodicSyncManager",
  22639. "PeriodicWave",
  22640. "PermissionStatus",
  22641. "Permissions",
  22642. "PhotoCapabilities",
  22643. "PictureInPictureEvent",
  22644. "PictureInPictureWindow",
  22645. "PlatformArch",
  22646. "PlatformInfo",
  22647. "PlatformNaclArch",
  22648. "PlatformOs",
  22649. "Plugin",
  22650. "PluginArray",
  22651. "PluralRules",
  22652. "PointerEvent",
  22653. "PopStateEvent",
  22654. "PopupBlockedEvent",
  22655. "Port",
  22656. "Presentation",
  22657. "PresentationAvailability",
  22658. "PresentationConnection",
  22659. "PresentationConnectionAvailableEvent",
  22660. "PresentationConnectionCloseEvent",
  22661. "PresentationConnectionList",
  22662. "PresentationReceiver",
  22663. "PresentationRequest",
  22664. "PressureObserver",
  22665. "PressureRecord",
  22666. "ProcessingInstruction",
  22667. "Profiler",
  22668. "ProgressEvent",
  22669. "Promise",
  22670. "PromiseRejectionEvent",
  22671. "PropertyNodeList",
  22672. "ProtectedAudience",
  22673. "Proxy",
  22674. "PublicKeyCredential",
  22675. "PushManager",
  22676. "PushSubscription",
  22677. "PushSubscriptionOptions",
  22678. "Q",
  22679. "QUERY_RESOLVE",
  22680. "QUERY_RESULT",
  22681. "QUERY_RESULT_AVAILABLE",
  22682. "QUOTA_ERR",
  22683. "QUOTA_EXCEEDED_ERR",
  22684. "QueryInterface",
  22685. "R11F_G11F_B10F",
  22686. "R16F",
  22687. "R16I",
  22688. "R16UI",
  22689. "R32F",
  22690. "R32I",
  22691. "R32UI",
  22692. "R8",
  22693. "R8I",
  22694. "R8UI",
  22695. "R8_SNORM",
  22696. "RASTERIZER_DISCARD",
  22697. "READ",
  22698. "READ_BUFFER",
  22699. "READ_FRAMEBUFFER",
  22700. "READ_FRAMEBUFFER_BINDING",
  22701. "READ_ONLY",
  22702. "READ_ONLY_ERR",
  22703. "READ_WRITE",
  22704. "RED",
  22705. "RED_BITS",
  22706. "RED_INTEGER",
  22707. "REMOVAL",
  22708. "RENDERBUFFER",
  22709. "RENDERBUFFER_ALPHA_SIZE",
  22710. "RENDERBUFFER_BINDING",
  22711. "RENDERBUFFER_BLUE_SIZE",
  22712. "RENDERBUFFER_DEPTH_SIZE",
  22713. "RENDERBUFFER_GREEN_SIZE",
  22714. "RENDERBUFFER_HEIGHT",
  22715. "RENDERBUFFER_INTERNAL_FORMAT",
  22716. "RENDERBUFFER_RED_SIZE",
  22717. "RENDERBUFFER_SAMPLES",
  22718. "RENDERBUFFER_STENCIL_SIZE",
  22719. "RENDERBUFFER_WIDTH",
  22720. "RENDERER",
  22721. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  22722. "RENDERING_INTENT_AUTO",
  22723. "RENDERING_INTENT_PERCEPTUAL",
  22724. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  22725. "RENDERING_INTENT_SATURATION",
  22726. "RENDERING_INTENT_UNKNOWN",
  22727. "RENDER_ATTACHMENT",
  22728. "REPEAT",
  22729. "REPLACE",
  22730. "RG",
  22731. "RG16F",
  22732. "RG16I",
  22733. "RG16UI",
  22734. "RG32F",
  22735. "RG32I",
  22736. "RG32UI",
  22737. "RG8",
  22738. "RG8I",
  22739. "RG8UI",
  22740. "RG8_SNORM",
  22741. "RGB",
  22742. "RGB10_A2",
  22743. "RGB10_A2UI",
  22744. "RGB16F",
  22745. "RGB16I",
  22746. "RGB16UI",
  22747. "RGB32F",
  22748. "RGB32I",
  22749. "RGB32UI",
  22750. "RGB565",
  22751. "RGB5_A1",
  22752. "RGB8",
  22753. "RGB8I",
  22754. "RGB8UI",
  22755. "RGB8_SNORM",
  22756. "RGB9_E5",
  22757. "RGBA",
  22758. "RGBA16F",
  22759. "RGBA16I",
  22760. "RGBA16UI",
  22761. "RGBA32F",
  22762. "RGBA32I",
  22763. "RGBA32UI",
  22764. "RGBA4",
  22765. "RGBA8",
  22766. "RGBA8I",
  22767. "RGBA8UI",
  22768. "RGBA8_SNORM",
  22769. "RGBA_INTEGER",
  22770. "RGBColor",
  22771. "RGB_INTEGER",
  22772. "RG_INTEGER",
  22773. "ROTATION_CLOCKWISE",
  22774. "ROTATION_COUNTERCLOCKWISE",
  22775. "RTCCertificate",
  22776. "RTCDTMFSender",
  22777. "RTCDTMFToneChangeEvent",
  22778. "RTCDataChannel",
  22779. "RTCDataChannelEvent",
  22780. "RTCDtlsTransport",
  22781. "RTCEncodedAudioFrame",
  22782. "RTCEncodedVideoFrame",
  22783. "RTCError",
  22784. "RTCErrorEvent",
  22785. "RTCIceCandidate",
  22786. "RTCIceTransport",
  22787. "RTCPeerConnection",
  22788. "RTCPeerConnectionIceErrorEvent",
  22789. "RTCPeerConnectionIceEvent",
  22790. "RTCRtpReceiver",
  22791. "RTCRtpScriptTransform",
  22792. "RTCRtpSender",
  22793. "RTCRtpTransceiver",
  22794. "RTCSctpTransport",
  22795. "RTCSessionDescription",
  22796. "RTCStatsReport",
  22797. "RTCTrackEvent",
  22798. "RadioNodeList",
  22799. "Range",
  22800. "RangeError",
  22801. "RangeException",
  22802. "ReadableByteStreamController",
  22803. "ReadableStream",
  22804. "ReadableStreamBYOBReader",
  22805. "ReadableStreamBYOBRequest",
  22806. "ReadableStreamDefaultController",
  22807. "ReadableStreamDefaultReader",
  22808. "RecordErrorEvent",
  22809. "Rect",
  22810. "ReferenceError",
  22811. "Reflect",
  22812. "RegExp",
  22813. "RelativeOrientationSensor",
  22814. "RelativeTimeFormat",
  22815. "RemotePlayback",
  22816. "Report",
  22817. "ReportBody",
  22818. "ReportingObserver",
  22819. "Request",
  22820. "RequestUpdateCheckStatus",
  22821. "ResizeObserver",
  22822. "ResizeObserverEntry",
  22823. "ResizeObserverSize",
  22824. "Response",
  22825. "RuntimeError",
  22826. "SAMPLER_2D",
  22827. "SAMPLER_2D_ARRAY",
  22828. "SAMPLER_2D_ARRAY_SHADOW",
  22829. "SAMPLER_2D_SHADOW",
  22830. "SAMPLER_3D",
  22831. "SAMPLER_BINDING",
  22832. "SAMPLER_CUBE",
  22833. "SAMPLER_CUBE_SHADOW",
  22834. "SAMPLES",
  22835. "SAMPLE_ALPHA_TO_COVERAGE",
  22836. "SAMPLE_BUFFERS",
  22837. "SAMPLE_COVERAGE",
  22838. "SAMPLE_COVERAGE_INVERT",
  22839. "SAMPLE_COVERAGE_VALUE",
  22840. "SAWTOOTH",
  22841. "SCHEDULED_STATE",
  22842. "SCISSOR_BOX",
  22843. "SCISSOR_TEST",
  22844. "SCROLL_PAGE_DOWN",
  22845. "SCROLL_PAGE_UP",
  22846. "SDP_ANSWER",
  22847. "SDP_OFFER",
  22848. "SDP_PRANSWER",
  22849. "SECURITY_ERR",
  22850. "SELECT",
  22851. "SEPARATE_ATTRIBS",
  22852. "SERIALIZE_ERR",
  22853. "SEVERITY_ERROR",
  22854. "SEVERITY_FATAL_ERROR",
  22855. "SEVERITY_WARNING",
  22856. "SHADER_COMPILER",
  22857. "SHADER_TYPE",
  22858. "SHADING_LANGUAGE_VERSION",
  22859. "SHIFT_MASK",
  22860. "SHORT",
  22861. "SHOWING",
  22862. "SHOW_ALL",
  22863. "SHOW_ATTRIBUTE",
  22864. "SHOW_CDATA_SECTION",
  22865. "SHOW_COMMENT",
  22866. "SHOW_DOCUMENT",
  22867. "SHOW_DOCUMENT_FRAGMENT",
  22868. "SHOW_DOCUMENT_TYPE",
  22869. "SHOW_ELEMENT",
  22870. "SHOW_ENTITY",
  22871. "SHOW_ENTITY_REFERENCE",
  22872. "SHOW_NOTATION",
  22873. "SHOW_PROCESSING_INSTRUCTION",
  22874. "SHOW_TEXT",
  22875. "SIGNALED",
  22876. "SIGNED_NORMALIZED",
  22877. "SINE",
  22878. "SOUNDFIELD",
  22879. "SQLException",
  22880. "SQRT1_2",
  22881. "SQRT2",
  22882. "SQUARE",
  22883. "SRC_ALPHA",
  22884. "SRC_ALPHA_SATURATE",
  22885. "SRC_COLOR",
  22886. "SRGB",
  22887. "SRGB8",
  22888. "SRGB8_ALPHA8",
  22889. "START_TO_END",
  22890. "START_TO_START",
  22891. "STATIC_COPY",
  22892. "STATIC_DRAW",
  22893. "STATIC_READ",
  22894. "STENCIL",
  22895. "STENCIL_ATTACHMENT",
  22896. "STENCIL_BACK_FAIL",
  22897. "STENCIL_BACK_FUNC",
  22898. "STENCIL_BACK_PASS_DEPTH_FAIL",
  22899. "STENCIL_BACK_PASS_DEPTH_PASS",
  22900. "STENCIL_BACK_REF",
  22901. "STENCIL_BACK_VALUE_MASK",
  22902. "STENCIL_BACK_WRITEMASK",
  22903. "STENCIL_BITS",
  22904. "STENCIL_BUFFER_BIT",
  22905. "STENCIL_CLEAR_VALUE",
  22906. "STENCIL_FAIL",
  22907. "STENCIL_FUNC",
  22908. "STENCIL_INDEX",
  22909. "STENCIL_INDEX8",
  22910. "STENCIL_PASS_DEPTH_FAIL",
  22911. "STENCIL_PASS_DEPTH_PASS",
  22912. "STENCIL_REF",
  22913. "STENCIL_TEST",
  22914. "STENCIL_VALUE_MASK",
  22915. "STENCIL_WRITEMASK",
  22916. "STORAGE",
  22917. "STORAGE_BINDING",
  22918. "STREAM_COPY",
  22919. "STREAM_DRAW",
  22920. "STREAM_READ",
  22921. "STRING_TYPE",
  22922. "STYLE_RULE",
  22923. "SUBPIXEL_BITS",
  22924. "SUPPORTS_RULE",
  22925. "SVGAElement",
  22926. "SVGAltGlyphDefElement",
  22927. "SVGAltGlyphElement",
  22928. "SVGAltGlyphItemElement",
  22929. "SVGAngle",
  22930. "SVGAnimateColorElement",
  22931. "SVGAnimateElement",
  22932. "SVGAnimateMotionElement",
  22933. "SVGAnimateTransformElement",
  22934. "SVGAnimatedAngle",
  22935. "SVGAnimatedBoolean",
  22936. "SVGAnimatedEnumeration",
  22937. "SVGAnimatedInteger",
  22938. "SVGAnimatedLength",
  22939. "SVGAnimatedLengthList",
  22940. "SVGAnimatedNumber",
  22941. "SVGAnimatedNumberList",
  22942. "SVGAnimatedPreserveAspectRatio",
  22943. "SVGAnimatedRect",
  22944. "SVGAnimatedString",
  22945. "SVGAnimatedTransformList",
  22946. "SVGAnimationElement",
  22947. "SVGCircleElement",
  22948. "SVGClipPathElement",
  22949. "SVGColor",
  22950. "SVGComponentTransferFunctionElement",
  22951. "SVGCursorElement",
  22952. "SVGDefsElement",
  22953. "SVGDescElement",
  22954. "SVGDiscardElement",
  22955. "SVGDocument",
  22956. "SVGElement",
  22957. "SVGElementInstance",
  22958. "SVGElementInstanceList",
  22959. "SVGEllipseElement",
  22960. "SVGException",
  22961. "SVGFEBlendElement",
  22962. "SVGFEColorMatrixElement",
  22963. "SVGFEComponentTransferElement",
  22964. "SVGFECompositeElement",
  22965. "SVGFEConvolveMatrixElement",
  22966. "SVGFEDiffuseLightingElement",
  22967. "SVGFEDisplacementMapElement",
  22968. "SVGFEDistantLightElement",
  22969. "SVGFEDropShadowElement",
  22970. "SVGFEFloodElement",
  22971. "SVGFEFuncAElement",
  22972. "SVGFEFuncBElement",
  22973. "SVGFEFuncGElement",
  22974. "SVGFEFuncRElement",
  22975. "SVGFEGaussianBlurElement",
  22976. "SVGFEImageElement",
  22977. "SVGFEMergeElement",
  22978. "SVGFEMergeNodeElement",
  22979. "SVGFEMorphologyElement",
  22980. "SVGFEOffsetElement",
  22981. "SVGFEPointLightElement",
  22982. "SVGFESpecularLightingElement",
  22983. "SVGFESpotLightElement",
  22984. "SVGFETileElement",
  22985. "SVGFETurbulenceElement",
  22986. "SVGFilterElement",
  22987. "SVGFontElement",
  22988. "SVGFontFaceElement",
  22989. "SVGFontFaceFormatElement",
  22990. "SVGFontFaceNameElement",
  22991. "SVGFontFaceSrcElement",
  22992. "SVGFontFaceUriElement",
  22993. "SVGForeignObjectElement",
  22994. "SVGGElement",
  22995. "SVGGeometryElement",
  22996. "SVGGlyphElement",
  22997. "SVGGlyphRefElement",
  22998. "SVGGradientElement",
  22999. "SVGGraphicsElement",
  23000. "SVGHKernElement",
  23001. "SVGImageElement",
  23002. "SVGLength",
  23003. "SVGLengthList",
  23004. "SVGLineElement",
  23005. "SVGLinearGradientElement",
  23006. "SVGMPathElement",
  23007. "SVGMarkerElement",
  23008. "SVGMaskElement",
  23009. "SVGMatrix",
  23010. "SVGMetadataElement",
  23011. "SVGMissingGlyphElement",
  23012. "SVGNumber",
  23013. "SVGNumberList",
  23014. "SVGPaint",
  23015. "SVGPathElement",
  23016. "SVGPathSeg",
  23017. "SVGPathSegArcAbs",
  23018. "SVGPathSegArcRel",
  23019. "SVGPathSegClosePath",
  23020. "SVGPathSegCurvetoCubicAbs",
  23021. "SVGPathSegCurvetoCubicRel",
  23022. "SVGPathSegCurvetoCubicSmoothAbs",
  23023. "SVGPathSegCurvetoCubicSmoothRel",
  23024. "SVGPathSegCurvetoQuadraticAbs",
  23025. "SVGPathSegCurvetoQuadraticRel",
  23026. "SVGPathSegCurvetoQuadraticSmoothAbs",
  23027. "SVGPathSegCurvetoQuadraticSmoothRel",
  23028. "SVGPathSegLinetoAbs",
  23029. "SVGPathSegLinetoHorizontalAbs",
  23030. "SVGPathSegLinetoHorizontalRel",
  23031. "SVGPathSegLinetoRel",
  23032. "SVGPathSegLinetoVerticalAbs",
  23033. "SVGPathSegLinetoVerticalRel",
  23034. "SVGPathSegList",
  23035. "SVGPathSegMovetoAbs",
  23036. "SVGPathSegMovetoRel",
  23037. "SVGPatternElement",
  23038. "SVGPoint",
  23039. "SVGPointList",
  23040. "SVGPolygonElement",
  23041. "SVGPolylineElement",
  23042. "SVGPreserveAspectRatio",
  23043. "SVGRadialGradientElement",
  23044. "SVGRect",
  23045. "SVGRectElement",
  23046. "SVGRenderingIntent",
  23047. "SVGSVGElement",
  23048. "SVGScriptElement",
  23049. "SVGSetElement",
  23050. "SVGStopElement",
  23051. "SVGStringList",
  23052. "SVGStyleElement",
  23053. "SVGSwitchElement",
  23054. "SVGSymbolElement",
  23055. "SVGTRefElement",
  23056. "SVGTSpanElement",
  23057. "SVGTextContentElement",
  23058. "SVGTextElement",
  23059. "SVGTextPathElement",
  23060. "SVGTextPositioningElement",
  23061. "SVGTitleElement",
  23062. "SVGTransform",
  23063. "SVGTransformList",
  23064. "SVGUnitTypes",
  23065. "SVGUseElement",
  23066. "SVGVKernElement",
  23067. "SVGViewElement",
  23068. "SVGViewSpec",
  23069. "SVGZoomAndPan",
  23070. "SVGZoomEvent",
  23071. "SVG_ANGLETYPE_DEG",
  23072. "SVG_ANGLETYPE_GRAD",
  23073. "SVG_ANGLETYPE_RAD",
  23074. "SVG_ANGLETYPE_UNKNOWN",
  23075. "SVG_ANGLETYPE_UNSPECIFIED",
  23076. "SVG_CHANNEL_A",
  23077. "SVG_CHANNEL_B",
  23078. "SVG_CHANNEL_G",
  23079. "SVG_CHANNEL_R",
  23080. "SVG_CHANNEL_UNKNOWN",
  23081. "SVG_COLORTYPE_CURRENTCOLOR",
  23082. "SVG_COLORTYPE_RGBCOLOR",
  23083. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  23084. "SVG_COLORTYPE_UNKNOWN",
  23085. "SVG_EDGEMODE_DUPLICATE",
  23086. "SVG_EDGEMODE_NONE",
  23087. "SVG_EDGEMODE_UNKNOWN",
  23088. "SVG_EDGEMODE_WRAP",
  23089. "SVG_FEBLEND_MODE_COLOR",
  23090. "SVG_FEBLEND_MODE_COLOR_BURN",
  23091. "SVG_FEBLEND_MODE_COLOR_DODGE",
  23092. "SVG_FEBLEND_MODE_DARKEN",
  23093. "SVG_FEBLEND_MODE_DIFFERENCE",
  23094. "SVG_FEBLEND_MODE_EXCLUSION",
  23095. "SVG_FEBLEND_MODE_HARD_LIGHT",
  23096. "SVG_FEBLEND_MODE_HUE",
  23097. "SVG_FEBLEND_MODE_LIGHTEN",
  23098. "SVG_FEBLEND_MODE_LUMINOSITY",
  23099. "SVG_FEBLEND_MODE_MULTIPLY",
  23100. "SVG_FEBLEND_MODE_NORMAL",
  23101. "SVG_FEBLEND_MODE_OVERLAY",
  23102. "SVG_FEBLEND_MODE_SATURATION",
  23103. "SVG_FEBLEND_MODE_SCREEN",
  23104. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  23105. "SVG_FEBLEND_MODE_UNKNOWN",
  23106. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  23107. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  23108. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  23109. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  23110. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  23111. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  23112. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  23113. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  23114. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  23115. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  23116. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  23117. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  23118. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  23119. "SVG_FECOMPOSITE_OPERATOR_IN",
  23120. "SVG_FECOMPOSITE_OPERATOR_LIGHTER",
  23121. "SVG_FECOMPOSITE_OPERATOR_OUT",
  23122. "SVG_FECOMPOSITE_OPERATOR_OVER",
  23123. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  23124. "SVG_FECOMPOSITE_OPERATOR_XOR",
  23125. "SVG_INVALID_VALUE_ERR",
  23126. "SVG_LENGTHTYPE_CM",
  23127. "SVG_LENGTHTYPE_EMS",
  23128. "SVG_LENGTHTYPE_EXS",
  23129. "SVG_LENGTHTYPE_IN",
  23130. "SVG_LENGTHTYPE_MM",
  23131. "SVG_LENGTHTYPE_NUMBER",
  23132. "SVG_LENGTHTYPE_PC",
  23133. "SVG_LENGTHTYPE_PERCENTAGE",
  23134. "SVG_LENGTHTYPE_PT",
  23135. "SVG_LENGTHTYPE_PX",
  23136. "SVG_LENGTHTYPE_UNKNOWN",
  23137. "SVG_MARKERUNITS_STROKEWIDTH",
  23138. "SVG_MARKERUNITS_UNKNOWN",
  23139. "SVG_MARKERUNITS_USERSPACEONUSE",
  23140. "SVG_MARKER_ORIENT_ANGLE",
  23141. "SVG_MARKER_ORIENT_AUTO",
  23142. "SVG_MARKER_ORIENT_AUTO_START_REVERSE",
  23143. "SVG_MARKER_ORIENT_UNKNOWN",
  23144. "SVG_MASKTYPE_ALPHA",
  23145. "SVG_MASKTYPE_LUMINANCE",
  23146. "SVG_MATRIX_NOT_INVERTABLE",
  23147. "SVG_MEETORSLICE_MEET",
  23148. "SVG_MEETORSLICE_SLICE",
  23149. "SVG_MEETORSLICE_UNKNOWN",
  23150. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  23151. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  23152. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  23153. "SVG_PAINTTYPE_CURRENTCOLOR",
  23154. "SVG_PAINTTYPE_NONE",
  23155. "SVG_PAINTTYPE_RGBCOLOR",
  23156. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  23157. "SVG_PAINTTYPE_UNKNOWN",
  23158. "SVG_PAINTTYPE_URI",
  23159. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  23160. "SVG_PAINTTYPE_URI_NONE",
  23161. "SVG_PAINTTYPE_URI_RGBCOLOR",
  23162. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  23163. "SVG_PRESERVEASPECTRATIO_NONE",
  23164. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  23165. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  23166. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  23167. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  23168. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  23169. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  23170. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  23171. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  23172. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  23173. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  23174. "SVG_SPREADMETHOD_PAD",
  23175. "SVG_SPREADMETHOD_REFLECT",
  23176. "SVG_SPREADMETHOD_REPEAT",
  23177. "SVG_SPREADMETHOD_UNKNOWN",
  23178. "SVG_STITCHTYPE_NOSTITCH",
  23179. "SVG_STITCHTYPE_STITCH",
  23180. "SVG_STITCHTYPE_UNKNOWN",
  23181. "SVG_TRANSFORM_MATRIX",
  23182. "SVG_TRANSFORM_ROTATE",
  23183. "SVG_TRANSFORM_SCALE",
  23184. "SVG_TRANSFORM_SKEWX",
  23185. "SVG_TRANSFORM_SKEWY",
  23186. "SVG_TRANSFORM_TRANSLATE",
  23187. "SVG_TRANSFORM_UNKNOWN",
  23188. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  23189. "SVG_TURBULENCE_TYPE_TURBULENCE",
  23190. "SVG_TURBULENCE_TYPE_UNKNOWN",
  23191. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  23192. "SVG_UNIT_TYPE_UNKNOWN",
  23193. "SVG_UNIT_TYPE_USERSPACEONUSE",
  23194. "SVG_WRONG_TYPE_ERR",
  23195. "SVG_ZOOMANDPAN_DISABLE",
  23196. "SVG_ZOOMANDPAN_MAGNIFY",
  23197. "SVG_ZOOMANDPAN_UNKNOWN",
  23198. "SYNC_CONDITION",
  23199. "SYNC_FENCE",
  23200. "SYNC_FLAGS",
  23201. "SYNC_FLUSH_COMMANDS_BIT",
  23202. "SYNC_GPU_COMMANDS_COMPLETE",
  23203. "SYNC_STATUS",
  23204. "SYNTAX_ERR",
  23205. "SavedPages",
  23206. "Scheduler",
  23207. "Scheduling",
  23208. "Screen",
  23209. "ScreenDetailed",
  23210. "ScreenDetails",
  23211. "ScreenOrientation",
  23212. "Script",
  23213. "ScriptProcessorNode",
  23214. "ScrollAreaEvent",
  23215. "ScrollTimeline",
  23216. "SecurityPolicyViolationEvent",
  23217. "Segmenter",
  23218. "Selection",
  23219. "Sensor",
  23220. "SensorErrorEvent",
  23221. "Serial",
  23222. "SerialPort",
  23223. "ServiceWorker",
  23224. "ServiceWorkerContainer",
  23225. "ServiceWorkerRegistration",
  23226. "SessionDescription",
  23227. "Set",
  23228. "ShadowRoot",
  23229. "SharedArrayBuffer",
  23230. "SharedStorage",
  23231. "SharedStorageWorklet",
  23232. "SharedWorker",
  23233. "SharingState",
  23234. "SimpleGestureEvent",
  23235. "SnapEvent",
  23236. "SourceBuffer",
  23237. "SourceBufferList",
  23238. "SpeechSynthesis",
  23239. "SpeechSynthesisErrorEvent",
  23240. "SpeechSynthesisEvent",
  23241. "SpeechSynthesisUtterance",
  23242. "SpeechSynthesisVoice",
  23243. "StaticRange",
  23244. "StereoPannerNode",
  23245. "StopIteration",
  23246. "Storage",
  23247. "StorageBucket",
  23248. "StorageBucketManager",
  23249. "StorageEvent",
  23250. "StorageManager",
  23251. "String",
  23252. "StructType",
  23253. "StylePropertyMap",
  23254. "StylePropertyMapReadOnly",
  23255. "StyleSheet",
  23256. "StyleSheetList",
  23257. "SubmitEvent",
  23258. "SubtleCrypto",
  23259. "Symbol",
  23260. "SyncManager",
  23261. "SyntaxError",
  23262. "TAB_ID_NONE",
  23263. "TAB_INDEX_NONE",
  23264. "TEMPORARY",
  23265. "TEXTPATH_METHODTYPE_ALIGN",
  23266. "TEXTPATH_METHODTYPE_STRETCH",
  23267. "TEXTPATH_METHODTYPE_UNKNOWN",
  23268. "TEXTPATH_SPACINGTYPE_AUTO",
  23269. "TEXTPATH_SPACINGTYPE_EXACT",
  23270. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  23271. "TEXTURE",
  23272. "TEXTURE0",
  23273. "TEXTURE1",
  23274. "TEXTURE10",
  23275. "TEXTURE11",
  23276. "TEXTURE12",
  23277. "TEXTURE13",
  23278. "TEXTURE14",
  23279. "TEXTURE15",
  23280. "TEXTURE16",
  23281. "TEXTURE17",
  23282. "TEXTURE18",
  23283. "TEXTURE19",
  23284. "TEXTURE2",
  23285. "TEXTURE20",
  23286. "TEXTURE21",
  23287. "TEXTURE22",
  23288. "TEXTURE23",
  23289. "TEXTURE24",
  23290. "TEXTURE25",
  23291. "TEXTURE26",
  23292. "TEXTURE27",
  23293. "TEXTURE28",
  23294. "TEXTURE29",
  23295. "TEXTURE3",
  23296. "TEXTURE30",
  23297. "TEXTURE31",
  23298. "TEXTURE4",
  23299. "TEXTURE5",
  23300. "TEXTURE6",
  23301. "TEXTURE7",
  23302. "TEXTURE8",
  23303. "TEXTURE9",
  23304. "TEXTURE_2D",
  23305. "TEXTURE_2D_ARRAY",
  23306. "TEXTURE_3D",
  23307. "TEXTURE_BASE_LEVEL",
  23308. "TEXTURE_BINDING",
  23309. "TEXTURE_BINDING_2D",
  23310. "TEXTURE_BINDING_2D_ARRAY",
  23311. "TEXTURE_BINDING_3D",
  23312. "TEXTURE_BINDING_CUBE_MAP",
  23313. "TEXTURE_COMPARE_FUNC",
  23314. "TEXTURE_COMPARE_MODE",
  23315. "TEXTURE_CUBE_MAP",
  23316. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  23317. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  23318. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  23319. "TEXTURE_CUBE_MAP_POSITIVE_X",
  23320. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  23321. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  23322. "TEXTURE_IMMUTABLE_FORMAT",
  23323. "TEXTURE_IMMUTABLE_LEVELS",
  23324. "TEXTURE_MAG_FILTER",
  23325. "TEXTURE_MAX_ANISOTROPY_EXT",
  23326. "TEXTURE_MAX_LEVEL",
  23327. "TEXTURE_MAX_LOD",
  23328. "TEXTURE_MIN_FILTER",
  23329. "TEXTURE_MIN_LOD",
  23330. "TEXTURE_WRAP_R",
  23331. "TEXTURE_WRAP_S",
  23332. "TEXTURE_WRAP_T",
  23333. "TEXT_NODE",
  23334. "TIMEOUT",
  23335. "TIMEOUT_ERR",
  23336. "TIMEOUT_EXPIRED",
  23337. "TIMEOUT_IGNORED",
  23338. "TOO_LARGE_ERR",
  23339. "TRANSACTION_INACTIVE_ERR",
  23340. "TRANSFORM_FEEDBACK",
  23341. "TRANSFORM_FEEDBACK_ACTIVE",
  23342. "TRANSFORM_FEEDBACK_BINDING",
  23343. "TRANSFORM_FEEDBACK_BUFFER",
  23344. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  23345. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  23346. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  23347. "TRANSFORM_FEEDBACK_BUFFER_START",
  23348. "TRANSFORM_FEEDBACK_PAUSED",
  23349. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  23350. "TRANSFORM_FEEDBACK_VARYINGS",
  23351. "TRIANGLE",
  23352. "TRIANGLES",
  23353. "TRIANGLE_FAN",
  23354. "TRIANGLE_STRIP",
  23355. "TYPE_BACK_FORWARD",
  23356. "TYPE_ERR",
  23357. "TYPE_MISMATCH_ERR",
  23358. "TYPE_NAVIGATE",
  23359. "TYPE_RELOAD",
  23360. "TYPE_RESERVED",
  23361. "Tab",
  23362. "TabStatus",
  23363. "Table",
  23364. "Tag",
  23365. "TaskAttributionTiming",
  23366. "TaskController",
  23367. "TaskPriorityChangeEvent",
  23368. "TaskSignal",
  23369. "Text",
  23370. "TextDecoder",
  23371. "TextDecoderStream",
  23372. "TextEncoder",
  23373. "TextEncoderStream",
  23374. "TextEvent",
  23375. "TextFormat",
  23376. "TextFormatUpdateEvent",
  23377. "TextMetrics",
  23378. "TextTrack",
  23379. "TextTrackCue",
  23380. "TextTrackCueList",
  23381. "TextTrackList",
  23382. "TextUpdateEvent",
  23383. "TimeEvent",
  23384. "TimeRanges",
  23385. "ToggleEvent",
  23386. "Touch",
  23387. "TouchEvent",
  23388. "TouchList",
  23389. "TrackEvent",
  23390. "TransformStream",
  23391. "TransformStreamDefaultController",
  23392. "TransitionEvent",
  23393. "TreeWalker",
  23394. "TrustedHTML",
  23395. "TrustedScript",
  23396. "TrustedScriptURL",
  23397. "TrustedTypePolicy",
  23398. "TrustedTypePolicyFactory",
  23399. "TypeError",
  23400. "TypedObject",
  23401. "U2F",
  23402. "UIEvent",
  23403. "UNCACHED",
  23404. "UNIFORM",
  23405. "UNIFORM_ARRAY_STRIDE",
  23406. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  23407. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  23408. "UNIFORM_BLOCK_BINDING",
  23409. "UNIFORM_BLOCK_DATA_SIZE",
  23410. "UNIFORM_BLOCK_INDEX",
  23411. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  23412. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  23413. "UNIFORM_BUFFER",
  23414. "UNIFORM_BUFFER_BINDING",
  23415. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  23416. "UNIFORM_BUFFER_SIZE",
  23417. "UNIFORM_BUFFER_START",
  23418. "UNIFORM_IS_ROW_MAJOR",
  23419. "UNIFORM_MATRIX_STRIDE",
  23420. "UNIFORM_OFFSET",
  23421. "UNIFORM_SIZE",
  23422. "UNIFORM_TYPE",
  23423. "UNKNOWN_ERR",
  23424. "UNKNOWN_RULE",
  23425. "UNMASKED_RENDERER_WEBGL",
  23426. "UNMASKED_VENDOR_WEBGL",
  23427. "UNORDERED_NODE_ITERATOR_TYPE",
  23428. "UNORDERED_NODE_SNAPSHOT_TYPE",
  23429. "UNPACK_ALIGNMENT",
  23430. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  23431. "UNPACK_FLIP_Y_WEBGL",
  23432. "UNPACK_IMAGE_HEIGHT",
  23433. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  23434. "UNPACK_ROW_LENGTH",
  23435. "UNPACK_SKIP_IMAGES",
  23436. "UNPACK_SKIP_PIXELS",
  23437. "UNPACK_SKIP_ROWS",
  23438. "UNSCHEDULED_STATE",
  23439. "UNSENT",
  23440. "UNSIGNALED",
  23441. "UNSIGNED_BYTE",
  23442. "UNSIGNED_INT",
  23443. "UNSIGNED_INT_10F_11F_11F_REV",
  23444. "UNSIGNED_INT_24_8",
  23445. "UNSIGNED_INT_2_10_10_10_REV",
  23446. "UNSIGNED_INT_5_9_9_9_REV",
  23447. "UNSIGNED_INT_SAMPLER_2D",
  23448. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  23449. "UNSIGNED_INT_SAMPLER_3D",
  23450. "UNSIGNED_INT_SAMPLER_CUBE",
  23451. "UNSIGNED_INT_VEC2",
  23452. "UNSIGNED_INT_VEC3",
  23453. "UNSIGNED_INT_VEC4",
  23454. "UNSIGNED_NORMALIZED",
  23455. "UNSIGNED_SHORT",
  23456. "UNSIGNED_SHORT_4_4_4_4",
  23457. "UNSIGNED_SHORT_5_5_5_1",
  23458. "UNSIGNED_SHORT_5_6_5",
  23459. "UNSPECIFIED_EVENT_TYPE_ERR",
  23460. "UPDATEREADY",
  23461. "URIError",
  23462. "URL",
  23463. "URLPattern",
  23464. "URLSearchParams",
  23465. "URLUnencoded",
  23466. "URL_MISMATCH_ERR",
  23467. "USB",
  23468. "USBAlternateInterface",
  23469. "USBConfiguration",
  23470. "USBConnectionEvent",
  23471. "USBDevice",
  23472. "USBEndpoint",
  23473. "USBInTransferResult",
  23474. "USBInterface",
  23475. "USBIsochronousInTransferPacket",
  23476. "USBIsochronousInTransferResult",
  23477. "USBIsochronousOutTransferPacket",
  23478. "USBIsochronousOutTransferResult",
  23479. "USBOutTransferResult",
  23480. "UTC",
  23481. "Uint16Array",
  23482. "Uint32Array",
  23483. "Uint8Array",
  23484. "Uint8ClampedArray",
  23485. "UpdateFilter",
  23486. "UpdatePropertyName",
  23487. "UserActivation",
  23488. "UserMessageHandler",
  23489. "UserMessageHandlersNamespace",
  23490. "UserProximityEvent",
  23491. "VALIDATE_STATUS",
  23492. "VALIDATION_ERR",
  23493. "VARIABLES_RULE",
  23494. "VENDOR",
  23495. "VERSION",
  23496. "VERSION_CHANGE",
  23497. "VERSION_ERR",
  23498. "VERTEX",
  23499. "VERTEX_ARRAY_BINDING",
  23500. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  23501. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  23502. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  23503. "VERTEX_ATTRIB_ARRAY_ENABLED",
  23504. "VERTEX_ATTRIB_ARRAY_INTEGER",
  23505. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  23506. "VERTEX_ATTRIB_ARRAY_POINTER",
  23507. "VERTEX_ATTRIB_ARRAY_SIZE",
  23508. "VERTEX_ATTRIB_ARRAY_STRIDE",
  23509. "VERTEX_ATTRIB_ARRAY_TYPE",
  23510. "VERTEX_SHADER",
  23511. "VERTICAL",
  23512. "VERTICAL_AXIS",
  23513. "VER_ERR",
  23514. "VIEWPORT",
  23515. "VIEWPORT_RULE",
  23516. "VRDisplay",
  23517. "VRDisplayCapabilities",
  23518. "VRDisplayEvent",
  23519. "VREyeParameters",
  23520. "VRFieldOfView",
  23521. "VRFrameData",
  23522. "VRPose",
  23523. "VRStageParameters",
  23524. "VTTCue",
  23525. "VTTRegion",
  23526. "ValidityState",
  23527. "VideoColorSpace",
  23528. "VideoDecoder",
  23529. "VideoEncoder",
  23530. "VideoFrame",
  23531. "VideoPlaybackQuality",
  23532. "VideoStreamTrack",
  23533. "ViewTimeline",
  23534. "ViewTransition",
  23535. "ViewTransitionTypeSet",
  23536. "ViewType",
  23537. "VirtualKeyboard",
  23538. "VirtualKeyboardGeometryChangeEvent",
  23539. "VisibilityStateEntry",
  23540. "VisualViewport",
  23541. "WAIT_FAILED",
  23542. "WEBKIT_FILTER_RULE",
  23543. "WEBKIT_KEYFRAMES_RULE",
  23544. "WEBKIT_KEYFRAME_RULE",
  23545. "WEBKIT_REGION_RULE",
  23546. "WGSLLanguageFeatures",
  23547. "WINDOW_ID_CURRENT",
  23548. "WINDOW_ID_NONE",
  23549. "WRITE",
  23550. "WRONG_DOCUMENT_ERR",
  23551. "WakeLock",
  23552. "WakeLockSentinel",
  23553. "WasmAnyRef",
  23554. "WaveShaperNode",
  23555. "WeakMap",
  23556. "WeakRef",
  23557. "WeakSet",
  23558. "WebAssembly",
  23559. "WebGL2RenderingContext",
  23560. "WebGLActiveInfo",
  23561. "WebGLBuffer",
  23562. "WebGLContextEvent",
  23563. "WebGLFramebuffer",
  23564. "WebGLObject",
  23565. "WebGLProgram",
  23566. "WebGLQuery",
  23567. "WebGLRenderbuffer",
  23568. "WebGLRenderingContext",
  23569. "WebGLSampler",
  23570. "WebGLShader",
  23571. "WebGLShaderPrecisionFormat",
  23572. "WebGLSync",
  23573. "WebGLTexture",
  23574. "WebGLTransformFeedback",
  23575. "WebGLUniformLocation",
  23576. "WebGLVertexArray",
  23577. "WebGLVertexArrayObject",
  23578. "WebKitAnimationEvent",
  23579. "WebKitBlobBuilder",
  23580. "WebKitCSSFilterRule",
  23581. "WebKitCSSFilterValue",
  23582. "WebKitCSSKeyframeRule",
  23583. "WebKitCSSKeyframesRule",
  23584. "WebKitCSSMatrix",
  23585. "WebKitCSSRegionRule",
  23586. "WebKitCSSTransformValue",
  23587. "WebKitDataCue",
  23588. "WebKitGamepad",
  23589. "WebKitMediaKeyError",
  23590. "WebKitMediaKeyMessageEvent",
  23591. "WebKitMediaKeySession",
  23592. "WebKitMediaKeys",
  23593. "WebKitMediaSource",
  23594. "WebKitMutationObserver",
  23595. "WebKitNamespace",
  23596. "WebKitPlaybackTargetAvailabilityEvent",
  23597. "WebKitPoint",
  23598. "WebKitShadowRoot",
  23599. "WebKitSourceBuffer",
  23600. "WebKitSourceBufferList",
  23601. "WebKitTransitionEvent",
  23602. "WebSocket",
  23603. "WebSocketError",
  23604. "WebSocketStream",
  23605. "WebTransport",
  23606. "WebTransportBidirectionalStream",
  23607. "WebTransportDatagramDuplexStream",
  23608. "WebTransportError",
  23609. "WebTransportReceiveStream",
  23610. "WebTransportSendStream",
  23611. "WebkitAlignContent",
  23612. "WebkitAlignItems",
  23613. "WebkitAlignSelf",
  23614. "WebkitAnimation",
  23615. "WebkitAnimationDelay",
  23616. "WebkitAnimationDirection",
  23617. "WebkitAnimationDuration",
  23618. "WebkitAnimationFillMode",
  23619. "WebkitAnimationIterationCount",
  23620. "WebkitAnimationName",
  23621. "WebkitAnimationPlayState",
  23622. "WebkitAnimationTimingFunction",
  23623. "WebkitAppearance",
  23624. "WebkitBackfaceVisibility",
  23625. "WebkitBackgroundClip",
  23626. "WebkitBackgroundOrigin",
  23627. "WebkitBackgroundSize",
  23628. "WebkitBorderBottomLeftRadius",
  23629. "WebkitBorderBottomRightRadius",
  23630. "WebkitBorderImage",
  23631. "WebkitBorderRadius",
  23632. "WebkitBorderTopLeftRadius",
  23633. "WebkitBorderTopRightRadius",
  23634. "WebkitBoxAlign",
  23635. "WebkitBoxDirection",
  23636. "WebkitBoxFlex",
  23637. "WebkitBoxOrdinalGroup",
  23638. "WebkitBoxOrient",
  23639. "WebkitBoxPack",
  23640. "WebkitBoxShadow",
  23641. "WebkitBoxSizing",
  23642. "WebkitClipPath",
  23643. "WebkitFilter",
  23644. "WebkitFlex",
  23645. "WebkitFlexBasis",
  23646. "WebkitFlexDirection",
  23647. "WebkitFlexFlow",
  23648. "WebkitFlexGrow",
  23649. "WebkitFlexShrink",
  23650. "WebkitFlexWrap",
  23651. "WebkitFontFeatureSettings",
  23652. "WebkitJustifyContent",
  23653. "WebkitLineClamp",
  23654. "WebkitMask",
  23655. "WebkitMaskClip",
  23656. "WebkitMaskComposite",
  23657. "WebkitMaskImage",
  23658. "WebkitMaskOrigin",
  23659. "WebkitMaskPosition",
  23660. "WebkitMaskPositionX",
  23661. "WebkitMaskPositionY",
  23662. "WebkitMaskRepeat",
  23663. "WebkitMaskSize",
  23664. "WebkitOrder",
  23665. "WebkitPerspective",
  23666. "WebkitPerspectiveOrigin",
  23667. "WebkitTextFillColor",
  23668. "WebkitTextSecurity",
  23669. "WebkitTextSizeAdjust",
  23670. "WebkitTextStroke",
  23671. "WebkitTextStrokeColor",
  23672. "WebkitTextStrokeWidth",
  23673. "WebkitTransform",
  23674. "WebkitTransformOrigin",
  23675. "WebkitTransformStyle",
  23676. "WebkitTransition",
  23677. "WebkitTransitionDelay",
  23678. "WebkitTransitionDuration",
  23679. "WebkitTransitionProperty",
  23680. "WebkitTransitionTimingFunction",
  23681. "WebkitUserSelect",
  23682. "WheelEvent",
  23683. "Window",
  23684. "WindowControlsOverlay",
  23685. "WindowControlsOverlayGeometryChangeEvent",
  23686. "WindowState",
  23687. "WindowType",
  23688. "Worker",
  23689. "Worklet",
  23690. "WritableStream",
  23691. "WritableStreamDefaultController",
  23692. "WritableStreamDefaultWriter",
  23693. "XMLDocument",
  23694. "XMLHttpRequest",
  23695. "XMLHttpRequestEventTarget",
  23696. "XMLHttpRequestException",
  23697. "XMLHttpRequestProgressEvent",
  23698. "XMLHttpRequestUpload",
  23699. "XMLSerializer",
  23700. "XMLStylesheetProcessingInstruction",
  23701. "XPathEvaluator",
  23702. "XPathException",
  23703. "XPathExpression",
  23704. "XPathNSResolver",
  23705. "XPathResult",
  23706. "XRAnchor",
  23707. "XRAnchorSet",
  23708. "XRBoundedReferenceSpace",
  23709. "XRCPUDepthInformation",
  23710. "XRCamera",
  23711. "XRDOMOverlayState",
  23712. "XRDepthInformation",
  23713. "XRFrame",
  23714. "XRHand",
  23715. "XRHitTestResult",
  23716. "XRHitTestSource",
  23717. "XRInputSource",
  23718. "XRInputSourceArray",
  23719. "XRInputSourceEvent",
  23720. "XRInputSourcesChangeEvent",
  23721. "XRJointPose",
  23722. "XRJointSpace",
  23723. "XRLayer",
  23724. "XRLightEstimate",
  23725. "XRLightProbe",
  23726. "XRPose",
  23727. "XRRay",
  23728. "XRReferenceSpace",
  23729. "XRReferenceSpaceEvent",
  23730. "XRRenderState",
  23731. "XRRigidTransform",
  23732. "XRSession",
  23733. "XRSessionEvent",
  23734. "XRSpace",
  23735. "XRSystem",
  23736. "XRTransientInputHitTestResult",
  23737. "XRTransientInputHitTestSource",
  23738. "XRView",
  23739. "XRViewerPose",
  23740. "XRViewport",
  23741. "XRWebGLBinding",
  23742. "XRWebGLDepthInformation",
  23743. "XRWebGLLayer",
  23744. "XSLTProcessor",
  23745. "ZERO",
  23746. "ZoomSettings",
  23747. "ZoomSettingsMode",
  23748. "ZoomSettingsScope",
  23749. "_XD0M_",
  23750. "_YD0M_",
  23751. "__REACT_DEVTOOLS_GLOBAL_HOOK__",
  23752. "__brand",
  23753. "__defineGetter__",
  23754. "__defineSetter__",
  23755. "__lookupGetter__",
  23756. "__lookupSetter__",
  23757. "__opera",
  23758. "__proto__",
  23759. "_browserjsran",
  23760. "a",
  23761. "aLink",
  23762. "abbr",
  23763. "abort",
  23764. "aborted",
  23765. "aboutConfigPrefs",
  23766. "abs",
  23767. "absolute",
  23768. "acceleration",
  23769. "accelerationIncludingGravity",
  23770. "accelerator",
  23771. "accent-color",
  23772. "accentColor",
  23773. "accept",
  23774. "acceptCharset",
  23775. "acceptNode",
  23776. "access",
  23777. "accessKey",
  23778. "accessKeyLabel",
  23779. "accuracy",
  23780. "acos",
  23781. "acosh",
  23782. "action",
  23783. "actionURL",
  23784. "actions",
  23785. "activated",
  23786. "activation",
  23787. "activationStart",
  23788. "active",
  23789. "activeCues",
  23790. "activeElement",
  23791. "activeSourceBuffers",
  23792. "activeSourceCount",
  23793. "activeTexture",
  23794. "activeVRDisplays",
  23795. "activityLog",
  23796. "actualBoundingBoxAscent",
  23797. "actualBoundingBoxDescent",
  23798. "actualBoundingBoxLeft",
  23799. "actualBoundingBoxRight",
  23800. "adAuctionComponents",
  23801. "adAuctionHeaders",
  23802. "add",
  23803. "addAll",
  23804. "addBehavior",
  23805. "addCandidate",
  23806. "addColorStop",
  23807. "addCue",
  23808. "addElement",
  23809. "addEventListener",
  23810. "addFilter",
  23811. "addFromString",
  23812. "addFromUri",
  23813. "addIceCandidate",
  23814. "addImport",
  23815. "addListener",
  23816. "addModule",
  23817. "addNamed",
  23818. "addPageRule",
  23819. "addPath",
  23820. "addPointer",
  23821. "addRange",
  23822. "addRegion",
  23823. "addRule",
  23824. "addSearchEngine",
  23825. "addSourceBuffer",
  23826. "addStream",
  23827. "addTextTrack",
  23828. "addTrack",
  23829. "addTransceiver",
  23830. "addWakeLockListener",
  23831. "added",
  23832. "addedNodes",
  23833. "additionalName",
  23834. "additiveSymbols",
  23835. "addons",
  23836. "address",
  23837. "addressLine",
  23838. "addressModeU",
  23839. "addressModeV",
  23840. "addressModeW",
  23841. "adoptNode",
  23842. "adoptedCallback",
  23843. "adoptedStyleSheets",
  23844. "adr",
  23845. "advance",
  23846. "after",
  23847. "alarms",
  23848. "album",
  23849. "alert",
  23850. "algorithm",
  23851. "align",
  23852. "align-content",
  23853. "align-items",
  23854. "align-self",
  23855. "alignContent",
  23856. "alignItems",
  23857. "alignSelf",
  23858. "alignmentBaseline",
  23859. "alinkColor",
  23860. "all",
  23861. "allSettled",
  23862. "allocationSize",
  23863. "allow",
  23864. "allowFullscreen",
  23865. "allowPaymentRequest",
  23866. "allowedDirections",
  23867. "allowedFeatures",
  23868. "allowedToPlay",
  23869. "allowsFeature",
  23870. "alpha",
  23871. "alphaMode",
  23872. "alphaToCoverageEnabled",
  23873. "alphabeticBaseline",
  23874. "alt",
  23875. "altGraphKey",
  23876. "altHtml",
  23877. "altKey",
  23878. "altLeft",
  23879. "alternate",
  23880. "alternateSetting",
  23881. "alternates",
  23882. "altitude",
  23883. "altitudeAccuracy",
  23884. "altitudeAngle",
  23885. "amplitude",
  23886. "ancestorOrigins",
  23887. "anchor",
  23888. "anchorNode",
  23889. "anchorOffset",
  23890. "anchorSpace",
  23891. "anchors",
  23892. "and",
  23893. "angle",
  23894. "angularAcceleration",
  23895. "angularVelocity",
  23896. "animVal",
  23897. "animate",
  23898. "animated",
  23899. "animatedInstanceRoot",
  23900. "animatedNormalizedPathSegList",
  23901. "animatedPathSegList",
  23902. "animatedPoints",
  23903. "animation",
  23904. "animation-composition",
  23905. "animation-delay",
  23906. "animation-direction",
  23907. "animation-duration",
  23908. "animation-fill-mode",
  23909. "animation-iteration-count",
  23910. "animation-name",
  23911. "animation-play-state",
  23912. "animation-timing-function",
  23913. "animationComposition",
  23914. "animationDelay",
  23915. "animationDirection",
  23916. "animationDuration",
  23917. "animationFillMode",
  23918. "animationIterationCount",
  23919. "animationName",
  23920. "animationPlayState",
  23921. "animationStartTime",
  23922. "animationTimingFunction",
  23923. "animationsPaused",
  23924. "anniversary",
  23925. "antialias",
  23926. "anticipatedRemoval",
  23927. "any",
  23928. "app",
  23929. "appCodeName",
  23930. "appMinorVersion",
  23931. "appName",
  23932. "appNotifications",
  23933. "appVersion",
  23934. "appearance",
  23935. "append",
  23936. "appendBuffer",
  23937. "appendChild",
  23938. "appendData",
  23939. "appendItem",
  23940. "appendMedium",
  23941. "appendNamed",
  23942. "appendRule",
  23943. "appendStream",
  23944. "appendWindowEnd",
  23945. "appendWindowStart",
  23946. "applets",
  23947. "applicationCache",
  23948. "applicationServerKey",
  23949. "apply",
  23950. "applyConstraints",
  23951. "applyElement",
  23952. "arc",
  23953. "arcTo",
  23954. "arch",
  23955. "architecture",
  23956. "archive",
  23957. "areas",
  23958. "arguments",
  23959. "ariaAtomic",
  23960. "ariaAutoComplete",
  23961. "ariaBrailleLabel",
  23962. "ariaBrailleRoleDescription",
  23963. "ariaBusy",
  23964. "ariaChecked",
  23965. "ariaColCount",
  23966. "ariaColIndex",
  23967. "ariaColIndexText",
  23968. "ariaColSpan",
  23969. "ariaCurrent",
  23970. "ariaDescription",
  23971. "ariaDisabled",
  23972. "ariaExpanded",
  23973. "ariaHasPopup",
  23974. "ariaHidden",
  23975. "ariaInvalid",
  23976. "ariaKeyShortcuts",
  23977. "ariaLabel",
  23978. "ariaLevel",
  23979. "ariaLive",
  23980. "ariaModal",
  23981. "ariaMultiLine",
  23982. "ariaMultiSelectable",
  23983. "ariaOrientation",
  23984. "ariaPlaceholder",
  23985. "ariaPosInSet",
  23986. "ariaPressed",
  23987. "ariaReadOnly",
  23988. "ariaRelevant",
  23989. "ariaRequired",
  23990. "ariaRoleDescription",
  23991. "ariaRowCount",
  23992. "ariaRowIndex",
  23993. "ariaRowIndexText",
  23994. "ariaRowSpan",
  23995. "ariaSelected",
  23996. "ariaSetSize",
  23997. "ariaSort",
  23998. "ariaValueMax",
  23999. "ariaValueMin",
  24000. "ariaValueNow",
  24001. "ariaValueText",
  24002. "arrayBuffer",
  24003. "arrayLayerCount",
  24004. "arrayStride",
  24005. "artist",
  24006. "artwork",
  24007. "as",
  24008. "asIntN",
  24009. "asUintN",
  24010. "ascentOverride",
  24011. "asin",
  24012. "asinh",
  24013. "aspect",
  24014. "aspect-ratio",
  24015. "aspectRatio",
  24016. "assert",
  24017. "assign",
  24018. "assignedElements",
  24019. "assignedNodes",
  24020. "assignedSlot",
  24021. "async",
  24022. "asyncDispose",
  24023. "asyncIterator",
  24024. "at",
  24025. "atEnd",
  24026. "atan",
  24027. "atan2",
  24028. "atanh",
  24029. "atob",
  24030. "attachEvent",
  24031. "attachInternals",
  24032. "attachShader",
  24033. "attachShadow",
  24034. "attachedElements",
  24035. "attachments",
  24036. "attack",
  24037. "attestationObject",
  24038. "attrChange",
  24039. "attrName",
  24040. "attributeChangedCallback",
  24041. "attributeFilter",
  24042. "attributeName",
  24043. "attributeNamespace",
  24044. "attributeOldValue",
  24045. "attributeStyleMap",
  24046. "attributes",
  24047. "attribution",
  24048. "attributionSrc",
  24049. "audioBitrateMode",
  24050. "audioBitsPerSecond",
  24051. "audioTracks",
  24052. "audioWorklet",
  24053. "authenticatedSignedWrites",
  24054. "authenticatorAttachment",
  24055. "authenticatorData",
  24056. "autoIncrement",
  24057. "autobuffer",
  24058. "autocapitalize",
  24059. "autocomplete",
  24060. "autocorrect",
  24061. "autofocus",
  24062. "automationRate",
  24063. "autoplay",
  24064. "availHeight",
  24065. "availLeft",
  24066. "availTop",
  24067. "availWidth",
  24068. "availability",
  24069. "available",
  24070. "averageLatency",
  24071. "aversion",
  24072. "ax",
  24073. "axes",
  24074. "axis",
  24075. "ay",
  24076. "azimuth",
  24077. "azimuthAngle",
  24078. "b",
  24079. "back",
  24080. "backdrop-filter",
  24081. "backdropFilter",
  24082. "backends",
  24083. "backface-visibility",
  24084. "backfaceVisibility",
  24085. "background",
  24086. "background-attachment",
  24087. "background-blend-mode",
  24088. "background-clip",
  24089. "background-color",
  24090. "background-image",
  24091. "background-origin",
  24092. "background-position",
  24093. "background-position-x",
  24094. "background-position-y",
  24095. "background-repeat",
  24096. "background-size",
  24097. "backgroundAttachment",
  24098. "backgroundBlendMode",
  24099. "backgroundClip",
  24100. "backgroundColor",
  24101. "backgroundFetch",
  24102. "backgroundImage",
  24103. "backgroundOrigin",
  24104. "backgroundPosition",
  24105. "backgroundPositionX",
  24106. "backgroundPositionY",
  24107. "backgroundRepeat",
  24108. "backgroundSize",
  24109. "badInput",
  24110. "badge",
  24111. "balance",
  24112. "baseArrayLayer",
  24113. "baseFrequencyX",
  24114. "baseFrequencyY",
  24115. "baseLatency",
  24116. "baseLayer",
  24117. "baseMipLevel",
  24118. "baseNode",
  24119. "baseOffset",
  24120. "basePalette",
  24121. "baseURI",
  24122. "baseVal",
  24123. "baseline-source",
  24124. "baselineShift",
  24125. "baselineSource",
  24126. "battery",
  24127. "bday",
  24128. "before",
  24129. "beginComputePass",
  24130. "beginElement",
  24131. "beginElementAt",
  24132. "beginOcclusionQuery",
  24133. "beginPath",
  24134. "beginQuery",
  24135. "beginRenderPass",
  24136. "beginTransformFeedback",
  24137. "beginningOfPassWriteIndex",
  24138. "behavior",
  24139. "behaviorCookie",
  24140. "behaviorPart",
  24141. "behaviorUrns",
  24142. "beta",
  24143. "bezierCurveTo",
  24144. "bgColor",
  24145. "bgProperties",
  24146. "bias",
  24147. "big",
  24148. "bigint64",
  24149. "biguint64",
  24150. "binaryType",
  24151. "bind",
  24152. "bindAttribLocation",
  24153. "bindBuffer",
  24154. "bindBufferBase",
  24155. "bindBufferRange",
  24156. "bindFramebuffer",
  24157. "bindGroupLayouts",
  24158. "bindRenderbuffer",
  24159. "bindSampler",
  24160. "bindTexture",
  24161. "bindTransformFeedback",
  24162. "bindVertexArray",
  24163. "binding",
  24164. "bitness",
  24165. "blend",
  24166. "blendColor",
  24167. "blendEquation",
  24168. "blendEquationSeparate",
  24169. "blendFunc",
  24170. "blendFuncSeparate",
  24171. "blink",
  24172. "blitFramebuffer",
  24173. "blob",
  24174. "block-size",
  24175. "blockDirection",
  24176. "blockSize",
  24177. "blockedURI",
  24178. "blocking",
  24179. "blockingDuration",
  24180. "blue",
  24181. "bluetooth",
  24182. "blur",
  24183. "body",
  24184. "bodyUsed",
  24185. "bold",
  24186. "bookmarks",
  24187. "booleanValue",
  24188. "border",
  24189. "border-block",
  24190. "border-block-color",
  24191. "border-block-end",
  24192. "border-block-end-color",
  24193. "border-block-end-style",
  24194. "border-block-end-width",
  24195. "border-block-start",
  24196. "border-block-start-color",
  24197. "border-block-start-style",
  24198. "border-block-start-width",
  24199. "border-block-style",
  24200. "border-block-width",
  24201. "border-bottom",
  24202. "border-bottom-color",
  24203. "border-bottom-left-radius",
  24204. "border-bottom-right-radius",
  24205. "border-bottom-style",
  24206. "border-bottom-width",
  24207. "border-collapse",
  24208. "border-color",
  24209. "border-end-end-radius",
  24210. "border-end-start-radius",
  24211. "border-image",
  24212. "border-image-outset",
  24213. "border-image-repeat",
  24214. "border-image-slice",
  24215. "border-image-source",
  24216. "border-image-width",
  24217. "border-inline",
  24218. "border-inline-color",
  24219. "border-inline-end",
  24220. "border-inline-end-color",
  24221. "border-inline-end-style",
  24222. "border-inline-end-width",
  24223. "border-inline-start",
  24224. "border-inline-start-color",
  24225. "border-inline-start-style",
  24226. "border-inline-start-width",
  24227. "border-inline-style",
  24228. "border-inline-width",
  24229. "border-left",
  24230. "border-left-color",
  24231. "border-left-style",
  24232. "border-left-width",
  24233. "border-radius",
  24234. "border-right",
  24235. "border-right-color",
  24236. "border-right-style",
  24237. "border-right-width",
  24238. "border-spacing",
  24239. "border-start-end-radius",
  24240. "border-start-start-radius",
  24241. "border-style",
  24242. "border-top",
  24243. "border-top-color",
  24244. "border-top-left-radius",
  24245. "border-top-right-radius",
  24246. "border-top-style",
  24247. "border-top-width",
  24248. "border-width",
  24249. "borderBlock",
  24250. "borderBlockColor",
  24251. "borderBlockEnd",
  24252. "borderBlockEndColor",
  24253. "borderBlockEndStyle",
  24254. "borderBlockEndWidth",
  24255. "borderBlockStart",
  24256. "borderBlockStartColor",
  24257. "borderBlockStartStyle",
  24258. "borderBlockStartWidth",
  24259. "borderBlockStyle",
  24260. "borderBlockWidth",
  24261. "borderBottom",
  24262. "borderBottomColor",
  24263. "borderBottomLeftRadius",
  24264. "borderBottomRightRadius",
  24265. "borderBottomStyle",
  24266. "borderBottomWidth",
  24267. "borderBoxSize",
  24268. "borderCollapse",
  24269. "borderColor",
  24270. "borderColorDark",
  24271. "borderColorLight",
  24272. "borderEndEndRadius",
  24273. "borderEndStartRadius",
  24274. "borderImage",
  24275. "borderImageOutset",
  24276. "borderImageRepeat",
  24277. "borderImageSlice",
  24278. "borderImageSource",
  24279. "borderImageWidth",
  24280. "borderInline",
  24281. "borderInlineColor",
  24282. "borderInlineEnd",
  24283. "borderInlineEndColor",
  24284. "borderInlineEndStyle",
  24285. "borderInlineEndWidth",
  24286. "borderInlineStart",
  24287. "borderInlineStartColor",
  24288. "borderInlineStartStyle",
  24289. "borderInlineStartWidth",
  24290. "borderInlineStyle",
  24291. "borderInlineWidth",
  24292. "borderLeft",
  24293. "borderLeftColor",
  24294. "borderLeftStyle",
  24295. "borderLeftWidth",
  24296. "borderRadius",
  24297. "borderRight",
  24298. "borderRightColor",
  24299. "borderRightStyle",
  24300. "borderRightWidth",
  24301. "borderSpacing",
  24302. "borderStartEndRadius",
  24303. "borderStartStartRadius",
  24304. "borderStyle",
  24305. "borderTop",
  24306. "borderTopColor",
  24307. "borderTopLeftRadius",
  24308. "borderTopRightRadius",
  24309. "borderTopStyle",
  24310. "borderTopWidth",
  24311. "borderWidth",
  24312. "bottom",
  24313. "bottomMargin",
  24314. "bound",
  24315. "boundElements",
  24316. "boundingClientRect",
  24317. "boundingHeight",
  24318. "boundingLeft",
  24319. "boundingRect",
  24320. "boundingTop",
  24321. "boundingWidth",
  24322. "bounds",
  24323. "boundsGeometry",
  24324. "box-decoration-break",
  24325. "box-shadow",
  24326. "box-sizing",
  24327. "boxDecorationBreak",
  24328. "boxShadow",
  24329. "boxSizing",
  24330. "brand",
  24331. "brands",
  24332. "break-after",
  24333. "break-before",
  24334. "break-inside",
  24335. "breakAfter",
  24336. "breakBefore",
  24337. "breakInside",
  24338. "broadcast",
  24339. "browser",
  24340. "browserLanguage",
  24341. "browserSettings",
  24342. "browsingData",
  24343. "browsingTopics",
  24344. "btoa",
  24345. "bubbles",
  24346. "buffer",
  24347. "bufferData",
  24348. "bufferDepth",
  24349. "bufferSize",
  24350. "bufferSubData",
  24351. "buffered",
  24352. "bufferedAmount",
  24353. "bufferedAmountLowThreshold",
  24354. "buffers",
  24355. "buildID",
  24356. "buildNumber",
  24357. "button",
  24358. "buttonID",
  24359. "buttons",
  24360. "byobRequest",
  24361. "byteLength",
  24362. "byteOffset",
  24363. "bytes",
  24364. "bytesPerRow",
  24365. "bytesWritten",
  24366. "c",
  24367. "cache",
  24368. "caches",
  24369. "call",
  24370. "caller",
  24371. "camera",
  24372. "canBeFormatted",
  24373. "canBeMounted",
  24374. "canBeShared",
  24375. "canConstructInDedicatedWorker",
  24376. "canGoBack",
  24377. "canGoForward",
  24378. "canHaveChildren",
  24379. "canHaveHTML",
  24380. "canInsertDTMF",
  24381. "canIntercept",
  24382. "canLoadAdAuctionFencedFrame",
  24383. "canLoadOpaqueURL",
  24384. "canMakePayment",
  24385. "canParse",
  24386. "canPlayType",
  24387. "canPresent",
  24388. "canShare",
  24389. "canTransition",
  24390. "canTrickleIceCandidates",
  24391. "cancel",
  24392. "cancelAndHoldAtTime",
  24393. "cancelAnimationFrame",
  24394. "cancelBubble",
  24395. "cancelIdleCallback",
  24396. "cancelScheduledValues",
  24397. "cancelVideoFrameCallback",
  24398. "cancelWatchAvailability",
  24399. "cancelable",
  24400. "candidate",
  24401. "canonicalUUID",
  24402. "canvas",
  24403. "cap",
  24404. "capabilities",
  24405. "caption",
  24406. "caption-side",
  24407. "captionSide",
  24408. "captivePortal",
  24409. "capture",
  24410. "captureEvents",
  24411. "captureStackTrace",
  24412. "captureStream",
  24413. "captureTab",
  24414. "captureVisibleTab",
  24415. "caret-color",
  24416. "caretBidiLevel",
  24417. "caretColor",
  24418. "caretPositionFromPoint",
  24419. "caretRangeFromPoint",
  24420. "cast",
  24421. "catch",
  24422. "category",
  24423. "cbrt",
  24424. "cd",
  24425. "ceil",
  24426. "cellIndex",
  24427. "cellPadding",
  24428. "cellSpacing",
  24429. "cells",
  24430. "ch",
  24431. "chOff",
  24432. "chain",
  24433. "challenge",
  24434. "changeType",
  24435. "changed",
  24436. "changedTouches",
  24437. "channel",
  24438. "channelCount",
  24439. "channelCountMode",
  24440. "channelInterpretation",
  24441. "chapterInfo",
  24442. "char",
  24443. "charAt",
  24444. "charCode",
  24445. "charCodeAt",
  24446. "charIndex",
  24447. "charLength",
  24448. "characterBounds",
  24449. "characterBoundsRangeStart",
  24450. "characterData",
  24451. "characterDataOldValue",
  24452. "characterSet",
  24453. "characteristic",
  24454. "charging",
  24455. "chargingTime",
  24456. "charset",
  24457. "check",
  24458. "checkDCE",
  24459. "checkEnclosure",
  24460. "checkFramebufferStatus",
  24461. "checkIntersection",
  24462. "checkValidity",
  24463. "checkVisibility",
  24464. "checked",
  24465. "childElementCount",
  24466. "childList",
  24467. "childNodes",
  24468. "children",
  24469. "chrome",
  24470. "ciphertext",
  24471. "cite",
  24472. "city",
  24473. "claimInterface",
  24474. "claimed",
  24475. "classList",
  24476. "className",
  24477. "classid",
  24478. "clear",
  24479. "clearAppBadge",
  24480. "clearAttributes",
  24481. "clearBuffer",
  24482. "clearBufferfi",
  24483. "clearBufferfv",
  24484. "clearBufferiv",
  24485. "clearBufferuiv",
  24486. "clearColor",
  24487. "clearData",
  24488. "clearDepth",
  24489. "clearHalt",
  24490. "clearImmediate",
  24491. "clearInterval",
  24492. "clearLiveSeekableRange",
  24493. "clearMarks",
  24494. "clearMaxGCPauseAccumulator",
  24495. "clearMeasures",
  24496. "clearOriginJoinedAdInterestGroups",
  24497. "clearParameters",
  24498. "clearRect",
  24499. "clearResourceTimings",
  24500. "clearShadow",
  24501. "clearStencil",
  24502. "clearTimeout",
  24503. "clearValue",
  24504. "clearWatch",
  24505. "click",
  24506. "clickCount",
  24507. "clientDataJSON",
  24508. "clientHeight",
  24509. "clientInformation",
  24510. "clientLeft",
  24511. "clientRect",
  24512. "clientRects",
  24513. "clientTop",
  24514. "clientWaitSync",
  24515. "clientWidth",
  24516. "clientX",
  24517. "clientY",
  24518. "clip",
  24519. "clip-path",
  24520. "clip-rule",
  24521. "clipBottom",
  24522. "clipLeft",
  24523. "clipPath",
  24524. "clipPathUnits",
  24525. "clipRight",
  24526. "clipRule",
  24527. "clipTop",
  24528. "clipboard",
  24529. "clipboardData",
  24530. "clonable",
  24531. "clone",
  24532. "cloneContents",
  24533. "cloneNode",
  24534. "cloneRange",
  24535. "close",
  24536. "closeCode",
  24537. "closePath",
  24538. "closed",
  24539. "closest",
  24540. "clz",
  24541. "clz32",
  24542. "cm",
  24543. "cmp",
  24544. "code",
  24545. "codeBase",
  24546. "codePointAt",
  24547. "codeType",
  24548. "codedHeight",
  24549. "codedRect",
  24550. "codedWidth",
  24551. "colSpan",
  24552. "collapse",
  24553. "collapseToEnd",
  24554. "collapseToStart",
  24555. "collapsed",
  24556. "collect",
  24557. "collections",
  24558. "colno",
  24559. "color",
  24560. "color-adjust",
  24561. "color-interpolation",
  24562. "color-interpolation-filters",
  24563. "color-scheme",
  24564. "colorAdjust",
  24565. "colorAttachments",
  24566. "colorDepth",
  24567. "colorFormats",
  24568. "colorInterpolation",
  24569. "colorInterpolationFilters",
  24570. "colorMask",
  24571. "colorScheme",
  24572. "colorSpace",
  24573. "colorType",
  24574. "cols",
  24575. "column-count",
  24576. "column-fill",
  24577. "column-gap",
  24578. "column-rule",
  24579. "column-rule-color",
  24580. "column-rule-style",
  24581. "column-rule-width",
  24582. "column-span",
  24583. "column-width",
  24584. "columnCount",
  24585. "columnFill",
  24586. "columnGap",
  24587. "columnNumber",
  24588. "columnRule",
  24589. "columnRuleColor",
  24590. "columnRuleStyle",
  24591. "columnRuleWidth",
  24592. "columnSpan",
  24593. "columnWidth",
  24594. "columns",
  24595. "command",
  24596. "commands",
  24597. "commit",
  24598. "commitLoadTime",
  24599. "commitPreferences",
  24600. "commitStyles",
  24601. "commonAncestorContainer",
  24602. "compact",
  24603. "compare",
  24604. "compareBoundaryPoints",
  24605. "compareDocumentPosition",
  24606. "compareEndPoints",
  24607. "compareExchange",
  24608. "compareNode",
  24609. "comparePoint",
  24610. "compatMode",
  24611. "compatible",
  24612. "compile",
  24613. "compileShader",
  24614. "compileStreaming",
  24615. "complete",
  24616. "completed",
  24617. "component",
  24618. "componentFromPoint",
  24619. "composed",
  24620. "composedPath",
  24621. "composite",
  24622. "compositionEndOffset",
  24623. "compositionStartOffset",
  24624. "compressedTexImage2D",
  24625. "compressedTexImage3D",
  24626. "compressedTexSubImage2D",
  24627. "compressedTexSubImage3D",
  24628. "compute",
  24629. "computedStyleMap",
  24630. "concat",
  24631. "conditionText",
  24632. "coneInnerAngle",
  24633. "coneOuterAngle",
  24634. "coneOuterGain",
  24635. "config",
  24636. "configurable",
  24637. "configuration",
  24638. "configurationName",
  24639. "configurationValue",
  24640. "configurations",
  24641. "configure",
  24642. "confirm",
  24643. "confirmComposition",
  24644. "confirmSiteSpecificTrackingException",
  24645. "confirmWebWideTrackingException",
  24646. "congestionControl",
  24647. "connect",
  24648. "connectEnd",
  24649. "connectNative",
  24650. "connectShark",
  24651. "connectStart",
  24652. "connected",
  24653. "connectedCallback",
  24654. "connection",
  24655. "connectionInfo",
  24656. "connectionList",
  24657. "connectionSpeed",
  24658. "connectionState",
  24659. "connections",
  24660. "console",
  24661. "consolidate",
  24662. "constants",
  24663. "constraint",
  24664. "constrictionActive",
  24665. "construct",
  24666. "constructor",
  24667. "contactID",
  24668. "contain",
  24669. "contain-intrinsic-block-size",
  24670. "contain-intrinsic-height",
  24671. "contain-intrinsic-inline-size",
  24672. "contain-intrinsic-size",
  24673. "contain-intrinsic-width",
  24674. "containIntrinsicBlockSize",
  24675. "containIntrinsicHeight",
  24676. "containIntrinsicInlineSize",
  24677. "containIntrinsicSize",
  24678. "containIntrinsicWidth",
  24679. "container",
  24680. "container-name",
  24681. "container-type",
  24682. "containerId",
  24683. "containerName",
  24684. "containerQuery",
  24685. "containerSrc",
  24686. "containerType",
  24687. "contains",
  24688. "containsNode",
  24689. "content",
  24690. "content-visibility",
  24691. "contentBoxSize",
  24692. "contentDocument",
  24693. "contentEditable",
  24694. "contentHint",
  24695. "contentOverflow",
  24696. "contentRect",
  24697. "contentScriptType",
  24698. "contentStyleType",
  24699. "contentType",
  24700. "contentVisibility",
  24701. "contentWindow",
  24702. "context",
  24703. "contextId",
  24704. "contextIds",
  24705. "contextMenu",
  24706. "contextMenus",
  24707. "contextType",
  24708. "contextTypes",
  24709. "contextmenu",
  24710. "contextualIdentities",
  24711. "continue",
  24712. "continuePrimaryKey",
  24713. "continuous",
  24714. "control",
  24715. "controlTransferIn",
  24716. "controlTransferOut",
  24717. "controller",
  24718. "controls",
  24719. "controlsList",
  24720. "convertPointFromNode",
  24721. "convertQuadFromNode",
  24722. "convertRectFromNode",
  24723. "convertToBlob",
  24724. "convertToSpecifiedUnits",
  24725. "cookie",
  24726. "cookieEnabled",
  24727. "cookieStore",
  24728. "cookies",
  24729. "coords",
  24730. "copyBufferSubData",
  24731. "copyBufferToBuffer",
  24732. "copyBufferToTexture",
  24733. "copyExternalImageToTexture",
  24734. "copyFromChannel",
  24735. "copyTexImage2D",
  24736. "copyTexSubImage2D",
  24737. "copyTexSubImage3D",
  24738. "copyTextureToBuffer",
  24739. "copyTextureToTexture",
  24740. "copyTo",
  24741. "copyToChannel",
  24742. "copyWithin",
  24743. "correspondingElement",
  24744. "correspondingUseElement",
  24745. "corruptedVideoFrames",
  24746. "cos",
  24747. "cosh",
  24748. "count",
  24749. "countReset",
  24750. "counter-increment",
  24751. "counter-reset",
  24752. "counter-set",
  24753. "counterIncrement",
  24754. "counterReset",
  24755. "counterSet",
  24756. "country",
  24757. "cpuClass",
  24758. "cpuSleepAllowed",
  24759. "cqb",
  24760. "cqh",
  24761. "cqi",
  24762. "cqmax",
  24763. "cqmin",
  24764. "cqw",
  24765. "create",
  24766. "createAnalyser",
  24767. "createAnchor",
  24768. "createAnswer",
  24769. "createAttribute",
  24770. "createAttributeNS",
  24771. "createAuctionNonce",
  24772. "createBidirectionalStream",
  24773. "createBindGroup",
  24774. "createBindGroupLayout",
  24775. "createBiquadFilter",
  24776. "createBuffer",
  24777. "createBufferSource",
  24778. "createCDATASection",
  24779. "createCSSStyleSheet",
  24780. "createCaption",
  24781. "createChannelMerger",
  24782. "createChannelSplitter",
  24783. "createCommandEncoder",
  24784. "createComment",
  24785. "createComputePipeline",
  24786. "createComputePipelineAsync",
  24787. "createConicGradient",
  24788. "createConstantSource",
  24789. "createContextualFragment",
  24790. "createControlRange",
  24791. "createConvolver",
  24792. "createDTMFSender",
  24793. "createDataChannel",
  24794. "createDelay",
  24795. "createDelayNode",
  24796. "createDocument",
  24797. "createDocumentFragment",
  24798. "createDocumentType",
  24799. "createDynamicsCompressor",
  24800. "createElement",
  24801. "createElementNS",
  24802. "createEncodedStreams",
  24803. "createEntityReference",
  24804. "createEvent",
  24805. "createEventObject",
  24806. "createExpression",
  24807. "createFramebuffer",
  24808. "createFunction",
  24809. "createGain",
  24810. "createGainNode",
  24811. "createHTML",
  24812. "createHTMLDocument",
  24813. "createIIRFilter",
  24814. "createImageBitmap",
  24815. "createImageData",
  24816. "createIndex",
  24817. "createJavaScriptNode",
  24818. "createLinearGradient",
  24819. "createMediaElementSource",
  24820. "createMediaKeys",
  24821. "createMediaStreamDestination",
  24822. "createMediaStreamSource",
  24823. "createMediaStreamTrackSource",
  24824. "createMutableFile",
  24825. "createNSResolver",
  24826. "createNodeIterator",
  24827. "createNotification",
  24828. "createObjectStore",
  24829. "createObjectURL",
  24830. "createOffer",
  24831. "createOscillator",
  24832. "createPanner",
  24833. "createPattern",
  24834. "createPeriodicWave",
  24835. "createPipelineLayout",
  24836. "createPolicy",
  24837. "createPopup",
  24838. "createProcessingInstruction",
  24839. "createProgram",
  24840. "createQuery",
  24841. "createQuerySet",
  24842. "createRadialGradient",
  24843. "createRange",
  24844. "createRangeCollection",
  24845. "createReader",
  24846. "createRenderBundleEncoder",
  24847. "createRenderPipeline",
  24848. "createRenderPipelineAsync",
  24849. "createRenderbuffer",
  24850. "createSVGAngle",
  24851. "createSVGLength",
  24852. "createSVGMatrix",
  24853. "createSVGNumber",
  24854. "createSVGPathSegArcAbs",
  24855. "createSVGPathSegArcRel",
  24856. "createSVGPathSegClosePath",
  24857. "createSVGPathSegCurvetoCubicAbs",
  24858. "createSVGPathSegCurvetoCubicRel",
  24859. "createSVGPathSegCurvetoCubicSmoothAbs",
  24860. "createSVGPathSegCurvetoCubicSmoothRel",
  24861. "createSVGPathSegCurvetoQuadraticAbs",
  24862. "createSVGPathSegCurvetoQuadraticRel",
  24863. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  24864. "createSVGPathSegCurvetoQuadraticSmoothRel",
  24865. "createSVGPathSegLinetoAbs",
  24866. "createSVGPathSegLinetoHorizontalAbs",
  24867. "createSVGPathSegLinetoHorizontalRel",
  24868. "createSVGPathSegLinetoRel",
  24869. "createSVGPathSegLinetoVerticalAbs",
  24870. "createSVGPathSegLinetoVerticalRel",
  24871. "createSVGPathSegMovetoAbs",
  24872. "createSVGPathSegMovetoRel",
  24873. "createSVGPoint",
  24874. "createSVGRect",
  24875. "createSVGTransform",
  24876. "createSVGTransformFromMatrix",
  24877. "createSampler",
  24878. "createScript",
  24879. "createScriptProcessor",
  24880. "createScriptURL",
  24881. "createSession",
  24882. "createShader",
  24883. "createShaderModule",
  24884. "createShadowRoot",
  24885. "createStereoPanner",
  24886. "createStyleSheet",
  24887. "createTBody",
  24888. "createTFoot",
  24889. "createTHead",
  24890. "createTask",
  24891. "createTextNode",
  24892. "createTextRange",
  24893. "createTexture",
  24894. "createTouch",
  24895. "createTouchList",
  24896. "createTransformFeedback",
  24897. "createTreeWalker",
  24898. "createUnidirectionalStream",
  24899. "createVertexArray",
  24900. "createView",
  24901. "createWaveShaper",
  24902. "createWorklet",
  24903. "createWritable",
  24904. "creationTime",
  24905. "credentialless",
  24906. "credentials",
  24907. "criticalCHRestart",
  24908. "cropTo",
  24909. "crossOrigin",
  24910. "crossOriginIsolated",
  24911. "crypto",
  24912. "csi",
  24913. "csp",
  24914. "cssFloat",
  24915. "cssRules",
  24916. "cssText",
  24917. "cssValueType",
  24918. "ctrlKey",
  24919. "ctrlLeft",
  24920. "cues",
  24921. "cullFace",
  24922. "cullMode",
  24923. "currentCSSZoom",
  24924. "currentDirection",
  24925. "currentEntry",
  24926. "currentLocalDescription",
  24927. "currentNode",
  24928. "currentPage",
  24929. "currentRect",
  24930. "currentRemoteDescription",
  24931. "currentScale",
  24932. "currentScreen",
  24933. "currentScript",
  24934. "currentSrc",
  24935. "currentState",
  24936. "currentStyle",
  24937. "currentTarget",
  24938. "currentTime",
  24939. "currentTranslate",
  24940. "currentView",
  24941. "cursor",
  24942. "curve",
  24943. "customElements",
  24944. "customError",
  24945. "cx",
  24946. "cy",
  24947. "d",
  24948. "data",
  24949. "dataFld",
  24950. "dataFormatAs",
  24951. "dataLoss",
  24952. "dataLossMessage",
  24953. "dataPageSize",
  24954. "dataSrc",
  24955. "dataTransfer",
  24956. "database",
  24957. "databases",
  24958. "datagrams",
  24959. "dataset",
  24960. "dateTime",
  24961. "db",
  24962. "debug",
  24963. "debuggerEnabled",
  24964. "declarativeNetRequest",
  24965. "declare",
  24966. "decode",
  24967. "decodeAudioData",
  24968. "decodeQueueSize",
  24969. "decodeURI",
  24970. "decodeURIComponent",
  24971. "decodedBodySize",
  24972. "decoding",
  24973. "decodingInfo",
  24974. "decrypt",
  24975. "default",
  24976. "defaultCharset",
  24977. "defaultChecked",
  24978. "defaultMuted",
  24979. "defaultPlaybackRate",
  24980. "defaultPolicy",
  24981. "defaultPrevented",
  24982. "defaultQueue",
  24983. "defaultRequest",
  24984. "defaultSelected",
  24985. "defaultStatus",
  24986. "defaultURL",
  24987. "defaultValue",
  24988. "defaultView",
  24989. "defaultstatus",
  24990. "defer",
  24991. "define",
  24992. "defineMagicFunction",
  24993. "defineMagicVariable",
  24994. "defineProperties",
  24995. "defineProperty",
  24996. "deg",
  24997. "delay",
  24998. "delayTime",
  24999. "delegatesFocus",
  25000. "delete",
  25001. "deleteBuffer",
  25002. "deleteCaption",
  25003. "deleteCell",
  25004. "deleteContents",
  25005. "deleteData",
  25006. "deleteDatabase",
  25007. "deleteFramebuffer",
  25008. "deleteFromDocument",
  25009. "deleteIndex",
  25010. "deleteMedium",
  25011. "deleteObjectStore",
  25012. "deleteProgram",
  25013. "deleteProperty",
  25014. "deleteQuery",
  25015. "deleteRenderbuffer",
  25016. "deleteRow",
  25017. "deleteRule",
  25018. "deleteSampler",
  25019. "deleteShader",
  25020. "deleteSync",
  25021. "deleteTFoot",
  25022. "deleteTHead",
  25023. "deleteTexture",
  25024. "deleteTransformFeedback",
  25025. "deleteVertexArray",
  25026. "deleted",
  25027. "deliverChangeRecords",
  25028. "deliveredFrames",
  25029. "deliveredFramesDuration",
  25030. "delivery",
  25031. "deliveryInfo",
  25032. "deliveryStatus",
  25033. "deliveryTimestamp",
  25034. "deliveryType",
  25035. "delta",
  25036. "deltaMode",
  25037. "deltaX",
  25038. "deltaY",
  25039. "deltaZ",
  25040. "dependentLocality",
  25041. "deprecatedReplaceInURN",
  25042. "deprecatedRunAdAuctionEnforcesKAnonymity",
  25043. "deprecatedURNToURL",
  25044. "depthBias",
  25045. "depthBiasClamp",
  25046. "depthBiasSlopeScale",
  25047. "depthClearValue",
  25048. "depthCompare",
  25049. "depthDataFormat",
  25050. "depthFailOp",
  25051. "depthFar",
  25052. "depthFunc",
  25053. "depthLoadOp",
  25054. "depthMask",
  25055. "depthNear",
  25056. "depthOrArrayLayers",
  25057. "depthRange",
  25058. "depthReadOnly",
  25059. "depthStencil",
  25060. "depthStencilAttachment",
  25061. "depthStencilFormat",
  25062. "depthStoreOp",
  25063. "depthUsage",
  25064. "depthWriteEnabled",
  25065. "deref",
  25066. "deriveBits",
  25067. "deriveKey",
  25068. "descentOverride",
  25069. "description",
  25070. "deselectAll",
  25071. "designMode",
  25072. "desiredSize",
  25073. "destination",
  25074. "destinationURL",
  25075. "destroy",
  25076. "detach",
  25077. "detachEvent",
  25078. "detachShader",
  25079. "detached",
  25080. "detail",
  25081. "details",
  25082. "detect",
  25083. "detectLanguage",
  25084. "detune",
  25085. "device",
  25086. "deviceClass",
  25087. "deviceId",
  25088. "deviceMemory",
  25089. "devicePixelContentBoxSize",
  25090. "devicePixelRatio",
  25091. "deviceProtocol",
  25092. "deviceSubclass",
  25093. "deviceVersionMajor",
  25094. "deviceVersionMinor",
  25095. "deviceVersionSubminor",
  25096. "deviceXDPI",
  25097. "deviceYDPI",
  25098. "devtools",
  25099. "devtools_panels",
  25100. "didTimeout",
  25101. "difference",
  25102. "diffuseConstant",
  25103. "digest",
  25104. "dimension",
  25105. "dimensions",
  25106. "dir",
  25107. "dirName",
  25108. "direction",
  25109. "dirxml",
  25110. "disable",
  25111. "disablePictureInPicture",
  25112. "disableRemotePlayback",
  25113. "disableVertexAttribArray",
  25114. "disabled",
  25115. "discard",
  25116. "discardedFrames",
  25117. "dischargingTime",
  25118. "disconnect",
  25119. "disconnectShark",
  25120. "disconnectedCallback",
  25121. "dispatchEvent",
  25122. "dispatchWorkgroups",
  25123. "dispatchWorkgroupsIndirect",
  25124. "display",
  25125. "displayHeight",
  25126. "displayId",
  25127. "displayName",
  25128. "displayWidth",
  25129. "dispose",
  25130. "disposition",
  25131. "distanceModel",
  25132. "div",
  25133. "divisor",
  25134. "djsapi",
  25135. "djsproxy",
  25136. "dns",
  25137. "doImport",
  25138. "doNotTrack",
  25139. "doScroll",
  25140. "doctype",
  25141. "document",
  25142. "documentElement",
  25143. "documentId",
  25144. "documentIds",
  25145. "documentLifecycle",
  25146. "documentMode",
  25147. "documentOrigin",
  25148. "documentOrigins",
  25149. "documentPictureInPicture",
  25150. "documentURI",
  25151. "documentUrl",
  25152. "documentUrls",
  25153. "dolphin",
  25154. "dolphinGameCenter",
  25155. "dolphininfo",
  25156. "dolphinmeta",
  25157. "dom",
  25158. "domComplete",
  25159. "domContentLoadedEventEnd",
  25160. "domContentLoadedEventStart",
  25161. "domInteractive",
  25162. "domLoading",
  25163. "domOverlayState",
  25164. "domain",
  25165. "domainLookupEnd",
  25166. "domainLookupStart",
  25167. "dominant-baseline",
  25168. "dominantBaseline",
  25169. "done",
  25170. "dopplerFactor",
  25171. "dotAll",
  25172. "downDegrees",
  25173. "downlink",
  25174. "download",
  25175. "downloadRequest",
  25176. "downloadTotal",
  25177. "downloaded",
  25178. "downloads",
  25179. "dpcm",
  25180. "dpi",
  25181. "dppx",
  25182. "dragDrop",
  25183. "draggable",
  25184. "draw",
  25185. "drawArrays",
  25186. "drawArraysInstanced",
  25187. "drawArraysInstancedANGLE",
  25188. "drawBuffers",
  25189. "drawCustomFocusRing",
  25190. "drawElements",
  25191. "drawElementsInstanced",
  25192. "drawElementsInstancedANGLE",
  25193. "drawFocusIfNeeded",
  25194. "drawImage",
  25195. "drawImageFromRect",
  25196. "drawIndexed",
  25197. "drawIndexedIndirect",
  25198. "drawIndirect",
  25199. "drawRangeElements",
  25200. "drawSystemFocusRing",
  25201. "drawingBufferColorSpace",
  25202. "drawingBufferFormat",
  25203. "drawingBufferHeight",
  25204. "drawingBufferStorage",
  25205. "drawingBufferWidth",
  25206. "drop",
  25207. "dropEffect",
  25208. "droppedVideoFrames",
  25209. "dropzone",
  25210. "dstFactor",
  25211. "dtmf",
  25212. "dump",
  25213. "dumpProfile",
  25214. "duplex",
  25215. "duplicate",
  25216. "durability",
  25217. "duration",
  25218. "dvb",
  25219. "dvh",
  25220. "dvi",
  25221. "dvmax",
  25222. "dvmin",
  25223. "dvname",
  25224. "dvnum",
  25225. "dvw",
  25226. "dx",
  25227. "dy",
  25228. "dynamicId",
  25229. "dynsrc",
  25230. "e",
  25231. "edgeMode",
  25232. "editContext",
  25233. "effect",
  25234. "effectAllowed",
  25235. "effectiveDirective",
  25236. "effectiveType",
  25237. "effects",
  25238. "elapsedTime",
  25239. "element",
  25240. "elementFromPoint",
  25241. "elementTiming",
  25242. "elements",
  25243. "elementsFromPoint",
  25244. "elevation",
  25245. "ellipse",
  25246. "em",
  25247. "emHeightAscent",
  25248. "emHeightDescent",
  25249. "email",
  25250. "embeds",
  25251. "emit",
  25252. "emma",
  25253. "empty",
  25254. "empty-cells",
  25255. "emptyCells",
  25256. "emptyHTML",
  25257. "emptyScript",
  25258. "emulatedPosition",
  25259. "enable",
  25260. "enableBackground",
  25261. "enableDelegations",
  25262. "enableStyleSheetsForSet",
  25263. "enableVertexAttribArray",
  25264. "enabled",
  25265. "enabledFeatures",
  25266. "enabledPlugin",
  25267. "encode",
  25268. "encodeInto",
  25269. "encodeQueueSize",
  25270. "encodeURI",
  25271. "encodeURIComponent",
  25272. "encodedBodySize",
  25273. "encoding",
  25274. "encodingInfo",
  25275. "encrypt",
  25276. "enctype",
  25277. "end",
  25278. "endContainer",
  25279. "endElement",
  25280. "endElementAt",
  25281. "endOcclusionQuery",
  25282. "endOfPassWriteIndex",
  25283. "endOfStream",
  25284. "endOffset",
  25285. "endQuery",
  25286. "endTime",
  25287. "endTransformFeedback",
  25288. "ended",
  25289. "endpoint",
  25290. "endpointNumber",
  25291. "endpoints",
  25292. "endsWith",
  25293. "enqueue",
  25294. "enterKeyHint",
  25295. "entities",
  25296. "entries",
  25297. "entry",
  25298. "entryPoint",
  25299. "entryType",
  25300. "enumerable",
  25301. "enumerate",
  25302. "enumerateDevices",
  25303. "enumerateEditable",
  25304. "environmentBlendMode",
  25305. "equals",
  25306. "error",
  25307. "errorCode",
  25308. "errorDetail",
  25309. "errorText",
  25310. "escape",
  25311. "estimate",
  25312. "eval",
  25313. "evaluate",
  25314. "event",
  25315. "eventCounts",
  25316. "eventPhase",
  25317. "events",
  25318. "every",
  25319. "ex",
  25320. "exception",
  25321. "exchange",
  25322. "exec",
  25323. "execCommand",
  25324. "execCommandShowHelp",
  25325. "execScript",
  25326. "executeBundles",
  25327. "executionStart",
  25328. "exitFullscreen",
  25329. "exitPictureInPicture",
  25330. "exitPointerLock",
  25331. "exitPresent",
  25332. "exp",
  25333. "expand",
  25334. "expandEntityReferences",
  25335. "expando",
  25336. "expansion",
  25337. "expectedImprovement",
  25338. "experiments",
  25339. "expiration",
  25340. "expirationTime",
  25341. "expires",
  25342. "expiryDate",
  25343. "explicitOriginalTarget",
  25344. "expm1",
  25345. "exponent",
  25346. "exponentialRampToValueAtTime",
  25347. "exportKey",
  25348. "exports",
  25349. "extend",
  25350. "extension",
  25351. "extensionTypes",
  25352. "extensions",
  25353. "extentNode",
  25354. "extentOffset",
  25355. "external",
  25356. "externalResourcesRequired",
  25357. "externalTexture",
  25358. "extractContents",
  25359. "extractable",
  25360. "eye",
  25361. "f",
  25362. "f16round",
  25363. "face",
  25364. "factoryReset",
  25365. "failOp",
  25366. "failureReason",
  25367. "fallback",
  25368. "family",
  25369. "familyName",
  25370. "farthestViewportElement",
  25371. "fastSeek",
  25372. "fatal",
  25373. "featureId",
  25374. "featurePolicy",
  25375. "featureSettings",
  25376. "features",
  25377. "fence",
  25378. "fenceSync",
  25379. "fetch",
  25380. "fetchPriority",
  25381. "fetchStart",
  25382. "fftSize",
  25383. "fgColor",
  25384. "fieldOfView",
  25385. "file",
  25386. "fileCreatedDate",
  25387. "fileHandle",
  25388. "fileModifiedDate",
  25389. "fileName",
  25390. "fileSize",
  25391. "fileUpdatedDate",
  25392. "filename",
  25393. "files",
  25394. "filesystem",
  25395. "fill",
  25396. "fill-opacity",
  25397. "fill-rule",
  25398. "fillJointRadii",
  25399. "fillLightMode",
  25400. "fillOpacity",
  25401. "fillPoses",
  25402. "fillRect",
  25403. "fillRule",
  25404. "fillStyle",
  25405. "fillText",
  25406. "filter",
  25407. "filterResX",
  25408. "filterResY",
  25409. "filterUnits",
  25410. "filters",
  25411. "finally",
  25412. "find",
  25413. "findIndex",
  25414. "findLast",
  25415. "findLastIndex",
  25416. "findRule",
  25417. "findText",
  25418. "finish",
  25419. "finishDocumentLoadTime",
  25420. "finishLoadTime",
  25421. "finished",
  25422. "fireEvent",
  25423. "firesTouchEvents",
  25424. "firstChild",
  25425. "firstElementChild",
  25426. "firstInterimResponseStart",
  25427. "firstPage",
  25428. "firstPaintAfterLoadTime",
  25429. "firstPaintTime",
  25430. "firstUIEventTimestamp",
  25431. "fixed",
  25432. "flags",
  25433. "flat",
  25434. "flatMap",
  25435. "flex",
  25436. "flex-basis",
  25437. "flex-direction",
  25438. "flex-flow",
  25439. "flex-grow",
  25440. "flex-shrink",
  25441. "flex-wrap",
  25442. "flexBasis",
  25443. "flexDirection",
  25444. "flexFlow",
  25445. "flexGrow",
  25446. "flexShrink",
  25447. "flexWrap",
  25448. "flipX",
  25449. "flipY",
  25450. "float",
  25451. "float32",
  25452. "float64",
  25453. "flood-color",
  25454. "flood-opacity",
  25455. "floodColor",
  25456. "floodOpacity",
  25457. "floor",
  25458. "flush",
  25459. "focus",
  25460. "focusNode",
  25461. "focusOffset",
  25462. "font",
  25463. "font-family",
  25464. "font-feature-settings",
  25465. "font-kerning",
  25466. "font-language-override",
  25467. "font-optical-sizing",
  25468. "font-palette",
  25469. "font-size",
  25470. "font-size-adjust",
  25471. "font-stretch",
  25472. "font-style",
  25473. "font-synthesis",
  25474. "font-synthesis-position",
  25475. "font-synthesis-small-caps",
  25476. "font-synthesis-style",
  25477. "font-synthesis-weight",
  25478. "font-variant",
  25479. "font-variant-alternates",
  25480. "font-variant-caps",
  25481. "font-variant-east-asian",
  25482. "font-variant-ligatures",
  25483. "font-variant-numeric",
  25484. "font-variant-position",
  25485. "font-variation-settings",
  25486. "font-weight",
  25487. "fontBoundingBoxAscent",
  25488. "fontBoundingBoxDescent",
  25489. "fontFamily",
  25490. "fontFeatureSettings",
  25491. "fontKerning",
  25492. "fontLanguageOverride",
  25493. "fontOpticalSizing",
  25494. "fontPalette",
  25495. "fontSize",
  25496. "fontSizeAdjust",
  25497. "fontSmoothingEnabled",
  25498. "fontStretch",
  25499. "fontStyle",
  25500. "fontSynthesis",
  25501. "fontSynthesisPosition",
  25502. "fontSynthesisSmallCaps",
  25503. "fontSynthesisStyle",
  25504. "fontSynthesisWeight",
  25505. "fontVariant",
  25506. "fontVariantAlternates",
  25507. "fontVariantCaps",
  25508. "fontVariantEastAsian",
  25509. "fontVariantLigatures",
  25510. "fontVariantNumeric",
  25511. "fontVariantPosition",
  25512. "fontVariationSettings",
  25513. "fontWeight",
  25514. "fontcolor",
  25515. "fontfaces",
  25516. "fonts",
  25517. "fontsize",
  25518. "for",
  25519. "forEach",
  25520. "force",
  25521. "forceFallbackAdapter",
  25522. "forceRedraw",
  25523. "forced-color-adjust",
  25524. "forcedColorAdjust",
  25525. "forcedStyleAndLayoutDuration",
  25526. "forget",
  25527. "form",
  25528. "formAction",
  25529. "formData",
  25530. "formEnctype",
  25531. "formMethod",
  25532. "formNoValidate",
  25533. "formTarget",
  25534. "format",
  25535. "formatToParts",
  25536. "forms",
  25537. "forward",
  25538. "forwardX",
  25539. "forwardY",
  25540. "forwardZ",
  25541. "foundation",
  25542. "fr",
  25543. "fragment",
  25544. "fragmentDirective",
  25545. "frame",
  25546. "frameBorder",
  25547. "frameCount",
  25548. "frameElement",
  25549. "frameId",
  25550. "frameIds",
  25551. "frameSpacing",
  25552. "framebuffer",
  25553. "framebufferHeight",
  25554. "framebufferRenderbuffer",
  25555. "framebufferTexture2D",
  25556. "framebufferTextureLayer",
  25557. "framebufferWidth",
  25558. "frames",
  25559. "freeSpace",
  25560. "freeze",
  25561. "frequency",
  25562. "frequencyBinCount",
  25563. "from",
  25564. "fromAsync",
  25565. "fromBase64",
  25566. "fromCharCode",
  25567. "fromCodePoint",
  25568. "fromElement",
  25569. "fromEntries",
  25570. "fromFloat32Array",
  25571. "fromFloat64Array",
  25572. "fromHex",
  25573. "fromMatrix",
  25574. "fromPoint",
  25575. "fromQuad",
  25576. "fromRect",
  25577. "frontFace",
  25578. "fround",
  25579. "fullName",
  25580. "fullPath",
  25581. "fullRange",
  25582. "fullScreen",
  25583. "fullVersionList",
  25584. "fullscreen",
  25585. "fullscreenElement",
  25586. "fullscreenEnabled",
  25587. "fx",
  25588. "fy",
  25589. "g",
  25590. "gain",
  25591. "gamepad",
  25592. "gamma",
  25593. "gap",
  25594. "gatheringState",
  25595. "gatt",
  25596. "geckoProfiler",
  25597. "genderIdentity",
  25598. "generateCertificate",
  25599. "generateKey",
  25600. "generateMipmap",
  25601. "generateRequest",
  25602. "geolocation",
  25603. "gestureObject",
  25604. "get",
  25605. "getAcceptLanguages",
  25606. "getActiveAttrib",
  25607. "getActiveUniform",
  25608. "getActiveUniformBlockName",
  25609. "getActiveUniformBlockParameter",
  25610. "getActiveUniforms",
  25611. "getAdjacentText",
  25612. "getAll",
  25613. "getAllKeys",
  25614. "getAllResponseHeaders",
  25615. "getAllowlistForFeature",
  25616. "getAnimations",
  25617. "getAsFile",
  25618. "getAsFileSystemHandle",
  25619. "getAsString",
  25620. "getAttachedShaders",
  25621. "getAttribLocation",
  25622. "getAttribute",
  25623. "getAttributeNS",
  25624. "getAttributeNames",
  25625. "getAttributeNode",
  25626. "getAttributeNodeNS",
  25627. "getAttributeType",
  25628. "getAudioTracks",
  25629. "getAuthenticatorData",
  25630. "getAutoplayPolicy",
  25631. "getAvailability",
  25632. "getBBox",
  25633. "getBackgroundPage",
  25634. "getBadgeBackgroundColor",
  25635. "getBadgeText",
  25636. "getBadgeTextColor",
  25637. "getBattery",
  25638. "getBigInt64",
  25639. "getBigUint64",
  25640. "getBindGroupLayout",
  25641. "getBlob",
  25642. "getBookmark",
  25643. "getBoundingClientRect",
  25644. "getBounds",
  25645. "getBoxQuads",
  25646. "getBrowserInfo",
  25647. "getBufferParameter",
  25648. "getBufferSubData",
  25649. "getByteFrequencyData",
  25650. "getByteTimeDomainData",
  25651. "getCSSCanvasContext",
  25652. "getCTM",
  25653. "getCameraImage",
  25654. "getCandidateWindowClientRect",
  25655. "getCanonicalLocales",
  25656. "getCapabilities",
  25657. "getCaptureHandle",
  25658. "getChannelData",
  25659. "getCharNumAtPosition",
  25660. "getCharacteristic",
  25661. "getCharacteristics",
  25662. "getClientExtensionResults",
  25663. "getClientRect",
  25664. "getClientRects",
  25665. "getCoalescedEvents",
  25666. "getCompilationInfo",
  25667. "getCompositionAlternatives",
  25668. "getComputedStyle",
  25669. "getComputedTextLength",
  25670. "getComputedTiming",
  25671. "getConfiguration",
  25672. "getConstraints",
  25673. "getContext",
  25674. "getContextAttributes",
  25675. "getContexts",
  25676. "getContributingSources",
  25677. "getCounterValue",
  25678. "getCueAsHTML",
  25679. "getCueById",
  25680. "getCurrent",
  25681. "getCurrentPosition",
  25682. "getCurrentTexture",
  25683. "getCurrentTime",
  25684. "getData",
  25685. "getDatabaseNames",
  25686. "getDate",
  25687. "getDay",
  25688. "getDefaultComputedStyle",
  25689. "getDepthInMeters",
  25690. "getDepthInformation",
  25691. "getDescriptor",
  25692. "getDescriptors",
  25693. "getDestinationInsertionPoints",
  25694. "getDevices",
  25695. "getDirectory",
  25696. "getDirectoryHandle",
  25697. "getDisplayMedia",
  25698. "getDistributedNodes",
  25699. "getEditable",
  25700. "getElementById",
  25701. "getElementsByClassName",
  25702. "getElementsByName",
  25703. "getElementsByTagName",
  25704. "getElementsByTagNameNS",
  25705. "getEnclosureList",
  25706. "getEndPositionOfChar",
  25707. "getEntries",
  25708. "getEntriesByName",
  25709. "getEntriesByType",
  25710. "getError",
  25711. "getExtension",
  25712. "getExtentOfChar",
  25713. "getEyeParameters",
  25714. "getFeature",
  25715. "getFiberRoots",
  25716. "getFile",
  25717. "getFileHandle",
  25718. "getFiles",
  25719. "getFilesAndDirectories",
  25720. "getFingerprints",
  25721. "getFloat16",
  25722. "getFloat32",
  25723. "getFloat64",
  25724. "getFloatFrequencyData",
  25725. "getFloatTimeDomainData",
  25726. "getFloatValue",
  25727. "getFragDataLocation",
  25728. "getFrameData",
  25729. "getFrameId",
  25730. "getFramebufferAttachmentParameter",
  25731. "getFrequencyResponse",
  25732. "getFullYear",
  25733. "getGamepads",
  25734. "getHTML",
  25735. "getHeaderExtensionsToNegotiate",
  25736. "getHighEntropyValues",
  25737. "getHitTestResults",
  25738. "getHitTestResultsForTransientInput",
  25739. "getHours",
  25740. "getIdentityAssertion",
  25741. "getIds",
  25742. "getImageData",
  25743. "getIndexedParameter",
  25744. "getInfo",
  25745. "getInnerHTML",
  25746. "getInstalledRelatedApps",
  25747. "getInt16",
  25748. "getInt32",
  25749. "getInt8",
  25750. "getInterestGroupAdAuctionData",
  25751. "getInternalModuleRanges",
  25752. "getInternalformatParameter",
  25753. "getIntersectionList",
  25754. "getItem",
  25755. "getItems",
  25756. "getJointPose",
  25757. "getKey",
  25758. "getKeyframes",
  25759. "getLastFocused",
  25760. "getLayers",
  25761. "getLayoutMap",
  25762. "getLightEstimate",
  25763. "getLineDash",
  25764. "getLocalCandidates",
  25765. "getLocalParameters",
  25766. "getLocalStreams",
  25767. "getManagedConfiguration",
  25768. "getManifest",
  25769. "getMappedRange",
  25770. "getMarks",
  25771. "getMatchedCSSRules",
  25772. "getMaxGCPauseSinceClear",
  25773. "getMeasures",
  25774. "getMessage",
  25775. "getMetadata",
  25776. "getMilliseconds",
  25777. "getMinutes",
  25778. "getModifierState",
  25779. "getMonth",
  25780. "getName",
  25781. "getNamedItem",
  25782. "getNamedItemNS",
  25783. "getNativeFramebufferScaleFactor",
  25784. "getNegotiatedHeaderExtensions",
  25785. "getNestedConfigs",
  25786. "getNotifications",
  25787. "getNotifier",
  25788. "getNumberOfChars",
  25789. "getOffsetReferenceSpace",
  25790. "getOutputTimestamp",
  25791. "getOverrideHistoryNavigationMode",
  25792. "getOverrideStyle",
  25793. "getOwnPropertyDescriptor",
  25794. "getOwnPropertyDescriptors",
  25795. "getOwnPropertyNames",
  25796. "getOwnPropertySymbols",
  25797. "getPackageDirectoryEntry",
  25798. "getParameter",
  25799. "getParameters",
  25800. "getParent",
  25801. "getPathSegAtLength",
  25802. "getPermissionWarningsByManifest",
  25803. "getPhotoCapabilities",
  25804. "getPhotoSettings",
  25805. "getPlatformInfo",
  25806. "getPointAtLength",
  25807. "getPopup",
  25808. "getPorts",
  25809. "getPose",
  25810. "getPredictedEvents",
  25811. "getPreference",
  25812. "getPreferenceDefault",
  25813. "getPreferredCanvasFormat",
  25814. "getPresentationAttribute",
  25815. "getPreventDefault",
  25816. "getPrimaryService",
  25817. "getPrimaryServices",
  25818. "getProgramInfoLog",
  25819. "getProgramParameter",
  25820. "getPropertyCSSValue",
  25821. "getPropertyPriority",
  25822. "getPropertyShorthand",
  25823. "getPropertyType",
  25824. "getPropertyValue",
  25825. "getPrototypeOf",
  25826. "getPublicKey",
  25827. "getPublicKeyAlgorithm",
  25828. "getQuery",
  25829. "getQueryParameter",
  25830. "getRGBColorValue",
  25831. "getRandomValues",
  25832. "getRangeAt",
  25833. "getReader",
  25834. "getReceivers",
  25835. "getRectValue",
  25836. "getReflectionCubeMap",
  25837. "getRegistration",
  25838. "getRegistrations",
  25839. "getRemoteCandidates",
  25840. "getRemoteCertificates",
  25841. "getRemoteParameters",
  25842. "getRemoteStreams",
  25843. "getRenderbufferParameter",
  25844. "getResponseHeader",
  25845. "getRoot",
  25846. "getRootNode",
  25847. "getRotationOfChar",
  25848. "getSVGDocument",
  25849. "getSamplerParameter",
  25850. "getScreenCTM",
  25851. "getScreenDetails",
  25852. "getSeconds",
  25853. "getSelectedCandidatePair",
  25854. "getSelection",
  25855. "getSelf",
  25856. "getSenders",
  25857. "getService",
  25858. "getSetCookie",
  25859. "getSettings",
  25860. "getShaderInfoLog",
  25861. "getShaderParameter",
  25862. "getShaderPrecisionFormat",
  25863. "getShaderSource",
  25864. "getSignals",
  25865. "getSimpleDuration",
  25866. "getSiteIcons",
  25867. "getSources",
  25868. "getSpeculativeParserUrls",
  25869. "getStartPositionOfChar",
  25870. "getStartTime",
  25871. "getState",
  25872. "getStats",
  25873. "getStatusForPolicy",
  25874. "getStorageUpdates",
  25875. "getStreamById",
  25876. "getStringValue",
  25877. "getSubStringLength",
  25878. "getSubscription",
  25879. "getSubscriptions",
  25880. "getSupportedConstraints",
  25881. "getSupportedExtensions",
  25882. "getSupportedFormats",
  25883. "getSyncParameter",
  25884. "getSynchronizationSources",
  25885. "getTags",
  25886. "getTargetRanges",
  25887. "getTexParameter",
  25888. "getTextFormats",
  25889. "getTime",
  25890. "getTimezoneOffset",
  25891. "getTiming",
  25892. "getTitle",
  25893. "getTitlebarAreaRect",
  25894. "getTotalLength",
  25895. "getTrackById",
  25896. "getTracks",
  25897. "getTransceivers",
  25898. "getTransform",
  25899. "getTransformFeedbackVarying",
  25900. "getTransformToElement",
  25901. "getTransports",
  25902. "getType",
  25903. "getTypeMapping",
  25904. "getUILanguage",
  25905. "getURL",
  25906. "getUTCDate",
  25907. "getUTCDay",
  25908. "getUTCFullYear",
  25909. "getUTCHours",
  25910. "getUTCMilliseconds",
  25911. "getUTCMinutes",
  25912. "getUTCMonth",
  25913. "getUTCSeconds",
  25914. "getUint16",
  25915. "getUint32",
  25916. "getUint8",
  25917. "getUniform",
  25918. "getUniformBlockIndex",
  25919. "getUniformIndices",
  25920. "getUniformLocation",
  25921. "getUserInfo",
  25922. "getUserMedia",
  25923. "getUserSettings",
  25924. "getVRDisplays",
  25925. "getValues",
  25926. "getVarDate",
  25927. "getVariableValue",
  25928. "getVertexAttrib",
  25929. "getVertexAttribOffset",
  25930. "getVideoPlaybackQuality",
  25931. "getVideoTracks",
  25932. "getViewerPose",
  25933. "getViewport",
  25934. "getViews",
  25935. "getVoices",
  25936. "getWakeLockState",
  25937. "getWriter",
  25938. "getYear",
  25939. "getZoom",
  25940. "getZoomSettings",
  25941. "givenName",
  25942. "global",
  25943. "globalAlpha",
  25944. "globalCompositeOperation",
  25945. "globalPrivacyControl",
  25946. "globalThis",
  25947. "glyphOrientationHorizontal",
  25948. "glyphOrientationVertical",
  25949. "glyphRef",
  25950. "go",
  25951. "goBack",
  25952. "goForward",
  25953. "gpu",
  25954. "grabFrame",
  25955. "grad",
  25956. "gradientTransform",
  25957. "gradientUnits",
  25958. "grammars",
  25959. "green",
  25960. "grid",
  25961. "grid-area",
  25962. "grid-auto-columns",
  25963. "grid-auto-flow",
  25964. "grid-auto-rows",
  25965. "grid-column",
  25966. "grid-column-end",
  25967. "grid-column-gap",
  25968. "grid-column-start",
  25969. "grid-gap",
  25970. "grid-row",
  25971. "grid-row-end",
  25972. "grid-row-gap",
  25973. "grid-row-start",
  25974. "grid-template",
  25975. "grid-template-areas",
  25976. "grid-template-columns",
  25977. "grid-template-rows",
  25978. "gridArea",
  25979. "gridAutoColumns",
  25980. "gridAutoFlow",
  25981. "gridAutoRows",
  25982. "gridColumn",
  25983. "gridColumnEnd",
  25984. "gridColumnGap",
  25985. "gridColumnStart",
  25986. "gridGap",
  25987. "gridRow",
  25988. "gridRowEnd",
  25989. "gridRowGap",
  25990. "gridRowStart",
  25991. "gridTemplate",
  25992. "gridTemplateAreas",
  25993. "gridTemplateColumns",
  25994. "gridTemplateRows",
  25995. "gripSpace",
  25996. "group",
  25997. "groupBy",
  25998. "groupCollapsed",
  25999. "groupEnd",
  26000. "groupId",
  26001. "groups",
  26002. "grow",
  26003. "growable",
  26004. "guestProcessId",
  26005. "guestRenderFrameRoutingId",
  26006. "hadRecentInput",
  26007. "hand",
  26008. "handedness",
  26009. "hangingBaseline",
  26010. "hapticActuators",
  26011. "hardwareConcurrency",
  26012. "has",
  26013. "hasAttribute",
  26014. "hasAttributeNS",
  26015. "hasAttributes",
  26016. "hasBeenActive",
  26017. "hasChildNodes",
  26018. "hasComposition",
  26019. "hasDynamicOffset",
  26020. "hasEnrolledInstrument",
  26021. "hasExtension",
  26022. "hasExternalDisplay",
  26023. "hasFeature",
  26024. "hasFocus",
  26025. "hasIndices",
  26026. "hasInstance",
  26027. "hasLayout",
  26028. "hasOrientation",
  26029. "hasOwn",
  26030. "hasOwnProperty",
  26031. "hasPointerCapture",
  26032. "hasPosition",
  26033. "hasPrivateToken",
  26034. "hasReading",
  26035. "hasRedemptionRecord",
  26036. "hasRegExpGroups",
  26037. "hasStorageAccess",
  26038. "hasUAVisualTransition",
  26039. "hasUnpartitionedCookieAccess",
  26040. "hash",
  26041. "hashChange",
  26042. "head",
  26043. "headers",
  26044. "heading",
  26045. "height",
  26046. "hid",
  26047. "hidden",
  26048. "hide",
  26049. "hideFocus",
  26050. "hidePopover",
  26051. "high",
  26052. "highWaterMark",
  26053. "highlight",
  26054. "highlights",
  26055. "hint",
  26056. "hints",
  26057. "history",
  26058. "honorificPrefix",
  26059. "honorificSuffix",
  26060. "horizontalOverflow",
  26061. "host",
  26062. "hostCandidate",
  26063. "hostname",
  26064. "href",
  26065. "hrefTranslate",
  26066. "hreflang",
  26067. "hspace",
  26068. "html5TagCheckInerface",
  26069. "htmlFor",
  26070. "htmlText",
  26071. "httpEquiv",
  26072. "httpRequestStatusCode",
  26073. "hwTimestamp",
  26074. "hyphenate-character",
  26075. "hyphenateCharacter",
  26076. "hyphens",
  26077. "hypot",
  26078. "i18n",
  26079. "ic",
  26080. "iccId",
  26081. "iceConnectionState",
  26082. "iceGatheringState",
  26083. "iceTransport",
  26084. "icon",
  26085. "iconURL",
  26086. "id",
  26087. "identifier",
  26088. "identity",
  26089. "ideographicBaseline",
  26090. "idle",
  26091. "idpLoginUrl",
  26092. "ignoreBOM",
  26093. "ignoreCase",
  26094. "ignoreDepthValues",
  26095. "image",
  26096. "image-orientation",
  26097. "image-rendering",
  26098. "imageHeight",
  26099. "imageOrientation",
  26100. "imageRendering",
  26101. "imageSizes",
  26102. "imageSmoothingEnabled",
  26103. "imageSmoothingQuality",
  26104. "imageSrcset",
  26105. "imageWidth",
  26106. "images",
  26107. "ime-mode",
  26108. "imeMode",
  26109. "implementation",
  26110. "importExternalTexture",
  26111. "importKey",
  26112. "importNode",
  26113. "importStylesheet",
  26114. "imports",
  26115. "impp",
  26116. "imul",
  26117. "in",
  26118. "in1",
  26119. "in2",
  26120. "inBandMetadataTrackDispatchType",
  26121. "inIncognitoContext",
  26122. "inRange",
  26123. "includes",
  26124. "incognito",
  26125. "incomingBidirectionalStreams",
  26126. "incomingHighWaterMark",
  26127. "incomingMaxAge",
  26128. "incomingUnidirectionalStreams",
  26129. "incremental",
  26130. "indeterminate",
  26131. "index",
  26132. "indexNames",
  26133. "indexOf",
  26134. "indexedDB",
  26135. "indicate",
  26136. "indices",
  26137. "inert",
  26138. "inertiaDestinationX",
  26139. "inertiaDestinationY",
  26140. "info",
  26141. "inherits",
  26142. "init",
  26143. "initAnimationEvent",
  26144. "initBeforeLoadEvent",
  26145. "initClipboardEvent",
  26146. "initCloseEvent",
  26147. "initCommandEvent",
  26148. "initCompositionEvent",
  26149. "initCustomEvent",
  26150. "initData",
  26151. "initDataType",
  26152. "initDeviceMotionEvent",
  26153. "initDeviceOrientationEvent",
  26154. "initDragEvent",
  26155. "initErrorEvent",
  26156. "initEvent",
  26157. "initFocusEvent",
  26158. "initGestureEvent",
  26159. "initHashChangeEvent",
  26160. "initKeyEvent",
  26161. "initKeyboardEvent",
  26162. "initMSManipulationEvent",
  26163. "initMessageEvent",
  26164. "initMouseEvent",
  26165. "initMouseScrollEvent",
  26166. "initMouseWheelEvent",
  26167. "initMutationEvent",
  26168. "initNSMouseEvent",
  26169. "initOverflowEvent",
  26170. "initPageEvent",
  26171. "initPageTransitionEvent",
  26172. "initPointerEvent",
  26173. "initPopStateEvent",
  26174. "initProgressEvent",
  26175. "initScrollAreaEvent",
  26176. "initSimpleGestureEvent",
  26177. "initStorageEvent",
  26178. "initTextEvent",
  26179. "initTimeEvent",
  26180. "initTouchEvent",
  26181. "initTransitionEvent",
  26182. "initUIEvent",
  26183. "initWebKitAnimationEvent",
  26184. "initWebKitTransitionEvent",
  26185. "initWebKitWheelEvent",
  26186. "initWheelEvent",
  26187. "initialTime",
  26188. "initialValue",
  26189. "initialize",
  26190. "initiatorType",
  26191. "inject",
  26192. "ink",
  26193. "inline-size",
  26194. "inlineSize",
  26195. "inlineVerticalFieldOfView",
  26196. "inner",
  26197. "innerHTML",
  26198. "innerHeight",
  26199. "innerText",
  26200. "innerWidth",
  26201. "input",
  26202. "inputBuffer",
  26203. "inputEncoding",
  26204. "inputMethod",
  26205. "inputMode",
  26206. "inputSource",
  26207. "inputSources",
  26208. "inputType",
  26209. "inputs",
  26210. "insertAdjacentElement",
  26211. "insertAdjacentHTML",
  26212. "insertAdjacentText",
  26213. "insertBefore",
  26214. "insertCell",
  26215. "insertDTMF",
  26216. "insertData",
  26217. "insertDebugMarker",
  26218. "insertItemBefore",
  26219. "insertNode",
  26220. "insertRow",
  26221. "insertRule",
  26222. "inset",
  26223. "inset-block",
  26224. "inset-block-end",
  26225. "inset-block-start",
  26226. "inset-inline",
  26227. "inset-inline-end",
  26228. "inset-inline-start",
  26229. "insetBlock",
  26230. "insetBlockEnd",
  26231. "insetBlockStart",
  26232. "insetInline",
  26233. "insetInlineEnd",
  26234. "insetInlineStart",
  26235. "install",
  26236. "installing",
  26237. "instanceRoot",
  26238. "instantiate",
  26239. "instantiateStreaming",
  26240. "instruments",
  26241. "int16",
  26242. "int32",
  26243. "int8",
  26244. "integrity",
  26245. "interactionId",
  26246. "interactionMode",
  26247. "intercept",
  26248. "interfaceClass",
  26249. "interfaceName",
  26250. "interfaceNumber",
  26251. "interfaceProtocol",
  26252. "interfaceSubclass",
  26253. "interfaces",
  26254. "interimResults",
  26255. "internalSubset",
  26256. "interpretation",
  26257. "intersection",
  26258. "intersectionRatio",
  26259. "intersectionRect",
  26260. "intersectsNode",
  26261. "interval",
  26262. "invalidIteratorState",
  26263. "invalidateFramebuffer",
  26264. "invalidateSubFramebuffer",
  26265. "inverse",
  26266. "invertSelf",
  26267. "invoker",
  26268. "invokerType",
  26269. "is",
  26270. "is2D",
  26271. "isActive",
  26272. "isAllowedFileSchemeAccess",
  26273. "isAllowedIncognitoAccess",
  26274. "isAlternate",
  26275. "isArray",
  26276. "isAutoSelected",
  26277. "isBingCurrentSearchDefault",
  26278. "isBuffer",
  26279. "isCandidateWindowVisible",
  26280. "isChar",
  26281. "isCollapsed",
  26282. "isComposing",
  26283. "isConcatSpreadable",
  26284. "isConditionalMediationAvailable",
  26285. "isConfigSupported",
  26286. "isConnected",
  26287. "isContentEditable",
  26288. "isContentHandlerRegistered",
  26289. "isContextLost",
  26290. "isDefaultNamespace",
  26291. "isDirectory",
  26292. "isDisabled",
  26293. "isDisjointFrom",
  26294. "isEnabled",
  26295. "isEqual",
  26296. "isEqualNode",
  26297. "isExtended",
  26298. "isExtensible",
  26299. "isExternalCTAP2SecurityKeySupported",
  26300. "isFallbackAdapter",
  26301. "isFile",
  26302. "isFinite",
  26303. "isFirstPersonObserver",
  26304. "isFramebuffer",
  26305. "isFrozen",
  26306. "isGenerator",
  26307. "isHTML",
  26308. "isHistoryNavigation",
  26309. "isId",
  26310. "isIdentity",
  26311. "isInjected",
  26312. "isInputPending",
  26313. "isInteger",
  26314. "isInternal",
  26315. "isIntersecting",
  26316. "isLockFree",
  26317. "isMap",
  26318. "isMultiLine",
  26319. "isNaN",
  26320. "isOpen",
  26321. "isPointInFill",
  26322. "isPointInPath",
  26323. "isPointInRange",
  26324. "isPointInStroke",
  26325. "isPrefAlternate",
  26326. "isPresenting",
  26327. "isPrimary",
  26328. "isProgram",
  26329. "isPropertyImplicit",
  26330. "isProtocolHandlerRegistered",
  26331. "isPrototypeOf",
  26332. "isQuery",
  26333. "isRawJSON",
  26334. "isRenderbuffer",
  26335. "isSafeInteger",
  26336. "isSameEntry",
  26337. "isSameNode",
  26338. "isSampler",
  26339. "isScript",
  26340. "isScriptURL",
  26341. "isSealed",
  26342. "isSecureContext",
  26343. "isSessionSupported",
  26344. "isShader",
  26345. "isSubsetOf",
  26346. "isSupersetOf",
  26347. "isSupported",
  26348. "isSync",
  26349. "isTextEdit",
  26350. "isTexture",
  26351. "isTransformFeedback",
  26352. "isTrusted",
  26353. "isTypeSupported",
  26354. "isUserVerifyingPlatformAuthenticatorAvailable",
  26355. "isVertexArray",
  26356. "isView",
  26357. "isVisible",
  26358. "isWellFormed",
  26359. "isochronousTransferIn",
  26360. "isochronousTransferOut",
  26361. "isolation",
  26362. "italics",
  26363. "item",
  26364. "itemId",
  26365. "itemProp",
  26366. "itemRef",
  26367. "itemScope",
  26368. "itemType",
  26369. "itemValue",
  26370. "items",
  26371. "iterateNext",
  26372. "iterationComposite",
  26373. "iterator",
  26374. "javaEnabled",
  26375. "jitterBufferTarget",
  26376. "jobTitle",
  26377. "join",
  26378. "joinAdInterestGroup",
  26379. "jointName",
  26380. "json",
  26381. "justify-content",
  26382. "justify-items",
  26383. "justify-self",
  26384. "justifyContent",
  26385. "justifyItems",
  26386. "justifySelf",
  26387. "k1",
  26388. "k2",
  26389. "k3",
  26390. "k4",
  26391. "kHz",
  26392. "keepalive",
  26393. "kernelMatrix",
  26394. "kernelUnitLengthX",
  26395. "kernelUnitLengthY",
  26396. "kerning",
  26397. "key",
  26398. "keyCode",
  26399. "keyFor",
  26400. "keyIdentifier",
  26401. "keyLightEnabled",
  26402. "keyLocation",
  26403. "keyPath",
  26404. "keyStatuses",
  26405. "keySystem",
  26406. "keyText",
  26407. "keyUsage",
  26408. "keyboard",
  26409. "keys",
  26410. "keytype",
  26411. "kind",
  26412. "knee",
  26413. "knownSources",
  26414. "label",
  26415. "labels",
  26416. "lang",
  26417. "language",
  26418. "languages",
  26419. "largeArcFlag",
  26420. "lastChild",
  26421. "lastElementChild",
  26422. "lastError",
  26423. "lastEventId",
  26424. "lastIndex",
  26425. "lastIndexOf",
  26426. "lastInputTime",
  26427. "lastMatch",
  26428. "lastMessageSubject",
  26429. "lastMessageType",
  26430. "lastModified",
  26431. "lastModifiedDate",
  26432. "lastPage",
  26433. "lastParen",
  26434. "lastState",
  26435. "lastStyleSheetSet",
  26436. "latency",
  26437. "latitude",
  26438. "launchQueue",
  26439. "layerName",
  26440. "layerX",
  26441. "layerY",
  26442. "layout",
  26443. "layoutFlow",
  26444. "layoutGrid",
  26445. "layoutGridChar",
  26446. "layoutGridLine",
  26447. "layoutGridMode",
  26448. "layoutGridType",
  26449. "lbound",
  26450. "leaveAdInterestGroup",
  26451. "left",
  26452. "leftContext",
  26453. "leftDegrees",
  26454. "leftMargin",
  26455. "leftProjectionMatrix",
  26456. "leftViewMatrix",
  26457. "length",
  26458. "lengthAdjust",
  26459. "lengthComputable",
  26460. "letter-spacing",
  26461. "letterSpacing",
  26462. "level",
  26463. "lh",
  26464. "lighting-color",
  26465. "lightingColor",
  26466. "limitingConeAngle",
  26467. "limits",
  26468. "line",
  26469. "line-break",
  26470. "line-height",
  26471. "lineAlign",
  26472. "lineBreak",
  26473. "lineCap",
  26474. "lineDashOffset",
  26475. "lineGapOverride",
  26476. "lineHeight",
  26477. "lineJoin",
  26478. "lineNum",
  26479. "lineNumber",
  26480. "linePos",
  26481. "lineTo",
  26482. "lineWidth",
  26483. "linearAcceleration",
  26484. "linearRampToValueAtTime",
  26485. "linearVelocity",
  26486. "lineno",
  26487. "lines",
  26488. "link",
  26489. "linkColor",
  26490. "linkProgram",
  26491. "links",
  26492. "list",
  26493. "list-style",
  26494. "list-style-image",
  26495. "list-style-position",
  26496. "list-style-type",
  26497. "listStyle",
  26498. "listStyleImage",
  26499. "listStylePosition",
  26500. "listStyleType",
  26501. "listener",
  26502. "listeners",
  26503. "load",
  26504. "loadEventEnd",
  26505. "loadEventStart",
  26506. "loadOp",
  26507. "loadTime",
  26508. "loadTimes",
  26509. "loaded",
  26510. "loading",
  26511. "localDescription",
  26512. "localName",
  26513. "localService",
  26514. "localStorage",
  26515. "locale",
  26516. "localeCompare",
  26517. "location",
  26518. "locationbar",
  26519. "lock",
  26520. "locked",
  26521. "lockedFile",
  26522. "locks",
  26523. "lodMaxClamp",
  26524. "lodMinClamp",
  26525. "log",
  26526. "log10",
  26527. "log1p",
  26528. "log2",
  26529. "logicalXDPI",
  26530. "logicalYDPI",
  26531. "login",
  26532. "loglevel",
  26533. "longDesc",
  26534. "longitude",
  26535. "lookupNamespaceURI",
  26536. "lookupPrefix",
  26537. "loop",
  26538. "loopEnd",
  26539. "loopStart",
  26540. "looping",
  26541. "lost",
  26542. "low",
  26543. "lower",
  26544. "lowerBound",
  26545. "lowerOpen",
  26546. "lowsrc",
  26547. "lvb",
  26548. "lvh",
  26549. "lvi",
  26550. "lvmax",
  26551. "lvmin",
  26552. "lvw",
  26553. "m11",
  26554. "m12",
  26555. "m13",
  26556. "m14",
  26557. "m21",
  26558. "m22",
  26559. "m23",
  26560. "m24",
  26561. "m31",
  26562. "m32",
  26563. "m33",
  26564. "m34",
  26565. "m41",
  26566. "m42",
  26567. "m43",
  26568. "m44",
  26569. "magFilter",
  26570. "makeXRCompatible",
  26571. "managed",
  26572. "management",
  26573. "manifest",
  26574. "manufacturer",
  26575. "manufacturerName",
  26576. "map",
  26577. "mapAsync",
  26578. "mapState",
  26579. "mappedAtCreation",
  26580. "mapping",
  26581. "margin",
  26582. "margin-block",
  26583. "margin-block-end",
  26584. "margin-block-start",
  26585. "margin-bottom",
  26586. "margin-inline",
  26587. "margin-inline-end",
  26588. "margin-inline-start",
  26589. "margin-left",
  26590. "margin-right",
  26591. "margin-top",
  26592. "marginBlock",
  26593. "marginBlockEnd",
  26594. "marginBlockStart",
  26595. "marginBottom",
  26596. "marginHeight",
  26597. "marginInline",
  26598. "marginInlineEnd",
  26599. "marginInlineStart",
  26600. "marginLeft",
  26601. "marginRight",
  26602. "marginTop",
  26603. "marginWidth",
  26604. "mark",
  26605. "marker",
  26606. "marker-end",
  26607. "marker-mid",
  26608. "marker-offset",
  26609. "marker-start",
  26610. "markerEnd",
  26611. "markerHeight",
  26612. "markerMid",
  26613. "markerOffset",
  26614. "markerStart",
  26615. "markerUnits",
  26616. "markerWidth",
  26617. "marks",
  26618. "mask",
  26619. "mask-clip",
  26620. "mask-composite",
  26621. "mask-image",
  26622. "mask-mode",
  26623. "mask-origin",
  26624. "mask-position",
  26625. "mask-position-x",
  26626. "mask-position-y",
  26627. "mask-repeat",
  26628. "mask-size",
  26629. "mask-type",
  26630. "maskClip",
  26631. "maskComposite",
  26632. "maskContentUnits",
  26633. "maskImage",
  26634. "maskMode",
  26635. "maskOrigin",
  26636. "maskPosition",
  26637. "maskPositionX",
  26638. "maskPositionY",
  26639. "maskRepeat",
  26640. "maskSize",
  26641. "maskType",
  26642. "maskUnits",
  26643. "match",
  26644. "matchAll",
  26645. "matchMedia",
  26646. "matchMedium",
  26647. "matchPatterns",
  26648. "matches",
  26649. "math-depth",
  26650. "math-style",
  26651. "mathDepth",
  26652. "mathStyle",
  26653. "matrix",
  26654. "matrixTransform",
  26655. "max",
  26656. "max-block-size",
  26657. "max-height",
  26658. "max-inline-size",
  26659. "max-width",
  26660. "maxActions",
  26661. "maxAlternatives",
  26662. "maxAnisotropy",
  26663. "maxBindGroups",
  26664. "maxBindGroupsPlusVertexBuffers",
  26665. "maxBindingsPerBindGroup",
  26666. "maxBlockSize",
  26667. "maxBufferSize",
  26668. "maxByteLength",
  26669. "maxChannelCount",
  26670. "maxChannels",
  26671. "maxColorAttachmentBytesPerSample",
  26672. "maxColorAttachments",
  26673. "maxComputeInvocationsPerWorkgroup",
  26674. "maxComputeWorkgroupSizeX",
  26675. "maxComputeWorkgroupSizeY",
  26676. "maxComputeWorkgroupSizeZ",
  26677. "maxComputeWorkgroupStorageSize",
  26678. "maxComputeWorkgroupsPerDimension",
  26679. "maxConnectionsPerServer",
  26680. "maxDatagramSize",
  26681. "maxDecibels",
  26682. "maxDistance",
  26683. "maxDrawCount",
  26684. "maxDynamicStorageBuffersPerPipelineLayout",
  26685. "maxDynamicUniformBuffersPerPipelineLayout",
  26686. "maxHeight",
  26687. "maxInlineSize",
  26688. "maxInterStageShaderComponents",
  26689. "maxInterStageShaderVariables",
  26690. "maxLayers",
  26691. "maxLength",
  26692. "maxMessageSize",
  26693. "maxPacketLifeTime",
  26694. "maxRetransmits",
  26695. "maxSampledTexturesPerShaderStage",
  26696. "maxSamplersPerShaderStage",
  26697. "maxStorageBufferBindingSize",
  26698. "maxStorageBuffersPerShaderStage",
  26699. "maxStorageTexturesPerShaderStage",
  26700. "maxTextureArrayLayers",
  26701. "maxTextureDimension1D",
  26702. "maxTextureDimension2D",
  26703. "maxTextureDimension3D",
  26704. "maxTouchPoints",
  26705. "maxUniformBufferBindingSize",
  26706. "maxUniformBuffersPerShaderStage",
  26707. "maxValue",
  26708. "maxVertexAttributes",
  26709. "maxVertexBufferArrayStride",
  26710. "maxVertexBuffers",
  26711. "maxWidth",
  26712. "maximumLatency",
  26713. "measure",
  26714. "measureText",
  26715. "media",
  26716. "mediaCapabilities",
  26717. "mediaDevices",
  26718. "mediaElement",
  26719. "mediaGroup",
  26720. "mediaKeys",
  26721. "mediaSession",
  26722. "mediaStream",
  26723. "mediaText",
  26724. "meetOrSlice",
  26725. "memory",
  26726. "menubar",
  26727. "menus",
  26728. "menusChild",
  26729. "menusInternal",
  26730. "mergeAttributes",
  26731. "message",
  26732. "messageClass",
  26733. "messageHandlers",
  26734. "messageType",
  26735. "messages",
  26736. "metaKey",
  26737. "metadata",
  26738. "method",
  26739. "methodDetails",
  26740. "methodName",
  26741. "mid",
  26742. "mimeType",
  26743. "mimeTypes",
  26744. "min",
  26745. "min-block-size",
  26746. "min-height",
  26747. "min-inline-size",
  26748. "min-width",
  26749. "minBindingSize",
  26750. "minBlockSize",
  26751. "minDecibels",
  26752. "minFilter",
  26753. "minHeight",
  26754. "minInlineSize",
  26755. "minLength",
  26756. "minStorageBufferOffsetAlignment",
  26757. "minUniformBufferOffsetAlignment",
  26758. "minValue",
  26759. "minWidth",
  26760. "minimumLatency",
  26761. "mipLevel",
  26762. "mipLevelCount",
  26763. "mipmapFilter",
  26764. "miterLimit",
  26765. "mix-blend-mode",
  26766. "mixBlendMode",
  26767. "mm",
  26768. "mobile",
  26769. "mode",
  26770. "model",
  26771. "modify",
  26772. "module",
  26773. "mount",
  26774. "move",
  26775. "moveBy",
  26776. "moveEnd",
  26777. "moveFirst",
  26778. "moveFocusDown",
  26779. "moveFocusLeft",
  26780. "moveFocusRight",
  26781. "moveFocusUp",
  26782. "moveInSuccession",
  26783. "moveNext",
  26784. "moveRow",
  26785. "moveStart",
  26786. "moveTo",
  26787. "moveToBookmark",
  26788. "moveToElementText",
  26789. "moveToPoint",
  26790. "movementX",
  26791. "movementY",
  26792. "mozAdd",
  26793. "mozAnimationStartTime",
  26794. "mozAnon",
  26795. "mozApps",
  26796. "mozAudioCaptured",
  26797. "mozAudioChannelType",
  26798. "mozAutoplayEnabled",
  26799. "mozCancelAnimationFrame",
  26800. "mozCancelFullScreen",
  26801. "mozCancelRequestAnimationFrame",
  26802. "mozCaptureStream",
  26803. "mozCaptureStreamUntilEnded",
  26804. "mozClearDataAt",
  26805. "mozContact",
  26806. "mozContacts",
  26807. "mozCreateFileHandle",
  26808. "mozCurrentTransform",
  26809. "mozCurrentTransformInverse",
  26810. "mozCursor",
  26811. "mozDash",
  26812. "mozDashOffset",
  26813. "mozDecodedFrames",
  26814. "mozExitPointerLock",
  26815. "mozFillRule",
  26816. "mozFragmentEnd",
  26817. "mozFrameDelay",
  26818. "mozFullScreen",
  26819. "mozFullScreenElement",
  26820. "mozFullScreenEnabled",
  26821. "mozGetAll",
  26822. "mozGetAllKeys",
  26823. "mozGetAsFile",
  26824. "mozGetDataAt",
  26825. "mozGetMetadata",
  26826. "mozGetUserMedia",
  26827. "mozHasAudio",
  26828. "mozHasItem",
  26829. "mozHidden",
  26830. "mozImageSmoothingEnabled",
  26831. "mozIndexedDB",
  26832. "mozInnerScreenX",
  26833. "mozInnerScreenY",
  26834. "mozInputSource",
  26835. "mozIsTextField",
  26836. "mozItem",
  26837. "mozItemCount",
  26838. "mozItems",
  26839. "mozLength",
  26840. "mozLockOrientation",
  26841. "mozMatchesSelector",
  26842. "mozMovementX",
  26843. "mozMovementY",
  26844. "mozOpaque",
  26845. "mozOrientation",
  26846. "mozPaintCount",
  26847. "mozPaintedFrames",
  26848. "mozParsedFrames",
  26849. "mozPay",
  26850. "mozPointerLockElement",
  26851. "mozPresentedFrames",
  26852. "mozPreservesPitch",
  26853. "mozPressure",
  26854. "mozPrintCallback",
  26855. "mozRTCIceCandidate",
  26856. "mozRTCPeerConnection",
  26857. "mozRTCSessionDescription",
  26858. "mozRemove",
  26859. "mozRequestAnimationFrame",
  26860. "mozRequestFullScreen",
  26861. "mozRequestPointerLock",
  26862. "mozSetDataAt",
  26863. "mozSetImageElement",
  26864. "mozSourceNode",
  26865. "mozSrcObject",
  26866. "mozSystem",
  26867. "mozTCPSocket",
  26868. "mozTextStyle",
  26869. "mozTypesAt",
  26870. "mozUnlockOrientation",
  26871. "mozUserCancelled",
  26872. "mozVisibilityState",
  26873. "ms",
  26874. "msAnimation",
  26875. "msAnimationDelay",
  26876. "msAnimationDirection",
  26877. "msAnimationDuration",
  26878. "msAnimationFillMode",
  26879. "msAnimationIterationCount",
  26880. "msAnimationName",
  26881. "msAnimationPlayState",
  26882. "msAnimationStartTime",
  26883. "msAnimationTimingFunction",
  26884. "msBackfaceVisibility",
  26885. "msBlockProgression",
  26886. "msCSSOMElementFloatMetrics",
  26887. "msCaching",
  26888. "msCachingEnabled",
  26889. "msCancelRequestAnimationFrame",
  26890. "msCapsLockWarningOff",
  26891. "msClearImmediate",
  26892. "msClose",
  26893. "msContentZoomChaining",
  26894. "msContentZoomFactor",
  26895. "msContentZoomLimit",
  26896. "msContentZoomLimitMax",
  26897. "msContentZoomLimitMin",
  26898. "msContentZoomSnap",
  26899. "msContentZoomSnapPoints",
  26900. "msContentZoomSnapType",
  26901. "msContentZooming",
  26902. "msConvertURL",
  26903. "msCrypto",
  26904. "msDoNotTrack",
  26905. "msElementsFromPoint",
  26906. "msElementsFromRect",
  26907. "msExitFullscreen",
  26908. "msExtendedCode",
  26909. "msFillRule",
  26910. "msFirstPaint",
  26911. "msFlex",
  26912. "msFlexAlign",
  26913. "msFlexDirection",
  26914. "msFlexFlow",
  26915. "msFlexItemAlign",
  26916. "msFlexLinePack",
  26917. "msFlexNegative",
  26918. "msFlexOrder",
  26919. "msFlexPack",
  26920. "msFlexPositive",
  26921. "msFlexPreferredSize",
  26922. "msFlexWrap",
  26923. "msFlowFrom",
  26924. "msFlowInto",
  26925. "msFontFeatureSettings",
  26926. "msFullscreenElement",
  26927. "msFullscreenEnabled",
  26928. "msGetInputContext",
  26929. "msGetRegionContent",
  26930. "msGetUntransformedBounds",
  26931. "msGraphicsTrustStatus",
  26932. "msGridColumn",
  26933. "msGridColumnAlign",
  26934. "msGridColumnSpan",
  26935. "msGridColumns",
  26936. "msGridRow",
  26937. "msGridRowAlign",
  26938. "msGridRowSpan",
  26939. "msGridRows",
  26940. "msHidden",
  26941. "msHighContrastAdjust",
  26942. "msHyphenateLimitChars",
  26943. "msHyphenateLimitLines",
  26944. "msHyphenateLimitZone",
  26945. "msHyphens",
  26946. "msImageSmoothingEnabled",
  26947. "msImeAlign",
  26948. "msIndexedDB",
  26949. "msInterpolationMode",
  26950. "msIsStaticHTML",
  26951. "msKeySystem",
  26952. "msKeys",
  26953. "msLaunchUri",
  26954. "msLockOrientation",
  26955. "msManipulationViewsEnabled",
  26956. "msMatchMedia",
  26957. "msMatchesSelector",
  26958. "msMaxTouchPoints",
  26959. "msOrientation",
  26960. "msOverflowStyle",
  26961. "msPerspective",
  26962. "msPerspectiveOrigin",
  26963. "msPlayToDisabled",
  26964. "msPlayToPreferredSourceUri",
  26965. "msPlayToPrimary",
  26966. "msPointerEnabled",
  26967. "msRegionOverflow",
  26968. "msReleasePointerCapture",
  26969. "msRequestAnimationFrame",
  26970. "msRequestFullscreen",
  26971. "msSaveBlob",
  26972. "msSaveOrOpenBlob",
  26973. "msScrollChaining",
  26974. "msScrollLimit",
  26975. "msScrollLimitXMax",
  26976. "msScrollLimitXMin",
  26977. "msScrollLimitYMax",
  26978. "msScrollLimitYMin",
  26979. "msScrollRails",
  26980. "msScrollSnapPointsX",
  26981. "msScrollSnapPointsY",
  26982. "msScrollSnapType",
  26983. "msScrollSnapX",
  26984. "msScrollSnapY",
  26985. "msScrollTranslation",
  26986. "msSetImmediate",
  26987. "msSetMediaKeys",
  26988. "msSetPointerCapture",
  26989. "msTextCombineHorizontal",
  26990. "msTextSizeAdjust",
  26991. "msToBlob",
  26992. "msTouchAction",
  26993. "msTouchSelect",
  26994. "msTraceAsyncCallbackCompleted",
  26995. "msTraceAsyncCallbackStarting",
  26996. "msTraceAsyncOperationCompleted",
  26997. "msTraceAsyncOperationStarting",
  26998. "msTransform",
  26999. "msTransformOrigin",
  27000. "msTransformStyle",
  27001. "msTransition",
  27002. "msTransitionDelay",
  27003. "msTransitionDuration",
  27004. "msTransitionProperty",
  27005. "msTransitionTimingFunction",
  27006. "msUnlockOrientation",
  27007. "msUpdateAsyncCallbackRelation",
  27008. "msUserSelect",
  27009. "msVisibilityState",
  27010. "msWrapFlow",
  27011. "msWrapMargin",
  27012. "msWrapThrough",
  27013. "msWriteProfilerMark",
  27014. "msZoom",
  27015. "msZoomTo",
  27016. "mt",
  27017. "mul",
  27018. "multiEntry",
  27019. "multiSelectionObj",
  27020. "multiline",
  27021. "multiple",
  27022. "multiply",
  27023. "multiplySelf",
  27024. "multisample",
  27025. "multisampled",
  27026. "mutableFile",
  27027. "muted",
  27028. "n",
  27029. "nacl_arch",
  27030. "name",
  27031. "nameList",
  27032. "nameProp",
  27033. "namedItem",
  27034. "namedRecordset",
  27035. "names",
  27036. "namespaceURI",
  27037. "namespaces",
  27038. "nativeApplication",
  27039. "nativeMap",
  27040. "nativeObjectCreate",
  27041. "nativeSet",
  27042. "nativeWeakMap",
  27043. "naturalHeight",
  27044. "naturalWidth",
  27045. "navigate",
  27046. "navigation",
  27047. "navigationMode",
  27048. "navigationPreload",
  27049. "navigationStart",
  27050. "navigationType",
  27051. "navigator",
  27052. "near",
  27053. "nearestViewportElement",
  27054. "negative",
  27055. "negotiated",
  27056. "netscape",
  27057. "networkState",
  27058. "networkStatus",
  27059. "newScale",
  27060. "newState",
  27061. "newTranslate",
  27062. "newURL",
  27063. "newValue",
  27064. "newValueSpecifiedUnits",
  27065. "newVersion",
  27066. "newhome",
  27067. "next",
  27068. "nextElementSibling",
  27069. "nextHopProtocol",
  27070. "nextNode",
  27071. "nextPage",
  27072. "nextSibling",
  27073. "nickname",
  27074. "noHref",
  27075. "noModule",
  27076. "noResize",
  27077. "noShade",
  27078. "noValidate",
  27079. "noWrap",
  27080. "node",
  27081. "nodeName",
  27082. "nodeType",
  27083. "nodeValue",
  27084. "nonce",
  27085. "normDepthBufferFromNormView",
  27086. "normalize",
  27087. "normalizedPathSegList",
  27088. "normandyAddonStudy",
  27089. "notRestoredReasons",
  27090. "notationName",
  27091. "notations",
  27092. "note",
  27093. "noteGrainOn",
  27094. "noteOff",
  27095. "noteOn",
  27096. "notifications",
  27097. "notify",
  27098. "now",
  27099. "npnNegotiatedProtocol",
  27100. "numOctaves",
  27101. "number",
  27102. "numberOfChannels",
  27103. "numberOfFrames",
  27104. "numberOfInputs",
  27105. "numberOfItems",
  27106. "numberOfOutputs",
  27107. "numberValue",
  27108. "oMatchesSelector",
  27109. "object",
  27110. "object-fit",
  27111. "object-position",
  27112. "objectFit",
  27113. "objectPosition",
  27114. "objectStore",
  27115. "objectStoreNames",
  27116. "objectType",
  27117. "observe",
  27118. "occlusionQuerySet",
  27119. "of",
  27120. "off",
  27121. "offscreenBuffering",
  27122. "offset",
  27123. "offset-anchor",
  27124. "offset-distance",
  27125. "offset-path",
  27126. "offset-position",
  27127. "offset-rotate",
  27128. "offsetAnchor",
  27129. "offsetDistance",
  27130. "offsetHeight",
  27131. "offsetLeft",
  27132. "offsetNode",
  27133. "offsetParent",
  27134. "offsetPath",
  27135. "offsetPosition",
  27136. "offsetRotate",
  27137. "offsetTop",
  27138. "offsetWidth",
  27139. "offsetX",
  27140. "offsetY",
  27141. "ok",
  27142. "oldState",
  27143. "oldURL",
  27144. "oldValue",
  27145. "oldVersion",
  27146. "olderShadowRoot",
  27147. "omnibox",
  27148. "on",
  27149. "onActivated",
  27150. "onAdded",
  27151. "onAttached",
  27152. "onBoundsChanged",
  27153. "onBrowserUpdateAvailable",
  27154. "onClicked",
  27155. "onCommitFiberRoot",
  27156. "onCommitFiberUnmount",
  27157. "onConnect",
  27158. "onConnectExternal",
  27159. "onConnectNative",
  27160. "onCreated",
  27161. "onDetached",
  27162. "onDisabled",
  27163. "onEnabled",
  27164. "onFocusChanged",
  27165. "onHighlighted",
  27166. "onInstalled",
  27167. "onLine",
  27168. "onMessage",
  27169. "onMessageExternal",
  27170. "onMoved",
  27171. "onPerformanceWarning",
  27172. "onPostCommitFiberRoot",
  27173. "onRemoved",
  27174. "onReplaced",
  27175. "onRestartRequired",
  27176. "onStartup",
  27177. "onSubmittedWorkDone",
  27178. "onSuspend",
  27179. "onSuspendCanceled",
  27180. "onUninstalled",
  27181. "onUpdateAvailable",
  27182. "onUpdated",
  27183. "onUserScriptConnect",
  27184. "onUserScriptMessage",
  27185. "onUserSettingsChanged",
  27186. "onZoomChange",
  27187. "onabort",
  27188. "onabsolutedeviceorientation",
  27189. "onactivate",
  27190. "onactive",
  27191. "onaddsourcebuffer",
  27192. "onaddstream",
  27193. "onaddtrack",
  27194. "onafterprint",
  27195. "onafterscriptexecute",
  27196. "onafterupdate",
  27197. "onanimationcancel",
  27198. "onanimationend",
  27199. "onanimationiteration",
  27200. "onanimationstart",
  27201. "onappinstalled",
  27202. "onaudioend",
  27203. "onaudioprocess",
  27204. "onaudiostart",
  27205. "onautocomplete",
  27206. "onautocompleteerror",
  27207. "onauxclick",
  27208. "onbeforeactivate",
  27209. "onbeforecopy",
  27210. "onbeforecut",
  27211. "onbeforedeactivate",
  27212. "onbeforeeditfocus",
  27213. "onbeforeinput",
  27214. "onbeforeinstallprompt",
  27215. "onbeforematch",
  27216. "onbeforepaste",
  27217. "onbeforeprint",
  27218. "onbeforescriptexecute",
  27219. "onbeforetoggle",
  27220. "onbeforeunload",
  27221. "onbeforeupdate",
  27222. "onbeforexrselect",
  27223. "onbegin",
  27224. "onblocked",
  27225. "onblur",
  27226. "onbounce",
  27227. "onboundary",
  27228. "onbufferedamountlow",
  27229. "oncached",
  27230. "oncancel",
  27231. "oncandidatewindowhide",
  27232. "oncandidatewindowshow",
  27233. "oncandidatewindowupdate",
  27234. "oncanplay",
  27235. "oncanplaythrough",
  27236. "oncapturehandlechange",
  27237. "once",
  27238. "oncellchange",
  27239. "onchange",
  27240. "oncharacterboundsupdate",
  27241. "oncharacteristicvaluechanged",
  27242. "onchargingchange",
  27243. "onchargingtimechange",
  27244. "onchecking",
  27245. "onclick",
  27246. "onclose",
  27247. "onclosing",
  27248. "oncompassneedscalibration",
  27249. "oncomplete",
  27250. "oncompositionend",
  27251. "oncompositionstart",
  27252. "onconnect",
  27253. "onconnecting",
  27254. "onconnectionavailable",
  27255. "onconnectionstatechange",
  27256. "oncontentvisibilityautostatechange",
  27257. "oncontextlost",
  27258. "oncontextmenu",
  27259. "oncontextrestored",
  27260. "oncontrollerchange",
  27261. "oncontrolselect",
  27262. "oncopy",
  27263. "oncuechange",
  27264. "oncurrententrychange",
  27265. "oncurrentscreenchange",
  27266. "oncut",
  27267. "ondataavailable",
  27268. "ondatachannel",
  27269. "ondatasetchanged",
  27270. "ondatasetcomplete",
  27271. "ondblclick",
  27272. "ondeactivate",
  27273. "ondequeue",
  27274. "ondevicechange",
  27275. "ondevicelight",
  27276. "ondevicemotion",
  27277. "ondeviceorientation",
  27278. "ondeviceorientationabsolute",
  27279. "ondeviceproximity",
  27280. "ondischargingtimechange",
  27281. "ondisconnect",
  27282. "ondisplay",
  27283. "ondispose",
  27284. "ondownloading",
  27285. "ondrag",
  27286. "ondragend",
  27287. "ondragenter",
  27288. "ondragexit",
  27289. "ondragleave",
  27290. "ondragover",
  27291. "ondragstart",
  27292. "ondrop",
  27293. "ondurationchange",
  27294. "onemptied",
  27295. "onencrypted",
  27296. "onend",
  27297. "onended",
  27298. "onenter",
  27299. "onenterpictureinpicture",
  27300. "onerror",
  27301. "onerrorupdate",
  27302. "onexit",
  27303. "onfencedtreeclick",
  27304. "onfilterchange",
  27305. "onfinish",
  27306. "onfocus",
  27307. "onfocusin",
  27308. "onfocusout",
  27309. "onformdata",
  27310. "onfreeze",
  27311. "onfullscreenchange",
  27312. "onfullscreenerror",
  27313. "ongamepadconnected",
  27314. "ongamepaddisconnected",
  27315. "ongatheringstatechange",
  27316. "ongattserverdisconnected",
  27317. "ongeometrychange",
  27318. "ongesturechange",
  27319. "ongestureend",
  27320. "ongesturestart",
  27321. "ongotpointercapture",
  27322. "onhashchange",
  27323. "onhelp",
  27324. "onicecandidate",
  27325. "onicecandidateerror",
  27326. "oniceconnectionstatechange",
  27327. "onicegatheringstatechange",
  27328. "oninactive",
  27329. "oninput",
  27330. "oninputreport",
  27331. "oninputsourceschange",
  27332. "oninvalid",
  27333. "onkeydown",
  27334. "onkeypress",
  27335. "onkeystatuseschange",
  27336. "onkeyup",
  27337. "onlanguagechange",
  27338. "onlayoutcomplete",
  27339. "onleavepictureinpicture",
  27340. "onlevelchange",
  27341. "onload",
  27342. "onloadT",
  27343. "onloadeddata",
  27344. "onloadedmetadata",
  27345. "onloadend",
  27346. "onloading",
  27347. "onloadingdone",
  27348. "onloadingerror",
  27349. "onloadstart",
  27350. "onlosecapture",
  27351. "onlostpointercapture",
  27352. "only",
  27353. "onmanagedconfigurationchange",
  27354. "onmark",
  27355. "onmessage",
  27356. "onmessageerror",
  27357. "onmidimessage",
  27358. "onmousedown",
  27359. "onmouseenter",
  27360. "onmouseleave",
  27361. "onmousemove",
  27362. "onmouseout",
  27363. "onmouseover",
  27364. "onmouseup",
  27365. "onmousewheel",
  27366. "onmove",
  27367. "onmoveend",
  27368. "onmovestart",
  27369. "onmozfullscreenchange",
  27370. "onmozfullscreenerror",
  27371. "onmozorientationchange",
  27372. "onmozpointerlockchange",
  27373. "onmozpointerlockerror",
  27374. "onmscontentzoom",
  27375. "onmsfullscreenchange",
  27376. "onmsfullscreenerror",
  27377. "onmsgesturechange",
  27378. "onmsgesturedoubletap",
  27379. "onmsgestureend",
  27380. "onmsgesturehold",
  27381. "onmsgesturestart",
  27382. "onmsgesturetap",
  27383. "onmsgotpointercapture",
  27384. "onmsinertiastart",
  27385. "onmslostpointercapture",
  27386. "onmsmanipulationstatechanged",
  27387. "onmsneedkey",
  27388. "onmsorientationchange",
  27389. "onmspointercancel",
  27390. "onmspointerdown",
  27391. "onmspointerenter",
  27392. "onmspointerhover",
  27393. "onmspointerleave",
  27394. "onmspointermove",
  27395. "onmspointerout",
  27396. "onmspointerover",
  27397. "onmspointerup",
  27398. "onmssitemodejumplistitemremoved",
  27399. "onmsthumbnailclick",
  27400. "onmute",
  27401. "onnavigate",
  27402. "onnavigateerror",
  27403. "onnavigatesuccess",
  27404. "onnegotiationneeded",
  27405. "onnomatch",
  27406. "onnoupdate",
  27407. "onobsolete",
  27408. "onoffline",
  27409. "ononline",
  27410. "onopen",
  27411. "onorientationchange",
  27412. "onpagechange",
  27413. "onpagehide",
  27414. "onpagereveal",
  27415. "onpageshow",
  27416. "onpageswap",
  27417. "onpaste",
  27418. "onpause",
  27419. "onpayerdetailchange",
  27420. "onpaymentmethodchange",
  27421. "onplay",
  27422. "onplaying",
  27423. "onpluginstreamstart",
  27424. "onpointercancel",
  27425. "onpointerdown",
  27426. "onpointerenter",
  27427. "onpointerleave",
  27428. "onpointerlockchange",
  27429. "onpointerlockerror",
  27430. "onpointermove",
  27431. "onpointerout",
  27432. "onpointerover",
  27433. "onpointerrawupdate",
  27434. "onpointerup",
  27435. "onpopstate",
  27436. "onprerenderingchange",
  27437. "onprioritychange",
  27438. "onprocessorerror",
  27439. "onprogress",
  27440. "onpropertychange",
  27441. "onratechange",
  27442. "onreading",
  27443. "onreadystatechange",
  27444. "onreflectionchange",
  27445. "onrejectionhandled",
  27446. "onrelease",
  27447. "onremove",
  27448. "onremovesourcebuffer",
  27449. "onremovestream",
  27450. "onremovetrack",
  27451. "onrepeat",
  27452. "onreset",
  27453. "onresize",
  27454. "onresizeend",
  27455. "onresizestart",
  27456. "onresourcetimingbufferfull",
  27457. "onresult",
  27458. "onresume",
  27459. "onrowenter",
  27460. "onrowexit",
  27461. "onrowsdelete",
  27462. "onrowsinserted",
  27463. "onscreenschange",
  27464. "onscroll",
  27465. "onscrollend",
  27466. "onscrollsnapchange",
  27467. "onscrollsnapchanging",
  27468. "onsearch",
  27469. "onsecuritypolicyviolation",
  27470. "onseeked",
  27471. "onseeking",
  27472. "onselect",
  27473. "onselectedcandidatepairchange",
  27474. "onselectend",
  27475. "onselectionchange",
  27476. "onselectstart",
  27477. "onshippingaddresschange",
  27478. "onshippingoptionchange",
  27479. "onshow",
  27480. "onsignalingstatechange",
  27481. "onsinkchange",
  27482. "onslotchange",
  27483. "onsoundend",
  27484. "onsoundstart",
  27485. "onsourceclose",
  27486. "onsourceclosed",
  27487. "onsourceended",
  27488. "onsourceopen",
  27489. "onspeechend",
  27490. "onspeechstart",
  27491. "onsqueeze",
  27492. "onsqueezeend",
  27493. "onsqueezestart",
  27494. "onstalled",
  27495. "onstart",
  27496. "onstatechange",
  27497. "onstop",
  27498. "onstorage",
  27499. "onstoragecommit",
  27500. "onsubmit",
  27501. "onsuccess",
  27502. "onsuspend",
  27503. "onterminate",
  27504. "ontextformatupdate",
  27505. "ontextinput",
  27506. "ontextupdate",
  27507. "ontimeout",
  27508. "ontimeupdate",
  27509. "ontoggle",
  27510. "ontonechange",
  27511. "ontouchcancel",
  27512. "ontouchend",
  27513. "ontouchmove",
  27514. "ontouchstart",
  27515. "ontrack",
  27516. "ontransitioncancel",
  27517. "ontransitionend",
  27518. "ontransitionrun",
  27519. "ontransitionstart",
  27520. "onuncapturederror",
  27521. "onunhandledrejection",
  27522. "onunload",
  27523. "onunmute",
  27524. "onupdate",
  27525. "onupdateend",
  27526. "onupdatefound",
  27527. "onupdateready",
  27528. "onupdatestart",
  27529. "onupgradeneeded",
  27530. "onuserproximity",
  27531. "onversionchange",
  27532. "onvisibilitychange",
  27533. "onvoiceschanged",
  27534. "onvolumechange",
  27535. "onvrdisplayactivate",
  27536. "onvrdisplayconnect",
  27537. "onvrdisplaydeactivate",
  27538. "onvrdisplaydisconnect",
  27539. "onvrdisplaypresentchange",
  27540. "onwaiting",
  27541. "onwaitingforkey",
  27542. "onwarning",
  27543. "onwebkitanimationend",
  27544. "onwebkitanimationiteration",
  27545. "onwebkitanimationstart",
  27546. "onwebkitcurrentplaybacktargetiswirelesschanged",
  27547. "onwebkitfullscreenchange",
  27548. "onwebkitfullscreenerror",
  27549. "onwebkitkeyadded",
  27550. "onwebkitkeyerror",
  27551. "onwebkitkeymessage",
  27552. "onwebkitneedkey",
  27553. "onwebkitorientationchange",
  27554. "onwebkitplaybacktargetavailabilitychanged",
  27555. "onwebkitpointerlockchange",
  27556. "onwebkitpointerlockerror",
  27557. "onwebkitresourcetimingbufferfull",
  27558. "onwebkittransitionend",
  27559. "onwheel",
  27560. "onzoom",
  27561. "opacity",
  27562. "open",
  27563. "openCursor",
  27564. "openDatabase",
  27565. "openKeyCursor",
  27566. "openOptionsPage",
  27567. "openOrClosedShadowRoot",
  27568. "openPopup",
  27569. "opened",
  27570. "opener",
  27571. "opera",
  27572. "operation",
  27573. "operationType",
  27574. "operator",
  27575. "opr",
  27576. "optimum",
  27577. "options",
  27578. "or",
  27579. "order",
  27580. "orderX",
  27581. "orderY",
  27582. "ordered",
  27583. "org",
  27584. "organization",
  27585. "orient",
  27586. "orientAngle",
  27587. "orientType",
  27588. "orientation",
  27589. "orientationX",
  27590. "orientationY",
  27591. "orientationZ",
  27592. "origin",
  27593. "originAgentCluster",
  27594. "originalPolicy",
  27595. "originalTarget",
  27596. "orphans",
  27597. "os",
  27598. "oscpu",
  27599. "outerHTML",
  27600. "outerHeight",
  27601. "outerText",
  27602. "outerWidth",
  27603. "outgoingHighWaterMark",
  27604. "outgoingMaxAge",
  27605. "outline",
  27606. "outline-color",
  27607. "outline-offset",
  27608. "outline-style",
  27609. "outline-width",
  27610. "outlineColor",
  27611. "outlineOffset",
  27612. "outlineStyle",
  27613. "outlineWidth",
  27614. "outputBuffer",
  27615. "outputChannelCount",
  27616. "outputLatency",
  27617. "outputs",
  27618. "overflow",
  27619. "overflow-anchor",
  27620. "overflow-block",
  27621. "overflow-clip-margin",
  27622. "overflow-inline",
  27623. "overflow-wrap",
  27624. "overflow-x",
  27625. "overflow-y",
  27626. "overflowAnchor",
  27627. "overflowBlock",
  27628. "overflowClipMargin",
  27629. "overflowInline",
  27630. "overflowWrap",
  27631. "overflowX",
  27632. "overflowY",
  27633. "overlaysContent",
  27634. "overrideColors",
  27635. "overrideMimeType",
  27636. "oversample",
  27637. "overscroll-behavior",
  27638. "overscroll-behavior-block",
  27639. "overscroll-behavior-inline",
  27640. "overscroll-behavior-x",
  27641. "overscroll-behavior-y",
  27642. "overscrollBehavior",
  27643. "overscrollBehaviorBlock",
  27644. "overscrollBehaviorInline",
  27645. "overscrollBehaviorX",
  27646. "overscrollBehaviorY",
  27647. "ownKeys",
  27648. "ownerDocument",
  27649. "ownerElement",
  27650. "ownerNode",
  27651. "ownerRule",
  27652. "ownerSVGElement",
  27653. "owningElement",
  27654. "p1",
  27655. "p2",
  27656. "p3",
  27657. "p4",
  27658. "packetSize",
  27659. "packets",
  27660. "pad",
  27661. "padEnd",
  27662. "padStart",
  27663. "padding",
  27664. "padding-block",
  27665. "padding-block-end",
  27666. "padding-block-start",
  27667. "padding-bottom",
  27668. "padding-inline",
  27669. "padding-inline-end",
  27670. "padding-inline-start",
  27671. "padding-left",
  27672. "padding-right",
  27673. "padding-top",
  27674. "paddingBlock",
  27675. "paddingBlockEnd",
  27676. "paddingBlockStart",
  27677. "paddingBottom",
  27678. "paddingInline",
  27679. "paddingInlineEnd",
  27680. "paddingInlineStart",
  27681. "paddingLeft",
  27682. "paddingRight",
  27683. "paddingTop",
  27684. "page",
  27685. "page-break-after",
  27686. "page-break-before",
  27687. "page-break-inside",
  27688. "page-orientation",
  27689. "pageAction",
  27690. "pageBreakAfter",
  27691. "pageBreakBefore",
  27692. "pageBreakInside",
  27693. "pageCount",
  27694. "pageLeft",
  27695. "pageOrientation",
  27696. "pageT",
  27697. "pageTop",
  27698. "pageX",
  27699. "pageXOffset",
  27700. "pageY",
  27701. "pageYOffset",
  27702. "pages",
  27703. "paint-order",
  27704. "paintOrder",
  27705. "paintRequests",
  27706. "paintType",
  27707. "paintWorklet",
  27708. "palette",
  27709. "pan",
  27710. "panningModel",
  27711. "parameterData",
  27712. "parameters",
  27713. "parent",
  27714. "parentElement",
  27715. "parentNode",
  27716. "parentRule",
  27717. "parentStyleSheet",
  27718. "parentTextEdit",
  27719. "parentWindow",
  27720. "parse",
  27721. "parseAll",
  27722. "parseCreationOptionsFromJSON",
  27723. "parseFloat",
  27724. "parseFromString",
  27725. "parseHTMLUnsafe",
  27726. "parseInt",
  27727. "parseRequestOptionsFromJSON",
  27728. "part",
  27729. "participants",
  27730. "passOp",
  27731. "passive",
  27732. "password",
  27733. "pasteHTML",
  27734. "path",
  27735. "pathLength",
  27736. "pathSegList",
  27737. "pathSegType",
  27738. "pathSegTypeAsLetter",
  27739. "pathname",
  27740. "pattern",
  27741. "patternContentUnits",
  27742. "patternMismatch",
  27743. "patternTransform",
  27744. "patternUnits",
  27745. "pause",
  27746. "pauseAnimations",
  27747. "pauseDuration",
  27748. "pauseOnExit",
  27749. "pauseProfilers",
  27750. "pauseTransformFeedback",
  27751. "paused",
  27752. "payerEmail",
  27753. "payerName",
  27754. "payerPhone",
  27755. "paymentManager",
  27756. "pc",
  27757. "pdfViewerEnabled",
  27758. "peerIdentity",
  27759. "pending",
  27760. "pendingLocalDescription",
  27761. "pendingRemoteDescription",
  27762. "percent",
  27763. "performance",
  27764. "periodicSync",
  27765. "permission",
  27766. "permissionState",
  27767. "permissions",
  27768. "persist",
  27769. "persisted",
  27770. "persistentDeviceId",
  27771. "personalbar",
  27772. "perspective",
  27773. "perspective-origin",
  27774. "perspectiveOrigin",
  27775. "phone",
  27776. "phoneticFamilyName",
  27777. "phoneticGivenName",
  27778. "photo",
  27779. "pictureInPictureChild",
  27780. "pictureInPictureElement",
  27781. "pictureInPictureEnabled",
  27782. "pictureInPictureWindow",
  27783. "ping",
  27784. "pipeThrough",
  27785. "pipeTo",
  27786. "pitch",
  27787. "pixelBottom",
  27788. "pixelDepth",
  27789. "pixelHeight",
  27790. "pixelLeft",
  27791. "pixelRight",
  27792. "pixelStorei",
  27793. "pixelTop",
  27794. "pixelUnitToMillimeterX",
  27795. "pixelUnitToMillimeterY",
  27796. "pixelWidth",
  27797. "pkcs11",
  27798. "place-content",
  27799. "place-items",
  27800. "place-self",
  27801. "placeContent",
  27802. "placeItems",
  27803. "placeSelf",
  27804. "placeholder",
  27805. "platform",
  27806. "platformVersion",
  27807. "platforms",
  27808. "play",
  27809. "playEffect",
  27810. "playState",
  27811. "playbackRate",
  27812. "playbackState",
  27813. "playbackTime",
  27814. "played",
  27815. "playoutDelayHint",
  27816. "playsInline",
  27817. "plugins",
  27818. "pluginspage",
  27819. "pname",
  27820. "pointer-events",
  27821. "pointerBeforeReferenceNode",
  27822. "pointerEnabled",
  27823. "pointerEvents",
  27824. "pointerId",
  27825. "pointerLockElement",
  27826. "pointerType",
  27827. "points",
  27828. "pointsAtX",
  27829. "pointsAtY",
  27830. "pointsAtZ",
  27831. "polygonOffset",
  27832. "pop",
  27833. "popDebugGroup",
  27834. "popErrorScope",
  27835. "popover",
  27836. "popoverTargetAction",
  27837. "popoverTargetElement",
  27838. "populateMatrix",
  27839. "popupWindowFeatures",
  27840. "popupWindowName",
  27841. "popupWindowURI",
  27842. "port",
  27843. "port1",
  27844. "port2",
  27845. "ports",
  27846. "posBottom",
  27847. "posHeight",
  27848. "posLeft",
  27849. "posRight",
  27850. "posTop",
  27851. "posWidth",
  27852. "pose",
  27853. "position",
  27854. "position-anchor",
  27855. "position-area",
  27856. "positionAlign",
  27857. "positionAnchor",
  27858. "positionArea",
  27859. "positionX",
  27860. "positionY",
  27861. "positionZ",
  27862. "postError",
  27863. "postMessage",
  27864. "postTask",
  27865. "postalCode",
  27866. "poster",
  27867. "postscriptName",
  27868. "pow",
  27869. "powerEfficient",
  27870. "powerOff",
  27871. "powerPreference",
  27872. "preMultiplySelf",
  27873. "precision",
  27874. "preferredReflectionFormat",
  27875. "preferredStyleSheetSet",
  27876. "preferredStylesheetSet",
  27877. "prefix",
  27878. "preload",
  27879. "premultipliedAlpha",
  27880. "prepend",
  27881. "prerendering",
  27882. "presentation",
  27883. "presentationArea",
  27884. "presentationStyle",
  27885. "preserveAlpha",
  27886. "preserveAspectRatio",
  27887. "preserveAspectRatioString",
  27888. "preservesPitch",
  27889. "pressed",
  27890. "pressure",
  27891. "prevValue",
  27892. "preventDefault",
  27893. "preventExtensions",
  27894. "preventSilentAccess",
  27895. "previousElementSibling",
  27896. "previousNode",
  27897. "previousPage",
  27898. "previousPriority",
  27899. "previousRect",
  27900. "previousScale",
  27901. "previousSibling",
  27902. "previousTranslate",
  27903. "primaries",
  27904. "primaryKey",
  27905. "primaryLightDirection",
  27906. "primaryLightIntensity",
  27907. "primitive",
  27908. "primitiveType",
  27909. "primitiveUnits",
  27910. "principals",
  27911. "print",
  27912. "print-color-adjust",
  27913. "printColorAdjust",
  27914. "printPreview",
  27915. "priority",
  27916. "privacy",
  27917. "privateKey",
  27918. "privateToken",
  27919. "probablySupportsContext",
  27920. "probeSpace",
  27921. "process",
  27922. "processIceMessage",
  27923. "processingEnd",
  27924. "processingStart",
  27925. "processorOptions",
  27926. "product",
  27927. "productId",
  27928. "productName",
  27929. "productSub",
  27930. "profile",
  27931. "profileEnd",
  27932. "profiles",
  27933. "projectionMatrix",
  27934. "promise",
  27935. "prompt",
  27936. "properties",
  27937. "propertyIsEnumerable",
  27938. "propertyName",
  27939. "protectedAudience",
  27940. "protocol",
  27941. "protocolLong",
  27942. "prototype",
  27943. "provider",
  27944. "proxy",
  27945. "pseudoClass",
  27946. "pseudoElement",
  27947. "pt",
  27948. "publicId",
  27949. "publicKey",
  27950. "published",
  27951. "pulse",
  27952. "push",
  27953. "pushDebugGroup",
  27954. "pushErrorScope",
  27955. "pushManager",
  27956. "pushNotification",
  27957. "pushState",
  27958. "put",
  27959. "putImageData",
  27960. "px",
  27961. "quadraticCurveTo",
  27962. "qualifier",
  27963. "quaternion",
  27964. "query",
  27965. "queryCommandEnabled",
  27966. "queryCommandIndeterm",
  27967. "queryCommandState",
  27968. "queryCommandSupported",
  27969. "queryCommandText",
  27970. "queryCommandValue",
  27971. "queryFeatureSupport",
  27972. "queryLocalFonts",
  27973. "queryPermission",
  27974. "querySelector",
  27975. "querySelectorAll",
  27976. "querySet",
  27977. "queue",
  27978. "queueMicrotask",
  27979. "quote",
  27980. "quotes",
  27981. "r",
  27982. "r1",
  27983. "r2",
  27984. "race",
  27985. "rad",
  27986. "radiogroup",
  27987. "radius",
  27988. "radiusX",
  27989. "radiusY",
  27990. "random",
  27991. "randomUUID",
  27992. "range",
  27993. "rangeCount",
  27994. "rangeEnd",
  27995. "rangeMax",
  27996. "rangeMin",
  27997. "rangeOffset",
  27998. "rangeOverflow",
  27999. "rangeParent",
  28000. "rangeStart",
  28001. "rangeUnderflow",
  28002. "rate",
  28003. "ratio",
  28004. "raw",
  28005. "rawId",
  28006. "rawJSON",
  28007. "rawValueToMeters",
  28008. "rcap",
  28009. "rch",
  28010. "read",
  28011. "readAsArrayBuffer",
  28012. "readAsBinaryString",
  28013. "readAsBlob",
  28014. "readAsDataURL",
  28015. "readAsText",
  28016. "readBuffer",
  28017. "readEntries",
  28018. "readOnly",
  28019. "readPixels",
  28020. "readReportRequested",
  28021. "readText",
  28022. "readValue",
  28023. "readable",
  28024. "ready",
  28025. "readyState",
  28026. "reason",
  28027. "reasons",
  28028. "reboot",
  28029. "receiveFeatureReport",
  28030. "receivedAlert",
  28031. "receiver",
  28032. "receivers",
  28033. "recipient",
  28034. "recommendedViewportScale",
  28035. "reconnect",
  28036. "recordNumber",
  28037. "recordsAvailable",
  28038. "recordset",
  28039. "rect",
  28040. "red",
  28041. "redEyeReduction",
  28042. "redirect",
  28043. "redirectCount",
  28044. "redirectEnd",
  28045. "redirectStart",
  28046. "redirected",
  28047. "reduce",
  28048. "reduceRight",
  28049. "reduction",
  28050. "refDistance",
  28051. "refX",
  28052. "refY",
  28053. "referenceNode",
  28054. "referenceSpace",
  28055. "referrer",
  28056. "referrerPolicy",
  28057. "refresh",
  28058. "region",
  28059. "regionAnchorX",
  28060. "regionAnchorY",
  28061. "regionId",
  28062. "regions",
  28063. "register",
  28064. "registerContentHandler",
  28065. "registerElement",
  28066. "registerInternalModuleStart",
  28067. "registerInternalModuleStop",
  28068. "registerProperty",
  28069. "registerProtocolHandler",
  28070. "reject",
  28071. "rel",
  28072. "relList",
  28073. "relatedAddress",
  28074. "relatedNode",
  28075. "relatedPort",
  28076. "relatedTarget",
  28077. "relayProtocol",
  28078. "release",
  28079. "releaseCapture",
  28080. "releaseEvents",
  28081. "releaseInterface",
  28082. "releaseLock",
  28083. "releasePointerCapture",
  28084. "releaseShaderCompiler",
  28085. "released",
  28086. "reliability",
  28087. "reliable",
  28088. "reliableWrite",
  28089. "reload",
  28090. "rem",
  28091. "remainingSpace",
  28092. "remote",
  28093. "remoteDescription",
  28094. "remove",
  28095. "removeAllRanges",
  28096. "removeAttribute",
  28097. "removeAttributeNS",
  28098. "removeAttributeNode",
  28099. "removeBehavior",
  28100. "removeChild",
  28101. "removeCue",
  28102. "removeEntry",
  28103. "removeEventListener",
  28104. "removeFilter",
  28105. "removeImport",
  28106. "removeItem",
  28107. "removeListener",
  28108. "removeNamedItem",
  28109. "removeNamedItemNS",
  28110. "removeNode",
  28111. "removeParameter",
  28112. "removeProperty",
  28113. "removeRange",
  28114. "removeRegion",
  28115. "removeRule",
  28116. "removeSiteSpecificTrackingException",
  28117. "removeSourceBuffer",
  28118. "removeStream",
  28119. "removeTrack",
  28120. "removeVariable",
  28121. "removeWakeLockListener",
  28122. "removeWebWideTrackingException",
  28123. "removed",
  28124. "removedNodes",
  28125. "renderBlockingStatus",
  28126. "renderHeight",
  28127. "renderStart",
  28128. "renderState",
  28129. "renderTime",
  28130. "renderWidth",
  28131. "renderbufferStorage",
  28132. "renderbufferStorageMultisample",
  28133. "renderedBuffer",
  28134. "rendererInterfaces",
  28135. "renderers",
  28136. "renderingMode",
  28137. "renotify",
  28138. "repeat",
  28139. "repetitionCount",
  28140. "replace",
  28141. "replaceAdjacentText",
  28142. "replaceAll",
  28143. "replaceChild",
  28144. "replaceChildren",
  28145. "replaceData",
  28146. "replaceId",
  28147. "replaceItem",
  28148. "replaceNode",
  28149. "replaceState",
  28150. "replaceSync",
  28151. "replaceTrack",
  28152. "replaceWholeText",
  28153. "replaceWith",
  28154. "reportError",
  28155. "reportEvent",
  28156. "reportId",
  28157. "reportValidity",
  28158. "request",
  28159. "requestAdapter",
  28160. "requestAdapterInfo",
  28161. "requestAnimationFrame",
  28162. "requestAutocomplete",
  28163. "requestClose",
  28164. "requestData",
  28165. "requestDevice",
  28166. "requestFrame",
  28167. "requestFullscreen",
  28168. "requestHitTestSource",
  28169. "requestHitTestSourceForTransientInput",
  28170. "requestId",
  28171. "requestIdleCallback",
  28172. "requestLightProbe",
  28173. "requestMIDIAccess",
  28174. "requestMediaKeySystemAccess",
  28175. "requestPermission",
  28176. "requestPictureInPicture",
  28177. "requestPointerLock",
  28178. "requestPort",
  28179. "requestPresent",
  28180. "requestPresenter",
  28181. "requestReferenceSpace",
  28182. "requestSession",
  28183. "requestStart",
  28184. "requestStorageAccess",
  28185. "requestStorageAccessFor",
  28186. "requestSubmit",
  28187. "requestTime",
  28188. "requestUpdateCheck",
  28189. "requestVideoFrameCallback",
  28190. "requestViewportScale",
  28191. "requestWindow",
  28192. "requestingWindow",
  28193. "requireInteraction",
  28194. "required",
  28195. "requiredExtensions",
  28196. "requiredFeatures",
  28197. "requiredLimits",
  28198. "reset",
  28199. "resetLatency",
  28200. "resetPose",
  28201. "resetTransform",
  28202. "resizable",
  28203. "resize",
  28204. "resizeBy",
  28205. "resizeTo",
  28206. "resolve",
  28207. "resolveQuerySet",
  28208. "resolveTarget",
  28209. "resource",
  28210. "respond",
  28211. "respondWithNewView",
  28212. "response",
  28213. "responseBody",
  28214. "responseEnd",
  28215. "responseReady",
  28216. "responseStart",
  28217. "responseStatus",
  28218. "responseText",
  28219. "responseType",
  28220. "responseURL",
  28221. "responseXML",
  28222. "restart",
  28223. "restartAfterDelay",
  28224. "restartIce",
  28225. "restore",
  28226. "result",
  28227. "resultIndex",
  28228. "resultType",
  28229. "results",
  28230. "resume",
  28231. "resumeProfilers",
  28232. "resumeTransformFeedback",
  28233. "retry",
  28234. "returnValue",
  28235. "rev",
  28236. "reverse",
  28237. "reversed",
  28238. "revocable",
  28239. "revokeObjectURL",
  28240. "rex",
  28241. "rgbColor",
  28242. "ric",
  28243. "right",
  28244. "rightContext",
  28245. "rightDegrees",
  28246. "rightMargin",
  28247. "rightProjectionMatrix",
  28248. "rightViewMatrix",
  28249. "rlh",
  28250. "role",
  28251. "rolloffFactor",
  28252. "root",
  28253. "rootBounds",
  28254. "rootElement",
  28255. "rootMargin",
  28256. "rotate",
  28257. "rotateAxisAngle",
  28258. "rotateAxisAngleSelf",
  28259. "rotateFromVector",
  28260. "rotateFromVectorSelf",
  28261. "rotateSelf",
  28262. "rotation",
  28263. "rotationAngle",
  28264. "rotationRate",
  28265. "round",
  28266. "roundRect",
  28267. "row-gap",
  28268. "rowGap",
  28269. "rowIndex",
  28270. "rowSpan",
  28271. "rows",
  28272. "rowsPerImage",
  28273. "rtcpTransport",
  28274. "rtt",
  28275. "ruby-align",
  28276. "ruby-position",
  28277. "rubyAlign",
  28278. "rubyOverhang",
  28279. "rubyPosition",
  28280. "rules",
  28281. "run",
  28282. "runAdAuction",
  28283. "runtime",
  28284. "runtimeStyle",
  28285. "rx",
  28286. "ry",
  28287. "s",
  28288. "safari",
  28289. "sameDocument",
  28290. "sample",
  28291. "sampleCount",
  28292. "sampleCoverage",
  28293. "sampleInterval",
  28294. "sampleRate",
  28295. "sampleType",
  28296. "sampler",
  28297. "samplerParameterf",
  28298. "samplerParameteri",
  28299. "sandbox",
  28300. "save",
  28301. "saveAsPDF",
  28302. "saveData",
  28303. "scale",
  28304. "scale3d",
  28305. "scale3dSelf",
  28306. "scaleNonUniform",
  28307. "scaleNonUniformSelf",
  28308. "scaleSelf",
  28309. "scheduler",
  28310. "scheduling",
  28311. "scheme",
  28312. "scissor",
  28313. "scope",
  28314. "scopeName",
  28315. "scoped",
  28316. "screen",
  28317. "screenBrightness",
  28318. "screenEnabled",
  28319. "screenLeft",
  28320. "screenPixelToMillimeterX",
  28321. "screenPixelToMillimeterY",
  28322. "screenState",
  28323. "screenTop",
  28324. "screenX",
  28325. "screenY",
  28326. "screens",
  28327. "scriptURL",
  28328. "scripting",
  28329. "scripts",
  28330. "scroll",
  28331. "scroll-behavior",
  28332. "scroll-margin",
  28333. "scroll-margin-block",
  28334. "scroll-margin-block-end",
  28335. "scroll-margin-block-start",
  28336. "scroll-margin-bottom",
  28337. "scroll-margin-inline",
  28338. "scroll-margin-inline-end",
  28339. "scroll-margin-inline-start",
  28340. "scroll-margin-left",
  28341. "scroll-margin-right",
  28342. "scroll-margin-top",
  28343. "scroll-padding",
  28344. "scroll-padding-block",
  28345. "scroll-padding-block-end",
  28346. "scroll-padding-block-start",
  28347. "scroll-padding-bottom",
  28348. "scroll-padding-inline",
  28349. "scroll-padding-inline-end",
  28350. "scroll-padding-inline-start",
  28351. "scroll-padding-left",
  28352. "scroll-padding-right",
  28353. "scroll-padding-top",
  28354. "scroll-snap-align",
  28355. "scroll-snap-stop",
  28356. "scroll-snap-type",
  28357. "scrollAmount",
  28358. "scrollBehavior",
  28359. "scrollBy",
  28360. "scrollByLines",
  28361. "scrollByPages",
  28362. "scrollDelay",
  28363. "scrollHeight",
  28364. "scrollIntoView",
  28365. "scrollIntoViewIfNeeded",
  28366. "scrollLeft",
  28367. "scrollLeftMax",
  28368. "scrollMargin",
  28369. "scrollMarginBlock",
  28370. "scrollMarginBlockEnd",
  28371. "scrollMarginBlockStart",
  28372. "scrollMarginBottom",
  28373. "scrollMarginInline",
  28374. "scrollMarginInlineEnd",
  28375. "scrollMarginInlineStart",
  28376. "scrollMarginLeft",
  28377. "scrollMarginRight",
  28378. "scrollMarginTop",
  28379. "scrollMaxX",
  28380. "scrollMaxY",
  28381. "scrollPadding",
  28382. "scrollPaddingBlock",
  28383. "scrollPaddingBlockEnd",
  28384. "scrollPaddingBlockStart",
  28385. "scrollPaddingBottom",
  28386. "scrollPaddingInline",
  28387. "scrollPaddingInlineEnd",
  28388. "scrollPaddingInlineStart",
  28389. "scrollPaddingLeft",
  28390. "scrollPaddingRight",
  28391. "scrollPaddingTop",
  28392. "scrollRestoration",
  28393. "scrollSnapAlign",
  28394. "scrollSnapStop",
  28395. "scrollSnapType",
  28396. "scrollTo",
  28397. "scrollTop",
  28398. "scrollTopMax",
  28399. "scrollWidth",
  28400. "scrollX",
  28401. "scrollY",
  28402. "scrollbar-color",
  28403. "scrollbar-gutter",
  28404. "scrollbar-width",
  28405. "scrollbar3dLightColor",
  28406. "scrollbarArrowColor",
  28407. "scrollbarBaseColor",
  28408. "scrollbarColor",
  28409. "scrollbarDarkShadowColor",
  28410. "scrollbarFaceColor",
  28411. "scrollbarGutter",
  28412. "scrollbarHighlightColor",
  28413. "scrollbarShadowColor",
  28414. "scrollbarTrackColor",
  28415. "scrollbarWidth",
  28416. "scrollbars",
  28417. "scrolling",
  28418. "scrollingElement",
  28419. "sctp",
  28420. "sctpCauseCode",
  28421. "sdp",
  28422. "sdpLineNumber",
  28423. "sdpMLineIndex",
  28424. "sdpMid",
  28425. "seal",
  28426. "search",
  28427. "searchBox",
  28428. "searchBoxJavaBridge_",
  28429. "searchParams",
  28430. "sectionRowIndex",
  28431. "secureConnectionStart",
  28432. "security",
  28433. "seed",
  28434. "seek",
  28435. "seekToNextFrame",
  28436. "seekable",
  28437. "seeking",
  28438. "select",
  28439. "selectAllChildren",
  28440. "selectAlternateInterface",
  28441. "selectAudioOutput",
  28442. "selectConfiguration",
  28443. "selectNode",
  28444. "selectNodeContents",
  28445. "selectNodes",
  28446. "selectSingleNode",
  28447. "selectSubString",
  28448. "selectURL",
  28449. "selected",
  28450. "selectedIndex",
  28451. "selectedOptions",
  28452. "selectedStyleSheetSet",
  28453. "selectedStylesheetSet",
  28454. "selectedTrack",
  28455. "selection",
  28456. "selectionDirection",
  28457. "selectionEnd",
  28458. "selectionStart",
  28459. "selector",
  28460. "selectorText",
  28461. "self",
  28462. "send",
  28463. "sendAsBinary",
  28464. "sendBeacon",
  28465. "sendFeatureReport",
  28466. "sendMessage",
  28467. "sendNativeMessage",
  28468. "sendOrder",
  28469. "sendReport",
  28470. "sender",
  28471. "sentAlert",
  28472. "sentTimestamp",
  28473. "separator",
  28474. "serial",
  28475. "serialNumber",
  28476. "serializable",
  28477. "serializeToString",
  28478. "serverTiming",
  28479. "service",
  28480. "serviceWorker",
  28481. "session",
  28482. "sessionId",
  28483. "sessionStorage",
  28484. "sessions",
  28485. "set",
  28486. "setActionHandler",
  28487. "setActive",
  28488. "setAlpha",
  28489. "setAppBadge",
  28490. "setAttribute",
  28491. "setAttributeNS",
  28492. "setAttributeNode",
  28493. "setAttributeNodeNS",
  28494. "setAttributionReporting",
  28495. "setBadgeBackgroundColor",
  28496. "setBadgeText",
  28497. "setBadgeTextColor",
  28498. "setBaseAndExtent",
  28499. "setBigInt64",
  28500. "setBigUint64",
  28501. "setBindGroup",
  28502. "setBingCurrentSearchDefault",
  28503. "setBlendConstant",
  28504. "setCameraActive",
  28505. "setCapture",
  28506. "setCaptureHandleConfig",
  28507. "setCodecPreferences",
  28508. "setColor",
  28509. "setCompositeOperation",
  28510. "setConfiguration",
  28511. "setConsumer",
  28512. "setCurrentTime",
  28513. "setCustomValidity",
  28514. "setData",
  28515. "setDate",
  28516. "setDragImage",
  28517. "setEnabled",
  28518. "setEnd",
  28519. "setEndAfter",
  28520. "setEndBefore",
  28521. "setEndPoint",
  28522. "setExpires",
  28523. "setFillColor",
  28524. "setFilterRes",
  28525. "setFloat16",
  28526. "setFloat32",
  28527. "setFloat64",
  28528. "setFloatValue",
  28529. "setFocusBehavior",
  28530. "setFormValue",
  28531. "setFromBase64",
  28532. "setFromHex",
  28533. "setFullYear",
  28534. "setHTMLUnsafe",
  28535. "setHeaderExtensionsToNegotiate",
  28536. "setHeaderValue",
  28537. "setHours",
  28538. "setIcon",
  28539. "setIdentityProvider",
  28540. "setImmediate",
  28541. "setIndexBuffer",
  28542. "setInt16",
  28543. "setInt32",
  28544. "setInt8",
  28545. "setInterval",
  28546. "setItem",
  28547. "setKeyframes",
  28548. "setLineCap",
  28549. "setLineDash",
  28550. "setLineJoin",
  28551. "setLineWidth",
  28552. "setLiveSeekableRange",
  28553. "setLocalDescription",
  28554. "setMatrix",
  28555. "setMatrixValue",
  28556. "setMediaKeys",
  28557. "setMicrophoneActive",
  28558. "setMilliseconds",
  28559. "setMinutes",
  28560. "setMiterLimit",
  28561. "setMonth",
  28562. "setNamedItem",
  28563. "setNamedItemNS",
  28564. "setNonUserCodeExceptions",
  28565. "setOrientToAngle",
  28566. "setOrientToAuto",
  28567. "setOrientation",
  28568. "setOverrideHistoryNavigationMode",
  28569. "setPaint",
  28570. "setParameter",
  28571. "setParameters",
  28572. "setPeriodicWave",
  28573. "setPipeline",
  28574. "setPointerCapture",
  28575. "setPopup",
  28576. "setPosition",
  28577. "setPositionState",
  28578. "setPreference",
  28579. "setPriority",
  28580. "setPrivateToken",
  28581. "setProperty",
  28582. "setPrototypeOf",
  28583. "setRGBColor",
  28584. "setRGBColorICCColor",
  28585. "setRadius",
  28586. "setRangeText",
  28587. "setRemoteDescription",
  28588. "setReportEventDataForAutomaticBeacons",
  28589. "setRequestHeader",
  28590. "setResizable",
  28591. "setResourceTimingBufferSize",
  28592. "setRotate",
  28593. "setScale",
  28594. "setScissorRect",
  28595. "setSeconds",
  28596. "setSelectionRange",
  28597. "setServerCertificate",
  28598. "setShadow",
  28599. "setSharedStorageContext",
  28600. "setSignals",
  28601. "setSinkId",
  28602. "setSkewX",
  28603. "setSkewY",
  28604. "setStart",
  28605. "setStartAfter",
  28606. "setStartBefore",
  28607. "setStatus",
  28608. "setStdDeviation",
  28609. "setStencilReference",
  28610. "setStreams",
  28611. "setStrictMode",
  28612. "setStringValue",
  28613. "setStrokeColor",
  28614. "setSuggestResult",
  28615. "setTargetAtTime",
  28616. "setTargetValueAtTime",
  28617. "setTime",
  28618. "setTimeout",
  28619. "setTitle",
  28620. "setTransform",
  28621. "setTranslate",
  28622. "setUTCDate",
  28623. "setUTCFullYear",
  28624. "setUTCHours",
  28625. "setUTCMilliseconds",
  28626. "setUTCMinutes",
  28627. "setUTCMonth",
  28628. "setUTCSeconds",
  28629. "setUint16",
  28630. "setUint32",
  28631. "setUint8",
  28632. "setUninstallURL",
  28633. "setUpdateUrlData",
  28634. "setUri",
  28635. "setValidity",
  28636. "setValueAtTime",
  28637. "setValueCurveAtTime",
  28638. "setVariable",
  28639. "setVelocity",
  28640. "setVersion",
  28641. "setVertexBuffer",
  28642. "setViewport",
  28643. "setYear",
  28644. "setZoom",
  28645. "setZoomSettings",
  28646. "settingName",
  28647. "settingValue",
  28648. "sex",
  28649. "shaderLocation",
  28650. "shaderSource",
  28651. "shadowBlur",
  28652. "shadowColor",
  28653. "shadowOffsetX",
  28654. "shadowOffsetY",
  28655. "shadowRoot",
  28656. "shadowRootClonable",
  28657. "shadowRootDelegatesFocus",
  28658. "shadowRootMode",
  28659. "shadowRootSerializable",
  28660. "shape",
  28661. "shape-image-threshold",
  28662. "shape-margin",
  28663. "shape-outside",
  28664. "shape-rendering",
  28665. "shapeImageThreshold",
  28666. "shapeMargin",
  28667. "shapeOutside",
  28668. "shapeRendering",
  28669. "share",
  28670. "sharedStorage",
  28671. "sharedStorageWritable",
  28672. "sheet",
  28673. "shift",
  28674. "shiftKey",
  28675. "shiftLeft",
  28676. "shippingAddress",
  28677. "shippingOption",
  28678. "shippingType",
  28679. "show",
  28680. "showDirectoryPicker",
  28681. "showHelp",
  28682. "showModal",
  28683. "showModalDialog",
  28684. "showModelessDialog",
  28685. "showNotification",
  28686. "showOpenFilePicker",
  28687. "showPicker",
  28688. "showPopover",
  28689. "showSaveFilePicker",
  28690. "sidebar",
  28691. "sidebarAction",
  28692. "sign",
  28693. "signal",
  28694. "signalingState",
  28695. "signature",
  28696. "silent",
  28697. "sin",
  28698. "singleNodeValue",
  28699. "sinh",
  28700. "sinkId",
  28701. "sittingToStandingTransform",
  28702. "size",
  28703. "sizeAdjust",
  28704. "sizeToContent",
  28705. "sizeX",
  28706. "sizeZ",
  28707. "sizes",
  28708. "skewX",
  28709. "skewXSelf",
  28710. "skewY",
  28711. "skewYSelf",
  28712. "skipTransition",
  28713. "skipped",
  28714. "slice",
  28715. "slope",
  28716. "slot",
  28717. "slotAssignment",
  28718. "small",
  28719. "smil",
  28720. "smooth",
  28721. "smoothingTimeConstant",
  28722. "snapTargetBlock",
  28723. "snapTargetInline",
  28724. "snapToLines",
  28725. "snapshotItem",
  28726. "snapshotLength",
  28727. "some",
  28728. "sort",
  28729. "sortingCode",
  28730. "source",
  28731. "sourceBuffer",
  28732. "sourceBuffers",
  28733. "sourceCapabilities",
  28734. "sourceCharPosition",
  28735. "sourceFile",
  28736. "sourceFunctionName",
  28737. "sourceIndex",
  28738. "sourceMap",
  28739. "sourceURL",
  28740. "sources",
  28741. "spacing",
  28742. "span",
  28743. "speak",
  28744. "speakAs",
  28745. "speaking",
  28746. "species",
  28747. "specified",
  28748. "specularConstant",
  28749. "specularExponent",
  28750. "speechSynthesis",
  28751. "speed",
  28752. "speedOfSound",
  28753. "spellcheck",
  28754. "sphericalHarmonicsCoefficients",
  28755. "splice",
  28756. "split",
  28757. "splitText",
  28758. "spreadMethod",
  28759. "sqrt",
  28760. "src",
  28761. "srcElement",
  28762. "srcFactor",
  28763. "srcFilter",
  28764. "srcObject",
  28765. "srcUrn",
  28766. "srcdoc",
  28767. "srclang",
  28768. "srcset",
  28769. "stack",
  28770. "stackTraceLimit",
  28771. "stacktrace",
  28772. "stageParameters",
  28773. "standalone",
  28774. "standby",
  28775. "start",
  28776. "startContainer",
  28777. "startE",
  28778. "startIce",
  28779. "startLoadTime",
  28780. "startMessages",
  28781. "startNotifications",
  28782. "startOffset",
  28783. "startProfiling",
  28784. "startRendering",
  28785. "startShark",
  28786. "startTime",
  28787. "startViewTransition",
  28788. "startsWith",
  28789. "state",
  28790. "states",
  28791. "stats",
  28792. "status",
  28793. "statusCode",
  28794. "statusMessage",
  28795. "statusText",
  28796. "statusbar",
  28797. "stdDeviationX",
  28798. "stdDeviationY",
  28799. "stencilBack",
  28800. "stencilClearValue",
  28801. "stencilFront",
  28802. "stencilFunc",
  28803. "stencilFuncSeparate",
  28804. "stencilLoadOp",
  28805. "stencilMask",
  28806. "stencilMaskSeparate",
  28807. "stencilOp",
  28808. "stencilOpSeparate",
  28809. "stencilReadMask",
  28810. "stencilReadOnly",
  28811. "stencilStoreOp",
  28812. "stencilWriteMask",
  28813. "step",
  28814. "stepDown",
  28815. "stepMismatch",
  28816. "stepMode",
  28817. "stepUp",
  28818. "sticky",
  28819. "stitchTiles",
  28820. "stop",
  28821. "stop-color",
  28822. "stop-opacity",
  28823. "stopColor",
  28824. "stopImmediatePropagation",
  28825. "stopNotifications",
  28826. "stopOpacity",
  28827. "stopProfiling",
  28828. "stopPropagation",
  28829. "stopShark",
  28830. "stopped",
  28831. "storage",
  28832. "storageArea",
  28833. "storageBuckets",
  28834. "storageName",
  28835. "storageStatus",
  28836. "storageTexture",
  28837. "store",
  28838. "storeOp",
  28839. "storeSiteSpecificTrackingException",
  28840. "storeWebWideTrackingException",
  28841. "stpVersion",
  28842. "stream",
  28843. "streamErrorCode",
  28844. "streams",
  28845. "stretch",
  28846. "strike",
  28847. "string",
  28848. "stringValue",
  28849. "stringify",
  28850. "stripIndexFormat",
  28851. "stroke",
  28852. "stroke-dasharray",
  28853. "stroke-dashoffset",
  28854. "stroke-linecap",
  28855. "stroke-linejoin",
  28856. "stroke-miterlimit",
  28857. "stroke-opacity",
  28858. "stroke-width",
  28859. "strokeDasharray",
  28860. "strokeDashoffset",
  28861. "strokeLinecap",
  28862. "strokeLinejoin",
  28863. "strokeMiterlimit",
  28864. "strokeOpacity",
  28865. "strokeRect",
  28866. "strokeStyle",
  28867. "strokeText",
  28868. "strokeWidth",
  28869. "structuredClone",
  28870. "style",
  28871. "styleAndLayoutStart",
  28872. "styleFloat",
  28873. "styleMap",
  28874. "styleMedia",
  28875. "styleSheet",
  28876. "styleSheetSets",
  28877. "styleSheets",
  28878. "sub",
  28879. "subarray",
  28880. "subject",
  28881. "submit",
  28882. "submitFrame",
  28883. "submitter",
  28884. "subscribe",
  28885. "substr",
  28886. "substring",
  28887. "substringData",
  28888. "subtle",
  28889. "subtree",
  28890. "suffix",
  28891. "suffixes",
  28892. "summary",
  28893. "sup",
  28894. "supported",
  28895. "supportedContentEncodings",
  28896. "supportedEntryTypes",
  28897. "supportedValuesOf",
  28898. "supports",
  28899. "supportsFiber",
  28900. "supportsSession",
  28901. "supportsText",
  28902. "surfaceScale",
  28903. "surroundContents",
  28904. "suspend",
  28905. "suspendRedraw",
  28906. "svb",
  28907. "svh",
  28908. "svi",
  28909. "svmax",
  28910. "svmin",
  28911. "svw",
  28912. "swapCache",
  28913. "swapNode",
  28914. "sweepFlag",
  28915. "symbols",
  28916. "symmetricDifference",
  28917. "sync",
  28918. "syntax",
  28919. "sysexEnabled",
  28920. "system",
  28921. "systemCode",
  28922. "systemId",
  28923. "systemLanguage",
  28924. "systemXDPI",
  28925. "systemYDPI",
  28926. "tBodies",
  28927. "tFoot",
  28928. "tHead",
  28929. "tab",
  28930. "tab-size",
  28931. "tabId",
  28932. "tabIds",
  28933. "tabIndex",
  28934. "tabSize",
  28935. "table",
  28936. "table-layout",
  28937. "tableLayout",
  28938. "tableValues",
  28939. "tabs",
  28940. "tag",
  28941. "tagName",
  28942. "tagUrn",
  28943. "tags",
  28944. "taintEnabled",
  28945. "take",
  28946. "takePhoto",
  28947. "takeRecords",
  28948. "tan",
  28949. "tangentialPressure",
  28950. "tanh",
  28951. "target",
  28952. "targetAddressSpace",
  28953. "targetElement",
  28954. "targetRayMode",
  28955. "targetRaySpace",
  28956. "targetTouches",
  28957. "targetURL",
  28958. "targetX",
  28959. "targetY",
  28960. "targets",
  28961. "tcpType",
  28962. "tee",
  28963. "tel",
  28964. "telemetry",
  28965. "terminate",
  28966. "test",
  28967. "texImage2D",
  28968. "texImage3D",
  28969. "texParameterf",
  28970. "texParameteri",
  28971. "texStorage2D",
  28972. "texStorage3D",
  28973. "texSubImage2D",
  28974. "texSubImage3D",
  28975. "text",
  28976. "text-align",
  28977. "text-align-last",
  28978. "text-anchor",
  28979. "text-combine-upright",
  28980. "text-decoration",
  28981. "text-decoration-color",
  28982. "text-decoration-line",
  28983. "text-decoration-skip-ink",
  28984. "text-decoration-style",
  28985. "text-decoration-thickness",
  28986. "text-emphasis",
  28987. "text-emphasis-color",
  28988. "text-emphasis-position",
  28989. "text-emphasis-style",
  28990. "text-indent",
  28991. "text-justify",
  28992. "text-orientation",
  28993. "text-overflow",
  28994. "text-rendering",
  28995. "text-shadow",
  28996. "text-transform",
  28997. "text-underline-offset",
  28998. "text-underline-position",
  28999. "text-wrap",
  29000. "text-wrap-mode",
  29001. "text-wrap-style",
  29002. "textAlign",
  29003. "textAlignLast",
  29004. "textAnchor",
  29005. "textAutospace",
  29006. "textBaseline",
  29007. "textCombineUpright",
  29008. "textContent",
  29009. "textDecoration",
  29010. "textDecorationBlink",
  29011. "textDecorationColor",
  29012. "textDecorationLine",
  29013. "textDecorationLineThrough",
  29014. "textDecorationNone",
  29015. "textDecorationOverline",
  29016. "textDecorationSkipInk",
  29017. "textDecorationStyle",
  29018. "textDecorationThickness",
  29019. "textDecorationUnderline",
  29020. "textEmphasis",
  29021. "textEmphasisColor",
  29022. "textEmphasisPosition",
  29023. "textEmphasisStyle",
  29024. "textIndent",
  29025. "textJustify",
  29026. "textJustifyTrim",
  29027. "textKashida",
  29028. "textKashidaSpace",
  29029. "textLength",
  29030. "textOrientation",
  29031. "textOverflow",
  29032. "textRendering",
  29033. "textShadow",
  29034. "textTracks",
  29035. "textTransform",
  29036. "textUnderlineOffset",
  29037. "textUnderlinePosition",
  29038. "textWrap",
  29039. "textWrapMode",
  29040. "textWrapStyle",
  29041. "texture",
  29042. "theme",
  29043. "then",
  29044. "threadId",
  29045. "threshold",
  29046. "thresholds",
  29047. "throwIfAborted",
  29048. "tiltX",
  29049. "tiltY",
  29050. "time",
  29051. "timeEnd",
  29052. "timeLog",
  29053. "timeOrigin",
  29054. "timeRemaining",
  29055. "timeStamp",
  29056. "timecode",
  29057. "timeline",
  29058. "timelineTime",
  29059. "timeout",
  29060. "timestamp",
  29061. "timestampOffset",
  29062. "timestampWrites",
  29063. "timing",
  29064. "title",
  29065. "titlebarAreaRect",
  29066. "tlsChannelId",
  29067. "to",
  29068. "toArray",
  29069. "toBase64",
  29070. "toBlob",
  29071. "toDataURL",
  29072. "toDateString",
  29073. "toElement",
  29074. "toExponential",
  29075. "toFixed",
  29076. "toFloat32Array",
  29077. "toFloat64Array",
  29078. "toGMTString",
  29079. "toHex",
  29080. "toISOString",
  29081. "toJSON",
  29082. "toLocaleDateString",
  29083. "toLocaleFormat",
  29084. "toLocaleLowerCase",
  29085. "toLocaleString",
  29086. "toLocaleTimeString",
  29087. "toLocaleUpperCase",
  29088. "toLowerCase",
  29089. "toMatrix",
  29090. "toMethod",
  29091. "toPrecision",
  29092. "toPrimitive",
  29093. "toReversed",
  29094. "toSdp",
  29095. "toSorted",
  29096. "toSource",
  29097. "toSpliced",
  29098. "toStaticHTML",
  29099. "toString",
  29100. "toStringTag",
  29101. "toSum",
  29102. "toTimeString",
  29103. "toUTCString",
  29104. "toUpperCase",
  29105. "toWellFormed",
  29106. "toggle",
  29107. "toggleAttribute",
  29108. "toggleLongPressEnabled",
  29109. "togglePopover",
  29110. "toggleReaderMode",
  29111. "token",
  29112. "tone",
  29113. "toneBuffer",
  29114. "tooLong",
  29115. "tooShort",
  29116. "toolbar",
  29117. "top",
  29118. "topMargin",
  29119. "topSites",
  29120. "topology",
  29121. "total",
  29122. "totalFrameDelay",
  29123. "totalFrames",
  29124. "totalFramesDuration",
  29125. "totalVideoFrames",
  29126. "touch-action",
  29127. "touchAction",
  29128. "touched",
  29129. "touches",
  29130. "trace",
  29131. "track",
  29132. "trackVisibility",
  29133. "trackedAnchors",
  29134. "tracks",
  29135. "tran",
  29136. "transaction",
  29137. "transactions",
  29138. "transceiver",
  29139. "transfer",
  29140. "transferControlToOffscreen",
  29141. "transferFromImageBitmap",
  29142. "transferImageBitmap",
  29143. "transferIn",
  29144. "transferOut",
  29145. "transferSize",
  29146. "transferToFixedLength",
  29147. "transferToImageBitmap",
  29148. "transform",
  29149. "transform-box",
  29150. "transform-origin",
  29151. "transform-style",
  29152. "transformBox",
  29153. "transformFeedbackVaryings",
  29154. "transformOrigin",
  29155. "transformPoint",
  29156. "transformString",
  29157. "transformStyle",
  29158. "transformToDocument",
  29159. "transformToFragment",
  29160. "transition",
  29161. "transition-behavior",
  29162. "transition-delay",
  29163. "transition-duration",
  29164. "transition-property",
  29165. "transition-timing-function",
  29166. "transitionBehavior",
  29167. "transitionDelay",
  29168. "transitionDuration",
  29169. "transitionProperty",
  29170. "transitionTimingFunction",
  29171. "translate",
  29172. "translateSelf",
  29173. "translationX",
  29174. "translationY",
  29175. "transport",
  29176. "traverseTo",
  29177. "trim",
  29178. "trimEnd",
  29179. "trimLeft",
  29180. "trimRight",
  29181. "trimStart",
  29182. "trueSpeed",
  29183. "trunc",
  29184. "truncate",
  29185. "trustedTypes",
  29186. "try",
  29187. "turn",
  29188. "twist",
  29189. "type",
  29190. "typeDetail",
  29191. "typeMismatch",
  29192. "typeMustMatch",
  29193. "types",
  29194. "u2f",
  29195. "ubound",
  29196. "uint16",
  29197. "uint32",
  29198. "uint8",
  29199. "uint8Clamped",
  29200. "unadjustedMovement",
  29201. "unclippedDepth",
  29202. "unconfigure",
  29203. "undefined",
  29204. "underlineStyle",
  29205. "underlineThickness",
  29206. "unescape",
  29207. "uneval",
  29208. "ungroup",
  29209. "unicode",
  29210. "unicode-bidi",
  29211. "unicodeBidi",
  29212. "unicodeRange",
  29213. "unicodeSets",
  29214. "uniform1f",
  29215. "uniform1fv",
  29216. "uniform1i",
  29217. "uniform1iv",
  29218. "uniform1ui",
  29219. "uniform1uiv",
  29220. "uniform2f",
  29221. "uniform2fv",
  29222. "uniform2i",
  29223. "uniform2iv",
  29224. "uniform2ui",
  29225. "uniform2uiv",
  29226. "uniform3f",
  29227. "uniform3fv",
  29228. "uniform3i",
  29229. "uniform3iv",
  29230. "uniform3ui",
  29231. "uniform3uiv",
  29232. "uniform4f",
  29233. "uniform4fv",
  29234. "uniform4i",
  29235. "uniform4iv",
  29236. "uniform4ui",
  29237. "uniform4uiv",
  29238. "uniformBlockBinding",
  29239. "uniformMatrix2fv",
  29240. "uniformMatrix2x3fv",
  29241. "uniformMatrix2x4fv",
  29242. "uniformMatrix3fv",
  29243. "uniformMatrix3x2fv",
  29244. "uniformMatrix3x4fv",
  29245. "uniformMatrix4fv",
  29246. "uniformMatrix4x2fv",
  29247. "uniformMatrix4x3fv",
  29248. "uninstallSelf",
  29249. "union",
  29250. "unique",
  29251. "uniqueID",
  29252. "uniqueNumber",
  29253. "unit",
  29254. "unitType",
  29255. "units",
  29256. "unloadEventEnd",
  29257. "unloadEventStart",
  29258. "unlock",
  29259. "unmap",
  29260. "unmount",
  29261. "unobserve",
  29262. "unpackColorSpace",
  29263. "unpause",
  29264. "unpauseAnimations",
  29265. "unreadCount",
  29266. "unregister",
  29267. "unregisterContentHandler",
  29268. "unregisterProtocolHandler",
  29269. "unscopables",
  29270. "unselectable",
  29271. "unshift",
  29272. "unsubscribe",
  29273. "unsuspendRedraw",
  29274. "unsuspendRedrawAll",
  29275. "unwatch",
  29276. "unwrapKey",
  29277. "upDegrees",
  29278. "upX",
  29279. "upY",
  29280. "upZ",
  29281. "update",
  29282. "updateAdInterestGroups",
  29283. "updateCallbackDone",
  29284. "updateCharacterBounds",
  29285. "updateCommands",
  29286. "updateControlBounds",
  29287. "updateCurrentEntry",
  29288. "updateIce",
  29289. "updateInkTrailStartPoint",
  29290. "updateInterval",
  29291. "updatePlaybackRate",
  29292. "updateRangeEnd",
  29293. "updateRangeStart",
  29294. "updateRenderState",
  29295. "updateSelection",
  29296. "updateSelectionBounds",
  29297. "updateSettings",
  29298. "updateText",
  29299. "updateTiming",
  29300. "updateViaCache",
  29301. "updateWith",
  29302. "updated",
  29303. "updating",
  29304. "upgrade",
  29305. "upload",
  29306. "uploadTotal",
  29307. "uploaded",
  29308. "upper",
  29309. "upperBound",
  29310. "upperOpen",
  29311. "uri",
  29312. "url",
  29313. "urn",
  29314. "urns",
  29315. "usage",
  29316. "usages",
  29317. "usb",
  29318. "usbVersionMajor",
  29319. "usbVersionMinor",
  29320. "usbVersionSubminor",
  29321. "useCurrentView",
  29322. "useMap",
  29323. "useProgram",
  29324. "usedSpace",
  29325. "user-select",
  29326. "userActivation",
  29327. "userAgent",
  29328. "userAgentData",
  29329. "userChoice",
  29330. "userHandle",
  29331. "userHint",
  29332. "userInitiated",
  29333. "userLanguage",
  29334. "userSelect",
  29335. "userState",
  29336. "userVisibleOnly",
  29337. "username",
  29338. "usernameFragment",
  29339. "utterance",
  29340. "uuid",
  29341. "v8BreakIterator",
  29342. "vAlign",
  29343. "vLink",
  29344. "valid",
  29345. "validate",
  29346. "validateProgram",
  29347. "validationMessage",
  29348. "validity",
  29349. "value",
  29350. "valueAsDate",
  29351. "valueAsNumber",
  29352. "valueAsString",
  29353. "valueInSpecifiedUnits",
  29354. "valueMissing",
  29355. "valueOf",
  29356. "valueText",
  29357. "valueType",
  29358. "values",
  29359. "variable",
  29360. "variant",
  29361. "variationSettings",
  29362. "vb",
  29363. "vector-effect",
  29364. "vectorEffect",
  29365. "velocityAngular",
  29366. "velocityExpansion",
  29367. "velocityX",
  29368. "velocityY",
  29369. "vendor",
  29370. "vendorId",
  29371. "vendorSub",
  29372. "verify",
  29373. "version",
  29374. "vertex",
  29375. "vertexAttrib1f",
  29376. "vertexAttrib1fv",
  29377. "vertexAttrib2f",
  29378. "vertexAttrib2fv",
  29379. "vertexAttrib3f",
  29380. "vertexAttrib3fv",
  29381. "vertexAttrib4f",
  29382. "vertexAttrib4fv",
  29383. "vertexAttribDivisor",
  29384. "vertexAttribDivisorANGLE",
  29385. "vertexAttribI4i",
  29386. "vertexAttribI4iv",
  29387. "vertexAttribI4ui",
  29388. "vertexAttribI4uiv",
  29389. "vertexAttribIPointer",
  29390. "vertexAttribPointer",
  29391. "vertical",
  29392. "vertical-align",
  29393. "verticalAlign",
  29394. "verticalOverflow",
  29395. "vh",
  29396. "vi",
  29397. "vibrate",
  29398. "vibrationActuator",
  29399. "videoBitsPerSecond",
  29400. "videoHeight",
  29401. "videoTracks",
  29402. "videoWidth",
  29403. "view",
  29404. "viewBox",
  29405. "viewBoxString",
  29406. "viewDimension",
  29407. "viewFormats",
  29408. "viewTarget",
  29409. "viewTargetString",
  29410. "viewTransition",
  29411. "viewport",
  29412. "viewportAnchorX",
  29413. "viewportAnchorY",
  29414. "viewportElement",
  29415. "views",
  29416. "violatedDirective",
  29417. "virtualKeyboard",
  29418. "virtualKeyboardPolicy",
  29419. "visibility",
  29420. "visibilityState",
  29421. "visible",
  29422. "visibleRect",
  29423. "visualViewport",
  29424. "vlinkColor",
  29425. "vmax",
  29426. "vmin",
  29427. "voice",
  29428. "voiceURI",
  29429. "volume",
  29430. "vrml",
  29431. "vspace",
  29432. "vw",
  29433. "w",
  29434. "wait",
  29435. "waitAsync",
  29436. "waitSync",
  29437. "waiting",
  29438. "wake",
  29439. "wakeLock",
  29440. "wand",
  29441. "warmup",
  29442. "warn",
  29443. "wasAlternateProtocolAvailable",
  29444. "wasClean",
  29445. "wasDiscarded",
  29446. "wasFetchedViaSpdy",
  29447. "wasNpnNegotiated",
  29448. "watch",
  29449. "watchAvailability",
  29450. "watchPosition",
  29451. "webNavigation",
  29452. "webRequest",
  29453. "webdriver",
  29454. "webkitAddKey",
  29455. "webkitAlignContent",
  29456. "webkitAlignItems",
  29457. "webkitAlignSelf",
  29458. "webkitAnimation",
  29459. "webkitAnimationDelay",
  29460. "webkitAnimationDirection",
  29461. "webkitAnimationDuration",
  29462. "webkitAnimationFillMode",
  29463. "webkitAnimationIterationCount",
  29464. "webkitAnimationName",
  29465. "webkitAnimationPlayState",
  29466. "webkitAnimationTimingFunction",
  29467. "webkitAppearance",
  29468. "webkitAudioContext",
  29469. "webkitAudioDecodedByteCount",
  29470. "webkitAudioPannerNode",
  29471. "webkitBackfaceVisibility",
  29472. "webkitBackground",
  29473. "webkitBackgroundAttachment",
  29474. "webkitBackgroundClip",
  29475. "webkitBackgroundColor",
  29476. "webkitBackgroundImage",
  29477. "webkitBackgroundOrigin",
  29478. "webkitBackgroundPosition",
  29479. "webkitBackgroundPositionX",
  29480. "webkitBackgroundPositionY",
  29481. "webkitBackgroundRepeat",
  29482. "webkitBackgroundSize",
  29483. "webkitBackingStorePixelRatio",
  29484. "webkitBorderBottomLeftRadius",
  29485. "webkitBorderBottomRightRadius",
  29486. "webkitBorderImage",
  29487. "webkitBorderImageOutset",
  29488. "webkitBorderImageRepeat",
  29489. "webkitBorderImageSlice",
  29490. "webkitBorderImageSource",
  29491. "webkitBorderImageWidth",
  29492. "webkitBorderRadius",
  29493. "webkitBorderTopLeftRadius",
  29494. "webkitBorderTopRightRadius",
  29495. "webkitBoxAlign",
  29496. "webkitBoxDirection",
  29497. "webkitBoxFlex",
  29498. "webkitBoxOrdinalGroup",
  29499. "webkitBoxOrient",
  29500. "webkitBoxPack",
  29501. "webkitBoxShadow",
  29502. "webkitBoxSizing",
  29503. "webkitCancelAnimationFrame",
  29504. "webkitCancelFullScreen",
  29505. "webkitCancelKeyRequest",
  29506. "webkitCancelRequestAnimationFrame",
  29507. "webkitClearResourceTimings",
  29508. "webkitClipPath",
  29509. "webkitClosedCaptionsVisible",
  29510. "webkitConvertPointFromNodeToPage",
  29511. "webkitConvertPointFromPageToNode",
  29512. "webkitCreateShadowRoot",
  29513. "webkitCurrentFullScreenElement",
  29514. "webkitCurrentPlaybackTargetIsWireless",
  29515. "webkitDecodedFrameCount",
  29516. "webkitDirectionInvertedFromDevice",
  29517. "webkitDisplayingFullscreen",
  29518. "webkitDroppedFrameCount",
  29519. "webkitEnterFullScreen",
  29520. "webkitEnterFullscreen",
  29521. "webkitEntries",
  29522. "webkitExitFullScreen",
  29523. "webkitExitFullscreen",
  29524. "webkitExitPointerLock",
  29525. "webkitFilter",
  29526. "webkitFlex",
  29527. "webkitFlexBasis",
  29528. "webkitFlexDirection",
  29529. "webkitFlexFlow",
  29530. "webkitFlexGrow",
  29531. "webkitFlexShrink",
  29532. "webkitFlexWrap",
  29533. "webkitFontFeatureSettings",
  29534. "webkitFullScreenKeyboardInputAllowed",
  29535. "webkitFullscreenElement",
  29536. "webkitFullscreenEnabled",
  29537. "webkitGenerateKeyRequest",
  29538. "webkitGetAsEntry",
  29539. "webkitGetDatabaseNames",
  29540. "webkitGetEntries",
  29541. "webkitGetEntriesByName",
  29542. "webkitGetEntriesByType",
  29543. "webkitGetFlowByName",
  29544. "webkitGetGamepads",
  29545. "webkitGetImageDataHD",
  29546. "webkitGetNamedFlows",
  29547. "webkitGetRegionFlowRanges",
  29548. "webkitGetUserMedia",
  29549. "webkitHasClosedCaptions",
  29550. "webkitHidden",
  29551. "webkitIDBCursor",
  29552. "webkitIDBDatabase",
  29553. "webkitIDBDatabaseError",
  29554. "webkitIDBDatabaseException",
  29555. "webkitIDBFactory",
  29556. "webkitIDBIndex",
  29557. "webkitIDBKeyRange",
  29558. "webkitIDBObjectStore",
  29559. "webkitIDBRequest",
  29560. "webkitIDBTransaction",
  29561. "webkitImageSmoothingEnabled",
  29562. "webkitIndexedDB",
  29563. "webkitInitMessageEvent",
  29564. "webkitIsFullScreen",
  29565. "webkitJustifyContent",
  29566. "webkitKeys",
  29567. "webkitLineClamp",
  29568. "webkitLineDashOffset",
  29569. "webkitLockOrientation",
  29570. "webkitMask",
  29571. "webkitMaskClip",
  29572. "webkitMaskComposite",
  29573. "webkitMaskImage",
  29574. "webkitMaskOrigin",
  29575. "webkitMaskPosition",
  29576. "webkitMaskPositionX",
  29577. "webkitMaskPositionY",
  29578. "webkitMaskRepeat",
  29579. "webkitMaskSize",
  29580. "webkitMatchesSelector",
  29581. "webkitMediaStream",
  29582. "webkitNotifications",
  29583. "webkitOfflineAudioContext",
  29584. "webkitOrder",
  29585. "webkitOrientation",
  29586. "webkitPeerConnection00",
  29587. "webkitPersistentStorage",
  29588. "webkitPerspective",
  29589. "webkitPerspectiveOrigin",
  29590. "webkitPointerLockElement",
  29591. "webkitPostMessage",
  29592. "webkitPreservesPitch",
  29593. "webkitPutImageDataHD",
  29594. "webkitRTCPeerConnection",
  29595. "webkitRegionOverset",
  29596. "webkitRelativePath",
  29597. "webkitRequestAnimationFrame",
  29598. "webkitRequestFileSystem",
  29599. "webkitRequestFullScreen",
  29600. "webkitRequestFullscreen",
  29601. "webkitRequestPointerLock",
  29602. "webkitResolveLocalFileSystemURL",
  29603. "webkitSetMediaKeys",
  29604. "webkitSetResourceTimingBufferSize",
  29605. "webkitShadowRoot",
  29606. "webkitShowPlaybackTargetPicker",
  29607. "webkitSlice",
  29608. "webkitSpeechGrammar",
  29609. "webkitSpeechGrammarList",
  29610. "webkitSpeechRecognition",
  29611. "webkitSpeechRecognitionError",
  29612. "webkitSpeechRecognitionEvent",
  29613. "webkitStorageInfo",
  29614. "webkitSupportsFullscreen",
  29615. "webkitTemporaryStorage",
  29616. "webkitTextFillColor",
  29617. "webkitTextSecurity",
  29618. "webkitTextSizeAdjust",
  29619. "webkitTextStroke",
  29620. "webkitTextStrokeColor",
  29621. "webkitTextStrokeWidth",
  29622. "webkitTransform",
  29623. "webkitTransformOrigin",
  29624. "webkitTransformStyle",
  29625. "webkitTransition",
  29626. "webkitTransitionDelay",
  29627. "webkitTransitionDuration",
  29628. "webkitTransitionProperty",
  29629. "webkitTransitionTimingFunction",
  29630. "webkitURL",
  29631. "webkitUnlockOrientation",
  29632. "webkitUserSelect",
  29633. "webkitVideoDecodedByteCount",
  29634. "webkitVisibilityState",
  29635. "webkitWirelessVideoPlaybackDisabled",
  29636. "webkitdirectory",
  29637. "webkitdropzone",
  29638. "webstore",
  29639. "weight",
  29640. "wgslLanguageFeatures",
  29641. "whatToShow",
  29642. "wheelDelta",
  29643. "wheelDeltaX",
  29644. "wheelDeltaY",
  29645. "whenDefined",
  29646. "which",
  29647. "white-space",
  29648. "white-space-collapse",
  29649. "whiteSpace",
  29650. "whiteSpaceCollapse",
  29651. "wholeText",
  29652. "widows",
  29653. "width",
  29654. "will-change",
  29655. "willChange",
  29656. "willValidate",
  29657. "window",
  29658. "windowAttribution",
  29659. "windowControlsOverlay",
  29660. "windowId",
  29661. "windowIds",
  29662. "windows",
  29663. "with",
  29664. "withCredentials",
  29665. "withResolvers",
  29666. "word-break",
  29667. "word-spacing",
  29668. "word-wrap",
  29669. "wordBreak",
  29670. "wordSpacing",
  29671. "wordWrap",
  29672. "workerStart",
  29673. "worklet",
  29674. "wow64",
  29675. "wrap",
  29676. "wrapKey",
  29677. "writable",
  29678. "writableAuxiliaries",
  29679. "write",
  29680. "writeBuffer",
  29681. "writeMask",
  29682. "writeText",
  29683. "writeTexture",
  29684. "writeTimestamp",
  29685. "writeValue",
  29686. "writeValueWithResponse",
  29687. "writeValueWithoutResponse",
  29688. "writeWithoutResponse",
  29689. "writeln",
  29690. "writing-mode",
  29691. "writingMode",
  29692. "writingSuggestions",
  29693. "x",
  29694. "x1",
  29695. "x2",
  29696. "xChannelSelector",
  29697. "xmlEncoding",
  29698. "xmlStandalone",
  29699. "xmlVersion",
  29700. "xmlbase",
  29701. "xmllang",
  29702. "xmlspace",
  29703. "xor",
  29704. "xr",
  29705. "y",
  29706. "y1",
  29707. "y2",
  29708. "yChannelSelector",
  29709. "yandex",
  29710. "yield",
  29711. "z",
  29712. "z-index",
  29713. "zIndex",
  29714. "zoom",
  29715. "zoomAndPan",
  29716. "zoomRectScreen",
  29717. ];
  29718. /***********************************************************************
  29719. A JavaScript tokenizer / parser / beautifier / compressor.
  29720. https://github.com/mishoo/UglifyJS2
  29721. -------------------------------- (C) ---------------------------------
  29722. Author: Mihai Bazon
  29723. <mihai.bazon@gmail.com>
  29724. http://mihai.bazon.net/blog
  29725. Distributed under the BSD license:
  29726. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  29727. Redistribution and use in source and binary forms, with or without
  29728. modification, are permitted provided that the following conditions
  29729. are met:
  29730. * Redistributions of source code must retain the above
  29731. copyright notice, this list of conditions and the following
  29732. disclaimer.
  29733. * Redistributions in binary form must reproduce the above
  29734. copyright notice, this list of conditions and the following
  29735. disclaimer in the documentation and/or other materials
  29736. provided with the distribution.
  29737. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  29738. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29739. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29740. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29741. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  29742. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29743. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29744. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29745. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  29746. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29747. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29748. SUCH DAMAGE.
  29749. ***********************************************************************/
  29750. function find_builtins(reserved) {
  29751. domprops.forEach(add);
  29752. // Compatibility fix for some standard defined globals not defined on every js environment
  29753. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  29754. var objects = {};
  29755. var global_ref = typeof global === "object" ? global : self;
  29756. new_globals.forEach(function (new_global) {
  29757. objects[new_global] = global_ref[new_global] || function() {};
  29758. });
  29759. [
  29760. "null",
  29761. "true",
  29762. "false",
  29763. "NaN",
  29764. "Infinity",
  29765. "-Infinity",
  29766. "undefined",
  29767. ].forEach(add);
  29768. [ Object, Array, Function, Number,
  29769. String, Boolean, Error, Math,
  29770. Date, RegExp, objects.Symbol, ArrayBuffer,
  29771. DataView, decodeURI, decodeURIComponent,
  29772. encodeURI, encodeURIComponent, eval, EvalError,
  29773. Float32Array, Float64Array, Int8Array, Int16Array,
  29774. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  29775. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  29776. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  29777. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  29778. objects.WeakMap, objects.WeakSet
  29779. ].forEach(function(ctor) {
  29780. Object.getOwnPropertyNames(ctor).map(add);
  29781. if (ctor.prototype) {
  29782. Object.getOwnPropertyNames(ctor.prototype).map(add);
  29783. }
  29784. });
  29785. function add(name) {
  29786. reserved.add(name);
  29787. }
  29788. }
  29789. function reserve_quoted_keys(ast, reserved) {
  29790. function add(name) {
  29791. push_uniq(reserved, name);
  29792. }
  29793. ast.walk(new TreeWalker(function(node) {
  29794. if (node instanceof AST_ObjectKeyVal && node.quote) {
  29795. add(node.key);
  29796. } else if (node instanceof AST_ObjectProperty && node.quote) {
  29797. add(node.key.name);
  29798. } else if (node instanceof AST_Sub) {
  29799. addStrings(node.property, add);
  29800. }
  29801. }));
  29802. }
  29803. function addStrings(node, add) {
  29804. node.walk(new TreeWalker(function(node) {
  29805. if (node instanceof AST_Sequence) {
  29806. addStrings(node.tail_node(), add);
  29807. } else if (node instanceof AST_String) {
  29808. add(node.value);
  29809. } else if (node instanceof AST_Conditional) {
  29810. addStrings(node.consequent, add);
  29811. addStrings(node.alternative, add);
  29812. }
  29813. return true;
  29814. }));
  29815. }
  29816. function mangle_private_properties(ast, options) {
  29817. var cprivate = -1;
  29818. var private_cache = new Map();
  29819. var nth_identifier = options.nth_identifier || base54;
  29820. ast = ast.transform(new TreeTransformer(function(node) {
  29821. if (
  29822. node instanceof AST_ClassPrivateProperty
  29823. || node instanceof AST_PrivateMethod
  29824. || node instanceof AST_PrivateGetter
  29825. || node instanceof AST_PrivateSetter
  29826. || node instanceof AST_PrivateIn
  29827. ) {
  29828. node.key.name = mangle_private(node.key.name);
  29829. } else if (node instanceof AST_DotHash) {
  29830. node.property = mangle_private(node.property);
  29831. }
  29832. }));
  29833. return ast;
  29834. function mangle_private(name) {
  29835. let mangled = private_cache.get(name);
  29836. if (!mangled) {
  29837. mangled = nth_identifier.get(++cprivate);
  29838. private_cache.set(name, mangled);
  29839. }
  29840. return mangled;
  29841. }
  29842. }
  29843. function find_annotated_props(ast) {
  29844. var annotated_props = new Set();
  29845. walk(ast, node => {
  29846. if (
  29847. node instanceof AST_ClassPrivateProperty
  29848. || node instanceof AST_PrivateMethod
  29849. || node instanceof AST_PrivateGetter
  29850. || node instanceof AST_PrivateSetter
  29851. || node instanceof AST_DotHash
  29852. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29853. if (typeof node.key == "string" && has_annotation(node, _MANGLEPROP)) {
  29854. annotated_props.add(node.key);
  29855. }
  29856. } else if (node instanceof AST_ObjectProperty) {
  29857. // setter or getter, since KeyVal is handled above
  29858. if (has_annotation(node, _MANGLEPROP)) {
  29859. annotated_props.add(node.key.name);
  29860. }
  29861. } else if (node instanceof AST_Dot) {
  29862. if (has_annotation(node, _MANGLEPROP)) {
  29863. annotated_props.add(node.property);
  29864. }
  29865. } else if (node instanceof AST_Sub) {
  29866. if (node.property instanceof AST_String && has_annotation(node, _MANGLEPROP)) {
  29867. annotated_props.add(node.property.value);
  29868. }
  29869. }
  29870. });
  29871. return annotated_props;
  29872. }
  29873. function mangle_properties(ast, options, annotated_props = find_annotated_props(ast)) {
  29874. options = defaults(options, {
  29875. builtins: false,
  29876. cache: null,
  29877. debug: false,
  29878. keep_quoted: false,
  29879. nth_identifier: base54,
  29880. only_cache: false,
  29881. regex: null,
  29882. reserved: null,
  29883. undeclared: false,
  29884. only_annotated: false,
  29885. }, true);
  29886. var nth_identifier = options.nth_identifier;
  29887. var reserved_option = options.reserved;
  29888. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  29889. var reserved = new Set(reserved_option);
  29890. if (!options.builtins) find_builtins(reserved);
  29891. var cname = -1;
  29892. var cache;
  29893. if (options.cache) {
  29894. cache = options.cache.props;
  29895. } else {
  29896. cache = new Map();
  29897. }
  29898. var only_annotated = options.only_annotated;
  29899. var regex = options.regex && new RegExp(options.regex);
  29900. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  29901. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  29902. // the same as passing an empty string.
  29903. var debug = options.debug !== false;
  29904. var debug_name_suffix;
  29905. if (debug) {
  29906. debug_name_suffix = (options.debug === true ? "" : options.debug);
  29907. }
  29908. var names_to_mangle = new Set();
  29909. var unmangleable = new Set();
  29910. // Track each already-mangled name to prevent nth_identifier from generating
  29911. // the same name.
  29912. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  29913. var keep_quoted = !!options.keep_quoted;
  29914. // step 1: find candidates to mangle
  29915. ast.walk(new TreeWalker(function(node) {
  29916. if (
  29917. node instanceof AST_ClassPrivateProperty
  29918. || node instanceof AST_PrivateMethod
  29919. || node instanceof AST_PrivateGetter
  29920. || node instanceof AST_PrivateSetter
  29921. || node instanceof AST_DotHash
  29922. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29923. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  29924. add(node.key);
  29925. }
  29926. } else if (node instanceof AST_ObjectProperty) {
  29927. // setter or getter, since KeyVal is handled above
  29928. if (!keep_quoted || !node.quote) {
  29929. add(node.key.name);
  29930. }
  29931. } else if (node instanceof AST_Dot) {
  29932. var declared = !!options.undeclared;
  29933. if (!declared) {
  29934. var root = node;
  29935. while (root.expression) {
  29936. root = root.expression;
  29937. }
  29938. declared = !(root.thedef && root.thedef.undeclared);
  29939. }
  29940. if (declared &&
  29941. (!keep_quoted || !node.quote)) {
  29942. add(node.property);
  29943. }
  29944. } else if (node instanceof AST_Sub) {
  29945. if (!keep_quoted) {
  29946. addStrings(node.property, add);
  29947. }
  29948. } else if (node instanceof AST_Call
  29949. && node.expression.print_to_string() == "Object.defineProperty") {
  29950. addStrings(node.args[1], add);
  29951. } else if (node instanceof AST_Binary && node.operator === "in") {
  29952. addStrings(node.left, add);
  29953. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  29954. add(node.value);
  29955. }
  29956. }));
  29957. // step 2: transform the tree, renaming properties
  29958. return ast.transform(new TreeTransformer(function(node) {
  29959. if (
  29960. node instanceof AST_ClassPrivateProperty
  29961. || node instanceof AST_PrivateMethod
  29962. || node instanceof AST_PrivateGetter
  29963. || node instanceof AST_PrivateSetter
  29964. || node instanceof AST_DotHash
  29965. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29966. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  29967. node.key = mangle(node.key);
  29968. }
  29969. } else if (node instanceof AST_ObjectProperty) {
  29970. // setter, getter, method or class field
  29971. if (!keep_quoted || !node.quote) {
  29972. if (!node.computed_key()) {
  29973. node.key.name = mangle(node.key.name);
  29974. }
  29975. }
  29976. } else if (node instanceof AST_Dot) {
  29977. if (!keep_quoted || !node.quote) {
  29978. node.property = mangle(node.property);
  29979. }
  29980. } else if (!keep_quoted && node instanceof AST_Sub) {
  29981. node.property = mangleStrings(node.property);
  29982. } else if (node instanceof AST_Call
  29983. && node.expression.print_to_string() == "Object.defineProperty") {
  29984. node.args[1] = mangleStrings(node.args[1]);
  29985. } else if (node instanceof AST_Binary && node.operator === "in") {
  29986. node.left = mangleStrings(node.left);
  29987. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  29988. // Clear _KEY annotation to prevent double mangling
  29989. clear_annotation(node, _KEY);
  29990. node.value = mangle(node.value);
  29991. }
  29992. }));
  29993. // only function declarations after this line
  29994. function can_mangle(name) {
  29995. if (unmangleable.has(name)) return false;
  29996. if (reserved.has(name)) return false;
  29997. if (options.only_cache) {
  29998. return cache.has(name);
  29999. }
  30000. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  30001. return true;
  30002. }
  30003. function should_mangle(name) {
  30004. if (only_annotated && !annotated_props.has(name)) return false;
  30005. if (regex && !regex.test(name)) {
  30006. return annotated_props.has(name);
  30007. }
  30008. if (reserved.has(name)) return false;
  30009. return cache.has(name)
  30010. || names_to_mangle.has(name);
  30011. }
  30012. function add(name) {
  30013. if (can_mangle(name)) {
  30014. names_to_mangle.add(name);
  30015. }
  30016. if (!should_mangle(name)) {
  30017. unmangleable.add(name);
  30018. }
  30019. }
  30020. function mangle(name) {
  30021. if (!should_mangle(name)) {
  30022. return name;
  30023. }
  30024. var mangled = cache.get(name);
  30025. if (!mangled) {
  30026. if (debug) {
  30027. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  30028. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  30029. if (can_mangle(debug_mangled)) {
  30030. mangled = debug_mangled;
  30031. }
  30032. }
  30033. // either debug mode is off, or it is on and we could not use the mangled name
  30034. if (!mangled) {
  30035. do {
  30036. mangled = nth_identifier.get(++cname);
  30037. } while (!can_mangle(mangled));
  30038. }
  30039. cache.set(name, mangled);
  30040. }
  30041. return mangled;
  30042. }
  30043. function mangleStrings(node) {
  30044. return node.transform(new TreeTransformer(function(node) {
  30045. if (node instanceof AST_Sequence) {
  30046. var last = node.expressions.length - 1;
  30047. node.expressions[last] = mangleStrings(node.expressions[last]);
  30048. } else if (node instanceof AST_String) {
  30049. // Clear _KEY annotation to prevent double mangling
  30050. clear_annotation(node, _KEY);
  30051. node.value = mangle(node.value);
  30052. } else if (node instanceof AST_Conditional) {
  30053. node.consequent = mangleStrings(node.consequent);
  30054. node.alternative = mangleStrings(node.alternative);
  30055. }
  30056. return node;
  30057. }));
  30058. }
  30059. }
  30060. // to/from base64 functions
  30061. // Prefer built-in Buffer, if available, then use hack
  30062. // https://developer.mozilla.org/en-US/docs/Glossary/Base64#The_Unicode_Problem
  30063. var to_ascii = typeof Buffer !== "undefined"
  30064. ? (b64) => Buffer.from(b64, "base64").toString()
  30065. : (b64) => decodeURIComponent(escape(atob(b64)));
  30066. var to_base64 = typeof Buffer !== "undefined"
  30067. ? (str) => Buffer.from(str).toString("base64")
  30068. : (str) => btoa(unescape(encodeURIComponent(str)));
  30069. function read_source_map(code) {
  30070. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  30071. if (!match) {
  30072. console.warn("inline source map not found");
  30073. return null;
  30074. }
  30075. return to_ascii(match[2]);
  30076. }
  30077. function set_shorthand(name, options, keys) {
  30078. if (options[name]) {
  30079. keys.forEach(function(key) {
  30080. if (options[key]) {
  30081. if (typeof options[key] != "object") options[key] = {};
  30082. if (!(name in options[key])) options[key][name] = options[name];
  30083. }
  30084. });
  30085. }
  30086. }
  30087. function init_cache(cache) {
  30088. if (!cache) return;
  30089. if (!("props" in cache)) {
  30090. cache.props = new Map();
  30091. } else if (!(cache.props instanceof Map)) {
  30092. cache.props = map_from_object(cache.props);
  30093. }
  30094. }
  30095. function cache_to_json(cache) {
  30096. return {
  30097. props: map_to_object(cache.props)
  30098. };
  30099. }
  30100. function log_input(files, options, fs, debug_folder) {
  30101. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  30102. return;
  30103. }
  30104. try {
  30105. fs.mkdirSync(debug_folder);
  30106. } catch (e) {
  30107. if (e.code !== "EEXIST") throw e;
  30108. }
  30109. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  30110. options = options || {};
  30111. const options_str = JSON.stringify(options, (_key, thing) => {
  30112. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  30113. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  30114. return thing;
  30115. }, 4);
  30116. const files_str = (file) => {
  30117. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  30118. return JSON.stringify(file, null, 2);
  30119. } else if (typeof file === "object") {
  30120. return Object.keys(file)
  30121. .map((key) => key + ": " + files_str(file[key]))
  30122. .join("\n\n");
  30123. } else if (typeof file === "string") {
  30124. return "```\n" + file + "\n```";
  30125. } else {
  30126. return file; // What do?
  30127. }
  30128. };
  30129. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  30130. }
  30131. function* minify_sync_or_async(files, options, _fs_module) {
  30132. if (
  30133. _fs_module
  30134. && typeof process === "object"
  30135. && process.env
  30136. && typeof process.env.TERSER_DEBUG_DIR === "string"
  30137. ) {
  30138. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  30139. }
  30140. options = defaults(options, {
  30141. compress: {},
  30142. ecma: undefined,
  30143. enclose: false,
  30144. ie8: false,
  30145. keep_classnames: undefined,
  30146. keep_fnames: false,
  30147. mangle: {},
  30148. module: false,
  30149. nameCache: null,
  30150. output: null,
  30151. format: null,
  30152. parse: {},
  30153. rename: undefined,
  30154. safari10: false,
  30155. sourceMap: false,
  30156. spidermonkey: false,
  30157. timings: false,
  30158. toplevel: false,
  30159. warnings: false,
  30160. wrap: false,
  30161. }, true);
  30162. var timings = options.timings && {
  30163. start: Date.now()
  30164. };
  30165. if (options.keep_classnames === undefined) {
  30166. options.keep_classnames = options.keep_fnames;
  30167. }
  30168. if (options.rename === undefined) {
  30169. options.rename = options.compress && options.mangle;
  30170. }
  30171. if (options.output && options.format) {
  30172. throw new Error("Please only specify either output or format option, preferrably format.");
  30173. }
  30174. options.format = options.format || options.output || {};
  30175. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  30176. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  30177. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  30178. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  30179. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  30180. set_shorthand("safari10", options, [ "mangle", "format" ]);
  30181. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  30182. set_shorthand("warnings", options, [ "compress" ]); // legacy
  30183. var quoted_props;
  30184. if (options.mangle) {
  30185. options.mangle = defaults(options.mangle, {
  30186. cache: options.nameCache && (options.nameCache.vars || {}),
  30187. eval: false,
  30188. ie8: false,
  30189. keep_classnames: false,
  30190. keep_fnames: false,
  30191. module: false,
  30192. nth_identifier: base54,
  30193. properties: false,
  30194. reserved: [],
  30195. safari10: false,
  30196. toplevel: false,
  30197. }, true);
  30198. if (options.mangle.properties) {
  30199. if (typeof options.mangle.properties != "object") {
  30200. options.mangle.properties = {};
  30201. }
  30202. if (options.mangle.properties.keep_quoted) {
  30203. quoted_props = options.mangle.properties.reserved;
  30204. if (!Array.isArray(quoted_props)) quoted_props = [];
  30205. options.mangle.properties.reserved = quoted_props;
  30206. }
  30207. if (options.nameCache && !("cache" in options.mangle.properties)) {
  30208. options.mangle.properties.cache = options.nameCache.props || {};
  30209. }
  30210. }
  30211. init_cache(options.mangle.cache);
  30212. init_cache(options.mangle.properties.cache);
  30213. }
  30214. if (options.sourceMap) {
  30215. options.sourceMap = defaults(options.sourceMap, {
  30216. asObject: false,
  30217. content: null,
  30218. filename: null,
  30219. includeSources: false,
  30220. root: null,
  30221. url: null,
  30222. }, true);
  30223. }
  30224. // -- Parse phase --
  30225. if (timings) timings.parse = Date.now();
  30226. var toplevel;
  30227. if (files instanceof AST_Toplevel) {
  30228. toplevel = files;
  30229. } else {
  30230. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  30231. files = [ files ];
  30232. }
  30233. options.parse = options.parse || {};
  30234. options.parse.toplevel = null;
  30235. if (options.parse.spidermonkey) {
  30236. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  30237. if (!toplevel) return files[name];
  30238. toplevel.body = toplevel.body.concat(files[name].body);
  30239. return toplevel;
  30240. }, null));
  30241. } else {
  30242. delete options.parse.spidermonkey;
  30243. for (var name in files) if (HOP(files, name)) {
  30244. options.parse.filename = name;
  30245. options.parse.toplevel = parse(files[name], options.parse);
  30246. if (options.sourceMap && options.sourceMap.content == "inline") {
  30247. if (Object.keys(files).length > 1)
  30248. throw new Error("inline source map only works with singular input");
  30249. options.sourceMap.content = read_source_map(files[name]);
  30250. }
  30251. }
  30252. }
  30253. if (options.parse.toplevel === null) {
  30254. throw new Error("no source file given");
  30255. }
  30256. toplevel = options.parse.toplevel;
  30257. }
  30258. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  30259. reserve_quoted_keys(toplevel, quoted_props);
  30260. }
  30261. var annotated_props;
  30262. if (options.mangle && options.mangle.properties) {
  30263. annotated_props = find_annotated_props(toplevel);
  30264. }
  30265. if (options.wrap) {
  30266. toplevel = toplevel.wrap_commonjs(options.wrap);
  30267. }
  30268. if (options.enclose) {
  30269. toplevel = toplevel.wrap_enclose(options.enclose);
  30270. }
  30271. if (timings) timings.rename = Date.now();
  30272. // -- Compress phase --
  30273. if (timings) timings.compress = Date.now();
  30274. if (options.compress) {
  30275. toplevel = new Compressor(options.compress, {
  30276. mangle_options: options.mangle
  30277. }).compress(toplevel);
  30278. }
  30279. // -- Mangle phase --
  30280. if (timings) timings.scope = Date.now();
  30281. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  30282. if (timings) timings.mangle = Date.now();
  30283. if (options.mangle) {
  30284. toplevel.compute_char_frequency(options.mangle);
  30285. toplevel.mangle_names(options.mangle);
  30286. toplevel = mangle_private_properties(toplevel, options.mangle);
  30287. }
  30288. if (timings) timings.properties = Date.now();
  30289. if (options.mangle && options.mangle.properties) {
  30290. toplevel = mangle_properties(toplevel, options.mangle.properties, annotated_props);
  30291. }
  30292. // Format phase
  30293. if (timings) timings.format = Date.now();
  30294. var result = {};
  30295. if (options.format.ast) {
  30296. result.ast = toplevel;
  30297. }
  30298. if (options.format.spidermonkey) {
  30299. result.ast = toplevel.to_mozilla_ast();
  30300. }
  30301. let format_options;
  30302. if (!HOP(options.format, "code") || options.format.code) {
  30303. // Make a shallow copy so that we can modify without mutating the user's input.
  30304. format_options = {...options.format};
  30305. if (!format_options.ast) {
  30306. // Destroy stuff to save RAM. (unless the deprecated `ast` option is on)
  30307. format_options._destroy_ast = true;
  30308. walk(toplevel, node => {
  30309. if (node instanceof AST_Scope) {
  30310. node.variables = undefined;
  30311. node.enclosed = undefined;
  30312. node.parent_scope = undefined;
  30313. }
  30314. if (node.block_scope) {
  30315. node.block_scope.variables = undefined;
  30316. node.block_scope.enclosed = undefined;
  30317. node.block_scope.parent_scope = undefined;
  30318. }
  30319. });
  30320. }
  30321. if (options.sourceMap) {
  30322. if (options.sourceMap.includeSources && files instanceof AST_Toplevel) {
  30323. throw new Error("original source content unavailable");
  30324. }
  30325. format_options.source_map = yield* SourceMap({
  30326. file: options.sourceMap.filename,
  30327. orig: options.sourceMap.content,
  30328. root: options.sourceMap.root,
  30329. files: options.sourceMap.includeSources ? files : null,
  30330. });
  30331. }
  30332. delete format_options.ast;
  30333. delete format_options.code;
  30334. delete format_options.spidermonkey;
  30335. var stream = OutputStream(format_options);
  30336. toplevel.print(stream);
  30337. result.code = stream.get();
  30338. if (options.sourceMap) {
  30339. Object.defineProperty(result, "map", {
  30340. configurable: true,
  30341. enumerable: true,
  30342. get() {
  30343. const map = format_options.source_map.getEncoded();
  30344. return (result.map = options.sourceMap.asObject ? map : JSON.stringify(map));
  30345. },
  30346. set(value) {
  30347. Object.defineProperty(result, "map", {
  30348. value,
  30349. writable: true,
  30350. });
  30351. }
  30352. });
  30353. result.decoded_map = format_options.source_map.getDecoded();
  30354. if (options.sourceMap.url == "inline") {
  30355. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  30356. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  30357. } else if (options.sourceMap.url) {
  30358. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  30359. }
  30360. }
  30361. }
  30362. if (options.nameCache && options.mangle) {
  30363. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  30364. if (options.mangle.properties && options.mangle.properties.cache) {
  30365. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  30366. }
  30367. }
  30368. if (format_options && format_options.source_map) {
  30369. format_options.source_map.destroy();
  30370. }
  30371. if (timings) {
  30372. timings.end = Date.now();
  30373. result.timings = {
  30374. parse: 1e-3 * (timings.rename - timings.parse),
  30375. rename: 1e-3 * (timings.compress - timings.rename),
  30376. compress: 1e-3 * (timings.scope - timings.compress),
  30377. scope: 1e-3 * (timings.mangle - timings.scope),
  30378. mangle: 1e-3 * (timings.properties - timings.mangle),
  30379. properties: 1e-3 * (timings.format - timings.properties),
  30380. format: 1e-3 * (timings.end - timings.format),
  30381. total: 1e-3 * (timings.end - timings.start)
  30382. };
  30383. }
  30384. return result;
  30385. }
  30386. async function minify(files, options, _fs_module) {
  30387. const gen = minify_sync_or_async(files, options, _fs_module);
  30388. let yielded;
  30389. let val;
  30390. do {
  30391. val = gen.next(await yielded);
  30392. yielded = val.value;
  30393. } while (!val.done);
  30394. return val.value;
  30395. }
  30396. function minify_sync(files, options, _fs_module) {
  30397. const gen = minify_sync_or_async(files, options, _fs_module);
  30398. let yielded;
  30399. let val;
  30400. do {
  30401. if (yielded && typeof yielded.then === "function") {
  30402. throw new Error("minify_sync cannot be used with the legacy source-map module");
  30403. }
  30404. val = gen.next(yielded);
  30405. yielded = val.value;
  30406. } while (!val.done);
  30407. return val.value;
  30408. }
  30409. async function run_cli({ program, packageJson, fs, path }) {
  30410. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  30411. var files = {};
  30412. var options = {
  30413. compress: false,
  30414. mangle: false
  30415. };
  30416. const default_options = await _default_options();
  30417. program.version(packageJson.name + " " + packageJson.version);
  30418. program.parseArgv = program.parse;
  30419. program.parse = undefined;
  30420. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  30421. else if (process.argv.includes("options")) program.helpInformation = function() {
  30422. var text = [];
  30423. for (var option in default_options) {
  30424. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  30425. text.push(format_object(default_options[option]));
  30426. text.push("");
  30427. }
  30428. return text.join("\n");
  30429. };
  30430. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  30431. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  30432. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  30433. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  30434. program.option("-f, --format [options]", "Format options.", parse_js());
  30435. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  30436. program.option("-o, --output <file>", "Output file (default STDOUT).");
  30437. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  30438. program.option("--config-file <file>", "Read minify() options from JSON file.");
  30439. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  30440. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  30441. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  30442. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  30443. program.option("--keep-classnames", "Do not mangle/drop class names.");
  30444. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  30445. program.option("--module", "Input is an ES6 module");
  30446. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  30447. program.option("--rename", "Force symbol expansion.");
  30448. program.option("--no-rename", "Disable symbol expansion.");
  30449. program.option("--safari10", "Support non-standard Safari 10.");
  30450. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  30451. program.option("--timings", "Display operations run time on STDERR.");
  30452. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  30453. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  30454. program.arguments("[files...]").parseArgv(process.argv);
  30455. if (program.configFile) {
  30456. options = JSON.parse(read_file(program.configFile));
  30457. }
  30458. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  30459. fatal("ERROR: cannot write source map to STDOUT");
  30460. }
  30461. [
  30462. "compress",
  30463. "enclose",
  30464. "ie8",
  30465. "mangle",
  30466. "module",
  30467. "safari10",
  30468. "sourceMap",
  30469. "toplevel",
  30470. "wrap"
  30471. ].forEach(function(name) {
  30472. if (name in program) {
  30473. options[name] = program[name];
  30474. }
  30475. });
  30476. if ("ecma" in program) {
  30477. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  30478. const ecma = program.ecma | 0;
  30479. if (ecma > 5 && ecma < 2015)
  30480. options.ecma = ecma + 2009;
  30481. else
  30482. options.ecma = ecma;
  30483. }
  30484. if (program.format || program.beautify) {
  30485. const chosenOption = program.format || program.beautify;
  30486. options.format = typeof chosenOption === "object" ? chosenOption : {};
  30487. }
  30488. if (program.comments) {
  30489. if (typeof options.format != "object") options.format = {};
  30490. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  30491. }
  30492. if (program.define) {
  30493. if (typeof options.compress != "object") options.compress = {};
  30494. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  30495. for (var expr in program.define) {
  30496. options.compress.global_defs[expr] = program.define[expr];
  30497. }
  30498. }
  30499. if (program.keepClassnames) {
  30500. options.keep_classnames = true;
  30501. }
  30502. if (program.keepFnames) {
  30503. options.keep_fnames = true;
  30504. }
  30505. if (program.mangleProps) {
  30506. if (program.mangleProps.domprops) {
  30507. delete program.mangleProps.domprops;
  30508. } else {
  30509. if (typeof program.mangleProps != "object") program.mangleProps = {};
  30510. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  30511. }
  30512. if (typeof options.mangle != "object") options.mangle = {};
  30513. options.mangle.properties = program.mangleProps;
  30514. }
  30515. if (program.nameCache) {
  30516. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  30517. }
  30518. if (program.output == "ast") {
  30519. options.format = {
  30520. ast: true,
  30521. code: false
  30522. };
  30523. }
  30524. if (program.parse) {
  30525. if (!program.parse.acorn && !program.parse.spidermonkey) {
  30526. options.parse = program.parse;
  30527. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  30528. fatal("ERROR: inline source map only works with built-in parser");
  30529. }
  30530. }
  30531. if (~program.rawArgs.indexOf("--rename")) {
  30532. options.rename = true;
  30533. } else if (!program.rename) {
  30534. options.rename = false;
  30535. }
  30536. let convert_path = name => name;
  30537. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  30538. convert_path = function() {
  30539. var base = program.sourceMap.base;
  30540. delete options.sourceMap.base;
  30541. return function(name) {
  30542. return path.relative(base, name);
  30543. };
  30544. }();
  30545. }
  30546. let filesList;
  30547. if (options.files && options.files.length) {
  30548. filesList = options.files;
  30549. delete options.files;
  30550. } else if (program.args.length) {
  30551. filesList = program.args;
  30552. }
  30553. if (filesList) {
  30554. simple_glob(filesList).forEach(function(name) {
  30555. files[convert_path(name)] = read_file(name);
  30556. });
  30557. } else {
  30558. await new Promise((resolve) => {
  30559. var chunks = [];
  30560. process.stdin.setEncoding("utf8");
  30561. process.stdin.on("data", function(chunk) {
  30562. chunks.push(chunk);
  30563. }).on("end", function() {
  30564. files = [ chunks.join("") ];
  30565. resolve();
  30566. });
  30567. process.stdin.resume();
  30568. });
  30569. }
  30570. await run_cli();
  30571. function convert_ast(fn) {
  30572. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  30573. }
  30574. async function run_cli() {
  30575. var content = program.sourceMap && program.sourceMap.content;
  30576. if (content && content !== "inline") {
  30577. options.sourceMap.content = read_file(content, content);
  30578. }
  30579. if (program.timings) options.timings = true;
  30580. try {
  30581. if (program.parse) {
  30582. if (program.parse.acorn) {
  30583. files = convert_ast(function(toplevel, name) {
  30584. return require("acorn").parse(files[name], {
  30585. ecmaVersion: 2018,
  30586. locations: true,
  30587. program: toplevel,
  30588. sourceFile: name,
  30589. sourceType: options.module || program.parse.module ? "module" : "script"
  30590. });
  30591. });
  30592. } else if (program.parse.spidermonkey) {
  30593. files = convert_ast(function(toplevel, name) {
  30594. var obj = JSON.parse(files[name]);
  30595. if (!toplevel) return obj;
  30596. toplevel.body = toplevel.body.concat(obj.body);
  30597. return toplevel;
  30598. });
  30599. }
  30600. }
  30601. } catch (ex) {
  30602. fatal(ex);
  30603. }
  30604. let result;
  30605. try {
  30606. result = await minify(files, options, fs);
  30607. } catch (ex) {
  30608. if (ex.name == "SyntaxError") {
  30609. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  30610. var col = ex.col;
  30611. var lines = files[ex.filename].split(/\r?\n/);
  30612. var line = lines[ex.line - 1];
  30613. if (!line && !col) {
  30614. line = lines[ex.line - 2];
  30615. col = line.length;
  30616. }
  30617. if (line) {
  30618. var limit = 70;
  30619. if (col > limit) {
  30620. line = line.slice(col - limit);
  30621. col = limit;
  30622. }
  30623. print_error(line.slice(0, 80));
  30624. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  30625. }
  30626. }
  30627. if (ex.defs) {
  30628. print_error("Supported options:");
  30629. print_error(format_object(ex.defs));
  30630. }
  30631. fatal(ex);
  30632. return;
  30633. }
  30634. if (program.output == "ast") {
  30635. if (!options.compress && !options.mangle) {
  30636. result.ast.figure_out_scope({});
  30637. }
  30638. console.log(JSON.stringify(result.ast, function(key, value) {
  30639. if (value) switch (key) {
  30640. case "thedef":
  30641. return symdef(value);
  30642. case "enclosed":
  30643. return value.length ? value.map(symdef) : undefined;
  30644. case "variables":
  30645. case "globals":
  30646. return value.size ? collect_from_map(value, symdef) : undefined;
  30647. }
  30648. if (skip_keys.has(key)) return;
  30649. if (value instanceof AST_Token) return;
  30650. if (value instanceof Map) return;
  30651. if (value instanceof AST_Node) {
  30652. var result = {
  30653. _class: "AST_" + value.TYPE
  30654. };
  30655. if (value.block_scope) {
  30656. result.variables = value.block_scope.variables;
  30657. result.enclosed = value.block_scope.enclosed;
  30658. }
  30659. value.CTOR.PROPS.forEach(function(prop) {
  30660. if (prop !== "block_scope") {
  30661. result[prop] = value[prop];
  30662. }
  30663. });
  30664. return result;
  30665. }
  30666. return value;
  30667. }, 2));
  30668. } else if (program.output == "spidermonkey") {
  30669. try {
  30670. const minified = await minify(
  30671. result.code,
  30672. {
  30673. compress: false,
  30674. mangle: false,
  30675. format: {
  30676. ast: true,
  30677. code: false
  30678. }
  30679. },
  30680. fs
  30681. );
  30682. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  30683. } catch (ex) {
  30684. fatal(ex);
  30685. return;
  30686. }
  30687. } else if (program.output) {
  30688. fs.mkdirSync(path.dirname(program.output), { recursive: true });
  30689. fs.writeFileSync(program.output, result.code);
  30690. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  30691. fs.writeFileSync(program.output + ".map", result.map);
  30692. }
  30693. } else {
  30694. console.log(result.code);
  30695. }
  30696. if (program.nameCache) {
  30697. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  30698. }
  30699. if (result.timings) for (var phase in result.timings) {
  30700. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  30701. }
  30702. }
  30703. function fatal(message) {
  30704. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  30705. print_error(message);
  30706. process.exit(1);
  30707. }
  30708. // A file glob function that only supports "*" and "?" wildcards in the basename.
  30709. // Example: "foo/bar/*baz??.*.js"
  30710. // Argument `glob` may be a string or an array of strings.
  30711. // Returns an array of strings. Garbage in, garbage out.
  30712. function simple_glob(glob) {
  30713. if (Array.isArray(glob)) {
  30714. return [].concat.apply([], glob.map(simple_glob));
  30715. }
  30716. if (glob && glob.match(/[*?]/)) {
  30717. var dir = path.dirname(glob);
  30718. try {
  30719. var entries = fs.readdirSync(dir);
  30720. } catch (ex) {}
  30721. if (entries) {
  30722. var pattern = "^" + path.basename(glob)
  30723. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  30724. .replace(/\*/g, "[^/\\\\]*")
  30725. .replace(/\?/g, "[^/\\\\]") + "$";
  30726. var mod = process.platform === "win32" ? "i" : "";
  30727. var rx = new RegExp(pattern, mod);
  30728. var results = entries.filter(function(name) {
  30729. return rx.test(name);
  30730. }).map(function(name) {
  30731. return path.join(dir, name);
  30732. });
  30733. if (results.length) return results;
  30734. }
  30735. }
  30736. return [ glob ];
  30737. }
  30738. function read_file(path, default_value) {
  30739. try {
  30740. return fs.readFileSync(path, "utf8");
  30741. } catch (ex) {
  30742. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  30743. fatal(ex);
  30744. }
  30745. }
  30746. function parse_js(flag) {
  30747. return function(value, options) {
  30748. options = options || {};
  30749. try {
  30750. walk(parse(value, { expression: true }), node => {
  30751. if (node instanceof AST_Assign) {
  30752. var name = node.left.print_to_string();
  30753. var value = node.right;
  30754. if (flag) {
  30755. options[name] = value;
  30756. } else if (value instanceof AST_Array) {
  30757. options[name] = value.elements.map(to_string);
  30758. } else if (value instanceof AST_RegExp) {
  30759. value = value.value;
  30760. options[name] = new RegExp(value.source, value.flags);
  30761. } else {
  30762. options[name] = to_string(value);
  30763. }
  30764. return true;
  30765. }
  30766. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  30767. var name = node.print_to_string();
  30768. options[name] = true;
  30769. return true;
  30770. }
  30771. if (!(node instanceof AST_Sequence)) throw node;
  30772. function to_string(value) {
  30773. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  30774. quote_keys: true
  30775. });
  30776. }
  30777. });
  30778. } catch(ex) {
  30779. if (flag) {
  30780. fatal("Error parsing arguments for '" + flag + "': " + value);
  30781. } else {
  30782. options[value] = null;
  30783. }
  30784. }
  30785. return options;
  30786. };
  30787. }
  30788. function symdef(def) {
  30789. var ret = (1e6 + def.id) + " " + def.name;
  30790. if (def.mangled_name) ret += " " + def.mangled_name;
  30791. return ret;
  30792. }
  30793. function collect_from_map(map, callback) {
  30794. var result = [];
  30795. map.forEach(function (def) {
  30796. result.push(callback(def));
  30797. });
  30798. return result;
  30799. }
  30800. function format_object(obj) {
  30801. var lines = [];
  30802. var padding = "";
  30803. Object.keys(obj).map(function(name) {
  30804. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  30805. return [ name, JSON.stringify(obj[name]) ];
  30806. }).forEach(function(tokens) {
  30807. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  30808. });
  30809. return lines.join("\n");
  30810. }
  30811. function print_error(msg) {
  30812. process.stderr.write(msg);
  30813. process.stderr.write("\n");
  30814. }
  30815. function describe_ast() {
  30816. var out = OutputStream({ beautify: true });
  30817. function doitem(ctor) {
  30818. out.print("AST_" + ctor.TYPE);
  30819. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  30820. if (props.length > 0) {
  30821. out.space();
  30822. out.with_parens(function() {
  30823. props.forEach(function(prop, i) {
  30824. if (i) out.space();
  30825. out.print(prop);
  30826. });
  30827. });
  30828. }
  30829. if (ctor.documentation) {
  30830. out.space();
  30831. out.print_string(ctor.documentation);
  30832. }
  30833. if (ctor.SUBCLASSES.length > 0) {
  30834. out.space();
  30835. out.with_block(function() {
  30836. ctor.SUBCLASSES.forEach(function(ctor) {
  30837. out.indent();
  30838. doitem(ctor);
  30839. out.newline();
  30840. });
  30841. });
  30842. }
  30843. }
  30844. doitem(AST_Node);
  30845. return out + "\n";
  30846. }
  30847. }
  30848. async function _default_options() {
  30849. const defs = {};
  30850. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  30851. const options = infer_options({
  30852. [component]: {0: 0}
  30853. });
  30854. if (options) defs[component] = options;
  30855. });
  30856. return defs;
  30857. }
  30858. async function infer_options(options) {
  30859. try {
  30860. await minify("", options);
  30861. } catch (error) {
  30862. return error.defs;
  30863. }
  30864. }
  30865. exports._default_options = _default_options;
  30866. exports._run_cli = run_cli;
  30867. exports.minify = minify;
  30868. exports.minify_sync = minify_sync;
  30869. }));