bundle.min.js 1004 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549
  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("operator", "*")
  2551. || is("punc", ";")
  2552. || is("punc", "}")
  2553. ) {
  2554. return annotate(
  2555. new AST_ClassPropertyVariant({
  2556. start,
  2557. static: is_static,
  2558. quote,
  2559. key,
  2560. end: prev()
  2561. })
  2562. );
  2563. }
  2564. }
  2565. }
  2566. function class_static_block() {
  2567. if (!is("punc", "{")) {
  2568. return null;
  2569. }
  2570. const start = S.token;
  2571. const body = [];
  2572. next();
  2573. while (!is("punc", "}")) {
  2574. body.push(statement());
  2575. }
  2576. next();
  2577. return new AST_ClassStaticBlock({ start, body, end: prev() });
  2578. }
  2579. function maybe_import_assertion() {
  2580. if (is("name", "assert") && !has_newline_before(S.token)) {
  2581. next();
  2582. return object_or_destructuring_();
  2583. }
  2584. return null;
  2585. }
  2586. function import_statement() {
  2587. var start = prev();
  2588. var imported_name;
  2589. var imported_names;
  2590. if (is("name")) {
  2591. imported_name = as_symbol(AST_SymbolImport);
  2592. }
  2593. if (is("punc", ",")) {
  2594. next();
  2595. }
  2596. imported_names = map_names(true);
  2597. if (imported_names || imported_name) {
  2598. expect_token("name", "from");
  2599. }
  2600. var mod_str = S.token;
  2601. if (mod_str.type !== "string") {
  2602. unexpected();
  2603. }
  2604. next();
  2605. const assert_clause = maybe_import_assertion();
  2606. return new AST_Import({
  2607. start,
  2608. imported_name,
  2609. imported_names,
  2610. module_name: new AST_String({
  2611. start: mod_str,
  2612. value: mod_str.value,
  2613. quote: mod_str.quote,
  2614. end: mod_str,
  2615. }),
  2616. assert_clause,
  2617. end: S.token,
  2618. });
  2619. }
  2620. function import_meta(allow_calls) {
  2621. var start = S.token;
  2622. expect_token("name", "import");
  2623. expect_token("punc", ".");
  2624. expect_token("name", "meta");
  2625. return subscripts(new AST_ImportMeta({
  2626. start: start,
  2627. end: prev()
  2628. }), allow_calls);
  2629. }
  2630. function map_name(is_import) {
  2631. function make_symbol(type, quote) {
  2632. return new type({
  2633. name: as_property_name(),
  2634. quote: quote || undefined,
  2635. start: prev(),
  2636. end: prev()
  2637. });
  2638. }
  2639. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2640. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2641. var start = S.token;
  2642. var foreign_name;
  2643. var name;
  2644. if (is_import) {
  2645. foreign_name = make_symbol(foreign_type, start.quote);
  2646. } else {
  2647. name = make_symbol(type, start.quote);
  2648. }
  2649. if (is("name", "as")) {
  2650. next(); // The "as" word
  2651. if (is_import) {
  2652. name = make_symbol(type);
  2653. } else {
  2654. foreign_name = make_symbol(foreign_type, S.token.quote);
  2655. }
  2656. } else if (is_import) {
  2657. name = new type(foreign_name);
  2658. } else {
  2659. foreign_name = new foreign_type(name);
  2660. }
  2661. return new AST_NameMapping({
  2662. start: start,
  2663. foreign_name: foreign_name,
  2664. name: name,
  2665. end: prev(),
  2666. });
  2667. }
  2668. function map_nameAsterisk(is_import, import_or_export_foreign_name) {
  2669. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2670. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2671. var start = S.token;
  2672. var name, foreign_name;
  2673. var end = prev();
  2674. if (is_import) {
  2675. name = import_or_export_foreign_name;
  2676. } else {
  2677. foreign_name = import_or_export_foreign_name;
  2678. }
  2679. name = name || new type({
  2680. start: start,
  2681. name: "*",
  2682. end: end,
  2683. });
  2684. foreign_name = foreign_name || new foreign_type({
  2685. start: start,
  2686. name: "*",
  2687. end: end,
  2688. });
  2689. return new AST_NameMapping({
  2690. start: start,
  2691. foreign_name: foreign_name,
  2692. name: name,
  2693. end: end,
  2694. });
  2695. }
  2696. function map_names(is_import) {
  2697. var names;
  2698. if (is("punc", "{")) {
  2699. next();
  2700. names = [];
  2701. while (!is("punc", "}")) {
  2702. names.push(map_name(is_import));
  2703. if (is("punc", ",")) {
  2704. next();
  2705. }
  2706. }
  2707. next();
  2708. } else if (is("operator", "*")) {
  2709. var name;
  2710. next();
  2711. if (is("name", "as")) {
  2712. next(); // The "as" word
  2713. name = is_import ? as_symbol(AST_SymbolImport) : as_symbol_or_string(AST_SymbolExportForeign);
  2714. }
  2715. names = [map_nameAsterisk(is_import, name)];
  2716. }
  2717. return names;
  2718. }
  2719. function export_statement() {
  2720. var start = S.token;
  2721. var is_default;
  2722. var exported_names;
  2723. if (is("keyword", "default")) {
  2724. is_default = true;
  2725. next();
  2726. } else if (exported_names = map_names(false)) {
  2727. if (is("name", "from")) {
  2728. next();
  2729. var mod_str = S.token;
  2730. if (mod_str.type !== "string") {
  2731. unexpected();
  2732. }
  2733. next();
  2734. const assert_clause = maybe_import_assertion();
  2735. return new AST_Export({
  2736. start: start,
  2737. is_default: is_default,
  2738. exported_names: exported_names,
  2739. module_name: new AST_String({
  2740. start: mod_str,
  2741. value: mod_str.value,
  2742. quote: mod_str.quote,
  2743. end: mod_str,
  2744. }),
  2745. end: prev(),
  2746. assert_clause
  2747. });
  2748. } else {
  2749. return new AST_Export({
  2750. start: start,
  2751. is_default: is_default,
  2752. exported_names: exported_names,
  2753. end: prev(),
  2754. });
  2755. }
  2756. }
  2757. var node;
  2758. var exported_value;
  2759. var exported_definition;
  2760. if (is("punc", "{")
  2761. || is_default
  2762. && (is("keyword", "class") || is("keyword", "function"))
  2763. && is_token(peek(), "punc")) {
  2764. exported_value = expression(false);
  2765. semicolon();
  2766. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2767. unexpected(node.start);
  2768. } else if (
  2769. node instanceof AST_Definitions
  2770. || node instanceof AST_Defun
  2771. || node instanceof AST_DefClass
  2772. ) {
  2773. exported_definition = node;
  2774. } else if (
  2775. node instanceof AST_ClassExpression
  2776. || node instanceof AST_Function
  2777. ) {
  2778. exported_value = node;
  2779. } else if (node instanceof AST_SimpleStatement) {
  2780. exported_value = node.body;
  2781. } else {
  2782. unexpected(node.start);
  2783. }
  2784. return new AST_Export({
  2785. start: start,
  2786. is_default: is_default,
  2787. exported_value: exported_value,
  2788. exported_definition: exported_definition,
  2789. end: prev(),
  2790. assert_clause: null
  2791. });
  2792. }
  2793. function as_property_name() {
  2794. var tmp = S.token;
  2795. switch (tmp.type) {
  2796. case "punc":
  2797. if (tmp.value === "[") {
  2798. next();
  2799. var ex = expression(false);
  2800. expect("]");
  2801. return ex;
  2802. } else unexpected(tmp);
  2803. case "operator":
  2804. if (tmp.value === "*") {
  2805. next();
  2806. return null;
  2807. }
  2808. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2809. unexpected(tmp);
  2810. }
  2811. /* falls through */
  2812. case "name":
  2813. case "privatename":
  2814. case "string":
  2815. case "num":
  2816. case "big_int":
  2817. case "keyword":
  2818. case "atom":
  2819. next();
  2820. return tmp.value;
  2821. default:
  2822. unexpected(tmp);
  2823. }
  2824. }
  2825. function as_name() {
  2826. var tmp = S.token;
  2827. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  2828. next();
  2829. return tmp.value;
  2830. }
  2831. function _make_symbol(type) {
  2832. var name = S.token.value;
  2833. return new (name == "this" ? AST_This :
  2834. name == "super" ? AST_Super :
  2835. type)({
  2836. name : String(name),
  2837. start : S.token,
  2838. end : S.token
  2839. });
  2840. }
  2841. function _verify_symbol(sym) {
  2842. var name = sym.name;
  2843. if (is_in_generator() && name == "yield") {
  2844. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2845. }
  2846. if (S.input.has_directive("use strict")) {
  2847. if (name == "yield") {
  2848. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2849. }
  2850. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2851. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2852. }
  2853. }
  2854. }
  2855. function as_symbol(type, noerror) {
  2856. if (!is("name")) {
  2857. if (!noerror) croak("Name expected");
  2858. return null;
  2859. }
  2860. var sym = _make_symbol(type);
  2861. _verify_symbol(sym);
  2862. next();
  2863. return sym;
  2864. }
  2865. function as_symbol_or_string(type) {
  2866. if (!is("name")) {
  2867. if (!is("string")) {
  2868. croak("Name or string expected");
  2869. }
  2870. var tok = S.token;
  2871. var ret = new type({
  2872. start : tok,
  2873. end : tok,
  2874. name : tok.value,
  2875. quote : tok.quote
  2876. });
  2877. next();
  2878. return ret;
  2879. }
  2880. var sym = _make_symbol(type);
  2881. _verify_symbol(sym);
  2882. next();
  2883. return sym;
  2884. }
  2885. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2886. function annotate(node, before_token = node.start) {
  2887. var comments = before_token.comments_before;
  2888. const comments_outside_parens = outer_comments_before_counts.get(before_token);
  2889. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2890. while (--i >= 0) {
  2891. var comment = comments[i];
  2892. if (/[@#]__/.test(comment.value)) {
  2893. if (/[@#]__PURE__/.test(comment.value)) {
  2894. set_annotation(node, _PURE);
  2895. break;
  2896. }
  2897. if (/[@#]__INLINE__/.test(comment.value)) {
  2898. set_annotation(node, _INLINE);
  2899. break;
  2900. }
  2901. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2902. set_annotation(node, _NOINLINE);
  2903. break;
  2904. }
  2905. if (/[@#]__KEY__/.test(comment.value)) {
  2906. set_annotation(node, _KEY);
  2907. break;
  2908. }
  2909. if (/[@#]__MANGLE_PROP__/.test(comment.value)) {
  2910. set_annotation(node, _MANGLEPROP);
  2911. break;
  2912. }
  2913. }
  2914. }
  2915. return node;
  2916. }
  2917. var subscripts = function(expr, allow_calls, is_chain) {
  2918. var start = expr.start;
  2919. if (is("punc", ".")) {
  2920. next();
  2921. if(is("privatename") && !S.in_class)
  2922. croak("Private field must be used in an enclosing class");
  2923. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2924. return annotate(subscripts(new AST_DotVariant({
  2925. start : start,
  2926. expression : expr,
  2927. optional : false,
  2928. property : as_name(),
  2929. end : prev()
  2930. }), allow_calls, is_chain));
  2931. }
  2932. if (is("punc", "[")) {
  2933. next();
  2934. var prop = expression(true);
  2935. expect("]");
  2936. return annotate(subscripts(new AST_Sub({
  2937. start : start,
  2938. expression : expr,
  2939. optional : false,
  2940. property : prop,
  2941. end : prev()
  2942. }), allow_calls, is_chain));
  2943. }
  2944. if (allow_calls && is("punc", "(")) {
  2945. next();
  2946. var call = new AST_Call({
  2947. start : start,
  2948. expression : expr,
  2949. optional : false,
  2950. args : call_args(),
  2951. end : prev()
  2952. });
  2953. annotate(call);
  2954. return subscripts(call, true, is_chain);
  2955. }
  2956. if (is("punc", "?.")) {
  2957. next();
  2958. let chain_contents;
  2959. if (allow_calls && is("punc", "(")) {
  2960. next();
  2961. const call = new AST_Call({
  2962. start,
  2963. optional: true,
  2964. expression: expr,
  2965. args: call_args(),
  2966. end: prev()
  2967. });
  2968. annotate(call);
  2969. chain_contents = subscripts(call, true, true);
  2970. } else if (is("name") || is("privatename")) {
  2971. if(is("privatename") && !S.in_class)
  2972. croak("Private field must be used in an enclosing class");
  2973. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2974. chain_contents = annotate(subscripts(new AST_DotVariant({
  2975. start,
  2976. expression: expr,
  2977. optional: true,
  2978. property: as_name(),
  2979. end: prev()
  2980. }), allow_calls, true));
  2981. } else if (is("punc", "[")) {
  2982. next();
  2983. const property = expression(true);
  2984. expect("]");
  2985. chain_contents = annotate(subscripts(new AST_Sub({
  2986. start,
  2987. expression: expr,
  2988. optional: true,
  2989. property,
  2990. end: prev()
  2991. }), allow_calls, true));
  2992. }
  2993. if (!chain_contents) unexpected();
  2994. if (chain_contents instanceof AST_Chain) return chain_contents;
  2995. return new AST_Chain({
  2996. start,
  2997. expression: chain_contents,
  2998. end: prev()
  2999. });
  3000. }
  3001. if (is("template_head")) {
  3002. if (is_chain) {
  3003. // a?.b`c` is a syntax error
  3004. unexpected();
  3005. }
  3006. return subscripts(new AST_PrefixedTemplateString({
  3007. start: start,
  3008. prefix: expr,
  3009. template_string: template_string(),
  3010. end: prev()
  3011. }), allow_calls);
  3012. }
  3013. return expr;
  3014. };
  3015. function call_args() {
  3016. var args = [];
  3017. while (!is("punc", ")")) {
  3018. if (is("expand", "...")) {
  3019. next();
  3020. args.push(new AST_Expansion({
  3021. start: prev(),
  3022. expression: expression(false),
  3023. end: prev()
  3024. }));
  3025. } else {
  3026. args.push(expression(false));
  3027. }
  3028. if (!is("punc", ")")) {
  3029. expect(",");
  3030. }
  3031. }
  3032. next();
  3033. return args;
  3034. }
  3035. var maybe_unary = function(allow_calls, allow_arrows) {
  3036. var start = S.token;
  3037. if (start.type == "name" && start.value == "await" && can_await()) {
  3038. next();
  3039. return _await_expression();
  3040. }
  3041. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  3042. next();
  3043. handle_regexp();
  3044. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  3045. ex.start = start;
  3046. ex.end = prev();
  3047. return ex;
  3048. }
  3049. var val = expr_atom(allow_calls, allow_arrows);
  3050. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  3051. if (val instanceof AST_Arrow) unexpected();
  3052. val = make_unary(AST_UnaryPostfix, S.token, val);
  3053. val.start = start;
  3054. val.end = S.token;
  3055. next();
  3056. }
  3057. return val;
  3058. };
  3059. function make_unary(ctor, token, expr) {
  3060. var op = token.value;
  3061. switch (op) {
  3062. case "++":
  3063. case "--":
  3064. if (!is_assignable(expr))
  3065. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  3066. break;
  3067. case "delete":
  3068. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3069. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3070. break;
  3071. }
  3072. return new ctor({ operator: op, expression: expr });
  3073. }
  3074. var expr_op = function(left, min_prec, no_in) {
  3075. var op = is("operator") ? S.token.value : null;
  3076. if (op == "in" && no_in) op = null;
  3077. if (op == "**" && left instanceof AST_UnaryPrefix
  3078. /* unary token in front not allowed - parenthesis required */
  3079. && !is_token(left.start, "punc", "(")
  3080. && left.operator !== "--" && left.operator !== "++")
  3081. unexpected(left.start);
  3082. var prec = op != null ? PRECEDENCE[op] : null;
  3083. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3084. next();
  3085. var right = expr_ops(no_in, prec, true);
  3086. return expr_op(new AST_Binary({
  3087. start : left.start,
  3088. left : left,
  3089. operator : op,
  3090. right : right,
  3091. end : right.end
  3092. }), min_prec, no_in);
  3093. }
  3094. return left;
  3095. };
  3096. function expr_ops(no_in, min_prec, allow_calls, allow_arrows) {
  3097. // maybe_unary won't return us a AST_SymbolPrivateProperty
  3098. if (!no_in && min_prec < PRECEDENCE["in"] && is("privatename")) {
  3099. if(!S.in_class) {
  3100. croak("Private field must be used in an enclosing class");
  3101. }
  3102. const start = S.token;
  3103. const key = new AST_SymbolPrivateProperty({
  3104. start,
  3105. name: start.value,
  3106. end: start
  3107. });
  3108. next();
  3109. expect_token("operator", "in");
  3110. const private_in = new AST_PrivateIn({
  3111. start,
  3112. key,
  3113. value: expr_ops(no_in, PRECEDENCE["in"], true),
  3114. end: prev()
  3115. });
  3116. return expr_op(private_in, 0, no_in);
  3117. } else {
  3118. return expr_op(maybe_unary(allow_calls, allow_arrows), min_prec, no_in);
  3119. }
  3120. }
  3121. var maybe_conditional = function(no_in) {
  3122. var start = S.token;
  3123. var expr = expr_ops(no_in, 0, true, true);
  3124. if (is("operator", "?")) {
  3125. next();
  3126. var yes = expression(false);
  3127. expect(":");
  3128. return new AST_Conditional({
  3129. start : start,
  3130. condition : expr,
  3131. consequent : yes,
  3132. alternative : expression(false, no_in),
  3133. end : prev()
  3134. });
  3135. }
  3136. return expr;
  3137. };
  3138. function is_assignable(expr) {
  3139. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3140. }
  3141. function to_destructuring(node) {
  3142. if (node instanceof AST_Object) {
  3143. node = new AST_Destructuring({
  3144. start: node.start,
  3145. names: node.properties.map(to_destructuring),
  3146. is_array: false,
  3147. end: node.end
  3148. });
  3149. } else if (node instanceof AST_Array) {
  3150. var names = [];
  3151. for (var i = 0; i < node.elements.length; i++) {
  3152. // Only allow expansion as last element
  3153. if (node.elements[i] instanceof AST_Expansion) {
  3154. if (i + 1 !== node.elements.length) {
  3155. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3156. }
  3157. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3158. }
  3159. names.push(to_destructuring(node.elements[i]));
  3160. }
  3161. node = new AST_Destructuring({
  3162. start: node.start,
  3163. names: names,
  3164. is_array: true,
  3165. end: node.end
  3166. });
  3167. } else if (node instanceof AST_ObjectProperty) {
  3168. node.value = to_destructuring(node.value);
  3169. } else if (node instanceof AST_Assign) {
  3170. node = new AST_DefaultAssign({
  3171. start: node.start,
  3172. left: node.left,
  3173. operator: "=",
  3174. right: node.right,
  3175. end: node.end
  3176. });
  3177. }
  3178. return node;
  3179. }
  3180. // In ES6, AssignmentExpression can also be an ArrowFunction
  3181. var maybe_assign = function(no_in) {
  3182. handle_regexp();
  3183. var start = S.token;
  3184. if (start.type == "name" && start.value == "yield") {
  3185. if (is_in_generator()) {
  3186. next();
  3187. return _yield_expression();
  3188. } else if (S.input.has_directive("use strict")) {
  3189. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3190. }
  3191. }
  3192. var left = maybe_conditional(no_in);
  3193. var val = S.token.value;
  3194. if (is("operator") && ASSIGNMENT.has(val)) {
  3195. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3196. next();
  3197. return new AST_Assign({
  3198. start : start,
  3199. left : left,
  3200. operator : val,
  3201. right : maybe_assign(no_in),
  3202. logical : LOGICAL_ASSIGNMENT.has(val),
  3203. end : prev()
  3204. });
  3205. }
  3206. croak("Invalid assignment");
  3207. }
  3208. return left;
  3209. };
  3210. var to_expr_or_sequence = function(start, exprs) {
  3211. if (exprs.length === 1) {
  3212. return exprs[0];
  3213. } else if (exprs.length > 1) {
  3214. return new AST_Sequence({ start, expressions: exprs, end: peek() });
  3215. } else {
  3216. croak("Invalid parenthesized expression");
  3217. }
  3218. };
  3219. var expression = function(commas, no_in) {
  3220. var start = S.token;
  3221. var exprs = [];
  3222. while (true) {
  3223. exprs.push(maybe_assign(no_in));
  3224. if (!commas || !is("punc", ",")) break;
  3225. next();
  3226. commas = true;
  3227. }
  3228. return to_expr_or_sequence(start, exprs);
  3229. };
  3230. function in_loop(cont) {
  3231. ++S.in_loop;
  3232. var ret = cont();
  3233. --S.in_loop;
  3234. return ret;
  3235. }
  3236. if (options.expression) {
  3237. return expression(true);
  3238. }
  3239. return (function parse_toplevel() {
  3240. var start = S.token;
  3241. var body = [];
  3242. S.input.push_directives_stack();
  3243. if (options.module) S.input.add_directive("use strict");
  3244. while (!is("eof")) {
  3245. body.push(statement());
  3246. }
  3247. S.input.pop_directives_stack();
  3248. var end = prev();
  3249. var toplevel = options.toplevel;
  3250. if (toplevel) {
  3251. toplevel.body = toplevel.body.concat(body);
  3252. toplevel.end = end;
  3253. } else {
  3254. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3255. }
  3256. TEMPLATE_RAWS = new Map();
  3257. return toplevel;
  3258. })();
  3259. }
  3260. /***********************************************************************
  3261. A JavaScript tokenizer / parser / beautifier / compressor.
  3262. https://github.com/mishoo/UglifyJS2
  3263. -------------------------------- (C) ---------------------------------
  3264. Author: Mihai Bazon
  3265. <mihai.bazon@gmail.com>
  3266. http://mihai.bazon.net/blog
  3267. Distributed under the BSD license:
  3268. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3269. Redistribution and use in source and binary forms, with or without
  3270. modification, are permitted provided that the following conditions
  3271. are met:
  3272. * Redistributions of source code must retain the above
  3273. copyright notice, this list of conditions and the following
  3274. disclaimer.
  3275. * Redistributions in binary form must reproduce the above
  3276. copyright notice, this list of conditions and the following
  3277. disclaimer in the documentation and/or other materials
  3278. provided with the distribution.
  3279. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3280. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3281. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3282. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3283. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3284. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3285. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3286. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3287. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3288. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3289. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3290. SUCH DAMAGE.
  3291. ***********************************************************************/
  3292. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  3293. if (!props) props = [];
  3294. else props = props.split(/\s+/);
  3295. var self_props = props;
  3296. if (base && base.PROPS)
  3297. props = props.concat(base.PROPS);
  3298. const proto = base && Object.create(base.prototype);
  3299. if (proto) {
  3300. ctor.prototype = proto;
  3301. ctor.BASE = base;
  3302. }
  3303. if (base) base.SUBCLASSES.push(ctor);
  3304. ctor.prototype.CTOR = ctor;
  3305. ctor.prototype.constructor = ctor;
  3306. ctor.PROPS = props || null;
  3307. ctor.SELF_PROPS = self_props;
  3308. ctor.SUBCLASSES = [];
  3309. if (type) {
  3310. ctor.prototype.TYPE = ctor.TYPE = type;
  3311. }
  3312. if (methods) for (let i in methods) if (HOP(methods, i)) {
  3313. if (i[0] === "$") {
  3314. ctor[i.substr(1)] = methods[i];
  3315. } else {
  3316. ctor.prototype[i] = methods[i];
  3317. }
  3318. }
  3319. ctor.DEFMETHOD = function(name, method) {
  3320. this.prototype[name] = method;
  3321. };
  3322. return ctor;
  3323. }
  3324. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  3325. const set_tok_flag = (tok, flag, truth) => {
  3326. if (truth) {
  3327. tok.flags |= flag;
  3328. } else {
  3329. tok.flags &= ~flag;
  3330. }
  3331. };
  3332. const TOK_FLAG_NLB = 0b0001;
  3333. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  3334. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  3335. const TOK_FLAG_TEMPLATE_END = 0b1000;
  3336. class AST_Token {
  3337. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  3338. this.flags = (nlb ? 1 : 0);
  3339. this.type = type;
  3340. this.value = value;
  3341. this.line = line;
  3342. this.col = col;
  3343. this.pos = pos;
  3344. this.comments_before = comments_before;
  3345. this.comments_after = comments_after;
  3346. this.file = file;
  3347. Object.seal(this);
  3348. }
  3349. // Return a string summary of the token for node.js console.log
  3350. [Symbol.for("nodejs.util.inspect.custom")](_depth, options) {
  3351. const special = str => options.stylize(str, "special");
  3352. const quote = typeof this.value === "string" && this.value.includes("`") ? "'" : "`";
  3353. const value = `${quote}${this.value}${quote}`;
  3354. return `${special("[AST_Token")} ${value} at ${this.line}:${this.col}${special("]")}`;
  3355. }
  3356. get nlb() {
  3357. return has_tok_flag(this, TOK_FLAG_NLB);
  3358. }
  3359. set nlb(new_nlb) {
  3360. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  3361. }
  3362. get quote() {
  3363. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  3364. ? ""
  3365. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  3366. }
  3367. set quote(quote_type) {
  3368. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  3369. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  3370. }
  3371. get template_end() {
  3372. return has_tok_flag(this, TOK_FLAG_TEMPLATE_END);
  3373. }
  3374. set template_end(new_template_end) {
  3375. set_tok_flag(this, TOK_FLAG_TEMPLATE_END, new_template_end);
  3376. }
  3377. }
  3378. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  3379. if (props) {
  3380. this.start = props.start;
  3381. this.end = props.end;
  3382. }
  3383. this.flags = 0;
  3384. }, {
  3385. _clone: function(deep) {
  3386. if (deep) {
  3387. var self = this.clone();
  3388. return self.transform(new TreeTransformer(function(node) {
  3389. if (node !== self) {
  3390. return node.clone(true);
  3391. }
  3392. }));
  3393. }
  3394. return new this.CTOR(this);
  3395. },
  3396. clone: function(deep) {
  3397. return this._clone(deep);
  3398. },
  3399. $documentation: "Base class of all AST nodes",
  3400. $propdoc: {
  3401. start: "[AST_Token] The first token of this node",
  3402. end: "[AST_Token] The last token of this node"
  3403. },
  3404. _walk: function(visitor) {
  3405. return visitor._visit(this);
  3406. },
  3407. walk: function(visitor) {
  3408. return this._walk(visitor); // not sure the indirection will be any help
  3409. },
  3410. _children_backwards: () => {}
  3411. }, null);
  3412. /* -----[ statements ]----- */
  3413. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  3414. if (props) {
  3415. this.start = props.start;
  3416. this.end = props.end;
  3417. }
  3418. this.flags = 0;
  3419. }, {
  3420. $documentation: "Base class of all statements",
  3421. });
  3422. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  3423. if (props) {
  3424. this.start = props.start;
  3425. this.end = props.end;
  3426. }
  3427. this.flags = 0;
  3428. }, {
  3429. $documentation: "Represents a debugger statement",
  3430. }, AST_Statement);
  3431. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  3432. if (props) {
  3433. this.value = props.value;
  3434. this.quote = props.quote;
  3435. this.start = props.start;
  3436. this.end = props.end;
  3437. }
  3438. this.flags = 0;
  3439. }, {
  3440. $documentation: "Represents a directive, like \"use strict\";",
  3441. $propdoc: {
  3442. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3443. quote: "[string] the original quote character"
  3444. },
  3445. }, AST_Statement);
  3446. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  3447. if (props) {
  3448. this.body = props.body;
  3449. this.start = props.start;
  3450. this.end = props.end;
  3451. }
  3452. this.flags = 0;
  3453. }, {
  3454. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3455. $propdoc: {
  3456. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3457. },
  3458. _walk: function(visitor) {
  3459. return visitor._visit(this, function() {
  3460. this.body._walk(visitor);
  3461. });
  3462. },
  3463. _children_backwards(push) {
  3464. push(this.body);
  3465. }
  3466. }, AST_Statement);
  3467. function walk_body(node, visitor) {
  3468. const body = node.body;
  3469. for (var i = 0, len = body.length; i < len; i++) {
  3470. body[i]._walk(visitor);
  3471. }
  3472. }
  3473. function clone_block_scope(deep) {
  3474. var clone = this._clone(deep);
  3475. if (this.block_scope) {
  3476. clone.block_scope = this.block_scope.clone();
  3477. }
  3478. return clone;
  3479. }
  3480. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  3481. if (props) {
  3482. this.body = props.body;
  3483. this.block_scope = props.block_scope;
  3484. this.start = props.start;
  3485. this.end = props.end;
  3486. }
  3487. this.flags = 0;
  3488. }, {
  3489. $documentation: "A body of statements (usually braced)",
  3490. $propdoc: {
  3491. body: "[AST_Statement*] an array of statements",
  3492. block_scope: "[AST_Scope] the block scope"
  3493. },
  3494. _walk: function(visitor) {
  3495. return visitor._visit(this, function() {
  3496. walk_body(this, visitor);
  3497. });
  3498. },
  3499. _children_backwards(push) {
  3500. let i = this.body.length;
  3501. while (i--) push(this.body[i]);
  3502. },
  3503. clone: clone_block_scope
  3504. }, AST_Statement);
  3505. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  3506. if (props) {
  3507. this.body = props.body;
  3508. this.block_scope = props.block_scope;
  3509. this.start = props.start;
  3510. this.end = props.end;
  3511. }
  3512. this.flags = 0;
  3513. }, {
  3514. $documentation: "A block statement",
  3515. }, AST_Block);
  3516. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  3517. if (props) {
  3518. this.start = props.start;
  3519. this.end = props.end;
  3520. }
  3521. this.flags = 0;
  3522. }, {
  3523. $documentation: "The empty statement (empty block or simply a semicolon)"
  3524. }, AST_Statement);
  3525. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  3526. if (props) {
  3527. this.body = props.body;
  3528. this.start = props.start;
  3529. this.end = props.end;
  3530. }
  3531. this.flags = 0;
  3532. }, {
  3533. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3534. $propdoc: {
  3535. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3536. }
  3537. }, AST_Statement);
  3538. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  3539. if (props) {
  3540. this.label = props.label;
  3541. this.body = props.body;
  3542. this.start = props.start;
  3543. this.end = props.end;
  3544. }
  3545. this.flags = 0;
  3546. }, {
  3547. $documentation: "Statement with a label",
  3548. $propdoc: {
  3549. label: "[AST_Label] a label definition"
  3550. },
  3551. _walk: function(visitor) {
  3552. return visitor._visit(this, function() {
  3553. this.label._walk(visitor);
  3554. this.body._walk(visitor);
  3555. });
  3556. },
  3557. _children_backwards(push) {
  3558. push(this.body);
  3559. push(this.label);
  3560. },
  3561. clone: function(deep) {
  3562. var node = this._clone(deep);
  3563. if (deep) {
  3564. var label = node.label;
  3565. var def = this.label;
  3566. node.walk(new TreeWalker(function(node) {
  3567. if (node instanceof AST_LoopControl
  3568. && node.label && node.label.thedef === def) {
  3569. node.label.thedef = label;
  3570. label.references.push(node);
  3571. }
  3572. }));
  3573. }
  3574. return node;
  3575. }
  3576. }, AST_StatementWithBody);
  3577. var AST_IterationStatement = DEFNODE(
  3578. "IterationStatement",
  3579. "block_scope",
  3580. function AST_IterationStatement(props) {
  3581. if (props) {
  3582. this.block_scope = props.block_scope;
  3583. this.body = props.body;
  3584. this.start = props.start;
  3585. this.end = props.end;
  3586. }
  3587. this.flags = 0;
  3588. },
  3589. {
  3590. $documentation: "Internal class. All loops inherit from it.",
  3591. $propdoc: {
  3592. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3593. },
  3594. clone: clone_block_scope
  3595. },
  3596. AST_StatementWithBody
  3597. );
  3598. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  3599. if (props) {
  3600. this.condition = props.condition;
  3601. this.block_scope = props.block_scope;
  3602. this.body = props.body;
  3603. this.start = props.start;
  3604. this.end = props.end;
  3605. }
  3606. this.flags = 0;
  3607. }, {
  3608. $documentation: "Base class for do/while statements",
  3609. $propdoc: {
  3610. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3611. }
  3612. }, AST_IterationStatement);
  3613. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  3614. if (props) {
  3615. this.condition = props.condition;
  3616. this.block_scope = props.block_scope;
  3617. this.body = props.body;
  3618. this.start = props.start;
  3619. this.end = props.end;
  3620. }
  3621. this.flags = 0;
  3622. }, {
  3623. $documentation: "A `do` statement",
  3624. _walk: function(visitor) {
  3625. return visitor._visit(this, function() {
  3626. this.body._walk(visitor);
  3627. this.condition._walk(visitor);
  3628. });
  3629. },
  3630. _children_backwards(push) {
  3631. push(this.condition);
  3632. push(this.body);
  3633. }
  3634. }, AST_DWLoop);
  3635. var AST_While = DEFNODE("While", null, function AST_While(props) {
  3636. if (props) {
  3637. this.condition = props.condition;
  3638. this.block_scope = props.block_scope;
  3639. this.body = props.body;
  3640. this.start = props.start;
  3641. this.end = props.end;
  3642. }
  3643. this.flags = 0;
  3644. }, {
  3645. $documentation: "A `while` statement",
  3646. _walk: function(visitor) {
  3647. return visitor._visit(this, function() {
  3648. this.condition._walk(visitor);
  3649. this.body._walk(visitor);
  3650. });
  3651. },
  3652. _children_backwards(push) {
  3653. push(this.body);
  3654. push(this.condition);
  3655. },
  3656. }, AST_DWLoop);
  3657. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  3658. if (props) {
  3659. this.init = props.init;
  3660. this.condition = props.condition;
  3661. this.step = props.step;
  3662. this.block_scope = props.block_scope;
  3663. this.body = props.body;
  3664. this.start = props.start;
  3665. this.end = props.end;
  3666. }
  3667. this.flags = 0;
  3668. }, {
  3669. $documentation: "A `for` statement",
  3670. $propdoc: {
  3671. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3672. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3673. step: "[AST_Node?] the `for` update clause, or null if empty"
  3674. },
  3675. _walk: function(visitor) {
  3676. return visitor._visit(this, function() {
  3677. if (this.init) this.init._walk(visitor);
  3678. if (this.condition) this.condition._walk(visitor);
  3679. if (this.step) this.step._walk(visitor);
  3680. this.body._walk(visitor);
  3681. });
  3682. },
  3683. _children_backwards(push) {
  3684. push(this.body);
  3685. if (this.step) push(this.step);
  3686. if (this.condition) push(this.condition);
  3687. if (this.init) push(this.init);
  3688. },
  3689. }, AST_IterationStatement);
  3690. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  3691. if (props) {
  3692. this.init = props.init;
  3693. this.object = props.object;
  3694. this.block_scope = props.block_scope;
  3695. this.body = props.body;
  3696. this.start = props.start;
  3697. this.end = props.end;
  3698. }
  3699. this.flags = 0;
  3700. }, {
  3701. $documentation: "A `for ... in` statement",
  3702. $propdoc: {
  3703. init: "[AST_Node] the `for/in` initialization code",
  3704. object: "[AST_Node] the object that we're looping through"
  3705. },
  3706. _walk: function(visitor) {
  3707. return visitor._visit(this, function() {
  3708. this.init._walk(visitor);
  3709. this.object._walk(visitor);
  3710. this.body._walk(visitor);
  3711. });
  3712. },
  3713. _children_backwards(push) {
  3714. push(this.body);
  3715. if (this.object) push(this.object);
  3716. if (this.init) push(this.init);
  3717. },
  3718. }, AST_IterationStatement);
  3719. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  3720. if (props) {
  3721. this.await = props.await;
  3722. this.init = props.init;
  3723. this.object = props.object;
  3724. this.block_scope = props.block_scope;
  3725. this.body = props.body;
  3726. this.start = props.start;
  3727. this.end = props.end;
  3728. }
  3729. this.flags = 0;
  3730. }, {
  3731. $documentation: "A `for ... of` statement",
  3732. }, AST_ForIn);
  3733. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  3734. if (props) {
  3735. this.expression = props.expression;
  3736. this.body = props.body;
  3737. this.start = props.start;
  3738. this.end = props.end;
  3739. }
  3740. this.flags = 0;
  3741. }, {
  3742. $documentation: "A `with` statement",
  3743. $propdoc: {
  3744. expression: "[AST_Node] the `with` expression"
  3745. },
  3746. _walk: function(visitor) {
  3747. return visitor._visit(this, function() {
  3748. this.expression._walk(visitor);
  3749. this.body._walk(visitor);
  3750. });
  3751. },
  3752. _children_backwards(push) {
  3753. push(this.body);
  3754. push(this.expression);
  3755. },
  3756. }, AST_StatementWithBody);
  3757. /* -----[ scope and functions ]----- */
  3758. var AST_Scope = DEFNODE(
  3759. "Scope",
  3760. "variables uses_with uses_eval parent_scope enclosed cname",
  3761. function AST_Scope(props) {
  3762. if (props) {
  3763. this.variables = props.variables;
  3764. this.uses_with = props.uses_with;
  3765. this.uses_eval = props.uses_eval;
  3766. this.parent_scope = props.parent_scope;
  3767. this.enclosed = props.enclosed;
  3768. this.cname = props.cname;
  3769. this.body = props.body;
  3770. this.block_scope = props.block_scope;
  3771. this.start = props.start;
  3772. this.end = props.end;
  3773. }
  3774. this.flags = 0;
  3775. },
  3776. {
  3777. $documentation: "Base class for all statements introducing a lexical scope",
  3778. $propdoc: {
  3779. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3780. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3781. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3782. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3783. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3784. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3785. },
  3786. get_defun_scope: function() {
  3787. var self = this;
  3788. while (self.is_block_scope()) {
  3789. self = self.parent_scope;
  3790. }
  3791. return self;
  3792. },
  3793. clone: function(deep, toplevel) {
  3794. var node = this._clone(deep);
  3795. if (deep && this.variables && toplevel && !this._block_scope) {
  3796. node.figure_out_scope({}, {
  3797. toplevel: toplevel,
  3798. parent_scope: this.parent_scope
  3799. });
  3800. } else {
  3801. if (this.variables) node.variables = new Map(this.variables);
  3802. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3803. if (this._block_scope) node._block_scope = this._block_scope;
  3804. }
  3805. return node;
  3806. },
  3807. pinned: function() {
  3808. return this.uses_eval || this.uses_with;
  3809. }
  3810. },
  3811. AST_Block
  3812. );
  3813. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  3814. if (props) {
  3815. this.globals = props.globals;
  3816. this.variables = props.variables;
  3817. this.uses_with = props.uses_with;
  3818. this.uses_eval = props.uses_eval;
  3819. this.parent_scope = props.parent_scope;
  3820. this.enclosed = props.enclosed;
  3821. this.cname = props.cname;
  3822. this.body = props.body;
  3823. this.block_scope = props.block_scope;
  3824. this.start = props.start;
  3825. this.end = props.end;
  3826. }
  3827. this.flags = 0;
  3828. }, {
  3829. $documentation: "The toplevel scope",
  3830. $propdoc: {
  3831. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3832. },
  3833. wrap_commonjs: function(name) {
  3834. var body = this.body;
  3835. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3836. wrapped_tl = parse(wrapped_tl);
  3837. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3838. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3839. return MAP.splice(body);
  3840. }
  3841. }));
  3842. return wrapped_tl;
  3843. },
  3844. wrap_enclose: function(args_values) {
  3845. if (typeof args_values != "string") args_values = "";
  3846. var index = args_values.indexOf(":");
  3847. if (index < 0) index = args_values.length;
  3848. var body = this.body;
  3849. return parse([
  3850. "(function(",
  3851. args_values.slice(0, index),
  3852. '){"$ORIG"})(',
  3853. args_values.slice(index + 1),
  3854. ")"
  3855. ].join("")).transform(new TreeTransformer(function(node) {
  3856. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3857. return MAP.splice(body);
  3858. }
  3859. }));
  3860. }
  3861. }, AST_Scope);
  3862. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  3863. if (props) {
  3864. this.expression = props.expression;
  3865. this.start = props.start;
  3866. this.end = props.end;
  3867. }
  3868. this.flags = 0;
  3869. }, {
  3870. $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",
  3871. $propdoc: {
  3872. expression: "[AST_Node] the thing to be expanded"
  3873. },
  3874. _walk: function(visitor) {
  3875. return visitor._visit(this, function() {
  3876. this.expression.walk(visitor);
  3877. });
  3878. },
  3879. _children_backwards(push) {
  3880. push(this.expression);
  3881. },
  3882. });
  3883. var AST_Lambda = DEFNODE(
  3884. "Lambda",
  3885. "name argnames uses_arguments is_generator async",
  3886. function AST_Lambda(props) {
  3887. if (props) {
  3888. this.name = props.name;
  3889. this.argnames = props.argnames;
  3890. this.uses_arguments = props.uses_arguments;
  3891. this.is_generator = props.is_generator;
  3892. this.async = props.async;
  3893. this.variables = props.variables;
  3894. this.uses_with = props.uses_with;
  3895. this.uses_eval = props.uses_eval;
  3896. this.parent_scope = props.parent_scope;
  3897. this.enclosed = props.enclosed;
  3898. this.cname = props.cname;
  3899. this.body = props.body;
  3900. this.block_scope = props.block_scope;
  3901. this.start = props.start;
  3902. this.end = props.end;
  3903. }
  3904. this.flags = 0;
  3905. },
  3906. {
  3907. $documentation: "Base class for functions",
  3908. $propdoc: {
  3909. name: "[AST_SymbolDeclaration?] the name of this function",
  3910. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3911. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3912. is_generator: "[boolean] is this a generator method",
  3913. async: "[boolean] is this method async",
  3914. },
  3915. args_as_names: function () {
  3916. var out = [];
  3917. for (var i = 0; i < this.argnames.length; i++) {
  3918. if (this.argnames[i] instanceof AST_Destructuring) {
  3919. out.push(...this.argnames[i].all_symbols());
  3920. } else {
  3921. out.push(this.argnames[i]);
  3922. }
  3923. }
  3924. return out;
  3925. },
  3926. _walk: function(visitor) {
  3927. return visitor._visit(this, function() {
  3928. if (this.name) this.name._walk(visitor);
  3929. var argnames = this.argnames;
  3930. for (var i = 0, len = argnames.length; i < len; i++) {
  3931. argnames[i]._walk(visitor);
  3932. }
  3933. walk_body(this, visitor);
  3934. });
  3935. },
  3936. _children_backwards(push) {
  3937. let i = this.body.length;
  3938. while (i--) push(this.body[i]);
  3939. i = this.argnames.length;
  3940. while (i--) push(this.argnames[i]);
  3941. if (this.name) push(this.name);
  3942. },
  3943. is_braceless() {
  3944. return this.body[0] instanceof AST_Return && this.body[0].value;
  3945. },
  3946. // Default args and expansion don't count, so .argnames.length doesn't cut it
  3947. length_property() {
  3948. let length = 0;
  3949. for (const arg of this.argnames) {
  3950. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  3951. length++;
  3952. }
  3953. }
  3954. return length;
  3955. }
  3956. },
  3957. AST_Scope
  3958. );
  3959. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  3960. if (props) {
  3961. this.name = props.name;
  3962. this.argnames = props.argnames;
  3963. this.uses_arguments = props.uses_arguments;
  3964. this.is_generator = props.is_generator;
  3965. this.async = props.async;
  3966. this.variables = props.variables;
  3967. this.uses_with = props.uses_with;
  3968. this.uses_eval = props.uses_eval;
  3969. this.parent_scope = props.parent_scope;
  3970. this.enclosed = props.enclosed;
  3971. this.cname = props.cname;
  3972. this.body = props.body;
  3973. this.block_scope = props.block_scope;
  3974. this.start = props.start;
  3975. this.end = props.end;
  3976. }
  3977. this.flags = 0;
  3978. }, {
  3979. $documentation: "A setter/getter function. The `name` property is always null."
  3980. }, AST_Lambda);
  3981. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  3982. if (props) {
  3983. this.name = props.name;
  3984. this.argnames = props.argnames;
  3985. this.uses_arguments = props.uses_arguments;
  3986. this.is_generator = props.is_generator;
  3987. this.async = props.async;
  3988. this.variables = props.variables;
  3989. this.uses_with = props.uses_with;
  3990. this.uses_eval = props.uses_eval;
  3991. this.parent_scope = props.parent_scope;
  3992. this.enclosed = props.enclosed;
  3993. this.cname = props.cname;
  3994. this.body = props.body;
  3995. this.block_scope = props.block_scope;
  3996. this.start = props.start;
  3997. this.end = props.end;
  3998. }
  3999. this.flags = 0;
  4000. }, {
  4001. $documentation: "A function expression"
  4002. }, AST_Lambda);
  4003. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  4004. if (props) {
  4005. this.name = props.name;
  4006. this.argnames = props.argnames;
  4007. this.uses_arguments = props.uses_arguments;
  4008. this.is_generator = props.is_generator;
  4009. this.async = props.async;
  4010. this.variables = props.variables;
  4011. this.uses_with = props.uses_with;
  4012. this.uses_eval = props.uses_eval;
  4013. this.parent_scope = props.parent_scope;
  4014. this.enclosed = props.enclosed;
  4015. this.cname = props.cname;
  4016. this.body = props.body;
  4017. this.block_scope = props.block_scope;
  4018. this.start = props.start;
  4019. this.end = props.end;
  4020. }
  4021. this.flags = 0;
  4022. }, {
  4023. $documentation: "An ES6 Arrow function ((a) => b)"
  4024. }, AST_Lambda);
  4025. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  4026. if (props) {
  4027. this.name = props.name;
  4028. this.argnames = props.argnames;
  4029. this.uses_arguments = props.uses_arguments;
  4030. this.is_generator = props.is_generator;
  4031. this.async = props.async;
  4032. this.variables = props.variables;
  4033. this.uses_with = props.uses_with;
  4034. this.uses_eval = props.uses_eval;
  4035. this.parent_scope = props.parent_scope;
  4036. this.enclosed = props.enclosed;
  4037. this.cname = props.cname;
  4038. this.body = props.body;
  4039. this.block_scope = props.block_scope;
  4040. this.start = props.start;
  4041. this.end = props.end;
  4042. }
  4043. this.flags = 0;
  4044. }, {
  4045. $documentation: "A function definition"
  4046. }, AST_Lambda);
  4047. /* -----[ DESTRUCTURING ]----- */
  4048. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  4049. if (props) {
  4050. this.names = props.names;
  4051. this.is_array = props.is_array;
  4052. this.start = props.start;
  4053. this.end = props.end;
  4054. }
  4055. this.flags = 0;
  4056. }, {
  4057. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  4058. $propdoc: {
  4059. "names": "[AST_Node*] Array of properties or elements",
  4060. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  4061. },
  4062. _walk: function(visitor) {
  4063. return visitor._visit(this, function() {
  4064. this.names.forEach(function(name) {
  4065. name._walk(visitor);
  4066. });
  4067. });
  4068. },
  4069. _children_backwards(push) {
  4070. let i = this.names.length;
  4071. while (i--) push(this.names[i]);
  4072. },
  4073. all_symbols: function() {
  4074. var out = [];
  4075. walk(this, node => {
  4076. if (node instanceof AST_SymbolDeclaration) {
  4077. out.push(node);
  4078. }
  4079. if (node instanceof AST_Lambda) {
  4080. return true;
  4081. }
  4082. });
  4083. return out;
  4084. }
  4085. });
  4086. var AST_PrefixedTemplateString = DEFNODE(
  4087. "PrefixedTemplateString",
  4088. "template_string prefix",
  4089. function AST_PrefixedTemplateString(props) {
  4090. if (props) {
  4091. this.template_string = props.template_string;
  4092. this.prefix = props.prefix;
  4093. this.start = props.start;
  4094. this.end = props.end;
  4095. }
  4096. this.flags = 0;
  4097. },
  4098. {
  4099. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  4100. $propdoc: {
  4101. template_string: "[AST_TemplateString] The template string",
  4102. prefix: "[AST_Node] The prefix, which will get called."
  4103. },
  4104. _walk: function(visitor) {
  4105. return visitor._visit(this, function () {
  4106. this.prefix._walk(visitor);
  4107. this.template_string._walk(visitor);
  4108. });
  4109. },
  4110. _children_backwards(push) {
  4111. push(this.template_string);
  4112. push(this.prefix);
  4113. },
  4114. }
  4115. );
  4116. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  4117. if (props) {
  4118. this.segments = props.segments;
  4119. this.start = props.start;
  4120. this.end = props.end;
  4121. }
  4122. this.flags = 0;
  4123. }, {
  4124. $documentation: "A template string literal",
  4125. $propdoc: {
  4126. 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."
  4127. },
  4128. _walk: function(visitor) {
  4129. return visitor._visit(this, function() {
  4130. this.segments.forEach(function(seg) {
  4131. seg._walk(visitor);
  4132. });
  4133. });
  4134. },
  4135. _children_backwards(push) {
  4136. let i = this.segments.length;
  4137. while (i--) push(this.segments[i]);
  4138. }
  4139. });
  4140. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  4141. if (props) {
  4142. this.value = props.value;
  4143. this.raw = props.raw;
  4144. this.start = props.start;
  4145. this.end = props.end;
  4146. }
  4147. this.flags = 0;
  4148. }, {
  4149. $documentation: "A segment of a template string literal",
  4150. $propdoc: {
  4151. value: "Content of the segment",
  4152. raw: "Raw source of the segment",
  4153. }
  4154. });
  4155. /* -----[ JUMPS ]----- */
  4156. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  4157. if (props) {
  4158. this.start = props.start;
  4159. this.end = props.end;
  4160. }
  4161. this.flags = 0;
  4162. }, {
  4163. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  4164. }, AST_Statement);
  4165. /** Base class for “exits” (`return` and `throw`) */
  4166. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  4167. if (props) {
  4168. this.value = props.value;
  4169. this.start = props.start;
  4170. this.end = props.end;
  4171. }
  4172. this.flags = 0;
  4173. }, {
  4174. $documentation: "Base class for “exits” (`return` and `throw`)",
  4175. $propdoc: {
  4176. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  4177. },
  4178. _walk: function(visitor) {
  4179. return visitor._visit(this, this.value && function() {
  4180. this.value._walk(visitor);
  4181. });
  4182. },
  4183. _children_backwards(push) {
  4184. if (this.value) push(this.value);
  4185. },
  4186. }, AST_Jump);
  4187. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  4188. if (props) {
  4189. this.value = props.value;
  4190. this.start = props.start;
  4191. this.end = props.end;
  4192. }
  4193. this.flags = 0;
  4194. }, {
  4195. $documentation: "A `return` statement"
  4196. }, AST_Exit);
  4197. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  4198. if (props) {
  4199. this.value = props.value;
  4200. this.start = props.start;
  4201. this.end = props.end;
  4202. }
  4203. this.flags = 0;
  4204. }, {
  4205. $documentation: "A `throw` statement"
  4206. }, AST_Exit);
  4207. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  4208. if (props) {
  4209. this.label = props.label;
  4210. this.start = props.start;
  4211. this.end = props.end;
  4212. }
  4213. this.flags = 0;
  4214. }, {
  4215. $documentation: "Base class for loop control statements (`break` and `continue`)",
  4216. $propdoc: {
  4217. label: "[AST_LabelRef?] the label, or null if none",
  4218. },
  4219. _walk: function(visitor) {
  4220. return visitor._visit(this, this.label && function() {
  4221. this.label._walk(visitor);
  4222. });
  4223. },
  4224. _children_backwards(push) {
  4225. if (this.label) push(this.label);
  4226. },
  4227. }, AST_Jump);
  4228. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  4229. if (props) {
  4230. this.label = props.label;
  4231. this.start = props.start;
  4232. this.end = props.end;
  4233. }
  4234. this.flags = 0;
  4235. }, {
  4236. $documentation: "A `break` statement"
  4237. }, AST_LoopControl);
  4238. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  4239. if (props) {
  4240. this.label = props.label;
  4241. this.start = props.start;
  4242. this.end = props.end;
  4243. }
  4244. this.flags = 0;
  4245. }, {
  4246. $documentation: "A `continue` statement"
  4247. }, AST_LoopControl);
  4248. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  4249. if (props) {
  4250. this.expression = props.expression;
  4251. this.start = props.start;
  4252. this.end = props.end;
  4253. }
  4254. this.flags = 0;
  4255. }, {
  4256. $documentation: "An `await` statement",
  4257. $propdoc: {
  4258. expression: "[AST_Node] the mandatory expression being awaited",
  4259. },
  4260. _walk: function(visitor) {
  4261. return visitor._visit(this, function() {
  4262. this.expression._walk(visitor);
  4263. });
  4264. },
  4265. _children_backwards(push) {
  4266. push(this.expression);
  4267. },
  4268. });
  4269. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  4270. if (props) {
  4271. this.expression = props.expression;
  4272. this.is_star = props.is_star;
  4273. this.start = props.start;
  4274. this.end = props.end;
  4275. }
  4276. this.flags = 0;
  4277. }, {
  4278. $documentation: "A `yield` statement",
  4279. $propdoc: {
  4280. 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",
  4281. is_star: "[Boolean] Whether this is a yield or yield* statement"
  4282. },
  4283. _walk: function(visitor) {
  4284. return visitor._visit(this, this.expression && function() {
  4285. this.expression._walk(visitor);
  4286. });
  4287. },
  4288. _children_backwards(push) {
  4289. if (this.expression) push(this.expression);
  4290. }
  4291. });
  4292. /* -----[ IF ]----- */
  4293. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  4294. if (props) {
  4295. this.condition = props.condition;
  4296. this.alternative = props.alternative;
  4297. this.body = props.body;
  4298. this.start = props.start;
  4299. this.end = props.end;
  4300. }
  4301. this.flags = 0;
  4302. }, {
  4303. $documentation: "A `if` statement",
  4304. $propdoc: {
  4305. condition: "[AST_Node] the `if` condition",
  4306. alternative: "[AST_Statement?] the `else` part, or null if not present"
  4307. },
  4308. _walk: function(visitor) {
  4309. return visitor._visit(this, function() {
  4310. this.condition._walk(visitor);
  4311. this.body._walk(visitor);
  4312. if (this.alternative) this.alternative._walk(visitor);
  4313. });
  4314. },
  4315. _children_backwards(push) {
  4316. if (this.alternative) {
  4317. push(this.alternative);
  4318. }
  4319. push(this.body);
  4320. push(this.condition);
  4321. }
  4322. }, AST_StatementWithBody);
  4323. /* -----[ SWITCH ]----- */
  4324. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  4325. if (props) {
  4326. this.expression = props.expression;
  4327. this.body = props.body;
  4328. this.block_scope = props.block_scope;
  4329. this.start = props.start;
  4330. this.end = props.end;
  4331. }
  4332. this.flags = 0;
  4333. }, {
  4334. $documentation: "A `switch` statement",
  4335. $propdoc: {
  4336. expression: "[AST_Node] the `switch` “discriminant”"
  4337. },
  4338. _walk: function(visitor) {
  4339. return visitor._visit(this, function() {
  4340. this.expression._walk(visitor);
  4341. walk_body(this, visitor);
  4342. });
  4343. },
  4344. _children_backwards(push) {
  4345. let i = this.body.length;
  4346. while (i--) push(this.body[i]);
  4347. push(this.expression);
  4348. }
  4349. }, AST_Block);
  4350. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  4351. if (props) {
  4352. this.body = props.body;
  4353. this.block_scope = props.block_scope;
  4354. this.start = props.start;
  4355. this.end = props.end;
  4356. }
  4357. this.flags = 0;
  4358. }, {
  4359. $documentation: "Base class for `switch` branches",
  4360. }, AST_Block);
  4361. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  4362. if (props) {
  4363. this.body = props.body;
  4364. this.block_scope = props.block_scope;
  4365. this.start = props.start;
  4366. this.end = props.end;
  4367. }
  4368. this.flags = 0;
  4369. }, {
  4370. $documentation: "A `default` switch branch",
  4371. }, AST_SwitchBranch);
  4372. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  4373. if (props) {
  4374. this.expression = props.expression;
  4375. this.body = props.body;
  4376. this.block_scope = props.block_scope;
  4377. this.start = props.start;
  4378. this.end = props.end;
  4379. }
  4380. this.flags = 0;
  4381. }, {
  4382. $documentation: "A `case` switch branch",
  4383. $propdoc: {
  4384. expression: "[AST_Node] the `case` expression"
  4385. },
  4386. _walk: function(visitor) {
  4387. return visitor._visit(this, function() {
  4388. this.expression._walk(visitor);
  4389. walk_body(this, visitor);
  4390. });
  4391. },
  4392. _children_backwards(push) {
  4393. let i = this.body.length;
  4394. while (i--) push(this.body[i]);
  4395. push(this.expression);
  4396. },
  4397. }, AST_SwitchBranch);
  4398. /* -----[ EXCEPTIONS ]----- */
  4399. var AST_Try = DEFNODE("Try", "body bcatch bfinally", function AST_Try(props) {
  4400. if (props) {
  4401. this.body = props.body;
  4402. this.bcatch = props.bcatch;
  4403. this.bfinally = props.bfinally;
  4404. this.start = props.start;
  4405. this.end = props.end;
  4406. }
  4407. this.flags = 0;
  4408. }, {
  4409. $documentation: "A `try` statement",
  4410. $propdoc: {
  4411. body: "[AST_TryBlock] the try block",
  4412. bcatch: "[AST_Catch?] the catch block, or null if not present",
  4413. bfinally: "[AST_Finally?] the finally block, or null if not present"
  4414. },
  4415. _walk: function(visitor) {
  4416. return visitor._visit(this, function() {
  4417. this.body._walk(visitor);
  4418. if (this.bcatch) this.bcatch._walk(visitor);
  4419. if (this.bfinally) this.bfinally._walk(visitor);
  4420. });
  4421. },
  4422. _children_backwards(push) {
  4423. if (this.bfinally) push(this.bfinally);
  4424. if (this.bcatch) push(this.bcatch);
  4425. push(this.body);
  4426. },
  4427. }, AST_Statement);
  4428. var AST_TryBlock = DEFNODE("TryBlock", null, function AST_TryBlock(props) {
  4429. if (props) {
  4430. this.body = props.body;
  4431. this.block_scope = props.block_scope;
  4432. this.start = props.start;
  4433. this.end = props.end;
  4434. }
  4435. this.flags = 0;
  4436. }, {
  4437. $documentation: "The `try` block of a try statement"
  4438. }, AST_Block);
  4439. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  4440. if (props) {
  4441. this.argname = props.argname;
  4442. this.body = props.body;
  4443. this.block_scope = props.block_scope;
  4444. this.start = props.start;
  4445. this.end = props.end;
  4446. }
  4447. this.flags = 0;
  4448. }, {
  4449. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  4450. $propdoc: {
  4451. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  4452. },
  4453. _walk: function(visitor) {
  4454. return visitor._visit(this, function() {
  4455. if (this.argname) this.argname._walk(visitor);
  4456. walk_body(this, visitor);
  4457. });
  4458. },
  4459. _children_backwards(push) {
  4460. let i = this.body.length;
  4461. while (i--) push(this.body[i]);
  4462. if (this.argname) push(this.argname);
  4463. },
  4464. }, AST_Block);
  4465. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  4466. if (props) {
  4467. this.body = props.body;
  4468. this.block_scope = props.block_scope;
  4469. this.start = props.start;
  4470. this.end = props.end;
  4471. }
  4472. this.flags = 0;
  4473. }, {
  4474. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  4475. }, AST_Block);
  4476. /* -----[ VAR/CONST ]----- */
  4477. var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
  4478. if (props) {
  4479. this.definitions = props.definitions;
  4480. this.start = props.start;
  4481. this.end = props.end;
  4482. }
  4483. this.flags = 0;
  4484. }, {
  4485. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  4486. $propdoc: {
  4487. definitions: "[AST_VarDef*] array of variable definitions"
  4488. },
  4489. _walk: function(visitor) {
  4490. return visitor._visit(this, function() {
  4491. var definitions = this.definitions;
  4492. for (var i = 0, len = definitions.length; i < len; i++) {
  4493. definitions[i]._walk(visitor);
  4494. }
  4495. });
  4496. },
  4497. _children_backwards(push) {
  4498. let i = this.definitions.length;
  4499. while (i--) push(this.definitions[i]);
  4500. },
  4501. }, AST_Statement);
  4502. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  4503. if (props) {
  4504. this.definitions = props.definitions;
  4505. this.start = props.start;
  4506. this.end = props.end;
  4507. }
  4508. this.flags = 0;
  4509. }, {
  4510. $documentation: "A `var` statement"
  4511. }, AST_Definitions);
  4512. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  4513. if (props) {
  4514. this.definitions = props.definitions;
  4515. this.start = props.start;
  4516. this.end = props.end;
  4517. }
  4518. this.flags = 0;
  4519. }, {
  4520. $documentation: "A `let` statement"
  4521. }, AST_Definitions);
  4522. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  4523. if (props) {
  4524. this.definitions = props.definitions;
  4525. this.start = props.start;
  4526. this.end = props.end;
  4527. }
  4528. this.flags = 0;
  4529. }, {
  4530. $documentation: "A `const` statement"
  4531. }, AST_Definitions);
  4532. var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
  4533. if (props) {
  4534. this.name = props.name;
  4535. this.value = props.value;
  4536. this.start = props.start;
  4537. this.end = props.end;
  4538. }
  4539. this.flags = 0;
  4540. }, {
  4541. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  4542. $propdoc: {
  4543. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  4544. value: "[AST_Node?] initializer, or null of there's no initializer"
  4545. },
  4546. _walk: function(visitor) {
  4547. return visitor._visit(this, function() {
  4548. this.name._walk(visitor);
  4549. if (this.value) this.value._walk(visitor);
  4550. });
  4551. },
  4552. _children_backwards(push) {
  4553. if (this.value) push(this.value);
  4554. push(this.name);
  4555. },
  4556. declarations_as_names() {
  4557. if (this.name instanceof AST_SymbolDeclaration) {
  4558. return [this];
  4559. } else {
  4560. return this.name.all_symbols();
  4561. }
  4562. }
  4563. });
  4564. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  4565. if (props) {
  4566. this.foreign_name = props.foreign_name;
  4567. this.name = props.name;
  4568. this.start = props.start;
  4569. this.end = props.end;
  4570. }
  4571. this.flags = 0;
  4572. }, {
  4573. $documentation: "The part of the export/import statement that declare names from a module.",
  4574. $propdoc: {
  4575. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  4576. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  4577. },
  4578. _walk: function (visitor) {
  4579. return visitor._visit(this, function() {
  4580. this.foreign_name._walk(visitor);
  4581. this.name._walk(visitor);
  4582. });
  4583. },
  4584. _children_backwards(push) {
  4585. push(this.name);
  4586. push(this.foreign_name);
  4587. },
  4588. });
  4589. var AST_Import = DEFNODE(
  4590. "Import",
  4591. "imported_name imported_names module_name assert_clause",
  4592. function AST_Import(props) {
  4593. if (props) {
  4594. this.imported_name = props.imported_name;
  4595. this.imported_names = props.imported_names;
  4596. this.module_name = props.module_name;
  4597. this.assert_clause = props.assert_clause;
  4598. this.start = props.start;
  4599. this.end = props.end;
  4600. }
  4601. this.flags = 0;
  4602. },
  4603. {
  4604. $documentation: "An `import` statement",
  4605. $propdoc: {
  4606. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  4607. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  4608. module_name: "[AST_String] String literal describing where this module came from",
  4609. assert_clause: "[AST_Object?] The import assertion"
  4610. },
  4611. _walk: function(visitor) {
  4612. return visitor._visit(this, function() {
  4613. if (this.imported_name) {
  4614. this.imported_name._walk(visitor);
  4615. }
  4616. if (this.imported_names) {
  4617. this.imported_names.forEach(function(name_import) {
  4618. name_import._walk(visitor);
  4619. });
  4620. }
  4621. this.module_name._walk(visitor);
  4622. });
  4623. },
  4624. _children_backwards(push) {
  4625. push(this.module_name);
  4626. if (this.imported_names) {
  4627. let i = this.imported_names.length;
  4628. while (i--) push(this.imported_names[i]);
  4629. }
  4630. if (this.imported_name) push(this.imported_name);
  4631. },
  4632. }
  4633. );
  4634. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  4635. if (props) {
  4636. this.start = props.start;
  4637. this.end = props.end;
  4638. }
  4639. this.flags = 0;
  4640. }, {
  4641. $documentation: "A reference to import.meta",
  4642. });
  4643. var AST_Export = DEFNODE(
  4644. "Export",
  4645. "exported_definition exported_value is_default exported_names module_name assert_clause",
  4646. function AST_Export(props) {
  4647. if (props) {
  4648. this.exported_definition = props.exported_definition;
  4649. this.exported_value = props.exported_value;
  4650. this.is_default = props.is_default;
  4651. this.exported_names = props.exported_names;
  4652. this.module_name = props.module_name;
  4653. this.assert_clause = props.assert_clause;
  4654. this.start = props.start;
  4655. this.end = props.end;
  4656. }
  4657. this.flags = 0;
  4658. },
  4659. {
  4660. $documentation: "An `export` statement",
  4661. $propdoc: {
  4662. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  4663. exported_value: "[AST_Node?] An exported value",
  4664. exported_names: "[AST_NameMapping*?] List of exported names",
  4665. module_name: "[AST_String?] Name of the file to load exports from",
  4666. is_default: "[Boolean] Whether this is the default exported value of this module",
  4667. assert_clause: "[AST_Object?] The import assertion"
  4668. },
  4669. _walk: function (visitor) {
  4670. return visitor._visit(this, function () {
  4671. if (this.exported_definition) {
  4672. this.exported_definition._walk(visitor);
  4673. }
  4674. if (this.exported_value) {
  4675. this.exported_value._walk(visitor);
  4676. }
  4677. if (this.exported_names) {
  4678. this.exported_names.forEach(function(name_export) {
  4679. name_export._walk(visitor);
  4680. });
  4681. }
  4682. if (this.module_name) {
  4683. this.module_name._walk(visitor);
  4684. }
  4685. });
  4686. },
  4687. _children_backwards(push) {
  4688. if (this.module_name) push(this.module_name);
  4689. if (this.exported_names) {
  4690. let i = this.exported_names.length;
  4691. while (i--) push(this.exported_names[i]);
  4692. }
  4693. if (this.exported_value) push(this.exported_value);
  4694. if (this.exported_definition) push(this.exported_definition);
  4695. }
  4696. },
  4697. AST_Statement
  4698. );
  4699. /* -----[ OTHER ]----- */
  4700. var AST_Call = DEFNODE(
  4701. "Call",
  4702. "expression args optional _annotations",
  4703. function AST_Call(props) {
  4704. if (props) {
  4705. this.expression = props.expression;
  4706. this.args = props.args;
  4707. this.optional = props.optional;
  4708. this._annotations = props._annotations;
  4709. this.start = props.start;
  4710. this.end = props.end;
  4711. this.initialize();
  4712. }
  4713. this.flags = 0;
  4714. },
  4715. {
  4716. $documentation: "A function call expression",
  4717. $propdoc: {
  4718. expression: "[AST_Node] expression to invoke as function",
  4719. args: "[AST_Node*] array of arguments",
  4720. optional: "[boolean] whether this is an optional call (IE ?.() )",
  4721. _annotations: "[number] bitfield containing information about the call"
  4722. },
  4723. initialize() {
  4724. if (this._annotations == null) this._annotations = 0;
  4725. },
  4726. _walk(visitor) {
  4727. return visitor._visit(this, function() {
  4728. var args = this.args;
  4729. for (var i = 0, len = args.length; i < len; i++) {
  4730. args[i]._walk(visitor);
  4731. }
  4732. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  4733. });
  4734. },
  4735. _children_backwards(push) {
  4736. let i = this.args.length;
  4737. while (i--) push(this.args[i]);
  4738. push(this.expression);
  4739. },
  4740. }
  4741. );
  4742. var AST_New = DEFNODE("New", null, function AST_New(props) {
  4743. if (props) {
  4744. this.expression = props.expression;
  4745. this.args = props.args;
  4746. this.optional = props.optional;
  4747. this._annotations = props._annotations;
  4748. this.start = props.start;
  4749. this.end = props.end;
  4750. this.initialize();
  4751. }
  4752. this.flags = 0;
  4753. }, {
  4754. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  4755. }, AST_Call);
  4756. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  4757. if (props) {
  4758. this.expressions = props.expressions;
  4759. this.start = props.start;
  4760. this.end = props.end;
  4761. }
  4762. this.flags = 0;
  4763. }, {
  4764. $documentation: "A sequence expression (comma-separated expressions)",
  4765. $propdoc: {
  4766. expressions: "[AST_Node*] array of expressions (at least two)"
  4767. },
  4768. _walk: function(visitor) {
  4769. return visitor._visit(this, function() {
  4770. this.expressions.forEach(function(node) {
  4771. node._walk(visitor);
  4772. });
  4773. });
  4774. },
  4775. _children_backwards(push) {
  4776. let i = this.expressions.length;
  4777. while (i--) push(this.expressions[i]);
  4778. },
  4779. });
  4780. var AST_PropAccess = DEFNODE(
  4781. "PropAccess",
  4782. "expression property optional",
  4783. function AST_PropAccess(props) {
  4784. if (props) {
  4785. this.expression = props.expression;
  4786. this.property = props.property;
  4787. this.optional = props.optional;
  4788. this.start = props.start;
  4789. this.end = props.end;
  4790. }
  4791. this.flags = 0;
  4792. },
  4793. {
  4794. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  4795. $propdoc: {
  4796. expression: "[AST_Node] the “container” expression",
  4797. 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",
  4798. optional: "[boolean] whether this is an optional property access (IE ?.)"
  4799. }
  4800. }
  4801. );
  4802. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  4803. if (props) {
  4804. this.quote = props.quote;
  4805. this.expression = props.expression;
  4806. this.property = props.property;
  4807. this.optional = props.optional;
  4808. this._annotations = props._annotations;
  4809. this.start = props.start;
  4810. this.end = props.end;
  4811. }
  4812. this.flags = 0;
  4813. }, {
  4814. $documentation: "A dotted property access expression",
  4815. $propdoc: {
  4816. quote: "[string] the original quote character when transformed from AST_Sub",
  4817. },
  4818. _walk: function(visitor) {
  4819. return visitor._visit(this, function() {
  4820. this.expression._walk(visitor);
  4821. });
  4822. },
  4823. _children_backwards(push) {
  4824. push(this.expression);
  4825. },
  4826. }, AST_PropAccess);
  4827. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  4828. if (props) {
  4829. this.expression = props.expression;
  4830. this.property = props.property;
  4831. this.optional = props.optional;
  4832. this.start = props.start;
  4833. this.end = props.end;
  4834. }
  4835. this.flags = 0;
  4836. }, {
  4837. $documentation: "A dotted property access to a private property",
  4838. _walk: function(visitor) {
  4839. return visitor._visit(this, function() {
  4840. this.expression._walk(visitor);
  4841. });
  4842. },
  4843. _children_backwards(push) {
  4844. push(this.expression);
  4845. },
  4846. }, AST_PropAccess);
  4847. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  4848. if (props) {
  4849. this.expression = props.expression;
  4850. this.property = props.property;
  4851. this.optional = props.optional;
  4852. this._annotations = props._annotations;
  4853. this.start = props.start;
  4854. this.end = props.end;
  4855. }
  4856. this.flags = 0;
  4857. }, {
  4858. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4859. _walk: function(visitor) {
  4860. return visitor._visit(this, function() {
  4861. this.expression._walk(visitor);
  4862. this.property._walk(visitor);
  4863. });
  4864. },
  4865. _children_backwards(push) {
  4866. push(this.property);
  4867. push(this.expression);
  4868. },
  4869. }, AST_PropAccess);
  4870. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  4871. if (props) {
  4872. this.expression = props.expression;
  4873. this.start = props.start;
  4874. this.end = props.end;
  4875. }
  4876. this.flags = 0;
  4877. }, {
  4878. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4879. $propdoc: {
  4880. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  4881. },
  4882. _walk: function (visitor) {
  4883. return visitor._visit(this, function() {
  4884. this.expression._walk(visitor);
  4885. });
  4886. },
  4887. _children_backwards(push) {
  4888. push(this.expression);
  4889. },
  4890. });
  4891. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  4892. if (props) {
  4893. this.operator = props.operator;
  4894. this.expression = props.expression;
  4895. this.start = props.start;
  4896. this.end = props.end;
  4897. }
  4898. this.flags = 0;
  4899. }, {
  4900. $documentation: "Base class for unary expressions",
  4901. $propdoc: {
  4902. operator: "[string] the operator",
  4903. expression: "[AST_Node] expression that this unary operator applies to"
  4904. },
  4905. _walk: function(visitor) {
  4906. return visitor._visit(this, function() {
  4907. this.expression._walk(visitor);
  4908. });
  4909. },
  4910. _children_backwards(push) {
  4911. push(this.expression);
  4912. },
  4913. });
  4914. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  4915. if (props) {
  4916. this.operator = props.operator;
  4917. this.expression = props.expression;
  4918. this.start = props.start;
  4919. this.end = props.end;
  4920. }
  4921. this.flags = 0;
  4922. }, {
  4923. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4924. }, AST_Unary);
  4925. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  4926. if (props) {
  4927. this.operator = props.operator;
  4928. this.expression = props.expression;
  4929. this.start = props.start;
  4930. this.end = props.end;
  4931. }
  4932. this.flags = 0;
  4933. }, {
  4934. $documentation: "Unary postfix expression, i.e. `i++`"
  4935. }, AST_Unary);
  4936. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  4937. if (props) {
  4938. this.operator = props.operator;
  4939. this.left = props.left;
  4940. this.right = props.right;
  4941. this.start = props.start;
  4942. this.end = props.end;
  4943. }
  4944. this.flags = 0;
  4945. }, {
  4946. $documentation: "Binary expression, i.e. `a + b`",
  4947. $propdoc: {
  4948. left: "[AST_Node] left-hand side expression",
  4949. operator: "[string] the operator",
  4950. right: "[AST_Node] right-hand side expression"
  4951. },
  4952. _walk: function(visitor) {
  4953. return visitor._visit(this, function() {
  4954. this.left._walk(visitor);
  4955. this.right._walk(visitor);
  4956. });
  4957. },
  4958. _children_backwards(push) {
  4959. push(this.right);
  4960. push(this.left);
  4961. },
  4962. });
  4963. var AST_Conditional = DEFNODE(
  4964. "Conditional",
  4965. "condition consequent alternative",
  4966. function AST_Conditional(props) {
  4967. if (props) {
  4968. this.condition = props.condition;
  4969. this.consequent = props.consequent;
  4970. this.alternative = props.alternative;
  4971. this.start = props.start;
  4972. this.end = props.end;
  4973. }
  4974. this.flags = 0;
  4975. },
  4976. {
  4977. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  4978. $propdoc: {
  4979. condition: "[AST_Node]",
  4980. consequent: "[AST_Node]",
  4981. alternative: "[AST_Node]"
  4982. },
  4983. _walk: function(visitor) {
  4984. return visitor._visit(this, function() {
  4985. this.condition._walk(visitor);
  4986. this.consequent._walk(visitor);
  4987. this.alternative._walk(visitor);
  4988. });
  4989. },
  4990. _children_backwards(push) {
  4991. push(this.alternative);
  4992. push(this.consequent);
  4993. push(this.condition);
  4994. },
  4995. }
  4996. );
  4997. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  4998. if (props) {
  4999. this.logical = props.logical;
  5000. this.operator = props.operator;
  5001. this.left = props.left;
  5002. this.right = props.right;
  5003. this.start = props.start;
  5004. this.end = props.end;
  5005. }
  5006. this.flags = 0;
  5007. }, {
  5008. $documentation: "An assignment expression — `a = b + 5`",
  5009. $propdoc: {
  5010. logical: "Whether it's a logical assignment"
  5011. }
  5012. }, AST_Binary);
  5013. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  5014. if (props) {
  5015. this.operator = props.operator;
  5016. this.left = props.left;
  5017. this.right = props.right;
  5018. this.start = props.start;
  5019. this.end = props.end;
  5020. }
  5021. this.flags = 0;
  5022. }, {
  5023. $documentation: "A default assignment expression like in `(a = 3) => a`"
  5024. }, AST_Binary);
  5025. /* -----[ LITERALS ]----- */
  5026. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  5027. if (props) {
  5028. this.elements = props.elements;
  5029. this.start = props.start;
  5030. this.end = props.end;
  5031. }
  5032. this.flags = 0;
  5033. }, {
  5034. $documentation: "An array literal",
  5035. $propdoc: {
  5036. elements: "[AST_Node*] array of elements"
  5037. },
  5038. _walk: function(visitor) {
  5039. return visitor._visit(this, function() {
  5040. var elements = this.elements;
  5041. for (var i = 0, len = elements.length; i < len; i++) {
  5042. elements[i]._walk(visitor);
  5043. }
  5044. });
  5045. },
  5046. _children_backwards(push) {
  5047. let i = this.elements.length;
  5048. while (i--) push(this.elements[i]);
  5049. },
  5050. });
  5051. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  5052. if (props) {
  5053. this.properties = props.properties;
  5054. this.start = props.start;
  5055. this.end = props.end;
  5056. }
  5057. this.flags = 0;
  5058. }, {
  5059. $documentation: "An object literal",
  5060. $propdoc: {
  5061. properties: "[AST_ObjectProperty*] array of properties"
  5062. },
  5063. _walk: function(visitor) {
  5064. return visitor._visit(this, function() {
  5065. var properties = this.properties;
  5066. for (var i = 0, len = properties.length; i < len; i++) {
  5067. properties[i]._walk(visitor);
  5068. }
  5069. });
  5070. },
  5071. _children_backwards(push) {
  5072. let i = this.properties.length;
  5073. while (i--) push(this.properties[i]);
  5074. },
  5075. });
  5076. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  5077. if (props) {
  5078. this.key = props.key;
  5079. this.value = props.value;
  5080. this.start = props.start;
  5081. this.end = props.end;
  5082. this._annotations = props._annotations;
  5083. }
  5084. this.flags = 0;
  5085. }, {
  5086. $documentation: "Base class for literal object properties",
  5087. $propdoc: {
  5088. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  5089. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  5090. },
  5091. _walk: function(visitor) {
  5092. return visitor._visit(this, function() {
  5093. if (this.key instanceof AST_Node)
  5094. this.key._walk(visitor);
  5095. this.value._walk(visitor);
  5096. });
  5097. },
  5098. _children_backwards(push) {
  5099. push(this.value);
  5100. if (this.key instanceof AST_Node) push(this.key);
  5101. }
  5102. });
  5103. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  5104. if (props) {
  5105. this.quote = props.quote;
  5106. this.key = props.key;
  5107. this.value = props.value;
  5108. this.start = props.start;
  5109. this.end = props.end;
  5110. this._annotations = props._annotations;
  5111. }
  5112. this.flags = 0;
  5113. }, {
  5114. $documentation: "A key: value object property",
  5115. $propdoc: {
  5116. quote: "[string] the original quote character"
  5117. },
  5118. computed_key() {
  5119. return this.key instanceof AST_Node;
  5120. }
  5121. }, AST_ObjectProperty);
  5122. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  5123. if (props) {
  5124. this.static = props.static;
  5125. this.key = props.key;
  5126. this.value = props.value;
  5127. this.start = props.start;
  5128. this.end = props.end;
  5129. }
  5130. this.flags = 0;
  5131. }, {
  5132. $propdoc: {
  5133. static: "[boolean] whether this is a static private setter"
  5134. },
  5135. $documentation: "A private setter property",
  5136. computed_key() {
  5137. return false;
  5138. }
  5139. }, AST_ObjectProperty);
  5140. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
  5141. if (props) {
  5142. this.static = props.static;
  5143. this.key = props.key;
  5144. this.value = props.value;
  5145. this.start = props.start;
  5146. this.end = props.end;
  5147. }
  5148. this.flags = 0;
  5149. }, {
  5150. $propdoc: {
  5151. static: "[boolean] whether this is a static private getter"
  5152. },
  5153. $documentation: "A private getter property",
  5154. computed_key() {
  5155. return false;
  5156. }
  5157. }, AST_ObjectProperty);
  5158. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  5159. if (props) {
  5160. this.quote = props.quote;
  5161. this.static = props.static;
  5162. this.key = props.key;
  5163. this.value = props.value;
  5164. this.start = props.start;
  5165. this.end = props.end;
  5166. this._annotations = props._annotations;
  5167. }
  5168. this.flags = 0;
  5169. }, {
  5170. $propdoc: {
  5171. quote: "[string|undefined] the original quote character, if any",
  5172. static: "[boolean] whether this is a static setter (classes only)"
  5173. },
  5174. $documentation: "An object setter property",
  5175. computed_key() {
  5176. return !(this.key instanceof AST_SymbolMethod);
  5177. }
  5178. }, AST_ObjectProperty);
  5179. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  5180. if (props) {
  5181. this.quote = props.quote;
  5182. this.static = props.static;
  5183. this.key = props.key;
  5184. this.value = props.value;
  5185. this.start = props.start;
  5186. this.end = props.end;
  5187. this._annotations = props._annotations;
  5188. }
  5189. this.flags = 0;
  5190. }, {
  5191. $propdoc: {
  5192. quote: "[string|undefined] the original quote character, if any",
  5193. static: "[boolean] whether this is a static getter (classes only)"
  5194. },
  5195. $documentation: "An object getter property",
  5196. computed_key() {
  5197. return !(this.key instanceof AST_SymbolMethod);
  5198. }
  5199. }, AST_ObjectProperty);
  5200. var AST_ConciseMethod = DEFNODE(
  5201. "ConciseMethod",
  5202. "quote static is_generator async",
  5203. function AST_ConciseMethod(props) {
  5204. if (props) {
  5205. this.quote = props.quote;
  5206. this.static = props.static;
  5207. this.is_generator = props.is_generator;
  5208. this.async = props.async;
  5209. this.key = props.key;
  5210. this.value = props.value;
  5211. this.start = props.start;
  5212. this.end = props.end;
  5213. this._annotations = props._annotations;
  5214. }
  5215. this.flags = 0;
  5216. },
  5217. {
  5218. $propdoc: {
  5219. quote: "[string|undefined] the original quote character, if any",
  5220. static: "[boolean] is this method static (classes only)",
  5221. is_generator: "[boolean] is this a generator method",
  5222. async: "[boolean] is this method async",
  5223. },
  5224. $documentation: "An ES6 concise method inside an object or class",
  5225. computed_key() {
  5226. return !(this.key instanceof AST_SymbolMethod);
  5227. }
  5228. },
  5229. AST_ObjectProperty
  5230. );
  5231. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
  5232. if (props) {
  5233. this.quote = props.quote;
  5234. this.static = props.static;
  5235. this.is_generator = props.is_generator;
  5236. this.async = props.async;
  5237. this.key = props.key;
  5238. this.value = props.value;
  5239. this.start = props.start;
  5240. this.end = props.end;
  5241. }
  5242. this.flags = 0;
  5243. }, {
  5244. $documentation: "A private class method inside a class",
  5245. }, AST_ConciseMethod);
  5246. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  5247. if (props) {
  5248. this.name = props.name;
  5249. this.extends = props.extends;
  5250. this.properties = props.properties;
  5251. this.variables = props.variables;
  5252. this.uses_with = props.uses_with;
  5253. this.uses_eval = props.uses_eval;
  5254. this.parent_scope = props.parent_scope;
  5255. this.enclosed = props.enclosed;
  5256. this.cname = props.cname;
  5257. this.body = props.body;
  5258. this.block_scope = props.block_scope;
  5259. this.start = props.start;
  5260. this.end = props.end;
  5261. }
  5262. this.flags = 0;
  5263. }, {
  5264. $propdoc: {
  5265. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  5266. extends: "[AST_Node]? optional parent class",
  5267. properties: "[AST_ObjectProperty*] array of properties"
  5268. },
  5269. $documentation: "An ES6 class",
  5270. _walk: function(visitor) {
  5271. return visitor._visit(this, function() {
  5272. if (this.name) {
  5273. this.name._walk(visitor);
  5274. }
  5275. if (this.extends) {
  5276. this.extends._walk(visitor);
  5277. }
  5278. this.properties.forEach((prop) => prop._walk(visitor));
  5279. });
  5280. },
  5281. _children_backwards(push) {
  5282. let i = this.properties.length;
  5283. while (i--) push(this.properties[i]);
  5284. if (this.extends) push(this.extends);
  5285. if (this.name) push(this.name);
  5286. },
  5287. /** go through the bits that are executed instantly, not when the class is `new`'d. Doesn't walk the name. */
  5288. visit_nondeferred_class_parts(visitor) {
  5289. if (this.extends) {
  5290. this.extends._walk(visitor);
  5291. }
  5292. this.properties.forEach((prop) => {
  5293. if (prop instanceof AST_ClassStaticBlock) {
  5294. prop._walk(visitor);
  5295. return;
  5296. }
  5297. if (prop.computed_key()) {
  5298. visitor.push(prop);
  5299. prop.key._walk(visitor);
  5300. visitor.pop();
  5301. }
  5302. if ((prop instanceof AST_ClassPrivateProperty || prop instanceof AST_ClassProperty) && prop.static && prop.value) {
  5303. visitor.push(prop);
  5304. prop.value._walk(visitor);
  5305. visitor.pop();
  5306. }
  5307. });
  5308. },
  5309. /** go through the bits that are executed later, when the class is `new`'d or a static method is called */
  5310. visit_deferred_class_parts(visitor) {
  5311. this.properties.forEach((prop) => {
  5312. if (prop instanceof AST_ConciseMethod) {
  5313. prop.walk(visitor);
  5314. } else if (prop instanceof AST_ClassProperty && !prop.static && prop.value) {
  5315. visitor.push(prop);
  5316. prop.value._walk(visitor);
  5317. visitor.pop();
  5318. }
  5319. });
  5320. },
  5321. is_self_referential: function() {
  5322. const this_id = this.name && this.name.definition().id;
  5323. let found = false;
  5324. let class_this = true;
  5325. this.visit_nondeferred_class_parts(new TreeWalker((node, descend) => {
  5326. if (found) return true;
  5327. if (node instanceof AST_This) return (found = class_this);
  5328. if (node instanceof AST_SymbolRef) return (found = node.definition().id === this_id);
  5329. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  5330. const class_this_save = class_this;
  5331. class_this = false;
  5332. descend();
  5333. class_this = class_this_save;
  5334. return true;
  5335. }
  5336. }));
  5337. return found;
  5338. },
  5339. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  5340. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  5341. if (props) {
  5342. this.static = props.static;
  5343. this.quote = props.quote;
  5344. this.key = props.key;
  5345. this.value = props.value;
  5346. this.start = props.start;
  5347. this.end = props.end;
  5348. this._annotations = props._annotations;
  5349. }
  5350. this.flags = 0;
  5351. }, {
  5352. $documentation: "A class property",
  5353. $propdoc: {
  5354. static: "[boolean] whether this is a static key",
  5355. quote: "[string] which quote is being used"
  5356. },
  5357. _walk: function(visitor) {
  5358. return visitor._visit(this, function() {
  5359. if (this.key instanceof AST_Node)
  5360. this.key._walk(visitor);
  5361. if (this.value instanceof AST_Node)
  5362. this.value._walk(visitor);
  5363. });
  5364. },
  5365. _children_backwards(push) {
  5366. if (this.value instanceof AST_Node) push(this.value);
  5367. if (this.key instanceof AST_Node) push(this.key);
  5368. },
  5369. computed_key() {
  5370. return !(this.key instanceof AST_SymbolClassProperty);
  5371. }
  5372. }, AST_ObjectProperty);
  5373. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  5374. if (props) {
  5375. this.static = props.static;
  5376. this.quote = props.quote;
  5377. this.key = props.key;
  5378. this.value = props.value;
  5379. this.start = props.start;
  5380. this.end = props.end;
  5381. }
  5382. this.flags = 0;
  5383. }, {
  5384. $documentation: "A class property for a private property",
  5385. }, AST_ClassProperty);
  5386. var AST_PrivateIn = DEFNODE("PrivateIn", "key value", function AST_PrivateIn(props) {
  5387. if (props) {
  5388. this.key = props.key;
  5389. this.value = props.value;
  5390. this.start = props.start;
  5391. this.end = props.end;
  5392. }
  5393. this.flags = 0;
  5394. }, {
  5395. $documentation: "An `in` binop when the key is private, eg #x in this",
  5396. _walk: function(visitor) {
  5397. return visitor._visit(this, function() {
  5398. this.key._walk(visitor);
  5399. this.value._walk(visitor);
  5400. });
  5401. },
  5402. _children_backwards(push) {
  5403. push(this.value);
  5404. push(this.key);
  5405. },
  5406. });
  5407. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  5408. if (props) {
  5409. this.name = props.name;
  5410. this.extends = props.extends;
  5411. this.properties = props.properties;
  5412. this.variables = props.variables;
  5413. this.uses_with = props.uses_with;
  5414. this.uses_eval = props.uses_eval;
  5415. this.parent_scope = props.parent_scope;
  5416. this.enclosed = props.enclosed;
  5417. this.cname = props.cname;
  5418. this.body = props.body;
  5419. this.block_scope = props.block_scope;
  5420. this.start = props.start;
  5421. this.end = props.end;
  5422. }
  5423. this.flags = 0;
  5424. }, {
  5425. $documentation: "A class definition",
  5426. }, AST_Class);
  5427. var AST_ClassStaticBlock = DEFNODE("ClassStaticBlock", "body block_scope", function AST_ClassStaticBlock (props) {
  5428. this.body = props.body;
  5429. this.block_scope = props.block_scope;
  5430. this.start = props.start;
  5431. this.end = props.end;
  5432. }, {
  5433. $documentation: "A block containing statements to be executed in the context of the class",
  5434. $propdoc: {
  5435. body: "[AST_Statement*] an array of statements",
  5436. },
  5437. _walk: function(visitor) {
  5438. return visitor._visit(this, function() {
  5439. walk_body(this, visitor);
  5440. });
  5441. },
  5442. _children_backwards(push) {
  5443. let i = this.body.length;
  5444. while (i--) push(this.body[i]);
  5445. },
  5446. clone: clone_block_scope,
  5447. computed_key: () => false
  5448. }, AST_Scope);
  5449. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  5450. if (props) {
  5451. this.name = props.name;
  5452. this.extends = props.extends;
  5453. this.properties = props.properties;
  5454. this.variables = props.variables;
  5455. this.uses_with = props.uses_with;
  5456. this.uses_eval = props.uses_eval;
  5457. this.parent_scope = props.parent_scope;
  5458. this.enclosed = props.enclosed;
  5459. this.cname = props.cname;
  5460. this.body = props.body;
  5461. this.block_scope = props.block_scope;
  5462. this.start = props.start;
  5463. this.end = props.end;
  5464. }
  5465. this.flags = 0;
  5466. }, {
  5467. $documentation: "A class expression."
  5468. }, AST_Class);
  5469. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  5470. if (props) {
  5471. this.scope = props.scope;
  5472. this.name = props.name;
  5473. this.thedef = props.thedef;
  5474. this.start = props.start;
  5475. this.end = props.end;
  5476. }
  5477. this.flags = 0;
  5478. }, {
  5479. $propdoc: {
  5480. name: "[string] name of this symbol",
  5481. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  5482. thedef: "[SymbolDef/S] the definition of this symbol"
  5483. },
  5484. $documentation: "Base class for all symbols"
  5485. });
  5486. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  5487. if (props) {
  5488. this.start = props.start;
  5489. this.end = props.end;
  5490. }
  5491. this.flags = 0;
  5492. }, {
  5493. $documentation: "A reference to new.target"
  5494. });
  5495. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  5496. if (props) {
  5497. this.init = props.init;
  5498. this.scope = props.scope;
  5499. this.name = props.name;
  5500. this.thedef = props.thedef;
  5501. this.start = props.start;
  5502. this.end = props.end;
  5503. }
  5504. this.flags = 0;
  5505. }, {
  5506. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  5507. }, AST_Symbol);
  5508. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
  5509. if (props) {
  5510. this.init = props.init;
  5511. this.scope = props.scope;
  5512. this.name = props.name;
  5513. this.thedef = props.thedef;
  5514. this.start = props.start;
  5515. this.end = props.end;
  5516. }
  5517. this.flags = 0;
  5518. }, {
  5519. $documentation: "Symbol defining a variable",
  5520. }, AST_SymbolDeclaration);
  5521. var AST_SymbolBlockDeclaration = DEFNODE(
  5522. "SymbolBlockDeclaration",
  5523. null,
  5524. function AST_SymbolBlockDeclaration(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. {
  5536. $documentation: "Base class for block-scoped declaration symbols"
  5537. },
  5538. AST_SymbolDeclaration
  5539. );
  5540. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  5541. if (props) {
  5542. this.init = props.init;
  5543. this.scope = props.scope;
  5544. this.name = props.name;
  5545. this.thedef = props.thedef;
  5546. this.start = props.start;
  5547. this.end = props.end;
  5548. }
  5549. this.flags = 0;
  5550. }, {
  5551. $documentation: "A constant declaration"
  5552. }, AST_SymbolBlockDeclaration);
  5553. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(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. $documentation: "A block-scoped `let` declaration"
  5565. }, AST_SymbolBlockDeclaration);
  5566. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
  5567. if (props) {
  5568. this.init = props.init;
  5569. this.scope = props.scope;
  5570. this.name = props.name;
  5571. this.thedef = props.thedef;
  5572. this.start = props.start;
  5573. this.end = props.end;
  5574. }
  5575. this.flags = 0;
  5576. }, {
  5577. $documentation: "Symbol naming a function argument",
  5578. }, AST_SymbolVar);
  5579. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
  5580. if (props) {
  5581. this.init = props.init;
  5582. this.scope = props.scope;
  5583. this.name = props.name;
  5584. this.thedef = props.thedef;
  5585. this.start = props.start;
  5586. this.end = props.end;
  5587. }
  5588. this.flags = 0;
  5589. }, {
  5590. $documentation: "Symbol defining a function",
  5591. }, AST_SymbolDeclaration);
  5592. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  5593. if (props) {
  5594. this.scope = props.scope;
  5595. this.name = props.name;
  5596. this.thedef = props.thedef;
  5597. this.start = props.start;
  5598. this.end = props.end;
  5599. }
  5600. this.flags = 0;
  5601. }, {
  5602. $documentation: "Symbol in an object defining a method",
  5603. }, AST_Symbol);
  5604. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  5605. if (props) {
  5606. this.scope = props.scope;
  5607. this.name = props.name;
  5608. this.thedef = props.thedef;
  5609. this.start = props.start;
  5610. this.end = props.end;
  5611. }
  5612. this.flags = 0;
  5613. }, {
  5614. $documentation: "Symbol for a class property",
  5615. }, AST_Symbol);
  5616. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  5617. if (props) {
  5618. this.init = props.init;
  5619. this.scope = props.scope;
  5620. this.name = props.name;
  5621. this.thedef = props.thedef;
  5622. this.start = props.start;
  5623. this.end = props.end;
  5624. }
  5625. this.flags = 0;
  5626. }, {
  5627. $documentation: "Symbol naming a function expression",
  5628. }, AST_SymbolDeclaration);
  5629. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
  5630. if (props) {
  5631. this.init = props.init;
  5632. this.scope = props.scope;
  5633. this.name = props.name;
  5634. this.thedef = props.thedef;
  5635. this.start = props.start;
  5636. this.end = props.end;
  5637. }
  5638. this.flags = 0;
  5639. }, {
  5640. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  5641. }, AST_SymbolBlockDeclaration);
  5642. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
  5643. if (props) {
  5644. this.init = props.init;
  5645. this.scope = props.scope;
  5646. this.name = props.name;
  5647. this.thedef = props.thedef;
  5648. this.start = props.start;
  5649. this.end = props.end;
  5650. }
  5651. this.flags = 0;
  5652. }, {
  5653. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  5654. }, AST_SymbolDeclaration);
  5655. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
  5656. if (props) {
  5657. this.init = props.init;
  5658. this.scope = props.scope;
  5659. this.name = props.name;
  5660. this.thedef = props.thedef;
  5661. this.start = props.start;
  5662. this.end = props.end;
  5663. }
  5664. this.flags = 0;
  5665. }, {
  5666. $documentation: "Symbol naming the exception in catch",
  5667. }, AST_SymbolBlockDeclaration);
  5668. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
  5669. if (props) {
  5670. this.init = props.init;
  5671. this.scope = props.scope;
  5672. this.name = props.name;
  5673. this.thedef = props.thedef;
  5674. this.start = props.start;
  5675. this.end = props.end;
  5676. }
  5677. this.flags = 0;
  5678. }, {
  5679. $documentation: "Symbol referring to an imported name",
  5680. }, AST_SymbolBlockDeclaration);
  5681. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
  5682. if (props) {
  5683. this.scope = props.scope;
  5684. this.name = props.name;
  5685. this.thedef = props.thedef;
  5686. this.quote = props.quote;
  5687. this.start = props.start;
  5688. this.end = props.end;
  5689. }
  5690. this.flags = 0;
  5691. }, {
  5692. $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",
  5693. }, AST_Symbol);
  5694. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  5695. if (props) {
  5696. this.references = props.references;
  5697. this.scope = props.scope;
  5698. this.name = props.name;
  5699. this.thedef = props.thedef;
  5700. this.start = props.start;
  5701. this.end = props.end;
  5702. this.initialize();
  5703. }
  5704. this.flags = 0;
  5705. }, {
  5706. $documentation: "Symbol naming a label (declaration)",
  5707. $propdoc: {
  5708. references: "[AST_LoopControl*] a list of nodes referring to this label"
  5709. },
  5710. initialize: function() {
  5711. this.references = [];
  5712. this.thedef = this;
  5713. }
  5714. }, AST_Symbol);
  5715. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  5716. if (props) {
  5717. this.scope = props.scope;
  5718. this.name = props.name;
  5719. this.thedef = props.thedef;
  5720. this.start = props.start;
  5721. this.end = props.end;
  5722. }
  5723. this.flags = 0;
  5724. }, {
  5725. $documentation: "Reference to some symbol (not definition/declaration)",
  5726. }, AST_Symbol);
  5727. var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
  5728. if (props) {
  5729. this.scope = props.scope;
  5730. this.name = props.name;
  5731. this.thedef = props.thedef;
  5732. this.quote = props.quote;
  5733. this.start = props.start;
  5734. this.end = props.end;
  5735. }
  5736. this.flags = 0;
  5737. }, {
  5738. $documentation: "Symbol referring to a name to export",
  5739. }, AST_SymbolRef);
  5740. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
  5741. if (props) {
  5742. this.scope = props.scope;
  5743. this.name = props.name;
  5744. this.thedef = props.thedef;
  5745. this.quote = props.quote;
  5746. this.start = props.start;
  5747. this.end = props.end;
  5748. }
  5749. this.flags = 0;
  5750. }, {
  5751. $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",
  5752. }, AST_Symbol);
  5753. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  5754. if (props) {
  5755. this.scope = props.scope;
  5756. this.name = props.name;
  5757. this.thedef = props.thedef;
  5758. this.start = props.start;
  5759. this.end = props.end;
  5760. }
  5761. this.flags = 0;
  5762. }, {
  5763. $documentation: "Reference to a label symbol",
  5764. }, AST_Symbol);
  5765. var AST_SymbolPrivateProperty = DEFNODE("SymbolPrivateProperty", null, function AST_SymbolPrivateProperty(props) {
  5766. if (props) {
  5767. this.scope = props.scope;
  5768. this.name = props.name;
  5769. this.thedef = props.thedef;
  5770. this.start = props.start;
  5771. this.end = props.end;
  5772. }
  5773. this.flags = 0;
  5774. }, {
  5775. $documentation: "A symbol that refers to a private property",
  5776. }, AST_Symbol);
  5777. var AST_This = DEFNODE("This", null, function AST_This(props) {
  5778. if (props) {
  5779. this.scope = props.scope;
  5780. this.name = props.name;
  5781. this.thedef = props.thedef;
  5782. this.start = props.start;
  5783. this.end = props.end;
  5784. }
  5785. this.flags = 0;
  5786. }, {
  5787. $documentation: "The `this` symbol",
  5788. }, AST_Symbol);
  5789. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  5790. if (props) {
  5791. this.scope = props.scope;
  5792. this.name = props.name;
  5793. this.thedef = props.thedef;
  5794. this.start = props.start;
  5795. this.end = props.end;
  5796. }
  5797. this.flags = 0;
  5798. }, {
  5799. $documentation: "The `super` symbol",
  5800. }, AST_This);
  5801. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  5802. if (props) {
  5803. this.start = props.start;
  5804. this.end = props.end;
  5805. }
  5806. this.flags = 0;
  5807. }, {
  5808. $documentation: "Base class for all constants",
  5809. getValue: function() {
  5810. return this.value;
  5811. }
  5812. });
  5813. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  5814. if (props) {
  5815. this.value = props.value;
  5816. this.quote = props.quote;
  5817. this.start = props.start;
  5818. this.end = props.end;
  5819. this._annotations = props._annotations;
  5820. }
  5821. this.flags = 0;
  5822. }, {
  5823. $documentation: "A string literal",
  5824. $propdoc: {
  5825. value: "[string] the contents of this string",
  5826. quote: "[string] the original quote character"
  5827. }
  5828. }, AST_Constant);
  5829. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  5830. if (props) {
  5831. this.value = props.value;
  5832. this.raw = props.raw;
  5833. this.start = props.start;
  5834. this.end = props.end;
  5835. }
  5836. this.flags = 0;
  5837. }, {
  5838. $documentation: "A number literal",
  5839. $propdoc: {
  5840. value: "[number] the numeric value",
  5841. raw: "[string] numeric value as string"
  5842. }
  5843. }, AST_Constant);
  5844. var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
  5845. if (props) {
  5846. this.value = props.value;
  5847. this.start = props.start;
  5848. this.end = props.end;
  5849. }
  5850. this.flags = 0;
  5851. }, {
  5852. $documentation: "A big int literal",
  5853. $propdoc: {
  5854. value: "[string] big int value"
  5855. }
  5856. }, AST_Constant);
  5857. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  5858. if (props) {
  5859. this.value = props.value;
  5860. this.start = props.start;
  5861. this.end = props.end;
  5862. }
  5863. this.flags = 0;
  5864. }, {
  5865. $documentation: "A regexp literal",
  5866. $propdoc: {
  5867. value: "[RegExp] the actual regexp",
  5868. }
  5869. }, AST_Constant);
  5870. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  5871. if (props) {
  5872. this.start = props.start;
  5873. this.end = props.end;
  5874. }
  5875. this.flags = 0;
  5876. }, {
  5877. $documentation: "Base class for atoms",
  5878. }, AST_Constant);
  5879. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  5880. if (props) {
  5881. this.start = props.start;
  5882. this.end = props.end;
  5883. }
  5884. this.flags = 0;
  5885. }, {
  5886. $documentation: "The `null` atom",
  5887. value: null
  5888. }, AST_Atom);
  5889. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  5890. if (props) {
  5891. this.start = props.start;
  5892. this.end = props.end;
  5893. }
  5894. this.flags = 0;
  5895. }, {
  5896. $documentation: "The impossible value",
  5897. value: 0/0
  5898. }, AST_Atom);
  5899. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  5900. if (props) {
  5901. this.start = props.start;
  5902. this.end = props.end;
  5903. }
  5904. this.flags = 0;
  5905. }, {
  5906. $documentation: "The `undefined` value",
  5907. value: (function() {}())
  5908. }, AST_Atom);
  5909. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  5910. if (props) {
  5911. this.start = props.start;
  5912. this.end = props.end;
  5913. }
  5914. this.flags = 0;
  5915. }, {
  5916. $documentation: "A hole in an array",
  5917. value: (function() {}())
  5918. }, AST_Atom);
  5919. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  5920. if (props) {
  5921. this.start = props.start;
  5922. this.end = props.end;
  5923. }
  5924. this.flags = 0;
  5925. }, {
  5926. $documentation: "The `Infinity` value",
  5927. value: 1/0
  5928. }, AST_Atom);
  5929. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  5930. if (props) {
  5931. this.start = props.start;
  5932. this.end = props.end;
  5933. }
  5934. this.flags = 0;
  5935. }, {
  5936. $documentation: "Base class for booleans",
  5937. }, AST_Atom);
  5938. var AST_False = DEFNODE("False", null, function AST_False(props) {
  5939. if (props) {
  5940. this.start = props.start;
  5941. this.end = props.end;
  5942. }
  5943. this.flags = 0;
  5944. }, {
  5945. $documentation: "The `false` atom",
  5946. value: false
  5947. }, AST_Boolean);
  5948. var AST_True = DEFNODE("True", null, function AST_True(props) {
  5949. if (props) {
  5950. this.start = props.start;
  5951. this.end = props.end;
  5952. }
  5953. this.flags = 0;
  5954. }, {
  5955. $documentation: "The `true` atom",
  5956. value: true
  5957. }, AST_Boolean);
  5958. /* -----[ Walk function ]---- */
  5959. /**
  5960. * Walk nodes in depth-first search fashion.
  5961. * Callback can return `walk_abort` symbol to stop iteration.
  5962. * It can also return `true` to stop iteration just for child nodes.
  5963. * Iteration can be stopped and continued by passing the `to_visit` argument,
  5964. * which is given to the callback in the second argument.
  5965. **/
  5966. function walk(node, cb, to_visit = [node]) {
  5967. const push = to_visit.push.bind(to_visit);
  5968. while (to_visit.length) {
  5969. const node = to_visit.pop();
  5970. const ret = cb(node, to_visit);
  5971. if (ret) {
  5972. if (ret === walk_abort) return true;
  5973. continue;
  5974. }
  5975. node._children_backwards(push);
  5976. }
  5977. return false;
  5978. }
  5979. /**
  5980. * Walks an AST node and its children.
  5981. *
  5982. * {cb} can return `walk_abort` to interrupt the walk.
  5983. *
  5984. * @param node
  5985. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  5986. *
  5987. * @returns {boolean} whether the walk was aborted
  5988. *
  5989. * @example
  5990. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  5991. * if (some_cond(node, parent())) return walk_abort
  5992. * });
  5993. */
  5994. function walk_parent(node, cb, initial_stack) {
  5995. const to_visit = [node];
  5996. const push = to_visit.push.bind(to_visit);
  5997. const stack = initial_stack ? initial_stack.slice() : [];
  5998. const parent_pop_indices = [];
  5999. let current;
  6000. const info = {
  6001. parent: (n = 0) => {
  6002. if (n === -1) {
  6003. return current;
  6004. }
  6005. // [ p1 p0 ] [ 1 0 ]
  6006. if (initial_stack && n >= stack.length) {
  6007. n -= stack.length;
  6008. return initial_stack[
  6009. initial_stack.length - (n + 1)
  6010. ];
  6011. }
  6012. return stack[stack.length - (1 + n)];
  6013. },
  6014. };
  6015. while (to_visit.length) {
  6016. current = to_visit.pop();
  6017. while (
  6018. parent_pop_indices.length &&
  6019. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  6020. ) {
  6021. stack.pop();
  6022. parent_pop_indices.pop();
  6023. }
  6024. const ret = cb(current, info);
  6025. if (ret) {
  6026. if (ret === walk_abort) return true;
  6027. continue;
  6028. }
  6029. const visit_length = to_visit.length;
  6030. current._children_backwards(push);
  6031. // Push only if we're going to traverse the children
  6032. if (to_visit.length > visit_length) {
  6033. stack.push(current);
  6034. parent_pop_indices.push(visit_length - 1);
  6035. }
  6036. }
  6037. return false;
  6038. }
  6039. const walk_abort = Symbol("abort walk");
  6040. /* -----[ TreeWalker ]----- */
  6041. class TreeWalker {
  6042. constructor(callback) {
  6043. this.visit = callback;
  6044. this.stack = [];
  6045. this.directives = Object.create(null);
  6046. }
  6047. _visit(node, descend) {
  6048. this.push(node);
  6049. var ret = this.visit(node, descend ? function() {
  6050. descend.call(node);
  6051. } : noop);
  6052. if (!ret && descend) {
  6053. descend.call(node);
  6054. }
  6055. this.pop();
  6056. return ret;
  6057. }
  6058. parent(n) {
  6059. return this.stack[this.stack.length - 2 - (n || 0)];
  6060. }
  6061. push(node) {
  6062. if (node instanceof AST_Lambda) {
  6063. this.directives = Object.create(this.directives);
  6064. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  6065. this.directives[node.value] = node;
  6066. } else if (node instanceof AST_Class) {
  6067. this.directives = Object.create(this.directives);
  6068. if (!this.directives["use strict"]) {
  6069. this.directives["use strict"] = node;
  6070. }
  6071. }
  6072. this.stack.push(node);
  6073. }
  6074. pop() {
  6075. var node = this.stack.pop();
  6076. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  6077. this.directives = Object.getPrototypeOf(this.directives);
  6078. }
  6079. }
  6080. self() {
  6081. return this.stack[this.stack.length - 1];
  6082. }
  6083. find_parent(type) {
  6084. var stack = this.stack;
  6085. for (var i = stack.length; --i >= 0;) {
  6086. var x = stack[i];
  6087. if (x instanceof type) return x;
  6088. }
  6089. }
  6090. find_scope() {
  6091. var stack = this.stack;
  6092. for (var i = stack.length; --i >= 0;) {
  6093. const p = stack[i];
  6094. if (p instanceof AST_Toplevel) return p;
  6095. if (p instanceof AST_Lambda) return p;
  6096. if (p.block_scope) return p.block_scope;
  6097. }
  6098. }
  6099. has_directive(type) {
  6100. var dir = this.directives[type];
  6101. if (dir) return dir;
  6102. var node = this.stack[this.stack.length - 1];
  6103. if (node instanceof AST_Scope && node.body) {
  6104. for (var i = 0; i < node.body.length; ++i) {
  6105. var st = node.body[i];
  6106. if (!(st instanceof AST_Directive)) break;
  6107. if (st.value == type) return st;
  6108. }
  6109. }
  6110. }
  6111. loopcontrol_target(node) {
  6112. var stack = this.stack;
  6113. if (node.label) for (var i = stack.length; --i >= 0;) {
  6114. var x = stack[i];
  6115. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  6116. return x.body;
  6117. } else for (var i = stack.length; --i >= 0;) {
  6118. var x = stack[i];
  6119. if (x instanceof AST_IterationStatement
  6120. || node instanceof AST_Break && x instanceof AST_Switch)
  6121. return x;
  6122. }
  6123. }
  6124. }
  6125. // Tree transformer helpers.
  6126. class TreeTransformer extends TreeWalker {
  6127. constructor(before, after) {
  6128. super();
  6129. this.before = before;
  6130. this.after = after;
  6131. }
  6132. }
  6133. const _PURE = 0b00000001;
  6134. const _INLINE = 0b00000010;
  6135. const _NOINLINE = 0b00000100;
  6136. const _KEY = 0b00001000;
  6137. const _MANGLEPROP = 0b00010000;
  6138. /***********************************************************************
  6139. A JavaScript tokenizer / parser / beautifier / compressor.
  6140. https://github.com/mishoo/UglifyJS2
  6141. -------------------------------- (C) ---------------------------------
  6142. Author: Mihai Bazon
  6143. <mihai.bazon@gmail.com>
  6144. http://mihai.bazon.net/blog
  6145. Distributed under the BSD license:
  6146. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6147. Redistribution and use in source and binary forms, with or without
  6148. modification, are permitted provided that the following conditions
  6149. are met:
  6150. * Redistributions of source code must retain the above
  6151. copyright notice, this list of conditions and the following
  6152. disclaimer.
  6153. * Redistributions in binary form must reproduce the above
  6154. copyright notice, this list of conditions and the following
  6155. disclaimer in the documentation and/or other materials
  6156. provided with the distribution.
  6157. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6158. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6159. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6160. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6161. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6162. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6163. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6164. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6165. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6166. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6167. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6168. SUCH DAMAGE.
  6169. ***********************************************************************/
  6170. function def_transform(node, descend) {
  6171. node.DEFMETHOD("transform", function(tw, in_list) {
  6172. let transformed = undefined;
  6173. tw.push(this);
  6174. if (tw.before) transformed = tw.before(this, descend, in_list);
  6175. if (transformed === undefined) {
  6176. transformed = this;
  6177. descend(transformed, tw);
  6178. if (tw.after) {
  6179. const after_ret = tw.after(transformed, in_list);
  6180. if (after_ret !== undefined) transformed = after_ret;
  6181. }
  6182. }
  6183. tw.pop();
  6184. return transformed;
  6185. });
  6186. }
  6187. def_transform(AST_Node, noop);
  6188. def_transform(AST_LabeledStatement, function(self, tw) {
  6189. self.label = self.label.transform(tw);
  6190. self.body = self.body.transform(tw);
  6191. });
  6192. def_transform(AST_SimpleStatement, function(self, tw) {
  6193. self.body = self.body.transform(tw);
  6194. });
  6195. def_transform(AST_Block, function(self, tw) {
  6196. self.body = MAP(self.body, tw);
  6197. });
  6198. def_transform(AST_Do, function(self, tw) {
  6199. self.body = self.body.transform(tw);
  6200. self.condition = self.condition.transform(tw);
  6201. });
  6202. def_transform(AST_While, function(self, tw) {
  6203. self.condition = self.condition.transform(tw);
  6204. self.body = self.body.transform(tw);
  6205. });
  6206. def_transform(AST_For, function(self, tw) {
  6207. if (self.init) self.init = self.init.transform(tw);
  6208. if (self.condition) self.condition = self.condition.transform(tw);
  6209. if (self.step) self.step = self.step.transform(tw);
  6210. self.body = self.body.transform(tw);
  6211. });
  6212. def_transform(AST_ForIn, function(self, tw) {
  6213. self.init = self.init.transform(tw);
  6214. self.object = self.object.transform(tw);
  6215. self.body = self.body.transform(tw);
  6216. });
  6217. def_transform(AST_With, function(self, tw) {
  6218. self.expression = self.expression.transform(tw);
  6219. self.body = self.body.transform(tw);
  6220. });
  6221. def_transform(AST_Exit, function(self, tw) {
  6222. if (self.value) self.value = self.value.transform(tw);
  6223. });
  6224. def_transform(AST_LoopControl, function(self, tw) {
  6225. if (self.label) self.label = self.label.transform(tw);
  6226. });
  6227. def_transform(AST_If, function(self, tw) {
  6228. self.condition = self.condition.transform(tw);
  6229. self.body = self.body.transform(tw);
  6230. if (self.alternative) self.alternative = self.alternative.transform(tw);
  6231. });
  6232. def_transform(AST_Switch, function(self, tw) {
  6233. self.expression = self.expression.transform(tw);
  6234. self.body = MAP(self.body, tw);
  6235. });
  6236. def_transform(AST_Case, function(self, tw) {
  6237. self.expression = self.expression.transform(tw);
  6238. self.body = MAP(self.body, tw);
  6239. });
  6240. def_transform(AST_Try, function(self, tw) {
  6241. self.body = self.body.transform(tw);
  6242. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  6243. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  6244. });
  6245. def_transform(AST_Catch, function(self, tw) {
  6246. if (self.argname) self.argname = self.argname.transform(tw);
  6247. self.body = MAP(self.body, tw);
  6248. });
  6249. def_transform(AST_Definitions, function(self, tw) {
  6250. self.definitions = MAP(self.definitions, tw);
  6251. });
  6252. def_transform(AST_VarDef, function(self, tw) {
  6253. self.name = self.name.transform(tw);
  6254. if (self.value) self.value = self.value.transform(tw);
  6255. });
  6256. def_transform(AST_Destructuring, function(self, tw) {
  6257. self.names = MAP(self.names, tw);
  6258. });
  6259. def_transform(AST_Lambda, function(self, tw) {
  6260. if (self.name) self.name = self.name.transform(tw);
  6261. self.argnames = MAP(self.argnames, tw, /* allow_splicing */ false);
  6262. if (self.body instanceof AST_Node) {
  6263. self.body = self.body.transform(tw);
  6264. } else {
  6265. self.body = MAP(self.body, tw);
  6266. }
  6267. });
  6268. def_transform(AST_Call, function(self, tw) {
  6269. self.expression = self.expression.transform(tw);
  6270. self.args = MAP(self.args, tw, /* allow_splicing */ false);
  6271. });
  6272. def_transform(AST_Sequence, function(self, tw) {
  6273. const result = MAP(self.expressions, tw);
  6274. self.expressions = result.length
  6275. ? result
  6276. : [new AST_Number({ value: 0 })];
  6277. });
  6278. def_transform(AST_PropAccess, function(self, tw) {
  6279. self.expression = self.expression.transform(tw);
  6280. });
  6281. def_transform(AST_Sub, function(self, tw) {
  6282. self.expression = self.expression.transform(tw);
  6283. self.property = self.property.transform(tw);
  6284. });
  6285. def_transform(AST_Chain, function(self, tw) {
  6286. self.expression = self.expression.transform(tw);
  6287. });
  6288. def_transform(AST_Yield, function(self, tw) {
  6289. if (self.expression) self.expression = self.expression.transform(tw);
  6290. });
  6291. def_transform(AST_Await, function(self, tw) {
  6292. self.expression = self.expression.transform(tw);
  6293. });
  6294. def_transform(AST_Unary, function(self, tw) {
  6295. self.expression = self.expression.transform(tw);
  6296. });
  6297. def_transform(AST_Binary, function(self, tw) {
  6298. self.left = self.left.transform(tw);
  6299. self.right = self.right.transform(tw);
  6300. });
  6301. def_transform(AST_PrivateIn, function(self, tw) {
  6302. self.key = self.key.transform(tw);
  6303. self.value = self.value.transform(tw);
  6304. });
  6305. def_transform(AST_Conditional, function(self, tw) {
  6306. self.condition = self.condition.transform(tw);
  6307. self.consequent = self.consequent.transform(tw);
  6308. self.alternative = self.alternative.transform(tw);
  6309. });
  6310. def_transform(AST_Array, function(self, tw) {
  6311. self.elements = MAP(self.elements, tw);
  6312. });
  6313. def_transform(AST_Object, function(self, tw) {
  6314. self.properties = MAP(self.properties, tw);
  6315. });
  6316. def_transform(AST_ObjectProperty, function(self, tw) {
  6317. if (self.key instanceof AST_Node) {
  6318. self.key = self.key.transform(tw);
  6319. }
  6320. if (self.value) self.value = self.value.transform(tw);
  6321. });
  6322. def_transform(AST_Class, function(self, tw) {
  6323. if (self.name) self.name = self.name.transform(tw);
  6324. if (self.extends) self.extends = self.extends.transform(tw);
  6325. self.properties = MAP(self.properties, tw);
  6326. });
  6327. def_transform(AST_ClassStaticBlock, function(self, tw) {
  6328. self.body = MAP(self.body, tw);
  6329. });
  6330. def_transform(AST_Expansion, function(self, tw) {
  6331. self.expression = self.expression.transform(tw);
  6332. });
  6333. def_transform(AST_NameMapping, function(self, tw) {
  6334. self.foreign_name = self.foreign_name.transform(tw);
  6335. self.name = self.name.transform(tw);
  6336. });
  6337. def_transform(AST_Import, function(self, tw) {
  6338. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  6339. if (self.imported_names) MAP(self.imported_names, tw);
  6340. self.module_name = self.module_name.transform(tw);
  6341. });
  6342. def_transform(AST_Export, function(self, tw) {
  6343. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  6344. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  6345. if (self.exported_names) MAP(self.exported_names, tw);
  6346. if (self.module_name) self.module_name = self.module_name.transform(tw);
  6347. });
  6348. def_transform(AST_TemplateString, function(self, tw) {
  6349. self.segments = MAP(self.segments, tw);
  6350. });
  6351. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  6352. self.prefix = self.prefix.transform(tw);
  6353. self.template_string = self.template_string.transform(tw);
  6354. });
  6355. /***********************************************************************
  6356. A JavaScript tokenizer / parser / beautifier / compressor.
  6357. https://github.com/mishoo/UglifyJS2
  6358. -------------------------------- (C) ---------------------------------
  6359. Author: Mihai Bazon
  6360. <mihai.bazon@gmail.com>
  6361. http://mihai.bazon.net/blog
  6362. Distributed under the BSD license:
  6363. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6364. Redistribution and use in source and binary forms, with or without
  6365. modification, are permitted provided that the following conditions
  6366. are met:
  6367. * Redistributions of source code must retain the above
  6368. copyright notice, this list of conditions and the following
  6369. disclaimer.
  6370. * Redistributions in binary form must reproduce the above
  6371. copyright notice, this list of conditions and the following
  6372. disclaimer in the documentation and/or other materials
  6373. provided with the distribution.
  6374. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6375. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6376. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6377. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6378. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6379. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6380. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6381. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6382. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6383. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6384. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6385. SUCH DAMAGE.
  6386. ***********************************************************************/
  6387. (function() {
  6388. var normalize_directives = function(body) {
  6389. for (var i = 0; i < body.length; i++) {
  6390. if (body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  6391. body[i] = new AST_Directive({
  6392. start: body[i].start,
  6393. end: body[i].end,
  6394. value: body[i].body.value
  6395. });
  6396. } else {
  6397. return body;
  6398. }
  6399. }
  6400. return body;
  6401. };
  6402. const assert_clause_from_moz = (assertions) => {
  6403. if (assertions && assertions.length > 0) {
  6404. return new AST_Object({
  6405. start: my_start_token(assertions),
  6406. end: my_end_token(assertions),
  6407. properties: assertions.map((assertion_kv) =>
  6408. new AST_ObjectKeyVal({
  6409. start: my_start_token(assertion_kv),
  6410. end: my_end_token(assertion_kv),
  6411. key: assertion_kv.key.name || assertion_kv.key.value,
  6412. value: from_moz(assertion_kv.value)
  6413. })
  6414. )
  6415. });
  6416. }
  6417. return null;
  6418. };
  6419. var MOZ_TO_ME = {
  6420. Program: function(M) {
  6421. return new AST_Toplevel({
  6422. start: my_start_token(M),
  6423. end: my_end_token(M),
  6424. body: normalize_directives(M.body.map(from_moz))
  6425. });
  6426. },
  6427. ArrayPattern: function(M) {
  6428. return new AST_Destructuring({
  6429. start: my_start_token(M),
  6430. end: my_end_token(M),
  6431. names: M.elements.map(function(elm) {
  6432. if (elm === null) {
  6433. return new AST_Hole();
  6434. }
  6435. return from_moz(elm);
  6436. }),
  6437. is_array: true
  6438. });
  6439. },
  6440. ObjectPattern: function(M) {
  6441. return new AST_Destructuring({
  6442. start: my_start_token(M),
  6443. end: my_end_token(M),
  6444. names: M.properties.map(from_moz),
  6445. is_array: false
  6446. });
  6447. },
  6448. AssignmentPattern: function(M) {
  6449. return new AST_DefaultAssign({
  6450. start: my_start_token(M),
  6451. end: my_end_token(M),
  6452. left: from_moz(M.left),
  6453. operator: "=",
  6454. right: from_moz(M.right)
  6455. });
  6456. },
  6457. SpreadElement: function(M) {
  6458. return new AST_Expansion({
  6459. start: my_start_token(M),
  6460. end: my_end_token(M),
  6461. expression: from_moz(M.argument)
  6462. });
  6463. },
  6464. RestElement: function(M) {
  6465. return new AST_Expansion({
  6466. start: my_start_token(M),
  6467. end: my_end_token(M),
  6468. expression: from_moz(M.argument)
  6469. });
  6470. },
  6471. TemplateElement: function(M) {
  6472. return new AST_TemplateSegment({
  6473. start: my_start_token(M),
  6474. end: my_end_token(M),
  6475. value: M.value.cooked,
  6476. raw: M.value.raw
  6477. });
  6478. },
  6479. TemplateLiteral: function(M) {
  6480. var segments = [];
  6481. for (var i = 0; i < M.quasis.length; i++) {
  6482. segments.push(from_moz(M.quasis[i]));
  6483. if (M.expressions[i]) {
  6484. segments.push(from_moz(M.expressions[i]));
  6485. }
  6486. }
  6487. return new AST_TemplateString({
  6488. start: my_start_token(M),
  6489. end: my_end_token(M),
  6490. segments: segments
  6491. });
  6492. },
  6493. TaggedTemplateExpression: function(M) {
  6494. return new AST_PrefixedTemplateString({
  6495. start: my_start_token(M),
  6496. end: my_end_token(M),
  6497. template_string: from_moz(M.quasi),
  6498. prefix: from_moz(M.tag)
  6499. });
  6500. },
  6501. FunctionDeclaration: function(M) {
  6502. return new AST_Defun({
  6503. start: my_start_token(M),
  6504. end: my_end_token(M),
  6505. name: from_moz(M.id),
  6506. argnames: M.params.map(from_moz),
  6507. is_generator: M.generator,
  6508. async: M.async,
  6509. body: normalize_directives(from_moz(M.body).body)
  6510. });
  6511. },
  6512. FunctionExpression: function(M) {
  6513. return new AST_Function({
  6514. start: my_start_token(M),
  6515. end: my_end_token(M),
  6516. name: from_moz(M.id),
  6517. argnames: M.params.map(from_moz),
  6518. is_generator: M.generator,
  6519. async: M.async,
  6520. body: normalize_directives(from_moz(M.body).body)
  6521. });
  6522. },
  6523. ArrowFunctionExpression: function(M) {
  6524. const body = M.body.type === "BlockStatement"
  6525. ? from_moz(M.body).body
  6526. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  6527. return new AST_Arrow({
  6528. start: my_start_token(M),
  6529. end: my_end_token(M),
  6530. argnames: M.params.map(from_moz),
  6531. body,
  6532. async: M.async,
  6533. });
  6534. },
  6535. ExpressionStatement: function(M) {
  6536. return new AST_SimpleStatement({
  6537. start: my_start_token(M),
  6538. end: my_end_token(M),
  6539. body: from_moz(M.expression)
  6540. });
  6541. },
  6542. TryStatement: function(M) {
  6543. var handlers = M.handlers || [M.handler];
  6544. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  6545. throw new Error("Multiple catch clauses are not supported.");
  6546. }
  6547. return new AST_Try({
  6548. start : my_start_token(M),
  6549. end : my_end_token(M),
  6550. body : new AST_TryBlock(from_moz(M.block)),
  6551. bcatch : from_moz(handlers[0]),
  6552. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  6553. });
  6554. },
  6555. Property: function(M) {
  6556. var key = M.key;
  6557. var args = {
  6558. start : my_start_token(key || M.value),
  6559. end : my_end_token(M.value),
  6560. key : key.type == "Identifier" ? key.name : key.value,
  6561. value : from_moz(M.value)
  6562. };
  6563. if (M.computed) {
  6564. args.key = from_moz(M.key);
  6565. }
  6566. if (M.method) {
  6567. args.is_generator = M.value.generator;
  6568. args.async = M.value.async;
  6569. if (!M.computed) {
  6570. args.key = new AST_SymbolMethod({ name: args.key });
  6571. } else {
  6572. args.key = from_moz(M.key);
  6573. }
  6574. return new AST_ConciseMethod(args);
  6575. }
  6576. if (M.kind == "init") {
  6577. if (key.type != "Identifier" && key.type != "Literal") {
  6578. args.key = from_moz(key);
  6579. }
  6580. return new AST_ObjectKeyVal(args);
  6581. }
  6582. if (typeof args.key === "string" || typeof args.key === "number") {
  6583. args.key = new AST_SymbolMethod({
  6584. name: args.key
  6585. });
  6586. }
  6587. args.value = new AST_Accessor(args.value);
  6588. if (M.kind == "get") return new AST_ObjectGetter(args);
  6589. if (M.kind == "set") return new AST_ObjectSetter(args);
  6590. if (M.kind == "method") {
  6591. args.async = M.value.async;
  6592. args.is_generator = M.value.generator;
  6593. args.quote = M.computed ? "\"" : null;
  6594. return new AST_ConciseMethod(args);
  6595. }
  6596. },
  6597. MethodDefinition: function(M) {
  6598. const is_private = M.key.type === "PrivateIdentifier";
  6599. const key = M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value });
  6600. var args = {
  6601. start : my_start_token(M),
  6602. end : my_end_token(M),
  6603. key,
  6604. value : from_moz(M.value),
  6605. static : M.static,
  6606. };
  6607. if (M.kind == "get") {
  6608. return new (is_private ? AST_PrivateGetter : AST_ObjectGetter)(args);
  6609. }
  6610. if (M.kind == "set") {
  6611. return new (is_private ? AST_PrivateSetter : AST_ObjectSetter)(args);
  6612. }
  6613. args.is_generator = M.value.generator;
  6614. args.async = M.value.async;
  6615. return new (is_private ? AST_PrivateMethod : AST_ConciseMethod)(args);
  6616. },
  6617. FieldDefinition: function(M) {
  6618. let key;
  6619. if (M.computed) {
  6620. key = from_moz(M.key);
  6621. } else {
  6622. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  6623. key = from_moz(M.key);
  6624. }
  6625. return new AST_ClassProperty({
  6626. start : my_start_token(M),
  6627. end : my_end_token(M),
  6628. key,
  6629. value : from_moz(M.value),
  6630. static : M.static,
  6631. });
  6632. },
  6633. PropertyDefinition: function(M) {
  6634. let key;
  6635. if (M.computed) {
  6636. key = from_moz(M.key);
  6637. } else if (M.key.type === "PrivateIdentifier") {
  6638. return new AST_ClassPrivateProperty({
  6639. start : my_start_token(M),
  6640. end : my_end_token(M),
  6641. key : from_moz(M.key),
  6642. value : from_moz(M.value),
  6643. static : M.static,
  6644. });
  6645. } else {
  6646. if (M.key.type !== "Identifier") {
  6647. throw new Error("Non-Identifier key in PropertyDefinition");
  6648. }
  6649. key = from_moz(M.key);
  6650. }
  6651. return new AST_ClassProperty({
  6652. start : my_start_token(M),
  6653. end : my_end_token(M),
  6654. key,
  6655. value : from_moz(M.value),
  6656. static : M.static,
  6657. });
  6658. },
  6659. PrivateIdentifier: function (M) {
  6660. return new AST_SymbolPrivateProperty({
  6661. start: my_start_token(M),
  6662. end: my_end_token(M),
  6663. name: M.name
  6664. });
  6665. },
  6666. StaticBlock: function(M) {
  6667. return new AST_ClassStaticBlock({
  6668. start : my_start_token(M),
  6669. end : my_end_token(M),
  6670. body : M.body.map(from_moz),
  6671. });
  6672. },
  6673. ArrayExpression: function(M) {
  6674. return new AST_Array({
  6675. start : my_start_token(M),
  6676. end : my_end_token(M),
  6677. elements : M.elements.map(function(elem) {
  6678. return elem === null ? new AST_Hole() : from_moz(elem);
  6679. })
  6680. });
  6681. },
  6682. ObjectExpression: function(M) {
  6683. return new AST_Object({
  6684. start : my_start_token(M),
  6685. end : my_end_token(M),
  6686. properties : M.properties.map(function(prop) {
  6687. if (prop.type === "SpreadElement") {
  6688. return from_moz(prop);
  6689. }
  6690. prop.type = "Property";
  6691. return from_moz(prop);
  6692. })
  6693. });
  6694. },
  6695. SequenceExpression: function(M) {
  6696. return new AST_Sequence({
  6697. start : my_start_token(M),
  6698. end : my_end_token(M),
  6699. expressions: M.expressions.map(from_moz)
  6700. });
  6701. },
  6702. MemberExpression: function(M) {
  6703. if (M.property.type === "PrivateIdentifier") {
  6704. return new AST_DotHash({
  6705. start : my_start_token(M),
  6706. end : my_end_token(M),
  6707. property : M.property.name,
  6708. expression : from_moz(M.object),
  6709. optional : M.optional || false
  6710. });
  6711. }
  6712. return new (M.computed ? AST_Sub : AST_Dot)({
  6713. start : my_start_token(M),
  6714. end : my_end_token(M),
  6715. property : M.computed ? from_moz(M.property) : M.property.name,
  6716. expression : from_moz(M.object),
  6717. optional : M.optional || false
  6718. });
  6719. },
  6720. ChainExpression: function(M) {
  6721. return new AST_Chain({
  6722. start : my_start_token(M),
  6723. end : my_end_token(M),
  6724. expression : from_moz(M.expression)
  6725. });
  6726. },
  6727. SwitchCase: function(M) {
  6728. return new (M.test ? AST_Case : AST_Default)({
  6729. start : my_start_token(M),
  6730. end : my_end_token(M),
  6731. expression : from_moz(M.test),
  6732. body : M.consequent.map(from_moz)
  6733. });
  6734. },
  6735. VariableDeclaration: function(M) {
  6736. return new (M.kind === "const" ? AST_Const :
  6737. M.kind === "let" ? AST_Let : AST_Var)({
  6738. start : my_start_token(M),
  6739. end : my_end_token(M),
  6740. definitions : M.declarations.map(from_moz)
  6741. });
  6742. },
  6743. ImportDeclaration: function(M) {
  6744. var imported_name = null;
  6745. var imported_names = null;
  6746. M.specifiers.forEach(function (specifier) {
  6747. if (specifier.type === "ImportSpecifier" || specifier.type === "ImportNamespaceSpecifier") {
  6748. if (!imported_names) { imported_names = []; }
  6749. imported_names.push(from_moz(specifier));
  6750. } else if (specifier.type === "ImportDefaultSpecifier") {
  6751. imported_name = from_moz(specifier);
  6752. }
  6753. });
  6754. return new AST_Import({
  6755. start : my_start_token(M),
  6756. end : my_end_token(M),
  6757. imported_name: imported_name,
  6758. imported_names : imported_names,
  6759. module_name : from_moz(M.source),
  6760. assert_clause: assert_clause_from_moz(M.assertions)
  6761. });
  6762. },
  6763. ImportSpecifier: function(M) {
  6764. return new AST_NameMapping({
  6765. start: my_start_token(M),
  6766. end: my_end_token(M),
  6767. foreign_name: from_moz(M.imported),
  6768. name: from_moz(M.local)
  6769. });
  6770. },
  6771. ImportDefaultSpecifier: function(M) {
  6772. return from_moz(M.local);
  6773. },
  6774. ImportNamespaceSpecifier: function(M) {
  6775. return new AST_NameMapping({
  6776. start: my_start_token(M),
  6777. end: my_end_token(M),
  6778. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  6779. name: from_moz(M.local)
  6780. });
  6781. },
  6782. ExportAllDeclaration: function(M) {
  6783. var foreign_name = M.exported == null ?
  6784. new AST_SymbolExportForeign({ name: "*" }) :
  6785. from_moz(M.exported);
  6786. return new AST_Export({
  6787. start: my_start_token(M),
  6788. end: my_end_token(M),
  6789. exported_names: [
  6790. new AST_NameMapping({
  6791. name: new AST_SymbolExportForeign({ name: "*" }),
  6792. foreign_name: foreign_name
  6793. })
  6794. ],
  6795. module_name: from_moz(M.source),
  6796. assert_clause: assert_clause_from_moz(M.assertions)
  6797. });
  6798. },
  6799. ExportNamedDeclaration: function(M) {
  6800. return new AST_Export({
  6801. start: my_start_token(M),
  6802. end: my_end_token(M),
  6803. exported_definition: from_moz(M.declaration),
  6804. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : null,
  6805. module_name: from_moz(M.source),
  6806. assert_clause: assert_clause_from_moz(M.assertions)
  6807. });
  6808. },
  6809. ExportDefaultDeclaration: function(M) {
  6810. return new AST_Export({
  6811. start: my_start_token(M),
  6812. end: my_end_token(M),
  6813. exported_value: from_moz(M.declaration),
  6814. is_default: true
  6815. });
  6816. },
  6817. ExportSpecifier: function(M) {
  6818. return new AST_NameMapping({
  6819. foreign_name: from_moz(M.exported),
  6820. name: from_moz(M.local)
  6821. });
  6822. },
  6823. Literal: function(M) {
  6824. var val = M.value, args = {
  6825. start : my_start_token(M),
  6826. end : my_end_token(M)
  6827. };
  6828. var rx = M.regex;
  6829. if (rx && rx.pattern) {
  6830. // RegExpLiteral as per ESTree AST spec
  6831. args.value = {
  6832. source: rx.pattern,
  6833. flags: rx.flags
  6834. };
  6835. return new AST_RegExp(args);
  6836. } else if (rx) {
  6837. // support legacy RegExp
  6838. const rx_source = M.raw || val;
  6839. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  6840. if (!match) throw new Error("Invalid regex source " + rx_source);
  6841. const [_, source, flags] = match;
  6842. args.value = { source, flags };
  6843. return new AST_RegExp(args);
  6844. }
  6845. if (val === null) return new AST_Null(args);
  6846. switch (typeof val) {
  6847. case "string":
  6848. args.quote = "\"";
  6849. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6850. if (p.type == "ImportSpecifier") {
  6851. args.name = val;
  6852. return new AST_SymbolImportForeign(args);
  6853. } else if (p.type == "ExportSpecifier") {
  6854. args.name = val;
  6855. if (M == p.exported) {
  6856. return new AST_SymbolExportForeign(args);
  6857. } else {
  6858. return new AST_SymbolExport(args);
  6859. }
  6860. } else if (p.type == "ExportAllDeclaration" && M == p.exported) {
  6861. args.name = val;
  6862. return new AST_SymbolExportForeign(args);
  6863. }
  6864. args.value = val;
  6865. return new AST_String(args);
  6866. case "number":
  6867. args.value = val;
  6868. args.raw = M.raw || val.toString();
  6869. return new AST_Number(args);
  6870. case "boolean":
  6871. return new (val ? AST_True : AST_False)(args);
  6872. }
  6873. },
  6874. MetaProperty: function(M) {
  6875. if (M.meta.name === "new" && M.property.name === "target") {
  6876. return new AST_NewTarget({
  6877. start: my_start_token(M),
  6878. end: my_end_token(M)
  6879. });
  6880. } else if (M.meta.name === "import" && M.property.name === "meta") {
  6881. return new AST_ImportMeta({
  6882. start: my_start_token(M),
  6883. end: my_end_token(M)
  6884. });
  6885. }
  6886. },
  6887. Identifier: function(M) {
  6888. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6889. return new ( p.type == "LabeledStatement" ? AST_Label
  6890. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  6891. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  6892. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  6893. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  6894. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  6895. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  6896. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  6897. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  6898. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  6899. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  6900. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  6901. : p.type == "CatchClause" ? AST_SymbolCatch
  6902. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  6903. : AST_SymbolRef)({
  6904. start : my_start_token(M),
  6905. end : my_end_token(M),
  6906. name : M.name
  6907. });
  6908. },
  6909. BigIntLiteral(M) {
  6910. return new AST_BigInt({
  6911. start : my_start_token(M),
  6912. end : my_end_token(M),
  6913. value : M.value
  6914. });
  6915. },
  6916. EmptyStatement: function(M) {
  6917. return new AST_EmptyStatement({
  6918. start: my_start_token(M),
  6919. end: my_end_token(M)
  6920. });
  6921. },
  6922. BlockStatement: function(M) {
  6923. return new AST_BlockStatement({
  6924. start: my_start_token(M),
  6925. end: my_end_token(M),
  6926. body: M.body.map(from_moz)
  6927. });
  6928. },
  6929. IfStatement: function(M) {
  6930. return new AST_If({
  6931. start: my_start_token(M),
  6932. end: my_end_token(M),
  6933. condition: from_moz(M.test),
  6934. body: from_moz(M.consequent),
  6935. alternative: from_moz(M.alternate)
  6936. });
  6937. },
  6938. LabeledStatement: function(M) {
  6939. return new AST_LabeledStatement({
  6940. start: my_start_token(M),
  6941. end: my_end_token(M),
  6942. label: from_moz(M.label),
  6943. body: from_moz(M.body)
  6944. });
  6945. },
  6946. BreakStatement: function(M) {
  6947. return new AST_Break({
  6948. start: my_start_token(M),
  6949. end: my_end_token(M),
  6950. label: from_moz(M.label)
  6951. });
  6952. },
  6953. ContinueStatement: function(M) {
  6954. return new AST_Continue({
  6955. start: my_start_token(M),
  6956. end: my_end_token(M),
  6957. label: from_moz(M.label)
  6958. });
  6959. },
  6960. WithStatement: function(M) {
  6961. return new AST_With({
  6962. start: my_start_token(M),
  6963. end: my_end_token(M),
  6964. expression: from_moz(M.object),
  6965. body: from_moz(M.body)
  6966. });
  6967. },
  6968. SwitchStatement: function(M) {
  6969. return new AST_Switch({
  6970. start: my_start_token(M),
  6971. end: my_end_token(M),
  6972. expression: from_moz(M.discriminant),
  6973. body: M.cases.map(from_moz)
  6974. });
  6975. },
  6976. ReturnStatement: function(M) {
  6977. return new AST_Return({
  6978. start: my_start_token(M),
  6979. end: my_end_token(M),
  6980. value: from_moz(M.argument)
  6981. });
  6982. },
  6983. ThrowStatement: function(M) {
  6984. return new AST_Throw({
  6985. start: my_start_token(M),
  6986. end: my_end_token(M),
  6987. value: from_moz(M.argument)
  6988. });
  6989. },
  6990. WhileStatement: function(M) {
  6991. return new AST_While({
  6992. start: my_start_token(M),
  6993. end: my_end_token(M),
  6994. condition: from_moz(M.test),
  6995. body: from_moz(M.body)
  6996. });
  6997. },
  6998. DoWhileStatement: function(M) {
  6999. return new AST_Do({
  7000. start: my_start_token(M),
  7001. end: my_end_token(M),
  7002. condition: from_moz(M.test),
  7003. body: from_moz(M.body)
  7004. });
  7005. },
  7006. ForStatement: function(M) {
  7007. return new AST_For({
  7008. start: my_start_token(M),
  7009. end: my_end_token(M),
  7010. init: from_moz(M.init),
  7011. condition: from_moz(M.test),
  7012. step: from_moz(M.update),
  7013. body: from_moz(M.body)
  7014. });
  7015. },
  7016. ForInStatement: function(M) {
  7017. return new AST_ForIn({
  7018. start: my_start_token(M),
  7019. end: my_end_token(M),
  7020. init: from_moz(M.left),
  7021. object: from_moz(M.right),
  7022. body: from_moz(M.body)
  7023. });
  7024. },
  7025. ForOfStatement: function(M) {
  7026. return new AST_ForOf({
  7027. start: my_start_token(M),
  7028. end: my_end_token(M),
  7029. init: from_moz(M.left),
  7030. object: from_moz(M.right),
  7031. body: from_moz(M.body),
  7032. await: M.await
  7033. });
  7034. },
  7035. AwaitExpression: function(M) {
  7036. return new AST_Await({
  7037. start: my_start_token(M),
  7038. end: my_end_token(M),
  7039. expression: from_moz(M.argument)
  7040. });
  7041. },
  7042. YieldExpression: function(M) {
  7043. return new AST_Yield({
  7044. start: my_start_token(M),
  7045. end: my_end_token(M),
  7046. expression: from_moz(M.argument),
  7047. is_star: M.delegate
  7048. });
  7049. },
  7050. DebuggerStatement: function(M) {
  7051. return new AST_Debugger({
  7052. start: my_start_token(M),
  7053. end: my_end_token(M)
  7054. });
  7055. },
  7056. VariableDeclarator: function(M) {
  7057. return new AST_VarDef({
  7058. start: my_start_token(M),
  7059. end: my_end_token(M),
  7060. name: from_moz(M.id),
  7061. value: from_moz(M.init)
  7062. });
  7063. },
  7064. CatchClause: function(M) {
  7065. return new AST_Catch({
  7066. start: my_start_token(M),
  7067. end: my_end_token(M),
  7068. argname: from_moz(M.param),
  7069. body: from_moz(M.body).body
  7070. });
  7071. },
  7072. ThisExpression: function(M) {
  7073. return new AST_This({
  7074. start: my_start_token(M),
  7075. end: my_end_token(M)
  7076. });
  7077. },
  7078. Super: function(M) {
  7079. return new AST_Super({
  7080. start: my_start_token(M),
  7081. end: my_end_token(M)
  7082. });
  7083. },
  7084. BinaryExpression: function(M) {
  7085. if (M.left.type === "PrivateIdentifier") {
  7086. return new AST_PrivateIn({
  7087. start: my_start_token(M),
  7088. end: my_end_token(M),
  7089. key: new AST_SymbolPrivateProperty({
  7090. start: my_start_token(M.left),
  7091. end: my_end_token(M.left),
  7092. name: M.left.name
  7093. }),
  7094. value: from_moz(M.right),
  7095. });
  7096. }
  7097. return new AST_Binary({
  7098. start: my_start_token(M),
  7099. end: my_end_token(M),
  7100. operator: M.operator,
  7101. left: from_moz(M.left),
  7102. right: from_moz(M.right)
  7103. });
  7104. },
  7105. LogicalExpression: function(M) {
  7106. return new AST_Binary({
  7107. start: my_start_token(M),
  7108. end: my_end_token(M),
  7109. operator: M.operator,
  7110. left: from_moz(M.left),
  7111. right: from_moz(M.right)
  7112. });
  7113. },
  7114. AssignmentExpression: function(M) {
  7115. return new AST_Assign({
  7116. start: my_start_token(M),
  7117. end: my_end_token(M),
  7118. operator: M.operator,
  7119. left: from_moz(M.left),
  7120. right: from_moz(M.right)
  7121. });
  7122. },
  7123. ConditionalExpression: function(M) {
  7124. return new AST_Conditional({
  7125. start: my_start_token(M),
  7126. end: my_end_token(M),
  7127. condition: from_moz(M.test),
  7128. consequent: from_moz(M.consequent),
  7129. alternative: from_moz(M.alternate)
  7130. });
  7131. },
  7132. NewExpression: function(M) {
  7133. return new AST_New({
  7134. start: my_start_token(M),
  7135. end: my_end_token(M),
  7136. expression: from_moz(M.callee),
  7137. args: M.arguments.map(from_moz)
  7138. });
  7139. },
  7140. CallExpression: function(M) {
  7141. return new AST_Call({
  7142. start: my_start_token(M),
  7143. end: my_end_token(M),
  7144. expression: from_moz(M.callee),
  7145. optional: M.optional,
  7146. args: M.arguments.map(from_moz)
  7147. });
  7148. }
  7149. };
  7150. MOZ_TO_ME.UpdateExpression =
  7151. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  7152. var prefix = "prefix" in M ? M.prefix
  7153. : M.type == "UnaryExpression" ? true : false;
  7154. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  7155. start : my_start_token(M),
  7156. end : my_end_token(M),
  7157. operator : M.operator,
  7158. expression : from_moz(M.argument)
  7159. });
  7160. };
  7161. MOZ_TO_ME.ClassDeclaration =
  7162. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  7163. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  7164. start : my_start_token(M),
  7165. end : my_end_token(M),
  7166. name : from_moz(M.id),
  7167. extends : from_moz(M.superClass),
  7168. properties: M.body.body.map(from_moz)
  7169. });
  7170. };
  7171. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  7172. return {
  7173. type: "EmptyStatement"
  7174. };
  7175. });
  7176. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  7177. return {
  7178. type: "BlockStatement",
  7179. body: M.body.map(to_moz)
  7180. };
  7181. });
  7182. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  7183. return {
  7184. type: "IfStatement",
  7185. test: to_moz(M.condition),
  7186. consequent: to_moz(M.body),
  7187. alternate: to_moz(M.alternative)
  7188. };
  7189. });
  7190. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  7191. return {
  7192. type: "LabeledStatement",
  7193. label: to_moz(M.label),
  7194. body: to_moz(M.body)
  7195. };
  7196. });
  7197. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  7198. return {
  7199. type: "BreakStatement",
  7200. label: to_moz(M.label)
  7201. };
  7202. });
  7203. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  7204. return {
  7205. type: "ContinueStatement",
  7206. label: to_moz(M.label)
  7207. };
  7208. });
  7209. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  7210. return {
  7211. type: "WithStatement",
  7212. object: to_moz(M.expression),
  7213. body: to_moz(M.body)
  7214. };
  7215. });
  7216. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  7217. return {
  7218. type: "SwitchStatement",
  7219. discriminant: to_moz(M.expression),
  7220. cases: M.body.map(to_moz)
  7221. };
  7222. });
  7223. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  7224. return {
  7225. type: "ReturnStatement",
  7226. argument: to_moz(M.value)
  7227. };
  7228. });
  7229. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  7230. return {
  7231. type: "ThrowStatement",
  7232. argument: to_moz(M.value)
  7233. };
  7234. });
  7235. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  7236. return {
  7237. type: "WhileStatement",
  7238. test: to_moz(M.condition),
  7239. body: to_moz(M.body)
  7240. };
  7241. });
  7242. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  7243. return {
  7244. type: "DoWhileStatement",
  7245. test: to_moz(M.condition),
  7246. body: to_moz(M.body)
  7247. };
  7248. });
  7249. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  7250. return {
  7251. type: "ForStatement",
  7252. init: to_moz(M.init),
  7253. test: to_moz(M.condition),
  7254. update: to_moz(M.step),
  7255. body: to_moz(M.body)
  7256. };
  7257. });
  7258. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  7259. return {
  7260. type: "ForInStatement",
  7261. left: to_moz(M.init),
  7262. right: to_moz(M.object),
  7263. body: to_moz(M.body)
  7264. };
  7265. });
  7266. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  7267. return {
  7268. type: "ForOfStatement",
  7269. left: to_moz(M.init),
  7270. right: to_moz(M.object),
  7271. body: to_moz(M.body),
  7272. await: M.await
  7273. };
  7274. });
  7275. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  7276. return {
  7277. type: "AwaitExpression",
  7278. argument: to_moz(M.expression)
  7279. };
  7280. });
  7281. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  7282. return {
  7283. type: "YieldExpression",
  7284. argument: to_moz(M.expression),
  7285. delegate: M.is_star
  7286. };
  7287. });
  7288. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  7289. return {
  7290. type: "DebuggerStatement"
  7291. };
  7292. });
  7293. def_to_moz(AST_VarDef, function To_Moz_VariableDeclarator(M) {
  7294. return {
  7295. type: "VariableDeclarator",
  7296. id: to_moz(M.name),
  7297. init: to_moz(M.value)
  7298. };
  7299. });
  7300. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7301. return {
  7302. type: "CatchClause",
  7303. param: to_moz(M.argname),
  7304. body: to_moz_block(M)
  7305. };
  7306. });
  7307. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  7308. return {
  7309. type: "ThisExpression"
  7310. };
  7311. });
  7312. def_to_moz(AST_Super, function To_Moz_Super() {
  7313. return {
  7314. type: "Super"
  7315. };
  7316. });
  7317. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7318. return {
  7319. type: "BinaryExpression",
  7320. operator: M.operator,
  7321. left: to_moz(M.left),
  7322. right: to_moz(M.right)
  7323. };
  7324. });
  7325. def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
  7326. return {
  7327. type: "LogicalExpression",
  7328. operator: M.operator,
  7329. left: to_moz(M.left),
  7330. right: to_moz(M.right)
  7331. };
  7332. });
  7333. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  7334. return {
  7335. type: "AssignmentExpression",
  7336. operator: M.operator,
  7337. left: to_moz(M.left),
  7338. right: to_moz(M.right)
  7339. };
  7340. });
  7341. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  7342. return {
  7343. type: "ConditionalExpression",
  7344. test: to_moz(M.condition),
  7345. consequent: to_moz(M.consequent),
  7346. alternate: to_moz(M.alternative)
  7347. };
  7348. });
  7349. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  7350. return {
  7351. type: "NewExpression",
  7352. callee: to_moz(M.expression),
  7353. arguments: M.args.map(to_moz)
  7354. };
  7355. });
  7356. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  7357. return {
  7358. type: "CallExpression",
  7359. callee: to_moz(M.expression),
  7360. optional: M.optional,
  7361. arguments: M.args.map(to_moz)
  7362. };
  7363. });
  7364. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  7365. return to_moz_scope("Program", M);
  7366. });
  7367. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  7368. return {
  7369. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  7370. argument: to_moz(M.expression)
  7371. };
  7372. });
  7373. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  7374. return {
  7375. type: "TaggedTemplateExpression",
  7376. tag: to_moz(M.prefix),
  7377. quasi: to_moz(M.template_string)
  7378. };
  7379. });
  7380. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  7381. var quasis = [];
  7382. var expressions = [];
  7383. for (var i = 0; i < M.segments.length; i++) {
  7384. if (i % 2 !== 0) {
  7385. expressions.push(to_moz(M.segments[i]));
  7386. } else {
  7387. quasis.push({
  7388. type: "TemplateElement",
  7389. value: {
  7390. raw: M.segments[i].raw,
  7391. cooked: M.segments[i].value
  7392. },
  7393. tail: i === M.segments.length - 1
  7394. });
  7395. }
  7396. }
  7397. return {
  7398. type: "TemplateLiteral",
  7399. quasis: quasis,
  7400. expressions: expressions
  7401. };
  7402. });
  7403. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  7404. return {
  7405. type: "FunctionDeclaration",
  7406. id: to_moz(M.name),
  7407. params: M.argnames.map(to_moz),
  7408. generator: M.is_generator,
  7409. async: M.async,
  7410. body: to_moz_scope("BlockStatement", M)
  7411. };
  7412. });
  7413. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  7414. var is_generator = parent.is_generator !== undefined ?
  7415. parent.is_generator : M.is_generator;
  7416. return {
  7417. type: "FunctionExpression",
  7418. id: to_moz(M.name),
  7419. params: M.argnames.map(to_moz),
  7420. generator: is_generator,
  7421. async: M.async,
  7422. body: to_moz_scope("BlockStatement", M)
  7423. };
  7424. });
  7425. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  7426. var body = {
  7427. type: "BlockStatement",
  7428. body: M.body.map(to_moz)
  7429. };
  7430. return {
  7431. type: "ArrowFunctionExpression",
  7432. params: M.argnames.map(to_moz),
  7433. async: M.async,
  7434. body: body
  7435. };
  7436. });
  7437. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  7438. if (M.is_array) {
  7439. return {
  7440. type: "ArrayPattern",
  7441. elements: M.names.map(to_moz)
  7442. };
  7443. }
  7444. return {
  7445. type: "ObjectPattern",
  7446. properties: M.names.map(to_moz)
  7447. };
  7448. });
  7449. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  7450. return {
  7451. type: "ExpressionStatement",
  7452. expression: {
  7453. type: "Literal",
  7454. value: M.value,
  7455. raw: M.print_to_string()
  7456. },
  7457. directive: M.value
  7458. };
  7459. });
  7460. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  7461. return {
  7462. type: "ExpressionStatement",
  7463. expression: to_moz(M.body)
  7464. };
  7465. });
  7466. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  7467. return {
  7468. type: "SwitchCase",
  7469. test: to_moz(M.expression),
  7470. consequent: M.body.map(to_moz)
  7471. };
  7472. });
  7473. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  7474. return {
  7475. type: "TryStatement",
  7476. block: to_moz_block(M.body),
  7477. handler: to_moz(M.bcatch),
  7478. guardedHandlers: [],
  7479. finalizer: to_moz(M.bfinally)
  7480. };
  7481. });
  7482. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7483. return {
  7484. type: "CatchClause",
  7485. param: to_moz(M.argname),
  7486. guard: null,
  7487. body: to_moz_block(M)
  7488. };
  7489. });
  7490. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  7491. return {
  7492. type: "VariableDeclaration",
  7493. kind:
  7494. M instanceof AST_Const ? "const" :
  7495. M instanceof AST_Let ? "let" : "var",
  7496. declarations: M.definitions.map(to_moz)
  7497. };
  7498. });
  7499. const assert_clause_to_moz = assert_clause => {
  7500. const assertions = [];
  7501. if (assert_clause) {
  7502. for (const { key, value } of assert_clause.properties) {
  7503. const key_moz = is_basic_identifier_string(key)
  7504. ? { type: "Identifier", name: key }
  7505. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  7506. assertions.push({
  7507. type: "ImportAttribute",
  7508. key: key_moz,
  7509. value: to_moz(value)
  7510. });
  7511. }
  7512. }
  7513. return assertions;
  7514. };
  7515. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  7516. if (M.exported_names) {
  7517. var first_exported = M.exported_names[0];
  7518. var first_exported_name = first_exported.name;
  7519. if (first_exported_name.name === "*" && !first_exported_name.quote) {
  7520. var foreign_name = first_exported.foreign_name;
  7521. var exported = foreign_name.name === "*" && !foreign_name.quote
  7522. ? null
  7523. : to_moz(foreign_name);
  7524. return {
  7525. type: "ExportAllDeclaration",
  7526. source: to_moz(M.module_name),
  7527. exported: exported,
  7528. assertions: assert_clause_to_moz(M.assert_clause)
  7529. };
  7530. }
  7531. return {
  7532. type: "ExportNamedDeclaration",
  7533. specifiers: M.exported_names.map(function (name_mapping) {
  7534. return {
  7535. type: "ExportSpecifier",
  7536. exported: to_moz(name_mapping.foreign_name),
  7537. local: to_moz(name_mapping.name)
  7538. };
  7539. }),
  7540. declaration: to_moz(M.exported_definition),
  7541. source: to_moz(M.module_name),
  7542. assertions: assert_clause_to_moz(M.assert_clause)
  7543. };
  7544. }
  7545. return {
  7546. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  7547. declaration: to_moz(M.exported_value || M.exported_definition)
  7548. };
  7549. });
  7550. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  7551. var specifiers = [];
  7552. if (M.imported_name) {
  7553. specifiers.push({
  7554. type: "ImportDefaultSpecifier",
  7555. local: to_moz(M.imported_name)
  7556. });
  7557. }
  7558. if (M.imported_names) {
  7559. var first_imported_foreign_name = M.imported_names[0].foreign_name;
  7560. if (first_imported_foreign_name.name === "*" && !first_imported_foreign_name.quote) {
  7561. specifiers.push({
  7562. type: "ImportNamespaceSpecifier",
  7563. local: to_moz(M.imported_names[0].name)
  7564. });
  7565. } else {
  7566. M.imported_names.forEach(function(name_mapping) {
  7567. specifiers.push({
  7568. type: "ImportSpecifier",
  7569. local: to_moz(name_mapping.name),
  7570. imported: to_moz(name_mapping.foreign_name)
  7571. });
  7572. });
  7573. }
  7574. }
  7575. return {
  7576. type: "ImportDeclaration",
  7577. specifiers: specifiers,
  7578. source: to_moz(M.module_name),
  7579. assertions: assert_clause_to_moz(M.assert_clause)
  7580. };
  7581. });
  7582. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  7583. return {
  7584. type: "MetaProperty",
  7585. meta: {
  7586. type: "Identifier",
  7587. name: "import"
  7588. },
  7589. property: {
  7590. type: "Identifier",
  7591. name: "meta"
  7592. }
  7593. };
  7594. });
  7595. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  7596. return {
  7597. type: "SequenceExpression",
  7598. expressions: M.expressions.map(to_moz)
  7599. };
  7600. });
  7601. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  7602. return {
  7603. type: "MemberExpression",
  7604. object: to_moz(M.expression),
  7605. computed: false,
  7606. property: {
  7607. type: "PrivateIdentifier",
  7608. name: M.property
  7609. },
  7610. optional: M.optional
  7611. };
  7612. });
  7613. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  7614. var isComputed = M instanceof AST_Sub;
  7615. return {
  7616. type: "MemberExpression",
  7617. object: to_moz(M.expression),
  7618. computed: isComputed,
  7619. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  7620. optional: M.optional
  7621. };
  7622. });
  7623. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  7624. return {
  7625. type: "ChainExpression",
  7626. expression: to_moz(M.expression)
  7627. };
  7628. });
  7629. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  7630. return {
  7631. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  7632. operator: M.operator,
  7633. prefix: M instanceof AST_UnaryPrefix,
  7634. argument: to_moz(M.expression)
  7635. };
  7636. });
  7637. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7638. if (M.operator == "=" && to_moz_in_destructuring()) {
  7639. return {
  7640. type: "AssignmentPattern",
  7641. left: to_moz(M.left),
  7642. right: to_moz(M.right)
  7643. };
  7644. }
  7645. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  7646. ? "LogicalExpression"
  7647. : "BinaryExpression";
  7648. return {
  7649. type,
  7650. left: to_moz(M.left),
  7651. operator: M.operator,
  7652. right: to_moz(M.right)
  7653. };
  7654. });
  7655. def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
  7656. return {
  7657. type: "BinaryExpression",
  7658. left: { type: "PrivateIdentifier", name: M.key.name },
  7659. operator: "in",
  7660. right: to_moz(M.value),
  7661. };
  7662. });
  7663. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  7664. return {
  7665. type: "ArrayExpression",
  7666. elements: M.elements.map(to_moz)
  7667. };
  7668. });
  7669. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  7670. return {
  7671. type: "ObjectExpression",
  7672. properties: M.properties.map(to_moz)
  7673. };
  7674. });
  7675. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  7676. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  7677. type: "Identifier",
  7678. value: M.key
  7679. };
  7680. if (typeof M.key === "number") {
  7681. key = {
  7682. type: "Literal",
  7683. value: Number(M.key)
  7684. };
  7685. }
  7686. if (typeof M.key === "string") {
  7687. key = {
  7688. type: "Identifier",
  7689. name: M.key
  7690. };
  7691. }
  7692. var kind;
  7693. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  7694. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  7695. if (M instanceof AST_ObjectKeyVal) {
  7696. kind = "init";
  7697. computed = !string_or_num;
  7698. } else
  7699. if (M instanceof AST_ObjectGetter) {
  7700. kind = "get";
  7701. } else
  7702. if (M instanceof AST_ObjectSetter) {
  7703. kind = "set";
  7704. }
  7705. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  7706. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  7707. return {
  7708. type: "MethodDefinition",
  7709. computed: false,
  7710. kind: kind,
  7711. static: M.static,
  7712. key: {
  7713. type: "PrivateIdentifier",
  7714. name: M.key.name
  7715. },
  7716. value: to_moz(M.value)
  7717. };
  7718. }
  7719. if (M instanceof AST_ClassPrivateProperty) {
  7720. return {
  7721. type: "PropertyDefinition",
  7722. key: {
  7723. type: "PrivateIdentifier",
  7724. name: M.key.name
  7725. },
  7726. value: to_moz(M.value),
  7727. computed: false,
  7728. static: M.static
  7729. };
  7730. }
  7731. if (M instanceof AST_ClassProperty) {
  7732. return {
  7733. type: "PropertyDefinition",
  7734. key,
  7735. value: to_moz(M.value),
  7736. computed,
  7737. static: M.static
  7738. };
  7739. }
  7740. if (parent instanceof AST_Class) {
  7741. return {
  7742. type: "MethodDefinition",
  7743. computed: computed,
  7744. kind: kind,
  7745. static: M.static,
  7746. key: to_moz(M.key),
  7747. value: to_moz(M.value)
  7748. };
  7749. }
  7750. return {
  7751. type: "Property",
  7752. computed: computed,
  7753. kind: kind,
  7754. key: key,
  7755. value: to_moz(M.value)
  7756. };
  7757. });
  7758. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  7759. if (parent instanceof AST_Object) {
  7760. return {
  7761. type: "Property",
  7762. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7763. kind: "init",
  7764. method: true,
  7765. shorthand: false,
  7766. key: to_moz(M.key),
  7767. value: to_moz(M.value)
  7768. };
  7769. }
  7770. const key = M instanceof AST_PrivateMethod
  7771. ? {
  7772. type: "PrivateIdentifier",
  7773. name: M.key.name
  7774. }
  7775. : to_moz(M.key);
  7776. return {
  7777. type: "MethodDefinition",
  7778. kind: M.key === "constructor" ? "constructor" : "method",
  7779. key,
  7780. value: to_moz(M.value),
  7781. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7782. static: M.static,
  7783. };
  7784. });
  7785. def_to_moz(AST_Class, function To_Moz_Class(M) {
  7786. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  7787. return {
  7788. type: type,
  7789. superClass: to_moz(M.extends),
  7790. id: M.name ? to_moz(M.name) : null,
  7791. body: {
  7792. type: "ClassBody",
  7793. body: M.properties.map(to_moz)
  7794. }
  7795. };
  7796. });
  7797. def_to_moz(AST_ClassStaticBlock, function To_Moz_StaticBlock(M) {
  7798. return {
  7799. type: "StaticBlock",
  7800. body: M.body.map(to_moz),
  7801. };
  7802. });
  7803. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  7804. return {
  7805. type: "MetaProperty",
  7806. meta: {
  7807. type: "Identifier",
  7808. name: "new"
  7809. },
  7810. property: {
  7811. type: "Identifier",
  7812. name: "target"
  7813. }
  7814. };
  7815. });
  7816. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  7817. if (
  7818. (M instanceof AST_SymbolMethod && parent.quote) ||
  7819. ((
  7820. M instanceof AST_SymbolImportForeign ||
  7821. M instanceof AST_SymbolExportForeign ||
  7822. M instanceof AST_SymbolExport
  7823. ) && M.quote)
  7824. ) {
  7825. return {
  7826. type: "Literal",
  7827. value: M.name
  7828. };
  7829. }
  7830. var def = M.definition();
  7831. return {
  7832. type: "Identifier",
  7833. name: def ? def.mangled_name || def.name : M.name
  7834. };
  7835. });
  7836. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  7837. const pattern = M.value.source;
  7838. const flags = M.value.flags;
  7839. return {
  7840. type: "Literal",
  7841. value: null,
  7842. raw: M.print_to_string(),
  7843. regex: { pattern, flags }
  7844. };
  7845. });
  7846. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  7847. var value = M.value;
  7848. return {
  7849. type: "Literal",
  7850. value: value,
  7851. raw: M.raw || M.print_to_string()
  7852. };
  7853. });
  7854. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  7855. return {
  7856. type: "Identifier",
  7857. name: String(M.value)
  7858. };
  7859. });
  7860. def_to_moz(AST_BigInt, M => ({
  7861. type: "BigIntLiteral",
  7862. value: M.value
  7863. }));
  7864. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7865. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7866. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  7867. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  7868. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  7869. /* -----[ tools ]----- */
  7870. function my_start_token(moznode) {
  7871. var loc = moznode.loc, start = loc && loc.start;
  7872. var range = moznode.range;
  7873. return new AST_Token(
  7874. "",
  7875. "",
  7876. start && start.line || 0,
  7877. start && start.column || 0,
  7878. range ? range [0] : moznode.start,
  7879. false,
  7880. [],
  7881. [],
  7882. loc && loc.source,
  7883. );
  7884. }
  7885. function my_end_token(moznode) {
  7886. var loc = moznode.loc, end = loc && loc.end;
  7887. var range = moznode.range;
  7888. return new AST_Token(
  7889. "",
  7890. "",
  7891. end && end.line || 0,
  7892. end && end.column || 0,
  7893. range ? range [0] : moznode.end,
  7894. false,
  7895. [],
  7896. [],
  7897. loc && loc.source,
  7898. );
  7899. }
  7900. var FROM_MOZ_STACK = null;
  7901. function from_moz(node) {
  7902. FROM_MOZ_STACK.push(node);
  7903. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  7904. FROM_MOZ_STACK.pop();
  7905. return ret;
  7906. }
  7907. AST_Node.from_mozilla_ast = function(node) {
  7908. var save_stack = FROM_MOZ_STACK;
  7909. FROM_MOZ_STACK = [];
  7910. var ast = from_moz(node);
  7911. FROM_MOZ_STACK = save_stack;
  7912. return ast;
  7913. };
  7914. function set_moz_loc(mynode, moznode) {
  7915. var start = mynode.start;
  7916. var end = mynode.end;
  7917. if (!(start && end)) {
  7918. return moznode;
  7919. }
  7920. if (start.pos != null && end.endpos != null) {
  7921. moznode.range = [start.pos, end.endpos];
  7922. }
  7923. if (start.line) {
  7924. moznode.loc = {
  7925. start: {line: start.line, column: start.col},
  7926. end: end.endline ? {line: end.endline, column: end.endcol} : null
  7927. };
  7928. if (start.file) {
  7929. moznode.loc.source = start.file;
  7930. }
  7931. }
  7932. return moznode;
  7933. }
  7934. function def_to_moz(mytype, handler) {
  7935. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  7936. return set_moz_loc(this, handler(this, parent));
  7937. });
  7938. }
  7939. var TO_MOZ_STACK = null;
  7940. function to_moz(node) {
  7941. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  7942. TO_MOZ_STACK.push(node);
  7943. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  7944. TO_MOZ_STACK.pop();
  7945. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  7946. return ast;
  7947. }
  7948. function to_moz_in_destructuring() {
  7949. var i = TO_MOZ_STACK.length;
  7950. while (i--) {
  7951. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  7952. return true;
  7953. }
  7954. }
  7955. return false;
  7956. }
  7957. function to_moz_block(node) {
  7958. return {
  7959. type: "BlockStatement",
  7960. body: node.body.map(to_moz)
  7961. };
  7962. }
  7963. function to_moz_scope(type, node) {
  7964. var body = node.body.map(to_moz);
  7965. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  7966. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  7967. }
  7968. return {
  7969. type: type,
  7970. body: body
  7971. };
  7972. }
  7973. })();
  7974. // return true if the node at the top of the stack (that means the
  7975. // innermost node in the current output) is lexically the first in
  7976. // a statement.
  7977. function first_in_statement(stack) {
  7978. let node = stack.parent(-1);
  7979. for (let i = 0, p; p = stack.parent(i); i++) {
  7980. if (p instanceof AST_Statement && p.body === node)
  7981. return true;
  7982. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  7983. (p.TYPE === "Call" && p.expression === node) ||
  7984. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  7985. (p instanceof AST_Dot && p.expression === node) ||
  7986. (p instanceof AST_Sub && p.expression === node) ||
  7987. (p instanceof AST_Chain && p.expression === node) ||
  7988. (p instanceof AST_Conditional && p.condition === node) ||
  7989. (p instanceof AST_Binary && p.left === node) ||
  7990. (p instanceof AST_UnaryPostfix && p.expression === node)
  7991. ) {
  7992. node = p;
  7993. } else {
  7994. return false;
  7995. }
  7996. }
  7997. }
  7998. // Returns whether the leftmost item in the expression is an object
  7999. function left_is_object(node) {
  8000. if (node instanceof AST_Object) return true;
  8001. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  8002. if (node.TYPE === "Call") return left_is_object(node.expression);
  8003. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  8004. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  8005. if (node instanceof AST_Chain) return left_is_object(node.expression);
  8006. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  8007. if (node instanceof AST_Binary) return left_is_object(node.left);
  8008. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  8009. return false;
  8010. }
  8011. /***********************************************************************
  8012. A JavaScript tokenizer / parser / beautifier / compressor.
  8013. https://github.com/mishoo/UglifyJS2
  8014. -------------------------------- (C) ---------------------------------
  8015. Author: Mihai Bazon
  8016. <mihai.bazon@gmail.com>
  8017. http://mihai.bazon.net/blog
  8018. Distributed under the BSD license:
  8019. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8020. Redistribution and use in source and binary forms, with or without
  8021. modification, are permitted provided that the following conditions
  8022. are met:
  8023. * Redistributions of source code must retain the above
  8024. copyright notice, this list of conditions and the following
  8025. disclaimer.
  8026. * Redistributions in binary form must reproduce the above
  8027. copyright notice, this list of conditions and the following
  8028. disclaimer in the documentation and/or other materials
  8029. provided with the distribution.
  8030. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8031. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8032. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8033. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8034. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8035. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8036. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8037. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8038. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8039. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8040. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8041. SUCH DAMAGE.
  8042. ***********************************************************************/
  8043. const CODE_LINE_BREAK = 10;
  8044. const CODE_SPACE = 32;
  8045. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/;
  8046. function is_some_comments(comment) {
  8047. // multiline comment
  8048. return (
  8049. (comment.type === "comment2" || comment.type === "comment1")
  8050. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  8051. );
  8052. }
  8053. const ROPE_COMMIT_WHEN = 8 * 1000;
  8054. class Rope {
  8055. constructor() {
  8056. this.committed = "";
  8057. this.current = "";
  8058. }
  8059. append(str) {
  8060. /** When `this.current` is too long, commit it. */
  8061. if (this.current.length > ROPE_COMMIT_WHEN) {
  8062. this.committed += this.current + str;
  8063. this.current = "";
  8064. } else {
  8065. this.current += str;
  8066. }
  8067. }
  8068. insertAt(char, index) {
  8069. const { committed, current } = this;
  8070. if (index < committed.length) {
  8071. this.committed = committed.slice(0, index) + char + committed.slice(index);
  8072. } else if (index === committed.length) {
  8073. this.committed += char;
  8074. } else {
  8075. index -= committed.length;
  8076. this.committed += current.slice(0, index) + char;
  8077. this.current = current.slice(index);
  8078. }
  8079. }
  8080. charAt(index) {
  8081. const { committed } = this;
  8082. if (index < committed.length) return committed[index];
  8083. return this.current[index - committed.length];
  8084. }
  8085. charCodeAt(index) {
  8086. const { committed } = this;
  8087. if (index < committed.length) return committed.charCodeAt(index);
  8088. return this.current.charCodeAt(index - committed.length);
  8089. }
  8090. length() {
  8091. return this.committed.length + this.current.length;
  8092. }
  8093. expectDirective() {
  8094. // /^$|[;{][\s\n]*$/
  8095. let ch, n = this.length();
  8096. if (n <= 0) return true;
  8097. // Skip N whitespace from the end
  8098. while (
  8099. (ch = this.charCodeAt(--n))
  8100. && (ch == CODE_SPACE || ch == CODE_LINE_BREAK)
  8101. );
  8102. // either ";", or "{", or the string ended
  8103. return !ch || ch === 59 || ch === 123;
  8104. }
  8105. hasNLB() {
  8106. let n = this.length() - 1;
  8107. while (n >= 0) {
  8108. const code = this.charCodeAt(n--);
  8109. if (code === CODE_LINE_BREAK) return true;
  8110. if (code !== CODE_SPACE) return false;
  8111. }
  8112. return true;
  8113. }
  8114. toString() {
  8115. return this.committed + this.current;
  8116. }
  8117. }
  8118. function OutputStream(options) {
  8119. var readonly = !options;
  8120. options = defaults(options, {
  8121. ascii_only : false,
  8122. beautify : false,
  8123. braces : false,
  8124. comments : "some",
  8125. ecma : 5,
  8126. ie8 : false,
  8127. indent_level : 4,
  8128. indent_start : 0,
  8129. inline_script : true,
  8130. keep_numbers : false,
  8131. keep_quoted_props : false,
  8132. max_line_len : false,
  8133. preamble : null,
  8134. preserve_annotations : false,
  8135. quote_keys : false,
  8136. quote_style : 0,
  8137. safari10 : false,
  8138. semicolons : true,
  8139. shebang : true,
  8140. shorthand : undefined,
  8141. source_map : null,
  8142. webkit : false,
  8143. width : 80,
  8144. wrap_iife : false,
  8145. wrap_func_args : true,
  8146. _destroy_ast : false
  8147. }, true);
  8148. if (options.shorthand === undefined)
  8149. options.shorthand = options.ecma > 5;
  8150. // Convert comment option to RegExp if necessary and set up comments filter
  8151. var comment_filter = return_false; // Default case, throw all comments away
  8152. if (options.comments) {
  8153. let comments = options.comments;
  8154. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  8155. var regex_pos = options.comments.lastIndexOf("/");
  8156. comments = new RegExp(
  8157. options.comments.substr(1, regex_pos - 1),
  8158. options.comments.substr(regex_pos + 1)
  8159. );
  8160. }
  8161. if (comments instanceof RegExp) {
  8162. comment_filter = function(comment) {
  8163. return comment.type != "comment5" && comments.test(comment.value);
  8164. };
  8165. } else if (typeof comments === "function") {
  8166. comment_filter = function(comment) {
  8167. return comment.type != "comment5" && comments(this, comment);
  8168. };
  8169. } else if (comments === "some") {
  8170. comment_filter = is_some_comments;
  8171. } else { // NOTE includes "all" option
  8172. comment_filter = return_true;
  8173. }
  8174. }
  8175. if (options.preserve_annotations) {
  8176. let prev_comment_filter = comment_filter;
  8177. comment_filter = function (comment) {
  8178. return r_annotation.test(comment.value) || prev_comment_filter.apply(this, arguments);
  8179. };
  8180. }
  8181. var indentation = 0;
  8182. var current_col = 0;
  8183. var current_line = 1;
  8184. var current_pos = 0;
  8185. var OUTPUT = new Rope();
  8186. let printed_comments = new Set();
  8187. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  8188. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  8189. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  8190. var code = get_full_char_code(ch, 0).toString(16);
  8191. return "\\u{" + code + "}";
  8192. });
  8193. }
  8194. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  8195. var code = ch.charCodeAt(0).toString(16);
  8196. if (code.length <= 2 && !identifier) {
  8197. while (code.length < 2) code = "0" + code;
  8198. return "\\x" + code;
  8199. } else {
  8200. while (code.length < 4) code = "0" + code;
  8201. return "\\u" + code;
  8202. }
  8203. });
  8204. } : function(str) {
  8205. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  8206. if (lone) {
  8207. return "\\u" + lone.charCodeAt(0).toString(16);
  8208. }
  8209. return match;
  8210. });
  8211. };
  8212. function make_string(str, quote) {
  8213. var dq = 0, sq = 0;
  8214. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  8215. function(s, i) {
  8216. switch (s) {
  8217. case '"': ++dq; return '"';
  8218. case "'": ++sq; return "'";
  8219. case "\\": return "\\\\";
  8220. case "\n": return "\\n";
  8221. case "\r": return "\\r";
  8222. case "\t": return "\\t";
  8223. case "\b": return "\\b";
  8224. case "\f": return "\\f";
  8225. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  8226. case "\u2028": return "\\u2028";
  8227. case "\u2029": return "\\u2029";
  8228. case "\ufeff": return "\\ufeff";
  8229. case "\0":
  8230. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  8231. }
  8232. return s;
  8233. });
  8234. function quote_single() {
  8235. return "'" + str.replace(/\x27/g, "\\'") + "'";
  8236. }
  8237. function quote_double() {
  8238. return '"' + str.replace(/\x22/g, '\\"') + '"';
  8239. }
  8240. function quote_template() {
  8241. return "`" + str.replace(/`/g, "\\`") + "`";
  8242. }
  8243. str = to_utf8(str);
  8244. if (quote === "`") return quote_template();
  8245. switch (options.quote_style) {
  8246. case 1:
  8247. return quote_single();
  8248. case 2:
  8249. return quote_double();
  8250. case 3:
  8251. return quote == "'" ? quote_single() : quote_double();
  8252. default:
  8253. return dq > sq ? quote_single() : quote_double();
  8254. }
  8255. }
  8256. function encode_string(str, quote) {
  8257. var ret = make_string(str, quote);
  8258. if (options.inline_script) {
  8259. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  8260. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  8261. ret = ret.replace(/--\x3e/g, "--\\x3e");
  8262. }
  8263. return ret;
  8264. }
  8265. function make_name(name) {
  8266. name = name.toString();
  8267. name = to_utf8(name, true);
  8268. return name;
  8269. }
  8270. function make_indent(back) {
  8271. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  8272. }
  8273. /* -----[ beautification/minification ]----- */
  8274. var has_parens = false;
  8275. var might_need_space = false;
  8276. var might_need_semicolon = false;
  8277. var might_add_newline = 0;
  8278. var need_newline_indented = false;
  8279. var need_space = false;
  8280. var newline_insert = -1;
  8281. var last = "";
  8282. var mapping_token, mapping_name, mappings = options.source_map && [];
  8283. var do_add_mapping = mappings ? function() {
  8284. mappings.forEach(function(mapping) {
  8285. try {
  8286. let { name, token } = mapping;
  8287. if (name !== false) {
  8288. if (token.type == "name" || token.type === "privatename") {
  8289. name = token.value;
  8290. } else if (name instanceof AST_Symbol) {
  8291. name = token.type === "string" ? token.value : name.name;
  8292. }
  8293. }
  8294. options.source_map.add(
  8295. mapping.token.file,
  8296. mapping.line, mapping.col,
  8297. mapping.token.line, mapping.token.col,
  8298. is_basic_identifier_string(name) ? name : undefined
  8299. );
  8300. } catch(ex) {
  8301. // Ignore bad mapping
  8302. }
  8303. });
  8304. mappings = [];
  8305. } : noop;
  8306. var ensure_line_len = options.max_line_len ? function() {
  8307. if (current_col > options.max_line_len) {
  8308. if (might_add_newline) {
  8309. OUTPUT.insertAt("\n", might_add_newline);
  8310. const len_after_newline = OUTPUT.length() - might_add_newline - 1;
  8311. if (mappings) {
  8312. var delta = len_after_newline - current_col;
  8313. mappings.forEach(function(mapping) {
  8314. mapping.line++;
  8315. mapping.col += delta;
  8316. });
  8317. }
  8318. current_line++;
  8319. current_pos++;
  8320. current_col = len_after_newline;
  8321. }
  8322. }
  8323. if (might_add_newline) {
  8324. might_add_newline = 0;
  8325. do_add_mapping();
  8326. }
  8327. } : noop;
  8328. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  8329. function print(str) {
  8330. str = String(str);
  8331. var ch = get_full_char(str, 0);
  8332. if (need_newline_indented && ch) {
  8333. need_newline_indented = false;
  8334. if (ch !== "\n") {
  8335. print("\n");
  8336. indent();
  8337. }
  8338. }
  8339. if (need_space && ch) {
  8340. need_space = false;
  8341. if (!/[\s;})]/.test(ch)) {
  8342. space();
  8343. }
  8344. }
  8345. newline_insert = -1;
  8346. var prev = last.charAt(last.length - 1);
  8347. if (might_need_semicolon) {
  8348. might_need_semicolon = false;
  8349. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  8350. if (options.semicolons || requireSemicolonChars.has(ch)) {
  8351. OUTPUT.append(";");
  8352. current_col++;
  8353. current_pos++;
  8354. } else {
  8355. ensure_line_len();
  8356. if (current_col > 0) {
  8357. OUTPUT.append("\n");
  8358. current_pos++;
  8359. current_line++;
  8360. current_col = 0;
  8361. }
  8362. if (/^\s+$/.test(str)) {
  8363. // reset the semicolon flag, since we didn't print one
  8364. // now and might still have to later
  8365. might_need_semicolon = true;
  8366. }
  8367. }
  8368. if (!options.beautify)
  8369. might_need_space = false;
  8370. }
  8371. }
  8372. if (might_need_space) {
  8373. if ((is_identifier_char(prev)
  8374. && (is_identifier_char(ch) || ch == "\\"))
  8375. || (ch == "/" && ch == prev)
  8376. || ((ch == "+" || ch == "-") && ch == last)
  8377. ) {
  8378. OUTPUT.append(" ");
  8379. current_col++;
  8380. current_pos++;
  8381. }
  8382. might_need_space = false;
  8383. }
  8384. if (mapping_token) {
  8385. mappings.push({
  8386. token: mapping_token,
  8387. name: mapping_name,
  8388. line: current_line,
  8389. col: current_col
  8390. });
  8391. mapping_token = false;
  8392. if (!might_add_newline) do_add_mapping();
  8393. }
  8394. OUTPUT.append(str);
  8395. has_parens = str[str.length - 1] == "(";
  8396. current_pos += str.length;
  8397. var a = str.split(/\r?\n/), n = a.length - 1;
  8398. current_line += n;
  8399. current_col += a[0].length;
  8400. if (n > 0) {
  8401. ensure_line_len();
  8402. current_col = a[n].length;
  8403. }
  8404. last = str;
  8405. }
  8406. var star = function() {
  8407. print("*");
  8408. };
  8409. var space = options.beautify ? function() {
  8410. print(" ");
  8411. } : function() {
  8412. might_need_space = true;
  8413. };
  8414. var indent = options.beautify ? function(half) {
  8415. if (options.beautify) {
  8416. print(make_indent(half ? 0.5 : 0));
  8417. }
  8418. } : noop;
  8419. var with_indent = options.beautify ? function(col, cont) {
  8420. if (col === true) col = next_indent();
  8421. var save_indentation = indentation;
  8422. indentation = col;
  8423. var ret = cont();
  8424. indentation = save_indentation;
  8425. return ret;
  8426. } : function(col, cont) { return cont(); };
  8427. var newline = options.beautify ? function() {
  8428. if (newline_insert < 0) return print("\n");
  8429. if (OUTPUT.charAt(newline_insert) != "\n") {
  8430. OUTPUT.insertAt("\n", newline_insert);
  8431. current_pos++;
  8432. current_line++;
  8433. }
  8434. newline_insert++;
  8435. } : options.max_line_len ? function() {
  8436. ensure_line_len();
  8437. might_add_newline = OUTPUT.length();
  8438. } : noop;
  8439. var semicolon = options.beautify ? function() {
  8440. print(";");
  8441. } : function() {
  8442. might_need_semicolon = true;
  8443. };
  8444. function force_semicolon() {
  8445. might_need_semicolon = false;
  8446. print(";");
  8447. }
  8448. function next_indent() {
  8449. return indentation + options.indent_level;
  8450. }
  8451. function with_block(cont) {
  8452. var ret;
  8453. print("{");
  8454. newline();
  8455. with_indent(next_indent(), function() {
  8456. ret = cont();
  8457. });
  8458. indent();
  8459. print("}");
  8460. return ret;
  8461. }
  8462. function with_parens(cont) {
  8463. print("(");
  8464. //XXX: still nice to have that for argument lists
  8465. //var ret = with_indent(current_col, cont);
  8466. var ret = cont();
  8467. print(")");
  8468. return ret;
  8469. }
  8470. function with_square(cont) {
  8471. print("[");
  8472. //var ret = with_indent(current_col, cont);
  8473. var ret = cont();
  8474. print("]");
  8475. return ret;
  8476. }
  8477. function comma() {
  8478. print(",");
  8479. space();
  8480. }
  8481. function colon() {
  8482. print(":");
  8483. space();
  8484. }
  8485. var add_mapping = mappings ? function(token, name) {
  8486. mapping_token = token;
  8487. mapping_name = name;
  8488. } : noop;
  8489. function get() {
  8490. if (might_add_newline) {
  8491. ensure_line_len();
  8492. }
  8493. return OUTPUT.toString();
  8494. }
  8495. function filter_comment(comment) {
  8496. if (!options.preserve_annotations) {
  8497. comment = comment.replace(r_annotation, " ");
  8498. }
  8499. if (/^\s*$/.test(comment)) {
  8500. return "";
  8501. }
  8502. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  8503. }
  8504. function prepend_comments(node) {
  8505. var self = this;
  8506. var start = node.start;
  8507. if (!start) return;
  8508. var printed_comments = self.printed_comments;
  8509. // There cannot be a newline between return/yield and its value.
  8510. const keyword_with_value =
  8511. node instanceof AST_Exit && node.value
  8512. || (node instanceof AST_Await || node instanceof AST_Yield)
  8513. && node.expression;
  8514. if (
  8515. start.comments_before
  8516. && printed_comments.has(start.comments_before)
  8517. ) {
  8518. if (keyword_with_value) {
  8519. start.comments_before = [];
  8520. } else {
  8521. return;
  8522. }
  8523. }
  8524. var comments = start.comments_before;
  8525. if (!comments) {
  8526. comments = start.comments_before = [];
  8527. }
  8528. printed_comments.add(comments);
  8529. if (keyword_with_value) {
  8530. var tw = new TreeWalker(function(node) {
  8531. var parent = tw.parent();
  8532. if (parent instanceof AST_Exit
  8533. || parent instanceof AST_Await
  8534. || parent instanceof AST_Yield
  8535. || parent instanceof AST_Binary && parent.left === node
  8536. || parent.TYPE == "Call" && parent.expression === node
  8537. || parent instanceof AST_Conditional && parent.condition === node
  8538. || parent instanceof AST_Dot && parent.expression === node
  8539. || parent instanceof AST_Sequence && parent.expressions[0] === node
  8540. || parent instanceof AST_Sub && parent.expression === node
  8541. || parent instanceof AST_UnaryPostfix) {
  8542. if (!node.start) return;
  8543. var text = node.start.comments_before;
  8544. if (text && !printed_comments.has(text)) {
  8545. printed_comments.add(text);
  8546. comments = comments.concat(text);
  8547. }
  8548. } else {
  8549. return true;
  8550. }
  8551. });
  8552. tw.push(node);
  8553. keyword_with_value.walk(tw);
  8554. }
  8555. if (current_pos == 0) {
  8556. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  8557. && !printed_comments.has(comments[0])) {
  8558. print("#!" + comments.shift().value + "\n");
  8559. indent();
  8560. }
  8561. var preamble = options.preamble;
  8562. if (preamble) {
  8563. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  8564. }
  8565. }
  8566. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  8567. if (comments.length == 0) return;
  8568. var last_nlb = OUTPUT.hasNLB();
  8569. comments.forEach(function(c, i) {
  8570. printed_comments.add(c);
  8571. if (!last_nlb) {
  8572. if (c.nlb) {
  8573. print("\n");
  8574. indent();
  8575. last_nlb = true;
  8576. } else if (i > 0) {
  8577. space();
  8578. }
  8579. }
  8580. if (/comment[134]/.test(c.type)) {
  8581. var value = filter_comment(c.value);
  8582. if (value) {
  8583. print("//" + value + "\n");
  8584. indent();
  8585. }
  8586. last_nlb = true;
  8587. } else if (c.type == "comment2") {
  8588. var value = filter_comment(c.value);
  8589. if (value) {
  8590. print("/*" + value + "*/");
  8591. }
  8592. last_nlb = false;
  8593. }
  8594. });
  8595. if (!last_nlb) {
  8596. if (start.nlb) {
  8597. print("\n");
  8598. indent();
  8599. } else {
  8600. space();
  8601. }
  8602. }
  8603. }
  8604. function append_comments(node, tail) {
  8605. var self = this;
  8606. var token = node.end;
  8607. if (!token) return;
  8608. var printed_comments = self.printed_comments;
  8609. var comments = token[tail ? "comments_before" : "comments_after"];
  8610. if (!comments || printed_comments.has(comments)) return;
  8611. if (!(node instanceof AST_Statement || comments.every((c) =>
  8612. !/comment[134]/.test(c.type)
  8613. ))) return;
  8614. printed_comments.add(comments);
  8615. var insert = OUTPUT.length();
  8616. comments.filter(comment_filter, node).forEach(function(c, i) {
  8617. if (printed_comments.has(c)) return;
  8618. printed_comments.add(c);
  8619. need_space = false;
  8620. if (need_newline_indented) {
  8621. print("\n");
  8622. indent();
  8623. need_newline_indented = false;
  8624. } else if (c.nlb && (i > 0 || !OUTPUT.hasNLB())) {
  8625. print("\n");
  8626. indent();
  8627. } else if (i > 0 || !tail) {
  8628. space();
  8629. }
  8630. if (/comment[134]/.test(c.type)) {
  8631. const value = filter_comment(c.value);
  8632. if (value) {
  8633. print("//" + value);
  8634. }
  8635. need_newline_indented = true;
  8636. } else if (c.type == "comment2") {
  8637. const value = filter_comment(c.value);
  8638. if (value) {
  8639. print("/*" + value + "*/");
  8640. }
  8641. need_space = true;
  8642. }
  8643. });
  8644. if (OUTPUT.length() > insert) newline_insert = insert;
  8645. }
  8646. /**
  8647. * When output.option("_destroy_ast") is enabled, destroy the function.
  8648. * Call this after printing it.
  8649. */
  8650. const gc_scope =
  8651. options["_destroy_ast"]
  8652. ? function gc_scope(scope) {
  8653. scope.body.length = 0;
  8654. scope.argnames.length = 0;
  8655. }
  8656. : noop;
  8657. var stack = [];
  8658. return {
  8659. get : get,
  8660. toString : get,
  8661. indent : indent,
  8662. in_directive : false,
  8663. use_asm : null,
  8664. active_scope : null,
  8665. indentation : function() { return indentation; },
  8666. current_width : function() { return current_col - indentation; },
  8667. should_break : function() { return options.width && this.current_width() >= options.width; },
  8668. has_parens : function() { return has_parens; },
  8669. newline : newline,
  8670. print : print,
  8671. star : star,
  8672. space : space,
  8673. comma : comma,
  8674. colon : colon,
  8675. last : function() { return last; },
  8676. semicolon : semicolon,
  8677. force_semicolon : force_semicolon,
  8678. to_utf8 : to_utf8,
  8679. print_name : function(name) { print(make_name(name)); },
  8680. print_string : function(str, quote, escape_directive) {
  8681. var encoded = encode_string(str, quote);
  8682. if (escape_directive === true && !encoded.includes("\\")) {
  8683. // Insert semicolons to break directive prologue
  8684. if (!OUTPUT.expectDirective()) {
  8685. force_semicolon();
  8686. }
  8687. force_semicolon();
  8688. }
  8689. print(encoded);
  8690. },
  8691. print_template_string_chars: function(str) {
  8692. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  8693. return print(encoded.substr(1, encoded.length - 2));
  8694. },
  8695. encode_string : encode_string,
  8696. next_indent : next_indent,
  8697. with_indent : with_indent,
  8698. with_block : with_block,
  8699. with_parens : with_parens,
  8700. with_square : with_square,
  8701. add_mapping : add_mapping,
  8702. option : function(opt) { return options[opt]; },
  8703. gc_scope,
  8704. printed_comments: printed_comments,
  8705. prepend_comments: readonly ? noop : prepend_comments,
  8706. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  8707. line : function() { return current_line; },
  8708. col : function() { return current_col; },
  8709. pos : function() { return current_pos; },
  8710. push_node : function(node) { stack.push(node); },
  8711. pop_node : function() { return stack.pop(); },
  8712. parent : function(n) {
  8713. return stack[stack.length - 2 - (n || 0)];
  8714. }
  8715. };
  8716. }
  8717. /* -----[ code generators ]----- */
  8718. (function() {
  8719. /* -----[ utils ]----- */
  8720. function DEFPRINT(nodetype, generator) {
  8721. nodetype.DEFMETHOD("_codegen", generator);
  8722. }
  8723. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  8724. var self = this, generator = self._codegen;
  8725. if (self instanceof AST_Scope) {
  8726. output.active_scope = self;
  8727. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  8728. output.use_asm = output.active_scope;
  8729. }
  8730. function doit() {
  8731. output.prepend_comments(self);
  8732. self.add_source_map(output);
  8733. generator(self, output);
  8734. output.append_comments(self);
  8735. }
  8736. output.push_node(self);
  8737. if (force_parens || self.needs_parens(output)) {
  8738. output.with_parens(doit);
  8739. } else {
  8740. doit();
  8741. }
  8742. output.pop_node();
  8743. if (self === output.use_asm) {
  8744. output.use_asm = null;
  8745. }
  8746. });
  8747. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  8748. AST_Node.DEFMETHOD("print_to_string", function(options) {
  8749. var output = OutputStream(options);
  8750. this.print(output);
  8751. return output.get();
  8752. });
  8753. /* -----[ PARENTHESES ]----- */
  8754. function PARENS(nodetype, func) {
  8755. if (Array.isArray(nodetype)) {
  8756. nodetype.forEach(function(nodetype) {
  8757. PARENS(nodetype, func);
  8758. });
  8759. } else {
  8760. nodetype.DEFMETHOD("needs_parens", func);
  8761. }
  8762. }
  8763. PARENS(AST_Node, return_false);
  8764. // a function expression needs parens around it when it's provably
  8765. // the first token to appear in a statement.
  8766. PARENS(AST_Function, function(output) {
  8767. if (!output.has_parens() && first_in_statement(output)) {
  8768. return true;
  8769. }
  8770. if (output.option("webkit")) {
  8771. var p = output.parent();
  8772. if (p instanceof AST_PropAccess && p.expression === this) {
  8773. return true;
  8774. }
  8775. }
  8776. if (output.option("wrap_iife")) {
  8777. var p = output.parent();
  8778. if (p instanceof AST_Call && p.expression === this) {
  8779. return true;
  8780. }
  8781. }
  8782. if (output.option("wrap_func_args")) {
  8783. var p = output.parent();
  8784. if (p instanceof AST_Call && p.args.includes(this)) {
  8785. return true;
  8786. }
  8787. }
  8788. return false;
  8789. });
  8790. PARENS(AST_Arrow, function(output) {
  8791. var p = output.parent();
  8792. if (
  8793. output.option("wrap_func_args")
  8794. && p instanceof AST_Call
  8795. && p.args.includes(this)
  8796. ) {
  8797. return true;
  8798. }
  8799. return p instanceof AST_PropAccess && p.expression === this
  8800. || p instanceof AST_Conditional && p.condition === this;
  8801. });
  8802. // same goes for an object literal (as in AST_Function), because
  8803. // otherwise {...} would be interpreted as a block of code.
  8804. PARENS(AST_Object, function(output) {
  8805. return !output.has_parens() && first_in_statement(output);
  8806. });
  8807. PARENS(AST_ClassExpression, first_in_statement);
  8808. PARENS(AST_Unary, function(output) {
  8809. var p = output.parent();
  8810. return p instanceof AST_PropAccess && p.expression === this
  8811. || p instanceof AST_Call && p.expression === this
  8812. || p instanceof AST_Binary
  8813. && p.operator === "**"
  8814. && this instanceof AST_UnaryPrefix
  8815. && p.left === this
  8816. && this.operator !== "++"
  8817. && this.operator !== "--";
  8818. });
  8819. PARENS(AST_Await, function(output) {
  8820. var p = output.parent();
  8821. return p instanceof AST_PropAccess && p.expression === this
  8822. || p instanceof AST_Call && p.expression === this
  8823. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  8824. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  8825. });
  8826. PARENS(AST_Sequence, function(output) {
  8827. var p = output.parent();
  8828. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  8829. || p instanceof AST_Unary // !(foo, bar, baz)
  8830. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  8831. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  8832. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  8833. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  8834. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  8835. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  8836. * ==> 20 (side effect, set a := 10 and b := 20) */
  8837. || p instanceof AST_Arrow // x => (x, x)
  8838. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  8839. || p instanceof AST_Expansion // [...(a, b)]
  8840. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  8841. || p instanceof AST_Yield // yield (foo, bar)
  8842. || p instanceof AST_Export // export default (foo, bar)
  8843. ;
  8844. });
  8845. PARENS(AST_Binary, function(output) {
  8846. var p = output.parent();
  8847. // (foo && bar)()
  8848. if (p instanceof AST_Call && p.expression === this)
  8849. return true;
  8850. // typeof (foo && bar)
  8851. if (p instanceof AST_Unary)
  8852. return true;
  8853. // (foo && bar)["prop"], (foo && bar).prop
  8854. if (p instanceof AST_PropAccess && p.expression === this)
  8855. return true;
  8856. // this deals with precedence: 3 * (2 + 1)
  8857. if (p instanceof AST_Binary) {
  8858. const parent_op = p.operator;
  8859. const op = this.operator;
  8860. // It is forbidden for ?? to be used with || or && without parens.
  8861. if (op === "??" && (parent_op === "||" || parent_op === "&&")) {
  8862. return true;
  8863. }
  8864. if (parent_op === "??" && (op === "||" || op === "&&")) {
  8865. return true;
  8866. }
  8867. const pp = PRECEDENCE[parent_op];
  8868. const sp = PRECEDENCE[op];
  8869. if (pp > sp
  8870. || (pp == sp
  8871. && (this === p.right || parent_op == "**"))) {
  8872. return true;
  8873. }
  8874. }
  8875. if (p instanceof AST_PrivateIn) {
  8876. const op = this.operator;
  8877. const pp = PRECEDENCE["in"];
  8878. const sp = PRECEDENCE[op];
  8879. if (pp > sp || (pp == sp && this === p.value)) {
  8880. return true;
  8881. }
  8882. }
  8883. });
  8884. PARENS(AST_PrivateIn, function(output) {
  8885. var p = output.parent();
  8886. // (#x in this)()
  8887. if (p instanceof AST_Call && p.expression === this) {
  8888. return true;
  8889. }
  8890. // typeof (#x in this)
  8891. if (p instanceof AST_Unary) {
  8892. return true;
  8893. }
  8894. // (#x in this)["prop"], (#x in this).prop
  8895. if (p instanceof AST_PropAccess && p.expression === this) {
  8896. return true;
  8897. }
  8898. // same precedence as regular in operator
  8899. if (p instanceof AST_Binary) {
  8900. const parent_op = p.operator;
  8901. const pp = PRECEDENCE[parent_op];
  8902. const sp = PRECEDENCE["in"];
  8903. if (pp > sp
  8904. || (pp == sp
  8905. && (this === p.right || parent_op == "**"))) {
  8906. return true;
  8907. }
  8908. }
  8909. // rules are the same as binary in, but the class differs
  8910. if (p instanceof AST_PrivateIn && this === p.value) {
  8911. return true;
  8912. }
  8913. });
  8914. PARENS(AST_Yield, function(output) {
  8915. var p = output.parent();
  8916. // (yield 1) + (yield 2)
  8917. // a = yield 3
  8918. if (p instanceof AST_Binary && p.operator !== "=")
  8919. return true;
  8920. // (yield 1)()
  8921. // new (yield 1)()
  8922. if (p instanceof AST_Call && p.expression === this)
  8923. return true;
  8924. // (yield 1) ? yield 2 : yield 3
  8925. if (p instanceof AST_Conditional && p.condition === this)
  8926. return true;
  8927. // -(yield 4)
  8928. if (p instanceof AST_Unary)
  8929. return true;
  8930. // (yield x).foo
  8931. // (yield x)['foo']
  8932. if (p instanceof AST_PropAccess && p.expression === this)
  8933. return true;
  8934. });
  8935. PARENS(AST_Chain, function(output) {
  8936. var p = output.parent();
  8937. if (!(p instanceof AST_Call || p instanceof AST_PropAccess)) return false;
  8938. return p.expression === this;
  8939. });
  8940. PARENS(AST_PropAccess, function(output) {
  8941. var p = output.parent();
  8942. if (p instanceof AST_New && p.expression === this) {
  8943. // i.e. new (foo.bar().baz)
  8944. //
  8945. // if there's one call into this subtree, then we need
  8946. // parens around it too, otherwise the call will be
  8947. // interpreted as passing the arguments to the upper New
  8948. // expression.
  8949. return walk(this, node => {
  8950. if (node instanceof AST_Scope) return true;
  8951. if (node instanceof AST_Call) {
  8952. return walk_abort; // makes walk() return true.
  8953. }
  8954. });
  8955. }
  8956. });
  8957. PARENS(AST_Call, function(output) {
  8958. var p = output.parent(), p1;
  8959. if (p instanceof AST_New && p.expression === this
  8960. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  8961. return true;
  8962. // workaround for Safari bug.
  8963. // https://bugs.webkit.org/show_bug.cgi?id=123506
  8964. return this.expression instanceof AST_Function
  8965. && p instanceof AST_PropAccess
  8966. && p.expression === this
  8967. && (p1 = output.parent(1)) instanceof AST_Assign
  8968. && p1.left === p;
  8969. });
  8970. PARENS(AST_New, function(output) {
  8971. var p = output.parent();
  8972. if (this.args.length === 0
  8973. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  8974. || p instanceof AST_Call && p.expression === this
  8975. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  8976. return true;
  8977. });
  8978. PARENS(AST_Number, function(output) {
  8979. var p = output.parent();
  8980. if (p instanceof AST_PropAccess && p.expression === this) {
  8981. var value = this.getValue();
  8982. if (value < 0 || /^0/.test(make_num(value))) {
  8983. return true;
  8984. }
  8985. }
  8986. });
  8987. PARENS(AST_BigInt, function(output) {
  8988. var p = output.parent();
  8989. if (p instanceof AST_PropAccess && p.expression === this) {
  8990. var value = this.getValue();
  8991. if (value.startsWith("-")) {
  8992. return true;
  8993. }
  8994. }
  8995. });
  8996. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  8997. var p = output.parent();
  8998. // !(a = false) → true
  8999. if (p instanceof AST_Unary)
  9000. return true;
  9001. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  9002. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  9003. return true;
  9004. // (a = func)() —or— new (a = Object)()
  9005. if (p instanceof AST_Call && p.expression === this)
  9006. return true;
  9007. // (a = foo) ? bar : baz
  9008. if (p instanceof AST_Conditional && p.condition === this)
  9009. return true;
  9010. // (a = foo)["prop"] —or— (a = foo).prop
  9011. if (p instanceof AST_PropAccess && p.expression === this)
  9012. return true;
  9013. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  9014. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  9015. return true;
  9016. });
  9017. /* -----[ PRINTERS ]----- */
  9018. DEFPRINT(AST_Directive, function(self, output) {
  9019. output.print_string(self.value, self.quote);
  9020. output.semicolon();
  9021. });
  9022. DEFPRINT(AST_Expansion, function (self, output) {
  9023. output.print("...");
  9024. self.expression.print(output);
  9025. });
  9026. DEFPRINT(AST_Destructuring, function (self, output) {
  9027. output.print(self.is_array ? "[" : "{");
  9028. var len = self.names.length;
  9029. self.names.forEach(function (name, i) {
  9030. if (i > 0) output.comma();
  9031. name.print(output);
  9032. // If the final element is a hole, we need to make sure it
  9033. // doesn't look like a trailing comma, by inserting an actual
  9034. // trailing comma.
  9035. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  9036. });
  9037. output.print(self.is_array ? "]" : "}");
  9038. });
  9039. DEFPRINT(AST_Debugger, function(self, output) {
  9040. output.print("debugger");
  9041. output.semicolon();
  9042. });
  9043. /* -----[ statements ]----- */
  9044. function display_body(body, is_toplevel, output, allow_directives) {
  9045. var last = body.length - 1;
  9046. output.in_directive = allow_directives;
  9047. body.forEach(function(stmt, i) {
  9048. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  9049. stmt instanceof AST_EmptyStatement ||
  9050. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  9051. )) {
  9052. output.in_directive = false;
  9053. }
  9054. if (!(stmt instanceof AST_EmptyStatement)) {
  9055. output.indent();
  9056. stmt.print(output);
  9057. if (!(i == last && is_toplevel)) {
  9058. output.newline();
  9059. if (is_toplevel) output.newline();
  9060. }
  9061. }
  9062. if (output.in_directive === true &&
  9063. stmt instanceof AST_SimpleStatement &&
  9064. stmt.body instanceof AST_String
  9065. ) {
  9066. output.in_directive = false;
  9067. }
  9068. });
  9069. output.in_directive = false;
  9070. }
  9071. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  9072. print_maybe_braced_body(this.body, output);
  9073. });
  9074. DEFPRINT(AST_Statement, function(self, output) {
  9075. self.body.print(output);
  9076. output.semicolon();
  9077. });
  9078. DEFPRINT(AST_Toplevel, function(self, output) {
  9079. display_body(self.body, true, output, true);
  9080. output.print("");
  9081. });
  9082. DEFPRINT(AST_LabeledStatement, function(self, output) {
  9083. self.label.print(output);
  9084. output.colon();
  9085. self.body.print(output);
  9086. });
  9087. DEFPRINT(AST_SimpleStatement, function(self, output) {
  9088. self.body.print(output);
  9089. output.semicolon();
  9090. });
  9091. function print_braced_empty(self, output) {
  9092. output.print("{");
  9093. output.with_indent(output.next_indent(), function() {
  9094. output.append_comments(self, true);
  9095. });
  9096. output.add_mapping(self.end);
  9097. output.print("}");
  9098. }
  9099. function print_braced(self, output, allow_directives) {
  9100. if (self.body.length > 0) {
  9101. output.with_block(function() {
  9102. display_body(self.body, false, output, allow_directives);
  9103. output.add_mapping(self.end);
  9104. });
  9105. } else print_braced_empty(self, output);
  9106. }
  9107. DEFPRINT(AST_BlockStatement, function(self, output) {
  9108. print_braced(self, output);
  9109. });
  9110. DEFPRINT(AST_EmptyStatement, function(self, output) {
  9111. output.semicolon();
  9112. });
  9113. DEFPRINT(AST_Do, function(self, output) {
  9114. output.print("do");
  9115. output.space();
  9116. make_block(self.body, output);
  9117. output.space();
  9118. output.print("while");
  9119. output.space();
  9120. output.with_parens(function() {
  9121. self.condition.print(output);
  9122. });
  9123. output.semicolon();
  9124. });
  9125. DEFPRINT(AST_While, function(self, output) {
  9126. output.print("while");
  9127. output.space();
  9128. output.with_parens(function() {
  9129. self.condition.print(output);
  9130. });
  9131. output.space();
  9132. self._do_print_body(output);
  9133. });
  9134. DEFPRINT(AST_For, function(self, output) {
  9135. output.print("for");
  9136. output.space();
  9137. output.with_parens(function() {
  9138. if (self.init) {
  9139. if (self.init instanceof AST_Definitions) {
  9140. self.init.print(output);
  9141. } else {
  9142. parenthesize_for_noin(self.init, output, true);
  9143. }
  9144. output.print(";");
  9145. output.space();
  9146. } else {
  9147. output.print(";");
  9148. }
  9149. if (self.condition) {
  9150. self.condition.print(output);
  9151. output.print(";");
  9152. output.space();
  9153. } else {
  9154. output.print(";");
  9155. }
  9156. if (self.step) {
  9157. self.step.print(output);
  9158. }
  9159. });
  9160. output.space();
  9161. self._do_print_body(output);
  9162. });
  9163. DEFPRINT(AST_ForIn, function(self, output) {
  9164. output.print("for");
  9165. if (self.await) {
  9166. output.space();
  9167. output.print("await");
  9168. }
  9169. output.space();
  9170. output.with_parens(function() {
  9171. self.init.print(output);
  9172. output.space();
  9173. output.print(self instanceof AST_ForOf ? "of" : "in");
  9174. output.space();
  9175. self.object.print(output);
  9176. });
  9177. output.space();
  9178. self._do_print_body(output);
  9179. });
  9180. DEFPRINT(AST_With, function(self, output) {
  9181. output.print("with");
  9182. output.space();
  9183. output.with_parens(function() {
  9184. self.expression.print(output);
  9185. });
  9186. output.space();
  9187. self._do_print_body(output);
  9188. });
  9189. /* -----[ functions ]----- */
  9190. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  9191. var self = this;
  9192. if (!nokeyword) {
  9193. if (self.async) {
  9194. output.print("async");
  9195. output.space();
  9196. }
  9197. output.print("function");
  9198. if (self.is_generator) {
  9199. output.star();
  9200. }
  9201. if (self.name) {
  9202. output.space();
  9203. }
  9204. }
  9205. if (self.name instanceof AST_Symbol) {
  9206. self.name.print(output);
  9207. } else if (nokeyword && self.name instanceof AST_Node) {
  9208. output.with_square(function() {
  9209. self.name.print(output); // Computed method name
  9210. });
  9211. }
  9212. output.with_parens(function() {
  9213. self.argnames.forEach(function(arg, i) {
  9214. if (i) output.comma();
  9215. arg.print(output);
  9216. });
  9217. });
  9218. output.space();
  9219. print_braced(self, output, true);
  9220. });
  9221. DEFPRINT(AST_Lambda, function(self, output) {
  9222. self._do_print(output);
  9223. output.gc_scope(self);
  9224. });
  9225. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  9226. var tag = self.prefix;
  9227. var parenthesize_tag = tag instanceof AST_Lambda
  9228. || tag instanceof AST_Binary
  9229. || tag instanceof AST_Conditional
  9230. || tag instanceof AST_Sequence
  9231. || tag instanceof AST_Unary
  9232. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  9233. if (parenthesize_tag) output.print("(");
  9234. self.prefix.print(output);
  9235. if (parenthesize_tag) output.print(")");
  9236. self.template_string.print(output);
  9237. });
  9238. DEFPRINT(AST_TemplateString, function(self, output) {
  9239. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  9240. output.print("`");
  9241. for (var i = 0; i < self.segments.length; i++) {
  9242. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  9243. output.print("${");
  9244. self.segments[i].print(output);
  9245. output.print("}");
  9246. } else if (is_tagged) {
  9247. output.print(self.segments[i].raw);
  9248. } else {
  9249. output.print_template_string_chars(self.segments[i].value);
  9250. }
  9251. }
  9252. output.print("`");
  9253. });
  9254. DEFPRINT(AST_TemplateSegment, function(self, output) {
  9255. output.print_template_string_chars(self.value);
  9256. });
  9257. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  9258. var self = this;
  9259. var parent = output.parent();
  9260. var needs_parens = (parent instanceof AST_Binary &&
  9261. !(parent instanceof AST_Assign) &&
  9262. !(parent instanceof AST_DefaultAssign)) ||
  9263. parent instanceof AST_Unary ||
  9264. (parent instanceof AST_Call && self === parent.expression);
  9265. if (needs_parens) { output.print("("); }
  9266. if (self.async) {
  9267. output.print("async");
  9268. output.space();
  9269. }
  9270. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  9271. self.argnames[0].print(output);
  9272. } else {
  9273. output.with_parens(function() {
  9274. self.argnames.forEach(function(arg, i) {
  9275. if (i) output.comma();
  9276. arg.print(output);
  9277. });
  9278. });
  9279. }
  9280. output.space();
  9281. output.print("=>");
  9282. output.space();
  9283. const first_statement = self.body[0];
  9284. if (
  9285. self.body.length === 1
  9286. && first_statement instanceof AST_Return
  9287. ) {
  9288. const returned = first_statement.value;
  9289. if (!returned) {
  9290. output.print("{}");
  9291. } else if (left_is_object(returned)) {
  9292. output.print("(");
  9293. returned.print(output);
  9294. output.print(")");
  9295. } else {
  9296. returned.print(output);
  9297. }
  9298. } else {
  9299. print_braced(self, output);
  9300. }
  9301. if (needs_parens) { output.print(")"); }
  9302. output.gc_scope(self);
  9303. });
  9304. /* -----[ exits ]----- */
  9305. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  9306. output.print(kind);
  9307. if (this.value) {
  9308. output.space();
  9309. const comments = this.value.start.comments_before;
  9310. if (comments && comments.length && !output.printed_comments.has(comments)) {
  9311. output.print("(");
  9312. this.value.print(output);
  9313. output.print(")");
  9314. } else {
  9315. this.value.print(output);
  9316. }
  9317. }
  9318. output.semicolon();
  9319. });
  9320. DEFPRINT(AST_Return, function(self, output) {
  9321. self._do_print(output, "return");
  9322. });
  9323. DEFPRINT(AST_Throw, function(self, output) {
  9324. self._do_print(output, "throw");
  9325. });
  9326. /* -----[ yield ]----- */
  9327. DEFPRINT(AST_Yield, function(self, output) {
  9328. var star = self.is_star ? "*" : "";
  9329. output.print("yield" + star);
  9330. if (self.expression) {
  9331. output.space();
  9332. self.expression.print(output);
  9333. }
  9334. });
  9335. DEFPRINT(AST_Await, function(self, output) {
  9336. output.print("await");
  9337. output.space();
  9338. var e = self.expression;
  9339. var parens = !(
  9340. e instanceof AST_Call
  9341. || e instanceof AST_SymbolRef
  9342. || e instanceof AST_PropAccess
  9343. || e instanceof AST_Unary
  9344. || e instanceof AST_Constant
  9345. || e instanceof AST_Await
  9346. || e instanceof AST_Object
  9347. );
  9348. if (parens) output.print("(");
  9349. self.expression.print(output);
  9350. if (parens) output.print(")");
  9351. });
  9352. /* -----[ loop control ]----- */
  9353. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  9354. output.print(kind);
  9355. if (this.label) {
  9356. output.space();
  9357. this.label.print(output);
  9358. }
  9359. output.semicolon();
  9360. });
  9361. DEFPRINT(AST_Break, function(self, output) {
  9362. self._do_print(output, "break");
  9363. });
  9364. DEFPRINT(AST_Continue, function(self, output) {
  9365. self._do_print(output, "continue");
  9366. });
  9367. /* -----[ if ]----- */
  9368. function make_then(self, output) {
  9369. var b = self.body;
  9370. if (output.option("braces")
  9371. || output.option("ie8") && b instanceof AST_Do)
  9372. return make_block(b, output);
  9373. // The squeezer replaces "block"-s that contain only a single
  9374. // statement with the statement itself; technically, the AST
  9375. // is correct, but this can create problems when we output an
  9376. // IF having an ELSE clause where the THEN clause ends in an
  9377. // IF *without* an ELSE block (then the outer ELSE would refer
  9378. // to the inner IF). This function checks for this case and
  9379. // adds the block braces if needed.
  9380. if (!b) return output.force_semicolon();
  9381. while (true) {
  9382. if (b instanceof AST_If) {
  9383. if (!b.alternative) {
  9384. make_block(self.body, output);
  9385. return;
  9386. }
  9387. b = b.alternative;
  9388. } else if (b instanceof AST_StatementWithBody) {
  9389. b = b.body;
  9390. } else break;
  9391. }
  9392. print_maybe_braced_body(self.body, output);
  9393. }
  9394. DEFPRINT(AST_If, function(self, output) {
  9395. output.print("if");
  9396. output.space();
  9397. output.with_parens(function() {
  9398. self.condition.print(output);
  9399. });
  9400. output.space();
  9401. if (self.alternative) {
  9402. make_then(self, output);
  9403. output.space();
  9404. output.print("else");
  9405. output.space();
  9406. if (self.alternative instanceof AST_If)
  9407. self.alternative.print(output);
  9408. else
  9409. print_maybe_braced_body(self.alternative, output);
  9410. } else {
  9411. self._do_print_body(output);
  9412. }
  9413. });
  9414. /* -----[ switch ]----- */
  9415. DEFPRINT(AST_Switch, function(self, output) {
  9416. output.print("switch");
  9417. output.space();
  9418. output.with_parens(function() {
  9419. self.expression.print(output);
  9420. });
  9421. output.space();
  9422. var last = self.body.length - 1;
  9423. if (last < 0) print_braced_empty(self, output);
  9424. else output.with_block(function() {
  9425. self.body.forEach(function(branch, i) {
  9426. output.indent(true);
  9427. branch.print(output);
  9428. if (i < last && branch.body.length > 0)
  9429. output.newline();
  9430. });
  9431. });
  9432. });
  9433. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  9434. output.newline();
  9435. this.body.forEach(function(stmt) {
  9436. output.indent();
  9437. stmt.print(output);
  9438. output.newline();
  9439. });
  9440. });
  9441. DEFPRINT(AST_Default, function(self, output) {
  9442. output.print("default:");
  9443. self._do_print_body(output);
  9444. });
  9445. DEFPRINT(AST_Case, function(self, output) {
  9446. output.print("case");
  9447. output.space();
  9448. self.expression.print(output);
  9449. output.print(":");
  9450. self._do_print_body(output);
  9451. });
  9452. /* -----[ exceptions ]----- */
  9453. DEFPRINT(AST_Try, function(self, output) {
  9454. output.print("try");
  9455. output.space();
  9456. self.body.print(output);
  9457. if (self.bcatch) {
  9458. output.space();
  9459. self.bcatch.print(output);
  9460. }
  9461. if (self.bfinally) {
  9462. output.space();
  9463. self.bfinally.print(output);
  9464. }
  9465. });
  9466. DEFPRINT(AST_TryBlock, function(self, output) {
  9467. print_braced(self, output);
  9468. });
  9469. DEFPRINT(AST_Catch, function(self, output) {
  9470. output.print("catch");
  9471. if (self.argname) {
  9472. output.space();
  9473. output.with_parens(function() {
  9474. self.argname.print(output);
  9475. });
  9476. }
  9477. output.space();
  9478. print_braced(self, output);
  9479. });
  9480. DEFPRINT(AST_Finally, function(self, output) {
  9481. output.print("finally");
  9482. output.space();
  9483. print_braced(self, output);
  9484. });
  9485. /* -----[ var/const ]----- */
  9486. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  9487. output.print(kind);
  9488. output.space();
  9489. this.definitions.forEach(function(def, i) {
  9490. if (i) output.comma();
  9491. def.print(output);
  9492. });
  9493. var p = output.parent();
  9494. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  9495. var output_semicolon = !in_for || p && p.init !== this;
  9496. if (output_semicolon)
  9497. output.semicolon();
  9498. });
  9499. DEFPRINT(AST_Let, function(self, output) {
  9500. self._do_print(output, "let");
  9501. });
  9502. DEFPRINT(AST_Var, function(self, output) {
  9503. self._do_print(output, "var");
  9504. });
  9505. DEFPRINT(AST_Const, function(self, output) {
  9506. self._do_print(output, "const");
  9507. });
  9508. DEFPRINT(AST_Import, function(self, output) {
  9509. output.print("import");
  9510. output.space();
  9511. if (self.imported_name) {
  9512. self.imported_name.print(output);
  9513. }
  9514. if (self.imported_name && self.imported_names) {
  9515. output.print(",");
  9516. output.space();
  9517. }
  9518. if (self.imported_names) {
  9519. if (self.imported_names.length === 1 &&
  9520. self.imported_names[0].foreign_name.name === "*" &&
  9521. !self.imported_names[0].foreign_name.quote) {
  9522. self.imported_names[0].print(output);
  9523. } else {
  9524. output.print("{");
  9525. self.imported_names.forEach(function (name_import, i) {
  9526. output.space();
  9527. name_import.print(output);
  9528. if (i < self.imported_names.length - 1) {
  9529. output.print(",");
  9530. }
  9531. });
  9532. output.space();
  9533. output.print("}");
  9534. }
  9535. }
  9536. if (self.imported_name || self.imported_names) {
  9537. output.space();
  9538. output.print("from");
  9539. output.space();
  9540. }
  9541. self.module_name.print(output);
  9542. if (self.assert_clause) {
  9543. output.print("assert");
  9544. self.assert_clause.print(output);
  9545. }
  9546. output.semicolon();
  9547. });
  9548. DEFPRINT(AST_ImportMeta, function(self, output) {
  9549. output.print("import.meta");
  9550. });
  9551. DEFPRINT(AST_NameMapping, function(self, output) {
  9552. var is_import = output.parent() instanceof AST_Import;
  9553. var definition = self.name.definition();
  9554. var foreign_name = self.foreign_name;
  9555. var names_are_different =
  9556. (definition && definition.mangled_name || self.name.name) !==
  9557. foreign_name.name;
  9558. if (!names_are_different &&
  9559. foreign_name.name === "*" &&
  9560. foreign_name.quote != self.name.quote) {
  9561. // export * as "*"
  9562. names_are_different = true;
  9563. }
  9564. var foreign_name_is_name = foreign_name.quote == null;
  9565. if (names_are_different) {
  9566. if (is_import) {
  9567. if (foreign_name_is_name) {
  9568. output.print(foreign_name.name);
  9569. } else {
  9570. output.print_string(foreign_name.name, foreign_name.quote);
  9571. }
  9572. } else {
  9573. if (self.name.quote == null) {
  9574. self.name.print(output);
  9575. } else {
  9576. output.print_string(self.name.name, self.name.quote);
  9577. }
  9578. }
  9579. output.space();
  9580. output.print("as");
  9581. output.space();
  9582. if (is_import) {
  9583. self.name.print(output);
  9584. } else {
  9585. if (foreign_name_is_name) {
  9586. output.print(foreign_name.name);
  9587. } else {
  9588. output.print_string(foreign_name.name, foreign_name.quote);
  9589. }
  9590. }
  9591. } else {
  9592. if (self.name.quote == null) {
  9593. self.name.print(output);
  9594. } else {
  9595. output.print_string(self.name.name, self.name.quote);
  9596. }
  9597. }
  9598. });
  9599. DEFPRINT(AST_Export, function(self, output) {
  9600. output.print("export");
  9601. output.space();
  9602. if (self.is_default) {
  9603. output.print("default");
  9604. output.space();
  9605. }
  9606. if (self.exported_names) {
  9607. if (self.exported_names.length === 1 &&
  9608. self.exported_names[0].name.name === "*" &&
  9609. !self.exported_names[0].name.quote) {
  9610. self.exported_names[0].print(output);
  9611. } else {
  9612. output.print("{");
  9613. self.exported_names.forEach(function(name_export, i) {
  9614. output.space();
  9615. name_export.print(output);
  9616. if (i < self.exported_names.length - 1) {
  9617. output.print(",");
  9618. }
  9619. });
  9620. output.space();
  9621. output.print("}");
  9622. }
  9623. } else if (self.exported_value) {
  9624. self.exported_value.print(output);
  9625. } else if (self.exported_definition) {
  9626. self.exported_definition.print(output);
  9627. if (self.exported_definition instanceof AST_Definitions) return;
  9628. }
  9629. if (self.module_name) {
  9630. output.space();
  9631. output.print("from");
  9632. output.space();
  9633. self.module_name.print(output);
  9634. }
  9635. if (self.assert_clause) {
  9636. output.print("assert");
  9637. self.assert_clause.print(output);
  9638. }
  9639. if (self.exported_value
  9640. && !(self.exported_value instanceof AST_Defun ||
  9641. self.exported_value instanceof AST_Function ||
  9642. self.exported_value instanceof AST_Class)
  9643. || self.module_name
  9644. || self.exported_names
  9645. ) {
  9646. output.semicolon();
  9647. }
  9648. });
  9649. function parenthesize_for_noin(node, output, noin) {
  9650. var parens = false;
  9651. // need to take some precautions here:
  9652. // https://github.com/mishoo/UglifyJS2/issues/60
  9653. if (noin) {
  9654. parens = walk(node, node => {
  9655. // Don't go into scopes -- except arrow functions:
  9656. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  9657. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  9658. return true;
  9659. }
  9660. if (
  9661. node instanceof AST_Binary && node.operator == "in"
  9662. || node instanceof AST_PrivateIn
  9663. ) {
  9664. return walk_abort; // makes walk() return true
  9665. }
  9666. });
  9667. }
  9668. node.print(output, parens);
  9669. }
  9670. DEFPRINT(AST_VarDef, function(self, output) {
  9671. self.name.print(output);
  9672. if (self.value) {
  9673. output.space();
  9674. output.print("=");
  9675. output.space();
  9676. var p = output.parent(1);
  9677. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  9678. parenthesize_for_noin(self.value, output, noin);
  9679. }
  9680. });
  9681. /* -----[ other expressions ]----- */
  9682. DEFPRINT(AST_Call, function(self, output) {
  9683. self.expression.print(output);
  9684. if (self instanceof AST_New && self.args.length === 0)
  9685. return;
  9686. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  9687. output.add_mapping(self.start);
  9688. }
  9689. if (self.optional) output.print("?.");
  9690. output.with_parens(function() {
  9691. self.args.forEach(function(expr, i) {
  9692. if (i) output.comma();
  9693. expr.print(output);
  9694. });
  9695. });
  9696. });
  9697. DEFPRINT(AST_New, function(self, output) {
  9698. output.print("new");
  9699. output.space();
  9700. AST_Call.prototype._codegen(self, output);
  9701. });
  9702. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  9703. this.expressions.forEach(function(node, index) {
  9704. if (index > 0) {
  9705. output.comma();
  9706. if (output.should_break()) {
  9707. output.newline();
  9708. output.indent();
  9709. }
  9710. }
  9711. node.print(output);
  9712. });
  9713. });
  9714. DEFPRINT(AST_Sequence, function(self, output) {
  9715. self._do_print(output);
  9716. // var p = output.parent();
  9717. // if (p instanceof AST_Statement) {
  9718. // output.with_indent(output.next_indent(), function(){
  9719. // self._do_print(output);
  9720. // });
  9721. // } else {
  9722. // self._do_print(output);
  9723. // }
  9724. });
  9725. DEFPRINT(AST_Dot, function(self, output) {
  9726. var expr = self.expression;
  9727. expr.print(output);
  9728. var prop = self.property;
  9729. var print_computed = ALL_RESERVED_WORDS.has(prop)
  9730. ? output.option("ie8")
  9731. : !is_identifier_string(
  9732. prop,
  9733. output.option("ecma") >= 2015 && !output.option("safari10")
  9734. );
  9735. if (self.optional) output.print("?.");
  9736. if (print_computed) {
  9737. output.print("[");
  9738. output.add_mapping(self.end);
  9739. output.print_string(prop);
  9740. output.print("]");
  9741. } else {
  9742. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  9743. if (!/[xa-f.)]/i.test(output.last())) {
  9744. output.print(".");
  9745. }
  9746. }
  9747. if (!self.optional) output.print(".");
  9748. // the name after dot would be mapped about here.
  9749. output.add_mapping(self.end);
  9750. output.print_name(prop);
  9751. }
  9752. });
  9753. DEFPRINT(AST_DotHash, function(self, output) {
  9754. var expr = self.expression;
  9755. expr.print(output);
  9756. var prop = self.property;
  9757. if (self.optional) output.print("?");
  9758. output.print(".#");
  9759. output.add_mapping(self.end);
  9760. output.print_name(prop);
  9761. });
  9762. DEFPRINT(AST_Sub, function(self, output) {
  9763. self.expression.print(output);
  9764. if (self.optional) output.print("?.");
  9765. output.print("[");
  9766. self.property.print(output);
  9767. output.print("]");
  9768. });
  9769. DEFPRINT(AST_Chain, function(self, output) {
  9770. self.expression.print(output);
  9771. });
  9772. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  9773. var op = self.operator;
  9774. if (op === "--" && output.last().endsWith("!")) {
  9775. // avoid printing "<!--"
  9776. output.print(" ");
  9777. }
  9778. output.print(op);
  9779. if (/^[a-z]/i.test(op)
  9780. || (/[+-]$/.test(op)
  9781. && self.expression instanceof AST_UnaryPrefix
  9782. && /^[+-]/.test(self.expression.operator))) {
  9783. output.space();
  9784. }
  9785. self.expression.print(output);
  9786. });
  9787. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  9788. self.expression.print(output);
  9789. output.print(self.operator);
  9790. });
  9791. DEFPRINT(AST_Binary, function(self, output) {
  9792. var op = self.operator;
  9793. self.left.print(output);
  9794. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  9795. && output.last().endsWith("--")) {
  9796. // space is mandatory to avoid outputting -->
  9797. output.print(" ");
  9798. } else {
  9799. // the space is optional depending on "beautify"
  9800. output.space();
  9801. }
  9802. output.print(op);
  9803. output.space();
  9804. self.right.print(output);
  9805. });
  9806. DEFPRINT(AST_Conditional, function(self, output) {
  9807. self.condition.print(output);
  9808. output.space();
  9809. output.print("?");
  9810. output.space();
  9811. self.consequent.print(output);
  9812. output.space();
  9813. output.colon();
  9814. self.alternative.print(output);
  9815. });
  9816. /* -----[ literals ]----- */
  9817. DEFPRINT(AST_Array, function(self, output) {
  9818. output.with_square(function() {
  9819. var a = self.elements, len = a.length;
  9820. if (len > 0) output.space();
  9821. a.forEach(function(exp, i) {
  9822. if (i) output.comma();
  9823. exp.print(output);
  9824. // If the final element is a hole, we need to make sure it
  9825. // doesn't look like a trailing comma, by inserting an actual
  9826. // trailing comma.
  9827. if (i === len - 1 && exp instanceof AST_Hole)
  9828. output.comma();
  9829. });
  9830. if (len > 0) output.space();
  9831. });
  9832. });
  9833. DEFPRINT(AST_Object, function(self, output) {
  9834. if (self.properties.length > 0) output.with_block(function() {
  9835. self.properties.forEach(function(prop, i) {
  9836. if (i) {
  9837. output.print(",");
  9838. output.newline();
  9839. }
  9840. output.indent();
  9841. prop.print(output);
  9842. });
  9843. output.newline();
  9844. });
  9845. else print_braced_empty(self, output);
  9846. });
  9847. DEFPRINT(AST_Class, function(self, output) {
  9848. output.print("class");
  9849. output.space();
  9850. if (self.name) {
  9851. self.name.print(output);
  9852. output.space();
  9853. }
  9854. if (self.extends) {
  9855. var parens = (
  9856. !(self.extends instanceof AST_SymbolRef)
  9857. && !(self.extends instanceof AST_PropAccess)
  9858. && !(self.extends instanceof AST_ClassExpression)
  9859. && !(self.extends instanceof AST_Function)
  9860. );
  9861. output.print("extends");
  9862. if (parens) {
  9863. output.print("(");
  9864. } else {
  9865. output.space();
  9866. }
  9867. self.extends.print(output);
  9868. if (parens) {
  9869. output.print(")");
  9870. } else {
  9871. output.space();
  9872. }
  9873. }
  9874. if (self.properties.length > 0) output.with_block(function() {
  9875. self.properties.forEach(function(prop, i) {
  9876. if (i) {
  9877. output.newline();
  9878. }
  9879. output.indent();
  9880. prop.print(output);
  9881. });
  9882. output.newline();
  9883. });
  9884. else output.print("{}");
  9885. });
  9886. DEFPRINT(AST_NewTarget, function(self, output) {
  9887. output.print("new.target");
  9888. });
  9889. /** Prints a prop name. Returns whether it can be used as a shorthand. */
  9890. function print_property_name(key, quote, output) {
  9891. if (output.option("quote_keys")) {
  9892. output.print_string(key);
  9893. return false;
  9894. }
  9895. if ("" + +key == key && key >= 0) {
  9896. if (output.option("keep_numbers")) {
  9897. output.print(key);
  9898. return false;
  9899. }
  9900. output.print(make_num(key));
  9901. return false;
  9902. }
  9903. var print_string = ALL_RESERVED_WORDS.has(key)
  9904. ? output.option("ie8")
  9905. : (
  9906. output.option("ecma") < 2015 || output.option("safari10")
  9907. ? !is_basic_identifier_string(key)
  9908. : !is_identifier_string(key, true)
  9909. );
  9910. if (print_string || (quote && output.option("keep_quoted_props"))) {
  9911. output.print_string(key, quote);
  9912. return false;
  9913. }
  9914. output.print_name(key);
  9915. return true;
  9916. }
  9917. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  9918. function get_name(self) {
  9919. var def = self.definition();
  9920. return def ? def.mangled_name || def.name : self.name;
  9921. }
  9922. const try_shorthand = output.option("shorthand") && !(self.key instanceof AST_Node);
  9923. if (
  9924. try_shorthand
  9925. && self.value instanceof AST_Symbol
  9926. && get_name(self.value) === self.key
  9927. && !ALL_RESERVED_WORDS.has(self.key)
  9928. ) {
  9929. const was_shorthand = print_property_name(self.key, self.quote, output);
  9930. if (!was_shorthand) {
  9931. output.colon();
  9932. self.value.print(output);
  9933. }
  9934. } else if (
  9935. try_shorthand
  9936. && self.value instanceof AST_DefaultAssign
  9937. && self.value.left instanceof AST_Symbol
  9938. && get_name(self.value.left) === self.key
  9939. ) {
  9940. const was_shorthand = print_property_name(self.key, self.quote, output);
  9941. if (!was_shorthand) {
  9942. output.colon();
  9943. self.value.left.print(output);
  9944. }
  9945. output.space();
  9946. output.print("=");
  9947. output.space();
  9948. self.value.right.print(output);
  9949. } else {
  9950. if (!(self.key instanceof AST_Node)) {
  9951. print_property_name(self.key, self.quote, output);
  9952. } else {
  9953. output.with_square(function() {
  9954. self.key.print(output);
  9955. });
  9956. }
  9957. output.colon();
  9958. self.value.print(output);
  9959. }
  9960. });
  9961. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  9962. if (self.static) {
  9963. output.print("static");
  9964. output.space();
  9965. }
  9966. output.print("#");
  9967. print_property_name(self.key.name, self.quote, output);
  9968. if (self.value) {
  9969. output.print("=");
  9970. self.value.print(output);
  9971. }
  9972. output.semicolon();
  9973. });
  9974. DEFPRINT(AST_ClassProperty, (self, output) => {
  9975. if (self.static) {
  9976. output.print("static");
  9977. output.space();
  9978. }
  9979. if (self.key instanceof AST_SymbolClassProperty) {
  9980. print_property_name(self.key.name, self.quote, output);
  9981. } else {
  9982. output.print("[");
  9983. self.key.print(output);
  9984. output.print("]");
  9985. }
  9986. if (self.value) {
  9987. output.print("=");
  9988. self.value.print(output);
  9989. }
  9990. output.semicolon();
  9991. });
  9992. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  9993. var self = this;
  9994. if (self.static) {
  9995. output.print("static");
  9996. output.space();
  9997. }
  9998. if (type) {
  9999. output.print(type);
  10000. output.space();
  10001. }
  10002. if (self.key instanceof AST_SymbolMethod) {
  10003. if (is_private) output.print("#");
  10004. print_property_name(self.key.name, self.quote, output);
  10005. self.key.add_source_map(output);
  10006. } else {
  10007. output.with_square(function() {
  10008. self.key.print(output);
  10009. });
  10010. }
  10011. self.value._do_print(output, true);
  10012. });
  10013. DEFPRINT(AST_ObjectSetter, function(self, output) {
  10014. self._print_getter_setter("set", false, output);
  10015. });
  10016. DEFPRINT(AST_ObjectGetter, function(self, output) {
  10017. self._print_getter_setter("get", false, output);
  10018. });
  10019. DEFPRINT(AST_PrivateSetter, function(self, output) {
  10020. self._print_getter_setter("set", true, output);
  10021. });
  10022. DEFPRINT(AST_PrivateGetter, function(self, output) {
  10023. self._print_getter_setter("get", true, output);
  10024. });
  10025. DEFPRINT(AST_PrivateMethod, function(self, output) {
  10026. var type;
  10027. if (self.is_generator && self.async) {
  10028. type = "async*";
  10029. } else if (self.is_generator) {
  10030. type = "*";
  10031. } else if (self.async) {
  10032. type = "async";
  10033. }
  10034. self._print_getter_setter(type, true, output);
  10035. });
  10036. DEFPRINT(AST_PrivateIn, function(self, output) {
  10037. self.key.print(output);
  10038. output.space();
  10039. output.print("in");
  10040. output.space();
  10041. self.value.print(output);
  10042. });
  10043. DEFPRINT(AST_SymbolPrivateProperty, function(self, output) {
  10044. output.print("#" + self.name);
  10045. });
  10046. DEFPRINT(AST_ConciseMethod, function(self, output) {
  10047. var type;
  10048. if (self.is_generator && self.async) {
  10049. type = "async*";
  10050. } else if (self.is_generator) {
  10051. type = "*";
  10052. } else if (self.async) {
  10053. type = "async";
  10054. }
  10055. self._print_getter_setter(type, false, output);
  10056. });
  10057. DEFPRINT(AST_ClassStaticBlock, function (self, output) {
  10058. output.print("static");
  10059. output.space();
  10060. print_braced(self, output);
  10061. });
  10062. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  10063. var def = this.definition();
  10064. output.print_name(def ? def.mangled_name || def.name : this.name);
  10065. });
  10066. DEFPRINT(AST_Symbol, function (self, output) {
  10067. self._do_print(output);
  10068. });
  10069. DEFPRINT(AST_Hole, noop);
  10070. DEFPRINT(AST_This, function(self, output) {
  10071. output.print("this");
  10072. });
  10073. DEFPRINT(AST_Super, function(self, output) {
  10074. output.print("super");
  10075. });
  10076. DEFPRINT(AST_Constant, function(self, output) {
  10077. output.print(self.getValue());
  10078. });
  10079. DEFPRINT(AST_String, function(self, output) {
  10080. output.print_string(self.getValue(), self.quote, output.in_directive);
  10081. });
  10082. DEFPRINT(AST_Number, function(self, output) {
  10083. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  10084. output.print(self.raw);
  10085. } else {
  10086. output.print(make_num(self.getValue()));
  10087. }
  10088. });
  10089. DEFPRINT(AST_BigInt, function(self, output) {
  10090. output.print(self.getValue() + "n");
  10091. });
  10092. const r_slash_script = /(<\s*\/\s*script)/i;
  10093. const r_starts_with_script = /^\s*script/i;
  10094. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  10095. DEFPRINT(AST_RegExp, function(self, output) {
  10096. let { source, flags } = self.getValue();
  10097. source = regexp_source_fix(source);
  10098. flags = flags ? sort_regexp_flags(flags) : "";
  10099. // Avoid outputting end of script tag
  10100. source = source.replace(r_slash_script, slash_script_replace);
  10101. if (r_starts_with_script.test(source) && output.last().endsWith("<")) {
  10102. output.print(" ");
  10103. }
  10104. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  10105. const parent = output.parent();
  10106. if (
  10107. parent instanceof AST_Binary
  10108. && /^\w/.test(parent.operator)
  10109. && parent.left === self
  10110. ) {
  10111. output.print(" ");
  10112. }
  10113. });
  10114. /** if, for, while, may or may not have braces surrounding its body */
  10115. function print_maybe_braced_body(stat, output) {
  10116. if (output.option("braces")) {
  10117. make_block(stat, output);
  10118. } else {
  10119. if (!stat || stat instanceof AST_EmptyStatement)
  10120. output.force_semicolon();
  10121. else if (stat instanceof AST_Let || stat instanceof AST_Const || stat instanceof AST_Class)
  10122. make_block(stat, output);
  10123. else
  10124. stat.print(output);
  10125. }
  10126. }
  10127. function best_of(a) {
  10128. var best = a[0], len = best.length;
  10129. for (var i = 1; i < a.length; ++i) {
  10130. if (a[i].length < len) {
  10131. best = a[i];
  10132. len = best.length;
  10133. }
  10134. }
  10135. return best;
  10136. }
  10137. function make_num(num) {
  10138. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  10139. var candidates = [ str ];
  10140. if (Math.floor(num) === num) {
  10141. if (num < 0) {
  10142. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  10143. } else {
  10144. candidates.push("0x" + num.toString(16).toLowerCase());
  10145. }
  10146. }
  10147. var match, len, digits;
  10148. if (match = /^\.0+/.exec(str)) {
  10149. len = match[0].length;
  10150. digits = str.slice(len);
  10151. candidates.push(digits + "e-" + (digits.length + len - 1));
  10152. } else if (match = /0+$/.exec(str)) {
  10153. len = match[0].length;
  10154. candidates.push(str.slice(0, -len) + "e" + len);
  10155. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  10156. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  10157. }
  10158. return best_of(candidates);
  10159. }
  10160. function make_block(stmt, output) {
  10161. if (!stmt || stmt instanceof AST_EmptyStatement)
  10162. output.print("{}");
  10163. else if (stmt instanceof AST_BlockStatement)
  10164. stmt.print(output);
  10165. else output.with_block(function() {
  10166. output.indent();
  10167. stmt.print(output);
  10168. output.newline();
  10169. });
  10170. }
  10171. /* -----[ source map generators ]----- */
  10172. function DEFMAP(nodetype, generator) {
  10173. nodetype.forEach(function(nodetype) {
  10174. nodetype.DEFMETHOD("add_source_map", generator);
  10175. });
  10176. }
  10177. DEFMAP([
  10178. // We could easily add info for ALL nodes, but it seems to me that
  10179. // would be quite wasteful, hence this noop in the base class.
  10180. AST_Node,
  10181. // since the label symbol will mark it
  10182. AST_LabeledStatement,
  10183. AST_Toplevel,
  10184. ], noop);
  10185. // XXX: I'm not exactly sure if we need it for all of these nodes,
  10186. // or if we should add even more.
  10187. DEFMAP([
  10188. AST_Array,
  10189. AST_BlockStatement,
  10190. AST_Catch,
  10191. AST_Class,
  10192. AST_Constant,
  10193. AST_Debugger,
  10194. AST_Definitions,
  10195. AST_Directive,
  10196. AST_Finally,
  10197. AST_Jump,
  10198. AST_Lambda,
  10199. AST_New,
  10200. AST_Object,
  10201. AST_StatementWithBody,
  10202. AST_Symbol,
  10203. AST_Switch,
  10204. AST_SwitchBranch,
  10205. AST_TemplateString,
  10206. AST_TemplateSegment,
  10207. AST_Try,
  10208. ], function(output) {
  10209. output.add_mapping(this.start);
  10210. });
  10211. DEFMAP([
  10212. AST_ObjectGetter,
  10213. AST_ObjectSetter,
  10214. AST_PrivateGetter,
  10215. AST_PrivateSetter,
  10216. AST_ConciseMethod,
  10217. AST_PrivateMethod,
  10218. ], function(output) {
  10219. output.add_mapping(this.start, false /*name handled below*/);
  10220. });
  10221. DEFMAP([
  10222. AST_SymbolMethod,
  10223. AST_SymbolPrivateProperty
  10224. ], function(output) {
  10225. const tok_type = this.end && this.end.type;
  10226. if (tok_type === "name" || tok_type === "privatename") {
  10227. output.add_mapping(this.end, this.name);
  10228. } else {
  10229. output.add_mapping(this.end);
  10230. }
  10231. });
  10232. DEFMAP([ AST_ObjectProperty ], function(output) {
  10233. output.add_mapping(this.start, this.key);
  10234. });
  10235. })();
  10236. const shallow_cmp = (node1, node2) => {
  10237. return (
  10238. node1 === null && node2 === null
  10239. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  10240. );
  10241. };
  10242. const equivalent_to = (tree1, tree2) => {
  10243. if (!shallow_cmp(tree1, tree2)) return false;
  10244. const walk_1_state = [tree1];
  10245. const walk_2_state = [tree2];
  10246. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  10247. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  10248. while (walk_1_state.length && walk_2_state.length) {
  10249. const node_1 = walk_1_state.pop();
  10250. const node_2 = walk_2_state.pop();
  10251. if (!shallow_cmp(node_1, node_2)) return false;
  10252. node_1._children_backwards(walk_1_push);
  10253. node_2._children_backwards(walk_2_push);
  10254. if (walk_1_state.length !== walk_2_state.length) {
  10255. // Different number of children
  10256. return false;
  10257. }
  10258. }
  10259. return walk_1_state.length == 0 && walk_2_state.length == 0;
  10260. };
  10261. const pass_through = () => true;
  10262. AST_Node.prototype.shallow_cmp = function () {
  10263. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  10264. };
  10265. AST_Debugger.prototype.shallow_cmp = pass_through;
  10266. AST_Directive.prototype.shallow_cmp = function(other) {
  10267. return this.value === other.value;
  10268. };
  10269. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  10270. AST_Block.prototype.shallow_cmp = pass_through;
  10271. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  10272. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  10273. return this.label.name === other.label.name;
  10274. };
  10275. AST_Do.prototype.shallow_cmp = pass_through;
  10276. AST_While.prototype.shallow_cmp = pass_through;
  10277. AST_For.prototype.shallow_cmp = function(other) {
  10278. 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);
  10279. };
  10280. AST_ForIn.prototype.shallow_cmp = pass_through;
  10281. AST_ForOf.prototype.shallow_cmp = pass_through;
  10282. AST_With.prototype.shallow_cmp = pass_through;
  10283. AST_Toplevel.prototype.shallow_cmp = pass_through;
  10284. AST_Expansion.prototype.shallow_cmp = pass_through;
  10285. AST_Lambda.prototype.shallow_cmp = function(other) {
  10286. return this.is_generator === other.is_generator && this.async === other.async;
  10287. };
  10288. AST_Destructuring.prototype.shallow_cmp = function(other) {
  10289. return this.is_array === other.is_array;
  10290. };
  10291. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  10292. AST_TemplateString.prototype.shallow_cmp = pass_through;
  10293. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  10294. return this.value === other.value;
  10295. };
  10296. AST_Jump.prototype.shallow_cmp = pass_through;
  10297. AST_LoopControl.prototype.shallow_cmp = pass_through;
  10298. AST_Await.prototype.shallow_cmp = pass_through;
  10299. AST_Yield.prototype.shallow_cmp = function(other) {
  10300. return this.is_star === other.is_star;
  10301. };
  10302. AST_If.prototype.shallow_cmp = function(other) {
  10303. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  10304. };
  10305. AST_Switch.prototype.shallow_cmp = pass_through;
  10306. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  10307. AST_Try.prototype.shallow_cmp = function(other) {
  10308. 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);
  10309. };
  10310. AST_Catch.prototype.shallow_cmp = function(other) {
  10311. return this.argname == null ? other.argname == null : this.argname === other.argname;
  10312. };
  10313. AST_Finally.prototype.shallow_cmp = pass_through;
  10314. AST_Definitions.prototype.shallow_cmp = pass_through;
  10315. AST_VarDef.prototype.shallow_cmp = function(other) {
  10316. return this.value == null ? other.value == null : this.value === other.value;
  10317. };
  10318. AST_NameMapping.prototype.shallow_cmp = pass_through;
  10319. AST_Import.prototype.shallow_cmp = function(other) {
  10320. 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);
  10321. };
  10322. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  10323. AST_Export.prototype.shallow_cmp = function(other) {
  10324. 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;
  10325. };
  10326. AST_Call.prototype.shallow_cmp = pass_through;
  10327. AST_Sequence.prototype.shallow_cmp = pass_through;
  10328. AST_PropAccess.prototype.shallow_cmp = pass_through;
  10329. AST_Chain.prototype.shallow_cmp = pass_through;
  10330. AST_Dot.prototype.shallow_cmp = function(other) {
  10331. return this.property === other.property;
  10332. };
  10333. AST_DotHash.prototype.shallow_cmp = function(other) {
  10334. return this.property === other.property;
  10335. };
  10336. AST_Unary.prototype.shallow_cmp = function(other) {
  10337. return this.operator === other.operator;
  10338. };
  10339. AST_Binary.prototype.shallow_cmp = function(other) {
  10340. return this.operator === other.operator;
  10341. };
  10342. AST_Conditional.prototype.shallow_cmp = pass_through;
  10343. AST_Array.prototype.shallow_cmp = pass_through;
  10344. AST_Object.prototype.shallow_cmp = pass_through;
  10345. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  10346. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  10347. return this.key === other.key;
  10348. };
  10349. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  10350. return this.static === other.static;
  10351. };
  10352. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  10353. return this.static === other.static;
  10354. };
  10355. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  10356. return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
  10357. };
  10358. AST_Class.prototype.shallow_cmp = function(other) {
  10359. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  10360. };
  10361. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  10362. return this.static === other.static;
  10363. };
  10364. AST_Symbol.prototype.shallow_cmp = function(other) {
  10365. return this.name === other.name;
  10366. };
  10367. AST_NewTarget.prototype.shallow_cmp = pass_through;
  10368. AST_This.prototype.shallow_cmp = pass_through;
  10369. AST_Super.prototype.shallow_cmp = pass_through;
  10370. AST_String.prototype.shallow_cmp = function(other) {
  10371. return this.value === other.value;
  10372. };
  10373. AST_Number.prototype.shallow_cmp = function(other) {
  10374. return this.value === other.value;
  10375. };
  10376. AST_BigInt.prototype.shallow_cmp = function(other) {
  10377. return this.value === other.value;
  10378. };
  10379. AST_RegExp.prototype.shallow_cmp = function (other) {
  10380. return (
  10381. this.value.flags === other.value.flags
  10382. && this.value.source === other.value.source
  10383. );
  10384. };
  10385. AST_Atom.prototype.shallow_cmp = pass_through;
  10386. /***********************************************************************
  10387. A JavaScript tokenizer / parser / beautifier / compressor.
  10388. https://github.com/mishoo/UglifyJS2
  10389. -------------------------------- (C) ---------------------------------
  10390. Author: Mihai Bazon
  10391. <mihai.bazon@gmail.com>
  10392. http://mihai.bazon.net/blog
  10393. Distributed under the BSD license:
  10394. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10395. Redistribution and use in source and binary forms, with or without
  10396. modification, are permitted provided that the following conditions
  10397. are met:
  10398. * Redistributions of source code must retain the above
  10399. copyright notice, this list of conditions and the following
  10400. disclaimer.
  10401. * Redistributions in binary form must reproduce the above
  10402. copyright notice, this list of conditions and the following
  10403. disclaimer in the documentation and/or other materials
  10404. provided with the distribution.
  10405. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10406. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10407. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10408. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10409. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10410. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10411. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10412. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10413. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10414. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10415. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10416. SUCH DAMAGE.
  10417. ***********************************************************************/
  10418. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  10419. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  10420. let function_defs = null;
  10421. let unmangleable_names = null;
  10422. /**
  10423. * When defined, there is a function declaration somewhere that's inside of a block.
  10424. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  10425. */
  10426. let scopes_with_block_defuns = null;
  10427. class SymbolDef {
  10428. constructor(scope, orig, init) {
  10429. this.name = orig.name;
  10430. this.orig = [ orig ];
  10431. this.init = init;
  10432. this.eliminated = 0;
  10433. this.assignments = 0;
  10434. this.scope = scope;
  10435. this.replaced = 0;
  10436. this.global = false;
  10437. this.export = 0;
  10438. this.mangled_name = null;
  10439. this.undeclared = false;
  10440. this.id = SymbolDef.next_id++;
  10441. this.chained = false;
  10442. this.direct_access = false;
  10443. this.escaped = 0;
  10444. this.recursive_refs = 0;
  10445. this.references = [];
  10446. this.should_replace = undefined;
  10447. this.single_use = false;
  10448. this.fixed = false;
  10449. Object.seal(this);
  10450. }
  10451. fixed_value() {
  10452. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  10453. return this.fixed();
  10454. }
  10455. unmangleable(options) {
  10456. if (!options) options = {};
  10457. if (
  10458. function_defs &&
  10459. function_defs.has(this.id) &&
  10460. keep_name(options.keep_fnames, this.orig[0].name)
  10461. ) return true;
  10462. return this.global && !options.toplevel
  10463. || (this.export & MASK_EXPORT_DONT_MANGLE)
  10464. || this.undeclared
  10465. || !options.eval && this.scope.pinned()
  10466. || (this.orig[0] instanceof AST_SymbolLambda
  10467. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  10468. || this.orig[0] instanceof AST_SymbolMethod
  10469. || (this.orig[0] instanceof AST_SymbolClass
  10470. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  10471. }
  10472. mangle(options) {
  10473. const cache = options.cache && options.cache.props;
  10474. if (this.global && cache && cache.has(this.name)) {
  10475. this.mangled_name = cache.get(this.name);
  10476. } else if (!this.mangled_name && !this.unmangleable(options)) {
  10477. var s = this.scope;
  10478. var sym = this.orig[0];
  10479. if (options.ie8 && sym instanceof AST_SymbolLambda)
  10480. s = s.parent_scope;
  10481. const redefinition = redefined_catch_def(this);
  10482. this.mangled_name = redefinition
  10483. ? redefinition.mangled_name || redefinition.name
  10484. : s.next_mangled(options, this);
  10485. if (this.global && cache) {
  10486. cache.set(this.name, this.mangled_name);
  10487. }
  10488. }
  10489. }
  10490. }
  10491. SymbolDef.next_id = 1;
  10492. function redefined_catch_def(def) {
  10493. if (def.orig[0] instanceof AST_SymbolCatch
  10494. && def.scope.is_block_scope()
  10495. ) {
  10496. return def.scope.get_defun_scope().variables.get(def.name);
  10497. }
  10498. }
  10499. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  10500. options = defaults(options, {
  10501. cache: null,
  10502. ie8: false,
  10503. safari10: false,
  10504. module: false,
  10505. });
  10506. if (!(toplevel instanceof AST_Toplevel)) {
  10507. throw new Error("Invalid toplevel scope");
  10508. }
  10509. // pass 1: setup scope chaining and handle definitions
  10510. var scope = this.parent_scope = parent_scope;
  10511. var labels = new Map();
  10512. var defun = null;
  10513. var in_destructuring = null;
  10514. var for_scopes = [];
  10515. var tw = new TreeWalker((node, descend) => {
  10516. if (node.is_block_scope()) {
  10517. const save_scope = scope;
  10518. node.block_scope = scope = new AST_Scope(node);
  10519. scope._block_scope = true;
  10520. scope.init_scope_vars(save_scope);
  10521. scope.uses_with = save_scope.uses_with;
  10522. scope.uses_eval = save_scope.uses_eval;
  10523. if (options.safari10) {
  10524. if (node instanceof AST_For || node instanceof AST_ForIn || node instanceof AST_ForOf) {
  10525. for_scopes.push(scope);
  10526. }
  10527. }
  10528. if (node instanceof AST_Switch) {
  10529. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  10530. // AST_Switch has a scope within the body, but it itself "is a block scope"
  10531. // This means the switched expression has to belong to the outer scope
  10532. // while the body inside belongs to the switch itself.
  10533. // This is pretty nasty and warrants an AST change
  10534. const the_block_scope = scope;
  10535. scope = save_scope;
  10536. node.expression.walk(tw);
  10537. scope = the_block_scope;
  10538. for (let i = 0; i < node.body.length; i++) {
  10539. node.body[i].walk(tw);
  10540. }
  10541. } else {
  10542. descend();
  10543. }
  10544. scope = save_scope;
  10545. return true;
  10546. }
  10547. if (node instanceof AST_Destructuring) {
  10548. const save_destructuring = in_destructuring;
  10549. in_destructuring = node;
  10550. descend();
  10551. in_destructuring = save_destructuring;
  10552. return true;
  10553. }
  10554. if (node instanceof AST_Scope) {
  10555. node.init_scope_vars(scope);
  10556. var save_scope = scope;
  10557. var save_defun = defun;
  10558. var save_labels = labels;
  10559. defun = scope = node;
  10560. labels = new Map();
  10561. descend();
  10562. scope = save_scope;
  10563. defun = save_defun;
  10564. labels = save_labels;
  10565. return true; // don't descend again in TreeWalker
  10566. }
  10567. if (node instanceof AST_LabeledStatement) {
  10568. var l = node.label;
  10569. if (labels.has(l.name)) {
  10570. throw new Error(string_template("Label {name} defined twice", l));
  10571. }
  10572. labels.set(l.name, l);
  10573. descend();
  10574. labels.delete(l.name);
  10575. return true; // no descend again
  10576. }
  10577. if (node instanceof AST_With) {
  10578. for (var s = scope; s; s = s.parent_scope)
  10579. s.uses_with = true;
  10580. return;
  10581. }
  10582. if (node instanceof AST_Symbol) {
  10583. node.scope = scope;
  10584. }
  10585. if (node instanceof AST_Label) {
  10586. node.thedef = node;
  10587. node.references = [];
  10588. }
  10589. if (node instanceof AST_SymbolLambda) {
  10590. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  10591. } else if (node instanceof AST_SymbolDefun) {
  10592. // Careful here, the scope where this should be defined is
  10593. // the parent scope. The reason is that we enter a new
  10594. // scope when we encounter the AST_Defun node (which is
  10595. // instanceof AST_Scope) but we get to the symbol a bit
  10596. // later.
  10597. const closest_scope = defun.parent_scope;
  10598. // In strict mode, function definitions are block-scoped
  10599. node.scope = tw.directives["use strict"]
  10600. ? closest_scope
  10601. : closest_scope.get_defun_scope();
  10602. mark_export(node.scope.def_function(node, defun), 1);
  10603. } else if (node instanceof AST_SymbolClass) {
  10604. mark_export(defun.def_variable(node, defun), 1);
  10605. } else if (node instanceof AST_SymbolImport) {
  10606. scope.def_variable(node);
  10607. } else if (node instanceof AST_SymbolDefClass) {
  10608. // This deals with the name of the class being available
  10609. // inside the class.
  10610. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  10611. } else if (
  10612. node instanceof AST_SymbolVar
  10613. || node instanceof AST_SymbolLet
  10614. || node instanceof AST_SymbolConst
  10615. || node instanceof AST_SymbolCatch
  10616. ) {
  10617. var def;
  10618. if (node instanceof AST_SymbolBlockDeclaration) {
  10619. def = scope.def_variable(node, null);
  10620. } else {
  10621. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  10622. }
  10623. if (!def.orig.every((sym) => {
  10624. if (sym === node) return true;
  10625. if (node instanceof AST_SymbolBlockDeclaration) {
  10626. return sym instanceof AST_SymbolLambda;
  10627. }
  10628. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  10629. })) {
  10630. js_error(
  10631. `"${node.name}" is redeclared`,
  10632. node.start.file,
  10633. node.start.line,
  10634. node.start.col,
  10635. node.start.pos
  10636. );
  10637. }
  10638. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  10639. if (defun !== scope) {
  10640. node.mark_enclosed();
  10641. var def = scope.find_variable(node);
  10642. if (node.thedef !== def) {
  10643. node.thedef = def;
  10644. node.reference();
  10645. }
  10646. }
  10647. } else if (node instanceof AST_LabelRef) {
  10648. var sym = labels.get(node.name);
  10649. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  10650. name: node.name,
  10651. line: node.start.line,
  10652. col: node.start.col
  10653. }));
  10654. node.thedef = sym;
  10655. }
  10656. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  10657. js_error(
  10658. `"${node.TYPE}" statement may only appear at the top level`,
  10659. node.start.file,
  10660. node.start.line,
  10661. node.start.col,
  10662. node.start.pos
  10663. );
  10664. }
  10665. });
  10666. if (options.module) {
  10667. tw.directives["use strict"] = true;
  10668. }
  10669. this.walk(tw);
  10670. function mark_export(def, level) {
  10671. if (in_destructuring) {
  10672. var i = 0;
  10673. do {
  10674. level++;
  10675. } while (tw.parent(i++) !== in_destructuring);
  10676. }
  10677. var node = tw.parent(level);
  10678. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  10679. var exported = node.exported_definition;
  10680. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  10681. def.export = MASK_EXPORT_WANT_MANGLE;
  10682. }
  10683. }
  10684. }
  10685. // pass 2: find back references and eval
  10686. const is_toplevel = this instanceof AST_Toplevel;
  10687. if (is_toplevel) {
  10688. this.globals = new Map();
  10689. }
  10690. var tw = new TreeWalker(node => {
  10691. if (node instanceof AST_LoopControl && node.label) {
  10692. node.label.thedef.references.push(node);
  10693. return true;
  10694. }
  10695. if (node instanceof AST_SymbolRef) {
  10696. var name = node.name;
  10697. if (name == "eval" && tw.parent() instanceof AST_Call) {
  10698. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  10699. s.uses_eval = true;
  10700. }
  10701. }
  10702. var sym;
  10703. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  10704. || !(sym = node.scope.find_variable(name))) {
  10705. sym = toplevel.def_global(node);
  10706. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  10707. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  10708. sym.scope.get_defun_scope().uses_arguments = true;
  10709. }
  10710. node.thedef = sym;
  10711. node.reference();
  10712. if (node.scope.is_block_scope()
  10713. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  10714. node.scope = node.scope.get_defun_scope();
  10715. }
  10716. return true;
  10717. }
  10718. // ensure mangling works if catch reuses a scope variable
  10719. var def;
  10720. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  10721. var s = node.scope;
  10722. while (s) {
  10723. push_uniq(s.enclosed, def);
  10724. if (s === def.scope) break;
  10725. s = s.parent_scope;
  10726. }
  10727. }
  10728. });
  10729. this.walk(tw);
  10730. // pass 3: work around IE8 and Safari catch scope bugs
  10731. if (options.ie8 || options.safari10) {
  10732. walk(this, node => {
  10733. if (node instanceof AST_SymbolCatch) {
  10734. var name = node.name;
  10735. var refs = node.thedef.references;
  10736. var scope = node.scope.get_defun_scope();
  10737. var def = scope.find_variable(name)
  10738. || toplevel.globals.get(name)
  10739. || scope.def_variable(node);
  10740. refs.forEach(function(ref) {
  10741. ref.thedef = def;
  10742. ref.reference();
  10743. });
  10744. node.thedef = def;
  10745. node.reference();
  10746. return true;
  10747. }
  10748. });
  10749. }
  10750. // pass 4: add symbol definitions to loop scopes
  10751. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  10752. // https://github.com/mishoo/UglifyJS2/issues/1753
  10753. // https://bugs.webkit.org/show_bug.cgi?id=171041
  10754. if (options.safari10) {
  10755. for (const scope of for_scopes) {
  10756. scope.parent_scope.variables.forEach(function(def) {
  10757. push_uniq(scope.enclosed, def);
  10758. });
  10759. }
  10760. }
  10761. });
  10762. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  10763. var globals = this.globals, name = node.name;
  10764. if (globals.has(name)) {
  10765. return globals.get(name);
  10766. } else {
  10767. var g = new SymbolDef(this, node);
  10768. g.undeclared = true;
  10769. g.global = true;
  10770. globals.set(name, g);
  10771. return g;
  10772. }
  10773. });
  10774. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  10775. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  10776. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  10777. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  10778. this.parent_scope = parent_scope; // the parent scope
  10779. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  10780. this.cname = -1; // the current index for mangling functions/variables
  10781. });
  10782. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  10783. return (
  10784. this.enclosed.find(def => def.name === name)
  10785. || this.variables.has(name)
  10786. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  10787. );
  10788. });
  10789. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  10790. return (
  10791. this.enclosed.find(def => def.name === name)
  10792. || this.variables.has(name)
  10793. );
  10794. });
  10795. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  10796. // `scope` is going to be moved into `this` right now.
  10797. // Update the required scopes' information
  10798. if (scope.parent_scope === this) return;
  10799. scope.parent_scope = this;
  10800. // Propagate to this.uses_arguments from arrow functions
  10801. if ((scope instanceof AST_Arrow) && !this.uses_arguments) {
  10802. this.uses_arguments = walk(scope, node => {
  10803. if (
  10804. node instanceof AST_SymbolRef
  10805. && node.scope instanceof AST_Lambda
  10806. && node.name === "arguments"
  10807. ) {
  10808. return walk_abort;
  10809. }
  10810. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  10811. return true;
  10812. }
  10813. });
  10814. }
  10815. this.uses_with = this.uses_with || scope.uses_with;
  10816. this.uses_eval = this.uses_eval || scope.uses_eval;
  10817. const scope_ancestry = (() => {
  10818. const ancestry = [];
  10819. let cur = this;
  10820. do {
  10821. ancestry.push(cur);
  10822. } while ((cur = cur.parent_scope));
  10823. ancestry.reverse();
  10824. return ancestry;
  10825. })();
  10826. const new_scope_enclosed_set = new Set(scope.enclosed);
  10827. const to_enclose = [];
  10828. for (const scope_topdown of scope_ancestry) {
  10829. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  10830. for (const def of scope_topdown.variables.values()) {
  10831. if (new_scope_enclosed_set.has(def)) {
  10832. push_uniq(to_enclose, def);
  10833. push_uniq(scope_topdown.enclosed, def);
  10834. }
  10835. }
  10836. }
  10837. });
  10838. function find_scopes_visible_from(scopes) {
  10839. const found_scopes = new Set();
  10840. for (const scope of new Set(scopes)) {
  10841. (function bubble_up(scope) {
  10842. if (scope == null || found_scopes.has(scope)) return;
  10843. found_scopes.add(scope);
  10844. bubble_up(scope.parent_scope);
  10845. })(scope);
  10846. }
  10847. return [...found_scopes];
  10848. }
  10849. // Creates a symbol during compression
  10850. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  10851. source,
  10852. tentative_name,
  10853. scope,
  10854. conflict_scopes = [scope],
  10855. init = null
  10856. } = {}) {
  10857. let symbol_name;
  10858. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  10859. if (tentative_name) {
  10860. // Implement hygiene (no new names are conflicting with existing names)
  10861. tentative_name =
  10862. symbol_name =
  10863. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  10864. let i = 0;
  10865. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  10866. symbol_name = tentative_name + "$" + i++;
  10867. }
  10868. }
  10869. if (!symbol_name) {
  10870. throw new Error("No symbol name could be generated in create_symbol()");
  10871. }
  10872. const symbol = make_node(SymClass, source, {
  10873. name: symbol_name,
  10874. scope
  10875. });
  10876. this.def_variable(symbol, init || null);
  10877. symbol.mark_enclosed();
  10878. return symbol;
  10879. });
  10880. AST_Node.DEFMETHOD("is_block_scope", return_false);
  10881. AST_Class.DEFMETHOD("is_block_scope", return_false);
  10882. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  10883. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  10884. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  10885. AST_Block.DEFMETHOD("is_block_scope", return_true);
  10886. AST_Scope.DEFMETHOD("is_block_scope", function () {
  10887. return this._block_scope || false;
  10888. });
  10889. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  10890. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  10891. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10892. this.uses_arguments = false;
  10893. this.def_variable(new AST_SymbolFunarg({
  10894. name: "arguments",
  10895. start: this.start,
  10896. end: this.end
  10897. }));
  10898. });
  10899. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  10900. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10901. this.uses_arguments = false;
  10902. });
  10903. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  10904. var def = this.definition();
  10905. var s = this.scope;
  10906. while (s) {
  10907. push_uniq(s.enclosed, def);
  10908. if (s === def.scope) break;
  10909. s = s.parent_scope;
  10910. }
  10911. });
  10912. AST_Symbol.DEFMETHOD("reference", function() {
  10913. this.definition().references.push(this);
  10914. this.mark_enclosed();
  10915. });
  10916. AST_Scope.DEFMETHOD("find_variable", function(name) {
  10917. if (name instanceof AST_Symbol) name = name.name;
  10918. return this.variables.get(name)
  10919. || (this.parent_scope && this.parent_scope.find_variable(name));
  10920. });
  10921. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  10922. var def = this.def_variable(symbol, init);
  10923. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  10924. return def;
  10925. });
  10926. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  10927. var def = this.variables.get(symbol.name);
  10928. if (def) {
  10929. def.orig.push(symbol);
  10930. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  10931. def.init = init;
  10932. }
  10933. } else {
  10934. def = new SymbolDef(this, symbol, init);
  10935. this.variables.set(symbol.name, def);
  10936. def.global = !this.parent_scope;
  10937. }
  10938. return symbol.thedef = def;
  10939. });
  10940. function next_mangled(scope, options) {
  10941. let defun_scope;
  10942. if (
  10943. scopes_with_block_defuns
  10944. && (defun_scope = scope.get_defun_scope())
  10945. && scopes_with_block_defuns.has(defun_scope)
  10946. ) {
  10947. scope = defun_scope;
  10948. }
  10949. var ext = scope.enclosed;
  10950. var nth_identifier = options.nth_identifier;
  10951. out: while (true) {
  10952. var m = nth_identifier.get(++scope.cname);
  10953. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  10954. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  10955. // shadow a name reserved from mangling.
  10956. if (options.reserved.has(m)) continue;
  10957. // Functions with short names might collide with base54 output
  10958. // and therefore cause collisions when keep_fnames is true.
  10959. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  10960. // we must ensure that the mangled name does not shadow a name
  10961. // from some parent scope that is referenced in this or in
  10962. // inner scopes.
  10963. for (let i = ext.length; --i >= 0;) {
  10964. const def = ext[i];
  10965. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  10966. if (m == name) continue out;
  10967. }
  10968. return m;
  10969. }
  10970. }
  10971. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  10972. return next_mangled(this, options);
  10973. });
  10974. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  10975. let name;
  10976. const mangled_names = this.mangled_names;
  10977. do {
  10978. name = next_mangled(this, options);
  10979. } while (mangled_names.has(name));
  10980. return name;
  10981. });
  10982. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  10983. // #179, #326
  10984. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  10985. // a function expression's argument cannot shadow the function expression's name
  10986. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  10987. // the function's mangled_name is null when keep_fnames is true
  10988. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  10989. while (true) {
  10990. var name = next_mangled(this, options);
  10991. if (!tricky_name || tricky_name != name)
  10992. return name;
  10993. }
  10994. });
  10995. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  10996. var def = this.definition();
  10997. return !def || def.unmangleable(options);
  10998. });
  10999. // labels are always mangleable
  11000. AST_Label.DEFMETHOD("unmangleable", return_false);
  11001. AST_Symbol.DEFMETHOD("unreferenced", function() {
  11002. return !this.definition().references.length && !this.scope.pinned();
  11003. });
  11004. AST_Symbol.DEFMETHOD("definition", function() {
  11005. return this.thedef;
  11006. });
  11007. AST_Symbol.DEFMETHOD("global", function() {
  11008. return this.thedef.global;
  11009. });
  11010. /**
  11011. * Format the mangler options (if any) into their appropriate types
  11012. */
  11013. function format_mangler_options(options) {
  11014. options = defaults(options, {
  11015. eval : false,
  11016. nth_identifier : base54,
  11017. ie8 : false,
  11018. keep_classnames: false,
  11019. keep_fnames : false,
  11020. module : false,
  11021. reserved : [],
  11022. toplevel : false,
  11023. });
  11024. if (options.module) options.toplevel = true;
  11025. if (!Array.isArray(options.reserved)
  11026. && !(options.reserved instanceof Set)
  11027. ) {
  11028. options.reserved = [];
  11029. }
  11030. options.reserved = new Set(options.reserved);
  11031. // Never mangle arguments
  11032. options.reserved.add("arguments");
  11033. return options;
  11034. }
  11035. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  11036. options = format_mangler_options(options);
  11037. var nth_identifier = options.nth_identifier;
  11038. // We only need to mangle declaration nodes. Special logic wired
  11039. // into the code generator will display the mangled name if it's
  11040. // present (and for AST_SymbolRef-s it'll use the mangled name of
  11041. // the AST_SymbolDeclaration that it points to).
  11042. var lname = -1;
  11043. var to_mangle = [];
  11044. if (options.keep_fnames) {
  11045. function_defs = new Set();
  11046. }
  11047. const mangled_names = this.mangled_names = new Set();
  11048. unmangleable_names = new Set();
  11049. if (options.cache) {
  11050. this.globals.forEach(collect);
  11051. if (options.cache.props) {
  11052. options.cache.props.forEach(function(mangled_name) {
  11053. mangled_names.add(mangled_name);
  11054. });
  11055. }
  11056. }
  11057. var tw = new TreeWalker(function(node, descend) {
  11058. if (node instanceof AST_LabeledStatement) {
  11059. // lname is incremented when we get to the AST_Label
  11060. var save_nesting = lname;
  11061. descend();
  11062. lname = save_nesting;
  11063. return true; // don't descend again in TreeWalker
  11064. }
  11065. if (
  11066. node instanceof AST_Defun
  11067. && !(tw.parent() instanceof AST_Scope)
  11068. ) {
  11069. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  11070. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  11071. }
  11072. if (node instanceof AST_Scope) {
  11073. node.variables.forEach(collect);
  11074. return;
  11075. }
  11076. if (node.is_block_scope()) {
  11077. node.block_scope.variables.forEach(collect);
  11078. return;
  11079. }
  11080. if (
  11081. function_defs
  11082. && node instanceof AST_VarDef
  11083. && node.value instanceof AST_Lambda
  11084. && !node.value.name
  11085. && keep_name(options.keep_fnames, node.name.name)
  11086. ) {
  11087. function_defs.add(node.name.definition().id);
  11088. return;
  11089. }
  11090. if (node instanceof AST_Label) {
  11091. let name;
  11092. do {
  11093. name = nth_identifier.get(++lname);
  11094. } while (ALL_RESERVED_WORDS.has(name));
  11095. node.mangled_name = name;
  11096. return true;
  11097. }
  11098. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  11099. to_mangle.push(node.definition());
  11100. return;
  11101. }
  11102. });
  11103. this.walk(tw);
  11104. if (options.keep_fnames || options.keep_classnames) {
  11105. // Collect a set of short names which are unmangleable,
  11106. // for use in avoiding collisions in next_mangled.
  11107. to_mangle.forEach(def => {
  11108. if (def.name.length < 6 && def.unmangleable(options)) {
  11109. unmangleable_names.add(def.name);
  11110. }
  11111. });
  11112. }
  11113. to_mangle.forEach(def => { def.mangle(options); });
  11114. function_defs = null;
  11115. unmangleable_names = null;
  11116. scopes_with_block_defuns = null;
  11117. function collect(symbol) {
  11118. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  11119. unmangleable_names.add(symbol.name);
  11120. } else if (!options.reserved.has(symbol.name)) {
  11121. to_mangle.push(symbol);
  11122. }
  11123. }
  11124. });
  11125. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  11126. const cache = options.cache && options.cache.props;
  11127. const avoid = new Set();
  11128. options.reserved.forEach(to_avoid);
  11129. this.globals.forEach(add_def);
  11130. this.walk(new TreeWalker(function(node) {
  11131. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  11132. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  11133. }));
  11134. return avoid;
  11135. function to_avoid(name) {
  11136. avoid.add(name);
  11137. }
  11138. function add_def(def) {
  11139. var name = def.name;
  11140. if (def.global && cache && cache.has(name)) name = cache.get(name);
  11141. else if (!def.unmangleable(options)) return;
  11142. to_avoid(name);
  11143. }
  11144. });
  11145. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  11146. options = format_mangler_options(options);
  11147. var nth_identifier = options.nth_identifier;
  11148. if (nth_identifier.reset && nth_identifier.sort) {
  11149. nth_identifier.reset();
  11150. nth_identifier.sort();
  11151. }
  11152. var avoid = this.find_colliding_names(options);
  11153. var cname = 0;
  11154. this.globals.forEach(rename);
  11155. this.walk(new TreeWalker(function(node) {
  11156. if (node instanceof AST_Scope) node.variables.forEach(rename);
  11157. if (node instanceof AST_SymbolCatch) rename(node.definition());
  11158. }));
  11159. function next_name() {
  11160. var name;
  11161. do {
  11162. name = nth_identifier.get(cname++);
  11163. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  11164. return name;
  11165. }
  11166. function rename(def) {
  11167. if (def.global && options.cache) return;
  11168. if (def.unmangleable(options)) return;
  11169. if (options.reserved.has(def.name)) return;
  11170. const redefinition = redefined_catch_def(def);
  11171. const name = def.name = redefinition ? redefinition.name : next_name();
  11172. def.orig.forEach(function(sym) {
  11173. sym.name = name;
  11174. });
  11175. def.references.forEach(function(sym) {
  11176. sym.name = name;
  11177. });
  11178. }
  11179. });
  11180. AST_Node.DEFMETHOD("tail_node", return_this);
  11181. AST_Sequence.DEFMETHOD("tail_node", function() {
  11182. return this.expressions[this.expressions.length - 1];
  11183. });
  11184. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  11185. options = format_mangler_options(options);
  11186. var nth_identifier = options.nth_identifier;
  11187. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  11188. // If the identifier mangler is invariant, skip computing character frequency.
  11189. return;
  11190. }
  11191. nth_identifier.reset();
  11192. try {
  11193. AST_Node.prototype.print = function(stream, force_parens) {
  11194. this._print(stream, force_parens);
  11195. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  11196. nth_identifier.consider(this.name, -1);
  11197. } else if (options.properties) {
  11198. if (this instanceof AST_DotHash) {
  11199. nth_identifier.consider("#" + this.property, -1);
  11200. } else if (this instanceof AST_Dot) {
  11201. nth_identifier.consider(this.property, -1);
  11202. } else if (this instanceof AST_Sub) {
  11203. skip_string(this.property);
  11204. }
  11205. }
  11206. };
  11207. nth_identifier.consider(this.print_to_string(), 1);
  11208. } finally {
  11209. AST_Node.prototype.print = AST_Node.prototype._print;
  11210. }
  11211. nth_identifier.sort();
  11212. function skip_string(node) {
  11213. if (node instanceof AST_String) {
  11214. nth_identifier.consider(node.value, -1);
  11215. } else if (node instanceof AST_Conditional) {
  11216. skip_string(node.consequent);
  11217. skip_string(node.alternative);
  11218. } else if (node instanceof AST_Sequence) {
  11219. skip_string(node.tail_node());
  11220. }
  11221. }
  11222. });
  11223. const base54 = (() => {
  11224. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  11225. const digits = "0123456789".split("");
  11226. let chars;
  11227. let frequency;
  11228. function reset() {
  11229. frequency = new Map();
  11230. leading.forEach(function(ch) {
  11231. frequency.set(ch, 0);
  11232. });
  11233. digits.forEach(function(ch) {
  11234. frequency.set(ch, 0);
  11235. });
  11236. }
  11237. function consider(str, delta) {
  11238. for (var i = str.length; --i >= 0;) {
  11239. frequency.set(str[i], frequency.get(str[i]) + delta);
  11240. }
  11241. }
  11242. function compare(a, b) {
  11243. return frequency.get(b) - frequency.get(a);
  11244. }
  11245. function sort() {
  11246. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  11247. }
  11248. // Ensure this is in a usable initial state.
  11249. reset();
  11250. sort();
  11251. function base54(num) {
  11252. var ret = "", base = 54;
  11253. num++;
  11254. do {
  11255. num--;
  11256. ret += chars[num % base];
  11257. num = Math.floor(num / base);
  11258. base = 64;
  11259. } while (num > 0);
  11260. return ret;
  11261. }
  11262. return {
  11263. get: base54,
  11264. consider,
  11265. reset,
  11266. sort
  11267. };
  11268. })();
  11269. let mangle_options = undefined;
  11270. AST_Node.prototype.size = function (compressor, stack) {
  11271. mangle_options = compressor && compressor._mangle_options;
  11272. let size = 0;
  11273. walk_parent(this, (node, info) => {
  11274. size += node._size(info);
  11275. // Braceless arrow functions have fake "return" statements
  11276. if (node instanceof AST_Arrow && node.is_braceless()) {
  11277. size += node.body[0].value._size(info);
  11278. return true;
  11279. }
  11280. }, stack || (compressor && compressor.stack));
  11281. // just to save a bit of memory
  11282. mangle_options = undefined;
  11283. return size;
  11284. };
  11285. AST_Node.prototype._size = () => 0;
  11286. AST_Debugger.prototype._size = () => 8;
  11287. AST_Directive.prototype._size = function () {
  11288. // TODO string encoding stuff
  11289. return 2 + this.value.length;
  11290. };
  11291. /** Count commas/semicolons necessary to show a list of expressions/statements */
  11292. const list_overhead = (array) => array.length && array.length - 1;
  11293. AST_Block.prototype._size = function () {
  11294. return 2 + list_overhead(this.body);
  11295. };
  11296. AST_Toplevel.prototype._size = function() {
  11297. return list_overhead(this.body);
  11298. };
  11299. AST_EmptyStatement.prototype._size = () => 1;
  11300. AST_LabeledStatement.prototype._size = () => 2; // x:
  11301. AST_Do.prototype._size = () => 9;
  11302. AST_While.prototype._size = () => 7;
  11303. AST_For.prototype._size = () => 8;
  11304. AST_ForIn.prototype._size = () => 8;
  11305. // AST_ForOf inherits ^
  11306. AST_With.prototype._size = () => 6;
  11307. AST_Expansion.prototype._size = () => 3;
  11308. const lambda_modifiers = func =>
  11309. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  11310. AST_Accessor.prototype._size = function () {
  11311. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  11312. };
  11313. AST_Function.prototype._size = function (info) {
  11314. const first = !!first_in_statement(info);
  11315. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  11316. };
  11317. AST_Defun.prototype._size = function () {
  11318. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  11319. };
  11320. AST_Arrow.prototype._size = function () {
  11321. let args_and_arrow = 2 + list_overhead(this.argnames);
  11322. if (
  11323. !(
  11324. this.argnames.length === 1
  11325. && this.argnames[0] instanceof AST_Symbol
  11326. )
  11327. ) {
  11328. args_and_arrow += 2; // parens around the args
  11329. }
  11330. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  11331. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  11332. };
  11333. AST_Destructuring.prototype._size = () => 2;
  11334. AST_TemplateString.prototype._size = function () {
  11335. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  11336. };
  11337. AST_TemplateSegment.prototype._size = function () {
  11338. return this.value.length;
  11339. };
  11340. AST_Return.prototype._size = function () {
  11341. return this.value ? 7 : 6;
  11342. };
  11343. AST_Throw.prototype._size = () => 6;
  11344. AST_Break.prototype._size = function () {
  11345. return this.label ? 6 : 5;
  11346. };
  11347. AST_Continue.prototype._size = function () {
  11348. return this.label ? 9 : 8;
  11349. };
  11350. AST_If.prototype._size = () => 4;
  11351. AST_Switch.prototype._size = function () {
  11352. return 8 + list_overhead(this.body);
  11353. };
  11354. AST_Case.prototype._size = function () {
  11355. return 5 + list_overhead(this.body);
  11356. };
  11357. AST_Default.prototype._size = function () {
  11358. return 8 + list_overhead(this.body);
  11359. };
  11360. AST_Try.prototype._size = () => 3;
  11361. AST_Catch.prototype._size = function () {
  11362. let size = 7 + list_overhead(this.body);
  11363. if (this.argname) {
  11364. size += 2;
  11365. }
  11366. return size;
  11367. };
  11368. AST_Finally.prototype._size = function () {
  11369. return 7 + list_overhead(this.body);
  11370. };
  11371. AST_Var.prototype._size = function () {
  11372. return 4 + list_overhead(this.definitions);
  11373. };
  11374. AST_Let.prototype._size = function () {
  11375. return 4 + list_overhead(this.definitions);
  11376. };
  11377. AST_Const.prototype._size = function () {
  11378. return 6 + list_overhead(this.definitions);
  11379. };
  11380. AST_VarDef.prototype._size = function () {
  11381. return this.value ? 1 : 0;
  11382. };
  11383. AST_NameMapping.prototype._size = function () {
  11384. // foreign name isn't mangled
  11385. return this.name ? 4 : 0;
  11386. };
  11387. AST_Import.prototype._size = function () {
  11388. // import
  11389. let size = 6;
  11390. if (this.imported_name) size += 1;
  11391. // from
  11392. if (this.imported_name || this.imported_names) size += 5;
  11393. // braces, and the commas
  11394. if (this.imported_names) {
  11395. size += 2 + list_overhead(this.imported_names);
  11396. }
  11397. return size;
  11398. };
  11399. AST_ImportMeta.prototype._size = () => 11;
  11400. AST_Export.prototype._size = function () {
  11401. let size = 7 + (this.is_default ? 8 : 0);
  11402. if (this.exported_value) {
  11403. size += this.exported_value._size();
  11404. }
  11405. if (this.exported_names) {
  11406. // Braces and commas
  11407. size += 2 + list_overhead(this.exported_names);
  11408. }
  11409. if (this.module_name) {
  11410. // "from "
  11411. size += 5;
  11412. }
  11413. return size;
  11414. };
  11415. AST_Call.prototype._size = function () {
  11416. if (this.optional) {
  11417. return 4 + list_overhead(this.args);
  11418. }
  11419. return 2 + list_overhead(this.args);
  11420. };
  11421. AST_New.prototype._size = function () {
  11422. return 6 + list_overhead(this.args);
  11423. };
  11424. AST_Sequence.prototype._size = function () {
  11425. return list_overhead(this.expressions);
  11426. };
  11427. AST_Dot.prototype._size = function () {
  11428. if (this.optional) {
  11429. return this.property.length + 2;
  11430. }
  11431. return this.property.length + 1;
  11432. };
  11433. AST_DotHash.prototype._size = function () {
  11434. if (this.optional) {
  11435. return this.property.length + 3;
  11436. }
  11437. return this.property.length + 2;
  11438. };
  11439. AST_Sub.prototype._size = function () {
  11440. return this.optional ? 4 : 2;
  11441. };
  11442. AST_Unary.prototype._size = function () {
  11443. if (this.operator === "typeof") return 7;
  11444. if (this.operator === "void") return 5;
  11445. return this.operator.length;
  11446. };
  11447. AST_Binary.prototype._size = function (info) {
  11448. if (this.operator === "in") return 4;
  11449. let size = this.operator.length;
  11450. if (
  11451. (this.operator === "+" || this.operator === "-")
  11452. && this.right instanceof AST_Unary && this.right.operator === this.operator
  11453. ) {
  11454. // 1+ +a > needs space between the +
  11455. size += 1;
  11456. }
  11457. if (this.needs_parens(info)) {
  11458. size += 2;
  11459. }
  11460. return size;
  11461. };
  11462. AST_Conditional.prototype._size = () => 3;
  11463. AST_Array.prototype._size = function () {
  11464. return 2 + list_overhead(this.elements);
  11465. };
  11466. AST_Object.prototype._size = function (info) {
  11467. let base = 2;
  11468. if (first_in_statement(info)) {
  11469. base += 2; // parens
  11470. }
  11471. return base + list_overhead(this.properties);
  11472. };
  11473. /*#__INLINE__*/
  11474. const key_size = key =>
  11475. typeof key === "string" ? key.length : 0;
  11476. AST_ObjectKeyVal.prototype._size = function () {
  11477. return key_size(this.key) + 1;
  11478. };
  11479. /*#__INLINE__*/
  11480. const static_size = is_static => is_static ? 7 : 0;
  11481. AST_ObjectGetter.prototype._size = function () {
  11482. return 5 + static_size(this.static) + key_size(this.key);
  11483. };
  11484. AST_ObjectSetter.prototype._size = function () {
  11485. return 5 + static_size(this.static) + key_size(this.key);
  11486. };
  11487. AST_ConciseMethod.prototype._size = function () {
  11488. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  11489. };
  11490. AST_PrivateMethod.prototype._size = function () {
  11491. return AST_ConciseMethod.prototype._size.call(this) + 1;
  11492. };
  11493. AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
  11494. return AST_ConciseMethod.prototype._size.call(this) + 4;
  11495. };
  11496. AST_PrivateIn.prototype._size = function () {
  11497. return 5; // "#", and " in "
  11498. };
  11499. AST_Class.prototype._size = function () {
  11500. return (
  11501. (this.name ? 8 : 7)
  11502. + (this.extends ? 8 : 0)
  11503. );
  11504. };
  11505. AST_ClassStaticBlock.prototype._size = function () {
  11506. // "static{}" + semicolons
  11507. return 8 + list_overhead(this.body);
  11508. };
  11509. AST_ClassProperty.prototype._size = function () {
  11510. return (
  11511. static_size(this.static)
  11512. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  11513. + (this.value ? 1 : 0)
  11514. );
  11515. };
  11516. AST_ClassPrivateProperty.prototype._size = function () {
  11517. return AST_ClassProperty.prototype._size.call(this) + 1;
  11518. };
  11519. AST_Symbol.prototype._size = function () {
  11520. if (!(mangle_options && this.thedef && !this.thedef.unmangleable(mangle_options))) {
  11521. return this.name.length;
  11522. } else {
  11523. return 1;
  11524. }
  11525. };
  11526. // TODO take propmangle into account
  11527. AST_SymbolClassProperty.prototype._size = function () {
  11528. return this.name.length;
  11529. };
  11530. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  11531. if (this.name === "arguments") return 9;
  11532. return AST_Symbol.prototype._size.call(this);
  11533. };
  11534. AST_NewTarget.prototype._size = () => 10;
  11535. AST_SymbolImportForeign.prototype._size = function () {
  11536. return this.name.length;
  11537. };
  11538. AST_SymbolExportForeign.prototype._size = function () {
  11539. return this.name.length;
  11540. };
  11541. AST_This.prototype._size = () => 4;
  11542. AST_Super.prototype._size = () => 5;
  11543. AST_String.prototype._size = function () {
  11544. return this.value.length + 2;
  11545. };
  11546. AST_Number.prototype._size = function () {
  11547. const { value } = this;
  11548. if (value === 0) return 1;
  11549. if (value > 0 && Math.floor(value) === value) {
  11550. return Math.floor(Math.log10(value) + 1);
  11551. }
  11552. return value.toString().length;
  11553. };
  11554. AST_BigInt.prototype._size = function () {
  11555. return this.value.length;
  11556. };
  11557. AST_RegExp.prototype._size = function () {
  11558. return this.value.toString().length;
  11559. };
  11560. AST_Null.prototype._size = () => 4;
  11561. AST_NaN.prototype._size = () => 3;
  11562. AST_Undefined.prototype._size = () => 6; // "void 0"
  11563. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  11564. AST_Infinity.prototype._size = () => 8;
  11565. AST_True.prototype._size = () => 4;
  11566. AST_False.prototype._size = () => 5;
  11567. AST_Await.prototype._size = () => 6;
  11568. AST_Yield.prototype._size = () => 6;
  11569. /***********************************************************************
  11570. A JavaScript tokenizer / parser / beautifier / compressor.
  11571. https://github.com/mishoo/UglifyJS2
  11572. -------------------------------- (C) ---------------------------------
  11573. Author: Mihai Bazon
  11574. <mihai.bazon@gmail.com>
  11575. http://mihai.bazon.net/blog
  11576. Distributed under the BSD license:
  11577. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11578. Redistribution and use in source and binary forms, with or without
  11579. modification, are permitted provided that the following conditions
  11580. are met:
  11581. * Redistributions of source code must retain the above
  11582. copyright notice, this list of conditions and the following
  11583. disclaimer.
  11584. * Redistributions in binary form must reproduce the above
  11585. copyright notice, this list of conditions and the following
  11586. disclaimer in the documentation and/or other materials
  11587. provided with the distribution.
  11588. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11589. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11590. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11591. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11592. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11593. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11594. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11595. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11596. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11597. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11598. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11599. SUCH DAMAGE.
  11600. ***********************************************************************/
  11601. // bitfield flags to be stored in node.flags.
  11602. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  11603. const UNUSED = 0b00000001;
  11604. const TRUTHY = 0b00000010;
  11605. const FALSY = 0b00000100;
  11606. const UNDEFINED = 0b00001000;
  11607. const INLINED = 0b00010000;
  11608. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  11609. const WRITE_ONLY = 0b00100000;
  11610. // information specific to a single compression pass
  11611. const SQUEEZED = 0b0000000100000000;
  11612. const OPTIMIZED = 0b0000001000000000;
  11613. const TOP = 0b0000010000000000;
  11614. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  11615. const has_flag = (node, flag) => node.flags & flag;
  11616. const set_flag = (node, flag) => { node.flags |= flag; };
  11617. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  11618. /***********************************************************************
  11619. A JavaScript tokenizer / parser / beautifier / compressor.
  11620. https://github.com/mishoo/UglifyJS2
  11621. -------------------------------- (C) ---------------------------------
  11622. Author: Mihai Bazon
  11623. <mihai.bazon@gmail.com>
  11624. http://mihai.bazon.net/blog
  11625. Distributed under the BSD license:
  11626. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11627. Redistribution and use in source and binary forms, with or without
  11628. modification, are permitted provided that the following conditions
  11629. are met:
  11630. * Redistributions of source code must retain the above
  11631. copyright notice, this list of conditions and the following
  11632. disclaimer.
  11633. * Redistributions in binary form must reproduce the above
  11634. copyright notice, this list of conditions and the following
  11635. disclaimer in the documentation and/or other materials
  11636. provided with the distribution.
  11637. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11638. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11639. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11640. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11641. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11642. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11643. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11644. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11645. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11646. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11647. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11648. SUCH DAMAGE.
  11649. ***********************************************************************/
  11650. function merge_sequence(array, node) {
  11651. if (node instanceof AST_Sequence) {
  11652. array.push(...node.expressions);
  11653. } else {
  11654. array.push(node);
  11655. }
  11656. return array;
  11657. }
  11658. function make_sequence(orig, expressions) {
  11659. if (expressions.length == 1) return expressions[0];
  11660. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  11661. return make_node(AST_Sequence, orig, {
  11662. expressions: expressions.reduce(merge_sequence, [])
  11663. });
  11664. }
  11665. function make_node_from_constant(val, orig) {
  11666. switch (typeof val) {
  11667. case "string":
  11668. return make_node(AST_String, orig, {
  11669. value: val
  11670. });
  11671. case "number":
  11672. if (isNaN(val)) return make_node(AST_NaN, orig);
  11673. if (isFinite(val)) {
  11674. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11675. operator: "-",
  11676. expression: make_node(AST_Number, orig, { value: -val })
  11677. }) : make_node(AST_Number, orig, { value: val });
  11678. }
  11679. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11680. operator: "-",
  11681. expression: make_node(AST_Infinity, orig)
  11682. }) : make_node(AST_Infinity, orig);
  11683. case "bigint":
  11684. return make_node(AST_BigInt, orig, { value: val.toString() });
  11685. case "boolean":
  11686. return make_node(val ? AST_True : AST_False, orig);
  11687. case "undefined":
  11688. return make_node(AST_Undefined, orig);
  11689. default:
  11690. if (val === null) {
  11691. return make_node(AST_Null, orig, { value: null });
  11692. }
  11693. if (val instanceof RegExp) {
  11694. return make_node(AST_RegExp, orig, {
  11695. value: {
  11696. source: regexp_source_fix(val.source),
  11697. flags: val.flags
  11698. }
  11699. });
  11700. }
  11701. throw new Error(string_template("Can't handle constant of type: {type}", {
  11702. type: typeof val
  11703. }));
  11704. }
  11705. }
  11706. function best_of_expression(ast1, ast2) {
  11707. return ast1.size() > ast2.size() ? ast2 : ast1;
  11708. }
  11709. function best_of_statement(ast1, ast2) {
  11710. return best_of_expression(
  11711. make_node(AST_SimpleStatement, ast1, {
  11712. body: ast1
  11713. }),
  11714. make_node(AST_SimpleStatement, ast2, {
  11715. body: ast2
  11716. })
  11717. ).body;
  11718. }
  11719. /** Find which node is smaller, and return that */
  11720. function best_of(compressor, ast1, ast2) {
  11721. if (first_in_statement(compressor)) {
  11722. return best_of_statement(ast1, ast2);
  11723. } else {
  11724. return best_of_expression(ast1, ast2);
  11725. }
  11726. }
  11727. /** Simplify an object property's key, if possible */
  11728. function get_simple_key(key) {
  11729. if (key instanceof AST_Constant) {
  11730. return key.getValue();
  11731. }
  11732. if (key instanceof AST_UnaryPrefix
  11733. && key.operator == "void"
  11734. && key.expression instanceof AST_Constant) {
  11735. return;
  11736. }
  11737. return key;
  11738. }
  11739. function read_property(obj, key) {
  11740. key = get_simple_key(key);
  11741. if (key instanceof AST_Node) return;
  11742. var value;
  11743. if (obj instanceof AST_Array) {
  11744. var elements = obj.elements;
  11745. if (key == "length") return make_node_from_constant(elements.length, obj);
  11746. if (typeof key == "number" && key in elements) value = elements[key];
  11747. } else if (obj instanceof AST_Object) {
  11748. key = "" + key;
  11749. var props = obj.properties;
  11750. for (var i = props.length; --i >= 0;) {
  11751. var prop = props[i];
  11752. if (!(prop instanceof AST_ObjectKeyVal)) return;
  11753. if (!value && props[i].key === key) value = props[i].value;
  11754. }
  11755. }
  11756. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  11757. }
  11758. function has_break_or_continue(loop, parent) {
  11759. var found = false;
  11760. var tw = new TreeWalker(function(node) {
  11761. if (found || node instanceof AST_Scope) return true;
  11762. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  11763. return found = true;
  11764. }
  11765. });
  11766. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  11767. tw.push(loop);
  11768. loop.body.walk(tw);
  11769. return found;
  11770. }
  11771. // we shouldn't compress (1,func)(something) to
  11772. // func(something) because that changes the meaning of
  11773. // the func (becomes lexical instead of global).
  11774. function maintain_this_binding(parent, orig, val) {
  11775. if (requires_sequence_to_maintain_binding(parent, orig, val)) {
  11776. const zero = make_node(AST_Number, orig, { value: 0 });
  11777. return make_sequence(orig, [ zero, val ]);
  11778. } else {
  11779. return val;
  11780. }
  11781. }
  11782. /** Detect (1, x.noThis)(), (0, eval)(), which need sequences */
  11783. function requires_sequence_to_maintain_binding(parent, orig, val) {
  11784. return (
  11785. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  11786. || parent instanceof AST_Call && parent.expression === orig
  11787. && (
  11788. val instanceof AST_Chain
  11789. || val instanceof AST_PropAccess
  11790. || val instanceof AST_SymbolRef && val.name == "eval"
  11791. )
  11792. );
  11793. }
  11794. function is_func_expr(node) {
  11795. return node instanceof AST_Arrow || node instanceof AST_Function;
  11796. }
  11797. /**
  11798. * Used to determine whether the node can benefit from negation.
  11799. * Not the case with arrow functions (you need an extra set of parens). */
  11800. function is_iife_call(node) {
  11801. if (node.TYPE != "Call") return false;
  11802. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  11803. }
  11804. function is_empty(thing) {
  11805. if (thing === null) return true;
  11806. if (thing instanceof AST_EmptyStatement) return true;
  11807. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  11808. return false;
  11809. }
  11810. const identifier_atom = makePredicate("Infinity NaN undefined");
  11811. function is_identifier_atom(node) {
  11812. return node instanceof AST_Infinity
  11813. || node instanceof AST_NaN
  11814. || node instanceof AST_Undefined;
  11815. }
  11816. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  11817. function is_ref_of(ref, type) {
  11818. if (!(ref instanceof AST_SymbolRef)) return false;
  11819. var orig = ref.definition().orig;
  11820. for (var i = orig.length; --i >= 0;) {
  11821. if (orig[i] instanceof type) return true;
  11822. }
  11823. }
  11824. /**Can we turn { block contents... } into just the block contents ?
  11825. * Not if one of these is inside.
  11826. **/
  11827. function can_be_evicted_from_block(node) {
  11828. return !(
  11829. node instanceof AST_DefClass ||
  11830. node instanceof AST_Defun ||
  11831. node instanceof AST_Let ||
  11832. node instanceof AST_Const ||
  11833. node instanceof AST_Export ||
  11834. node instanceof AST_Import
  11835. );
  11836. }
  11837. function as_statement_array(thing) {
  11838. if (thing === null) return [];
  11839. if (thing instanceof AST_BlockStatement) return thing.body;
  11840. if (thing instanceof AST_EmptyStatement) return [];
  11841. if (thing instanceof AST_Statement) return [ thing ];
  11842. throw new Error("Can't convert thing to statement array");
  11843. }
  11844. function is_reachable(scope_node, defs) {
  11845. const find_ref = node => {
  11846. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  11847. return walk_abort;
  11848. }
  11849. };
  11850. return walk_parent(scope_node, (node, info) => {
  11851. if (node instanceof AST_Scope && node !== scope_node) {
  11852. var parent = info.parent();
  11853. if (
  11854. parent instanceof AST_Call
  11855. && parent.expression === node
  11856. // Async/Generators aren't guaranteed to sync evaluate all of
  11857. // their body steps, so it's possible they close over the variable.
  11858. && !(node.async || node.is_generator)
  11859. ) {
  11860. return;
  11861. }
  11862. if (walk(node, find_ref)) return walk_abort;
  11863. return true;
  11864. }
  11865. });
  11866. }
  11867. /** Check if a ref refers to the name of a function/class it's defined within */
  11868. function is_recursive_ref(compressor, def) {
  11869. var node;
  11870. for (var i = 0; node = compressor.parent(i); i++) {
  11871. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  11872. var name = node.name;
  11873. if (name && name.definition() === def) {
  11874. return true;
  11875. }
  11876. }
  11877. }
  11878. return false;
  11879. }
  11880. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  11881. function retain_top_func(fn, compressor) {
  11882. return compressor.top_retain
  11883. && fn instanceof AST_Defun
  11884. && has_flag(fn, TOP)
  11885. && fn.name
  11886. && compressor.top_retain(fn.name.definition());
  11887. }
  11888. /***********************************************************************
  11889. A JavaScript tokenizer / parser / beautifier / compressor.
  11890. https://github.com/mishoo/UglifyJS2
  11891. -------------------------------- (C) ---------------------------------
  11892. Author: Mihai Bazon
  11893. <mihai.bazon@gmail.com>
  11894. http://mihai.bazon.net/blog
  11895. Distributed under the BSD license:
  11896. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11897. Redistribution and use in source and binary forms, with or without
  11898. modification, are permitted provided that the following conditions
  11899. are met:
  11900. * Redistributions of source code must retain the above
  11901. copyright notice, this list of conditions and the following
  11902. disclaimer.
  11903. * Redistributions in binary form must reproduce the above
  11904. copyright notice, this list of conditions and the following
  11905. disclaimer in the documentation and/or other materials
  11906. provided with the distribution.
  11907. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11908. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11909. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11910. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11911. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11912. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11913. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11914. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11915. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11916. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11917. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11918. SUCH DAMAGE.
  11919. ***********************************************************************/
  11920. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  11921. // Note: Lots of methods and functions are missing here, in case they aren't pure
  11922. // or not available in all JS environments.
  11923. function make_nested_lookup(obj) {
  11924. const out = new Map();
  11925. for (var key of Object.keys(obj)) {
  11926. out.set(key, makePredicate(obj[key]));
  11927. }
  11928. const does_have = (global_name, fname) => {
  11929. const inner_map = out.get(global_name);
  11930. return inner_map != null && inner_map.has(fname);
  11931. };
  11932. return does_have;
  11933. }
  11934. // Objects which are safe to access without throwing or causing a side effect.
  11935. // Usually we'd check the `unsafe` option first but these are way too common for that
  11936. const pure_prop_access_globals = new Set([
  11937. "Number",
  11938. "String",
  11939. "Array",
  11940. "Object",
  11941. "Function",
  11942. "Promise",
  11943. ]);
  11944. const object_methods = [
  11945. "constructor",
  11946. "toString",
  11947. "valueOf",
  11948. ];
  11949. const is_pure_native_method = make_nested_lookup({
  11950. Array: [
  11951. "at",
  11952. "flat",
  11953. "includes",
  11954. "indexOf",
  11955. "join",
  11956. "lastIndexOf",
  11957. "slice",
  11958. ...object_methods,
  11959. ],
  11960. Boolean: object_methods,
  11961. Function: object_methods,
  11962. Number: [
  11963. "toExponential",
  11964. "toFixed",
  11965. "toPrecision",
  11966. ...object_methods,
  11967. ],
  11968. Object: object_methods,
  11969. RegExp: [
  11970. "test",
  11971. ...object_methods,
  11972. ],
  11973. String: [
  11974. "at",
  11975. "charAt",
  11976. "charCodeAt",
  11977. "charPointAt",
  11978. "concat",
  11979. "endsWith",
  11980. "fromCharCode",
  11981. "fromCodePoint",
  11982. "includes",
  11983. "indexOf",
  11984. "italics",
  11985. "lastIndexOf",
  11986. "localeCompare",
  11987. "match",
  11988. "matchAll",
  11989. "normalize",
  11990. "padStart",
  11991. "padEnd",
  11992. "repeat",
  11993. "replace",
  11994. "replaceAll",
  11995. "search",
  11996. "slice",
  11997. "split",
  11998. "startsWith",
  11999. "substr",
  12000. "substring",
  12001. "repeat",
  12002. "toLocaleLowerCase",
  12003. "toLocaleUpperCase",
  12004. "toLowerCase",
  12005. "toUpperCase",
  12006. "trim",
  12007. "trimEnd",
  12008. "trimStart",
  12009. ...object_methods,
  12010. ],
  12011. });
  12012. const is_pure_native_fn = make_nested_lookup({
  12013. Array: [
  12014. "isArray",
  12015. ],
  12016. Math: [
  12017. "abs",
  12018. "acos",
  12019. "asin",
  12020. "atan",
  12021. "ceil",
  12022. "cos",
  12023. "exp",
  12024. "floor",
  12025. "log",
  12026. "round",
  12027. "sin",
  12028. "sqrt",
  12029. "tan",
  12030. "atan2",
  12031. "pow",
  12032. "max",
  12033. "min",
  12034. ],
  12035. Number: [
  12036. "isFinite",
  12037. "isNaN",
  12038. ],
  12039. Object: [
  12040. "create",
  12041. "getOwnPropertyDescriptor",
  12042. "getOwnPropertyNames",
  12043. "getPrototypeOf",
  12044. "isExtensible",
  12045. "isFrozen",
  12046. "isSealed",
  12047. "hasOwn",
  12048. "keys",
  12049. ],
  12050. String: [
  12051. "fromCharCode",
  12052. ],
  12053. });
  12054. // Known numeric values which come with JS environments
  12055. const is_pure_native_value = make_nested_lookup({
  12056. Math: [
  12057. "E",
  12058. "LN10",
  12059. "LN2",
  12060. "LOG2E",
  12061. "LOG10E",
  12062. "PI",
  12063. "SQRT1_2",
  12064. "SQRT2",
  12065. ],
  12066. Number: [
  12067. "MAX_VALUE",
  12068. "MIN_VALUE",
  12069. "NaN",
  12070. "NEGATIVE_INFINITY",
  12071. "POSITIVE_INFINITY",
  12072. ],
  12073. });
  12074. /***********************************************************************
  12075. A JavaScript tokenizer / parser / beautifier / compressor.
  12076. https://github.com/mishoo/UglifyJS2
  12077. -------------------------------- (C) ---------------------------------
  12078. Author: Mihai Bazon
  12079. <mihai.bazon@gmail.com>
  12080. http://mihai.bazon.net/blog
  12081. Distributed under the BSD license:
  12082. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12083. Redistribution and use in source and binary forms, with or without
  12084. modification, are permitted provided that the following conditions
  12085. are met:
  12086. * Redistributions of source code must retain the above
  12087. copyright notice, this list of conditions and the following
  12088. disclaimer.
  12089. * Redistributions in binary form must reproduce the above
  12090. copyright notice, this list of conditions and the following
  12091. disclaimer in the documentation and/or other materials
  12092. provided with the distribution.
  12093. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12094. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12095. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12096. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12097. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12098. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12099. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12100. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12101. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12102. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12103. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12104. SUCH DAMAGE.
  12105. ***********************************************************************/
  12106. // Functions and methods to infer certain facts about expressions
  12107. // It's not always possible to be 100% sure about something just by static analysis,
  12108. // so `true` means yes, and `false` means maybe
  12109. const is_undeclared_ref = (node) =>
  12110. node instanceof AST_SymbolRef && node.definition().undeclared;
  12111. const bitwise_binop = makePredicate("<<< >> << & | ^ ~");
  12112. const lazy_op = makePredicate("&& || ??");
  12113. const unary_side_effects = makePredicate("delete ++ --");
  12114. // methods to determine whether an expression has a boolean result type
  12115. (function(def_is_boolean) {
  12116. const unary_bool = makePredicate("! delete");
  12117. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  12118. def_is_boolean(AST_Node, return_false);
  12119. def_is_boolean(AST_UnaryPrefix, function() {
  12120. return unary_bool.has(this.operator);
  12121. });
  12122. def_is_boolean(AST_Binary, function() {
  12123. return binary_bool.has(this.operator)
  12124. || lazy_op.has(this.operator)
  12125. && this.left.is_boolean()
  12126. && this.right.is_boolean();
  12127. });
  12128. def_is_boolean(AST_Conditional, function() {
  12129. return this.consequent.is_boolean() && this.alternative.is_boolean();
  12130. });
  12131. def_is_boolean(AST_Assign, function() {
  12132. return this.operator == "=" && this.right.is_boolean();
  12133. });
  12134. def_is_boolean(AST_Sequence, function() {
  12135. return this.tail_node().is_boolean();
  12136. });
  12137. def_is_boolean(AST_True, return_true);
  12138. def_is_boolean(AST_False, return_true);
  12139. })(function(node, func) {
  12140. node.DEFMETHOD("is_boolean", func);
  12141. });
  12142. // methods to determine if an expression has a numeric result type
  12143. (function(def_is_number) {
  12144. def_is_number(AST_Node, return_false);
  12145. def_is_number(AST_Number, return_true);
  12146. const unary = makePredicate("+ - ~ ++ --");
  12147. def_is_number(AST_Unary, function() {
  12148. return unary.has(this.operator) && !(this.expression instanceof AST_BigInt);
  12149. });
  12150. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  12151. def_is_number(AST_Binary, function(compressor) {
  12152. return numeric_ops.has(this.operator) || this.operator == "+"
  12153. && this.left.is_number(compressor)
  12154. && this.right.is_number(compressor);
  12155. });
  12156. def_is_number(AST_Assign, function(compressor) {
  12157. return numeric_ops.has(this.operator.slice(0, -1))
  12158. || this.operator == "=" && this.right.is_number(compressor);
  12159. });
  12160. def_is_number(AST_Sequence, function(compressor) {
  12161. return this.tail_node().is_number(compressor);
  12162. });
  12163. def_is_number(AST_Conditional, function(compressor) {
  12164. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  12165. });
  12166. })(function(node, func) {
  12167. node.DEFMETHOD("is_number", func);
  12168. });
  12169. // 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
  12170. (function(def_is_32_bit_integer) {
  12171. def_is_32_bit_integer(AST_Node, return_false);
  12172. def_is_32_bit_integer(AST_Number, function() {
  12173. return this.value === (this.value | 0);
  12174. });
  12175. def_is_32_bit_integer(AST_UnaryPrefix, function() {
  12176. return this.operator == "~" ? this.expression.is_number()
  12177. : this.operator === "+" ? this.expression.is_32_bit_integer()
  12178. : false;
  12179. });
  12180. def_is_32_bit_integer(AST_Binary, function() {
  12181. return bitwise_binop.has(this.operator);
  12182. });
  12183. }(function (node, func) {
  12184. node.DEFMETHOD("is_32_bit_integer", func);
  12185. }));
  12186. // methods to determine if an expression has a string result type
  12187. (function(def_is_string) {
  12188. def_is_string(AST_Node, return_false);
  12189. def_is_string(AST_String, return_true);
  12190. def_is_string(AST_TemplateString, return_true);
  12191. def_is_string(AST_UnaryPrefix, function() {
  12192. return this.operator == "typeof";
  12193. });
  12194. def_is_string(AST_Binary, function(compressor) {
  12195. return this.operator == "+" &&
  12196. (this.left.is_string(compressor) || this.right.is_string(compressor));
  12197. });
  12198. def_is_string(AST_Assign, function(compressor) {
  12199. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  12200. });
  12201. def_is_string(AST_Sequence, function(compressor) {
  12202. return this.tail_node().is_string(compressor);
  12203. });
  12204. def_is_string(AST_Conditional, function(compressor) {
  12205. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  12206. });
  12207. })(function(node, func) {
  12208. node.DEFMETHOD("is_string", func);
  12209. });
  12210. function is_undefined(node, compressor) {
  12211. return (
  12212. has_flag(node, UNDEFINED)
  12213. || node instanceof AST_Undefined
  12214. || node instanceof AST_UnaryPrefix
  12215. && node.operator == "void"
  12216. && !node.expression.has_side_effects(compressor)
  12217. );
  12218. }
  12219. // Is the node explicitly null or undefined.
  12220. function is_null_or_undefined(node, compressor) {
  12221. let fixed;
  12222. return (
  12223. node instanceof AST_Null
  12224. || is_undefined(node, compressor)
  12225. || (
  12226. node instanceof AST_SymbolRef
  12227. && (fixed = node.definition().fixed) instanceof AST_Node
  12228. && is_nullish(fixed, compressor)
  12229. )
  12230. );
  12231. }
  12232. // Find out if this expression is optionally chained from a base-point that we
  12233. // can statically analyze as null or undefined.
  12234. function is_nullish_shortcircuited(node, compressor) {
  12235. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  12236. return (
  12237. (node.optional && is_null_or_undefined(node.expression, compressor))
  12238. || is_nullish_shortcircuited(node.expression, compressor)
  12239. );
  12240. }
  12241. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  12242. return false;
  12243. }
  12244. // Find out if something is == null, or can short circuit into nullish.
  12245. // Used to optimize ?. and ??
  12246. function is_nullish(node, compressor) {
  12247. if (is_null_or_undefined(node, compressor)) return true;
  12248. return is_nullish_shortcircuited(node, compressor);
  12249. }
  12250. // Determine if expression might cause side effects
  12251. // If there's a possibility that a node may change something when it's executed, this returns true
  12252. (function(def_has_side_effects) {
  12253. def_has_side_effects(AST_Node, return_true);
  12254. def_has_side_effects(AST_EmptyStatement, return_false);
  12255. def_has_side_effects(AST_Constant, return_false);
  12256. def_has_side_effects(AST_This, return_false);
  12257. function any(list, compressor) {
  12258. for (var i = list.length; --i >= 0;)
  12259. if (list[i].has_side_effects(compressor))
  12260. return true;
  12261. return false;
  12262. }
  12263. def_has_side_effects(AST_Block, function(compressor) {
  12264. return any(this.body, compressor);
  12265. });
  12266. def_has_side_effects(AST_Call, function(compressor) {
  12267. if (
  12268. !this.is_callee_pure(compressor)
  12269. && (!this.expression.is_call_pure(compressor)
  12270. || this.expression.has_side_effects(compressor))
  12271. ) {
  12272. return true;
  12273. }
  12274. return any(this.args, compressor);
  12275. });
  12276. def_has_side_effects(AST_Switch, function(compressor) {
  12277. return this.expression.has_side_effects(compressor)
  12278. || any(this.body, compressor);
  12279. });
  12280. def_has_side_effects(AST_Case, function(compressor) {
  12281. return this.expression.has_side_effects(compressor)
  12282. || any(this.body, compressor);
  12283. });
  12284. def_has_side_effects(AST_Try, function(compressor) {
  12285. return this.body.has_side_effects(compressor)
  12286. || this.bcatch && this.bcatch.has_side_effects(compressor)
  12287. || this.bfinally && this.bfinally.has_side_effects(compressor);
  12288. });
  12289. def_has_side_effects(AST_If, function(compressor) {
  12290. return this.condition.has_side_effects(compressor)
  12291. || this.body && this.body.has_side_effects(compressor)
  12292. || this.alternative && this.alternative.has_side_effects(compressor);
  12293. });
  12294. def_has_side_effects(AST_ImportMeta, return_false);
  12295. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  12296. return this.body.has_side_effects(compressor);
  12297. });
  12298. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  12299. return this.body.has_side_effects(compressor);
  12300. });
  12301. def_has_side_effects(AST_Lambda, return_false);
  12302. def_has_side_effects(AST_Class, function (compressor) {
  12303. if (this.extends && this.extends.has_side_effects(compressor)) {
  12304. return true;
  12305. }
  12306. return any(this.properties, compressor);
  12307. });
  12308. def_has_side_effects(AST_ClassStaticBlock, function(compressor) {
  12309. return any(this.body, compressor);
  12310. });
  12311. def_has_side_effects(AST_Binary, function(compressor) {
  12312. return this.left.has_side_effects(compressor)
  12313. || this.right.has_side_effects(compressor);
  12314. });
  12315. def_has_side_effects(AST_Assign, return_true);
  12316. def_has_side_effects(AST_Conditional, function(compressor) {
  12317. return this.condition.has_side_effects(compressor)
  12318. || this.consequent.has_side_effects(compressor)
  12319. || this.alternative.has_side_effects(compressor);
  12320. });
  12321. def_has_side_effects(AST_Unary, function(compressor) {
  12322. return unary_side_effects.has(this.operator)
  12323. || this.expression.has_side_effects(compressor);
  12324. });
  12325. def_has_side_effects(AST_SymbolRef, function(compressor) {
  12326. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12327. });
  12328. def_has_side_effects(AST_SymbolClassProperty, return_false);
  12329. def_has_side_effects(AST_SymbolDeclaration, return_false);
  12330. def_has_side_effects(AST_Object, function(compressor) {
  12331. return any(this.properties, compressor);
  12332. });
  12333. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  12334. return (
  12335. this.computed_key() && this.key.has_side_effects(compressor)
  12336. || this.value && this.value.has_side_effects(compressor)
  12337. );
  12338. });
  12339. def_has_side_effects(AST_ClassProperty, function(compressor) {
  12340. return (
  12341. this.computed_key() && this.key.has_side_effects(compressor)
  12342. || this.static && this.value && this.value.has_side_effects(compressor)
  12343. );
  12344. });
  12345. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  12346. return this.computed_key() && this.key.has_side_effects(compressor);
  12347. });
  12348. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  12349. return this.computed_key() && this.key.has_side_effects(compressor);
  12350. });
  12351. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  12352. return this.computed_key() && this.key.has_side_effects(compressor);
  12353. });
  12354. def_has_side_effects(AST_Array, function(compressor) {
  12355. return any(this.elements, compressor);
  12356. });
  12357. def_has_side_effects(AST_Dot, function(compressor) {
  12358. if (is_nullish(this, compressor)) {
  12359. return this.expression.has_side_effects(compressor);
  12360. }
  12361. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  12362. return true;
  12363. }
  12364. return this.expression.has_side_effects(compressor);
  12365. });
  12366. def_has_side_effects(AST_Sub, function(compressor) {
  12367. if (is_nullish(this, compressor)) {
  12368. return this.expression.has_side_effects(compressor);
  12369. }
  12370. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  12371. return true;
  12372. }
  12373. var property = this.property.has_side_effects(compressor);
  12374. if (property && this.optional) return true; // "?." is a condition
  12375. return property || this.expression.has_side_effects(compressor);
  12376. });
  12377. def_has_side_effects(AST_Chain, function (compressor) {
  12378. return this.expression.has_side_effects(compressor);
  12379. });
  12380. def_has_side_effects(AST_Sequence, function(compressor) {
  12381. return any(this.expressions, compressor);
  12382. });
  12383. def_has_side_effects(AST_Definitions, function(compressor) {
  12384. return any(this.definitions, compressor);
  12385. });
  12386. def_has_side_effects(AST_VarDef, function() {
  12387. return this.value != null;
  12388. });
  12389. def_has_side_effects(AST_TemplateSegment, return_false);
  12390. def_has_side_effects(AST_TemplateString, function(compressor) {
  12391. return any(this.segments, compressor);
  12392. });
  12393. })(function(node, func) {
  12394. node.DEFMETHOD("has_side_effects", func);
  12395. });
  12396. // determine if expression may throw
  12397. (function(def_may_throw) {
  12398. def_may_throw(AST_Node, return_true);
  12399. def_may_throw(AST_Constant, return_false);
  12400. def_may_throw(AST_EmptyStatement, return_false);
  12401. def_may_throw(AST_Lambda, return_false);
  12402. def_may_throw(AST_SymbolDeclaration, return_false);
  12403. def_may_throw(AST_This, return_false);
  12404. def_may_throw(AST_ImportMeta, return_false);
  12405. function any(list, compressor) {
  12406. for (var i = list.length; --i >= 0;)
  12407. if (list[i].may_throw(compressor))
  12408. return true;
  12409. return false;
  12410. }
  12411. def_may_throw(AST_Class, function(compressor) {
  12412. if (this.extends && this.extends.may_throw(compressor)) return true;
  12413. return any(this.properties, compressor);
  12414. });
  12415. def_may_throw(AST_ClassStaticBlock, function (compressor) {
  12416. return any(this.body, compressor);
  12417. });
  12418. def_may_throw(AST_Array, function(compressor) {
  12419. return any(this.elements, compressor);
  12420. });
  12421. def_may_throw(AST_Assign, function(compressor) {
  12422. if (this.right.may_throw(compressor)) return true;
  12423. if (!compressor.has_directive("use strict")
  12424. && this.operator == "="
  12425. && this.left instanceof AST_SymbolRef) {
  12426. return false;
  12427. }
  12428. return this.left.may_throw(compressor);
  12429. });
  12430. def_may_throw(AST_Binary, function(compressor) {
  12431. return this.left.may_throw(compressor)
  12432. || this.right.may_throw(compressor);
  12433. });
  12434. def_may_throw(AST_Block, function(compressor) {
  12435. return any(this.body, compressor);
  12436. });
  12437. def_may_throw(AST_Call, function(compressor) {
  12438. if (is_nullish(this, compressor)) return false;
  12439. if (any(this.args, compressor)) return true;
  12440. if (this.is_callee_pure(compressor)) return false;
  12441. if (this.expression.may_throw(compressor)) return true;
  12442. return !(this.expression instanceof AST_Lambda)
  12443. || any(this.expression.body, compressor);
  12444. });
  12445. def_may_throw(AST_Case, function(compressor) {
  12446. return this.expression.may_throw(compressor)
  12447. || any(this.body, compressor);
  12448. });
  12449. def_may_throw(AST_Conditional, function(compressor) {
  12450. return this.condition.may_throw(compressor)
  12451. || this.consequent.may_throw(compressor)
  12452. || this.alternative.may_throw(compressor);
  12453. });
  12454. def_may_throw(AST_Definitions, function(compressor) {
  12455. return any(this.definitions, compressor);
  12456. });
  12457. def_may_throw(AST_If, function(compressor) {
  12458. return this.condition.may_throw(compressor)
  12459. || this.body && this.body.may_throw(compressor)
  12460. || this.alternative && this.alternative.may_throw(compressor);
  12461. });
  12462. def_may_throw(AST_LabeledStatement, function(compressor) {
  12463. return this.body.may_throw(compressor);
  12464. });
  12465. def_may_throw(AST_Object, function(compressor) {
  12466. return any(this.properties, compressor);
  12467. });
  12468. def_may_throw(AST_ObjectProperty, function(compressor) {
  12469. // TODO key may throw too
  12470. return this.value ? this.value.may_throw(compressor) : false;
  12471. });
  12472. def_may_throw(AST_ClassProperty, function(compressor) {
  12473. return (
  12474. this.computed_key() && this.key.may_throw(compressor)
  12475. || this.static && this.value && this.value.may_throw(compressor)
  12476. );
  12477. });
  12478. def_may_throw(AST_ConciseMethod, function(compressor) {
  12479. return this.computed_key() && this.key.may_throw(compressor);
  12480. });
  12481. def_may_throw(AST_ObjectGetter, function(compressor) {
  12482. return this.computed_key() && this.key.may_throw(compressor);
  12483. });
  12484. def_may_throw(AST_ObjectSetter, function(compressor) {
  12485. return this.computed_key() && this.key.may_throw(compressor);
  12486. });
  12487. def_may_throw(AST_Return, function(compressor) {
  12488. return this.value && this.value.may_throw(compressor);
  12489. });
  12490. def_may_throw(AST_Sequence, function(compressor) {
  12491. return any(this.expressions, compressor);
  12492. });
  12493. def_may_throw(AST_SimpleStatement, function(compressor) {
  12494. return this.body.may_throw(compressor);
  12495. });
  12496. def_may_throw(AST_Dot, function(compressor) {
  12497. if (is_nullish(this, compressor)) return false;
  12498. return !this.optional && this.expression.may_throw_on_access(compressor)
  12499. || this.expression.may_throw(compressor);
  12500. });
  12501. def_may_throw(AST_Sub, function(compressor) {
  12502. if (is_nullish(this, compressor)) return false;
  12503. return !this.optional && this.expression.may_throw_on_access(compressor)
  12504. || this.expression.may_throw(compressor)
  12505. || this.property.may_throw(compressor);
  12506. });
  12507. def_may_throw(AST_Chain, function(compressor) {
  12508. return this.expression.may_throw(compressor);
  12509. });
  12510. def_may_throw(AST_Switch, function(compressor) {
  12511. return this.expression.may_throw(compressor)
  12512. || any(this.body, compressor);
  12513. });
  12514. def_may_throw(AST_SymbolRef, function(compressor) {
  12515. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12516. });
  12517. def_may_throw(AST_SymbolClassProperty, return_false);
  12518. def_may_throw(AST_Try, function(compressor) {
  12519. return this.bcatch ? this.bcatch.may_throw(compressor) : this.body.may_throw(compressor)
  12520. || this.bfinally && this.bfinally.may_throw(compressor);
  12521. });
  12522. def_may_throw(AST_Unary, function(compressor) {
  12523. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12524. return false;
  12525. return this.expression.may_throw(compressor);
  12526. });
  12527. def_may_throw(AST_VarDef, function(compressor) {
  12528. if (!this.value) return false;
  12529. return this.value.may_throw(compressor);
  12530. });
  12531. })(function(node, func) {
  12532. node.DEFMETHOD("may_throw", func);
  12533. });
  12534. // determine if expression is constant
  12535. (function(def_is_constant_expression) {
  12536. function all_refs_local(scope) {
  12537. let result = true;
  12538. walk(this, node => {
  12539. if (node instanceof AST_SymbolRef) {
  12540. if (has_flag(this, INLINED)) {
  12541. result = false;
  12542. return walk_abort;
  12543. }
  12544. var def = node.definition();
  12545. if (
  12546. member(def, this.enclosed)
  12547. && !this.variables.has(def.name)
  12548. ) {
  12549. if (scope) {
  12550. var scope_def = scope.find_variable(node);
  12551. if (def.undeclared ? !scope_def : scope_def === def) {
  12552. result = "f";
  12553. return true;
  12554. }
  12555. }
  12556. result = false;
  12557. return walk_abort;
  12558. }
  12559. return true;
  12560. }
  12561. if (node instanceof AST_This && this instanceof AST_Arrow) {
  12562. result = false;
  12563. return walk_abort;
  12564. }
  12565. });
  12566. return result;
  12567. }
  12568. def_is_constant_expression(AST_Node, return_false);
  12569. def_is_constant_expression(AST_Constant, return_true);
  12570. def_is_constant_expression(AST_Class, function(scope) {
  12571. if (this.extends && !this.extends.is_constant_expression(scope)) {
  12572. return false;
  12573. }
  12574. for (const prop of this.properties) {
  12575. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  12576. return false;
  12577. }
  12578. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  12579. return false;
  12580. }
  12581. if (prop instanceof AST_ClassStaticBlock) {
  12582. return false;
  12583. }
  12584. }
  12585. return all_refs_local.call(this, scope);
  12586. });
  12587. def_is_constant_expression(AST_Lambda, all_refs_local);
  12588. def_is_constant_expression(AST_Unary, function() {
  12589. return this.expression.is_constant_expression();
  12590. });
  12591. def_is_constant_expression(AST_Binary, function() {
  12592. return this.left.is_constant_expression()
  12593. && this.right.is_constant_expression();
  12594. });
  12595. def_is_constant_expression(AST_Array, function() {
  12596. return this.elements.every((l) => l.is_constant_expression());
  12597. });
  12598. def_is_constant_expression(AST_Object, function() {
  12599. return this.properties.every((l) => l.is_constant_expression());
  12600. });
  12601. def_is_constant_expression(AST_ObjectProperty, function() {
  12602. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  12603. });
  12604. })(function(node, func) {
  12605. node.DEFMETHOD("is_constant_expression", func);
  12606. });
  12607. // may_throw_on_access()
  12608. // returns true if this node may be null, undefined or contain `AST_Accessor`
  12609. (function(def_may_throw_on_access) {
  12610. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  12611. return !compressor.option("pure_getters")
  12612. || this._dot_throw(compressor);
  12613. });
  12614. function is_strict(compressor) {
  12615. return /strict/.test(compressor.option("pure_getters"));
  12616. }
  12617. def_may_throw_on_access(AST_Node, is_strict);
  12618. def_may_throw_on_access(AST_Null, return_true);
  12619. def_may_throw_on_access(AST_Undefined, return_true);
  12620. def_may_throw_on_access(AST_Constant, return_false);
  12621. def_may_throw_on_access(AST_Array, return_false);
  12622. def_may_throw_on_access(AST_Object, function(compressor) {
  12623. if (!is_strict(compressor)) return false;
  12624. for (var i = this.properties.length; --i >=0;)
  12625. if (this.properties[i]._dot_throw(compressor)) return true;
  12626. return false;
  12627. });
  12628. // Do not be as strict with classes as we are with objects.
  12629. // Hopefully the community is not going to abuse static getters and setters.
  12630. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  12631. def_may_throw_on_access(AST_Class, return_false);
  12632. def_may_throw_on_access(AST_ObjectProperty, return_false);
  12633. def_may_throw_on_access(AST_ObjectGetter, return_true);
  12634. def_may_throw_on_access(AST_Expansion, function(compressor) {
  12635. return this.expression._dot_throw(compressor);
  12636. });
  12637. def_may_throw_on_access(AST_Function, return_false);
  12638. def_may_throw_on_access(AST_Arrow, return_false);
  12639. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  12640. def_may_throw_on_access(AST_UnaryPrefix, function() {
  12641. return this.operator == "void";
  12642. });
  12643. def_may_throw_on_access(AST_Binary, function(compressor) {
  12644. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  12645. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  12646. });
  12647. def_may_throw_on_access(AST_Assign, function(compressor) {
  12648. if (this.logical) return true;
  12649. return this.operator == "="
  12650. && this.right._dot_throw(compressor);
  12651. });
  12652. def_may_throw_on_access(AST_Conditional, function(compressor) {
  12653. return this.consequent._dot_throw(compressor)
  12654. || this.alternative._dot_throw(compressor);
  12655. });
  12656. def_may_throw_on_access(AST_Dot, function(compressor) {
  12657. if (!is_strict(compressor)) return false;
  12658. if (this.property == "prototype") {
  12659. return !(
  12660. this.expression instanceof AST_Function
  12661. || this.expression instanceof AST_Class
  12662. );
  12663. }
  12664. return true;
  12665. });
  12666. def_may_throw_on_access(AST_Chain, function(compressor) {
  12667. return this.expression._dot_throw(compressor);
  12668. });
  12669. def_may_throw_on_access(AST_Sequence, function(compressor) {
  12670. return this.tail_node()._dot_throw(compressor);
  12671. });
  12672. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  12673. if (this.name === "arguments" && this.scope instanceof AST_Lambda) return false;
  12674. if (has_flag(this, UNDEFINED)) return true;
  12675. if (!is_strict(compressor)) return false;
  12676. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  12677. if (this.is_immutable()) return false;
  12678. var fixed = this.fixed_value();
  12679. return !fixed || fixed._dot_throw(compressor);
  12680. });
  12681. })(function(node, func) {
  12682. node.DEFMETHOD("_dot_throw", func);
  12683. });
  12684. function is_lhs(node, parent) {
  12685. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  12686. if (parent instanceof AST_Assign && parent.left === node) return node;
  12687. if (parent instanceof AST_ForIn && parent.init === node) return node;
  12688. }
  12689. // method to negate an expression
  12690. (function(def_negate) {
  12691. function basic_negation(exp) {
  12692. return make_node(AST_UnaryPrefix, exp, {
  12693. operator: "!",
  12694. expression: exp
  12695. });
  12696. }
  12697. function best(orig, alt, first_in_statement) {
  12698. var negated = basic_negation(orig);
  12699. if (first_in_statement) {
  12700. var stat = make_node(AST_SimpleStatement, alt, {
  12701. body: alt
  12702. });
  12703. return best_of_expression(negated, stat) === stat ? alt : negated;
  12704. }
  12705. return best_of_expression(negated, alt);
  12706. }
  12707. def_negate(AST_Node, function() {
  12708. return basic_negation(this);
  12709. });
  12710. def_negate(AST_Statement, function() {
  12711. throw new Error("Cannot negate a statement");
  12712. });
  12713. def_negate(AST_Function, function() {
  12714. return basic_negation(this);
  12715. });
  12716. def_negate(AST_Class, function() {
  12717. return basic_negation(this);
  12718. });
  12719. def_negate(AST_Arrow, function() {
  12720. return basic_negation(this);
  12721. });
  12722. def_negate(AST_UnaryPrefix, function() {
  12723. if (this.operator == "!")
  12724. return this.expression;
  12725. return basic_negation(this);
  12726. });
  12727. def_negate(AST_Sequence, function(compressor) {
  12728. var expressions = this.expressions.slice();
  12729. expressions.push(expressions.pop().negate(compressor));
  12730. return make_sequence(this, expressions);
  12731. });
  12732. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  12733. var self = this.clone();
  12734. self.consequent = self.consequent.negate(compressor);
  12735. self.alternative = self.alternative.negate(compressor);
  12736. return best(this, self, first_in_statement);
  12737. });
  12738. def_negate(AST_Binary, function(compressor, first_in_statement) {
  12739. var self = this.clone(), op = this.operator;
  12740. if (compressor.option("unsafe_comps")) {
  12741. switch (op) {
  12742. case "<=" : self.operator = ">" ; return self;
  12743. case "<" : self.operator = ">=" ; return self;
  12744. case ">=" : self.operator = "<" ; return self;
  12745. case ">" : self.operator = "<=" ; return self;
  12746. }
  12747. }
  12748. switch (op) {
  12749. case "==" : self.operator = "!="; return self;
  12750. case "!=" : self.operator = "=="; return self;
  12751. case "===": self.operator = "!=="; return self;
  12752. case "!==": self.operator = "==="; return self;
  12753. case "&&":
  12754. self.operator = "||";
  12755. self.left = self.left.negate(compressor, first_in_statement);
  12756. self.right = self.right.negate(compressor);
  12757. return best(this, self, first_in_statement);
  12758. case "||":
  12759. self.operator = "&&";
  12760. self.left = self.left.negate(compressor, first_in_statement);
  12761. self.right = self.right.negate(compressor);
  12762. return best(this, self, first_in_statement);
  12763. }
  12764. return basic_negation(this);
  12765. });
  12766. })(function(node, func) {
  12767. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  12768. return func.call(this, compressor, first_in_statement);
  12769. });
  12770. });
  12771. (function (def_bitwise_negate) {
  12772. function basic_negation(exp) {
  12773. return make_node(AST_UnaryPrefix, exp, {
  12774. operator: "~",
  12775. expression: exp
  12776. });
  12777. }
  12778. def_bitwise_negate(AST_Node, function() {
  12779. return basic_negation(this);
  12780. });
  12781. def_bitwise_negate(AST_Number, function() {
  12782. const neg = ~this.value;
  12783. if (neg.toString().length > this.value.toString().length) {
  12784. return basic_negation(this);
  12785. }
  12786. return make_node(AST_Number, this, { value: neg });
  12787. });
  12788. def_bitwise_negate(AST_UnaryPrefix, function(in_32_bit_context) {
  12789. if (this.operator == "~" && (in_32_bit_context || this.expression.is_32_bit_integer())) {
  12790. return this.expression;
  12791. } else {
  12792. return basic_negation(this);
  12793. }
  12794. });
  12795. })(function (node, func) {
  12796. node.DEFMETHOD("bitwise_negate", func);
  12797. });
  12798. // Is the callee of this function pure?
  12799. 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");
  12800. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  12801. if (compressor.option("unsafe")) {
  12802. var expr = this.expression;
  12803. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  12804. if (
  12805. expr.expression && expr.expression.name === "hasOwnProperty" &&
  12806. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  12807. ) {
  12808. return false;
  12809. }
  12810. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  12811. if (
  12812. expr instanceof AST_Dot
  12813. && is_undeclared_ref(expr.expression)
  12814. && is_pure_native_fn(expr.expression.name, expr.property)
  12815. ) {
  12816. return true;
  12817. }
  12818. }
  12819. if ((this instanceof AST_New) && compressor.option("pure_new")) {
  12820. return true;
  12821. }
  12822. if (compressor.option("side_effects") && has_annotation(this, _PURE)) {
  12823. return true;
  12824. }
  12825. return !compressor.pure_funcs(this);
  12826. });
  12827. // If I call this, is it a pure function?
  12828. AST_Node.DEFMETHOD("is_call_pure", return_false);
  12829. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  12830. if (!compressor.option("unsafe")) return;
  12831. const expr = this.expression;
  12832. let native_obj;
  12833. if (expr instanceof AST_Array) {
  12834. native_obj = "Array";
  12835. } else if (expr.is_boolean()) {
  12836. native_obj = "Boolean";
  12837. } else if (expr.is_number(compressor)) {
  12838. native_obj = "Number";
  12839. } else if (expr instanceof AST_RegExp) {
  12840. native_obj = "RegExp";
  12841. } else if (expr.is_string(compressor)) {
  12842. native_obj = "String";
  12843. } else if (!this.may_throw_on_access(compressor)) {
  12844. native_obj = "Object";
  12845. }
  12846. return native_obj != null && is_pure_native_method(native_obj, this.property);
  12847. });
  12848. // tell me if a statement aborts
  12849. const aborts = (thing) => thing && thing.aborts();
  12850. (function(def_aborts) {
  12851. def_aborts(AST_Statement, return_null);
  12852. def_aborts(AST_Jump, return_this);
  12853. function block_aborts() {
  12854. for (var i = 0; i < this.body.length; i++) {
  12855. if (aborts(this.body[i])) {
  12856. return this.body[i];
  12857. }
  12858. }
  12859. return null;
  12860. }
  12861. def_aborts(AST_Import, return_null);
  12862. def_aborts(AST_BlockStatement, block_aborts);
  12863. def_aborts(AST_SwitchBranch, block_aborts);
  12864. def_aborts(AST_DefClass, function () {
  12865. for (const prop of this.properties) {
  12866. if (prop instanceof AST_ClassStaticBlock) {
  12867. if (prop.aborts()) return prop;
  12868. }
  12869. }
  12870. return null;
  12871. });
  12872. def_aborts(AST_ClassStaticBlock, block_aborts);
  12873. def_aborts(AST_If, function() {
  12874. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  12875. });
  12876. })(function(node, func) {
  12877. node.DEFMETHOD("aborts", func);
  12878. });
  12879. AST_Node.DEFMETHOD("contains_this", function() {
  12880. return walk(this, node => {
  12881. if (node instanceof AST_This) return walk_abort;
  12882. if (
  12883. node !== this
  12884. && node instanceof AST_Scope
  12885. && !(node instanceof AST_Arrow)
  12886. ) {
  12887. return true;
  12888. }
  12889. });
  12890. });
  12891. function is_modified(compressor, tw, node, value, level, immutable) {
  12892. var parent = tw.parent(level);
  12893. var lhs = is_lhs(node, parent);
  12894. if (lhs) return lhs;
  12895. if (!immutable
  12896. && parent instanceof AST_Call
  12897. && parent.expression === node
  12898. && !(value instanceof AST_Arrow)
  12899. && !(value instanceof AST_Class)
  12900. && !parent.is_callee_pure(compressor)
  12901. && (!(value instanceof AST_Function)
  12902. || !(parent instanceof AST_New) && value.contains_this())) {
  12903. return true;
  12904. }
  12905. if (parent instanceof AST_Array) {
  12906. return is_modified(compressor, tw, parent, parent, level + 1);
  12907. }
  12908. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  12909. var obj = tw.parent(level + 1);
  12910. return is_modified(compressor, tw, obj, obj, level + 2);
  12911. }
  12912. if (parent instanceof AST_PropAccess && parent.expression === node) {
  12913. var prop = read_property(value, parent.property);
  12914. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  12915. }
  12916. }
  12917. /***********************************************************************
  12918. A JavaScript tokenizer / parser / beautifier / compressor.
  12919. https://github.com/mishoo/UglifyJS2
  12920. -------------------------------- (C) ---------------------------------
  12921. Author: Mihai Bazon
  12922. <mihai.bazon@gmail.com>
  12923. http://mihai.bazon.net/blog
  12924. Distributed under the BSD license:
  12925. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12926. Redistribution and use in source and binary forms, with or without
  12927. modification, are permitted provided that the following conditions
  12928. are met:
  12929. * Redistributions of source code must retain the above
  12930. copyright notice, this list of conditions and the following
  12931. disclaimer.
  12932. * Redistributions in binary form must reproduce the above
  12933. copyright notice, this list of conditions and the following
  12934. disclaimer in the documentation and/or other materials
  12935. provided with the distribution.
  12936. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12937. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12938. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12939. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12940. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12941. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12942. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12943. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12944. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12945. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12946. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12947. SUCH DAMAGE.
  12948. ***********************************************************************/
  12949. // methods to evaluate a constant expression
  12950. function def_eval(node, func) {
  12951. node.DEFMETHOD("_eval", func);
  12952. }
  12953. // Used to propagate a nullish short-circuit signal upwards through the chain.
  12954. const nullish = Symbol("This AST_Chain is nullish");
  12955. // If the node has been successfully reduced to a constant,
  12956. // then its value is returned; otherwise the element itself
  12957. // is returned.
  12958. // They can be distinguished as constant value is never a
  12959. // descendant of AST_Node.
  12960. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  12961. if (!compressor.option("evaluate"))
  12962. return this;
  12963. var val = this._eval(compressor, 1);
  12964. if (!val || val instanceof RegExp)
  12965. return val;
  12966. if (typeof val == "function" || typeof val == "object" || val == nullish)
  12967. return this;
  12968. // Evaluated strings can be larger than the original expression
  12969. if (typeof val === "string") {
  12970. const unevaluated_size = this.size(compressor);
  12971. if (val.length + 2 > unevaluated_size) return this;
  12972. }
  12973. return val;
  12974. });
  12975. var unaryPrefix = makePredicate("! ~ - + void");
  12976. AST_Node.DEFMETHOD("is_constant", function () {
  12977. // Accomodate when compress option evaluate=false
  12978. // as well as the common constant expressions !0 and -1
  12979. if (this instanceof AST_Constant) {
  12980. return !(this instanceof AST_RegExp);
  12981. } else {
  12982. return this instanceof AST_UnaryPrefix
  12983. && this.expression instanceof AST_Constant
  12984. && unaryPrefix.has(this.operator);
  12985. }
  12986. });
  12987. def_eval(AST_Statement, function () {
  12988. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  12989. });
  12990. def_eval(AST_Lambda, return_this);
  12991. def_eval(AST_Class, return_this);
  12992. def_eval(AST_Node, return_this);
  12993. def_eval(AST_Constant, function () {
  12994. return this.getValue();
  12995. });
  12996. const supports_bigint = typeof BigInt === "function";
  12997. def_eval(AST_BigInt, function () {
  12998. if (supports_bigint) {
  12999. return BigInt(this.value);
  13000. } else {
  13001. return this;
  13002. }
  13003. });
  13004. def_eval(AST_RegExp, function (compressor) {
  13005. let evaluated = compressor.evaluated_regexps.get(this.value);
  13006. if (evaluated === undefined && regexp_is_safe(this.value.source)) {
  13007. try {
  13008. const { source, flags } = this.value;
  13009. evaluated = new RegExp(source, flags);
  13010. } catch (e) {
  13011. evaluated = null;
  13012. }
  13013. compressor.evaluated_regexps.set(this.value, evaluated);
  13014. }
  13015. return evaluated || this;
  13016. });
  13017. def_eval(AST_TemplateString, function () {
  13018. if (this.segments.length !== 1) return this;
  13019. return this.segments[0].value;
  13020. });
  13021. def_eval(AST_Function, function (compressor) {
  13022. if (compressor.option("unsafe")) {
  13023. var fn = function () { };
  13024. fn.node = this;
  13025. fn.toString = () => this.print_to_string();
  13026. return fn;
  13027. }
  13028. return this;
  13029. });
  13030. def_eval(AST_Array, function (compressor, depth) {
  13031. if (compressor.option("unsafe")) {
  13032. var elements = [];
  13033. for (var i = 0, len = this.elements.length; i < len; i++) {
  13034. var element = this.elements[i];
  13035. var value = element._eval(compressor, depth);
  13036. if (element === value)
  13037. return this;
  13038. elements.push(value);
  13039. }
  13040. return elements;
  13041. }
  13042. return this;
  13043. });
  13044. def_eval(AST_Object, function (compressor, depth) {
  13045. if (compressor.option("unsafe")) {
  13046. var val = {};
  13047. for (var i = 0, len = this.properties.length; i < len; i++) {
  13048. var prop = this.properties[i];
  13049. if (prop instanceof AST_Expansion)
  13050. return this;
  13051. var key = prop.key;
  13052. if (key instanceof AST_Symbol) {
  13053. key = key.name;
  13054. } else if (key instanceof AST_Node) {
  13055. key = key._eval(compressor, depth);
  13056. if (key === prop.key)
  13057. return this;
  13058. }
  13059. if (typeof Object.prototype[key] === "function") {
  13060. return this;
  13061. }
  13062. if (prop.value instanceof AST_Function)
  13063. continue;
  13064. val[key] = prop.value._eval(compressor, depth);
  13065. if (val[key] === prop.value)
  13066. return this;
  13067. }
  13068. return val;
  13069. }
  13070. return this;
  13071. });
  13072. var non_converting_unary = makePredicate("! typeof void");
  13073. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  13074. var e = this.expression;
  13075. // Function would be evaluated to an array and so typeof would
  13076. // incorrectly return 'object'. Hence making is a special case.
  13077. if (compressor.option("typeofs")
  13078. && this.operator == "typeof"
  13079. && (e instanceof AST_Lambda
  13080. || e instanceof AST_SymbolRef
  13081. && e.fixed_value() instanceof AST_Lambda)) {
  13082. return typeof function () { };
  13083. }
  13084. if (!non_converting_unary.has(this.operator))
  13085. depth++;
  13086. e = e._eval(compressor, depth);
  13087. if (e === this.expression)
  13088. return this;
  13089. switch (this.operator) {
  13090. case "!": return !e;
  13091. case "typeof":
  13092. // typeof <RegExp> returns "object" or "function" on different platforms
  13093. // so cannot evaluate reliably
  13094. if (e instanceof RegExp)
  13095. return this;
  13096. return typeof e;
  13097. case "void": return void e;
  13098. case "~": return ~e;
  13099. case "-": return -e;
  13100. case "+": return +e;
  13101. }
  13102. return this;
  13103. });
  13104. var non_converting_binary = makePredicate("&& || ?? === !==");
  13105. const identity_comparison = makePredicate("== != === !==");
  13106. const has_identity = value => typeof value === "object"
  13107. || typeof value === "function"
  13108. || typeof value === "symbol";
  13109. def_eval(AST_Binary, function (compressor, depth) {
  13110. if (!non_converting_binary.has(this.operator))
  13111. depth++;
  13112. var left = this.left._eval(compressor, depth);
  13113. if (left === this.left)
  13114. return this;
  13115. var right = this.right._eval(compressor, depth);
  13116. if (right === this.right)
  13117. return this;
  13118. if (left != null
  13119. && right != null
  13120. && identity_comparison.has(this.operator)
  13121. && has_identity(left)
  13122. && has_identity(right)
  13123. && typeof left === typeof right) {
  13124. // Do not compare by reference
  13125. return this;
  13126. }
  13127. // Do not mix BigInt and Number; Don't use `>>>` on BigInt or `/ 0n`
  13128. if (
  13129. (typeof left === "bigint") !== (typeof right === "bigint")
  13130. || typeof left === "bigint"
  13131. && (this.operator === ">>>"
  13132. || this.operator === "/" && Number(right) === 0)
  13133. ) {
  13134. return this;
  13135. }
  13136. var result;
  13137. switch (this.operator) {
  13138. case "&&": result = left && right; break;
  13139. case "||": result = left || right; break;
  13140. case "??": result = left != null ? left : right; break;
  13141. case "|": result = left | right; break;
  13142. case "&": result = left & right; break;
  13143. case "^": result = left ^ right; break;
  13144. case "+": result = left + right; break;
  13145. case "*": result = left * right; break;
  13146. case "**": result = left ** right; break;
  13147. case "/": result = left / right; break;
  13148. case "%": result = left % right; break;
  13149. case "-": result = left - right; break;
  13150. case "<<": result = left << right; break;
  13151. case ">>": result = left >> right; break;
  13152. case ">>>": result = left >>> right; break;
  13153. case "==": result = left == right; break;
  13154. case "===": result = left === right; break;
  13155. case "!=": result = left != right; break;
  13156. case "!==": result = left !== right; break;
  13157. case "<": result = left < right; break;
  13158. case "<=": result = left <= right; break;
  13159. case ">": result = left > right; break;
  13160. case ">=": result = left >= right; break;
  13161. default:
  13162. return this;
  13163. }
  13164. if (typeof result === "number" && isNaN(result) && compressor.find_parent(AST_With)) {
  13165. // leave original expression as is
  13166. return this;
  13167. }
  13168. return result;
  13169. });
  13170. def_eval(AST_Conditional, function (compressor, depth) {
  13171. var condition = this.condition._eval(compressor, depth);
  13172. if (condition === this.condition)
  13173. return this;
  13174. var node = condition ? this.consequent : this.alternative;
  13175. var value = node._eval(compressor, depth);
  13176. return value === node ? this : value;
  13177. });
  13178. // Set of AST_SymbolRef which are currently being evaluated.
  13179. // Avoids infinite recursion of ._eval()
  13180. const reentrant_ref_eval = new Set();
  13181. def_eval(AST_SymbolRef, function (compressor, depth) {
  13182. if (reentrant_ref_eval.has(this))
  13183. return this;
  13184. var fixed = this.fixed_value();
  13185. if (!fixed)
  13186. return this;
  13187. reentrant_ref_eval.add(this);
  13188. const value = fixed._eval(compressor, depth);
  13189. reentrant_ref_eval.delete(this);
  13190. if (value === fixed)
  13191. return this;
  13192. if (value && typeof value == "object") {
  13193. var escaped = this.definition().escaped;
  13194. if (escaped && depth > escaped)
  13195. return this;
  13196. }
  13197. return value;
  13198. });
  13199. const global_objs = { Array, Math, Number, Object, String };
  13200. const regexp_flags = new Set([
  13201. "dotAll",
  13202. "global",
  13203. "ignoreCase",
  13204. "multiline",
  13205. "sticky",
  13206. "unicode",
  13207. ]);
  13208. def_eval(AST_PropAccess, function (compressor, depth) {
  13209. let obj = this.expression._eval(compressor, depth + 1);
  13210. if (obj === nullish || (this.optional && obj == null)) return nullish;
  13211. // `.length` of strings and arrays is always safe
  13212. if (this.property === "length") {
  13213. if (typeof obj === "string") {
  13214. return obj.length;
  13215. }
  13216. const is_spreadless_array =
  13217. obj instanceof AST_Array
  13218. && obj.elements.every(el => !(el instanceof AST_Expansion));
  13219. if (
  13220. is_spreadless_array
  13221. && obj.elements.every(el => !el.has_side_effects(compressor))
  13222. ) {
  13223. return obj.elements.length;
  13224. }
  13225. }
  13226. if (compressor.option("unsafe")) {
  13227. var key = this.property;
  13228. if (key instanceof AST_Node) {
  13229. key = key._eval(compressor, depth);
  13230. if (key === this.property)
  13231. return this;
  13232. }
  13233. var exp = this.expression;
  13234. if (is_undeclared_ref(exp)) {
  13235. var aa;
  13236. var first_arg = exp.name === "hasOwnProperty"
  13237. && key === "call"
  13238. && (aa = compressor.parent() && compressor.parent().args)
  13239. && (aa && aa[0]
  13240. && aa[0].evaluate(compressor));
  13241. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13242. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  13243. return this.clone();
  13244. }
  13245. if (!is_pure_native_value(exp.name, key))
  13246. return this;
  13247. obj = global_objs[exp.name];
  13248. } else {
  13249. if (obj instanceof RegExp) {
  13250. if (key == "source") {
  13251. return regexp_source_fix(obj.source);
  13252. } else if (key == "flags" || regexp_flags.has(key)) {
  13253. return obj[key];
  13254. }
  13255. }
  13256. if (!obj || obj === exp || !HOP(obj, key))
  13257. return this;
  13258. if (typeof obj == "function")
  13259. switch (key) {
  13260. case "name":
  13261. return obj.node.name ? obj.node.name.name : "";
  13262. case "length":
  13263. return obj.node.length_property();
  13264. default:
  13265. return this;
  13266. }
  13267. }
  13268. return obj[key];
  13269. }
  13270. return this;
  13271. });
  13272. def_eval(AST_Chain, function (compressor, depth) {
  13273. const evaluated = this.expression._eval(compressor, depth);
  13274. return evaluated === nullish
  13275. ? undefined
  13276. : evaluated === this.expression
  13277. ? this
  13278. : evaluated;
  13279. });
  13280. def_eval(AST_Call, function (compressor, depth) {
  13281. var exp = this.expression;
  13282. const callee = exp._eval(compressor, depth);
  13283. if (callee === nullish || (this.optional && callee == null)) return nullish;
  13284. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  13285. var key = exp.property;
  13286. if (key instanceof AST_Node) {
  13287. key = key._eval(compressor, depth);
  13288. if (key === exp.property)
  13289. return this;
  13290. }
  13291. var val;
  13292. var e = exp.expression;
  13293. if (is_undeclared_ref(e)) {
  13294. var first_arg = e.name === "hasOwnProperty" &&
  13295. key === "call" &&
  13296. (this.args[0] && this.args[0].evaluate(compressor));
  13297. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13298. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  13299. return this.clone();
  13300. }
  13301. if (!is_pure_native_fn(e.name, key)) return this;
  13302. val = global_objs[e.name];
  13303. } else {
  13304. val = e._eval(compressor, depth + 1);
  13305. if (val === e || !val)
  13306. return this;
  13307. if (!is_pure_native_method(val.constructor.name, key))
  13308. return this;
  13309. }
  13310. var args = [];
  13311. for (var i = 0, len = this.args.length; i < len; i++) {
  13312. var arg = this.args[i];
  13313. var value = arg._eval(compressor, depth);
  13314. if (arg === value)
  13315. return this;
  13316. if (arg instanceof AST_Lambda)
  13317. return this;
  13318. args.push(value);
  13319. }
  13320. try {
  13321. return val[key].apply(val, args);
  13322. } catch (ex) {
  13323. // We don't really care
  13324. }
  13325. }
  13326. return this;
  13327. });
  13328. // Also a subclass of AST_Call
  13329. def_eval(AST_New, return_this);
  13330. /***********************************************************************
  13331. A JavaScript tokenizer / parser / beautifier / compressor.
  13332. https://github.com/mishoo/UglifyJS2
  13333. -------------------------------- (C) ---------------------------------
  13334. Author: Mihai Bazon
  13335. <mihai.bazon@gmail.com>
  13336. http://mihai.bazon.net/blog
  13337. Distributed under the BSD license:
  13338. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13339. Redistribution and use in source and binary forms, with or without
  13340. modification, are permitted provided that the following conditions
  13341. are met:
  13342. * Redistributions of source code must retain the above
  13343. copyright notice, this list of conditions and the following
  13344. disclaimer.
  13345. * Redistributions in binary form must reproduce the above
  13346. copyright notice, this list of conditions and the following
  13347. disclaimer in the documentation and/or other materials
  13348. provided with the distribution.
  13349. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13350. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13351. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13352. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13353. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13354. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13355. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13356. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13357. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13358. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13359. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13360. SUCH DAMAGE.
  13361. ***********************************************************************/
  13362. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  13363. // only about side effects. We'll be defining this method for each node type in this module
  13364. //
  13365. // Examples:
  13366. // foo++ -> foo++
  13367. // 1 + func() -> func()
  13368. // 10 -> (nothing)
  13369. // knownPureFunc(foo++) -> foo++
  13370. function def_drop_side_effect_free(node, func) {
  13371. node.DEFMETHOD("drop_side_effect_free", func);
  13372. }
  13373. // Drop side-effect-free elements from an array of expressions.
  13374. // Returns an array of expressions with side-effects or null
  13375. // if all elements were dropped. Note: original array may be
  13376. // returned if nothing changed.
  13377. function trim(nodes, compressor, first_in_statement) {
  13378. var len = nodes.length;
  13379. if (!len) return null;
  13380. var ret = [], changed = false;
  13381. for (var i = 0; i < len; i++) {
  13382. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  13383. changed |= node !== nodes[i];
  13384. if (node) {
  13385. ret.push(node);
  13386. first_in_statement = false;
  13387. }
  13388. }
  13389. return changed ? ret.length ? ret : null : nodes;
  13390. }
  13391. def_drop_side_effect_free(AST_Node, return_this);
  13392. def_drop_side_effect_free(AST_Constant, return_null);
  13393. def_drop_side_effect_free(AST_This, return_null);
  13394. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  13395. if (is_nullish_shortcircuited(this, compressor)) {
  13396. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13397. }
  13398. if (!this.is_callee_pure(compressor)) {
  13399. if (this.expression.is_call_pure(compressor)) {
  13400. var exprs = this.args.slice();
  13401. exprs.unshift(this.expression.expression);
  13402. exprs = trim(exprs, compressor, first_in_statement);
  13403. return exprs && make_sequence(this, exprs);
  13404. }
  13405. if (is_func_expr(this.expression)
  13406. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  13407. var node = this.clone();
  13408. node.expression.process_expression(false, compressor);
  13409. return node;
  13410. }
  13411. return this;
  13412. }
  13413. var args = trim(this.args, compressor, first_in_statement);
  13414. return args && make_sequence(this, args);
  13415. });
  13416. def_drop_side_effect_free(AST_Accessor, return_null);
  13417. def_drop_side_effect_free(AST_Function, return_null);
  13418. def_drop_side_effect_free(AST_Arrow, return_null);
  13419. def_drop_side_effect_free(AST_Class, function (compressor) {
  13420. const with_effects = [];
  13421. if (this.is_self_referential() && this.has_side_effects(compressor)) {
  13422. return this;
  13423. }
  13424. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  13425. if (trimmed_extends) with_effects.push(trimmed_extends);
  13426. for (const prop of this.properties) {
  13427. if (prop instanceof AST_ClassStaticBlock) {
  13428. if (prop.has_side_effects(compressor)) {
  13429. return this; // Be cautious about these
  13430. }
  13431. } else {
  13432. const trimmed_prop = prop.drop_side_effect_free(compressor);
  13433. if (trimmed_prop) with_effects.push(trimmed_prop);
  13434. }
  13435. }
  13436. if (!with_effects.length)
  13437. return null;
  13438. const exprs = make_sequence(this, with_effects);
  13439. if (this instanceof AST_DefClass) {
  13440. // We want a statement
  13441. return make_node(AST_SimpleStatement, this, { body: exprs });
  13442. } else {
  13443. return exprs;
  13444. }
  13445. });
  13446. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  13447. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  13448. const value = this.static && this.value
  13449. && this.value.drop_side_effect_free(compressor);
  13450. if (key && value)
  13451. return make_sequence(this, [key, value]);
  13452. return key || value || null;
  13453. });
  13454. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  13455. var right = this.right.drop_side_effect_free(compressor);
  13456. if (!right)
  13457. return this.left.drop_side_effect_free(compressor, first_in_statement);
  13458. if (lazy_op.has(this.operator)) {
  13459. if (right === this.right)
  13460. return this;
  13461. var node = this.clone();
  13462. node.right = right;
  13463. return node;
  13464. } else {
  13465. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  13466. if (!left)
  13467. return this.right.drop_side_effect_free(compressor, first_in_statement);
  13468. return make_sequence(this, [left, right]);
  13469. }
  13470. });
  13471. def_drop_side_effect_free(AST_Assign, function (compressor) {
  13472. if (this.logical)
  13473. return this;
  13474. var left = this.left;
  13475. if (left.has_side_effects(compressor)
  13476. || compressor.has_directive("use strict")
  13477. && left instanceof AST_PropAccess
  13478. && left.expression.is_constant()) {
  13479. return this;
  13480. }
  13481. set_flag(this, WRITE_ONLY);
  13482. while (left instanceof AST_PropAccess) {
  13483. left = left.expression;
  13484. }
  13485. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  13486. return this.right.drop_side_effect_free(compressor);
  13487. }
  13488. return this;
  13489. });
  13490. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  13491. var consequent = this.consequent.drop_side_effect_free(compressor);
  13492. var alternative = this.alternative.drop_side_effect_free(compressor);
  13493. if (consequent === this.consequent && alternative === this.alternative)
  13494. return this;
  13495. if (!consequent)
  13496. return alternative ? make_node(AST_Binary, this, {
  13497. operator: "||",
  13498. left: this.condition,
  13499. right: alternative
  13500. }) : this.condition.drop_side_effect_free(compressor);
  13501. if (!alternative)
  13502. return make_node(AST_Binary, this, {
  13503. operator: "&&",
  13504. left: this.condition,
  13505. right: consequent
  13506. });
  13507. var node = this.clone();
  13508. node.consequent = consequent;
  13509. node.alternative = alternative;
  13510. return node;
  13511. });
  13512. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  13513. if (unary_side_effects.has(this.operator)) {
  13514. if (!this.expression.has_side_effects(compressor)) {
  13515. set_flag(this, WRITE_ONLY);
  13516. } else {
  13517. clear_flag(this, WRITE_ONLY);
  13518. }
  13519. return this;
  13520. }
  13521. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  13522. return null;
  13523. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13524. if (first_in_statement && expression && is_iife_call(expression)) {
  13525. if (expression === this.expression && this.operator == "!")
  13526. return this;
  13527. return expression.negate(compressor, first_in_statement);
  13528. }
  13529. return expression;
  13530. });
  13531. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  13532. const safe_access = this.is_declared(compressor)
  13533. || pure_prop_access_globals.has(this.name);
  13534. return safe_access ? null : this;
  13535. });
  13536. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  13537. var values = trim(this.properties, compressor, first_in_statement);
  13538. return values && make_sequence(this, values);
  13539. });
  13540. def_drop_side_effect_free(AST_ObjectProperty, function (compressor, first_in_statement) {
  13541. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  13542. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  13543. const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
  13544. if (key && value) {
  13545. return make_sequence(this, [key, value]);
  13546. }
  13547. return key || value;
  13548. });
  13549. def_drop_side_effect_free(AST_ConciseMethod, function () {
  13550. return this.computed_key() ? this.key : null;
  13551. });
  13552. def_drop_side_effect_free(AST_ObjectGetter, function () {
  13553. return this.computed_key() ? this.key : null;
  13554. });
  13555. def_drop_side_effect_free(AST_ObjectSetter, function () {
  13556. return this.computed_key() ? this.key : null;
  13557. });
  13558. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  13559. var values = trim(this.elements, compressor, first_in_statement);
  13560. return values && make_sequence(this, values);
  13561. });
  13562. def_drop_side_effect_free(AST_Dot, 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.optional && this.expression.may_throw_on_access(compressor)) {
  13567. return this;
  13568. }
  13569. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13570. });
  13571. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  13572. if (is_nullish_shortcircuited(this, compressor)) {
  13573. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13574. }
  13575. if (!this.optional && this.expression.may_throw_on_access(compressor)) {
  13576. return this;
  13577. }
  13578. var property = this.property.drop_side_effect_free(compressor);
  13579. if (property && this.optional) return this;
  13580. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13581. if (expression && property) return make_sequence(this, [expression, property]);
  13582. return expression || property;
  13583. });
  13584. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  13585. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13586. });
  13587. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  13588. var last = this.tail_node();
  13589. var expr = last.drop_side_effect_free(compressor);
  13590. if (expr === last)
  13591. return this;
  13592. var expressions = this.expressions.slice(0, -1);
  13593. if (expr)
  13594. expressions.push(expr);
  13595. if (!expressions.length) {
  13596. return make_node(AST_Number, this, { value: 0 });
  13597. }
  13598. return make_sequence(this, expressions);
  13599. });
  13600. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  13601. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13602. });
  13603. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  13604. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  13605. var values = trim(this.segments, compressor, first_in_statement);
  13606. return values && make_sequence(this, values);
  13607. });
  13608. /***********************************************************************
  13609. A JavaScript tokenizer / parser / beautifier / compressor.
  13610. https://github.com/mishoo/UglifyJS2
  13611. -------------------------------- (C) ---------------------------------
  13612. Author: Mihai Bazon
  13613. <mihai.bazon@gmail.com>
  13614. http://mihai.bazon.net/blog
  13615. Distributed under the BSD license:
  13616. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13617. Redistribution and use in source and binary forms, with or without
  13618. modification, are permitted provided that the following conditions
  13619. are met:
  13620. * Redistributions of source code must retain the above
  13621. copyright notice, this list of conditions and the following
  13622. disclaimer.
  13623. * Redistributions in binary form must reproduce the above
  13624. copyright notice, this list of conditions and the following
  13625. disclaimer in the documentation and/or other materials
  13626. provided with the distribution.
  13627. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13628. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13629. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13630. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13631. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13632. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13633. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13634. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13635. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13636. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13637. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13638. SUCH DAMAGE.
  13639. ***********************************************************************/
  13640. const r_keep_assign = /keep_assign/;
  13641. /** Drop unused variables from this scope */
  13642. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  13643. if (!compressor.option("unused")) return;
  13644. if (compressor.has_directive("use asm")) return;
  13645. if (!this.variables) return; // not really a scope (eg: AST_Class)
  13646. var self = this;
  13647. if (self.pinned()) return;
  13648. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  13649. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  13650. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  13651. if (node instanceof AST_Assign
  13652. && !node.logical
  13653. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  13654. ) {
  13655. return node.left;
  13656. }
  13657. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  13658. return node.expression;
  13659. }
  13660. };
  13661. var in_use_ids = new Map();
  13662. var fixed_ids = new Map();
  13663. if (self instanceof AST_Toplevel && compressor.top_retain) {
  13664. self.variables.forEach(function(def) {
  13665. if (compressor.top_retain(def)) {
  13666. in_use_ids.set(def.id, def);
  13667. }
  13668. });
  13669. }
  13670. var var_defs_by_id = new Map();
  13671. var initializations = new Map();
  13672. // pass 1: find out which symbols are directly used in
  13673. // this scope (not in nested scopes).
  13674. var scope = this;
  13675. var tw = new TreeWalker(function(node, descend) {
  13676. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  13677. node.argnames.forEach(function(argname) {
  13678. if (!(argname instanceof AST_SymbolDeclaration)) return;
  13679. var def = argname.definition();
  13680. in_use_ids.set(def.id, def);
  13681. });
  13682. }
  13683. if (node === self) return;
  13684. if (node instanceof AST_Class && node.has_side_effects(compressor)) {
  13685. if (node.is_self_referential()) {
  13686. descend();
  13687. } else {
  13688. node.visit_nondeferred_class_parts(tw);
  13689. }
  13690. }
  13691. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  13692. var node_def = node.name.definition();
  13693. const in_export = tw.parent() instanceof AST_Export;
  13694. if (in_export || !drop_funcs && scope === self) {
  13695. if (node_def.global) {
  13696. in_use_ids.set(node_def.id, node_def);
  13697. }
  13698. }
  13699. map_add(initializations, node_def.id, node);
  13700. return true; // don't go in nested scopes
  13701. }
  13702. // In the root scope, we drop things. In inner scopes, we just check for uses.
  13703. const in_root_scope = scope === self;
  13704. if (node instanceof AST_SymbolFunarg && in_root_scope) {
  13705. map_add(var_defs_by_id, node.definition().id, node);
  13706. }
  13707. if (node instanceof AST_Definitions && in_root_scope) {
  13708. const in_export = tw.parent() instanceof AST_Export;
  13709. node.definitions.forEach(function(def) {
  13710. if (def.name instanceof AST_SymbolVar) {
  13711. map_add(var_defs_by_id, def.name.definition().id, def);
  13712. }
  13713. if (in_export || !drop_vars) {
  13714. walk(def.name, node => {
  13715. if (node instanceof AST_SymbolDeclaration) {
  13716. const def = node.definition();
  13717. if (def.global) {
  13718. in_use_ids.set(def.id, def);
  13719. }
  13720. }
  13721. });
  13722. }
  13723. if (def.name instanceof AST_Destructuring) {
  13724. def.walk(tw);
  13725. }
  13726. if (def.name instanceof AST_SymbolDeclaration && def.value) {
  13727. var node_def = def.name.definition();
  13728. map_add(initializations, node_def.id, def.value);
  13729. if (!node_def.chained && def.name.fixed_value() === def.value) {
  13730. fixed_ids.set(node_def.id, def);
  13731. }
  13732. if (def.value.has_side_effects(compressor)) {
  13733. def.value.walk(tw);
  13734. }
  13735. }
  13736. });
  13737. return true;
  13738. }
  13739. return scan_ref_scoped(node, descend);
  13740. });
  13741. self.walk(tw);
  13742. // pass 2: for every used symbol we need to walk its
  13743. // initialization code to figure out if it uses other
  13744. // symbols (that may not be in_use).
  13745. tw = new TreeWalker(scan_ref_scoped);
  13746. in_use_ids.forEach(function (def) {
  13747. var init = initializations.get(def.id);
  13748. if (init) init.forEach(function(init) {
  13749. init.walk(tw);
  13750. });
  13751. });
  13752. // pass 3: we should drop declarations not in_use
  13753. var tt = new TreeTransformer(
  13754. function before(node, descend, in_list) {
  13755. var parent = tt.parent();
  13756. if (drop_vars) {
  13757. const sym = assign_as_unused(node);
  13758. if (sym instanceof AST_SymbolRef) {
  13759. var def = sym.definition();
  13760. var in_use = in_use_ids.has(def.id);
  13761. if (node instanceof AST_Assign) {
  13762. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  13763. const assignee = node.right.transform(tt);
  13764. if (!in_use && !assignee.has_side_effects(compressor) && !is_used_in_expression(tt)) {
  13765. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  13766. }
  13767. return maintain_this_binding(parent, node, assignee);
  13768. }
  13769. } else if (!in_use) {
  13770. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  13771. }
  13772. }
  13773. }
  13774. if (scope !== self) return;
  13775. var def;
  13776. if (node.name
  13777. && (node instanceof AST_ClassExpression
  13778. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  13779. || node instanceof AST_Function
  13780. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  13781. // any declarations with same name will overshadow
  13782. // name of this anonymous function and can therefore
  13783. // never be used anywhere
  13784. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  13785. }
  13786. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  13787. var trim =
  13788. !compressor.option("keep_fargs")
  13789. // Is this an IIFE that won't refer to its name?
  13790. || parent instanceof AST_Call
  13791. && parent.expression === node
  13792. && !node.pinned()
  13793. && (!node.name || node.name.unreferenced());
  13794. for (var a = node.argnames, i = a.length; --i >= 0;) {
  13795. var sym = a[i];
  13796. if (sym instanceof AST_Expansion) {
  13797. sym = sym.expression;
  13798. }
  13799. if (sym instanceof AST_DefaultAssign) {
  13800. sym = sym.left;
  13801. }
  13802. // Do not drop destructuring arguments.
  13803. // They constitute a type assertion of sorts
  13804. if (
  13805. !(sym instanceof AST_Destructuring)
  13806. && !in_use_ids.has(sym.definition().id)
  13807. ) {
  13808. set_flag(sym, UNUSED);
  13809. if (trim) {
  13810. a.pop();
  13811. }
  13812. } else {
  13813. trim = false;
  13814. }
  13815. }
  13816. }
  13817. if (node instanceof AST_DefClass && node !== self) {
  13818. const def = node.name.definition();
  13819. descend(node, this);
  13820. const keep_class = def.global && !drop_funcs || in_use_ids.has(def.id);
  13821. if (!keep_class) {
  13822. const kept = node.drop_side_effect_free(compressor);
  13823. if (kept == null) {
  13824. def.eliminated++;
  13825. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  13826. }
  13827. return kept;
  13828. }
  13829. return node;
  13830. }
  13831. if (node instanceof AST_Defun && node !== self) {
  13832. const def = node.name.definition();
  13833. const keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  13834. if (!keep) {
  13835. def.eliminated++;
  13836. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  13837. }
  13838. }
  13839. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  13840. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  13841. // place uninitialized names at the start
  13842. var body = [], head = [], tail = [];
  13843. // for unused names whose initialization has
  13844. // side effects, we can cascade the init. code
  13845. // into the next one, or next statement.
  13846. var side_effects = [];
  13847. node.definitions.forEach(function(def) {
  13848. if (def.value) def.value = def.value.transform(tt);
  13849. var is_destructure = def.name instanceof AST_Destructuring;
  13850. var sym = is_destructure
  13851. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  13852. : def.name.definition();
  13853. if (drop_block && sym.global) return tail.push(def);
  13854. if (!(drop_vars || drop_block)
  13855. || is_destructure
  13856. && (def.name.names.length
  13857. || def.name.is_array
  13858. || compressor.option("pure_getters") != true)
  13859. || in_use_ids.has(sym.id)
  13860. ) {
  13861. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  13862. def.value = def.value.drop_side_effect_free(compressor);
  13863. }
  13864. if (def.name instanceof AST_SymbolVar) {
  13865. var var_defs = var_defs_by_id.get(sym.id);
  13866. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  13867. if (def.value) {
  13868. var ref = make_node(AST_SymbolRef, def.name, def.name);
  13869. sym.references.push(ref);
  13870. var assign = make_node(AST_Assign, def, {
  13871. operator: "=",
  13872. logical: false,
  13873. left: ref,
  13874. right: def.value
  13875. });
  13876. if (fixed_ids.get(sym.id) === def) {
  13877. fixed_ids.set(sym.id, assign);
  13878. }
  13879. side_effects.push(assign.transform(tt));
  13880. }
  13881. remove(var_defs, def);
  13882. sym.eliminated++;
  13883. return;
  13884. }
  13885. }
  13886. if (def.value) {
  13887. if (side_effects.length > 0) {
  13888. if (tail.length > 0) {
  13889. side_effects.push(def.value);
  13890. def.value = make_sequence(def.value, side_effects);
  13891. } else {
  13892. body.push(make_node(AST_SimpleStatement, node, {
  13893. body: make_sequence(node, side_effects)
  13894. }));
  13895. }
  13896. side_effects = [];
  13897. }
  13898. tail.push(def);
  13899. } else {
  13900. head.push(def);
  13901. }
  13902. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  13903. var value = def.value && def.value.drop_side_effect_free(compressor);
  13904. if (value) side_effects.push(value);
  13905. def.value = null;
  13906. head.push(def);
  13907. } else {
  13908. var value = def.value && def.value.drop_side_effect_free(compressor);
  13909. if (value) {
  13910. side_effects.push(value);
  13911. }
  13912. sym.eliminated++;
  13913. }
  13914. });
  13915. if (head.length > 0 || tail.length > 0) {
  13916. node.definitions = head.concat(tail);
  13917. body.push(node);
  13918. }
  13919. if (side_effects.length > 0) {
  13920. body.push(make_node(AST_SimpleStatement, node, {
  13921. body: make_sequence(node, side_effects)
  13922. }));
  13923. }
  13924. switch (body.length) {
  13925. case 0:
  13926. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  13927. case 1:
  13928. return body[0];
  13929. default:
  13930. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, { body });
  13931. }
  13932. }
  13933. // certain combination of unused name + side effect leads to:
  13934. // https://github.com/mishoo/UglifyJS2/issues/44
  13935. // https://github.com/mishoo/UglifyJS2/issues/1830
  13936. // https://github.com/mishoo/UglifyJS2/issues/1838
  13937. // that's an invalid AST.
  13938. // We fix it at this stage by moving the `var` outside the `for`.
  13939. if (node instanceof AST_For) {
  13940. descend(node, this);
  13941. var block;
  13942. if (node.init instanceof AST_BlockStatement) {
  13943. block = node.init;
  13944. node.init = block.body.pop();
  13945. block.body.push(node);
  13946. }
  13947. if (node.init instanceof AST_SimpleStatement) {
  13948. node.init = node.init.body;
  13949. } else if (is_empty(node.init)) {
  13950. node.init = null;
  13951. }
  13952. return !block ? node : in_list ? MAP.splice(block.body) : block;
  13953. }
  13954. if (node instanceof AST_LabeledStatement
  13955. && node.body instanceof AST_For
  13956. ) {
  13957. descend(node, this);
  13958. if (node.body instanceof AST_BlockStatement) {
  13959. var block = node.body;
  13960. node.body = block.body.pop();
  13961. block.body.push(node);
  13962. return in_list ? MAP.splice(block.body) : block;
  13963. }
  13964. return node;
  13965. }
  13966. if (node instanceof AST_BlockStatement) {
  13967. descend(node, this);
  13968. if (in_list && node.body.every(can_be_evicted_from_block)) {
  13969. return MAP.splice(node.body);
  13970. }
  13971. return node;
  13972. }
  13973. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  13974. const save_scope = scope;
  13975. scope = node;
  13976. descend(node, this);
  13977. scope = save_scope;
  13978. return node;
  13979. }
  13980. },
  13981. function after(node, in_list) {
  13982. if (node instanceof AST_Sequence) {
  13983. switch (node.expressions.length) {
  13984. case 0: return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  13985. case 1: return node.expressions[0];
  13986. }
  13987. }
  13988. }
  13989. );
  13990. self.transform(tt);
  13991. function scan_ref_scoped(node, descend) {
  13992. var node_def;
  13993. const sym = assign_as_unused(node);
  13994. if (sym instanceof AST_SymbolRef
  13995. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  13996. && self.variables.get(sym.name) === (node_def = sym.definition())
  13997. ) {
  13998. if (node instanceof AST_Assign) {
  13999. node.right.walk(tw);
  14000. if (!node_def.chained && node.left.fixed_value() === node.right) {
  14001. fixed_ids.set(node_def.id, node);
  14002. }
  14003. }
  14004. return true;
  14005. }
  14006. if (node instanceof AST_SymbolRef) {
  14007. node_def = node.definition();
  14008. if (!in_use_ids.has(node_def.id)) {
  14009. in_use_ids.set(node_def.id, node_def);
  14010. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  14011. const redef = node_def.scope.is_block_scope()
  14012. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  14013. if (redef) in_use_ids.set(redef.id, redef);
  14014. }
  14015. }
  14016. return true;
  14017. }
  14018. if (node instanceof AST_Class) {
  14019. descend();
  14020. return true;
  14021. }
  14022. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  14023. var save_scope = scope;
  14024. scope = node;
  14025. descend();
  14026. scope = save_scope;
  14027. return true;
  14028. }
  14029. }
  14030. });
  14031. /**
  14032. * Check if a node may be used by the expression it's in
  14033. * void (0, 1, {node}, 2) -> false
  14034. * console.log(0, {node}) -> true
  14035. */
  14036. function is_used_in_expression(tw) {
  14037. for (let p = -1, node, parent; node = tw.parent(p), parent = tw.parent(p + 1); p++) {
  14038. if (parent instanceof AST_Sequence) {
  14039. const nth_expression = parent.expressions.indexOf(node);
  14040. if (nth_expression !== parent.expressions.length - 1) {
  14041. // Detect (0, x.noThis)() constructs
  14042. const grandparent = tw.parent(p + 2);
  14043. if (
  14044. parent.expressions.length > 2
  14045. || parent.expressions.length === 1
  14046. || !requires_sequence_to_maintain_binding(grandparent, parent, parent.expressions[1])
  14047. ) {
  14048. return false;
  14049. }
  14050. return true;
  14051. } else {
  14052. continue;
  14053. }
  14054. }
  14055. if (parent instanceof AST_Unary) {
  14056. const op = parent.operator;
  14057. if (op === "void") {
  14058. return false;
  14059. }
  14060. if (op === "typeof" || op === "+" || op === "-" || op === "!" || op === "~") {
  14061. continue;
  14062. }
  14063. }
  14064. return true;
  14065. }
  14066. return true;
  14067. }
  14068. /***********************************************************************
  14069. A JavaScript tokenizer / parser / beautifier / compressor.
  14070. https://github.com/mishoo/UglifyJS2
  14071. -------------------------------- (C) ---------------------------------
  14072. Author: Mihai Bazon
  14073. <mihai.bazon@gmail.com>
  14074. http://mihai.bazon.net/blog
  14075. Distributed under the BSD license:
  14076. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14077. Redistribution and use in source and binary forms, with or without
  14078. modification, are permitted provided that the following conditions
  14079. are met:
  14080. * Redistributions of source code must retain the above
  14081. copyright notice, this list of conditions and the following
  14082. disclaimer.
  14083. * Redistributions in binary form must reproduce the above
  14084. copyright notice, this list of conditions and the following
  14085. disclaimer in the documentation and/or other materials
  14086. provided with the distribution.
  14087. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14088. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14089. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14090. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14091. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14092. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14093. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14094. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14095. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14096. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14097. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14098. SUCH DAMAGE.
  14099. ***********************************************************************/
  14100. /**
  14101. * Define the method AST_Node#reduce_vars, which goes through the AST in
  14102. * execution order to perform basic flow analysis
  14103. */
  14104. function def_reduce_vars(node, func) {
  14105. node.DEFMETHOD("reduce_vars", func);
  14106. }
  14107. def_reduce_vars(AST_Node, noop);
  14108. /** Clear definition properties */
  14109. function reset_def(compressor, def) {
  14110. def.assignments = 0;
  14111. def.chained = false;
  14112. def.direct_access = false;
  14113. def.escaped = 0;
  14114. def.recursive_refs = 0;
  14115. def.references = [];
  14116. def.single_use = undefined;
  14117. if (
  14118. def.scope.pinned()
  14119. || (def.orig[0] instanceof AST_SymbolFunarg && def.scope.uses_arguments)
  14120. ) {
  14121. def.fixed = false;
  14122. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  14123. def.fixed = def.init;
  14124. } else {
  14125. def.fixed = false;
  14126. }
  14127. }
  14128. function reset_variables(tw, compressor, node) {
  14129. node.variables.forEach(function(def) {
  14130. reset_def(compressor, def);
  14131. if (def.fixed === null) {
  14132. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  14133. mark(tw, def, true);
  14134. } else if (def.fixed) {
  14135. tw.loop_ids.set(def.id, tw.in_loop);
  14136. mark(tw, def, true);
  14137. }
  14138. });
  14139. }
  14140. function reset_block_variables(compressor, node) {
  14141. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  14142. reset_def(compressor, def);
  14143. });
  14144. }
  14145. function push(tw) {
  14146. tw.safe_ids = Object.create(tw.safe_ids);
  14147. }
  14148. function pop(tw) {
  14149. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  14150. }
  14151. function mark(tw, def, safe) {
  14152. tw.safe_ids[def.id] = safe;
  14153. }
  14154. function safe_to_read(tw, def) {
  14155. if (def.single_use == "m") return false;
  14156. if (tw.safe_ids[def.id]) {
  14157. if (def.fixed == null) {
  14158. var orig = def.orig[0];
  14159. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  14160. def.fixed = make_node(AST_Undefined, orig);
  14161. }
  14162. return true;
  14163. }
  14164. return def.fixed instanceof AST_Defun;
  14165. }
  14166. function safe_to_assign(tw, def, scope, value) {
  14167. if (def.fixed === undefined) return true;
  14168. let def_safe_ids;
  14169. if (def.fixed === null
  14170. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  14171. ) {
  14172. def_safe_ids[def.id] = false;
  14173. tw.defs_to_safe_ids.delete(def.id);
  14174. return true;
  14175. }
  14176. if (!HOP(tw.safe_ids, def.id)) return false;
  14177. if (!safe_to_read(tw, def)) return false;
  14178. if (def.fixed === false) return false;
  14179. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  14180. if (def.fixed instanceof AST_Defun) {
  14181. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  14182. }
  14183. return def.orig.every((sym) => {
  14184. return !(sym instanceof AST_SymbolConst
  14185. || sym instanceof AST_SymbolDefun
  14186. || sym instanceof AST_SymbolLambda);
  14187. });
  14188. }
  14189. function ref_once(tw, compressor, def) {
  14190. return compressor.option("unused")
  14191. && !def.scope.pinned()
  14192. && def.references.length - def.recursive_refs == 1
  14193. && tw.loop_ids.get(def.id) === tw.in_loop;
  14194. }
  14195. function is_immutable(value) {
  14196. if (!value) return false;
  14197. return value.is_constant()
  14198. || value instanceof AST_Lambda
  14199. || value instanceof AST_This;
  14200. }
  14201. // A definition "escapes" when its value can leave the point of use.
  14202. // Example: `a = b || c`
  14203. // In this example, "b" and "c" are escaping, because they're going into "a"
  14204. //
  14205. // def.escaped is != 0 when it escapes.
  14206. //
  14207. // When greater than 1, it means that N chained properties will be read off
  14208. // of that def before an escape occurs. This is useful for evaluating
  14209. // property accesses, where you need to know when to stop.
  14210. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  14211. var parent = tw.parent(level);
  14212. if (value) {
  14213. if (value.is_constant()) return;
  14214. if (value instanceof AST_ClassExpression) return;
  14215. }
  14216. if (
  14217. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  14218. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  14219. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  14220. || parent instanceof AST_VarDef && node === parent.value
  14221. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  14222. ) {
  14223. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  14224. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  14225. return;
  14226. } else if (
  14227. parent instanceof AST_Array
  14228. || parent instanceof AST_Await
  14229. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  14230. || parent instanceof AST_Conditional && node !== parent.condition
  14231. || parent instanceof AST_Expansion
  14232. || parent instanceof AST_Sequence && node === parent.tail_node()
  14233. ) {
  14234. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  14235. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  14236. var obj = tw.parent(level + 1);
  14237. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  14238. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  14239. value = read_property(value, parent.property);
  14240. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  14241. if (value) return;
  14242. }
  14243. if (level > 0) return;
  14244. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  14245. if (parent instanceof AST_SimpleStatement) return;
  14246. d.direct_access = true;
  14247. }
  14248. const suppress = node => walk(node, node => {
  14249. if (!(node instanceof AST_Symbol)) return;
  14250. var d = node.definition();
  14251. if (!d) return;
  14252. if (node instanceof AST_SymbolRef) d.references.push(node);
  14253. d.fixed = false;
  14254. });
  14255. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  14256. push(tw);
  14257. reset_variables(tw, compressor, this);
  14258. descend();
  14259. pop(tw);
  14260. return true;
  14261. });
  14262. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  14263. var node = this;
  14264. if (node.left instanceof AST_Destructuring) {
  14265. suppress(node.left);
  14266. return;
  14267. }
  14268. const finish_walk = () => {
  14269. if (node.logical) {
  14270. node.left.walk(tw);
  14271. push(tw);
  14272. node.right.walk(tw);
  14273. pop(tw);
  14274. return true;
  14275. }
  14276. };
  14277. var sym = node.left;
  14278. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  14279. var def = sym.definition();
  14280. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  14281. def.assignments++;
  14282. if (!safe) return finish_walk();
  14283. var fixed = def.fixed;
  14284. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  14285. var eq = node.operator == "=";
  14286. var value = eq ? node.right : node;
  14287. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  14288. def.references.push(sym);
  14289. if (!node.logical) {
  14290. if (!eq) def.chained = true;
  14291. def.fixed = eq ? function() {
  14292. return node.right;
  14293. } : function() {
  14294. return make_node(AST_Binary, node, {
  14295. operator: node.operator.slice(0, -1),
  14296. left: fixed instanceof AST_Node ? fixed : fixed(),
  14297. right: node.right
  14298. });
  14299. };
  14300. }
  14301. if (node.logical) {
  14302. mark(tw, def, false);
  14303. push(tw);
  14304. node.right.walk(tw);
  14305. pop(tw);
  14306. return true;
  14307. }
  14308. mark(tw, def, false);
  14309. node.right.walk(tw);
  14310. mark(tw, def, true);
  14311. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  14312. return true;
  14313. });
  14314. def_reduce_vars(AST_Binary, function(tw) {
  14315. if (!lazy_op.has(this.operator)) return;
  14316. this.left.walk(tw);
  14317. push(tw);
  14318. this.right.walk(tw);
  14319. pop(tw);
  14320. return true;
  14321. });
  14322. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  14323. reset_block_variables(compressor, this);
  14324. });
  14325. def_reduce_vars(AST_Case, function(tw) {
  14326. push(tw);
  14327. this.expression.walk(tw);
  14328. pop(tw);
  14329. push(tw);
  14330. walk_body(this, tw);
  14331. pop(tw);
  14332. return true;
  14333. });
  14334. def_reduce_vars(AST_Class, function(tw, descend) {
  14335. clear_flag(this, INLINED);
  14336. push(tw);
  14337. descend();
  14338. pop(tw);
  14339. return true;
  14340. });
  14341. def_reduce_vars(AST_ClassStaticBlock, function(tw, descend, compressor) {
  14342. reset_block_variables(compressor, this);
  14343. });
  14344. def_reduce_vars(AST_Conditional, function(tw) {
  14345. this.condition.walk(tw);
  14346. push(tw);
  14347. this.consequent.walk(tw);
  14348. pop(tw);
  14349. push(tw);
  14350. this.alternative.walk(tw);
  14351. pop(tw);
  14352. return true;
  14353. });
  14354. def_reduce_vars(AST_Chain, function(tw, descend) {
  14355. // Chains' conditions apply left-to-right, cumulatively.
  14356. // If we walk normally we don't go in that order because we would pop before pushing again
  14357. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  14358. // Then we pop everything when they are done being walked.
  14359. const safe_ids = tw.safe_ids;
  14360. descend();
  14361. // Unroll back to start
  14362. tw.safe_ids = safe_ids;
  14363. return true;
  14364. });
  14365. def_reduce_vars(AST_Call, function (tw) {
  14366. this.expression.walk(tw);
  14367. if (this.optional) {
  14368. // Never pop -- it's popped at AST_Chain above
  14369. push(tw);
  14370. }
  14371. for (const arg of this.args) arg.walk(tw);
  14372. return true;
  14373. });
  14374. def_reduce_vars(AST_PropAccess, function (tw) {
  14375. if (!this.optional) return;
  14376. this.expression.walk(tw);
  14377. // Never pop -- it's popped at AST_Chain above
  14378. push(tw);
  14379. if (this.property instanceof AST_Node) this.property.walk(tw);
  14380. return true;
  14381. });
  14382. def_reduce_vars(AST_Default, function(tw, descend) {
  14383. push(tw);
  14384. descend();
  14385. pop(tw);
  14386. return true;
  14387. });
  14388. function mark_lambda(tw, descend, compressor) {
  14389. clear_flag(this, INLINED);
  14390. push(tw);
  14391. reset_variables(tw, compressor, this);
  14392. var iife;
  14393. if (!this.name
  14394. && !this.uses_arguments
  14395. && !this.pinned()
  14396. && (iife = tw.parent()) instanceof AST_Call
  14397. && iife.expression === this
  14398. && !iife.args.some(arg => arg instanceof AST_Expansion)
  14399. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  14400. ) {
  14401. // Virtually turn IIFE parameters into variable definitions:
  14402. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  14403. // So existing transformation rules can work on them.
  14404. this.argnames.forEach((arg, i) => {
  14405. if (!arg.definition) return;
  14406. var d = arg.definition();
  14407. // Avoid setting fixed when there's more than one origin for a variable value
  14408. if (d.orig.length > 1) return;
  14409. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  14410. d.fixed = function() {
  14411. return iife.args[i] || make_node(AST_Undefined, iife);
  14412. };
  14413. tw.loop_ids.set(d.id, tw.in_loop);
  14414. mark(tw, d, true);
  14415. } else {
  14416. d.fixed = false;
  14417. }
  14418. });
  14419. }
  14420. descend();
  14421. pop(tw);
  14422. handle_defined_after_hoist(this);
  14423. return true;
  14424. }
  14425. /**
  14426. * It's possible for a hoisted function to use something that's not defined yet. Example:
  14427. *
  14428. * hoisted();
  14429. * var defined_after = true;
  14430. * function hoisted() {
  14431. * // use defined_after
  14432. * }
  14433. *
  14434. * This function is called on the parent to handle this issue.
  14435. */
  14436. function handle_defined_after_hoist(parent) {
  14437. const defuns = [];
  14438. walk(parent, node => {
  14439. if (node === parent) return;
  14440. if (node instanceof AST_Defun) defuns.push(node);
  14441. if (
  14442. node instanceof AST_Scope
  14443. || node instanceof AST_SimpleStatement
  14444. ) return true;
  14445. });
  14446. const symbols_of_interest = new Set();
  14447. const defuns_of_interest = new Set();
  14448. const potential_conflicts = [];
  14449. for (const defun of defuns) {
  14450. const fname_def = defun.name.definition();
  14451. const found_self_ref_in_other_defuns = defuns.some(
  14452. d => d !== defun && d.enclosed.indexOf(fname_def) !== -1
  14453. );
  14454. for (const def of defun.enclosed) {
  14455. if (
  14456. def.fixed === false
  14457. || def === fname_def
  14458. || def.scope.get_defun_scope() !== parent
  14459. ) {
  14460. continue;
  14461. }
  14462. // defun is hoisted, so always safe
  14463. if (
  14464. def.assignments === 0
  14465. && def.orig.length === 1
  14466. && def.orig[0] instanceof AST_SymbolDefun
  14467. ) {
  14468. continue;
  14469. }
  14470. if (found_self_ref_in_other_defuns) {
  14471. def.fixed = false;
  14472. continue;
  14473. }
  14474. // for the slower checks below this loop
  14475. potential_conflicts.push({ defun, def, fname_def });
  14476. symbols_of_interest.add(def.id);
  14477. symbols_of_interest.add(fname_def.id);
  14478. defuns_of_interest.add(defun);
  14479. }
  14480. }
  14481. // linearize all symbols, and locate defs that are read after the defun
  14482. if (potential_conflicts.length) {
  14483. // All "symbols of interest", that is, defuns or defs, that we found.
  14484. // These are placed in order so we can check which is after which.
  14485. const found_symbols = [];
  14486. // Indices of `found_symbols` which are writes
  14487. const found_symbol_writes = new Set();
  14488. // Defun ranges are recorded because we don't care if a function uses the def internally
  14489. const defun_ranges = new Map();
  14490. let tw;
  14491. parent.walk((tw = new TreeWalker((node, descend) => {
  14492. if (node instanceof AST_Defun && defuns_of_interest.has(node)) {
  14493. const start = found_symbols.length;
  14494. descend();
  14495. const end = found_symbols.length;
  14496. defun_ranges.set(node, { start, end });
  14497. return true;
  14498. }
  14499. // if we found a defun on the list, mark IN_DEFUN=id and descend
  14500. if (node instanceof AST_Symbol && node.thedef) {
  14501. const id = node.definition().id;
  14502. if (symbols_of_interest.has(id)) {
  14503. if (node instanceof AST_SymbolDeclaration || is_lhs(node, tw)) {
  14504. found_symbol_writes.add(found_symbols.length);
  14505. }
  14506. found_symbols.push(id);
  14507. }
  14508. }
  14509. })));
  14510. for (const { def, defun, fname_def } of potential_conflicts) {
  14511. const defun_range = defun_ranges.get(defun);
  14512. // find the index in `found_symbols`, with some special rules:
  14513. const find = (sym_id, starting_at = 0, must_be_write = false) => {
  14514. let index = starting_at;
  14515. for (;;) {
  14516. index = found_symbols.indexOf(sym_id, index);
  14517. if (index === -1) {
  14518. break;
  14519. } else if (index >= defun_range.start && index < defun_range.end) {
  14520. index = defun_range.end;
  14521. continue;
  14522. } else if (must_be_write && !found_symbol_writes.has(index)) {
  14523. index++;
  14524. continue;
  14525. } else {
  14526. break;
  14527. }
  14528. }
  14529. return index;
  14530. };
  14531. const read_defun_at = find(fname_def.id);
  14532. const wrote_def_at = find(def.id, read_defun_at + 1, true);
  14533. const wrote_def_after_reading_defun = read_defun_at != -1 && wrote_def_at != -1 && wrote_def_at > read_defun_at;
  14534. if (wrote_def_after_reading_defun) {
  14535. def.fixed = false;
  14536. }
  14537. }
  14538. }
  14539. }
  14540. def_reduce_vars(AST_Lambda, mark_lambda);
  14541. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  14542. reset_block_variables(compressor, this);
  14543. const saved_loop = tw.in_loop;
  14544. tw.in_loop = this;
  14545. push(tw);
  14546. this.body.walk(tw);
  14547. if (has_break_or_continue(this)) {
  14548. pop(tw);
  14549. push(tw);
  14550. }
  14551. this.condition.walk(tw);
  14552. pop(tw);
  14553. tw.in_loop = saved_loop;
  14554. return true;
  14555. });
  14556. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  14557. reset_block_variables(compressor, this);
  14558. if (this.init) this.init.walk(tw);
  14559. const saved_loop = tw.in_loop;
  14560. tw.in_loop = this;
  14561. push(tw);
  14562. if (this.condition) this.condition.walk(tw);
  14563. this.body.walk(tw);
  14564. if (this.step) {
  14565. if (has_break_or_continue(this)) {
  14566. pop(tw);
  14567. push(tw);
  14568. }
  14569. this.step.walk(tw);
  14570. }
  14571. pop(tw);
  14572. tw.in_loop = saved_loop;
  14573. return true;
  14574. });
  14575. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  14576. reset_block_variables(compressor, this);
  14577. suppress(this.init);
  14578. this.object.walk(tw);
  14579. const saved_loop = tw.in_loop;
  14580. tw.in_loop = this;
  14581. push(tw);
  14582. this.body.walk(tw);
  14583. pop(tw);
  14584. tw.in_loop = saved_loop;
  14585. return true;
  14586. });
  14587. def_reduce_vars(AST_If, function(tw) {
  14588. this.condition.walk(tw);
  14589. push(tw);
  14590. this.body.walk(tw);
  14591. pop(tw);
  14592. if (this.alternative) {
  14593. push(tw);
  14594. this.alternative.walk(tw);
  14595. pop(tw);
  14596. }
  14597. return true;
  14598. });
  14599. def_reduce_vars(AST_LabeledStatement, function(tw) {
  14600. push(tw);
  14601. this.body.walk(tw);
  14602. pop(tw);
  14603. return true;
  14604. });
  14605. def_reduce_vars(AST_SymbolCatch, function() {
  14606. this.definition().fixed = false;
  14607. });
  14608. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  14609. var d = this.definition();
  14610. d.references.push(this);
  14611. if (d.references.length == 1
  14612. && !d.fixed
  14613. && d.orig[0] instanceof AST_SymbolDefun) {
  14614. tw.loop_ids.set(d.id, tw.in_loop);
  14615. }
  14616. var fixed_value;
  14617. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  14618. d.fixed = false;
  14619. } else if (d.fixed) {
  14620. fixed_value = this.fixed_value();
  14621. if (
  14622. fixed_value instanceof AST_Lambda
  14623. && is_recursive_ref(tw, d)
  14624. ) {
  14625. d.recursive_refs++;
  14626. } else if (fixed_value
  14627. && !compressor.exposed(d)
  14628. && ref_once(tw, compressor, d)
  14629. ) {
  14630. d.single_use =
  14631. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  14632. || fixed_value instanceof AST_Class
  14633. || d.scope === this.scope && fixed_value.is_constant_expression();
  14634. } else {
  14635. d.single_use = false;
  14636. }
  14637. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  14638. if (d.single_use) {
  14639. d.single_use = "m";
  14640. } else {
  14641. d.fixed = false;
  14642. }
  14643. }
  14644. }
  14645. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  14646. });
  14647. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  14648. this.globals.forEach(function(def) {
  14649. reset_def(compressor, def);
  14650. });
  14651. reset_variables(tw, compressor, this);
  14652. descend();
  14653. handle_defined_after_hoist(this);
  14654. return true;
  14655. });
  14656. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  14657. reset_block_variables(compressor, this);
  14658. push(tw);
  14659. this.body.walk(tw);
  14660. pop(tw);
  14661. if (this.bcatch) {
  14662. push(tw);
  14663. this.bcatch.walk(tw);
  14664. pop(tw);
  14665. }
  14666. if (this.bfinally) this.bfinally.walk(tw);
  14667. return true;
  14668. });
  14669. def_reduce_vars(AST_Unary, function(tw) {
  14670. var node = this;
  14671. if (node.operator !== "++" && node.operator !== "--") return;
  14672. var exp = node.expression;
  14673. if (!(exp instanceof AST_SymbolRef)) return;
  14674. var def = exp.definition();
  14675. var safe = safe_to_assign(tw, def, exp.scope, true);
  14676. def.assignments++;
  14677. if (!safe) return;
  14678. var fixed = def.fixed;
  14679. if (!fixed) return;
  14680. def.references.push(exp);
  14681. def.chained = true;
  14682. def.fixed = function() {
  14683. return make_node(AST_Binary, node, {
  14684. operator: node.operator.slice(0, -1),
  14685. left: make_node(AST_UnaryPrefix, node, {
  14686. operator: "+",
  14687. expression: fixed instanceof AST_Node ? fixed : fixed()
  14688. }),
  14689. right: make_node(AST_Number, node, {
  14690. value: 1
  14691. })
  14692. });
  14693. };
  14694. mark(tw, def, true);
  14695. return true;
  14696. });
  14697. def_reduce_vars(AST_VarDef, function(tw, descend) {
  14698. var node = this;
  14699. if (node.name instanceof AST_Destructuring) {
  14700. suppress(node.name);
  14701. return;
  14702. }
  14703. var d = node.name.definition();
  14704. if (node.value) {
  14705. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  14706. d.fixed = function() {
  14707. return node.value;
  14708. };
  14709. tw.loop_ids.set(d.id, tw.in_loop);
  14710. mark(tw, d, false);
  14711. descend();
  14712. mark(tw, d, true);
  14713. return true;
  14714. } else {
  14715. d.fixed = false;
  14716. }
  14717. }
  14718. });
  14719. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  14720. reset_block_variables(compressor, this);
  14721. const saved_loop = tw.in_loop;
  14722. tw.in_loop = this;
  14723. push(tw);
  14724. descend();
  14725. pop(tw);
  14726. tw.in_loop = saved_loop;
  14727. return true;
  14728. });
  14729. /***********************************************************************
  14730. A JavaScript tokenizer / parser / beautifier / compressor.
  14731. https://github.com/mishoo/UglifyJS2
  14732. -------------------------------- (C) ---------------------------------
  14733. Author: Mihai Bazon
  14734. <mihai.bazon@gmail.com>
  14735. http://mihai.bazon.net/blog
  14736. Distributed under the BSD license:
  14737. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14738. Redistribution and use in source and binary forms, with or without
  14739. modification, are permitted provided that the following conditions
  14740. are met:
  14741. * Redistributions of source code must retain the above
  14742. copyright notice, this list of conditions and the following
  14743. disclaimer.
  14744. * Redistributions in binary form must reproduce the above
  14745. copyright notice, this list of conditions and the following
  14746. disclaimer in the documentation and/or other materials
  14747. provided with the distribution.
  14748. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14749. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14750. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14751. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14752. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14753. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14754. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14755. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14756. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14757. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14758. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14759. SUCH DAMAGE.
  14760. ***********************************************************************/
  14761. function loop_body(x) {
  14762. if (x instanceof AST_IterationStatement) {
  14763. return x.body instanceof AST_BlockStatement ? x.body : x;
  14764. }
  14765. return x;
  14766. }
  14767. function is_lhs_read_only(lhs) {
  14768. if (lhs instanceof AST_This) return true;
  14769. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  14770. if (lhs instanceof AST_PropAccess) {
  14771. lhs = lhs.expression;
  14772. if (lhs instanceof AST_SymbolRef) {
  14773. if (lhs.is_immutable()) return false;
  14774. lhs = lhs.fixed_value();
  14775. }
  14776. if (!lhs) return true;
  14777. if (lhs instanceof AST_RegExp) return false;
  14778. if (lhs instanceof AST_Constant) return true;
  14779. return is_lhs_read_only(lhs);
  14780. }
  14781. return false;
  14782. }
  14783. /** var a = 1 --> var a*/
  14784. function remove_initializers(var_statement) {
  14785. var decls = [];
  14786. var_statement.definitions.forEach(function(def) {
  14787. if (def.name instanceof AST_SymbolDeclaration) {
  14788. def.value = null;
  14789. decls.push(def);
  14790. } else {
  14791. def.declarations_as_names().forEach(name => {
  14792. decls.push(make_node(AST_VarDef, def, {
  14793. name,
  14794. value: null
  14795. }));
  14796. });
  14797. }
  14798. });
  14799. return decls.length ? make_node(AST_Var, var_statement, { definitions: decls }) : null;
  14800. }
  14801. /** Called on code which we know is unreachable, to keep elements that affect outside of it. */
  14802. function trim_unreachable_code(compressor, stat, target) {
  14803. walk(stat, node => {
  14804. if (node instanceof AST_Var) {
  14805. const no_initializers = remove_initializers(node);
  14806. if (no_initializers) target.push(no_initializers);
  14807. return true;
  14808. }
  14809. if (
  14810. node instanceof AST_Defun
  14811. && (node === stat || !compressor.has_directive("use strict"))
  14812. ) {
  14813. target.push(node === stat ? node : make_node(AST_Var, node, {
  14814. definitions: [
  14815. make_node(AST_VarDef, node, {
  14816. name: make_node(AST_SymbolVar, node.name, node.name),
  14817. value: null
  14818. })
  14819. ]
  14820. }));
  14821. return true;
  14822. }
  14823. if (node instanceof AST_Export || node instanceof AST_Import) {
  14824. target.push(node);
  14825. return true;
  14826. }
  14827. if (node instanceof AST_Scope) {
  14828. return true;
  14829. }
  14830. });
  14831. }
  14832. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  14833. function tighten_body(statements, compressor) {
  14834. const nearest_scope = compressor.find_scope();
  14835. const defun_scope = nearest_scope.get_defun_scope();
  14836. const { in_loop, in_try } = find_loop_scope_try();
  14837. var CHANGED, max_iter = 10;
  14838. do {
  14839. CHANGED = false;
  14840. eliminate_spurious_blocks(statements);
  14841. if (compressor.option("dead_code")) {
  14842. eliminate_dead_code(statements, compressor);
  14843. }
  14844. if (compressor.option("if_return")) {
  14845. handle_if_return(statements, compressor);
  14846. }
  14847. if (compressor.sequences_limit > 0) {
  14848. sequencesize(statements, compressor);
  14849. sequencesize_2(statements, compressor);
  14850. }
  14851. if (compressor.option("join_vars")) {
  14852. join_consecutive_vars(statements);
  14853. }
  14854. if (compressor.option("collapse_vars")) {
  14855. collapse(statements, compressor);
  14856. }
  14857. } while (CHANGED && max_iter-- > 0);
  14858. function find_loop_scope_try() {
  14859. var node = compressor.self(), level = 0, in_loop = false, in_try = false;
  14860. do {
  14861. if (node instanceof AST_IterationStatement) {
  14862. in_loop = true;
  14863. } else if (node instanceof AST_Scope) {
  14864. break;
  14865. } else if (node instanceof AST_TryBlock) {
  14866. in_try = true;
  14867. }
  14868. } while (node = compressor.parent(level++));
  14869. return { in_loop, in_try };
  14870. }
  14871. // Search from right to left for assignment-like expressions:
  14872. // - `var a = x;`
  14873. // - `a = x;`
  14874. // - `++a`
  14875. // For each candidate, scan from left to right for first usage, then try
  14876. // to fold assignment into the site for compression.
  14877. // Will not attempt to collapse assignments into or past code blocks
  14878. // which are not sequentially executed, e.g. loops and conditionals.
  14879. function collapse(statements, compressor) {
  14880. if (nearest_scope.pinned() || defun_scope.pinned())
  14881. return statements;
  14882. var args;
  14883. var candidates = [];
  14884. var stat_index = statements.length;
  14885. var scanner = new TreeTransformer(function (node) {
  14886. if (abort)
  14887. return node;
  14888. // Skip nodes before `candidate` as quickly as possible
  14889. if (!hit) {
  14890. if (node !== hit_stack[hit_index])
  14891. return node;
  14892. hit_index++;
  14893. if (hit_index < hit_stack.length)
  14894. return handle_custom_scan_order(node);
  14895. hit = true;
  14896. stop_after = find_stop(node, 0);
  14897. if (stop_after === node)
  14898. abort = true;
  14899. return node;
  14900. }
  14901. // Stop immediately if these node types are encountered
  14902. var parent = scanner.parent();
  14903. if (node instanceof AST_Assign
  14904. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  14905. || node instanceof AST_Await
  14906. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  14907. ||
  14908. (node instanceof AST_Call || node instanceof AST_PropAccess)
  14909. && node.optional
  14910. || node instanceof AST_Debugger
  14911. || node instanceof AST_Destructuring
  14912. || node instanceof AST_Expansion
  14913. && node.expression instanceof AST_Symbol
  14914. && (
  14915. node.expression instanceof AST_This
  14916. || node.expression.definition().references.length > 1
  14917. )
  14918. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  14919. || node instanceof AST_LoopControl
  14920. || node instanceof AST_Try
  14921. || node instanceof AST_With
  14922. || node instanceof AST_Yield
  14923. || node instanceof AST_Export
  14924. || node instanceof AST_Class
  14925. || parent instanceof AST_For && node !== parent.init
  14926. || !replace_all
  14927. && (
  14928. node instanceof AST_SymbolRef
  14929. && !node.is_declared(compressor)
  14930. && !pure_prop_access_globals.has(node)
  14931. )
  14932. || node instanceof AST_SymbolRef
  14933. && parent instanceof AST_Call
  14934. && has_annotation(parent, _NOINLINE)
  14935. || node instanceof AST_ObjectProperty && node.key instanceof AST_Node
  14936. ) {
  14937. abort = true;
  14938. return node;
  14939. }
  14940. // Stop only if candidate is found within conditional branches
  14941. if (!stop_if_hit && (!lhs_local || !replace_all)
  14942. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  14943. || parent instanceof AST_Conditional && parent.condition !== node
  14944. || parent instanceof AST_If && parent.condition !== node)) {
  14945. stop_if_hit = parent;
  14946. }
  14947. // Replace variable with assignment when found
  14948. if (
  14949. can_replace
  14950. && !(node instanceof AST_SymbolDeclaration)
  14951. && lhs.equivalent_to(node)
  14952. && !shadows(scanner.find_scope() || nearest_scope, lvalues)
  14953. ) {
  14954. if (stop_if_hit) {
  14955. abort = true;
  14956. return node;
  14957. }
  14958. if (is_lhs(node, parent)) {
  14959. if (value_def)
  14960. replaced++;
  14961. return node;
  14962. } else {
  14963. replaced++;
  14964. if (value_def && candidate instanceof AST_VarDef)
  14965. return node;
  14966. }
  14967. CHANGED = abort = true;
  14968. if (candidate instanceof AST_UnaryPostfix) {
  14969. return make_node(AST_UnaryPrefix, candidate, candidate);
  14970. }
  14971. if (candidate instanceof AST_VarDef) {
  14972. var def = candidate.name.definition();
  14973. var value = candidate.value;
  14974. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  14975. def.replaced++;
  14976. if (funarg && is_identifier_atom(value)) {
  14977. return value.transform(compressor);
  14978. } else {
  14979. return maintain_this_binding(parent, node, value);
  14980. }
  14981. }
  14982. return make_node(AST_Assign, candidate, {
  14983. operator: "=",
  14984. logical: false,
  14985. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  14986. right: value
  14987. });
  14988. }
  14989. clear_flag(candidate, WRITE_ONLY);
  14990. return candidate;
  14991. }
  14992. // These node types have child nodes that execute sequentially,
  14993. // but are otherwise not safe to scan into or beyond them.
  14994. var sym;
  14995. if (node instanceof AST_Call
  14996. || node instanceof AST_Exit
  14997. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  14998. || node instanceof AST_PropAccess
  14999. && (side_effects || node.expression.may_throw_on_access(compressor))
  15000. || node instanceof AST_SymbolRef
  15001. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  15002. || node instanceof AST_VarDef && node.value
  15003. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  15004. || (sym = is_lhs(node.left, node))
  15005. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  15006. || may_throw
  15007. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  15008. stop_after = node;
  15009. if (node instanceof AST_Scope)
  15010. abort = true;
  15011. }
  15012. return handle_custom_scan_order(node);
  15013. }, function (node) {
  15014. if (abort)
  15015. return;
  15016. if (stop_after === node)
  15017. abort = true;
  15018. if (stop_if_hit === node)
  15019. stop_if_hit = null;
  15020. });
  15021. var multi_replacer = new TreeTransformer(function (node) {
  15022. if (abort)
  15023. return node;
  15024. // Skip nodes before `candidate` as quickly as possible
  15025. if (!hit) {
  15026. if (node !== hit_stack[hit_index])
  15027. return node;
  15028. hit_index++;
  15029. if (hit_index < hit_stack.length)
  15030. return;
  15031. hit = true;
  15032. return node;
  15033. }
  15034. // Replace variable when found
  15035. if (node instanceof AST_SymbolRef
  15036. && node.name == def.name) {
  15037. if (!--replaced)
  15038. abort = true;
  15039. if (is_lhs(node, multi_replacer.parent()))
  15040. return node;
  15041. def.replaced++;
  15042. value_def.replaced--;
  15043. return candidate.value;
  15044. }
  15045. // Skip (non-executed) functions and (leading) default case in switch statements
  15046. if (node instanceof AST_Default || node instanceof AST_Scope)
  15047. return node;
  15048. });
  15049. while (--stat_index >= 0) {
  15050. // Treat parameters as collapsible in IIFE, i.e.
  15051. // function(a, b){ ... }(x());
  15052. // would be translated into equivalent assignments:
  15053. // var a = x(), b = undefined;
  15054. if (stat_index == 0 && compressor.option("unused"))
  15055. extract_args();
  15056. // Find collapsible assignments
  15057. var hit_stack = [];
  15058. extract_candidates(statements[stat_index]);
  15059. while (candidates.length > 0) {
  15060. hit_stack = candidates.pop();
  15061. var hit_index = 0;
  15062. var candidate = hit_stack[hit_stack.length - 1];
  15063. var value_def = null;
  15064. var stop_after = null;
  15065. var stop_if_hit = null;
  15066. var lhs = get_lhs(candidate);
  15067. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  15068. continue;
  15069. // Locate symbols which may execute code outside of scanning range
  15070. var lvalues = get_lvalues(candidate);
  15071. var lhs_local = is_lhs_local(lhs);
  15072. if (lhs instanceof AST_SymbolRef) {
  15073. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  15074. }
  15075. var side_effects = value_has_side_effects(candidate);
  15076. var replace_all = replace_all_symbols();
  15077. var may_throw = candidate.may_throw(compressor);
  15078. var funarg = candidate.name instanceof AST_SymbolFunarg;
  15079. var hit = funarg;
  15080. var abort = false, replaced = 0, can_replace = !args || !hit;
  15081. if (!can_replace) {
  15082. for (
  15083. let j = compressor.self().argnames.lastIndexOf(candidate.name) + 1;
  15084. !abort && j < args.length;
  15085. j++
  15086. ) {
  15087. args[j].transform(scanner);
  15088. }
  15089. can_replace = true;
  15090. }
  15091. for (var i = stat_index; !abort && i < statements.length; i++) {
  15092. statements[i].transform(scanner);
  15093. }
  15094. if (value_def) {
  15095. var def = candidate.name.definition();
  15096. if (abort && def.references.length - def.replaced > replaced)
  15097. replaced = false;
  15098. else {
  15099. abort = false;
  15100. hit_index = 0;
  15101. hit = funarg;
  15102. for (var i = stat_index; !abort && i < statements.length; i++) {
  15103. statements[i].transform(multi_replacer);
  15104. }
  15105. value_def.single_use = false;
  15106. }
  15107. }
  15108. if (replaced && !remove_candidate(candidate))
  15109. statements.splice(stat_index, 1);
  15110. }
  15111. }
  15112. function handle_custom_scan_order(node) {
  15113. // Skip (non-executed) functions
  15114. if (node instanceof AST_Scope)
  15115. return node;
  15116. // Scan case expressions first in a switch statement
  15117. if (node instanceof AST_Switch) {
  15118. node.expression = node.expression.transform(scanner);
  15119. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  15120. var branch = node.body[i];
  15121. if (branch instanceof AST_Case) {
  15122. if (!hit) {
  15123. if (branch !== hit_stack[hit_index])
  15124. continue;
  15125. hit_index++;
  15126. }
  15127. branch.expression = branch.expression.transform(scanner);
  15128. if (!replace_all)
  15129. break;
  15130. }
  15131. }
  15132. abort = true;
  15133. return node;
  15134. }
  15135. }
  15136. function redefined_within_scope(def, scope) {
  15137. if (def.global)
  15138. return false;
  15139. let cur_scope = def.scope;
  15140. while (cur_scope && cur_scope !== scope) {
  15141. if (cur_scope.variables.has(def.name)) {
  15142. return true;
  15143. }
  15144. cur_scope = cur_scope.parent_scope;
  15145. }
  15146. return false;
  15147. }
  15148. function has_overlapping_symbol(fn, arg, fn_strict) {
  15149. var found = false, scan_this = !(fn instanceof AST_Arrow);
  15150. arg.walk(new TreeWalker(function (node, descend) {
  15151. if (found)
  15152. return true;
  15153. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  15154. var s = node.definition().scope;
  15155. if (s !== defun_scope)
  15156. while (s = s.parent_scope) {
  15157. if (s === defun_scope)
  15158. return true;
  15159. }
  15160. return found = true;
  15161. }
  15162. if ((fn_strict || scan_this) && node instanceof AST_This) {
  15163. return found = true;
  15164. }
  15165. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  15166. var prev = scan_this;
  15167. scan_this = false;
  15168. descend();
  15169. scan_this = prev;
  15170. return true;
  15171. }
  15172. }));
  15173. return found;
  15174. }
  15175. function arg_is_injectable(arg) {
  15176. if (arg instanceof AST_Expansion) return false;
  15177. const contains_await = walk(arg, (node) => {
  15178. if (node instanceof AST_Await) return walk_abort;
  15179. });
  15180. if (contains_await) return false;
  15181. return true;
  15182. }
  15183. function extract_args() {
  15184. var iife, fn = compressor.self();
  15185. if (is_func_expr(fn)
  15186. && !fn.name
  15187. && !fn.uses_arguments
  15188. && !fn.pinned()
  15189. && (iife = compressor.parent()) instanceof AST_Call
  15190. && iife.expression === fn
  15191. && iife.args.every(arg_is_injectable)
  15192. ) {
  15193. var fn_strict = compressor.has_directive("use strict");
  15194. if (fn_strict && !member(fn_strict, fn.body))
  15195. fn_strict = false;
  15196. var len = fn.argnames.length;
  15197. args = iife.args.slice(len);
  15198. var names = new Set();
  15199. for (var i = len; --i >= 0;) {
  15200. var sym = fn.argnames[i];
  15201. var arg = iife.args[i];
  15202. // The following two line fix is a duplicate of the fix at
  15203. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  15204. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  15205. // Might be doing the exact same thing.
  15206. const def = sym.definition && sym.definition();
  15207. const is_reassigned = def && def.orig.length > 1;
  15208. if (is_reassigned)
  15209. continue;
  15210. args.unshift(make_node(AST_VarDef, sym, {
  15211. name: sym,
  15212. value: arg
  15213. }));
  15214. if (names.has(sym.name))
  15215. continue;
  15216. names.add(sym.name);
  15217. if (sym instanceof AST_Expansion) {
  15218. var elements = iife.args.slice(i);
  15219. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  15220. )) {
  15221. candidates.unshift([make_node(AST_VarDef, sym, {
  15222. name: sym.expression,
  15223. value: make_node(AST_Array, iife, {
  15224. elements: elements
  15225. })
  15226. })]);
  15227. }
  15228. } else {
  15229. if (!arg) {
  15230. arg = make_node(AST_Undefined, sym).transform(compressor);
  15231. } else if (arg instanceof AST_Lambda && arg.pinned()
  15232. || has_overlapping_symbol(fn, arg, fn_strict)) {
  15233. arg = null;
  15234. }
  15235. if (arg)
  15236. candidates.unshift([make_node(AST_VarDef, sym, {
  15237. name: sym,
  15238. value: arg
  15239. })]);
  15240. }
  15241. }
  15242. }
  15243. }
  15244. function extract_candidates(expr) {
  15245. hit_stack.push(expr);
  15246. if (expr instanceof AST_Assign) {
  15247. if (!expr.left.has_side_effects(compressor)
  15248. && !(expr.right instanceof AST_Chain)) {
  15249. candidates.push(hit_stack.slice());
  15250. }
  15251. extract_candidates(expr.right);
  15252. } else if (expr instanceof AST_Binary) {
  15253. extract_candidates(expr.left);
  15254. extract_candidates(expr.right);
  15255. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  15256. extract_candidates(expr.expression);
  15257. expr.args.forEach(extract_candidates);
  15258. } else if (expr instanceof AST_Case) {
  15259. extract_candidates(expr.expression);
  15260. } else if (expr instanceof AST_Conditional) {
  15261. extract_candidates(expr.condition);
  15262. extract_candidates(expr.consequent);
  15263. extract_candidates(expr.alternative);
  15264. } else if (expr instanceof AST_Definitions) {
  15265. var len = expr.definitions.length;
  15266. // limit number of trailing variable definitions for consideration
  15267. var i = len - 200;
  15268. if (i < 0)
  15269. i = 0;
  15270. for (; i < len; i++) {
  15271. extract_candidates(expr.definitions[i]);
  15272. }
  15273. } else if (expr instanceof AST_DWLoop) {
  15274. extract_candidates(expr.condition);
  15275. if (!(expr.body instanceof AST_Block)) {
  15276. extract_candidates(expr.body);
  15277. }
  15278. } else if (expr instanceof AST_Exit) {
  15279. if (expr.value)
  15280. extract_candidates(expr.value);
  15281. } else if (expr instanceof AST_For) {
  15282. if (expr.init)
  15283. extract_candidates(expr.init);
  15284. if (expr.condition)
  15285. extract_candidates(expr.condition);
  15286. if (expr.step)
  15287. extract_candidates(expr.step);
  15288. if (!(expr.body instanceof AST_Block)) {
  15289. extract_candidates(expr.body);
  15290. }
  15291. } else if (expr instanceof AST_ForIn) {
  15292. extract_candidates(expr.object);
  15293. if (!(expr.body instanceof AST_Block)) {
  15294. extract_candidates(expr.body);
  15295. }
  15296. } else if (expr instanceof AST_If) {
  15297. extract_candidates(expr.condition);
  15298. if (!(expr.body instanceof AST_Block)) {
  15299. extract_candidates(expr.body);
  15300. }
  15301. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  15302. extract_candidates(expr.alternative);
  15303. }
  15304. } else if (expr instanceof AST_Sequence) {
  15305. expr.expressions.forEach(extract_candidates);
  15306. } else if (expr instanceof AST_SimpleStatement) {
  15307. extract_candidates(expr.body);
  15308. } else if (expr instanceof AST_Switch) {
  15309. extract_candidates(expr.expression);
  15310. expr.body.forEach(extract_candidates);
  15311. } else if (expr instanceof AST_Unary) {
  15312. if (expr.operator == "++" || expr.operator == "--") {
  15313. candidates.push(hit_stack.slice());
  15314. }
  15315. } else if (expr instanceof AST_VarDef) {
  15316. if (expr.value && !(expr.value instanceof AST_Chain)) {
  15317. candidates.push(hit_stack.slice());
  15318. extract_candidates(expr.value);
  15319. }
  15320. }
  15321. hit_stack.pop();
  15322. }
  15323. function find_stop(node, level, write_only) {
  15324. var parent = scanner.parent(level);
  15325. if (parent instanceof AST_Assign) {
  15326. if (write_only
  15327. && !parent.logical
  15328. && !(parent.left instanceof AST_PropAccess
  15329. || lvalues.has(parent.left.name))) {
  15330. return find_stop(parent, level + 1, write_only);
  15331. }
  15332. return node;
  15333. }
  15334. if (parent instanceof AST_Binary) {
  15335. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  15336. return find_stop(parent, level + 1, write_only);
  15337. }
  15338. return node;
  15339. }
  15340. if (parent instanceof AST_Call)
  15341. return node;
  15342. if (parent instanceof AST_Case)
  15343. return node;
  15344. if (parent instanceof AST_Conditional) {
  15345. if (write_only && parent.condition === node) {
  15346. return find_stop(parent, level + 1, write_only);
  15347. }
  15348. return node;
  15349. }
  15350. if (parent instanceof AST_Definitions) {
  15351. return find_stop(parent, level + 1, true);
  15352. }
  15353. if (parent instanceof AST_Exit) {
  15354. return write_only ? find_stop(parent, level + 1, write_only) : node;
  15355. }
  15356. if (parent instanceof AST_If) {
  15357. if (write_only && parent.condition === node) {
  15358. return find_stop(parent, level + 1, write_only);
  15359. }
  15360. return node;
  15361. }
  15362. if (parent instanceof AST_IterationStatement)
  15363. return node;
  15364. if (parent instanceof AST_Sequence) {
  15365. return find_stop(parent, level + 1, parent.tail_node() !== node);
  15366. }
  15367. if (parent instanceof AST_SimpleStatement) {
  15368. return find_stop(parent, level + 1, true);
  15369. }
  15370. if (parent instanceof AST_Switch)
  15371. return node;
  15372. if (parent instanceof AST_VarDef)
  15373. return node;
  15374. return null;
  15375. }
  15376. function mangleable_var(var_def) {
  15377. var value = var_def.value;
  15378. if (!(value instanceof AST_SymbolRef))
  15379. return;
  15380. if (value.name == "arguments")
  15381. return;
  15382. var def = value.definition();
  15383. if (def.undeclared)
  15384. return;
  15385. return value_def = def;
  15386. }
  15387. function get_lhs(expr) {
  15388. if (expr instanceof AST_Assign && expr.logical) {
  15389. return false;
  15390. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  15391. var def = expr.name.definition();
  15392. if (!member(expr.name, def.orig))
  15393. return;
  15394. var referenced = def.references.length - def.replaced;
  15395. if (!referenced)
  15396. return;
  15397. var declared = def.orig.length - def.eliminated;
  15398. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  15399. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  15400. return make_node(AST_SymbolRef, expr.name, expr.name);
  15401. }
  15402. } else {
  15403. const lhs = expr instanceof AST_Assign
  15404. ? expr.left
  15405. : expr.expression;
  15406. return !is_ref_of(lhs, AST_SymbolConst)
  15407. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  15408. }
  15409. }
  15410. function get_rvalue(expr) {
  15411. if (expr instanceof AST_Assign) {
  15412. return expr.right;
  15413. } else {
  15414. return expr.value;
  15415. }
  15416. }
  15417. function get_lvalues(expr) {
  15418. var lvalues = new Map();
  15419. if (expr instanceof AST_Unary)
  15420. return lvalues;
  15421. var tw = new TreeWalker(function (node) {
  15422. var sym = node;
  15423. while (sym instanceof AST_PropAccess)
  15424. sym = sym.expression;
  15425. if (sym instanceof AST_SymbolRef) {
  15426. const prev = lvalues.get(sym.name);
  15427. if (!prev || !prev.modified) {
  15428. lvalues.set(sym.name, {
  15429. def: sym.definition(),
  15430. modified: is_modified(compressor, tw, node, node, 0)
  15431. });
  15432. }
  15433. }
  15434. });
  15435. get_rvalue(expr).walk(tw);
  15436. return lvalues;
  15437. }
  15438. function remove_candidate(expr) {
  15439. if (expr.name instanceof AST_SymbolFunarg) {
  15440. var iife = compressor.parent(), argnames = compressor.self().argnames;
  15441. var index = argnames.indexOf(expr.name);
  15442. if (index < 0) {
  15443. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  15444. } else {
  15445. var args = iife.args;
  15446. if (args[index])
  15447. args[index] = make_node(AST_Number, args[index], {
  15448. value: 0
  15449. });
  15450. }
  15451. return true;
  15452. }
  15453. var found = false;
  15454. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  15455. if (found)
  15456. return node;
  15457. if (node === expr || node.body === expr) {
  15458. found = true;
  15459. if (node instanceof AST_VarDef) {
  15460. node.value = node.name instanceof AST_SymbolConst
  15461. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  15462. : null;
  15463. return node;
  15464. }
  15465. return in_list ? MAP.skip : null;
  15466. }
  15467. }, function (node) {
  15468. if (node instanceof AST_Sequence)
  15469. switch (node.expressions.length) {
  15470. case 0: return null;
  15471. case 1: return node.expressions[0];
  15472. }
  15473. }));
  15474. }
  15475. function is_lhs_local(lhs) {
  15476. while (lhs instanceof AST_PropAccess)
  15477. lhs = lhs.expression;
  15478. return lhs instanceof AST_SymbolRef
  15479. && lhs.definition().scope.get_defun_scope() === defun_scope
  15480. && !(in_loop
  15481. && (lvalues.has(lhs.name)
  15482. || candidate instanceof AST_Unary
  15483. || (candidate instanceof AST_Assign
  15484. && !candidate.logical
  15485. && candidate.operator != "=")));
  15486. }
  15487. function value_has_side_effects(expr) {
  15488. if (expr instanceof AST_Unary)
  15489. return unary_side_effects.has(expr.operator);
  15490. return get_rvalue(expr).has_side_effects(compressor);
  15491. }
  15492. function replace_all_symbols() {
  15493. if (side_effects)
  15494. return false;
  15495. if (value_def)
  15496. return true;
  15497. if (lhs instanceof AST_SymbolRef) {
  15498. var def = lhs.definition();
  15499. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  15500. return true;
  15501. }
  15502. }
  15503. return false;
  15504. }
  15505. function may_modify(sym) {
  15506. if (!sym.definition)
  15507. return true; // AST_Destructuring
  15508. var def = sym.definition();
  15509. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  15510. return false;
  15511. if (def.scope.get_defun_scope() !== defun_scope)
  15512. return true;
  15513. return def.references.some((ref) =>
  15514. ref.scope.get_defun_scope() !== defun_scope
  15515. );
  15516. }
  15517. function side_effects_external(node, lhs) {
  15518. if (node instanceof AST_Assign)
  15519. return side_effects_external(node.left, true);
  15520. if (node instanceof AST_Unary)
  15521. return side_effects_external(node.expression, true);
  15522. if (node instanceof AST_VarDef)
  15523. return node.value && side_effects_external(node.value);
  15524. if (lhs) {
  15525. if (node instanceof AST_Dot)
  15526. return side_effects_external(node.expression, true);
  15527. if (node instanceof AST_Sub)
  15528. return side_effects_external(node.expression, true);
  15529. if (node instanceof AST_SymbolRef)
  15530. return node.definition().scope.get_defun_scope() !== defun_scope;
  15531. }
  15532. return false;
  15533. }
  15534. /**
  15535. * Will any of the pulled-in lvalues shadow a variable in newScope or parents?
  15536. * similar to scope_encloses_variables_in_this_scope */
  15537. function shadows(my_scope, lvalues) {
  15538. for (const { def } of lvalues.values()) {
  15539. const looked_up = my_scope.find_variable(def.name);
  15540. if (looked_up) {
  15541. if (looked_up === def) continue;
  15542. return true;
  15543. }
  15544. }
  15545. return false;
  15546. }
  15547. }
  15548. function eliminate_spurious_blocks(statements) {
  15549. var seen_dirs = [];
  15550. for (var i = 0; i < statements.length;) {
  15551. var stat = statements[i];
  15552. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  15553. CHANGED = true;
  15554. eliminate_spurious_blocks(stat.body);
  15555. statements.splice(i, 1, ...stat.body);
  15556. i += stat.body.length;
  15557. } else if (stat instanceof AST_EmptyStatement) {
  15558. CHANGED = true;
  15559. statements.splice(i, 1);
  15560. } else if (stat instanceof AST_Directive) {
  15561. if (seen_dirs.indexOf(stat.value) < 0) {
  15562. i++;
  15563. seen_dirs.push(stat.value);
  15564. } else {
  15565. CHANGED = true;
  15566. statements.splice(i, 1);
  15567. }
  15568. } else
  15569. i++;
  15570. }
  15571. }
  15572. function handle_if_return(statements, compressor) {
  15573. var self = compressor.self();
  15574. var multiple_if_returns = has_multiple_if_returns(statements);
  15575. var in_lambda = self instanceof AST_Lambda;
  15576. // Prevent extremely deep nesting
  15577. // https://github.com/terser/terser/issues/1432
  15578. // https://github.com/webpack/webpack/issues/17548
  15579. const iteration_start = Math.min(statements.length, 500);
  15580. for (var i = iteration_start; --i >= 0;) {
  15581. var stat = statements[i];
  15582. var j = next_index(i);
  15583. var next = statements[j];
  15584. if (in_lambda && !next && stat instanceof AST_Return) {
  15585. if (!stat.value) {
  15586. CHANGED = true;
  15587. statements.splice(i, 1);
  15588. continue;
  15589. }
  15590. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  15591. CHANGED = true;
  15592. statements[i] = make_node(AST_SimpleStatement, stat, {
  15593. body: stat.value.expression
  15594. });
  15595. continue;
  15596. }
  15597. }
  15598. if (stat instanceof AST_If) {
  15599. let ab, new_else;
  15600. ab = aborts(stat.body);
  15601. if (
  15602. can_merge_flow(ab)
  15603. && (new_else = as_statement_array_with_return(stat.body, ab))
  15604. ) {
  15605. if (ab.label) {
  15606. remove(ab.label.thedef.references, ab);
  15607. }
  15608. CHANGED = true;
  15609. stat = stat.clone();
  15610. stat.condition = stat.condition.negate(compressor);
  15611. stat.body = make_node(AST_BlockStatement, stat, {
  15612. body: as_statement_array(stat.alternative).concat(extract_functions())
  15613. });
  15614. stat.alternative = make_node(AST_BlockStatement, stat, {
  15615. body: new_else
  15616. });
  15617. statements[i] = stat.transform(compressor);
  15618. continue;
  15619. }
  15620. ab = aborts(stat.alternative);
  15621. if (
  15622. can_merge_flow(ab)
  15623. && (new_else = as_statement_array_with_return(stat.alternative, ab))
  15624. ) {
  15625. if (ab.label) {
  15626. remove(ab.label.thedef.references, ab);
  15627. }
  15628. CHANGED = true;
  15629. stat = stat.clone();
  15630. stat.body = make_node(AST_BlockStatement, stat.body, {
  15631. body: as_statement_array(stat.body).concat(extract_functions())
  15632. });
  15633. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  15634. body: new_else
  15635. });
  15636. statements[i] = stat.transform(compressor);
  15637. continue;
  15638. }
  15639. }
  15640. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  15641. var value = stat.body.value;
  15642. //---
  15643. // pretty silly case, but:
  15644. // if (foo()) return; return; ==> foo(); return;
  15645. if (!value && !stat.alternative
  15646. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  15647. CHANGED = true;
  15648. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  15649. body: stat.condition
  15650. });
  15651. continue;
  15652. }
  15653. //---
  15654. // if (foo()) return x; return y; ==> return foo() ? x : y;
  15655. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  15656. CHANGED = true;
  15657. stat = stat.clone();
  15658. stat.alternative = next;
  15659. statements[i] = stat.transform(compressor);
  15660. statements.splice(j, 1);
  15661. continue;
  15662. }
  15663. //---
  15664. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  15665. if (value && !stat.alternative
  15666. && (!next && in_lambda && multiple_if_returns
  15667. || next instanceof AST_Return)) {
  15668. CHANGED = true;
  15669. stat = stat.clone();
  15670. stat.alternative = next || make_node(AST_Return, stat, {
  15671. value: null
  15672. });
  15673. statements[i] = stat.transform(compressor);
  15674. if (next)
  15675. statements.splice(j, 1);
  15676. continue;
  15677. }
  15678. //---
  15679. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  15680. //
  15681. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  15682. // however, with sequences on this helps producing slightly better output for
  15683. // the example code.
  15684. var prev = statements[prev_index(i)];
  15685. if (compressor.option("sequences") && in_lambda && !stat.alternative
  15686. && prev instanceof AST_If && prev.body instanceof AST_Return
  15687. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  15688. CHANGED = true;
  15689. stat = stat.clone();
  15690. stat.alternative = make_node(AST_BlockStatement, next, {
  15691. body: [
  15692. next,
  15693. make_node(AST_Return, next, {
  15694. value: null
  15695. })
  15696. ]
  15697. });
  15698. statements[i] = stat.transform(compressor);
  15699. statements.splice(j, 1);
  15700. continue;
  15701. }
  15702. }
  15703. }
  15704. function has_multiple_if_returns(statements) {
  15705. var n = 0;
  15706. for (var i = statements.length; --i >= 0;) {
  15707. var stat = statements[i];
  15708. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  15709. if (++n > 1)
  15710. return true;
  15711. }
  15712. }
  15713. return false;
  15714. }
  15715. function is_return_void(value) {
  15716. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  15717. }
  15718. function can_merge_flow(ab) {
  15719. if (!ab)
  15720. return false;
  15721. for (var j = i + 1, len = statements.length; j < len; j++) {
  15722. var stat = statements[j];
  15723. if (stat instanceof AST_Const || stat instanceof AST_Let)
  15724. return false;
  15725. }
  15726. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  15727. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  15728. || ab instanceof AST_Continue && self === loop_body(lct)
  15729. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  15730. }
  15731. function extract_functions() {
  15732. var tail = statements.slice(i + 1);
  15733. statements.length = i + 1;
  15734. return tail.filter(function (stat) {
  15735. if (stat instanceof AST_Defun) {
  15736. statements.push(stat);
  15737. return false;
  15738. }
  15739. return true;
  15740. });
  15741. }
  15742. function as_statement_array_with_return(node, ab) {
  15743. var body = as_statement_array(node);
  15744. if (ab !== body[body.length - 1]) {
  15745. return undefined;
  15746. }
  15747. body = body.slice(0, -1);
  15748. if (ab.value) {
  15749. body.push(make_node(AST_SimpleStatement, ab.value, {
  15750. body: ab.value.expression
  15751. }));
  15752. }
  15753. return body;
  15754. }
  15755. function next_index(i) {
  15756. for (var j = i + 1, len = statements.length; j < len; j++) {
  15757. var stat = statements[j];
  15758. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  15759. break;
  15760. }
  15761. }
  15762. return j;
  15763. }
  15764. function prev_index(i) {
  15765. for (var j = i; --j >= 0;) {
  15766. var stat = statements[j];
  15767. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  15768. break;
  15769. }
  15770. }
  15771. return j;
  15772. }
  15773. }
  15774. function eliminate_dead_code(statements, compressor) {
  15775. var has_quit;
  15776. var self = compressor.self();
  15777. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  15778. var stat = statements[i];
  15779. if (stat instanceof AST_LoopControl) {
  15780. var lct = compressor.loopcontrol_target(stat);
  15781. if (stat instanceof AST_Break
  15782. && !(lct instanceof AST_IterationStatement)
  15783. && loop_body(lct) === self
  15784. || stat instanceof AST_Continue
  15785. && loop_body(lct) === self) {
  15786. if (stat.label) {
  15787. remove(stat.label.thedef.references, stat);
  15788. }
  15789. } else {
  15790. statements[n++] = stat;
  15791. }
  15792. } else {
  15793. statements[n++] = stat;
  15794. }
  15795. if (aborts(stat)) {
  15796. has_quit = statements.slice(i + 1);
  15797. break;
  15798. }
  15799. }
  15800. statements.length = n;
  15801. CHANGED = n != len;
  15802. if (has_quit)
  15803. has_quit.forEach(function (stat) {
  15804. trim_unreachable_code(compressor, stat, statements);
  15805. });
  15806. }
  15807. function declarations_only(node) {
  15808. return node.definitions.every((var_def) => !var_def.value);
  15809. }
  15810. function sequencesize(statements, compressor) {
  15811. if (statements.length < 2)
  15812. return;
  15813. var seq = [], n = 0;
  15814. function push_seq() {
  15815. if (!seq.length)
  15816. return;
  15817. var body = make_sequence(seq[0], seq);
  15818. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  15819. seq = [];
  15820. }
  15821. for (var i = 0, len = statements.length; i < len; i++) {
  15822. var stat = statements[i];
  15823. if (stat instanceof AST_SimpleStatement) {
  15824. if (seq.length >= compressor.sequences_limit)
  15825. push_seq();
  15826. var body = stat.body;
  15827. if (seq.length > 0)
  15828. body = body.drop_side_effect_free(compressor);
  15829. if (body)
  15830. merge_sequence(seq, body);
  15831. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  15832. || stat instanceof AST_Defun) {
  15833. statements[n++] = stat;
  15834. } else {
  15835. push_seq();
  15836. statements[n++] = stat;
  15837. }
  15838. }
  15839. push_seq();
  15840. statements.length = n;
  15841. if (n != len)
  15842. CHANGED = true;
  15843. }
  15844. function to_simple_statement(block, decls) {
  15845. if (!(block instanceof AST_BlockStatement))
  15846. return block;
  15847. var stat = null;
  15848. for (var i = 0, len = block.body.length; i < len; i++) {
  15849. var line = block.body[i];
  15850. if (line instanceof AST_Var && declarations_only(line)) {
  15851. decls.push(line);
  15852. } else if (stat || line instanceof AST_Const || line instanceof AST_Let) {
  15853. return false;
  15854. } else {
  15855. stat = line;
  15856. }
  15857. }
  15858. return stat;
  15859. }
  15860. function sequencesize_2(statements, compressor) {
  15861. function cons_seq(right) {
  15862. n--;
  15863. CHANGED = true;
  15864. var left = prev.body;
  15865. return make_sequence(left, [left, right]).transform(compressor);
  15866. }
  15867. var n = 0, prev;
  15868. for (var i = 0; i < statements.length; i++) {
  15869. var stat = statements[i];
  15870. if (prev) {
  15871. if (stat instanceof AST_Exit) {
  15872. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  15873. } else if (stat instanceof AST_For) {
  15874. if (!(stat.init instanceof AST_Definitions)) {
  15875. const abort = walk(prev.body, node => {
  15876. if (node instanceof AST_Scope)
  15877. return true;
  15878. if (node instanceof AST_Binary
  15879. && node.operator === "in") {
  15880. return walk_abort;
  15881. }
  15882. });
  15883. if (!abort) {
  15884. if (stat.init)
  15885. stat.init = cons_seq(stat.init);
  15886. else {
  15887. stat.init = prev.body;
  15888. n--;
  15889. CHANGED = true;
  15890. }
  15891. }
  15892. }
  15893. } else if (stat instanceof AST_ForIn) {
  15894. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  15895. stat.object = cons_seq(stat.object);
  15896. }
  15897. } else if (stat instanceof AST_If) {
  15898. stat.condition = cons_seq(stat.condition);
  15899. } else if (stat instanceof AST_Switch) {
  15900. stat.expression = cons_seq(stat.expression);
  15901. } else if (stat instanceof AST_With) {
  15902. stat.expression = cons_seq(stat.expression);
  15903. }
  15904. }
  15905. if (compressor.option("conditionals") && stat instanceof AST_If) {
  15906. var decls = [];
  15907. var body = to_simple_statement(stat.body, decls);
  15908. var alt = to_simple_statement(stat.alternative, decls);
  15909. if (body !== false && alt !== false && decls.length > 0) {
  15910. var len = decls.length;
  15911. decls.push(make_node(AST_If, stat, {
  15912. condition: stat.condition,
  15913. body: body || make_node(AST_EmptyStatement, stat.body),
  15914. alternative: alt
  15915. }));
  15916. decls.unshift(n, 1);
  15917. [].splice.apply(statements, decls);
  15918. i += len;
  15919. n += len + 1;
  15920. prev = null;
  15921. CHANGED = true;
  15922. continue;
  15923. }
  15924. }
  15925. statements[n++] = stat;
  15926. prev = stat instanceof AST_SimpleStatement ? stat : null;
  15927. }
  15928. statements.length = n;
  15929. }
  15930. function join_object_assignments(defn, body) {
  15931. if (!(defn instanceof AST_Definitions))
  15932. return;
  15933. var def = defn.definitions[defn.definitions.length - 1];
  15934. if (!(def.value instanceof AST_Object))
  15935. return;
  15936. var exprs;
  15937. if (body instanceof AST_Assign && !body.logical) {
  15938. exprs = [body];
  15939. } else if (body instanceof AST_Sequence) {
  15940. exprs = body.expressions.slice();
  15941. }
  15942. if (!exprs)
  15943. return;
  15944. var trimmed = false;
  15945. do {
  15946. var node = exprs[0];
  15947. if (!(node instanceof AST_Assign))
  15948. break;
  15949. if (node.operator != "=")
  15950. break;
  15951. if (!(node.left instanceof AST_PropAccess))
  15952. break;
  15953. var sym = node.left.expression;
  15954. if (!(sym instanceof AST_SymbolRef))
  15955. break;
  15956. if (def.name.name != sym.name)
  15957. break;
  15958. if (!node.right.is_constant_expression(nearest_scope))
  15959. break;
  15960. var prop = node.left.property;
  15961. if (prop instanceof AST_Node) {
  15962. prop = prop.evaluate(compressor);
  15963. }
  15964. if (prop instanceof AST_Node)
  15965. break;
  15966. prop = "" + prop;
  15967. var diff = compressor.option("ecma") < 2015
  15968. && compressor.has_directive("use strict") ? function (node) {
  15969. return node.key != prop && (node.key && node.key.name != prop);
  15970. } : function (node) {
  15971. return node.key && node.key.name != prop;
  15972. };
  15973. if (!def.value.properties.every(diff))
  15974. break;
  15975. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  15976. if (!p) {
  15977. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  15978. key: prop,
  15979. value: node.right
  15980. }));
  15981. } else {
  15982. p.value = new AST_Sequence({
  15983. start: p.start,
  15984. expressions: [p.value.clone(), node.right.clone()],
  15985. end: p.end
  15986. });
  15987. }
  15988. exprs.shift();
  15989. trimmed = true;
  15990. } while (exprs.length);
  15991. return trimmed && exprs;
  15992. }
  15993. function join_consecutive_vars(statements) {
  15994. var defs;
  15995. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  15996. var stat = statements[i];
  15997. var prev = statements[j];
  15998. if (stat instanceof AST_Definitions) {
  15999. if (prev && prev.TYPE == stat.TYPE) {
  16000. prev.definitions = prev.definitions.concat(stat.definitions);
  16001. CHANGED = true;
  16002. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  16003. defs.definitions = defs.definitions.concat(stat.definitions);
  16004. CHANGED = true;
  16005. } else {
  16006. statements[++j] = stat;
  16007. defs = stat;
  16008. }
  16009. } else if (stat instanceof AST_Exit) {
  16010. stat.value = extract_object_assignments(stat.value);
  16011. } else if (stat instanceof AST_For) {
  16012. var exprs = join_object_assignments(prev, stat.init);
  16013. if (exprs) {
  16014. CHANGED = true;
  16015. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  16016. statements[++j] = stat;
  16017. } else if (
  16018. prev instanceof AST_Var
  16019. && (!stat.init || stat.init.TYPE == prev.TYPE)
  16020. ) {
  16021. if (stat.init) {
  16022. prev.definitions = prev.definitions.concat(stat.init.definitions);
  16023. }
  16024. stat.init = prev;
  16025. statements[j] = stat;
  16026. CHANGED = true;
  16027. } else if (
  16028. defs instanceof AST_Var
  16029. && stat.init instanceof AST_Var
  16030. && declarations_only(stat.init)
  16031. ) {
  16032. defs.definitions = defs.definitions.concat(stat.init.definitions);
  16033. stat.init = null;
  16034. statements[++j] = stat;
  16035. CHANGED = true;
  16036. } else {
  16037. statements[++j] = stat;
  16038. }
  16039. } else if (stat instanceof AST_ForIn) {
  16040. stat.object = extract_object_assignments(stat.object);
  16041. } else if (stat instanceof AST_If) {
  16042. stat.condition = extract_object_assignments(stat.condition);
  16043. } else if (stat instanceof AST_SimpleStatement) {
  16044. var exprs = join_object_assignments(prev, stat.body);
  16045. if (exprs) {
  16046. CHANGED = true;
  16047. if (!exprs.length)
  16048. continue;
  16049. stat.body = make_sequence(stat.body, exprs);
  16050. }
  16051. statements[++j] = stat;
  16052. } else if (stat instanceof AST_Switch) {
  16053. stat.expression = extract_object_assignments(stat.expression);
  16054. } else if (stat instanceof AST_With) {
  16055. stat.expression = extract_object_assignments(stat.expression);
  16056. } else {
  16057. statements[++j] = stat;
  16058. }
  16059. }
  16060. statements.length = j + 1;
  16061. function extract_object_assignments(value) {
  16062. statements[++j] = stat;
  16063. var exprs = join_object_assignments(prev, value);
  16064. if (exprs) {
  16065. CHANGED = true;
  16066. if (exprs.length) {
  16067. return make_sequence(value, exprs);
  16068. } else if (value instanceof AST_Sequence) {
  16069. return value.tail_node().left;
  16070. } else {
  16071. return value.left;
  16072. }
  16073. }
  16074. return value;
  16075. }
  16076. }
  16077. }
  16078. /***********************************************************************
  16079. A JavaScript tokenizer / parser / beautifier / compressor.
  16080. https://github.com/mishoo/UglifyJS2
  16081. -------------------------------- (C) ---------------------------------
  16082. Author: Mihai Bazon
  16083. <mihai.bazon@gmail.com>
  16084. http://mihai.bazon.net/blog
  16085. Distributed under the BSD license:
  16086. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16087. Redistribution and use in source and binary forms, with or without
  16088. modification, are permitted provided that the following conditions
  16089. are met:
  16090. * Redistributions of source code must retain the above
  16091. copyright notice, this list of conditions and the following
  16092. disclaimer.
  16093. * Redistributions in binary form must reproduce the above
  16094. copyright notice, this list of conditions and the following
  16095. disclaimer in the documentation and/or other materials
  16096. provided with the distribution.
  16097. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16098. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16099. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16100. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16101. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16102. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16103. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16104. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16105. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16106. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16107. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16108. SUCH DAMAGE.
  16109. ***********************************************************************/
  16110. /**
  16111. * Module that contains the inlining logic.
  16112. *
  16113. * @module
  16114. *
  16115. * The stars of the show are `inline_into_symbolref` and `inline_into_call`.
  16116. */
  16117. function within_array_or_object_literal(compressor) {
  16118. var node, level = 0;
  16119. while (node = compressor.parent(level++)) {
  16120. if (node instanceof AST_Statement) return false;
  16121. if (node instanceof AST_Array
  16122. || node instanceof AST_ObjectKeyVal
  16123. || node instanceof AST_Object) {
  16124. return true;
  16125. }
  16126. }
  16127. return false;
  16128. }
  16129. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  16130. for (const enclosed of pulled_scope.enclosed) {
  16131. if (pulled_scope.variables.has(enclosed.name)) {
  16132. continue;
  16133. }
  16134. const looked_up = scope.find_variable(enclosed.name);
  16135. if (looked_up) {
  16136. if (looked_up === enclosed) continue;
  16137. return true;
  16138. }
  16139. }
  16140. return false;
  16141. }
  16142. /**
  16143. * An extra check function for `top_retain` option, compare the length of const identifier
  16144. * and init value length and return true if init value is longer than identifier. for example:
  16145. * ```
  16146. * // top_retain: ["example"]
  16147. * const example = 100
  16148. * ```
  16149. * it will return false because length of "100" is short than identifier "example".
  16150. */
  16151. function is_const_symbol_short_than_init_value(def, fixed_value) {
  16152. if (def.orig.length === 1 && fixed_value) {
  16153. const init_value_length = fixed_value.size();
  16154. const identifer_length = def.name.length;
  16155. return init_value_length > identifer_length;
  16156. }
  16157. return true;
  16158. }
  16159. function inline_into_symbolref(self, compressor) {
  16160. if (compressor.in_computed_key()) return self;
  16161. const parent = compressor.parent();
  16162. const def = self.definition();
  16163. const nearest_scope = compressor.find_scope();
  16164. let fixed = self.fixed_value();
  16165. if (
  16166. compressor.top_retain &&
  16167. def.global &&
  16168. compressor.top_retain(def) &&
  16169. // when identifier is in top_retain option dose not mean we can always inline it.
  16170. // if identifier name is longer then init value, we can replace it.
  16171. is_const_symbol_short_than_init_value(def, fixed)
  16172. ) {
  16173. // keep it
  16174. def.fixed = false;
  16175. def.single_use = false;
  16176. return self;
  16177. }
  16178. let single_use = def.single_use
  16179. && !(parent instanceof AST_Call
  16180. && (parent.is_callee_pure(compressor))
  16181. || has_annotation(parent, _NOINLINE))
  16182. && !(parent instanceof AST_Export
  16183. && fixed instanceof AST_Lambda
  16184. && fixed.name);
  16185. if (single_use && fixed instanceof AST_Node) {
  16186. single_use =
  16187. !fixed.has_side_effects(compressor)
  16188. && !fixed.may_throw(compressor);
  16189. }
  16190. if (fixed instanceof AST_Class && def.scope !== self.scope) {
  16191. return self;
  16192. }
  16193. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16194. if (retain_top_func(fixed, compressor)) {
  16195. single_use = false;
  16196. } else if (def.scope !== self.scope
  16197. && (def.escaped == 1
  16198. || has_flag(fixed, INLINED)
  16199. || within_array_or_object_literal(compressor)
  16200. || !compressor.option("reduce_funcs"))) {
  16201. single_use = false;
  16202. } else if (is_recursive_ref(compressor, def)) {
  16203. single_use = false;
  16204. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  16205. single_use = fixed.is_constant_expression(self.scope);
  16206. if (single_use == "f") {
  16207. var scope = self.scope;
  16208. do {
  16209. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  16210. set_flag(scope, INLINED);
  16211. }
  16212. } while (scope = scope.parent_scope);
  16213. }
  16214. }
  16215. }
  16216. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16217. single_use =
  16218. def.scope === self.scope
  16219. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16220. || parent instanceof AST_Call
  16221. && parent.expression === self
  16222. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16223. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  16224. }
  16225. if (single_use && fixed) {
  16226. if (fixed instanceof AST_DefClass) {
  16227. set_flag(fixed, SQUEEZED);
  16228. fixed = make_node(AST_ClassExpression, fixed, fixed);
  16229. }
  16230. if (fixed instanceof AST_Defun) {
  16231. set_flag(fixed, SQUEEZED);
  16232. fixed = make_node(AST_Function, fixed, fixed);
  16233. }
  16234. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  16235. const defun_def = fixed.name.definition();
  16236. let lambda_def = fixed.variables.get(fixed.name.name);
  16237. let name = lambda_def && lambda_def.orig[0];
  16238. if (!(name instanceof AST_SymbolLambda)) {
  16239. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  16240. name.scope = fixed;
  16241. fixed.name = name;
  16242. lambda_def = fixed.def_function(name);
  16243. }
  16244. walk(fixed, node => {
  16245. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  16246. node.thedef = lambda_def;
  16247. lambda_def.references.push(node);
  16248. }
  16249. });
  16250. }
  16251. if (
  16252. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  16253. && fixed.parent_scope !== nearest_scope
  16254. ) {
  16255. fixed = fixed.clone(true, compressor.get_toplevel());
  16256. nearest_scope.add_child_scope(fixed);
  16257. }
  16258. return fixed.optimize(compressor);
  16259. }
  16260. // multiple uses
  16261. if (fixed) {
  16262. let replace;
  16263. if (fixed instanceof AST_This) {
  16264. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  16265. && def.references.every((ref) =>
  16266. def.scope === ref.scope
  16267. )) {
  16268. replace = fixed;
  16269. }
  16270. } else {
  16271. var ev = fixed.evaluate(compressor);
  16272. if (
  16273. ev !== fixed
  16274. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  16275. ) {
  16276. replace = make_node_from_constant(ev, fixed);
  16277. }
  16278. }
  16279. if (replace) {
  16280. const name_length = self.size(compressor);
  16281. const replace_size = replace.size(compressor);
  16282. let overhead = 0;
  16283. if (compressor.option("unused") && !compressor.exposed(def)) {
  16284. overhead =
  16285. (name_length + 2 + fixed.size(compressor)) /
  16286. (def.references.length - def.assignments);
  16287. }
  16288. if (replace_size <= name_length + overhead) {
  16289. return replace;
  16290. }
  16291. }
  16292. }
  16293. return self;
  16294. }
  16295. function inline_into_call(self, compressor) {
  16296. if (compressor.in_computed_key()) return self;
  16297. var exp = self.expression;
  16298. var fn = exp;
  16299. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  16300. if (compressor.option("reduce_vars")
  16301. && fn instanceof AST_SymbolRef
  16302. && !has_annotation(self, _NOINLINE)
  16303. ) {
  16304. const fixed = fn.fixed_value();
  16305. if (
  16306. retain_top_func(fixed, compressor)
  16307. || !compressor.toplevel.funcs && exp.definition().global
  16308. ) {
  16309. return self;
  16310. }
  16311. fn = fixed;
  16312. }
  16313. var is_func = fn instanceof AST_Lambda;
  16314. var stat = is_func && fn.body[0];
  16315. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  16316. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  16317. if (can_inline && stat instanceof AST_Return) {
  16318. let returned = stat.value;
  16319. if (!returned || returned.is_constant_expression()) {
  16320. if (returned) {
  16321. returned = returned.clone(true);
  16322. } else {
  16323. returned = make_node(AST_Undefined, self);
  16324. }
  16325. const args = self.args.concat(returned);
  16326. return make_sequence(self, args).optimize(compressor);
  16327. }
  16328. // optimize identity function
  16329. if (
  16330. fn.argnames.length === 1
  16331. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  16332. && self.args.length < 2
  16333. && !(self.args[0] instanceof AST_Expansion)
  16334. && returned instanceof AST_SymbolRef
  16335. && returned.name === fn.argnames[0].name
  16336. ) {
  16337. const replacement =
  16338. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  16339. let parent;
  16340. if (
  16341. replacement instanceof AST_PropAccess
  16342. && (parent = compressor.parent()) instanceof AST_Call
  16343. && parent.expression === self
  16344. ) {
  16345. // identity function was being used to remove `this`, like in
  16346. //
  16347. // id(bag.no_this)(...)
  16348. //
  16349. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  16350. return make_sequence(self, [
  16351. make_node(AST_Number, self, { value: 0 }),
  16352. replacement
  16353. ]);
  16354. }
  16355. // replace call with first argument or undefined if none passed
  16356. return replacement;
  16357. }
  16358. }
  16359. if (can_inline) {
  16360. var scope, in_loop, level = -1;
  16361. let def;
  16362. let returned_value;
  16363. let nearest_scope;
  16364. if (simple_args
  16365. && !fn.uses_arguments
  16366. && !(compressor.parent() instanceof AST_Class)
  16367. && !(fn.name && fn instanceof AST_Function)
  16368. && (returned_value = can_flatten_body(stat))
  16369. && (exp === fn
  16370. || has_annotation(self, _INLINE)
  16371. || compressor.option("unused")
  16372. && (def = exp.definition()).references.length == 1
  16373. && !is_recursive_ref(compressor, def)
  16374. && fn.is_constant_expression(exp.scope))
  16375. && !has_annotation(self, _PURE | _NOINLINE)
  16376. && !fn.contains_this()
  16377. && can_inject_symbols()
  16378. && (nearest_scope = compressor.find_scope())
  16379. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  16380. && !(function in_default_assign() {
  16381. // Due to the fact function parameters have their own scope
  16382. // which can't use `var something` in the function body within,
  16383. // we simply don't inline into DefaultAssign.
  16384. let i = 0;
  16385. let p;
  16386. while ((p = compressor.parent(i++))) {
  16387. if (p instanceof AST_DefaultAssign) return true;
  16388. if (p instanceof AST_Block) break;
  16389. }
  16390. return false;
  16391. })()
  16392. && !(scope instanceof AST_Class)
  16393. ) {
  16394. set_flag(fn, SQUEEZED);
  16395. nearest_scope.add_child_scope(fn);
  16396. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  16397. }
  16398. }
  16399. if (can_inline && has_annotation(self, _INLINE)) {
  16400. set_flag(fn, SQUEEZED);
  16401. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  16402. fn = fn.clone(true);
  16403. fn.figure_out_scope({}, {
  16404. parent_scope: compressor.find_scope(),
  16405. toplevel: compressor.get_toplevel()
  16406. });
  16407. return make_node(AST_Call, self, {
  16408. expression: fn,
  16409. args: self.args,
  16410. }).optimize(compressor);
  16411. }
  16412. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  16413. if (can_drop_this_call) {
  16414. var args = self.args.concat(make_node(AST_Undefined, self));
  16415. return make_sequence(self, args).optimize(compressor);
  16416. }
  16417. if (compressor.option("negate_iife")
  16418. && compressor.parent() instanceof AST_SimpleStatement
  16419. && is_iife_call(self)) {
  16420. return self.negate(compressor, true);
  16421. }
  16422. var ev = self.evaluate(compressor);
  16423. if (ev !== self) {
  16424. ev = make_node_from_constant(ev, self).optimize(compressor);
  16425. return best_of(compressor, ev, self);
  16426. }
  16427. return self;
  16428. function return_value(stat) {
  16429. if (!stat) return make_node(AST_Undefined, self);
  16430. if (stat instanceof AST_Return) {
  16431. if (!stat.value) return make_node(AST_Undefined, self);
  16432. return stat.value.clone(true);
  16433. }
  16434. if (stat instanceof AST_SimpleStatement) {
  16435. return make_node(AST_UnaryPrefix, stat, {
  16436. operator: "void",
  16437. expression: stat.body.clone(true)
  16438. });
  16439. }
  16440. }
  16441. function can_flatten_body(stat) {
  16442. var body = fn.body;
  16443. var len = body.length;
  16444. if (compressor.option("inline") < 3) {
  16445. return len == 1 && return_value(stat);
  16446. }
  16447. stat = null;
  16448. for (var i = 0; i < len; i++) {
  16449. var line = body[i];
  16450. if (line instanceof AST_Var) {
  16451. if (stat && !line.definitions.every((var_def) =>
  16452. !var_def.value
  16453. )) {
  16454. return false;
  16455. }
  16456. } else if (stat) {
  16457. return false;
  16458. } else if (!(line instanceof AST_EmptyStatement)) {
  16459. stat = line;
  16460. }
  16461. }
  16462. return return_value(stat);
  16463. }
  16464. function can_inject_args(block_scoped, safe_to_inject) {
  16465. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  16466. var arg = fn.argnames[i];
  16467. if (arg instanceof AST_DefaultAssign) {
  16468. if (has_flag(arg.left, UNUSED)) continue;
  16469. return false;
  16470. }
  16471. if (arg instanceof AST_Destructuring) return false;
  16472. if (arg instanceof AST_Expansion) {
  16473. if (has_flag(arg.expression, UNUSED)) continue;
  16474. return false;
  16475. }
  16476. if (has_flag(arg, UNUSED)) continue;
  16477. if (!safe_to_inject
  16478. || block_scoped.has(arg.name)
  16479. || identifier_atom.has(arg.name)
  16480. || scope.conflicting_def(arg.name)) {
  16481. return false;
  16482. }
  16483. if (in_loop) in_loop.push(arg.definition());
  16484. }
  16485. return true;
  16486. }
  16487. function can_inject_vars(block_scoped, safe_to_inject) {
  16488. var len = fn.body.length;
  16489. for (var i = 0; i < len; i++) {
  16490. var stat = fn.body[i];
  16491. if (!(stat instanceof AST_Var)) continue;
  16492. if (!safe_to_inject) return false;
  16493. for (var j = stat.definitions.length; --j >= 0;) {
  16494. var name = stat.definitions[j].name;
  16495. if (name instanceof AST_Destructuring
  16496. || block_scoped.has(name.name)
  16497. || identifier_atom.has(name.name)
  16498. || scope.conflicting_def(name.name)) {
  16499. return false;
  16500. }
  16501. if (in_loop) in_loop.push(name.definition());
  16502. }
  16503. }
  16504. return true;
  16505. }
  16506. function can_inject_symbols() {
  16507. var block_scoped = new Set();
  16508. do {
  16509. scope = compressor.parent(++level);
  16510. if (scope.is_block_scope() && scope.block_scope) {
  16511. // TODO this is sometimes undefined during compression.
  16512. // But it should always have a value!
  16513. scope.block_scope.variables.forEach(function (variable) {
  16514. block_scoped.add(variable.name);
  16515. });
  16516. }
  16517. if (scope instanceof AST_Catch) {
  16518. // TODO can we delete? AST_Catch is a block scope.
  16519. if (scope.argname) {
  16520. block_scoped.add(scope.argname.name);
  16521. }
  16522. } else if (scope instanceof AST_IterationStatement) {
  16523. in_loop = [];
  16524. } else if (scope instanceof AST_SymbolRef) {
  16525. if (scope.fixed_value() instanceof AST_Scope) return false;
  16526. }
  16527. } while (!(scope instanceof AST_Scope));
  16528. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  16529. var inline = compressor.option("inline");
  16530. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  16531. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  16532. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  16533. }
  16534. function append_var(decls, expressions, name, value) {
  16535. var def = name.definition();
  16536. // Name already exists, only when a function argument had the same name
  16537. const already_appended = scope.variables.has(name.name);
  16538. if (!already_appended) {
  16539. scope.variables.set(name.name, def);
  16540. scope.enclosed.push(def);
  16541. decls.push(make_node(AST_VarDef, name, {
  16542. name: name,
  16543. value: null
  16544. }));
  16545. }
  16546. var sym = make_node(AST_SymbolRef, name, name);
  16547. def.references.push(sym);
  16548. if (value) expressions.push(make_node(AST_Assign, self, {
  16549. operator: "=",
  16550. logical: false,
  16551. left: sym,
  16552. right: value.clone()
  16553. }));
  16554. }
  16555. function flatten_args(decls, expressions) {
  16556. var len = fn.argnames.length;
  16557. for (var i = self.args.length; --i >= len;) {
  16558. expressions.push(self.args[i]);
  16559. }
  16560. for (i = len; --i >= 0;) {
  16561. var name = fn.argnames[i];
  16562. var value = self.args[i];
  16563. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  16564. if (value) expressions.push(value);
  16565. } else {
  16566. var symbol = make_node(AST_SymbolVar, name, name);
  16567. name.definition().orig.push(symbol);
  16568. if (!value && in_loop) value = make_node(AST_Undefined, self);
  16569. append_var(decls, expressions, symbol, value);
  16570. }
  16571. }
  16572. decls.reverse();
  16573. expressions.reverse();
  16574. }
  16575. function flatten_vars(decls, expressions) {
  16576. var pos = expressions.length;
  16577. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  16578. var stat = fn.body[i];
  16579. if (!(stat instanceof AST_Var)) continue;
  16580. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  16581. var var_def = stat.definitions[j];
  16582. var name = var_def.name;
  16583. append_var(decls, expressions, name, var_def.value);
  16584. if (in_loop && fn.argnames.every((argname) =>
  16585. argname.name != name.name
  16586. )) {
  16587. var def = fn.variables.get(name.name);
  16588. var sym = make_node(AST_SymbolRef, name, name);
  16589. def.references.push(sym);
  16590. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  16591. operator: "=",
  16592. logical: false,
  16593. left: sym,
  16594. right: make_node(AST_Undefined, name)
  16595. }));
  16596. }
  16597. }
  16598. }
  16599. }
  16600. function flatten_fn(returned_value) {
  16601. var decls = [];
  16602. var expressions = [];
  16603. flatten_args(decls, expressions);
  16604. flatten_vars(decls, expressions);
  16605. expressions.push(returned_value);
  16606. if (decls.length) {
  16607. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  16608. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  16609. definitions: decls
  16610. }));
  16611. }
  16612. return expressions.map(exp => exp.clone(true));
  16613. }
  16614. }
  16615. (function(def_find_defs) {
  16616. function to_node(value, orig) {
  16617. if (value instanceof AST_Node) {
  16618. if (!(value instanceof AST_Constant)) {
  16619. // Value may be a function, an array including functions and even a complex assign / block expression,
  16620. // so it should never be shared in different places.
  16621. // Otherwise wrong information may be used in the compression phase
  16622. value = value.clone(true);
  16623. }
  16624. return make_node(value.CTOR, orig, value);
  16625. }
  16626. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  16627. elements: value.map(function(value) {
  16628. return to_node(value, orig);
  16629. })
  16630. });
  16631. if (value && typeof value == "object") {
  16632. var props = [];
  16633. for (var key in value) if (HOP(value, key)) {
  16634. props.push(make_node(AST_ObjectKeyVal, orig, {
  16635. key: key,
  16636. value: to_node(value[key], orig)
  16637. }));
  16638. }
  16639. return make_node(AST_Object, orig, {
  16640. properties: props
  16641. });
  16642. }
  16643. return make_node_from_constant(value, orig);
  16644. }
  16645. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  16646. if (!compressor.option("global_defs")) return this;
  16647. this.figure_out_scope({ ie8: compressor.option("ie8") });
  16648. return this.transform(new TreeTransformer(function(node) {
  16649. var def = node._find_defs(compressor, "");
  16650. if (!def) return;
  16651. var level = 0, child = node, parent;
  16652. while (parent = this.parent(level++)) {
  16653. if (!(parent instanceof AST_PropAccess)) break;
  16654. if (parent.expression !== child) break;
  16655. child = parent;
  16656. }
  16657. if (is_lhs(child, parent)) {
  16658. return;
  16659. }
  16660. return def;
  16661. }));
  16662. });
  16663. def_find_defs(AST_Node, noop);
  16664. def_find_defs(AST_Chain, function(compressor, suffix) {
  16665. return this.expression._find_defs(compressor, suffix);
  16666. });
  16667. def_find_defs(AST_Dot, function(compressor, suffix) {
  16668. return this.expression._find_defs(compressor, "." + this.property + suffix);
  16669. });
  16670. def_find_defs(AST_SymbolDeclaration, function() {
  16671. if (!this.global()) return;
  16672. });
  16673. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  16674. if (!this.global()) return;
  16675. var defines = compressor.option("global_defs");
  16676. var name = this.name + suffix;
  16677. if (HOP(defines, name)) return to_node(defines[name], this);
  16678. });
  16679. def_find_defs(AST_ImportMeta, function(compressor, suffix) {
  16680. var defines = compressor.option("global_defs");
  16681. var name = "import.meta" + suffix;
  16682. if (HOP(defines, name)) return to_node(defines[name], this);
  16683. });
  16684. })(function(node, func) {
  16685. node.DEFMETHOD("_find_defs", func);
  16686. });
  16687. /***********************************************************************
  16688. A JavaScript tokenizer / parser / beautifier / compressor.
  16689. https://github.com/mishoo/UglifyJS2
  16690. -------------------------------- (C) ---------------------------------
  16691. Author: Mihai Bazon
  16692. <mihai.bazon@gmail.com>
  16693. http://mihai.bazon.net/blog
  16694. Distributed under the BSD license:
  16695. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16696. Redistribution and use in source and binary forms, with or without
  16697. modification, are permitted provided that the following conditions
  16698. are met:
  16699. * Redistributions of source code must retain the above
  16700. copyright notice, this list of conditions and the following
  16701. disclaimer.
  16702. * Redistributions in binary form must reproduce the above
  16703. copyright notice, this list of conditions and the following
  16704. disclaimer in the documentation and/or other materials
  16705. provided with the distribution.
  16706. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16707. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16708. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16709. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16710. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16711. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16712. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16713. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16714. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16715. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16716. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16717. SUCH DAMAGE.
  16718. ***********************************************************************/
  16719. class Compressor extends TreeWalker {
  16720. constructor(options, { false_by_default = false, mangle_options = false }) {
  16721. super();
  16722. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  16723. this.options = defaults(options, {
  16724. arguments : false,
  16725. arrows : !false_by_default,
  16726. booleans : !false_by_default,
  16727. booleans_as_integers : false,
  16728. collapse_vars : !false_by_default,
  16729. comparisons : !false_by_default,
  16730. computed_props: !false_by_default,
  16731. conditionals : !false_by_default,
  16732. dead_code : !false_by_default,
  16733. defaults : true,
  16734. directives : !false_by_default,
  16735. drop_console : false,
  16736. drop_debugger : !false_by_default,
  16737. ecma : 5,
  16738. evaluate : !false_by_default,
  16739. expression : false,
  16740. global_defs : false,
  16741. hoist_funs : false,
  16742. hoist_props : !false_by_default,
  16743. hoist_vars : false,
  16744. ie8 : false,
  16745. if_return : !false_by_default,
  16746. inline : !false_by_default,
  16747. join_vars : !false_by_default,
  16748. keep_classnames: false,
  16749. keep_fargs : true,
  16750. keep_fnames : false,
  16751. keep_infinity : false,
  16752. lhs_constants : !false_by_default,
  16753. loops : !false_by_default,
  16754. module : false,
  16755. negate_iife : !false_by_default,
  16756. passes : 1,
  16757. properties : !false_by_default,
  16758. pure_getters : !false_by_default && "strict",
  16759. pure_funcs : null,
  16760. pure_new : false,
  16761. reduce_funcs : !false_by_default,
  16762. reduce_vars : !false_by_default,
  16763. sequences : !false_by_default,
  16764. side_effects : !false_by_default,
  16765. switches : !false_by_default,
  16766. top_retain : null,
  16767. toplevel : !!(options && options["top_retain"]),
  16768. typeofs : !false_by_default,
  16769. unsafe : false,
  16770. unsafe_arrows : false,
  16771. unsafe_comps : false,
  16772. unsafe_Function: false,
  16773. unsafe_math : false,
  16774. unsafe_symbols: false,
  16775. unsafe_methods: false,
  16776. unsafe_proto : false,
  16777. unsafe_regexp : false,
  16778. unsafe_undefined: false,
  16779. unused : !false_by_default,
  16780. warnings : false // legacy
  16781. }, true);
  16782. var global_defs = this.options["global_defs"];
  16783. if (typeof global_defs == "object") for (var key in global_defs) {
  16784. if (key[0] === "@" && HOP(global_defs, key)) {
  16785. global_defs[key.slice(1)] = parse(global_defs[key], {
  16786. expression: true
  16787. });
  16788. }
  16789. }
  16790. if (this.options["inline"] === true) this.options["inline"] = 3;
  16791. var pure_funcs = this.options["pure_funcs"];
  16792. if (typeof pure_funcs == "function") {
  16793. this.pure_funcs = pure_funcs;
  16794. } else {
  16795. this.pure_funcs = pure_funcs ? function(node) {
  16796. return !pure_funcs.includes(node.expression.print_to_string());
  16797. } : return_true;
  16798. }
  16799. var top_retain = this.options["top_retain"];
  16800. if (top_retain instanceof RegExp) {
  16801. this.top_retain = function(def) {
  16802. return top_retain.test(def.name);
  16803. };
  16804. } else if (typeof top_retain == "function") {
  16805. this.top_retain = top_retain;
  16806. } else if (top_retain) {
  16807. if (typeof top_retain == "string") {
  16808. top_retain = top_retain.split(/,/);
  16809. }
  16810. this.top_retain = function(def) {
  16811. return top_retain.includes(def.name);
  16812. };
  16813. }
  16814. if (this.options["module"]) {
  16815. this.directives["use strict"] = true;
  16816. this.options["toplevel"] = true;
  16817. }
  16818. var toplevel = this.options["toplevel"];
  16819. this.toplevel = typeof toplevel == "string" ? {
  16820. funcs: /funcs/.test(toplevel),
  16821. vars: /vars/.test(toplevel)
  16822. } : {
  16823. funcs: toplevel,
  16824. vars: toplevel
  16825. };
  16826. var sequences = this.options["sequences"];
  16827. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  16828. this.evaluated_regexps = new Map();
  16829. this._toplevel = undefined;
  16830. this._mangle_options = mangle_options
  16831. ? format_mangler_options(mangle_options)
  16832. : mangle_options;
  16833. }
  16834. mangle_options() {
  16835. var nth_identifier = this._mangle_options && this._mangle_options.nth_identifier || base54;
  16836. var module = this._mangle_options && this._mangle_options.module || this.option("module");
  16837. return { ie8: this.option("ie8"), nth_identifier, module };
  16838. }
  16839. option(key) {
  16840. return this.options[key];
  16841. }
  16842. exposed(def) {
  16843. if (def.export) return true;
  16844. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  16845. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  16846. return true;
  16847. return false;
  16848. }
  16849. in_boolean_context() {
  16850. if (!this.option("booleans")) return false;
  16851. var self = this.self();
  16852. for (var i = 0, p; p = this.parent(i); i++) {
  16853. if (p instanceof AST_SimpleStatement
  16854. || p instanceof AST_Conditional && p.condition === self
  16855. || p instanceof AST_DWLoop && p.condition === self
  16856. || p instanceof AST_For && p.condition === self
  16857. || p instanceof AST_If && p.condition === self
  16858. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  16859. return true;
  16860. }
  16861. if (
  16862. p instanceof AST_Binary
  16863. && (
  16864. p.operator == "&&"
  16865. || p.operator == "||"
  16866. || p.operator == "??"
  16867. )
  16868. || p instanceof AST_Conditional
  16869. || p.tail_node() === self
  16870. ) {
  16871. self = p;
  16872. } else {
  16873. return false;
  16874. }
  16875. }
  16876. }
  16877. in_32_bit_context() {
  16878. if (!this.option("evaluate")) return false;
  16879. var self = this.self();
  16880. for (var i = 0, p; p = this.parent(i); i++) {
  16881. if (p instanceof AST_Binary && bitwise_binop.has(p.operator)) {
  16882. return true;
  16883. }
  16884. if (p instanceof AST_UnaryPrefix) {
  16885. return p.operator === "~";
  16886. }
  16887. if (
  16888. p instanceof AST_Binary
  16889. && (
  16890. p.operator == "&&"
  16891. || p.operator == "||"
  16892. || p.operator == "??"
  16893. )
  16894. || p instanceof AST_Conditional && p.condition !== self
  16895. || p.tail_node() === self
  16896. ) {
  16897. self = p;
  16898. } else {
  16899. return false;
  16900. }
  16901. }
  16902. }
  16903. in_computed_key() {
  16904. if (!this.option("evaluate")) return false;
  16905. var self = this.self();
  16906. for (var i = 0, p; p = this.parent(i); i++) {
  16907. if (p instanceof AST_ObjectProperty && p.key === self) {
  16908. return true;
  16909. }
  16910. }
  16911. return false;
  16912. }
  16913. get_toplevel() {
  16914. return this._toplevel;
  16915. }
  16916. compress(toplevel) {
  16917. toplevel = toplevel.resolve_defines(this);
  16918. this._toplevel = toplevel;
  16919. if (this.option("expression")) {
  16920. this._toplevel.process_expression(true);
  16921. }
  16922. var passes = +this.options.passes || 1;
  16923. var min_count = 1 / 0;
  16924. var stopping = false;
  16925. var mangle = this.mangle_options();
  16926. for (var pass = 0; pass < passes; pass++) {
  16927. this._toplevel.figure_out_scope(mangle);
  16928. if (pass === 0 && this.option("drop_console")) {
  16929. // must be run before reduce_vars and compress pass
  16930. this._toplevel = this._toplevel.drop_console(this.option("drop_console"));
  16931. }
  16932. if (pass > 0 || this.option("reduce_vars")) {
  16933. this._toplevel.reset_opt_flags(this);
  16934. }
  16935. this._toplevel = this._toplevel.transform(this);
  16936. if (passes > 1) {
  16937. let count = 0;
  16938. walk(this._toplevel, () => { count++; });
  16939. if (count < min_count) {
  16940. min_count = count;
  16941. stopping = false;
  16942. } else if (stopping) {
  16943. break;
  16944. } else {
  16945. stopping = true;
  16946. }
  16947. }
  16948. }
  16949. if (this.option("expression")) {
  16950. this._toplevel.process_expression(false);
  16951. }
  16952. toplevel = this._toplevel;
  16953. this._toplevel = undefined;
  16954. return toplevel;
  16955. }
  16956. before(node, descend) {
  16957. if (has_flag(node, SQUEEZED)) return node;
  16958. var was_scope = false;
  16959. if (node instanceof AST_Scope) {
  16960. node = node.hoist_properties(this);
  16961. node = node.hoist_declarations(this);
  16962. was_scope = true;
  16963. }
  16964. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  16965. // would call AST_Node.transform() if a different instance of AST_Node is
  16966. // produced after def_optimize().
  16967. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  16968. // Migrate and defer all children's AST_Node.transform() to below, which
  16969. // will now happen after this parent AST_Node has been properly substituted
  16970. // thus gives a consistent AST snapshot.
  16971. descend(node, this);
  16972. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  16973. // following replacement call would result in degraded efficiency of both
  16974. // output and performance.
  16975. descend(node, this);
  16976. var opt = node.optimize(this);
  16977. if (was_scope && opt instanceof AST_Scope) {
  16978. opt.drop_unused(this);
  16979. descend(opt, this);
  16980. }
  16981. if (opt === node) set_flag(opt, SQUEEZED);
  16982. return opt;
  16983. }
  16984. /** Alternative to plain is_lhs() which doesn't work within .optimize() */
  16985. is_lhs() {
  16986. const self = this.stack[this.stack.length - 1];
  16987. const parent = this.stack[this.stack.length - 2];
  16988. return is_lhs(self, parent);
  16989. }
  16990. }
  16991. function def_optimize(node, optimizer) {
  16992. node.DEFMETHOD("optimize", function(compressor) {
  16993. var self = this;
  16994. if (has_flag(self, OPTIMIZED)) return self;
  16995. if (compressor.has_directive("use asm")) return self;
  16996. var opt = optimizer(self, compressor);
  16997. set_flag(opt, OPTIMIZED);
  16998. return opt;
  16999. });
  17000. }
  17001. def_optimize(AST_Node, function(self) {
  17002. return self;
  17003. });
  17004. AST_Toplevel.DEFMETHOD("drop_console", function(options) {
  17005. var isArray = Array.isArray(options);
  17006. return this.transform(new TreeTransformer(function(self) {
  17007. if (self.TYPE !== "Call") {
  17008. return;
  17009. }
  17010. var exp = self.expression;
  17011. if (!(exp instanceof AST_PropAccess)) {
  17012. return;
  17013. }
  17014. if (isArray && options.indexOf(exp.property) === -1) {
  17015. return;
  17016. }
  17017. var name = exp.expression;
  17018. while (name.expression) {
  17019. name = name.expression;
  17020. }
  17021. if (is_undeclared_ref(name) && name.name == "console") {
  17022. return make_node(AST_Undefined, self);
  17023. }
  17024. }));
  17025. });
  17026. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  17027. return equivalent_to(this, node);
  17028. });
  17029. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  17030. var self = this;
  17031. var tt = new TreeTransformer(function(node) {
  17032. if (insert && node instanceof AST_SimpleStatement) {
  17033. return make_node(AST_Return, node, {
  17034. value: node.body
  17035. });
  17036. }
  17037. if (!insert && node instanceof AST_Return) {
  17038. if (compressor) {
  17039. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  17040. return value
  17041. ? make_node(AST_SimpleStatement, node, { body: value })
  17042. : make_node(AST_EmptyStatement, node);
  17043. }
  17044. return make_node(AST_SimpleStatement, node, {
  17045. body: node.value || make_node(AST_UnaryPrefix, node, {
  17046. operator: "void",
  17047. expression: make_node(AST_Number, node, {
  17048. value: 0
  17049. })
  17050. })
  17051. });
  17052. }
  17053. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  17054. return node;
  17055. }
  17056. if (node instanceof AST_Block) {
  17057. var index = node.body.length - 1;
  17058. if (index >= 0) {
  17059. node.body[index] = node.body[index].transform(tt);
  17060. }
  17061. } else if (node instanceof AST_If) {
  17062. node.body = node.body.transform(tt);
  17063. if (node.alternative) {
  17064. node.alternative = node.alternative.transform(tt);
  17065. }
  17066. } else if (node instanceof AST_With) {
  17067. node.body = node.body.transform(tt);
  17068. }
  17069. return node;
  17070. });
  17071. self.transform(tt);
  17072. });
  17073. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  17074. const self = this;
  17075. const reduce_vars = compressor.option("reduce_vars");
  17076. const preparation = new TreeWalker(function(node, descend) {
  17077. clear_flag(node, CLEAR_BETWEEN_PASSES);
  17078. if (reduce_vars) {
  17079. if (compressor.top_retain
  17080. && node instanceof AST_Defun // Only functions are retained
  17081. && preparation.parent() === self
  17082. ) {
  17083. set_flag(node, TOP);
  17084. }
  17085. return node.reduce_vars(preparation, descend, compressor);
  17086. }
  17087. });
  17088. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  17089. // properly assigned before use:
  17090. // - `push()` & `pop()` when visiting conditional branches
  17091. preparation.safe_ids = Object.create(null);
  17092. preparation.in_loop = null;
  17093. preparation.loop_ids = new Map();
  17094. preparation.defs_to_safe_ids = new Map();
  17095. self.walk(preparation);
  17096. });
  17097. AST_Symbol.DEFMETHOD("fixed_value", function() {
  17098. var fixed = this.thedef.fixed;
  17099. if (!fixed || fixed instanceof AST_Node) return fixed;
  17100. return fixed();
  17101. });
  17102. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  17103. var orig = this.definition().orig;
  17104. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  17105. });
  17106. function find_variable(compressor, name) {
  17107. var scope, i = 0;
  17108. while (scope = compressor.parent(i++)) {
  17109. if (scope instanceof AST_Scope) break;
  17110. if (scope instanceof AST_Catch && scope.argname) {
  17111. scope = scope.argname.definition().scope;
  17112. break;
  17113. }
  17114. }
  17115. return scope.find_variable(name);
  17116. }
  17117. 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");
  17118. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  17119. return !this.definition().undeclared
  17120. || compressor.option("unsafe") && global_names.has(this.name);
  17121. });
  17122. /* -----[ optimizers ]----- */
  17123. var directives = new Set(["use asm", "use strict"]);
  17124. def_optimize(AST_Directive, function(self, compressor) {
  17125. if (compressor.option("directives")
  17126. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  17127. return make_node(AST_EmptyStatement, self);
  17128. }
  17129. return self;
  17130. });
  17131. def_optimize(AST_Debugger, function(self, compressor) {
  17132. if (compressor.option("drop_debugger"))
  17133. return make_node(AST_EmptyStatement, self);
  17134. return self;
  17135. });
  17136. def_optimize(AST_LabeledStatement, function(self, compressor) {
  17137. if (self.body instanceof AST_Break
  17138. && compressor.loopcontrol_target(self.body) === self.body) {
  17139. return make_node(AST_EmptyStatement, self);
  17140. }
  17141. return self.label.references.length == 0 ? self.body : self;
  17142. });
  17143. def_optimize(AST_Block, function(self, compressor) {
  17144. tighten_body(self.body, compressor);
  17145. return self;
  17146. });
  17147. function can_be_extracted_from_if_block(node) {
  17148. return !(
  17149. node instanceof AST_Const
  17150. || node instanceof AST_Let
  17151. || node instanceof AST_Class
  17152. );
  17153. }
  17154. def_optimize(AST_BlockStatement, function(self, compressor) {
  17155. tighten_body(self.body, compressor);
  17156. switch (self.body.length) {
  17157. case 1:
  17158. if (!compressor.has_directive("use strict")
  17159. && compressor.parent() instanceof AST_If
  17160. && can_be_extracted_from_if_block(self.body[0])
  17161. || can_be_evicted_from_block(self.body[0])) {
  17162. return self.body[0];
  17163. }
  17164. break;
  17165. case 0: return make_node(AST_EmptyStatement, self);
  17166. }
  17167. return self;
  17168. });
  17169. function opt_AST_Lambda(self, compressor) {
  17170. tighten_body(self.body, compressor);
  17171. if (compressor.option("side_effects")
  17172. && self.body.length == 1
  17173. && self.body[0] === compressor.has_directive("use strict")) {
  17174. self.body.length = 0;
  17175. }
  17176. return self;
  17177. }
  17178. def_optimize(AST_Lambda, opt_AST_Lambda);
  17179. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  17180. var self = this;
  17181. if (compressor.has_directive("use asm")) return self;
  17182. var hoist_funs = compressor.option("hoist_funs");
  17183. var hoist_vars = compressor.option("hoist_vars");
  17184. if (hoist_funs || hoist_vars) {
  17185. var dirs = [];
  17186. var hoisted = [];
  17187. var vars = new Map(), vars_found = 0, var_decl = 0;
  17188. // let's count var_decl first, we seem to waste a lot of
  17189. // space if we hoist `var` when there's only one.
  17190. walk(self, node => {
  17191. if (node instanceof AST_Scope && node !== self)
  17192. return true;
  17193. if (node instanceof AST_Var) {
  17194. ++var_decl;
  17195. return true;
  17196. }
  17197. });
  17198. hoist_vars = hoist_vars && var_decl > 1;
  17199. var tt = new TreeTransformer(
  17200. function before(node) {
  17201. if (node !== self) {
  17202. if (node instanceof AST_Directive) {
  17203. dirs.push(node);
  17204. return make_node(AST_EmptyStatement, node);
  17205. }
  17206. if (hoist_funs && node instanceof AST_Defun
  17207. && !(tt.parent() instanceof AST_Export)
  17208. && tt.parent() === self) {
  17209. hoisted.push(node);
  17210. return make_node(AST_EmptyStatement, node);
  17211. }
  17212. if (
  17213. hoist_vars
  17214. && node instanceof AST_Var
  17215. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  17216. ) {
  17217. node.definitions.forEach(function(def) {
  17218. vars.set(def.name.name, def);
  17219. ++vars_found;
  17220. });
  17221. var seq = node.to_assignments(compressor);
  17222. var p = tt.parent();
  17223. if (p instanceof AST_ForIn && p.init === node) {
  17224. if (seq == null) {
  17225. var def = node.definitions[0].name;
  17226. return make_node(AST_SymbolRef, def, def);
  17227. }
  17228. return seq;
  17229. }
  17230. if (p instanceof AST_For && p.init === node) {
  17231. return seq;
  17232. }
  17233. if (!seq) return make_node(AST_EmptyStatement, node);
  17234. return make_node(AST_SimpleStatement, node, {
  17235. body: seq
  17236. });
  17237. }
  17238. if (node instanceof AST_Scope)
  17239. return node; // to avoid descending in nested scopes
  17240. }
  17241. }
  17242. );
  17243. self = self.transform(tt);
  17244. if (vars_found > 0) {
  17245. // collect only vars which don't show up in self's arguments list
  17246. var defs = [];
  17247. const is_lambda = self instanceof AST_Lambda;
  17248. const args_as_names = is_lambda ? self.args_as_names() : null;
  17249. vars.forEach((def, name) => {
  17250. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  17251. vars.delete(name);
  17252. } else {
  17253. def = def.clone();
  17254. def.value = null;
  17255. defs.push(def);
  17256. vars.set(name, def);
  17257. }
  17258. });
  17259. if (defs.length > 0) {
  17260. // try to merge in assignments
  17261. for (var i = 0; i < self.body.length;) {
  17262. if (self.body[i] instanceof AST_SimpleStatement) {
  17263. var expr = self.body[i].body, sym, assign;
  17264. if (expr instanceof AST_Assign
  17265. && expr.operator == "="
  17266. && (sym = expr.left) instanceof AST_Symbol
  17267. && vars.has(sym.name)
  17268. ) {
  17269. var def = vars.get(sym.name);
  17270. if (def.value) break;
  17271. def.value = expr.right;
  17272. remove(defs, def);
  17273. defs.push(def);
  17274. self.body.splice(i, 1);
  17275. continue;
  17276. }
  17277. if (expr instanceof AST_Sequence
  17278. && (assign = expr.expressions[0]) instanceof AST_Assign
  17279. && assign.operator == "="
  17280. && (sym = assign.left) instanceof AST_Symbol
  17281. && vars.has(sym.name)
  17282. ) {
  17283. var def = vars.get(sym.name);
  17284. if (def.value) break;
  17285. def.value = assign.right;
  17286. remove(defs, def);
  17287. defs.push(def);
  17288. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  17289. continue;
  17290. }
  17291. }
  17292. if (self.body[i] instanceof AST_EmptyStatement) {
  17293. self.body.splice(i, 1);
  17294. continue;
  17295. }
  17296. if (self.body[i] instanceof AST_BlockStatement) {
  17297. self.body.splice(i, 1, ...self.body[i].body);
  17298. continue;
  17299. }
  17300. break;
  17301. }
  17302. defs = make_node(AST_Var, self, {
  17303. definitions: defs
  17304. });
  17305. hoisted.push(defs);
  17306. }
  17307. }
  17308. self.body = dirs.concat(hoisted, self.body);
  17309. }
  17310. return self;
  17311. });
  17312. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  17313. var self = this;
  17314. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  17315. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  17316. var defs_by_id = new Map();
  17317. var hoister = new TreeTransformer(function(node, descend) {
  17318. if (node instanceof AST_VarDef) {
  17319. const sym = node.name;
  17320. let def;
  17321. let value;
  17322. if (sym.scope === self
  17323. && (def = sym.definition()).escaped != 1
  17324. && !def.assignments
  17325. && !def.direct_access
  17326. && !def.single_use
  17327. && !compressor.exposed(def)
  17328. && !top_retain(def)
  17329. && (value = sym.fixed_value()) === node.value
  17330. && value instanceof AST_Object
  17331. && !value.properties.some(prop =>
  17332. prop instanceof AST_Expansion || prop.computed_key()
  17333. )
  17334. ) {
  17335. descend(node, this);
  17336. const defs = new Map();
  17337. const assignments = [];
  17338. value.properties.forEach(({ key, value }) => {
  17339. const scope = hoister.find_scope();
  17340. const symbol = self.create_symbol(sym.CTOR, {
  17341. source: sym,
  17342. scope,
  17343. conflict_scopes: new Set([
  17344. scope,
  17345. ...sym.definition().references.map(ref => ref.scope)
  17346. ]),
  17347. tentative_name: sym.name + "_" + key
  17348. });
  17349. defs.set(String(key), symbol.definition());
  17350. assignments.push(make_node(AST_VarDef, node, {
  17351. name: symbol,
  17352. value
  17353. }));
  17354. });
  17355. defs_by_id.set(def.id, defs);
  17356. return MAP.splice(assignments);
  17357. }
  17358. } else if (node instanceof AST_PropAccess
  17359. && node.expression instanceof AST_SymbolRef
  17360. ) {
  17361. const defs = defs_by_id.get(node.expression.definition().id);
  17362. if (defs) {
  17363. const def = defs.get(String(get_simple_key(node.property)));
  17364. const sym = make_node(AST_SymbolRef, node, {
  17365. name: def.name,
  17366. scope: node.expression.scope,
  17367. thedef: def
  17368. });
  17369. sym.reference({});
  17370. return sym;
  17371. }
  17372. }
  17373. });
  17374. return self.transform(hoister);
  17375. });
  17376. def_optimize(AST_SimpleStatement, function(self, compressor) {
  17377. if (compressor.option("side_effects")) {
  17378. var body = self.body;
  17379. var node = body.drop_side_effect_free(compressor, true);
  17380. if (!node) {
  17381. return make_node(AST_EmptyStatement, self);
  17382. }
  17383. if (node !== body) {
  17384. return make_node(AST_SimpleStatement, self, { body: node });
  17385. }
  17386. }
  17387. return self;
  17388. });
  17389. def_optimize(AST_While, function(self, compressor) {
  17390. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  17391. });
  17392. def_optimize(AST_Do, function(self, compressor) {
  17393. if (!compressor.option("loops")) return self;
  17394. var cond = self.condition.tail_node().evaluate(compressor);
  17395. if (!(cond instanceof AST_Node)) {
  17396. if (cond) return make_node(AST_For, self, {
  17397. body: make_node(AST_BlockStatement, self.body, {
  17398. body: [
  17399. self.body,
  17400. make_node(AST_SimpleStatement, self.condition, {
  17401. body: self.condition
  17402. })
  17403. ]
  17404. })
  17405. }).optimize(compressor);
  17406. if (!has_break_or_continue(self, compressor.parent())) {
  17407. return make_node(AST_BlockStatement, self.body, {
  17408. body: [
  17409. self.body,
  17410. make_node(AST_SimpleStatement, self.condition, {
  17411. body: self.condition
  17412. })
  17413. ]
  17414. }).optimize(compressor);
  17415. }
  17416. }
  17417. return self;
  17418. });
  17419. function if_break_in_loop(self, compressor) {
  17420. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  17421. if (compressor.option("dead_code") && is_break(first)) {
  17422. var body = [];
  17423. if (self.init instanceof AST_Statement) {
  17424. body.push(self.init);
  17425. } else if (self.init) {
  17426. body.push(make_node(AST_SimpleStatement, self.init, {
  17427. body: self.init
  17428. }));
  17429. }
  17430. if (self.condition) {
  17431. body.push(make_node(AST_SimpleStatement, self.condition, {
  17432. body: self.condition
  17433. }));
  17434. }
  17435. trim_unreachable_code(compressor, self.body, body);
  17436. return make_node(AST_BlockStatement, self, {
  17437. body: body
  17438. });
  17439. }
  17440. if (first instanceof AST_If) {
  17441. if (is_break(first.body)) {
  17442. if (self.condition) {
  17443. self.condition = make_node(AST_Binary, self.condition, {
  17444. left: self.condition,
  17445. operator: "&&",
  17446. right: first.condition.negate(compressor),
  17447. });
  17448. } else {
  17449. self.condition = first.condition.negate(compressor);
  17450. }
  17451. drop_it(first.alternative);
  17452. } else if (is_break(first.alternative)) {
  17453. if (self.condition) {
  17454. self.condition = make_node(AST_Binary, self.condition, {
  17455. left: self.condition,
  17456. operator: "&&",
  17457. right: first.condition,
  17458. });
  17459. } else {
  17460. self.condition = first.condition;
  17461. }
  17462. drop_it(first.body);
  17463. }
  17464. }
  17465. return self;
  17466. function is_break(node) {
  17467. return node instanceof AST_Break
  17468. && compressor.loopcontrol_target(node) === compressor.self();
  17469. }
  17470. function drop_it(rest) {
  17471. rest = as_statement_array(rest);
  17472. if (self.body instanceof AST_BlockStatement) {
  17473. self.body = self.body.clone();
  17474. self.body.body = rest.concat(self.body.body.slice(1));
  17475. self.body = self.body.transform(compressor);
  17476. } else {
  17477. self.body = make_node(AST_BlockStatement, self.body, {
  17478. body: rest
  17479. }).transform(compressor);
  17480. }
  17481. self = if_break_in_loop(self, compressor);
  17482. }
  17483. }
  17484. def_optimize(AST_For, function(self, compressor) {
  17485. if (!compressor.option("loops")) return self;
  17486. if (compressor.option("side_effects") && self.init) {
  17487. self.init = self.init.drop_side_effect_free(compressor);
  17488. }
  17489. if (self.condition) {
  17490. var cond = self.condition.evaluate(compressor);
  17491. if (!(cond instanceof AST_Node)) {
  17492. if (cond) self.condition = null;
  17493. else if (!compressor.option("dead_code")) {
  17494. var orig = self.condition;
  17495. self.condition = make_node_from_constant(cond, self.condition);
  17496. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17497. }
  17498. }
  17499. if (compressor.option("dead_code")) {
  17500. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17501. if (!cond) {
  17502. var body = [];
  17503. trim_unreachable_code(compressor, self.body, body);
  17504. if (self.init instanceof AST_Statement) {
  17505. body.push(self.init);
  17506. } else if (self.init) {
  17507. body.push(make_node(AST_SimpleStatement, self.init, {
  17508. body: self.init
  17509. }));
  17510. }
  17511. body.push(make_node(AST_SimpleStatement, self.condition, {
  17512. body: self.condition
  17513. }));
  17514. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17515. }
  17516. }
  17517. }
  17518. return if_break_in_loop(self, compressor);
  17519. });
  17520. def_optimize(AST_If, function(self, compressor) {
  17521. if (is_empty(self.alternative)) self.alternative = null;
  17522. if (!compressor.option("conditionals")) return self;
  17523. // if condition can be statically determined, drop
  17524. // one of the blocks. note, statically determined implies
  17525. // “has no side effects”; also it doesn't work for cases like
  17526. // `x && true`, though it probably should.
  17527. var cond = self.condition.evaluate(compressor);
  17528. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  17529. var orig = self.condition;
  17530. self.condition = make_node_from_constant(cond, orig);
  17531. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17532. }
  17533. if (compressor.option("dead_code")) {
  17534. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17535. if (!cond) {
  17536. var body = [];
  17537. trim_unreachable_code(compressor, self.body, body);
  17538. body.push(make_node(AST_SimpleStatement, self.condition, {
  17539. body: self.condition
  17540. }));
  17541. if (self.alternative) body.push(self.alternative);
  17542. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17543. } else if (!(cond instanceof AST_Node)) {
  17544. var body = [];
  17545. body.push(make_node(AST_SimpleStatement, self.condition, {
  17546. body: self.condition
  17547. }));
  17548. body.push(self.body);
  17549. if (self.alternative) {
  17550. trim_unreachable_code(compressor, self.alternative, body);
  17551. }
  17552. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17553. }
  17554. }
  17555. var negated = self.condition.negate(compressor);
  17556. var self_condition_length = self.condition.size();
  17557. var negated_length = negated.size();
  17558. var negated_is_best = negated_length < self_condition_length;
  17559. if (self.alternative && negated_is_best) {
  17560. negated_is_best = false; // because we already do the switch here.
  17561. // no need to swap values of self_condition_length and negated_length
  17562. // here because they are only used in an equality comparison later on.
  17563. self.condition = negated;
  17564. var tmp = self.body;
  17565. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  17566. self.alternative = tmp;
  17567. }
  17568. if (is_empty(self.body) && is_empty(self.alternative)) {
  17569. return make_node(AST_SimpleStatement, self.condition, {
  17570. body: self.condition.clone()
  17571. }).optimize(compressor);
  17572. }
  17573. if (self.body instanceof AST_SimpleStatement
  17574. && self.alternative instanceof AST_SimpleStatement) {
  17575. return make_node(AST_SimpleStatement, self, {
  17576. body: make_node(AST_Conditional, self, {
  17577. condition : self.condition,
  17578. consequent : self.body.body,
  17579. alternative : self.alternative.body
  17580. })
  17581. }).optimize(compressor);
  17582. }
  17583. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  17584. if (self_condition_length === negated_length && !negated_is_best
  17585. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  17586. // although the code length of self.condition and negated are the same,
  17587. // negated does not require additional surrounding parentheses.
  17588. // see https://github.com/mishoo/UglifyJS2/issues/979
  17589. negated_is_best = true;
  17590. }
  17591. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  17592. body: make_node(AST_Binary, self, {
  17593. operator : "||",
  17594. left : negated,
  17595. right : self.body.body
  17596. })
  17597. }).optimize(compressor);
  17598. return make_node(AST_SimpleStatement, self, {
  17599. body: make_node(AST_Binary, self, {
  17600. operator : "&&",
  17601. left : self.condition,
  17602. right : self.body.body
  17603. })
  17604. }).optimize(compressor);
  17605. }
  17606. if (self.body instanceof AST_EmptyStatement
  17607. && self.alternative instanceof AST_SimpleStatement) {
  17608. return make_node(AST_SimpleStatement, self, {
  17609. body: make_node(AST_Binary, self, {
  17610. operator : "||",
  17611. left : self.condition,
  17612. right : self.alternative.body
  17613. })
  17614. }).optimize(compressor);
  17615. }
  17616. if (self.body instanceof AST_Exit
  17617. && self.alternative instanceof AST_Exit
  17618. && self.body.TYPE == self.alternative.TYPE) {
  17619. return make_node(self.body.CTOR, self, {
  17620. value: make_node(AST_Conditional, self, {
  17621. condition : self.condition,
  17622. consequent : self.body.value || make_node(AST_Undefined, self.body),
  17623. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  17624. }).transform(compressor)
  17625. }).optimize(compressor);
  17626. }
  17627. if (self.body instanceof AST_If
  17628. && !self.body.alternative
  17629. && !self.alternative) {
  17630. self = make_node(AST_If, self, {
  17631. condition: make_node(AST_Binary, self.condition, {
  17632. operator: "&&",
  17633. left: self.condition,
  17634. right: self.body.condition
  17635. }),
  17636. body: self.body.body,
  17637. alternative: null
  17638. });
  17639. }
  17640. if (aborts(self.body)) {
  17641. if (self.alternative) {
  17642. var alt = self.alternative;
  17643. self.alternative = null;
  17644. return make_node(AST_BlockStatement, self, {
  17645. body: [ self, alt ]
  17646. }).optimize(compressor);
  17647. }
  17648. }
  17649. if (aborts(self.alternative)) {
  17650. var body = self.body;
  17651. self.body = self.alternative;
  17652. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  17653. self.alternative = null;
  17654. return make_node(AST_BlockStatement, self, {
  17655. body: [ self, body ]
  17656. }).optimize(compressor);
  17657. }
  17658. return self;
  17659. });
  17660. def_optimize(AST_Switch, function(self, compressor) {
  17661. if (!compressor.option("switches")) return self;
  17662. var branch;
  17663. var value = self.expression.evaluate(compressor);
  17664. if (!(value instanceof AST_Node)) {
  17665. var orig = self.expression;
  17666. self.expression = make_node_from_constant(value, orig);
  17667. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  17668. }
  17669. if (!compressor.option("dead_code")) return self;
  17670. if (value instanceof AST_Node) {
  17671. value = self.expression.tail_node().evaluate(compressor);
  17672. }
  17673. var decl = [];
  17674. var body = [];
  17675. var default_branch;
  17676. var exact_match;
  17677. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  17678. branch = self.body[i];
  17679. if (branch instanceof AST_Default) {
  17680. if (!default_branch) {
  17681. default_branch = branch;
  17682. } else {
  17683. eliminate_branch(branch, body[body.length - 1]);
  17684. }
  17685. } else if (!(value instanceof AST_Node)) {
  17686. var exp = branch.expression.evaluate(compressor);
  17687. if (!(exp instanceof AST_Node) && exp !== value) {
  17688. eliminate_branch(branch, body[body.length - 1]);
  17689. continue;
  17690. }
  17691. if (exp instanceof AST_Node && !exp.has_side_effects(compressor)) {
  17692. exp = branch.expression.tail_node().evaluate(compressor);
  17693. }
  17694. if (exp === value) {
  17695. exact_match = branch;
  17696. if (default_branch) {
  17697. var default_index = body.indexOf(default_branch);
  17698. body.splice(default_index, 1);
  17699. eliminate_branch(default_branch, body[default_index - 1]);
  17700. default_branch = null;
  17701. }
  17702. }
  17703. }
  17704. body.push(branch);
  17705. }
  17706. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  17707. self.body = body;
  17708. let default_or_exact = default_branch || exact_match;
  17709. default_branch = null;
  17710. exact_match = null;
  17711. // group equivalent branches so they will be located next to each other,
  17712. // that way the next micro-optimization will merge them.
  17713. // ** bail micro-optimization if not a simple switch case with breaks
  17714. if (body.every((branch, i) =>
  17715. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  17716. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  17717. ) {
  17718. for (let i = 0; i < body.length; i++) {
  17719. const branch = body[i];
  17720. for (let j = i + 1; j < body.length; j++) {
  17721. const next = body[j];
  17722. if (next.body.length === 0) continue;
  17723. const last_branch = j === (body.length - 1);
  17724. const equivalentBranch = branches_equivalent(next, branch, false);
  17725. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  17726. if (!equivalentBranch && last_branch) {
  17727. next.body.push(make_node(AST_Break));
  17728. }
  17729. // let's find previous siblings with inert fallthrough...
  17730. let x = j - 1;
  17731. let fallthroughDepth = 0;
  17732. while (x > i) {
  17733. if (is_inert_body(body[x--])) {
  17734. fallthroughDepth++;
  17735. } else {
  17736. break;
  17737. }
  17738. }
  17739. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  17740. body.splice(i + 1, 0, ...plucked);
  17741. i += plucked.length;
  17742. }
  17743. }
  17744. }
  17745. }
  17746. // merge equivalent branches in a row
  17747. for (let i = 0; i < body.length; i++) {
  17748. let branch = body[i];
  17749. if (branch.body.length === 0) continue;
  17750. if (!aborts(branch)) continue;
  17751. for (let j = i + 1; j < body.length; i++, j++) {
  17752. let next = body[j];
  17753. if (next.body.length === 0) continue;
  17754. if (
  17755. branches_equivalent(next, branch, false)
  17756. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  17757. ) {
  17758. branch.body = [];
  17759. branch = next;
  17760. continue;
  17761. }
  17762. break;
  17763. }
  17764. }
  17765. // Prune any empty branches at the end of the switch statement.
  17766. {
  17767. let i = body.length - 1;
  17768. for (; i >= 0; i--) {
  17769. let bbody = body[i].body;
  17770. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  17771. if (!is_inert_body(body[i])) break;
  17772. }
  17773. // i now points to the index of a branch that contains a body. By incrementing, it's
  17774. // pointing to the first branch that's empty.
  17775. i++;
  17776. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  17777. // The default behavior is to do nothing. We can take advantage of that to
  17778. // remove all case expressions that are side-effect free that also do
  17779. // nothing, since they'll default to doing nothing. But we can't remove any
  17780. // case expressions before one that would side-effect, since they may cause
  17781. // the side-effect to be skipped.
  17782. for (let j = body.length - 1; j >= i; j--) {
  17783. let branch = body[j];
  17784. if (branch === default_or_exact) {
  17785. default_or_exact = null;
  17786. body.pop();
  17787. } else if (!branch.expression.has_side_effects(compressor)) {
  17788. body.pop();
  17789. } else {
  17790. break;
  17791. }
  17792. }
  17793. }
  17794. }
  17795. // Prune side-effect free branches that fall into default.
  17796. DEFAULT: if (default_or_exact) {
  17797. let default_index = body.indexOf(default_or_exact);
  17798. let default_body_index = default_index;
  17799. for (; default_body_index < body.length - 1; default_body_index++) {
  17800. if (!is_inert_body(body[default_body_index])) break;
  17801. }
  17802. if (default_body_index < body.length - 1) {
  17803. break DEFAULT;
  17804. }
  17805. let side_effect_index = body.length - 1;
  17806. for (; side_effect_index >= 0; side_effect_index--) {
  17807. let branch = body[side_effect_index];
  17808. if (branch === default_or_exact) continue;
  17809. if (branch.expression.has_side_effects(compressor)) break;
  17810. }
  17811. // If the default behavior comes after any side-effect case expressions,
  17812. // then we can fold all side-effect free cases into the default branch.
  17813. // If the side-effect case is after the default, then any side-effect
  17814. // free cases could prevent the side-effect from occurring.
  17815. if (default_body_index > side_effect_index) {
  17816. let prev_body_index = default_index - 1;
  17817. for (; prev_body_index >= 0; prev_body_index--) {
  17818. if (!is_inert_body(body[prev_body_index])) break;
  17819. }
  17820. let before = Math.max(side_effect_index, prev_body_index) + 1;
  17821. let after = default_index;
  17822. if (side_effect_index > default_index) {
  17823. // If the default falls into the same body as a side-effect
  17824. // case, then we need preserve that case and only prune the
  17825. // cases after it.
  17826. after = side_effect_index;
  17827. body[side_effect_index].body = body[default_body_index].body;
  17828. } else {
  17829. // The default will be the last branch.
  17830. default_or_exact.body = body[default_body_index].body;
  17831. }
  17832. // Prune everything after the default (or last side-effect case)
  17833. // until the next case with a body.
  17834. body.splice(after + 1, default_body_index - after);
  17835. // Prune everything before the default that falls into it.
  17836. body.splice(before, default_index - before);
  17837. }
  17838. }
  17839. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  17840. DEFAULT: if (default_or_exact) {
  17841. let i = body.findIndex(branch => !is_inert_body(branch));
  17842. let caseBody;
  17843. // `i` is equal to one of the following:
  17844. // - `-1`, there is no body in the switch statement.
  17845. // - `body.length - 1`, all cases fall into the same body.
  17846. // - anything else, there are multiple bodies in the switch.
  17847. if (i === body.length - 1) {
  17848. // All cases fall into the case body.
  17849. let branch = body[i];
  17850. if (has_nested_break(self)) break DEFAULT;
  17851. // This is the last case body, and we've already pruned any breaks, so it's
  17852. // safe to hoist.
  17853. caseBody = make_node(AST_BlockStatement, branch, {
  17854. body: branch.body
  17855. });
  17856. branch.body = [];
  17857. } else if (i !== -1) {
  17858. // If there are multiple bodies, then we cannot optimize anything.
  17859. break DEFAULT;
  17860. }
  17861. let sideEffect = body.find(
  17862. branch => branch !== default_or_exact && branch.expression.has_side_effects(compressor)
  17863. );
  17864. // If no cases cause a side-effect, we can eliminate the switch entirely.
  17865. if (!sideEffect) {
  17866. return make_node(AST_BlockStatement, self, {
  17867. body: decl.concat(
  17868. statement(self.expression),
  17869. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  17870. caseBody || []
  17871. )
  17872. }).optimize(compressor);
  17873. }
  17874. // If we're this far, either there was no body or all cases fell into the same body.
  17875. // If there was no body, then we don't need a default branch (because the default is
  17876. // do nothing). If there was a body, we'll extract it to after the switch, so the
  17877. // switch's new default is to do nothing and we can still prune it.
  17878. const default_index = body.indexOf(default_or_exact);
  17879. body.splice(default_index, 1);
  17880. default_or_exact = null;
  17881. if (caseBody) {
  17882. // Recurse into switch statement one more time so that we can append the case body
  17883. // outside of the switch. This recursion will only happen once since we've pruned
  17884. // the default case.
  17885. return make_node(AST_BlockStatement, self, {
  17886. body: decl.concat(self, caseBody)
  17887. }).optimize(compressor);
  17888. }
  17889. // If we fall here, there is a default branch somewhere, there are no case bodies,
  17890. // and there's a side-effect somewhere. Just let the below paths take care of it.
  17891. }
  17892. if (body.length > 0) {
  17893. body[0].body = decl.concat(body[0].body);
  17894. }
  17895. if (body.length == 0) {
  17896. return make_node(AST_BlockStatement, self, {
  17897. body: decl.concat(statement(self.expression))
  17898. }).optimize(compressor);
  17899. }
  17900. if (body.length == 1 && !has_nested_break(self)) {
  17901. // This is the last case body, and we've already pruned any breaks, so it's
  17902. // safe to hoist.
  17903. let branch = body[0];
  17904. return make_node(AST_If, self, {
  17905. condition: make_node(AST_Binary, self, {
  17906. operator: "===",
  17907. left: self.expression,
  17908. right: branch.expression,
  17909. }),
  17910. body: make_node(AST_BlockStatement, branch, {
  17911. body: branch.body
  17912. }),
  17913. alternative: null
  17914. }).optimize(compressor);
  17915. }
  17916. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  17917. let branch = body[0] === default_or_exact ? body[1] : body[0];
  17918. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  17919. if (aborts(body[0])) {
  17920. // Only the first branch body could have a break (at the last statement)
  17921. let first = body[0];
  17922. if (is_break(first.body[first.body.length - 1], compressor)) {
  17923. first.body.pop();
  17924. }
  17925. return make_node(AST_If, self, {
  17926. condition: make_node(AST_Binary, self, {
  17927. operator: "===",
  17928. left: self.expression,
  17929. right: branch.expression,
  17930. }),
  17931. body: make_node(AST_BlockStatement, branch, {
  17932. body: branch.body
  17933. }),
  17934. alternative: make_node(AST_BlockStatement, default_or_exact, {
  17935. body: [].concat(
  17936. exact_exp || [],
  17937. default_or_exact.body
  17938. )
  17939. })
  17940. }).optimize(compressor);
  17941. }
  17942. let operator = "===";
  17943. let consequent = make_node(AST_BlockStatement, branch, {
  17944. body: branch.body,
  17945. });
  17946. let always = make_node(AST_BlockStatement, default_or_exact, {
  17947. body: [].concat(
  17948. exact_exp || [],
  17949. default_or_exact.body
  17950. )
  17951. });
  17952. if (body[0] === default_or_exact) {
  17953. operator = "!==";
  17954. let tmp = always;
  17955. always = consequent;
  17956. consequent = tmp;
  17957. }
  17958. return make_node(AST_BlockStatement, self, {
  17959. body: [
  17960. make_node(AST_If, self, {
  17961. condition: make_node(AST_Binary, self, {
  17962. operator: operator,
  17963. left: self.expression,
  17964. right: branch.expression,
  17965. }),
  17966. body: consequent,
  17967. alternative: null,
  17968. }),
  17969. always,
  17970. ],
  17971. }).optimize(compressor);
  17972. }
  17973. return self;
  17974. function eliminate_branch(branch, prev) {
  17975. if (prev && !aborts(prev)) {
  17976. prev.body = prev.body.concat(branch.body);
  17977. } else {
  17978. trim_unreachable_code(compressor, branch, decl);
  17979. }
  17980. }
  17981. function branches_equivalent(branch, prev, insertBreak) {
  17982. let bbody = branch.body;
  17983. let pbody = prev.body;
  17984. if (insertBreak) {
  17985. bbody = bbody.concat(make_node(AST_Break));
  17986. }
  17987. if (bbody.length !== pbody.length) return false;
  17988. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  17989. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  17990. return bblock.equivalent_to(pblock);
  17991. }
  17992. function statement(body) {
  17993. return make_node(AST_SimpleStatement, body, { body });
  17994. }
  17995. function has_nested_break(root) {
  17996. let has_break = false;
  17997. let tw = new TreeWalker(node => {
  17998. if (has_break) return true;
  17999. if (node instanceof AST_Lambda) return true;
  18000. if (node instanceof AST_SimpleStatement) return true;
  18001. if (!is_break(node, tw)) return;
  18002. let parent = tw.parent();
  18003. if (
  18004. parent instanceof AST_SwitchBranch
  18005. && parent.body[parent.body.length - 1] === node
  18006. ) {
  18007. return;
  18008. }
  18009. has_break = true;
  18010. });
  18011. root.walk(tw);
  18012. return has_break;
  18013. }
  18014. function is_break(node, stack) {
  18015. return node instanceof AST_Break
  18016. && stack.loopcontrol_target(node) === self;
  18017. }
  18018. function is_inert_body(branch) {
  18019. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  18020. body: branch.body
  18021. }).has_side_effects(compressor);
  18022. }
  18023. });
  18024. def_optimize(AST_Try, function(self, compressor) {
  18025. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  18026. if (compressor.option("dead_code") && self.body.body.every(is_empty)) {
  18027. var body = [];
  18028. if (self.bcatch) {
  18029. trim_unreachable_code(compressor, self.bcatch, body);
  18030. }
  18031. if (self.bfinally) body.push(...self.bfinally.body);
  18032. return make_node(AST_BlockStatement, self, {
  18033. body: body
  18034. }).optimize(compressor);
  18035. }
  18036. return self;
  18037. });
  18038. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  18039. var reduce_vars = compressor.option("reduce_vars");
  18040. var assignments = [];
  18041. for (const def of this.definitions) {
  18042. if (def.value) {
  18043. var name = make_node(AST_SymbolRef, def.name, def.name);
  18044. assignments.push(make_node(AST_Assign, def, {
  18045. operator : "=",
  18046. logical: false,
  18047. left : name,
  18048. right : def.value
  18049. }));
  18050. if (reduce_vars) name.definition().fixed = false;
  18051. }
  18052. const thedef = def.name.definition();
  18053. thedef.eliminated++;
  18054. thedef.replaced--;
  18055. }
  18056. if (assignments.length == 0) return null;
  18057. return make_sequence(this, assignments);
  18058. });
  18059. def_optimize(AST_Definitions, function(self) {
  18060. if (self.definitions.length == 0) {
  18061. return make_node(AST_EmptyStatement, self);
  18062. }
  18063. return self;
  18064. });
  18065. def_optimize(AST_VarDef, function(self, compressor) {
  18066. if (
  18067. self.name instanceof AST_SymbolLet
  18068. && self.value != null
  18069. && is_undefined(self.value, compressor)
  18070. ) {
  18071. self.value = null;
  18072. }
  18073. return self;
  18074. });
  18075. def_optimize(AST_Import, function(self) {
  18076. return self;
  18077. });
  18078. def_optimize(AST_Call, function(self, compressor) {
  18079. var exp = self.expression;
  18080. var fn = exp;
  18081. inline_array_like_spread(self.args);
  18082. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  18083. if (compressor.option("reduce_vars") && fn instanceof AST_SymbolRef) {
  18084. fn = fn.fixed_value();
  18085. }
  18086. var is_func = fn instanceof AST_Lambda;
  18087. if (is_func && fn.pinned()) return self;
  18088. if (compressor.option("unused")
  18089. && simple_args
  18090. && is_func
  18091. && !fn.uses_arguments) {
  18092. var pos = 0, last = 0;
  18093. for (var i = 0, len = self.args.length; i < len; i++) {
  18094. if (fn.argnames[i] instanceof AST_Expansion) {
  18095. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  18096. var node = self.args[i++].drop_side_effect_free(compressor);
  18097. if (node) {
  18098. self.args[pos++] = node;
  18099. }
  18100. } else while (i < len) {
  18101. self.args[pos++] = self.args[i++];
  18102. }
  18103. last = pos;
  18104. break;
  18105. }
  18106. var trim = i >= fn.argnames.length;
  18107. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  18108. var node = self.args[i].drop_side_effect_free(compressor);
  18109. if (node) {
  18110. self.args[pos++] = node;
  18111. } else if (!trim) {
  18112. self.args[pos++] = make_node(AST_Number, self.args[i], {
  18113. value: 0
  18114. });
  18115. continue;
  18116. }
  18117. } else {
  18118. self.args[pos++] = self.args[i];
  18119. }
  18120. last = pos;
  18121. }
  18122. self.args.length = last;
  18123. }
  18124. if (compressor.option("unsafe") && !exp.contains_optional()) {
  18125. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  18126. const [argument] = self.args;
  18127. if (argument instanceof AST_Array) {
  18128. return make_node(AST_Array, argument, {
  18129. elements: argument.elements
  18130. }).optimize(compressor);
  18131. }
  18132. }
  18133. if (is_undeclared_ref(exp)) switch (exp.name) {
  18134. case "Array":
  18135. if (self.args.length != 1) {
  18136. return make_node(AST_Array, self, {
  18137. elements: self.args
  18138. }).optimize(compressor);
  18139. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  18140. const elements = [];
  18141. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  18142. return new AST_Array({ elements });
  18143. }
  18144. break;
  18145. case "Object":
  18146. if (self.args.length == 0) {
  18147. return make_node(AST_Object, self, {
  18148. properties: []
  18149. });
  18150. }
  18151. break;
  18152. case "String":
  18153. if (self.args.length == 0) return make_node(AST_String, self, {
  18154. value: ""
  18155. });
  18156. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  18157. left: self.args[0],
  18158. operator: "+",
  18159. right: make_node(AST_String, self, { value: "" })
  18160. }).optimize(compressor);
  18161. break;
  18162. case "Number":
  18163. if (self.args.length == 0) return make_node(AST_Number, self, {
  18164. value: 0
  18165. });
  18166. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  18167. return make_node(AST_UnaryPrefix, self, {
  18168. expression: self.args[0],
  18169. operator: "+"
  18170. }).optimize(compressor);
  18171. }
  18172. break;
  18173. case "Symbol":
  18174. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  18175. self.args.length = 0;
  18176. break;
  18177. case "Boolean":
  18178. if (self.args.length == 0) return make_node(AST_False, self);
  18179. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  18180. expression: make_node(AST_UnaryPrefix, self, {
  18181. expression: self.args[0],
  18182. operator: "!"
  18183. }),
  18184. operator: "!"
  18185. }).optimize(compressor);
  18186. break;
  18187. case "RegExp":
  18188. var params = [];
  18189. if (self.args.length >= 1
  18190. && self.args.length <= 2
  18191. && self.args.every((arg) => {
  18192. var value = arg.evaluate(compressor);
  18193. params.push(value);
  18194. return arg !== value;
  18195. })
  18196. && regexp_is_safe(params[0])
  18197. ) {
  18198. let [ source, flags ] = params;
  18199. source = regexp_source_fix(new RegExp(source).source);
  18200. const rx = make_node(AST_RegExp, self, {
  18201. value: { source, flags }
  18202. });
  18203. if (rx._eval(compressor) !== rx) {
  18204. return rx;
  18205. }
  18206. }
  18207. break;
  18208. } else if (exp instanceof AST_Dot) switch(exp.property) {
  18209. case "toString":
  18210. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  18211. return make_node(AST_Binary, self, {
  18212. left: make_node(AST_String, self, { value: "" }),
  18213. operator: "+",
  18214. right: exp.expression
  18215. }).optimize(compressor);
  18216. }
  18217. break;
  18218. case "join":
  18219. if (exp.expression instanceof AST_Array) EXIT: {
  18220. var separator;
  18221. if (self.args.length > 0) {
  18222. separator = self.args[0].evaluate(compressor);
  18223. if (separator === self.args[0]) break EXIT; // not a constant
  18224. }
  18225. var elements = [];
  18226. var consts = [];
  18227. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  18228. var el = exp.expression.elements[i];
  18229. if (el instanceof AST_Expansion) break EXIT;
  18230. var value = el.evaluate(compressor);
  18231. if (value !== el) {
  18232. consts.push(value);
  18233. } else {
  18234. if (consts.length > 0) {
  18235. elements.push(make_node(AST_String, self, {
  18236. value: consts.join(separator)
  18237. }));
  18238. consts.length = 0;
  18239. }
  18240. elements.push(el);
  18241. }
  18242. }
  18243. if (consts.length > 0) {
  18244. elements.push(make_node(AST_String, self, {
  18245. value: consts.join(separator)
  18246. }));
  18247. }
  18248. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  18249. if (elements.length == 1) {
  18250. if (elements[0].is_string(compressor)) {
  18251. return elements[0];
  18252. }
  18253. return make_node(AST_Binary, elements[0], {
  18254. operator : "+",
  18255. left : make_node(AST_String, self, { value: "" }),
  18256. right : elements[0]
  18257. });
  18258. }
  18259. if (separator == "") {
  18260. var first;
  18261. if (elements[0].is_string(compressor)
  18262. || elements[1].is_string(compressor)) {
  18263. first = elements.shift();
  18264. } else {
  18265. first = make_node(AST_String, self, { value: "" });
  18266. }
  18267. return elements.reduce(function(prev, el) {
  18268. return make_node(AST_Binary, el, {
  18269. operator : "+",
  18270. left : prev,
  18271. right : el
  18272. });
  18273. }, first).optimize(compressor);
  18274. }
  18275. // need this awkward cloning to not affect original element
  18276. // best_of will decide which one to get through.
  18277. var node = self.clone();
  18278. node.expression = node.expression.clone();
  18279. node.expression.expression = node.expression.expression.clone();
  18280. node.expression.expression.elements = elements;
  18281. return best_of(compressor, self, node);
  18282. }
  18283. break;
  18284. case "charAt":
  18285. if (exp.expression.is_string(compressor)) {
  18286. var arg = self.args[0];
  18287. var index = arg ? arg.evaluate(compressor) : 0;
  18288. if (index !== arg) {
  18289. return make_node(AST_Sub, exp, {
  18290. expression: exp.expression,
  18291. property: make_node_from_constant(index | 0, arg || exp)
  18292. }).optimize(compressor);
  18293. }
  18294. }
  18295. break;
  18296. case "apply":
  18297. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  18298. var args = self.args[1].elements.slice();
  18299. args.unshift(self.args[0]);
  18300. return make_node(AST_Call, self, {
  18301. expression: make_node(AST_Dot, exp, {
  18302. expression: exp.expression,
  18303. optional: false,
  18304. property: "call"
  18305. }),
  18306. args: args
  18307. }).optimize(compressor);
  18308. }
  18309. break;
  18310. case "call":
  18311. var func = exp.expression;
  18312. if (func instanceof AST_SymbolRef) {
  18313. func = func.fixed_value();
  18314. }
  18315. if (func instanceof AST_Lambda && !func.contains_this()) {
  18316. return (self.args.length ? make_sequence(this, [
  18317. self.args[0],
  18318. make_node(AST_Call, self, {
  18319. expression: exp.expression,
  18320. args: self.args.slice(1)
  18321. })
  18322. ]) : make_node(AST_Call, self, {
  18323. expression: exp.expression,
  18324. args: []
  18325. })).optimize(compressor);
  18326. }
  18327. break;
  18328. }
  18329. }
  18330. if (compressor.option("unsafe_Function")
  18331. && is_undeclared_ref(exp)
  18332. && exp.name == "Function") {
  18333. // new Function() => function(){}
  18334. if (self.args.length == 0) return make_node(AST_Function, self, {
  18335. argnames: [],
  18336. body: []
  18337. }).optimize(compressor);
  18338. if (self.args.every((x) => x instanceof AST_String)) {
  18339. // quite a corner-case, but we can handle it:
  18340. // https://github.com/mishoo/UglifyJS2/issues/203
  18341. // if the code argument is a constant, then we can minify it.
  18342. try {
  18343. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  18344. return arg.value;
  18345. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  18346. var ast = parse(code);
  18347. var mangle = compressor.mangle_options();
  18348. ast.figure_out_scope(mangle);
  18349. var comp = new Compressor(compressor.options, {
  18350. mangle_options: compressor._mangle_options
  18351. });
  18352. ast = ast.transform(comp);
  18353. ast.figure_out_scope(mangle);
  18354. ast.compute_char_frequency(mangle);
  18355. ast.mangle_names(mangle);
  18356. var fun;
  18357. walk(ast, node => {
  18358. if (is_func_expr(node)) {
  18359. fun = node;
  18360. return walk_abort;
  18361. }
  18362. });
  18363. var code = OutputStream();
  18364. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  18365. self.args = [
  18366. make_node(AST_String, self, {
  18367. value: fun.argnames.map(function(arg) {
  18368. return arg.print_to_string();
  18369. }).join(",")
  18370. }),
  18371. make_node(AST_String, self.args[self.args.length - 1], {
  18372. value: code.get().replace(/^{|}$/g, "")
  18373. })
  18374. ];
  18375. return self;
  18376. } catch (ex) {
  18377. if (!(ex instanceof JS_Parse_Error)) {
  18378. throw ex;
  18379. }
  18380. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  18381. }
  18382. }
  18383. }
  18384. return inline_into_call(self, compressor);
  18385. });
  18386. /** Does this node contain optional property access or optional call? */
  18387. AST_Node.DEFMETHOD("contains_optional", function() {
  18388. if (
  18389. this instanceof AST_PropAccess
  18390. || this instanceof AST_Call
  18391. || this instanceof AST_Chain
  18392. ) {
  18393. if (this.optional) {
  18394. return true;
  18395. } else {
  18396. return this.expression.contains_optional();
  18397. }
  18398. } else {
  18399. return false;
  18400. }
  18401. });
  18402. def_optimize(AST_New, function(self, compressor) {
  18403. if (
  18404. compressor.option("unsafe") &&
  18405. is_undeclared_ref(self.expression) &&
  18406. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  18407. ) return make_node(AST_Call, self, self).transform(compressor);
  18408. return self;
  18409. });
  18410. def_optimize(AST_Sequence, function(self, compressor) {
  18411. if (!compressor.option("side_effects")) return self;
  18412. var expressions = [];
  18413. filter_for_side_effects();
  18414. var end = expressions.length - 1;
  18415. trim_right_for_undefined();
  18416. if (end == 0) {
  18417. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  18418. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  18419. return self;
  18420. }
  18421. self.expressions = expressions;
  18422. return self;
  18423. function filter_for_side_effects() {
  18424. var first = first_in_statement(compressor);
  18425. var last = self.expressions.length - 1;
  18426. self.expressions.forEach(function(expr, index) {
  18427. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  18428. if (expr) {
  18429. merge_sequence(expressions, expr);
  18430. first = false;
  18431. }
  18432. });
  18433. }
  18434. function trim_right_for_undefined() {
  18435. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  18436. if (end < expressions.length - 1) {
  18437. expressions[end] = make_node(AST_UnaryPrefix, self, {
  18438. operator : "void",
  18439. expression : expressions[end]
  18440. });
  18441. expressions.length = end + 1;
  18442. }
  18443. }
  18444. });
  18445. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  18446. if (compressor.option("sequences")) {
  18447. if (this.expression instanceof AST_Sequence) {
  18448. var x = this.expression.expressions.slice();
  18449. var e = this.clone();
  18450. e.expression = x.pop();
  18451. x.push(e);
  18452. return make_sequence(this, x).optimize(compressor);
  18453. }
  18454. }
  18455. return this;
  18456. });
  18457. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  18458. return self.lift_sequences(compressor);
  18459. });
  18460. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  18461. var e = self.expression;
  18462. if (
  18463. self.operator == "delete" &&
  18464. !(
  18465. e instanceof AST_SymbolRef ||
  18466. e instanceof AST_PropAccess ||
  18467. e instanceof AST_Chain ||
  18468. is_identifier_atom(e)
  18469. )
  18470. ) {
  18471. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  18472. }
  18473. var seq = self.lift_sequences(compressor);
  18474. if (seq !== self) {
  18475. return seq;
  18476. }
  18477. if (compressor.option("side_effects") && self.operator == "void") {
  18478. e = e.drop_side_effect_free(compressor);
  18479. if (e) {
  18480. self.expression = e;
  18481. return self;
  18482. } else {
  18483. return make_node(AST_Undefined, self).optimize(compressor);
  18484. }
  18485. }
  18486. if (compressor.in_boolean_context()) {
  18487. switch (self.operator) {
  18488. case "!":
  18489. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  18490. // !!foo ==> foo, if we're in boolean context
  18491. return e.expression;
  18492. }
  18493. if (e instanceof AST_Binary) {
  18494. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  18495. }
  18496. break;
  18497. case "typeof":
  18498. // typeof always returns a non-empty string, thus it's
  18499. // always true in booleans
  18500. // And we don't need to check if it's undeclared, because in typeof, that's OK
  18501. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  18502. e,
  18503. make_node(AST_True, self)
  18504. ])).optimize(compressor);
  18505. }
  18506. }
  18507. if (self.operator == "-" && e instanceof AST_Infinity) {
  18508. e = e.transform(compressor);
  18509. }
  18510. if (e instanceof AST_Binary
  18511. && (self.operator == "+" || self.operator == "-")
  18512. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  18513. return make_node(AST_Binary, self, {
  18514. operator: e.operator,
  18515. left: make_node(AST_UnaryPrefix, e.left, {
  18516. operator: self.operator,
  18517. expression: e.left
  18518. }),
  18519. right: e.right
  18520. });
  18521. }
  18522. if (compressor.option("evaluate")) {
  18523. // ~~x => x (in 32-bit context)
  18524. // ~~{32 bit integer} => {32 bit integer}
  18525. if (
  18526. self.operator === "~"
  18527. && self.expression instanceof AST_UnaryPrefix
  18528. && self.expression.operator === "~"
  18529. && (compressor.in_32_bit_context() || self.expression.expression.is_32_bit_integer())
  18530. ) {
  18531. return self.expression.expression;
  18532. }
  18533. // ~(x ^ y) => x ^ ~y
  18534. if (
  18535. self.operator === "~"
  18536. && e instanceof AST_Binary
  18537. && e.operator === "^"
  18538. ) {
  18539. if (e.left instanceof AST_UnaryPrefix && e.left.operator === "~") {
  18540. // ~(~x ^ y) => x ^ y
  18541. e.left = e.left.bitwise_negate(true);
  18542. } else {
  18543. e.right = e.right.bitwise_negate(true);
  18544. }
  18545. return e;
  18546. }
  18547. }
  18548. if (
  18549. self.operator != "-"
  18550. // avoid infinite recursion of numerals
  18551. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)
  18552. ) {
  18553. var ev = self.evaluate(compressor);
  18554. if (ev !== self) {
  18555. ev = make_node_from_constant(ev, self).optimize(compressor);
  18556. return best_of(compressor, ev, self);
  18557. }
  18558. }
  18559. return self;
  18560. });
  18561. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  18562. if (compressor.option("sequences")) {
  18563. if (this.left instanceof AST_Sequence) {
  18564. var x = this.left.expressions.slice();
  18565. var e = this.clone();
  18566. e.left = x.pop();
  18567. x.push(e);
  18568. return make_sequence(this, x).optimize(compressor);
  18569. }
  18570. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  18571. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  18572. var x = this.right.expressions;
  18573. var last = x.length - 1;
  18574. for (var i = 0; i < last; i++) {
  18575. if (!assign && x[i].has_side_effects(compressor)) break;
  18576. }
  18577. if (i == last) {
  18578. x = x.slice();
  18579. var e = this.clone();
  18580. e.right = x.pop();
  18581. x.push(e);
  18582. return make_sequence(this, x).optimize(compressor);
  18583. } else if (i > 0) {
  18584. var e = this.clone();
  18585. e.right = make_sequence(this.right, x.slice(i));
  18586. x = x.slice(0, i);
  18587. x.push(e);
  18588. return make_sequence(this, x).optimize(compressor);
  18589. }
  18590. }
  18591. }
  18592. return this;
  18593. });
  18594. var commutativeOperators = makePredicate("== === != !== * & | ^");
  18595. function is_object(node) {
  18596. return node instanceof AST_Array
  18597. || node instanceof AST_Lambda
  18598. || node instanceof AST_Object
  18599. || node instanceof AST_Class;
  18600. }
  18601. def_optimize(AST_Binary, function(self, compressor) {
  18602. function reversible() {
  18603. return self.left.is_constant()
  18604. || self.right.is_constant()
  18605. || !self.left.has_side_effects(compressor)
  18606. && !self.right.has_side_effects(compressor);
  18607. }
  18608. function reverse(op) {
  18609. if (reversible()) {
  18610. if (op) self.operator = op;
  18611. var tmp = self.left;
  18612. self.left = self.right;
  18613. self.right = tmp;
  18614. }
  18615. }
  18616. if (compressor.option("lhs_constants") && commutativeOperators.has(self.operator)) {
  18617. if (self.right.is_constant()
  18618. && !self.left.is_constant()) {
  18619. // if right is a constant, whatever side effects the
  18620. // left side might have could not influence the
  18621. // result. hence, force switch.
  18622. if (!(self.left instanceof AST_Binary
  18623. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  18624. reverse();
  18625. }
  18626. }
  18627. }
  18628. self = self.lift_sequences(compressor);
  18629. if (compressor.option("comparisons")) switch (self.operator) {
  18630. case "===":
  18631. case "!==":
  18632. var is_strict_comparison = true;
  18633. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  18634. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  18635. (self.left.is_boolean() && self.right.is_boolean()) ||
  18636. self.left.equivalent_to(self.right)) {
  18637. self.operator = self.operator.substr(0, 2);
  18638. }
  18639. // XXX: intentionally falling down to the next case
  18640. case "==":
  18641. case "!=":
  18642. // void 0 == x => null == x
  18643. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  18644. self.left = make_node(AST_Null, self.left);
  18645. // x == void 0 => x == null
  18646. } else if (!is_strict_comparison && is_undefined(self.right, compressor)) {
  18647. self.right = make_node(AST_Null, self.right);
  18648. } else if (compressor.option("typeofs")
  18649. // "undefined" == typeof x => undefined === x
  18650. && self.left instanceof AST_String
  18651. && self.left.value == "undefined"
  18652. && self.right instanceof AST_UnaryPrefix
  18653. && self.right.operator == "typeof") {
  18654. var expr = self.right.expression;
  18655. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  18656. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  18657. self.right = expr;
  18658. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  18659. if (self.operator.length == 2) self.operator += "=";
  18660. }
  18661. } else if (compressor.option("typeofs")
  18662. // typeof x === "undefined" => x === undefined
  18663. && self.left instanceof AST_UnaryPrefix
  18664. && self.left.operator == "typeof"
  18665. && self.right instanceof AST_String
  18666. && self.right.value == "undefined") {
  18667. var expr = self.left.expression;
  18668. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  18669. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  18670. self.left = expr;
  18671. self.right = make_node(AST_Undefined, self.right).optimize(compressor);
  18672. if (self.operator.length == 2) self.operator += "=";
  18673. }
  18674. } else if (self.left instanceof AST_SymbolRef
  18675. // obj !== obj => false
  18676. && self.right instanceof AST_SymbolRef
  18677. && self.left.definition() === self.right.definition()
  18678. && is_object(self.left.fixed_value())) {
  18679. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  18680. } else if (self.left.is_32_bit_integer() && self.right.is_32_bit_integer()) {
  18681. const not = node => make_node(AST_UnaryPrefix, node, {
  18682. operator: "!",
  18683. expression: node
  18684. });
  18685. const booleanify = (node, truthy) => {
  18686. if (truthy) {
  18687. return compressor.in_boolean_context()
  18688. ? node
  18689. : not(not(node));
  18690. } else {
  18691. return not(node);
  18692. }
  18693. };
  18694. // The only falsy 32-bit integer is 0
  18695. if (self.left instanceof AST_Number && self.left.value === 0) {
  18696. return booleanify(self.right, self.operator[0] === "!");
  18697. }
  18698. if (self.right instanceof AST_Number && self.right.value === 0) {
  18699. return booleanify(self.left, self.operator[0] === "!");
  18700. }
  18701. // Mask all-bits check
  18702. // (x & 0xFF) != 0xFF => !(~x & 0xFF)
  18703. let and_op, x, mask;
  18704. if (
  18705. (and_op =
  18706. self.left instanceof AST_Binary ? self.left
  18707. : self.right instanceof AST_Binary ? self.right : null)
  18708. && (mask = and_op === self.left ? self.right : self.left)
  18709. && and_op.operator === "&"
  18710. && mask instanceof AST_Number
  18711. && mask.is_32_bit_integer()
  18712. && (x =
  18713. and_op.left.equivalent_to(mask) ? and_op.right
  18714. : and_op.right.equivalent_to(mask) ? and_op.left : null)
  18715. ) {
  18716. let optimized = booleanify(make_node(AST_Binary, self, {
  18717. operator: "&",
  18718. left: mask,
  18719. right: make_node(AST_UnaryPrefix, self, {
  18720. operator: "~",
  18721. expression: x
  18722. })
  18723. }), self.operator[0] === "!");
  18724. return best_of(compressor, optimized, self);
  18725. }
  18726. }
  18727. break;
  18728. case "&&":
  18729. case "||":
  18730. var lhs = self.left;
  18731. if (lhs.operator == self.operator) {
  18732. lhs = lhs.right;
  18733. }
  18734. if (lhs instanceof AST_Binary
  18735. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  18736. && self.right instanceof AST_Binary
  18737. && lhs.operator == self.right.operator
  18738. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  18739. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  18740. && !lhs.right.has_side_effects(compressor)
  18741. && lhs.right.equivalent_to(self.right.right)) {
  18742. var combined = make_node(AST_Binary, self, {
  18743. operator: lhs.operator.slice(0, -1),
  18744. left: make_node(AST_Null, self),
  18745. right: lhs.right
  18746. });
  18747. if (lhs !== self.left) {
  18748. combined = make_node(AST_Binary, self, {
  18749. operator: self.operator,
  18750. left: self.left.left,
  18751. right: combined
  18752. });
  18753. }
  18754. return combined;
  18755. }
  18756. break;
  18757. }
  18758. if (self.operator == "+" && compressor.in_boolean_context()) {
  18759. var ll = self.left.evaluate(compressor);
  18760. var rr = self.right.evaluate(compressor);
  18761. if (ll && typeof ll == "string") {
  18762. return make_sequence(self, [
  18763. self.right,
  18764. make_node(AST_True, self)
  18765. ]).optimize(compressor);
  18766. }
  18767. if (rr && typeof rr == "string") {
  18768. return make_sequence(self, [
  18769. self.left,
  18770. make_node(AST_True, self)
  18771. ]).optimize(compressor);
  18772. }
  18773. }
  18774. if (compressor.option("comparisons") && self.is_boolean()) {
  18775. if (!(compressor.parent() instanceof AST_Binary)
  18776. || compressor.parent() instanceof AST_Assign) {
  18777. var negated = make_node(AST_UnaryPrefix, self, {
  18778. operator: "!",
  18779. expression: self.negate(compressor, first_in_statement(compressor))
  18780. });
  18781. self = best_of(compressor, self, negated);
  18782. }
  18783. if (compressor.option("unsafe_comps")) {
  18784. switch (self.operator) {
  18785. case "<": reverse(">"); break;
  18786. case "<=": reverse(">="); break;
  18787. }
  18788. }
  18789. }
  18790. if (self.operator == "+") {
  18791. if (self.right instanceof AST_String
  18792. && self.right.getValue() == ""
  18793. && self.left.is_string(compressor)) {
  18794. return self.left;
  18795. }
  18796. if (self.left instanceof AST_String
  18797. && self.left.getValue() == ""
  18798. && self.right.is_string(compressor)) {
  18799. return self.right;
  18800. }
  18801. if (self.left instanceof AST_Binary
  18802. && self.left.operator == "+"
  18803. && self.left.left instanceof AST_String
  18804. && self.left.left.getValue() == ""
  18805. && self.right.is_string(compressor)) {
  18806. self.left = self.left.right;
  18807. return self;
  18808. }
  18809. }
  18810. if (compressor.option("evaluate")) {
  18811. switch (self.operator) {
  18812. case "&&":
  18813. var ll = has_flag(self.left, TRUTHY)
  18814. ? true
  18815. : has_flag(self.left, FALSY)
  18816. ? false
  18817. : self.left.evaluate(compressor);
  18818. if (!ll) {
  18819. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  18820. } else if (!(ll instanceof AST_Node)) {
  18821. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  18822. }
  18823. var rr = self.right.evaluate(compressor);
  18824. if (!rr) {
  18825. if (compressor.in_boolean_context()) {
  18826. return make_sequence(self, [
  18827. self.left,
  18828. make_node(AST_False, self)
  18829. ]).optimize(compressor);
  18830. } else {
  18831. set_flag(self, FALSY);
  18832. }
  18833. } else if (!(rr instanceof AST_Node)) {
  18834. var parent = compressor.parent();
  18835. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  18836. return self.left.optimize(compressor);
  18837. }
  18838. }
  18839. // x || false && y ---> x ? y : false
  18840. if (self.left.operator == "||") {
  18841. var lr = self.left.right.evaluate(compressor);
  18842. if (!lr) return make_node(AST_Conditional, self, {
  18843. condition: self.left.left,
  18844. consequent: self.right,
  18845. alternative: self.left.right
  18846. }).optimize(compressor);
  18847. }
  18848. break;
  18849. case "||":
  18850. var ll = has_flag(self.left, TRUTHY)
  18851. ? true
  18852. : has_flag(self.left, FALSY)
  18853. ? false
  18854. : self.left.evaluate(compressor);
  18855. if (!ll) {
  18856. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  18857. } else if (!(ll instanceof AST_Node)) {
  18858. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  18859. }
  18860. var rr = self.right.evaluate(compressor);
  18861. if (!rr) {
  18862. var parent = compressor.parent();
  18863. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  18864. return self.left.optimize(compressor);
  18865. }
  18866. } else if (!(rr instanceof AST_Node)) {
  18867. if (compressor.in_boolean_context()) {
  18868. return make_sequence(self, [
  18869. self.left,
  18870. make_node(AST_True, self)
  18871. ]).optimize(compressor);
  18872. } else {
  18873. set_flag(self, TRUTHY);
  18874. }
  18875. }
  18876. if (self.left.operator == "&&") {
  18877. var lr = self.left.right.evaluate(compressor);
  18878. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  18879. condition: self.left.left,
  18880. consequent: self.left.right,
  18881. alternative: self.right
  18882. }).optimize(compressor);
  18883. }
  18884. break;
  18885. case "??":
  18886. if (is_nullish(self.left, compressor)) {
  18887. return self.right;
  18888. }
  18889. var ll = self.left.evaluate(compressor);
  18890. if (!(ll instanceof AST_Node)) {
  18891. // if we know the value for sure we can simply compute right away.
  18892. return ll == null ? self.right : self.left;
  18893. }
  18894. if (compressor.in_boolean_context()) {
  18895. const rr = self.right.evaluate(compressor);
  18896. if (!(rr instanceof AST_Node) && !rr) {
  18897. return self.left;
  18898. }
  18899. }
  18900. }
  18901. var associative = true;
  18902. switch (self.operator) {
  18903. case "+":
  18904. // (x + "foo") + "bar" => x + "foobar"
  18905. if (self.right instanceof AST_Constant
  18906. && self.left instanceof AST_Binary
  18907. && self.left.operator == "+"
  18908. && self.left.is_string(compressor)) {
  18909. var binary = make_node(AST_Binary, self, {
  18910. operator: "+",
  18911. left: self.left.right,
  18912. right: self.right,
  18913. });
  18914. var r = binary.optimize(compressor);
  18915. if (binary !== r) {
  18916. self = make_node(AST_Binary, self, {
  18917. operator: "+",
  18918. left: self.left.left,
  18919. right: r
  18920. });
  18921. }
  18922. }
  18923. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  18924. if (self.left instanceof AST_Binary
  18925. && self.left.operator == "+"
  18926. && self.left.is_string(compressor)
  18927. && self.right instanceof AST_Binary
  18928. && self.right.operator == "+"
  18929. && self.right.is_string(compressor)) {
  18930. var binary = make_node(AST_Binary, self, {
  18931. operator: "+",
  18932. left: self.left.right,
  18933. right: self.right.left,
  18934. });
  18935. var m = binary.optimize(compressor);
  18936. if (binary !== m) {
  18937. self = make_node(AST_Binary, self, {
  18938. operator: "+",
  18939. left: make_node(AST_Binary, self.left, {
  18940. operator: "+",
  18941. left: self.left.left,
  18942. right: m
  18943. }),
  18944. right: self.right.right
  18945. });
  18946. }
  18947. }
  18948. // a + -b => a - b
  18949. if (self.right instanceof AST_UnaryPrefix
  18950. && self.right.operator == "-"
  18951. && self.left.is_number(compressor)) {
  18952. self = make_node(AST_Binary, self, {
  18953. operator: "-",
  18954. left: self.left,
  18955. right: self.right.expression
  18956. });
  18957. break;
  18958. }
  18959. // -a + b => b - a
  18960. if (self.left instanceof AST_UnaryPrefix
  18961. && self.left.operator == "-"
  18962. && reversible()
  18963. && self.right.is_number(compressor)) {
  18964. self = make_node(AST_Binary, self, {
  18965. operator: "-",
  18966. left: self.right,
  18967. right: self.left.expression
  18968. });
  18969. break;
  18970. }
  18971. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  18972. if (self.left instanceof AST_TemplateString) {
  18973. var l = self.left;
  18974. var r = self.right.evaluate(compressor);
  18975. if (r != self.right) {
  18976. l.segments[l.segments.length - 1].value += String(r);
  18977. return l;
  18978. }
  18979. }
  18980. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  18981. if (self.right instanceof AST_TemplateString) {
  18982. var r = self.right;
  18983. var l = self.left.evaluate(compressor);
  18984. if (l != self.left) {
  18985. r.segments[0].value = String(l) + r.segments[0].value;
  18986. return r;
  18987. }
  18988. }
  18989. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  18990. if (self.left instanceof AST_TemplateString
  18991. && self.right instanceof AST_TemplateString) {
  18992. var l = self.left;
  18993. var segments = l.segments;
  18994. var r = self.right;
  18995. segments[segments.length - 1].value += r.segments[0].value;
  18996. for (var i = 1; i < r.segments.length; i++) {
  18997. segments.push(r.segments[i]);
  18998. }
  18999. return l;
  19000. }
  19001. case "*":
  19002. associative = compressor.option("unsafe_math");
  19003. case "&":
  19004. case "|":
  19005. case "^":
  19006. // a + +b => +b + a
  19007. if (self.left.is_number(compressor)
  19008. && self.right.is_number(compressor)
  19009. && reversible()
  19010. && !(self.left instanceof AST_Binary
  19011. && self.left.operator != self.operator
  19012. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  19013. var reversed = make_node(AST_Binary, self, {
  19014. operator: self.operator,
  19015. left: self.right,
  19016. right: self.left
  19017. });
  19018. if (self.right instanceof AST_Constant
  19019. && !(self.left instanceof AST_Constant)) {
  19020. self = best_of(compressor, reversed, self);
  19021. } else {
  19022. self = best_of(compressor, self, reversed);
  19023. }
  19024. }
  19025. if (associative && self.is_number(compressor)) {
  19026. // a + (b + c) => (a + b) + c
  19027. if (self.right instanceof AST_Binary
  19028. && self.right.operator == self.operator) {
  19029. self = make_node(AST_Binary, self, {
  19030. operator: self.operator,
  19031. left: make_node(AST_Binary, self.left, {
  19032. operator: self.operator,
  19033. left: self.left,
  19034. right: self.right.left,
  19035. start: self.left.start,
  19036. end: self.right.left.end
  19037. }),
  19038. right: self.right.right
  19039. });
  19040. }
  19041. // (n + 2) + 3 => 5 + n
  19042. // (2 * n) * 3 => 6 + n
  19043. if (self.right instanceof AST_Constant
  19044. && self.left instanceof AST_Binary
  19045. && self.left.operator == self.operator) {
  19046. if (self.left.left instanceof AST_Constant) {
  19047. self = make_node(AST_Binary, self, {
  19048. operator: self.operator,
  19049. left: make_node(AST_Binary, self.left, {
  19050. operator: self.operator,
  19051. left: self.left.left,
  19052. right: self.right,
  19053. start: self.left.left.start,
  19054. end: self.right.end
  19055. }),
  19056. right: self.left.right
  19057. });
  19058. } else if (self.left.right instanceof AST_Constant) {
  19059. self = make_node(AST_Binary, self, {
  19060. operator: self.operator,
  19061. left: make_node(AST_Binary, self.left, {
  19062. operator: self.operator,
  19063. left: self.left.right,
  19064. right: self.right,
  19065. start: self.left.right.start,
  19066. end: self.right.end
  19067. }),
  19068. right: self.left.left
  19069. });
  19070. }
  19071. }
  19072. // (a | 1) | (2 | d) => (3 | a) | b
  19073. if (self.left instanceof AST_Binary
  19074. && self.left.operator == self.operator
  19075. && self.left.right instanceof AST_Constant
  19076. && self.right instanceof AST_Binary
  19077. && self.right.operator == self.operator
  19078. && self.right.left instanceof AST_Constant) {
  19079. self = make_node(AST_Binary, self, {
  19080. operator: self.operator,
  19081. left: make_node(AST_Binary, self.left, {
  19082. operator: self.operator,
  19083. left: make_node(AST_Binary, self.left.left, {
  19084. operator: self.operator,
  19085. left: self.left.right,
  19086. right: self.right.left,
  19087. start: self.left.right.start,
  19088. end: self.right.left.end
  19089. }),
  19090. right: self.left.left
  19091. }),
  19092. right: self.right.right
  19093. });
  19094. }
  19095. }
  19096. }
  19097. // bitwise ops
  19098. if (bitwise_binop.has(self.operator)) {
  19099. // Use De Morgan's laws
  19100. // z & (X | y)
  19101. // => z & X (given y & z === 0)
  19102. // => z & X | {y & z} (given y & z !== 0)
  19103. let y, z, x_node, y_node, z_node = self.left;
  19104. if (
  19105. self.operator === "&"
  19106. && self.right instanceof AST_Binary
  19107. && self.right.operator === "|"
  19108. && typeof (z = self.left.evaluate(compressor)) === "number"
  19109. ) {
  19110. if (typeof (y = self.right.right.evaluate(compressor)) === "number") {
  19111. // z & (X | y)
  19112. x_node = self.right.left;
  19113. y_node = self.right.right;
  19114. } else if (typeof (y = self.right.left.evaluate(compressor)) === "number") {
  19115. // z & (y | X)
  19116. x_node = self.right.right;
  19117. y_node = self.right.left;
  19118. }
  19119. if (x_node && y_node) {
  19120. if ((y & z) === 0) {
  19121. self = make_node(AST_Binary, self, {
  19122. operator: self.operator,
  19123. left: z_node,
  19124. right: x_node
  19125. });
  19126. } else {
  19127. const reordered_ops = make_node(AST_Binary, self, {
  19128. operator: "|",
  19129. left: make_node(AST_Binary, self, {
  19130. operator: "&",
  19131. left: x_node,
  19132. right: z_node
  19133. }),
  19134. right: make_node_from_constant(y & z, y_node),
  19135. });
  19136. self = best_of(compressor, self, reordered_ops);
  19137. }
  19138. }
  19139. }
  19140. // x ^ x => 0
  19141. // x | x => 0 | x
  19142. // x & x => 0 | x
  19143. const same_operands = self.left.equivalent_to(self.right) && !self.left.has_side_effects(compressor);
  19144. if (same_operands) {
  19145. if (self.operator === "^") {
  19146. return make_node(AST_Number, self, { value: 0 });
  19147. }
  19148. if (self.operator === "|" || self.operator === "&") {
  19149. self.left = make_node(AST_Number, self, { value: 0 });
  19150. self.operator = "|";
  19151. }
  19152. }
  19153. // Shifts that do nothing
  19154. // {anything} >> 0 => {anything} | 0
  19155. // {anything} << 0 => {anything} | 0
  19156. if (
  19157. (self.operator === "<<" || self.operator === ">>")
  19158. && self.right instanceof AST_Number && self.right.value === 0
  19159. ) {
  19160. self.operator = "|";
  19161. }
  19162. // Find useless to-bitwise conversions
  19163. // {32 bit integer} | 0 => {32 bit integer}
  19164. // {32 bit integer} ^ 0 => {32 bit integer}
  19165. const zero_side = self.right instanceof AST_Number && self.right.value === 0 ? self.right
  19166. : self.left instanceof AST_Number && self.left.value === 0 ? self.left
  19167. : null;
  19168. const non_zero_side = zero_side && (zero_side === self.right ? self.left : self.right);
  19169. if (
  19170. zero_side
  19171. && (self.operator === "|" || self.operator === "^")
  19172. && (non_zero_side.is_32_bit_integer() || compressor.in_32_bit_context())
  19173. ) {
  19174. return non_zero_side;
  19175. }
  19176. // {anything} & 0 => 0
  19177. if (
  19178. zero_side
  19179. && self.operator === "&"
  19180. && !non_zero_side.has_side_effects(compressor)
  19181. ) {
  19182. return zero_side;
  19183. }
  19184. const is_full_mask = (node) =>
  19185. node instanceof AST_Number && node.value === -1
  19186. ||
  19187. node instanceof AST_UnaryPrefix && (
  19188. node.operator === "-"
  19189. && node.expression instanceof AST_Number
  19190. && node.expression.value === 1
  19191. || node.operator === "~"
  19192. && node.expression instanceof AST_Number
  19193. && node.expression.value === 0);
  19194. const full_mask = is_full_mask(self.right) ? self.right
  19195. : is_full_mask(self.left) ? self.left
  19196. : null;
  19197. const non_full_mask_side = full_mask && (full_mask === self.right ? self.left : self.right);
  19198. switch (self.operator) {
  19199. case "|":
  19200. // {anything} | -1 => -1
  19201. if (full_mask && !non_full_mask_side.has_side_effects(compressor)) {
  19202. return full_mask;
  19203. }
  19204. break;
  19205. case "&":
  19206. // {32 bit integer} & -1 => {32 bit integer}
  19207. if (
  19208. full_mask
  19209. && (non_full_mask_side.is_32_bit_integer() || compressor.in_32_bit_context())
  19210. ) {
  19211. return non_full_mask_side;
  19212. }
  19213. break;
  19214. case "^":
  19215. // {anything} ^ -1 => ~{anything}
  19216. if (full_mask) {
  19217. return non_full_mask_side.bitwise_negate(compressor.in_32_bit_context());
  19218. }
  19219. // ~x ^ ~y => x ^ y
  19220. if (
  19221. self.left instanceof AST_UnaryPrefix
  19222. && self.left.operator === "~"
  19223. && self.right instanceof AST_UnaryPrefix
  19224. && self.right.operator === "~"
  19225. ) {
  19226. self = make_node(AST_Binary, self, {
  19227. operator: "^",
  19228. left: self.left.expression,
  19229. right: self.right.expression
  19230. });
  19231. }
  19232. break;
  19233. }
  19234. }
  19235. }
  19236. // x && (y && z) ==> x && y && z
  19237. // x || (y || z) ==> x || y || z
  19238. // x + ("y" + z) ==> x + "y" + z
  19239. // "x" + (y + "z")==> "x" + y + "z"
  19240. if (self.right instanceof AST_Binary
  19241. && self.right.operator == self.operator
  19242. && (lazy_op.has(self.operator)
  19243. || (self.operator == "+"
  19244. && (self.right.left.is_string(compressor)
  19245. || (self.left.is_string(compressor)
  19246. && self.right.right.is_string(compressor)))))
  19247. ) {
  19248. self.left = make_node(AST_Binary, self.left, {
  19249. operator : self.operator,
  19250. left : self.left.transform(compressor),
  19251. right : self.right.left.transform(compressor)
  19252. });
  19253. self.right = self.right.right.transform(compressor);
  19254. return self.transform(compressor);
  19255. }
  19256. var ev = self.evaluate(compressor);
  19257. if (ev !== self) {
  19258. ev = make_node_from_constant(ev, self).optimize(compressor);
  19259. return best_of(compressor, ev, self);
  19260. }
  19261. return self;
  19262. });
  19263. def_optimize(AST_SymbolExport, function(self) {
  19264. return self;
  19265. });
  19266. def_optimize(AST_SymbolRef, function(self, compressor) {
  19267. if (
  19268. !compressor.option("ie8")
  19269. && is_undeclared_ref(self)
  19270. && !compressor.find_parent(AST_With)
  19271. ) {
  19272. switch (self.name) {
  19273. case "undefined":
  19274. return make_node(AST_Undefined, self).optimize(compressor);
  19275. case "NaN":
  19276. return make_node(AST_NaN, self).optimize(compressor);
  19277. case "Infinity":
  19278. return make_node(AST_Infinity, self).optimize(compressor);
  19279. }
  19280. }
  19281. if (compressor.option("reduce_vars") && !compressor.is_lhs()) {
  19282. return inline_into_symbolref(self, compressor);
  19283. } else {
  19284. return self;
  19285. }
  19286. });
  19287. function is_atomic(lhs, self) {
  19288. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  19289. }
  19290. def_optimize(AST_Undefined, function(self, compressor) {
  19291. if (compressor.option("unsafe_undefined")) {
  19292. var undef = find_variable(compressor, "undefined");
  19293. if (undef) {
  19294. var ref = make_node(AST_SymbolRef, self, {
  19295. name : "undefined",
  19296. scope : undef.scope,
  19297. thedef : undef
  19298. });
  19299. set_flag(ref, UNDEFINED);
  19300. return ref;
  19301. }
  19302. }
  19303. var lhs = compressor.is_lhs();
  19304. if (lhs && is_atomic(lhs, self)) return self;
  19305. return make_node(AST_UnaryPrefix, self, {
  19306. operator: "void",
  19307. expression: make_node(AST_Number, self, {
  19308. value: 0
  19309. })
  19310. });
  19311. });
  19312. def_optimize(AST_Infinity, function(self, compressor) {
  19313. var lhs = compressor.is_lhs();
  19314. if (lhs && is_atomic(lhs, self)) return self;
  19315. if (
  19316. compressor.option("keep_infinity")
  19317. && !(lhs && !is_atomic(lhs, self))
  19318. && !find_variable(compressor, "Infinity")
  19319. ) {
  19320. return self;
  19321. }
  19322. return make_node(AST_Binary, self, {
  19323. operator: "/",
  19324. left: make_node(AST_Number, self, {
  19325. value: 1
  19326. }),
  19327. right: make_node(AST_Number, self, {
  19328. value: 0
  19329. })
  19330. });
  19331. });
  19332. def_optimize(AST_NaN, function(self, compressor) {
  19333. var lhs = compressor.is_lhs();
  19334. if (lhs && !is_atomic(lhs, self)
  19335. || find_variable(compressor, "NaN")) {
  19336. return make_node(AST_Binary, self, {
  19337. operator: "/",
  19338. left: make_node(AST_Number, self, {
  19339. value: 0
  19340. }),
  19341. right: make_node(AST_Number, self, {
  19342. value: 0
  19343. })
  19344. });
  19345. }
  19346. return self;
  19347. });
  19348. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  19349. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  19350. def_optimize(AST_Assign, function(self, compressor) {
  19351. if (self.logical) {
  19352. return self.lift_sequences(compressor);
  19353. }
  19354. var def;
  19355. // x = x ---> x
  19356. if (
  19357. self.operator === "="
  19358. && self.left instanceof AST_SymbolRef
  19359. && self.left.name !== "arguments"
  19360. && !(def = self.left.definition()).undeclared
  19361. && self.right.equivalent_to(self.left)
  19362. ) {
  19363. return self.right;
  19364. }
  19365. if (compressor.option("dead_code")
  19366. && self.left instanceof AST_SymbolRef
  19367. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  19368. var level = 0, node, parent = self;
  19369. do {
  19370. node = parent;
  19371. parent = compressor.parent(level++);
  19372. if (parent instanceof AST_Exit) {
  19373. if (in_try(level, parent)) break;
  19374. if (is_reachable(def.scope, [ def ])) break;
  19375. if (self.operator == "=") return self.right;
  19376. def.fixed = false;
  19377. return make_node(AST_Binary, self, {
  19378. operator: self.operator.slice(0, -1),
  19379. left: self.left,
  19380. right: self.right
  19381. }).optimize(compressor);
  19382. }
  19383. } while (parent instanceof AST_Binary && parent.right === node
  19384. || parent instanceof AST_Sequence && parent.tail_node() === node);
  19385. }
  19386. self = self.lift_sequences(compressor);
  19387. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  19388. // x = expr1 OP expr2
  19389. if (self.right.left instanceof AST_SymbolRef
  19390. && self.right.left.name == self.left.name
  19391. && ASSIGN_OPS.has(self.right.operator)) {
  19392. // x = x - 2 ---> x -= 2
  19393. self.operator = self.right.operator + "=";
  19394. self.right = self.right.right;
  19395. } else if (self.right.right instanceof AST_SymbolRef
  19396. && self.right.right.name == self.left.name
  19397. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  19398. && !self.right.left.has_side_effects(compressor)) {
  19399. // x = 2 & x ---> x &= 2
  19400. self.operator = self.right.operator + "=";
  19401. self.right = self.right.left;
  19402. }
  19403. }
  19404. return self;
  19405. function in_try(level, node) {
  19406. function may_assignment_throw() {
  19407. const right = self.right;
  19408. self.right = make_node(AST_Null, right);
  19409. const may_throw = node.may_throw(compressor);
  19410. self.right = right;
  19411. return may_throw;
  19412. }
  19413. var stop_at = self.left.definition().scope.get_defun_scope();
  19414. var parent;
  19415. while ((parent = compressor.parent(level++)) !== stop_at) {
  19416. if (parent instanceof AST_Try) {
  19417. if (parent.bfinally) return true;
  19418. if (parent.bcatch && may_assignment_throw()) return true;
  19419. }
  19420. }
  19421. }
  19422. });
  19423. def_optimize(AST_DefaultAssign, function(self, compressor) {
  19424. if (!compressor.option("evaluate")) {
  19425. return self;
  19426. }
  19427. var evaluateRight = self.right.evaluate(compressor);
  19428. // `[x = undefined] = foo` ---> `[x] = foo`
  19429. // `(arg = undefined) => ...` ---> `(arg) => ...` (unless `keep_fargs`)
  19430. // `((arg = undefined) => ...)()` ---> `((arg) => ...)()`
  19431. let lambda, iife;
  19432. if (evaluateRight === undefined) {
  19433. if (
  19434. (lambda = compressor.parent()) instanceof AST_Lambda
  19435. ? (
  19436. compressor.option("keep_fargs") === false
  19437. || (iife = compressor.parent(1)).TYPE === "Call"
  19438. && iife.expression === lambda
  19439. )
  19440. : true
  19441. ) {
  19442. self = self.left;
  19443. }
  19444. } else if (evaluateRight !== self.right) {
  19445. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  19446. self.right = best_of_expression(evaluateRight, self.right);
  19447. }
  19448. return self;
  19449. });
  19450. function is_nullish_check(check, check_subject, compressor) {
  19451. if (check_subject.may_throw(compressor)) return false;
  19452. let nullish_side;
  19453. // foo == null
  19454. if (
  19455. check instanceof AST_Binary
  19456. && check.operator === "=="
  19457. // which side is nullish?
  19458. && (
  19459. (nullish_side = is_nullish(check.left, compressor) && check.left)
  19460. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  19461. )
  19462. // is the other side the same as the check_subject
  19463. && (
  19464. nullish_side === check.left
  19465. ? check.right
  19466. : check.left
  19467. ).equivalent_to(check_subject)
  19468. ) {
  19469. return true;
  19470. }
  19471. // foo === null || foo === undefined
  19472. if (check instanceof AST_Binary && check.operator === "||") {
  19473. let null_cmp;
  19474. let undefined_cmp;
  19475. const find_comparison = cmp => {
  19476. if (!(
  19477. cmp instanceof AST_Binary
  19478. && (cmp.operator === "===" || cmp.operator === "==")
  19479. )) {
  19480. return false;
  19481. }
  19482. let found = 0;
  19483. let defined_side;
  19484. if (cmp.left instanceof AST_Null) {
  19485. found++;
  19486. null_cmp = cmp;
  19487. defined_side = cmp.right;
  19488. }
  19489. if (cmp.right instanceof AST_Null) {
  19490. found++;
  19491. null_cmp = cmp;
  19492. defined_side = cmp.left;
  19493. }
  19494. if (is_undefined(cmp.left, compressor)) {
  19495. found++;
  19496. undefined_cmp = cmp;
  19497. defined_side = cmp.right;
  19498. }
  19499. if (is_undefined(cmp.right, compressor)) {
  19500. found++;
  19501. undefined_cmp = cmp;
  19502. defined_side = cmp.left;
  19503. }
  19504. if (found !== 1) {
  19505. return false;
  19506. }
  19507. if (!defined_side.equivalent_to(check_subject)) {
  19508. return false;
  19509. }
  19510. return true;
  19511. };
  19512. if (!find_comparison(check.left)) return false;
  19513. if (!find_comparison(check.right)) return false;
  19514. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  19515. return true;
  19516. }
  19517. }
  19518. return false;
  19519. }
  19520. def_optimize(AST_Conditional, function(self, compressor) {
  19521. if (!compressor.option("conditionals")) return self;
  19522. // This looks like lift_sequences(), should probably be under "sequences"
  19523. if (self.condition instanceof AST_Sequence) {
  19524. var expressions = self.condition.expressions.slice();
  19525. self.condition = expressions.pop();
  19526. expressions.push(self);
  19527. return make_sequence(self, expressions);
  19528. }
  19529. var cond = self.condition.evaluate(compressor);
  19530. if (cond !== self.condition) {
  19531. if (cond) {
  19532. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  19533. } else {
  19534. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  19535. }
  19536. }
  19537. var negated = cond.negate(compressor, first_in_statement(compressor));
  19538. if (best_of(compressor, cond, negated) === negated) {
  19539. self = make_node(AST_Conditional, self, {
  19540. condition: negated,
  19541. consequent: self.alternative,
  19542. alternative: self.consequent
  19543. });
  19544. }
  19545. var condition = self.condition;
  19546. var consequent = self.consequent;
  19547. var alternative = self.alternative;
  19548. // x?x:y --> x||y
  19549. if (condition instanceof AST_SymbolRef
  19550. && consequent instanceof AST_SymbolRef
  19551. && condition.definition() === consequent.definition()) {
  19552. return make_node(AST_Binary, self, {
  19553. operator: "||",
  19554. left: condition,
  19555. right: alternative
  19556. });
  19557. }
  19558. // if (foo) exp = something; else exp = something_else;
  19559. // |
  19560. // v
  19561. // exp = foo ? something : something_else;
  19562. if (
  19563. consequent instanceof AST_Assign
  19564. && alternative instanceof AST_Assign
  19565. && consequent.operator === alternative.operator
  19566. && consequent.logical === alternative.logical
  19567. && consequent.left.equivalent_to(alternative.left)
  19568. && (!self.condition.has_side_effects(compressor)
  19569. || consequent.operator == "="
  19570. && !consequent.left.has_side_effects(compressor))
  19571. ) {
  19572. return make_node(AST_Assign, self, {
  19573. operator: consequent.operator,
  19574. left: consequent.left,
  19575. logical: consequent.logical,
  19576. right: make_node(AST_Conditional, self, {
  19577. condition: self.condition,
  19578. consequent: consequent.right,
  19579. alternative: alternative.right
  19580. })
  19581. });
  19582. }
  19583. // x ? y(a) : y(b) --> y(x ? a : b)
  19584. var arg_index;
  19585. if (consequent instanceof AST_Call
  19586. && alternative.TYPE === consequent.TYPE
  19587. && consequent.args.length > 0
  19588. && consequent.args.length == alternative.args.length
  19589. && consequent.expression.equivalent_to(alternative.expression)
  19590. && !self.condition.has_side_effects(compressor)
  19591. && !consequent.expression.has_side_effects(compressor)
  19592. && typeof (arg_index = single_arg_diff()) == "number") {
  19593. var node = consequent.clone();
  19594. node.args[arg_index] = make_node(AST_Conditional, self, {
  19595. condition: self.condition,
  19596. consequent: consequent.args[arg_index],
  19597. alternative: alternative.args[arg_index]
  19598. });
  19599. return node;
  19600. }
  19601. // a ? b : c ? b : d --> (a || c) ? b : d
  19602. if (alternative instanceof AST_Conditional
  19603. && consequent.equivalent_to(alternative.consequent)) {
  19604. return make_node(AST_Conditional, self, {
  19605. condition: make_node(AST_Binary, self, {
  19606. operator: "||",
  19607. left: condition,
  19608. right: alternative.condition
  19609. }),
  19610. consequent: consequent,
  19611. alternative: alternative.alternative
  19612. }).optimize(compressor);
  19613. }
  19614. // a == null ? b : a -> a ?? b
  19615. if (
  19616. compressor.option("ecma") >= 2020 &&
  19617. is_nullish_check(condition, alternative, compressor)
  19618. ) {
  19619. return make_node(AST_Binary, self, {
  19620. operator: "??",
  19621. left: alternative,
  19622. right: consequent
  19623. }).optimize(compressor);
  19624. }
  19625. // a ? b : (c, b) --> (a || c), b
  19626. if (alternative instanceof AST_Sequence
  19627. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  19628. return make_sequence(self, [
  19629. make_node(AST_Binary, self, {
  19630. operator: "||",
  19631. left: condition,
  19632. right: make_sequence(self, alternative.expressions.slice(0, -1))
  19633. }),
  19634. consequent
  19635. ]).optimize(compressor);
  19636. }
  19637. // a ? b : (c && b) --> (a || c) && b
  19638. if (alternative instanceof AST_Binary
  19639. && alternative.operator == "&&"
  19640. && consequent.equivalent_to(alternative.right)) {
  19641. return make_node(AST_Binary, self, {
  19642. operator: "&&",
  19643. left: make_node(AST_Binary, self, {
  19644. operator: "||",
  19645. left: condition,
  19646. right: alternative.left
  19647. }),
  19648. right: consequent
  19649. }).optimize(compressor);
  19650. }
  19651. // x?y?z:a:a --> x&&y?z:a
  19652. if (consequent instanceof AST_Conditional
  19653. && consequent.alternative.equivalent_to(alternative)) {
  19654. return make_node(AST_Conditional, self, {
  19655. condition: make_node(AST_Binary, self, {
  19656. left: self.condition,
  19657. operator: "&&",
  19658. right: consequent.condition
  19659. }),
  19660. consequent: consequent.consequent,
  19661. alternative: alternative
  19662. });
  19663. }
  19664. // x ? y : y --> x, y
  19665. if (consequent.equivalent_to(alternative)) {
  19666. return make_sequence(self, [
  19667. self.condition,
  19668. consequent
  19669. ]).optimize(compressor);
  19670. }
  19671. // x ? y || z : z --> x && y || z
  19672. if (consequent instanceof AST_Binary
  19673. && consequent.operator == "||"
  19674. && consequent.right.equivalent_to(alternative)) {
  19675. return make_node(AST_Binary, self, {
  19676. operator: "||",
  19677. left: make_node(AST_Binary, self, {
  19678. operator: "&&",
  19679. left: self.condition,
  19680. right: consequent.left
  19681. }),
  19682. right: alternative
  19683. }).optimize(compressor);
  19684. }
  19685. const in_bool = compressor.in_boolean_context();
  19686. if (is_true(self.consequent)) {
  19687. if (is_false(self.alternative)) {
  19688. // c ? true : false ---> !!c
  19689. return booleanize(self.condition);
  19690. }
  19691. // c ? true : x ---> !!c || x
  19692. return make_node(AST_Binary, self, {
  19693. operator: "||",
  19694. left: booleanize(self.condition),
  19695. right: self.alternative
  19696. });
  19697. }
  19698. if (is_false(self.consequent)) {
  19699. if (is_true(self.alternative)) {
  19700. // c ? false : true ---> !c
  19701. return booleanize(self.condition.negate(compressor));
  19702. }
  19703. // c ? false : x ---> !c && x
  19704. return make_node(AST_Binary, self, {
  19705. operator: "&&",
  19706. left: booleanize(self.condition.negate(compressor)),
  19707. right: self.alternative
  19708. });
  19709. }
  19710. if (is_true(self.alternative)) {
  19711. // c ? x : true ---> !c || x
  19712. return make_node(AST_Binary, self, {
  19713. operator: "||",
  19714. left: booleanize(self.condition.negate(compressor)),
  19715. right: self.consequent
  19716. });
  19717. }
  19718. if (is_false(self.alternative)) {
  19719. // c ? x : false ---> !!c && x
  19720. return make_node(AST_Binary, self, {
  19721. operator: "&&",
  19722. left: booleanize(self.condition),
  19723. right: self.consequent
  19724. });
  19725. }
  19726. return self;
  19727. function booleanize(node) {
  19728. if (node.is_boolean()) return node;
  19729. // !!expression
  19730. return make_node(AST_UnaryPrefix, node, {
  19731. operator: "!",
  19732. expression: node.negate(compressor)
  19733. });
  19734. }
  19735. // AST_True or !0
  19736. function is_true(node) {
  19737. return node instanceof AST_True
  19738. || in_bool
  19739. && node instanceof AST_Constant
  19740. && node.getValue()
  19741. || (node instanceof AST_UnaryPrefix
  19742. && node.operator == "!"
  19743. && node.expression instanceof AST_Constant
  19744. && !node.expression.getValue());
  19745. }
  19746. // AST_False or !1
  19747. function is_false(node) {
  19748. return node instanceof AST_False
  19749. || in_bool
  19750. && node instanceof AST_Constant
  19751. && !node.getValue()
  19752. || (node instanceof AST_UnaryPrefix
  19753. && node.operator == "!"
  19754. && node.expression instanceof AST_Constant
  19755. && node.expression.getValue());
  19756. }
  19757. function single_arg_diff() {
  19758. var a = consequent.args;
  19759. var b = alternative.args;
  19760. for (var i = 0, len = a.length; i < len; i++) {
  19761. if (a[i] instanceof AST_Expansion) return;
  19762. if (!a[i].equivalent_to(b[i])) {
  19763. if (b[i] instanceof AST_Expansion) return;
  19764. for (var j = i + 1; j < len; j++) {
  19765. if (a[j] instanceof AST_Expansion) return;
  19766. if (!a[j].equivalent_to(b[j])) return;
  19767. }
  19768. return i;
  19769. }
  19770. }
  19771. }
  19772. });
  19773. def_optimize(AST_Boolean, function(self, compressor) {
  19774. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  19775. value: +self.value
  19776. });
  19777. var p = compressor.parent();
  19778. if (compressor.option("booleans_as_integers")) {
  19779. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  19780. p.operator = p.operator.replace(/=$/, "");
  19781. }
  19782. return make_node(AST_Number, self, {
  19783. value: +self.value
  19784. });
  19785. }
  19786. if (compressor.option("booleans")) {
  19787. if (p instanceof AST_Binary && (p.operator == "=="
  19788. || p.operator == "!=")) {
  19789. return make_node(AST_Number, self, {
  19790. value: +self.value
  19791. });
  19792. }
  19793. return make_node(AST_UnaryPrefix, self, {
  19794. operator: "!",
  19795. expression: make_node(AST_Number, self, {
  19796. value: 1 - self.value
  19797. })
  19798. });
  19799. }
  19800. return self;
  19801. });
  19802. function safe_to_flatten(value, compressor) {
  19803. if (value instanceof AST_SymbolRef) {
  19804. value = value.fixed_value();
  19805. }
  19806. if (!value) return false;
  19807. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  19808. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  19809. return compressor.parent() instanceof AST_New;
  19810. }
  19811. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  19812. if (!compressor.option("properties")) return;
  19813. if (key === "__proto__") return;
  19814. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  19815. var expr = this.expression;
  19816. if (expr instanceof AST_Object) {
  19817. var props = expr.properties;
  19818. for (var i = props.length; --i >= 0;) {
  19819. var prop = props[i];
  19820. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  19821. const all_props_flattenable = props.every((p) =>
  19822. (p instanceof AST_ObjectKeyVal
  19823. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  19824. )
  19825. && !p.computed_key()
  19826. );
  19827. if (!all_props_flattenable) return;
  19828. if (!safe_to_flatten(prop.value, compressor)) return;
  19829. return make_node(AST_Sub, this, {
  19830. expression: make_node(AST_Array, expr, {
  19831. elements: props.map(function(prop) {
  19832. var v = prop.value;
  19833. if (v instanceof AST_Accessor) {
  19834. v = make_node(AST_Function, v, v);
  19835. }
  19836. var k = prop.key;
  19837. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  19838. return make_sequence(prop, [ k, v ]);
  19839. }
  19840. return v;
  19841. })
  19842. }),
  19843. property: make_node(AST_Number, this, {
  19844. value: i
  19845. })
  19846. });
  19847. }
  19848. }
  19849. }
  19850. });
  19851. def_optimize(AST_Sub, function(self, compressor) {
  19852. var expr = self.expression;
  19853. var prop = self.property;
  19854. if (compressor.option("properties")) {
  19855. var key = prop.evaluate(compressor);
  19856. if (key !== prop) {
  19857. if (typeof key == "string") {
  19858. if (key == "undefined") {
  19859. key = undefined;
  19860. } else {
  19861. var value = parseFloat(key);
  19862. if (value.toString() == key) {
  19863. key = value;
  19864. }
  19865. }
  19866. }
  19867. prop = self.property = best_of_expression(
  19868. prop,
  19869. make_node_from_constant(key, prop).transform(compressor)
  19870. );
  19871. var property = "" + key;
  19872. if (is_basic_identifier_string(property)
  19873. && property.length <= prop.size() + 1) {
  19874. return make_node(AST_Dot, self, {
  19875. expression: expr,
  19876. optional: self.optional,
  19877. property: property,
  19878. quote: prop.quote,
  19879. }).optimize(compressor);
  19880. }
  19881. }
  19882. }
  19883. var fn;
  19884. OPT_ARGUMENTS: if (compressor.option("arguments")
  19885. && expr instanceof AST_SymbolRef
  19886. && expr.name == "arguments"
  19887. && expr.definition().orig.length == 1
  19888. && (fn = expr.scope) instanceof AST_Lambda
  19889. && fn.uses_arguments
  19890. && !(fn instanceof AST_Arrow)
  19891. && prop instanceof AST_Number) {
  19892. var index = prop.getValue();
  19893. var params = new Set();
  19894. var argnames = fn.argnames;
  19895. for (var n = 0; n < argnames.length; n++) {
  19896. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  19897. break OPT_ARGUMENTS; // destructuring parameter - bail
  19898. }
  19899. var param = argnames[n].name;
  19900. if (params.has(param)) {
  19901. break OPT_ARGUMENTS; // duplicate parameter - bail
  19902. }
  19903. params.add(param);
  19904. }
  19905. var argname = fn.argnames[index];
  19906. if (argname && compressor.has_directive("use strict")) {
  19907. var def = argname.definition();
  19908. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  19909. argname = null;
  19910. }
  19911. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  19912. while (index >= fn.argnames.length) {
  19913. argname = fn.create_symbol(AST_SymbolFunarg, {
  19914. source: fn,
  19915. scope: fn,
  19916. tentative_name: "argument_" + fn.argnames.length,
  19917. });
  19918. fn.argnames.push(argname);
  19919. }
  19920. }
  19921. if (argname) {
  19922. var sym = make_node(AST_SymbolRef, self, argname);
  19923. sym.reference({});
  19924. clear_flag(argname, UNUSED);
  19925. return sym;
  19926. }
  19927. }
  19928. if (compressor.is_lhs()) return self;
  19929. if (key !== prop) {
  19930. var sub = self.flatten_object(property, compressor);
  19931. if (sub) {
  19932. expr = self.expression = sub.expression;
  19933. prop = self.property = sub.property;
  19934. }
  19935. }
  19936. if (compressor.option("properties") && compressor.option("side_effects")
  19937. && prop instanceof AST_Number && expr instanceof AST_Array) {
  19938. var index = prop.getValue();
  19939. var elements = expr.elements;
  19940. var retValue = elements[index];
  19941. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  19942. var flatten = true;
  19943. var values = [];
  19944. for (var i = elements.length; --i > index;) {
  19945. var value = elements[i].drop_side_effect_free(compressor);
  19946. if (value) {
  19947. values.unshift(value);
  19948. if (flatten && value.has_side_effects(compressor)) flatten = false;
  19949. }
  19950. }
  19951. if (retValue instanceof AST_Expansion) break FLATTEN;
  19952. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  19953. if (!flatten) values.unshift(retValue);
  19954. while (--i >= 0) {
  19955. var value = elements[i];
  19956. if (value instanceof AST_Expansion) break FLATTEN;
  19957. value = value.drop_side_effect_free(compressor);
  19958. if (value) values.unshift(value);
  19959. else index--;
  19960. }
  19961. if (flatten) {
  19962. values.push(retValue);
  19963. return make_sequence(self, values).optimize(compressor);
  19964. } else return make_node(AST_Sub, self, {
  19965. expression: make_node(AST_Array, expr, {
  19966. elements: values
  19967. }),
  19968. property: make_node(AST_Number, prop, {
  19969. value: index
  19970. })
  19971. });
  19972. }
  19973. }
  19974. var ev = self.evaluate(compressor);
  19975. if (ev !== self) {
  19976. ev = make_node_from_constant(ev, self).optimize(compressor);
  19977. return best_of(compressor, ev, self);
  19978. }
  19979. return self;
  19980. });
  19981. def_optimize(AST_Chain, function (self, compressor) {
  19982. if (is_nullish(self.expression, compressor)) {
  19983. let parent = compressor.parent();
  19984. // It's valid to delete a nullish optional chain, but if we optimized
  19985. // this to `delete undefined` then it would appear to be a syntax error
  19986. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  19987. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  19988. return make_node_from_constant(0, self);
  19989. }
  19990. return make_node(AST_Undefined, self);
  19991. }
  19992. return self;
  19993. });
  19994. def_optimize(AST_Dot, function(self, compressor) {
  19995. const parent = compressor.parent();
  19996. if (compressor.is_lhs()) return self;
  19997. if (compressor.option("unsafe_proto")
  19998. && self.expression instanceof AST_Dot
  19999. && self.expression.property == "prototype") {
  20000. var exp = self.expression.expression;
  20001. if (is_undeclared_ref(exp)) switch (exp.name) {
  20002. case "Array":
  20003. self.expression = make_node(AST_Array, self.expression, {
  20004. elements: []
  20005. });
  20006. break;
  20007. case "Function":
  20008. self.expression = make_node(AST_Function, self.expression, {
  20009. argnames: [],
  20010. body: []
  20011. });
  20012. break;
  20013. case "Number":
  20014. self.expression = make_node(AST_Number, self.expression, {
  20015. value: 0
  20016. });
  20017. break;
  20018. case "Object":
  20019. self.expression = make_node(AST_Object, self.expression, {
  20020. properties: []
  20021. });
  20022. break;
  20023. case "RegExp":
  20024. self.expression = make_node(AST_RegExp, self.expression, {
  20025. value: { source: "t", flags: "" }
  20026. });
  20027. break;
  20028. case "String":
  20029. self.expression = make_node(AST_String, self.expression, {
  20030. value: ""
  20031. });
  20032. break;
  20033. }
  20034. }
  20035. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  20036. const sub = self.flatten_object(self.property, compressor);
  20037. if (sub) return sub.optimize(compressor);
  20038. }
  20039. if (self.expression instanceof AST_PropAccess
  20040. && parent instanceof AST_PropAccess) {
  20041. return self;
  20042. }
  20043. let ev = self.evaluate(compressor);
  20044. if (ev !== self) {
  20045. ev = make_node_from_constant(ev, self).optimize(compressor);
  20046. return best_of(compressor, ev, self);
  20047. }
  20048. return self;
  20049. });
  20050. function literals_in_boolean_context(self, compressor) {
  20051. if (compressor.in_boolean_context()) {
  20052. return best_of(compressor, self, make_sequence(self, [
  20053. self,
  20054. make_node(AST_True, self)
  20055. ]).optimize(compressor));
  20056. }
  20057. return self;
  20058. }
  20059. function inline_array_like_spread(elements) {
  20060. for (var i = 0; i < elements.length; i++) {
  20061. var el = elements[i];
  20062. if (el instanceof AST_Expansion) {
  20063. var expr = el.expression;
  20064. if (
  20065. expr instanceof AST_Array
  20066. && !expr.elements.some(elm => elm instanceof AST_Hole)
  20067. ) {
  20068. elements.splice(i, 1, ...expr.elements);
  20069. // Step back one, as the element at i is now new.
  20070. i--;
  20071. }
  20072. // In array-like spread, spreading a non-iterable value is TypeError.
  20073. // We therefore can’t optimize anything else, unlike with object spread.
  20074. }
  20075. }
  20076. }
  20077. def_optimize(AST_Array, function(self, compressor) {
  20078. var optimized = literals_in_boolean_context(self, compressor);
  20079. if (optimized !== self) {
  20080. return optimized;
  20081. }
  20082. inline_array_like_spread(self.elements);
  20083. return self;
  20084. });
  20085. function inline_object_prop_spread(props) {
  20086. for (var i = 0; i < props.length; i++) {
  20087. var prop = props[i];
  20088. if (prop instanceof AST_Expansion) {
  20089. const expr = prop.expression;
  20090. if (
  20091. expr instanceof AST_Object
  20092. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  20093. ) {
  20094. props.splice(i, 1, ...expr.properties);
  20095. // Step back one, as the property at i is now new.
  20096. i--;
  20097. } else if ((
  20098. // `expr.is_constant()` returns `false` for `AST_RegExp`, so need both.
  20099. expr instanceof AST_Constant
  20100. || expr.is_constant()
  20101. ) && !(expr instanceof AST_String)) {
  20102. // Unlike array-like spread, in object spread, spreading a
  20103. // non-iterable value silently does nothing; it is thus safe
  20104. // to remove. AST_String is the only iterable constant.
  20105. props.splice(i, 1);
  20106. i--;
  20107. }
  20108. }
  20109. }
  20110. }
  20111. def_optimize(AST_Object, function(self, compressor) {
  20112. var optimized = literals_in_boolean_context(self, compressor);
  20113. if (optimized !== self) {
  20114. return optimized;
  20115. }
  20116. inline_object_prop_spread(self.properties);
  20117. return self;
  20118. });
  20119. def_optimize(AST_RegExp, literals_in_boolean_context);
  20120. def_optimize(AST_Return, function(self, compressor) {
  20121. if (self.value && is_undefined(self.value, compressor)) {
  20122. self.value = null;
  20123. }
  20124. return self;
  20125. });
  20126. def_optimize(AST_Arrow, opt_AST_Lambda);
  20127. def_optimize(AST_Function, function(self, compressor) {
  20128. self = opt_AST_Lambda(self, compressor);
  20129. if (compressor.option("unsafe_arrows")
  20130. && compressor.option("ecma") >= 2015
  20131. && !self.name
  20132. && !self.is_generator
  20133. && !self.uses_arguments
  20134. && !self.pinned()) {
  20135. const uses_this = walk(self, node => {
  20136. if (node instanceof AST_This) return walk_abort;
  20137. });
  20138. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  20139. }
  20140. return self;
  20141. });
  20142. def_optimize(AST_Class, function(self) {
  20143. for (let i = 0; i < self.properties.length; i++) {
  20144. const prop = self.properties[i];
  20145. if (prop instanceof AST_ClassStaticBlock && prop.body.length == 0) {
  20146. self.properties.splice(i, 1);
  20147. i--;
  20148. }
  20149. }
  20150. return self;
  20151. });
  20152. def_optimize(AST_ClassStaticBlock, function(self, compressor) {
  20153. tighten_body(self.body, compressor);
  20154. return self;
  20155. });
  20156. def_optimize(AST_Yield, function(self, compressor) {
  20157. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  20158. self.expression = null;
  20159. }
  20160. return self;
  20161. });
  20162. def_optimize(AST_TemplateString, function(self, compressor) {
  20163. if (
  20164. !compressor.option("evaluate")
  20165. || compressor.parent() instanceof AST_PrefixedTemplateString
  20166. ) {
  20167. return self;
  20168. }
  20169. var segments = [];
  20170. for (var i = 0; i < self.segments.length; i++) {
  20171. var segment = self.segments[i];
  20172. if (segment instanceof AST_Node) {
  20173. var result = segment.evaluate(compressor);
  20174. // Evaluate to constant value
  20175. // Constant value shorter than ${segment}
  20176. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  20177. // There should always be a previous and next segment if segment is a node
  20178. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  20179. continue;
  20180. }
  20181. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  20182. // TODO:
  20183. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  20184. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  20185. if (segment instanceof AST_TemplateString) {
  20186. var inners = segment.segments;
  20187. segments[segments.length - 1].value += inners[0].value;
  20188. for (var j = 1; j < inners.length; j++) {
  20189. segment = inners[j];
  20190. segments.push(segment);
  20191. }
  20192. continue;
  20193. }
  20194. }
  20195. segments.push(segment);
  20196. }
  20197. self.segments = segments;
  20198. // `foo` => "foo"
  20199. if (segments.length == 1) {
  20200. return make_node(AST_String, self, segments[0]);
  20201. }
  20202. if (
  20203. segments.length === 3
  20204. && segments[1] instanceof AST_Node
  20205. && (
  20206. segments[1].is_string(compressor)
  20207. || segments[1].is_number(compressor)
  20208. || is_nullish(segments[1], compressor)
  20209. || compressor.option("unsafe")
  20210. )
  20211. ) {
  20212. // `foo${bar}` => "foo" + bar
  20213. if (segments[2].value === "") {
  20214. return make_node(AST_Binary, self, {
  20215. operator: "+",
  20216. left: make_node(AST_String, self, {
  20217. value: segments[0].value,
  20218. }),
  20219. right: segments[1],
  20220. });
  20221. }
  20222. // `${bar}baz` => bar + "baz"
  20223. if (segments[0].value === "") {
  20224. return make_node(AST_Binary, self, {
  20225. operator: "+",
  20226. left: segments[1],
  20227. right: make_node(AST_String, self, {
  20228. value: segments[2].value,
  20229. }),
  20230. });
  20231. }
  20232. }
  20233. return self;
  20234. });
  20235. def_optimize(AST_PrefixedTemplateString, function(self) {
  20236. return self;
  20237. });
  20238. // ["p"]:1 ---> p:1
  20239. // [42]:1 ---> 42:1
  20240. function lift_key(self, compressor) {
  20241. if (!compressor.option("computed_props")) return self;
  20242. // save a comparison in the typical case
  20243. if (!(self.key instanceof AST_Constant)) return self;
  20244. // allow certain acceptable props as not all AST_Constants are true constants
  20245. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  20246. const key = self.key.value.toString();
  20247. if (key === "__proto__") return self;
  20248. if (key == "constructor"
  20249. && compressor.parent() instanceof AST_Class) return self;
  20250. if (self instanceof AST_ObjectKeyVal) {
  20251. self.quote = self.key.quote;
  20252. self.key = key;
  20253. } else if (self instanceof AST_ClassProperty) {
  20254. self.quote = self.key.quote;
  20255. self.key = make_node(AST_SymbolClassProperty, self.key, {
  20256. name: key,
  20257. });
  20258. } else {
  20259. self.quote = self.key.quote;
  20260. self.key = make_node(AST_SymbolMethod, self.key, {
  20261. name: key,
  20262. });
  20263. }
  20264. }
  20265. return self;
  20266. }
  20267. def_optimize(AST_ObjectProperty, lift_key);
  20268. def_optimize(AST_ConciseMethod, function(self, compressor) {
  20269. lift_key(self, compressor);
  20270. // p(){return x;} ---> p:()=>x
  20271. if (compressor.option("arrows")
  20272. && compressor.parent() instanceof AST_Object
  20273. && !self.is_generator
  20274. && !self.value.uses_arguments
  20275. && !self.value.pinned()
  20276. && self.value.body.length == 1
  20277. && self.value.body[0] instanceof AST_Return
  20278. && self.value.body[0].value
  20279. && !self.value.contains_this()) {
  20280. var arrow = make_node(AST_Arrow, self.value, self.value);
  20281. arrow.async = self.async;
  20282. arrow.is_generator = self.is_generator;
  20283. return make_node(AST_ObjectKeyVal, self, {
  20284. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  20285. value: arrow,
  20286. quote: self.quote,
  20287. });
  20288. }
  20289. return self;
  20290. });
  20291. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  20292. lift_key(self, compressor);
  20293. // p:function(){} ---> p(){}
  20294. // p:function*(){} ---> *p(){}
  20295. // p:async function(){} ---> async p(){}
  20296. // p:()=>{} ---> p(){}
  20297. // p:async()=>{} ---> async p(){}
  20298. var unsafe_methods = compressor.option("unsafe_methods");
  20299. if (unsafe_methods
  20300. && compressor.option("ecma") >= 2015
  20301. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  20302. var key = self.key;
  20303. var value = self.value;
  20304. var is_arrow_with_block = value instanceof AST_Arrow
  20305. && Array.isArray(value.body)
  20306. && !value.contains_this();
  20307. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  20308. return make_node(AST_ConciseMethod, self, {
  20309. async: value.async,
  20310. is_generator: value.is_generator,
  20311. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  20312. name: key,
  20313. }),
  20314. value: make_node(AST_Accessor, value, value),
  20315. quote: self.quote,
  20316. });
  20317. }
  20318. }
  20319. return self;
  20320. });
  20321. def_optimize(AST_Destructuring, function(self, compressor) {
  20322. if (compressor.option("pure_getters") == true
  20323. && compressor.option("unused")
  20324. && !self.is_array
  20325. && Array.isArray(self.names)
  20326. && !is_destructuring_export_decl(compressor)
  20327. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  20328. var keep = [];
  20329. for (var i = 0; i < self.names.length; i++) {
  20330. var elem = self.names[i];
  20331. if (!(elem instanceof AST_ObjectKeyVal
  20332. && typeof elem.key == "string"
  20333. && elem.value instanceof AST_SymbolDeclaration
  20334. && !should_retain(compressor, elem.value.definition()))) {
  20335. keep.push(elem);
  20336. }
  20337. }
  20338. if (keep.length != self.names.length) {
  20339. self.names = keep;
  20340. }
  20341. }
  20342. return self;
  20343. function is_destructuring_export_decl(compressor) {
  20344. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  20345. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  20346. var parent = compressor.parent(p);
  20347. if (!parent) return false;
  20348. if (a === 0 && parent.TYPE == "Destructuring") continue;
  20349. if (!ancestors[a].test(parent.TYPE)) {
  20350. return false;
  20351. }
  20352. a++;
  20353. }
  20354. return true;
  20355. }
  20356. function should_retain(compressor, def) {
  20357. if (def.references.length) return true;
  20358. if (!def.global) return false;
  20359. if (compressor.toplevel.vars) {
  20360. if (compressor.top_retain) {
  20361. return compressor.top_retain(def);
  20362. }
  20363. return false;
  20364. }
  20365. return true;
  20366. }
  20367. });
  20368. /***********************************************************************
  20369. A JavaScript tokenizer / parser / beautifier / compressor.
  20370. https://github.com/mishoo/UglifyJS2
  20371. -------------------------------- (C) ---------------------------------
  20372. Author: Mihai Bazon
  20373. <mihai.bazon@gmail.com>
  20374. http://mihai.bazon.net/blog
  20375. Distributed under the BSD license:
  20376. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  20377. Redistribution and use in source and binary forms, with or without
  20378. modification, are permitted provided that the following conditions
  20379. are met:
  20380. * Redistributions of source code must retain the above
  20381. copyright notice, this list of conditions and the following
  20382. disclaimer.
  20383. * Redistributions in binary form must reproduce the above
  20384. copyright notice, this list of conditions and the following
  20385. disclaimer in the documentation and/or other materials
  20386. provided with the distribution.
  20387. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  20388. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20389. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20390. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  20391. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  20392. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20393. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20394. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20395. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  20396. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  20397. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  20398. SUCH DAMAGE.
  20399. ***********************************************************************/
  20400. // a small wrapper around source-map and @jridgewell/source-map
  20401. function* SourceMap(options) {
  20402. options = defaults(options, {
  20403. file : null,
  20404. root : null,
  20405. orig : null,
  20406. files: {},
  20407. });
  20408. var orig_map;
  20409. var generator = new sourceMap.SourceMapGenerator({
  20410. file : options.file,
  20411. sourceRoot : options.root
  20412. });
  20413. let sourcesContent = {__proto__: null};
  20414. let files = options.files;
  20415. for (var name in files) if (HOP(files, name)) {
  20416. sourcesContent[name] = files[name];
  20417. }
  20418. if (options.orig) {
  20419. // We support both @jridgewell/source-map (which has a sync
  20420. // SourceMapConsumer) and source-map (which has an async
  20421. // SourceMapConsumer).
  20422. orig_map = yield new sourceMap.SourceMapConsumer(options.orig);
  20423. if (orig_map.sourcesContent) {
  20424. orig_map.sources.forEach(function(source, i) {
  20425. var content = orig_map.sourcesContent[i];
  20426. if (content) {
  20427. sourcesContent[source] = content;
  20428. }
  20429. });
  20430. }
  20431. }
  20432. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  20433. let generatedPos = { line: gen_line, column: gen_col };
  20434. if (orig_map) {
  20435. var info = orig_map.originalPositionFor({
  20436. line: orig_line,
  20437. column: orig_col
  20438. });
  20439. if (info.source === null) {
  20440. generator.addMapping({
  20441. generated: generatedPos,
  20442. original: null,
  20443. source: null,
  20444. name: null
  20445. });
  20446. return;
  20447. }
  20448. source = info.source;
  20449. orig_line = info.line;
  20450. orig_col = info.column;
  20451. name = info.name || name;
  20452. }
  20453. generator.addMapping({
  20454. generated : generatedPos,
  20455. original : { line: orig_line, column: orig_col },
  20456. source : source,
  20457. name : name
  20458. });
  20459. generator.setSourceContent(source, sourcesContent[source]);
  20460. }
  20461. function clean(map) {
  20462. const allNull = map.sourcesContent && map.sourcesContent.every(c => c == null);
  20463. if (allNull) delete map.sourcesContent;
  20464. if (map.file === undefined) delete map.file;
  20465. if (map.sourceRoot === undefined) delete map.sourceRoot;
  20466. return map;
  20467. }
  20468. function getDecoded() {
  20469. if (!generator.toDecodedMap) return null;
  20470. return clean(generator.toDecodedMap());
  20471. }
  20472. function getEncoded() {
  20473. return clean(generator.toJSON());
  20474. }
  20475. function destroy() {
  20476. // @jridgewell/source-map's SourceMapConsumer does not need to be
  20477. // manually freed.
  20478. if (orig_map && orig_map.destroy) orig_map.destroy();
  20479. }
  20480. return {
  20481. add,
  20482. getDecoded,
  20483. getEncoded,
  20484. destroy,
  20485. };
  20486. }
  20487. var domprops = [
  20488. "$&",
  20489. "$'",
  20490. "$*",
  20491. "$+",
  20492. "$1",
  20493. "$2",
  20494. "$3",
  20495. "$4",
  20496. "$5",
  20497. "$6",
  20498. "$7",
  20499. "$8",
  20500. "$9",
  20501. "$_",
  20502. "$`",
  20503. "$input",
  20504. "-moz-animation",
  20505. "-moz-animation-delay",
  20506. "-moz-animation-direction",
  20507. "-moz-animation-duration",
  20508. "-moz-animation-fill-mode",
  20509. "-moz-animation-iteration-count",
  20510. "-moz-animation-name",
  20511. "-moz-animation-play-state",
  20512. "-moz-animation-timing-function",
  20513. "-moz-appearance",
  20514. "-moz-backface-visibility",
  20515. "-moz-border-end",
  20516. "-moz-border-end-color",
  20517. "-moz-border-end-style",
  20518. "-moz-border-end-width",
  20519. "-moz-border-image",
  20520. "-moz-border-start",
  20521. "-moz-border-start-color",
  20522. "-moz-border-start-style",
  20523. "-moz-border-start-width",
  20524. "-moz-box-align",
  20525. "-moz-box-direction",
  20526. "-moz-box-flex",
  20527. "-moz-box-ordinal-group",
  20528. "-moz-box-orient",
  20529. "-moz-box-pack",
  20530. "-moz-box-sizing",
  20531. "-moz-float-edge",
  20532. "-moz-font-feature-settings",
  20533. "-moz-font-language-override",
  20534. "-moz-force-broken-image-icon",
  20535. "-moz-hyphens",
  20536. "-moz-image-region",
  20537. "-moz-margin-end",
  20538. "-moz-margin-start",
  20539. "-moz-orient",
  20540. "-moz-osx-font-smoothing",
  20541. "-moz-outline-radius",
  20542. "-moz-outline-radius-bottomleft",
  20543. "-moz-outline-radius-bottomright",
  20544. "-moz-outline-radius-topleft",
  20545. "-moz-outline-radius-topright",
  20546. "-moz-padding-end",
  20547. "-moz-padding-start",
  20548. "-moz-perspective",
  20549. "-moz-perspective-origin",
  20550. "-moz-tab-size",
  20551. "-moz-text-size-adjust",
  20552. "-moz-transform",
  20553. "-moz-transform-origin",
  20554. "-moz-transform-style",
  20555. "-moz-transition",
  20556. "-moz-transition-delay",
  20557. "-moz-transition-duration",
  20558. "-moz-transition-property",
  20559. "-moz-transition-timing-function",
  20560. "-moz-user-focus",
  20561. "-moz-user-input",
  20562. "-moz-user-modify",
  20563. "-moz-user-select",
  20564. "-moz-window-dragging",
  20565. "-webkit-align-content",
  20566. "-webkit-align-items",
  20567. "-webkit-align-self",
  20568. "-webkit-animation",
  20569. "-webkit-animation-delay",
  20570. "-webkit-animation-direction",
  20571. "-webkit-animation-duration",
  20572. "-webkit-animation-fill-mode",
  20573. "-webkit-animation-iteration-count",
  20574. "-webkit-animation-name",
  20575. "-webkit-animation-play-state",
  20576. "-webkit-animation-timing-function",
  20577. "-webkit-appearance",
  20578. "-webkit-backface-visibility",
  20579. "-webkit-background-clip",
  20580. "-webkit-background-origin",
  20581. "-webkit-background-size",
  20582. "-webkit-border-bottom-left-radius",
  20583. "-webkit-border-bottom-right-radius",
  20584. "-webkit-border-image",
  20585. "-webkit-border-radius",
  20586. "-webkit-border-top-left-radius",
  20587. "-webkit-border-top-right-radius",
  20588. "-webkit-box-align",
  20589. "-webkit-box-direction",
  20590. "-webkit-box-flex",
  20591. "-webkit-box-ordinal-group",
  20592. "-webkit-box-orient",
  20593. "-webkit-box-pack",
  20594. "-webkit-box-shadow",
  20595. "-webkit-box-sizing",
  20596. "-webkit-clip-path",
  20597. "-webkit-filter",
  20598. "-webkit-flex",
  20599. "-webkit-flex-basis",
  20600. "-webkit-flex-direction",
  20601. "-webkit-flex-flow",
  20602. "-webkit-flex-grow",
  20603. "-webkit-flex-shrink",
  20604. "-webkit-flex-wrap",
  20605. "-webkit-justify-content",
  20606. "-webkit-line-clamp",
  20607. "-webkit-mask",
  20608. "-webkit-mask-clip",
  20609. "-webkit-mask-composite",
  20610. "-webkit-mask-image",
  20611. "-webkit-mask-origin",
  20612. "-webkit-mask-position",
  20613. "-webkit-mask-position-x",
  20614. "-webkit-mask-position-y",
  20615. "-webkit-mask-repeat",
  20616. "-webkit-mask-size",
  20617. "-webkit-order",
  20618. "-webkit-perspective",
  20619. "-webkit-perspective-origin",
  20620. "-webkit-text-fill-color",
  20621. "-webkit-text-security",
  20622. "-webkit-text-size-adjust",
  20623. "-webkit-text-stroke",
  20624. "-webkit-text-stroke-color",
  20625. "-webkit-text-stroke-width",
  20626. "-webkit-transform",
  20627. "-webkit-transform-origin",
  20628. "-webkit-transform-style",
  20629. "-webkit-transition",
  20630. "-webkit-transition-delay",
  20631. "-webkit-transition-duration",
  20632. "-webkit-transition-property",
  20633. "-webkit-transition-timing-function",
  20634. "-webkit-user-select",
  20635. "0",
  20636. "1",
  20637. "10",
  20638. "11",
  20639. "12",
  20640. "13",
  20641. "14",
  20642. "15",
  20643. "16",
  20644. "17",
  20645. "18",
  20646. "19",
  20647. "2",
  20648. "20",
  20649. "3",
  20650. "4",
  20651. "5",
  20652. "6",
  20653. "7",
  20654. "8",
  20655. "9",
  20656. "@@iterator",
  20657. "ABORT_ERR",
  20658. "ACTIVE",
  20659. "ACTIVE_ATTRIBUTES",
  20660. "ACTIVE_TEXTURE",
  20661. "ACTIVE_UNIFORMS",
  20662. "ACTIVE_UNIFORM_BLOCKS",
  20663. "ADDITION",
  20664. "ALIASED_LINE_WIDTH_RANGE",
  20665. "ALIASED_POINT_SIZE_RANGE",
  20666. "ALL",
  20667. "ALLOW_KEYBOARD_INPUT",
  20668. "ALLPASS",
  20669. "ALPHA",
  20670. "ALPHA_BITS",
  20671. "ALREADY_SIGNALED",
  20672. "ALT_MASK",
  20673. "ALWAYS",
  20674. "ANY_SAMPLES_PASSED",
  20675. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  20676. "ANY_TYPE",
  20677. "ANY_UNORDERED_NODE_TYPE",
  20678. "ARRAY_BUFFER",
  20679. "ARRAY_BUFFER_BINDING",
  20680. "ATTACHED_SHADERS",
  20681. "ATTRIBUTE_NODE",
  20682. "AT_TARGET",
  20683. "AbortController",
  20684. "AbortSignal",
  20685. "AbsoluteOrientationSensor",
  20686. "AbstractRange",
  20687. "Accelerometer",
  20688. "AddSearchProvider",
  20689. "AggregateError",
  20690. "AnalyserNode",
  20691. "Animation",
  20692. "AnimationEffect",
  20693. "AnimationEvent",
  20694. "AnimationPlaybackEvent",
  20695. "AnimationTimeline",
  20696. "AnonXMLHttpRequest",
  20697. "Any",
  20698. "ApplicationCache",
  20699. "ApplicationCacheErrorEvent",
  20700. "Array",
  20701. "ArrayBuffer",
  20702. "ArrayType",
  20703. "Atomics",
  20704. "Attr",
  20705. "Audio",
  20706. "AudioBuffer",
  20707. "AudioBufferSourceNode",
  20708. "AudioContext",
  20709. "AudioData",
  20710. "AudioDecoder",
  20711. "AudioDestinationNode",
  20712. "AudioEncoder",
  20713. "AudioListener",
  20714. "AudioNode",
  20715. "AudioParam",
  20716. "AudioParamMap",
  20717. "AudioProcessingEvent",
  20718. "AudioScheduledSourceNode",
  20719. "AudioSinkInfo",
  20720. "AudioStreamTrack",
  20721. "AudioWorklet",
  20722. "AudioWorkletNode",
  20723. "AuthenticatorAssertionResponse",
  20724. "AuthenticatorAttestationResponse",
  20725. "AuthenticatorResponse",
  20726. "AutocompleteErrorEvent",
  20727. "BACK",
  20728. "BAD_BOUNDARYPOINTS_ERR",
  20729. "BAD_REQUEST",
  20730. "BANDPASS",
  20731. "BLEND",
  20732. "BLEND_COLOR",
  20733. "BLEND_DST_ALPHA",
  20734. "BLEND_DST_RGB",
  20735. "BLEND_EQUATION",
  20736. "BLEND_EQUATION_ALPHA",
  20737. "BLEND_EQUATION_RGB",
  20738. "BLEND_SRC_ALPHA",
  20739. "BLEND_SRC_RGB",
  20740. "BLUE",
  20741. "BLUE_BITS",
  20742. "BLUR",
  20743. "BOOL",
  20744. "BOOLEAN_TYPE",
  20745. "BOOL_VEC2",
  20746. "BOOL_VEC3",
  20747. "BOOL_VEC4",
  20748. "BOTH",
  20749. "BROWSER_DEFAULT_WEBGL",
  20750. "BUBBLING_PHASE",
  20751. "BUFFER_SIZE",
  20752. "BUFFER_USAGE",
  20753. "BYTE",
  20754. "BYTES_PER_ELEMENT",
  20755. "BackgroundFetchManager",
  20756. "BackgroundFetchRecord",
  20757. "BackgroundFetchRegistration",
  20758. "BarProp",
  20759. "BarcodeDetector",
  20760. "BaseAudioContext",
  20761. "BaseHref",
  20762. "BatteryManager",
  20763. "BeforeInstallPromptEvent",
  20764. "BeforeLoadEvent",
  20765. "BeforeUnloadEvent",
  20766. "BigInt",
  20767. "BigInt64Array",
  20768. "BigUint64Array",
  20769. "BiquadFilterNode",
  20770. "Blob",
  20771. "BlobEvent",
  20772. "Bluetooth",
  20773. "BluetoothCharacteristicProperties",
  20774. "BluetoothDevice",
  20775. "BluetoothRemoteGATTCharacteristic",
  20776. "BluetoothRemoteGATTDescriptor",
  20777. "BluetoothRemoteGATTServer",
  20778. "BluetoothRemoteGATTService",
  20779. "BluetoothUUID",
  20780. "Boolean",
  20781. "BroadcastChannel",
  20782. "BrowserCaptureMediaStreamTrack",
  20783. "ByteLengthQueuingStrategy",
  20784. "CAPTURING_PHASE",
  20785. "CCW",
  20786. "CDATASection",
  20787. "CDATA_SECTION_NODE",
  20788. "CHANGE",
  20789. "CHARSET_RULE",
  20790. "CHECKING",
  20791. "CLAMP_TO_EDGE",
  20792. "CLICK",
  20793. "CLOSED",
  20794. "CLOSING",
  20795. "COLOR",
  20796. "COLOR_ATTACHMENT0",
  20797. "COLOR_ATTACHMENT1",
  20798. "COLOR_ATTACHMENT10",
  20799. "COLOR_ATTACHMENT11",
  20800. "COLOR_ATTACHMENT12",
  20801. "COLOR_ATTACHMENT13",
  20802. "COLOR_ATTACHMENT14",
  20803. "COLOR_ATTACHMENT15",
  20804. "COLOR_ATTACHMENT2",
  20805. "COLOR_ATTACHMENT3",
  20806. "COLOR_ATTACHMENT4",
  20807. "COLOR_ATTACHMENT5",
  20808. "COLOR_ATTACHMENT6",
  20809. "COLOR_ATTACHMENT7",
  20810. "COLOR_ATTACHMENT8",
  20811. "COLOR_ATTACHMENT9",
  20812. "COLOR_BUFFER_BIT",
  20813. "COLOR_CLEAR_VALUE",
  20814. "COLOR_WRITEMASK",
  20815. "COMMENT_NODE",
  20816. "COMPARE_REF_TO_TEXTURE",
  20817. "COMPILE_STATUS",
  20818. "COMPLETION_STATUS_KHR",
  20819. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  20820. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  20821. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  20822. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  20823. "COMPRESSED_TEXTURE_FORMATS",
  20824. "COMPUTE",
  20825. "CONDITION_SATISFIED",
  20826. "CONFIGURATION_UNSUPPORTED",
  20827. "CONNECTING",
  20828. "CONSTANT_ALPHA",
  20829. "CONSTANT_COLOR",
  20830. "CONSTRAINT_ERR",
  20831. "CONTEXT_LOST_WEBGL",
  20832. "CONTROL_MASK",
  20833. "COPY_DST",
  20834. "COPY_READ_BUFFER",
  20835. "COPY_READ_BUFFER_BINDING",
  20836. "COPY_SRC",
  20837. "COPY_WRITE_BUFFER",
  20838. "COPY_WRITE_BUFFER_BINDING",
  20839. "COUNTER_STYLE_RULE",
  20840. "CSS",
  20841. "CSS2Properties",
  20842. "CSSAnimation",
  20843. "CSSCharsetRule",
  20844. "CSSConditionRule",
  20845. "CSSContainerRule",
  20846. "CSSCounterStyleRule",
  20847. "CSSFontFaceRule",
  20848. "CSSFontFeatureValuesRule",
  20849. "CSSFontPaletteValuesRule",
  20850. "CSSGroupingRule",
  20851. "CSSImageValue",
  20852. "CSSImportRule",
  20853. "CSSKeyframeRule",
  20854. "CSSKeyframesRule",
  20855. "CSSKeywordValue",
  20856. "CSSLayerBlockRule",
  20857. "CSSLayerStatementRule",
  20858. "CSSMathClamp",
  20859. "CSSMathInvert",
  20860. "CSSMathMax",
  20861. "CSSMathMin",
  20862. "CSSMathNegate",
  20863. "CSSMathProduct",
  20864. "CSSMathSum",
  20865. "CSSMathValue",
  20866. "CSSMatrixComponent",
  20867. "CSSMediaRule",
  20868. "CSSMozDocumentRule",
  20869. "CSSNameSpaceRule",
  20870. "CSSNamespaceRule",
  20871. "CSSNumericArray",
  20872. "CSSNumericValue",
  20873. "CSSPageRule",
  20874. "CSSPerspective",
  20875. "CSSPositionValue",
  20876. "CSSPrimitiveValue",
  20877. "CSSPropertyRule",
  20878. "CSSRotate",
  20879. "CSSRule",
  20880. "CSSRuleList",
  20881. "CSSScale",
  20882. "CSSScopeRule",
  20883. "CSSSkew",
  20884. "CSSSkewX",
  20885. "CSSSkewY",
  20886. "CSSStartingStyleRule",
  20887. "CSSStyleDeclaration",
  20888. "CSSStyleRule",
  20889. "CSSStyleSheet",
  20890. "CSSStyleValue",
  20891. "CSSSupportsRule",
  20892. "CSSTransformComponent",
  20893. "CSSTransformValue",
  20894. "CSSTransition",
  20895. "CSSTranslate",
  20896. "CSSUnitValue",
  20897. "CSSUnknownRule",
  20898. "CSSUnparsedValue",
  20899. "CSSValue",
  20900. "CSSValueList",
  20901. "CSSVariableReferenceValue",
  20902. "CSSVariablesDeclaration",
  20903. "CSSVariablesRule",
  20904. "CSSViewportRule",
  20905. "CSS_ATTR",
  20906. "CSS_CM",
  20907. "CSS_COUNTER",
  20908. "CSS_CUSTOM",
  20909. "CSS_DEG",
  20910. "CSS_DIMENSION",
  20911. "CSS_EMS",
  20912. "CSS_EXS",
  20913. "CSS_FILTER_BLUR",
  20914. "CSS_FILTER_BRIGHTNESS",
  20915. "CSS_FILTER_CONTRAST",
  20916. "CSS_FILTER_CUSTOM",
  20917. "CSS_FILTER_DROP_SHADOW",
  20918. "CSS_FILTER_GRAYSCALE",
  20919. "CSS_FILTER_HUE_ROTATE",
  20920. "CSS_FILTER_INVERT",
  20921. "CSS_FILTER_OPACITY",
  20922. "CSS_FILTER_REFERENCE",
  20923. "CSS_FILTER_SATURATE",
  20924. "CSS_FILTER_SEPIA",
  20925. "CSS_GRAD",
  20926. "CSS_HZ",
  20927. "CSS_IDENT",
  20928. "CSS_IN",
  20929. "CSS_INHERIT",
  20930. "CSS_KHZ",
  20931. "CSS_MATRIX",
  20932. "CSS_MATRIX3D",
  20933. "CSS_MM",
  20934. "CSS_MS",
  20935. "CSS_NUMBER",
  20936. "CSS_PC",
  20937. "CSS_PERCENTAGE",
  20938. "CSS_PERSPECTIVE",
  20939. "CSS_PRIMITIVE_VALUE",
  20940. "CSS_PT",
  20941. "CSS_PX",
  20942. "CSS_RAD",
  20943. "CSS_RECT",
  20944. "CSS_RGBCOLOR",
  20945. "CSS_ROTATE",
  20946. "CSS_ROTATE3D",
  20947. "CSS_ROTATEX",
  20948. "CSS_ROTATEY",
  20949. "CSS_ROTATEZ",
  20950. "CSS_S",
  20951. "CSS_SCALE",
  20952. "CSS_SCALE3D",
  20953. "CSS_SCALEX",
  20954. "CSS_SCALEY",
  20955. "CSS_SCALEZ",
  20956. "CSS_SKEW",
  20957. "CSS_SKEWX",
  20958. "CSS_SKEWY",
  20959. "CSS_STRING",
  20960. "CSS_TRANSLATE",
  20961. "CSS_TRANSLATE3D",
  20962. "CSS_TRANSLATEX",
  20963. "CSS_TRANSLATEY",
  20964. "CSS_TRANSLATEZ",
  20965. "CSS_UNKNOWN",
  20966. "CSS_URI",
  20967. "CSS_VALUE_LIST",
  20968. "CSS_VH",
  20969. "CSS_VMAX",
  20970. "CSS_VMIN",
  20971. "CSS_VW",
  20972. "CULL_FACE",
  20973. "CULL_FACE_MODE",
  20974. "CURRENT_PROGRAM",
  20975. "CURRENT_QUERY",
  20976. "CURRENT_VERTEX_ATTRIB",
  20977. "CUSTOM",
  20978. "CW",
  20979. "Cache",
  20980. "CacheStorage",
  20981. "CanvasCaptureMediaStream",
  20982. "CanvasCaptureMediaStreamTrack",
  20983. "CanvasGradient",
  20984. "CanvasPattern",
  20985. "CanvasRenderingContext2D",
  20986. "CaptureController",
  20987. "CaretPosition",
  20988. "ChannelMergerNode",
  20989. "ChannelSplitterNode",
  20990. "CharacterBoundsUpdateEvent",
  20991. "CharacterData",
  20992. "ClientRect",
  20993. "ClientRectList",
  20994. "Clipboard",
  20995. "ClipboardEvent",
  20996. "ClipboardItem",
  20997. "CloseEvent",
  20998. "Collator",
  20999. "CommandEvent",
  21000. "Comment",
  21001. "CompileError",
  21002. "CompositionEvent",
  21003. "CompressionStream",
  21004. "Console",
  21005. "ConstantSourceNode",
  21006. "ContentVisibilityAutoStateChangeEvent",
  21007. "Controllers",
  21008. "ConvolverNode",
  21009. "CookieChangeEvent",
  21010. "CookieStore",
  21011. "CookieStoreManager",
  21012. "CountQueuingStrategy",
  21013. "Counter",
  21014. "Credential",
  21015. "CredentialsContainer",
  21016. "CropTarget",
  21017. "Crypto",
  21018. "CryptoKey",
  21019. "CustomElementRegistry",
  21020. "CustomEvent",
  21021. "CustomStateSet",
  21022. "DATABASE_ERR",
  21023. "DATA_CLONE_ERR",
  21024. "DATA_ERR",
  21025. "DBLCLICK",
  21026. "DECR",
  21027. "DECR_WRAP",
  21028. "DELETE_STATUS",
  21029. "DEPTH",
  21030. "DEPTH24_STENCIL8",
  21031. "DEPTH32F_STENCIL8",
  21032. "DEPTH_ATTACHMENT",
  21033. "DEPTH_BITS",
  21034. "DEPTH_BUFFER_BIT",
  21035. "DEPTH_CLEAR_VALUE",
  21036. "DEPTH_COMPONENT",
  21037. "DEPTH_COMPONENT16",
  21038. "DEPTH_COMPONENT24",
  21039. "DEPTH_COMPONENT32F",
  21040. "DEPTH_FUNC",
  21041. "DEPTH_RANGE",
  21042. "DEPTH_STENCIL",
  21043. "DEPTH_STENCIL_ATTACHMENT",
  21044. "DEPTH_TEST",
  21045. "DEPTH_WRITEMASK",
  21046. "DEVICE_INELIGIBLE",
  21047. "DIRECTION_DOWN",
  21048. "DIRECTION_LEFT",
  21049. "DIRECTION_RIGHT",
  21050. "DIRECTION_UP",
  21051. "DISABLED",
  21052. "DISPATCH_REQUEST_ERR",
  21053. "DITHER",
  21054. "DOCUMENT_FRAGMENT_NODE",
  21055. "DOCUMENT_NODE",
  21056. "DOCUMENT_POSITION_CONTAINED_BY",
  21057. "DOCUMENT_POSITION_CONTAINS",
  21058. "DOCUMENT_POSITION_DISCONNECTED",
  21059. "DOCUMENT_POSITION_FOLLOWING",
  21060. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  21061. "DOCUMENT_POSITION_PRECEDING",
  21062. "DOCUMENT_TYPE_NODE",
  21063. "DOMCursor",
  21064. "DOMError",
  21065. "DOMException",
  21066. "DOMImplementation",
  21067. "DOMImplementationLS",
  21068. "DOMMatrix",
  21069. "DOMMatrixReadOnly",
  21070. "DOMParser",
  21071. "DOMPoint",
  21072. "DOMPointReadOnly",
  21073. "DOMQuad",
  21074. "DOMRect",
  21075. "DOMRectList",
  21076. "DOMRectReadOnly",
  21077. "DOMRequest",
  21078. "DOMSTRING_SIZE_ERR",
  21079. "DOMSettableTokenList",
  21080. "DOMStringList",
  21081. "DOMStringMap",
  21082. "DOMTokenList",
  21083. "DOMTransactionEvent",
  21084. "DOM_DELTA_LINE",
  21085. "DOM_DELTA_PAGE",
  21086. "DOM_DELTA_PIXEL",
  21087. "DOM_INPUT_METHOD_DROP",
  21088. "DOM_INPUT_METHOD_HANDWRITING",
  21089. "DOM_INPUT_METHOD_IME",
  21090. "DOM_INPUT_METHOD_KEYBOARD",
  21091. "DOM_INPUT_METHOD_MULTIMODAL",
  21092. "DOM_INPUT_METHOD_OPTION",
  21093. "DOM_INPUT_METHOD_PASTE",
  21094. "DOM_INPUT_METHOD_SCRIPT",
  21095. "DOM_INPUT_METHOD_UNKNOWN",
  21096. "DOM_INPUT_METHOD_VOICE",
  21097. "DOM_KEY_LOCATION_JOYSTICK",
  21098. "DOM_KEY_LOCATION_LEFT",
  21099. "DOM_KEY_LOCATION_MOBILE",
  21100. "DOM_KEY_LOCATION_NUMPAD",
  21101. "DOM_KEY_LOCATION_RIGHT",
  21102. "DOM_KEY_LOCATION_STANDARD",
  21103. "DOM_VK_0",
  21104. "DOM_VK_1",
  21105. "DOM_VK_2",
  21106. "DOM_VK_3",
  21107. "DOM_VK_4",
  21108. "DOM_VK_5",
  21109. "DOM_VK_6",
  21110. "DOM_VK_7",
  21111. "DOM_VK_8",
  21112. "DOM_VK_9",
  21113. "DOM_VK_A",
  21114. "DOM_VK_ACCEPT",
  21115. "DOM_VK_ADD",
  21116. "DOM_VK_ALT",
  21117. "DOM_VK_ALTGR",
  21118. "DOM_VK_AMPERSAND",
  21119. "DOM_VK_ASTERISK",
  21120. "DOM_VK_AT",
  21121. "DOM_VK_ATTN",
  21122. "DOM_VK_B",
  21123. "DOM_VK_BACKSPACE",
  21124. "DOM_VK_BACK_QUOTE",
  21125. "DOM_VK_BACK_SLASH",
  21126. "DOM_VK_BACK_SPACE",
  21127. "DOM_VK_C",
  21128. "DOM_VK_CANCEL",
  21129. "DOM_VK_CAPS_LOCK",
  21130. "DOM_VK_CIRCUMFLEX",
  21131. "DOM_VK_CLEAR",
  21132. "DOM_VK_CLOSE_BRACKET",
  21133. "DOM_VK_CLOSE_CURLY_BRACKET",
  21134. "DOM_VK_CLOSE_PAREN",
  21135. "DOM_VK_COLON",
  21136. "DOM_VK_COMMA",
  21137. "DOM_VK_CONTEXT_MENU",
  21138. "DOM_VK_CONTROL",
  21139. "DOM_VK_CONVERT",
  21140. "DOM_VK_CRSEL",
  21141. "DOM_VK_CTRL",
  21142. "DOM_VK_D",
  21143. "DOM_VK_DECIMAL",
  21144. "DOM_VK_DELETE",
  21145. "DOM_VK_DIVIDE",
  21146. "DOM_VK_DOLLAR",
  21147. "DOM_VK_DOUBLE_QUOTE",
  21148. "DOM_VK_DOWN",
  21149. "DOM_VK_E",
  21150. "DOM_VK_EISU",
  21151. "DOM_VK_END",
  21152. "DOM_VK_ENTER",
  21153. "DOM_VK_EQUALS",
  21154. "DOM_VK_EREOF",
  21155. "DOM_VK_ESCAPE",
  21156. "DOM_VK_EXCLAMATION",
  21157. "DOM_VK_EXECUTE",
  21158. "DOM_VK_EXSEL",
  21159. "DOM_VK_F",
  21160. "DOM_VK_F1",
  21161. "DOM_VK_F10",
  21162. "DOM_VK_F11",
  21163. "DOM_VK_F12",
  21164. "DOM_VK_F13",
  21165. "DOM_VK_F14",
  21166. "DOM_VK_F15",
  21167. "DOM_VK_F16",
  21168. "DOM_VK_F17",
  21169. "DOM_VK_F18",
  21170. "DOM_VK_F19",
  21171. "DOM_VK_F2",
  21172. "DOM_VK_F20",
  21173. "DOM_VK_F21",
  21174. "DOM_VK_F22",
  21175. "DOM_VK_F23",
  21176. "DOM_VK_F24",
  21177. "DOM_VK_F25",
  21178. "DOM_VK_F26",
  21179. "DOM_VK_F27",
  21180. "DOM_VK_F28",
  21181. "DOM_VK_F29",
  21182. "DOM_VK_F3",
  21183. "DOM_VK_F30",
  21184. "DOM_VK_F31",
  21185. "DOM_VK_F32",
  21186. "DOM_VK_F33",
  21187. "DOM_VK_F34",
  21188. "DOM_VK_F35",
  21189. "DOM_VK_F36",
  21190. "DOM_VK_F4",
  21191. "DOM_VK_F5",
  21192. "DOM_VK_F6",
  21193. "DOM_VK_F7",
  21194. "DOM_VK_F8",
  21195. "DOM_VK_F9",
  21196. "DOM_VK_FINAL",
  21197. "DOM_VK_FRONT",
  21198. "DOM_VK_G",
  21199. "DOM_VK_GREATER_THAN",
  21200. "DOM_VK_H",
  21201. "DOM_VK_HANGUL",
  21202. "DOM_VK_HANJA",
  21203. "DOM_VK_HASH",
  21204. "DOM_VK_HELP",
  21205. "DOM_VK_HK_TOGGLE",
  21206. "DOM_VK_HOME",
  21207. "DOM_VK_HYPHEN_MINUS",
  21208. "DOM_VK_I",
  21209. "DOM_VK_INSERT",
  21210. "DOM_VK_J",
  21211. "DOM_VK_JUNJA",
  21212. "DOM_VK_K",
  21213. "DOM_VK_KANA",
  21214. "DOM_VK_KANJI",
  21215. "DOM_VK_L",
  21216. "DOM_VK_LEFT",
  21217. "DOM_VK_LEFT_TAB",
  21218. "DOM_VK_LESS_THAN",
  21219. "DOM_VK_M",
  21220. "DOM_VK_META",
  21221. "DOM_VK_MODECHANGE",
  21222. "DOM_VK_MULTIPLY",
  21223. "DOM_VK_N",
  21224. "DOM_VK_NONCONVERT",
  21225. "DOM_VK_NUMPAD0",
  21226. "DOM_VK_NUMPAD1",
  21227. "DOM_VK_NUMPAD2",
  21228. "DOM_VK_NUMPAD3",
  21229. "DOM_VK_NUMPAD4",
  21230. "DOM_VK_NUMPAD5",
  21231. "DOM_VK_NUMPAD6",
  21232. "DOM_VK_NUMPAD7",
  21233. "DOM_VK_NUMPAD8",
  21234. "DOM_VK_NUMPAD9",
  21235. "DOM_VK_NUM_LOCK",
  21236. "DOM_VK_O",
  21237. "DOM_VK_OEM_1",
  21238. "DOM_VK_OEM_102",
  21239. "DOM_VK_OEM_2",
  21240. "DOM_VK_OEM_3",
  21241. "DOM_VK_OEM_4",
  21242. "DOM_VK_OEM_5",
  21243. "DOM_VK_OEM_6",
  21244. "DOM_VK_OEM_7",
  21245. "DOM_VK_OEM_8",
  21246. "DOM_VK_OEM_COMMA",
  21247. "DOM_VK_OEM_MINUS",
  21248. "DOM_VK_OEM_PERIOD",
  21249. "DOM_VK_OEM_PLUS",
  21250. "DOM_VK_OPEN_BRACKET",
  21251. "DOM_VK_OPEN_CURLY_BRACKET",
  21252. "DOM_VK_OPEN_PAREN",
  21253. "DOM_VK_P",
  21254. "DOM_VK_PA1",
  21255. "DOM_VK_PAGEDOWN",
  21256. "DOM_VK_PAGEUP",
  21257. "DOM_VK_PAGE_DOWN",
  21258. "DOM_VK_PAGE_UP",
  21259. "DOM_VK_PAUSE",
  21260. "DOM_VK_PERCENT",
  21261. "DOM_VK_PERIOD",
  21262. "DOM_VK_PIPE",
  21263. "DOM_VK_PLAY",
  21264. "DOM_VK_PLUS",
  21265. "DOM_VK_PRINT",
  21266. "DOM_VK_PRINTSCREEN",
  21267. "DOM_VK_PROCESSKEY",
  21268. "DOM_VK_PROPERITES",
  21269. "DOM_VK_Q",
  21270. "DOM_VK_QUESTION_MARK",
  21271. "DOM_VK_QUOTE",
  21272. "DOM_VK_R",
  21273. "DOM_VK_REDO",
  21274. "DOM_VK_RETURN",
  21275. "DOM_VK_RIGHT",
  21276. "DOM_VK_S",
  21277. "DOM_VK_SCROLL_LOCK",
  21278. "DOM_VK_SELECT",
  21279. "DOM_VK_SEMICOLON",
  21280. "DOM_VK_SEPARATOR",
  21281. "DOM_VK_SHIFT",
  21282. "DOM_VK_SLASH",
  21283. "DOM_VK_SLEEP",
  21284. "DOM_VK_SPACE",
  21285. "DOM_VK_SUBTRACT",
  21286. "DOM_VK_T",
  21287. "DOM_VK_TAB",
  21288. "DOM_VK_TILDE",
  21289. "DOM_VK_U",
  21290. "DOM_VK_UNDERSCORE",
  21291. "DOM_VK_UNDO",
  21292. "DOM_VK_UNICODE",
  21293. "DOM_VK_UP",
  21294. "DOM_VK_V",
  21295. "DOM_VK_VOLUME_DOWN",
  21296. "DOM_VK_VOLUME_MUTE",
  21297. "DOM_VK_VOLUME_UP",
  21298. "DOM_VK_W",
  21299. "DOM_VK_WIN",
  21300. "DOM_VK_WINDOW",
  21301. "DOM_VK_WIN_ICO_00",
  21302. "DOM_VK_WIN_ICO_CLEAR",
  21303. "DOM_VK_WIN_ICO_HELP",
  21304. "DOM_VK_WIN_OEM_ATTN",
  21305. "DOM_VK_WIN_OEM_AUTO",
  21306. "DOM_VK_WIN_OEM_BACKTAB",
  21307. "DOM_VK_WIN_OEM_CLEAR",
  21308. "DOM_VK_WIN_OEM_COPY",
  21309. "DOM_VK_WIN_OEM_CUSEL",
  21310. "DOM_VK_WIN_OEM_ENLW",
  21311. "DOM_VK_WIN_OEM_FINISH",
  21312. "DOM_VK_WIN_OEM_FJ_JISHO",
  21313. "DOM_VK_WIN_OEM_FJ_LOYA",
  21314. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  21315. "DOM_VK_WIN_OEM_FJ_ROYA",
  21316. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  21317. "DOM_VK_WIN_OEM_JUMP",
  21318. "DOM_VK_WIN_OEM_PA1",
  21319. "DOM_VK_WIN_OEM_PA2",
  21320. "DOM_VK_WIN_OEM_PA3",
  21321. "DOM_VK_WIN_OEM_RESET",
  21322. "DOM_VK_WIN_OEM_WSCTRL",
  21323. "DOM_VK_X",
  21324. "DOM_VK_XF86XK_ADD_FAVORITE",
  21325. "DOM_VK_XF86XK_APPLICATION_LEFT",
  21326. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  21327. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  21328. "DOM_VK_XF86XK_AUDIO_FORWARD",
  21329. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  21330. "DOM_VK_XF86XK_AUDIO_MEDIA",
  21331. "DOM_VK_XF86XK_AUDIO_MUTE",
  21332. "DOM_VK_XF86XK_AUDIO_NEXT",
  21333. "DOM_VK_XF86XK_AUDIO_PAUSE",
  21334. "DOM_VK_XF86XK_AUDIO_PLAY",
  21335. "DOM_VK_XF86XK_AUDIO_PREV",
  21336. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  21337. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  21338. "DOM_VK_XF86XK_AUDIO_RECORD",
  21339. "DOM_VK_XF86XK_AUDIO_REPEAT",
  21340. "DOM_VK_XF86XK_AUDIO_REWIND",
  21341. "DOM_VK_XF86XK_AUDIO_STOP",
  21342. "DOM_VK_XF86XK_AWAY",
  21343. "DOM_VK_XF86XK_BACK",
  21344. "DOM_VK_XF86XK_BACK_FORWARD",
  21345. "DOM_VK_XF86XK_BATTERY",
  21346. "DOM_VK_XF86XK_BLUE",
  21347. "DOM_VK_XF86XK_BLUETOOTH",
  21348. "DOM_VK_XF86XK_BOOK",
  21349. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  21350. "DOM_VK_XF86XK_CALCULATOR",
  21351. "DOM_VK_XF86XK_CALENDAR",
  21352. "DOM_VK_XF86XK_CD",
  21353. "DOM_VK_XF86XK_CLOSE",
  21354. "DOM_VK_XF86XK_COMMUNITY",
  21355. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  21356. "DOM_VK_XF86XK_COPY",
  21357. "DOM_VK_XF86XK_CUT",
  21358. "DOM_VK_XF86XK_CYCLE_ANGLE",
  21359. "DOM_VK_XF86XK_DISPLAY",
  21360. "DOM_VK_XF86XK_DOCUMENTS",
  21361. "DOM_VK_XF86XK_DOS",
  21362. "DOM_VK_XF86XK_EJECT",
  21363. "DOM_VK_XF86XK_EXCEL",
  21364. "DOM_VK_XF86XK_EXPLORER",
  21365. "DOM_VK_XF86XK_FAVORITES",
  21366. "DOM_VK_XF86XK_FINANCE",
  21367. "DOM_VK_XF86XK_FORWARD",
  21368. "DOM_VK_XF86XK_FRAME_BACK",
  21369. "DOM_VK_XF86XK_FRAME_FORWARD",
  21370. "DOM_VK_XF86XK_GAME",
  21371. "DOM_VK_XF86XK_GO",
  21372. "DOM_VK_XF86XK_GREEN",
  21373. "DOM_VK_XF86XK_HIBERNATE",
  21374. "DOM_VK_XF86XK_HISTORY",
  21375. "DOM_VK_XF86XK_HOME_PAGE",
  21376. "DOM_VK_XF86XK_HOT_LINKS",
  21377. "DOM_VK_XF86XK_I_TOUCH",
  21378. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  21379. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  21380. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  21381. "DOM_VK_XF86XK_LAUNCH0",
  21382. "DOM_VK_XF86XK_LAUNCH1",
  21383. "DOM_VK_XF86XK_LAUNCH2",
  21384. "DOM_VK_XF86XK_LAUNCH3",
  21385. "DOM_VK_XF86XK_LAUNCH4",
  21386. "DOM_VK_XF86XK_LAUNCH5",
  21387. "DOM_VK_XF86XK_LAUNCH6",
  21388. "DOM_VK_XF86XK_LAUNCH7",
  21389. "DOM_VK_XF86XK_LAUNCH8",
  21390. "DOM_VK_XF86XK_LAUNCH9",
  21391. "DOM_VK_XF86XK_LAUNCH_A",
  21392. "DOM_VK_XF86XK_LAUNCH_B",
  21393. "DOM_VK_XF86XK_LAUNCH_C",
  21394. "DOM_VK_XF86XK_LAUNCH_D",
  21395. "DOM_VK_XF86XK_LAUNCH_E",
  21396. "DOM_VK_XF86XK_LAUNCH_F",
  21397. "DOM_VK_XF86XK_LIGHT_BULB",
  21398. "DOM_VK_XF86XK_LOG_OFF",
  21399. "DOM_VK_XF86XK_MAIL",
  21400. "DOM_VK_XF86XK_MAIL_FORWARD",
  21401. "DOM_VK_XF86XK_MARKET",
  21402. "DOM_VK_XF86XK_MEETING",
  21403. "DOM_VK_XF86XK_MEMO",
  21404. "DOM_VK_XF86XK_MENU_KB",
  21405. "DOM_VK_XF86XK_MENU_PB",
  21406. "DOM_VK_XF86XK_MESSENGER",
  21407. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  21408. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  21409. "DOM_VK_XF86XK_MUSIC",
  21410. "DOM_VK_XF86XK_MY_COMPUTER",
  21411. "DOM_VK_XF86XK_MY_SITES",
  21412. "DOM_VK_XF86XK_NEW",
  21413. "DOM_VK_XF86XK_NEWS",
  21414. "DOM_VK_XF86XK_OFFICE_HOME",
  21415. "DOM_VK_XF86XK_OPEN",
  21416. "DOM_VK_XF86XK_OPEN_URL",
  21417. "DOM_VK_XF86XK_OPTION",
  21418. "DOM_VK_XF86XK_PASTE",
  21419. "DOM_VK_XF86XK_PHONE",
  21420. "DOM_VK_XF86XK_PICTURES",
  21421. "DOM_VK_XF86XK_POWER_DOWN",
  21422. "DOM_VK_XF86XK_POWER_OFF",
  21423. "DOM_VK_XF86XK_RED",
  21424. "DOM_VK_XF86XK_REFRESH",
  21425. "DOM_VK_XF86XK_RELOAD",
  21426. "DOM_VK_XF86XK_REPLY",
  21427. "DOM_VK_XF86XK_ROCKER_DOWN",
  21428. "DOM_VK_XF86XK_ROCKER_ENTER",
  21429. "DOM_VK_XF86XK_ROCKER_UP",
  21430. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  21431. "DOM_VK_XF86XK_ROTATION_KB",
  21432. "DOM_VK_XF86XK_ROTATION_PB",
  21433. "DOM_VK_XF86XK_SAVE",
  21434. "DOM_VK_XF86XK_SCREEN_SAVER",
  21435. "DOM_VK_XF86XK_SCROLL_CLICK",
  21436. "DOM_VK_XF86XK_SCROLL_DOWN",
  21437. "DOM_VK_XF86XK_SCROLL_UP",
  21438. "DOM_VK_XF86XK_SEARCH",
  21439. "DOM_VK_XF86XK_SEND",
  21440. "DOM_VK_XF86XK_SHOP",
  21441. "DOM_VK_XF86XK_SPELL",
  21442. "DOM_VK_XF86XK_SPLIT_SCREEN",
  21443. "DOM_VK_XF86XK_STANDBY",
  21444. "DOM_VK_XF86XK_START",
  21445. "DOM_VK_XF86XK_STOP",
  21446. "DOM_VK_XF86XK_SUBTITLE",
  21447. "DOM_VK_XF86XK_SUPPORT",
  21448. "DOM_VK_XF86XK_SUSPEND",
  21449. "DOM_VK_XF86XK_TASK_PANE",
  21450. "DOM_VK_XF86XK_TERMINAL",
  21451. "DOM_VK_XF86XK_TIME",
  21452. "DOM_VK_XF86XK_TOOLS",
  21453. "DOM_VK_XF86XK_TOP_MENU",
  21454. "DOM_VK_XF86XK_TO_DO_LIST",
  21455. "DOM_VK_XF86XK_TRAVEL",
  21456. "DOM_VK_XF86XK_USER1KB",
  21457. "DOM_VK_XF86XK_USER2KB",
  21458. "DOM_VK_XF86XK_USER_PB",
  21459. "DOM_VK_XF86XK_UWB",
  21460. "DOM_VK_XF86XK_VENDOR_HOME",
  21461. "DOM_VK_XF86XK_VIDEO",
  21462. "DOM_VK_XF86XK_VIEW",
  21463. "DOM_VK_XF86XK_WAKE_UP",
  21464. "DOM_VK_XF86XK_WEB_CAM",
  21465. "DOM_VK_XF86XK_WHEEL_BUTTON",
  21466. "DOM_VK_XF86XK_WLAN",
  21467. "DOM_VK_XF86XK_WORD",
  21468. "DOM_VK_XF86XK_WWW",
  21469. "DOM_VK_XF86XK_XFER",
  21470. "DOM_VK_XF86XK_YELLOW",
  21471. "DOM_VK_XF86XK_ZOOM_IN",
  21472. "DOM_VK_XF86XK_ZOOM_OUT",
  21473. "DOM_VK_Y",
  21474. "DOM_VK_Z",
  21475. "DOM_VK_ZOOM",
  21476. "DONE",
  21477. "DONT_CARE",
  21478. "DOWNLOADING",
  21479. "DRAGDROP",
  21480. "DRAW_BUFFER0",
  21481. "DRAW_BUFFER1",
  21482. "DRAW_BUFFER10",
  21483. "DRAW_BUFFER11",
  21484. "DRAW_BUFFER12",
  21485. "DRAW_BUFFER13",
  21486. "DRAW_BUFFER14",
  21487. "DRAW_BUFFER15",
  21488. "DRAW_BUFFER2",
  21489. "DRAW_BUFFER3",
  21490. "DRAW_BUFFER4",
  21491. "DRAW_BUFFER5",
  21492. "DRAW_BUFFER6",
  21493. "DRAW_BUFFER7",
  21494. "DRAW_BUFFER8",
  21495. "DRAW_BUFFER9",
  21496. "DRAW_FRAMEBUFFER",
  21497. "DRAW_FRAMEBUFFER_BINDING",
  21498. "DST_ALPHA",
  21499. "DST_COLOR",
  21500. "DYNAMIC_COPY",
  21501. "DYNAMIC_DRAW",
  21502. "DYNAMIC_READ",
  21503. "DataChannel",
  21504. "DataTransfer",
  21505. "DataTransferItem",
  21506. "DataTransferItemList",
  21507. "DataView",
  21508. "Date",
  21509. "DateTimeFormat",
  21510. "DecompressionStream",
  21511. "DelayNode",
  21512. "DelegatedInkTrailPresenter",
  21513. "DeprecationReportBody",
  21514. "DesktopNotification",
  21515. "DesktopNotificationCenter",
  21516. "DeviceLightEvent",
  21517. "DeviceMotionEvent",
  21518. "DeviceMotionEventAcceleration",
  21519. "DeviceMotionEventRotationRate",
  21520. "DeviceOrientationEvent",
  21521. "DeviceProximityEvent",
  21522. "DeviceStorage",
  21523. "DeviceStorageChangeEvent",
  21524. "Directory",
  21525. "DisplayNames",
  21526. "Document",
  21527. "DocumentFragment",
  21528. "DocumentPictureInPicture",
  21529. "DocumentPictureInPictureEvent",
  21530. "DocumentTimeline",
  21531. "DocumentType",
  21532. "DragEvent",
  21533. "DynamicsCompressorNode",
  21534. "E",
  21535. "ELEMENT_ARRAY_BUFFER",
  21536. "ELEMENT_ARRAY_BUFFER_BINDING",
  21537. "ELEMENT_NODE",
  21538. "EMPTY",
  21539. "ENCODING_ERR",
  21540. "ENDED",
  21541. "END_TO_END",
  21542. "END_TO_START",
  21543. "ENTITY_NODE",
  21544. "ENTITY_REFERENCE_NODE",
  21545. "EPSILON",
  21546. "EQUAL",
  21547. "EQUALPOWER",
  21548. "ERROR",
  21549. "EXPONENTIAL_DISTANCE",
  21550. "EditContext",
  21551. "Element",
  21552. "ElementInternals",
  21553. "ElementQuery",
  21554. "EncodedAudioChunk",
  21555. "EncodedVideoChunk",
  21556. "EnterPictureInPictureEvent",
  21557. "Entity",
  21558. "EntityReference",
  21559. "Error",
  21560. "ErrorEvent",
  21561. "EvalError",
  21562. "Event",
  21563. "EventCounts",
  21564. "EventException",
  21565. "EventSource",
  21566. "EventTarget",
  21567. "Exception",
  21568. "External",
  21569. "EyeDropper",
  21570. "FASTEST",
  21571. "FIDOSDK",
  21572. "FILTER_ACCEPT",
  21573. "FILTER_INTERRUPT",
  21574. "FILTER_REJECT",
  21575. "FILTER_SKIP",
  21576. "FINISHED_STATE",
  21577. "FIRST_ORDERED_NODE_TYPE",
  21578. "FLOAT",
  21579. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  21580. "FLOAT_MAT2",
  21581. "FLOAT_MAT2x3",
  21582. "FLOAT_MAT2x4",
  21583. "FLOAT_MAT3",
  21584. "FLOAT_MAT3x2",
  21585. "FLOAT_MAT3x4",
  21586. "FLOAT_MAT4",
  21587. "FLOAT_MAT4x2",
  21588. "FLOAT_MAT4x3",
  21589. "FLOAT_VEC2",
  21590. "FLOAT_VEC3",
  21591. "FLOAT_VEC4",
  21592. "FOCUS",
  21593. "FONT_FACE_RULE",
  21594. "FONT_FEATURE_VALUES_RULE",
  21595. "FRAGMENT",
  21596. "FRAGMENT_SHADER",
  21597. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  21598. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  21599. "FRAMEBUFFER",
  21600. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  21601. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  21602. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  21603. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  21604. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  21605. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  21606. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  21607. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  21608. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  21609. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  21610. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  21611. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  21612. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  21613. "FRAMEBUFFER_BINDING",
  21614. "FRAMEBUFFER_COMPLETE",
  21615. "FRAMEBUFFER_DEFAULT",
  21616. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  21617. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  21618. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  21619. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  21620. "FRAMEBUFFER_UNSUPPORTED",
  21621. "FRONT",
  21622. "FRONT_AND_BACK",
  21623. "FRONT_FACE",
  21624. "FUNC_ADD",
  21625. "FUNC_REVERSE_SUBTRACT",
  21626. "FUNC_SUBTRACT",
  21627. "FeaturePolicy",
  21628. "FeaturePolicyViolationReportBody",
  21629. "FederatedCredential",
  21630. "Feed",
  21631. "FeedEntry",
  21632. "Fence",
  21633. "FencedFrameConfig",
  21634. "File",
  21635. "FileError",
  21636. "FileList",
  21637. "FileReader",
  21638. "FileSystem",
  21639. "FileSystemDirectoryEntry",
  21640. "FileSystemDirectoryHandle",
  21641. "FileSystemDirectoryReader",
  21642. "FileSystemEntry",
  21643. "FileSystemFileEntry",
  21644. "FileSystemFileHandle",
  21645. "FileSystemHandle",
  21646. "FileSystemWritableFileStream",
  21647. "FinalizationRegistry",
  21648. "FindInPage",
  21649. "Float32Array",
  21650. "Float64Array",
  21651. "FocusEvent",
  21652. "FontData",
  21653. "FontFace",
  21654. "FontFaceSet",
  21655. "FontFaceSetLoadEvent",
  21656. "FormData",
  21657. "FormDataEvent",
  21658. "FragmentDirective",
  21659. "Function",
  21660. "GENERATE_MIPMAP_HINT",
  21661. "GEQUAL",
  21662. "GPU",
  21663. "GPUAdapter",
  21664. "GPUAdapterInfo",
  21665. "GPUBindGroup",
  21666. "GPUBindGroupLayout",
  21667. "GPUBuffer",
  21668. "GPUBufferUsage",
  21669. "GPUCanvasContext",
  21670. "GPUColorWrite",
  21671. "GPUCommandBuffer",
  21672. "GPUCommandEncoder",
  21673. "GPUCompilationInfo",
  21674. "GPUCompilationMessage",
  21675. "GPUComputePassEncoder",
  21676. "GPUComputePipeline",
  21677. "GPUDevice",
  21678. "GPUDeviceLostInfo",
  21679. "GPUError",
  21680. "GPUExternalTexture",
  21681. "GPUInternalError",
  21682. "GPUMapMode",
  21683. "GPUOutOfMemoryError",
  21684. "GPUPipelineError",
  21685. "GPUPipelineLayout",
  21686. "GPUQuerySet",
  21687. "GPUQueue",
  21688. "GPURenderBundle",
  21689. "GPURenderBundleEncoder",
  21690. "GPURenderPassEncoder",
  21691. "GPURenderPipeline",
  21692. "GPUSampler",
  21693. "GPUShaderModule",
  21694. "GPUShaderStage",
  21695. "GPUSupportedFeatures",
  21696. "GPUSupportedLimits",
  21697. "GPUTexture",
  21698. "GPUTextureUsage",
  21699. "GPUTextureView",
  21700. "GPUUncapturedErrorEvent",
  21701. "GPUValidationError",
  21702. "GREATER",
  21703. "GREEN",
  21704. "GREEN_BITS",
  21705. "GainNode",
  21706. "Gamepad",
  21707. "GamepadAxisMoveEvent",
  21708. "GamepadButton",
  21709. "GamepadButtonEvent",
  21710. "GamepadEvent",
  21711. "GamepadHapticActuator",
  21712. "GamepadPose",
  21713. "Geolocation",
  21714. "GeolocationCoordinates",
  21715. "GeolocationPosition",
  21716. "GeolocationPositionError",
  21717. "GestureEvent",
  21718. "Global",
  21719. "GravitySensor",
  21720. "Gyroscope",
  21721. "HALF_FLOAT",
  21722. "HAVE_CURRENT_DATA",
  21723. "HAVE_ENOUGH_DATA",
  21724. "HAVE_FUTURE_DATA",
  21725. "HAVE_METADATA",
  21726. "HAVE_NOTHING",
  21727. "HEADERS_RECEIVED",
  21728. "HID",
  21729. "HIDConnectionEvent",
  21730. "HIDDEN",
  21731. "HIDDevice",
  21732. "HIDInputReportEvent",
  21733. "HIERARCHY_REQUEST_ERR",
  21734. "HIGHPASS",
  21735. "HIGHSHELF",
  21736. "HIGH_FLOAT",
  21737. "HIGH_INT",
  21738. "HORIZONTAL",
  21739. "HORIZONTAL_AXIS",
  21740. "HRTF",
  21741. "HTMLAllCollection",
  21742. "HTMLAnchorElement",
  21743. "HTMLAppletElement",
  21744. "HTMLAreaElement",
  21745. "HTMLAudioElement",
  21746. "HTMLBRElement",
  21747. "HTMLBaseElement",
  21748. "HTMLBaseFontElement",
  21749. "HTMLBlockquoteElement",
  21750. "HTMLBodyElement",
  21751. "HTMLButtonElement",
  21752. "HTMLCanvasElement",
  21753. "HTMLCollection",
  21754. "HTMLCommandElement",
  21755. "HTMLContentElement",
  21756. "HTMLDListElement",
  21757. "HTMLDataElement",
  21758. "HTMLDataListElement",
  21759. "HTMLDetailsElement",
  21760. "HTMLDialogElement",
  21761. "HTMLDirectoryElement",
  21762. "HTMLDivElement",
  21763. "HTMLDocument",
  21764. "HTMLElement",
  21765. "HTMLEmbedElement",
  21766. "HTMLFencedFrameElement",
  21767. "HTMLFieldSetElement",
  21768. "HTMLFontElement",
  21769. "HTMLFormControlsCollection",
  21770. "HTMLFormElement",
  21771. "HTMLFrameElement",
  21772. "HTMLFrameSetElement",
  21773. "HTMLHRElement",
  21774. "HTMLHeadElement",
  21775. "HTMLHeadingElement",
  21776. "HTMLHtmlElement",
  21777. "HTMLIFrameElement",
  21778. "HTMLImageElement",
  21779. "HTMLInputElement",
  21780. "HTMLIsIndexElement",
  21781. "HTMLKeygenElement",
  21782. "HTMLLIElement",
  21783. "HTMLLabelElement",
  21784. "HTMLLegendElement",
  21785. "HTMLLinkElement",
  21786. "HTMLMapElement",
  21787. "HTMLMarqueeElement",
  21788. "HTMLMediaElement",
  21789. "HTMLMenuElement",
  21790. "HTMLMenuItemElement",
  21791. "HTMLMetaElement",
  21792. "HTMLMeterElement",
  21793. "HTMLModElement",
  21794. "HTMLOListElement",
  21795. "HTMLObjectElement",
  21796. "HTMLOptGroupElement",
  21797. "HTMLOptionElement",
  21798. "HTMLOptionsCollection",
  21799. "HTMLOutputElement",
  21800. "HTMLParagraphElement",
  21801. "HTMLParamElement",
  21802. "HTMLPictureElement",
  21803. "HTMLPreElement",
  21804. "HTMLProgressElement",
  21805. "HTMLPropertiesCollection",
  21806. "HTMLQuoteElement",
  21807. "HTMLScriptElement",
  21808. "HTMLSelectElement",
  21809. "HTMLShadowElement",
  21810. "HTMLSlotElement",
  21811. "HTMLSourceElement",
  21812. "HTMLSpanElement",
  21813. "HTMLStyleElement",
  21814. "HTMLTableCaptionElement",
  21815. "HTMLTableCellElement",
  21816. "HTMLTableColElement",
  21817. "HTMLTableElement",
  21818. "HTMLTableRowElement",
  21819. "HTMLTableSectionElement",
  21820. "HTMLTemplateElement",
  21821. "HTMLTextAreaElement",
  21822. "HTMLTimeElement",
  21823. "HTMLTitleElement",
  21824. "HTMLTrackElement",
  21825. "HTMLUListElement",
  21826. "HTMLUnknownElement",
  21827. "HTMLVideoElement",
  21828. "HashChangeEvent",
  21829. "Headers",
  21830. "Highlight",
  21831. "HighlightRegistry",
  21832. "History",
  21833. "Hz",
  21834. "ICE_CHECKING",
  21835. "ICE_CLOSED",
  21836. "ICE_COMPLETED",
  21837. "ICE_CONNECTED",
  21838. "ICE_FAILED",
  21839. "ICE_GATHERING",
  21840. "ICE_WAITING",
  21841. "IDBCursor",
  21842. "IDBCursorWithValue",
  21843. "IDBDatabase",
  21844. "IDBDatabaseException",
  21845. "IDBFactory",
  21846. "IDBFileHandle",
  21847. "IDBFileRequest",
  21848. "IDBIndex",
  21849. "IDBKeyRange",
  21850. "IDBMutableFile",
  21851. "IDBObjectStore",
  21852. "IDBOpenDBRequest",
  21853. "IDBRequest",
  21854. "IDBTransaction",
  21855. "IDBVersionChangeEvent",
  21856. "IDLE",
  21857. "IIRFilterNode",
  21858. "IMPLEMENTATION_COLOR_READ_FORMAT",
  21859. "IMPLEMENTATION_COLOR_READ_TYPE",
  21860. "IMPORT_RULE",
  21861. "INCR",
  21862. "INCR_WRAP",
  21863. "INDEX",
  21864. "INDEX_SIZE_ERR",
  21865. "INDIRECT",
  21866. "INT",
  21867. "INTERLEAVED_ATTRIBS",
  21868. "INT_2_10_10_10_REV",
  21869. "INT_SAMPLER_2D",
  21870. "INT_SAMPLER_2D_ARRAY",
  21871. "INT_SAMPLER_3D",
  21872. "INT_SAMPLER_CUBE",
  21873. "INT_VEC2",
  21874. "INT_VEC3",
  21875. "INT_VEC4",
  21876. "INUSE_ATTRIBUTE_ERR",
  21877. "INVALID_ACCESS_ERR",
  21878. "INVALID_CHARACTER_ERR",
  21879. "INVALID_ENUM",
  21880. "INVALID_EXPRESSION_ERR",
  21881. "INVALID_FRAMEBUFFER_OPERATION",
  21882. "INVALID_INDEX",
  21883. "INVALID_MODIFICATION_ERR",
  21884. "INVALID_NODE_TYPE_ERR",
  21885. "INVALID_OPERATION",
  21886. "INVALID_STATE_ERR",
  21887. "INVALID_VALUE",
  21888. "INVERSE_DISTANCE",
  21889. "INVERT",
  21890. "IceCandidate",
  21891. "IdentityCredential",
  21892. "IdentityCredentialError",
  21893. "IdentityProvider",
  21894. "IdleDeadline",
  21895. "IdleDetector",
  21896. "Image",
  21897. "ImageBitmap",
  21898. "ImageBitmapRenderingContext",
  21899. "ImageCapture",
  21900. "ImageData",
  21901. "ImageDecoder",
  21902. "ImageTrack",
  21903. "ImageTrackList",
  21904. "Infinity",
  21905. "Ink",
  21906. "InputDeviceCapabilities",
  21907. "InputDeviceInfo",
  21908. "InputEvent",
  21909. "InputMethodContext",
  21910. "InstallTrigger",
  21911. "InstallTriggerImpl",
  21912. "Instance",
  21913. "Int16Array",
  21914. "Int32Array",
  21915. "Int8Array",
  21916. "Intent",
  21917. "InternalError",
  21918. "IntersectionObserver",
  21919. "IntersectionObserverEntry",
  21920. "Intl",
  21921. "IsSearchProviderInstalled",
  21922. "Iterator",
  21923. "JSON",
  21924. "JSTag",
  21925. "KEEP",
  21926. "KEYDOWN",
  21927. "KEYFRAMES_RULE",
  21928. "KEYFRAME_RULE",
  21929. "KEYPRESS",
  21930. "KEYUP",
  21931. "KeyEvent",
  21932. "Keyboard",
  21933. "KeyboardEvent",
  21934. "KeyboardLayoutMap",
  21935. "KeyframeEffect",
  21936. "LENGTHADJUST_SPACING",
  21937. "LENGTHADJUST_SPACINGANDGLYPHS",
  21938. "LENGTHADJUST_UNKNOWN",
  21939. "LEQUAL",
  21940. "LESS",
  21941. "LINEAR",
  21942. "LINEAR_DISTANCE",
  21943. "LINEAR_MIPMAP_LINEAR",
  21944. "LINEAR_MIPMAP_NEAREST",
  21945. "LINES",
  21946. "LINE_LOOP",
  21947. "LINE_STRIP",
  21948. "LINE_WIDTH",
  21949. "LINK_STATUS",
  21950. "LIVE",
  21951. "LN10",
  21952. "LN2",
  21953. "LOADED",
  21954. "LOADING",
  21955. "LOG10E",
  21956. "LOG2E",
  21957. "LOWPASS",
  21958. "LOWSHELF",
  21959. "LOW_FLOAT",
  21960. "LOW_INT",
  21961. "LSException",
  21962. "LSParserFilter",
  21963. "LUMINANCE",
  21964. "LUMINANCE_ALPHA",
  21965. "LargestContentfulPaint",
  21966. "LaunchParams",
  21967. "LaunchQueue",
  21968. "LayoutShift",
  21969. "LayoutShiftAttribution",
  21970. "LinearAccelerationSensor",
  21971. "LinkError",
  21972. "ListFormat",
  21973. "LocalMediaStream",
  21974. "Locale",
  21975. "Location",
  21976. "Lock",
  21977. "LockManager",
  21978. "MAP_READ",
  21979. "MAP_WRITE",
  21980. "MAX",
  21981. "MAX_3D_TEXTURE_SIZE",
  21982. "MAX_ARRAY_TEXTURE_LAYERS",
  21983. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  21984. "MAX_COLOR_ATTACHMENTS",
  21985. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  21986. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  21987. "MAX_COMBINED_UNIFORM_BLOCKS",
  21988. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  21989. "MAX_CUBE_MAP_TEXTURE_SIZE",
  21990. "MAX_DRAW_BUFFERS",
  21991. "MAX_ELEMENTS_INDICES",
  21992. "MAX_ELEMENTS_VERTICES",
  21993. "MAX_ELEMENT_INDEX",
  21994. "MAX_FRAGMENT_INPUT_COMPONENTS",
  21995. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  21996. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  21997. "MAX_FRAGMENT_UNIFORM_VECTORS",
  21998. "MAX_PROGRAM_TEXEL_OFFSET",
  21999. "MAX_RENDERBUFFER_SIZE",
  22000. "MAX_SAFE_INTEGER",
  22001. "MAX_SAMPLES",
  22002. "MAX_SERVER_WAIT_TIMEOUT",
  22003. "MAX_TEXTURE_IMAGE_UNITS",
  22004. "MAX_TEXTURE_LOD_BIAS",
  22005. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  22006. "MAX_TEXTURE_SIZE",
  22007. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  22008. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  22009. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  22010. "MAX_UNIFORM_BLOCK_SIZE",
  22011. "MAX_UNIFORM_BUFFER_BINDINGS",
  22012. "MAX_VALUE",
  22013. "MAX_VARYING_COMPONENTS",
  22014. "MAX_VARYING_VECTORS",
  22015. "MAX_VERTEX_ATTRIBS",
  22016. "MAX_VERTEX_OUTPUT_COMPONENTS",
  22017. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  22018. "MAX_VERTEX_UNIFORM_BLOCKS",
  22019. "MAX_VERTEX_UNIFORM_COMPONENTS",
  22020. "MAX_VERTEX_UNIFORM_VECTORS",
  22021. "MAX_VIEWPORT_DIMS",
  22022. "MEDIA_ERR_ABORTED",
  22023. "MEDIA_ERR_DECODE",
  22024. "MEDIA_ERR_ENCRYPTED",
  22025. "MEDIA_ERR_NETWORK",
  22026. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  22027. "MEDIA_KEYERR_CLIENT",
  22028. "MEDIA_KEYERR_DOMAIN",
  22029. "MEDIA_KEYERR_HARDWARECHANGE",
  22030. "MEDIA_KEYERR_OUTPUT",
  22031. "MEDIA_KEYERR_SERVICE",
  22032. "MEDIA_KEYERR_UNKNOWN",
  22033. "MEDIA_RULE",
  22034. "MEDIUM_FLOAT",
  22035. "MEDIUM_INT",
  22036. "META_MASK",
  22037. "MIDIAccess",
  22038. "MIDIConnectionEvent",
  22039. "MIDIInput",
  22040. "MIDIInputMap",
  22041. "MIDIMessageEvent",
  22042. "MIDIOutput",
  22043. "MIDIOutputMap",
  22044. "MIDIPort",
  22045. "MIN",
  22046. "MIN_PROGRAM_TEXEL_OFFSET",
  22047. "MIN_SAFE_INTEGER",
  22048. "MIN_VALUE",
  22049. "MIRRORED_REPEAT",
  22050. "MODE_ASYNCHRONOUS",
  22051. "MODE_SYNCHRONOUS",
  22052. "MODIFICATION",
  22053. "MOUSEDOWN",
  22054. "MOUSEDRAG",
  22055. "MOUSEMOVE",
  22056. "MOUSEOUT",
  22057. "MOUSEOVER",
  22058. "MOUSEUP",
  22059. "MOZ_KEYFRAMES_RULE",
  22060. "MOZ_KEYFRAME_RULE",
  22061. "MOZ_SOURCE_CURSOR",
  22062. "MOZ_SOURCE_ERASER",
  22063. "MOZ_SOURCE_KEYBOARD",
  22064. "MOZ_SOURCE_MOUSE",
  22065. "MOZ_SOURCE_PEN",
  22066. "MOZ_SOURCE_TOUCH",
  22067. "MOZ_SOURCE_UNKNOWN",
  22068. "MSGESTURE_FLAG_BEGIN",
  22069. "MSGESTURE_FLAG_CANCEL",
  22070. "MSGESTURE_FLAG_END",
  22071. "MSGESTURE_FLAG_INERTIA",
  22072. "MSGESTURE_FLAG_NONE",
  22073. "MSPOINTER_TYPE_MOUSE",
  22074. "MSPOINTER_TYPE_PEN",
  22075. "MSPOINTER_TYPE_TOUCH",
  22076. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  22077. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  22078. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  22079. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  22080. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  22081. "MS_ASYNC_OP_STATUS_CANCELED",
  22082. "MS_ASYNC_OP_STATUS_ERROR",
  22083. "MS_ASYNC_OP_STATUS_SUCCESS",
  22084. "MS_MANIPULATION_STATE_ACTIVE",
  22085. "MS_MANIPULATION_STATE_CANCELLED",
  22086. "MS_MANIPULATION_STATE_COMMITTED",
  22087. "MS_MANIPULATION_STATE_DRAGGING",
  22088. "MS_MANIPULATION_STATE_INERTIA",
  22089. "MS_MANIPULATION_STATE_PRESELECT",
  22090. "MS_MANIPULATION_STATE_SELECTING",
  22091. "MS_MANIPULATION_STATE_STOPPED",
  22092. "MS_MEDIA_ERR_ENCRYPTED",
  22093. "MS_MEDIA_KEYERR_CLIENT",
  22094. "MS_MEDIA_KEYERR_DOMAIN",
  22095. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  22096. "MS_MEDIA_KEYERR_OUTPUT",
  22097. "MS_MEDIA_KEYERR_SERVICE",
  22098. "MS_MEDIA_KEYERR_UNKNOWN",
  22099. "Map",
  22100. "Math",
  22101. "MathMLElement",
  22102. "MediaCapabilities",
  22103. "MediaCapabilitiesInfo",
  22104. "MediaController",
  22105. "MediaDeviceInfo",
  22106. "MediaDevices",
  22107. "MediaElementAudioSourceNode",
  22108. "MediaEncryptedEvent",
  22109. "MediaError",
  22110. "MediaKeyError",
  22111. "MediaKeyEvent",
  22112. "MediaKeyMessageEvent",
  22113. "MediaKeyNeededEvent",
  22114. "MediaKeySession",
  22115. "MediaKeyStatusMap",
  22116. "MediaKeySystemAccess",
  22117. "MediaKeys",
  22118. "MediaList",
  22119. "MediaMetadata",
  22120. "MediaQueryList",
  22121. "MediaQueryListEvent",
  22122. "MediaRecorder",
  22123. "MediaRecorderErrorEvent",
  22124. "MediaSession",
  22125. "MediaSettingsRange",
  22126. "MediaSource",
  22127. "MediaSourceHandle",
  22128. "MediaStream",
  22129. "MediaStreamAudioDestinationNode",
  22130. "MediaStreamAudioSourceNode",
  22131. "MediaStreamEvent",
  22132. "MediaStreamTrack",
  22133. "MediaStreamTrackAudioSourceNode",
  22134. "MediaStreamTrackEvent",
  22135. "MediaStreamTrackGenerator",
  22136. "MediaStreamTrackProcessor",
  22137. "MediaStreamTrackVideoStats",
  22138. "Memory",
  22139. "MessageChannel",
  22140. "MessageEvent",
  22141. "MessagePort",
  22142. "Methods",
  22143. "MimeType",
  22144. "MimeTypeArray",
  22145. "Module",
  22146. "MouseEvent",
  22147. "MouseScrollEvent",
  22148. "MozAnimation",
  22149. "MozAnimationDelay",
  22150. "MozAnimationDirection",
  22151. "MozAnimationDuration",
  22152. "MozAnimationFillMode",
  22153. "MozAnimationIterationCount",
  22154. "MozAnimationName",
  22155. "MozAnimationPlayState",
  22156. "MozAnimationTimingFunction",
  22157. "MozAppearance",
  22158. "MozBackfaceVisibility",
  22159. "MozBinding",
  22160. "MozBorderBottomColors",
  22161. "MozBorderEnd",
  22162. "MozBorderEndColor",
  22163. "MozBorderEndStyle",
  22164. "MozBorderEndWidth",
  22165. "MozBorderImage",
  22166. "MozBorderLeftColors",
  22167. "MozBorderRightColors",
  22168. "MozBorderStart",
  22169. "MozBorderStartColor",
  22170. "MozBorderStartStyle",
  22171. "MozBorderStartWidth",
  22172. "MozBorderTopColors",
  22173. "MozBoxAlign",
  22174. "MozBoxDirection",
  22175. "MozBoxFlex",
  22176. "MozBoxOrdinalGroup",
  22177. "MozBoxOrient",
  22178. "MozBoxPack",
  22179. "MozBoxSizing",
  22180. "MozCSSKeyframeRule",
  22181. "MozCSSKeyframesRule",
  22182. "MozColumnCount",
  22183. "MozColumnFill",
  22184. "MozColumnGap",
  22185. "MozColumnRule",
  22186. "MozColumnRuleColor",
  22187. "MozColumnRuleStyle",
  22188. "MozColumnRuleWidth",
  22189. "MozColumnWidth",
  22190. "MozColumns",
  22191. "MozContactChangeEvent",
  22192. "MozFloatEdge",
  22193. "MozFontFeatureSettings",
  22194. "MozFontLanguageOverride",
  22195. "MozForceBrokenImageIcon",
  22196. "MozHyphens",
  22197. "MozImageRegion",
  22198. "MozMarginEnd",
  22199. "MozMarginStart",
  22200. "MozMmsEvent",
  22201. "MozMmsMessage",
  22202. "MozMobileMessageThread",
  22203. "MozOSXFontSmoothing",
  22204. "MozOrient",
  22205. "MozOsxFontSmoothing",
  22206. "MozOutlineRadius",
  22207. "MozOutlineRadiusBottomleft",
  22208. "MozOutlineRadiusBottomright",
  22209. "MozOutlineRadiusTopleft",
  22210. "MozOutlineRadiusTopright",
  22211. "MozPaddingEnd",
  22212. "MozPaddingStart",
  22213. "MozPerspective",
  22214. "MozPerspectiveOrigin",
  22215. "MozPowerManager",
  22216. "MozSettingsEvent",
  22217. "MozSmsEvent",
  22218. "MozSmsMessage",
  22219. "MozStackSizing",
  22220. "MozTabSize",
  22221. "MozTextAlignLast",
  22222. "MozTextDecorationColor",
  22223. "MozTextDecorationLine",
  22224. "MozTextDecorationStyle",
  22225. "MozTextSizeAdjust",
  22226. "MozTransform",
  22227. "MozTransformOrigin",
  22228. "MozTransformStyle",
  22229. "MozTransition",
  22230. "MozTransitionDelay",
  22231. "MozTransitionDuration",
  22232. "MozTransitionProperty",
  22233. "MozTransitionTimingFunction",
  22234. "MozUserFocus",
  22235. "MozUserInput",
  22236. "MozUserModify",
  22237. "MozUserSelect",
  22238. "MozWindowDragging",
  22239. "MozWindowShadow",
  22240. "MutationEvent",
  22241. "MutationObserver",
  22242. "MutationRecord",
  22243. "NAMESPACE_ERR",
  22244. "NAMESPACE_RULE",
  22245. "NEAREST",
  22246. "NEAREST_MIPMAP_LINEAR",
  22247. "NEAREST_MIPMAP_NEAREST",
  22248. "NEGATIVE_INFINITY",
  22249. "NETWORK_EMPTY",
  22250. "NETWORK_ERR",
  22251. "NETWORK_IDLE",
  22252. "NETWORK_LOADED",
  22253. "NETWORK_LOADING",
  22254. "NETWORK_NO_SOURCE",
  22255. "NEVER",
  22256. "NEW",
  22257. "NEXT",
  22258. "NEXT_NO_DUPLICATE",
  22259. "NICEST",
  22260. "NODE_AFTER",
  22261. "NODE_BEFORE",
  22262. "NODE_BEFORE_AND_AFTER",
  22263. "NODE_INSIDE",
  22264. "NONE",
  22265. "NON_TRANSIENT_ERR",
  22266. "NOTATION_NODE",
  22267. "NOTCH",
  22268. "NOTEQUAL",
  22269. "NOT_ALLOWED_ERR",
  22270. "NOT_FOUND_ERR",
  22271. "NOT_READABLE_ERR",
  22272. "NOT_SUPPORTED_ERR",
  22273. "NO_DATA_ALLOWED_ERR",
  22274. "NO_ERR",
  22275. "NO_ERROR",
  22276. "NO_MODIFICATION_ALLOWED_ERR",
  22277. "NUMBER_TYPE",
  22278. "NUM_COMPRESSED_TEXTURE_FORMATS",
  22279. "NaN",
  22280. "NamedNodeMap",
  22281. "NavigateEvent",
  22282. "Navigation",
  22283. "NavigationActivation",
  22284. "NavigationCurrentEntryChangeEvent",
  22285. "NavigationDestination",
  22286. "NavigationHistoryEntry",
  22287. "NavigationPreloadManager",
  22288. "NavigationTransition",
  22289. "Navigator",
  22290. "NavigatorLogin",
  22291. "NavigatorManagedData",
  22292. "NavigatorUAData",
  22293. "NearbyLinks",
  22294. "NetworkInformation",
  22295. "Node",
  22296. "NodeFilter",
  22297. "NodeIterator",
  22298. "NodeList",
  22299. "NotRestoredReasonDetails",
  22300. "NotRestoredReasons",
  22301. "Notation",
  22302. "Notification",
  22303. "NotifyPaintEvent",
  22304. "Number",
  22305. "NumberFormat",
  22306. "OBJECT_TYPE",
  22307. "OBSOLETE",
  22308. "OK",
  22309. "ONE",
  22310. "ONE_MINUS_CONSTANT_ALPHA",
  22311. "ONE_MINUS_CONSTANT_COLOR",
  22312. "ONE_MINUS_DST_ALPHA",
  22313. "ONE_MINUS_DST_COLOR",
  22314. "ONE_MINUS_SRC_ALPHA",
  22315. "ONE_MINUS_SRC_COLOR",
  22316. "OPEN",
  22317. "OPENED",
  22318. "OPENING",
  22319. "ORDERED_NODE_ITERATOR_TYPE",
  22320. "ORDERED_NODE_SNAPSHOT_TYPE",
  22321. "OTHER_ERROR",
  22322. "OTPCredential",
  22323. "OUT_OF_MEMORY",
  22324. "Object",
  22325. "OfflineAudioCompletionEvent",
  22326. "OfflineAudioContext",
  22327. "OfflineResourceList",
  22328. "OffscreenCanvas",
  22329. "OffscreenCanvasRenderingContext2D",
  22330. "Option",
  22331. "OrientationSensor",
  22332. "OscillatorNode",
  22333. "OverconstrainedError",
  22334. "OverflowEvent",
  22335. "PACK_ALIGNMENT",
  22336. "PACK_ROW_LENGTH",
  22337. "PACK_SKIP_PIXELS",
  22338. "PACK_SKIP_ROWS",
  22339. "PAGE_RULE",
  22340. "PARSE_ERR",
  22341. "PATHSEG_ARC_ABS",
  22342. "PATHSEG_ARC_REL",
  22343. "PATHSEG_CLOSEPATH",
  22344. "PATHSEG_CURVETO_CUBIC_ABS",
  22345. "PATHSEG_CURVETO_CUBIC_REL",
  22346. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  22347. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  22348. "PATHSEG_CURVETO_QUADRATIC_ABS",
  22349. "PATHSEG_CURVETO_QUADRATIC_REL",
  22350. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  22351. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  22352. "PATHSEG_LINETO_ABS",
  22353. "PATHSEG_LINETO_HORIZONTAL_ABS",
  22354. "PATHSEG_LINETO_HORIZONTAL_REL",
  22355. "PATHSEG_LINETO_REL",
  22356. "PATHSEG_LINETO_VERTICAL_ABS",
  22357. "PATHSEG_LINETO_VERTICAL_REL",
  22358. "PATHSEG_MOVETO_ABS",
  22359. "PATHSEG_MOVETO_REL",
  22360. "PATHSEG_UNKNOWN",
  22361. "PATH_EXISTS_ERR",
  22362. "PEAKING",
  22363. "PERMISSION_DENIED",
  22364. "PERSISTENT",
  22365. "PI",
  22366. "PIXEL_PACK_BUFFER",
  22367. "PIXEL_PACK_BUFFER_BINDING",
  22368. "PIXEL_UNPACK_BUFFER",
  22369. "PIXEL_UNPACK_BUFFER_BINDING",
  22370. "PLAYING_STATE",
  22371. "POINTS",
  22372. "POLYGON_OFFSET_FACTOR",
  22373. "POLYGON_OFFSET_FILL",
  22374. "POLYGON_OFFSET_UNITS",
  22375. "POSITION_UNAVAILABLE",
  22376. "POSITIVE_INFINITY",
  22377. "PREV",
  22378. "PREV_NO_DUPLICATE",
  22379. "PROCESSING_INSTRUCTION_NODE",
  22380. "PageChangeEvent",
  22381. "PageRevealEvent",
  22382. "PageSwapEvent",
  22383. "PageTransitionEvent",
  22384. "PaintRequest",
  22385. "PaintRequestList",
  22386. "PannerNode",
  22387. "PasswordCredential",
  22388. "Path2D",
  22389. "PaymentAddress",
  22390. "PaymentInstruments",
  22391. "PaymentManager",
  22392. "PaymentMethodChangeEvent",
  22393. "PaymentRequest",
  22394. "PaymentRequestUpdateEvent",
  22395. "PaymentResponse",
  22396. "Performance",
  22397. "PerformanceElementTiming",
  22398. "PerformanceEntry",
  22399. "PerformanceEventTiming",
  22400. "PerformanceLongAnimationFrameTiming",
  22401. "PerformanceLongTaskTiming",
  22402. "PerformanceMark",
  22403. "PerformanceMeasure",
  22404. "PerformanceNavigation",
  22405. "PerformanceNavigationTiming",
  22406. "PerformanceObserver",
  22407. "PerformanceObserverEntryList",
  22408. "PerformancePaintTiming",
  22409. "PerformanceResourceTiming",
  22410. "PerformanceScriptTiming",
  22411. "PerformanceServerTiming",
  22412. "PerformanceTiming",
  22413. "PeriodicSyncManager",
  22414. "PeriodicWave",
  22415. "PermissionStatus",
  22416. "Permissions",
  22417. "PhotoCapabilities",
  22418. "PictureInPictureEvent",
  22419. "PictureInPictureWindow",
  22420. "Plugin",
  22421. "PluginArray",
  22422. "PluralRules",
  22423. "PointerEvent",
  22424. "PopStateEvent",
  22425. "PopupBlockedEvent",
  22426. "Presentation",
  22427. "PresentationAvailability",
  22428. "PresentationConnection",
  22429. "PresentationConnectionAvailableEvent",
  22430. "PresentationConnectionCloseEvent",
  22431. "PresentationConnectionList",
  22432. "PresentationReceiver",
  22433. "PresentationRequest",
  22434. "ProcessingInstruction",
  22435. "Profiler",
  22436. "ProgressEvent",
  22437. "Promise",
  22438. "PromiseRejectionEvent",
  22439. "PropertyNodeList",
  22440. "Proxy",
  22441. "PublicKeyCredential",
  22442. "PushManager",
  22443. "PushSubscription",
  22444. "PushSubscriptionOptions",
  22445. "Q",
  22446. "QUERY_RESOLVE",
  22447. "QUERY_RESULT",
  22448. "QUERY_RESULT_AVAILABLE",
  22449. "QUOTA_ERR",
  22450. "QUOTA_EXCEEDED_ERR",
  22451. "QueryInterface",
  22452. "R11F_G11F_B10F",
  22453. "R16F",
  22454. "R16I",
  22455. "R16UI",
  22456. "R32F",
  22457. "R32I",
  22458. "R32UI",
  22459. "R8",
  22460. "R8I",
  22461. "R8UI",
  22462. "R8_SNORM",
  22463. "RASTERIZER_DISCARD",
  22464. "READ",
  22465. "READ_BUFFER",
  22466. "READ_FRAMEBUFFER",
  22467. "READ_FRAMEBUFFER_BINDING",
  22468. "READ_ONLY",
  22469. "READ_ONLY_ERR",
  22470. "READ_WRITE",
  22471. "RED",
  22472. "RED_BITS",
  22473. "RED_INTEGER",
  22474. "REMOVAL",
  22475. "RENDERBUFFER",
  22476. "RENDERBUFFER_ALPHA_SIZE",
  22477. "RENDERBUFFER_BINDING",
  22478. "RENDERBUFFER_BLUE_SIZE",
  22479. "RENDERBUFFER_DEPTH_SIZE",
  22480. "RENDERBUFFER_GREEN_SIZE",
  22481. "RENDERBUFFER_HEIGHT",
  22482. "RENDERBUFFER_INTERNAL_FORMAT",
  22483. "RENDERBUFFER_RED_SIZE",
  22484. "RENDERBUFFER_SAMPLES",
  22485. "RENDERBUFFER_STENCIL_SIZE",
  22486. "RENDERBUFFER_WIDTH",
  22487. "RENDERER",
  22488. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  22489. "RENDERING_INTENT_AUTO",
  22490. "RENDERING_INTENT_PERCEPTUAL",
  22491. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  22492. "RENDERING_INTENT_SATURATION",
  22493. "RENDERING_INTENT_UNKNOWN",
  22494. "RENDER_ATTACHMENT",
  22495. "REPEAT",
  22496. "REPLACE",
  22497. "RG",
  22498. "RG16F",
  22499. "RG16I",
  22500. "RG16UI",
  22501. "RG32F",
  22502. "RG32I",
  22503. "RG32UI",
  22504. "RG8",
  22505. "RG8I",
  22506. "RG8UI",
  22507. "RG8_SNORM",
  22508. "RGB",
  22509. "RGB10_A2",
  22510. "RGB10_A2UI",
  22511. "RGB16F",
  22512. "RGB16I",
  22513. "RGB16UI",
  22514. "RGB32F",
  22515. "RGB32I",
  22516. "RGB32UI",
  22517. "RGB565",
  22518. "RGB5_A1",
  22519. "RGB8",
  22520. "RGB8I",
  22521. "RGB8UI",
  22522. "RGB8_SNORM",
  22523. "RGB9_E5",
  22524. "RGBA",
  22525. "RGBA16F",
  22526. "RGBA16I",
  22527. "RGBA16UI",
  22528. "RGBA32F",
  22529. "RGBA32I",
  22530. "RGBA32UI",
  22531. "RGBA4",
  22532. "RGBA8",
  22533. "RGBA8I",
  22534. "RGBA8UI",
  22535. "RGBA8_SNORM",
  22536. "RGBA_INTEGER",
  22537. "RGBColor",
  22538. "RGB_INTEGER",
  22539. "RG_INTEGER",
  22540. "ROTATION_CLOCKWISE",
  22541. "ROTATION_COUNTERCLOCKWISE",
  22542. "RTCCertificate",
  22543. "RTCDTMFSender",
  22544. "RTCDTMFToneChangeEvent",
  22545. "RTCDataChannel",
  22546. "RTCDataChannelEvent",
  22547. "RTCDtlsTransport",
  22548. "RTCEncodedAudioFrame",
  22549. "RTCEncodedVideoFrame",
  22550. "RTCError",
  22551. "RTCErrorEvent",
  22552. "RTCIceCandidate",
  22553. "RTCIceTransport",
  22554. "RTCPeerConnection",
  22555. "RTCPeerConnectionIceErrorEvent",
  22556. "RTCPeerConnectionIceEvent",
  22557. "RTCRtpReceiver",
  22558. "RTCRtpScriptTransform",
  22559. "RTCRtpSender",
  22560. "RTCRtpTransceiver",
  22561. "RTCSctpTransport",
  22562. "RTCSessionDescription",
  22563. "RTCStatsReport",
  22564. "RTCTrackEvent",
  22565. "RadioNodeList",
  22566. "Range",
  22567. "RangeError",
  22568. "RangeException",
  22569. "ReadableByteStreamController",
  22570. "ReadableStream",
  22571. "ReadableStreamBYOBReader",
  22572. "ReadableStreamBYOBRequest",
  22573. "ReadableStreamDefaultController",
  22574. "ReadableStreamDefaultReader",
  22575. "RecordErrorEvent",
  22576. "Rect",
  22577. "ReferenceError",
  22578. "Reflect",
  22579. "RegExp",
  22580. "RelativeOrientationSensor",
  22581. "RelativeTimeFormat",
  22582. "RemotePlayback",
  22583. "Report",
  22584. "ReportBody",
  22585. "ReportingObserver",
  22586. "Request",
  22587. "ResizeObserver",
  22588. "ResizeObserverEntry",
  22589. "ResizeObserverSize",
  22590. "Response",
  22591. "RuntimeError",
  22592. "SAMPLER_2D",
  22593. "SAMPLER_2D_ARRAY",
  22594. "SAMPLER_2D_ARRAY_SHADOW",
  22595. "SAMPLER_2D_SHADOW",
  22596. "SAMPLER_3D",
  22597. "SAMPLER_BINDING",
  22598. "SAMPLER_CUBE",
  22599. "SAMPLER_CUBE_SHADOW",
  22600. "SAMPLES",
  22601. "SAMPLE_ALPHA_TO_COVERAGE",
  22602. "SAMPLE_BUFFERS",
  22603. "SAMPLE_COVERAGE",
  22604. "SAMPLE_COVERAGE_INVERT",
  22605. "SAMPLE_COVERAGE_VALUE",
  22606. "SAWTOOTH",
  22607. "SCHEDULED_STATE",
  22608. "SCISSOR_BOX",
  22609. "SCISSOR_TEST",
  22610. "SCROLL_PAGE_DOWN",
  22611. "SCROLL_PAGE_UP",
  22612. "SDP_ANSWER",
  22613. "SDP_OFFER",
  22614. "SDP_PRANSWER",
  22615. "SECURITY_ERR",
  22616. "SELECT",
  22617. "SEPARATE_ATTRIBS",
  22618. "SERIALIZE_ERR",
  22619. "SEVERITY_ERROR",
  22620. "SEVERITY_FATAL_ERROR",
  22621. "SEVERITY_WARNING",
  22622. "SHADER_COMPILER",
  22623. "SHADER_TYPE",
  22624. "SHADING_LANGUAGE_VERSION",
  22625. "SHIFT_MASK",
  22626. "SHORT",
  22627. "SHOWING",
  22628. "SHOW_ALL",
  22629. "SHOW_ATTRIBUTE",
  22630. "SHOW_CDATA_SECTION",
  22631. "SHOW_COMMENT",
  22632. "SHOW_DOCUMENT",
  22633. "SHOW_DOCUMENT_FRAGMENT",
  22634. "SHOW_DOCUMENT_TYPE",
  22635. "SHOW_ELEMENT",
  22636. "SHOW_ENTITY",
  22637. "SHOW_ENTITY_REFERENCE",
  22638. "SHOW_NOTATION",
  22639. "SHOW_PROCESSING_INSTRUCTION",
  22640. "SHOW_TEXT",
  22641. "SIGNALED",
  22642. "SIGNED_NORMALIZED",
  22643. "SINE",
  22644. "SOUNDFIELD",
  22645. "SQLException",
  22646. "SQRT1_2",
  22647. "SQRT2",
  22648. "SQUARE",
  22649. "SRC_ALPHA",
  22650. "SRC_ALPHA_SATURATE",
  22651. "SRC_COLOR",
  22652. "SRGB",
  22653. "SRGB8",
  22654. "SRGB8_ALPHA8",
  22655. "START_TO_END",
  22656. "START_TO_START",
  22657. "STATIC_COPY",
  22658. "STATIC_DRAW",
  22659. "STATIC_READ",
  22660. "STENCIL",
  22661. "STENCIL_ATTACHMENT",
  22662. "STENCIL_BACK_FAIL",
  22663. "STENCIL_BACK_FUNC",
  22664. "STENCIL_BACK_PASS_DEPTH_FAIL",
  22665. "STENCIL_BACK_PASS_DEPTH_PASS",
  22666. "STENCIL_BACK_REF",
  22667. "STENCIL_BACK_VALUE_MASK",
  22668. "STENCIL_BACK_WRITEMASK",
  22669. "STENCIL_BITS",
  22670. "STENCIL_BUFFER_BIT",
  22671. "STENCIL_CLEAR_VALUE",
  22672. "STENCIL_FAIL",
  22673. "STENCIL_FUNC",
  22674. "STENCIL_INDEX",
  22675. "STENCIL_INDEX8",
  22676. "STENCIL_PASS_DEPTH_FAIL",
  22677. "STENCIL_PASS_DEPTH_PASS",
  22678. "STENCIL_REF",
  22679. "STENCIL_TEST",
  22680. "STENCIL_VALUE_MASK",
  22681. "STENCIL_WRITEMASK",
  22682. "STORAGE",
  22683. "STORAGE_BINDING",
  22684. "STREAM_COPY",
  22685. "STREAM_DRAW",
  22686. "STREAM_READ",
  22687. "STRING_TYPE",
  22688. "STYLE_RULE",
  22689. "SUBPIXEL_BITS",
  22690. "SUPPORTS_RULE",
  22691. "SVGAElement",
  22692. "SVGAltGlyphDefElement",
  22693. "SVGAltGlyphElement",
  22694. "SVGAltGlyphItemElement",
  22695. "SVGAngle",
  22696. "SVGAnimateColorElement",
  22697. "SVGAnimateElement",
  22698. "SVGAnimateMotionElement",
  22699. "SVGAnimateTransformElement",
  22700. "SVGAnimatedAngle",
  22701. "SVGAnimatedBoolean",
  22702. "SVGAnimatedEnumeration",
  22703. "SVGAnimatedInteger",
  22704. "SVGAnimatedLength",
  22705. "SVGAnimatedLengthList",
  22706. "SVGAnimatedNumber",
  22707. "SVGAnimatedNumberList",
  22708. "SVGAnimatedPreserveAspectRatio",
  22709. "SVGAnimatedRect",
  22710. "SVGAnimatedString",
  22711. "SVGAnimatedTransformList",
  22712. "SVGAnimationElement",
  22713. "SVGCircleElement",
  22714. "SVGClipPathElement",
  22715. "SVGColor",
  22716. "SVGComponentTransferFunctionElement",
  22717. "SVGCursorElement",
  22718. "SVGDefsElement",
  22719. "SVGDescElement",
  22720. "SVGDiscardElement",
  22721. "SVGDocument",
  22722. "SVGElement",
  22723. "SVGElementInstance",
  22724. "SVGElementInstanceList",
  22725. "SVGEllipseElement",
  22726. "SVGException",
  22727. "SVGFEBlendElement",
  22728. "SVGFEColorMatrixElement",
  22729. "SVGFEComponentTransferElement",
  22730. "SVGFECompositeElement",
  22731. "SVGFEConvolveMatrixElement",
  22732. "SVGFEDiffuseLightingElement",
  22733. "SVGFEDisplacementMapElement",
  22734. "SVGFEDistantLightElement",
  22735. "SVGFEDropShadowElement",
  22736. "SVGFEFloodElement",
  22737. "SVGFEFuncAElement",
  22738. "SVGFEFuncBElement",
  22739. "SVGFEFuncGElement",
  22740. "SVGFEFuncRElement",
  22741. "SVGFEGaussianBlurElement",
  22742. "SVGFEImageElement",
  22743. "SVGFEMergeElement",
  22744. "SVGFEMergeNodeElement",
  22745. "SVGFEMorphologyElement",
  22746. "SVGFEOffsetElement",
  22747. "SVGFEPointLightElement",
  22748. "SVGFESpecularLightingElement",
  22749. "SVGFESpotLightElement",
  22750. "SVGFETileElement",
  22751. "SVGFETurbulenceElement",
  22752. "SVGFilterElement",
  22753. "SVGFontElement",
  22754. "SVGFontFaceElement",
  22755. "SVGFontFaceFormatElement",
  22756. "SVGFontFaceNameElement",
  22757. "SVGFontFaceSrcElement",
  22758. "SVGFontFaceUriElement",
  22759. "SVGForeignObjectElement",
  22760. "SVGGElement",
  22761. "SVGGeometryElement",
  22762. "SVGGlyphElement",
  22763. "SVGGlyphRefElement",
  22764. "SVGGradientElement",
  22765. "SVGGraphicsElement",
  22766. "SVGHKernElement",
  22767. "SVGImageElement",
  22768. "SVGLength",
  22769. "SVGLengthList",
  22770. "SVGLineElement",
  22771. "SVGLinearGradientElement",
  22772. "SVGMPathElement",
  22773. "SVGMarkerElement",
  22774. "SVGMaskElement",
  22775. "SVGMatrix",
  22776. "SVGMetadataElement",
  22777. "SVGMissingGlyphElement",
  22778. "SVGNumber",
  22779. "SVGNumberList",
  22780. "SVGPaint",
  22781. "SVGPathElement",
  22782. "SVGPathSeg",
  22783. "SVGPathSegArcAbs",
  22784. "SVGPathSegArcRel",
  22785. "SVGPathSegClosePath",
  22786. "SVGPathSegCurvetoCubicAbs",
  22787. "SVGPathSegCurvetoCubicRel",
  22788. "SVGPathSegCurvetoCubicSmoothAbs",
  22789. "SVGPathSegCurvetoCubicSmoothRel",
  22790. "SVGPathSegCurvetoQuadraticAbs",
  22791. "SVGPathSegCurvetoQuadraticRel",
  22792. "SVGPathSegCurvetoQuadraticSmoothAbs",
  22793. "SVGPathSegCurvetoQuadraticSmoothRel",
  22794. "SVGPathSegLinetoAbs",
  22795. "SVGPathSegLinetoHorizontalAbs",
  22796. "SVGPathSegLinetoHorizontalRel",
  22797. "SVGPathSegLinetoRel",
  22798. "SVGPathSegLinetoVerticalAbs",
  22799. "SVGPathSegLinetoVerticalRel",
  22800. "SVGPathSegList",
  22801. "SVGPathSegMovetoAbs",
  22802. "SVGPathSegMovetoRel",
  22803. "SVGPatternElement",
  22804. "SVGPoint",
  22805. "SVGPointList",
  22806. "SVGPolygonElement",
  22807. "SVGPolylineElement",
  22808. "SVGPreserveAspectRatio",
  22809. "SVGRadialGradientElement",
  22810. "SVGRect",
  22811. "SVGRectElement",
  22812. "SVGRenderingIntent",
  22813. "SVGSVGElement",
  22814. "SVGScriptElement",
  22815. "SVGSetElement",
  22816. "SVGStopElement",
  22817. "SVGStringList",
  22818. "SVGStyleElement",
  22819. "SVGSwitchElement",
  22820. "SVGSymbolElement",
  22821. "SVGTRefElement",
  22822. "SVGTSpanElement",
  22823. "SVGTextContentElement",
  22824. "SVGTextElement",
  22825. "SVGTextPathElement",
  22826. "SVGTextPositioningElement",
  22827. "SVGTitleElement",
  22828. "SVGTransform",
  22829. "SVGTransformList",
  22830. "SVGUnitTypes",
  22831. "SVGUseElement",
  22832. "SVGVKernElement",
  22833. "SVGViewElement",
  22834. "SVGViewSpec",
  22835. "SVGZoomAndPan",
  22836. "SVGZoomEvent",
  22837. "SVG_ANGLETYPE_DEG",
  22838. "SVG_ANGLETYPE_GRAD",
  22839. "SVG_ANGLETYPE_RAD",
  22840. "SVG_ANGLETYPE_UNKNOWN",
  22841. "SVG_ANGLETYPE_UNSPECIFIED",
  22842. "SVG_CHANNEL_A",
  22843. "SVG_CHANNEL_B",
  22844. "SVG_CHANNEL_G",
  22845. "SVG_CHANNEL_R",
  22846. "SVG_CHANNEL_UNKNOWN",
  22847. "SVG_COLORTYPE_CURRENTCOLOR",
  22848. "SVG_COLORTYPE_RGBCOLOR",
  22849. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  22850. "SVG_COLORTYPE_UNKNOWN",
  22851. "SVG_EDGEMODE_DUPLICATE",
  22852. "SVG_EDGEMODE_NONE",
  22853. "SVG_EDGEMODE_UNKNOWN",
  22854. "SVG_EDGEMODE_WRAP",
  22855. "SVG_FEBLEND_MODE_COLOR",
  22856. "SVG_FEBLEND_MODE_COLOR_BURN",
  22857. "SVG_FEBLEND_MODE_COLOR_DODGE",
  22858. "SVG_FEBLEND_MODE_DARKEN",
  22859. "SVG_FEBLEND_MODE_DIFFERENCE",
  22860. "SVG_FEBLEND_MODE_EXCLUSION",
  22861. "SVG_FEBLEND_MODE_HARD_LIGHT",
  22862. "SVG_FEBLEND_MODE_HUE",
  22863. "SVG_FEBLEND_MODE_LIGHTEN",
  22864. "SVG_FEBLEND_MODE_LUMINOSITY",
  22865. "SVG_FEBLEND_MODE_MULTIPLY",
  22866. "SVG_FEBLEND_MODE_NORMAL",
  22867. "SVG_FEBLEND_MODE_OVERLAY",
  22868. "SVG_FEBLEND_MODE_SATURATION",
  22869. "SVG_FEBLEND_MODE_SCREEN",
  22870. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  22871. "SVG_FEBLEND_MODE_UNKNOWN",
  22872. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  22873. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  22874. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  22875. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  22876. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  22877. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  22878. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  22879. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  22880. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  22881. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  22882. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  22883. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  22884. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  22885. "SVG_FECOMPOSITE_OPERATOR_IN",
  22886. "SVG_FECOMPOSITE_OPERATOR_LIGHTER",
  22887. "SVG_FECOMPOSITE_OPERATOR_OUT",
  22888. "SVG_FECOMPOSITE_OPERATOR_OVER",
  22889. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  22890. "SVG_FECOMPOSITE_OPERATOR_XOR",
  22891. "SVG_INVALID_VALUE_ERR",
  22892. "SVG_LENGTHTYPE_CM",
  22893. "SVG_LENGTHTYPE_EMS",
  22894. "SVG_LENGTHTYPE_EXS",
  22895. "SVG_LENGTHTYPE_IN",
  22896. "SVG_LENGTHTYPE_MM",
  22897. "SVG_LENGTHTYPE_NUMBER",
  22898. "SVG_LENGTHTYPE_PC",
  22899. "SVG_LENGTHTYPE_PERCENTAGE",
  22900. "SVG_LENGTHTYPE_PT",
  22901. "SVG_LENGTHTYPE_PX",
  22902. "SVG_LENGTHTYPE_UNKNOWN",
  22903. "SVG_MARKERUNITS_STROKEWIDTH",
  22904. "SVG_MARKERUNITS_UNKNOWN",
  22905. "SVG_MARKERUNITS_USERSPACEONUSE",
  22906. "SVG_MARKER_ORIENT_ANGLE",
  22907. "SVG_MARKER_ORIENT_AUTO",
  22908. "SVG_MARKER_ORIENT_AUTO_START_REVERSE",
  22909. "SVG_MARKER_ORIENT_UNKNOWN",
  22910. "SVG_MASKTYPE_ALPHA",
  22911. "SVG_MASKTYPE_LUMINANCE",
  22912. "SVG_MATRIX_NOT_INVERTABLE",
  22913. "SVG_MEETORSLICE_MEET",
  22914. "SVG_MEETORSLICE_SLICE",
  22915. "SVG_MEETORSLICE_UNKNOWN",
  22916. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  22917. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  22918. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  22919. "SVG_PAINTTYPE_CURRENTCOLOR",
  22920. "SVG_PAINTTYPE_NONE",
  22921. "SVG_PAINTTYPE_RGBCOLOR",
  22922. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  22923. "SVG_PAINTTYPE_UNKNOWN",
  22924. "SVG_PAINTTYPE_URI",
  22925. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  22926. "SVG_PAINTTYPE_URI_NONE",
  22927. "SVG_PAINTTYPE_URI_RGBCOLOR",
  22928. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  22929. "SVG_PRESERVEASPECTRATIO_NONE",
  22930. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  22931. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  22932. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  22933. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  22934. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  22935. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  22936. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  22937. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  22938. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  22939. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  22940. "SVG_SPREADMETHOD_PAD",
  22941. "SVG_SPREADMETHOD_REFLECT",
  22942. "SVG_SPREADMETHOD_REPEAT",
  22943. "SVG_SPREADMETHOD_UNKNOWN",
  22944. "SVG_STITCHTYPE_NOSTITCH",
  22945. "SVG_STITCHTYPE_STITCH",
  22946. "SVG_STITCHTYPE_UNKNOWN",
  22947. "SVG_TRANSFORM_MATRIX",
  22948. "SVG_TRANSFORM_ROTATE",
  22949. "SVG_TRANSFORM_SCALE",
  22950. "SVG_TRANSFORM_SKEWX",
  22951. "SVG_TRANSFORM_SKEWY",
  22952. "SVG_TRANSFORM_TRANSLATE",
  22953. "SVG_TRANSFORM_UNKNOWN",
  22954. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  22955. "SVG_TURBULENCE_TYPE_TURBULENCE",
  22956. "SVG_TURBULENCE_TYPE_UNKNOWN",
  22957. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  22958. "SVG_UNIT_TYPE_UNKNOWN",
  22959. "SVG_UNIT_TYPE_USERSPACEONUSE",
  22960. "SVG_WRONG_TYPE_ERR",
  22961. "SVG_ZOOMANDPAN_DISABLE",
  22962. "SVG_ZOOMANDPAN_MAGNIFY",
  22963. "SVG_ZOOMANDPAN_UNKNOWN",
  22964. "SYNC_CONDITION",
  22965. "SYNC_FENCE",
  22966. "SYNC_FLAGS",
  22967. "SYNC_FLUSH_COMMANDS_BIT",
  22968. "SYNC_GPU_COMMANDS_COMPLETE",
  22969. "SYNC_STATUS",
  22970. "SYNTAX_ERR",
  22971. "SavedPages",
  22972. "Scheduler",
  22973. "Scheduling",
  22974. "Screen",
  22975. "ScreenDetailed",
  22976. "ScreenDetails",
  22977. "ScreenOrientation",
  22978. "Script",
  22979. "ScriptProcessorNode",
  22980. "ScrollAreaEvent",
  22981. "ScrollTimeline",
  22982. "SecurityPolicyViolationEvent",
  22983. "Segmenter",
  22984. "Selection",
  22985. "Sensor",
  22986. "SensorErrorEvent",
  22987. "Serial",
  22988. "SerialPort",
  22989. "ServiceWorker",
  22990. "ServiceWorkerContainer",
  22991. "ServiceWorkerRegistration",
  22992. "SessionDescription",
  22993. "Set",
  22994. "ShadowRoot",
  22995. "SharedArrayBuffer",
  22996. "SharedStorage",
  22997. "SharedStorageWorklet",
  22998. "SharedWorker",
  22999. "SimpleGestureEvent",
  23000. "SourceBuffer",
  23001. "SourceBufferList",
  23002. "SpeechSynthesis",
  23003. "SpeechSynthesisErrorEvent",
  23004. "SpeechSynthesisEvent",
  23005. "SpeechSynthesisUtterance",
  23006. "SpeechSynthesisVoice",
  23007. "StaticRange",
  23008. "StereoPannerNode",
  23009. "StopIteration",
  23010. "Storage",
  23011. "StorageBucket",
  23012. "StorageBucketManager",
  23013. "StorageEvent",
  23014. "StorageManager",
  23015. "String",
  23016. "StructType",
  23017. "StylePropertyMap",
  23018. "StylePropertyMapReadOnly",
  23019. "StyleSheet",
  23020. "StyleSheetList",
  23021. "SubmitEvent",
  23022. "SubtleCrypto",
  23023. "Symbol",
  23024. "SyncManager",
  23025. "SyntaxError",
  23026. "TEMPORARY",
  23027. "TEXTPATH_METHODTYPE_ALIGN",
  23028. "TEXTPATH_METHODTYPE_STRETCH",
  23029. "TEXTPATH_METHODTYPE_UNKNOWN",
  23030. "TEXTPATH_SPACINGTYPE_AUTO",
  23031. "TEXTPATH_SPACINGTYPE_EXACT",
  23032. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  23033. "TEXTURE",
  23034. "TEXTURE0",
  23035. "TEXTURE1",
  23036. "TEXTURE10",
  23037. "TEXTURE11",
  23038. "TEXTURE12",
  23039. "TEXTURE13",
  23040. "TEXTURE14",
  23041. "TEXTURE15",
  23042. "TEXTURE16",
  23043. "TEXTURE17",
  23044. "TEXTURE18",
  23045. "TEXTURE19",
  23046. "TEXTURE2",
  23047. "TEXTURE20",
  23048. "TEXTURE21",
  23049. "TEXTURE22",
  23050. "TEXTURE23",
  23051. "TEXTURE24",
  23052. "TEXTURE25",
  23053. "TEXTURE26",
  23054. "TEXTURE27",
  23055. "TEXTURE28",
  23056. "TEXTURE29",
  23057. "TEXTURE3",
  23058. "TEXTURE30",
  23059. "TEXTURE31",
  23060. "TEXTURE4",
  23061. "TEXTURE5",
  23062. "TEXTURE6",
  23063. "TEXTURE7",
  23064. "TEXTURE8",
  23065. "TEXTURE9",
  23066. "TEXTURE_2D",
  23067. "TEXTURE_2D_ARRAY",
  23068. "TEXTURE_3D",
  23069. "TEXTURE_BASE_LEVEL",
  23070. "TEXTURE_BINDING",
  23071. "TEXTURE_BINDING_2D",
  23072. "TEXTURE_BINDING_2D_ARRAY",
  23073. "TEXTURE_BINDING_3D",
  23074. "TEXTURE_BINDING_CUBE_MAP",
  23075. "TEXTURE_COMPARE_FUNC",
  23076. "TEXTURE_COMPARE_MODE",
  23077. "TEXTURE_CUBE_MAP",
  23078. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  23079. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  23080. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  23081. "TEXTURE_CUBE_MAP_POSITIVE_X",
  23082. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  23083. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  23084. "TEXTURE_IMMUTABLE_FORMAT",
  23085. "TEXTURE_IMMUTABLE_LEVELS",
  23086. "TEXTURE_MAG_FILTER",
  23087. "TEXTURE_MAX_ANISOTROPY_EXT",
  23088. "TEXTURE_MAX_LEVEL",
  23089. "TEXTURE_MAX_LOD",
  23090. "TEXTURE_MIN_FILTER",
  23091. "TEXTURE_MIN_LOD",
  23092. "TEXTURE_WRAP_R",
  23093. "TEXTURE_WRAP_S",
  23094. "TEXTURE_WRAP_T",
  23095. "TEXT_NODE",
  23096. "TIMEOUT",
  23097. "TIMEOUT_ERR",
  23098. "TIMEOUT_EXPIRED",
  23099. "TIMEOUT_IGNORED",
  23100. "TOO_LARGE_ERR",
  23101. "TRANSACTION_INACTIVE_ERR",
  23102. "TRANSFORM_FEEDBACK",
  23103. "TRANSFORM_FEEDBACK_ACTIVE",
  23104. "TRANSFORM_FEEDBACK_BINDING",
  23105. "TRANSFORM_FEEDBACK_BUFFER",
  23106. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  23107. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  23108. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  23109. "TRANSFORM_FEEDBACK_BUFFER_START",
  23110. "TRANSFORM_FEEDBACK_PAUSED",
  23111. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  23112. "TRANSFORM_FEEDBACK_VARYINGS",
  23113. "TRIANGLE",
  23114. "TRIANGLES",
  23115. "TRIANGLE_FAN",
  23116. "TRIANGLE_STRIP",
  23117. "TYPE_BACK_FORWARD",
  23118. "TYPE_ERR",
  23119. "TYPE_MISMATCH_ERR",
  23120. "TYPE_NAVIGATE",
  23121. "TYPE_RELOAD",
  23122. "TYPE_RESERVED",
  23123. "Table",
  23124. "Tag",
  23125. "TaskAttributionTiming",
  23126. "TaskController",
  23127. "TaskPriorityChangeEvent",
  23128. "TaskSignal",
  23129. "Text",
  23130. "TextDecoder",
  23131. "TextDecoderStream",
  23132. "TextEncoder",
  23133. "TextEncoderStream",
  23134. "TextEvent",
  23135. "TextFormat",
  23136. "TextFormatUpdateEvent",
  23137. "TextMetrics",
  23138. "TextTrack",
  23139. "TextTrackCue",
  23140. "TextTrackCueList",
  23141. "TextTrackList",
  23142. "TextUpdateEvent",
  23143. "TimeEvent",
  23144. "TimeRanges",
  23145. "ToggleEvent",
  23146. "Touch",
  23147. "TouchEvent",
  23148. "TouchList",
  23149. "TrackEvent",
  23150. "TransformStream",
  23151. "TransformStreamDefaultController",
  23152. "TransitionEvent",
  23153. "TreeWalker",
  23154. "TrustedHTML",
  23155. "TrustedScript",
  23156. "TrustedScriptURL",
  23157. "TrustedTypePolicy",
  23158. "TrustedTypePolicyFactory",
  23159. "TypeError",
  23160. "TypedObject",
  23161. "U2F",
  23162. "UIEvent",
  23163. "UNCACHED",
  23164. "UNIFORM",
  23165. "UNIFORM_ARRAY_STRIDE",
  23166. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  23167. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  23168. "UNIFORM_BLOCK_BINDING",
  23169. "UNIFORM_BLOCK_DATA_SIZE",
  23170. "UNIFORM_BLOCK_INDEX",
  23171. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  23172. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  23173. "UNIFORM_BUFFER",
  23174. "UNIFORM_BUFFER_BINDING",
  23175. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  23176. "UNIFORM_BUFFER_SIZE",
  23177. "UNIFORM_BUFFER_START",
  23178. "UNIFORM_IS_ROW_MAJOR",
  23179. "UNIFORM_MATRIX_STRIDE",
  23180. "UNIFORM_OFFSET",
  23181. "UNIFORM_SIZE",
  23182. "UNIFORM_TYPE",
  23183. "UNKNOWN_ERR",
  23184. "UNKNOWN_RULE",
  23185. "UNMASKED_RENDERER_WEBGL",
  23186. "UNMASKED_VENDOR_WEBGL",
  23187. "UNORDERED_NODE_ITERATOR_TYPE",
  23188. "UNORDERED_NODE_SNAPSHOT_TYPE",
  23189. "UNPACK_ALIGNMENT",
  23190. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  23191. "UNPACK_FLIP_Y_WEBGL",
  23192. "UNPACK_IMAGE_HEIGHT",
  23193. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  23194. "UNPACK_ROW_LENGTH",
  23195. "UNPACK_SKIP_IMAGES",
  23196. "UNPACK_SKIP_PIXELS",
  23197. "UNPACK_SKIP_ROWS",
  23198. "UNSCHEDULED_STATE",
  23199. "UNSENT",
  23200. "UNSIGNALED",
  23201. "UNSIGNED_BYTE",
  23202. "UNSIGNED_INT",
  23203. "UNSIGNED_INT_10F_11F_11F_REV",
  23204. "UNSIGNED_INT_24_8",
  23205. "UNSIGNED_INT_2_10_10_10_REV",
  23206. "UNSIGNED_INT_5_9_9_9_REV",
  23207. "UNSIGNED_INT_SAMPLER_2D",
  23208. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  23209. "UNSIGNED_INT_SAMPLER_3D",
  23210. "UNSIGNED_INT_SAMPLER_CUBE",
  23211. "UNSIGNED_INT_VEC2",
  23212. "UNSIGNED_INT_VEC3",
  23213. "UNSIGNED_INT_VEC4",
  23214. "UNSIGNED_NORMALIZED",
  23215. "UNSIGNED_SHORT",
  23216. "UNSIGNED_SHORT_4_4_4_4",
  23217. "UNSIGNED_SHORT_5_5_5_1",
  23218. "UNSIGNED_SHORT_5_6_5",
  23219. "UNSPECIFIED_EVENT_TYPE_ERR",
  23220. "UPDATEREADY",
  23221. "URIError",
  23222. "URL",
  23223. "URLPattern",
  23224. "URLSearchParams",
  23225. "URLUnencoded",
  23226. "URL_MISMATCH_ERR",
  23227. "USB",
  23228. "USBAlternateInterface",
  23229. "USBConfiguration",
  23230. "USBConnectionEvent",
  23231. "USBDevice",
  23232. "USBEndpoint",
  23233. "USBInTransferResult",
  23234. "USBInterface",
  23235. "USBIsochronousInTransferPacket",
  23236. "USBIsochronousInTransferResult",
  23237. "USBIsochronousOutTransferPacket",
  23238. "USBIsochronousOutTransferResult",
  23239. "USBOutTransferResult",
  23240. "UTC",
  23241. "Uint16Array",
  23242. "Uint32Array",
  23243. "Uint8Array",
  23244. "Uint8ClampedArray",
  23245. "UserActivation",
  23246. "UserMessageHandler",
  23247. "UserMessageHandlersNamespace",
  23248. "UserProximityEvent",
  23249. "VALIDATE_STATUS",
  23250. "VALIDATION_ERR",
  23251. "VARIABLES_RULE",
  23252. "VENDOR",
  23253. "VERSION",
  23254. "VERSION_CHANGE",
  23255. "VERSION_ERR",
  23256. "VERTEX",
  23257. "VERTEX_ARRAY_BINDING",
  23258. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  23259. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  23260. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  23261. "VERTEX_ATTRIB_ARRAY_ENABLED",
  23262. "VERTEX_ATTRIB_ARRAY_INTEGER",
  23263. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  23264. "VERTEX_ATTRIB_ARRAY_POINTER",
  23265. "VERTEX_ATTRIB_ARRAY_SIZE",
  23266. "VERTEX_ATTRIB_ARRAY_STRIDE",
  23267. "VERTEX_ATTRIB_ARRAY_TYPE",
  23268. "VERTEX_SHADER",
  23269. "VERTICAL",
  23270. "VERTICAL_AXIS",
  23271. "VER_ERR",
  23272. "VIEWPORT",
  23273. "VIEWPORT_RULE",
  23274. "VRDisplay",
  23275. "VRDisplayCapabilities",
  23276. "VRDisplayEvent",
  23277. "VREyeParameters",
  23278. "VRFieldOfView",
  23279. "VRFrameData",
  23280. "VRPose",
  23281. "VRStageParameters",
  23282. "VTTCue",
  23283. "VTTRegion",
  23284. "ValidityState",
  23285. "VideoColorSpace",
  23286. "VideoDecoder",
  23287. "VideoEncoder",
  23288. "VideoFrame",
  23289. "VideoPlaybackQuality",
  23290. "VideoStreamTrack",
  23291. "ViewTimeline",
  23292. "ViewTransition",
  23293. "VirtualKeyboard",
  23294. "VirtualKeyboardGeometryChangeEvent",
  23295. "VisibilityStateEntry",
  23296. "VisualViewport",
  23297. "WAIT_FAILED",
  23298. "WEBKIT_FILTER_RULE",
  23299. "WEBKIT_KEYFRAMES_RULE",
  23300. "WEBKIT_KEYFRAME_RULE",
  23301. "WEBKIT_REGION_RULE",
  23302. "WGSLLanguageFeatures",
  23303. "WRITE",
  23304. "WRONG_DOCUMENT_ERR",
  23305. "WakeLock",
  23306. "WakeLockSentinel",
  23307. "WasmAnyRef",
  23308. "WaveShaperNode",
  23309. "WeakMap",
  23310. "WeakRef",
  23311. "WeakSet",
  23312. "WebAssembly",
  23313. "WebGL2RenderingContext",
  23314. "WebGLActiveInfo",
  23315. "WebGLBuffer",
  23316. "WebGLContextEvent",
  23317. "WebGLFramebuffer",
  23318. "WebGLProgram",
  23319. "WebGLQuery",
  23320. "WebGLRenderbuffer",
  23321. "WebGLRenderingContext",
  23322. "WebGLSampler",
  23323. "WebGLShader",
  23324. "WebGLShaderPrecisionFormat",
  23325. "WebGLSync",
  23326. "WebGLTexture",
  23327. "WebGLTransformFeedback",
  23328. "WebGLUniformLocation",
  23329. "WebGLVertexArray",
  23330. "WebGLVertexArrayObject",
  23331. "WebKitAnimationEvent",
  23332. "WebKitBlobBuilder",
  23333. "WebKitCSSFilterRule",
  23334. "WebKitCSSFilterValue",
  23335. "WebKitCSSKeyframeRule",
  23336. "WebKitCSSKeyframesRule",
  23337. "WebKitCSSMatrix",
  23338. "WebKitCSSRegionRule",
  23339. "WebKitCSSTransformValue",
  23340. "WebKitDataCue",
  23341. "WebKitGamepad",
  23342. "WebKitMediaKeyError",
  23343. "WebKitMediaKeyMessageEvent",
  23344. "WebKitMediaKeySession",
  23345. "WebKitMediaKeys",
  23346. "WebKitMediaSource",
  23347. "WebKitMutationObserver",
  23348. "WebKitNamespace",
  23349. "WebKitPlaybackTargetAvailabilityEvent",
  23350. "WebKitPoint",
  23351. "WebKitShadowRoot",
  23352. "WebKitSourceBuffer",
  23353. "WebKitSourceBufferList",
  23354. "WebKitTransitionEvent",
  23355. "WebSocket",
  23356. "WebSocketError",
  23357. "WebSocketStream",
  23358. "WebTransport",
  23359. "WebTransportBidirectionalStream",
  23360. "WebTransportDatagramDuplexStream",
  23361. "WebTransportError",
  23362. "WebTransportReceiveStream",
  23363. "WebTransportSendStream",
  23364. "WebkitAlignContent",
  23365. "WebkitAlignItems",
  23366. "WebkitAlignSelf",
  23367. "WebkitAnimation",
  23368. "WebkitAnimationDelay",
  23369. "WebkitAnimationDirection",
  23370. "WebkitAnimationDuration",
  23371. "WebkitAnimationFillMode",
  23372. "WebkitAnimationIterationCount",
  23373. "WebkitAnimationName",
  23374. "WebkitAnimationPlayState",
  23375. "WebkitAnimationTimingFunction",
  23376. "WebkitAppearance",
  23377. "WebkitBackfaceVisibility",
  23378. "WebkitBackgroundClip",
  23379. "WebkitBackgroundOrigin",
  23380. "WebkitBackgroundSize",
  23381. "WebkitBorderBottomLeftRadius",
  23382. "WebkitBorderBottomRightRadius",
  23383. "WebkitBorderImage",
  23384. "WebkitBorderRadius",
  23385. "WebkitBorderTopLeftRadius",
  23386. "WebkitBorderTopRightRadius",
  23387. "WebkitBoxAlign",
  23388. "WebkitBoxDirection",
  23389. "WebkitBoxFlex",
  23390. "WebkitBoxOrdinalGroup",
  23391. "WebkitBoxOrient",
  23392. "WebkitBoxPack",
  23393. "WebkitBoxShadow",
  23394. "WebkitBoxSizing",
  23395. "WebkitClipPath",
  23396. "WebkitFilter",
  23397. "WebkitFlex",
  23398. "WebkitFlexBasis",
  23399. "WebkitFlexDirection",
  23400. "WebkitFlexFlow",
  23401. "WebkitFlexGrow",
  23402. "WebkitFlexShrink",
  23403. "WebkitFlexWrap",
  23404. "WebkitJustifyContent",
  23405. "WebkitLineClamp",
  23406. "WebkitMask",
  23407. "WebkitMaskClip",
  23408. "WebkitMaskComposite",
  23409. "WebkitMaskImage",
  23410. "WebkitMaskOrigin",
  23411. "WebkitMaskPosition",
  23412. "WebkitMaskPositionX",
  23413. "WebkitMaskPositionY",
  23414. "WebkitMaskRepeat",
  23415. "WebkitMaskSize",
  23416. "WebkitOrder",
  23417. "WebkitPerspective",
  23418. "WebkitPerspectiveOrigin",
  23419. "WebkitTextFillColor",
  23420. "WebkitTextSecurity",
  23421. "WebkitTextSizeAdjust",
  23422. "WebkitTextStroke",
  23423. "WebkitTextStrokeColor",
  23424. "WebkitTextStrokeWidth",
  23425. "WebkitTransform",
  23426. "WebkitTransformOrigin",
  23427. "WebkitTransformStyle",
  23428. "WebkitTransition",
  23429. "WebkitTransitionDelay",
  23430. "WebkitTransitionDuration",
  23431. "WebkitTransitionProperty",
  23432. "WebkitTransitionTimingFunction",
  23433. "WebkitUserSelect",
  23434. "WheelEvent",
  23435. "Window",
  23436. "WindowControlsOverlay",
  23437. "WindowControlsOverlayGeometryChangeEvent",
  23438. "Worker",
  23439. "Worklet",
  23440. "WritableStream",
  23441. "WritableStreamDefaultController",
  23442. "WritableStreamDefaultWriter",
  23443. "XMLDocument",
  23444. "XMLHttpRequest",
  23445. "XMLHttpRequestEventTarget",
  23446. "XMLHttpRequestException",
  23447. "XMLHttpRequestProgressEvent",
  23448. "XMLHttpRequestUpload",
  23449. "XMLSerializer",
  23450. "XMLStylesheetProcessingInstruction",
  23451. "XPathEvaluator",
  23452. "XPathException",
  23453. "XPathExpression",
  23454. "XPathNSResolver",
  23455. "XPathResult",
  23456. "XRAnchor",
  23457. "XRAnchorSet",
  23458. "XRBoundedReferenceSpace",
  23459. "XRCPUDepthInformation",
  23460. "XRCamera",
  23461. "XRDOMOverlayState",
  23462. "XRDepthInformation",
  23463. "XRFrame",
  23464. "XRHitTestResult",
  23465. "XRHitTestSource",
  23466. "XRInputSource",
  23467. "XRInputSourceArray",
  23468. "XRInputSourceEvent",
  23469. "XRInputSourcesChangeEvent",
  23470. "XRLayer",
  23471. "XRLightEstimate",
  23472. "XRLightProbe",
  23473. "XRPose",
  23474. "XRRay",
  23475. "XRReferenceSpace",
  23476. "XRReferenceSpaceEvent",
  23477. "XRRenderState",
  23478. "XRRigidTransform",
  23479. "XRSession",
  23480. "XRSessionEvent",
  23481. "XRSpace",
  23482. "XRSystem",
  23483. "XRTransientInputHitTestResult",
  23484. "XRTransientInputHitTestSource",
  23485. "XRView",
  23486. "XRViewerPose",
  23487. "XRViewport",
  23488. "XRWebGLBinding",
  23489. "XRWebGLDepthInformation",
  23490. "XRWebGLLayer",
  23491. "XSLTProcessor",
  23492. "ZERO",
  23493. "_XD0M_",
  23494. "_YD0M_",
  23495. "__REACT_DEVTOOLS_GLOBAL_HOOK__",
  23496. "__brand",
  23497. "__defineGetter__",
  23498. "__defineSetter__",
  23499. "__lookupGetter__",
  23500. "__lookupSetter__",
  23501. "__opera",
  23502. "__proto__",
  23503. "_browserjsran",
  23504. "a",
  23505. "aLink",
  23506. "abbr",
  23507. "abort",
  23508. "aborted",
  23509. "abs",
  23510. "absolute",
  23511. "acceleration",
  23512. "accelerationIncludingGravity",
  23513. "accelerator",
  23514. "accent-color",
  23515. "accentColor",
  23516. "accept",
  23517. "acceptCharset",
  23518. "acceptNode",
  23519. "access",
  23520. "accessKey",
  23521. "accessKeyLabel",
  23522. "accuracy",
  23523. "acos",
  23524. "acosh",
  23525. "action",
  23526. "actionURL",
  23527. "actions",
  23528. "activated",
  23529. "activation",
  23530. "activationStart",
  23531. "active",
  23532. "activeCues",
  23533. "activeElement",
  23534. "activeSourceBuffers",
  23535. "activeSourceCount",
  23536. "activeTexture",
  23537. "activeVRDisplays",
  23538. "actualBoundingBoxAscent",
  23539. "actualBoundingBoxDescent",
  23540. "actualBoundingBoxLeft",
  23541. "actualBoundingBoxRight",
  23542. "adAuctionComponents",
  23543. "adAuctionHeaders",
  23544. "add",
  23545. "addAll",
  23546. "addBehavior",
  23547. "addCandidate",
  23548. "addColorStop",
  23549. "addCue",
  23550. "addElement",
  23551. "addEventListener",
  23552. "addFilter",
  23553. "addFromString",
  23554. "addFromUri",
  23555. "addIceCandidate",
  23556. "addImport",
  23557. "addListener",
  23558. "addModule",
  23559. "addNamed",
  23560. "addPageRule",
  23561. "addPath",
  23562. "addPointer",
  23563. "addRange",
  23564. "addRegion",
  23565. "addRule",
  23566. "addSearchEngine",
  23567. "addSourceBuffer",
  23568. "addStream",
  23569. "addTextTrack",
  23570. "addTrack",
  23571. "addTransceiver",
  23572. "addWakeLockListener",
  23573. "added",
  23574. "addedNodes",
  23575. "additionalName",
  23576. "additiveSymbols",
  23577. "addons",
  23578. "address",
  23579. "addressLine",
  23580. "addressModeU",
  23581. "addressModeV",
  23582. "addressModeW",
  23583. "adoptNode",
  23584. "adoptedCallback",
  23585. "adoptedStyleSheets",
  23586. "adr",
  23587. "advance",
  23588. "after",
  23589. "album",
  23590. "alert",
  23591. "algorithm",
  23592. "align",
  23593. "align-content",
  23594. "align-items",
  23595. "align-self",
  23596. "alignContent",
  23597. "alignItems",
  23598. "alignSelf",
  23599. "alignmentBaseline",
  23600. "alinkColor",
  23601. "all",
  23602. "allSettled",
  23603. "allocationSize",
  23604. "allow",
  23605. "allowFullscreen",
  23606. "allowPaymentRequest",
  23607. "allowedDirections",
  23608. "allowedFeatures",
  23609. "allowedToPlay",
  23610. "allowsFeature",
  23611. "alpha",
  23612. "alphaMode",
  23613. "alphaToCoverageEnabled",
  23614. "alphabeticBaseline",
  23615. "alt",
  23616. "altGraphKey",
  23617. "altHtml",
  23618. "altKey",
  23619. "altLeft",
  23620. "alternate",
  23621. "alternateSetting",
  23622. "alternates",
  23623. "altitude",
  23624. "altitudeAccuracy",
  23625. "altitudeAngle",
  23626. "amplitude",
  23627. "ancestorOrigins",
  23628. "anchor",
  23629. "anchorNode",
  23630. "anchorOffset",
  23631. "anchorSpace",
  23632. "anchors",
  23633. "and",
  23634. "angle",
  23635. "angularAcceleration",
  23636. "angularVelocity",
  23637. "animVal",
  23638. "animate",
  23639. "animated",
  23640. "animatedInstanceRoot",
  23641. "animatedNormalizedPathSegList",
  23642. "animatedPathSegList",
  23643. "animatedPoints",
  23644. "animation",
  23645. "animation-composition",
  23646. "animation-delay",
  23647. "animation-direction",
  23648. "animation-duration",
  23649. "animation-fill-mode",
  23650. "animation-iteration-count",
  23651. "animation-name",
  23652. "animation-play-state",
  23653. "animation-timing-function",
  23654. "animationComposition",
  23655. "animationDelay",
  23656. "animationDirection",
  23657. "animationDuration",
  23658. "animationFillMode",
  23659. "animationIterationCount",
  23660. "animationName",
  23661. "animationPlayState",
  23662. "animationStartTime",
  23663. "animationTimingFunction",
  23664. "animationsPaused",
  23665. "anniversary",
  23666. "antialias",
  23667. "anticipatedRemoval",
  23668. "any",
  23669. "app",
  23670. "appCodeName",
  23671. "appMinorVersion",
  23672. "appName",
  23673. "appNotifications",
  23674. "appVersion",
  23675. "appearance",
  23676. "append",
  23677. "appendBuffer",
  23678. "appendChild",
  23679. "appendData",
  23680. "appendItem",
  23681. "appendMedium",
  23682. "appendNamed",
  23683. "appendRule",
  23684. "appendStream",
  23685. "appendWindowEnd",
  23686. "appendWindowStart",
  23687. "applets",
  23688. "applicationCache",
  23689. "applicationServerKey",
  23690. "apply",
  23691. "applyConstraints",
  23692. "applyElement",
  23693. "arc",
  23694. "arcTo",
  23695. "architecture",
  23696. "archive",
  23697. "areas",
  23698. "arguments",
  23699. "ariaAtomic",
  23700. "ariaAutoComplete",
  23701. "ariaBrailleLabel",
  23702. "ariaBrailleRoleDescription",
  23703. "ariaBusy",
  23704. "ariaChecked",
  23705. "ariaColCount",
  23706. "ariaColIndex",
  23707. "ariaColIndexText",
  23708. "ariaColSpan",
  23709. "ariaCurrent",
  23710. "ariaDescription",
  23711. "ariaDisabled",
  23712. "ariaExpanded",
  23713. "ariaHasPopup",
  23714. "ariaHidden",
  23715. "ariaInvalid",
  23716. "ariaKeyShortcuts",
  23717. "ariaLabel",
  23718. "ariaLevel",
  23719. "ariaLive",
  23720. "ariaModal",
  23721. "ariaMultiLine",
  23722. "ariaMultiSelectable",
  23723. "ariaOrientation",
  23724. "ariaPlaceholder",
  23725. "ariaPosInSet",
  23726. "ariaPressed",
  23727. "ariaReadOnly",
  23728. "ariaRelevant",
  23729. "ariaRequired",
  23730. "ariaRoleDescription",
  23731. "ariaRowCount",
  23732. "ariaRowIndex",
  23733. "ariaRowIndexText",
  23734. "ariaRowSpan",
  23735. "ariaSelected",
  23736. "ariaSetSize",
  23737. "ariaSort",
  23738. "ariaValueMax",
  23739. "ariaValueMin",
  23740. "ariaValueNow",
  23741. "ariaValueText",
  23742. "arrayBuffer",
  23743. "arrayLayerCount",
  23744. "arrayStride",
  23745. "artist",
  23746. "artwork",
  23747. "as",
  23748. "asIntN",
  23749. "asUintN",
  23750. "ascentOverride",
  23751. "asin",
  23752. "asinh",
  23753. "aspect",
  23754. "aspect-ratio",
  23755. "aspectRatio",
  23756. "assert",
  23757. "assign",
  23758. "assignedElements",
  23759. "assignedNodes",
  23760. "assignedSlot",
  23761. "async",
  23762. "asyncIterator",
  23763. "at",
  23764. "atEnd",
  23765. "atan",
  23766. "atan2",
  23767. "atanh",
  23768. "atob",
  23769. "attachEvent",
  23770. "attachInternals",
  23771. "attachShader",
  23772. "attachShadow",
  23773. "attachedElements",
  23774. "attachments",
  23775. "attack",
  23776. "attestationObject",
  23777. "attrChange",
  23778. "attrName",
  23779. "attributeChangedCallback",
  23780. "attributeFilter",
  23781. "attributeName",
  23782. "attributeNamespace",
  23783. "attributeOldValue",
  23784. "attributeStyleMap",
  23785. "attributes",
  23786. "attribution",
  23787. "attributionSrc",
  23788. "audioBitrateMode",
  23789. "audioBitsPerSecond",
  23790. "audioTracks",
  23791. "audioWorklet",
  23792. "authenticatedSignedWrites",
  23793. "authenticatorAttachment",
  23794. "authenticatorData",
  23795. "autoIncrement",
  23796. "autobuffer",
  23797. "autocapitalize",
  23798. "autocomplete",
  23799. "autocorrect",
  23800. "autofocus",
  23801. "automationRate",
  23802. "autoplay",
  23803. "availHeight",
  23804. "availLeft",
  23805. "availTop",
  23806. "availWidth",
  23807. "availability",
  23808. "available",
  23809. "aversion",
  23810. "ax",
  23811. "axes",
  23812. "axis",
  23813. "ay",
  23814. "azimuth",
  23815. "azimuthAngle",
  23816. "b",
  23817. "back",
  23818. "backdrop-filter",
  23819. "backdropFilter",
  23820. "backends",
  23821. "backface-visibility",
  23822. "backfaceVisibility",
  23823. "background",
  23824. "background-attachment",
  23825. "background-blend-mode",
  23826. "background-clip",
  23827. "background-color",
  23828. "background-image",
  23829. "background-origin",
  23830. "background-position",
  23831. "background-position-x",
  23832. "background-position-y",
  23833. "background-repeat",
  23834. "background-size",
  23835. "backgroundAttachment",
  23836. "backgroundBlendMode",
  23837. "backgroundClip",
  23838. "backgroundColor",
  23839. "backgroundFetch",
  23840. "backgroundImage",
  23841. "backgroundOrigin",
  23842. "backgroundPosition",
  23843. "backgroundPositionX",
  23844. "backgroundPositionY",
  23845. "backgroundRepeat",
  23846. "backgroundSize",
  23847. "badInput",
  23848. "badge",
  23849. "balance",
  23850. "baseArrayLayer",
  23851. "baseFrequencyX",
  23852. "baseFrequencyY",
  23853. "baseLatency",
  23854. "baseLayer",
  23855. "baseMipLevel",
  23856. "baseNode",
  23857. "baseOffset",
  23858. "basePalette",
  23859. "baseURI",
  23860. "baseVal",
  23861. "baseline-source",
  23862. "baselineShift",
  23863. "baselineSource",
  23864. "battery",
  23865. "bday",
  23866. "before",
  23867. "beginComputePass",
  23868. "beginElement",
  23869. "beginElementAt",
  23870. "beginOcclusionQuery",
  23871. "beginPath",
  23872. "beginQuery",
  23873. "beginRenderPass",
  23874. "beginTransformFeedback",
  23875. "beginningOfPassWriteIndex",
  23876. "behavior",
  23877. "behaviorCookie",
  23878. "behaviorPart",
  23879. "behaviorUrns",
  23880. "beta",
  23881. "bezierCurveTo",
  23882. "bgColor",
  23883. "bgProperties",
  23884. "bias",
  23885. "big",
  23886. "bigint64",
  23887. "biguint64",
  23888. "binaryType",
  23889. "bind",
  23890. "bindAttribLocation",
  23891. "bindBuffer",
  23892. "bindBufferBase",
  23893. "bindBufferRange",
  23894. "bindFramebuffer",
  23895. "bindGroupLayouts",
  23896. "bindRenderbuffer",
  23897. "bindSampler",
  23898. "bindTexture",
  23899. "bindTransformFeedback",
  23900. "bindVertexArray",
  23901. "binding",
  23902. "bitness",
  23903. "blend",
  23904. "blendColor",
  23905. "blendEquation",
  23906. "blendEquationSeparate",
  23907. "blendFunc",
  23908. "blendFuncSeparate",
  23909. "blink",
  23910. "blitFramebuffer",
  23911. "blob",
  23912. "block-size",
  23913. "blockDirection",
  23914. "blockSize",
  23915. "blockedURI",
  23916. "blocking",
  23917. "blockingDuration",
  23918. "blue",
  23919. "bluetooth",
  23920. "blur",
  23921. "body",
  23922. "bodyUsed",
  23923. "bold",
  23924. "bookmarks",
  23925. "booleanValue",
  23926. "border",
  23927. "border-block",
  23928. "border-block-color",
  23929. "border-block-end",
  23930. "border-block-end-color",
  23931. "border-block-end-style",
  23932. "border-block-end-width",
  23933. "border-block-start",
  23934. "border-block-start-color",
  23935. "border-block-start-style",
  23936. "border-block-start-width",
  23937. "border-block-style",
  23938. "border-block-width",
  23939. "border-bottom",
  23940. "border-bottom-color",
  23941. "border-bottom-left-radius",
  23942. "border-bottom-right-radius",
  23943. "border-bottom-style",
  23944. "border-bottom-width",
  23945. "border-collapse",
  23946. "border-color",
  23947. "border-end-end-radius",
  23948. "border-end-start-radius",
  23949. "border-image",
  23950. "border-image-outset",
  23951. "border-image-repeat",
  23952. "border-image-slice",
  23953. "border-image-source",
  23954. "border-image-width",
  23955. "border-inline",
  23956. "border-inline-color",
  23957. "border-inline-end",
  23958. "border-inline-end-color",
  23959. "border-inline-end-style",
  23960. "border-inline-end-width",
  23961. "border-inline-start",
  23962. "border-inline-start-color",
  23963. "border-inline-start-style",
  23964. "border-inline-start-width",
  23965. "border-inline-style",
  23966. "border-inline-width",
  23967. "border-left",
  23968. "border-left-color",
  23969. "border-left-style",
  23970. "border-left-width",
  23971. "border-radius",
  23972. "border-right",
  23973. "border-right-color",
  23974. "border-right-style",
  23975. "border-right-width",
  23976. "border-spacing",
  23977. "border-start-end-radius",
  23978. "border-start-start-radius",
  23979. "border-style",
  23980. "border-top",
  23981. "border-top-color",
  23982. "border-top-left-radius",
  23983. "border-top-right-radius",
  23984. "border-top-style",
  23985. "border-top-width",
  23986. "border-width",
  23987. "borderBlock",
  23988. "borderBlockColor",
  23989. "borderBlockEnd",
  23990. "borderBlockEndColor",
  23991. "borderBlockEndStyle",
  23992. "borderBlockEndWidth",
  23993. "borderBlockStart",
  23994. "borderBlockStartColor",
  23995. "borderBlockStartStyle",
  23996. "borderBlockStartWidth",
  23997. "borderBlockStyle",
  23998. "borderBlockWidth",
  23999. "borderBottom",
  24000. "borderBottomColor",
  24001. "borderBottomLeftRadius",
  24002. "borderBottomRightRadius",
  24003. "borderBottomStyle",
  24004. "borderBottomWidth",
  24005. "borderBoxSize",
  24006. "borderCollapse",
  24007. "borderColor",
  24008. "borderColorDark",
  24009. "borderColorLight",
  24010. "borderEndEndRadius",
  24011. "borderEndStartRadius",
  24012. "borderImage",
  24013. "borderImageOutset",
  24014. "borderImageRepeat",
  24015. "borderImageSlice",
  24016. "borderImageSource",
  24017. "borderImageWidth",
  24018. "borderInline",
  24019. "borderInlineColor",
  24020. "borderInlineEnd",
  24021. "borderInlineEndColor",
  24022. "borderInlineEndStyle",
  24023. "borderInlineEndWidth",
  24024. "borderInlineStart",
  24025. "borderInlineStartColor",
  24026. "borderInlineStartStyle",
  24027. "borderInlineStartWidth",
  24028. "borderInlineStyle",
  24029. "borderInlineWidth",
  24030. "borderLeft",
  24031. "borderLeftColor",
  24032. "borderLeftStyle",
  24033. "borderLeftWidth",
  24034. "borderRadius",
  24035. "borderRight",
  24036. "borderRightColor",
  24037. "borderRightStyle",
  24038. "borderRightWidth",
  24039. "borderSpacing",
  24040. "borderStartEndRadius",
  24041. "borderStartStartRadius",
  24042. "borderStyle",
  24043. "borderTop",
  24044. "borderTopColor",
  24045. "borderTopLeftRadius",
  24046. "borderTopRightRadius",
  24047. "borderTopStyle",
  24048. "borderTopWidth",
  24049. "borderWidth",
  24050. "bottom",
  24051. "bottomMargin",
  24052. "bound",
  24053. "boundElements",
  24054. "boundingClientRect",
  24055. "boundingHeight",
  24056. "boundingLeft",
  24057. "boundingRect",
  24058. "boundingTop",
  24059. "boundingWidth",
  24060. "bounds",
  24061. "boundsGeometry",
  24062. "box-decoration-break",
  24063. "box-shadow",
  24064. "box-sizing",
  24065. "boxDecorationBreak",
  24066. "boxShadow",
  24067. "boxSizing",
  24068. "brand",
  24069. "brands",
  24070. "break-after",
  24071. "break-before",
  24072. "break-inside",
  24073. "breakAfter",
  24074. "breakBefore",
  24075. "breakInside",
  24076. "broadcast",
  24077. "browserLanguage",
  24078. "browsingTopics",
  24079. "btoa",
  24080. "bubbles",
  24081. "buffer",
  24082. "bufferData",
  24083. "bufferDepth",
  24084. "bufferSize",
  24085. "bufferSubData",
  24086. "buffered",
  24087. "bufferedAmount",
  24088. "bufferedAmountLowThreshold",
  24089. "buffers",
  24090. "buildID",
  24091. "buildNumber",
  24092. "button",
  24093. "buttonID",
  24094. "buttons",
  24095. "byobRequest",
  24096. "byteLength",
  24097. "byteOffset",
  24098. "bytesPerRow",
  24099. "bytesWritten",
  24100. "c",
  24101. "cache",
  24102. "caches",
  24103. "call",
  24104. "caller",
  24105. "camera",
  24106. "canBeFormatted",
  24107. "canBeMounted",
  24108. "canBeShared",
  24109. "canConstructInDedicatedWorker",
  24110. "canGoBack",
  24111. "canGoForward",
  24112. "canHaveChildren",
  24113. "canHaveHTML",
  24114. "canInsertDTMF",
  24115. "canIntercept",
  24116. "canLoadAdAuctionFencedFrame",
  24117. "canLoadOpaqueURL",
  24118. "canMakePayment",
  24119. "canParse",
  24120. "canPlayType",
  24121. "canPresent",
  24122. "canShare",
  24123. "canTransition",
  24124. "canTrickleIceCandidates",
  24125. "cancel",
  24126. "cancelAndHoldAtTime",
  24127. "cancelAnimationFrame",
  24128. "cancelBubble",
  24129. "cancelIdleCallback",
  24130. "cancelScheduledValues",
  24131. "cancelVideoFrameCallback",
  24132. "cancelWatchAvailability",
  24133. "cancelable",
  24134. "candidate",
  24135. "canonicalUUID",
  24136. "canvas",
  24137. "cap",
  24138. "capabilities",
  24139. "caption",
  24140. "caption-side",
  24141. "captionSide",
  24142. "capture",
  24143. "captureEvents",
  24144. "captureStackTrace",
  24145. "captureStream",
  24146. "caret-color",
  24147. "caretBidiLevel",
  24148. "caretColor",
  24149. "caretPositionFromPoint",
  24150. "caretRangeFromPoint",
  24151. "cast",
  24152. "catch",
  24153. "category",
  24154. "cbrt",
  24155. "cd",
  24156. "ceil",
  24157. "cellIndex",
  24158. "cellPadding",
  24159. "cellSpacing",
  24160. "cells",
  24161. "ch",
  24162. "chOff",
  24163. "chain",
  24164. "challenge",
  24165. "changeType",
  24166. "changed",
  24167. "changedTouches",
  24168. "channel",
  24169. "channelCount",
  24170. "channelCountMode",
  24171. "channelInterpretation",
  24172. "char",
  24173. "charAt",
  24174. "charCode",
  24175. "charCodeAt",
  24176. "charIndex",
  24177. "charLength",
  24178. "characterBounds",
  24179. "characterBoundsRangeStart",
  24180. "characterData",
  24181. "characterDataOldValue",
  24182. "characterSet",
  24183. "characteristic",
  24184. "charging",
  24185. "chargingTime",
  24186. "charset",
  24187. "check",
  24188. "checkDCE",
  24189. "checkEnclosure",
  24190. "checkFramebufferStatus",
  24191. "checkIntersection",
  24192. "checkValidity",
  24193. "checkVisibility",
  24194. "checked",
  24195. "childElementCount",
  24196. "childList",
  24197. "childNodes",
  24198. "children",
  24199. "chrome",
  24200. "ciphertext",
  24201. "cite",
  24202. "city",
  24203. "claimInterface",
  24204. "claimed",
  24205. "classList",
  24206. "className",
  24207. "classid",
  24208. "clear",
  24209. "clearAppBadge",
  24210. "clearAttributes",
  24211. "clearBuffer",
  24212. "clearBufferfi",
  24213. "clearBufferfv",
  24214. "clearBufferiv",
  24215. "clearBufferuiv",
  24216. "clearColor",
  24217. "clearData",
  24218. "clearDepth",
  24219. "clearHalt",
  24220. "clearImmediate",
  24221. "clearInterval",
  24222. "clearLiveSeekableRange",
  24223. "clearMarks",
  24224. "clearMaxGCPauseAccumulator",
  24225. "clearMeasures",
  24226. "clearOriginJoinedAdInterestGroups",
  24227. "clearParameters",
  24228. "clearRect",
  24229. "clearResourceTimings",
  24230. "clearShadow",
  24231. "clearStencil",
  24232. "clearTimeout",
  24233. "clearValue",
  24234. "clearWatch",
  24235. "click",
  24236. "clickCount",
  24237. "clientDataJSON",
  24238. "clientHeight",
  24239. "clientInformation",
  24240. "clientLeft",
  24241. "clientRect",
  24242. "clientRects",
  24243. "clientTop",
  24244. "clientWaitSync",
  24245. "clientWidth",
  24246. "clientX",
  24247. "clientY",
  24248. "clip",
  24249. "clip-path",
  24250. "clip-rule",
  24251. "clipBottom",
  24252. "clipLeft",
  24253. "clipPath",
  24254. "clipPathUnits",
  24255. "clipRight",
  24256. "clipRule",
  24257. "clipTop",
  24258. "clipboard",
  24259. "clipboardData",
  24260. "clonable",
  24261. "clone",
  24262. "cloneContents",
  24263. "cloneNode",
  24264. "cloneRange",
  24265. "close",
  24266. "closeCode",
  24267. "closePath",
  24268. "closed",
  24269. "closest",
  24270. "clz",
  24271. "clz32",
  24272. "cm",
  24273. "cmp",
  24274. "code",
  24275. "codeBase",
  24276. "codePointAt",
  24277. "codeType",
  24278. "codedHeight",
  24279. "codedRect",
  24280. "codedWidth",
  24281. "colSpan",
  24282. "collapse",
  24283. "collapseToEnd",
  24284. "collapseToStart",
  24285. "collapsed",
  24286. "collect",
  24287. "collections",
  24288. "colno",
  24289. "color",
  24290. "color-adjust",
  24291. "color-interpolation",
  24292. "color-interpolation-filters",
  24293. "color-scheme",
  24294. "colorAdjust",
  24295. "colorAttachments",
  24296. "colorDepth",
  24297. "colorFormats",
  24298. "colorInterpolation",
  24299. "colorInterpolationFilters",
  24300. "colorMask",
  24301. "colorScheme",
  24302. "colorSpace",
  24303. "colorType",
  24304. "cols",
  24305. "column-count",
  24306. "column-fill",
  24307. "column-gap",
  24308. "column-rule",
  24309. "column-rule-color",
  24310. "column-rule-style",
  24311. "column-rule-width",
  24312. "column-span",
  24313. "column-width",
  24314. "columnCount",
  24315. "columnFill",
  24316. "columnGap",
  24317. "columnNumber",
  24318. "columnRule",
  24319. "columnRuleColor",
  24320. "columnRuleStyle",
  24321. "columnRuleWidth",
  24322. "columnSpan",
  24323. "columnWidth",
  24324. "columns",
  24325. "command",
  24326. "commit",
  24327. "commitPreferences",
  24328. "commitStyles",
  24329. "commonAncestorContainer",
  24330. "compact",
  24331. "compare",
  24332. "compareBoundaryPoints",
  24333. "compareDocumentPosition",
  24334. "compareEndPoints",
  24335. "compareExchange",
  24336. "compareNode",
  24337. "comparePoint",
  24338. "compatMode",
  24339. "compatible",
  24340. "compile",
  24341. "compileShader",
  24342. "compileStreaming",
  24343. "complete",
  24344. "completed",
  24345. "component",
  24346. "componentFromPoint",
  24347. "composed",
  24348. "composedPath",
  24349. "composite",
  24350. "compositionEndOffset",
  24351. "compositionStartOffset",
  24352. "compressedTexImage2D",
  24353. "compressedTexImage3D",
  24354. "compressedTexSubImage2D",
  24355. "compressedTexSubImage3D",
  24356. "compute",
  24357. "computedStyleMap",
  24358. "concat",
  24359. "conditionText",
  24360. "coneInnerAngle",
  24361. "coneOuterAngle",
  24362. "coneOuterGain",
  24363. "config",
  24364. "configurable",
  24365. "configuration",
  24366. "configurationName",
  24367. "configurationValue",
  24368. "configurations",
  24369. "configure",
  24370. "confirm",
  24371. "confirmComposition",
  24372. "confirmSiteSpecificTrackingException",
  24373. "confirmWebWideTrackingException",
  24374. "congestionControl",
  24375. "connect",
  24376. "connectEnd",
  24377. "connectShark",
  24378. "connectStart",
  24379. "connected",
  24380. "connectedCallback",
  24381. "connection",
  24382. "connectionList",
  24383. "connectionSpeed",
  24384. "connectionState",
  24385. "connections",
  24386. "console",
  24387. "consolidate",
  24388. "constants",
  24389. "constraint",
  24390. "constrictionActive",
  24391. "construct",
  24392. "constructor",
  24393. "contactID",
  24394. "contain",
  24395. "contain-intrinsic-block-size",
  24396. "contain-intrinsic-height",
  24397. "contain-intrinsic-inline-size",
  24398. "contain-intrinsic-size",
  24399. "contain-intrinsic-width",
  24400. "containIntrinsicBlockSize",
  24401. "containIntrinsicHeight",
  24402. "containIntrinsicInlineSize",
  24403. "containIntrinsicSize",
  24404. "containIntrinsicWidth",
  24405. "container",
  24406. "container-name",
  24407. "container-type",
  24408. "containerId",
  24409. "containerName",
  24410. "containerQuery",
  24411. "containerSrc",
  24412. "containerType",
  24413. "contains",
  24414. "containsNode",
  24415. "content",
  24416. "content-visibility",
  24417. "contentBoxSize",
  24418. "contentDocument",
  24419. "contentEditable",
  24420. "contentHint",
  24421. "contentOverflow",
  24422. "contentRect",
  24423. "contentScriptType",
  24424. "contentStyleType",
  24425. "contentType",
  24426. "contentVisibility",
  24427. "contentWindow",
  24428. "context",
  24429. "contextMenu",
  24430. "contextmenu",
  24431. "continue",
  24432. "continuePrimaryKey",
  24433. "continuous",
  24434. "control",
  24435. "controlTransferIn",
  24436. "controlTransferOut",
  24437. "controller",
  24438. "controls",
  24439. "controlsList",
  24440. "convertPointFromNode",
  24441. "convertQuadFromNode",
  24442. "convertRectFromNode",
  24443. "convertToBlob",
  24444. "convertToSpecifiedUnits",
  24445. "cookie",
  24446. "cookieEnabled",
  24447. "cookieStore",
  24448. "cookies",
  24449. "coords",
  24450. "copyBufferSubData",
  24451. "copyBufferToBuffer",
  24452. "copyBufferToTexture",
  24453. "copyExternalImageToTexture",
  24454. "copyFromChannel",
  24455. "copyTexImage2D",
  24456. "copyTexSubImage2D",
  24457. "copyTexSubImage3D",
  24458. "copyTextureToBuffer",
  24459. "copyTextureToTexture",
  24460. "copyTo",
  24461. "copyToChannel",
  24462. "copyWithin",
  24463. "correspondingElement",
  24464. "correspondingUseElement",
  24465. "corruptedVideoFrames",
  24466. "cos",
  24467. "cosh",
  24468. "count",
  24469. "countReset",
  24470. "counter-increment",
  24471. "counter-reset",
  24472. "counter-set",
  24473. "counterIncrement",
  24474. "counterReset",
  24475. "counterSet",
  24476. "country",
  24477. "cpuClass",
  24478. "cpuSleepAllowed",
  24479. "cqb",
  24480. "cqh",
  24481. "cqi",
  24482. "cqmax",
  24483. "cqmin",
  24484. "cqw",
  24485. "create",
  24486. "createAnalyser",
  24487. "createAnchor",
  24488. "createAnswer",
  24489. "createAttribute",
  24490. "createAttributeNS",
  24491. "createAuctionNonce",
  24492. "createBidirectionalStream",
  24493. "createBindGroup",
  24494. "createBindGroupLayout",
  24495. "createBiquadFilter",
  24496. "createBuffer",
  24497. "createBufferSource",
  24498. "createCDATASection",
  24499. "createCSSStyleSheet",
  24500. "createCaption",
  24501. "createChannelMerger",
  24502. "createChannelSplitter",
  24503. "createCommandEncoder",
  24504. "createComment",
  24505. "createComputePipeline",
  24506. "createComputePipelineAsync",
  24507. "createConicGradient",
  24508. "createConstantSource",
  24509. "createContextualFragment",
  24510. "createControlRange",
  24511. "createConvolver",
  24512. "createDTMFSender",
  24513. "createDataChannel",
  24514. "createDelay",
  24515. "createDelayNode",
  24516. "createDocument",
  24517. "createDocumentFragment",
  24518. "createDocumentType",
  24519. "createDynamicsCompressor",
  24520. "createElement",
  24521. "createElementNS",
  24522. "createEncodedStreams",
  24523. "createEntityReference",
  24524. "createEvent",
  24525. "createEventObject",
  24526. "createExpression",
  24527. "createFramebuffer",
  24528. "createFunction",
  24529. "createGain",
  24530. "createGainNode",
  24531. "createHTML",
  24532. "createHTMLDocument",
  24533. "createIIRFilter",
  24534. "createImageBitmap",
  24535. "createImageData",
  24536. "createIndex",
  24537. "createJavaScriptNode",
  24538. "createLinearGradient",
  24539. "createMediaElementSource",
  24540. "createMediaKeys",
  24541. "createMediaStreamDestination",
  24542. "createMediaStreamSource",
  24543. "createMediaStreamTrackSource",
  24544. "createMutableFile",
  24545. "createNSResolver",
  24546. "createNodeIterator",
  24547. "createNotification",
  24548. "createObjectStore",
  24549. "createObjectURL",
  24550. "createOffer",
  24551. "createOscillator",
  24552. "createPanner",
  24553. "createPattern",
  24554. "createPeriodicWave",
  24555. "createPipelineLayout",
  24556. "createPolicy",
  24557. "createPopup",
  24558. "createProcessingInstruction",
  24559. "createProgram",
  24560. "createQuery",
  24561. "createQuerySet",
  24562. "createRadialGradient",
  24563. "createRange",
  24564. "createRangeCollection",
  24565. "createReader",
  24566. "createRenderBundleEncoder",
  24567. "createRenderPipeline",
  24568. "createRenderPipelineAsync",
  24569. "createRenderbuffer",
  24570. "createSVGAngle",
  24571. "createSVGLength",
  24572. "createSVGMatrix",
  24573. "createSVGNumber",
  24574. "createSVGPathSegArcAbs",
  24575. "createSVGPathSegArcRel",
  24576. "createSVGPathSegClosePath",
  24577. "createSVGPathSegCurvetoCubicAbs",
  24578. "createSVGPathSegCurvetoCubicRel",
  24579. "createSVGPathSegCurvetoCubicSmoothAbs",
  24580. "createSVGPathSegCurvetoCubicSmoothRel",
  24581. "createSVGPathSegCurvetoQuadraticAbs",
  24582. "createSVGPathSegCurvetoQuadraticRel",
  24583. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  24584. "createSVGPathSegCurvetoQuadraticSmoothRel",
  24585. "createSVGPathSegLinetoAbs",
  24586. "createSVGPathSegLinetoHorizontalAbs",
  24587. "createSVGPathSegLinetoHorizontalRel",
  24588. "createSVGPathSegLinetoRel",
  24589. "createSVGPathSegLinetoVerticalAbs",
  24590. "createSVGPathSegLinetoVerticalRel",
  24591. "createSVGPathSegMovetoAbs",
  24592. "createSVGPathSegMovetoRel",
  24593. "createSVGPoint",
  24594. "createSVGRect",
  24595. "createSVGTransform",
  24596. "createSVGTransformFromMatrix",
  24597. "createSampler",
  24598. "createScript",
  24599. "createScriptProcessor",
  24600. "createScriptURL",
  24601. "createSession",
  24602. "createShader",
  24603. "createShaderModule",
  24604. "createShadowRoot",
  24605. "createStereoPanner",
  24606. "createStyleSheet",
  24607. "createTBody",
  24608. "createTFoot",
  24609. "createTHead",
  24610. "createTask",
  24611. "createTextNode",
  24612. "createTextRange",
  24613. "createTexture",
  24614. "createTouch",
  24615. "createTouchList",
  24616. "createTransformFeedback",
  24617. "createTreeWalker",
  24618. "createUnidirectionalStream",
  24619. "createVertexArray",
  24620. "createView",
  24621. "createWaveShaper",
  24622. "createWritable",
  24623. "creationTime",
  24624. "credentialless",
  24625. "credentials",
  24626. "criticalCHRestart",
  24627. "cropTo",
  24628. "crossOrigin",
  24629. "crossOriginIsolated",
  24630. "crypto",
  24631. "csi",
  24632. "csp",
  24633. "cssFloat",
  24634. "cssRules",
  24635. "cssText",
  24636. "cssValueType",
  24637. "ctrlKey",
  24638. "ctrlLeft",
  24639. "cues",
  24640. "cullFace",
  24641. "cullMode",
  24642. "currentDirection",
  24643. "currentEntry",
  24644. "currentLocalDescription",
  24645. "currentNode",
  24646. "currentPage",
  24647. "currentRect",
  24648. "currentRemoteDescription",
  24649. "currentScale",
  24650. "currentScreen",
  24651. "currentScript",
  24652. "currentSrc",
  24653. "currentState",
  24654. "currentStyle",
  24655. "currentTarget",
  24656. "currentTime",
  24657. "currentTranslate",
  24658. "currentView",
  24659. "cursor",
  24660. "curve",
  24661. "customElements",
  24662. "customError",
  24663. "cx",
  24664. "cy",
  24665. "d",
  24666. "data",
  24667. "dataFld",
  24668. "dataFormatAs",
  24669. "dataLoss",
  24670. "dataLossMessage",
  24671. "dataPageSize",
  24672. "dataSrc",
  24673. "dataTransfer",
  24674. "database",
  24675. "databases",
  24676. "datagrams",
  24677. "dataset",
  24678. "dateTime",
  24679. "db",
  24680. "debug",
  24681. "debuggerEnabled",
  24682. "declare",
  24683. "decode",
  24684. "decodeAudioData",
  24685. "decodeQueueSize",
  24686. "decodeURI",
  24687. "decodeURIComponent",
  24688. "decodedBodySize",
  24689. "decoding",
  24690. "decodingInfo",
  24691. "decrypt",
  24692. "default",
  24693. "defaultCharset",
  24694. "defaultChecked",
  24695. "defaultMuted",
  24696. "defaultPlaybackRate",
  24697. "defaultPolicy",
  24698. "defaultPrevented",
  24699. "defaultQueue",
  24700. "defaultRequest",
  24701. "defaultSelected",
  24702. "defaultStatus",
  24703. "defaultURL",
  24704. "defaultValue",
  24705. "defaultView",
  24706. "defaultstatus",
  24707. "defer",
  24708. "define",
  24709. "defineMagicFunction",
  24710. "defineMagicVariable",
  24711. "defineProperties",
  24712. "defineProperty",
  24713. "deg",
  24714. "delay",
  24715. "delayTime",
  24716. "delegatesFocus",
  24717. "delete",
  24718. "deleteBuffer",
  24719. "deleteCaption",
  24720. "deleteCell",
  24721. "deleteContents",
  24722. "deleteData",
  24723. "deleteDatabase",
  24724. "deleteFramebuffer",
  24725. "deleteFromDocument",
  24726. "deleteIndex",
  24727. "deleteMedium",
  24728. "deleteObjectStore",
  24729. "deleteProgram",
  24730. "deleteProperty",
  24731. "deleteQuery",
  24732. "deleteRenderbuffer",
  24733. "deleteRow",
  24734. "deleteRule",
  24735. "deleteSampler",
  24736. "deleteShader",
  24737. "deleteSync",
  24738. "deleteTFoot",
  24739. "deleteTHead",
  24740. "deleteTexture",
  24741. "deleteTransformFeedback",
  24742. "deleteVertexArray",
  24743. "deleted",
  24744. "deliverChangeRecords",
  24745. "deliveredFrames",
  24746. "delivery",
  24747. "deliveryInfo",
  24748. "deliveryStatus",
  24749. "deliveryTimestamp",
  24750. "deliveryType",
  24751. "delta",
  24752. "deltaMode",
  24753. "deltaX",
  24754. "deltaY",
  24755. "deltaZ",
  24756. "dependentLocality",
  24757. "deprecatedReplaceInURN",
  24758. "deprecatedRunAdAuctionEnforcesKAnonymity",
  24759. "deprecatedURNToURL",
  24760. "depthBias",
  24761. "depthBiasClamp",
  24762. "depthBiasSlopeScale",
  24763. "depthClearValue",
  24764. "depthCompare",
  24765. "depthDataFormat",
  24766. "depthFailOp",
  24767. "depthFar",
  24768. "depthFunc",
  24769. "depthLoadOp",
  24770. "depthMask",
  24771. "depthNear",
  24772. "depthOrArrayLayers",
  24773. "depthRange",
  24774. "depthReadOnly",
  24775. "depthStencil",
  24776. "depthStencilAttachment",
  24777. "depthStencilFormat",
  24778. "depthStoreOp",
  24779. "depthUsage",
  24780. "depthWriteEnabled",
  24781. "deref",
  24782. "deriveBits",
  24783. "deriveKey",
  24784. "descentOverride",
  24785. "description",
  24786. "deselectAll",
  24787. "designMode",
  24788. "desiredSize",
  24789. "destination",
  24790. "destinationURL",
  24791. "destroy",
  24792. "detach",
  24793. "detachEvent",
  24794. "detachShader",
  24795. "detached",
  24796. "detail",
  24797. "details",
  24798. "detect",
  24799. "detune",
  24800. "device",
  24801. "deviceClass",
  24802. "deviceId",
  24803. "deviceMemory",
  24804. "devicePixelContentBoxSize",
  24805. "devicePixelRatio",
  24806. "deviceProtocol",
  24807. "deviceSubclass",
  24808. "deviceVersionMajor",
  24809. "deviceVersionMinor",
  24810. "deviceVersionSubminor",
  24811. "deviceXDPI",
  24812. "deviceYDPI",
  24813. "didTimeout",
  24814. "difference",
  24815. "diffuseConstant",
  24816. "digest",
  24817. "dimension",
  24818. "dimensions",
  24819. "dir",
  24820. "dirName",
  24821. "direction",
  24822. "dirxml",
  24823. "disable",
  24824. "disablePictureInPicture",
  24825. "disableRemotePlayback",
  24826. "disableVertexAttribArray",
  24827. "disabled",
  24828. "discardedFrames",
  24829. "dischargingTime",
  24830. "disconnect",
  24831. "disconnectShark",
  24832. "disconnectedCallback",
  24833. "dispatchEvent",
  24834. "dispatchWorkgroups",
  24835. "dispatchWorkgroupsIndirect",
  24836. "display",
  24837. "displayHeight",
  24838. "displayId",
  24839. "displayName",
  24840. "displayWidth",
  24841. "disposition",
  24842. "distanceModel",
  24843. "div",
  24844. "divisor",
  24845. "djsapi",
  24846. "djsproxy",
  24847. "doImport",
  24848. "doNotTrack",
  24849. "doScroll",
  24850. "doctype",
  24851. "document",
  24852. "documentElement",
  24853. "documentMode",
  24854. "documentPictureInPicture",
  24855. "documentURI",
  24856. "dolphin",
  24857. "dolphinGameCenter",
  24858. "dolphininfo",
  24859. "dolphinmeta",
  24860. "domComplete",
  24861. "domContentLoadedEventEnd",
  24862. "domContentLoadedEventStart",
  24863. "domInteractive",
  24864. "domLoading",
  24865. "domOverlayState",
  24866. "domain",
  24867. "domainLookupEnd",
  24868. "domainLookupStart",
  24869. "dominant-baseline",
  24870. "dominantBaseline",
  24871. "done",
  24872. "dopplerFactor",
  24873. "dotAll",
  24874. "downDegrees",
  24875. "downlink",
  24876. "download",
  24877. "downloadRequest",
  24878. "downloadTotal",
  24879. "downloaded",
  24880. "dpcm",
  24881. "dpi",
  24882. "dppx",
  24883. "dragDrop",
  24884. "draggable",
  24885. "draw",
  24886. "drawArrays",
  24887. "drawArraysInstanced",
  24888. "drawArraysInstancedANGLE",
  24889. "drawBuffers",
  24890. "drawCustomFocusRing",
  24891. "drawElements",
  24892. "drawElementsInstanced",
  24893. "drawElementsInstancedANGLE",
  24894. "drawFocusIfNeeded",
  24895. "drawImage",
  24896. "drawImageFromRect",
  24897. "drawIndexed",
  24898. "drawIndexedIndirect",
  24899. "drawIndirect",
  24900. "drawRangeElements",
  24901. "drawSystemFocusRing",
  24902. "drawingBufferColorSpace",
  24903. "drawingBufferFormat",
  24904. "drawingBufferHeight",
  24905. "drawingBufferStorage",
  24906. "drawingBufferWidth",
  24907. "drop",
  24908. "dropEffect",
  24909. "droppedVideoFrames",
  24910. "dropzone",
  24911. "dstFactor",
  24912. "dtmf",
  24913. "dump",
  24914. "dumpProfile",
  24915. "duplicate",
  24916. "durability",
  24917. "duration",
  24918. "dvb",
  24919. "dvh",
  24920. "dvi",
  24921. "dvmax",
  24922. "dvmin",
  24923. "dvname",
  24924. "dvnum",
  24925. "dvw",
  24926. "dx",
  24927. "dy",
  24928. "dynsrc",
  24929. "e",
  24930. "edgeMode",
  24931. "editContext",
  24932. "effect",
  24933. "effectAllowed",
  24934. "effectiveDirective",
  24935. "effectiveType",
  24936. "elapsedTime",
  24937. "element",
  24938. "elementFromPoint",
  24939. "elementTiming",
  24940. "elements",
  24941. "elementsFromPoint",
  24942. "elevation",
  24943. "ellipse",
  24944. "em",
  24945. "emHeightAscent",
  24946. "emHeightDescent",
  24947. "email",
  24948. "embeds",
  24949. "emit",
  24950. "emma",
  24951. "empty",
  24952. "empty-cells",
  24953. "emptyCells",
  24954. "emptyHTML",
  24955. "emptyScript",
  24956. "emulatedPosition",
  24957. "enable",
  24958. "enableBackground",
  24959. "enableDelegations",
  24960. "enableStyleSheetsForSet",
  24961. "enableVertexAttribArray",
  24962. "enabled",
  24963. "enabledFeatures",
  24964. "enabledPlugin",
  24965. "encode",
  24966. "encodeInto",
  24967. "encodeQueueSize",
  24968. "encodeURI",
  24969. "encodeURIComponent",
  24970. "encodedBodySize",
  24971. "encoding",
  24972. "encodingInfo",
  24973. "encrypt",
  24974. "enctype",
  24975. "end",
  24976. "endContainer",
  24977. "endElement",
  24978. "endElementAt",
  24979. "endOcclusionQuery",
  24980. "endOfPassWriteIndex",
  24981. "endOfStream",
  24982. "endOffset",
  24983. "endQuery",
  24984. "endTime",
  24985. "endTransformFeedback",
  24986. "ended",
  24987. "endpoint",
  24988. "endpointNumber",
  24989. "endpoints",
  24990. "endsWith",
  24991. "enqueue",
  24992. "enterKeyHint",
  24993. "entities",
  24994. "entries",
  24995. "entry",
  24996. "entryPoint",
  24997. "entryType",
  24998. "enumerable",
  24999. "enumerate",
  25000. "enumerateDevices",
  25001. "enumerateEditable",
  25002. "environmentBlendMode",
  25003. "equals",
  25004. "error",
  25005. "errorCode",
  25006. "errorDetail",
  25007. "errorText",
  25008. "escape",
  25009. "estimate",
  25010. "eval",
  25011. "evaluate",
  25012. "event",
  25013. "eventCounts",
  25014. "eventPhase",
  25015. "every",
  25016. "ex",
  25017. "exception",
  25018. "exchange",
  25019. "exec",
  25020. "execCommand",
  25021. "execCommandShowHelp",
  25022. "execScript",
  25023. "executeBundles",
  25024. "executionStart",
  25025. "exitFullscreen",
  25026. "exitPictureInPicture",
  25027. "exitPointerLock",
  25028. "exitPresent",
  25029. "exp",
  25030. "expand",
  25031. "expandEntityReferences",
  25032. "expando",
  25033. "expansion",
  25034. "expectedImprovement",
  25035. "expiration",
  25036. "expirationTime",
  25037. "expires",
  25038. "expiryDate",
  25039. "explicitOriginalTarget",
  25040. "expm1",
  25041. "exponent",
  25042. "exponentialRampToValueAtTime",
  25043. "exportKey",
  25044. "exports",
  25045. "extend",
  25046. "extensions",
  25047. "extentNode",
  25048. "extentOffset",
  25049. "external",
  25050. "externalResourcesRequired",
  25051. "externalTexture",
  25052. "extractContents",
  25053. "extractable",
  25054. "eye",
  25055. "f",
  25056. "face",
  25057. "factoryReset",
  25058. "failOp",
  25059. "failureReason",
  25060. "fallback",
  25061. "family",
  25062. "familyName",
  25063. "farthestViewportElement",
  25064. "fastSeek",
  25065. "fatal",
  25066. "featureId",
  25067. "featurePolicy",
  25068. "featureSettings",
  25069. "features",
  25070. "fence",
  25071. "fenceSync",
  25072. "fetch",
  25073. "fetchPriority",
  25074. "fetchStart",
  25075. "fftSize",
  25076. "fgColor",
  25077. "fieldOfView",
  25078. "file",
  25079. "fileCreatedDate",
  25080. "fileHandle",
  25081. "fileModifiedDate",
  25082. "fileName",
  25083. "fileSize",
  25084. "fileUpdatedDate",
  25085. "filename",
  25086. "files",
  25087. "filesystem",
  25088. "fill",
  25089. "fill-opacity",
  25090. "fill-rule",
  25091. "fillLightMode",
  25092. "fillOpacity",
  25093. "fillRect",
  25094. "fillRule",
  25095. "fillStyle",
  25096. "fillText",
  25097. "filter",
  25098. "filterResX",
  25099. "filterResY",
  25100. "filterUnits",
  25101. "filters",
  25102. "finally",
  25103. "find",
  25104. "findIndex",
  25105. "findLast",
  25106. "findLastIndex",
  25107. "findRule",
  25108. "findText",
  25109. "finish",
  25110. "finished",
  25111. "fireEvent",
  25112. "firesTouchEvents",
  25113. "firstChild",
  25114. "firstElementChild",
  25115. "firstInterimResponseStart",
  25116. "firstPage",
  25117. "firstUIEventTimestamp",
  25118. "fixed",
  25119. "flags",
  25120. "flat",
  25121. "flatMap",
  25122. "flex",
  25123. "flex-basis",
  25124. "flex-direction",
  25125. "flex-flow",
  25126. "flex-grow",
  25127. "flex-shrink",
  25128. "flex-wrap",
  25129. "flexBasis",
  25130. "flexDirection",
  25131. "flexFlow",
  25132. "flexGrow",
  25133. "flexShrink",
  25134. "flexWrap",
  25135. "flipX",
  25136. "flipY",
  25137. "float",
  25138. "float32",
  25139. "float64",
  25140. "flood-color",
  25141. "flood-opacity",
  25142. "floodColor",
  25143. "floodOpacity",
  25144. "floor",
  25145. "flush",
  25146. "focus",
  25147. "focusNode",
  25148. "focusOffset",
  25149. "font",
  25150. "font-family",
  25151. "font-feature-settings",
  25152. "font-kerning",
  25153. "font-language-override",
  25154. "font-optical-sizing",
  25155. "font-palette",
  25156. "font-size",
  25157. "font-size-adjust",
  25158. "font-stretch",
  25159. "font-style",
  25160. "font-synthesis",
  25161. "font-synthesis-position",
  25162. "font-synthesis-small-caps",
  25163. "font-synthesis-style",
  25164. "font-synthesis-weight",
  25165. "font-variant",
  25166. "font-variant-alternates",
  25167. "font-variant-caps",
  25168. "font-variant-east-asian",
  25169. "font-variant-ligatures",
  25170. "font-variant-numeric",
  25171. "font-variant-position",
  25172. "font-variation-settings",
  25173. "font-weight",
  25174. "fontBoundingBoxAscent",
  25175. "fontBoundingBoxDescent",
  25176. "fontFamily",
  25177. "fontFeatureSettings",
  25178. "fontKerning",
  25179. "fontLanguageOverride",
  25180. "fontOpticalSizing",
  25181. "fontPalette",
  25182. "fontSize",
  25183. "fontSizeAdjust",
  25184. "fontSmoothingEnabled",
  25185. "fontStretch",
  25186. "fontStyle",
  25187. "fontSynthesis",
  25188. "fontSynthesisPosition",
  25189. "fontSynthesisSmallCaps",
  25190. "fontSynthesisStyle",
  25191. "fontSynthesisWeight",
  25192. "fontVariant",
  25193. "fontVariantAlternates",
  25194. "fontVariantCaps",
  25195. "fontVariantEastAsian",
  25196. "fontVariantLigatures",
  25197. "fontVariantNumeric",
  25198. "fontVariantPosition",
  25199. "fontVariationSettings",
  25200. "fontWeight",
  25201. "fontcolor",
  25202. "fontfaces",
  25203. "fonts",
  25204. "fontsize",
  25205. "for",
  25206. "forEach",
  25207. "force",
  25208. "forceFallbackAdapter",
  25209. "forceRedraw",
  25210. "forced-color-adjust",
  25211. "forcedColorAdjust",
  25212. "forcedStyleAndLayoutDuration",
  25213. "forget",
  25214. "form",
  25215. "formAction",
  25216. "formData",
  25217. "formEnctype",
  25218. "formMethod",
  25219. "formNoValidate",
  25220. "formTarget",
  25221. "format",
  25222. "formatToParts",
  25223. "forms",
  25224. "forward",
  25225. "forwardX",
  25226. "forwardY",
  25227. "forwardZ",
  25228. "foundation",
  25229. "fr",
  25230. "fragment",
  25231. "fragmentDirective",
  25232. "frame",
  25233. "frameBorder",
  25234. "frameCount",
  25235. "frameElement",
  25236. "frameSpacing",
  25237. "framebuffer",
  25238. "framebufferHeight",
  25239. "framebufferRenderbuffer",
  25240. "framebufferTexture2D",
  25241. "framebufferTextureLayer",
  25242. "framebufferWidth",
  25243. "frames",
  25244. "freeSpace",
  25245. "freeze",
  25246. "frequency",
  25247. "frequencyBinCount",
  25248. "from",
  25249. "fromAsync",
  25250. "fromCharCode",
  25251. "fromCodePoint",
  25252. "fromElement",
  25253. "fromEntries",
  25254. "fromFloat32Array",
  25255. "fromFloat64Array",
  25256. "fromMatrix",
  25257. "fromPoint",
  25258. "fromQuad",
  25259. "fromRect",
  25260. "frontFace",
  25261. "fround",
  25262. "fullName",
  25263. "fullPath",
  25264. "fullRange",
  25265. "fullScreen",
  25266. "fullVersionList",
  25267. "fullscreen",
  25268. "fullscreenElement",
  25269. "fullscreenEnabled",
  25270. "fx",
  25271. "fy",
  25272. "g",
  25273. "gain",
  25274. "gamepad",
  25275. "gamma",
  25276. "gap",
  25277. "gatheringState",
  25278. "gatt",
  25279. "genderIdentity",
  25280. "generateCertificate",
  25281. "generateKey",
  25282. "generateMipmap",
  25283. "generateRequest",
  25284. "geolocation",
  25285. "gestureObject",
  25286. "get",
  25287. "getActiveAttrib",
  25288. "getActiveUniform",
  25289. "getActiveUniformBlockName",
  25290. "getActiveUniformBlockParameter",
  25291. "getActiveUniforms",
  25292. "getAdjacentText",
  25293. "getAll",
  25294. "getAllKeys",
  25295. "getAllResponseHeaders",
  25296. "getAllowlistForFeature",
  25297. "getAnimations",
  25298. "getAsFile",
  25299. "getAsFileSystemHandle",
  25300. "getAsString",
  25301. "getAttachedShaders",
  25302. "getAttribLocation",
  25303. "getAttribute",
  25304. "getAttributeNS",
  25305. "getAttributeNames",
  25306. "getAttributeNode",
  25307. "getAttributeNodeNS",
  25308. "getAttributeType",
  25309. "getAudioTracks",
  25310. "getAuthenticatorData",
  25311. "getAutoplayPolicy",
  25312. "getAvailability",
  25313. "getBBox",
  25314. "getBattery",
  25315. "getBigInt64",
  25316. "getBigUint64",
  25317. "getBindGroupLayout",
  25318. "getBlob",
  25319. "getBookmark",
  25320. "getBoundingClientRect",
  25321. "getBounds",
  25322. "getBoxQuads",
  25323. "getBufferParameter",
  25324. "getBufferSubData",
  25325. "getByteFrequencyData",
  25326. "getByteTimeDomainData",
  25327. "getCSSCanvasContext",
  25328. "getCTM",
  25329. "getCameraImage",
  25330. "getCandidateWindowClientRect",
  25331. "getCanonicalLocales",
  25332. "getCapabilities",
  25333. "getCaptureHandle",
  25334. "getChannelData",
  25335. "getCharNumAtPosition",
  25336. "getCharacteristic",
  25337. "getCharacteristics",
  25338. "getClientExtensionResults",
  25339. "getClientRect",
  25340. "getClientRects",
  25341. "getCoalescedEvents",
  25342. "getCompilationInfo",
  25343. "getCompositionAlternatives",
  25344. "getComputedStyle",
  25345. "getComputedTextLength",
  25346. "getComputedTiming",
  25347. "getConfiguration",
  25348. "getConstraints",
  25349. "getContext",
  25350. "getContextAttributes",
  25351. "getContributingSources",
  25352. "getCounterValue",
  25353. "getCueAsHTML",
  25354. "getCueById",
  25355. "getCurrentPosition",
  25356. "getCurrentTexture",
  25357. "getCurrentTime",
  25358. "getData",
  25359. "getDatabaseNames",
  25360. "getDate",
  25361. "getDay",
  25362. "getDefaultComputedStyle",
  25363. "getDepthInMeters",
  25364. "getDepthInformation",
  25365. "getDescriptor",
  25366. "getDescriptors",
  25367. "getDestinationInsertionPoints",
  25368. "getDevices",
  25369. "getDirectory",
  25370. "getDirectoryHandle",
  25371. "getDisplayMedia",
  25372. "getDistributedNodes",
  25373. "getEditable",
  25374. "getElementById",
  25375. "getElementsByClassName",
  25376. "getElementsByName",
  25377. "getElementsByTagName",
  25378. "getElementsByTagNameNS",
  25379. "getEnclosureList",
  25380. "getEndPositionOfChar",
  25381. "getEntries",
  25382. "getEntriesByName",
  25383. "getEntriesByType",
  25384. "getError",
  25385. "getExtension",
  25386. "getExtentOfChar",
  25387. "getEyeParameters",
  25388. "getFeature",
  25389. "getFiberRoots",
  25390. "getFile",
  25391. "getFileHandle",
  25392. "getFiles",
  25393. "getFilesAndDirectories",
  25394. "getFingerprints",
  25395. "getFloat32",
  25396. "getFloat64",
  25397. "getFloatFrequencyData",
  25398. "getFloatTimeDomainData",
  25399. "getFloatValue",
  25400. "getFragDataLocation",
  25401. "getFrameData",
  25402. "getFramebufferAttachmentParameter",
  25403. "getFrequencyResponse",
  25404. "getFullYear",
  25405. "getGamepads",
  25406. "getHeaderExtensionsToNegotiate",
  25407. "getHighEntropyValues",
  25408. "getHitTestResults",
  25409. "getHitTestResultsForTransientInput",
  25410. "getHours",
  25411. "getIdentityAssertion",
  25412. "getIds",
  25413. "getImageData",
  25414. "getIndexedParameter",
  25415. "getInfo",
  25416. "getInnerHTML",
  25417. "getInstalledRelatedApps",
  25418. "getInt16",
  25419. "getInt32",
  25420. "getInt8",
  25421. "getInternalModuleRanges",
  25422. "getInternalformatParameter",
  25423. "getIntersectionList",
  25424. "getItem",
  25425. "getItems",
  25426. "getKey",
  25427. "getKeyframes",
  25428. "getLayers",
  25429. "getLayoutMap",
  25430. "getLightEstimate",
  25431. "getLineDash",
  25432. "getLocalCandidates",
  25433. "getLocalParameters",
  25434. "getLocalStreams",
  25435. "getManagedConfiguration",
  25436. "getMappedRange",
  25437. "getMarks",
  25438. "getMatchedCSSRules",
  25439. "getMaxGCPauseSinceClear",
  25440. "getMeasures",
  25441. "getMetadata",
  25442. "getMilliseconds",
  25443. "getMinutes",
  25444. "getModifierState",
  25445. "getMonth",
  25446. "getName",
  25447. "getNamedItem",
  25448. "getNamedItemNS",
  25449. "getNativeFramebufferScaleFactor",
  25450. "getNegotiatedHeaderExtensions",
  25451. "getNestedConfigs",
  25452. "getNotifications",
  25453. "getNotifier",
  25454. "getNumberOfChars",
  25455. "getOffsetReferenceSpace",
  25456. "getOutputTimestamp",
  25457. "getOverrideHistoryNavigationMode",
  25458. "getOverrideStyle",
  25459. "getOwnPropertyDescriptor",
  25460. "getOwnPropertyDescriptors",
  25461. "getOwnPropertyNames",
  25462. "getOwnPropertySymbols",
  25463. "getParameter",
  25464. "getParameters",
  25465. "getParent",
  25466. "getPathSegAtLength",
  25467. "getPhotoCapabilities",
  25468. "getPhotoSettings",
  25469. "getPointAtLength",
  25470. "getPorts",
  25471. "getPose",
  25472. "getPredictedEvents",
  25473. "getPreference",
  25474. "getPreferenceDefault",
  25475. "getPreferredCanvasFormat",
  25476. "getPresentationAttribute",
  25477. "getPreventDefault",
  25478. "getPrimaryService",
  25479. "getPrimaryServices",
  25480. "getProgramInfoLog",
  25481. "getProgramParameter",
  25482. "getPropertyCSSValue",
  25483. "getPropertyPriority",
  25484. "getPropertyShorthand",
  25485. "getPropertyType",
  25486. "getPropertyValue",
  25487. "getPrototypeOf",
  25488. "getPublicKey",
  25489. "getPublicKeyAlgorithm",
  25490. "getQuery",
  25491. "getQueryParameter",
  25492. "getRGBColorValue",
  25493. "getRandomValues",
  25494. "getRangeAt",
  25495. "getReader",
  25496. "getReceivers",
  25497. "getRectValue",
  25498. "getReflectionCubeMap",
  25499. "getRegistration",
  25500. "getRegistrations",
  25501. "getRemoteCandidates",
  25502. "getRemoteCertificates",
  25503. "getRemoteParameters",
  25504. "getRemoteStreams",
  25505. "getRenderbufferParameter",
  25506. "getResponseHeader",
  25507. "getRoot",
  25508. "getRootNode",
  25509. "getRotationOfChar",
  25510. "getSVGDocument",
  25511. "getSamplerParameter",
  25512. "getScreenCTM",
  25513. "getScreenDetails",
  25514. "getSeconds",
  25515. "getSelectedCandidatePair",
  25516. "getSelection",
  25517. "getSenders",
  25518. "getService",
  25519. "getSetCookie",
  25520. "getSettings",
  25521. "getShaderInfoLog",
  25522. "getShaderParameter",
  25523. "getShaderPrecisionFormat",
  25524. "getShaderSource",
  25525. "getSignals",
  25526. "getSimpleDuration",
  25527. "getSiteIcons",
  25528. "getSources",
  25529. "getSpeculativeParserUrls",
  25530. "getStartPositionOfChar",
  25531. "getStartTime",
  25532. "getState",
  25533. "getStats",
  25534. "getStatusForPolicy",
  25535. "getStorageUpdates",
  25536. "getStreamById",
  25537. "getStringValue",
  25538. "getSubStringLength",
  25539. "getSubscription",
  25540. "getSubscriptions",
  25541. "getSupportedConstraints",
  25542. "getSupportedExtensions",
  25543. "getSupportedFormats",
  25544. "getSyncParameter",
  25545. "getSynchronizationSources",
  25546. "getTags",
  25547. "getTargetRanges",
  25548. "getTexParameter",
  25549. "getTextFormats",
  25550. "getTime",
  25551. "getTimezoneOffset",
  25552. "getTiming",
  25553. "getTitlebarAreaRect",
  25554. "getTotalLength",
  25555. "getTrackById",
  25556. "getTracks",
  25557. "getTransceivers",
  25558. "getTransform",
  25559. "getTransformFeedbackVarying",
  25560. "getTransformToElement",
  25561. "getTransports",
  25562. "getType",
  25563. "getTypeMapping",
  25564. "getUTCDate",
  25565. "getUTCDay",
  25566. "getUTCFullYear",
  25567. "getUTCHours",
  25568. "getUTCMilliseconds",
  25569. "getUTCMinutes",
  25570. "getUTCMonth",
  25571. "getUTCSeconds",
  25572. "getUint16",
  25573. "getUint32",
  25574. "getUint8",
  25575. "getUniform",
  25576. "getUniformBlockIndex",
  25577. "getUniformIndices",
  25578. "getUniformLocation",
  25579. "getUserInfo",
  25580. "getUserMedia",
  25581. "getVRDisplays",
  25582. "getValues",
  25583. "getVarDate",
  25584. "getVariableValue",
  25585. "getVertexAttrib",
  25586. "getVertexAttribOffset",
  25587. "getVideoPlaybackQuality",
  25588. "getVideoTracks",
  25589. "getViewerPose",
  25590. "getViewport",
  25591. "getVoices",
  25592. "getWakeLockState",
  25593. "getWriter",
  25594. "getYear",
  25595. "givenName",
  25596. "global",
  25597. "globalAlpha",
  25598. "globalCompositeOperation",
  25599. "globalPrivacyControl",
  25600. "globalThis",
  25601. "glyphOrientationHorizontal",
  25602. "glyphOrientationVertical",
  25603. "glyphRef",
  25604. "go",
  25605. "gpu",
  25606. "grabFrame",
  25607. "grad",
  25608. "gradientTransform",
  25609. "gradientUnits",
  25610. "grammars",
  25611. "green",
  25612. "grid",
  25613. "grid-area",
  25614. "grid-auto-columns",
  25615. "grid-auto-flow",
  25616. "grid-auto-rows",
  25617. "grid-column",
  25618. "grid-column-end",
  25619. "grid-column-gap",
  25620. "grid-column-start",
  25621. "grid-gap",
  25622. "grid-row",
  25623. "grid-row-end",
  25624. "grid-row-gap",
  25625. "grid-row-start",
  25626. "grid-template",
  25627. "grid-template-areas",
  25628. "grid-template-columns",
  25629. "grid-template-rows",
  25630. "gridArea",
  25631. "gridAutoColumns",
  25632. "gridAutoFlow",
  25633. "gridAutoRows",
  25634. "gridColumn",
  25635. "gridColumnEnd",
  25636. "gridColumnGap",
  25637. "gridColumnStart",
  25638. "gridGap",
  25639. "gridRow",
  25640. "gridRowEnd",
  25641. "gridRowGap",
  25642. "gridRowStart",
  25643. "gridTemplate",
  25644. "gridTemplateAreas",
  25645. "gridTemplateColumns",
  25646. "gridTemplateRows",
  25647. "gripSpace",
  25648. "group",
  25649. "groupBy",
  25650. "groupCollapsed",
  25651. "groupEnd",
  25652. "groupId",
  25653. "groups",
  25654. "hadRecentInput",
  25655. "hand",
  25656. "handedness",
  25657. "hangingBaseline",
  25658. "hapticActuators",
  25659. "hardwareConcurrency",
  25660. "has",
  25661. "hasAttribute",
  25662. "hasAttributeNS",
  25663. "hasAttributes",
  25664. "hasBeenActive",
  25665. "hasChildNodes",
  25666. "hasComposition",
  25667. "hasDynamicOffset",
  25668. "hasEnrolledInstrument",
  25669. "hasExtension",
  25670. "hasExternalDisplay",
  25671. "hasFeature",
  25672. "hasFocus",
  25673. "hasIndices",
  25674. "hasInstance",
  25675. "hasLayout",
  25676. "hasOrientation",
  25677. "hasOwn",
  25678. "hasOwnProperty",
  25679. "hasPointerCapture",
  25680. "hasPosition",
  25681. "hasPrivateToken",
  25682. "hasReading",
  25683. "hasRedemptionRecord",
  25684. "hasRegExpGroups",
  25685. "hasStorageAccess",
  25686. "hasUAVisualTransition",
  25687. "hash",
  25688. "hashChange",
  25689. "head",
  25690. "headers",
  25691. "heading",
  25692. "height",
  25693. "hid",
  25694. "hidden",
  25695. "hide",
  25696. "hideFocus",
  25697. "hidePopover",
  25698. "high",
  25699. "highWaterMark",
  25700. "highlights",
  25701. "hint",
  25702. "hints",
  25703. "history",
  25704. "honorificPrefix",
  25705. "honorificSuffix",
  25706. "horizontalOverflow",
  25707. "host",
  25708. "hostCandidate",
  25709. "hostname",
  25710. "href",
  25711. "hrefTranslate",
  25712. "hreflang",
  25713. "hspace",
  25714. "html5TagCheckInerface",
  25715. "htmlFor",
  25716. "htmlText",
  25717. "httpEquiv",
  25718. "httpRequestStatusCode",
  25719. "hwTimestamp",
  25720. "hyphenate-character",
  25721. "hyphenateCharacter",
  25722. "hyphens",
  25723. "hypot",
  25724. "ic",
  25725. "iccId",
  25726. "iceConnectionState",
  25727. "iceGatheringState",
  25728. "iceTransport",
  25729. "icon",
  25730. "iconURL",
  25731. "id",
  25732. "identifier",
  25733. "identity",
  25734. "ideographicBaseline",
  25735. "idpLoginUrl",
  25736. "ignoreBOM",
  25737. "ignoreCase",
  25738. "ignoreDepthValues",
  25739. "image",
  25740. "image-orientation",
  25741. "image-rendering",
  25742. "imageHeight",
  25743. "imageOrientation",
  25744. "imageRendering",
  25745. "imageSizes",
  25746. "imageSmoothingEnabled",
  25747. "imageSmoothingQuality",
  25748. "imageSrcset",
  25749. "imageWidth",
  25750. "images",
  25751. "ime-mode",
  25752. "imeMode",
  25753. "implementation",
  25754. "importExternalTexture",
  25755. "importKey",
  25756. "importNode",
  25757. "importStylesheet",
  25758. "imports",
  25759. "impp",
  25760. "imul",
  25761. "in",
  25762. "in1",
  25763. "in2",
  25764. "inBandMetadataTrackDispatchType",
  25765. "inRange",
  25766. "includes",
  25767. "incomingBidirectionalStreams",
  25768. "incomingHighWaterMark",
  25769. "incomingMaxAge",
  25770. "incomingUnidirectionalStreams",
  25771. "incremental",
  25772. "indeterminate",
  25773. "index",
  25774. "indexNames",
  25775. "indexOf",
  25776. "indexedDB",
  25777. "indicate",
  25778. "indices",
  25779. "inert",
  25780. "inertiaDestinationX",
  25781. "inertiaDestinationY",
  25782. "info",
  25783. "inherits",
  25784. "init",
  25785. "initAnimationEvent",
  25786. "initBeforeLoadEvent",
  25787. "initClipboardEvent",
  25788. "initCloseEvent",
  25789. "initCommandEvent",
  25790. "initCompositionEvent",
  25791. "initCustomEvent",
  25792. "initData",
  25793. "initDataType",
  25794. "initDeviceMotionEvent",
  25795. "initDeviceOrientationEvent",
  25796. "initDragEvent",
  25797. "initErrorEvent",
  25798. "initEvent",
  25799. "initFocusEvent",
  25800. "initGestureEvent",
  25801. "initHashChangeEvent",
  25802. "initKeyEvent",
  25803. "initKeyboardEvent",
  25804. "initMSManipulationEvent",
  25805. "initMessageEvent",
  25806. "initMouseEvent",
  25807. "initMouseScrollEvent",
  25808. "initMouseWheelEvent",
  25809. "initMutationEvent",
  25810. "initNSMouseEvent",
  25811. "initOverflowEvent",
  25812. "initPageEvent",
  25813. "initPageTransitionEvent",
  25814. "initPointerEvent",
  25815. "initPopStateEvent",
  25816. "initProgressEvent",
  25817. "initScrollAreaEvent",
  25818. "initSimpleGestureEvent",
  25819. "initStorageEvent",
  25820. "initTextEvent",
  25821. "initTimeEvent",
  25822. "initTouchEvent",
  25823. "initTransitionEvent",
  25824. "initUIEvent",
  25825. "initWebKitAnimationEvent",
  25826. "initWebKitTransitionEvent",
  25827. "initWebKitWheelEvent",
  25828. "initWheelEvent",
  25829. "initialTime",
  25830. "initialValue",
  25831. "initialize",
  25832. "initiatorType",
  25833. "inject",
  25834. "ink",
  25835. "inline-size",
  25836. "inlineSize",
  25837. "inlineVerticalFieldOfView",
  25838. "inner",
  25839. "innerHTML",
  25840. "innerHeight",
  25841. "innerText",
  25842. "innerWidth",
  25843. "input",
  25844. "inputBuffer",
  25845. "inputEncoding",
  25846. "inputMethod",
  25847. "inputMode",
  25848. "inputSource",
  25849. "inputSources",
  25850. "inputType",
  25851. "inputs",
  25852. "insertAdjacentElement",
  25853. "insertAdjacentHTML",
  25854. "insertAdjacentText",
  25855. "insertBefore",
  25856. "insertCell",
  25857. "insertDTMF",
  25858. "insertData",
  25859. "insertDebugMarker",
  25860. "insertItemBefore",
  25861. "insertNode",
  25862. "insertRow",
  25863. "insertRule",
  25864. "inset",
  25865. "inset-block",
  25866. "inset-block-end",
  25867. "inset-block-start",
  25868. "inset-inline",
  25869. "inset-inline-end",
  25870. "inset-inline-start",
  25871. "insetBlock",
  25872. "insetBlockEnd",
  25873. "insetBlockStart",
  25874. "insetInline",
  25875. "insetInlineEnd",
  25876. "insetInlineStart",
  25877. "installing",
  25878. "instanceRoot",
  25879. "instantiate",
  25880. "instantiateStreaming",
  25881. "instruments",
  25882. "int16",
  25883. "int32",
  25884. "int8",
  25885. "integrity",
  25886. "interactionId",
  25887. "interactionMode",
  25888. "intercept",
  25889. "interfaceClass",
  25890. "interfaceName",
  25891. "interfaceNumber",
  25892. "interfaceProtocol",
  25893. "interfaceSubclass",
  25894. "interfaces",
  25895. "interimResults",
  25896. "internalSubset",
  25897. "interpretation",
  25898. "intersection",
  25899. "intersectionRatio",
  25900. "intersectionRect",
  25901. "intersectsNode",
  25902. "interval",
  25903. "invalidIteratorState",
  25904. "invalidateFramebuffer",
  25905. "invalidateSubFramebuffer",
  25906. "inverse",
  25907. "invertSelf",
  25908. "invoker",
  25909. "invokerType",
  25910. "is",
  25911. "is2D",
  25912. "isActive",
  25913. "isAlternate",
  25914. "isArray",
  25915. "isAutoSelected",
  25916. "isBingCurrentSearchDefault",
  25917. "isBuffer",
  25918. "isCandidateWindowVisible",
  25919. "isChar",
  25920. "isCollapsed",
  25921. "isComposing",
  25922. "isConcatSpreadable",
  25923. "isConditionalMediationAvailable",
  25924. "isConfigSupported",
  25925. "isConnected",
  25926. "isContentEditable",
  25927. "isContentHandlerRegistered",
  25928. "isContextLost",
  25929. "isDefaultNamespace",
  25930. "isDirectory",
  25931. "isDisabled",
  25932. "isDisjointFrom",
  25933. "isEnabled",
  25934. "isEqual",
  25935. "isEqualNode",
  25936. "isExtended",
  25937. "isExtensible",
  25938. "isExternalCTAP2SecurityKeySupported",
  25939. "isFallbackAdapter",
  25940. "isFile",
  25941. "isFinite",
  25942. "isFirstPersonObserver",
  25943. "isFramebuffer",
  25944. "isFrozen",
  25945. "isGenerator",
  25946. "isHTML",
  25947. "isHistoryNavigation",
  25948. "isId",
  25949. "isIdentity",
  25950. "isInjected",
  25951. "isInputPending",
  25952. "isInteger",
  25953. "isInternal",
  25954. "isIntersecting",
  25955. "isLockFree",
  25956. "isMap",
  25957. "isMultiLine",
  25958. "isNaN",
  25959. "isOpen",
  25960. "isPointInFill",
  25961. "isPointInPath",
  25962. "isPointInRange",
  25963. "isPointInStroke",
  25964. "isPrefAlternate",
  25965. "isPresenting",
  25966. "isPrimary",
  25967. "isProgram",
  25968. "isPropertyImplicit",
  25969. "isProtocolHandlerRegistered",
  25970. "isPrototypeOf",
  25971. "isQuery",
  25972. "isRawJSON",
  25973. "isRenderbuffer",
  25974. "isSafeInteger",
  25975. "isSameEntry",
  25976. "isSameNode",
  25977. "isSampler",
  25978. "isScript",
  25979. "isScriptURL",
  25980. "isSealed",
  25981. "isSecureContext",
  25982. "isSessionSupported",
  25983. "isShader",
  25984. "isSubsetOf",
  25985. "isSupersetOf",
  25986. "isSupported",
  25987. "isSync",
  25988. "isTextEdit",
  25989. "isTexture",
  25990. "isTransformFeedback",
  25991. "isTrusted",
  25992. "isTypeSupported",
  25993. "isUserVerifyingPlatformAuthenticatorAvailable",
  25994. "isVertexArray",
  25995. "isView",
  25996. "isVisible",
  25997. "isWellFormed",
  25998. "isochronousTransferIn",
  25999. "isochronousTransferOut",
  26000. "isolation",
  26001. "italics",
  26002. "item",
  26003. "itemId",
  26004. "itemProp",
  26005. "itemRef",
  26006. "itemScope",
  26007. "itemType",
  26008. "itemValue",
  26009. "items",
  26010. "iterateNext",
  26011. "iterationComposite",
  26012. "iterator",
  26013. "javaEnabled",
  26014. "jitterBufferTarget",
  26015. "jobTitle",
  26016. "join",
  26017. "joinAdInterestGroup",
  26018. "json",
  26019. "justify-content",
  26020. "justify-items",
  26021. "justify-self",
  26022. "justifyContent",
  26023. "justifyItems",
  26024. "justifySelf",
  26025. "k1",
  26026. "k2",
  26027. "k3",
  26028. "k4",
  26029. "kHz",
  26030. "keepalive",
  26031. "kernelMatrix",
  26032. "kernelUnitLengthX",
  26033. "kernelUnitLengthY",
  26034. "kerning",
  26035. "key",
  26036. "keyCode",
  26037. "keyFor",
  26038. "keyIdentifier",
  26039. "keyLightEnabled",
  26040. "keyLocation",
  26041. "keyPath",
  26042. "keyStatuses",
  26043. "keySystem",
  26044. "keyText",
  26045. "keyUsage",
  26046. "keyboard",
  26047. "keys",
  26048. "keytype",
  26049. "kind",
  26050. "knee",
  26051. "label",
  26052. "labels",
  26053. "lang",
  26054. "language",
  26055. "languages",
  26056. "largeArcFlag",
  26057. "lastChild",
  26058. "lastElementChild",
  26059. "lastEventId",
  26060. "lastIndex",
  26061. "lastIndexOf",
  26062. "lastInputTime",
  26063. "lastMatch",
  26064. "lastMessageSubject",
  26065. "lastMessageType",
  26066. "lastModified",
  26067. "lastModifiedDate",
  26068. "lastPage",
  26069. "lastParen",
  26070. "lastState",
  26071. "lastStyleSheetSet",
  26072. "latitude",
  26073. "launchQueue",
  26074. "layerName",
  26075. "layerX",
  26076. "layerY",
  26077. "layout",
  26078. "layoutFlow",
  26079. "layoutGrid",
  26080. "layoutGridChar",
  26081. "layoutGridLine",
  26082. "layoutGridMode",
  26083. "layoutGridType",
  26084. "lbound",
  26085. "leaveAdInterestGroup",
  26086. "left",
  26087. "leftContext",
  26088. "leftDegrees",
  26089. "leftMargin",
  26090. "leftProjectionMatrix",
  26091. "leftViewMatrix",
  26092. "length",
  26093. "lengthAdjust",
  26094. "lengthComputable",
  26095. "letter-spacing",
  26096. "letterSpacing",
  26097. "level",
  26098. "lh",
  26099. "lighting-color",
  26100. "lightingColor",
  26101. "limitingConeAngle",
  26102. "limits",
  26103. "line",
  26104. "line-break",
  26105. "line-height",
  26106. "lineAlign",
  26107. "lineBreak",
  26108. "lineCap",
  26109. "lineDashOffset",
  26110. "lineGapOverride",
  26111. "lineHeight",
  26112. "lineJoin",
  26113. "lineNum",
  26114. "lineNumber",
  26115. "linePos",
  26116. "lineTo",
  26117. "lineWidth",
  26118. "linearAcceleration",
  26119. "linearRampToValueAtTime",
  26120. "linearVelocity",
  26121. "lineno",
  26122. "lines",
  26123. "link",
  26124. "linkColor",
  26125. "linkProgram",
  26126. "links",
  26127. "list",
  26128. "list-style",
  26129. "list-style-image",
  26130. "list-style-position",
  26131. "list-style-type",
  26132. "listStyle",
  26133. "listStyleImage",
  26134. "listStylePosition",
  26135. "listStyleType",
  26136. "listener",
  26137. "listeners",
  26138. "load",
  26139. "loadEventEnd",
  26140. "loadEventStart",
  26141. "loadOp",
  26142. "loadTime",
  26143. "loadTimes",
  26144. "loaded",
  26145. "loading",
  26146. "localDescription",
  26147. "localName",
  26148. "localService",
  26149. "localStorage",
  26150. "locale",
  26151. "localeCompare",
  26152. "location",
  26153. "locationbar",
  26154. "lock",
  26155. "locked",
  26156. "lockedFile",
  26157. "locks",
  26158. "lodMaxClamp",
  26159. "lodMinClamp",
  26160. "log",
  26161. "log10",
  26162. "log1p",
  26163. "log2",
  26164. "logicalXDPI",
  26165. "logicalYDPI",
  26166. "login",
  26167. "loglevel",
  26168. "longDesc",
  26169. "longitude",
  26170. "lookupNamespaceURI",
  26171. "lookupPrefix",
  26172. "loop",
  26173. "loopEnd",
  26174. "loopStart",
  26175. "looping",
  26176. "lost",
  26177. "low",
  26178. "lower",
  26179. "lowerBound",
  26180. "lowerOpen",
  26181. "lowsrc",
  26182. "lvb",
  26183. "lvh",
  26184. "lvi",
  26185. "lvmax",
  26186. "lvmin",
  26187. "lvw",
  26188. "m11",
  26189. "m12",
  26190. "m13",
  26191. "m14",
  26192. "m21",
  26193. "m22",
  26194. "m23",
  26195. "m24",
  26196. "m31",
  26197. "m32",
  26198. "m33",
  26199. "m34",
  26200. "m41",
  26201. "m42",
  26202. "m43",
  26203. "m44",
  26204. "magFilter",
  26205. "makeXRCompatible",
  26206. "managed",
  26207. "manifest",
  26208. "manufacturer",
  26209. "manufacturerName",
  26210. "map",
  26211. "mapAsync",
  26212. "mapState",
  26213. "mappedAtCreation",
  26214. "mapping",
  26215. "margin",
  26216. "margin-block",
  26217. "margin-block-end",
  26218. "margin-block-start",
  26219. "margin-bottom",
  26220. "margin-inline",
  26221. "margin-inline-end",
  26222. "margin-inline-start",
  26223. "margin-left",
  26224. "margin-right",
  26225. "margin-top",
  26226. "marginBlock",
  26227. "marginBlockEnd",
  26228. "marginBlockStart",
  26229. "marginBottom",
  26230. "marginHeight",
  26231. "marginInline",
  26232. "marginInlineEnd",
  26233. "marginInlineStart",
  26234. "marginLeft",
  26235. "marginRight",
  26236. "marginTop",
  26237. "marginWidth",
  26238. "mark",
  26239. "marker",
  26240. "marker-end",
  26241. "marker-mid",
  26242. "marker-offset",
  26243. "marker-start",
  26244. "markerEnd",
  26245. "markerHeight",
  26246. "markerMid",
  26247. "markerOffset",
  26248. "markerStart",
  26249. "markerUnits",
  26250. "markerWidth",
  26251. "marks",
  26252. "mask",
  26253. "mask-clip",
  26254. "mask-composite",
  26255. "mask-image",
  26256. "mask-mode",
  26257. "mask-origin",
  26258. "mask-position",
  26259. "mask-position-x",
  26260. "mask-position-y",
  26261. "mask-repeat",
  26262. "mask-size",
  26263. "mask-type",
  26264. "maskClip",
  26265. "maskComposite",
  26266. "maskContentUnits",
  26267. "maskImage",
  26268. "maskMode",
  26269. "maskOrigin",
  26270. "maskPosition",
  26271. "maskPositionX",
  26272. "maskPositionY",
  26273. "maskRepeat",
  26274. "maskSize",
  26275. "maskType",
  26276. "maskUnits",
  26277. "match",
  26278. "matchAll",
  26279. "matchMedia",
  26280. "matchMedium",
  26281. "matches",
  26282. "math-depth",
  26283. "math-style",
  26284. "mathDepth",
  26285. "mathStyle",
  26286. "matrix",
  26287. "matrixTransform",
  26288. "max",
  26289. "max-block-size",
  26290. "max-height",
  26291. "max-inline-size",
  26292. "max-width",
  26293. "maxActions",
  26294. "maxAlternatives",
  26295. "maxAnisotropy",
  26296. "maxBindGroups",
  26297. "maxBindGroupsPlusVertexBuffers",
  26298. "maxBindingsPerBindGroup",
  26299. "maxBlockSize",
  26300. "maxBufferSize",
  26301. "maxByteLength",
  26302. "maxChannelCount",
  26303. "maxChannels",
  26304. "maxColorAttachmentBytesPerSample",
  26305. "maxColorAttachments",
  26306. "maxComputeInvocationsPerWorkgroup",
  26307. "maxComputeWorkgroupSizeX",
  26308. "maxComputeWorkgroupSizeY",
  26309. "maxComputeWorkgroupSizeZ",
  26310. "maxComputeWorkgroupStorageSize",
  26311. "maxComputeWorkgroupsPerDimension",
  26312. "maxConnectionsPerServer",
  26313. "maxDatagramSize",
  26314. "maxDecibels",
  26315. "maxDistance",
  26316. "maxDrawCount",
  26317. "maxDynamicStorageBuffersPerPipelineLayout",
  26318. "maxDynamicUniformBuffersPerPipelineLayout",
  26319. "maxHeight",
  26320. "maxInlineSize",
  26321. "maxInterStageShaderComponents",
  26322. "maxInterStageShaderVariables",
  26323. "maxLayers",
  26324. "maxLength",
  26325. "maxMessageSize",
  26326. "maxPacketLifeTime",
  26327. "maxRetransmits",
  26328. "maxSampledTexturesPerShaderStage",
  26329. "maxSamplersPerShaderStage",
  26330. "maxStorageBufferBindingSize",
  26331. "maxStorageBuffersPerShaderStage",
  26332. "maxStorageTexturesPerShaderStage",
  26333. "maxTextureArrayLayers",
  26334. "maxTextureDimension1D",
  26335. "maxTextureDimension2D",
  26336. "maxTextureDimension3D",
  26337. "maxTouchPoints",
  26338. "maxUniformBufferBindingSize",
  26339. "maxUniformBuffersPerShaderStage",
  26340. "maxValue",
  26341. "maxVertexAttributes",
  26342. "maxVertexBufferArrayStride",
  26343. "maxVertexBuffers",
  26344. "maxWidth",
  26345. "measure",
  26346. "measureText",
  26347. "media",
  26348. "mediaCapabilities",
  26349. "mediaDevices",
  26350. "mediaElement",
  26351. "mediaGroup",
  26352. "mediaKeys",
  26353. "mediaSession",
  26354. "mediaStream",
  26355. "mediaText",
  26356. "meetOrSlice",
  26357. "memory",
  26358. "menubar",
  26359. "mergeAttributes",
  26360. "message",
  26361. "messageClass",
  26362. "messageHandlers",
  26363. "messageType",
  26364. "messages",
  26365. "metaKey",
  26366. "metadata",
  26367. "method",
  26368. "methodDetails",
  26369. "methodName",
  26370. "mid",
  26371. "mimeType",
  26372. "mimeTypes",
  26373. "min",
  26374. "min-block-size",
  26375. "min-height",
  26376. "min-inline-size",
  26377. "min-width",
  26378. "minBindingSize",
  26379. "minBlockSize",
  26380. "minDecibels",
  26381. "minFilter",
  26382. "minHeight",
  26383. "minInlineSize",
  26384. "minLength",
  26385. "minStorageBufferOffsetAlignment",
  26386. "minUniformBufferOffsetAlignment",
  26387. "minValue",
  26388. "minWidth",
  26389. "mipLevel",
  26390. "mipLevelCount",
  26391. "mipmapFilter",
  26392. "miterLimit",
  26393. "mix-blend-mode",
  26394. "mixBlendMode",
  26395. "mm",
  26396. "mobile",
  26397. "mode",
  26398. "model",
  26399. "modify",
  26400. "module",
  26401. "mount",
  26402. "move",
  26403. "moveBy",
  26404. "moveEnd",
  26405. "moveFirst",
  26406. "moveFocusDown",
  26407. "moveFocusLeft",
  26408. "moveFocusRight",
  26409. "moveFocusUp",
  26410. "moveNext",
  26411. "moveRow",
  26412. "moveStart",
  26413. "moveTo",
  26414. "moveToBookmark",
  26415. "moveToElementText",
  26416. "moveToPoint",
  26417. "movementX",
  26418. "movementY",
  26419. "mozAdd",
  26420. "mozAnimationStartTime",
  26421. "mozAnon",
  26422. "mozApps",
  26423. "mozAudioCaptured",
  26424. "mozAudioChannelType",
  26425. "mozAutoplayEnabled",
  26426. "mozCancelAnimationFrame",
  26427. "mozCancelFullScreen",
  26428. "mozCancelRequestAnimationFrame",
  26429. "mozCaptureStream",
  26430. "mozCaptureStreamUntilEnded",
  26431. "mozClearDataAt",
  26432. "mozContact",
  26433. "mozContacts",
  26434. "mozCreateFileHandle",
  26435. "mozCurrentTransform",
  26436. "mozCurrentTransformInverse",
  26437. "mozCursor",
  26438. "mozDash",
  26439. "mozDashOffset",
  26440. "mozDecodedFrames",
  26441. "mozExitPointerLock",
  26442. "mozFillRule",
  26443. "mozFragmentEnd",
  26444. "mozFrameDelay",
  26445. "mozFullScreen",
  26446. "mozFullScreenElement",
  26447. "mozFullScreenEnabled",
  26448. "mozGetAll",
  26449. "mozGetAllKeys",
  26450. "mozGetAsFile",
  26451. "mozGetDataAt",
  26452. "mozGetMetadata",
  26453. "mozGetUserMedia",
  26454. "mozHasAudio",
  26455. "mozHasItem",
  26456. "mozHidden",
  26457. "mozImageSmoothingEnabled",
  26458. "mozIndexedDB",
  26459. "mozInnerScreenX",
  26460. "mozInnerScreenY",
  26461. "mozInputSource",
  26462. "mozIsTextField",
  26463. "mozItem",
  26464. "mozItemCount",
  26465. "mozItems",
  26466. "mozLength",
  26467. "mozLockOrientation",
  26468. "mozMatchesSelector",
  26469. "mozMovementX",
  26470. "mozMovementY",
  26471. "mozOpaque",
  26472. "mozOrientation",
  26473. "mozPaintCount",
  26474. "mozPaintedFrames",
  26475. "mozParsedFrames",
  26476. "mozPay",
  26477. "mozPointerLockElement",
  26478. "mozPresentedFrames",
  26479. "mozPreservesPitch",
  26480. "mozPressure",
  26481. "mozPrintCallback",
  26482. "mozRTCIceCandidate",
  26483. "mozRTCPeerConnection",
  26484. "mozRTCSessionDescription",
  26485. "mozRemove",
  26486. "mozRequestAnimationFrame",
  26487. "mozRequestFullScreen",
  26488. "mozRequestPointerLock",
  26489. "mozSetDataAt",
  26490. "mozSetImageElement",
  26491. "mozSourceNode",
  26492. "mozSrcObject",
  26493. "mozSystem",
  26494. "mozTCPSocket",
  26495. "mozTextStyle",
  26496. "mozTypesAt",
  26497. "mozUnlockOrientation",
  26498. "mozUserCancelled",
  26499. "mozVisibilityState",
  26500. "ms",
  26501. "msAnimation",
  26502. "msAnimationDelay",
  26503. "msAnimationDirection",
  26504. "msAnimationDuration",
  26505. "msAnimationFillMode",
  26506. "msAnimationIterationCount",
  26507. "msAnimationName",
  26508. "msAnimationPlayState",
  26509. "msAnimationStartTime",
  26510. "msAnimationTimingFunction",
  26511. "msBackfaceVisibility",
  26512. "msBlockProgression",
  26513. "msCSSOMElementFloatMetrics",
  26514. "msCaching",
  26515. "msCachingEnabled",
  26516. "msCancelRequestAnimationFrame",
  26517. "msCapsLockWarningOff",
  26518. "msClearImmediate",
  26519. "msClose",
  26520. "msContentZoomChaining",
  26521. "msContentZoomFactor",
  26522. "msContentZoomLimit",
  26523. "msContentZoomLimitMax",
  26524. "msContentZoomLimitMin",
  26525. "msContentZoomSnap",
  26526. "msContentZoomSnapPoints",
  26527. "msContentZoomSnapType",
  26528. "msContentZooming",
  26529. "msConvertURL",
  26530. "msCrypto",
  26531. "msDoNotTrack",
  26532. "msElementsFromPoint",
  26533. "msElementsFromRect",
  26534. "msExitFullscreen",
  26535. "msExtendedCode",
  26536. "msFillRule",
  26537. "msFirstPaint",
  26538. "msFlex",
  26539. "msFlexAlign",
  26540. "msFlexDirection",
  26541. "msFlexFlow",
  26542. "msFlexItemAlign",
  26543. "msFlexLinePack",
  26544. "msFlexNegative",
  26545. "msFlexOrder",
  26546. "msFlexPack",
  26547. "msFlexPositive",
  26548. "msFlexPreferredSize",
  26549. "msFlexWrap",
  26550. "msFlowFrom",
  26551. "msFlowInto",
  26552. "msFontFeatureSettings",
  26553. "msFullscreenElement",
  26554. "msFullscreenEnabled",
  26555. "msGetInputContext",
  26556. "msGetRegionContent",
  26557. "msGetUntransformedBounds",
  26558. "msGraphicsTrustStatus",
  26559. "msGridColumn",
  26560. "msGridColumnAlign",
  26561. "msGridColumnSpan",
  26562. "msGridColumns",
  26563. "msGridRow",
  26564. "msGridRowAlign",
  26565. "msGridRowSpan",
  26566. "msGridRows",
  26567. "msHidden",
  26568. "msHighContrastAdjust",
  26569. "msHyphenateLimitChars",
  26570. "msHyphenateLimitLines",
  26571. "msHyphenateLimitZone",
  26572. "msHyphens",
  26573. "msImageSmoothingEnabled",
  26574. "msImeAlign",
  26575. "msIndexedDB",
  26576. "msInterpolationMode",
  26577. "msIsStaticHTML",
  26578. "msKeySystem",
  26579. "msKeys",
  26580. "msLaunchUri",
  26581. "msLockOrientation",
  26582. "msManipulationViewsEnabled",
  26583. "msMatchMedia",
  26584. "msMatchesSelector",
  26585. "msMaxTouchPoints",
  26586. "msOrientation",
  26587. "msOverflowStyle",
  26588. "msPerspective",
  26589. "msPerspectiveOrigin",
  26590. "msPlayToDisabled",
  26591. "msPlayToPreferredSourceUri",
  26592. "msPlayToPrimary",
  26593. "msPointerEnabled",
  26594. "msRegionOverflow",
  26595. "msReleasePointerCapture",
  26596. "msRequestAnimationFrame",
  26597. "msRequestFullscreen",
  26598. "msSaveBlob",
  26599. "msSaveOrOpenBlob",
  26600. "msScrollChaining",
  26601. "msScrollLimit",
  26602. "msScrollLimitXMax",
  26603. "msScrollLimitXMin",
  26604. "msScrollLimitYMax",
  26605. "msScrollLimitYMin",
  26606. "msScrollRails",
  26607. "msScrollSnapPointsX",
  26608. "msScrollSnapPointsY",
  26609. "msScrollSnapType",
  26610. "msScrollSnapX",
  26611. "msScrollSnapY",
  26612. "msScrollTranslation",
  26613. "msSetImmediate",
  26614. "msSetMediaKeys",
  26615. "msSetPointerCapture",
  26616. "msTextCombineHorizontal",
  26617. "msTextSizeAdjust",
  26618. "msToBlob",
  26619. "msTouchAction",
  26620. "msTouchSelect",
  26621. "msTraceAsyncCallbackCompleted",
  26622. "msTraceAsyncCallbackStarting",
  26623. "msTraceAsyncOperationCompleted",
  26624. "msTraceAsyncOperationStarting",
  26625. "msTransform",
  26626. "msTransformOrigin",
  26627. "msTransformStyle",
  26628. "msTransition",
  26629. "msTransitionDelay",
  26630. "msTransitionDuration",
  26631. "msTransitionProperty",
  26632. "msTransitionTimingFunction",
  26633. "msUnlockOrientation",
  26634. "msUpdateAsyncCallbackRelation",
  26635. "msUserSelect",
  26636. "msVisibilityState",
  26637. "msWrapFlow",
  26638. "msWrapMargin",
  26639. "msWrapThrough",
  26640. "msWriteProfilerMark",
  26641. "msZoom",
  26642. "msZoomTo",
  26643. "mt",
  26644. "mul",
  26645. "multiEntry",
  26646. "multiSelectionObj",
  26647. "multiline",
  26648. "multiple",
  26649. "multiply",
  26650. "multiplySelf",
  26651. "multisample",
  26652. "multisampled",
  26653. "mutableFile",
  26654. "muted",
  26655. "n",
  26656. "name",
  26657. "nameList",
  26658. "nameProp",
  26659. "namedItem",
  26660. "namedRecordset",
  26661. "names",
  26662. "namespaceURI",
  26663. "namespaces",
  26664. "nativeMap",
  26665. "nativeObjectCreate",
  26666. "nativeSet",
  26667. "nativeWeakMap",
  26668. "naturalHeight",
  26669. "naturalWidth",
  26670. "navigate",
  26671. "navigation",
  26672. "navigationMode",
  26673. "navigationPreload",
  26674. "navigationStart",
  26675. "navigationType",
  26676. "navigator",
  26677. "near",
  26678. "nearestViewportElement",
  26679. "negative",
  26680. "negotiated",
  26681. "netscape",
  26682. "networkState",
  26683. "newScale",
  26684. "newState",
  26685. "newTranslate",
  26686. "newURL",
  26687. "newValue",
  26688. "newValueSpecifiedUnits",
  26689. "newVersion",
  26690. "newhome",
  26691. "next",
  26692. "nextElementSibling",
  26693. "nextHopProtocol",
  26694. "nextNode",
  26695. "nextPage",
  26696. "nextSibling",
  26697. "nickname",
  26698. "noHref",
  26699. "noModule",
  26700. "noResize",
  26701. "noShade",
  26702. "noValidate",
  26703. "noWrap",
  26704. "node",
  26705. "nodeName",
  26706. "nodeType",
  26707. "nodeValue",
  26708. "nonce",
  26709. "normDepthBufferFromNormView",
  26710. "normalize",
  26711. "normalizedPathSegList",
  26712. "notRestoredReasons",
  26713. "notationName",
  26714. "notations",
  26715. "note",
  26716. "noteGrainOn",
  26717. "noteOff",
  26718. "noteOn",
  26719. "notify",
  26720. "now",
  26721. "numOctaves",
  26722. "number",
  26723. "numberOfChannels",
  26724. "numberOfFrames",
  26725. "numberOfInputs",
  26726. "numberOfItems",
  26727. "numberOfOutputs",
  26728. "numberValue",
  26729. "oMatchesSelector",
  26730. "object",
  26731. "object-fit",
  26732. "object-position",
  26733. "objectFit",
  26734. "objectPosition",
  26735. "objectStore",
  26736. "objectStoreNames",
  26737. "objectType",
  26738. "observe",
  26739. "occlusionQuerySet",
  26740. "of",
  26741. "off",
  26742. "offscreenBuffering",
  26743. "offset",
  26744. "offset-anchor",
  26745. "offset-distance",
  26746. "offset-path",
  26747. "offset-position",
  26748. "offset-rotate",
  26749. "offsetAnchor",
  26750. "offsetDistance",
  26751. "offsetHeight",
  26752. "offsetLeft",
  26753. "offsetNode",
  26754. "offsetParent",
  26755. "offsetPath",
  26756. "offsetPosition",
  26757. "offsetRotate",
  26758. "offsetTop",
  26759. "offsetWidth",
  26760. "offsetX",
  26761. "offsetY",
  26762. "ok",
  26763. "oldState",
  26764. "oldURL",
  26765. "oldValue",
  26766. "oldVersion",
  26767. "olderShadowRoot",
  26768. "on",
  26769. "onCommitFiberRoot",
  26770. "onCommitFiberUnmount",
  26771. "onLine",
  26772. "onPostCommitFiberRoot",
  26773. "onSubmittedWorkDone",
  26774. "onabort",
  26775. "onabsolutedeviceorientation",
  26776. "onactivate",
  26777. "onactive",
  26778. "onaddsourcebuffer",
  26779. "onaddstream",
  26780. "onaddtrack",
  26781. "onafterprint",
  26782. "onafterscriptexecute",
  26783. "onafterupdate",
  26784. "onanimationcancel",
  26785. "onanimationend",
  26786. "onanimationiteration",
  26787. "onanimationstart",
  26788. "onappinstalled",
  26789. "onaudioend",
  26790. "onaudioprocess",
  26791. "onaudiostart",
  26792. "onautocomplete",
  26793. "onautocompleteerror",
  26794. "onauxclick",
  26795. "onbeforeactivate",
  26796. "onbeforecopy",
  26797. "onbeforecut",
  26798. "onbeforedeactivate",
  26799. "onbeforeeditfocus",
  26800. "onbeforeinput",
  26801. "onbeforeinstallprompt",
  26802. "onbeforematch",
  26803. "onbeforepaste",
  26804. "onbeforeprint",
  26805. "onbeforescriptexecute",
  26806. "onbeforetoggle",
  26807. "onbeforeunload",
  26808. "onbeforeupdate",
  26809. "onbeforexrselect",
  26810. "onbegin",
  26811. "onblocked",
  26812. "onblur",
  26813. "onbounce",
  26814. "onboundary",
  26815. "onbufferedamountlow",
  26816. "oncached",
  26817. "oncancel",
  26818. "oncandidatewindowhide",
  26819. "oncandidatewindowshow",
  26820. "oncandidatewindowupdate",
  26821. "oncanplay",
  26822. "oncanplaythrough",
  26823. "oncapturehandlechange",
  26824. "once",
  26825. "oncellchange",
  26826. "onchange",
  26827. "oncharacterboundsupdate",
  26828. "oncharacteristicvaluechanged",
  26829. "onchargingchange",
  26830. "onchargingtimechange",
  26831. "onchecking",
  26832. "onclick",
  26833. "onclose",
  26834. "onclosing",
  26835. "oncompassneedscalibration",
  26836. "oncomplete",
  26837. "oncompositionend",
  26838. "oncompositionstart",
  26839. "onconnect",
  26840. "onconnecting",
  26841. "onconnectionavailable",
  26842. "onconnectionstatechange",
  26843. "oncontentvisibilityautostatechange",
  26844. "oncontextlost",
  26845. "oncontextmenu",
  26846. "oncontextrestored",
  26847. "oncontrollerchange",
  26848. "oncontrolselect",
  26849. "oncopy",
  26850. "oncuechange",
  26851. "oncurrententrychange",
  26852. "oncurrentscreenchange",
  26853. "oncut",
  26854. "ondataavailable",
  26855. "ondatachannel",
  26856. "ondatasetchanged",
  26857. "ondatasetcomplete",
  26858. "ondblclick",
  26859. "ondeactivate",
  26860. "ondequeue",
  26861. "ondevicechange",
  26862. "ondevicelight",
  26863. "ondevicemotion",
  26864. "ondeviceorientation",
  26865. "ondeviceorientationabsolute",
  26866. "ondeviceproximity",
  26867. "ondischargingtimechange",
  26868. "ondisconnect",
  26869. "ondisplay",
  26870. "ondispose",
  26871. "ondownloading",
  26872. "ondrag",
  26873. "ondragend",
  26874. "ondragenter",
  26875. "ondragexit",
  26876. "ondragleave",
  26877. "ondragover",
  26878. "ondragstart",
  26879. "ondrop",
  26880. "ondurationchange",
  26881. "onemptied",
  26882. "onencrypted",
  26883. "onend",
  26884. "onended",
  26885. "onenter",
  26886. "onenterpictureinpicture",
  26887. "onerror",
  26888. "onerrorupdate",
  26889. "onexit",
  26890. "onfencedtreeclick",
  26891. "onfilterchange",
  26892. "onfinish",
  26893. "onfocus",
  26894. "onfocusin",
  26895. "onfocusout",
  26896. "onformdata",
  26897. "onfreeze",
  26898. "onfullscreenchange",
  26899. "onfullscreenerror",
  26900. "ongamepadconnected",
  26901. "ongamepaddisconnected",
  26902. "ongatheringstatechange",
  26903. "ongattserverdisconnected",
  26904. "ongeometrychange",
  26905. "ongesturechange",
  26906. "ongestureend",
  26907. "ongesturestart",
  26908. "ongotpointercapture",
  26909. "onhashchange",
  26910. "onhelp",
  26911. "onicecandidate",
  26912. "onicecandidateerror",
  26913. "oniceconnectionstatechange",
  26914. "onicegatheringstatechange",
  26915. "oninactive",
  26916. "oninput",
  26917. "oninputreport",
  26918. "oninputsourceschange",
  26919. "oninvalid",
  26920. "onkeydown",
  26921. "onkeypress",
  26922. "onkeystatuseschange",
  26923. "onkeyup",
  26924. "onlanguagechange",
  26925. "onlayoutcomplete",
  26926. "onleavepictureinpicture",
  26927. "onlevelchange",
  26928. "onload",
  26929. "onloadeddata",
  26930. "onloadedmetadata",
  26931. "onloadend",
  26932. "onloading",
  26933. "onloadingdone",
  26934. "onloadingerror",
  26935. "onloadstart",
  26936. "onlosecapture",
  26937. "onlostpointercapture",
  26938. "only",
  26939. "onmanagedconfigurationchange",
  26940. "onmark",
  26941. "onmessage",
  26942. "onmessageerror",
  26943. "onmidimessage",
  26944. "onmousedown",
  26945. "onmouseenter",
  26946. "onmouseleave",
  26947. "onmousemove",
  26948. "onmouseout",
  26949. "onmouseover",
  26950. "onmouseup",
  26951. "onmousewheel",
  26952. "onmove",
  26953. "onmoveend",
  26954. "onmovestart",
  26955. "onmozfullscreenchange",
  26956. "onmozfullscreenerror",
  26957. "onmozorientationchange",
  26958. "onmozpointerlockchange",
  26959. "onmozpointerlockerror",
  26960. "onmscontentzoom",
  26961. "onmsfullscreenchange",
  26962. "onmsfullscreenerror",
  26963. "onmsgesturechange",
  26964. "onmsgesturedoubletap",
  26965. "onmsgestureend",
  26966. "onmsgesturehold",
  26967. "onmsgesturestart",
  26968. "onmsgesturetap",
  26969. "onmsgotpointercapture",
  26970. "onmsinertiastart",
  26971. "onmslostpointercapture",
  26972. "onmsmanipulationstatechanged",
  26973. "onmsneedkey",
  26974. "onmsorientationchange",
  26975. "onmspointercancel",
  26976. "onmspointerdown",
  26977. "onmspointerenter",
  26978. "onmspointerhover",
  26979. "onmspointerleave",
  26980. "onmspointermove",
  26981. "onmspointerout",
  26982. "onmspointerover",
  26983. "onmspointerup",
  26984. "onmssitemodejumplistitemremoved",
  26985. "onmsthumbnailclick",
  26986. "onmute",
  26987. "onnavigate",
  26988. "onnavigateerror",
  26989. "onnavigatesuccess",
  26990. "onnegotiationneeded",
  26991. "onnomatch",
  26992. "onnoupdate",
  26993. "onobsolete",
  26994. "onoffline",
  26995. "ononline",
  26996. "onopen",
  26997. "onorientationchange",
  26998. "onpagechange",
  26999. "onpagehide",
  27000. "onpagereveal",
  27001. "onpageshow",
  27002. "onpageswap",
  27003. "onpaste",
  27004. "onpause",
  27005. "onpayerdetailchange",
  27006. "onpaymentmethodchange",
  27007. "onplay",
  27008. "onplaying",
  27009. "onpluginstreamstart",
  27010. "onpointercancel",
  27011. "onpointerdown",
  27012. "onpointerenter",
  27013. "onpointerleave",
  27014. "onpointerlockchange",
  27015. "onpointerlockerror",
  27016. "onpointermove",
  27017. "onpointerout",
  27018. "onpointerover",
  27019. "onpointerrawupdate",
  27020. "onpointerup",
  27021. "onpopstate",
  27022. "onprerenderingchange",
  27023. "onprioritychange",
  27024. "onprocessorerror",
  27025. "onprogress",
  27026. "onpropertychange",
  27027. "onratechange",
  27028. "onreading",
  27029. "onreadystatechange",
  27030. "onreflectionchange",
  27031. "onrejectionhandled",
  27032. "onrelease",
  27033. "onremove",
  27034. "onremovesourcebuffer",
  27035. "onremovestream",
  27036. "onremovetrack",
  27037. "onrepeat",
  27038. "onreset",
  27039. "onresize",
  27040. "onresizeend",
  27041. "onresizestart",
  27042. "onresourcetimingbufferfull",
  27043. "onresult",
  27044. "onresume",
  27045. "onrowenter",
  27046. "onrowexit",
  27047. "onrowsdelete",
  27048. "onrowsinserted",
  27049. "onscreenschange",
  27050. "onscroll",
  27051. "onscrollend",
  27052. "onsearch",
  27053. "onsecuritypolicyviolation",
  27054. "onseeked",
  27055. "onseeking",
  27056. "onselect",
  27057. "onselectedcandidatepairchange",
  27058. "onselectend",
  27059. "onselectionchange",
  27060. "onselectstart",
  27061. "onshippingaddresschange",
  27062. "onshippingoptionchange",
  27063. "onshow",
  27064. "onsignalingstatechange",
  27065. "onsinkchange",
  27066. "onslotchange",
  27067. "onsoundend",
  27068. "onsoundstart",
  27069. "onsourceclose",
  27070. "onsourceclosed",
  27071. "onsourceended",
  27072. "onsourceopen",
  27073. "onspeechend",
  27074. "onspeechstart",
  27075. "onsqueeze",
  27076. "onsqueezeend",
  27077. "onsqueezestart",
  27078. "onstalled",
  27079. "onstart",
  27080. "onstatechange",
  27081. "onstop",
  27082. "onstorage",
  27083. "onstoragecommit",
  27084. "onsubmit",
  27085. "onsuccess",
  27086. "onsuspend",
  27087. "onterminate",
  27088. "ontextformatupdate",
  27089. "ontextinput",
  27090. "ontextupdate",
  27091. "ontimeout",
  27092. "ontimeupdate",
  27093. "ontoggle",
  27094. "ontonechange",
  27095. "ontouchcancel",
  27096. "ontouchend",
  27097. "ontouchmove",
  27098. "ontouchstart",
  27099. "ontrack",
  27100. "ontransitioncancel",
  27101. "ontransitionend",
  27102. "ontransitionrun",
  27103. "ontransitionstart",
  27104. "onuncapturederror",
  27105. "onunhandledrejection",
  27106. "onunload",
  27107. "onunmute",
  27108. "onupdate",
  27109. "onupdateend",
  27110. "onupdatefound",
  27111. "onupdateready",
  27112. "onupdatestart",
  27113. "onupgradeneeded",
  27114. "onuserproximity",
  27115. "onversionchange",
  27116. "onvisibilitychange",
  27117. "onvoiceschanged",
  27118. "onvolumechange",
  27119. "onvrdisplayactivate",
  27120. "onvrdisplayconnect",
  27121. "onvrdisplaydeactivate",
  27122. "onvrdisplaydisconnect",
  27123. "onvrdisplaypresentchange",
  27124. "onwaiting",
  27125. "onwaitingforkey",
  27126. "onwarning",
  27127. "onwebkitanimationend",
  27128. "onwebkitanimationiteration",
  27129. "onwebkitanimationstart",
  27130. "onwebkitcurrentplaybacktargetiswirelesschanged",
  27131. "onwebkitfullscreenchange",
  27132. "onwebkitfullscreenerror",
  27133. "onwebkitkeyadded",
  27134. "onwebkitkeyerror",
  27135. "onwebkitkeymessage",
  27136. "onwebkitneedkey",
  27137. "onwebkitorientationchange",
  27138. "onwebkitplaybacktargetavailabilitychanged",
  27139. "onwebkitpointerlockchange",
  27140. "onwebkitpointerlockerror",
  27141. "onwebkitresourcetimingbufferfull",
  27142. "onwebkittransitionend",
  27143. "onwheel",
  27144. "onzoom",
  27145. "opacity",
  27146. "open",
  27147. "openCursor",
  27148. "openDatabase",
  27149. "openKeyCursor",
  27150. "opened",
  27151. "opener",
  27152. "opera",
  27153. "operation",
  27154. "operationType",
  27155. "operator",
  27156. "opr",
  27157. "optimum",
  27158. "options",
  27159. "or",
  27160. "order",
  27161. "orderX",
  27162. "orderY",
  27163. "ordered",
  27164. "org",
  27165. "organization",
  27166. "orient",
  27167. "orientAngle",
  27168. "orientType",
  27169. "orientation",
  27170. "orientationX",
  27171. "orientationY",
  27172. "orientationZ",
  27173. "origin",
  27174. "originAgentCluster",
  27175. "originalPolicy",
  27176. "originalTarget",
  27177. "orphans",
  27178. "oscpu",
  27179. "outerHTML",
  27180. "outerHeight",
  27181. "outerText",
  27182. "outerWidth",
  27183. "outgoingHighWaterMark",
  27184. "outgoingMaxAge",
  27185. "outline",
  27186. "outline-color",
  27187. "outline-offset",
  27188. "outline-style",
  27189. "outline-width",
  27190. "outlineColor",
  27191. "outlineOffset",
  27192. "outlineStyle",
  27193. "outlineWidth",
  27194. "outputBuffer",
  27195. "outputChannelCount",
  27196. "outputLatency",
  27197. "outputs",
  27198. "overflow",
  27199. "overflow-anchor",
  27200. "overflow-block",
  27201. "overflow-clip-margin",
  27202. "overflow-inline",
  27203. "overflow-wrap",
  27204. "overflow-x",
  27205. "overflow-y",
  27206. "overflowAnchor",
  27207. "overflowBlock",
  27208. "overflowClipMargin",
  27209. "overflowInline",
  27210. "overflowWrap",
  27211. "overflowX",
  27212. "overflowY",
  27213. "overlaysContent",
  27214. "overrideColors",
  27215. "overrideMimeType",
  27216. "oversample",
  27217. "overscroll-behavior",
  27218. "overscroll-behavior-block",
  27219. "overscroll-behavior-inline",
  27220. "overscroll-behavior-x",
  27221. "overscroll-behavior-y",
  27222. "overscrollBehavior",
  27223. "overscrollBehaviorBlock",
  27224. "overscrollBehaviorInline",
  27225. "overscrollBehaviorX",
  27226. "overscrollBehaviorY",
  27227. "ownKeys",
  27228. "ownerDocument",
  27229. "ownerElement",
  27230. "ownerNode",
  27231. "ownerRule",
  27232. "ownerSVGElement",
  27233. "owningElement",
  27234. "p1",
  27235. "p2",
  27236. "p3",
  27237. "p4",
  27238. "packetSize",
  27239. "packets",
  27240. "pad",
  27241. "padEnd",
  27242. "padStart",
  27243. "padding",
  27244. "padding-block",
  27245. "padding-block-end",
  27246. "padding-block-start",
  27247. "padding-bottom",
  27248. "padding-inline",
  27249. "padding-inline-end",
  27250. "padding-inline-start",
  27251. "padding-left",
  27252. "padding-right",
  27253. "padding-top",
  27254. "paddingBlock",
  27255. "paddingBlockEnd",
  27256. "paddingBlockStart",
  27257. "paddingBottom",
  27258. "paddingInline",
  27259. "paddingInlineEnd",
  27260. "paddingInlineStart",
  27261. "paddingLeft",
  27262. "paddingRight",
  27263. "paddingTop",
  27264. "page",
  27265. "page-break-after",
  27266. "page-break-before",
  27267. "page-break-inside",
  27268. "pageBreakAfter",
  27269. "pageBreakBefore",
  27270. "pageBreakInside",
  27271. "pageCount",
  27272. "pageLeft",
  27273. "pageTop",
  27274. "pageX",
  27275. "pageXOffset",
  27276. "pageY",
  27277. "pageYOffset",
  27278. "pages",
  27279. "paint-order",
  27280. "paintOrder",
  27281. "paintRequests",
  27282. "paintType",
  27283. "paintWorklet",
  27284. "palette",
  27285. "pan",
  27286. "panningModel",
  27287. "parameterData",
  27288. "parameters",
  27289. "parent",
  27290. "parentElement",
  27291. "parentNode",
  27292. "parentRule",
  27293. "parentStyleSheet",
  27294. "parentTextEdit",
  27295. "parentWindow",
  27296. "parse",
  27297. "parseAll",
  27298. "parseCreationOptionsFromJSON",
  27299. "parseFloat",
  27300. "parseFromString",
  27301. "parseHTMLUnsafe",
  27302. "parseInt",
  27303. "parseRequestOptionsFromJSON",
  27304. "part",
  27305. "participants",
  27306. "passOp",
  27307. "passive",
  27308. "password",
  27309. "pasteHTML",
  27310. "path",
  27311. "pathLength",
  27312. "pathSegList",
  27313. "pathSegType",
  27314. "pathSegTypeAsLetter",
  27315. "pathname",
  27316. "pattern",
  27317. "patternContentUnits",
  27318. "patternMismatch",
  27319. "patternTransform",
  27320. "patternUnits",
  27321. "pause",
  27322. "pauseAnimations",
  27323. "pauseDuration",
  27324. "pauseOnExit",
  27325. "pauseProfilers",
  27326. "pauseTransformFeedback",
  27327. "paused",
  27328. "payerEmail",
  27329. "payerName",
  27330. "payerPhone",
  27331. "paymentManager",
  27332. "pc",
  27333. "pdfViewerEnabled",
  27334. "peerIdentity",
  27335. "pending",
  27336. "pendingLocalDescription",
  27337. "pendingRemoteDescription",
  27338. "percent",
  27339. "performance",
  27340. "periodicSync",
  27341. "permission",
  27342. "permissionState",
  27343. "permissions",
  27344. "persist",
  27345. "persisted",
  27346. "personalbar",
  27347. "perspective",
  27348. "perspective-origin",
  27349. "perspectiveOrigin",
  27350. "phone",
  27351. "phoneticFamilyName",
  27352. "phoneticGivenName",
  27353. "photo",
  27354. "pictureInPictureElement",
  27355. "pictureInPictureEnabled",
  27356. "pictureInPictureWindow",
  27357. "ping",
  27358. "pipeThrough",
  27359. "pipeTo",
  27360. "pitch",
  27361. "pixelBottom",
  27362. "pixelDepth",
  27363. "pixelHeight",
  27364. "pixelLeft",
  27365. "pixelRight",
  27366. "pixelStorei",
  27367. "pixelTop",
  27368. "pixelUnitToMillimeterX",
  27369. "pixelUnitToMillimeterY",
  27370. "pixelWidth",
  27371. "place-content",
  27372. "place-items",
  27373. "place-self",
  27374. "placeContent",
  27375. "placeItems",
  27376. "placeSelf",
  27377. "placeholder",
  27378. "platform",
  27379. "platformVersion",
  27380. "platforms",
  27381. "play",
  27382. "playEffect",
  27383. "playState",
  27384. "playbackRate",
  27385. "playbackState",
  27386. "playbackTime",
  27387. "played",
  27388. "playoutDelayHint",
  27389. "playsInline",
  27390. "plugins",
  27391. "pluginspage",
  27392. "pname",
  27393. "pointer-events",
  27394. "pointerBeforeReferenceNode",
  27395. "pointerEnabled",
  27396. "pointerEvents",
  27397. "pointerId",
  27398. "pointerLockElement",
  27399. "pointerType",
  27400. "points",
  27401. "pointsAtX",
  27402. "pointsAtY",
  27403. "pointsAtZ",
  27404. "polygonOffset",
  27405. "pop",
  27406. "popDebugGroup",
  27407. "popErrorScope",
  27408. "popover",
  27409. "popoverTargetAction",
  27410. "popoverTargetElement",
  27411. "populateMatrix",
  27412. "popupWindowFeatures",
  27413. "popupWindowName",
  27414. "popupWindowURI",
  27415. "port",
  27416. "port1",
  27417. "port2",
  27418. "ports",
  27419. "posBottom",
  27420. "posHeight",
  27421. "posLeft",
  27422. "posRight",
  27423. "posTop",
  27424. "posWidth",
  27425. "pose",
  27426. "position",
  27427. "positionAlign",
  27428. "positionX",
  27429. "positionY",
  27430. "positionZ",
  27431. "postError",
  27432. "postMessage",
  27433. "postTask",
  27434. "postalCode",
  27435. "poster",
  27436. "postscriptName",
  27437. "pow",
  27438. "powerEfficient",
  27439. "powerOff",
  27440. "powerPreference",
  27441. "preMultiplySelf",
  27442. "precision",
  27443. "preferredReflectionFormat",
  27444. "preferredStyleSheetSet",
  27445. "preferredStylesheetSet",
  27446. "prefix",
  27447. "preload",
  27448. "premultipliedAlpha",
  27449. "prepend",
  27450. "prerendering",
  27451. "presentation",
  27452. "presentationArea",
  27453. "preserveAlpha",
  27454. "preserveAspectRatio",
  27455. "preserveAspectRatioString",
  27456. "preservesPitch",
  27457. "pressed",
  27458. "pressure",
  27459. "prevValue",
  27460. "preventDefault",
  27461. "preventExtensions",
  27462. "preventSilentAccess",
  27463. "previousElementSibling",
  27464. "previousNode",
  27465. "previousPage",
  27466. "previousPriority",
  27467. "previousRect",
  27468. "previousScale",
  27469. "previousSibling",
  27470. "previousTranslate",
  27471. "primaries",
  27472. "primaryKey",
  27473. "primaryLightDirection",
  27474. "primaryLightIntensity",
  27475. "primitive",
  27476. "primitiveType",
  27477. "primitiveUnits",
  27478. "principals",
  27479. "print",
  27480. "print-color-adjust",
  27481. "printColorAdjust",
  27482. "priority",
  27483. "privateKey",
  27484. "privateToken",
  27485. "probablySupportsContext",
  27486. "probeSpace",
  27487. "process",
  27488. "processIceMessage",
  27489. "processingEnd",
  27490. "processingStart",
  27491. "processorOptions",
  27492. "product",
  27493. "productId",
  27494. "productName",
  27495. "productSub",
  27496. "profile",
  27497. "profileEnd",
  27498. "profiles",
  27499. "projectionMatrix",
  27500. "promise",
  27501. "prompt",
  27502. "properties",
  27503. "propertyIsEnumerable",
  27504. "propertyName",
  27505. "protocol",
  27506. "protocolLong",
  27507. "prototype",
  27508. "provider",
  27509. "pseudoClass",
  27510. "pseudoElement",
  27511. "pt",
  27512. "publicId",
  27513. "publicKey",
  27514. "published",
  27515. "pulse",
  27516. "push",
  27517. "pushDebugGroup",
  27518. "pushErrorScope",
  27519. "pushManager",
  27520. "pushNotification",
  27521. "pushState",
  27522. "put",
  27523. "putImageData",
  27524. "px",
  27525. "quadraticCurveTo",
  27526. "qualifier",
  27527. "quaternion",
  27528. "query",
  27529. "queryCommandEnabled",
  27530. "queryCommandIndeterm",
  27531. "queryCommandState",
  27532. "queryCommandSupported",
  27533. "queryCommandText",
  27534. "queryCommandValue",
  27535. "queryLocalFonts",
  27536. "queryPermission",
  27537. "querySelector",
  27538. "querySelectorAll",
  27539. "querySet",
  27540. "queue",
  27541. "queueMicrotask",
  27542. "quote",
  27543. "quotes",
  27544. "r",
  27545. "r1",
  27546. "r2",
  27547. "race",
  27548. "rad",
  27549. "radiogroup",
  27550. "radiusX",
  27551. "radiusY",
  27552. "random",
  27553. "randomUUID",
  27554. "range",
  27555. "rangeCount",
  27556. "rangeEnd",
  27557. "rangeMax",
  27558. "rangeMin",
  27559. "rangeOffset",
  27560. "rangeOverflow",
  27561. "rangeParent",
  27562. "rangeStart",
  27563. "rangeUnderflow",
  27564. "rate",
  27565. "ratio",
  27566. "raw",
  27567. "rawId",
  27568. "rawJSON",
  27569. "rawValueToMeters",
  27570. "rcap",
  27571. "rch",
  27572. "read",
  27573. "readAsArrayBuffer",
  27574. "readAsBinaryString",
  27575. "readAsBlob",
  27576. "readAsDataURL",
  27577. "readAsText",
  27578. "readBuffer",
  27579. "readEntries",
  27580. "readOnly",
  27581. "readPixels",
  27582. "readReportRequested",
  27583. "readText",
  27584. "readValue",
  27585. "readable",
  27586. "ready",
  27587. "readyState",
  27588. "reason",
  27589. "reasons",
  27590. "reboot",
  27591. "receiveFeatureReport",
  27592. "receivedAlert",
  27593. "receiver",
  27594. "receivers",
  27595. "recipient",
  27596. "recommendedViewportScale",
  27597. "reconnect",
  27598. "recordNumber",
  27599. "recordsAvailable",
  27600. "recordset",
  27601. "rect",
  27602. "red",
  27603. "redEyeReduction",
  27604. "redirect",
  27605. "redirectCount",
  27606. "redirectEnd",
  27607. "redirectStart",
  27608. "redirected",
  27609. "reduce",
  27610. "reduceRight",
  27611. "reduction",
  27612. "refDistance",
  27613. "refX",
  27614. "refY",
  27615. "referenceNode",
  27616. "referenceSpace",
  27617. "referrer",
  27618. "referrerPolicy",
  27619. "refresh",
  27620. "region",
  27621. "regionAnchorX",
  27622. "regionAnchorY",
  27623. "regionId",
  27624. "regions",
  27625. "register",
  27626. "registerContentHandler",
  27627. "registerElement",
  27628. "registerInternalModuleStart",
  27629. "registerInternalModuleStop",
  27630. "registerProperty",
  27631. "registerProtocolHandler",
  27632. "reject",
  27633. "rel",
  27634. "relList",
  27635. "relatedAddress",
  27636. "relatedNode",
  27637. "relatedPort",
  27638. "relatedTarget",
  27639. "relayProtocol",
  27640. "release",
  27641. "releaseCapture",
  27642. "releaseEvents",
  27643. "releaseInterface",
  27644. "releaseLock",
  27645. "releasePointerCapture",
  27646. "releaseShaderCompiler",
  27647. "released",
  27648. "reliability",
  27649. "reliable",
  27650. "reliableWrite",
  27651. "reload",
  27652. "rem",
  27653. "remainingSpace",
  27654. "remote",
  27655. "remoteDescription",
  27656. "remove",
  27657. "removeAllRanges",
  27658. "removeAttribute",
  27659. "removeAttributeNS",
  27660. "removeAttributeNode",
  27661. "removeBehavior",
  27662. "removeChild",
  27663. "removeCue",
  27664. "removeEntry",
  27665. "removeEventListener",
  27666. "removeFilter",
  27667. "removeImport",
  27668. "removeItem",
  27669. "removeListener",
  27670. "removeNamedItem",
  27671. "removeNamedItemNS",
  27672. "removeNode",
  27673. "removeParameter",
  27674. "removeProperty",
  27675. "removeRange",
  27676. "removeRegion",
  27677. "removeRule",
  27678. "removeSiteSpecificTrackingException",
  27679. "removeSourceBuffer",
  27680. "removeStream",
  27681. "removeTrack",
  27682. "removeVariable",
  27683. "removeWakeLockListener",
  27684. "removeWebWideTrackingException",
  27685. "removed",
  27686. "removedNodes",
  27687. "renderBlockingStatus",
  27688. "renderHeight",
  27689. "renderStart",
  27690. "renderState",
  27691. "renderTime",
  27692. "renderWidth",
  27693. "renderbufferStorage",
  27694. "renderbufferStorageMultisample",
  27695. "renderedBuffer",
  27696. "rendererInterfaces",
  27697. "renderers",
  27698. "renderingMode",
  27699. "renotify",
  27700. "repeat",
  27701. "repetitionCount",
  27702. "replace",
  27703. "replaceAdjacentText",
  27704. "replaceAll",
  27705. "replaceChild",
  27706. "replaceChildren",
  27707. "replaceData",
  27708. "replaceId",
  27709. "replaceItem",
  27710. "replaceNode",
  27711. "replaceState",
  27712. "replaceSync",
  27713. "replaceTrack",
  27714. "replaceWholeText",
  27715. "replaceWith",
  27716. "reportError",
  27717. "reportEvent",
  27718. "reportId",
  27719. "reportValidity",
  27720. "request",
  27721. "requestAdapter",
  27722. "requestAdapterInfo",
  27723. "requestAnimationFrame",
  27724. "requestAutocomplete",
  27725. "requestData",
  27726. "requestDevice",
  27727. "requestFrame",
  27728. "requestFullscreen",
  27729. "requestHitTestSource",
  27730. "requestHitTestSourceForTransientInput",
  27731. "requestId",
  27732. "requestIdleCallback",
  27733. "requestLightProbe",
  27734. "requestMIDIAccess",
  27735. "requestMediaKeySystemAccess",
  27736. "requestPermission",
  27737. "requestPictureInPicture",
  27738. "requestPointerLock",
  27739. "requestPort",
  27740. "requestPresent",
  27741. "requestPresenter",
  27742. "requestReferenceSpace",
  27743. "requestSession",
  27744. "requestStart",
  27745. "requestStorageAccess",
  27746. "requestStorageAccessFor",
  27747. "requestSubmit",
  27748. "requestVideoFrameCallback",
  27749. "requestViewportScale",
  27750. "requestWindow",
  27751. "requestingWindow",
  27752. "requireInteraction",
  27753. "required",
  27754. "requiredExtensions",
  27755. "requiredFeatures",
  27756. "requiredLimits",
  27757. "reset",
  27758. "resetPose",
  27759. "resetTransform",
  27760. "resizable",
  27761. "resize",
  27762. "resizeBy",
  27763. "resizeTo",
  27764. "resolve",
  27765. "resolveQuerySet",
  27766. "resolveTarget",
  27767. "resource",
  27768. "respond",
  27769. "respondWithNewView",
  27770. "response",
  27771. "responseBody",
  27772. "responseEnd",
  27773. "responseReady",
  27774. "responseStart",
  27775. "responseStatus",
  27776. "responseText",
  27777. "responseType",
  27778. "responseURL",
  27779. "responseXML",
  27780. "restartIce",
  27781. "restore",
  27782. "result",
  27783. "resultIndex",
  27784. "resultType",
  27785. "results",
  27786. "resume",
  27787. "resumeProfilers",
  27788. "resumeTransformFeedback",
  27789. "retry",
  27790. "returnValue",
  27791. "rev",
  27792. "reverse",
  27793. "reversed",
  27794. "revocable",
  27795. "revokeObjectURL",
  27796. "rex",
  27797. "rgbColor",
  27798. "ric",
  27799. "right",
  27800. "rightContext",
  27801. "rightDegrees",
  27802. "rightMargin",
  27803. "rightProjectionMatrix",
  27804. "rightViewMatrix",
  27805. "rlh",
  27806. "role",
  27807. "rolloffFactor",
  27808. "root",
  27809. "rootBounds",
  27810. "rootElement",
  27811. "rootMargin",
  27812. "rotate",
  27813. "rotateAxisAngle",
  27814. "rotateAxisAngleSelf",
  27815. "rotateFromVector",
  27816. "rotateFromVectorSelf",
  27817. "rotateSelf",
  27818. "rotation",
  27819. "rotationAngle",
  27820. "rotationRate",
  27821. "round",
  27822. "roundRect",
  27823. "row-gap",
  27824. "rowGap",
  27825. "rowIndex",
  27826. "rowSpan",
  27827. "rows",
  27828. "rowsPerImage",
  27829. "rtcpTransport",
  27830. "rtt",
  27831. "ruby-align",
  27832. "ruby-position",
  27833. "rubyAlign",
  27834. "rubyOverhang",
  27835. "rubyPosition",
  27836. "rules",
  27837. "run",
  27838. "runAdAuction",
  27839. "runtime",
  27840. "runtimeStyle",
  27841. "rx",
  27842. "ry",
  27843. "s",
  27844. "safari",
  27845. "sameDocument",
  27846. "sample",
  27847. "sampleCount",
  27848. "sampleCoverage",
  27849. "sampleInterval",
  27850. "sampleRate",
  27851. "sampleType",
  27852. "sampler",
  27853. "samplerParameterf",
  27854. "samplerParameteri",
  27855. "sandbox",
  27856. "save",
  27857. "saveData",
  27858. "scale",
  27859. "scale3d",
  27860. "scale3dSelf",
  27861. "scaleNonUniform",
  27862. "scaleNonUniformSelf",
  27863. "scaleSelf",
  27864. "scheduler",
  27865. "scheduling",
  27866. "scheme",
  27867. "scissor",
  27868. "scope",
  27869. "scopeName",
  27870. "scoped",
  27871. "screen",
  27872. "screenBrightness",
  27873. "screenEnabled",
  27874. "screenLeft",
  27875. "screenPixelToMillimeterX",
  27876. "screenPixelToMillimeterY",
  27877. "screenState",
  27878. "screenTop",
  27879. "screenX",
  27880. "screenY",
  27881. "screens",
  27882. "scriptURL",
  27883. "scripts",
  27884. "scroll",
  27885. "scroll-behavior",
  27886. "scroll-margin",
  27887. "scroll-margin-block",
  27888. "scroll-margin-block-end",
  27889. "scroll-margin-block-start",
  27890. "scroll-margin-bottom",
  27891. "scroll-margin-inline",
  27892. "scroll-margin-inline-end",
  27893. "scroll-margin-inline-start",
  27894. "scroll-margin-left",
  27895. "scroll-margin-right",
  27896. "scroll-margin-top",
  27897. "scroll-padding",
  27898. "scroll-padding-block",
  27899. "scroll-padding-block-end",
  27900. "scroll-padding-block-start",
  27901. "scroll-padding-bottom",
  27902. "scroll-padding-inline",
  27903. "scroll-padding-inline-end",
  27904. "scroll-padding-inline-start",
  27905. "scroll-padding-left",
  27906. "scroll-padding-right",
  27907. "scroll-padding-top",
  27908. "scroll-snap-align",
  27909. "scroll-snap-stop",
  27910. "scroll-snap-type",
  27911. "scrollAmount",
  27912. "scrollBehavior",
  27913. "scrollBy",
  27914. "scrollByLines",
  27915. "scrollByPages",
  27916. "scrollDelay",
  27917. "scrollHeight",
  27918. "scrollIntoView",
  27919. "scrollIntoViewIfNeeded",
  27920. "scrollLeft",
  27921. "scrollLeftMax",
  27922. "scrollMargin",
  27923. "scrollMarginBlock",
  27924. "scrollMarginBlockEnd",
  27925. "scrollMarginBlockStart",
  27926. "scrollMarginBottom",
  27927. "scrollMarginInline",
  27928. "scrollMarginInlineEnd",
  27929. "scrollMarginInlineStart",
  27930. "scrollMarginLeft",
  27931. "scrollMarginRight",
  27932. "scrollMarginTop",
  27933. "scrollMaxX",
  27934. "scrollMaxY",
  27935. "scrollPadding",
  27936. "scrollPaddingBlock",
  27937. "scrollPaddingBlockEnd",
  27938. "scrollPaddingBlockStart",
  27939. "scrollPaddingBottom",
  27940. "scrollPaddingInline",
  27941. "scrollPaddingInlineEnd",
  27942. "scrollPaddingInlineStart",
  27943. "scrollPaddingLeft",
  27944. "scrollPaddingRight",
  27945. "scrollPaddingTop",
  27946. "scrollRestoration",
  27947. "scrollSnapAlign",
  27948. "scrollSnapStop",
  27949. "scrollSnapType",
  27950. "scrollTo",
  27951. "scrollTop",
  27952. "scrollTopMax",
  27953. "scrollWidth",
  27954. "scrollX",
  27955. "scrollY",
  27956. "scrollbar-color",
  27957. "scrollbar-gutter",
  27958. "scrollbar-width",
  27959. "scrollbar3dLightColor",
  27960. "scrollbarArrowColor",
  27961. "scrollbarBaseColor",
  27962. "scrollbarColor",
  27963. "scrollbarDarkShadowColor",
  27964. "scrollbarFaceColor",
  27965. "scrollbarGutter",
  27966. "scrollbarHighlightColor",
  27967. "scrollbarShadowColor",
  27968. "scrollbarTrackColor",
  27969. "scrollbarWidth",
  27970. "scrollbars",
  27971. "scrolling",
  27972. "scrollingElement",
  27973. "sctp",
  27974. "sctpCauseCode",
  27975. "sdp",
  27976. "sdpLineNumber",
  27977. "sdpMLineIndex",
  27978. "sdpMid",
  27979. "seal",
  27980. "search",
  27981. "searchBox",
  27982. "searchBoxJavaBridge_",
  27983. "searchParams",
  27984. "sectionRowIndex",
  27985. "secureConnectionStart",
  27986. "security",
  27987. "seed",
  27988. "seek",
  27989. "seekToNextFrame",
  27990. "seekable",
  27991. "seeking",
  27992. "select",
  27993. "selectAllChildren",
  27994. "selectAlternateInterface",
  27995. "selectAudioOutput",
  27996. "selectConfiguration",
  27997. "selectNode",
  27998. "selectNodeContents",
  27999. "selectNodes",
  28000. "selectSingleNode",
  28001. "selectSubString",
  28002. "selectURL",
  28003. "selected",
  28004. "selectedIndex",
  28005. "selectedOptions",
  28006. "selectedStyleSheetSet",
  28007. "selectedStylesheetSet",
  28008. "selectedTrack",
  28009. "selection",
  28010. "selectionDirection",
  28011. "selectionEnd",
  28012. "selectionStart",
  28013. "selector",
  28014. "selectorText",
  28015. "self",
  28016. "send",
  28017. "sendAsBinary",
  28018. "sendBeacon",
  28019. "sendFeatureReport",
  28020. "sendOrder",
  28021. "sendReport",
  28022. "sender",
  28023. "sentAlert",
  28024. "sentTimestamp",
  28025. "separator",
  28026. "serial",
  28027. "serialNumber",
  28028. "serializeToString",
  28029. "serverTiming",
  28030. "service",
  28031. "serviceWorker",
  28032. "session",
  28033. "sessionId",
  28034. "sessionStorage",
  28035. "set",
  28036. "setActionHandler",
  28037. "setActive",
  28038. "setAlpha",
  28039. "setAppBadge",
  28040. "setAttribute",
  28041. "setAttributeNS",
  28042. "setAttributeNode",
  28043. "setAttributeNodeNS",
  28044. "setAttributionReporting",
  28045. "setBaseAndExtent",
  28046. "setBigInt64",
  28047. "setBigUint64",
  28048. "setBindGroup",
  28049. "setBingCurrentSearchDefault",
  28050. "setBlendConstant",
  28051. "setCameraActive",
  28052. "setCapture",
  28053. "setCaptureHandleConfig",
  28054. "setCodecPreferences",
  28055. "setColor",
  28056. "setCompositeOperation",
  28057. "setConfiguration",
  28058. "setConsumer",
  28059. "setCurrentTime",
  28060. "setCustomValidity",
  28061. "setData",
  28062. "setDate",
  28063. "setDragImage",
  28064. "setEnd",
  28065. "setEndAfter",
  28066. "setEndBefore",
  28067. "setEndPoint",
  28068. "setExpires",
  28069. "setFillColor",
  28070. "setFilterRes",
  28071. "setFloat32",
  28072. "setFloat64",
  28073. "setFloatValue",
  28074. "setFocusBehavior",
  28075. "setFormValue",
  28076. "setFullYear",
  28077. "setHTMLUnsafe",
  28078. "setHeaderExtensionsToNegotiate",
  28079. "setHeaderValue",
  28080. "setHours",
  28081. "setIdentityProvider",
  28082. "setImmediate",
  28083. "setIndexBuffer",
  28084. "setInt16",
  28085. "setInt32",
  28086. "setInt8",
  28087. "setInterval",
  28088. "setItem",
  28089. "setKeyframes",
  28090. "setLineCap",
  28091. "setLineDash",
  28092. "setLineJoin",
  28093. "setLineWidth",
  28094. "setLiveSeekableRange",
  28095. "setLocalDescription",
  28096. "setMatrix",
  28097. "setMatrixValue",
  28098. "setMediaKeys",
  28099. "setMicrophoneActive",
  28100. "setMilliseconds",
  28101. "setMinutes",
  28102. "setMiterLimit",
  28103. "setMonth",
  28104. "setNamedItem",
  28105. "setNamedItemNS",
  28106. "setNonUserCodeExceptions",
  28107. "setOrientToAngle",
  28108. "setOrientToAuto",
  28109. "setOrientation",
  28110. "setOverrideHistoryNavigationMode",
  28111. "setPaint",
  28112. "setParameter",
  28113. "setParameters",
  28114. "setPeriodicWave",
  28115. "setPipeline",
  28116. "setPointerCapture",
  28117. "setPosition",
  28118. "setPositionState",
  28119. "setPreference",
  28120. "setPriority",
  28121. "setPrivateToken",
  28122. "setProperty",
  28123. "setPrototypeOf",
  28124. "setRGBColor",
  28125. "setRGBColorICCColor",
  28126. "setRadius",
  28127. "setRangeText",
  28128. "setRemoteDescription",
  28129. "setReportEventDataForAutomaticBeacons",
  28130. "setRequestHeader",
  28131. "setResizable",
  28132. "setResourceTimingBufferSize",
  28133. "setRotate",
  28134. "setScale",
  28135. "setScissorRect",
  28136. "setSeconds",
  28137. "setSelectionRange",
  28138. "setServerCertificate",
  28139. "setShadow",
  28140. "setSharedStorageContext",
  28141. "setSignals",
  28142. "setSinkId",
  28143. "setSkewX",
  28144. "setSkewY",
  28145. "setStart",
  28146. "setStartAfter",
  28147. "setStartBefore",
  28148. "setStatus",
  28149. "setStdDeviation",
  28150. "setStencilReference",
  28151. "setStreams",
  28152. "setStrictMode",
  28153. "setStringValue",
  28154. "setStrokeColor",
  28155. "setSuggestResult",
  28156. "setTargetAtTime",
  28157. "setTargetValueAtTime",
  28158. "setTime",
  28159. "setTimeout",
  28160. "setTransform",
  28161. "setTranslate",
  28162. "setUTCDate",
  28163. "setUTCFullYear",
  28164. "setUTCHours",
  28165. "setUTCMilliseconds",
  28166. "setUTCMinutes",
  28167. "setUTCMonth",
  28168. "setUTCSeconds",
  28169. "setUint16",
  28170. "setUint32",
  28171. "setUint8",
  28172. "setUri",
  28173. "setValidity",
  28174. "setValueAtTime",
  28175. "setValueCurveAtTime",
  28176. "setVariable",
  28177. "setVelocity",
  28178. "setVersion",
  28179. "setVertexBuffer",
  28180. "setViewport",
  28181. "setYear",
  28182. "settingName",
  28183. "settingValue",
  28184. "sex",
  28185. "shaderLocation",
  28186. "shaderSource",
  28187. "shadowBlur",
  28188. "shadowColor",
  28189. "shadowOffsetX",
  28190. "shadowOffsetY",
  28191. "shadowRoot",
  28192. "shadowRootClonable",
  28193. "shadowRootDelegatesFocus",
  28194. "shadowRootMode",
  28195. "shape",
  28196. "shape-image-threshold",
  28197. "shape-margin",
  28198. "shape-outside",
  28199. "shape-rendering",
  28200. "shapeImageThreshold",
  28201. "shapeMargin",
  28202. "shapeOutside",
  28203. "shapeRendering",
  28204. "share",
  28205. "sharedStorage",
  28206. "sharedStorageWritable",
  28207. "sheet",
  28208. "shift",
  28209. "shiftKey",
  28210. "shiftLeft",
  28211. "shippingAddress",
  28212. "shippingOption",
  28213. "shippingType",
  28214. "show",
  28215. "showDirectoryPicker",
  28216. "showHelp",
  28217. "showModal",
  28218. "showModalDialog",
  28219. "showModelessDialog",
  28220. "showNotification",
  28221. "showOpenFilePicker",
  28222. "showPicker",
  28223. "showPopover",
  28224. "showSaveFilePicker",
  28225. "sidebar",
  28226. "sign",
  28227. "signal",
  28228. "signalingState",
  28229. "signature",
  28230. "silent",
  28231. "sin",
  28232. "singleNodeValue",
  28233. "sinh",
  28234. "sinkId",
  28235. "sittingToStandingTransform",
  28236. "size",
  28237. "sizeAdjust",
  28238. "sizeToContent",
  28239. "sizeX",
  28240. "sizeZ",
  28241. "sizes",
  28242. "skewX",
  28243. "skewXSelf",
  28244. "skewY",
  28245. "skewYSelf",
  28246. "skipTransition",
  28247. "skipped",
  28248. "slice",
  28249. "slope",
  28250. "slot",
  28251. "slotAssignment",
  28252. "small",
  28253. "smil",
  28254. "smooth",
  28255. "smoothingTimeConstant",
  28256. "snapToLines",
  28257. "snapshotItem",
  28258. "snapshotLength",
  28259. "some",
  28260. "sort",
  28261. "sortingCode",
  28262. "source",
  28263. "sourceBuffer",
  28264. "sourceBuffers",
  28265. "sourceCapabilities",
  28266. "sourceCharPosition",
  28267. "sourceFile",
  28268. "sourceFunctionName",
  28269. "sourceIndex",
  28270. "sourceMap",
  28271. "sourceURL",
  28272. "sources",
  28273. "spacing",
  28274. "span",
  28275. "speak",
  28276. "speakAs",
  28277. "speaking",
  28278. "species",
  28279. "specified",
  28280. "specularConstant",
  28281. "specularExponent",
  28282. "speechSynthesis",
  28283. "speed",
  28284. "speedOfSound",
  28285. "spellcheck",
  28286. "sphericalHarmonicsCoefficients",
  28287. "splice",
  28288. "split",
  28289. "splitText",
  28290. "spreadMethod",
  28291. "sqrt",
  28292. "src",
  28293. "srcElement",
  28294. "srcFactor",
  28295. "srcFilter",
  28296. "srcObject",
  28297. "srcUrn",
  28298. "srcdoc",
  28299. "srclang",
  28300. "srcset",
  28301. "stack",
  28302. "stackTraceLimit",
  28303. "stacktrace",
  28304. "stageParameters",
  28305. "standalone",
  28306. "standby",
  28307. "start",
  28308. "startContainer",
  28309. "startIce",
  28310. "startMessages",
  28311. "startNotifications",
  28312. "startOffset",
  28313. "startProfiling",
  28314. "startRendering",
  28315. "startShark",
  28316. "startTime",
  28317. "startViewTransition",
  28318. "startsWith",
  28319. "state",
  28320. "states",
  28321. "stats",
  28322. "status",
  28323. "statusCode",
  28324. "statusMessage",
  28325. "statusText",
  28326. "statusbar",
  28327. "stdDeviationX",
  28328. "stdDeviationY",
  28329. "stencilBack",
  28330. "stencilClearValue",
  28331. "stencilFront",
  28332. "stencilFunc",
  28333. "stencilFuncSeparate",
  28334. "stencilLoadOp",
  28335. "stencilMask",
  28336. "stencilMaskSeparate",
  28337. "stencilOp",
  28338. "stencilOpSeparate",
  28339. "stencilReadMask",
  28340. "stencilReadOnly",
  28341. "stencilStoreOp",
  28342. "stencilWriteMask",
  28343. "step",
  28344. "stepDown",
  28345. "stepMismatch",
  28346. "stepMode",
  28347. "stepUp",
  28348. "sticky",
  28349. "stitchTiles",
  28350. "stop",
  28351. "stop-color",
  28352. "stop-opacity",
  28353. "stopColor",
  28354. "stopImmediatePropagation",
  28355. "stopNotifications",
  28356. "stopOpacity",
  28357. "stopProfiling",
  28358. "stopPropagation",
  28359. "stopShark",
  28360. "stopped",
  28361. "storage",
  28362. "storageArea",
  28363. "storageBuckets",
  28364. "storageName",
  28365. "storageStatus",
  28366. "storageTexture",
  28367. "store",
  28368. "storeOp",
  28369. "storeSiteSpecificTrackingException",
  28370. "storeWebWideTrackingException",
  28371. "stpVersion",
  28372. "stream",
  28373. "streamErrorCode",
  28374. "streams",
  28375. "stretch",
  28376. "strike",
  28377. "string",
  28378. "stringValue",
  28379. "stringify",
  28380. "stripIndexFormat",
  28381. "stroke",
  28382. "stroke-dasharray",
  28383. "stroke-dashoffset",
  28384. "stroke-linecap",
  28385. "stroke-linejoin",
  28386. "stroke-miterlimit",
  28387. "stroke-opacity",
  28388. "stroke-width",
  28389. "strokeDasharray",
  28390. "strokeDashoffset",
  28391. "strokeLinecap",
  28392. "strokeLinejoin",
  28393. "strokeMiterlimit",
  28394. "strokeOpacity",
  28395. "strokeRect",
  28396. "strokeStyle",
  28397. "strokeText",
  28398. "strokeWidth",
  28399. "structuredClone",
  28400. "style",
  28401. "styleAndLayoutStart",
  28402. "styleFloat",
  28403. "styleMap",
  28404. "styleMedia",
  28405. "styleSheet",
  28406. "styleSheetSets",
  28407. "styleSheets",
  28408. "sub",
  28409. "subarray",
  28410. "subject",
  28411. "submit",
  28412. "submitFrame",
  28413. "submitter",
  28414. "subscribe",
  28415. "substr",
  28416. "substring",
  28417. "substringData",
  28418. "subtle",
  28419. "subtree",
  28420. "suffix",
  28421. "suffixes",
  28422. "summary",
  28423. "sup",
  28424. "supported",
  28425. "supportedContentEncodings",
  28426. "supportedEntryTypes",
  28427. "supportedValuesOf",
  28428. "supports",
  28429. "supportsFiber",
  28430. "supportsSession",
  28431. "supportsText",
  28432. "surfaceScale",
  28433. "surroundContents",
  28434. "suspend",
  28435. "suspendRedraw",
  28436. "svb",
  28437. "svh",
  28438. "svi",
  28439. "svmax",
  28440. "svmin",
  28441. "svw",
  28442. "swapCache",
  28443. "swapNode",
  28444. "sweepFlag",
  28445. "symbols",
  28446. "symmetricDifference",
  28447. "sync",
  28448. "syntax",
  28449. "sysexEnabled",
  28450. "system",
  28451. "systemCode",
  28452. "systemId",
  28453. "systemLanguage",
  28454. "systemXDPI",
  28455. "systemYDPI",
  28456. "tBodies",
  28457. "tFoot",
  28458. "tHead",
  28459. "tab-size",
  28460. "tabIndex",
  28461. "tabSize",
  28462. "table",
  28463. "table-layout",
  28464. "tableLayout",
  28465. "tableValues",
  28466. "tag",
  28467. "tagName",
  28468. "tagUrn",
  28469. "tags",
  28470. "taintEnabled",
  28471. "take",
  28472. "takePhoto",
  28473. "takeRecords",
  28474. "tan",
  28475. "tangentialPressure",
  28476. "tanh",
  28477. "target",
  28478. "targetAddressSpace",
  28479. "targetElement",
  28480. "targetRayMode",
  28481. "targetRaySpace",
  28482. "targetTouches",
  28483. "targetURL",
  28484. "targetX",
  28485. "targetY",
  28486. "targets",
  28487. "tcpType",
  28488. "tee",
  28489. "tel",
  28490. "terminate",
  28491. "test",
  28492. "texImage2D",
  28493. "texImage3D",
  28494. "texParameterf",
  28495. "texParameteri",
  28496. "texStorage2D",
  28497. "texStorage3D",
  28498. "texSubImage2D",
  28499. "texSubImage3D",
  28500. "text",
  28501. "text-align",
  28502. "text-align-last",
  28503. "text-anchor",
  28504. "text-combine-upright",
  28505. "text-decoration",
  28506. "text-decoration-color",
  28507. "text-decoration-line",
  28508. "text-decoration-skip-ink",
  28509. "text-decoration-style",
  28510. "text-decoration-thickness",
  28511. "text-emphasis",
  28512. "text-emphasis-color",
  28513. "text-emphasis-position",
  28514. "text-emphasis-style",
  28515. "text-indent",
  28516. "text-justify",
  28517. "text-orientation",
  28518. "text-overflow",
  28519. "text-rendering",
  28520. "text-shadow",
  28521. "text-transform",
  28522. "text-underline-offset",
  28523. "text-underline-position",
  28524. "text-wrap",
  28525. "text-wrap-mode",
  28526. "text-wrap-style",
  28527. "textAlign",
  28528. "textAlignLast",
  28529. "textAnchor",
  28530. "textAutospace",
  28531. "textBaseline",
  28532. "textCombineUpright",
  28533. "textContent",
  28534. "textDecoration",
  28535. "textDecorationBlink",
  28536. "textDecorationColor",
  28537. "textDecorationLine",
  28538. "textDecorationLineThrough",
  28539. "textDecorationNone",
  28540. "textDecorationOverline",
  28541. "textDecorationSkipInk",
  28542. "textDecorationStyle",
  28543. "textDecorationThickness",
  28544. "textDecorationUnderline",
  28545. "textEmphasis",
  28546. "textEmphasisColor",
  28547. "textEmphasisPosition",
  28548. "textEmphasisStyle",
  28549. "textIndent",
  28550. "textJustify",
  28551. "textJustifyTrim",
  28552. "textKashida",
  28553. "textKashidaSpace",
  28554. "textLength",
  28555. "textOrientation",
  28556. "textOverflow",
  28557. "textRendering",
  28558. "textShadow",
  28559. "textTracks",
  28560. "textTransform",
  28561. "textUnderlineOffset",
  28562. "textUnderlinePosition",
  28563. "textWrap",
  28564. "textWrapMode",
  28565. "textWrapStyle",
  28566. "texture",
  28567. "then",
  28568. "threadId",
  28569. "threshold",
  28570. "thresholds",
  28571. "throwIfAborted",
  28572. "tiltX",
  28573. "tiltY",
  28574. "time",
  28575. "timeEnd",
  28576. "timeLog",
  28577. "timeOrigin",
  28578. "timeRemaining",
  28579. "timeStamp",
  28580. "timecode",
  28581. "timeline",
  28582. "timelineTime",
  28583. "timeout",
  28584. "timestamp",
  28585. "timestampOffset",
  28586. "timestampWrites",
  28587. "timing",
  28588. "title",
  28589. "titlebarAreaRect",
  28590. "to",
  28591. "toArray",
  28592. "toBlob",
  28593. "toDataURL",
  28594. "toDateString",
  28595. "toElement",
  28596. "toExponential",
  28597. "toFixed",
  28598. "toFloat32Array",
  28599. "toFloat64Array",
  28600. "toGMTString",
  28601. "toISOString",
  28602. "toJSON",
  28603. "toLocaleDateString",
  28604. "toLocaleFormat",
  28605. "toLocaleLowerCase",
  28606. "toLocaleString",
  28607. "toLocaleTimeString",
  28608. "toLocaleUpperCase",
  28609. "toLowerCase",
  28610. "toMatrix",
  28611. "toMethod",
  28612. "toPrecision",
  28613. "toPrimitive",
  28614. "toReversed",
  28615. "toSdp",
  28616. "toSorted",
  28617. "toSource",
  28618. "toSpliced",
  28619. "toStaticHTML",
  28620. "toString",
  28621. "toStringTag",
  28622. "toSum",
  28623. "toTimeString",
  28624. "toUTCString",
  28625. "toUpperCase",
  28626. "toWellFormed",
  28627. "toggle",
  28628. "toggleAttribute",
  28629. "toggleLongPressEnabled",
  28630. "togglePopover",
  28631. "token",
  28632. "tone",
  28633. "toneBuffer",
  28634. "tooLong",
  28635. "tooShort",
  28636. "toolbar",
  28637. "top",
  28638. "topMargin",
  28639. "topology",
  28640. "total",
  28641. "totalFrameDelay",
  28642. "totalFrames",
  28643. "totalVideoFrames",
  28644. "touch-action",
  28645. "touchAction",
  28646. "touched",
  28647. "touches",
  28648. "trace",
  28649. "track",
  28650. "trackVisibility",
  28651. "trackedAnchors",
  28652. "tracks",
  28653. "transaction",
  28654. "transactions",
  28655. "transceiver",
  28656. "transfer",
  28657. "transferControlToOffscreen",
  28658. "transferFromImageBitmap",
  28659. "transferImageBitmap",
  28660. "transferIn",
  28661. "transferOut",
  28662. "transferSize",
  28663. "transferToFixedLength",
  28664. "transferToImageBitmap",
  28665. "transform",
  28666. "transform-box",
  28667. "transform-origin",
  28668. "transform-style",
  28669. "transformBox",
  28670. "transformFeedbackVaryings",
  28671. "transformOrigin",
  28672. "transformPoint",
  28673. "transformString",
  28674. "transformStyle",
  28675. "transformToDocument",
  28676. "transformToFragment",
  28677. "transition",
  28678. "transition-delay",
  28679. "transition-duration",
  28680. "transition-property",
  28681. "transition-timing-function",
  28682. "transitionDelay",
  28683. "transitionDuration",
  28684. "transitionProperty",
  28685. "transitionTimingFunction",
  28686. "translate",
  28687. "translateSelf",
  28688. "translationX",
  28689. "translationY",
  28690. "transport",
  28691. "traverseTo",
  28692. "trim",
  28693. "trimEnd",
  28694. "trimLeft",
  28695. "trimRight",
  28696. "trimStart",
  28697. "trueSpeed",
  28698. "trunc",
  28699. "truncate",
  28700. "trustedTypes",
  28701. "turn",
  28702. "twist",
  28703. "type",
  28704. "typeDetail",
  28705. "typeMismatch",
  28706. "typeMustMatch",
  28707. "types",
  28708. "u2f",
  28709. "ubound",
  28710. "uint16",
  28711. "uint32",
  28712. "uint8",
  28713. "uint8Clamped",
  28714. "unadjustedMovement",
  28715. "unclippedDepth",
  28716. "unconfigure",
  28717. "undefined",
  28718. "underlineStyle",
  28719. "underlineThickness",
  28720. "unescape",
  28721. "uneval",
  28722. "unicode",
  28723. "unicode-bidi",
  28724. "unicodeBidi",
  28725. "unicodeRange",
  28726. "unicodeSets",
  28727. "uniform1f",
  28728. "uniform1fv",
  28729. "uniform1i",
  28730. "uniform1iv",
  28731. "uniform1ui",
  28732. "uniform1uiv",
  28733. "uniform2f",
  28734. "uniform2fv",
  28735. "uniform2i",
  28736. "uniform2iv",
  28737. "uniform2ui",
  28738. "uniform2uiv",
  28739. "uniform3f",
  28740. "uniform3fv",
  28741. "uniform3i",
  28742. "uniform3iv",
  28743. "uniform3ui",
  28744. "uniform3uiv",
  28745. "uniform4f",
  28746. "uniform4fv",
  28747. "uniform4i",
  28748. "uniform4iv",
  28749. "uniform4ui",
  28750. "uniform4uiv",
  28751. "uniformBlockBinding",
  28752. "uniformMatrix2fv",
  28753. "uniformMatrix2x3fv",
  28754. "uniformMatrix2x4fv",
  28755. "uniformMatrix3fv",
  28756. "uniformMatrix3x2fv",
  28757. "uniformMatrix3x4fv",
  28758. "uniformMatrix4fv",
  28759. "uniformMatrix4x2fv",
  28760. "uniformMatrix4x3fv",
  28761. "union",
  28762. "unique",
  28763. "uniqueID",
  28764. "uniqueNumber",
  28765. "unit",
  28766. "unitType",
  28767. "units",
  28768. "unloadEventEnd",
  28769. "unloadEventStart",
  28770. "unlock",
  28771. "unmap",
  28772. "unmount",
  28773. "unobserve",
  28774. "unpackColorSpace",
  28775. "unpause",
  28776. "unpauseAnimations",
  28777. "unreadCount",
  28778. "unregister",
  28779. "unregisterContentHandler",
  28780. "unregisterProtocolHandler",
  28781. "unscopables",
  28782. "unselectable",
  28783. "unshift",
  28784. "unsubscribe",
  28785. "unsuspendRedraw",
  28786. "unsuspendRedrawAll",
  28787. "unwatch",
  28788. "unwrapKey",
  28789. "upDegrees",
  28790. "upX",
  28791. "upY",
  28792. "upZ",
  28793. "update",
  28794. "updateAdInterestGroups",
  28795. "updateCallbackDone",
  28796. "updateCharacterBounds",
  28797. "updateCommands",
  28798. "updateControlBounds",
  28799. "updateCurrentEntry",
  28800. "updateIce",
  28801. "updateInkTrailStartPoint",
  28802. "updateInterval",
  28803. "updatePlaybackRate",
  28804. "updateRangeEnd",
  28805. "updateRangeStart",
  28806. "updateRenderState",
  28807. "updateSelection",
  28808. "updateSelectionBounds",
  28809. "updateSettings",
  28810. "updateText",
  28811. "updateTiming",
  28812. "updateViaCache",
  28813. "updateWith",
  28814. "updated",
  28815. "updating",
  28816. "upgrade",
  28817. "upload",
  28818. "uploadTotal",
  28819. "uploaded",
  28820. "upper",
  28821. "upperBound",
  28822. "upperOpen",
  28823. "uri",
  28824. "url",
  28825. "urn",
  28826. "urns",
  28827. "usage",
  28828. "usages",
  28829. "usb",
  28830. "usbVersionMajor",
  28831. "usbVersionMinor",
  28832. "usbVersionSubminor",
  28833. "useCurrentView",
  28834. "useMap",
  28835. "useProgram",
  28836. "usedSpace",
  28837. "user-select",
  28838. "userActivation",
  28839. "userAgent",
  28840. "userAgentData",
  28841. "userChoice",
  28842. "userHandle",
  28843. "userHint",
  28844. "userInitiated",
  28845. "userLanguage",
  28846. "userSelect",
  28847. "userState",
  28848. "userVisibleOnly",
  28849. "username",
  28850. "usernameFragment",
  28851. "utterance",
  28852. "uuid",
  28853. "v8BreakIterator",
  28854. "vAlign",
  28855. "vLink",
  28856. "valid",
  28857. "validate",
  28858. "validateProgram",
  28859. "validationMessage",
  28860. "validity",
  28861. "value",
  28862. "valueAsDate",
  28863. "valueAsNumber",
  28864. "valueAsString",
  28865. "valueInSpecifiedUnits",
  28866. "valueMissing",
  28867. "valueOf",
  28868. "valueText",
  28869. "valueType",
  28870. "values",
  28871. "variable",
  28872. "variant",
  28873. "variationSettings",
  28874. "vb",
  28875. "vector-effect",
  28876. "vectorEffect",
  28877. "velocityAngular",
  28878. "velocityExpansion",
  28879. "velocityX",
  28880. "velocityY",
  28881. "vendor",
  28882. "vendorId",
  28883. "vendorSub",
  28884. "verify",
  28885. "version",
  28886. "vertex",
  28887. "vertexAttrib1f",
  28888. "vertexAttrib1fv",
  28889. "vertexAttrib2f",
  28890. "vertexAttrib2fv",
  28891. "vertexAttrib3f",
  28892. "vertexAttrib3fv",
  28893. "vertexAttrib4f",
  28894. "vertexAttrib4fv",
  28895. "vertexAttribDivisor",
  28896. "vertexAttribDivisorANGLE",
  28897. "vertexAttribI4i",
  28898. "vertexAttribI4iv",
  28899. "vertexAttribI4ui",
  28900. "vertexAttribI4uiv",
  28901. "vertexAttribIPointer",
  28902. "vertexAttribPointer",
  28903. "vertical",
  28904. "vertical-align",
  28905. "verticalAlign",
  28906. "verticalOverflow",
  28907. "vh",
  28908. "vi",
  28909. "vibrate",
  28910. "vibrationActuator",
  28911. "videoBitsPerSecond",
  28912. "videoHeight",
  28913. "videoTracks",
  28914. "videoWidth",
  28915. "view",
  28916. "viewBox",
  28917. "viewBoxString",
  28918. "viewDimension",
  28919. "viewFormats",
  28920. "viewTarget",
  28921. "viewTargetString",
  28922. "viewport",
  28923. "viewportAnchorX",
  28924. "viewportAnchorY",
  28925. "viewportElement",
  28926. "views",
  28927. "violatedDirective",
  28928. "virtualKeyboard",
  28929. "virtualKeyboardPolicy",
  28930. "visibility",
  28931. "visibilityState",
  28932. "visible",
  28933. "visibleRect",
  28934. "visualViewport",
  28935. "vlinkColor",
  28936. "vmax",
  28937. "vmin",
  28938. "voice",
  28939. "voiceURI",
  28940. "volume",
  28941. "vrml",
  28942. "vspace",
  28943. "vw",
  28944. "w",
  28945. "wait",
  28946. "waitAsync",
  28947. "waitSync",
  28948. "waiting",
  28949. "wake",
  28950. "wakeLock",
  28951. "wand",
  28952. "warn",
  28953. "wasClean",
  28954. "wasDiscarded",
  28955. "watch",
  28956. "watchAvailability",
  28957. "watchPosition",
  28958. "webdriver",
  28959. "webkitAddKey",
  28960. "webkitAlignContent",
  28961. "webkitAlignItems",
  28962. "webkitAlignSelf",
  28963. "webkitAnimation",
  28964. "webkitAnimationDelay",
  28965. "webkitAnimationDirection",
  28966. "webkitAnimationDuration",
  28967. "webkitAnimationFillMode",
  28968. "webkitAnimationIterationCount",
  28969. "webkitAnimationName",
  28970. "webkitAnimationPlayState",
  28971. "webkitAnimationTimingFunction",
  28972. "webkitAppearance",
  28973. "webkitAudioContext",
  28974. "webkitAudioDecodedByteCount",
  28975. "webkitAudioPannerNode",
  28976. "webkitBackfaceVisibility",
  28977. "webkitBackground",
  28978. "webkitBackgroundAttachment",
  28979. "webkitBackgroundClip",
  28980. "webkitBackgroundColor",
  28981. "webkitBackgroundImage",
  28982. "webkitBackgroundOrigin",
  28983. "webkitBackgroundPosition",
  28984. "webkitBackgroundPositionX",
  28985. "webkitBackgroundPositionY",
  28986. "webkitBackgroundRepeat",
  28987. "webkitBackgroundSize",
  28988. "webkitBackingStorePixelRatio",
  28989. "webkitBorderBottomLeftRadius",
  28990. "webkitBorderBottomRightRadius",
  28991. "webkitBorderImage",
  28992. "webkitBorderImageOutset",
  28993. "webkitBorderImageRepeat",
  28994. "webkitBorderImageSlice",
  28995. "webkitBorderImageSource",
  28996. "webkitBorderImageWidth",
  28997. "webkitBorderRadius",
  28998. "webkitBorderTopLeftRadius",
  28999. "webkitBorderTopRightRadius",
  29000. "webkitBoxAlign",
  29001. "webkitBoxDirection",
  29002. "webkitBoxFlex",
  29003. "webkitBoxOrdinalGroup",
  29004. "webkitBoxOrient",
  29005. "webkitBoxPack",
  29006. "webkitBoxShadow",
  29007. "webkitBoxSizing",
  29008. "webkitCancelAnimationFrame",
  29009. "webkitCancelFullScreen",
  29010. "webkitCancelKeyRequest",
  29011. "webkitCancelRequestAnimationFrame",
  29012. "webkitClearResourceTimings",
  29013. "webkitClipPath",
  29014. "webkitClosedCaptionsVisible",
  29015. "webkitConvertPointFromNodeToPage",
  29016. "webkitConvertPointFromPageToNode",
  29017. "webkitCreateShadowRoot",
  29018. "webkitCurrentFullScreenElement",
  29019. "webkitCurrentPlaybackTargetIsWireless",
  29020. "webkitDecodedFrameCount",
  29021. "webkitDirectionInvertedFromDevice",
  29022. "webkitDisplayingFullscreen",
  29023. "webkitDroppedFrameCount",
  29024. "webkitEnterFullScreen",
  29025. "webkitEnterFullscreen",
  29026. "webkitEntries",
  29027. "webkitExitFullScreen",
  29028. "webkitExitFullscreen",
  29029. "webkitExitPointerLock",
  29030. "webkitFilter",
  29031. "webkitFlex",
  29032. "webkitFlexBasis",
  29033. "webkitFlexDirection",
  29034. "webkitFlexFlow",
  29035. "webkitFlexGrow",
  29036. "webkitFlexShrink",
  29037. "webkitFlexWrap",
  29038. "webkitFullScreenKeyboardInputAllowed",
  29039. "webkitFullscreenElement",
  29040. "webkitFullscreenEnabled",
  29041. "webkitGenerateKeyRequest",
  29042. "webkitGetAsEntry",
  29043. "webkitGetDatabaseNames",
  29044. "webkitGetEntries",
  29045. "webkitGetEntriesByName",
  29046. "webkitGetEntriesByType",
  29047. "webkitGetFlowByName",
  29048. "webkitGetGamepads",
  29049. "webkitGetImageDataHD",
  29050. "webkitGetNamedFlows",
  29051. "webkitGetRegionFlowRanges",
  29052. "webkitGetUserMedia",
  29053. "webkitHasClosedCaptions",
  29054. "webkitHidden",
  29055. "webkitIDBCursor",
  29056. "webkitIDBDatabase",
  29057. "webkitIDBDatabaseError",
  29058. "webkitIDBDatabaseException",
  29059. "webkitIDBFactory",
  29060. "webkitIDBIndex",
  29061. "webkitIDBKeyRange",
  29062. "webkitIDBObjectStore",
  29063. "webkitIDBRequest",
  29064. "webkitIDBTransaction",
  29065. "webkitImageSmoothingEnabled",
  29066. "webkitIndexedDB",
  29067. "webkitInitMessageEvent",
  29068. "webkitIsFullScreen",
  29069. "webkitJustifyContent",
  29070. "webkitKeys",
  29071. "webkitLineClamp",
  29072. "webkitLineDashOffset",
  29073. "webkitLockOrientation",
  29074. "webkitMask",
  29075. "webkitMaskClip",
  29076. "webkitMaskComposite",
  29077. "webkitMaskImage",
  29078. "webkitMaskOrigin",
  29079. "webkitMaskPosition",
  29080. "webkitMaskPositionX",
  29081. "webkitMaskPositionY",
  29082. "webkitMaskRepeat",
  29083. "webkitMaskSize",
  29084. "webkitMatchesSelector",
  29085. "webkitMediaStream",
  29086. "webkitNotifications",
  29087. "webkitOfflineAudioContext",
  29088. "webkitOrder",
  29089. "webkitOrientation",
  29090. "webkitPeerConnection00",
  29091. "webkitPersistentStorage",
  29092. "webkitPerspective",
  29093. "webkitPerspectiveOrigin",
  29094. "webkitPointerLockElement",
  29095. "webkitPostMessage",
  29096. "webkitPreservesPitch",
  29097. "webkitPutImageDataHD",
  29098. "webkitRTCPeerConnection",
  29099. "webkitRegionOverset",
  29100. "webkitRelativePath",
  29101. "webkitRequestAnimationFrame",
  29102. "webkitRequestFileSystem",
  29103. "webkitRequestFullScreen",
  29104. "webkitRequestFullscreen",
  29105. "webkitRequestPointerLock",
  29106. "webkitResolveLocalFileSystemURL",
  29107. "webkitSetMediaKeys",
  29108. "webkitSetResourceTimingBufferSize",
  29109. "webkitShadowRoot",
  29110. "webkitShowPlaybackTargetPicker",
  29111. "webkitSlice",
  29112. "webkitSpeechGrammar",
  29113. "webkitSpeechGrammarList",
  29114. "webkitSpeechRecognition",
  29115. "webkitSpeechRecognitionError",
  29116. "webkitSpeechRecognitionEvent",
  29117. "webkitStorageInfo",
  29118. "webkitSupportsFullscreen",
  29119. "webkitTemporaryStorage",
  29120. "webkitTextFillColor",
  29121. "webkitTextSecurity",
  29122. "webkitTextSizeAdjust",
  29123. "webkitTextStroke",
  29124. "webkitTextStrokeColor",
  29125. "webkitTextStrokeWidth",
  29126. "webkitTransform",
  29127. "webkitTransformOrigin",
  29128. "webkitTransformStyle",
  29129. "webkitTransition",
  29130. "webkitTransitionDelay",
  29131. "webkitTransitionDuration",
  29132. "webkitTransitionProperty",
  29133. "webkitTransitionTimingFunction",
  29134. "webkitURL",
  29135. "webkitUnlockOrientation",
  29136. "webkitUserSelect",
  29137. "webkitVideoDecodedByteCount",
  29138. "webkitVisibilityState",
  29139. "webkitWirelessVideoPlaybackDisabled",
  29140. "webkitdirectory",
  29141. "webkitdropzone",
  29142. "webstore",
  29143. "weight",
  29144. "wgslLanguageFeatures",
  29145. "whatToShow",
  29146. "wheelDelta",
  29147. "wheelDeltaX",
  29148. "wheelDeltaY",
  29149. "whenDefined",
  29150. "which",
  29151. "white-space",
  29152. "white-space-collapse",
  29153. "whiteSpace",
  29154. "whiteSpaceCollapse",
  29155. "wholeText",
  29156. "widows",
  29157. "width",
  29158. "will-change",
  29159. "willChange",
  29160. "willValidate",
  29161. "window",
  29162. "windowAttribution",
  29163. "windowControlsOverlay",
  29164. "with",
  29165. "withCredentials",
  29166. "withResolvers",
  29167. "word-break",
  29168. "word-spacing",
  29169. "word-wrap",
  29170. "wordBreak",
  29171. "wordSpacing",
  29172. "wordWrap",
  29173. "workerStart",
  29174. "worklet",
  29175. "wow64",
  29176. "wrap",
  29177. "wrapKey",
  29178. "writable",
  29179. "writableAuxiliaries",
  29180. "write",
  29181. "writeBuffer",
  29182. "writeMask",
  29183. "writeText",
  29184. "writeTexture",
  29185. "writeTimestamp",
  29186. "writeValue",
  29187. "writeValueWithResponse",
  29188. "writeValueWithoutResponse",
  29189. "writeWithoutResponse",
  29190. "writeln",
  29191. "writing-mode",
  29192. "writingMode",
  29193. "writingSuggestions",
  29194. "x",
  29195. "x1",
  29196. "x2",
  29197. "xChannelSelector",
  29198. "xmlEncoding",
  29199. "xmlStandalone",
  29200. "xmlVersion",
  29201. "xmlbase",
  29202. "xmllang",
  29203. "xmlspace",
  29204. "xor",
  29205. "xr",
  29206. "y",
  29207. "y1",
  29208. "y2",
  29209. "yChannelSelector",
  29210. "yandex",
  29211. "z",
  29212. "z-index",
  29213. "zIndex",
  29214. "zoom",
  29215. "zoomAndPan",
  29216. "zoomRectScreen",
  29217. ];
  29218. /***********************************************************************
  29219. A JavaScript tokenizer / parser / beautifier / compressor.
  29220. https://github.com/mishoo/UglifyJS2
  29221. -------------------------------- (C) ---------------------------------
  29222. Author: Mihai Bazon
  29223. <mihai.bazon@gmail.com>
  29224. http://mihai.bazon.net/blog
  29225. Distributed under the BSD license:
  29226. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  29227. Redistribution and use in source and binary forms, with or without
  29228. modification, are permitted provided that the following conditions
  29229. are met:
  29230. * Redistributions of source code must retain the above
  29231. copyright notice, this list of conditions and the following
  29232. disclaimer.
  29233. * Redistributions in binary form must reproduce the above
  29234. copyright notice, this list of conditions and the following
  29235. disclaimer in the documentation and/or other materials
  29236. provided with the distribution.
  29237. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  29238. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29239. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29240. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29241. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  29242. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29243. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29244. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29245. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  29246. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29247. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29248. SUCH DAMAGE.
  29249. ***********************************************************************/
  29250. function find_builtins(reserved) {
  29251. domprops.forEach(add);
  29252. // Compatibility fix for some standard defined globals not defined on every js environment
  29253. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  29254. var objects = {};
  29255. var global_ref = typeof global === "object" ? global : self;
  29256. new_globals.forEach(function (new_global) {
  29257. objects[new_global] = global_ref[new_global] || function() {};
  29258. });
  29259. [
  29260. "null",
  29261. "true",
  29262. "false",
  29263. "NaN",
  29264. "Infinity",
  29265. "-Infinity",
  29266. "undefined",
  29267. ].forEach(add);
  29268. [ Object, Array, Function, Number,
  29269. String, Boolean, Error, Math,
  29270. Date, RegExp, objects.Symbol, ArrayBuffer,
  29271. DataView, decodeURI, decodeURIComponent,
  29272. encodeURI, encodeURIComponent, eval, EvalError,
  29273. Float32Array, Float64Array, Int8Array, Int16Array,
  29274. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  29275. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  29276. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  29277. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  29278. objects.WeakMap, objects.WeakSet
  29279. ].forEach(function(ctor) {
  29280. Object.getOwnPropertyNames(ctor).map(add);
  29281. if (ctor.prototype) {
  29282. Object.getOwnPropertyNames(ctor.prototype).map(add);
  29283. }
  29284. });
  29285. function add(name) {
  29286. reserved.add(name);
  29287. }
  29288. }
  29289. function reserve_quoted_keys(ast, reserved) {
  29290. function add(name) {
  29291. push_uniq(reserved, name);
  29292. }
  29293. ast.walk(new TreeWalker(function(node) {
  29294. if (node instanceof AST_ObjectKeyVal && node.quote) {
  29295. add(node.key);
  29296. } else if (node instanceof AST_ObjectProperty && node.quote) {
  29297. add(node.key.name);
  29298. } else if (node instanceof AST_Sub) {
  29299. addStrings(node.property, add);
  29300. }
  29301. }));
  29302. }
  29303. function addStrings(node, add) {
  29304. node.walk(new TreeWalker(function(node) {
  29305. if (node instanceof AST_Sequence) {
  29306. addStrings(node.tail_node(), add);
  29307. } else if (node instanceof AST_String) {
  29308. add(node.value);
  29309. } else if (node instanceof AST_Conditional) {
  29310. addStrings(node.consequent, add);
  29311. addStrings(node.alternative, add);
  29312. }
  29313. return true;
  29314. }));
  29315. }
  29316. function mangle_private_properties(ast, options) {
  29317. var cprivate = -1;
  29318. var private_cache = new Map();
  29319. var nth_identifier = options.nth_identifier || base54;
  29320. ast = ast.transform(new TreeTransformer(function(node) {
  29321. if (
  29322. node instanceof AST_ClassPrivateProperty
  29323. || node instanceof AST_PrivateMethod
  29324. || node instanceof AST_PrivateGetter
  29325. || node instanceof AST_PrivateSetter
  29326. || node instanceof AST_PrivateIn
  29327. ) {
  29328. node.key.name = mangle_private(node.key.name);
  29329. } else if (node instanceof AST_DotHash) {
  29330. node.property = mangle_private(node.property);
  29331. }
  29332. }));
  29333. return ast;
  29334. function mangle_private(name) {
  29335. let mangled = private_cache.get(name);
  29336. if (!mangled) {
  29337. mangled = nth_identifier.get(++cprivate);
  29338. private_cache.set(name, mangled);
  29339. }
  29340. return mangled;
  29341. }
  29342. }
  29343. function find_annotated_props(ast) {
  29344. var annotated_props = new Set();
  29345. walk(ast, node => {
  29346. if (
  29347. node instanceof AST_ClassPrivateProperty
  29348. || node instanceof AST_PrivateMethod
  29349. || node instanceof AST_PrivateGetter
  29350. || node instanceof AST_PrivateSetter
  29351. || node instanceof AST_DotHash
  29352. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29353. if (typeof node.key == "string" && has_annotation(node, _MANGLEPROP)) {
  29354. annotated_props.add(node.key);
  29355. }
  29356. } else if (node instanceof AST_ObjectProperty) {
  29357. // setter or getter, since KeyVal is handled above
  29358. if (has_annotation(node, _MANGLEPROP)) {
  29359. annotated_props.add(node.key.name);
  29360. }
  29361. } else if (node instanceof AST_Dot) {
  29362. if (has_annotation(node, _MANGLEPROP)) {
  29363. annotated_props.add(node.property);
  29364. }
  29365. } else if (node instanceof AST_Sub) {
  29366. if (node.property instanceof AST_String && has_annotation(node, _MANGLEPROP)) {
  29367. annotated_props.add(node.property.value);
  29368. }
  29369. }
  29370. });
  29371. return annotated_props;
  29372. }
  29373. function mangle_properties(ast, options, annotated_props = find_annotated_props(ast)) {
  29374. options = defaults(options, {
  29375. builtins: false,
  29376. cache: null,
  29377. debug: false,
  29378. keep_quoted: false,
  29379. nth_identifier: base54,
  29380. only_cache: false,
  29381. regex: null,
  29382. reserved: null,
  29383. undeclared: false,
  29384. only_annotated: false,
  29385. }, true);
  29386. var nth_identifier = options.nth_identifier;
  29387. var reserved_option = options.reserved;
  29388. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  29389. var reserved = new Set(reserved_option);
  29390. if (!options.builtins) find_builtins(reserved);
  29391. var cname = -1;
  29392. var cache;
  29393. if (options.cache) {
  29394. cache = options.cache.props;
  29395. } else {
  29396. cache = new Map();
  29397. }
  29398. var only_annotated = options.only_annotated;
  29399. var regex = options.regex && new RegExp(options.regex);
  29400. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  29401. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  29402. // the same as passing an empty string.
  29403. var debug = options.debug !== false;
  29404. var debug_name_suffix;
  29405. if (debug) {
  29406. debug_name_suffix = (options.debug === true ? "" : options.debug);
  29407. }
  29408. var names_to_mangle = new Set();
  29409. var unmangleable = new Set();
  29410. // Track each already-mangled name to prevent nth_identifier from generating
  29411. // the same name.
  29412. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  29413. var keep_quoted = !!options.keep_quoted;
  29414. // step 1: find candidates to mangle
  29415. ast.walk(new TreeWalker(function(node) {
  29416. if (
  29417. node instanceof AST_ClassPrivateProperty
  29418. || node instanceof AST_PrivateMethod
  29419. || node instanceof AST_PrivateGetter
  29420. || node instanceof AST_PrivateSetter
  29421. || node instanceof AST_DotHash
  29422. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29423. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  29424. add(node.key);
  29425. }
  29426. } else if (node instanceof AST_ObjectProperty) {
  29427. // setter or getter, since KeyVal is handled above
  29428. if (!keep_quoted || !node.quote) {
  29429. add(node.key.name);
  29430. }
  29431. } else if (node instanceof AST_Dot) {
  29432. var declared = !!options.undeclared;
  29433. if (!declared) {
  29434. var root = node;
  29435. while (root.expression) {
  29436. root = root.expression;
  29437. }
  29438. declared = !(root.thedef && root.thedef.undeclared);
  29439. }
  29440. if (declared &&
  29441. (!keep_quoted || !node.quote)) {
  29442. add(node.property);
  29443. }
  29444. } else if (node instanceof AST_Sub) {
  29445. if (!keep_quoted) {
  29446. addStrings(node.property, add);
  29447. }
  29448. } else if (node instanceof AST_Call
  29449. && node.expression.print_to_string() == "Object.defineProperty") {
  29450. addStrings(node.args[1], add);
  29451. } else if (node instanceof AST_Binary && node.operator === "in") {
  29452. addStrings(node.left, add);
  29453. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  29454. add(node.value);
  29455. }
  29456. }));
  29457. // step 2: transform the tree, renaming properties
  29458. return ast.transform(new TreeTransformer(function(node) {
  29459. if (
  29460. node instanceof AST_ClassPrivateProperty
  29461. || node instanceof AST_PrivateMethod
  29462. || node instanceof AST_PrivateGetter
  29463. || node instanceof AST_PrivateSetter
  29464. || node instanceof AST_DotHash
  29465. ) ; else if (node instanceof AST_ObjectKeyVal) {
  29466. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  29467. node.key = mangle(node.key);
  29468. }
  29469. } else if (node instanceof AST_ObjectProperty) {
  29470. // setter, getter, method or class field
  29471. if (!keep_quoted || !node.quote) {
  29472. node.key.name = mangle(node.key.name);
  29473. }
  29474. } else if (node instanceof AST_Dot) {
  29475. if (!keep_quoted || !node.quote) {
  29476. node.property = mangle(node.property);
  29477. }
  29478. } else if (!keep_quoted && node instanceof AST_Sub) {
  29479. node.property = mangleStrings(node.property);
  29480. } else if (node instanceof AST_Call
  29481. && node.expression.print_to_string() == "Object.defineProperty") {
  29482. node.args[1] = mangleStrings(node.args[1]);
  29483. } else if (node instanceof AST_Binary && node.operator === "in") {
  29484. node.left = mangleStrings(node.left);
  29485. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  29486. // Clear _KEY annotation to prevent double mangling
  29487. clear_annotation(node, _KEY);
  29488. node.value = mangle(node.value);
  29489. }
  29490. }));
  29491. // only function declarations after this line
  29492. function can_mangle(name) {
  29493. if (unmangleable.has(name)) return false;
  29494. if (reserved.has(name)) return false;
  29495. if (options.only_cache) {
  29496. return cache.has(name);
  29497. }
  29498. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  29499. return true;
  29500. }
  29501. function should_mangle(name) {
  29502. if (only_annotated && !annotated_props.has(name)) return false;
  29503. if (regex && !regex.test(name)) {
  29504. return annotated_props.has(name);
  29505. }
  29506. if (reserved.has(name)) return false;
  29507. return cache.has(name)
  29508. || names_to_mangle.has(name);
  29509. }
  29510. function add(name) {
  29511. if (can_mangle(name)) {
  29512. names_to_mangle.add(name);
  29513. }
  29514. if (!should_mangle(name)) {
  29515. unmangleable.add(name);
  29516. }
  29517. }
  29518. function mangle(name) {
  29519. if (!should_mangle(name)) {
  29520. return name;
  29521. }
  29522. var mangled = cache.get(name);
  29523. if (!mangled) {
  29524. if (debug) {
  29525. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  29526. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  29527. if (can_mangle(debug_mangled)) {
  29528. mangled = debug_mangled;
  29529. }
  29530. }
  29531. // either debug mode is off, or it is on and we could not use the mangled name
  29532. if (!mangled) {
  29533. do {
  29534. mangled = nth_identifier.get(++cname);
  29535. } while (!can_mangle(mangled));
  29536. }
  29537. cache.set(name, mangled);
  29538. }
  29539. return mangled;
  29540. }
  29541. function mangleStrings(node) {
  29542. return node.transform(new TreeTransformer(function(node) {
  29543. if (node instanceof AST_Sequence) {
  29544. var last = node.expressions.length - 1;
  29545. node.expressions[last] = mangleStrings(node.expressions[last]);
  29546. } else if (node instanceof AST_String) {
  29547. // Clear _KEY annotation to prevent double mangling
  29548. clear_annotation(node, _KEY);
  29549. node.value = mangle(node.value);
  29550. } else if (node instanceof AST_Conditional) {
  29551. node.consequent = mangleStrings(node.consequent);
  29552. node.alternative = mangleStrings(node.alternative);
  29553. }
  29554. return node;
  29555. }));
  29556. }
  29557. }
  29558. // to/from base64 functions
  29559. // Prefer built-in Buffer, if available, then use hack
  29560. // https://developer.mozilla.org/en-US/docs/Glossary/Base64#The_Unicode_Problem
  29561. var to_ascii = typeof Buffer !== "undefined"
  29562. ? (b64) => Buffer.from(b64, "base64").toString()
  29563. : (b64) => decodeURIComponent(escape(atob(b64)));
  29564. var to_base64 = typeof Buffer !== "undefined"
  29565. ? (str) => Buffer.from(str).toString("base64")
  29566. : (str) => btoa(unescape(encodeURIComponent(str)));
  29567. function read_source_map(code) {
  29568. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  29569. if (!match) {
  29570. console.warn("inline source map not found");
  29571. return null;
  29572. }
  29573. return to_ascii(match[2]);
  29574. }
  29575. function set_shorthand(name, options, keys) {
  29576. if (options[name]) {
  29577. keys.forEach(function(key) {
  29578. if (options[key]) {
  29579. if (typeof options[key] != "object") options[key] = {};
  29580. if (!(name in options[key])) options[key][name] = options[name];
  29581. }
  29582. });
  29583. }
  29584. }
  29585. function init_cache(cache) {
  29586. if (!cache) return;
  29587. if (!("props" in cache)) {
  29588. cache.props = new Map();
  29589. } else if (!(cache.props instanceof Map)) {
  29590. cache.props = map_from_object(cache.props);
  29591. }
  29592. }
  29593. function cache_to_json(cache) {
  29594. return {
  29595. props: map_to_object(cache.props)
  29596. };
  29597. }
  29598. function log_input(files, options, fs, debug_folder) {
  29599. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  29600. return;
  29601. }
  29602. try {
  29603. fs.mkdirSync(debug_folder);
  29604. } catch (e) {
  29605. if (e.code !== "EEXIST") throw e;
  29606. }
  29607. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  29608. options = options || {};
  29609. const options_str = JSON.stringify(options, (_key, thing) => {
  29610. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  29611. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  29612. return thing;
  29613. }, 4);
  29614. const files_str = (file) => {
  29615. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  29616. return JSON.stringify(file, null, 2);
  29617. } else if (typeof file === "object") {
  29618. return Object.keys(file)
  29619. .map((key) => key + ": " + files_str(file[key]))
  29620. .join("\n\n");
  29621. } else if (typeof file === "string") {
  29622. return "```\n" + file + "\n```";
  29623. } else {
  29624. return file; // What do?
  29625. }
  29626. };
  29627. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  29628. }
  29629. function* minify_sync_or_async(files, options, _fs_module) {
  29630. if (
  29631. _fs_module
  29632. && typeof process === "object"
  29633. && process.env
  29634. && typeof process.env.TERSER_DEBUG_DIR === "string"
  29635. ) {
  29636. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  29637. }
  29638. options = defaults(options, {
  29639. compress: {},
  29640. ecma: undefined,
  29641. enclose: false,
  29642. ie8: false,
  29643. keep_classnames: undefined,
  29644. keep_fnames: false,
  29645. mangle: {},
  29646. module: false,
  29647. nameCache: null,
  29648. output: null,
  29649. format: null,
  29650. parse: {},
  29651. rename: undefined,
  29652. safari10: false,
  29653. sourceMap: false,
  29654. spidermonkey: false,
  29655. timings: false,
  29656. toplevel: false,
  29657. warnings: false,
  29658. wrap: false,
  29659. }, true);
  29660. var timings = options.timings && {
  29661. start: Date.now()
  29662. };
  29663. if (options.keep_classnames === undefined) {
  29664. options.keep_classnames = options.keep_fnames;
  29665. }
  29666. if (options.rename === undefined) {
  29667. options.rename = options.compress && options.mangle;
  29668. }
  29669. if (options.output && options.format) {
  29670. throw new Error("Please only specify either output or format option, preferrably format.");
  29671. }
  29672. options.format = options.format || options.output || {};
  29673. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  29674. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  29675. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  29676. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  29677. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  29678. set_shorthand("safari10", options, [ "mangle", "format" ]);
  29679. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  29680. set_shorthand("warnings", options, [ "compress" ]); // legacy
  29681. var quoted_props;
  29682. if (options.mangle) {
  29683. options.mangle = defaults(options.mangle, {
  29684. cache: options.nameCache && (options.nameCache.vars || {}),
  29685. eval: false,
  29686. ie8: false,
  29687. keep_classnames: false,
  29688. keep_fnames: false,
  29689. module: false,
  29690. nth_identifier: base54,
  29691. properties: false,
  29692. reserved: [],
  29693. safari10: false,
  29694. toplevel: false,
  29695. }, true);
  29696. if (options.mangle.properties) {
  29697. if (typeof options.mangle.properties != "object") {
  29698. options.mangle.properties = {};
  29699. }
  29700. if (options.mangle.properties.keep_quoted) {
  29701. quoted_props = options.mangle.properties.reserved;
  29702. if (!Array.isArray(quoted_props)) quoted_props = [];
  29703. options.mangle.properties.reserved = quoted_props;
  29704. }
  29705. if (options.nameCache && !("cache" in options.mangle.properties)) {
  29706. options.mangle.properties.cache = options.nameCache.props || {};
  29707. }
  29708. }
  29709. init_cache(options.mangle.cache);
  29710. init_cache(options.mangle.properties.cache);
  29711. }
  29712. if (options.sourceMap) {
  29713. options.sourceMap = defaults(options.sourceMap, {
  29714. asObject: false,
  29715. content: null,
  29716. filename: null,
  29717. includeSources: false,
  29718. root: null,
  29719. url: null,
  29720. }, true);
  29721. }
  29722. // -- Parse phase --
  29723. if (timings) timings.parse = Date.now();
  29724. var toplevel;
  29725. if (files instanceof AST_Toplevel) {
  29726. toplevel = files;
  29727. } else {
  29728. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  29729. files = [ files ];
  29730. }
  29731. options.parse = options.parse || {};
  29732. options.parse.toplevel = null;
  29733. if (options.parse.spidermonkey) {
  29734. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  29735. if (!toplevel) return files[name];
  29736. toplevel.body = toplevel.body.concat(files[name].body);
  29737. return toplevel;
  29738. }, null));
  29739. } else {
  29740. delete options.parse.spidermonkey;
  29741. for (var name in files) if (HOP(files, name)) {
  29742. options.parse.filename = name;
  29743. options.parse.toplevel = parse(files[name], options.parse);
  29744. if (options.sourceMap && options.sourceMap.content == "inline") {
  29745. if (Object.keys(files).length > 1)
  29746. throw new Error("inline source map only works with singular input");
  29747. options.sourceMap.content = read_source_map(files[name]);
  29748. }
  29749. }
  29750. }
  29751. if (options.parse.toplevel === null) {
  29752. throw new Error("no source file given");
  29753. }
  29754. toplevel = options.parse.toplevel;
  29755. }
  29756. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  29757. reserve_quoted_keys(toplevel, quoted_props);
  29758. }
  29759. var annotated_props;
  29760. if (options.mangle && options.mangle.properties) {
  29761. annotated_props = find_annotated_props(toplevel);
  29762. }
  29763. if (options.wrap) {
  29764. toplevel = toplevel.wrap_commonjs(options.wrap);
  29765. }
  29766. if (options.enclose) {
  29767. toplevel = toplevel.wrap_enclose(options.enclose);
  29768. }
  29769. if (timings) timings.rename = Date.now();
  29770. // -- Compress phase --
  29771. if (timings) timings.compress = Date.now();
  29772. if (options.compress) {
  29773. toplevel = new Compressor(options.compress, {
  29774. mangle_options: options.mangle
  29775. }).compress(toplevel);
  29776. }
  29777. // -- Mangle phase --
  29778. if (timings) timings.scope = Date.now();
  29779. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  29780. if (timings) timings.mangle = Date.now();
  29781. if (options.mangle) {
  29782. toplevel.compute_char_frequency(options.mangle);
  29783. toplevel.mangle_names(options.mangle);
  29784. toplevel = mangle_private_properties(toplevel, options.mangle);
  29785. }
  29786. if (timings) timings.properties = Date.now();
  29787. if (options.mangle && options.mangle.properties) {
  29788. toplevel = mangle_properties(toplevel, options.mangle.properties, annotated_props);
  29789. }
  29790. // Format phase
  29791. if (timings) timings.format = Date.now();
  29792. var result = {};
  29793. if (options.format.ast) {
  29794. result.ast = toplevel;
  29795. }
  29796. if (options.format.spidermonkey) {
  29797. result.ast = toplevel.to_mozilla_ast();
  29798. }
  29799. let format_options;
  29800. if (!HOP(options.format, "code") || options.format.code) {
  29801. // Make a shallow copy so that we can modify without mutating the user's input.
  29802. format_options = {...options.format};
  29803. if (!format_options.ast) {
  29804. // Destroy stuff to save RAM. (unless the deprecated `ast` option is on)
  29805. format_options._destroy_ast = true;
  29806. walk(toplevel, node => {
  29807. if (node instanceof AST_Scope) {
  29808. node.variables = undefined;
  29809. node.enclosed = undefined;
  29810. node.parent_scope = undefined;
  29811. }
  29812. if (node.block_scope) {
  29813. node.block_scope.variables = undefined;
  29814. node.block_scope.enclosed = undefined;
  29815. node.parent_scope = undefined;
  29816. }
  29817. });
  29818. }
  29819. if (options.sourceMap) {
  29820. if (options.sourceMap.includeSources && files instanceof AST_Toplevel) {
  29821. throw new Error("original source content unavailable");
  29822. }
  29823. format_options.source_map = yield* SourceMap({
  29824. file: options.sourceMap.filename,
  29825. orig: options.sourceMap.content,
  29826. root: options.sourceMap.root,
  29827. files: options.sourceMap.includeSources ? files : null,
  29828. });
  29829. }
  29830. delete format_options.ast;
  29831. delete format_options.code;
  29832. delete format_options.spidermonkey;
  29833. var stream = OutputStream(format_options);
  29834. toplevel.print(stream);
  29835. result.code = stream.get();
  29836. if (options.sourceMap) {
  29837. Object.defineProperty(result, "map", {
  29838. configurable: true,
  29839. enumerable: true,
  29840. get() {
  29841. const map = format_options.source_map.getEncoded();
  29842. return (result.map = options.sourceMap.asObject ? map : JSON.stringify(map));
  29843. },
  29844. set(value) {
  29845. Object.defineProperty(result, "map", {
  29846. value,
  29847. writable: true,
  29848. });
  29849. }
  29850. });
  29851. result.decoded_map = format_options.source_map.getDecoded();
  29852. if (options.sourceMap.url == "inline") {
  29853. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  29854. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  29855. } else if (options.sourceMap.url) {
  29856. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  29857. }
  29858. }
  29859. }
  29860. if (options.nameCache && options.mangle) {
  29861. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  29862. if (options.mangle.properties && options.mangle.properties.cache) {
  29863. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  29864. }
  29865. }
  29866. if (format_options && format_options.source_map) {
  29867. format_options.source_map.destroy();
  29868. }
  29869. if (timings) {
  29870. timings.end = Date.now();
  29871. result.timings = {
  29872. parse: 1e-3 * (timings.rename - timings.parse),
  29873. rename: 1e-3 * (timings.compress - timings.rename),
  29874. compress: 1e-3 * (timings.scope - timings.compress),
  29875. scope: 1e-3 * (timings.mangle - timings.scope),
  29876. mangle: 1e-3 * (timings.properties - timings.mangle),
  29877. properties: 1e-3 * (timings.format - timings.properties),
  29878. format: 1e-3 * (timings.end - timings.format),
  29879. total: 1e-3 * (timings.end - timings.start)
  29880. };
  29881. }
  29882. return result;
  29883. }
  29884. async function minify(files, options, _fs_module) {
  29885. const gen = minify_sync_or_async(files, options, _fs_module);
  29886. let yielded;
  29887. let val;
  29888. do {
  29889. val = gen.next(await yielded);
  29890. yielded = val.value;
  29891. } while (!val.done);
  29892. return val.value;
  29893. }
  29894. function minify_sync(files, options, _fs_module) {
  29895. const gen = minify_sync_or_async(files, options, _fs_module);
  29896. let yielded;
  29897. let val;
  29898. do {
  29899. if (yielded && typeof yielded.then === "function") {
  29900. throw new Error("minify_sync cannot be used with the legacy source-map module");
  29901. }
  29902. val = gen.next(yielded);
  29903. yielded = val.value;
  29904. } while (!val.done);
  29905. return val.value;
  29906. }
  29907. async function run_cli({ program, packageJson, fs, path }) {
  29908. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  29909. var files = {};
  29910. var options = {
  29911. compress: false,
  29912. mangle: false
  29913. };
  29914. const default_options = await _default_options();
  29915. program.version(packageJson.name + " " + packageJson.version);
  29916. program.parseArgv = program.parse;
  29917. program.parse = undefined;
  29918. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  29919. else if (process.argv.includes("options")) program.helpInformation = function() {
  29920. var text = [];
  29921. for (var option in default_options) {
  29922. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  29923. text.push(format_object(default_options[option]));
  29924. text.push("");
  29925. }
  29926. return text.join("\n");
  29927. };
  29928. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  29929. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  29930. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  29931. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  29932. program.option("-f, --format [options]", "Format options.", parse_js());
  29933. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  29934. program.option("-o, --output <file>", "Output file (default STDOUT).");
  29935. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  29936. program.option("--config-file <file>", "Read minify() options from JSON file.");
  29937. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  29938. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  29939. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  29940. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  29941. program.option("--keep-classnames", "Do not mangle/drop class names.");
  29942. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  29943. program.option("--module", "Input is an ES6 module");
  29944. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  29945. program.option("--rename", "Force symbol expansion.");
  29946. program.option("--no-rename", "Disable symbol expansion.");
  29947. program.option("--safari10", "Support non-standard Safari 10.");
  29948. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  29949. program.option("--timings", "Display operations run time on STDERR.");
  29950. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  29951. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  29952. program.arguments("[files...]").parseArgv(process.argv);
  29953. if (program.configFile) {
  29954. options = JSON.parse(read_file(program.configFile));
  29955. }
  29956. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  29957. fatal("ERROR: cannot write source map to STDOUT");
  29958. }
  29959. [
  29960. "compress",
  29961. "enclose",
  29962. "ie8",
  29963. "mangle",
  29964. "module",
  29965. "safari10",
  29966. "sourceMap",
  29967. "toplevel",
  29968. "wrap"
  29969. ].forEach(function(name) {
  29970. if (name in program) {
  29971. options[name] = program[name];
  29972. }
  29973. });
  29974. if ("ecma" in program) {
  29975. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  29976. const ecma = program.ecma | 0;
  29977. if (ecma > 5 && ecma < 2015)
  29978. options.ecma = ecma + 2009;
  29979. else
  29980. options.ecma = ecma;
  29981. }
  29982. if (program.format || program.beautify) {
  29983. const chosenOption = program.format || program.beautify;
  29984. options.format = typeof chosenOption === "object" ? chosenOption : {};
  29985. }
  29986. if (program.comments) {
  29987. if (typeof options.format != "object") options.format = {};
  29988. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  29989. }
  29990. if (program.define) {
  29991. if (typeof options.compress != "object") options.compress = {};
  29992. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  29993. for (var expr in program.define) {
  29994. options.compress.global_defs[expr] = program.define[expr];
  29995. }
  29996. }
  29997. if (program.keepClassnames) {
  29998. options.keep_classnames = true;
  29999. }
  30000. if (program.keepFnames) {
  30001. options.keep_fnames = true;
  30002. }
  30003. if (program.mangleProps) {
  30004. if (program.mangleProps.domprops) {
  30005. delete program.mangleProps.domprops;
  30006. } else {
  30007. if (typeof program.mangleProps != "object") program.mangleProps = {};
  30008. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  30009. }
  30010. if (typeof options.mangle != "object") options.mangle = {};
  30011. options.mangle.properties = program.mangleProps;
  30012. }
  30013. if (program.nameCache) {
  30014. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  30015. }
  30016. if (program.output == "ast") {
  30017. options.format = {
  30018. ast: true,
  30019. code: false
  30020. };
  30021. }
  30022. if (program.parse) {
  30023. if (!program.parse.acorn && !program.parse.spidermonkey) {
  30024. options.parse = program.parse;
  30025. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  30026. fatal("ERROR: inline source map only works with built-in parser");
  30027. }
  30028. }
  30029. if (~program.rawArgs.indexOf("--rename")) {
  30030. options.rename = true;
  30031. } else if (!program.rename) {
  30032. options.rename = false;
  30033. }
  30034. let convert_path = name => name;
  30035. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  30036. convert_path = function() {
  30037. var base = program.sourceMap.base;
  30038. delete options.sourceMap.base;
  30039. return function(name) {
  30040. return path.relative(base, name);
  30041. };
  30042. }();
  30043. }
  30044. let filesList;
  30045. if (options.files && options.files.length) {
  30046. filesList = options.files;
  30047. delete options.files;
  30048. } else if (program.args.length) {
  30049. filesList = program.args;
  30050. }
  30051. if (filesList) {
  30052. simple_glob(filesList).forEach(function(name) {
  30053. files[convert_path(name)] = read_file(name);
  30054. });
  30055. } else {
  30056. await new Promise((resolve) => {
  30057. var chunks = [];
  30058. process.stdin.setEncoding("utf8");
  30059. process.stdin.on("data", function(chunk) {
  30060. chunks.push(chunk);
  30061. }).on("end", function() {
  30062. files = [ chunks.join("") ];
  30063. resolve();
  30064. });
  30065. process.stdin.resume();
  30066. });
  30067. }
  30068. await run_cli();
  30069. function convert_ast(fn) {
  30070. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  30071. }
  30072. async function run_cli() {
  30073. var content = program.sourceMap && program.sourceMap.content;
  30074. if (content && content !== "inline") {
  30075. options.sourceMap.content = read_file(content, content);
  30076. }
  30077. if (program.timings) options.timings = true;
  30078. try {
  30079. if (program.parse) {
  30080. if (program.parse.acorn) {
  30081. files = convert_ast(function(toplevel, name) {
  30082. return require("acorn").parse(files[name], {
  30083. ecmaVersion: 2018,
  30084. locations: true,
  30085. program: toplevel,
  30086. sourceFile: name,
  30087. sourceType: options.module || program.parse.module ? "module" : "script"
  30088. });
  30089. });
  30090. } else if (program.parse.spidermonkey) {
  30091. files = convert_ast(function(toplevel, name) {
  30092. var obj = JSON.parse(files[name]);
  30093. if (!toplevel) return obj;
  30094. toplevel.body = toplevel.body.concat(obj.body);
  30095. return toplevel;
  30096. });
  30097. }
  30098. }
  30099. } catch (ex) {
  30100. fatal(ex);
  30101. }
  30102. let result;
  30103. try {
  30104. result = await minify(files, options, fs);
  30105. } catch (ex) {
  30106. if (ex.name == "SyntaxError") {
  30107. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  30108. var col = ex.col;
  30109. var lines = files[ex.filename].split(/\r?\n/);
  30110. var line = lines[ex.line - 1];
  30111. if (!line && !col) {
  30112. line = lines[ex.line - 2];
  30113. col = line.length;
  30114. }
  30115. if (line) {
  30116. var limit = 70;
  30117. if (col > limit) {
  30118. line = line.slice(col - limit);
  30119. col = limit;
  30120. }
  30121. print_error(line.slice(0, 80));
  30122. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  30123. }
  30124. }
  30125. if (ex.defs) {
  30126. print_error("Supported options:");
  30127. print_error(format_object(ex.defs));
  30128. }
  30129. fatal(ex);
  30130. return;
  30131. }
  30132. if (program.output == "ast") {
  30133. if (!options.compress && !options.mangle) {
  30134. result.ast.figure_out_scope({});
  30135. }
  30136. console.log(JSON.stringify(result.ast, function(key, value) {
  30137. if (value) switch (key) {
  30138. case "thedef":
  30139. return symdef(value);
  30140. case "enclosed":
  30141. return value.length ? value.map(symdef) : undefined;
  30142. case "variables":
  30143. case "globals":
  30144. return value.size ? collect_from_map(value, symdef) : undefined;
  30145. }
  30146. if (skip_keys.has(key)) return;
  30147. if (value instanceof AST_Token) return;
  30148. if (value instanceof Map) return;
  30149. if (value instanceof AST_Node) {
  30150. var result = {
  30151. _class: "AST_" + value.TYPE
  30152. };
  30153. if (value.block_scope) {
  30154. result.variables = value.block_scope.variables;
  30155. result.enclosed = value.block_scope.enclosed;
  30156. }
  30157. value.CTOR.PROPS.forEach(function(prop) {
  30158. if (prop !== "block_scope") {
  30159. result[prop] = value[prop];
  30160. }
  30161. });
  30162. return result;
  30163. }
  30164. return value;
  30165. }, 2));
  30166. } else if (program.output == "spidermonkey") {
  30167. try {
  30168. const minified = await minify(
  30169. result.code,
  30170. {
  30171. compress: false,
  30172. mangle: false,
  30173. format: {
  30174. ast: true,
  30175. code: false
  30176. }
  30177. },
  30178. fs
  30179. );
  30180. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  30181. } catch (ex) {
  30182. fatal(ex);
  30183. return;
  30184. }
  30185. } else if (program.output) {
  30186. fs.writeFileSync(program.output, result.code);
  30187. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  30188. fs.writeFileSync(program.output + ".map", result.map);
  30189. }
  30190. } else {
  30191. console.log(result.code);
  30192. }
  30193. if (program.nameCache) {
  30194. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  30195. }
  30196. if (result.timings) for (var phase in result.timings) {
  30197. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  30198. }
  30199. }
  30200. function fatal(message) {
  30201. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  30202. print_error(message);
  30203. process.exit(1);
  30204. }
  30205. // A file glob function that only supports "*" and "?" wildcards in the basename.
  30206. // Example: "foo/bar/*baz??.*.js"
  30207. // Argument `glob` may be a string or an array of strings.
  30208. // Returns an array of strings. Garbage in, garbage out.
  30209. function simple_glob(glob) {
  30210. if (Array.isArray(glob)) {
  30211. return [].concat.apply([], glob.map(simple_glob));
  30212. }
  30213. if (glob && glob.match(/[*?]/)) {
  30214. var dir = path.dirname(glob);
  30215. try {
  30216. var entries = fs.readdirSync(dir);
  30217. } catch (ex) {}
  30218. if (entries) {
  30219. var pattern = "^" + path.basename(glob)
  30220. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  30221. .replace(/\*/g, "[^/\\\\]*")
  30222. .replace(/\?/g, "[^/\\\\]") + "$";
  30223. var mod = process.platform === "win32" ? "i" : "";
  30224. var rx = new RegExp(pattern, mod);
  30225. var results = entries.filter(function(name) {
  30226. return rx.test(name);
  30227. }).map(function(name) {
  30228. return path.join(dir, name);
  30229. });
  30230. if (results.length) return results;
  30231. }
  30232. }
  30233. return [ glob ];
  30234. }
  30235. function read_file(path, default_value) {
  30236. try {
  30237. return fs.readFileSync(path, "utf8");
  30238. } catch (ex) {
  30239. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  30240. fatal(ex);
  30241. }
  30242. }
  30243. function parse_js(flag) {
  30244. return function(value, options) {
  30245. options = options || {};
  30246. try {
  30247. walk(parse(value, { expression: true }), node => {
  30248. if (node instanceof AST_Assign) {
  30249. var name = node.left.print_to_string();
  30250. var value = node.right;
  30251. if (flag) {
  30252. options[name] = value;
  30253. } else if (value instanceof AST_Array) {
  30254. options[name] = value.elements.map(to_string);
  30255. } else if (value instanceof AST_RegExp) {
  30256. value = value.value;
  30257. options[name] = new RegExp(value.source, value.flags);
  30258. } else {
  30259. options[name] = to_string(value);
  30260. }
  30261. return true;
  30262. }
  30263. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  30264. var name = node.print_to_string();
  30265. options[name] = true;
  30266. return true;
  30267. }
  30268. if (!(node instanceof AST_Sequence)) throw node;
  30269. function to_string(value) {
  30270. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  30271. quote_keys: true
  30272. });
  30273. }
  30274. });
  30275. } catch(ex) {
  30276. if (flag) {
  30277. fatal("Error parsing arguments for '" + flag + "': " + value);
  30278. } else {
  30279. options[value] = null;
  30280. }
  30281. }
  30282. return options;
  30283. };
  30284. }
  30285. function symdef(def) {
  30286. var ret = (1e6 + def.id) + " " + def.name;
  30287. if (def.mangled_name) ret += " " + def.mangled_name;
  30288. return ret;
  30289. }
  30290. function collect_from_map(map, callback) {
  30291. var result = [];
  30292. map.forEach(function (def) {
  30293. result.push(callback(def));
  30294. });
  30295. return result;
  30296. }
  30297. function format_object(obj) {
  30298. var lines = [];
  30299. var padding = "";
  30300. Object.keys(obj).map(function(name) {
  30301. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  30302. return [ name, JSON.stringify(obj[name]) ];
  30303. }).forEach(function(tokens) {
  30304. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  30305. });
  30306. return lines.join("\n");
  30307. }
  30308. function print_error(msg) {
  30309. process.stderr.write(msg);
  30310. process.stderr.write("\n");
  30311. }
  30312. function describe_ast() {
  30313. var out = OutputStream({ beautify: true });
  30314. function doitem(ctor) {
  30315. out.print("AST_" + ctor.TYPE);
  30316. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  30317. if (props.length > 0) {
  30318. out.space();
  30319. out.with_parens(function() {
  30320. props.forEach(function(prop, i) {
  30321. if (i) out.space();
  30322. out.print(prop);
  30323. });
  30324. });
  30325. }
  30326. if (ctor.documentation) {
  30327. out.space();
  30328. out.print_string(ctor.documentation);
  30329. }
  30330. if (ctor.SUBCLASSES.length > 0) {
  30331. out.space();
  30332. out.with_block(function() {
  30333. ctor.SUBCLASSES.forEach(function(ctor) {
  30334. out.indent();
  30335. doitem(ctor);
  30336. out.newline();
  30337. });
  30338. });
  30339. }
  30340. }
  30341. doitem(AST_Node);
  30342. return out + "\n";
  30343. }
  30344. }
  30345. async function _default_options() {
  30346. const defs = {};
  30347. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  30348. const options = infer_options({
  30349. [component]: {0: 0}
  30350. });
  30351. if (options) defs[component] = options;
  30352. });
  30353. return defs;
  30354. }
  30355. async function infer_options(options) {
  30356. try {
  30357. await minify("", options);
  30358. } catch (error) {
  30359. return error.defs;
  30360. }
  30361. }
  30362. exports._default_options = _default_options;
  30363. exports._run_cli = run_cli;
  30364. exports.minify = minify;
  30365. exports.minify_sync = minify_sync;
  30366. })));