terser.js 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524
  1. 'use strict';
  2. var require$$0 = require('fs');
  3. var require$$1 = require('path');
  4. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
  5. var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
  6. var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
  7. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  8. var bundle_min$1 = {exports: {}};
  9. var sourceMap = {};
  10. var sourceMapGenerator = {};
  11. var base64Vlq = {};
  12. var base64$1 = {};
  13. /* -*- Mode: js; js-indent-level: 2; -*- */
  14. /*
  15. * Copyright 2011 Mozilla Foundation and contributors
  16. * Licensed under the New BSD license. See LICENSE or:
  17. * http://opensource.org/licenses/BSD-3-Clause
  18. */
  19. const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
  20. /**
  21. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  22. */
  23. base64$1.encode = function(number) {
  24. if (0 <= number && number < intToCharMap.length) {
  25. return intToCharMap[number];
  26. }
  27. throw new TypeError("Must be between 0 and 63: " + number);
  28. };
  29. /* -*- Mode: js; js-indent-level: 2; -*- */
  30. /*
  31. * Copyright 2011 Mozilla Foundation and contributors
  32. * Licensed under the New BSD license. See LICENSE or:
  33. * http://opensource.org/licenses/BSD-3-Clause
  34. *
  35. * Based on the Base 64 VLQ implementation in Closure Compiler:
  36. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  37. *
  38. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  39. * Redistribution and use in source and binary forms, with or without
  40. * modification, are permitted provided that the following conditions are
  41. * met:
  42. *
  43. * * Redistributions of source code must retain the above copyright
  44. * notice, this list of conditions and the following disclaimer.
  45. * * Redistributions in binary form must reproduce the above
  46. * copyright notice, this list of conditions and the following
  47. * disclaimer in the documentation and/or other materials provided
  48. * with the distribution.
  49. * * Neither the name of Google Inc. nor the names of its
  50. * contributors may be used to endorse or promote products derived
  51. * from this software without specific prior written permission.
  52. *
  53. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  54. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  55. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  56. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  57. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  58. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  59. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  60. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  61. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  62. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  63. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  64. */
  65. const base64 = base64$1;
  66. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  67. // length quantities we use in the source map spec, the first bit is the sign,
  68. // the next four bits are the actual value, and the 6th bit is the
  69. // continuation bit. The continuation bit tells us whether there are more
  70. // digits in this value following this digit.
  71. //
  72. // Continuation
  73. // | Sign
  74. // | |
  75. // V V
  76. // 101011
  77. const VLQ_BASE_SHIFT = 5;
  78. // binary: 100000
  79. const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  80. // binary: 011111
  81. const VLQ_BASE_MASK = VLQ_BASE - 1;
  82. // binary: 100000
  83. const VLQ_CONTINUATION_BIT = VLQ_BASE;
  84. /**
  85. * Converts from a two-complement value to a value where the sign bit is
  86. * placed in the least significant bit. For example, as decimals:
  87. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  88. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  89. */
  90. function toVLQSigned(aValue) {
  91. return aValue < 0
  92. ? ((-aValue) << 1) + 1
  93. : (aValue << 1) + 0;
  94. }
  95. /**
  96. * Returns the base 64 VLQ encoded value.
  97. */
  98. base64Vlq.encode = function base64VLQ_encode(aValue) {
  99. let encoded = "";
  100. let digit;
  101. let vlq = toVLQSigned(aValue);
  102. do {
  103. digit = vlq & VLQ_BASE_MASK;
  104. vlq >>>= VLQ_BASE_SHIFT;
  105. if (vlq > 0) {
  106. // There are still more digits in this value, so we must make sure the
  107. // continuation bit is marked.
  108. digit |= VLQ_CONTINUATION_BIT;
  109. }
  110. encoded += base64.encode(digit);
  111. } while (vlq > 0);
  112. return encoded;
  113. };
  114. var util$4 = {};
  115. /* -*- Mode: js; js-indent-level: 2; -*- */
  116. (function (exports) {
  117. /*
  118. * Copyright 2011 Mozilla Foundation and contributors
  119. * Licensed under the New BSD license. See LICENSE or:
  120. * http://opensource.org/licenses/BSD-3-Clause
  121. */
  122. /**
  123. * This is a helper function for getting values from parameter/options
  124. * objects.
  125. *
  126. * @param args The object we are extracting values from
  127. * @param name The name of the property we are getting.
  128. * @param defaultValue An optional value to return if the property is missing
  129. * from the object. If this is not specified and the property is missing, an
  130. * error will be thrown.
  131. */
  132. function getArg(aArgs, aName, aDefaultValue) {
  133. if (aName in aArgs) {
  134. return aArgs[aName];
  135. } else if (arguments.length === 3) {
  136. return aDefaultValue;
  137. }
  138. throw new Error('"' + aName + '" is a required argument.');
  139. }
  140. exports.getArg = getArg;
  141. const urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  142. const dataUrlRegexp = /^data:.+\,.+$/;
  143. function urlParse(aUrl) {
  144. const match = aUrl.match(urlRegexp);
  145. if (!match) {
  146. return null;
  147. }
  148. return {
  149. scheme: match[1],
  150. auth: match[2],
  151. host: match[3],
  152. port: match[4],
  153. path: match[5]
  154. };
  155. }
  156. exports.urlParse = urlParse;
  157. function urlGenerate(aParsedUrl) {
  158. let url = "";
  159. if (aParsedUrl.scheme) {
  160. url += aParsedUrl.scheme + ":";
  161. }
  162. url += "//";
  163. if (aParsedUrl.auth) {
  164. url += aParsedUrl.auth + "@";
  165. }
  166. if (aParsedUrl.host) {
  167. url += aParsedUrl.host;
  168. }
  169. if (aParsedUrl.port) {
  170. url += ":" + aParsedUrl.port;
  171. }
  172. if (aParsedUrl.path) {
  173. url += aParsedUrl.path;
  174. }
  175. return url;
  176. }
  177. exports.urlGenerate = urlGenerate;
  178. const MAX_CACHED_INPUTS = 32;
  179. /**
  180. * Takes some function `f(input) -> result` and returns a memoized version of
  181. * `f`.
  182. *
  183. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  184. * memoization is a dumb-simple, linear least-recently-used cache.
  185. */
  186. function lruMemoize(f) {
  187. const cache = [];
  188. return function(input) {
  189. for (let i = 0; i < cache.length; i++) {
  190. if (cache[i].input === input) {
  191. const temp = cache[0];
  192. cache[0] = cache[i];
  193. cache[i] = temp;
  194. return cache[0].result;
  195. }
  196. }
  197. const result = f(input);
  198. cache.unshift({
  199. input,
  200. result,
  201. });
  202. if (cache.length > MAX_CACHED_INPUTS) {
  203. cache.pop();
  204. }
  205. return result;
  206. };
  207. }
  208. /**
  209. * Normalizes a path, or the path portion of a URL:
  210. *
  211. * - Replaces consecutive slashes with one slash.
  212. * - Removes unnecessary '.' parts.
  213. * - Removes unnecessary '<dir>/..' parts.
  214. *
  215. * Based on code in the Node.js 'path' core module.
  216. *
  217. * @param aPath The path or url to normalize.
  218. */
  219. const normalize = lruMemoize(function normalize(aPath) {
  220. let path = aPath;
  221. const url = urlParse(aPath);
  222. if (url) {
  223. if (!url.path) {
  224. return aPath;
  225. }
  226. path = url.path;
  227. }
  228. const isAbsolute = exports.isAbsolute(path);
  229. // Split the path into parts between `/` characters. This is much faster than
  230. // using `.split(/\/+/g)`.
  231. const parts = [];
  232. let start = 0;
  233. let i = 0;
  234. while (true) {
  235. start = i;
  236. i = path.indexOf("/", start);
  237. if (i === -1) {
  238. parts.push(path.slice(start));
  239. break;
  240. } else {
  241. parts.push(path.slice(start, i));
  242. while (i < path.length && path[i] === "/") {
  243. i++;
  244. }
  245. }
  246. }
  247. let up = 0;
  248. for (i = parts.length - 1; i >= 0; i--) {
  249. const part = parts[i];
  250. if (part === ".") {
  251. parts.splice(i, 1);
  252. } else if (part === "..") {
  253. up++;
  254. } else if (up > 0) {
  255. if (part === "") {
  256. // The first part is blank if the path is absolute. Trying to go
  257. // above the root is a no-op. Therefore we can remove all '..' parts
  258. // directly after the root.
  259. parts.splice(i + 1, up);
  260. up = 0;
  261. } else {
  262. parts.splice(i, 2);
  263. up--;
  264. }
  265. }
  266. }
  267. path = parts.join("/");
  268. if (path === "") {
  269. path = isAbsolute ? "/" : ".";
  270. }
  271. if (url) {
  272. url.path = path;
  273. return urlGenerate(url);
  274. }
  275. return path;
  276. });
  277. exports.normalize = normalize;
  278. /**
  279. * Joins two paths/URLs.
  280. *
  281. * @param aRoot The root path or URL.
  282. * @param aPath The path or URL to be joined with the root.
  283. *
  284. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  285. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  286. * first.
  287. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  288. * is updated with the result and aRoot is returned. Otherwise the result
  289. * is returned.
  290. * - If aPath is absolute, the result is aPath.
  291. * - Otherwise the two paths are joined with a slash.
  292. * - Joining for example 'http://' and 'www.example.com' is also supported.
  293. */
  294. function join(aRoot, aPath) {
  295. if (aRoot === "") {
  296. aRoot = ".";
  297. }
  298. if (aPath === "") {
  299. aPath = ".";
  300. }
  301. const aPathUrl = urlParse(aPath);
  302. const aRootUrl = urlParse(aRoot);
  303. if (aRootUrl) {
  304. aRoot = aRootUrl.path || "/";
  305. }
  306. // `join(foo, '//www.example.org')`
  307. if (aPathUrl && !aPathUrl.scheme) {
  308. if (aRootUrl) {
  309. aPathUrl.scheme = aRootUrl.scheme;
  310. }
  311. return urlGenerate(aPathUrl);
  312. }
  313. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  314. return aPath;
  315. }
  316. // `join('http://', 'www.example.com')`
  317. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  318. aRootUrl.host = aPath;
  319. return urlGenerate(aRootUrl);
  320. }
  321. const joined = aPath.charAt(0) === "/"
  322. ? aPath
  323. : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
  324. if (aRootUrl) {
  325. aRootUrl.path = joined;
  326. return urlGenerate(aRootUrl);
  327. }
  328. return joined;
  329. }
  330. exports.join = join;
  331. exports.isAbsolute = function(aPath) {
  332. return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
  333. };
  334. /**
  335. * Make a path relative to a URL or another path.
  336. *
  337. * @param aRoot The root path or URL.
  338. * @param aPath The path or URL to be made relative to aRoot.
  339. */
  340. function relative(aRoot, aPath) {
  341. if (aRoot === "") {
  342. aRoot = ".";
  343. }
  344. aRoot = aRoot.replace(/\/$/, "");
  345. // It is possible for the path to be above the root. In this case, simply
  346. // checking whether the root is a prefix of the path won't work. Instead, we
  347. // need to remove components from the root one by one, until either we find
  348. // a prefix that fits, or we run out of components to remove.
  349. let level = 0;
  350. while (aPath.indexOf(aRoot + "/") !== 0) {
  351. const index = aRoot.lastIndexOf("/");
  352. if (index < 0) {
  353. return aPath;
  354. }
  355. // If the only part of the root that is left is the scheme (i.e. http://,
  356. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  357. // have exhausted all components, so the path is not relative to the root.
  358. aRoot = aRoot.slice(0, index);
  359. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  360. return aPath;
  361. }
  362. ++level;
  363. }
  364. // Make sure we add a "../" for each component we removed from the root.
  365. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  366. }
  367. exports.relative = relative;
  368. const supportsNullProto = (function() {
  369. const obj = Object.create(null);
  370. return !("__proto__" in obj);
  371. }());
  372. function identity(s) {
  373. return s;
  374. }
  375. /**
  376. * Because behavior goes wacky when you set `__proto__` on objects, we
  377. * have to prefix all the strings in our set with an arbitrary character.
  378. *
  379. * See https://github.com/mozilla/source-map/pull/31 and
  380. * https://github.com/mozilla/source-map/issues/30
  381. *
  382. * @param String aStr
  383. */
  384. function toSetString(aStr) {
  385. if (isProtoString(aStr)) {
  386. return "$" + aStr;
  387. }
  388. return aStr;
  389. }
  390. exports.toSetString = supportsNullProto ? identity : toSetString;
  391. function fromSetString(aStr) {
  392. if (isProtoString(aStr)) {
  393. return aStr.slice(1);
  394. }
  395. return aStr;
  396. }
  397. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  398. function isProtoString(s) {
  399. if (!s) {
  400. return false;
  401. }
  402. const length = s.length;
  403. if (length < 9 /* "__proto__".length */) {
  404. return false;
  405. }
  406. /* eslint-disable no-multi-spaces */
  407. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  408. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  409. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  410. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  411. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  412. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  413. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  414. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  415. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  416. return false;
  417. }
  418. /* eslint-enable no-multi-spaces */
  419. for (let i = length - 10; i >= 0; i--) {
  420. if (s.charCodeAt(i) !== 36 /* '$' */) {
  421. return false;
  422. }
  423. }
  424. return true;
  425. }
  426. /**
  427. * Comparator between two mappings where the original positions are compared.
  428. *
  429. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  430. * mappings with the same original source/line/column, but different generated
  431. * line and column the same. Useful when searching for a mapping with a
  432. * stubbed out mapping.
  433. */
  434. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  435. let cmp = strcmp(mappingA.source, mappingB.source);
  436. if (cmp !== 0) {
  437. return cmp;
  438. }
  439. cmp = mappingA.originalLine - mappingB.originalLine;
  440. if (cmp !== 0) {
  441. return cmp;
  442. }
  443. cmp = mappingA.originalColumn - mappingB.originalColumn;
  444. if (cmp !== 0 || onlyCompareOriginal) {
  445. return cmp;
  446. }
  447. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  448. if (cmp !== 0) {
  449. return cmp;
  450. }
  451. cmp = mappingA.generatedLine - mappingB.generatedLine;
  452. if (cmp !== 0) {
  453. return cmp;
  454. }
  455. return strcmp(mappingA.name, mappingB.name);
  456. }
  457. exports.compareByOriginalPositions = compareByOriginalPositions;
  458. /**
  459. * Comparator between two mappings with deflated source and name indices where
  460. * the generated positions are compared.
  461. *
  462. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  463. * mappings with the same generated line and column, but different
  464. * source/name/original line and column the same. Useful when searching for a
  465. * mapping with a stubbed out mapping.
  466. */
  467. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  468. let cmp = mappingA.generatedLine - mappingB.generatedLine;
  469. if (cmp !== 0) {
  470. return cmp;
  471. }
  472. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  473. if (cmp !== 0 || onlyCompareGenerated) {
  474. return cmp;
  475. }
  476. cmp = strcmp(mappingA.source, mappingB.source);
  477. if (cmp !== 0) {
  478. return cmp;
  479. }
  480. cmp = mappingA.originalLine - mappingB.originalLine;
  481. if (cmp !== 0) {
  482. return cmp;
  483. }
  484. cmp = mappingA.originalColumn - mappingB.originalColumn;
  485. if (cmp !== 0) {
  486. return cmp;
  487. }
  488. return strcmp(mappingA.name, mappingB.name);
  489. }
  490. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  491. function strcmp(aStr1, aStr2) {
  492. if (aStr1 === aStr2) {
  493. return 0;
  494. }
  495. if (aStr1 === null) {
  496. return 1; // aStr2 !== null
  497. }
  498. if (aStr2 === null) {
  499. return -1; // aStr1 !== null
  500. }
  501. if (aStr1 > aStr2) {
  502. return 1;
  503. }
  504. return -1;
  505. }
  506. /**
  507. * Comparator between two mappings with inflated source and name strings where
  508. * the generated positions are compared.
  509. */
  510. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  511. let cmp = mappingA.generatedLine - mappingB.generatedLine;
  512. if (cmp !== 0) {
  513. return cmp;
  514. }
  515. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  516. if (cmp !== 0) {
  517. return cmp;
  518. }
  519. cmp = strcmp(mappingA.source, mappingB.source);
  520. if (cmp !== 0) {
  521. return cmp;
  522. }
  523. cmp = mappingA.originalLine - mappingB.originalLine;
  524. if (cmp !== 0) {
  525. return cmp;
  526. }
  527. cmp = mappingA.originalColumn - mappingB.originalColumn;
  528. if (cmp !== 0) {
  529. return cmp;
  530. }
  531. return strcmp(mappingA.name, mappingB.name);
  532. }
  533. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  534. /**
  535. * Strip any JSON XSSI avoidance prefix from the string (as documented
  536. * in the source maps specification), and then parse the string as
  537. * JSON.
  538. */
  539. function parseSourceMapInput(str) {
  540. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
  541. }
  542. exports.parseSourceMapInput = parseSourceMapInput;
  543. /**
  544. * Compute the URL of a source given the the source root, the source's
  545. * URL, and the source map's URL.
  546. */
  547. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  548. sourceURL = sourceURL || "";
  549. if (sourceRoot) {
  550. // This follows what Chrome does.
  551. if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") {
  552. sourceRoot += "/";
  553. }
  554. // The spec says:
  555. // Line 4: An optional source root, useful for relocating source
  556. // files on a server or removing repeated values in the
  557. // “sources” entry. This value is prepended to the individual
  558. // entries in the “source” field.
  559. sourceURL = sourceRoot + sourceURL;
  560. }
  561. // Historically, SourceMapConsumer did not take the sourceMapURL as
  562. // a parameter. This mode is still somewhat supported, which is why
  563. // this code block is conditional. However, it's preferable to pass
  564. // the source map URL to SourceMapConsumer, so that this function
  565. // can implement the source URL resolution algorithm as outlined in
  566. // the spec. This block is basically the equivalent of:
  567. // new URL(sourceURL, sourceMapURL).toString()
  568. // ... except it avoids using URL, which wasn't available in the
  569. // older releases of node still supported by this library.
  570. //
  571. // The spec says:
  572. // If the sources are not absolute URLs after prepending of the
  573. // “sourceRoot”, the sources are resolved relative to the
  574. // SourceMap (like resolving script src in a html document).
  575. if (sourceMapURL) {
  576. const parsed = urlParse(sourceMapURL);
  577. if (!parsed) {
  578. throw new Error("sourceMapURL could not be parsed");
  579. }
  580. if (parsed.path) {
  581. // Strip the last path component, but keep the "/".
  582. const index = parsed.path.lastIndexOf("/");
  583. if (index >= 0) {
  584. parsed.path = parsed.path.substring(0, index + 1);
  585. }
  586. }
  587. sourceURL = join(urlGenerate(parsed), sourceURL);
  588. }
  589. return normalize(sourceURL);
  590. }
  591. exports.computeSourceURL = computeSourceURL;
  592. }(util$4));
  593. var arraySet = {};
  594. /* -*- Mode: js; js-indent-level: 2; -*- */
  595. /*
  596. * Copyright 2011 Mozilla Foundation and contributors
  597. * Licensed under the New BSD license. See LICENSE or:
  598. * http://opensource.org/licenses/BSD-3-Clause
  599. */
  600. /**
  601. * A data structure which is a combination of an array and a set. Adding a new
  602. * member is O(1), testing for membership is O(1), and finding the index of an
  603. * element is O(1). Removing elements from the set is not supported. Only
  604. * strings are supported for membership.
  605. */
  606. class ArraySet$2 {
  607. constructor() {
  608. this._array = [];
  609. this._set = new Map();
  610. }
  611. /**
  612. * Static method for creating ArraySet instances from an existing array.
  613. */
  614. static fromArray(aArray, aAllowDuplicates) {
  615. const set = new ArraySet$2();
  616. for (let i = 0, len = aArray.length; i < len; i++) {
  617. set.add(aArray[i], aAllowDuplicates);
  618. }
  619. return set;
  620. }
  621. /**
  622. * Return how many unique items are in this ArraySet. If duplicates have been
  623. * added, than those do not count towards the size.
  624. *
  625. * @returns Number
  626. */
  627. size() {
  628. return this._set.size;
  629. }
  630. /**
  631. * Add the given string to this set.
  632. *
  633. * @param String aStr
  634. */
  635. add(aStr, aAllowDuplicates) {
  636. const isDuplicate = this.has(aStr);
  637. const idx = this._array.length;
  638. if (!isDuplicate || aAllowDuplicates) {
  639. this._array.push(aStr);
  640. }
  641. if (!isDuplicate) {
  642. this._set.set(aStr, idx);
  643. }
  644. }
  645. /**
  646. * Is the given string a member of this set?
  647. *
  648. * @param String aStr
  649. */
  650. has(aStr) {
  651. return this._set.has(aStr);
  652. }
  653. /**
  654. * What is the index of the given string in the array?
  655. *
  656. * @param String aStr
  657. */
  658. indexOf(aStr) {
  659. const idx = this._set.get(aStr);
  660. if (idx >= 0) {
  661. return idx;
  662. }
  663. throw new Error('"' + aStr + '" is not in the set.');
  664. }
  665. /**
  666. * What is the element at the given index?
  667. *
  668. * @param Number aIdx
  669. */
  670. at(aIdx) {
  671. if (aIdx >= 0 && aIdx < this._array.length) {
  672. return this._array[aIdx];
  673. }
  674. throw new Error("No element indexed by " + aIdx);
  675. }
  676. /**
  677. * Returns the array representation of this set (which has the proper indices
  678. * indicated by indexOf). Note that this is a copy of the internal array used
  679. * for storing the members so that no one can mess with internal state.
  680. */
  681. toArray() {
  682. return this._array.slice();
  683. }
  684. }
  685. arraySet.ArraySet = ArraySet$2;
  686. var mappingList = {};
  687. /* -*- Mode: js; js-indent-level: 2; -*- */
  688. /*
  689. * Copyright 2014 Mozilla Foundation and contributors
  690. * Licensed under the New BSD license. See LICENSE or:
  691. * http://opensource.org/licenses/BSD-3-Clause
  692. */
  693. const util$3 = util$4;
  694. /**
  695. * Determine whether mappingB is after mappingA with respect to generated
  696. * position.
  697. */
  698. function generatedPositionAfter(mappingA, mappingB) {
  699. // Optimized for most common case
  700. const lineA = mappingA.generatedLine;
  701. const lineB = mappingB.generatedLine;
  702. const columnA = mappingA.generatedColumn;
  703. const columnB = mappingB.generatedColumn;
  704. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  705. util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  706. }
  707. /**
  708. * A data structure to provide a sorted view of accumulated mappings in a
  709. * performance conscious manner. It trades a negligible overhead in general
  710. * case for a large speedup in case of mappings being added in order.
  711. */
  712. class MappingList$1 {
  713. constructor() {
  714. this._array = [];
  715. this._sorted = true;
  716. // Serves as infimum
  717. this._last = {generatedLine: -1, generatedColumn: 0};
  718. }
  719. /**
  720. * Iterate through internal items. This method takes the same arguments that
  721. * `Array.prototype.forEach` takes.
  722. *
  723. * NOTE: The order of the mappings is NOT guaranteed.
  724. */
  725. unsortedForEach(aCallback, aThisArg) {
  726. this._array.forEach(aCallback, aThisArg);
  727. }
  728. /**
  729. * Add the given source mapping.
  730. *
  731. * @param Object aMapping
  732. */
  733. add(aMapping) {
  734. if (generatedPositionAfter(this._last, aMapping)) {
  735. this._last = aMapping;
  736. this._array.push(aMapping);
  737. } else {
  738. this._sorted = false;
  739. this._array.push(aMapping);
  740. }
  741. }
  742. /**
  743. * Returns the flat, sorted array of mappings. The mappings are sorted by
  744. * generated position.
  745. *
  746. * WARNING: This method returns internal data without copying, for
  747. * performance. The return value must NOT be mutated, and should be treated as
  748. * an immutable borrow. If you want to take ownership, you must make your own
  749. * copy.
  750. */
  751. toArray() {
  752. if (!this._sorted) {
  753. this._array.sort(util$3.compareByGeneratedPositionsInflated);
  754. this._sorted = true;
  755. }
  756. return this._array;
  757. }
  758. }
  759. mappingList.MappingList = MappingList$1;
  760. /* -*- Mode: js; js-indent-level: 2; -*- */
  761. /*
  762. * Copyright 2011 Mozilla Foundation and contributors
  763. * Licensed under the New BSD license. See LICENSE or:
  764. * http://opensource.org/licenses/BSD-3-Clause
  765. */
  766. const base64VLQ = base64Vlq;
  767. const util$2 = util$4;
  768. const ArraySet$1 = arraySet.ArraySet;
  769. const MappingList = mappingList.MappingList;
  770. /**
  771. * An instance of the SourceMapGenerator represents a source map which is
  772. * being built incrementally. You may pass an object with the following
  773. * properties:
  774. *
  775. * - file: The filename of the generated source.
  776. * - sourceRoot: A root for all relative URLs in this source map.
  777. */
  778. class SourceMapGenerator$1 {
  779. constructor(aArgs) {
  780. if (!aArgs) {
  781. aArgs = {};
  782. }
  783. this._file = util$2.getArg(aArgs, "file", null);
  784. this._sourceRoot = util$2.getArg(aArgs, "sourceRoot", null);
  785. this._skipValidation = util$2.getArg(aArgs, "skipValidation", false);
  786. this._sources = new ArraySet$1();
  787. this._names = new ArraySet$1();
  788. this._mappings = new MappingList();
  789. this._sourcesContents = null;
  790. }
  791. /**
  792. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  793. *
  794. * @param aSourceMapConsumer The SourceMap.
  795. */
  796. static fromSourceMap(aSourceMapConsumer) {
  797. const sourceRoot = aSourceMapConsumer.sourceRoot;
  798. const generator = new SourceMapGenerator$1({
  799. file: aSourceMapConsumer.file,
  800. sourceRoot
  801. });
  802. aSourceMapConsumer.eachMapping(function(mapping) {
  803. const newMapping = {
  804. generated: {
  805. line: mapping.generatedLine,
  806. column: mapping.generatedColumn
  807. }
  808. };
  809. if (mapping.source != null) {
  810. newMapping.source = mapping.source;
  811. if (sourceRoot != null) {
  812. newMapping.source = util$2.relative(sourceRoot, newMapping.source);
  813. }
  814. newMapping.original = {
  815. line: mapping.originalLine,
  816. column: mapping.originalColumn
  817. };
  818. if (mapping.name != null) {
  819. newMapping.name = mapping.name;
  820. }
  821. }
  822. generator.addMapping(newMapping);
  823. });
  824. aSourceMapConsumer.sources.forEach(function(sourceFile) {
  825. let sourceRelative = sourceFile;
  826. if (sourceRoot !== null) {
  827. sourceRelative = util$2.relative(sourceRoot, sourceFile);
  828. }
  829. if (!generator._sources.has(sourceRelative)) {
  830. generator._sources.add(sourceRelative);
  831. }
  832. const content = aSourceMapConsumer.sourceContentFor(sourceFile);
  833. if (content != null) {
  834. generator.setSourceContent(sourceFile, content);
  835. }
  836. });
  837. return generator;
  838. }
  839. /**
  840. * Add a single mapping from original source line and column to the generated
  841. * source's line and column for this source map being created. The mapping
  842. * object should have the following properties:
  843. *
  844. * - generated: An object with the generated line and column positions.
  845. * - original: An object with the original line and column positions.
  846. * - source: The original source file (relative to the sourceRoot).
  847. * - name: An optional original token name for this mapping.
  848. */
  849. addMapping(aArgs) {
  850. const generated = util$2.getArg(aArgs, "generated");
  851. const original = util$2.getArg(aArgs, "original", null);
  852. let source = util$2.getArg(aArgs, "source", null);
  853. let name = util$2.getArg(aArgs, "name", null);
  854. if (!this._skipValidation) {
  855. this._validateMapping(generated, original, source, name);
  856. }
  857. if (source != null) {
  858. source = String(source);
  859. if (!this._sources.has(source)) {
  860. this._sources.add(source);
  861. }
  862. }
  863. if (name != null) {
  864. name = String(name);
  865. if (!this._names.has(name)) {
  866. this._names.add(name);
  867. }
  868. }
  869. this._mappings.add({
  870. generatedLine: generated.line,
  871. generatedColumn: generated.column,
  872. originalLine: original != null && original.line,
  873. originalColumn: original != null && original.column,
  874. source,
  875. name
  876. });
  877. }
  878. /**
  879. * Set the source content for a source file.
  880. */
  881. setSourceContent(aSourceFile, aSourceContent) {
  882. let source = aSourceFile;
  883. if (this._sourceRoot != null) {
  884. source = util$2.relative(this._sourceRoot, source);
  885. }
  886. if (aSourceContent != null) {
  887. // Add the source content to the _sourcesContents map.
  888. // Create a new _sourcesContents map if the property is null.
  889. if (!this._sourcesContents) {
  890. this._sourcesContents = Object.create(null);
  891. }
  892. this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
  893. } else if (this._sourcesContents) {
  894. // Remove the source file from the _sourcesContents map.
  895. // If the _sourcesContents map is empty, set the property to null.
  896. delete this._sourcesContents[util$2.toSetString(source)];
  897. if (Object.keys(this._sourcesContents).length === 0) {
  898. this._sourcesContents = null;
  899. }
  900. }
  901. }
  902. /**
  903. * Applies the mappings of a sub-source-map for a specific source file to the
  904. * source map being generated. Each mapping to the supplied source file is
  905. * rewritten using the supplied source map. Note: The resolution for the
  906. * resulting mappings is the minimium of this map and the supplied map.
  907. *
  908. * @param aSourceMapConsumer The source map to be applied.
  909. * @param aSourceFile Optional. The filename of the source file.
  910. * If omitted, SourceMapConsumer's file property will be used.
  911. * @param aSourceMapPath Optional. The dirname of the path to the source map
  912. * to be applied. If relative, it is relative to the SourceMapConsumer.
  913. * This parameter is needed when the two source maps aren't in the same
  914. * directory, and the source map to be applied contains relative source
  915. * paths. If so, those relative source paths need to be rewritten
  916. * relative to the SourceMapGenerator.
  917. */
  918. applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  919. let sourceFile = aSourceFile;
  920. // If aSourceFile is omitted, we will use the file property of the SourceMap
  921. if (aSourceFile == null) {
  922. if (aSourceMapConsumer.file == null) {
  923. throw new Error(
  924. "SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " +
  925. 'or the source map\'s "file" property. Both were omitted.'
  926. );
  927. }
  928. sourceFile = aSourceMapConsumer.file;
  929. }
  930. const sourceRoot = this._sourceRoot;
  931. // Make "sourceFile" relative if an absolute Url is passed.
  932. if (sourceRoot != null) {
  933. sourceFile = util$2.relative(sourceRoot, sourceFile);
  934. }
  935. // Applying the SourceMap can add and remove items from the sources and
  936. // the names array.
  937. const newSources = this._mappings.toArray().length > 0
  938. ? new ArraySet$1()
  939. : this._sources;
  940. const newNames = new ArraySet$1();
  941. // Find mappings for the "sourceFile"
  942. this._mappings.unsortedForEach(function(mapping) {
  943. if (mapping.source === sourceFile && mapping.originalLine != null) {
  944. // Check if it can be mapped by the source map, then update the mapping.
  945. const original = aSourceMapConsumer.originalPositionFor({
  946. line: mapping.originalLine,
  947. column: mapping.originalColumn
  948. });
  949. if (original.source != null) {
  950. // Copy mapping
  951. mapping.source = original.source;
  952. if (aSourceMapPath != null) {
  953. mapping.source = util$2.join(aSourceMapPath, mapping.source);
  954. }
  955. if (sourceRoot != null) {
  956. mapping.source = util$2.relative(sourceRoot, mapping.source);
  957. }
  958. mapping.originalLine = original.line;
  959. mapping.originalColumn = original.column;
  960. if (original.name != null) {
  961. mapping.name = original.name;
  962. }
  963. }
  964. }
  965. const source = mapping.source;
  966. if (source != null && !newSources.has(source)) {
  967. newSources.add(source);
  968. }
  969. const name = mapping.name;
  970. if (name != null && !newNames.has(name)) {
  971. newNames.add(name);
  972. }
  973. }, this);
  974. this._sources = newSources;
  975. this._names = newNames;
  976. // Copy sourcesContents of applied map.
  977. aSourceMapConsumer.sources.forEach(function(srcFile) {
  978. const content = aSourceMapConsumer.sourceContentFor(srcFile);
  979. if (content != null) {
  980. if (aSourceMapPath != null) {
  981. srcFile = util$2.join(aSourceMapPath, srcFile);
  982. }
  983. if (sourceRoot != null) {
  984. srcFile = util$2.relative(sourceRoot, srcFile);
  985. }
  986. this.setSourceContent(srcFile, content);
  987. }
  988. }, this);
  989. }
  990. /**
  991. * A mapping can have one of the three levels of data:
  992. *
  993. * 1. Just the generated position.
  994. * 2. The Generated position, original position, and original source.
  995. * 3. Generated and original position, original source, as well as a name
  996. * token.
  997. *
  998. * To maintain consistency, we validate that any new mapping being added falls
  999. * in to one of these categories.
  1000. */
  1001. _validateMapping(aGenerated, aOriginal, aSource, aName) {
  1002. // When aOriginal is truthy but has empty values for .line and .column,
  1003. // it is most likely a programmer error. In this case we throw a very
  1004. // specific error message to try to guide them the right way.
  1005. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  1006. if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
  1007. throw new Error(
  1008. "original.line and original.column are not numbers -- you probably meant to omit " +
  1009. "the original mapping entirely and only map the generated position. If so, pass " +
  1010. "null for the original mapping instead of an object with empty or null values."
  1011. );
  1012. }
  1013. if (aGenerated && "line" in aGenerated && "column" in aGenerated
  1014. && aGenerated.line > 0 && aGenerated.column >= 0
  1015. && !aOriginal && !aSource && !aName) ; else if (aGenerated && "line" in aGenerated && "column" in aGenerated
  1016. && aOriginal && "line" in aOriginal && "column" in aOriginal
  1017. && aGenerated.line > 0 && aGenerated.column >= 0
  1018. && aOriginal.line > 0 && aOriginal.column >= 0
  1019. && aSource) ; else {
  1020. throw new Error("Invalid mapping: " + JSON.stringify({
  1021. generated: aGenerated,
  1022. source: aSource,
  1023. original: aOriginal,
  1024. name: aName
  1025. }));
  1026. }
  1027. }
  1028. /**
  1029. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  1030. * specified by the source map format.
  1031. */
  1032. _serializeMappings() {
  1033. let previousGeneratedColumn = 0;
  1034. let previousGeneratedLine = 1;
  1035. let previousOriginalColumn = 0;
  1036. let previousOriginalLine = 0;
  1037. let previousName = 0;
  1038. let previousSource = 0;
  1039. let result = "";
  1040. let next;
  1041. let mapping;
  1042. let nameIdx;
  1043. let sourceIdx;
  1044. const mappings = this._mappings.toArray();
  1045. for (let i = 0, len = mappings.length; i < len; i++) {
  1046. mapping = mappings[i];
  1047. next = "";
  1048. if (mapping.generatedLine !== previousGeneratedLine) {
  1049. previousGeneratedColumn = 0;
  1050. while (mapping.generatedLine !== previousGeneratedLine) {
  1051. next += ";";
  1052. previousGeneratedLine++;
  1053. }
  1054. } else if (i > 0) {
  1055. if (!util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  1056. continue;
  1057. }
  1058. next += ",";
  1059. }
  1060. next += base64VLQ.encode(mapping.generatedColumn
  1061. - previousGeneratedColumn);
  1062. previousGeneratedColumn = mapping.generatedColumn;
  1063. if (mapping.source != null) {
  1064. sourceIdx = this._sources.indexOf(mapping.source);
  1065. next += base64VLQ.encode(sourceIdx - previousSource);
  1066. previousSource = sourceIdx;
  1067. // lines are stored 0-based in SourceMap spec version 3
  1068. next += base64VLQ.encode(mapping.originalLine - 1
  1069. - previousOriginalLine);
  1070. previousOriginalLine = mapping.originalLine - 1;
  1071. next += base64VLQ.encode(mapping.originalColumn
  1072. - previousOriginalColumn);
  1073. previousOriginalColumn = mapping.originalColumn;
  1074. if (mapping.name != null) {
  1075. nameIdx = this._names.indexOf(mapping.name);
  1076. next += base64VLQ.encode(nameIdx - previousName);
  1077. previousName = nameIdx;
  1078. }
  1079. }
  1080. result += next;
  1081. }
  1082. return result;
  1083. }
  1084. _generateSourcesContent(aSources, aSourceRoot) {
  1085. return aSources.map(function(source) {
  1086. if (!this._sourcesContents) {
  1087. return null;
  1088. }
  1089. if (aSourceRoot != null) {
  1090. source = util$2.relative(aSourceRoot, source);
  1091. }
  1092. const key = util$2.toSetString(source);
  1093. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  1094. ? this._sourcesContents[key]
  1095. : null;
  1096. }, this);
  1097. }
  1098. /**
  1099. * Externalize the source map.
  1100. */
  1101. toJSON() {
  1102. const map = {
  1103. version: this._version,
  1104. sources: this._sources.toArray(),
  1105. names: this._names.toArray(),
  1106. mappings: this._serializeMappings()
  1107. };
  1108. if (this._file != null) {
  1109. map.file = this._file;
  1110. }
  1111. if (this._sourceRoot != null) {
  1112. map.sourceRoot = this._sourceRoot;
  1113. }
  1114. if (this._sourcesContents) {
  1115. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  1116. }
  1117. return map;
  1118. }
  1119. /**
  1120. * Render the source map being generated to a string.
  1121. */
  1122. toString() {
  1123. return JSON.stringify(this.toJSON());
  1124. }
  1125. }
  1126. SourceMapGenerator$1.prototype._version = 3;
  1127. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$1;
  1128. var sourceMapConsumer = {};
  1129. var binarySearch$1 = {};
  1130. /* -*- Mode: js; js-indent-level: 2; -*- */
  1131. (function (exports) {
  1132. /*
  1133. * Copyright 2011 Mozilla Foundation and contributors
  1134. * Licensed under the New BSD license. See LICENSE or:
  1135. * http://opensource.org/licenses/BSD-3-Clause
  1136. */
  1137. exports.GREATEST_LOWER_BOUND = 1;
  1138. exports.LEAST_UPPER_BOUND = 2;
  1139. /**
  1140. * Recursive implementation of binary search.
  1141. *
  1142. * @param aLow Indices here and lower do not contain the needle.
  1143. * @param aHigh Indices here and higher do not contain the needle.
  1144. * @param aNeedle The element being searched for.
  1145. * @param aHaystack The non-empty array being searched.
  1146. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  1147. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  1148. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  1149. * closest element that is smaller than or greater than the one we are
  1150. * searching for, respectively, if the exact element cannot be found.
  1151. */
  1152. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  1153. // This function terminates when one of the following is true:
  1154. //
  1155. // 1. We find the exact element we are looking for.
  1156. //
  1157. // 2. We did not find the exact element, but we can return the index of
  1158. // the next-closest element.
  1159. //
  1160. // 3. We did not find the exact element, and there is no next-closest
  1161. // element than the one we are searching for, so we return -1.
  1162. const mid = Math.floor((aHigh - aLow) / 2) + aLow;
  1163. const cmp = aCompare(aNeedle, aHaystack[mid], true);
  1164. if (cmp === 0) {
  1165. // Found the element we are looking for.
  1166. return mid;
  1167. } else if (cmp > 0) {
  1168. // Our needle is greater than aHaystack[mid].
  1169. if (aHigh - mid > 1) {
  1170. // The element is in the upper half.
  1171. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  1172. }
  1173. // The exact needle element was not found in this haystack. Determine if
  1174. // we are in termination case (3) or (2) and return the appropriate thing.
  1175. if (aBias == exports.LEAST_UPPER_BOUND) {
  1176. return aHigh < aHaystack.length ? aHigh : -1;
  1177. }
  1178. return mid;
  1179. }
  1180. // Our needle is less than aHaystack[mid].
  1181. if (mid - aLow > 1) {
  1182. // The element is in the lower half.
  1183. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  1184. }
  1185. // we are in termination case (3) or (2) and return the appropriate thing.
  1186. if (aBias == exports.LEAST_UPPER_BOUND) {
  1187. return mid;
  1188. }
  1189. return aLow < 0 ? -1 : aLow;
  1190. }
  1191. /**
  1192. * This is an implementation of binary search which will always try and return
  1193. * the index of the closest element if there is no exact hit. This is because
  1194. * mappings between original and generated line/col pairs are single points,
  1195. * and there is an implicit region between each of them, so a miss just means
  1196. * that you aren't on the very start of a region.
  1197. *
  1198. * @param aNeedle The element you are looking for.
  1199. * @param aHaystack The array that is being searched.
  1200. * @param aCompare A function which takes the needle and an element in the
  1201. * array and returns -1, 0, or 1 depending on whether the needle is less
  1202. * than, equal to, or greater than the element, respectively.
  1203. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  1204. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  1205. * closest element that is smaller than or greater than the one we are
  1206. * searching for, respectively, if the exact element cannot be found.
  1207. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  1208. */
  1209. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  1210. if (aHaystack.length === 0) {
  1211. return -1;
  1212. }
  1213. let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  1214. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  1215. if (index < 0) {
  1216. return -1;
  1217. }
  1218. // We have found either the exact element, or the next-closest element than
  1219. // the one we are searching for. However, there may be more than one such
  1220. // element. Make sure we always return the smallest of these.
  1221. while (index - 1 >= 0) {
  1222. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  1223. break;
  1224. }
  1225. --index;
  1226. }
  1227. return index;
  1228. };
  1229. }(binarySearch$1));
  1230. var readWasm$2 = {exports: {}};
  1231. if (typeof fetch === "function") {
  1232. // Web version of reading a wasm file into an array buffer.
  1233. let mappingsWasmUrl = null;
  1234. readWasm$2.exports = function readWasm() {
  1235. if (typeof mappingsWasmUrl !== "string") {
  1236. throw new Error("You must provide the URL of lib/mappings.wasm by calling " +
  1237. "SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) " +
  1238. "before using SourceMapConsumer");
  1239. }
  1240. return fetch(mappingsWasmUrl)
  1241. .then(response => response.arrayBuffer());
  1242. };
  1243. readWasm$2.exports.initialize = url => mappingsWasmUrl = url;
  1244. } else {
  1245. // Node version of reading a wasm file into an array buffer.
  1246. const fs = require$$0__default;
  1247. const path = require$$1__default;
  1248. readWasm$2.exports = function readWasm() {
  1249. return new Promise((resolve, reject) => {
  1250. const wasmPath = path.join(__dirname, "mappings.wasm");
  1251. fs.readFile(wasmPath, null, (error, data) => {
  1252. if (error) {
  1253. reject(error);
  1254. return;
  1255. }
  1256. resolve(data.buffer);
  1257. });
  1258. });
  1259. };
  1260. readWasm$2.exports.initialize = _ => {
  1261. console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
  1262. };
  1263. }
  1264. const readWasm$1 = readWasm$2.exports;
  1265. /**
  1266. * Provide the JIT with a nice shape / hidden class.
  1267. */
  1268. function Mapping() {
  1269. this.generatedLine = 0;
  1270. this.generatedColumn = 0;
  1271. this.lastGeneratedColumn = null;
  1272. this.source = null;
  1273. this.originalLine = null;
  1274. this.originalColumn = null;
  1275. this.name = null;
  1276. }
  1277. let cachedWasm = null;
  1278. var wasm$1 = function wasm() {
  1279. if (cachedWasm) {
  1280. return cachedWasm;
  1281. }
  1282. const callbackStack = [];
  1283. cachedWasm = readWasm$1().then(buffer => {
  1284. return WebAssembly.instantiate(buffer, {
  1285. env: {
  1286. mapping_callback(
  1287. generatedLine,
  1288. generatedColumn,
  1289. hasLastGeneratedColumn,
  1290. lastGeneratedColumn,
  1291. hasOriginal,
  1292. source,
  1293. originalLine,
  1294. originalColumn,
  1295. hasName,
  1296. name
  1297. ) {
  1298. const mapping = new Mapping();
  1299. // JS uses 1-based line numbers, wasm uses 0-based.
  1300. mapping.generatedLine = generatedLine + 1;
  1301. mapping.generatedColumn = generatedColumn;
  1302. if (hasLastGeneratedColumn) {
  1303. // JS uses inclusive last generated column, wasm uses exclusive.
  1304. mapping.lastGeneratedColumn = lastGeneratedColumn - 1;
  1305. }
  1306. if (hasOriginal) {
  1307. mapping.source = source;
  1308. // JS uses 1-based line numbers, wasm uses 0-based.
  1309. mapping.originalLine = originalLine + 1;
  1310. mapping.originalColumn = originalColumn;
  1311. if (hasName) {
  1312. mapping.name = name;
  1313. }
  1314. }
  1315. callbackStack[callbackStack.length - 1](mapping);
  1316. },
  1317. start_all_generated_locations_for() { console.time("all_generated_locations_for"); },
  1318. end_all_generated_locations_for() { console.timeEnd("all_generated_locations_for"); },
  1319. start_compute_column_spans() { console.time("compute_column_spans"); },
  1320. end_compute_column_spans() { console.timeEnd("compute_column_spans"); },
  1321. start_generated_location_for() { console.time("generated_location_for"); },
  1322. end_generated_location_for() { console.timeEnd("generated_location_for"); },
  1323. start_original_location_for() { console.time("original_location_for"); },
  1324. end_original_location_for() { console.timeEnd("original_location_for"); },
  1325. start_parse_mappings() { console.time("parse_mappings"); },
  1326. end_parse_mappings() { console.timeEnd("parse_mappings"); },
  1327. start_sort_by_generated_location() { console.time("sort_by_generated_location"); },
  1328. end_sort_by_generated_location() { console.timeEnd("sort_by_generated_location"); },
  1329. start_sort_by_original_location() { console.time("sort_by_original_location"); },
  1330. end_sort_by_original_location() { console.timeEnd("sort_by_original_location"); },
  1331. }
  1332. });
  1333. }).then(Wasm => {
  1334. return {
  1335. exports: Wasm.instance.exports,
  1336. withMappingCallback: (mappingCallback, f) => {
  1337. callbackStack.push(mappingCallback);
  1338. try {
  1339. f();
  1340. } finally {
  1341. callbackStack.pop();
  1342. }
  1343. }
  1344. };
  1345. }).then(null, e => {
  1346. cachedWasm = null;
  1347. throw e;
  1348. });
  1349. return cachedWasm;
  1350. };
  1351. /* -*- Mode: js; js-indent-level: 2; -*- */
  1352. /*
  1353. * Copyright 2011 Mozilla Foundation and contributors
  1354. * Licensed under the New BSD license. See LICENSE or:
  1355. * http://opensource.org/licenses/BSD-3-Clause
  1356. */
  1357. const util$1 = util$4;
  1358. const binarySearch = binarySearch$1;
  1359. const ArraySet = arraySet.ArraySet;
  1360. const readWasm = readWasm$2.exports;
  1361. const wasm = wasm$1;
  1362. const INTERNAL = Symbol("smcInternal");
  1363. class SourceMapConsumer {
  1364. constructor(aSourceMap, aSourceMapURL) {
  1365. // If the constructor was called by super(), just return Promise<this>.
  1366. // Yes, this is a hack to retain the pre-existing API of the base-class
  1367. // constructor also being an async factory function.
  1368. if (aSourceMap == INTERNAL) {
  1369. return Promise.resolve(this);
  1370. }
  1371. return _factory(aSourceMap, aSourceMapURL);
  1372. }
  1373. static initialize(opts) {
  1374. readWasm.initialize(opts["lib/mappings.wasm"]);
  1375. }
  1376. static fromSourceMap(aSourceMap, aSourceMapURL) {
  1377. return _factoryBSM(aSourceMap, aSourceMapURL);
  1378. }
  1379. /**
  1380. * Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
  1381. * (see the `SourceMapConsumer` constructor for details. Then, invoke the `async
  1382. * function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
  1383. * for `f` to complete, call `destroy` on the consumer, and return `f`'s return
  1384. * value.
  1385. *
  1386. * You must not use the consumer after `f` completes!
  1387. *
  1388. * By using `with`, you do not have to remember to manually call `destroy` on
  1389. * the consumer, since it will be called automatically once `f` completes.
  1390. *
  1391. * ```js
  1392. * const xSquared = await SourceMapConsumer.with(
  1393. * myRawSourceMap,
  1394. * null,
  1395. * async function (consumer) {
  1396. * // Use `consumer` inside here and don't worry about remembering
  1397. * // to call `destroy`.
  1398. *
  1399. * const x = await whatever(consumer);
  1400. * return x * x;
  1401. * }
  1402. * );
  1403. *
  1404. * // You may not use that `consumer` anymore out here; it has
  1405. * // been destroyed. But you can use `xSquared`.
  1406. * console.log(xSquared);
  1407. * ```
  1408. */
  1409. static with(rawSourceMap, sourceMapUrl, f) {
  1410. // Note: The `acorn` version that `webpack` currently depends on doesn't
  1411. // support `async` functions, and the nodes that we support don't all have
  1412. // `.finally`. Therefore, this is written a bit more convolutedly than it
  1413. // should really be.
  1414. let consumer = null;
  1415. const promise = new SourceMapConsumer(rawSourceMap, sourceMapUrl);
  1416. return promise
  1417. .then(c => {
  1418. consumer = c;
  1419. return f(c);
  1420. })
  1421. .then(x => {
  1422. if (consumer) {
  1423. consumer.destroy();
  1424. }
  1425. return x;
  1426. }, e => {
  1427. if (consumer) {
  1428. consumer.destroy();
  1429. }
  1430. throw e;
  1431. });
  1432. }
  1433. /**
  1434. * Parse the mappings in a string in to a data structure which we can easily
  1435. * query (the ordered arrays in the `this.__generatedMappings` and
  1436. * `this.__originalMappings` properties).
  1437. */
  1438. _parseMappings(aStr, aSourceRoot) {
  1439. throw new Error("Subclasses must implement _parseMappings");
  1440. }
  1441. /**
  1442. * Iterate over each mapping between an original source/line/column and a
  1443. * generated line/column in this source map.
  1444. *
  1445. * @param Function aCallback
  1446. * The function that is called with each mapping.
  1447. * @param Object aContext
  1448. * Optional. If specified, this object will be the value of `this` every
  1449. * time that `aCallback` is called.
  1450. * @param aOrder
  1451. * Either `SourceMapConsumer.GENERATED_ORDER` or
  1452. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  1453. * iterate over the mappings sorted by the generated file's line/column
  1454. * order or the original's source/line/column order, respectively. Defaults to
  1455. * `SourceMapConsumer.GENERATED_ORDER`.
  1456. */
  1457. eachMapping(aCallback, aContext, aOrder) {
  1458. throw new Error("Subclasses must implement eachMapping");
  1459. }
  1460. /**
  1461. * Returns all generated line and column information for the original source,
  1462. * line, and column provided. If no column is provided, returns all mappings
  1463. * corresponding to a either the line we are searching for or the next
  1464. * closest line that has any mappings. Otherwise, returns all mappings
  1465. * corresponding to the given line and either the column we are searching for
  1466. * or the next closest column that has any offsets.
  1467. *
  1468. * The only argument is an object with the following properties:
  1469. *
  1470. * - source: The filename of the original source.
  1471. * - line: The line number in the original source. The line number is 1-based.
  1472. * - column: Optional. the column number in the original source.
  1473. * The column number is 0-based.
  1474. *
  1475. * and an array of objects is returned, each with the following properties:
  1476. *
  1477. * - line: The line number in the generated source, or null. The
  1478. * line number is 1-based.
  1479. * - column: The column number in the generated source, or null.
  1480. * The column number is 0-based.
  1481. */
  1482. allGeneratedPositionsFor(aArgs) {
  1483. throw new Error("Subclasses must implement allGeneratedPositionsFor");
  1484. }
  1485. destroy() {
  1486. throw new Error("Subclasses must implement destroy");
  1487. }
  1488. }
  1489. /**
  1490. * The version of the source mapping spec that we are consuming.
  1491. */
  1492. SourceMapConsumer.prototype._version = 3;
  1493. SourceMapConsumer.GENERATED_ORDER = 1;
  1494. SourceMapConsumer.ORIGINAL_ORDER = 2;
  1495. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  1496. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  1497. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer;
  1498. /**
  1499. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  1500. * query for information about the original file positions by giving it a file
  1501. * position in the generated source.
  1502. *
  1503. * The first parameter is the raw source map (either as a JSON string, or
  1504. * already parsed to an object). According to the spec, source maps have the
  1505. * following attributes:
  1506. *
  1507. * - version: Which version of the source map spec this map is following.
  1508. * - sources: An array of URLs to the original source files.
  1509. * - names: An array of identifiers which can be referenced by individual mappings.
  1510. * - sourceRoot: Optional. The URL root from which all sources are relative.
  1511. * - sourcesContent: Optional. An array of contents of the original source files.
  1512. * - mappings: A string of base64 VLQs which contain the actual mappings.
  1513. * - file: Optional. The generated file this source map is associated with.
  1514. *
  1515. * Here is an example source map, taken from the source map spec[0]:
  1516. *
  1517. * {
  1518. * version : 3,
  1519. * file: "out.js",
  1520. * sourceRoot : "",
  1521. * sources: ["foo.js", "bar.js"],
  1522. * names: ["src", "maps", "are", "fun"],
  1523. * mappings: "AA,AB;;ABCDE;"
  1524. * }
  1525. *
  1526. * The second parameter, if given, is a string whose value is the URL
  1527. * at which the source map was found. This URL is used to compute the
  1528. * sources array.
  1529. *
  1530. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  1531. */
  1532. class BasicSourceMapConsumer extends SourceMapConsumer {
  1533. constructor(aSourceMap, aSourceMapURL) {
  1534. return super(INTERNAL).then(that => {
  1535. let sourceMap = aSourceMap;
  1536. if (typeof aSourceMap === "string") {
  1537. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  1538. }
  1539. const version = util$1.getArg(sourceMap, "version");
  1540. let sources = util$1.getArg(sourceMap, "sources");
  1541. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  1542. // requires the array) to play nice here.
  1543. const names = util$1.getArg(sourceMap, "names", []);
  1544. let sourceRoot = util$1.getArg(sourceMap, "sourceRoot", null);
  1545. const sourcesContent = util$1.getArg(sourceMap, "sourcesContent", null);
  1546. const mappings = util$1.getArg(sourceMap, "mappings");
  1547. const file = util$1.getArg(sourceMap, "file", null);
  1548. // Once again, Sass deviates from the spec and supplies the version as a
  1549. // string rather than a number, so we use loose equality checking here.
  1550. if (version != that._version) {
  1551. throw new Error("Unsupported version: " + version);
  1552. }
  1553. if (sourceRoot) {
  1554. sourceRoot = util$1.normalize(sourceRoot);
  1555. }
  1556. sources = sources
  1557. .map(String)
  1558. // Some source maps produce relative source paths like "./foo.js" instead of
  1559. // "foo.js". Normalize these first so that future comparisons will succeed.
  1560. // See bugzil.la/1090768.
  1561. .map(util$1.normalize)
  1562. // Always ensure that absolute sources are internally stored relative to
  1563. // the source root, if the source root is absolute. Not doing this would
  1564. // be particularly problematic when the source root is a prefix of the
  1565. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  1566. .map(function(source) {
  1567. return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
  1568. ? util$1.relative(sourceRoot, source)
  1569. : source;
  1570. });
  1571. // Pass `true` below to allow duplicate names and sources. While source maps
  1572. // are intended to be compressed and deduplicated, the TypeScript compiler
  1573. // sometimes generates source maps with duplicates in them. See Github issue
  1574. // #72 and bugzil.la/889492.
  1575. that._names = ArraySet.fromArray(names.map(String), true);
  1576. that._sources = ArraySet.fromArray(sources, true);
  1577. that._absoluteSources = that._sources.toArray().map(function(s) {
  1578. return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
  1579. });
  1580. that.sourceRoot = sourceRoot;
  1581. that.sourcesContent = sourcesContent;
  1582. that._mappings = mappings;
  1583. that._sourceMapURL = aSourceMapURL;
  1584. that.file = file;
  1585. that._computedColumnSpans = false;
  1586. that._mappingsPtr = 0;
  1587. that._wasm = null;
  1588. return wasm().then(w => {
  1589. that._wasm = w;
  1590. return that;
  1591. });
  1592. });
  1593. }
  1594. /**
  1595. * Utility function to find the index of a source. Returns -1 if not
  1596. * found.
  1597. */
  1598. _findSourceIndex(aSource) {
  1599. let relativeSource = aSource;
  1600. if (this.sourceRoot != null) {
  1601. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  1602. }
  1603. if (this._sources.has(relativeSource)) {
  1604. return this._sources.indexOf(relativeSource);
  1605. }
  1606. // Maybe aSource is an absolute URL as returned by |sources|. In
  1607. // this case we can't simply undo the transform.
  1608. for (let i = 0; i < this._absoluteSources.length; ++i) {
  1609. if (this._absoluteSources[i] == aSource) {
  1610. return i;
  1611. }
  1612. }
  1613. return -1;
  1614. }
  1615. /**
  1616. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  1617. *
  1618. * @param SourceMapGenerator aSourceMap
  1619. * The source map that will be consumed.
  1620. * @param String aSourceMapURL
  1621. * The URL at which the source map can be found (optional)
  1622. * @returns BasicSourceMapConsumer
  1623. */
  1624. static fromSourceMap(aSourceMap, aSourceMapURL) {
  1625. return new BasicSourceMapConsumer(aSourceMap.toString());
  1626. }
  1627. get sources() {
  1628. return this._absoluteSources.slice();
  1629. }
  1630. _getMappingsPtr() {
  1631. if (this._mappingsPtr === 0) {
  1632. this._parseMappings(this._mappings, this.sourceRoot);
  1633. }
  1634. return this._mappingsPtr;
  1635. }
  1636. /**
  1637. * Parse the mappings in a string in to a data structure which we can easily
  1638. * query (the ordered arrays in the `this.__generatedMappings` and
  1639. * `this.__originalMappings` properties).
  1640. */
  1641. _parseMappings(aStr, aSourceRoot) {
  1642. const size = aStr.length;
  1643. const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
  1644. const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
  1645. for (let i = 0; i < size; i++) {
  1646. mappingsBuf[i] = aStr.charCodeAt(i);
  1647. }
  1648. const mappingsPtr = this._wasm.exports.parse_mappings(mappingsBufPtr);
  1649. if (!mappingsPtr) {
  1650. const error = this._wasm.exports.get_last_error();
  1651. let msg = `Error parsing mappings (code ${error}): `;
  1652. // XXX: keep these error codes in sync with `fitzgen/source-map-mappings`.
  1653. switch (error) {
  1654. case 1:
  1655. msg += "the mappings contained a negative line, column, source index, or name index";
  1656. break;
  1657. case 2:
  1658. msg += "the mappings contained a number larger than 2**32";
  1659. break;
  1660. case 3:
  1661. msg += "reached EOF while in the middle of parsing a VLQ";
  1662. break;
  1663. case 4:
  1664. msg += "invalid base 64 character while parsing a VLQ";
  1665. break;
  1666. default:
  1667. msg += "unknown error code";
  1668. break;
  1669. }
  1670. throw new Error(msg);
  1671. }
  1672. this._mappingsPtr = mappingsPtr;
  1673. }
  1674. eachMapping(aCallback, aContext, aOrder) {
  1675. const context = aContext || null;
  1676. const order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  1677. const sourceRoot = this.sourceRoot;
  1678. this._wasm.withMappingCallback(
  1679. mapping => {
  1680. if (mapping.source !== null) {
  1681. mapping.source = this._sources.at(mapping.source);
  1682. mapping.source = util$1.computeSourceURL(sourceRoot, mapping.source, this._sourceMapURL);
  1683. if (mapping.name !== null) {
  1684. mapping.name = this._names.at(mapping.name);
  1685. }
  1686. }
  1687. aCallback.call(context, mapping);
  1688. },
  1689. () => {
  1690. switch (order) {
  1691. case SourceMapConsumer.GENERATED_ORDER:
  1692. this._wasm.exports.by_generated_location(this._getMappingsPtr());
  1693. break;
  1694. case SourceMapConsumer.ORIGINAL_ORDER:
  1695. this._wasm.exports.by_original_location(this._getMappingsPtr());
  1696. break;
  1697. default:
  1698. throw new Error("Unknown order of iteration.");
  1699. }
  1700. }
  1701. );
  1702. }
  1703. allGeneratedPositionsFor(aArgs) {
  1704. let source = util$1.getArg(aArgs, "source");
  1705. const originalLine = util$1.getArg(aArgs, "line");
  1706. const originalColumn = aArgs.column || 0;
  1707. source = this._findSourceIndex(source);
  1708. if (source < 0) {
  1709. return [];
  1710. }
  1711. if (originalLine < 1) {
  1712. throw new Error("Line numbers must be >= 1");
  1713. }
  1714. if (originalColumn < 0) {
  1715. throw new Error("Column numbers must be >= 0");
  1716. }
  1717. const mappings = [];
  1718. this._wasm.withMappingCallback(
  1719. m => {
  1720. let lastColumn = m.lastGeneratedColumn;
  1721. if (this._computedColumnSpans && lastColumn === null) {
  1722. lastColumn = Infinity;
  1723. }
  1724. mappings.push({
  1725. line: m.generatedLine,
  1726. column: m.generatedColumn,
  1727. lastColumn,
  1728. });
  1729. }, () => {
  1730. this._wasm.exports.all_generated_locations_for(
  1731. this._getMappingsPtr(),
  1732. source,
  1733. originalLine - 1,
  1734. "column" in aArgs,
  1735. originalColumn
  1736. );
  1737. }
  1738. );
  1739. return mappings;
  1740. }
  1741. destroy() {
  1742. if (this._mappingsPtr !== 0) {
  1743. this._wasm.exports.free_mappings(this._mappingsPtr);
  1744. this._mappingsPtr = 0;
  1745. }
  1746. }
  1747. /**
  1748. * Compute the last column for each generated mapping. The last column is
  1749. * inclusive.
  1750. */
  1751. computeColumnSpans() {
  1752. if (this._computedColumnSpans) {
  1753. return;
  1754. }
  1755. this._wasm.exports.compute_column_spans(this._getMappingsPtr());
  1756. this._computedColumnSpans = true;
  1757. }
  1758. /**
  1759. * Returns the original source, line, and column information for the generated
  1760. * source's line and column positions provided. The only argument is an object
  1761. * with the following properties:
  1762. *
  1763. * - line: The line number in the generated source. The line number
  1764. * is 1-based.
  1765. * - column: The column number in the generated source. The column
  1766. * number is 0-based.
  1767. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  1768. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  1769. * closest element that is smaller than or greater than the one we are
  1770. * searching for, respectively, if the exact element cannot be found.
  1771. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  1772. *
  1773. * and an object is returned with the following properties:
  1774. *
  1775. * - source: The original source file, or null.
  1776. * - line: The line number in the original source, or null. The
  1777. * line number is 1-based.
  1778. * - column: The column number in the original source, or null. The
  1779. * column number is 0-based.
  1780. * - name: The original identifier, or null.
  1781. */
  1782. originalPositionFor(aArgs) {
  1783. const needle = {
  1784. generatedLine: util$1.getArg(aArgs, "line"),
  1785. generatedColumn: util$1.getArg(aArgs, "column")
  1786. };
  1787. if (needle.generatedLine < 1) {
  1788. throw new Error("Line numbers must be >= 1");
  1789. }
  1790. if (needle.generatedColumn < 0) {
  1791. throw new Error("Column numbers must be >= 0");
  1792. }
  1793. let bias = util$1.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
  1794. if (bias == null) {
  1795. bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
  1796. }
  1797. let mapping;
  1798. this._wasm.withMappingCallback(m => mapping = m, () => {
  1799. this._wasm.exports.original_location_for(
  1800. this._getMappingsPtr(),
  1801. needle.generatedLine - 1,
  1802. needle.generatedColumn,
  1803. bias
  1804. );
  1805. });
  1806. if (mapping) {
  1807. if (mapping.generatedLine === needle.generatedLine) {
  1808. let source = util$1.getArg(mapping, "source", null);
  1809. if (source !== null) {
  1810. source = this._sources.at(source);
  1811. source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  1812. }
  1813. let name = util$1.getArg(mapping, "name", null);
  1814. if (name !== null) {
  1815. name = this._names.at(name);
  1816. }
  1817. return {
  1818. source,
  1819. line: util$1.getArg(mapping, "originalLine", null),
  1820. column: util$1.getArg(mapping, "originalColumn", null),
  1821. name
  1822. };
  1823. }
  1824. }
  1825. return {
  1826. source: null,
  1827. line: null,
  1828. column: null,
  1829. name: null
  1830. };
  1831. }
  1832. /**
  1833. * Return true if we have the source content for every source in the source
  1834. * map, false otherwise.
  1835. */
  1836. hasContentsOfAllSources() {
  1837. if (!this.sourcesContent) {
  1838. return false;
  1839. }
  1840. return this.sourcesContent.length >= this._sources.size() &&
  1841. !this.sourcesContent.some(function(sc) { return sc == null; });
  1842. }
  1843. /**
  1844. * Returns the original source content. The only argument is the url of the
  1845. * original source file. Returns null if no original source content is
  1846. * available.
  1847. */
  1848. sourceContentFor(aSource, nullOnMissing) {
  1849. if (!this.sourcesContent) {
  1850. return null;
  1851. }
  1852. const index = this._findSourceIndex(aSource);
  1853. if (index >= 0) {
  1854. return this.sourcesContent[index];
  1855. }
  1856. let relativeSource = aSource;
  1857. if (this.sourceRoot != null) {
  1858. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  1859. }
  1860. let url;
  1861. if (this.sourceRoot != null
  1862. && (url = util$1.urlParse(this.sourceRoot))) {
  1863. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  1864. // many users. We can help them out when they expect file:// URIs to
  1865. // behave like it would if they were running a local HTTP server. See
  1866. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  1867. const fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  1868. if (url.scheme == "file"
  1869. && this._sources.has(fileUriAbsPath)) {
  1870. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
  1871. }
  1872. if ((!url.path || url.path == "/")
  1873. && this._sources.has("/" + relativeSource)) {
  1874. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  1875. }
  1876. }
  1877. // This function is used recursively from
  1878. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  1879. // don't want to throw if we can't find the source - we just want to
  1880. // return null, so we provide a flag to exit gracefully.
  1881. if (nullOnMissing) {
  1882. return null;
  1883. }
  1884. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  1885. }
  1886. /**
  1887. * Returns the generated line and column information for the original source,
  1888. * line, and column positions provided. The only argument is an object with
  1889. * the following properties:
  1890. *
  1891. * - source: The filename of the original source.
  1892. * - line: The line number in the original source. The line number
  1893. * is 1-based.
  1894. * - column: The column number in the original source. The column
  1895. * number is 0-based.
  1896. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  1897. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  1898. * closest element that is smaller than or greater than the one we are
  1899. * searching for, respectively, if the exact element cannot be found.
  1900. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  1901. *
  1902. * and an object is returned with the following properties:
  1903. *
  1904. * - line: The line number in the generated source, or null. The
  1905. * line number is 1-based.
  1906. * - column: The column number in the generated source, or null.
  1907. * The column number is 0-based.
  1908. */
  1909. generatedPositionFor(aArgs) {
  1910. let source = util$1.getArg(aArgs, "source");
  1911. source = this._findSourceIndex(source);
  1912. if (source < 0) {
  1913. return {
  1914. line: null,
  1915. column: null,
  1916. lastColumn: null
  1917. };
  1918. }
  1919. const needle = {
  1920. source,
  1921. originalLine: util$1.getArg(aArgs, "line"),
  1922. originalColumn: util$1.getArg(aArgs, "column")
  1923. };
  1924. if (needle.originalLine < 1) {
  1925. throw new Error("Line numbers must be >= 1");
  1926. }
  1927. if (needle.originalColumn < 0) {
  1928. throw new Error("Column numbers must be >= 0");
  1929. }
  1930. let bias = util$1.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
  1931. if (bias == null) {
  1932. bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
  1933. }
  1934. let mapping;
  1935. this._wasm.withMappingCallback(m => mapping = m, () => {
  1936. this._wasm.exports.generated_location_for(
  1937. this._getMappingsPtr(),
  1938. needle.source,
  1939. needle.originalLine - 1,
  1940. needle.originalColumn,
  1941. bias
  1942. );
  1943. });
  1944. if (mapping) {
  1945. if (mapping.source === needle.source) {
  1946. let lastColumn = mapping.lastGeneratedColumn;
  1947. if (this._computedColumnSpans && lastColumn === null) {
  1948. lastColumn = Infinity;
  1949. }
  1950. return {
  1951. line: util$1.getArg(mapping, "generatedLine", null),
  1952. column: util$1.getArg(mapping, "generatedColumn", null),
  1953. lastColumn,
  1954. };
  1955. }
  1956. }
  1957. return {
  1958. line: null,
  1959. column: null,
  1960. lastColumn: null
  1961. };
  1962. }
  1963. }
  1964. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  1965. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  1966. /**
  1967. * An IndexedSourceMapConsumer instance represents a parsed source map which
  1968. * we can query for information. It differs from BasicSourceMapConsumer in
  1969. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  1970. * input.
  1971. *
  1972. * The first parameter is a raw source map (either as a JSON string, or already
  1973. * parsed to an object). According to the spec for indexed source maps, they
  1974. * have the following attributes:
  1975. *
  1976. * - version: Which version of the source map spec this map is following.
  1977. * - file: Optional. The generated file this source map is associated with.
  1978. * - sections: A list of section definitions.
  1979. *
  1980. * Each value under the "sections" field has two fields:
  1981. * - offset: The offset into the original specified at which this section
  1982. * begins to apply, defined as an object with a "line" and "column"
  1983. * field.
  1984. * - map: A source map definition. This source map could also be indexed,
  1985. * but doesn't have to be.
  1986. *
  1987. * Instead of the "map" field, it's also possible to have a "url" field
  1988. * specifying a URL to retrieve a source map from, but that's currently
  1989. * unsupported.
  1990. *
  1991. * Here's an example source map, taken from the source map spec[0], but
  1992. * modified to omit a section which uses the "url" field.
  1993. *
  1994. * {
  1995. * version : 3,
  1996. * file: "app.js",
  1997. * sections: [{
  1998. * offset: {line:100, column:10},
  1999. * map: {
  2000. * version : 3,
  2001. * file: "section.js",
  2002. * sources: ["foo.js", "bar.js"],
  2003. * names: ["src", "maps", "are", "fun"],
  2004. * mappings: "AAAA,E;;ABCDE;"
  2005. * }
  2006. * }],
  2007. * }
  2008. *
  2009. * The second parameter, if given, is a string whose value is the URL
  2010. * at which the source map was found. This URL is used to compute the
  2011. * sources array.
  2012. *
  2013. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  2014. */
  2015. class IndexedSourceMapConsumer extends SourceMapConsumer {
  2016. constructor(aSourceMap, aSourceMapURL) {
  2017. return super(INTERNAL).then(that => {
  2018. let sourceMap = aSourceMap;
  2019. if (typeof aSourceMap === "string") {
  2020. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  2021. }
  2022. const version = util$1.getArg(sourceMap, "version");
  2023. const sections = util$1.getArg(sourceMap, "sections");
  2024. if (version != that._version) {
  2025. throw new Error("Unsupported version: " + version);
  2026. }
  2027. that._sources = new ArraySet();
  2028. that._names = new ArraySet();
  2029. that.__generatedMappings = null;
  2030. that.__originalMappings = null;
  2031. that.__generatedMappingsUnsorted = null;
  2032. that.__originalMappingsUnsorted = null;
  2033. let lastOffset = {
  2034. line: -1,
  2035. column: 0
  2036. };
  2037. return Promise.all(sections.map(s => {
  2038. if (s.url) {
  2039. // The url field will require support for asynchronicity.
  2040. // See https://github.com/mozilla/source-map/issues/16
  2041. throw new Error("Support for url field in sections not implemented.");
  2042. }
  2043. const offset = util$1.getArg(s, "offset");
  2044. const offsetLine = util$1.getArg(offset, "line");
  2045. const offsetColumn = util$1.getArg(offset, "column");
  2046. if (offsetLine < lastOffset.line ||
  2047. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  2048. throw new Error("Section offsets must be ordered and non-overlapping.");
  2049. }
  2050. lastOffset = offset;
  2051. const cons = new SourceMapConsumer(util$1.getArg(s, "map"), aSourceMapURL);
  2052. return cons.then(consumer => {
  2053. return {
  2054. generatedOffset: {
  2055. // The offset fields are 0-based, but we use 1-based indices when
  2056. // encoding/decoding from VLQ.
  2057. generatedLine: offsetLine + 1,
  2058. generatedColumn: offsetColumn + 1
  2059. },
  2060. consumer
  2061. };
  2062. });
  2063. })).then(s => {
  2064. that._sections = s;
  2065. return that;
  2066. });
  2067. });
  2068. }
  2069. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  2070. // parsed mapping coordinates from the source map's "mappings" attribute. They
  2071. // are lazily instantiated, accessed via the `_generatedMappings` and
  2072. // `_originalMappings` getters respectively, and we only parse the mappings
  2073. // and create these arrays once queried for a source location. We jump through
  2074. // these hoops because there can be many thousands of mappings, and parsing
  2075. // them is expensive, so we only want to do it if we must.
  2076. //
  2077. // Each object in the arrays is of the form:
  2078. //
  2079. // {
  2080. // generatedLine: The line number in the generated code,
  2081. // generatedColumn: The column number in the generated code,
  2082. // source: The path to the original source file that generated this
  2083. // chunk of code,
  2084. // originalLine: The line number in the original source that
  2085. // corresponds to this chunk of generated code,
  2086. // originalColumn: The column number in the original source that
  2087. // corresponds to this chunk of generated code,
  2088. // name: The name of the original symbol which generated this chunk of
  2089. // code.
  2090. // }
  2091. //
  2092. // All properties except for `generatedLine` and `generatedColumn` can be
  2093. // `null`.
  2094. //
  2095. // `_generatedMappings` is ordered by the generated positions.
  2096. //
  2097. // `_originalMappings` is ordered by the original positions.
  2098. get _generatedMappings() {
  2099. if (!this.__generatedMappings) {
  2100. this._sortGeneratedMappings();
  2101. }
  2102. return this.__generatedMappings;
  2103. }
  2104. get _originalMappings() {
  2105. if (!this.__originalMappings) {
  2106. this._sortOriginalMappings();
  2107. }
  2108. return this.__originalMappings;
  2109. }
  2110. get _generatedMappingsUnsorted() {
  2111. if (!this.__generatedMappingsUnsorted) {
  2112. this._parseMappings(this._mappings, this.sourceRoot);
  2113. }
  2114. return this.__generatedMappingsUnsorted;
  2115. }
  2116. get _originalMappingsUnsorted() {
  2117. if (!this.__originalMappingsUnsorted) {
  2118. this._parseMappings(this._mappings, this.sourceRoot);
  2119. }
  2120. return this.__originalMappingsUnsorted;
  2121. }
  2122. _sortGeneratedMappings() {
  2123. const mappings = this._generatedMappingsUnsorted;
  2124. mappings.sort(util$1.compareByGeneratedPositionsDeflated);
  2125. this.__generatedMappings = mappings;
  2126. }
  2127. _sortOriginalMappings() {
  2128. const mappings = this._originalMappingsUnsorted;
  2129. mappings.sort(util$1.compareByOriginalPositions);
  2130. this.__originalMappings = mappings;
  2131. }
  2132. /**
  2133. * The list of original sources.
  2134. */
  2135. get sources() {
  2136. const sources = [];
  2137. for (let i = 0; i < this._sections.length; i++) {
  2138. for (let j = 0; j < this._sections[i].consumer.sources.length; j++) {
  2139. sources.push(this._sections[i].consumer.sources[j]);
  2140. }
  2141. }
  2142. return sources;
  2143. }
  2144. /**
  2145. * Returns the original source, line, and column information for the generated
  2146. * source's line and column positions provided. The only argument is an object
  2147. * with the following properties:
  2148. *
  2149. * - line: The line number in the generated source. The line number
  2150. * is 1-based.
  2151. * - column: The column number in the generated source. The column
  2152. * number is 0-based.
  2153. *
  2154. * and an object is returned with the following properties:
  2155. *
  2156. * - source: The original source file, or null.
  2157. * - line: The line number in the original source, or null. The
  2158. * line number is 1-based.
  2159. * - column: The column number in the original source, or null. The
  2160. * column number is 0-based.
  2161. * - name: The original identifier, or null.
  2162. */
  2163. originalPositionFor(aArgs) {
  2164. const needle = {
  2165. generatedLine: util$1.getArg(aArgs, "line"),
  2166. generatedColumn: util$1.getArg(aArgs, "column")
  2167. };
  2168. // Find the section containing the generated position we're trying to map
  2169. // to an original position.
  2170. const sectionIndex = binarySearch.search(needle, this._sections,
  2171. function(aNeedle, section) {
  2172. const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
  2173. if (cmp) {
  2174. return cmp;
  2175. }
  2176. return (aNeedle.generatedColumn -
  2177. section.generatedOffset.generatedColumn);
  2178. });
  2179. const section = this._sections[sectionIndex];
  2180. if (!section) {
  2181. return {
  2182. source: null,
  2183. line: null,
  2184. column: null,
  2185. name: null
  2186. };
  2187. }
  2188. return section.consumer.originalPositionFor({
  2189. line: needle.generatedLine -
  2190. (section.generatedOffset.generatedLine - 1),
  2191. column: needle.generatedColumn -
  2192. (section.generatedOffset.generatedLine === needle.generatedLine
  2193. ? section.generatedOffset.generatedColumn - 1
  2194. : 0),
  2195. bias: aArgs.bias
  2196. });
  2197. }
  2198. /**
  2199. * Return true if we have the source content for every source in the source
  2200. * map, false otherwise.
  2201. */
  2202. hasContentsOfAllSources() {
  2203. return this._sections.every(function(s) {
  2204. return s.consumer.hasContentsOfAllSources();
  2205. });
  2206. }
  2207. /**
  2208. * Returns the original source content. The only argument is the url of the
  2209. * original source file. Returns null if no original source content is
  2210. * available.
  2211. */
  2212. sourceContentFor(aSource, nullOnMissing) {
  2213. for (let i = 0; i < this._sections.length; i++) {
  2214. const section = this._sections[i];
  2215. const content = section.consumer.sourceContentFor(aSource, true);
  2216. if (content) {
  2217. return content;
  2218. }
  2219. }
  2220. if (nullOnMissing) {
  2221. return null;
  2222. }
  2223. throw new Error('"' + aSource + '" is not in the SourceMap.');
  2224. }
  2225. /**
  2226. * Returns the generated line and column information for the original source,
  2227. * line, and column positions provided. The only argument is an object with
  2228. * the following properties:
  2229. *
  2230. * - source: The filename of the original source.
  2231. * - line: The line number in the original source. The line number
  2232. * is 1-based.
  2233. * - column: The column number in the original source. The column
  2234. * number is 0-based.
  2235. *
  2236. * and an object is returned with the following properties:
  2237. *
  2238. * - line: The line number in the generated source, or null. The
  2239. * line number is 1-based.
  2240. * - column: The column number in the generated source, or null.
  2241. * The column number is 0-based.
  2242. */
  2243. generatedPositionFor(aArgs) {
  2244. for (let i = 0; i < this._sections.length; i++) {
  2245. const section = this._sections[i];
  2246. // Only consider this section if the requested source is in the list of
  2247. // sources of the consumer.
  2248. if (section.consumer._findSourceIndex(util$1.getArg(aArgs, "source")) === -1) {
  2249. continue;
  2250. }
  2251. const generatedPosition = section.consumer.generatedPositionFor(aArgs);
  2252. if (generatedPosition) {
  2253. const ret = {
  2254. line: generatedPosition.line +
  2255. (section.generatedOffset.generatedLine - 1),
  2256. column: generatedPosition.column +
  2257. (section.generatedOffset.generatedLine === generatedPosition.line
  2258. ? section.generatedOffset.generatedColumn - 1
  2259. : 0)
  2260. };
  2261. return ret;
  2262. }
  2263. }
  2264. return {
  2265. line: null,
  2266. column: null
  2267. };
  2268. }
  2269. /**
  2270. * Parse the mappings in a string in to a data structure which we can easily
  2271. * query (the ordered arrays in the `this.__generatedMappings` and
  2272. * `this.__originalMappings` properties).
  2273. */
  2274. _parseMappings(aStr, aSourceRoot) {
  2275. const generatedMappings = this.__generatedMappingsUnsorted = [];
  2276. const originalMappings = this.__originalMappingsUnsorted = [];
  2277. for (let i = 0; i < this._sections.length; i++) {
  2278. const section = this._sections[i];
  2279. const sectionMappings = [];
  2280. section.consumer.eachMapping(m => sectionMappings.push(m));
  2281. for (let j = 0; j < sectionMappings.length; j++) {
  2282. const mapping = sectionMappings[j];
  2283. // TODO: test if null is correct here. The original code used
  2284. // `source`, which would actually have gotten used as null because
  2285. // var's get hoisted.
  2286. // See: https://github.com/mozilla/source-map/issues/333
  2287. let source = util$1.computeSourceURL(section.consumer.sourceRoot, null, this._sourceMapURL);
  2288. this._sources.add(source);
  2289. source = this._sources.indexOf(source);
  2290. let name = null;
  2291. if (mapping.name) {
  2292. this._names.add(mapping.name);
  2293. name = this._names.indexOf(mapping.name);
  2294. }
  2295. // The mappings coming from the consumer for the section have
  2296. // generated positions relative to the start of the section, so we
  2297. // need to offset them to be relative to the start of the concatenated
  2298. // generated file.
  2299. const adjustedMapping = {
  2300. source,
  2301. generatedLine: mapping.generatedLine +
  2302. (section.generatedOffset.generatedLine - 1),
  2303. generatedColumn: mapping.generatedColumn +
  2304. (section.generatedOffset.generatedLine === mapping.generatedLine
  2305. ? section.generatedOffset.generatedColumn - 1
  2306. : 0),
  2307. originalLine: mapping.originalLine,
  2308. originalColumn: mapping.originalColumn,
  2309. name
  2310. };
  2311. generatedMappings.push(adjustedMapping);
  2312. if (typeof adjustedMapping.originalLine === "number") {
  2313. originalMappings.push(adjustedMapping);
  2314. }
  2315. }
  2316. }
  2317. }
  2318. eachMapping(aCallback, aContext, aOrder) {
  2319. const context = aContext || null;
  2320. const order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  2321. let mappings;
  2322. switch (order) {
  2323. case SourceMapConsumer.GENERATED_ORDER:
  2324. mappings = this._generatedMappings;
  2325. break;
  2326. case SourceMapConsumer.ORIGINAL_ORDER:
  2327. mappings = this._originalMappings;
  2328. break;
  2329. default:
  2330. throw new Error("Unknown order of iteration.");
  2331. }
  2332. const sourceRoot = this.sourceRoot;
  2333. mappings.map(function(mapping) {
  2334. let source = null;
  2335. if (mapping.source !== null) {
  2336. source = this._sources.at(mapping.source);
  2337. source = util$1.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  2338. }
  2339. return {
  2340. source,
  2341. generatedLine: mapping.generatedLine,
  2342. generatedColumn: mapping.generatedColumn,
  2343. originalLine: mapping.originalLine,
  2344. originalColumn: mapping.originalColumn,
  2345. name: mapping.name === null ? null : this._names.at(mapping.name)
  2346. };
  2347. }, this).forEach(aCallback, context);
  2348. }
  2349. /**
  2350. * Find the mapping that best matches the hypothetical "needle" mapping that
  2351. * we are searching for in the given "haystack" of mappings.
  2352. */
  2353. _findMapping(aNeedle, aMappings, aLineName,
  2354. aColumnName, aComparator, aBias) {
  2355. // To return the position we are searching for, we must first find the
  2356. // mapping for the given position and then return the opposite position it
  2357. // points to. Because the mappings are sorted, we can use binary search to
  2358. // find the best mapping.
  2359. if (aNeedle[aLineName] <= 0) {
  2360. throw new TypeError("Line must be greater than or equal to 1, got "
  2361. + aNeedle[aLineName]);
  2362. }
  2363. if (aNeedle[aColumnName] < 0) {
  2364. throw new TypeError("Column must be greater than or equal to 0, got "
  2365. + aNeedle[aColumnName]);
  2366. }
  2367. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  2368. }
  2369. allGeneratedPositionsFor(aArgs) {
  2370. const line = util$1.getArg(aArgs, "line");
  2371. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  2372. // returns the index of the closest mapping less than the needle. By
  2373. // setting needle.originalColumn to 0, we thus find the last mapping for
  2374. // the given line, provided such a mapping exists.
  2375. const needle = {
  2376. source: util$1.getArg(aArgs, "source"),
  2377. originalLine: line,
  2378. originalColumn: util$1.getArg(aArgs, "column", 0)
  2379. };
  2380. needle.source = this._findSourceIndex(needle.source);
  2381. if (needle.source < 0) {
  2382. return [];
  2383. }
  2384. if (needle.originalLine < 1) {
  2385. throw new Error("Line numbers must be >= 1");
  2386. }
  2387. if (needle.originalColumn < 0) {
  2388. throw new Error("Column numbers must be >= 0");
  2389. }
  2390. const mappings = [];
  2391. let index = this._findMapping(needle,
  2392. this._originalMappings,
  2393. "originalLine",
  2394. "originalColumn",
  2395. util$1.compareByOriginalPositions,
  2396. binarySearch.LEAST_UPPER_BOUND);
  2397. if (index >= 0) {
  2398. let mapping = this._originalMappings[index];
  2399. if (aArgs.column === undefined) {
  2400. const originalLine = mapping.originalLine;
  2401. // Iterate until either we run out of mappings, or we run into
  2402. // a mapping for a different line than the one we found. Since
  2403. // mappings are sorted, this is guaranteed to find all mappings for
  2404. // the line we found.
  2405. while (mapping && mapping.originalLine === originalLine) {
  2406. let lastColumn = mapping.lastGeneratedColumn;
  2407. if (this._computedColumnSpans && lastColumn === null) {
  2408. lastColumn = Infinity;
  2409. }
  2410. mappings.push({
  2411. line: util$1.getArg(mapping, "generatedLine", null),
  2412. column: util$1.getArg(mapping, "generatedColumn", null),
  2413. lastColumn,
  2414. });
  2415. mapping = this._originalMappings[++index];
  2416. }
  2417. } else {
  2418. const originalColumn = mapping.originalColumn;
  2419. // Iterate until either we run out of mappings, or we run into
  2420. // a mapping for a different line than the one we were searching for.
  2421. // Since mappings are sorted, this is guaranteed to find all mappings for
  2422. // the line we are searching for.
  2423. while (mapping &&
  2424. mapping.originalLine === line &&
  2425. mapping.originalColumn == originalColumn) {
  2426. let lastColumn = mapping.lastGeneratedColumn;
  2427. if (this._computedColumnSpans && lastColumn === null) {
  2428. lastColumn = Infinity;
  2429. }
  2430. mappings.push({
  2431. line: util$1.getArg(mapping, "generatedLine", null),
  2432. column: util$1.getArg(mapping, "generatedColumn", null),
  2433. lastColumn,
  2434. });
  2435. mapping = this._originalMappings[++index];
  2436. }
  2437. }
  2438. }
  2439. return mappings;
  2440. }
  2441. destroy() {
  2442. for (let i = 0; i < this._sections.length; i++) {
  2443. this._sections[i].consumer.destroy();
  2444. }
  2445. }
  2446. }
  2447. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  2448. /*
  2449. * Cheat to get around inter-twingled classes. `factory()` can be at the end
  2450. * where it has access to non-hoisted classes, but it gets hoisted itself.
  2451. */
  2452. function _factory(aSourceMap, aSourceMapURL) {
  2453. let sourceMap = aSourceMap;
  2454. if (typeof aSourceMap === "string") {
  2455. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  2456. }
  2457. const consumer = sourceMap.sections != null
  2458. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  2459. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  2460. return Promise.resolve(consumer);
  2461. }
  2462. function _factoryBSM(aSourceMap, aSourceMapURL) {
  2463. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  2464. }
  2465. var sourceNode = {};
  2466. /* -*- Mode: js; js-indent-level: 2; -*- */
  2467. /*
  2468. * Copyright 2011 Mozilla Foundation and contributors
  2469. * Licensed under the New BSD license. See LICENSE or:
  2470. * http://opensource.org/licenses/BSD-3-Clause
  2471. */
  2472. const SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  2473. const util = util$4;
  2474. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  2475. // operating systems these days (capturing the result).
  2476. const REGEX_NEWLINE = /(\r?\n)/;
  2477. // Newline character code for charCodeAt() comparisons
  2478. const NEWLINE_CODE = 10;
  2479. // Private symbol for identifying `SourceNode`s when multiple versions of
  2480. // the source-map library are loaded. This MUST NOT CHANGE across
  2481. // versions!
  2482. const isSourceNode = "$$$isSourceNode$$$";
  2483. /**
  2484. * SourceNodes provide a way to abstract over interpolating/concatenating
  2485. * snippets of generated JavaScript source code while maintaining the line and
  2486. * column information associated with the original source code.
  2487. *
  2488. * @param aLine The original line number.
  2489. * @param aColumn The original column number.
  2490. * @param aSource The original source's filename.
  2491. * @param aChunks Optional. An array of strings which are snippets of
  2492. * generated JS, or other SourceNodes.
  2493. * @param aName The original identifier.
  2494. */
  2495. class SourceNode {
  2496. constructor(aLine, aColumn, aSource, aChunks, aName) {
  2497. this.children = [];
  2498. this.sourceContents = {};
  2499. this.line = aLine == null ? null : aLine;
  2500. this.column = aColumn == null ? null : aColumn;
  2501. this.source = aSource == null ? null : aSource;
  2502. this.name = aName == null ? null : aName;
  2503. this[isSourceNode] = true;
  2504. if (aChunks != null) this.add(aChunks);
  2505. }
  2506. /**
  2507. * Creates a SourceNode from generated code and a SourceMapConsumer.
  2508. *
  2509. * @param aGeneratedCode The generated code
  2510. * @param aSourceMapConsumer The SourceMap for the generated code
  2511. * @param aRelativePath Optional. The path that relative sources in the
  2512. * SourceMapConsumer should be relative to.
  2513. */
  2514. static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  2515. // The SourceNode we want to fill with the generated code
  2516. // and the SourceMap
  2517. const node = new SourceNode();
  2518. // All even indices of this array are one line of the generated code,
  2519. // while all odd indices are the newlines between two adjacent lines
  2520. // (since `REGEX_NEWLINE` captures its match).
  2521. // Processed fragments are accessed by calling `shiftNextLine`.
  2522. const remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  2523. let remainingLinesIndex = 0;
  2524. const shiftNextLine = function() {
  2525. const lineContents = getNextLine();
  2526. // The last line of a file might not have a newline.
  2527. const newLine = getNextLine() || "";
  2528. return lineContents + newLine;
  2529. function getNextLine() {
  2530. return remainingLinesIndex < remainingLines.length ?
  2531. remainingLines[remainingLinesIndex++] : undefined;
  2532. }
  2533. };
  2534. // We need to remember the position of "remainingLines"
  2535. let lastGeneratedLine = 1, lastGeneratedColumn = 0;
  2536. // The generate SourceNodes we need a code range.
  2537. // To extract it current and last mapping is used.
  2538. // Here we store the last mapping.
  2539. let lastMapping = null;
  2540. let nextLine;
  2541. aSourceMapConsumer.eachMapping(function(mapping) {
  2542. if (lastMapping !== null) {
  2543. // We add the code from "lastMapping" to "mapping":
  2544. // First check if there is a new line in between.
  2545. if (lastGeneratedLine < mapping.generatedLine) {
  2546. // Associate first line with "lastMapping"
  2547. addMappingWithCode(lastMapping, shiftNextLine());
  2548. lastGeneratedLine++;
  2549. lastGeneratedColumn = 0;
  2550. // The remaining code is added without mapping
  2551. } else {
  2552. // There is no new line in between.
  2553. // Associate the code between "lastGeneratedColumn" and
  2554. // "mapping.generatedColumn" with "lastMapping"
  2555. nextLine = remainingLines[remainingLinesIndex] || "";
  2556. const code = nextLine.substr(0, mapping.generatedColumn -
  2557. lastGeneratedColumn);
  2558. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  2559. lastGeneratedColumn);
  2560. lastGeneratedColumn = mapping.generatedColumn;
  2561. addMappingWithCode(lastMapping, code);
  2562. // No more remaining code, continue
  2563. lastMapping = mapping;
  2564. return;
  2565. }
  2566. }
  2567. // We add the generated code until the first mapping
  2568. // to the SourceNode without any mapping.
  2569. // Each line is added as separate string.
  2570. while (lastGeneratedLine < mapping.generatedLine) {
  2571. node.add(shiftNextLine());
  2572. lastGeneratedLine++;
  2573. }
  2574. if (lastGeneratedColumn < mapping.generatedColumn) {
  2575. nextLine = remainingLines[remainingLinesIndex] || "";
  2576. node.add(nextLine.substr(0, mapping.generatedColumn));
  2577. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  2578. lastGeneratedColumn = mapping.generatedColumn;
  2579. }
  2580. lastMapping = mapping;
  2581. }, this);
  2582. // We have processed all mappings.
  2583. if (remainingLinesIndex < remainingLines.length) {
  2584. if (lastMapping) {
  2585. // Associate the remaining code in the current line with "lastMapping"
  2586. addMappingWithCode(lastMapping, shiftNextLine());
  2587. }
  2588. // and add the remaining lines without any mapping
  2589. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  2590. }
  2591. // Copy sourcesContent into SourceNode
  2592. aSourceMapConsumer.sources.forEach(function(sourceFile) {
  2593. const content = aSourceMapConsumer.sourceContentFor(sourceFile);
  2594. if (content != null) {
  2595. if (aRelativePath != null) {
  2596. sourceFile = util.join(aRelativePath, sourceFile);
  2597. }
  2598. node.setSourceContent(sourceFile, content);
  2599. }
  2600. });
  2601. return node;
  2602. function addMappingWithCode(mapping, code) {
  2603. if (mapping === null || mapping.source === undefined) {
  2604. node.add(code);
  2605. } else {
  2606. const source = aRelativePath
  2607. ? util.join(aRelativePath, mapping.source)
  2608. : mapping.source;
  2609. node.add(new SourceNode(mapping.originalLine,
  2610. mapping.originalColumn,
  2611. source,
  2612. code,
  2613. mapping.name));
  2614. }
  2615. }
  2616. }
  2617. /**
  2618. * Add a chunk of generated JS to this source node.
  2619. *
  2620. * @param aChunk A string snippet of generated JS code, another instance of
  2621. * SourceNode, or an array where each member is one of those things.
  2622. */
  2623. add(aChunk) {
  2624. if (Array.isArray(aChunk)) {
  2625. aChunk.forEach(function(chunk) {
  2626. this.add(chunk);
  2627. }, this);
  2628. } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  2629. if (aChunk) {
  2630. this.children.push(aChunk);
  2631. }
  2632. } else {
  2633. throw new TypeError(
  2634. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  2635. );
  2636. }
  2637. return this;
  2638. }
  2639. /**
  2640. * Add a chunk of generated JS to the beginning of this source node.
  2641. *
  2642. * @param aChunk A string snippet of generated JS code, another instance of
  2643. * SourceNode, or an array where each member is one of those things.
  2644. */
  2645. prepend(aChunk) {
  2646. if (Array.isArray(aChunk)) {
  2647. for (let i = aChunk.length - 1; i >= 0; i--) {
  2648. this.prepend(aChunk[i]);
  2649. }
  2650. } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  2651. this.children.unshift(aChunk);
  2652. } else {
  2653. throw new TypeError(
  2654. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  2655. );
  2656. }
  2657. return this;
  2658. }
  2659. /**
  2660. * Walk over the tree of JS snippets in this node and its children. The
  2661. * walking function is called once for each snippet of JS and is passed that
  2662. * snippet and the its original associated source's line/column location.
  2663. *
  2664. * @param aFn The traversal function.
  2665. */
  2666. walk(aFn) {
  2667. let chunk;
  2668. for (let i = 0, len = this.children.length; i < len; i++) {
  2669. chunk = this.children[i];
  2670. if (chunk[isSourceNode]) {
  2671. chunk.walk(aFn);
  2672. } else if (chunk !== "") {
  2673. aFn(chunk, { source: this.source,
  2674. line: this.line,
  2675. column: this.column,
  2676. name: this.name });
  2677. }
  2678. }
  2679. }
  2680. /**
  2681. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  2682. * each of `this.children`.
  2683. *
  2684. * @param aSep The separator.
  2685. */
  2686. join(aSep) {
  2687. let newChildren;
  2688. let i;
  2689. const len = this.children.length;
  2690. if (len > 0) {
  2691. newChildren = [];
  2692. for (i = 0; i < len - 1; i++) {
  2693. newChildren.push(this.children[i]);
  2694. newChildren.push(aSep);
  2695. }
  2696. newChildren.push(this.children[i]);
  2697. this.children = newChildren;
  2698. }
  2699. return this;
  2700. }
  2701. /**
  2702. * Call String.prototype.replace on the very right-most source snippet. Useful
  2703. * for trimming whitespace from the end of a source node, etc.
  2704. *
  2705. * @param aPattern The pattern to replace.
  2706. * @param aReplacement The thing to replace the pattern with.
  2707. */
  2708. replaceRight(aPattern, aReplacement) {
  2709. const lastChild = this.children[this.children.length - 1];
  2710. if (lastChild[isSourceNode]) {
  2711. lastChild.replaceRight(aPattern, aReplacement);
  2712. } else if (typeof lastChild === "string") {
  2713. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  2714. } else {
  2715. this.children.push("".replace(aPattern, aReplacement));
  2716. }
  2717. return this;
  2718. }
  2719. /**
  2720. * Set the source content for a source file. This will be added to the SourceMapGenerator
  2721. * in the sourcesContent field.
  2722. *
  2723. * @param aSourceFile The filename of the source file
  2724. * @param aSourceContent The content of the source file
  2725. */
  2726. setSourceContent(aSourceFile, aSourceContent) {
  2727. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  2728. }
  2729. /**
  2730. * Walk over the tree of SourceNodes. The walking function is called for each
  2731. * source file content and is passed the filename and source content.
  2732. *
  2733. * @param aFn The traversal function.
  2734. */
  2735. walkSourceContents(aFn) {
  2736. for (let i = 0, len = this.children.length; i < len; i++) {
  2737. if (this.children[i][isSourceNode]) {
  2738. this.children[i].walkSourceContents(aFn);
  2739. }
  2740. }
  2741. const sources = Object.keys(this.sourceContents);
  2742. for (let i = 0, len = sources.length; i < len; i++) {
  2743. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  2744. }
  2745. }
  2746. /**
  2747. * Return the string representation of this source node. Walks over the tree
  2748. * and concatenates all the various snippets together to one string.
  2749. */
  2750. toString() {
  2751. let str = "";
  2752. this.walk(function(chunk) {
  2753. str += chunk;
  2754. });
  2755. return str;
  2756. }
  2757. /**
  2758. * Returns the string representation of this source node along with a source
  2759. * map.
  2760. */
  2761. toStringWithSourceMap(aArgs) {
  2762. const generated = {
  2763. code: "",
  2764. line: 1,
  2765. column: 0
  2766. };
  2767. const map = new SourceMapGenerator(aArgs);
  2768. let sourceMappingActive = false;
  2769. let lastOriginalSource = null;
  2770. let lastOriginalLine = null;
  2771. let lastOriginalColumn = null;
  2772. let lastOriginalName = null;
  2773. this.walk(function(chunk, original) {
  2774. generated.code += chunk;
  2775. if (original.source !== null
  2776. && original.line !== null
  2777. && original.column !== null) {
  2778. if (lastOriginalSource !== original.source
  2779. || lastOriginalLine !== original.line
  2780. || lastOriginalColumn !== original.column
  2781. || lastOriginalName !== original.name) {
  2782. map.addMapping({
  2783. source: original.source,
  2784. original: {
  2785. line: original.line,
  2786. column: original.column
  2787. },
  2788. generated: {
  2789. line: generated.line,
  2790. column: generated.column
  2791. },
  2792. name: original.name
  2793. });
  2794. }
  2795. lastOriginalSource = original.source;
  2796. lastOriginalLine = original.line;
  2797. lastOriginalColumn = original.column;
  2798. lastOriginalName = original.name;
  2799. sourceMappingActive = true;
  2800. } else if (sourceMappingActive) {
  2801. map.addMapping({
  2802. generated: {
  2803. line: generated.line,
  2804. column: generated.column
  2805. }
  2806. });
  2807. lastOriginalSource = null;
  2808. sourceMappingActive = false;
  2809. }
  2810. for (let idx = 0, length = chunk.length; idx < length; idx++) {
  2811. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  2812. generated.line++;
  2813. generated.column = 0;
  2814. // Mappings end at eol
  2815. if (idx + 1 === length) {
  2816. lastOriginalSource = null;
  2817. sourceMappingActive = false;
  2818. } else if (sourceMappingActive) {
  2819. map.addMapping({
  2820. source: original.source,
  2821. original: {
  2822. line: original.line,
  2823. column: original.column
  2824. },
  2825. generated: {
  2826. line: generated.line,
  2827. column: generated.column
  2828. },
  2829. name: original.name
  2830. });
  2831. }
  2832. } else {
  2833. generated.column++;
  2834. }
  2835. }
  2836. });
  2837. this.walkSourceContents(function(sourceFile, sourceContent) {
  2838. map.setSourceContent(sourceFile, sourceContent);
  2839. });
  2840. return { code: generated.code, map };
  2841. }
  2842. }
  2843. sourceNode.SourceNode = SourceNode;
  2844. /*
  2845. * Copyright 2009-2011 Mozilla Foundation and contributors
  2846. * Licensed under the New BSD license. See LICENSE.txt or:
  2847. * http://opensource.org/licenses/BSD-3-Clause
  2848. */
  2849. sourceMap.SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  2850. sourceMap.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
  2851. sourceMap.SourceNode = sourceNode.SourceNode;
  2852. var acorn = {exports: {}};
  2853. (function (module, exports) {
  2854. (function (global, factory) {
  2855. factory(exports) ;
  2856. }(commonjsGlobal, (function (exports) {
  2857. // Reserved word lists for various dialects of the language
  2858. var reservedWords = {
  2859. 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
  2860. 5: "class enum extends super const export import",
  2861. 6: "enum",
  2862. strict: "implements interface let package private protected public static yield",
  2863. strictBind: "eval arguments"
  2864. };
  2865. // And the keywords
  2866. var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
  2867. var keywords = {
  2868. 5: ecma5AndLessKeywords,
  2869. "5module": ecma5AndLessKeywords + " export import",
  2870. 6: ecma5AndLessKeywords + " const class extends export import super"
  2871. };
  2872. var keywordRelationalOperator = /^in(stanceof)?$/;
  2873. // ## Character categories
  2874. // Big ugly regular expressions that match characters in the
  2875. // whitespace, identifier, and identifier-start categories. These
  2876. // are only applied when a character is found to actually have a
  2877. // code point above 128.
  2878. // Generated by `bin/generate-identifier-regex.js`.
  2879. var nonASCIIidentifierStartChars = "\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\u0560-\u0588\u05d0-\u05ea\u05ef-\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\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\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\u09fc\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\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u1878\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\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\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-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\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-\uab69\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";
  2880. var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
  2881. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  2882. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  2883. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  2884. // These are a run-length and offset encoded representation of the
  2885. // >0xffff code points that are a valid part of identifiers. The
  2886. // offset starts at 0x10000, and each pair of numbers represents an
  2887. // offset to the next range, and then a size of the range. They were
  2888. // generated by bin/generate-identifier-regex.js
  2889. // eslint-disable-next-line comma-spacing
  2890. var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938];
  2891. // eslint-disable-next-line comma-spacing
  2892. var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239];
  2893. // This has a complexity linear to the value of the code. The
  2894. // assumption is that looking up astral identifier characters is
  2895. // rare.
  2896. function isInAstralSet(code, set) {
  2897. var pos = 0x10000;
  2898. for (var i = 0; i < set.length; i += 2) {
  2899. pos += set[i];
  2900. if (pos > code) { return false }
  2901. pos += set[i + 1];
  2902. if (pos >= code) { return true }
  2903. }
  2904. }
  2905. // Test whether a given character code starts an identifier.
  2906. function isIdentifierStart(code, astral) {
  2907. if (code < 65) { return code === 36 }
  2908. if (code < 91) { return true }
  2909. if (code < 97) { return code === 95 }
  2910. if (code < 123) { return true }
  2911. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }
  2912. if (astral === false) { return false }
  2913. return isInAstralSet(code, astralIdentifierStartCodes)
  2914. }
  2915. // Test whether a given character is part of an identifier.
  2916. function isIdentifierChar(code, astral) {
  2917. if (code < 48) { return code === 36 }
  2918. if (code < 58) { return true }
  2919. if (code < 65) { return false }
  2920. if (code < 91) { return true }
  2921. if (code < 97) { return code === 95 }
  2922. if (code < 123) { return true }
  2923. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) }
  2924. if (astral === false) { return false }
  2925. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
  2926. }
  2927. // ## Token types
  2928. // The assignment of fine-grained, information-carrying type objects
  2929. // allows the tokenizer to store the information it has about a
  2930. // token in a way that is very cheap for the parser to look up.
  2931. // All token type variables start with an underscore, to make them
  2932. // easy to recognize.
  2933. // The `beforeExpr` property is used to disambiguate between regular
  2934. // expressions and divisions. It is set on all token types that can
  2935. // be followed by an expression (thus, a slash after them would be a
  2936. // regular expression).
  2937. //
  2938. // The `startsExpr` property is used to check if the token ends a
  2939. // `yield` expression. It is set on all token types that either can
  2940. // directly start an expression (like a quotation mark) or can
  2941. // continue an expression (like the body of a string).
  2942. //
  2943. // `isLoop` marks a keyword as starting a loop, which is important
  2944. // to know when parsing a label, in order to allow or disallow
  2945. // continue jumps to that label.
  2946. var TokenType = function TokenType(label, conf) {
  2947. if ( conf === void 0 ) conf = {};
  2948. this.label = label;
  2949. this.keyword = conf.keyword;
  2950. this.beforeExpr = !!conf.beforeExpr;
  2951. this.startsExpr = !!conf.startsExpr;
  2952. this.isLoop = !!conf.isLoop;
  2953. this.isAssign = !!conf.isAssign;
  2954. this.prefix = !!conf.prefix;
  2955. this.postfix = !!conf.postfix;
  2956. this.binop = conf.binop || null;
  2957. this.updateContext = null;
  2958. };
  2959. function binop(name, prec) {
  2960. return new TokenType(name, {beforeExpr: true, binop: prec})
  2961. }
  2962. var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
  2963. // Map keyword names to token types.
  2964. var keywords$1 = {};
  2965. // Succinct definitions of keyword token types
  2966. function kw(name, options) {
  2967. if ( options === void 0 ) options = {};
  2968. options.keyword = name;
  2969. return keywords$1[name] = new TokenType(name, options)
  2970. }
  2971. var types = {
  2972. num: new TokenType("num", startsExpr),
  2973. regexp: new TokenType("regexp", startsExpr),
  2974. string: new TokenType("string", startsExpr),
  2975. name: new TokenType("name", startsExpr),
  2976. privateId: new TokenType("privateId", startsExpr),
  2977. eof: new TokenType("eof"),
  2978. // Punctuation token types.
  2979. bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
  2980. bracketR: new TokenType("]"),
  2981. braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
  2982. braceR: new TokenType("}"),
  2983. parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
  2984. parenR: new TokenType(")"),
  2985. comma: new TokenType(",", beforeExpr),
  2986. semi: new TokenType(";", beforeExpr),
  2987. colon: new TokenType(":", beforeExpr),
  2988. dot: new TokenType("."),
  2989. question: new TokenType("?", beforeExpr),
  2990. questionDot: new TokenType("?."),
  2991. arrow: new TokenType("=>", beforeExpr),
  2992. template: new TokenType("template"),
  2993. invalidTemplate: new TokenType("invalidTemplate"),
  2994. ellipsis: new TokenType("...", beforeExpr),
  2995. backQuote: new TokenType("`", startsExpr),
  2996. dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
  2997. // Operators. These carry several kinds of properties to help the
  2998. // parser use them properly (the presence of these properties is
  2999. // what categorizes them as operators).
  3000. //
  3001. // `binop`, when present, specifies that this operator is a binary
  3002. // operator, and will refer to its precedence.
  3003. //
  3004. // `prefix` and `postfix` mark the operator as a prefix or postfix
  3005. // unary operator.
  3006. //
  3007. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  3008. // binary operators with a very low precedence, that should result
  3009. // in AssignmentExpression nodes.
  3010. eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
  3011. assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
  3012. incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
  3013. prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
  3014. logicalOR: binop("||", 1),
  3015. logicalAND: binop("&&", 2),
  3016. bitwiseOR: binop("|", 3),
  3017. bitwiseXOR: binop("^", 4),
  3018. bitwiseAND: binop("&", 5),
  3019. equality: binop("==/!=/===/!==", 6),
  3020. relational: binop("</>/<=/>=", 7),
  3021. bitShift: binop("<</>>/>>>", 8),
  3022. plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
  3023. modulo: binop("%", 10),
  3024. star: binop("*", 10),
  3025. slash: binop("/", 10),
  3026. starstar: new TokenType("**", {beforeExpr: true}),
  3027. coalesce: binop("??", 1),
  3028. // Keyword token types.
  3029. _break: kw("break"),
  3030. _case: kw("case", beforeExpr),
  3031. _catch: kw("catch"),
  3032. _continue: kw("continue"),
  3033. _debugger: kw("debugger"),
  3034. _default: kw("default", beforeExpr),
  3035. _do: kw("do", {isLoop: true, beforeExpr: true}),
  3036. _else: kw("else", beforeExpr),
  3037. _finally: kw("finally"),
  3038. _for: kw("for", {isLoop: true}),
  3039. _function: kw("function", startsExpr),
  3040. _if: kw("if"),
  3041. _return: kw("return", beforeExpr),
  3042. _switch: kw("switch"),
  3043. _throw: kw("throw", beforeExpr),
  3044. _try: kw("try"),
  3045. _var: kw("var"),
  3046. _const: kw("const"),
  3047. _while: kw("while", {isLoop: true}),
  3048. _with: kw("with"),
  3049. _new: kw("new", {beforeExpr: true, startsExpr: true}),
  3050. _this: kw("this", startsExpr),
  3051. _super: kw("super", startsExpr),
  3052. _class: kw("class", startsExpr),
  3053. _extends: kw("extends", beforeExpr),
  3054. _export: kw("export"),
  3055. _import: kw("import", startsExpr),
  3056. _null: kw("null", startsExpr),
  3057. _true: kw("true", startsExpr),
  3058. _false: kw("false", startsExpr),
  3059. _in: kw("in", {beforeExpr: true, binop: 7}),
  3060. _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
  3061. _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
  3062. _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
  3063. _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
  3064. };
  3065. // Matches a whole line break (where CRLF is considered a single
  3066. // line break). Used to count lines.
  3067. var lineBreak = /\r\n?|\n|\u2028|\u2029/;
  3068. var lineBreakG = new RegExp(lineBreak.source, "g");
  3069. function isNewLine(code, ecma2019String) {
  3070. return code === 10 || code === 13 || (!ecma2019String && (code === 0x2028 || code === 0x2029))
  3071. }
  3072. var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  3073. var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  3074. var ref = Object.prototype;
  3075. var hasOwnProperty = ref.hasOwnProperty;
  3076. var toString = ref.toString;
  3077. // Checks if an object has a property.
  3078. function has(obj, propName) {
  3079. return hasOwnProperty.call(obj, propName)
  3080. }
  3081. var isArray = Array.isArray || (function (obj) { return (
  3082. toString.call(obj) === "[object Array]"
  3083. ); });
  3084. function wordsRegexp(words) {
  3085. return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
  3086. }
  3087. // These are used when `options.locations` is on, for the
  3088. // `startLoc` and `endLoc` properties.
  3089. var Position = function Position(line, col) {
  3090. this.line = line;
  3091. this.column = col;
  3092. };
  3093. Position.prototype.offset = function offset (n) {
  3094. return new Position(this.line, this.column + n)
  3095. };
  3096. var SourceLocation = function SourceLocation(p, start, end) {
  3097. this.start = start;
  3098. this.end = end;
  3099. if (p.sourceFile !== null) { this.source = p.sourceFile; }
  3100. };
  3101. // The `getLineInfo` function is mostly useful when the
  3102. // `locations` option is off (for performance reasons) and you
  3103. // want to find the line/column position for a given character
  3104. // offset. `input` should be the code string that the offset refers
  3105. // into.
  3106. function getLineInfo(input, offset) {
  3107. for (var line = 1, cur = 0;;) {
  3108. lineBreakG.lastIndex = cur;
  3109. var match = lineBreakG.exec(input);
  3110. if (match && match.index < offset) {
  3111. ++line;
  3112. cur = match.index + match[0].length;
  3113. } else {
  3114. return new Position(line, offset - cur)
  3115. }
  3116. }
  3117. }
  3118. // A second argument must be given to configure the parser process.
  3119. // These options are recognized (only `ecmaVersion` is required):
  3120. var defaultOptions = {
  3121. // `ecmaVersion` indicates the ECMAScript version to parse. Must be
  3122. // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
  3123. // (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"` (the
  3124. // latest version the library supports). This influences support
  3125. // for strict mode, the set of reserved words, and support for
  3126. // new syntax features.
  3127. ecmaVersion: null,
  3128. // `sourceType` indicates the mode the code should be parsed in.
  3129. // Can be either `"script"` or `"module"`. This influences global
  3130. // strict mode and parsing of `import` and `export` declarations.
  3131. sourceType: "script",
  3132. // `onInsertedSemicolon` can be a callback that will be called
  3133. // when a semicolon is automatically inserted. It will be passed
  3134. // the position of the comma as an offset, and if `locations` is
  3135. // enabled, it is given the location as a `{line, column}` object
  3136. // as second argument.
  3137. onInsertedSemicolon: null,
  3138. // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  3139. // trailing commas.
  3140. onTrailingComma: null,
  3141. // By default, reserved words are only enforced if ecmaVersion >= 5.
  3142. // Set `allowReserved` to a boolean value to explicitly turn this on
  3143. // an off. When this option has the value "never", reserved words
  3144. // and keywords can also not be used as property names.
  3145. allowReserved: null,
  3146. // When enabled, a return at the top level is not considered an
  3147. // error.
  3148. allowReturnOutsideFunction: false,
  3149. // When enabled, import/export statements are not constrained to
  3150. // appearing at the top of the program, and an import.meta expression
  3151. // in a script isn't considered an error.
  3152. allowImportExportEverywhere: false,
  3153. // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022.
  3154. // When enabled, await identifiers are allowed to appear at the top-level scope,
  3155. // but they are still not allowed in non-async functions.
  3156. allowAwaitOutsideFunction: null,
  3157. // When enabled, super identifiers are not constrained to
  3158. // appearing in methods and do not raise an error when they appear elsewhere.
  3159. allowSuperOutsideMethod: null,
  3160. // When enabled, hashbang directive in the beginning of file
  3161. // is allowed and treated as a line comment.
  3162. allowHashBang: false,
  3163. // When `locations` is on, `loc` properties holding objects with
  3164. // `start` and `end` properties in `{line, column}` form (with
  3165. // line being 1-based and column 0-based) will be attached to the
  3166. // nodes.
  3167. locations: false,
  3168. // A function can be passed as `onToken` option, which will
  3169. // cause Acorn to call that function with object in the same
  3170. // format as tokens returned from `tokenizer().getToken()`. Note
  3171. // that you are not allowed to call the parser from the
  3172. // callback—that will corrupt its internal state.
  3173. onToken: null,
  3174. // A function can be passed as `onComment` option, which will
  3175. // cause Acorn to call that function with `(block, text, start,
  3176. // end)` parameters whenever a comment is skipped. `block` is a
  3177. // boolean indicating whether this is a block (`/* */`) comment,
  3178. // `text` is the content of the comment, and `start` and `end` are
  3179. // character offsets that denote the start and end of the comment.
  3180. // When the `locations` option is on, two more parameters are
  3181. // passed, the full `{line, column}` locations of the start and
  3182. // end of the comments. Note that you are not allowed to call the
  3183. // parser from the callback—that will corrupt its internal state.
  3184. onComment: null,
  3185. // Nodes have their start and end characters offsets recorded in
  3186. // `start` and `end` properties (directly on the node, rather than
  3187. // the `loc` object, which holds line/column data. To also add a
  3188. // [semi-standardized][range] `range` property holding a `[start,
  3189. // end]` array with the same numbers, set the `ranges` option to
  3190. // `true`.
  3191. //
  3192. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  3193. ranges: false,
  3194. // It is possible to parse multiple files into a single AST by
  3195. // passing the tree produced by parsing the first file as
  3196. // `program` option in subsequent parses. This will add the
  3197. // toplevel forms of the parsed file to the `Program` (top) node
  3198. // of an existing parse tree.
  3199. program: null,
  3200. // When `locations` is on, you can pass this to record the source
  3201. // file in every node's `loc` object.
  3202. sourceFile: null,
  3203. // This value, if given, is stored in every node, whether
  3204. // `locations` is on or off.
  3205. directSourceFile: null,
  3206. // When enabled, parenthesized expressions are represented by
  3207. // (non-standard) ParenthesizedExpression nodes
  3208. preserveParens: false
  3209. };
  3210. // Interpret and default an options object
  3211. var warnedAboutEcmaVersion = false;
  3212. function getOptions(opts) {
  3213. var options = {};
  3214. for (var opt in defaultOptions)
  3215. { options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]; }
  3216. if (options.ecmaVersion === "latest") {
  3217. options.ecmaVersion = 1e8;
  3218. } else if (options.ecmaVersion == null) {
  3219. if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) {
  3220. warnedAboutEcmaVersion = true;
  3221. console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.");
  3222. }
  3223. options.ecmaVersion = 11;
  3224. } else if (options.ecmaVersion >= 2015) {
  3225. options.ecmaVersion -= 2009;
  3226. }
  3227. if (options.allowReserved == null)
  3228. { options.allowReserved = options.ecmaVersion < 5; }
  3229. if (isArray(options.onToken)) {
  3230. var tokens = options.onToken;
  3231. options.onToken = function (token) { return tokens.push(token); };
  3232. }
  3233. if (isArray(options.onComment))
  3234. { options.onComment = pushComment(options, options.onComment); }
  3235. return options
  3236. }
  3237. function pushComment(options, array) {
  3238. return function(block, text, start, end, startLoc, endLoc) {
  3239. var comment = {
  3240. type: block ? "Block" : "Line",
  3241. value: text,
  3242. start: start,
  3243. end: end
  3244. };
  3245. if (options.locations)
  3246. { comment.loc = new SourceLocation(this, startLoc, endLoc); }
  3247. if (options.ranges)
  3248. { comment.range = [start, end]; }
  3249. array.push(comment);
  3250. }
  3251. }
  3252. // Each scope gets a bitset that may contain these flags
  3253. var
  3254. SCOPE_TOP = 1,
  3255. SCOPE_FUNCTION = 2,
  3256. SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION,
  3257. SCOPE_ASYNC = 4,
  3258. SCOPE_GENERATOR = 8,
  3259. SCOPE_ARROW = 16,
  3260. SCOPE_SIMPLE_CATCH = 32,
  3261. SCOPE_SUPER = 64,
  3262. SCOPE_DIRECT_SUPER = 128;
  3263. function functionFlags(async, generator) {
  3264. return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)
  3265. }
  3266. // Used in checkLVal* and declareName to determine the type of a binding
  3267. var
  3268. BIND_NONE = 0, // Not a binding
  3269. BIND_VAR = 1, // Var-style binding
  3270. BIND_LEXICAL = 2, // Let- or const-style binding
  3271. BIND_FUNCTION = 3, // Function declaration
  3272. BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding
  3273. BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
  3274. var Parser = function Parser(options, input, startPos) {
  3275. this.options = options = getOptions(options);
  3276. this.sourceFile = options.sourceFile;
  3277. this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
  3278. var reserved = "";
  3279. if (options.allowReserved !== true) {
  3280. reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
  3281. if (options.sourceType === "module") { reserved += " await"; }
  3282. }
  3283. this.reservedWords = wordsRegexp(reserved);
  3284. var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
  3285. this.reservedWordsStrict = wordsRegexp(reservedStrict);
  3286. this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
  3287. this.input = String(input);
  3288. // Used to signal to callers of `readWord1` whether the word
  3289. // contained any escape sequences. This is needed because words with
  3290. // escape sequences must not be interpreted as keywords.
  3291. this.containsEsc = false;
  3292. // Set up token state
  3293. // The current position of the tokenizer in the input.
  3294. if (startPos) {
  3295. this.pos = startPos;
  3296. this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
  3297. this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
  3298. } else {
  3299. this.pos = this.lineStart = 0;
  3300. this.curLine = 1;
  3301. }
  3302. // Properties of the current token:
  3303. // Its type
  3304. this.type = types.eof;
  3305. // For tokens that include more information than their type, the value
  3306. this.value = null;
  3307. // Its start and end offset
  3308. this.start = this.end = this.pos;
  3309. // And, if locations are used, the {line, column} object
  3310. // corresponding to those offsets
  3311. this.startLoc = this.endLoc = this.curPosition();
  3312. // Position information for the previous token
  3313. this.lastTokEndLoc = this.lastTokStartLoc = null;
  3314. this.lastTokStart = this.lastTokEnd = this.pos;
  3315. // The context stack is used to superficially track syntactic
  3316. // context to predict whether a regular expression is allowed in a
  3317. // given position.
  3318. this.context = this.initialContext();
  3319. this.exprAllowed = true;
  3320. // Figure out if it's a module code.
  3321. this.inModule = options.sourceType === "module";
  3322. this.strict = this.inModule || this.strictDirective(this.pos);
  3323. // Used to signify the start of a potential arrow function
  3324. this.potentialArrowAt = -1;
  3325. this.potentialArrowInForAwait = false;
  3326. // Positions to delayed-check that yield/await does not exist in default parameters.
  3327. this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
  3328. // Labels in scope.
  3329. this.labels = [];
  3330. // Thus-far undefined exports.
  3331. this.undefinedExports = Object.create(null);
  3332. // If enabled, skip leading hashbang line.
  3333. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!")
  3334. { this.skipLineComment(2); }
  3335. // Scope tracking for duplicate variable names (see scope.js)
  3336. this.scopeStack = [];
  3337. this.enterScope(SCOPE_TOP);
  3338. // For RegExp validation
  3339. this.regexpState = null;
  3340. // The stack of private names.
  3341. // Each element has two properties: 'declared' and 'used'.
  3342. // When it exited from the outermost class definition, all used private names must be declared.
  3343. this.privateNameStack = [];
  3344. };
  3345. var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },inNonArrowFunction: { configurable: true } };
  3346. Parser.prototype.parse = function parse () {
  3347. var node = this.options.program || this.startNode();
  3348. this.nextToken();
  3349. return this.parseTopLevel(node)
  3350. };
  3351. prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
  3352. prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
  3353. prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
  3354. prototypeAccessors.canAwait.get = function () {
  3355. for (var i = this.scopeStack.length - 1; i >= 0; i--) {
  3356. var scope = this.scopeStack[i];
  3357. if (scope.inClassFieldInit) { return false }
  3358. if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }
  3359. }
  3360. return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
  3361. };
  3362. prototypeAccessors.allowSuper.get = function () {
  3363. var ref = this.currentThisScope();
  3364. var flags = ref.flags;
  3365. var inClassFieldInit = ref.inClassFieldInit;
  3366. return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod
  3367. };
  3368. prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
  3369. prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
  3370. prototypeAccessors.inNonArrowFunction.get = function () {
  3371. var ref = this.currentThisScope();
  3372. var flags = ref.flags;
  3373. var inClassFieldInit = ref.inClassFieldInit;
  3374. return (flags & SCOPE_FUNCTION) > 0 || inClassFieldInit
  3375. };
  3376. Parser.extend = function extend () {
  3377. var plugins = [], len = arguments.length;
  3378. while ( len-- ) plugins[ len ] = arguments[ len ];
  3379. var cls = this;
  3380. for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }
  3381. return cls
  3382. };
  3383. Parser.parse = function parse (input, options) {
  3384. return new this(options, input).parse()
  3385. };
  3386. Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) {
  3387. var parser = new this(options, input, pos);
  3388. parser.nextToken();
  3389. return parser.parseExpression()
  3390. };
  3391. Parser.tokenizer = function tokenizer (input, options) {
  3392. return new this(options, input)
  3393. };
  3394. Object.defineProperties( Parser.prototype, prototypeAccessors );
  3395. var pp = Parser.prototype;
  3396. // ## Parser utilities
  3397. var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
  3398. pp.strictDirective = function(start) {
  3399. for (;;) {
  3400. // Try to find string literal.
  3401. skipWhiteSpace.lastIndex = start;
  3402. start += skipWhiteSpace.exec(this.input)[0].length;
  3403. var match = literal.exec(this.input.slice(start));
  3404. if (!match) { return false }
  3405. if ((match[1] || match[2]) === "use strict") {
  3406. skipWhiteSpace.lastIndex = start + match[0].length;
  3407. var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
  3408. var next = this.input.charAt(end);
  3409. return next === ";" || next === "}" ||
  3410. (lineBreak.test(spaceAfter[0]) &&
  3411. !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
  3412. }
  3413. start += match[0].length;
  3414. // Skip semicolon, if any.
  3415. skipWhiteSpace.lastIndex = start;
  3416. start += skipWhiteSpace.exec(this.input)[0].length;
  3417. if (this.input[start] === ";")
  3418. { start++; }
  3419. }
  3420. };
  3421. // Predicate that tests whether the next token is of the given
  3422. // type, and if yes, consumes it as a side effect.
  3423. pp.eat = function(type) {
  3424. if (this.type === type) {
  3425. this.next();
  3426. return true
  3427. } else {
  3428. return false
  3429. }
  3430. };
  3431. // Tests whether parsed token is a contextual keyword.
  3432. pp.isContextual = function(name) {
  3433. return this.type === types.name && this.value === name && !this.containsEsc
  3434. };
  3435. // Consumes contextual keyword if possible.
  3436. pp.eatContextual = function(name) {
  3437. if (!this.isContextual(name)) { return false }
  3438. this.next();
  3439. return true
  3440. };
  3441. // Asserts that following token is given contextual keyword.
  3442. pp.expectContextual = function(name) {
  3443. if (!this.eatContextual(name)) { this.unexpected(); }
  3444. };
  3445. // Test whether a semicolon can be inserted at the current position.
  3446. pp.canInsertSemicolon = function() {
  3447. return this.type === types.eof ||
  3448. this.type === types.braceR ||
  3449. lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  3450. };
  3451. pp.insertSemicolon = function() {
  3452. if (this.canInsertSemicolon()) {
  3453. if (this.options.onInsertedSemicolon)
  3454. { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
  3455. return true
  3456. }
  3457. };
  3458. // Consume a semicolon, or, failing that, see if we are allowed to
  3459. // pretend that there is a semicolon at this position.
  3460. pp.semicolon = function() {
  3461. if (!this.eat(types.semi) && !this.insertSemicolon()) { this.unexpected(); }
  3462. };
  3463. pp.afterTrailingComma = function(tokType, notNext) {
  3464. if (this.type === tokType) {
  3465. if (this.options.onTrailingComma)
  3466. { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
  3467. if (!notNext)
  3468. { this.next(); }
  3469. return true
  3470. }
  3471. };
  3472. // Expect a token of a given type. If found, consume it, otherwise,
  3473. // raise an unexpected token error.
  3474. pp.expect = function(type) {
  3475. this.eat(type) || this.unexpected();
  3476. };
  3477. // Raise an unexpected token error.
  3478. pp.unexpected = function(pos) {
  3479. this.raise(pos != null ? pos : this.start, "Unexpected token");
  3480. };
  3481. function DestructuringErrors() {
  3482. this.shorthandAssign =
  3483. this.trailingComma =
  3484. this.parenthesizedAssign =
  3485. this.parenthesizedBind =
  3486. this.doubleProto =
  3487. -1;
  3488. }
  3489. pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
  3490. if (!refDestructuringErrors) { return }
  3491. if (refDestructuringErrors.trailingComma > -1)
  3492. { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
  3493. var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
  3494. if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
  3495. };
  3496. pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
  3497. if (!refDestructuringErrors) { return false }
  3498. var shorthandAssign = refDestructuringErrors.shorthandAssign;
  3499. var doubleProto = refDestructuringErrors.doubleProto;
  3500. if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
  3501. if (shorthandAssign >= 0)
  3502. { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
  3503. if (doubleProto >= 0)
  3504. { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
  3505. };
  3506. pp.checkYieldAwaitInDefaultParams = function() {
  3507. if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
  3508. { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
  3509. if (this.awaitPos)
  3510. { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
  3511. };
  3512. pp.isSimpleAssignTarget = function(expr) {
  3513. if (expr.type === "ParenthesizedExpression")
  3514. { return this.isSimpleAssignTarget(expr.expression) }
  3515. return expr.type === "Identifier" || expr.type === "MemberExpression"
  3516. };
  3517. var pp$1 = Parser.prototype;
  3518. // ### Statement parsing
  3519. // Parse a program. Initializes the parser, reads any number of
  3520. // statements, and wraps them in a Program node. Optionally takes a
  3521. // `program` argument. If present, the statements will be appended
  3522. // to its body instead of creating a new node.
  3523. pp$1.parseTopLevel = function(node) {
  3524. var exports = Object.create(null);
  3525. if (!node.body) { node.body = []; }
  3526. while (this.type !== types.eof) {
  3527. var stmt = this.parseStatement(null, true, exports);
  3528. node.body.push(stmt);
  3529. }
  3530. if (this.inModule)
  3531. { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)
  3532. {
  3533. var name = list[i];
  3534. this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined"));
  3535. } }
  3536. this.adaptDirectivePrologue(node.body);
  3537. this.next();
  3538. node.sourceType = this.options.sourceType;
  3539. return this.finishNode(node, "Program")
  3540. };
  3541. var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
  3542. pp$1.isLet = function(context) {
  3543. if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
  3544. skipWhiteSpace.lastIndex = this.pos;
  3545. var skip = skipWhiteSpace.exec(this.input);
  3546. var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
  3547. // For ambiguous cases, determine if a LexicalDeclaration (or only a
  3548. // Statement) is allowed here. If context is not empty then only a Statement
  3549. // is allowed. However, `let [` is an explicit negative lookahead for
  3550. // ExpressionStatement, so special-case it first.
  3551. if (nextCh === 91 || nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '[', '/', astral
  3552. if (context) { return false }
  3553. if (nextCh === 123) { return true } // '{'
  3554. if (isIdentifierStart(nextCh, true)) {
  3555. var pos = next + 1;
  3556. while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }
  3557. if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }
  3558. var ident = this.input.slice(next, pos);
  3559. if (!keywordRelationalOperator.test(ident)) { return true }
  3560. }
  3561. return false
  3562. };
  3563. // check 'async [no LineTerminator here] function'
  3564. // - 'async /*foo*/ function' is OK.
  3565. // - 'async /*\n*/ function' is invalid.
  3566. pp$1.isAsyncFunction = function() {
  3567. if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
  3568. { return false }
  3569. skipWhiteSpace.lastIndex = this.pos;
  3570. var skip = skipWhiteSpace.exec(this.input);
  3571. var next = this.pos + skip[0].length, after;
  3572. return !lineBreak.test(this.input.slice(this.pos, next)) &&
  3573. this.input.slice(next, next + 8) === "function" &&
  3574. (next + 8 === this.input.length ||
  3575. !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
  3576. };
  3577. // Parse a single statement.
  3578. //
  3579. // If expecting a statement and finding a slash operator, parse a
  3580. // regular expression literal. This is to handle cases like
  3581. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  3582. // does not help.
  3583. pp$1.parseStatement = function(context, topLevel, exports) {
  3584. var starttype = this.type, node = this.startNode(), kind;
  3585. if (this.isLet(context)) {
  3586. starttype = types._var;
  3587. kind = "let";
  3588. }
  3589. // Most types of statements are recognized by the keyword they
  3590. // start with. Many are trivial to parse, some require a bit of
  3591. // complexity.
  3592. switch (starttype) {
  3593. case types._break: case types._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
  3594. case types._debugger: return this.parseDebuggerStatement(node)
  3595. case types._do: return this.parseDoStatement(node)
  3596. case types._for: return this.parseForStatement(node)
  3597. case types._function:
  3598. // Function as sole body of either an if statement or a labeled statement
  3599. // works, but not when it is part of a labeled statement that is the sole
  3600. // body of an if statement.
  3601. if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
  3602. return this.parseFunctionStatement(node, false, !context)
  3603. case types._class:
  3604. if (context) { this.unexpected(); }
  3605. return this.parseClass(node, true)
  3606. case types._if: return this.parseIfStatement(node)
  3607. case types._return: return this.parseReturnStatement(node)
  3608. case types._switch: return this.parseSwitchStatement(node)
  3609. case types._throw: return this.parseThrowStatement(node)
  3610. case types._try: return this.parseTryStatement(node)
  3611. case types._const: case types._var:
  3612. kind = kind || this.value;
  3613. if (context && kind !== "var") { this.unexpected(); }
  3614. return this.parseVarStatement(node, kind)
  3615. case types._while: return this.parseWhileStatement(node)
  3616. case types._with: return this.parseWithStatement(node)
  3617. case types.braceL: return this.parseBlock(true, node)
  3618. case types.semi: return this.parseEmptyStatement(node)
  3619. case types._export:
  3620. case types._import:
  3621. if (this.options.ecmaVersion > 10 && starttype === types._import) {
  3622. skipWhiteSpace.lastIndex = this.pos;
  3623. var skip = skipWhiteSpace.exec(this.input);
  3624. var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
  3625. if (nextCh === 40 || nextCh === 46) // '(' or '.'
  3626. { return this.parseExpressionStatement(node, this.parseExpression()) }
  3627. }
  3628. if (!this.options.allowImportExportEverywhere) {
  3629. if (!topLevel)
  3630. { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
  3631. if (!this.inModule)
  3632. { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
  3633. }
  3634. return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports)
  3635. // If the statement does not start with a statement keyword or a
  3636. // brace, it's an ExpressionStatement or LabeledStatement. We
  3637. // simply start parsing an expression, and afterwards, if the
  3638. // next token is a colon and the expression was a simple
  3639. // Identifier node, we switch to interpreting it as a label.
  3640. default:
  3641. if (this.isAsyncFunction()) {
  3642. if (context) { this.unexpected(); }
  3643. this.next();
  3644. return this.parseFunctionStatement(node, true, !context)
  3645. }
  3646. var maybeName = this.value, expr = this.parseExpression();
  3647. if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon))
  3648. { return this.parseLabeledStatement(node, maybeName, expr, context) }
  3649. else { return this.parseExpressionStatement(node, expr) }
  3650. }
  3651. };
  3652. pp$1.parseBreakContinueStatement = function(node, keyword) {
  3653. var isBreak = keyword === "break";
  3654. this.next();
  3655. if (this.eat(types.semi) || this.insertSemicolon()) { node.label = null; }
  3656. else if (this.type !== types.name) { this.unexpected(); }
  3657. else {
  3658. node.label = this.parseIdent();
  3659. this.semicolon();
  3660. }
  3661. // Verify that there is an actual destination to break or
  3662. // continue to.
  3663. var i = 0;
  3664. for (; i < this.labels.length; ++i) {
  3665. var lab = this.labels[i];
  3666. if (node.label == null || lab.name === node.label.name) {
  3667. if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
  3668. if (node.label && isBreak) { break }
  3669. }
  3670. }
  3671. if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
  3672. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
  3673. };
  3674. pp$1.parseDebuggerStatement = function(node) {
  3675. this.next();
  3676. this.semicolon();
  3677. return this.finishNode(node, "DebuggerStatement")
  3678. };
  3679. pp$1.parseDoStatement = function(node) {
  3680. this.next();
  3681. this.labels.push(loopLabel);
  3682. node.body = this.parseStatement("do");
  3683. this.labels.pop();
  3684. this.expect(types._while);
  3685. node.test = this.parseParenExpression();
  3686. if (this.options.ecmaVersion >= 6)
  3687. { this.eat(types.semi); }
  3688. else
  3689. { this.semicolon(); }
  3690. return this.finishNode(node, "DoWhileStatement")
  3691. };
  3692. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  3693. // loop is non-trivial. Basically, we have to parse the init `var`
  3694. // statement or expression, disallowing the `in` operator (see
  3695. // the second parameter to `parseExpression`), and then check
  3696. // whether the next token is `in` or `of`. When there is no init
  3697. // part (semicolon immediately after the opening parenthesis), it
  3698. // is a regular `for` loop.
  3699. pp$1.parseForStatement = function(node) {
  3700. this.next();
  3701. var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1;
  3702. this.labels.push(loopLabel);
  3703. this.enterScope(0);
  3704. this.expect(types.parenL);
  3705. if (this.type === types.semi) {
  3706. if (awaitAt > -1) { this.unexpected(awaitAt); }
  3707. return this.parseFor(node, null)
  3708. }
  3709. var isLet = this.isLet();
  3710. if (this.type === types._var || this.type === types._const || isLet) {
  3711. var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
  3712. this.next();
  3713. this.parseVar(init$1, true, kind);
  3714. this.finishNode(init$1, "VariableDeclaration");
  3715. if ((this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
  3716. if (this.options.ecmaVersion >= 9) {
  3717. if (this.type === types._in) {
  3718. if (awaitAt > -1) { this.unexpected(awaitAt); }
  3719. } else { node.await = awaitAt > -1; }
  3720. }
  3721. return this.parseForIn(node, init$1)
  3722. }
  3723. if (awaitAt > -1) { this.unexpected(awaitAt); }
  3724. return this.parseFor(node, init$1)
  3725. }
  3726. var refDestructuringErrors = new DestructuringErrors;
  3727. var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
  3728. if (this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
  3729. if (this.options.ecmaVersion >= 9) {
  3730. if (this.type === types._in) {
  3731. if (awaitAt > -1) { this.unexpected(awaitAt); }
  3732. } else { node.await = awaitAt > -1; }
  3733. }
  3734. this.toAssignable(init, false, refDestructuringErrors);
  3735. this.checkLValPattern(init);
  3736. return this.parseForIn(node, init)
  3737. } else {
  3738. this.checkExpressionErrors(refDestructuringErrors, true);
  3739. }
  3740. if (awaitAt > -1) { this.unexpected(awaitAt); }
  3741. return this.parseFor(node, init)
  3742. };
  3743. pp$1.parseFunctionStatement = function(node, isAsync, declarationPosition) {
  3744. this.next();
  3745. return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
  3746. };
  3747. pp$1.parseIfStatement = function(node) {
  3748. this.next();
  3749. node.test = this.parseParenExpression();
  3750. // allow function declarations in branches, but only in non-strict mode
  3751. node.consequent = this.parseStatement("if");
  3752. node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
  3753. return this.finishNode(node, "IfStatement")
  3754. };
  3755. pp$1.parseReturnStatement = function(node) {
  3756. if (!this.inFunction && !this.options.allowReturnOutsideFunction)
  3757. { this.raise(this.start, "'return' outside of function"); }
  3758. this.next();
  3759. // In `return` (and `break`/`continue`), the keywords with
  3760. // optional arguments, we eagerly look for a semicolon or the
  3761. // possibility to insert one.
  3762. if (this.eat(types.semi) || this.insertSemicolon()) { node.argument = null; }
  3763. else { node.argument = this.parseExpression(); this.semicolon(); }
  3764. return this.finishNode(node, "ReturnStatement")
  3765. };
  3766. pp$1.parseSwitchStatement = function(node) {
  3767. this.next();
  3768. node.discriminant = this.parseParenExpression();
  3769. node.cases = [];
  3770. this.expect(types.braceL);
  3771. this.labels.push(switchLabel);
  3772. this.enterScope(0);
  3773. // Statements under must be grouped (by label) in SwitchCase
  3774. // nodes. `cur` is used to keep the node that we are currently
  3775. // adding statements to.
  3776. var cur;
  3777. for (var sawDefault = false; this.type !== types.braceR;) {
  3778. if (this.type === types._case || this.type === types._default) {
  3779. var isCase = this.type === types._case;
  3780. if (cur) { this.finishNode(cur, "SwitchCase"); }
  3781. node.cases.push(cur = this.startNode());
  3782. cur.consequent = [];
  3783. this.next();
  3784. if (isCase) {
  3785. cur.test = this.parseExpression();
  3786. } else {
  3787. if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); }
  3788. sawDefault = true;
  3789. cur.test = null;
  3790. }
  3791. this.expect(types.colon);
  3792. } else {
  3793. if (!cur) { this.unexpected(); }
  3794. cur.consequent.push(this.parseStatement(null));
  3795. }
  3796. }
  3797. this.exitScope();
  3798. if (cur) { this.finishNode(cur, "SwitchCase"); }
  3799. this.next(); // Closing brace
  3800. this.labels.pop();
  3801. return this.finishNode(node, "SwitchStatement")
  3802. };
  3803. pp$1.parseThrowStatement = function(node) {
  3804. this.next();
  3805. if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
  3806. { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
  3807. node.argument = this.parseExpression();
  3808. this.semicolon();
  3809. return this.finishNode(node, "ThrowStatement")
  3810. };
  3811. // Reused empty array added for node fields that are always empty.
  3812. var empty = [];
  3813. pp$1.parseTryStatement = function(node) {
  3814. this.next();
  3815. node.block = this.parseBlock();
  3816. node.handler = null;
  3817. if (this.type === types._catch) {
  3818. var clause = this.startNode();
  3819. this.next();
  3820. if (this.eat(types.parenL)) {
  3821. clause.param = this.parseBindingAtom();
  3822. var simple = clause.param.type === "Identifier";
  3823. this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
  3824. this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
  3825. this.expect(types.parenR);
  3826. } else {
  3827. if (this.options.ecmaVersion < 10) { this.unexpected(); }
  3828. clause.param = null;
  3829. this.enterScope(0);
  3830. }
  3831. clause.body = this.parseBlock(false);
  3832. this.exitScope();
  3833. node.handler = this.finishNode(clause, "CatchClause");
  3834. }
  3835. node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
  3836. if (!node.handler && !node.finalizer)
  3837. { this.raise(node.start, "Missing catch or finally clause"); }
  3838. return this.finishNode(node, "TryStatement")
  3839. };
  3840. pp$1.parseVarStatement = function(node, kind) {
  3841. this.next();
  3842. this.parseVar(node, false, kind);
  3843. this.semicolon();
  3844. return this.finishNode(node, "VariableDeclaration")
  3845. };
  3846. pp$1.parseWhileStatement = function(node) {
  3847. this.next();
  3848. node.test = this.parseParenExpression();
  3849. this.labels.push(loopLabel);
  3850. node.body = this.parseStatement("while");
  3851. this.labels.pop();
  3852. return this.finishNode(node, "WhileStatement")
  3853. };
  3854. pp$1.parseWithStatement = function(node) {
  3855. if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
  3856. this.next();
  3857. node.object = this.parseParenExpression();
  3858. node.body = this.parseStatement("with");
  3859. return this.finishNode(node, "WithStatement")
  3860. };
  3861. pp$1.parseEmptyStatement = function(node) {
  3862. this.next();
  3863. return this.finishNode(node, "EmptyStatement")
  3864. };
  3865. pp$1.parseLabeledStatement = function(node, maybeName, expr, context) {
  3866. for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
  3867. {
  3868. var label = list[i$1];
  3869. if (label.name === maybeName)
  3870. { this.raise(expr.start, "Label '" + maybeName + "' is already declared");
  3871. } }
  3872. var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
  3873. for (var i = this.labels.length - 1; i >= 0; i--) {
  3874. var label$1 = this.labels[i];
  3875. if (label$1.statementStart === node.start) {
  3876. // Update information about previous labels on this node
  3877. label$1.statementStart = this.start;
  3878. label$1.kind = kind;
  3879. } else { break }
  3880. }
  3881. this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
  3882. node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
  3883. this.labels.pop();
  3884. node.label = expr;
  3885. return this.finishNode(node, "LabeledStatement")
  3886. };
  3887. pp$1.parseExpressionStatement = function(node, expr) {
  3888. node.expression = expr;
  3889. this.semicolon();
  3890. return this.finishNode(node, "ExpressionStatement")
  3891. };
  3892. // Parse a semicolon-enclosed block of statements, handling `"use
  3893. // strict"` declarations when `allowStrict` is true (used for
  3894. // function bodies).
  3895. pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) {
  3896. if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
  3897. if ( node === void 0 ) node = this.startNode();
  3898. node.body = [];
  3899. this.expect(types.braceL);
  3900. if (createNewLexicalScope) { this.enterScope(0); }
  3901. while (this.type !== types.braceR) {
  3902. var stmt = this.parseStatement(null);
  3903. node.body.push(stmt);
  3904. }
  3905. if (exitStrict) { this.strict = false; }
  3906. this.next();
  3907. if (createNewLexicalScope) { this.exitScope(); }
  3908. return this.finishNode(node, "BlockStatement")
  3909. };
  3910. // Parse a regular `for` loop. The disambiguation code in
  3911. // `parseStatement` will already have parsed the init statement or
  3912. // expression.
  3913. pp$1.parseFor = function(node, init) {
  3914. node.init = init;
  3915. this.expect(types.semi);
  3916. node.test = this.type === types.semi ? null : this.parseExpression();
  3917. this.expect(types.semi);
  3918. node.update = this.type === types.parenR ? null : this.parseExpression();
  3919. this.expect(types.parenR);
  3920. node.body = this.parseStatement("for");
  3921. this.exitScope();
  3922. this.labels.pop();
  3923. return this.finishNode(node, "ForStatement")
  3924. };
  3925. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  3926. // same from parser's perspective.
  3927. pp$1.parseForIn = function(node, init) {
  3928. var isForIn = this.type === types._in;
  3929. this.next();
  3930. if (
  3931. init.type === "VariableDeclaration" &&
  3932. init.declarations[0].init != null &&
  3933. (
  3934. !isForIn ||
  3935. this.options.ecmaVersion < 8 ||
  3936. this.strict ||
  3937. init.kind !== "var" ||
  3938. init.declarations[0].id.type !== "Identifier"
  3939. )
  3940. ) {
  3941. this.raise(
  3942. init.start,
  3943. ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer")
  3944. );
  3945. }
  3946. node.left = init;
  3947. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
  3948. this.expect(types.parenR);
  3949. node.body = this.parseStatement("for");
  3950. this.exitScope();
  3951. this.labels.pop();
  3952. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
  3953. };
  3954. // Parse a list of variable declarations.
  3955. pp$1.parseVar = function(node, isFor, kind) {
  3956. node.declarations = [];
  3957. node.kind = kind;
  3958. for (;;) {
  3959. var decl = this.startNode();
  3960. this.parseVarId(decl, kind);
  3961. if (this.eat(types.eq)) {
  3962. decl.init = this.parseMaybeAssign(isFor);
  3963. } else if (kind === "const" && !(this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
  3964. this.unexpected();
  3965. } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types._in || this.isContextual("of")))) {
  3966. this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
  3967. } else {
  3968. decl.init = null;
  3969. }
  3970. node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
  3971. if (!this.eat(types.comma)) { break }
  3972. }
  3973. return node
  3974. };
  3975. pp$1.parseVarId = function(decl, kind) {
  3976. decl.id = this.parseBindingAtom();
  3977. this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
  3978. };
  3979. var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
  3980. // Parse a function declaration or literal (depending on the
  3981. // `statement & FUNC_STATEMENT`).
  3982. // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
  3983. pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync) {
  3984. this.initFunction(node);
  3985. if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
  3986. if (this.type === types.star && (statement & FUNC_HANGING_STATEMENT))
  3987. { this.unexpected(); }
  3988. node.generator = this.eat(types.star);
  3989. }
  3990. if (this.options.ecmaVersion >= 8)
  3991. { node.async = !!isAsync; }
  3992. if (statement & FUNC_STATEMENT) {
  3993. node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types.name ? null : this.parseIdent();
  3994. if (node.id && !(statement & FUNC_HANGING_STATEMENT))
  3995. // If it is a regular function declaration in sloppy mode, then it is
  3996. // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
  3997. // mode depends on properties of the current scope (see
  3998. // treatFunctionsAsVar).
  3999. { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }
  4000. }
  4001. var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  4002. this.yieldPos = 0;
  4003. this.awaitPos = 0;
  4004. this.awaitIdentPos = 0;
  4005. this.enterScope(functionFlags(node.async, node.generator));
  4006. if (!(statement & FUNC_STATEMENT))
  4007. { node.id = this.type === types.name ? this.parseIdent() : null; }
  4008. this.parseFunctionParams(node);
  4009. this.parseFunctionBody(node, allowExpressionBody, false);
  4010. this.yieldPos = oldYieldPos;
  4011. this.awaitPos = oldAwaitPos;
  4012. this.awaitIdentPos = oldAwaitIdentPos;
  4013. return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
  4014. };
  4015. pp$1.parseFunctionParams = function(node) {
  4016. this.expect(types.parenL);
  4017. node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
  4018. this.checkYieldAwaitInDefaultParams();
  4019. };
  4020. // Parse a class declaration or literal (depending on the
  4021. // `isStatement` parameter).
  4022. pp$1.parseClass = function(node, isStatement) {
  4023. this.next();
  4024. // ecma-262 14.6 Class Definitions
  4025. // A class definition is always strict mode code.
  4026. var oldStrict = this.strict;
  4027. this.strict = true;
  4028. this.parseClassId(node, isStatement);
  4029. this.parseClassSuper(node);
  4030. var privateNameMap = this.enterClassBody();
  4031. var classBody = this.startNode();
  4032. var hadConstructor = false;
  4033. classBody.body = [];
  4034. this.expect(types.braceL);
  4035. while (this.type !== types.braceR) {
  4036. var element = this.parseClassElement(node.superClass !== null);
  4037. if (element) {
  4038. classBody.body.push(element);
  4039. if (element.type === "MethodDefinition" && element.kind === "constructor") {
  4040. if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
  4041. hadConstructor = true;
  4042. } else if (element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
  4043. this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
  4044. }
  4045. }
  4046. }
  4047. this.strict = oldStrict;
  4048. this.next();
  4049. node.body = this.finishNode(classBody, "ClassBody");
  4050. this.exitClassBody();
  4051. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
  4052. };
  4053. pp$1.parseClassElement = function(constructorAllowsSuper) {
  4054. if (this.eat(types.semi)) { return null }
  4055. var ecmaVersion = this.options.ecmaVersion;
  4056. var node = this.startNode();
  4057. var keyName = "";
  4058. var isGenerator = false;
  4059. var isAsync = false;
  4060. var kind = "method";
  4061. // Parse modifiers
  4062. node.static = false;
  4063. if (this.eatContextual("static")) {
  4064. if (this.isClassElementNameStart() || this.type === types.star) {
  4065. node.static = true;
  4066. } else {
  4067. keyName = "static";
  4068. }
  4069. }
  4070. if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
  4071. if ((this.isClassElementNameStart() || this.type === types.star) && !this.canInsertSemicolon()) {
  4072. isAsync = true;
  4073. } else {
  4074. keyName = "async";
  4075. }
  4076. }
  4077. if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types.star)) {
  4078. isGenerator = true;
  4079. }
  4080. if (!keyName && !isAsync && !isGenerator) {
  4081. var lastValue = this.value;
  4082. if (this.eatContextual("get") || this.eatContextual("set")) {
  4083. if (this.isClassElementNameStart()) {
  4084. kind = lastValue;
  4085. } else {
  4086. keyName = lastValue;
  4087. }
  4088. }
  4089. }
  4090. // Parse element name
  4091. if (keyName) {
  4092. // 'async', 'get', 'set', or 'static' were not a keyword contextually.
  4093. // The last token is any of those. Make it the element name.
  4094. node.computed = false;
  4095. node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
  4096. node.key.name = keyName;
  4097. this.finishNode(node.key, "Identifier");
  4098. } else {
  4099. this.parseClassElementName(node);
  4100. }
  4101. // Parse element value
  4102. if (ecmaVersion < 13 || this.type === types.parenL || kind !== "method" || isGenerator || isAsync) {
  4103. var isConstructor = !node.static && checkKeyName(node, "constructor");
  4104. var allowsDirectSuper = isConstructor && constructorAllowsSuper;
  4105. // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
  4106. if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); }
  4107. node.kind = isConstructor ? "constructor" : kind;
  4108. this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
  4109. } else {
  4110. this.parseClassField(node);
  4111. }
  4112. return node
  4113. };
  4114. pp$1.isClassElementNameStart = function() {
  4115. return (
  4116. this.type === types.name ||
  4117. this.type === types.privateId ||
  4118. this.type === types.num ||
  4119. this.type === types.string ||
  4120. this.type === types.bracketL ||
  4121. this.type.keyword
  4122. )
  4123. };
  4124. pp$1.parseClassElementName = function(element) {
  4125. if (this.type === types.privateId) {
  4126. if (this.value === "constructor") {
  4127. this.raise(this.start, "Classes can't have an element named '#constructor'");
  4128. }
  4129. element.computed = false;
  4130. element.key = this.parsePrivateIdent();
  4131. } else {
  4132. this.parsePropertyName(element);
  4133. }
  4134. };
  4135. pp$1.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
  4136. // Check key and flags
  4137. var key = method.key;
  4138. if (method.kind === "constructor") {
  4139. if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
  4140. if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
  4141. } else if (method.static && checkKeyName(method, "prototype")) {
  4142. this.raise(key.start, "Classes may not have a static property named prototype");
  4143. }
  4144. // Parse value
  4145. var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
  4146. // Check value
  4147. if (method.kind === "get" && value.params.length !== 0)
  4148. { this.raiseRecoverable(value.start, "getter should have no params"); }
  4149. if (method.kind === "set" && value.params.length !== 1)
  4150. { this.raiseRecoverable(value.start, "setter should have exactly one param"); }
  4151. if (method.kind === "set" && value.params[0].type === "RestElement")
  4152. { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); }
  4153. return this.finishNode(method, "MethodDefinition")
  4154. };
  4155. pp$1.parseClassField = function(field) {
  4156. if (checkKeyName(field, "constructor")) {
  4157. this.raise(field.key.start, "Classes can't have a field named 'constructor'");
  4158. } else if (field.static && checkKeyName(field, "prototype")) {
  4159. this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
  4160. }
  4161. if (this.eat(types.eq)) {
  4162. // To raise SyntaxError if 'arguments' exists in the initializer.
  4163. var scope = this.currentThisScope();
  4164. var inClassFieldInit = scope.inClassFieldInit;
  4165. scope.inClassFieldInit = true;
  4166. field.value = this.parseMaybeAssign();
  4167. scope.inClassFieldInit = inClassFieldInit;
  4168. } else {
  4169. field.value = null;
  4170. }
  4171. this.semicolon();
  4172. return this.finishNode(field, "PropertyDefinition")
  4173. };
  4174. pp$1.parseClassId = function(node, isStatement) {
  4175. if (this.type === types.name) {
  4176. node.id = this.parseIdent();
  4177. if (isStatement)
  4178. { this.checkLValSimple(node.id, BIND_LEXICAL, false); }
  4179. } else {
  4180. if (isStatement === true)
  4181. { this.unexpected(); }
  4182. node.id = null;
  4183. }
  4184. };
  4185. pp$1.parseClassSuper = function(node) {
  4186. node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
  4187. };
  4188. pp$1.enterClassBody = function() {
  4189. var element = {declared: Object.create(null), used: []};
  4190. this.privateNameStack.push(element);
  4191. return element.declared
  4192. };
  4193. pp$1.exitClassBody = function() {
  4194. var ref = this.privateNameStack.pop();
  4195. var declared = ref.declared;
  4196. var used = ref.used;
  4197. var len = this.privateNameStack.length;
  4198. var parent = len === 0 ? null : this.privateNameStack[len - 1];
  4199. for (var i = 0; i < used.length; ++i) {
  4200. var id = used[i];
  4201. if (!has(declared, id.name)) {
  4202. if (parent) {
  4203. parent.used.push(id);
  4204. } else {
  4205. this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class"));
  4206. }
  4207. }
  4208. }
  4209. };
  4210. function isPrivateNameConflicted(privateNameMap, element) {
  4211. var name = element.key.name;
  4212. var curr = privateNameMap[name];
  4213. var next = "true";
  4214. if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
  4215. next = (element.static ? "s" : "i") + element.kind;
  4216. }
  4217. // `class { get #a(){}; static set #a(_){} }` is also conflict.
  4218. if (
  4219. curr === "iget" && next === "iset" ||
  4220. curr === "iset" && next === "iget" ||
  4221. curr === "sget" && next === "sset" ||
  4222. curr === "sset" && next === "sget"
  4223. ) {
  4224. privateNameMap[name] = "true";
  4225. return false
  4226. } else if (!curr) {
  4227. privateNameMap[name] = next;
  4228. return false
  4229. } else {
  4230. return true
  4231. }
  4232. }
  4233. function checkKeyName(node, name) {
  4234. var computed = node.computed;
  4235. var key = node.key;
  4236. return !computed && (
  4237. key.type === "Identifier" && key.name === name ||
  4238. key.type === "Literal" && key.value === name
  4239. )
  4240. }
  4241. // Parses module export declaration.
  4242. pp$1.parseExport = function(node, exports) {
  4243. this.next();
  4244. // export * from '...'
  4245. if (this.eat(types.star)) {
  4246. if (this.options.ecmaVersion >= 11) {
  4247. if (this.eatContextual("as")) {
  4248. node.exported = this.parseIdent(true);
  4249. this.checkExport(exports, node.exported.name, this.lastTokStart);
  4250. } else {
  4251. node.exported = null;
  4252. }
  4253. }
  4254. this.expectContextual("from");
  4255. if (this.type !== types.string) { this.unexpected(); }
  4256. node.source = this.parseExprAtom();
  4257. this.semicolon();
  4258. return this.finishNode(node, "ExportAllDeclaration")
  4259. }
  4260. if (this.eat(types._default)) { // export default ...
  4261. this.checkExport(exports, "default", this.lastTokStart);
  4262. var isAsync;
  4263. if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
  4264. var fNode = this.startNode();
  4265. this.next();
  4266. if (isAsync) { this.next(); }
  4267. node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
  4268. } else if (this.type === types._class) {
  4269. var cNode = this.startNode();
  4270. node.declaration = this.parseClass(cNode, "nullableID");
  4271. } else {
  4272. node.declaration = this.parseMaybeAssign();
  4273. this.semicolon();
  4274. }
  4275. return this.finishNode(node, "ExportDefaultDeclaration")
  4276. }
  4277. // export var|const|let|function|class ...
  4278. if (this.shouldParseExportStatement()) {
  4279. node.declaration = this.parseStatement(null);
  4280. if (node.declaration.type === "VariableDeclaration")
  4281. { this.checkVariableExport(exports, node.declaration.declarations); }
  4282. else
  4283. { this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
  4284. node.specifiers = [];
  4285. node.source = null;
  4286. } else { // export { x, y as z } [from '...']
  4287. node.declaration = null;
  4288. node.specifiers = this.parseExportSpecifiers(exports);
  4289. if (this.eatContextual("from")) {
  4290. if (this.type !== types.string) { this.unexpected(); }
  4291. node.source = this.parseExprAtom();
  4292. } else {
  4293. for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
  4294. // check for keywords used as local names
  4295. var spec = list[i];
  4296. this.checkUnreserved(spec.local);
  4297. // check if export is defined
  4298. this.checkLocalExport(spec.local);
  4299. }
  4300. node.source = null;
  4301. }
  4302. this.semicolon();
  4303. }
  4304. return this.finishNode(node, "ExportNamedDeclaration")
  4305. };
  4306. pp$1.checkExport = function(exports, name, pos) {
  4307. if (!exports) { return }
  4308. if (has(exports, name))
  4309. { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
  4310. exports[name] = true;
  4311. };
  4312. pp$1.checkPatternExport = function(exports, pat) {
  4313. var type = pat.type;
  4314. if (type === "Identifier")
  4315. { this.checkExport(exports, pat.name, pat.start); }
  4316. else if (type === "ObjectPattern")
  4317. { for (var i = 0, list = pat.properties; i < list.length; i += 1)
  4318. {
  4319. var prop = list[i];
  4320. this.checkPatternExport(exports, prop);
  4321. } }
  4322. else if (type === "ArrayPattern")
  4323. { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
  4324. var elt = list$1[i$1];
  4325. if (elt) { this.checkPatternExport(exports, elt); }
  4326. } }
  4327. else if (type === "Property")
  4328. { this.checkPatternExport(exports, pat.value); }
  4329. else if (type === "AssignmentPattern")
  4330. { this.checkPatternExport(exports, pat.left); }
  4331. else if (type === "RestElement")
  4332. { this.checkPatternExport(exports, pat.argument); }
  4333. else if (type === "ParenthesizedExpression")
  4334. { this.checkPatternExport(exports, pat.expression); }
  4335. };
  4336. pp$1.checkVariableExport = function(exports, decls) {
  4337. if (!exports) { return }
  4338. for (var i = 0, list = decls; i < list.length; i += 1)
  4339. {
  4340. var decl = list[i];
  4341. this.checkPatternExport(exports, decl.id);
  4342. }
  4343. };
  4344. pp$1.shouldParseExportStatement = function() {
  4345. return this.type.keyword === "var" ||
  4346. this.type.keyword === "const" ||
  4347. this.type.keyword === "class" ||
  4348. this.type.keyword === "function" ||
  4349. this.isLet() ||
  4350. this.isAsyncFunction()
  4351. };
  4352. // Parses a comma-separated list of module exports.
  4353. pp$1.parseExportSpecifiers = function(exports) {
  4354. var nodes = [], first = true;
  4355. // export { x, y as z } [from '...']
  4356. this.expect(types.braceL);
  4357. while (!this.eat(types.braceR)) {
  4358. if (!first) {
  4359. this.expect(types.comma);
  4360. if (this.afterTrailingComma(types.braceR)) { break }
  4361. } else { first = false; }
  4362. var node = this.startNode();
  4363. node.local = this.parseIdent(true);
  4364. node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
  4365. this.checkExport(exports, node.exported.name, node.exported.start);
  4366. nodes.push(this.finishNode(node, "ExportSpecifier"));
  4367. }
  4368. return nodes
  4369. };
  4370. // Parses import declaration.
  4371. pp$1.parseImport = function(node) {
  4372. this.next();
  4373. // import '...'
  4374. if (this.type === types.string) {
  4375. node.specifiers = empty;
  4376. node.source = this.parseExprAtom();
  4377. } else {
  4378. node.specifiers = this.parseImportSpecifiers();
  4379. this.expectContextual("from");
  4380. node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
  4381. }
  4382. this.semicolon();
  4383. return this.finishNode(node, "ImportDeclaration")
  4384. };
  4385. // Parses a comma-separated list of module imports.
  4386. pp$1.parseImportSpecifiers = function() {
  4387. var nodes = [], first = true;
  4388. if (this.type === types.name) {
  4389. // import defaultObj, { x, y as z } from '...'
  4390. var node = this.startNode();
  4391. node.local = this.parseIdent();
  4392. this.checkLValSimple(node.local, BIND_LEXICAL);
  4393. nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
  4394. if (!this.eat(types.comma)) { return nodes }
  4395. }
  4396. if (this.type === types.star) {
  4397. var node$1 = this.startNode();
  4398. this.next();
  4399. this.expectContextual("as");
  4400. node$1.local = this.parseIdent();
  4401. this.checkLValSimple(node$1.local, BIND_LEXICAL);
  4402. nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
  4403. return nodes
  4404. }
  4405. this.expect(types.braceL);
  4406. while (!this.eat(types.braceR)) {
  4407. if (!first) {
  4408. this.expect(types.comma);
  4409. if (this.afterTrailingComma(types.braceR)) { break }
  4410. } else { first = false; }
  4411. var node$2 = this.startNode();
  4412. node$2.imported = this.parseIdent(true);
  4413. if (this.eatContextual("as")) {
  4414. node$2.local = this.parseIdent();
  4415. } else {
  4416. this.checkUnreserved(node$2.imported);
  4417. node$2.local = node$2.imported;
  4418. }
  4419. this.checkLValSimple(node$2.local, BIND_LEXICAL);
  4420. nodes.push(this.finishNode(node$2, "ImportSpecifier"));
  4421. }
  4422. return nodes
  4423. };
  4424. // Set `ExpressionStatement#directive` property for directive prologues.
  4425. pp$1.adaptDirectivePrologue = function(statements) {
  4426. for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
  4427. statements[i].directive = statements[i].expression.raw.slice(1, -1);
  4428. }
  4429. };
  4430. pp$1.isDirectiveCandidate = function(statement) {
  4431. return (
  4432. statement.type === "ExpressionStatement" &&
  4433. statement.expression.type === "Literal" &&
  4434. typeof statement.expression.value === "string" &&
  4435. // Reject parenthesized strings.
  4436. (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
  4437. )
  4438. };
  4439. var pp$2 = Parser.prototype;
  4440. // Convert existing expression atom to assignable pattern
  4441. // if possible.
  4442. pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) {
  4443. if (this.options.ecmaVersion >= 6 && node) {
  4444. switch (node.type) {
  4445. case "Identifier":
  4446. if (this.inAsync && node.name === "await")
  4447. { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); }
  4448. break
  4449. case "ObjectPattern":
  4450. case "ArrayPattern":
  4451. case "AssignmentPattern":
  4452. case "RestElement":
  4453. break
  4454. case "ObjectExpression":
  4455. node.type = "ObjectPattern";
  4456. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  4457. for (var i = 0, list = node.properties; i < list.length; i += 1) {
  4458. var prop = list[i];
  4459. this.toAssignable(prop, isBinding);
  4460. // Early error:
  4461. // AssignmentRestProperty[Yield, Await] :
  4462. // `...` DestructuringAssignmentTarget[Yield, Await]
  4463. //
  4464. // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
  4465. if (
  4466. prop.type === "RestElement" &&
  4467. (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
  4468. ) {
  4469. this.raise(prop.argument.start, "Unexpected token");
  4470. }
  4471. }
  4472. break
  4473. case "Property":
  4474. // AssignmentProperty has type === "Property"
  4475. if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
  4476. this.toAssignable(node.value, isBinding);
  4477. break
  4478. case "ArrayExpression":
  4479. node.type = "ArrayPattern";
  4480. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  4481. this.toAssignableList(node.elements, isBinding);
  4482. break
  4483. case "SpreadElement":
  4484. node.type = "RestElement";
  4485. this.toAssignable(node.argument, isBinding);
  4486. if (node.argument.type === "AssignmentPattern")
  4487. { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
  4488. break
  4489. case "AssignmentExpression":
  4490. if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
  4491. node.type = "AssignmentPattern";
  4492. delete node.operator;
  4493. this.toAssignable(node.left, isBinding);
  4494. break
  4495. case "ParenthesizedExpression":
  4496. this.toAssignable(node.expression, isBinding, refDestructuringErrors);
  4497. break
  4498. case "ChainExpression":
  4499. this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
  4500. break
  4501. case "MemberExpression":
  4502. if (!isBinding) { break }
  4503. default:
  4504. this.raise(node.start, "Assigning to rvalue");
  4505. }
  4506. } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  4507. return node
  4508. };
  4509. // Convert list of expression atoms to binding list.
  4510. pp$2.toAssignableList = function(exprList, isBinding) {
  4511. var end = exprList.length;
  4512. for (var i = 0; i < end; i++) {
  4513. var elt = exprList[i];
  4514. if (elt) { this.toAssignable(elt, isBinding); }
  4515. }
  4516. if (end) {
  4517. var last = exprList[end - 1];
  4518. if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
  4519. { this.unexpected(last.argument.start); }
  4520. }
  4521. return exprList
  4522. };
  4523. // Parses spread element.
  4524. pp$2.parseSpread = function(refDestructuringErrors) {
  4525. var node = this.startNode();
  4526. this.next();
  4527. node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  4528. return this.finishNode(node, "SpreadElement")
  4529. };
  4530. pp$2.parseRestBinding = function() {
  4531. var node = this.startNode();
  4532. this.next();
  4533. // RestElement inside of a function parameter must be an identifier
  4534. if (this.options.ecmaVersion === 6 && this.type !== types.name)
  4535. { this.unexpected(); }
  4536. node.argument = this.parseBindingAtom();
  4537. return this.finishNode(node, "RestElement")
  4538. };
  4539. // Parses lvalue (assignable) atom.
  4540. pp$2.parseBindingAtom = function() {
  4541. if (this.options.ecmaVersion >= 6) {
  4542. switch (this.type) {
  4543. case types.bracketL:
  4544. var node = this.startNode();
  4545. this.next();
  4546. node.elements = this.parseBindingList(types.bracketR, true, true);
  4547. return this.finishNode(node, "ArrayPattern")
  4548. case types.braceL:
  4549. return this.parseObj(true)
  4550. }
  4551. }
  4552. return this.parseIdent()
  4553. };
  4554. pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
  4555. var elts = [], first = true;
  4556. while (!this.eat(close)) {
  4557. if (first) { first = false; }
  4558. else { this.expect(types.comma); }
  4559. if (allowEmpty && this.type === types.comma) {
  4560. elts.push(null);
  4561. } else if (allowTrailingComma && this.afterTrailingComma(close)) {
  4562. break
  4563. } else if (this.type === types.ellipsis) {
  4564. var rest = this.parseRestBinding();
  4565. this.parseBindingListItem(rest);
  4566. elts.push(rest);
  4567. if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
  4568. this.expect(close);
  4569. break
  4570. } else {
  4571. var elem = this.parseMaybeDefault(this.start, this.startLoc);
  4572. this.parseBindingListItem(elem);
  4573. elts.push(elem);
  4574. }
  4575. }
  4576. return elts
  4577. };
  4578. pp$2.parseBindingListItem = function(param) {
  4579. return param
  4580. };
  4581. // Parses assignment pattern around given atom if possible.
  4582. pp$2.parseMaybeDefault = function(startPos, startLoc, left) {
  4583. left = left || this.parseBindingAtom();
  4584. if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) { return left }
  4585. var node = this.startNodeAt(startPos, startLoc);
  4586. node.left = left;
  4587. node.right = this.parseMaybeAssign();
  4588. return this.finishNode(node, "AssignmentPattern")
  4589. };
  4590. // The following three functions all verify that a node is an lvalue —
  4591. // something that can be bound, or assigned to. In order to do so, they perform
  4592. // a variety of checks:
  4593. //
  4594. // - Check that none of the bound/assigned-to identifiers are reserved words.
  4595. // - Record name declarations for bindings in the appropriate scope.
  4596. // - Check duplicate argument names, if checkClashes is set.
  4597. //
  4598. // If a complex binding pattern is encountered (e.g., object and array
  4599. // destructuring), the entire pattern is recursively checked.
  4600. //
  4601. // There are three versions of checkLVal*() appropriate for different
  4602. // circumstances:
  4603. //
  4604. // - checkLValSimple() shall be used if the syntactic construct supports
  4605. // nothing other than identifiers and member expressions. Parenthesized
  4606. // expressions are also correctly handled. This is generally appropriate for
  4607. // constructs for which the spec says
  4608. //
  4609. // > It is a Syntax Error if AssignmentTargetType of [the production] is not
  4610. // > simple.
  4611. //
  4612. // It is also appropriate for checking if an identifier is valid and not
  4613. // defined elsewhere, like import declarations or function/class identifiers.
  4614. //
  4615. // Examples where this is used include:
  4616. // a += …;
  4617. // import a from '…';
  4618. // where a is the node to be checked.
  4619. //
  4620. // - checkLValPattern() shall be used if the syntactic construct supports
  4621. // anything checkLValSimple() supports, as well as object and array
  4622. // destructuring patterns. This is generally appropriate for constructs for
  4623. // which the spec says
  4624. //
  4625. // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor
  4626. // > an ArrayLiteral and AssignmentTargetType of [the production] is not
  4627. // > simple.
  4628. //
  4629. // Examples where this is used include:
  4630. // (a = …);
  4631. // const a = …;
  4632. // try { … } catch (a) { … }
  4633. // where a is the node to be checked.
  4634. //
  4635. // - checkLValInnerPattern() shall be used if the syntactic construct supports
  4636. // anything checkLValPattern() supports, as well as default assignment
  4637. // patterns, rest elements, and other constructs that may appear within an
  4638. // object or array destructuring pattern.
  4639. //
  4640. // As a special case, function parameters also use checkLValInnerPattern(),
  4641. // as they also support defaults and rest constructs.
  4642. //
  4643. // These functions deliberately support both assignment and binding constructs,
  4644. // as the logic for both is exceedingly similar. If the node is the target of
  4645. // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it
  4646. // should be set to the appropriate BIND_* constant, like BIND_VAR or
  4647. // BIND_LEXICAL.
  4648. //
  4649. // If the function is called with a non-BIND_NONE bindingType, then
  4650. // additionally a checkClashes object may be specified to allow checking for
  4651. // duplicate argument names. checkClashes is ignored if the provided construct
  4652. // is an assignment (i.e., bindingType is BIND_NONE).
  4653. pp$2.checkLValSimple = function(expr, bindingType, checkClashes) {
  4654. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  4655. var isBind = bindingType !== BIND_NONE;
  4656. switch (expr.type) {
  4657. case "Identifier":
  4658. if (this.strict && this.reservedWordsStrictBind.test(expr.name))
  4659. { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
  4660. if (isBind) {
  4661. if (bindingType === BIND_LEXICAL && expr.name === "let")
  4662. { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); }
  4663. if (checkClashes) {
  4664. if (has(checkClashes, expr.name))
  4665. { this.raiseRecoverable(expr.start, "Argument name clash"); }
  4666. checkClashes[expr.name] = true;
  4667. }
  4668. if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
  4669. }
  4670. break
  4671. case "ChainExpression":
  4672. this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
  4673. break
  4674. case "MemberExpression":
  4675. if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); }
  4676. break
  4677. case "ParenthesizedExpression":
  4678. if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); }
  4679. return this.checkLValSimple(expr.expression, bindingType, checkClashes)
  4680. default:
  4681. this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
  4682. }
  4683. };
  4684. pp$2.checkLValPattern = function(expr, bindingType, checkClashes) {
  4685. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  4686. switch (expr.type) {
  4687. case "ObjectPattern":
  4688. for (var i = 0, list = expr.properties; i < list.length; i += 1) {
  4689. var prop = list[i];
  4690. this.checkLValInnerPattern(prop, bindingType, checkClashes);
  4691. }
  4692. break
  4693. case "ArrayPattern":
  4694. for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
  4695. var elem = list$1[i$1];
  4696. if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); }
  4697. }
  4698. break
  4699. default:
  4700. this.checkLValSimple(expr, bindingType, checkClashes);
  4701. }
  4702. };
  4703. pp$2.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
  4704. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  4705. switch (expr.type) {
  4706. case "Property":
  4707. // AssignmentProperty has type === "Property"
  4708. this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
  4709. break
  4710. case "AssignmentPattern":
  4711. this.checkLValPattern(expr.left, bindingType, checkClashes);
  4712. break
  4713. case "RestElement":
  4714. this.checkLValPattern(expr.argument, bindingType, checkClashes);
  4715. break
  4716. default:
  4717. this.checkLValPattern(expr, bindingType, checkClashes);
  4718. }
  4719. };
  4720. // A recursive descent parser operates by defining functions for all
  4721. var pp$3 = Parser.prototype;
  4722. // Check if property name clashes with already added.
  4723. // Object/class getters and setters are not allowed to clash —
  4724. // either with each other or with an init property — and in
  4725. // strict mode, init properties are also not allowed to be repeated.
  4726. pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) {
  4727. if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
  4728. { return }
  4729. if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
  4730. { return }
  4731. var key = prop.key;
  4732. var name;
  4733. switch (key.type) {
  4734. case "Identifier": name = key.name; break
  4735. case "Literal": name = String(key.value); break
  4736. default: return
  4737. }
  4738. var kind = prop.kind;
  4739. if (this.options.ecmaVersion >= 6) {
  4740. if (name === "__proto__" && kind === "init") {
  4741. if (propHash.proto) {
  4742. if (refDestructuringErrors) {
  4743. if (refDestructuringErrors.doubleProto < 0)
  4744. { refDestructuringErrors.doubleProto = key.start; }
  4745. // Backwards-compat kludge. Can be removed in version 6.0
  4746. } else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); }
  4747. }
  4748. propHash.proto = true;
  4749. }
  4750. return
  4751. }
  4752. name = "$" + name;
  4753. var other = propHash[name];
  4754. if (other) {
  4755. var redefinition;
  4756. if (kind === "init") {
  4757. redefinition = this.strict && other.init || other.get || other.set;
  4758. } else {
  4759. redefinition = other.init || other[kind];
  4760. }
  4761. if (redefinition)
  4762. { this.raiseRecoverable(key.start, "Redefinition of property"); }
  4763. } else {
  4764. other = propHash[name] = {
  4765. init: false,
  4766. get: false,
  4767. set: false
  4768. };
  4769. }
  4770. other[kind] = true;
  4771. };
  4772. // ### Expression parsing
  4773. // These nest, from the most general expression type at the top to
  4774. // 'atomic', nondivisible expression types at the bottom. Most of
  4775. // the functions will simply let the function(s) below them parse,
  4776. // and, *if* the syntactic construct they handle is present, wrap
  4777. // the AST node that the inner parser gave them in another node.
  4778. // Parse a full expression. The optional arguments are used to
  4779. // forbid the `in` operator (in for loops initalization expressions)
  4780. // and provide reference for storing '=' operator inside shorthand
  4781. // property assignment in contexts where both object expression
  4782. // and object pattern might appear (so it's possible to raise
  4783. // delayed syntax error at correct position).
  4784. pp$3.parseExpression = function(forInit, refDestructuringErrors) {
  4785. var startPos = this.start, startLoc = this.startLoc;
  4786. var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
  4787. if (this.type === types.comma) {
  4788. var node = this.startNodeAt(startPos, startLoc);
  4789. node.expressions = [expr];
  4790. while (this.eat(types.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
  4791. return this.finishNode(node, "SequenceExpression")
  4792. }
  4793. return expr
  4794. };
  4795. // Parse an assignment expression. This includes applications of
  4796. // operators like `+=`.
  4797. pp$3.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
  4798. if (this.isContextual("yield")) {
  4799. if (this.inGenerator) { return this.parseYield(forInit) }
  4800. // The tokenizer will assume an expression is allowed after
  4801. // `yield`, but this isn't that kind of yield
  4802. else { this.exprAllowed = false; }
  4803. }
  4804. var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1;
  4805. if (refDestructuringErrors) {
  4806. oldParenAssign = refDestructuringErrors.parenthesizedAssign;
  4807. oldTrailingComma = refDestructuringErrors.trailingComma;
  4808. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
  4809. } else {
  4810. refDestructuringErrors = new DestructuringErrors;
  4811. ownDestructuringErrors = true;
  4812. }
  4813. var startPos = this.start, startLoc = this.startLoc;
  4814. if (this.type === types.parenL || this.type === types.name) {
  4815. this.potentialArrowAt = this.start;
  4816. this.potentialArrowInForAwait = forInit === "await";
  4817. }
  4818. var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
  4819. if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
  4820. if (this.type.isAssign) {
  4821. var node = this.startNodeAt(startPos, startLoc);
  4822. node.operator = this.value;
  4823. if (this.type === types.eq)
  4824. { left = this.toAssignable(left, false, refDestructuringErrors); }
  4825. if (!ownDestructuringErrors) {
  4826. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
  4827. }
  4828. if (refDestructuringErrors.shorthandAssign >= left.start)
  4829. { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
  4830. if (this.type === types.eq)
  4831. { this.checkLValPattern(left); }
  4832. else
  4833. { this.checkLValSimple(left); }
  4834. node.left = left;
  4835. this.next();
  4836. node.right = this.parseMaybeAssign(forInit);
  4837. return this.finishNode(node, "AssignmentExpression")
  4838. } else {
  4839. if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
  4840. }
  4841. if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
  4842. if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
  4843. return left
  4844. };
  4845. // Parse a ternary conditional (`?:`) operator.
  4846. pp$3.parseMaybeConditional = function(forInit, refDestructuringErrors) {
  4847. var startPos = this.start, startLoc = this.startLoc;
  4848. var expr = this.parseExprOps(forInit, refDestructuringErrors);
  4849. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  4850. if (this.eat(types.question)) {
  4851. var node = this.startNodeAt(startPos, startLoc);
  4852. node.test = expr;
  4853. node.consequent = this.parseMaybeAssign();
  4854. this.expect(types.colon);
  4855. node.alternate = this.parseMaybeAssign(forInit);
  4856. return this.finishNode(node, "ConditionalExpression")
  4857. }
  4858. return expr
  4859. };
  4860. // Start the precedence parser.
  4861. pp$3.parseExprOps = function(forInit, refDestructuringErrors) {
  4862. var startPos = this.start, startLoc = this.startLoc;
  4863. var expr = this.parseMaybeUnary(refDestructuringErrors, false);
  4864. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  4865. return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
  4866. };
  4867. // Parse binary operators with the operator precedence parsing
  4868. // algorithm. `left` is the left-hand side of the operator.
  4869. // `minPrec` provides context that allows the function to stop and
  4870. // defer further parser to one of its callers when it encounters an
  4871. // operator that has a lower precedence than the set it is parsing.
  4872. pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
  4873. var prec = this.type.binop;
  4874. if (prec != null && (!forInit || this.type !== types._in)) {
  4875. if (prec > minPrec) {
  4876. var logical = this.type === types.logicalOR || this.type === types.logicalAND;
  4877. var coalesce = this.type === types.coalesce;
  4878. if (coalesce) {
  4879. // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
  4880. // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
  4881. prec = types.logicalAND.binop;
  4882. }
  4883. var op = this.value;
  4884. this.next();
  4885. var startPos = this.start, startLoc = this.startLoc;
  4886. var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, forInit);
  4887. var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
  4888. if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) {
  4889. this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
  4890. }
  4891. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
  4892. }
  4893. }
  4894. return left
  4895. };
  4896. pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {
  4897. var node = this.startNodeAt(startPos, startLoc);
  4898. node.left = left;
  4899. node.operator = op;
  4900. node.right = right;
  4901. return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
  4902. };
  4903. // Parse unary operators, both prefix and postfix.
  4904. pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec) {
  4905. var startPos = this.start, startLoc = this.startLoc, expr;
  4906. if (this.isContextual("await") && this.canAwait) {
  4907. expr = this.parseAwait();
  4908. sawUnary = true;
  4909. } else if (this.type.prefix) {
  4910. var node = this.startNode(), update = this.type === types.incDec;
  4911. node.operator = this.value;
  4912. node.prefix = true;
  4913. this.next();
  4914. node.argument = this.parseMaybeUnary(null, true, update);
  4915. this.checkExpressionErrors(refDestructuringErrors, true);
  4916. if (update) { this.checkLValSimple(node.argument); }
  4917. else if (this.strict && node.operator === "delete" &&
  4918. node.argument.type === "Identifier")
  4919. { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
  4920. else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
  4921. { this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
  4922. else { sawUnary = true; }
  4923. expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
  4924. } else {
  4925. expr = this.parseExprSubscripts(refDestructuringErrors);
  4926. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  4927. while (this.type.postfix && !this.canInsertSemicolon()) {
  4928. var node$1 = this.startNodeAt(startPos, startLoc);
  4929. node$1.operator = this.value;
  4930. node$1.prefix = false;
  4931. node$1.argument = expr;
  4932. this.checkLValSimple(expr);
  4933. this.next();
  4934. expr = this.finishNode(node$1, "UpdateExpression");
  4935. }
  4936. }
  4937. if (!incDec && this.eat(types.starstar)) {
  4938. if (sawUnary)
  4939. { this.unexpected(this.lastTokStart); }
  4940. else
  4941. { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) }
  4942. } else {
  4943. return expr
  4944. }
  4945. };
  4946. function isPrivateFieldAccess(node) {
  4947. return (
  4948. node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
  4949. node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
  4950. )
  4951. }
  4952. // Parse call, dot, and `[]`-subscript expressions.
  4953. pp$3.parseExprSubscripts = function(refDestructuringErrors) {
  4954. var startPos = this.start, startLoc = this.startLoc;
  4955. var expr = this.parseExprAtom(refDestructuringErrors);
  4956. if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
  4957. { return expr }
  4958. var result = this.parseSubscripts(expr, startPos, startLoc);
  4959. if (refDestructuringErrors && result.type === "MemberExpression") {
  4960. if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
  4961. if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
  4962. if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }
  4963. }
  4964. return result
  4965. };
  4966. pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
  4967. var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
  4968. this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
  4969. this.potentialArrowAt === base.start;
  4970. var optionalChained = false;
  4971. while (true) {
  4972. var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained);
  4973. if (element.optional) { optionalChained = true; }
  4974. if (element === base || element.type === "ArrowFunctionExpression") {
  4975. if (optionalChained) {
  4976. var chainNode = this.startNodeAt(startPos, startLoc);
  4977. chainNode.expression = element;
  4978. element = this.finishNode(chainNode, "ChainExpression");
  4979. }
  4980. return element
  4981. }
  4982. base = element;
  4983. }
  4984. };
  4985. pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained) {
  4986. var optionalSupported = this.options.ecmaVersion >= 11;
  4987. var optional = optionalSupported && this.eat(types.questionDot);
  4988. if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
  4989. var computed = this.eat(types.bracketL);
  4990. if (computed || (optional && this.type !== types.parenL && this.type !== types.backQuote) || this.eat(types.dot)) {
  4991. var node = this.startNodeAt(startPos, startLoc);
  4992. node.object = base;
  4993. if (computed) {
  4994. node.property = this.parseExpression();
  4995. this.expect(types.bracketR);
  4996. } else if (this.type === types.privateId && base.type !== "Super") {
  4997. node.property = this.parsePrivateIdent();
  4998. } else {
  4999. node.property = this.parseIdent(this.options.allowReserved !== "never");
  5000. }
  5001. node.computed = !!computed;
  5002. if (optionalSupported) {
  5003. node.optional = optional;
  5004. }
  5005. base = this.finishNode(node, "MemberExpression");
  5006. } else if (!noCalls && this.eat(types.parenL)) {
  5007. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  5008. this.yieldPos = 0;
  5009. this.awaitPos = 0;
  5010. this.awaitIdentPos = 0;
  5011. var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
  5012. if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types.arrow)) {
  5013. this.checkPatternErrors(refDestructuringErrors, false);
  5014. this.checkYieldAwaitInDefaultParams();
  5015. if (this.awaitIdentPos > 0)
  5016. { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); }
  5017. this.yieldPos = oldYieldPos;
  5018. this.awaitPos = oldAwaitPos;
  5019. this.awaitIdentPos = oldAwaitIdentPos;
  5020. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true)
  5021. }
  5022. this.checkExpressionErrors(refDestructuringErrors, true);
  5023. this.yieldPos = oldYieldPos || this.yieldPos;
  5024. this.awaitPos = oldAwaitPos || this.awaitPos;
  5025. this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
  5026. var node$1 = this.startNodeAt(startPos, startLoc);
  5027. node$1.callee = base;
  5028. node$1.arguments = exprList;
  5029. if (optionalSupported) {
  5030. node$1.optional = optional;
  5031. }
  5032. base = this.finishNode(node$1, "CallExpression");
  5033. } else if (this.type === types.backQuote) {
  5034. if (optional || optionalChained) {
  5035. this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
  5036. }
  5037. var node$2 = this.startNodeAt(startPos, startLoc);
  5038. node$2.tag = base;
  5039. node$2.quasi = this.parseTemplate({isTagged: true});
  5040. base = this.finishNode(node$2, "TaggedTemplateExpression");
  5041. }
  5042. return base
  5043. };
  5044. // Parse an atomic expression — either a single token that is an
  5045. // expression, an expression started by a keyword like `function` or
  5046. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  5047. // or `{}`.
  5048. pp$3.parseExprAtom = function(refDestructuringErrors) {
  5049. // If a division operator appears in an expression position, the
  5050. // tokenizer got confused, and we force it to read a regexp instead.
  5051. if (this.type === types.slash) { this.readRegexp(); }
  5052. var node, canBeArrow = this.potentialArrowAt === this.start;
  5053. switch (this.type) {
  5054. case types._super:
  5055. if (!this.allowSuper)
  5056. { this.raise(this.start, "'super' keyword outside a method"); }
  5057. node = this.startNode();
  5058. this.next();
  5059. if (this.type === types.parenL && !this.allowDirectSuper)
  5060. { this.raise(node.start, "super() call outside constructor of a subclass"); }
  5061. // The `super` keyword can appear at below:
  5062. // SuperProperty:
  5063. // super [ Expression ]
  5064. // super . IdentifierName
  5065. // SuperCall:
  5066. // super ( Arguments )
  5067. if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
  5068. { this.unexpected(); }
  5069. return this.finishNode(node, "Super")
  5070. case types._this:
  5071. node = this.startNode();
  5072. this.next();
  5073. return this.finishNode(node, "ThisExpression")
  5074. case types.name:
  5075. var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
  5076. var id = this.parseIdent(false);
  5077. if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function))
  5078. { return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true) }
  5079. if (canBeArrow && !this.canInsertSemicolon()) {
  5080. if (this.eat(types.arrow))
  5081. { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) }
  5082. if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc &&
  5083. (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
  5084. id = this.parseIdent(false);
  5085. if (this.canInsertSemicolon() || !this.eat(types.arrow))
  5086. { this.unexpected(); }
  5087. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true)
  5088. }
  5089. }
  5090. return id
  5091. case types.regexp:
  5092. var value = this.value;
  5093. node = this.parseLiteral(value.value);
  5094. node.regex = {pattern: value.pattern, flags: value.flags};
  5095. return node
  5096. case types.num: case types.string:
  5097. return this.parseLiteral(this.value)
  5098. case types._null: case types._true: case types._false:
  5099. node = this.startNode();
  5100. node.value = this.type === types._null ? null : this.type === types._true;
  5101. node.raw = this.type.keyword;
  5102. this.next();
  5103. return this.finishNode(node, "Literal")
  5104. case types.parenL:
  5105. var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow);
  5106. if (refDestructuringErrors) {
  5107. if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
  5108. { refDestructuringErrors.parenthesizedAssign = start; }
  5109. if (refDestructuringErrors.parenthesizedBind < 0)
  5110. { refDestructuringErrors.parenthesizedBind = start; }
  5111. }
  5112. return expr
  5113. case types.bracketL:
  5114. node = this.startNode();
  5115. this.next();
  5116. node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
  5117. return this.finishNode(node, "ArrayExpression")
  5118. case types.braceL:
  5119. return this.parseObj(false, refDestructuringErrors)
  5120. case types._function:
  5121. node = this.startNode();
  5122. this.next();
  5123. return this.parseFunction(node, 0)
  5124. case types._class:
  5125. return this.parseClass(this.startNode(), false)
  5126. case types._new:
  5127. return this.parseNew()
  5128. case types.backQuote:
  5129. return this.parseTemplate()
  5130. case types._import:
  5131. if (this.options.ecmaVersion >= 11) {
  5132. return this.parseExprImport()
  5133. } else {
  5134. return this.unexpected()
  5135. }
  5136. default:
  5137. this.unexpected();
  5138. }
  5139. };
  5140. pp$3.parseExprImport = function() {
  5141. var node = this.startNode();
  5142. // Consume `import` as an identifier for `import.meta`.
  5143. // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
  5144. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
  5145. var meta = this.parseIdent(true);
  5146. switch (this.type) {
  5147. case types.parenL:
  5148. return this.parseDynamicImport(node)
  5149. case types.dot:
  5150. node.meta = meta;
  5151. return this.parseImportMeta(node)
  5152. default:
  5153. this.unexpected();
  5154. }
  5155. };
  5156. pp$3.parseDynamicImport = function(node) {
  5157. this.next(); // skip `(`
  5158. // Parse node.source.
  5159. node.source = this.parseMaybeAssign();
  5160. // Verify ending.
  5161. if (!this.eat(types.parenR)) {
  5162. var errorPos = this.start;
  5163. if (this.eat(types.comma) && this.eat(types.parenR)) {
  5164. this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
  5165. } else {
  5166. this.unexpected(errorPos);
  5167. }
  5168. }
  5169. return this.finishNode(node, "ImportExpression")
  5170. };
  5171. pp$3.parseImportMeta = function(node) {
  5172. this.next(); // skip `.`
  5173. var containsEsc = this.containsEsc;
  5174. node.property = this.parseIdent(true);
  5175. if (node.property.name !== "meta")
  5176. { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
  5177. if (containsEsc)
  5178. { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
  5179. if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere)
  5180. { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
  5181. return this.finishNode(node, "MetaProperty")
  5182. };
  5183. pp$3.parseLiteral = function(value) {
  5184. var node = this.startNode();
  5185. node.value = value;
  5186. node.raw = this.input.slice(this.start, this.end);
  5187. if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
  5188. this.next();
  5189. return this.finishNode(node, "Literal")
  5190. };
  5191. pp$3.parseParenExpression = function() {
  5192. this.expect(types.parenL);
  5193. var val = this.parseExpression();
  5194. this.expect(types.parenR);
  5195. return val
  5196. };
  5197. pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
  5198. var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
  5199. if (this.options.ecmaVersion >= 6) {
  5200. this.next();
  5201. var innerStartPos = this.start, innerStartLoc = this.startLoc;
  5202. var exprList = [], first = true, lastIsComma = false;
  5203. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
  5204. this.yieldPos = 0;
  5205. this.awaitPos = 0;
  5206. // Do not save awaitIdentPos to allow checking awaits nested in parameters
  5207. while (this.type !== types.parenR) {
  5208. first ? first = false : this.expect(types.comma);
  5209. if (allowTrailingComma && this.afterTrailingComma(types.parenR, true)) {
  5210. lastIsComma = true;
  5211. break
  5212. } else if (this.type === types.ellipsis) {
  5213. spreadStart = this.start;
  5214. exprList.push(this.parseParenItem(this.parseRestBinding()));
  5215. if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
  5216. break
  5217. } else {
  5218. exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
  5219. }
  5220. }
  5221. var innerEndPos = this.start, innerEndLoc = this.startLoc;
  5222. this.expect(types.parenR);
  5223. if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
  5224. this.checkPatternErrors(refDestructuringErrors, false);
  5225. this.checkYieldAwaitInDefaultParams();
  5226. this.yieldPos = oldYieldPos;
  5227. this.awaitPos = oldAwaitPos;
  5228. return this.parseParenArrowList(startPos, startLoc, exprList)
  5229. }
  5230. if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
  5231. if (spreadStart) { this.unexpected(spreadStart); }
  5232. this.checkExpressionErrors(refDestructuringErrors, true);
  5233. this.yieldPos = oldYieldPos || this.yieldPos;
  5234. this.awaitPos = oldAwaitPos || this.awaitPos;
  5235. if (exprList.length > 1) {
  5236. val = this.startNodeAt(innerStartPos, innerStartLoc);
  5237. val.expressions = exprList;
  5238. this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
  5239. } else {
  5240. val = exprList[0];
  5241. }
  5242. } else {
  5243. val = this.parseParenExpression();
  5244. }
  5245. if (this.options.preserveParens) {
  5246. var par = this.startNodeAt(startPos, startLoc);
  5247. par.expression = val;
  5248. return this.finishNode(par, "ParenthesizedExpression")
  5249. } else {
  5250. return val
  5251. }
  5252. };
  5253. pp$3.parseParenItem = function(item) {
  5254. return item
  5255. };
  5256. pp$3.parseParenArrowList = function(startPos, startLoc, exprList) {
  5257. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)
  5258. };
  5259. // New's precedence is slightly tricky. It must allow its argument to
  5260. // be a `[]` or dot subscript expression, but not a call — at least,
  5261. // not without wrapping it in parentheses. Thus, it uses the noCalls
  5262. // argument to parseSubscripts to prevent it from consuming the
  5263. // argument list.
  5264. var empty$1 = [];
  5265. pp$3.parseNew = function() {
  5266. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
  5267. var node = this.startNode();
  5268. var meta = this.parseIdent(true);
  5269. if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
  5270. node.meta = meta;
  5271. var containsEsc = this.containsEsc;
  5272. node.property = this.parseIdent(true);
  5273. if (node.property.name !== "target")
  5274. { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
  5275. if (containsEsc)
  5276. { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
  5277. if (!this.inNonArrowFunction)
  5278. { this.raiseRecoverable(node.start, "'new.target' can only be used in functions"); }
  5279. return this.finishNode(node, "MetaProperty")
  5280. }
  5281. var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import;
  5282. node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
  5283. if (isImport && node.callee.type === "ImportExpression") {
  5284. this.raise(startPos, "Cannot use new with import()");
  5285. }
  5286. if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); }
  5287. else { node.arguments = empty$1; }
  5288. return this.finishNode(node, "NewExpression")
  5289. };
  5290. // Parse template expression.
  5291. pp$3.parseTemplateElement = function(ref) {
  5292. var isTagged = ref.isTagged;
  5293. var elem = this.startNode();
  5294. if (this.type === types.invalidTemplate) {
  5295. if (!isTagged) {
  5296. this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
  5297. }
  5298. elem.value = {
  5299. raw: this.value,
  5300. cooked: null
  5301. };
  5302. } else {
  5303. elem.value = {
  5304. raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
  5305. cooked: this.value
  5306. };
  5307. }
  5308. this.next();
  5309. elem.tail = this.type === types.backQuote;
  5310. return this.finishNode(elem, "TemplateElement")
  5311. };
  5312. pp$3.parseTemplate = function(ref) {
  5313. if ( ref === void 0 ) ref = {};
  5314. var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
  5315. var node = this.startNode();
  5316. this.next();
  5317. node.expressions = [];
  5318. var curElt = this.parseTemplateElement({isTagged: isTagged});
  5319. node.quasis = [curElt];
  5320. while (!curElt.tail) {
  5321. if (this.type === types.eof) { this.raise(this.pos, "Unterminated template literal"); }
  5322. this.expect(types.dollarBraceL);
  5323. node.expressions.push(this.parseExpression());
  5324. this.expect(types.braceR);
  5325. node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
  5326. }
  5327. this.next();
  5328. return this.finishNode(node, "TemplateLiteral")
  5329. };
  5330. pp$3.isAsyncProp = function(prop) {
  5331. return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
  5332. (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types.star)) &&
  5333. !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  5334. };
  5335. // Parse an object literal or binding pattern.
  5336. pp$3.parseObj = function(isPattern, refDestructuringErrors) {
  5337. var node = this.startNode(), first = true, propHash = {};
  5338. node.properties = [];
  5339. this.next();
  5340. while (!this.eat(types.braceR)) {
  5341. if (!first) {
  5342. this.expect(types.comma);
  5343. if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) { break }
  5344. } else { first = false; }
  5345. var prop = this.parseProperty(isPattern, refDestructuringErrors);
  5346. if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }
  5347. node.properties.push(prop);
  5348. }
  5349. return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
  5350. };
  5351. pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
  5352. var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
  5353. if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
  5354. if (isPattern) {
  5355. prop.argument = this.parseIdent(false);
  5356. if (this.type === types.comma) {
  5357. this.raise(this.start, "Comma is not permitted after the rest element");
  5358. }
  5359. return this.finishNode(prop, "RestElement")
  5360. }
  5361. // To disallow parenthesized identifier via `this.toAssignable()`.
  5362. if (this.type === types.parenL && refDestructuringErrors) {
  5363. if (refDestructuringErrors.parenthesizedAssign < 0) {
  5364. refDestructuringErrors.parenthesizedAssign = this.start;
  5365. }
  5366. if (refDestructuringErrors.parenthesizedBind < 0) {
  5367. refDestructuringErrors.parenthesizedBind = this.start;
  5368. }
  5369. }
  5370. // Parse argument.
  5371. prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  5372. // To disallow trailing comma via `this.toAssignable()`.
  5373. if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
  5374. refDestructuringErrors.trailingComma = this.start;
  5375. }
  5376. // Finish
  5377. return this.finishNode(prop, "SpreadElement")
  5378. }
  5379. if (this.options.ecmaVersion >= 6) {
  5380. prop.method = false;
  5381. prop.shorthand = false;
  5382. if (isPattern || refDestructuringErrors) {
  5383. startPos = this.start;
  5384. startLoc = this.startLoc;
  5385. }
  5386. if (!isPattern)
  5387. { isGenerator = this.eat(types.star); }
  5388. }
  5389. var containsEsc = this.containsEsc;
  5390. this.parsePropertyName(prop);
  5391. if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
  5392. isAsync = true;
  5393. isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
  5394. this.parsePropertyName(prop, refDestructuringErrors);
  5395. } else {
  5396. isAsync = false;
  5397. }
  5398. this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
  5399. return this.finishNode(prop, "Property")
  5400. };
  5401. pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
  5402. if ((isGenerator || isAsync) && this.type === types.colon)
  5403. { this.unexpected(); }
  5404. if (this.eat(types.colon)) {
  5405. prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
  5406. prop.kind = "init";
  5407. } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
  5408. if (isPattern) { this.unexpected(); }
  5409. prop.kind = "init";
  5410. prop.method = true;
  5411. prop.value = this.parseMethod(isGenerator, isAsync);
  5412. } else if (!isPattern && !containsEsc &&
  5413. this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
  5414. (prop.key.name === "get" || prop.key.name === "set") &&
  5415. (this.type !== types.comma && this.type !== types.braceR && this.type !== types.eq)) {
  5416. if (isGenerator || isAsync) { this.unexpected(); }
  5417. prop.kind = prop.key.name;
  5418. this.parsePropertyName(prop);
  5419. prop.value = this.parseMethod(false);
  5420. var paramCount = prop.kind === "get" ? 0 : 1;
  5421. if (prop.value.params.length !== paramCount) {
  5422. var start = prop.value.start;
  5423. if (prop.kind === "get")
  5424. { this.raiseRecoverable(start, "getter should have no params"); }
  5425. else
  5426. { this.raiseRecoverable(start, "setter should have exactly one param"); }
  5427. } else {
  5428. if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
  5429. { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
  5430. }
  5431. } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  5432. if (isGenerator || isAsync) { this.unexpected(); }
  5433. this.checkUnreserved(prop.key);
  5434. if (prop.key.name === "await" && !this.awaitIdentPos)
  5435. { this.awaitIdentPos = startPos; }
  5436. prop.kind = "init";
  5437. if (isPattern) {
  5438. prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
  5439. } else if (this.type === types.eq && refDestructuringErrors) {
  5440. if (refDestructuringErrors.shorthandAssign < 0)
  5441. { refDestructuringErrors.shorthandAssign = this.start; }
  5442. prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
  5443. } else {
  5444. prop.value = this.copyNode(prop.key);
  5445. }
  5446. prop.shorthand = true;
  5447. } else { this.unexpected(); }
  5448. };
  5449. pp$3.parsePropertyName = function(prop) {
  5450. if (this.options.ecmaVersion >= 6) {
  5451. if (this.eat(types.bracketL)) {
  5452. prop.computed = true;
  5453. prop.key = this.parseMaybeAssign();
  5454. this.expect(types.bracketR);
  5455. return prop.key
  5456. } else {
  5457. prop.computed = false;
  5458. }
  5459. }
  5460. return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
  5461. };
  5462. // Initialize empty function node.
  5463. pp$3.initFunction = function(node) {
  5464. node.id = null;
  5465. if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
  5466. if (this.options.ecmaVersion >= 8) { node.async = false; }
  5467. };
  5468. // Parse object or class method.
  5469. pp$3.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
  5470. var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  5471. this.initFunction(node);
  5472. if (this.options.ecmaVersion >= 6)
  5473. { node.generator = isGenerator; }
  5474. if (this.options.ecmaVersion >= 8)
  5475. { node.async = !!isAsync; }
  5476. this.yieldPos = 0;
  5477. this.awaitPos = 0;
  5478. this.awaitIdentPos = 0;
  5479. this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
  5480. this.expect(types.parenL);
  5481. node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
  5482. this.checkYieldAwaitInDefaultParams();
  5483. this.parseFunctionBody(node, false, true);
  5484. this.yieldPos = oldYieldPos;
  5485. this.awaitPos = oldAwaitPos;
  5486. this.awaitIdentPos = oldAwaitIdentPos;
  5487. return this.finishNode(node, "FunctionExpression")
  5488. };
  5489. // Parse arrow function expression with given parameters.
  5490. pp$3.parseArrowExpression = function(node, params, isAsync) {
  5491. var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  5492. this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
  5493. this.initFunction(node);
  5494. if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }
  5495. this.yieldPos = 0;
  5496. this.awaitPos = 0;
  5497. this.awaitIdentPos = 0;
  5498. node.params = this.toAssignableList(params, true);
  5499. this.parseFunctionBody(node, true, false);
  5500. this.yieldPos = oldYieldPos;
  5501. this.awaitPos = oldAwaitPos;
  5502. this.awaitIdentPos = oldAwaitIdentPos;
  5503. return this.finishNode(node, "ArrowFunctionExpression")
  5504. };
  5505. // Parse function body and check parameters.
  5506. pp$3.parseFunctionBody = function(node, isArrowFunction, isMethod) {
  5507. var isExpression = isArrowFunction && this.type !== types.braceL;
  5508. var oldStrict = this.strict, useStrict = false;
  5509. if (isExpression) {
  5510. node.body = this.parseMaybeAssign();
  5511. node.expression = true;
  5512. this.checkParams(node, false);
  5513. } else {
  5514. var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
  5515. if (!oldStrict || nonSimple) {
  5516. useStrict = this.strictDirective(this.end);
  5517. // If this is a strict mode function, verify that argument names
  5518. // are not repeated, and it does not try to bind the words `eval`
  5519. // or `arguments`.
  5520. if (useStrict && nonSimple)
  5521. { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
  5522. }
  5523. // Start a new scope with regard to labels and the `inFunction`
  5524. // flag (restore them to their old value afterwards).
  5525. var oldLabels = this.labels;
  5526. this.labels = [];
  5527. if (useStrict) { this.strict = true; }
  5528. // Add the params to varDeclaredNames to ensure that an error is thrown
  5529. // if a let/const declaration in the function clashes with one of the params.
  5530. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
  5531. // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
  5532. if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); }
  5533. node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
  5534. node.expression = false;
  5535. this.adaptDirectivePrologue(node.body.body);
  5536. this.labels = oldLabels;
  5537. }
  5538. this.exitScope();
  5539. };
  5540. pp$3.isSimpleParamList = function(params) {
  5541. for (var i = 0, list = params; i < list.length; i += 1)
  5542. {
  5543. var param = list[i];
  5544. if (param.type !== "Identifier") { return false
  5545. } }
  5546. return true
  5547. };
  5548. // Checks function params for various disallowed patterns such as using "eval"
  5549. // or "arguments" and duplicate parameters.
  5550. pp$3.checkParams = function(node, allowDuplicates) {
  5551. var nameHash = Object.create(null);
  5552. for (var i = 0, list = node.params; i < list.length; i += 1)
  5553. {
  5554. var param = list[i];
  5555. this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
  5556. }
  5557. };
  5558. // Parses a comma-separated list of expressions, and returns them as
  5559. // an array. `close` is the token type that ends the list, and
  5560. // `allowEmpty` can be turned on to allow subsequent commas with
  5561. // nothing in between them to be parsed as `null` (which is needed
  5562. // for array literals).
  5563. pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
  5564. var elts = [], first = true;
  5565. while (!this.eat(close)) {
  5566. if (!first) {
  5567. this.expect(types.comma);
  5568. if (allowTrailingComma && this.afterTrailingComma(close)) { break }
  5569. } else { first = false; }
  5570. var elt = (void 0);
  5571. if (allowEmpty && this.type === types.comma)
  5572. { elt = null; }
  5573. else if (this.type === types.ellipsis) {
  5574. elt = this.parseSpread(refDestructuringErrors);
  5575. if (refDestructuringErrors && this.type === types.comma && refDestructuringErrors.trailingComma < 0)
  5576. { refDestructuringErrors.trailingComma = this.start; }
  5577. } else {
  5578. elt = this.parseMaybeAssign(false, refDestructuringErrors);
  5579. }
  5580. elts.push(elt);
  5581. }
  5582. return elts
  5583. };
  5584. pp$3.checkUnreserved = function(ref) {
  5585. var start = ref.start;
  5586. var end = ref.end;
  5587. var name = ref.name;
  5588. if (this.inGenerator && name === "yield")
  5589. { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
  5590. if (this.inAsync && name === "await")
  5591. { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
  5592. if (this.currentThisScope().inClassFieldInit && name === "arguments")
  5593. { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
  5594. if (this.keywords.test(name))
  5595. { this.raise(start, ("Unexpected keyword '" + name + "'")); }
  5596. if (this.options.ecmaVersion < 6 &&
  5597. this.input.slice(start, end).indexOf("\\") !== -1) { return }
  5598. var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
  5599. if (re.test(name)) {
  5600. if (!this.inAsync && name === "await")
  5601. { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); }
  5602. this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
  5603. }
  5604. };
  5605. // Parse the next token as an identifier. If `liberal` is true (used
  5606. // when parsing properties), it will also convert keywords into
  5607. // identifiers.
  5608. pp$3.parseIdent = function(liberal, isBinding) {
  5609. var node = this.startNode();
  5610. if (this.type === types.name) {
  5611. node.name = this.value;
  5612. } else if (this.type.keyword) {
  5613. node.name = this.type.keyword;
  5614. // To fix https://github.com/acornjs/acorn/issues/575
  5615. // `class` and `function` keywords push new context into this.context.
  5616. // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
  5617. // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
  5618. if ((node.name === "class" || node.name === "function") &&
  5619. (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
  5620. this.context.pop();
  5621. }
  5622. } else {
  5623. this.unexpected();
  5624. }
  5625. this.next(!!liberal);
  5626. this.finishNode(node, "Identifier");
  5627. if (!liberal) {
  5628. this.checkUnreserved(node);
  5629. if (node.name === "await" && !this.awaitIdentPos)
  5630. { this.awaitIdentPos = node.start; }
  5631. }
  5632. return node
  5633. };
  5634. pp$3.parsePrivateIdent = function() {
  5635. var node = this.startNode();
  5636. if (this.type === types.privateId) {
  5637. node.name = this.value;
  5638. } else {
  5639. this.unexpected();
  5640. }
  5641. this.next();
  5642. this.finishNode(node, "PrivateIdentifier");
  5643. // For validating existence
  5644. if (this.privateNameStack.length === 0) {
  5645. this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
  5646. } else {
  5647. this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
  5648. }
  5649. return node
  5650. };
  5651. // Parses yield expression inside generator.
  5652. pp$3.parseYield = function(forInit) {
  5653. if (!this.yieldPos) { this.yieldPos = this.start; }
  5654. var node = this.startNode();
  5655. this.next();
  5656. if (this.type === types.semi || this.canInsertSemicolon() || (this.type !== types.star && !this.type.startsExpr)) {
  5657. node.delegate = false;
  5658. node.argument = null;
  5659. } else {
  5660. node.delegate = this.eat(types.star);
  5661. node.argument = this.parseMaybeAssign(forInit);
  5662. }
  5663. return this.finishNode(node, "YieldExpression")
  5664. };
  5665. pp$3.parseAwait = function() {
  5666. if (!this.awaitPos) { this.awaitPos = this.start; }
  5667. var node = this.startNode();
  5668. this.next();
  5669. node.argument = this.parseMaybeUnary(null, true);
  5670. return this.finishNode(node, "AwaitExpression")
  5671. };
  5672. var pp$4 = Parser.prototype;
  5673. // This function is used to raise exceptions on parse errors. It
  5674. // takes an offset integer (into the current `input`) to indicate
  5675. // the location of the error, attaches the position to the end
  5676. // of the error message, and then raises a `SyntaxError` with that
  5677. // message.
  5678. pp$4.raise = function(pos, message) {
  5679. var loc = getLineInfo(this.input, pos);
  5680. message += " (" + loc.line + ":" + loc.column + ")";
  5681. var err = new SyntaxError(message);
  5682. err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
  5683. throw err
  5684. };
  5685. pp$4.raiseRecoverable = pp$4.raise;
  5686. pp$4.curPosition = function() {
  5687. if (this.options.locations) {
  5688. return new Position(this.curLine, this.pos - this.lineStart)
  5689. }
  5690. };
  5691. var pp$5 = Parser.prototype;
  5692. var Scope = function Scope(flags) {
  5693. this.flags = flags;
  5694. // A list of var-declared names in the current lexical scope
  5695. this.var = [];
  5696. // A list of lexically-declared names in the current lexical scope
  5697. this.lexical = [];
  5698. // A list of lexically-declared FunctionDeclaration names in the current lexical scope
  5699. this.functions = [];
  5700. // A switch to disallow the identifier reference 'arguments'
  5701. this.inClassFieldInit = false;
  5702. };
  5703. // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
  5704. pp$5.enterScope = function(flags) {
  5705. this.scopeStack.push(new Scope(flags));
  5706. };
  5707. pp$5.exitScope = function() {
  5708. this.scopeStack.pop();
  5709. };
  5710. // The spec says:
  5711. // > At the top level of a function, or script, function declarations are
  5712. // > treated like var declarations rather than like lexical declarations.
  5713. pp$5.treatFunctionsAsVarInScope = function(scope) {
  5714. return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
  5715. };
  5716. pp$5.declareName = function(name, bindingType, pos) {
  5717. var redeclared = false;
  5718. if (bindingType === BIND_LEXICAL) {
  5719. var scope = this.currentScope();
  5720. redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
  5721. scope.lexical.push(name);
  5722. if (this.inModule && (scope.flags & SCOPE_TOP))
  5723. { delete this.undefinedExports[name]; }
  5724. } else if (bindingType === BIND_SIMPLE_CATCH) {
  5725. var scope$1 = this.currentScope();
  5726. scope$1.lexical.push(name);
  5727. } else if (bindingType === BIND_FUNCTION) {
  5728. var scope$2 = this.currentScope();
  5729. if (this.treatFunctionsAsVar)
  5730. { redeclared = scope$2.lexical.indexOf(name) > -1; }
  5731. else
  5732. { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }
  5733. scope$2.functions.push(name);
  5734. } else {
  5735. for (var i = this.scopeStack.length - 1; i >= 0; --i) {
  5736. var scope$3 = this.scopeStack[i];
  5737. if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||
  5738. !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
  5739. redeclared = true;
  5740. break
  5741. }
  5742. scope$3.var.push(name);
  5743. if (this.inModule && (scope$3.flags & SCOPE_TOP))
  5744. { delete this.undefinedExports[name]; }
  5745. if (scope$3.flags & SCOPE_VAR) { break }
  5746. }
  5747. }
  5748. if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
  5749. };
  5750. pp$5.checkLocalExport = function(id) {
  5751. // scope.functions must be empty as Module code is always strict.
  5752. if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
  5753. this.scopeStack[0].var.indexOf(id.name) === -1) {
  5754. this.undefinedExports[id.name] = id;
  5755. }
  5756. };
  5757. pp$5.currentScope = function() {
  5758. return this.scopeStack[this.scopeStack.length - 1]
  5759. };
  5760. pp$5.currentVarScope = function() {
  5761. for (var i = this.scopeStack.length - 1;; i--) {
  5762. var scope = this.scopeStack[i];
  5763. if (scope.flags & SCOPE_VAR) { return scope }
  5764. }
  5765. };
  5766. // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
  5767. pp$5.currentThisScope = function() {
  5768. for (var i = this.scopeStack.length - 1;; i--) {
  5769. var scope = this.scopeStack[i];
  5770. if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
  5771. }
  5772. };
  5773. var Node = function Node(parser, pos, loc) {
  5774. this.type = "";
  5775. this.start = pos;
  5776. this.end = 0;
  5777. if (parser.options.locations)
  5778. { this.loc = new SourceLocation(parser, loc); }
  5779. if (parser.options.directSourceFile)
  5780. { this.sourceFile = parser.options.directSourceFile; }
  5781. if (parser.options.ranges)
  5782. { this.range = [pos, 0]; }
  5783. };
  5784. // Start an AST node, attaching a start offset.
  5785. var pp$6 = Parser.prototype;
  5786. pp$6.startNode = function() {
  5787. return new Node(this, this.start, this.startLoc)
  5788. };
  5789. pp$6.startNodeAt = function(pos, loc) {
  5790. return new Node(this, pos, loc)
  5791. };
  5792. // Finish an AST node, adding `type` and `end` properties.
  5793. function finishNodeAt(node, type, pos, loc) {
  5794. node.type = type;
  5795. node.end = pos;
  5796. if (this.options.locations)
  5797. { node.loc.end = loc; }
  5798. if (this.options.ranges)
  5799. { node.range[1] = pos; }
  5800. return node
  5801. }
  5802. pp$6.finishNode = function(node, type) {
  5803. return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
  5804. };
  5805. // Finish node at given position
  5806. pp$6.finishNodeAt = function(node, type, pos, loc) {
  5807. return finishNodeAt.call(this, node, type, pos, loc)
  5808. };
  5809. pp$6.copyNode = function(node) {
  5810. var newNode = new Node(this, node.start, this.startLoc);
  5811. for (var prop in node) { newNode[prop] = node[prop]; }
  5812. return newNode
  5813. };
  5814. // The algorithm used to determine whether a regexp can appear at a
  5815. var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
  5816. this.token = token;
  5817. this.isExpr = !!isExpr;
  5818. this.preserveSpace = !!preserveSpace;
  5819. this.override = override;
  5820. this.generator = !!generator;
  5821. };
  5822. var types$1 = {
  5823. b_stat: new TokContext("{", false),
  5824. b_expr: new TokContext("{", true),
  5825. b_tmpl: new TokContext("${", false),
  5826. p_stat: new TokContext("(", false),
  5827. p_expr: new TokContext("(", true),
  5828. q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
  5829. f_stat: new TokContext("function", false),
  5830. f_expr: new TokContext("function", true),
  5831. f_expr_gen: new TokContext("function", true, false, null, true),
  5832. f_gen: new TokContext("function", false, false, null, true)
  5833. };
  5834. var pp$7 = Parser.prototype;
  5835. pp$7.initialContext = function() {
  5836. return [types$1.b_stat]
  5837. };
  5838. pp$7.braceIsBlock = function(prevType) {
  5839. var parent = this.curContext();
  5840. if (parent === types$1.f_expr || parent === types$1.f_stat)
  5841. { return true }
  5842. if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr))
  5843. { return !parent.isExpr }
  5844. // The check for `tt.name && exprAllowed` detects whether we are
  5845. // after a `yield` or `of` construct. See the `updateContext` for
  5846. // `tt.name`.
  5847. if (prevType === types._return || prevType === types.name && this.exprAllowed)
  5848. { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
  5849. if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow)
  5850. { return true }
  5851. if (prevType === types.braceL)
  5852. { return parent === types$1.b_stat }
  5853. if (prevType === types._var || prevType === types._const || prevType === types.name)
  5854. { return false }
  5855. return !this.exprAllowed
  5856. };
  5857. pp$7.inGeneratorContext = function() {
  5858. for (var i = this.context.length - 1; i >= 1; i--) {
  5859. var context = this.context[i];
  5860. if (context.token === "function")
  5861. { return context.generator }
  5862. }
  5863. return false
  5864. };
  5865. pp$7.updateContext = function(prevType) {
  5866. var update, type = this.type;
  5867. if (type.keyword && prevType === types.dot)
  5868. { this.exprAllowed = false; }
  5869. else if (update = type.updateContext)
  5870. { update.call(this, prevType); }
  5871. else
  5872. { this.exprAllowed = type.beforeExpr; }
  5873. };
  5874. // Token-specific context update code
  5875. types.parenR.updateContext = types.braceR.updateContext = function() {
  5876. if (this.context.length === 1) {
  5877. this.exprAllowed = true;
  5878. return
  5879. }
  5880. var out = this.context.pop();
  5881. if (out === types$1.b_stat && this.curContext().token === "function") {
  5882. out = this.context.pop();
  5883. }
  5884. this.exprAllowed = !out.isExpr;
  5885. };
  5886. types.braceL.updateContext = function(prevType) {
  5887. this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
  5888. this.exprAllowed = true;
  5889. };
  5890. types.dollarBraceL.updateContext = function() {
  5891. this.context.push(types$1.b_tmpl);
  5892. this.exprAllowed = true;
  5893. };
  5894. types.parenL.updateContext = function(prevType) {
  5895. var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
  5896. this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
  5897. this.exprAllowed = true;
  5898. };
  5899. types.incDec.updateContext = function() {
  5900. // tokExprAllowed stays unchanged
  5901. };
  5902. types._function.updateContext = types._class.updateContext = function(prevType) {
  5903. if (prevType.beforeExpr && prevType !== types._else &&
  5904. !(prevType === types.semi && this.curContext() !== types$1.p_stat) &&
  5905. !(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
  5906. !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat))
  5907. { this.context.push(types$1.f_expr); }
  5908. else
  5909. { this.context.push(types$1.f_stat); }
  5910. this.exprAllowed = false;
  5911. };
  5912. types.backQuote.updateContext = function() {
  5913. if (this.curContext() === types$1.q_tmpl)
  5914. { this.context.pop(); }
  5915. else
  5916. { this.context.push(types$1.q_tmpl); }
  5917. this.exprAllowed = false;
  5918. };
  5919. types.star.updateContext = function(prevType) {
  5920. if (prevType === types._function) {
  5921. var index = this.context.length - 1;
  5922. if (this.context[index] === types$1.f_expr)
  5923. { this.context[index] = types$1.f_expr_gen; }
  5924. else
  5925. { this.context[index] = types$1.f_gen; }
  5926. }
  5927. this.exprAllowed = true;
  5928. };
  5929. types.name.updateContext = function(prevType) {
  5930. var allowed = false;
  5931. if (this.options.ecmaVersion >= 6 && prevType !== types.dot) {
  5932. if (this.value === "of" && !this.exprAllowed ||
  5933. this.value === "yield" && this.inGeneratorContext())
  5934. { allowed = true; }
  5935. }
  5936. this.exprAllowed = allowed;
  5937. };
  5938. // This file contains Unicode properties extracted from the ECMAScript
  5939. // specification. The lists are extracted like so:
  5940. // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
  5941. // #table-binary-unicode-properties
  5942. var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS";
  5943. var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
  5944. var ecma11BinaryProperties = ecma10BinaryProperties;
  5945. var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
  5946. var unicodeBinaryProperties = {
  5947. 9: ecma9BinaryProperties,
  5948. 10: ecma10BinaryProperties,
  5949. 11: ecma11BinaryProperties,
  5950. 12: ecma12BinaryProperties
  5951. };
  5952. // #table-unicode-general-category-values
  5953. var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu";
  5954. // #table-unicode-script-values
  5955. var ecma9ScriptValues = "Adlam Adlm Ahom Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
  5956. var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
  5957. var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
  5958. var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
  5959. var unicodeScriptValues = {
  5960. 9: ecma9ScriptValues,
  5961. 10: ecma10ScriptValues,
  5962. 11: ecma11ScriptValues,
  5963. 12: ecma12ScriptValues
  5964. };
  5965. var data = {};
  5966. function buildUnicodeData(ecmaVersion) {
  5967. var d = data[ecmaVersion] = {
  5968. binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
  5969. nonBinary: {
  5970. General_Category: wordsRegexp(unicodeGeneralCategoryValues),
  5971. Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
  5972. }
  5973. };
  5974. d.nonBinary.Script_Extensions = d.nonBinary.Script;
  5975. d.nonBinary.gc = d.nonBinary.General_Category;
  5976. d.nonBinary.sc = d.nonBinary.Script;
  5977. d.nonBinary.scx = d.nonBinary.Script_Extensions;
  5978. }
  5979. buildUnicodeData(9);
  5980. buildUnicodeData(10);
  5981. buildUnicodeData(11);
  5982. buildUnicodeData(12);
  5983. var pp$8 = Parser.prototype;
  5984. var RegExpValidationState = function RegExpValidationState(parser) {
  5985. this.parser = parser;
  5986. this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
  5987. this.unicodeProperties = data[parser.options.ecmaVersion >= 12 ? 12 : parser.options.ecmaVersion];
  5988. this.source = "";
  5989. this.flags = "";
  5990. this.start = 0;
  5991. this.switchU = false;
  5992. this.switchN = false;
  5993. this.pos = 0;
  5994. this.lastIntValue = 0;
  5995. this.lastStringValue = "";
  5996. this.lastAssertionIsQuantifiable = false;
  5997. this.numCapturingParens = 0;
  5998. this.maxBackReference = 0;
  5999. this.groupNames = [];
  6000. this.backReferenceNames = [];
  6001. };
  6002. RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
  6003. var unicode = flags.indexOf("u") !== -1;
  6004. this.start = start | 0;
  6005. this.source = pattern + "";
  6006. this.flags = flags;
  6007. this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
  6008. this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
  6009. };
  6010. RegExpValidationState.prototype.raise = function raise (message) {
  6011. this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
  6012. };
  6013. // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
  6014. // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
  6015. RegExpValidationState.prototype.at = function at (i, forceU) {
  6016. if ( forceU === void 0 ) forceU = false;
  6017. var s = this.source;
  6018. var l = s.length;
  6019. if (i >= l) {
  6020. return -1
  6021. }
  6022. var c = s.charCodeAt(i);
  6023. if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
  6024. return c
  6025. }
  6026. var next = s.charCodeAt(i + 1);
  6027. return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
  6028. };
  6029. RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
  6030. if ( forceU === void 0 ) forceU = false;
  6031. var s = this.source;
  6032. var l = s.length;
  6033. if (i >= l) {
  6034. return l
  6035. }
  6036. var c = s.charCodeAt(i), next;
  6037. if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
  6038. (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
  6039. return i + 1
  6040. }
  6041. return i + 2
  6042. };
  6043. RegExpValidationState.prototype.current = function current (forceU) {
  6044. if ( forceU === void 0 ) forceU = false;
  6045. return this.at(this.pos, forceU)
  6046. };
  6047. RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
  6048. if ( forceU === void 0 ) forceU = false;
  6049. return this.at(this.nextIndex(this.pos, forceU), forceU)
  6050. };
  6051. RegExpValidationState.prototype.advance = function advance (forceU) {
  6052. if ( forceU === void 0 ) forceU = false;
  6053. this.pos = this.nextIndex(this.pos, forceU);
  6054. };
  6055. RegExpValidationState.prototype.eat = function eat (ch, forceU) {
  6056. if ( forceU === void 0 ) forceU = false;
  6057. if (this.current(forceU) === ch) {
  6058. this.advance(forceU);
  6059. return true
  6060. }
  6061. return false
  6062. };
  6063. function codePointToString(ch) {
  6064. if (ch <= 0xFFFF) { return String.fromCharCode(ch) }
  6065. ch -= 0x10000;
  6066. return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)
  6067. }
  6068. /**
  6069. * Validate the flags part of a given RegExpLiteral.
  6070. *
  6071. * @param {RegExpValidationState} state The state to validate RegExp.
  6072. * @returns {void}
  6073. */
  6074. pp$8.validateRegExpFlags = function(state) {
  6075. var validFlags = state.validFlags;
  6076. var flags = state.flags;
  6077. for (var i = 0; i < flags.length; i++) {
  6078. var flag = flags.charAt(i);
  6079. if (validFlags.indexOf(flag) === -1) {
  6080. this.raise(state.start, "Invalid regular expression flag");
  6081. }
  6082. if (flags.indexOf(flag, i + 1) > -1) {
  6083. this.raise(state.start, "Duplicate regular expression flag");
  6084. }
  6085. }
  6086. };
  6087. /**
  6088. * Validate the pattern part of a given RegExpLiteral.
  6089. *
  6090. * @param {RegExpValidationState} state The state to validate RegExp.
  6091. * @returns {void}
  6092. */
  6093. pp$8.validateRegExpPattern = function(state) {
  6094. this.regexp_pattern(state);
  6095. // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
  6096. // parsing contains a |GroupName|, reparse with the goal symbol
  6097. // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
  6098. // exception if _P_ did not conform to the grammar, if any elements of _P_
  6099. // were not matched by the parse, or if any Early Error conditions exist.
  6100. if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
  6101. state.switchN = true;
  6102. this.regexp_pattern(state);
  6103. }
  6104. };
  6105. // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
  6106. pp$8.regexp_pattern = function(state) {
  6107. state.pos = 0;
  6108. state.lastIntValue = 0;
  6109. state.lastStringValue = "";
  6110. state.lastAssertionIsQuantifiable = false;
  6111. state.numCapturingParens = 0;
  6112. state.maxBackReference = 0;
  6113. state.groupNames.length = 0;
  6114. state.backReferenceNames.length = 0;
  6115. this.regexp_disjunction(state);
  6116. if (state.pos !== state.source.length) {
  6117. // Make the same messages as V8.
  6118. if (state.eat(0x29 /* ) */)) {
  6119. state.raise("Unmatched ')'");
  6120. }
  6121. if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
  6122. state.raise("Lone quantifier brackets");
  6123. }
  6124. }
  6125. if (state.maxBackReference > state.numCapturingParens) {
  6126. state.raise("Invalid escape");
  6127. }
  6128. for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
  6129. var name = list[i];
  6130. if (state.groupNames.indexOf(name) === -1) {
  6131. state.raise("Invalid named capture referenced");
  6132. }
  6133. }
  6134. };
  6135. // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
  6136. pp$8.regexp_disjunction = function(state) {
  6137. this.regexp_alternative(state);
  6138. while (state.eat(0x7C /* | */)) {
  6139. this.regexp_alternative(state);
  6140. }
  6141. // Make the same message as V8.
  6142. if (this.regexp_eatQuantifier(state, true)) {
  6143. state.raise("Nothing to repeat");
  6144. }
  6145. if (state.eat(0x7B /* { */)) {
  6146. state.raise("Lone quantifier brackets");
  6147. }
  6148. };
  6149. // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
  6150. pp$8.regexp_alternative = function(state) {
  6151. while (state.pos < state.source.length && this.regexp_eatTerm(state))
  6152. { }
  6153. };
  6154. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
  6155. pp$8.regexp_eatTerm = function(state) {
  6156. if (this.regexp_eatAssertion(state)) {
  6157. // Handle `QuantifiableAssertion Quantifier` alternative.
  6158. // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
  6159. // is a QuantifiableAssertion.
  6160. if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
  6161. // Make the same message as V8.
  6162. if (state.switchU) {
  6163. state.raise("Invalid quantifier");
  6164. }
  6165. }
  6166. return true
  6167. }
  6168. if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
  6169. this.regexp_eatQuantifier(state);
  6170. return true
  6171. }
  6172. return false
  6173. };
  6174. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
  6175. pp$8.regexp_eatAssertion = function(state) {
  6176. var start = state.pos;
  6177. state.lastAssertionIsQuantifiable = false;
  6178. // ^, $
  6179. if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
  6180. return true
  6181. }
  6182. // \b \B
  6183. if (state.eat(0x5C /* \ */)) {
  6184. if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
  6185. return true
  6186. }
  6187. state.pos = start;
  6188. }
  6189. // Lookahead / Lookbehind
  6190. if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
  6191. var lookbehind = false;
  6192. if (this.options.ecmaVersion >= 9) {
  6193. lookbehind = state.eat(0x3C /* < */);
  6194. }
  6195. if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
  6196. this.regexp_disjunction(state);
  6197. if (!state.eat(0x29 /* ) */)) {
  6198. state.raise("Unterminated group");
  6199. }
  6200. state.lastAssertionIsQuantifiable = !lookbehind;
  6201. return true
  6202. }
  6203. }
  6204. state.pos = start;
  6205. return false
  6206. };
  6207. // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
  6208. pp$8.regexp_eatQuantifier = function(state, noError) {
  6209. if ( noError === void 0 ) noError = false;
  6210. if (this.regexp_eatQuantifierPrefix(state, noError)) {
  6211. state.eat(0x3F /* ? */);
  6212. return true
  6213. }
  6214. return false
  6215. };
  6216. // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
  6217. pp$8.regexp_eatQuantifierPrefix = function(state, noError) {
  6218. return (
  6219. state.eat(0x2A /* * */) ||
  6220. state.eat(0x2B /* + */) ||
  6221. state.eat(0x3F /* ? */) ||
  6222. this.regexp_eatBracedQuantifier(state, noError)
  6223. )
  6224. };
  6225. pp$8.regexp_eatBracedQuantifier = function(state, noError) {
  6226. var start = state.pos;
  6227. if (state.eat(0x7B /* { */)) {
  6228. var min = 0, max = -1;
  6229. if (this.regexp_eatDecimalDigits(state)) {
  6230. min = state.lastIntValue;
  6231. if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
  6232. max = state.lastIntValue;
  6233. }
  6234. if (state.eat(0x7D /* } */)) {
  6235. // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
  6236. if (max !== -1 && max < min && !noError) {
  6237. state.raise("numbers out of order in {} quantifier");
  6238. }
  6239. return true
  6240. }
  6241. }
  6242. if (state.switchU && !noError) {
  6243. state.raise("Incomplete quantifier");
  6244. }
  6245. state.pos = start;
  6246. }
  6247. return false
  6248. };
  6249. // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
  6250. pp$8.regexp_eatAtom = function(state) {
  6251. return (
  6252. this.regexp_eatPatternCharacters(state) ||
  6253. state.eat(0x2E /* . */) ||
  6254. this.regexp_eatReverseSolidusAtomEscape(state) ||
  6255. this.regexp_eatCharacterClass(state) ||
  6256. this.regexp_eatUncapturingGroup(state) ||
  6257. this.regexp_eatCapturingGroup(state)
  6258. )
  6259. };
  6260. pp$8.regexp_eatReverseSolidusAtomEscape = function(state) {
  6261. var start = state.pos;
  6262. if (state.eat(0x5C /* \ */)) {
  6263. if (this.regexp_eatAtomEscape(state)) {
  6264. return true
  6265. }
  6266. state.pos = start;
  6267. }
  6268. return false
  6269. };
  6270. pp$8.regexp_eatUncapturingGroup = function(state) {
  6271. var start = state.pos;
  6272. if (state.eat(0x28 /* ( */)) {
  6273. if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
  6274. this.regexp_disjunction(state);
  6275. if (state.eat(0x29 /* ) */)) {
  6276. return true
  6277. }
  6278. state.raise("Unterminated group");
  6279. }
  6280. state.pos = start;
  6281. }
  6282. return false
  6283. };
  6284. pp$8.regexp_eatCapturingGroup = function(state) {
  6285. if (state.eat(0x28 /* ( */)) {
  6286. if (this.options.ecmaVersion >= 9) {
  6287. this.regexp_groupSpecifier(state);
  6288. } else if (state.current() === 0x3F /* ? */) {
  6289. state.raise("Invalid group");
  6290. }
  6291. this.regexp_disjunction(state);
  6292. if (state.eat(0x29 /* ) */)) {
  6293. state.numCapturingParens += 1;
  6294. return true
  6295. }
  6296. state.raise("Unterminated group");
  6297. }
  6298. return false
  6299. };
  6300. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
  6301. pp$8.regexp_eatExtendedAtom = function(state) {
  6302. return (
  6303. state.eat(0x2E /* . */) ||
  6304. this.regexp_eatReverseSolidusAtomEscape(state) ||
  6305. this.regexp_eatCharacterClass(state) ||
  6306. this.regexp_eatUncapturingGroup(state) ||
  6307. this.regexp_eatCapturingGroup(state) ||
  6308. this.regexp_eatInvalidBracedQuantifier(state) ||
  6309. this.regexp_eatExtendedPatternCharacter(state)
  6310. )
  6311. };
  6312. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
  6313. pp$8.regexp_eatInvalidBracedQuantifier = function(state) {
  6314. if (this.regexp_eatBracedQuantifier(state, true)) {
  6315. state.raise("Nothing to repeat");
  6316. }
  6317. return false
  6318. };
  6319. // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
  6320. pp$8.regexp_eatSyntaxCharacter = function(state) {
  6321. var ch = state.current();
  6322. if (isSyntaxCharacter(ch)) {
  6323. state.lastIntValue = ch;
  6324. state.advance();
  6325. return true
  6326. }
  6327. return false
  6328. };
  6329. function isSyntaxCharacter(ch) {
  6330. return (
  6331. ch === 0x24 /* $ */ ||
  6332. ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
  6333. ch === 0x2E /* . */ ||
  6334. ch === 0x3F /* ? */ ||
  6335. ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
  6336. ch >= 0x7B /* { */ && ch <= 0x7D /* } */
  6337. )
  6338. }
  6339. // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
  6340. // But eat eager.
  6341. pp$8.regexp_eatPatternCharacters = function(state) {
  6342. var start = state.pos;
  6343. var ch = 0;
  6344. while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
  6345. state.advance();
  6346. }
  6347. return state.pos !== start
  6348. };
  6349. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
  6350. pp$8.regexp_eatExtendedPatternCharacter = function(state) {
  6351. var ch = state.current();
  6352. if (
  6353. ch !== -1 &&
  6354. ch !== 0x24 /* $ */ &&
  6355. !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&
  6356. ch !== 0x2E /* . */ &&
  6357. ch !== 0x3F /* ? */ &&
  6358. ch !== 0x5B /* [ */ &&
  6359. ch !== 0x5E /* ^ */ &&
  6360. ch !== 0x7C /* | */
  6361. ) {
  6362. state.advance();
  6363. return true
  6364. }
  6365. return false
  6366. };
  6367. // GroupSpecifier ::
  6368. // [empty]
  6369. // `?` GroupName
  6370. pp$8.regexp_groupSpecifier = function(state) {
  6371. if (state.eat(0x3F /* ? */)) {
  6372. if (this.regexp_eatGroupName(state)) {
  6373. if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
  6374. state.raise("Duplicate capture group name");
  6375. }
  6376. state.groupNames.push(state.lastStringValue);
  6377. return
  6378. }
  6379. state.raise("Invalid group");
  6380. }
  6381. };
  6382. // GroupName ::
  6383. // `<` RegExpIdentifierName `>`
  6384. // Note: this updates `state.lastStringValue` property with the eaten name.
  6385. pp$8.regexp_eatGroupName = function(state) {
  6386. state.lastStringValue = "";
  6387. if (state.eat(0x3C /* < */)) {
  6388. if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
  6389. return true
  6390. }
  6391. state.raise("Invalid capture group name");
  6392. }
  6393. return false
  6394. };
  6395. // RegExpIdentifierName ::
  6396. // RegExpIdentifierStart
  6397. // RegExpIdentifierName RegExpIdentifierPart
  6398. // Note: this updates `state.lastStringValue` property with the eaten name.
  6399. pp$8.regexp_eatRegExpIdentifierName = function(state) {
  6400. state.lastStringValue = "";
  6401. if (this.regexp_eatRegExpIdentifierStart(state)) {
  6402. state.lastStringValue += codePointToString(state.lastIntValue);
  6403. while (this.regexp_eatRegExpIdentifierPart(state)) {
  6404. state.lastStringValue += codePointToString(state.lastIntValue);
  6405. }
  6406. return true
  6407. }
  6408. return false
  6409. };
  6410. // RegExpIdentifierStart ::
  6411. // UnicodeIDStart
  6412. // `$`
  6413. // `_`
  6414. // `\` RegExpUnicodeEscapeSequence[+U]
  6415. pp$8.regexp_eatRegExpIdentifierStart = function(state) {
  6416. var start = state.pos;
  6417. var forceU = this.options.ecmaVersion >= 11;
  6418. var ch = state.current(forceU);
  6419. state.advance(forceU);
  6420. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
  6421. ch = state.lastIntValue;
  6422. }
  6423. if (isRegExpIdentifierStart(ch)) {
  6424. state.lastIntValue = ch;
  6425. return true
  6426. }
  6427. state.pos = start;
  6428. return false
  6429. };
  6430. function isRegExpIdentifierStart(ch) {
  6431. return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
  6432. }
  6433. // RegExpIdentifierPart ::
  6434. // UnicodeIDContinue
  6435. // `$`
  6436. // `_`
  6437. // `\` RegExpUnicodeEscapeSequence[+U]
  6438. // <ZWNJ>
  6439. // <ZWJ>
  6440. pp$8.regexp_eatRegExpIdentifierPart = function(state) {
  6441. var start = state.pos;
  6442. var forceU = this.options.ecmaVersion >= 11;
  6443. var ch = state.current(forceU);
  6444. state.advance(forceU);
  6445. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
  6446. ch = state.lastIntValue;
  6447. }
  6448. if (isRegExpIdentifierPart(ch)) {
  6449. state.lastIntValue = ch;
  6450. return true
  6451. }
  6452. state.pos = start;
  6453. return false
  6454. };
  6455. function isRegExpIdentifierPart(ch) {
  6456. return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D /* <ZWJ> */
  6457. }
  6458. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
  6459. pp$8.regexp_eatAtomEscape = function(state) {
  6460. if (
  6461. this.regexp_eatBackReference(state) ||
  6462. this.regexp_eatCharacterClassEscape(state) ||
  6463. this.regexp_eatCharacterEscape(state) ||
  6464. (state.switchN && this.regexp_eatKGroupName(state))
  6465. ) {
  6466. return true
  6467. }
  6468. if (state.switchU) {
  6469. // Make the same message as V8.
  6470. if (state.current() === 0x63 /* c */) {
  6471. state.raise("Invalid unicode escape");
  6472. }
  6473. state.raise("Invalid escape");
  6474. }
  6475. return false
  6476. };
  6477. pp$8.regexp_eatBackReference = function(state) {
  6478. var start = state.pos;
  6479. if (this.regexp_eatDecimalEscape(state)) {
  6480. var n = state.lastIntValue;
  6481. if (state.switchU) {
  6482. // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
  6483. if (n > state.maxBackReference) {
  6484. state.maxBackReference = n;
  6485. }
  6486. return true
  6487. }
  6488. if (n <= state.numCapturingParens) {
  6489. return true
  6490. }
  6491. state.pos = start;
  6492. }
  6493. return false
  6494. };
  6495. pp$8.regexp_eatKGroupName = function(state) {
  6496. if (state.eat(0x6B /* k */)) {
  6497. if (this.regexp_eatGroupName(state)) {
  6498. state.backReferenceNames.push(state.lastStringValue);
  6499. return true
  6500. }
  6501. state.raise("Invalid named reference");
  6502. }
  6503. return false
  6504. };
  6505. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
  6506. pp$8.regexp_eatCharacterEscape = function(state) {
  6507. return (
  6508. this.regexp_eatControlEscape(state) ||
  6509. this.regexp_eatCControlLetter(state) ||
  6510. this.regexp_eatZero(state) ||
  6511. this.regexp_eatHexEscapeSequence(state) ||
  6512. this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
  6513. (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
  6514. this.regexp_eatIdentityEscape(state)
  6515. )
  6516. };
  6517. pp$8.regexp_eatCControlLetter = function(state) {
  6518. var start = state.pos;
  6519. if (state.eat(0x63 /* c */)) {
  6520. if (this.regexp_eatControlLetter(state)) {
  6521. return true
  6522. }
  6523. state.pos = start;
  6524. }
  6525. return false
  6526. };
  6527. pp$8.regexp_eatZero = function(state) {
  6528. if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
  6529. state.lastIntValue = 0;
  6530. state.advance();
  6531. return true
  6532. }
  6533. return false
  6534. };
  6535. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
  6536. pp$8.regexp_eatControlEscape = function(state) {
  6537. var ch = state.current();
  6538. if (ch === 0x74 /* t */) {
  6539. state.lastIntValue = 0x09; /* \t */
  6540. state.advance();
  6541. return true
  6542. }
  6543. if (ch === 0x6E /* n */) {
  6544. state.lastIntValue = 0x0A; /* \n */
  6545. state.advance();
  6546. return true
  6547. }
  6548. if (ch === 0x76 /* v */) {
  6549. state.lastIntValue = 0x0B; /* \v */
  6550. state.advance();
  6551. return true
  6552. }
  6553. if (ch === 0x66 /* f */) {
  6554. state.lastIntValue = 0x0C; /* \f */
  6555. state.advance();
  6556. return true
  6557. }
  6558. if (ch === 0x72 /* r */) {
  6559. state.lastIntValue = 0x0D; /* \r */
  6560. state.advance();
  6561. return true
  6562. }
  6563. return false
  6564. };
  6565. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
  6566. pp$8.regexp_eatControlLetter = function(state) {
  6567. var ch = state.current();
  6568. if (isControlLetter(ch)) {
  6569. state.lastIntValue = ch % 0x20;
  6570. state.advance();
  6571. return true
  6572. }
  6573. return false
  6574. };
  6575. function isControlLetter(ch) {
  6576. return (
  6577. (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
  6578. (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
  6579. )
  6580. }
  6581. // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
  6582. pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
  6583. if ( forceU === void 0 ) forceU = false;
  6584. var start = state.pos;
  6585. var switchU = forceU || state.switchU;
  6586. if (state.eat(0x75 /* u */)) {
  6587. if (this.regexp_eatFixedHexDigits(state, 4)) {
  6588. var lead = state.lastIntValue;
  6589. if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
  6590. var leadSurrogateEnd = state.pos;
  6591. if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
  6592. var trail = state.lastIntValue;
  6593. if (trail >= 0xDC00 && trail <= 0xDFFF) {
  6594. state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  6595. return true
  6596. }
  6597. }
  6598. state.pos = leadSurrogateEnd;
  6599. state.lastIntValue = lead;
  6600. }
  6601. return true
  6602. }
  6603. if (
  6604. switchU &&
  6605. state.eat(0x7B /* { */) &&
  6606. this.regexp_eatHexDigits(state) &&
  6607. state.eat(0x7D /* } */) &&
  6608. isValidUnicode(state.lastIntValue)
  6609. ) {
  6610. return true
  6611. }
  6612. if (switchU) {
  6613. state.raise("Invalid unicode escape");
  6614. }
  6615. state.pos = start;
  6616. }
  6617. return false
  6618. };
  6619. function isValidUnicode(ch) {
  6620. return ch >= 0 && ch <= 0x10FFFF
  6621. }
  6622. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
  6623. pp$8.regexp_eatIdentityEscape = function(state) {
  6624. if (state.switchU) {
  6625. if (this.regexp_eatSyntaxCharacter(state)) {
  6626. return true
  6627. }
  6628. if (state.eat(0x2F /* / */)) {
  6629. state.lastIntValue = 0x2F; /* / */
  6630. return true
  6631. }
  6632. return false
  6633. }
  6634. var ch = state.current();
  6635. if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
  6636. state.lastIntValue = ch;
  6637. state.advance();
  6638. return true
  6639. }
  6640. return false
  6641. };
  6642. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
  6643. pp$8.regexp_eatDecimalEscape = function(state) {
  6644. state.lastIntValue = 0;
  6645. var ch = state.current();
  6646. if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
  6647. do {
  6648. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  6649. state.advance();
  6650. } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
  6651. return true
  6652. }
  6653. return false
  6654. };
  6655. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
  6656. pp$8.regexp_eatCharacterClassEscape = function(state) {
  6657. var ch = state.current();
  6658. if (isCharacterClassEscape(ch)) {
  6659. state.lastIntValue = -1;
  6660. state.advance();
  6661. return true
  6662. }
  6663. if (
  6664. state.switchU &&
  6665. this.options.ecmaVersion >= 9 &&
  6666. (ch === 0x50 /* P */ || ch === 0x70 /* p */)
  6667. ) {
  6668. state.lastIntValue = -1;
  6669. state.advance();
  6670. if (
  6671. state.eat(0x7B /* { */) &&
  6672. this.regexp_eatUnicodePropertyValueExpression(state) &&
  6673. state.eat(0x7D /* } */)
  6674. ) {
  6675. return true
  6676. }
  6677. state.raise("Invalid property name");
  6678. }
  6679. return false
  6680. };
  6681. function isCharacterClassEscape(ch) {
  6682. return (
  6683. ch === 0x64 /* d */ ||
  6684. ch === 0x44 /* D */ ||
  6685. ch === 0x73 /* s */ ||
  6686. ch === 0x53 /* S */ ||
  6687. ch === 0x77 /* w */ ||
  6688. ch === 0x57 /* W */
  6689. )
  6690. }
  6691. // UnicodePropertyValueExpression ::
  6692. // UnicodePropertyName `=` UnicodePropertyValue
  6693. // LoneUnicodePropertyNameOrValue
  6694. pp$8.regexp_eatUnicodePropertyValueExpression = function(state) {
  6695. var start = state.pos;
  6696. // UnicodePropertyName `=` UnicodePropertyValue
  6697. if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
  6698. var name = state.lastStringValue;
  6699. if (this.regexp_eatUnicodePropertyValue(state)) {
  6700. var value = state.lastStringValue;
  6701. this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
  6702. return true
  6703. }
  6704. }
  6705. state.pos = start;
  6706. // LoneUnicodePropertyNameOrValue
  6707. if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
  6708. var nameOrValue = state.lastStringValue;
  6709. this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
  6710. return true
  6711. }
  6712. return false
  6713. };
  6714. pp$8.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
  6715. if (!has(state.unicodeProperties.nonBinary, name))
  6716. { state.raise("Invalid property name"); }
  6717. if (!state.unicodeProperties.nonBinary[name].test(value))
  6718. { state.raise("Invalid property value"); }
  6719. };
  6720. pp$8.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
  6721. if (!state.unicodeProperties.binary.test(nameOrValue))
  6722. { state.raise("Invalid property name"); }
  6723. };
  6724. // UnicodePropertyName ::
  6725. // UnicodePropertyNameCharacters
  6726. pp$8.regexp_eatUnicodePropertyName = function(state) {
  6727. var ch = 0;
  6728. state.lastStringValue = "";
  6729. while (isUnicodePropertyNameCharacter(ch = state.current())) {
  6730. state.lastStringValue += codePointToString(ch);
  6731. state.advance();
  6732. }
  6733. return state.lastStringValue !== ""
  6734. };
  6735. function isUnicodePropertyNameCharacter(ch) {
  6736. return isControlLetter(ch) || ch === 0x5F /* _ */
  6737. }
  6738. // UnicodePropertyValue ::
  6739. // UnicodePropertyValueCharacters
  6740. pp$8.regexp_eatUnicodePropertyValue = function(state) {
  6741. var ch = 0;
  6742. state.lastStringValue = "";
  6743. while (isUnicodePropertyValueCharacter(ch = state.current())) {
  6744. state.lastStringValue += codePointToString(ch);
  6745. state.advance();
  6746. }
  6747. return state.lastStringValue !== ""
  6748. };
  6749. function isUnicodePropertyValueCharacter(ch) {
  6750. return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
  6751. }
  6752. // LoneUnicodePropertyNameOrValue ::
  6753. // UnicodePropertyValueCharacters
  6754. pp$8.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
  6755. return this.regexp_eatUnicodePropertyValue(state)
  6756. };
  6757. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
  6758. pp$8.regexp_eatCharacterClass = function(state) {
  6759. if (state.eat(0x5B /* [ */)) {
  6760. state.eat(0x5E /* ^ */);
  6761. this.regexp_classRanges(state);
  6762. if (state.eat(0x5D /* ] */)) {
  6763. return true
  6764. }
  6765. // Unreachable since it threw "unterminated regular expression" error before.
  6766. state.raise("Unterminated character class");
  6767. }
  6768. return false
  6769. };
  6770. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
  6771. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
  6772. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
  6773. pp$8.regexp_classRanges = function(state) {
  6774. while (this.regexp_eatClassAtom(state)) {
  6775. var left = state.lastIntValue;
  6776. if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
  6777. var right = state.lastIntValue;
  6778. if (state.switchU && (left === -1 || right === -1)) {
  6779. state.raise("Invalid character class");
  6780. }
  6781. if (left !== -1 && right !== -1 && left > right) {
  6782. state.raise("Range out of order in character class");
  6783. }
  6784. }
  6785. }
  6786. };
  6787. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
  6788. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
  6789. pp$8.regexp_eatClassAtom = function(state) {
  6790. var start = state.pos;
  6791. if (state.eat(0x5C /* \ */)) {
  6792. if (this.regexp_eatClassEscape(state)) {
  6793. return true
  6794. }
  6795. if (state.switchU) {
  6796. // Make the same message as V8.
  6797. var ch$1 = state.current();
  6798. if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
  6799. state.raise("Invalid class escape");
  6800. }
  6801. state.raise("Invalid escape");
  6802. }
  6803. state.pos = start;
  6804. }
  6805. var ch = state.current();
  6806. if (ch !== 0x5D /* ] */) {
  6807. state.lastIntValue = ch;
  6808. state.advance();
  6809. return true
  6810. }
  6811. return false
  6812. };
  6813. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
  6814. pp$8.regexp_eatClassEscape = function(state) {
  6815. var start = state.pos;
  6816. if (state.eat(0x62 /* b */)) {
  6817. state.lastIntValue = 0x08; /* <BS> */
  6818. return true
  6819. }
  6820. if (state.switchU && state.eat(0x2D /* - */)) {
  6821. state.lastIntValue = 0x2D; /* - */
  6822. return true
  6823. }
  6824. if (!state.switchU && state.eat(0x63 /* c */)) {
  6825. if (this.regexp_eatClassControlLetter(state)) {
  6826. return true
  6827. }
  6828. state.pos = start;
  6829. }
  6830. return (
  6831. this.regexp_eatCharacterClassEscape(state) ||
  6832. this.regexp_eatCharacterEscape(state)
  6833. )
  6834. };
  6835. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
  6836. pp$8.regexp_eatClassControlLetter = function(state) {
  6837. var ch = state.current();
  6838. if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
  6839. state.lastIntValue = ch % 0x20;
  6840. state.advance();
  6841. return true
  6842. }
  6843. return false
  6844. };
  6845. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  6846. pp$8.regexp_eatHexEscapeSequence = function(state) {
  6847. var start = state.pos;
  6848. if (state.eat(0x78 /* x */)) {
  6849. if (this.regexp_eatFixedHexDigits(state, 2)) {
  6850. return true
  6851. }
  6852. if (state.switchU) {
  6853. state.raise("Invalid escape");
  6854. }
  6855. state.pos = start;
  6856. }
  6857. return false
  6858. };
  6859. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
  6860. pp$8.regexp_eatDecimalDigits = function(state) {
  6861. var start = state.pos;
  6862. var ch = 0;
  6863. state.lastIntValue = 0;
  6864. while (isDecimalDigit(ch = state.current())) {
  6865. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  6866. state.advance();
  6867. }
  6868. return state.pos !== start
  6869. };
  6870. function isDecimalDigit(ch) {
  6871. return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
  6872. }
  6873. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
  6874. pp$8.regexp_eatHexDigits = function(state) {
  6875. var start = state.pos;
  6876. var ch = 0;
  6877. state.lastIntValue = 0;
  6878. while (isHexDigit(ch = state.current())) {
  6879. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  6880. state.advance();
  6881. }
  6882. return state.pos !== start
  6883. };
  6884. function isHexDigit(ch) {
  6885. return (
  6886. (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
  6887. (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
  6888. (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
  6889. )
  6890. }
  6891. function hexToInt(ch) {
  6892. if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
  6893. return 10 + (ch - 0x41 /* A */)
  6894. }
  6895. if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
  6896. return 10 + (ch - 0x61 /* a */)
  6897. }
  6898. return ch - 0x30 /* 0 */
  6899. }
  6900. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
  6901. // Allows only 0-377(octal) i.e. 0-255(decimal).
  6902. pp$8.regexp_eatLegacyOctalEscapeSequence = function(state) {
  6903. if (this.regexp_eatOctalDigit(state)) {
  6904. var n1 = state.lastIntValue;
  6905. if (this.regexp_eatOctalDigit(state)) {
  6906. var n2 = state.lastIntValue;
  6907. if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
  6908. state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
  6909. } else {
  6910. state.lastIntValue = n1 * 8 + n2;
  6911. }
  6912. } else {
  6913. state.lastIntValue = n1;
  6914. }
  6915. return true
  6916. }
  6917. return false
  6918. };
  6919. // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
  6920. pp$8.regexp_eatOctalDigit = function(state) {
  6921. var ch = state.current();
  6922. if (isOctalDigit(ch)) {
  6923. state.lastIntValue = ch - 0x30; /* 0 */
  6924. state.advance();
  6925. return true
  6926. }
  6927. state.lastIntValue = 0;
  6928. return false
  6929. };
  6930. function isOctalDigit(ch) {
  6931. return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
  6932. }
  6933. // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
  6934. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
  6935. // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  6936. pp$8.regexp_eatFixedHexDigits = function(state, length) {
  6937. var start = state.pos;
  6938. state.lastIntValue = 0;
  6939. for (var i = 0; i < length; ++i) {
  6940. var ch = state.current();
  6941. if (!isHexDigit(ch)) {
  6942. state.pos = start;
  6943. return false
  6944. }
  6945. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  6946. state.advance();
  6947. }
  6948. return true
  6949. };
  6950. // Object type used to represent tokens. Note that normally, tokens
  6951. // simply exist as properties on the parser object. This is only
  6952. // used for the onToken callback and the external tokenizer.
  6953. var Token = function Token(p) {
  6954. this.type = p.type;
  6955. this.value = p.value;
  6956. this.start = p.start;
  6957. this.end = p.end;
  6958. if (p.options.locations)
  6959. { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
  6960. if (p.options.ranges)
  6961. { this.range = [p.start, p.end]; }
  6962. };
  6963. // ## Tokenizer
  6964. var pp$9 = Parser.prototype;
  6965. // Move to the next token
  6966. pp$9.next = function(ignoreEscapeSequenceInKeyword) {
  6967. if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
  6968. { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
  6969. if (this.options.onToken)
  6970. { this.options.onToken(new Token(this)); }
  6971. this.lastTokEnd = this.end;
  6972. this.lastTokStart = this.start;
  6973. this.lastTokEndLoc = this.endLoc;
  6974. this.lastTokStartLoc = this.startLoc;
  6975. this.nextToken();
  6976. };
  6977. pp$9.getToken = function() {
  6978. this.next();
  6979. return new Token(this)
  6980. };
  6981. // If we're in an ES6 environment, make parsers iterable
  6982. if (typeof Symbol !== "undefined")
  6983. { pp$9[Symbol.iterator] = function() {
  6984. var this$1$1 = this;
  6985. return {
  6986. next: function () {
  6987. var token = this$1$1.getToken();
  6988. return {
  6989. done: token.type === types.eof,
  6990. value: token
  6991. }
  6992. }
  6993. }
  6994. }; }
  6995. // Toggle strict mode. Re-reads the next number or string to please
  6996. // pedantic tests (`"use strict"; 010;` should fail).
  6997. pp$9.curContext = function() {
  6998. return this.context[this.context.length - 1]
  6999. };
  7000. // Read a single token, updating the parser object's token-related
  7001. // properties.
  7002. pp$9.nextToken = function() {
  7003. var curContext = this.curContext();
  7004. if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
  7005. this.start = this.pos;
  7006. if (this.options.locations) { this.startLoc = this.curPosition(); }
  7007. if (this.pos >= this.input.length) { return this.finishToken(types.eof) }
  7008. if (curContext.override) { return curContext.override(this) }
  7009. else { this.readToken(this.fullCharCodeAtPos()); }
  7010. };
  7011. pp$9.readToken = function(code) {
  7012. // Identifier or keyword. '\uXXXX' sequences are allowed in
  7013. // identifiers, so '\' also dispatches to that.
  7014. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
  7015. { return this.readWord() }
  7016. return this.getTokenFromCode(code)
  7017. };
  7018. pp$9.fullCharCodeAtPos = function() {
  7019. var code = this.input.charCodeAt(this.pos);
  7020. if (code <= 0xd7ff || code >= 0xdc00) { return code }
  7021. var next = this.input.charCodeAt(this.pos + 1);
  7022. return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
  7023. };
  7024. pp$9.skipBlockComment = function() {
  7025. var startLoc = this.options.onComment && this.curPosition();
  7026. var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
  7027. if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
  7028. this.pos = end + 2;
  7029. if (this.options.locations) {
  7030. lineBreakG.lastIndex = start;
  7031. var match;
  7032. while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
  7033. ++this.curLine;
  7034. this.lineStart = match.index + match[0].length;
  7035. }
  7036. }
  7037. if (this.options.onComment)
  7038. { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
  7039. startLoc, this.curPosition()); }
  7040. };
  7041. pp$9.skipLineComment = function(startSkip) {
  7042. var start = this.pos;
  7043. var startLoc = this.options.onComment && this.curPosition();
  7044. var ch = this.input.charCodeAt(this.pos += startSkip);
  7045. while (this.pos < this.input.length && !isNewLine(ch)) {
  7046. ch = this.input.charCodeAt(++this.pos);
  7047. }
  7048. if (this.options.onComment)
  7049. { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
  7050. startLoc, this.curPosition()); }
  7051. };
  7052. // Called at the start of the parse and after every token. Skips
  7053. // whitespace and comments, and.
  7054. pp$9.skipSpace = function() {
  7055. loop: while (this.pos < this.input.length) {
  7056. var ch = this.input.charCodeAt(this.pos);
  7057. switch (ch) {
  7058. case 32: case 160: // ' '
  7059. ++this.pos;
  7060. break
  7061. case 13:
  7062. if (this.input.charCodeAt(this.pos + 1) === 10) {
  7063. ++this.pos;
  7064. }
  7065. case 10: case 8232: case 8233:
  7066. ++this.pos;
  7067. if (this.options.locations) {
  7068. ++this.curLine;
  7069. this.lineStart = this.pos;
  7070. }
  7071. break
  7072. case 47: // '/'
  7073. switch (this.input.charCodeAt(this.pos + 1)) {
  7074. case 42: // '*'
  7075. this.skipBlockComment();
  7076. break
  7077. case 47:
  7078. this.skipLineComment(2);
  7079. break
  7080. default:
  7081. break loop
  7082. }
  7083. break
  7084. default:
  7085. if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  7086. ++this.pos;
  7087. } else {
  7088. break loop
  7089. }
  7090. }
  7091. }
  7092. };
  7093. // Called at the end of every token. Sets `end`, `val`, and
  7094. // maintains `context` and `exprAllowed`, and skips the space after
  7095. // the token, so that the next one's `start` will point at the
  7096. // right position.
  7097. pp$9.finishToken = function(type, val) {
  7098. this.end = this.pos;
  7099. if (this.options.locations) { this.endLoc = this.curPosition(); }
  7100. var prevType = this.type;
  7101. this.type = type;
  7102. this.value = val;
  7103. this.updateContext(prevType);
  7104. };
  7105. // ### Token reading
  7106. // This is the function that is called to fetch the next token. It
  7107. // is somewhat obscure, because it works in character codes rather
  7108. // than characters, and because operator parsing has been inlined
  7109. // into it.
  7110. //
  7111. // All in the name of speed.
  7112. //
  7113. pp$9.readToken_dot = function() {
  7114. var next = this.input.charCodeAt(this.pos + 1);
  7115. if (next >= 48 && next <= 57) { return this.readNumber(true) }
  7116. var next2 = this.input.charCodeAt(this.pos + 2);
  7117. if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
  7118. this.pos += 3;
  7119. return this.finishToken(types.ellipsis)
  7120. } else {
  7121. ++this.pos;
  7122. return this.finishToken(types.dot)
  7123. }
  7124. };
  7125. pp$9.readToken_slash = function() { // '/'
  7126. var next = this.input.charCodeAt(this.pos + 1);
  7127. if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
  7128. if (next === 61) { return this.finishOp(types.assign, 2) }
  7129. return this.finishOp(types.slash, 1)
  7130. };
  7131. pp$9.readToken_mult_modulo_exp = function(code) { // '%*'
  7132. var next = this.input.charCodeAt(this.pos + 1);
  7133. var size = 1;
  7134. var tokentype = code === 42 ? types.star : types.modulo;
  7135. // exponentiation operator ** and **=
  7136. if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
  7137. ++size;
  7138. tokentype = types.starstar;
  7139. next = this.input.charCodeAt(this.pos + 2);
  7140. }
  7141. if (next === 61) { return this.finishOp(types.assign, size + 1) }
  7142. return this.finishOp(tokentype, size)
  7143. };
  7144. pp$9.readToken_pipe_amp = function(code) { // '|&'
  7145. var next = this.input.charCodeAt(this.pos + 1);
  7146. if (next === code) {
  7147. if (this.options.ecmaVersion >= 12) {
  7148. var next2 = this.input.charCodeAt(this.pos + 2);
  7149. if (next2 === 61) { return this.finishOp(types.assign, 3) }
  7150. }
  7151. return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2)
  7152. }
  7153. if (next === 61) { return this.finishOp(types.assign, 2) }
  7154. return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1)
  7155. };
  7156. pp$9.readToken_caret = function() { // '^'
  7157. var next = this.input.charCodeAt(this.pos + 1);
  7158. if (next === 61) { return this.finishOp(types.assign, 2) }
  7159. return this.finishOp(types.bitwiseXOR, 1)
  7160. };
  7161. pp$9.readToken_plus_min = function(code) { // '+-'
  7162. var next = this.input.charCodeAt(this.pos + 1);
  7163. if (next === code) {
  7164. if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
  7165. (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
  7166. // A `-->` line comment
  7167. this.skipLineComment(3);
  7168. this.skipSpace();
  7169. return this.nextToken()
  7170. }
  7171. return this.finishOp(types.incDec, 2)
  7172. }
  7173. if (next === 61) { return this.finishOp(types.assign, 2) }
  7174. return this.finishOp(types.plusMin, 1)
  7175. };
  7176. pp$9.readToken_lt_gt = function(code) { // '<>'
  7177. var next = this.input.charCodeAt(this.pos + 1);
  7178. var size = 1;
  7179. if (next === code) {
  7180. size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
  7181. if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
  7182. return this.finishOp(types.bitShift, size)
  7183. }
  7184. if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
  7185. this.input.charCodeAt(this.pos + 3) === 45) {
  7186. // `<!--`, an XML-style comment that should be interpreted as a line comment
  7187. this.skipLineComment(4);
  7188. this.skipSpace();
  7189. return this.nextToken()
  7190. }
  7191. if (next === 61) { size = 2; }
  7192. return this.finishOp(types.relational, size)
  7193. };
  7194. pp$9.readToken_eq_excl = function(code) { // '=!'
  7195. var next = this.input.charCodeAt(this.pos + 1);
  7196. if (next === 61) { return this.finishOp(types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
  7197. if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
  7198. this.pos += 2;
  7199. return this.finishToken(types.arrow)
  7200. }
  7201. return this.finishOp(code === 61 ? types.eq : types.prefix, 1)
  7202. };
  7203. pp$9.readToken_question = function() { // '?'
  7204. var ecmaVersion = this.options.ecmaVersion;
  7205. if (ecmaVersion >= 11) {
  7206. var next = this.input.charCodeAt(this.pos + 1);
  7207. if (next === 46) {
  7208. var next2 = this.input.charCodeAt(this.pos + 2);
  7209. if (next2 < 48 || next2 > 57) { return this.finishOp(types.questionDot, 2) }
  7210. }
  7211. if (next === 63) {
  7212. if (ecmaVersion >= 12) {
  7213. var next2$1 = this.input.charCodeAt(this.pos + 2);
  7214. if (next2$1 === 61) { return this.finishOp(types.assign, 3) }
  7215. }
  7216. return this.finishOp(types.coalesce, 2)
  7217. }
  7218. }
  7219. return this.finishOp(types.question, 1)
  7220. };
  7221. pp$9.readToken_numberSign = function() { // '#'
  7222. var ecmaVersion = this.options.ecmaVersion;
  7223. var code = 35; // '#'
  7224. if (ecmaVersion >= 13) {
  7225. ++this.pos;
  7226. code = this.fullCharCodeAtPos();
  7227. if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
  7228. return this.finishToken(types.privateId, this.readWord1())
  7229. }
  7230. }
  7231. this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
  7232. };
  7233. pp$9.getTokenFromCode = function(code) {
  7234. switch (code) {
  7235. // The interpretation of a dot depends on whether it is followed
  7236. // by a digit or another two dots.
  7237. case 46: // '.'
  7238. return this.readToken_dot()
  7239. // Punctuation tokens.
  7240. case 40: ++this.pos; return this.finishToken(types.parenL)
  7241. case 41: ++this.pos; return this.finishToken(types.parenR)
  7242. case 59: ++this.pos; return this.finishToken(types.semi)
  7243. case 44: ++this.pos; return this.finishToken(types.comma)
  7244. case 91: ++this.pos; return this.finishToken(types.bracketL)
  7245. case 93: ++this.pos; return this.finishToken(types.bracketR)
  7246. case 123: ++this.pos; return this.finishToken(types.braceL)
  7247. case 125: ++this.pos; return this.finishToken(types.braceR)
  7248. case 58: ++this.pos; return this.finishToken(types.colon)
  7249. case 96: // '`'
  7250. if (this.options.ecmaVersion < 6) { break }
  7251. ++this.pos;
  7252. return this.finishToken(types.backQuote)
  7253. case 48: // '0'
  7254. var next = this.input.charCodeAt(this.pos + 1);
  7255. if (next === 120 || next === 88) { return this.readRadixNumber(16) } // '0x', '0X' - hex number
  7256. if (this.options.ecmaVersion >= 6) {
  7257. if (next === 111 || next === 79) { return this.readRadixNumber(8) } // '0o', '0O' - octal number
  7258. if (next === 98 || next === 66) { return this.readRadixNumber(2) } // '0b', '0B' - binary number
  7259. }
  7260. // Anything else beginning with a digit is an integer, octal
  7261. // number, or float.
  7262. case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
  7263. return this.readNumber(false)
  7264. // Quotes produce strings.
  7265. case 34: case 39: // '"', "'"
  7266. return this.readString(code)
  7267. // Operators are parsed inline in tiny state machines. '=' (61) is
  7268. // often referred to. `finishOp` simply skips the amount of
  7269. // characters it is given as second argument, and returns a token
  7270. // of the type given by its first argument.
  7271. case 47: // '/'
  7272. return this.readToken_slash()
  7273. case 37: case 42: // '%*'
  7274. return this.readToken_mult_modulo_exp(code)
  7275. case 124: case 38: // '|&'
  7276. return this.readToken_pipe_amp(code)
  7277. case 94: // '^'
  7278. return this.readToken_caret()
  7279. case 43: case 45: // '+-'
  7280. return this.readToken_plus_min(code)
  7281. case 60: case 62: // '<>'
  7282. return this.readToken_lt_gt(code)
  7283. case 61: case 33: // '=!'
  7284. return this.readToken_eq_excl(code)
  7285. case 63: // '?'
  7286. return this.readToken_question()
  7287. case 126: // '~'
  7288. return this.finishOp(types.prefix, 1)
  7289. case 35: // '#'
  7290. return this.readToken_numberSign()
  7291. }
  7292. this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
  7293. };
  7294. pp$9.finishOp = function(type, size) {
  7295. var str = this.input.slice(this.pos, this.pos + size);
  7296. this.pos += size;
  7297. return this.finishToken(type, str)
  7298. };
  7299. pp$9.readRegexp = function() {
  7300. var escaped, inClass, start = this.pos;
  7301. for (;;) {
  7302. if (this.pos >= this.input.length) { this.raise(start, "Unterminated regular expression"); }
  7303. var ch = this.input.charAt(this.pos);
  7304. if (lineBreak.test(ch)) { this.raise(start, "Unterminated regular expression"); }
  7305. if (!escaped) {
  7306. if (ch === "[") { inClass = true; }
  7307. else if (ch === "]" && inClass) { inClass = false; }
  7308. else if (ch === "/" && !inClass) { break }
  7309. escaped = ch === "\\";
  7310. } else { escaped = false; }
  7311. ++this.pos;
  7312. }
  7313. var pattern = this.input.slice(start, this.pos);
  7314. ++this.pos;
  7315. var flagsStart = this.pos;
  7316. var flags = this.readWord1();
  7317. if (this.containsEsc) { this.unexpected(flagsStart); }
  7318. // Validate pattern
  7319. var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
  7320. state.reset(start, pattern, flags);
  7321. this.validateRegExpFlags(state);
  7322. this.validateRegExpPattern(state);
  7323. // Create Literal#value property value.
  7324. var value = null;
  7325. try {
  7326. value = new RegExp(pattern, flags);
  7327. } catch (e) {
  7328. // ESTree requires null if it failed to instantiate RegExp object.
  7329. // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
  7330. }
  7331. return this.finishToken(types.regexp, {pattern: pattern, flags: flags, value: value})
  7332. };
  7333. // Read an integer in the given radix. Return null if zero digits
  7334. // were read, the integer value otherwise. When `len` is given, this
  7335. // will return `null` unless the integer has exactly `len` digits.
  7336. pp$9.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
  7337. // `len` is used for character escape sequences. In that case, disallow separators.
  7338. var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined;
  7339. // `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
  7340. // and isn't fraction part nor exponent part. In that case, if the first digit
  7341. // is zero then disallow separators.
  7342. var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
  7343. var start = this.pos, total = 0, lastCode = 0;
  7344. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
  7345. var code = this.input.charCodeAt(this.pos), val = (void 0);
  7346. if (allowSeparators && code === 95) {
  7347. if (isLegacyOctalNumericLiteral) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"); }
  7348. if (lastCode === 95) { this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"); }
  7349. if (i === 0) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"); }
  7350. lastCode = code;
  7351. continue
  7352. }
  7353. if (code >= 97) { val = code - 97 + 10; } // a
  7354. else if (code >= 65) { val = code - 65 + 10; } // A
  7355. else if (code >= 48 && code <= 57) { val = code - 48; } // 0-9
  7356. else { val = Infinity; }
  7357. if (val >= radix) { break }
  7358. lastCode = code;
  7359. total = total * radix + val;
  7360. }
  7361. if (allowSeparators && lastCode === 95) { this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"); }
  7362. if (this.pos === start || len != null && this.pos - start !== len) { return null }
  7363. return total
  7364. };
  7365. function stringToNumber(str, isLegacyOctalNumericLiteral) {
  7366. if (isLegacyOctalNumericLiteral) {
  7367. return parseInt(str, 8)
  7368. }
  7369. // `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
  7370. return parseFloat(str.replace(/_/g, ""))
  7371. }
  7372. function stringToBigInt(str) {
  7373. if (typeof BigInt !== "function") {
  7374. return null
  7375. }
  7376. // `BigInt(value)` throws syntax error if the string contains numeric separators.
  7377. return BigInt(str.replace(/_/g, ""))
  7378. }
  7379. pp$9.readRadixNumber = function(radix) {
  7380. var start = this.pos;
  7381. this.pos += 2; // 0x
  7382. var val = this.readInt(radix);
  7383. if (val == null) { this.raise(this.start + 2, "Expected number in radix " + radix); }
  7384. if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
  7385. val = stringToBigInt(this.input.slice(start, this.pos));
  7386. ++this.pos;
  7387. } else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  7388. return this.finishToken(types.num, val)
  7389. };
  7390. // Read an integer, octal integer, or floating-point number.
  7391. pp$9.readNumber = function(startsWithDot) {
  7392. var start = this.pos;
  7393. if (!startsWithDot && this.readInt(10, undefined, true) === null) { this.raise(start, "Invalid number"); }
  7394. var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  7395. if (octal && this.strict) { this.raise(start, "Invalid number"); }
  7396. var next = this.input.charCodeAt(this.pos);
  7397. if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
  7398. var val$1 = stringToBigInt(this.input.slice(start, this.pos));
  7399. ++this.pos;
  7400. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  7401. return this.finishToken(types.num, val$1)
  7402. }
  7403. if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
  7404. if (next === 46 && !octal) { // '.'
  7405. ++this.pos;
  7406. this.readInt(10);
  7407. next = this.input.charCodeAt(this.pos);
  7408. }
  7409. if ((next === 69 || next === 101) && !octal) { // 'eE'
  7410. next = this.input.charCodeAt(++this.pos);
  7411. if (next === 43 || next === 45) { ++this.pos; } // '+-'
  7412. if (this.readInt(10) === null) { this.raise(start, "Invalid number"); }
  7413. }
  7414. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  7415. var val = stringToNumber(this.input.slice(start, this.pos), octal);
  7416. return this.finishToken(types.num, val)
  7417. };
  7418. // Read a string value, interpreting backslash-escapes.
  7419. pp$9.readCodePoint = function() {
  7420. var ch = this.input.charCodeAt(this.pos), code;
  7421. if (ch === 123) { // '{'
  7422. if (this.options.ecmaVersion < 6) { this.unexpected(); }
  7423. var codePos = ++this.pos;
  7424. code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
  7425. ++this.pos;
  7426. if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
  7427. } else {
  7428. code = this.readHexChar(4);
  7429. }
  7430. return code
  7431. };
  7432. function codePointToString$1(code) {
  7433. // UTF-16 Decoding
  7434. if (code <= 0xFFFF) { return String.fromCharCode(code) }
  7435. code -= 0x10000;
  7436. return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
  7437. }
  7438. pp$9.readString = function(quote) {
  7439. var out = "", chunkStart = ++this.pos;
  7440. for (;;) {
  7441. if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated string constant"); }
  7442. var ch = this.input.charCodeAt(this.pos);
  7443. if (ch === quote) { break }
  7444. if (ch === 92) { // '\'
  7445. out += this.input.slice(chunkStart, this.pos);
  7446. out += this.readEscapedChar(false);
  7447. chunkStart = this.pos;
  7448. } else {
  7449. if (isNewLine(ch, this.options.ecmaVersion >= 10)) { this.raise(this.start, "Unterminated string constant"); }
  7450. ++this.pos;
  7451. }
  7452. }
  7453. out += this.input.slice(chunkStart, this.pos++);
  7454. return this.finishToken(types.string, out)
  7455. };
  7456. // Reads template string tokens.
  7457. var INVALID_TEMPLATE_ESCAPE_ERROR = {};
  7458. pp$9.tryReadTemplateToken = function() {
  7459. this.inTemplateElement = true;
  7460. try {
  7461. this.readTmplToken();
  7462. } catch (err) {
  7463. if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
  7464. this.readInvalidTemplateToken();
  7465. } else {
  7466. throw err
  7467. }
  7468. }
  7469. this.inTemplateElement = false;
  7470. };
  7471. pp$9.invalidStringToken = function(position, message) {
  7472. if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
  7473. throw INVALID_TEMPLATE_ESCAPE_ERROR
  7474. } else {
  7475. this.raise(position, message);
  7476. }
  7477. };
  7478. pp$9.readTmplToken = function() {
  7479. var out = "", chunkStart = this.pos;
  7480. for (;;) {
  7481. if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated template"); }
  7482. var ch = this.input.charCodeAt(this.pos);
  7483. if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
  7484. if (this.pos === this.start && (this.type === types.template || this.type === types.invalidTemplate)) {
  7485. if (ch === 36) {
  7486. this.pos += 2;
  7487. return this.finishToken(types.dollarBraceL)
  7488. } else {
  7489. ++this.pos;
  7490. return this.finishToken(types.backQuote)
  7491. }
  7492. }
  7493. out += this.input.slice(chunkStart, this.pos);
  7494. return this.finishToken(types.template, out)
  7495. }
  7496. if (ch === 92) { // '\'
  7497. out += this.input.slice(chunkStart, this.pos);
  7498. out += this.readEscapedChar(true);
  7499. chunkStart = this.pos;
  7500. } else if (isNewLine(ch)) {
  7501. out += this.input.slice(chunkStart, this.pos);
  7502. ++this.pos;
  7503. switch (ch) {
  7504. case 13:
  7505. if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; }
  7506. case 10:
  7507. out += "\n";
  7508. break
  7509. default:
  7510. out += String.fromCharCode(ch);
  7511. break
  7512. }
  7513. if (this.options.locations) {
  7514. ++this.curLine;
  7515. this.lineStart = this.pos;
  7516. }
  7517. chunkStart = this.pos;
  7518. } else {
  7519. ++this.pos;
  7520. }
  7521. }
  7522. };
  7523. // Reads a template token to search for the end, without validating any escape sequences
  7524. pp$9.readInvalidTemplateToken = function() {
  7525. for (; this.pos < this.input.length; this.pos++) {
  7526. switch (this.input[this.pos]) {
  7527. case "\\":
  7528. ++this.pos;
  7529. break
  7530. case "$":
  7531. if (this.input[this.pos + 1] !== "{") {
  7532. break
  7533. }
  7534. // falls through
  7535. case "`":
  7536. return this.finishToken(types.invalidTemplate, this.input.slice(this.start, this.pos))
  7537. // no default
  7538. }
  7539. }
  7540. this.raise(this.start, "Unterminated template");
  7541. };
  7542. // Used to read escaped characters
  7543. pp$9.readEscapedChar = function(inTemplate) {
  7544. var ch = this.input.charCodeAt(++this.pos);
  7545. ++this.pos;
  7546. switch (ch) {
  7547. case 110: return "\n" // 'n' -> '\n'
  7548. case 114: return "\r" // 'r' -> '\r'
  7549. case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
  7550. case 117: return codePointToString$1(this.readCodePoint()) // 'u'
  7551. case 116: return "\t" // 't' -> '\t'
  7552. case 98: return "\b" // 'b' -> '\b'
  7553. case 118: return "\u000b" // 'v' -> '\u000b'
  7554. case 102: return "\f" // 'f' -> '\f'
  7555. case 13: if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; } // '\r\n'
  7556. case 10: // ' \n'
  7557. if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
  7558. return ""
  7559. case 56:
  7560. case 57:
  7561. if (this.strict) {
  7562. this.invalidStringToken(
  7563. this.pos - 1,
  7564. "Invalid escape sequence"
  7565. );
  7566. }
  7567. if (inTemplate) {
  7568. var codePos = this.pos - 1;
  7569. this.invalidStringToken(
  7570. codePos,
  7571. "Invalid escape sequence in template string"
  7572. );
  7573. return null
  7574. }
  7575. default:
  7576. if (ch >= 48 && ch <= 55) {
  7577. var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
  7578. var octal = parseInt(octalStr, 8);
  7579. if (octal > 255) {
  7580. octalStr = octalStr.slice(0, -1);
  7581. octal = parseInt(octalStr, 8);
  7582. }
  7583. this.pos += octalStr.length - 1;
  7584. ch = this.input.charCodeAt(this.pos);
  7585. if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
  7586. this.invalidStringToken(
  7587. this.pos - 1 - octalStr.length,
  7588. inTemplate
  7589. ? "Octal literal in template string"
  7590. : "Octal literal in strict mode"
  7591. );
  7592. }
  7593. return String.fromCharCode(octal)
  7594. }
  7595. if (isNewLine(ch)) {
  7596. // Unicode new line characters after \ get removed from output in both
  7597. // template literals and strings
  7598. return ""
  7599. }
  7600. return String.fromCharCode(ch)
  7601. }
  7602. };
  7603. // Used to read character escape sequences ('\x', '\u', '\U').
  7604. pp$9.readHexChar = function(len) {
  7605. var codePos = this.pos;
  7606. var n = this.readInt(16, len);
  7607. if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
  7608. return n
  7609. };
  7610. // Read an identifier, and return it as a string. Sets `this.containsEsc`
  7611. // to whether the word contained a '\u' escape.
  7612. //
  7613. // Incrementally adds only escaped chars, adding other chunks as-is
  7614. // as a micro-optimization.
  7615. pp$9.readWord1 = function() {
  7616. this.containsEsc = false;
  7617. var word = "", first = true, chunkStart = this.pos;
  7618. var astral = this.options.ecmaVersion >= 6;
  7619. while (this.pos < this.input.length) {
  7620. var ch = this.fullCharCodeAtPos();
  7621. if (isIdentifierChar(ch, astral)) {
  7622. this.pos += ch <= 0xffff ? 1 : 2;
  7623. } else if (ch === 92) { // "\"
  7624. this.containsEsc = true;
  7625. word += this.input.slice(chunkStart, this.pos);
  7626. var escStart = this.pos;
  7627. if (this.input.charCodeAt(++this.pos) !== 117) // "u"
  7628. { this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"); }
  7629. ++this.pos;
  7630. var esc = this.readCodePoint();
  7631. if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
  7632. { this.invalidStringToken(escStart, "Invalid Unicode escape"); }
  7633. word += codePointToString$1(esc);
  7634. chunkStart = this.pos;
  7635. } else {
  7636. break
  7637. }
  7638. first = false;
  7639. }
  7640. return word + this.input.slice(chunkStart, this.pos)
  7641. };
  7642. // Read an identifier or keyword token. Will check for reserved
  7643. // words when necessary.
  7644. pp$9.readWord = function() {
  7645. var word = this.readWord1();
  7646. var type = types.name;
  7647. if (this.keywords.test(word)) {
  7648. type = keywords$1[word];
  7649. }
  7650. return this.finishToken(type, word)
  7651. };
  7652. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
  7653. var version = "8.4.1";
  7654. Parser.acorn = {
  7655. Parser: Parser,
  7656. version: version,
  7657. defaultOptions: defaultOptions,
  7658. Position: Position,
  7659. SourceLocation: SourceLocation,
  7660. getLineInfo: getLineInfo,
  7661. Node: Node,
  7662. TokenType: TokenType,
  7663. tokTypes: types,
  7664. keywordTypes: keywords$1,
  7665. TokContext: TokContext,
  7666. tokContexts: types$1,
  7667. isIdentifierChar: isIdentifierChar,
  7668. isIdentifierStart: isIdentifierStart,
  7669. Token: Token,
  7670. isNewLine: isNewLine,
  7671. lineBreak: lineBreak,
  7672. lineBreakG: lineBreakG,
  7673. nonASCIIwhitespace: nonASCIIwhitespace
  7674. };
  7675. // The main exported interface (under `self.acorn` when in the
  7676. // browser) is a `parse` function that takes a code string and
  7677. // returns an abstract syntax tree as specified by [Mozilla parser
  7678. // API][api].
  7679. //
  7680. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  7681. function parse(input, options) {
  7682. return Parser.parse(input, options)
  7683. }
  7684. // This function tries to parse a single expression at a given
  7685. // offset in a string. Useful for parsing mixed-language formats
  7686. // that embed JavaScript expressions.
  7687. function parseExpressionAt(input, pos, options) {
  7688. return Parser.parseExpressionAt(input, pos, options)
  7689. }
  7690. // Acorn is organized as a tokenizer and a recursive-descent parser.
  7691. // The `tokenizer` export provides an interface to the tokenizer.
  7692. function tokenizer(input, options) {
  7693. return Parser.tokenizer(input, options)
  7694. }
  7695. exports.Node = Node;
  7696. exports.Parser = Parser;
  7697. exports.Position = Position;
  7698. exports.SourceLocation = SourceLocation;
  7699. exports.TokContext = TokContext;
  7700. exports.Token = Token;
  7701. exports.TokenType = TokenType;
  7702. exports.defaultOptions = defaultOptions;
  7703. exports.getLineInfo = getLineInfo;
  7704. exports.isIdentifierChar = isIdentifierChar;
  7705. exports.isIdentifierStart = isIdentifierStart;
  7706. exports.isNewLine = isNewLine;
  7707. exports.keywordTypes = keywords$1;
  7708. exports.lineBreak = lineBreak;
  7709. exports.lineBreakG = lineBreakG;
  7710. exports.nonASCIIwhitespace = nonASCIIwhitespace;
  7711. exports.parse = parse;
  7712. exports.parseExpressionAt = parseExpressionAt;
  7713. exports.tokContexts = types$1;
  7714. exports.tokTypes = types;
  7715. exports.tokenizer = tokenizer;
  7716. exports.version = version;
  7717. Object.defineProperty(exports, '__esModule', { value: true });
  7718. })));
  7719. }(acorn, acorn.exports));
  7720. (function (module, exports) {
  7721. (function (global, factory) {
  7722. factory(exports, sourceMap) ;
  7723. }(commonjsGlobal, (function (exports, MOZ_SourceMap) {
  7724. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  7725. var MOZ_SourceMap__default = /*#__PURE__*/_interopDefaultLegacy(MOZ_SourceMap);
  7726. /***********************************************************************
  7727. A JavaScript tokenizer / parser / beautifier / compressor.
  7728. https://github.com/mishoo/UglifyJS2
  7729. -------------------------------- (C) ---------------------------------
  7730. Author: Mihai Bazon
  7731. <mihai.bazon@gmail.com>
  7732. http://mihai.bazon.net/blog
  7733. Distributed under the BSD license:
  7734. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  7735. Redistribution and use in source and binary forms, with or without
  7736. modification, are permitted provided that the following conditions
  7737. are met:
  7738. * Redistributions of source code must retain the above
  7739. copyright notice, this list of conditions and the following
  7740. disclaimer.
  7741. * Redistributions in binary form must reproduce the above
  7742. copyright notice, this list of conditions and the following
  7743. disclaimer in the documentation and/or other materials
  7744. provided with the distribution.
  7745. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  7746. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7747. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  7748. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  7749. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  7750. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  7751. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  7752. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7753. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  7754. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  7755. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  7756. SUCH DAMAGE.
  7757. ***********************************************************************/
  7758. function characters(str) {
  7759. return str.split("");
  7760. }
  7761. function member(name, array) {
  7762. return array.includes(name);
  7763. }
  7764. class DefaultsError extends Error {
  7765. constructor(msg, defs) {
  7766. super();
  7767. this.name = "DefaultsError";
  7768. this.message = msg;
  7769. this.defs = defs;
  7770. }
  7771. }
  7772. function defaults(args, defs, croak) {
  7773. if (args === true) {
  7774. args = {};
  7775. } else if (args != null && typeof args === "object") {
  7776. args = {...args};
  7777. }
  7778. const ret = args || {};
  7779. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  7780. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  7781. }
  7782. for (const i in defs) if (HOP(defs, i)) {
  7783. if (!args || !HOP(args, i)) {
  7784. ret[i] = defs[i];
  7785. } else if (i === "ecma") {
  7786. let ecma = args[i] | 0;
  7787. if (ecma > 5 && ecma < 2015) ecma += 2009;
  7788. ret[i] = ecma;
  7789. } else {
  7790. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  7791. }
  7792. }
  7793. return ret;
  7794. }
  7795. function noop() {}
  7796. function return_false() { return false; }
  7797. function return_true() { return true; }
  7798. function return_this() { return this; }
  7799. function return_null() { return null; }
  7800. var MAP = (function() {
  7801. function MAP(a, f, backwards) {
  7802. var ret = [], top = [], i;
  7803. function doit() {
  7804. var val = f(a[i], i);
  7805. var is_last = val instanceof Last;
  7806. if (is_last) val = val.v;
  7807. if (val instanceof AtTop) {
  7808. val = val.v;
  7809. if (val instanceof Splice) {
  7810. top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
  7811. } else {
  7812. top.push(val);
  7813. }
  7814. } else if (val !== skip) {
  7815. if (val instanceof Splice) {
  7816. ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
  7817. } else {
  7818. ret.push(val);
  7819. }
  7820. }
  7821. return is_last;
  7822. }
  7823. if (Array.isArray(a)) {
  7824. if (backwards) {
  7825. for (i = a.length; --i >= 0;) if (doit()) break;
  7826. ret.reverse();
  7827. top.reverse();
  7828. } else {
  7829. for (i = 0; i < a.length; ++i) if (doit()) break;
  7830. }
  7831. } else {
  7832. for (i in a) if (HOP(a, i)) if (doit()) break;
  7833. }
  7834. return top.concat(ret);
  7835. }
  7836. MAP.at_top = function(val) { return new AtTop(val); };
  7837. MAP.splice = function(val) { return new Splice(val); };
  7838. MAP.last = function(val) { return new Last(val); };
  7839. var skip = MAP.skip = {};
  7840. function AtTop(val) { this.v = val; }
  7841. function Splice(val) { this.v = val; }
  7842. function Last(val) { this.v = val; }
  7843. return MAP;
  7844. })();
  7845. function make_node(ctor, orig, props) {
  7846. if (!props) props = {};
  7847. if (orig) {
  7848. if (!props.start) props.start = orig.start;
  7849. if (!props.end) props.end = orig.end;
  7850. }
  7851. return new ctor(props);
  7852. }
  7853. function push_uniq(array, el) {
  7854. if (!array.includes(el))
  7855. array.push(el);
  7856. }
  7857. function string_template(text, props) {
  7858. return text.replace(/{(.+?)}/g, function(str, p) {
  7859. return props && props[p];
  7860. });
  7861. }
  7862. function remove(array, el) {
  7863. for (var i = array.length; --i >= 0;) {
  7864. if (array[i] === el) array.splice(i, 1);
  7865. }
  7866. }
  7867. function mergeSort(array, cmp) {
  7868. if (array.length < 2) return array.slice();
  7869. function merge(a, b) {
  7870. var r = [], ai = 0, bi = 0, i = 0;
  7871. while (ai < a.length && bi < b.length) {
  7872. cmp(a[ai], b[bi]) <= 0
  7873. ? r[i++] = a[ai++]
  7874. : r[i++] = b[bi++];
  7875. }
  7876. if (ai < a.length) r.push.apply(r, a.slice(ai));
  7877. if (bi < b.length) r.push.apply(r, b.slice(bi));
  7878. return r;
  7879. }
  7880. function _ms(a) {
  7881. if (a.length <= 1)
  7882. return a;
  7883. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  7884. left = _ms(left);
  7885. right = _ms(right);
  7886. return merge(left, right);
  7887. }
  7888. return _ms(array);
  7889. }
  7890. function makePredicate(words) {
  7891. if (!Array.isArray(words)) words = words.split(" ");
  7892. return new Set(words.sort());
  7893. }
  7894. function map_add(map, key, value) {
  7895. if (map.has(key)) {
  7896. map.get(key).push(value);
  7897. } else {
  7898. map.set(key, [ value ]);
  7899. }
  7900. }
  7901. function map_from_object(obj) {
  7902. var map = new Map();
  7903. for (var key in obj) {
  7904. if (HOP(obj, key) && key.charAt(0) === "$") {
  7905. map.set(key.substr(1), obj[key]);
  7906. }
  7907. }
  7908. return map;
  7909. }
  7910. function map_to_object(map) {
  7911. var obj = Object.create(null);
  7912. map.forEach(function (value, key) {
  7913. obj["$" + key] = value;
  7914. });
  7915. return obj;
  7916. }
  7917. function HOP(obj, prop) {
  7918. return Object.prototype.hasOwnProperty.call(obj, prop);
  7919. }
  7920. function keep_name(keep_setting, name) {
  7921. return keep_setting === true
  7922. || (keep_setting instanceof RegExp && keep_setting.test(name));
  7923. }
  7924. var lineTerminatorEscape = {
  7925. "\0": "0",
  7926. "\n": "n",
  7927. "\r": "r",
  7928. "\u2028": "u2028",
  7929. "\u2029": "u2029",
  7930. };
  7931. function regexp_source_fix(source) {
  7932. // V8 does not escape line terminators in regexp patterns in node 12
  7933. // We'll also remove literal \0
  7934. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  7935. var escaped = source[offset - 1] == "\\"
  7936. && (source[offset - 2] != "\\"
  7937. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  7938. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  7939. });
  7940. }
  7941. const all_flags = "gimuy";
  7942. function sort_regexp_flags(flags) {
  7943. const existing_flags = new Set(flags.split(""));
  7944. let out = "";
  7945. for (const flag of all_flags) {
  7946. if (existing_flags.has(flag)) {
  7947. out += flag;
  7948. existing_flags.delete(flag);
  7949. }
  7950. }
  7951. if (existing_flags.size) {
  7952. // Flags Terser doesn't know about
  7953. existing_flags.forEach(flag => { out += flag; });
  7954. }
  7955. return out;
  7956. }
  7957. function has_annotation(node, annotation) {
  7958. return node._annotations & annotation;
  7959. }
  7960. function set_annotation(node, annotation) {
  7961. node._annotations |= annotation;
  7962. }
  7963. /***********************************************************************
  7964. A JavaScript tokenizer / parser / beautifier / compressor.
  7965. https://github.com/mishoo/UglifyJS2
  7966. -------------------------------- (C) ---------------------------------
  7967. Author: Mihai Bazon
  7968. <mihai.bazon@gmail.com>
  7969. http://mihai.bazon.net/blog
  7970. Distributed under the BSD license:
  7971. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  7972. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  7973. Redistribution and use in source and binary forms, with or without
  7974. modification, are permitted provided that the following conditions
  7975. are met:
  7976. * Redistributions of source code must retain the above
  7977. copyright notice, this list of conditions and the following
  7978. disclaimer.
  7979. * Redistributions in binary form must reproduce the above
  7980. copyright notice, this list of conditions and the following
  7981. disclaimer in the documentation and/or other materials
  7982. provided with the distribution.
  7983. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  7984. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7985. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  7986. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  7987. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  7988. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  7989. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  7990. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7991. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  7992. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  7993. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  7994. SUCH DAMAGE.
  7995. ***********************************************************************/
  7996. var LATEST_RAW = ""; // Only used for numbers and template strings
  7997. var LATEST_TEMPLATE_END = true;
  7998. 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";
  7999. var KEYWORDS_ATOM = "false null true";
  8000. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  8001. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  8002. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  8003. KEYWORDS = makePredicate(KEYWORDS);
  8004. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  8005. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  8006. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  8007. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  8008. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  8009. var RE_NUM_LITERAL = /[0-9a-f]/i;
  8010. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  8011. var RE_OCT_NUMBER = /^0[0-7]+$/;
  8012. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  8013. var RE_BIN_NUMBER = /^0b[01]+$/i;
  8014. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  8015. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  8016. var OPERATORS = makePredicate([
  8017. "in",
  8018. "instanceof",
  8019. "typeof",
  8020. "new",
  8021. "void",
  8022. "delete",
  8023. "++",
  8024. "--",
  8025. "+",
  8026. "-",
  8027. "!",
  8028. "~",
  8029. "&",
  8030. "|",
  8031. "^",
  8032. "*",
  8033. "**",
  8034. "/",
  8035. "%",
  8036. ">>",
  8037. "<<",
  8038. ">>>",
  8039. "<",
  8040. ">",
  8041. "<=",
  8042. ">=",
  8043. "==",
  8044. "===",
  8045. "!=",
  8046. "!==",
  8047. "?",
  8048. "=",
  8049. "+=",
  8050. "-=",
  8051. "||=",
  8052. "&&=",
  8053. "??=",
  8054. "/=",
  8055. "*=",
  8056. "**=",
  8057. "%=",
  8058. ">>=",
  8059. "<<=",
  8060. ">>>=",
  8061. "|=",
  8062. "^=",
  8063. "&=",
  8064. "&&",
  8065. "??",
  8066. "||",
  8067. ]);
  8068. 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"));
  8069. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  8070. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  8071. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  8072. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  8073. /* -----[ Tokenizer ]----- */
  8074. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  8075. var UNICODE = {
  8076. 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]/,
  8077. 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])+/,
  8078. };
  8079. function get_full_char(str, pos) {
  8080. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  8081. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  8082. return str.charAt(pos) + str.charAt(pos + 1);
  8083. }
  8084. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  8085. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  8086. return str.charAt(pos - 1) + str.charAt(pos);
  8087. }
  8088. }
  8089. return str.charAt(pos);
  8090. }
  8091. function get_full_char_code(str, pos) {
  8092. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  8093. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  8094. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  8095. }
  8096. return str.charCodeAt(pos);
  8097. }
  8098. function get_full_char_length(str) {
  8099. var surrogates = 0;
  8100. for (var i = 0; i < str.length; i++) {
  8101. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  8102. surrogates++;
  8103. i++;
  8104. }
  8105. }
  8106. return str.length - surrogates;
  8107. }
  8108. function from_char_code(code) {
  8109. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  8110. if (code > 0xFFFF) {
  8111. code -= 0x10000;
  8112. return (String.fromCharCode((code >> 10) + 0xD800) +
  8113. String.fromCharCode((code % 0x400) + 0xDC00));
  8114. }
  8115. return String.fromCharCode(code);
  8116. }
  8117. function is_surrogate_pair_head(code) {
  8118. return code >= 0xd800 && code <= 0xdbff;
  8119. }
  8120. function is_surrogate_pair_tail(code) {
  8121. return code >= 0xdc00 && code <= 0xdfff;
  8122. }
  8123. function is_digit(code) {
  8124. return code >= 48 && code <= 57;
  8125. }
  8126. function is_identifier_start(ch) {
  8127. return UNICODE.ID_Start.test(ch);
  8128. }
  8129. function is_identifier_char(ch) {
  8130. return UNICODE.ID_Continue.test(ch);
  8131. }
  8132. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  8133. function is_basic_identifier_string(str) {
  8134. return BASIC_IDENT.test(str);
  8135. }
  8136. function is_identifier_string(str, allow_surrogates) {
  8137. if (BASIC_IDENT.test(str)) {
  8138. return true;
  8139. }
  8140. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  8141. return false;
  8142. }
  8143. var match = UNICODE.ID_Start.exec(str);
  8144. if (!match || match.index !== 0) {
  8145. return false;
  8146. }
  8147. str = str.slice(match[0].length);
  8148. if (!str) {
  8149. return true;
  8150. }
  8151. match = UNICODE.ID_Continue.exec(str);
  8152. return !!match && match[0].length === str.length;
  8153. }
  8154. function parse_js_number(num, allow_e = true) {
  8155. if (!allow_e && num.includes("e")) {
  8156. return NaN;
  8157. }
  8158. if (RE_HEX_NUMBER.test(num)) {
  8159. return parseInt(num.substr(2), 16);
  8160. } else if (RE_OCT_NUMBER.test(num)) {
  8161. return parseInt(num.substr(1), 8);
  8162. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  8163. return parseInt(num.substr(2), 8);
  8164. } else if (RE_BIN_NUMBER.test(num)) {
  8165. return parseInt(num.substr(2), 2);
  8166. } else if (RE_DEC_NUMBER.test(num)) {
  8167. return parseFloat(num);
  8168. } else {
  8169. var val = parseFloat(num);
  8170. if (val == num) return val;
  8171. }
  8172. }
  8173. class JS_Parse_Error extends Error {
  8174. constructor(message, filename, line, col, pos) {
  8175. super();
  8176. this.name = "SyntaxError";
  8177. this.message = message;
  8178. this.filename = filename;
  8179. this.line = line;
  8180. this.col = col;
  8181. this.pos = pos;
  8182. }
  8183. }
  8184. function js_error(message, filename, line, col, pos) {
  8185. throw new JS_Parse_Error(message, filename, line, col, pos);
  8186. }
  8187. function is_token(token, type, val) {
  8188. return token.type == type && (val == null || token.value == val);
  8189. }
  8190. var EX_EOF = {};
  8191. function tokenizer($TEXT, filename, html5_comments, shebang) {
  8192. var S = {
  8193. text : $TEXT,
  8194. filename : filename,
  8195. pos : 0,
  8196. tokpos : 0,
  8197. line : 1,
  8198. tokline : 0,
  8199. col : 0,
  8200. tokcol : 0,
  8201. newline_before : false,
  8202. regex_allowed : false,
  8203. brace_counter : 0,
  8204. template_braces : [],
  8205. comments_before : [],
  8206. directives : {},
  8207. directive_stack : []
  8208. };
  8209. function peek() { return get_full_char(S.text, S.pos); }
  8210. // Used because parsing ?. involves a lookahead for a digit
  8211. function is_option_chain_op() {
  8212. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  8213. if (!must_be_dot) return false;
  8214. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  8215. return cannot_be_digit < 48 || cannot_be_digit > 57;
  8216. }
  8217. function next(signal_eof, in_string) {
  8218. var ch = get_full_char(S.text, S.pos++);
  8219. if (signal_eof && !ch)
  8220. throw EX_EOF;
  8221. if (NEWLINE_CHARS.has(ch)) {
  8222. S.newline_before = S.newline_before || !in_string;
  8223. ++S.line;
  8224. S.col = 0;
  8225. if (ch == "\r" && peek() == "\n") {
  8226. // treat a \r\n sequence as a single \n
  8227. ++S.pos;
  8228. ch = "\n";
  8229. }
  8230. } else {
  8231. if (ch.length > 1) {
  8232. ++S.pos;
  8233. ++S.col;
  8234. }
  8235. ++S.col;
  8236. }
  8237. return ch;
  8238. }
  8239. function forward(i) {
  8240. while (i--) next();
  8241. }
  8242. function looking_at(str) {
  8243. return S.text.substr(S.pos, str.length) == str;
  8244. }
  8245. function find_eol() {
  8246. var text = S.text;
  8247. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  8248. var ch = text[i];
  8249. if (NEWLINE_CHARS.has(ch))
  8250. return i;
  8251. }
  8252. return -1;
  8253. }
  8254. function find(what, signal_eof) {
  8255. var pos = S.text.indexOf(what, S.pos);
  8256. if (signal_eof && pos == -1) throw EX_EOF;
  8257. return pos;
  8258. }
  8259. function start_token() {
  8260. S.tokline = S.line;
  8261. S.tokcol = S.col;
  8262. S.tokpos = S.pos;
  8263. }
  8264. var prev_was_dot = false;
  8265. var previous_token = null;
  8266. function token(type, value, is_comment) {
  8267. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  8268. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  8269. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  8270. (type == "arrow");
  8271. if (type == "punc" && (value == "." || value == "?.")) {
  8272. prev_was_dot = true;
  8273. } else if (!is_comment) {
  8274. prev_was_dot = false;
  8275. }
  8276. const line = S.tokline;
  8277. const col = S.tokcol;
  8278. const pos = S.tokpos;
  8279. const nlb = S.newline_before;
  8280. const file = filename;
  8281. let comments_before = [];
  8282. let comments_after = [];
  8283. if (!is_comment) {
  8284. comments_before = S.comments_before;
  8285. comments_after = S.comments_before = [];
  8286. }
  8287. S.newline_before = false;
  8288. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  8289. if (!is_comment) previous_token = tok;
  8290. return tok;
  8291. }
  8292. function skip_whitespace() {
  8293. while (WHITESPACE_CHARS.has(peek()))
  8294. next();
  8295. }
  8296. function read_while(pred) {
  8297. var ret = "", ch, i = 0;
  8298. while ((ch = peek()) && pred(ch, i++))
  8299. ret += next();
  8300. return ret;
  8301. }
  8302. function parse_error(err) {
  8303. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  8304. }
  8305. function read_num(prefix) {
  8306. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  8307. var num = read_while(function(ch, i) {
  8308. if (is_big_int) return false;
  8309. var code = ch.charCodeAt(0);
  8310. switch (code) {
  8311. case 95: // _
  8312. return (numeric_separator = true);
  8313. case 98: case 66: // bB
  8314. return (has_x = true); // Can occur in hex sequence, don't return false yet
  8315. case 111: case 79: // oO
  8316. case 120: case 88: // xX
  8317. return has_x ? false : (has_x = true);
  8318. case 101: case 69: // eE
  8319. return has_x ? true : has_e ? false : (has_e = after_e = true);
  8320. case 45: // -
  8321. return after_e || (i == 0 && !prefix);
  8322. case 43: // +
  8323. return after_e;
  8324. case (after_e = false, 46): // .
  8325. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  8326. }
  8327. if (ch === "n") {
  8328. is_big_int = true;
  8329. return true;
  8330. }
  8331. return RE_NUM_LITERAL.test(ch);
  8332. });
  8333. if (prefix) num = prefix + num;
  8334. LATEST_RAW = num;
  8335. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  8336. parse_error("Legacy octal literals are not allowed in strict mode");
  8337. }
  8338. if (numeric_separator) {
  8339. if (num.endsWith("_")) {
  8340. parse_error("Numeric separators are not allowed at the end of numeric literals");
  8341. } else if (num.includes("__")) {
  8342. parse_error("Only one underscore is allowed as numeric separator");
  8343. }
  8344. num = num.replace(/_/g, "");
  8345. }
  8346. if (num.endsWith("n")) {
  8347. const without_n = num.slice(0, -1);
  8348. const allow_e = RE_HEX_NUMBER.test(without_n);
  8349. const valid = parse_js_number(without_n, allow_e);
  8350. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  8351. return token("big_int", without_n);
  8352. parse_error("Invalid or unexpected token");
  8353. }
  8354. var valid = parse_js_number(num);
  8355. if (!isNaN(valid)) {
  8356. return token("num", valid);
  8357. } else {
  8358. parse_error("Invalid syntax: " + num);
  8359. }
  8360. }
  8361. function is_octal(ch) {
  8362. return ch >= "0" && ch <= "7";
  8363. }
  8364. function read_escaped_char(in_string, strict_hex, template_string) {
  8365. var ch = next(true, in_string);
  8366. switch (ch.charCodeAt(0)) {
  8367. case 110 : return "\n";
  8368. case 114 : return "\r";
  8369. case 116 : return "\t";
  8370. case 98 : return "\b";
  8371. case 118 : return "\u000b"; // \v
  8372. case 102 : return "\f";
  8373. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  8374. case 117 : // \u
  8375. if (peek() == "{") {
  8376. next(true);
  8377. if (peek() === "}")
  8378. parse_error("Expecting hex-character between {}");
  8379. while (peek() == "0") next(true); // No significance
  8380. var result, length = find("}", true) - S.pos;
  8381. // Avoid 32 bit integer overflow (1 << 32 === 1)
  8382. // We know first character isn't 0 and thus out of range anyway
  8383. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  8384. parse_error("Unicode reference out of bounds");
  8385. }
  8386. next(true);
  8387. return from_char_code(result);
  8388. }
  8389. return String.fromCharCode(hex_bytes(4, strict_hex));
  8390. case 10 : return ""; // newline
  8391. case 13 : // \r
  8392. if (peek() == "\n") { // DOS newline
  8393. next(true, in_string);
  8394. return "";
  8395. }
  8396. }
  8397. if (is_octal(ch)) {
  8398. if (template_string && strict_hex) {
  8399. const represents_null_character = ch === "0" && !is_octal(peek());
  8400. if (!represents_null_character) {
  8401. parse_error("Octal escape sequences are not allowed in template strings");
  8402. }
  8403. }
  8404. return read_octal_escape_sequence(ch, strict_hex);
  8405. }
  8406. return ch;
  8407. }
  8408. function read_octal_escape_sequence(ch, strict_octal) {
  8409. // Read
  8410. var p = peek();
  8411. if (p >= "0" && p <= "7") {
  8412. ch += next(true);
  8413. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  8414. ch += next(true);
  8415. }
  8416. // Parse
  8417. if (ch === "0") return "\0";
  8418. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  8419. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  8420. return String.fromCharCode(parseInt(ch, 8));
  8421. }
  8422. function hex_bytes(n, strict_hex) {
  8423. var num = 0;
  8424. for (; n > 0; --n) {
  8425. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  8426. return parseInt(num, 16) || "";
  8427. }
  8428. var digit = next(true);
  8429. if (isNaN(parseInt(digit, 16)))
  8430. parse_error("Invalid hex-character pattern in string");
  8431. num += digit;
  8432. }
  8433. return parseInt(num, 16);
  8434. }
  8435. var read_string = with_eof_error("Unterminated string constant", function() {
  8436. const start_pos = S.pos;
  8437. var quote = next(), ret = [];
  8438. for (;;) {
  8439. var ch = next(true, true);
  8440. if (ch == "\\") ch = read_escaped_char(true, true);
  8441. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  8442. else if (ch == quote) break;
  8443. ret.push(ch);
  8444. }
  8445. var tok = token("string", ret.join(""));
  8446. LATEST_RAW = S.text.slice(start_pos, S.pos);
  8447. tok.quote = quote;
  8448. return tok;
  8449. });
  8450. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  8451. if (begin) {
  8452. S.template_braces.push(S.brace_counter);
  8453. }
  8454. var content = "", raw = "", ch, tok;
  8455. next(true, true);
  8456. while ((ch = next(true, true)) != "`") {
  8457. if (ch == "\r") {
  8458. if (peek() == "\n") ++S.pos;
  8459. ch = "\n";
  8460. } else if (ch == "$" && peek() == "{") {
  8461. next(true, true);
  8462. S.brace_counter++;
  8463. tok = token(begin ? "template_head" : "template_substitution", content);
  8464. LATEST_RAW = raw;
  8465. LATEST_TEMPLATE_END = false;
  8466. return tok;
  8467. }
  8468. raw += ch;
  8469. if (ch == "\\") {
  8470. var tmp = S.pos;
  8471. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  8472. ch = read_escaped_char(true, !prev_is_tag, true);
  8473. raw += S.text.substr(tmp, S.pos - tmp);
  8474. }
  8475. content += ch;
  8476. }
  8477. S.template_braces.pop();
  8478. tok = token(begin ? "template_head" : "template_substitution", content);
  8479. LATEST_RAW = raw;
  8480. LATEST_TEMPLATE_END = true;
  8481. return tok;
  8482. });
  8483. function skip_line_comment(type) {
  8484. var regex_allowed = S.regex_allowed;
  8485. var i = find_eol(), ret;
  8486. if (i == -1) {
  8487. ret = S.text.substr(S.pos);
  8488. S.pos = S.text.length;
  8489. } else {
  8490. ret = S.text.substring(S.pos, i);
  8491. S.pos = i;
  8492. }
  8493. S.col = S.tokcol + (S.pos - S.tokpos);
  8494. S.comments_before.push(token(type, ret, true));
  8495. S.regex_allowed = regex_allowed;
  8496. return next_token;
  8497. }
  8498. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  8499. var regex_allowed = S.regex_allowed;
  8500. var i = find("*/", true);
  8501. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  8502. // update stream position
  8503. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  8504. S.comments_before.push(token("comment2", text, true));
  8505. S.newline_before = S.newline_before || text.includes("\n");
  8506. S.regex_allowed = regex_allowed;
  8507. return next_token;
  8508. });
  8509. var read_name = with_eof_error("Unterminated identifier name", function() {
  8510. var name = [], ch, escaped = false;
  8511. var read_escaped_identifier_char = function() {
  8512. escaped = true;
  8513. next();
  8514. if (peek() !== "u") {
  8515. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  8516. }
  8517. return read_escaped_char(false, true);
  8518. };
  8519. // Read first character (ID_Start)
  8520. if ((ch = peek()) === "\\") {
  8521. ch = read_escaped_identifier_char();
  8522. if (!is_identifier_start(ch)) {
  8523. parse_error("First identifier char is an invalid identifier char");
  8524. }
  8525. } else if (is_identifier_start(ch)) {
  8526. next();
  8527. } else {
  8528. return "";
  8529. }
  8530. name.push(ch);
  8531. // Read ID_Continue
  8532. while ((ch = peek()) != null) {
  8533. if ((ch = peek()) === "\\") {
  8534. ch = read_escaped_identifier_char();
  8535. if (!is_identifier_char(ch)) {
  8536. parse_error("Invalid escaped identifier char");
  8537. }
  8538. } else {
  8539. if (!is_identifier_char(ch)) {
  8540. break;
  8541. }
  8542. next();
  8543. }
  8544. name.push(ch);
  8545. }
  8546. const name_str = name.join("");
  8547. if (RESERVED_WORDS.has(name_str) && escaped) {
  8548. parse_error("Escaped characters are not allowed in keywords");
  8549. }
  8550. return name_str;
  8551. });
  8552. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  8553. var prev_backslash = false, ch, in_class = false;
  8554. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  8555. parse_error("Unexpected line terminator");
  8556. } else if (prev_backslash) {
  8557. source += "\\" + ch;
  8558. prev_backslash = false;
  8559. } else if (ch == "[") {
  8560. in_class = true;
  8561. source += ch;
  8562. } else if (ch == "]" && in_class) {
  8563. in_class = false;
  8564. source += ch;
  8565. } else if (ch == "/" && !in_class) {
  8566. break;
  8567. } else if (ch == "\\") {
  8568. prev_backslash = true;
  8569. } else {
  8570. source += ch;
  8571. }
  8572. const flags = read_name();
  8573. return token("regexp", "/" + source + "/" + flags);
  8574. });
  8575. function read_operator(prefix) {
  8576. function grow(op) {
  8577. if (!peek()) return op;
  8578. var bigger = op + peek();
  8579. if (OPERATORS.has(bigger)) {
  8580. next();
  8581. return grow(bigger);
  8582. } else {
  8583. return op;
  8584. }
  8585. }
  8586. return token("operator", grow(prefix || next()));
  8587. }
  8588. function handle_slash() {
  8589. next();
  8590. switch (peek()) {
  8591. case "/":
  8592. next();
  8593. return skip_line_comment("comment1");
  8594. case "*":
  8595. next();
  8596. return skip_multiline_comment();
  8597. }
  8598. return S.regex_allowed ? read_regexp("") : read_operator("/");
  8599. }
  8600. function handle_eq_sign() {
  8601. next();
  8602. if (peek() === ">") {
  8603. next();
  8604. return token("arrow", "=>");
  8605. } else {
  8606. return read_operator("=");
  8607. }
  8608. }
  8609. function handle_dot() {
  8610. next();
  8611. if (is_digit(peek().charCodeAt(0))) {
  8612. return read_num(".");
  8613. }
  8614. if (peek() === ".") {
  8615. next(); // Consume second dot
  8616. next(); // Consume third dot
  8617. return token("expand", "...");
  8618. }
  8619. return token("punc", ".");
  8620. }
  8621. function read_word() {
  8622. var word = read_name();
  8623. if (prev_was_dot) return token("name", word);
  8624. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  8625. : !KEYWORDS.has(word) ? token("name", word)
  8626. : OPERATORS.has(word) ? token("operator", word)
  8627. : token("keyword", word);
  8628. }
  8629. function read_private_word() {
  8630. next();
  8631. return token("privatename", read_name());
  8632. }
  8633. function with_eof_error(eof_error, cont) {
  8634. return function(x) {
  8635. try {
  8636. return cont(x);
  8637. } catch(ex) {
  8638. if (ex === EX_EOF) parse_error(eof_error);
  8639. else throw ex;
  8640. }
  8641. };
  8642. }
  8643. function next_token(force_regexp) {
  8644. if (force_regexp != null)
  8645. return read_regexp(force_regexp);
  8646. if (shebang && S.pos == 0 && looking_at("#!")) {
  8647. start_token();
  8648. forward(2);
  8649. skip_line_comment("comment5");
  8650. }
  8651. for (;;) {
  8652. skip_whitespace();
  8653. start_token();
  8654. if (html5_comments) {
  8655. if (looking_at("<!--")) {
  8656. forward(4);
  8657. skip_line_comment("comment3");
  8658. continue;
  8659. }
  8660. if (looking_at("-->") && S.newline_before) {
  8661. forward(3);
  8662. skip_line_comment("comment4");
  8663. continue;
  8664. }
  8665. }
  8666. var ch = peek();
  8667. if (!ch) return token("eof");
  8668. var code = ch.charCodeAt(0);
  8669. switch (code) {
  8670. case 34: case 39: return read_string();
  8671. case 46: return handle_dot();
  8672. case 47: {
  8673. var tok = handle_slash();
  8674. if (tok === next_token) continue;
  8675. return tok;
  8676. }
  8677. case 61: return handle_eq_sign();
  8678. case 63: {
  8679. if (!is_option_chain_op()) break; // Handled below
  8680. next(); // ?
  8681. next(); // .
  8682. return token("punc", "?.");
  8683. }
  8684. case 96: return read_template_characters(true);
  8685. case 123:
  8686. S.brace_counter++;
  8687. break;
  8688. case 125:
  8689. S.brace_counter--;
  8690. if (S.template_braces.length > 0
  8691. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  8692. return read_template_characters(false);
  8693. break;
  8694. }
  8695. if (is_digit(code)) return read_num();
  8696. if (PUNC_CHARS.has(ch)) return token("punc", next());
  8697. if (OPERATOR_CHARS.has(ch)) return read_operator();
  8698. if (code == 92 || is_identifier_start(ch)) return read_word();
  8699. if (code == 35) return read_private_word();
  8700. break;
  8701. }
  8702. parse_error("Unexpected character '" + ch + "'");
  8703. }
  8704. next_token.next = next;
  8705. next_token.peek = peek;
  8706. next_token.context = function(nc) {
  8707. if (nc) S = nc;
  8708. return S;
  8709. };
  8710. next_token.add_directive = function(directive) {
  8711. S.directive_stack[S.directive_stack.length - 1].push(directive);
  8712. if (S.directives[directive] === undefined) {
  8713. S.directives[directive] = 1;
  8714. } else {
  8715. S.directives[directive]++;
  8716. }
  8717. };
  8718. next_token.push_directives_stack = function() {
  8719. S.directive_stack.push([]);
  8720. };
  8721. next_token.pop_directives_stack = function() {
  8722. var directives = S.directive_stack[S.directive_stack.length - 1];
  8723. for (var i = 0; i < directives.length; i++) {
  8724. S.directives[directives[i]]--;
  8725. }
  8726. S.directive_stack.pop();
  8727. };
  8728. next_token.has_directive = function(directive) {
  8729. return S.directives[directive] > 0;
  8730. };
  8731. return next_token;
  8732. }
  8733. /* -----[ Parser (constants) ]----- */
  8734. var UNARY_PREFIX = makePredicate([
  8735. "typeof",
  8736. "void",
  8737. "delete",
  8738. "--",
  8739. "++",
  8740. "!",
  8741. "~",
  8742. "-",
  8743. "+"
  8744. ]);
  8745. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  8746. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  8747. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  8748. var PRECEDENCE = (function(a, ret) {
  8749. for (var i = 0; i < a.length; ++i) {
  8750. var b = a[i];
  8751. for (var j = 0; j < b.length; ++j) {
  8752. ret[b[j]] = i + 1;
  8753. }
  8754. }
  8755. return ret;
  8756. })(
  8757. [
  8758. ["||"],
  8759. ["??"],
  8760. ["&&"],
  8761. ["|"],
  8762. ["^"],
  8763. ["&"],
  8764. ["==", "===", "!=", "!=="],
  8765. ["<", ">", "<=", ">=", "in", "instanceof"],
  8766. [">>", "<<", ">>>"],
  8767. ["+", "-"],
  8768. ["*", "/", "%"],
  8769. ["**"]
  8770. ],
  8771. {}
  8772. );
  8773. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name" ]);
  8774. /* -----[ Parser ]----- */
  8775. function parse($TEXT, options) {
  8776. // maps start tokens to count of comments found outside of their parens
  8777. // Example: /* I count */ ( /* I don't */ foo() )
  8778. // Useful because comments_before property of call with parens outside
  8779. // contains both comments inside and outside these parens. Used to find the
  8780. const outer_comments_before_counts = new WeakMap();
  8781. options = defaults(options, {
  8782. bare_returns : false,
  8783. ecma : null, // Legacy
  8784. expression : false,
  8785. filename : null,
  8786. html5_comments : true,
  8787. module : false,
  8788. shebang : true,
  8789. strict : false,
  8790. toplevel : null,
  8791. }, true);
  8792. var S = {
  8793. input : (typeof $TEXT == "string"
  8794. ? tokenizer($TEXT, options.filename,
  8795. options.html5_comments, options.shebang)
  8796. : $TEXT),
  8797. token : null,
  8798. prev : null,
  8799. peeked : null,
  8800. in_function : 0,
  8801. in_async : -1,
  8802. in_generator : -1,
  8803. in_directives : true,
  8804. in_loop : 0,
  8805. labels : []
  8806. };
  8807. S.token = next();
  8808. function is(type, value) {
  8809. return is_token(S.token, type, value);
  8810. }
  8811. function peek() { return S.peeked || (S.peeked = S.input()); }
  8812. function next() {
  8813. S.prev = S.token;
  8814. if (!S.peeked) peek();
  8815. S.token = S.peeked;
  8816. S.peeked = null;
  8817. S.in_directives = S.in_directives && (
  8818. S.token.type == "string" || is("punc", ";")
  8819. );
  8820. return S.token;
  8821. }
  8822. function prev() {
  8823. return S.prev;
  8824. }
  8825. function croak(msg, line, col, pos) {
  8826. var ctx = S.input.context();
  8827. js_error(msg,
  8828. ctx.filename,
  8829. line != null ? line : ctx.tokline,
  8830. col != null ? col : ctx.tokcol,
  8831. pos != null ? pos : ctx.tokpos);
  8832. }
  8833. function token_error(token, msg) {
  8834. croak(msg, token.line, token.col);
  8835. }
  8836. function unexpected(token) {
  8837. if (token == null)
  8838. token = S.token;
  8839. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  8840. }
  8841. function expect_token(type, val) {
  8842. if (is(type, val)) {
  8843. return next();
  8844. }
  8845. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  8846. }
  8847. function expect(punc) { return expect_token("punc", punc); }
  8848. function has_newline_before(token) {
  8849. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  8850. }
  8851. function can_insert_semicolon() {
  8852. return !options.strict
  8853. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  8854. }
  8855. function is_in_generator() {
  8856. return S.in_generator === S.in_function;
  8857. }
  8858. function is_in_async() {
  8859. return S.in_async === S.in_function;
  8860. }
  8861. function can_await() {
  8862. return (
  8863. S.in_async === S.in_function
  8864. || S.in_function === 0 && S.input.has_directive("use strict")
  8865. );
  8866. }
  8867. function semicolon(optional) {
  8868. if (is("punc", ";")) next();
  8869. else if (!optional && !can_insert_semicolon()) unexpected();
  8870. }
  8871. function parenthesised() {
  8872. expect("(");
  8873. var exp = expression(true);
  8874. expect(")");
  8875. return exp;
  8876. }
  8877. function embed_tokens(parser) {
  8878. return function _embed_tokens_wrapper(...args) {
  8879. const start = S.token;
  8880. const expr = parser(...args);
  8881. expr.start = start;
  8882. expr.end = prev();
  8883. return expr;
  8884. };
  8885. }
  8886. function handle_regexp() {
  8887. if (is("operator", "/") || is("operator", "/=")) {
  8888. S.peeked = null;
  8889. S.token = S.input(S.token.value.substr(1)); // force regexp
  8890. }
  8891. }
  8892. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  8893. handle_regexp();
  8894. switch (S.token.type) {
  8895. case "string":
  8896. if (S.in_directives) {
  8897. var token = peek();
  8898. if (!LATEST_RAW.includes("\\")
  8899. && (is_token(token, "punc", ";")
  8900. || is_token(token, "punc", "}")
  8901. || has_newline_before(token)
  8902. || is_token(token, "eof"))) {
  8903. S.input.add_directive(S.token.value);
  8904. } else {
  8905. S.in_directives = false;
  8906. }
  8907. }
  8908. var dir = S.in_directives, stat = simple_statement();
  8909. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  8910. case "template_head":
  8911. case "num":
  8912. case "big_int":
  8913. case "regexp":
  8914. case "operator":
  8915. case "atom":
  8916. return simple_statement();
  8917. case "name":
  8918. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  8919. next();
  8920. next();
  8921. if (is_for_body) {
  8922. croak("functions are not allowed as the body of a loop");
  8923. }
  8924. return function_(AST_Defun, false, true, is_export_default);
  8925. }
  8926. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  8927. next();
  8928. var node = import_();
  8929. semicolon();
  8930. return node;
  8931. }
  8932. return is_token(peek(), "punc", ":")
  8933. ? labeled_statement()
  8934. : simple_statement();
  8935. case "punc":
  8936. switch (S.token.value) {
  8937. case "{":
  8938. return new AST_BlockStatement({
  8939. start : S.token,
  8940. body : block_(),
  8941. end : prev()
  8942. });
  8943. case "[":
  8944. case "(":
  8945. return simple_statement();
  8946. case ";":
  8947. S.in_directives = false;
  8948. next();
  8949. return new AST_EmptyStatement();
  8950. default:
  8951. unexpected();
  8952. }
  8953. case "keyword":
  8954. switch (S.token.value) {
  8955. case "break":
  8956. next();
  8957. return break_cont(AST_Break);
  8958. case "continue":
  8959. next();
  8960. return break_cont(AST_Continue);
  8961. case "debugger":
  8962. next();
  8963. semicolon();
  8964. return new AST_Debugger();
  8965. case "do":
  8966. next();
  8967. var body = in_loop(statement);
  8968. expect_token("keyword", "while");
  8969. var condition = parenthesised();
  8970. semicolon(true);
  8971. return new AST_Do({
  8972. body : body,
  8973. condition : condition
  8974. });
  8975. case "while":
  8976. next();
  8977. return new AST_While({
  8978. condition : parenthesised(),
  8979. body : in_loop(function() { return statement(false, true); })
  8980. });
  8981. case "for":
  8982. next();
  8983. return for_();
  8984. case "class":
  8985. next();
  8986. if (is_for_body) {
  8987. croak("classes are not allowed as the body of a loop");
  8988. }
  8989. if (is_if_body) {
  8990. croak("classes are not allowed as the body of an if");
  8991. }
  8992. return class_(AST_DefClass, is_export_default);
  8993. case "function":
  8994. next();
  8995. if (is_for_body) {
  8996. croak("functions are not allowed as the body of a loop");
  8997. }
  8998. return function_(AST_Defun, false, false, is_export_default);
  8999. case "if":
  9000. next();
  9001. return if_();
  9002. case "return":
  9003. if (S.in_function == 0 && !options.bare_returns)
  9004. croak("'return' outside of function");
  9005. next();
  9006. var value = null;
  9007. if (is("punc", ";")) {
  9008. next();
  9009. } else if (!can_insert_semicolon()) {
  9010. value = expression(true);
  9011. semicolon();
  9012. }
  9013. return new AST_Return({
  9014. value: value
  9015. });
  9016. case "switch":
  9017. next();
  9018. return new AST_Switch({
  9019. expression : parenthesised(),
  9020. body : in_loop(switch_body_)
  9021. });
  9022. case "throw":
  9023. next();
  9024. if (has_newline_before(S.token))
  9025. croak("Illegal newline after 'throw'");
  9026. var value = expression(true);
  9027. semicolon();
  9028. return new AST_Throw({
  9029. value: value
  9030. });
  9031. case "try":
  9032. next();
  9033. return try_();
  9034. case "var":
  9035. next();
  9036. var node = var_();
  9037. semicolon();
  9038. return node;
  9039. case "let":
  9040. next();
  9041. var node = let_();
  9042. semicolon();
  9043. return node;
  9044. case "const":
  9045. next();
  9046. var node = const_();
  9047. semicolon();
  9048. return node;
  9049. case "with":
  9050. if (S.input.has_directive("use strict")) {
  9051. croak("Strict mode may not include a with statement");
  9052. }
  9053. next();
  9054. return new AST_With({
  9055. expression : parenthesised(),
  9056. body : statement()
  9057. });
  9058. case "export":
  9059. if (!is_token(peek(), "punc", "(")) {
  9060. next();
  9061. var node = export_();
  9062. if (is("punc", ";")) semicolon();
  9063. return node;
  9064. }
  9065. }
  9066. }
  9067. unexpected();
  9068. });
  9069. function labeled_statement() {
  9070. var label = as_symbol(AST_Label);
  9071. if (label.name === "await" && is_in_async()) {
  9072. token_error(S.prev, "await cannot be used as label inside async function");
  9073. }
  9074. if (S.labels.some((l) => l.name === label.name)) {
  9075. // ECMA-262, 12.12: An ECMAScript program is considered
  9076. // syntactically incorrect if it contains a
  9077. // LabelledStatement that is enclosed by a
  9078. // LabelledStatement with the same Identifier as label.
  9079. croak("Label " + label.name + " defined twice");
  9080. }
  9081. expect(":");
  9082. S.labels.push(label);
  9083. var stat = statement();
  9084. S.labels.pop();
  9085. if (!(stat instanceof AST_IterationStatement)) {
  9086. // check for `continue` that refers to this label.
  9087. // those should be reported as syntax errors.
  9088. // https://github.com/mishoo/UglifyJS2/issues/287
  9089. label.references.forEach(function(ref) {
  9090. if (ref instanceof AST_Continue) {
  9091. ref = ref.label.start;
  9092. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  9093. ref.line, ref.col, ref.pos);
  9094. }
  9095. });
  9096. }
  9097. return new AST_LabeledStatement({ body: stat, label: label });
  9098. }
  9099. function simple_statement(tmp) {
  9100. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  9101. }
  9102. function break_cont(type) {
  9103. var label = null, ldef;
  9104. if (!can_insert_semicolon()) {
  9105. label = as_symbol(AST_LabelRef, true);
  9106. }
  9107. if (label != null) {
  9108. ldef = S.labels.find((l) => l.name === label.name);
  9109. if (!ldef)
  9110. croak("Undefined label " + label.name);
  9111. label.thedef = ldef;
  9112. } else if (S.in_loop == 0)
  9113. croak(type.TYPE + " not inside a loop or switch");
  9114. semicolon();
  9115. var stat = new type({ label: label });
  9116. if (ldef) ldef.references.push(stat);
  9117. return stat;
  9118. }
  9119. function for_() {
  9120. var for_await_error = "`for await` invalid in this context";
  9121. var await_tok = S.token;
  9122. if (await_tok.type == "name" && await_tok.value == "await") {
  9123. if (!can_await()) {
  9124. token_error(await_tok, for_await_error);
  9125. }
  9126. next();
  9127. } else {
  9128. await_tok = false;
  9129. }
  9130. expect("(");
  9131. var init = null;
  9132. if (!is("punc", ";")) {
  9133. init =
  9134. is("keyword", "var") ? (next(), var_(true)) :
  9135. is("keyword", "let") ? (next(), let_(true)) :
  9136. is("keyword", "const") ? (next(), const_(true)) :
  9137. expression(true, true);
  9138. var is_in = is("operator", "in");
  9139. var is_of = is("name", "of");
  9140. if (await_tok && !is_of) {
  9141. token_error(await_tok, for_await_error);
  9142. }
  9143. if (is_in || is_of) {
  9144. if (init instanceof AST_Definitions) {
  9145. if (init.definitions.length > 1)
  9146. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  9147. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  9148. token_error(init.start, "Invalid left-hand side in for..in loop");
  9149. }
  9150. next();
  9151. if (is_in) {
  9152. return for_in(init);
  9153. } else {
  9154. return for_of(init, !!await_tok);
  9155. }
  9156. }
  9157. } else if (await_tok) {
  9158. token_error(await_tok, for_await_error);
  9159. }
  9160. return regular_for(init);
  9161. }
  9162. function regular_for(init) {
  9163. expect(";");
  9164. var test = is("punc", ";") ? null : expression(true);
  9165. expect(";");
  9166. var step = is("punc", ")") ? null : expression(true);
  9167. expect(")");
  9168. return new AST_For({
  9169. init : init,
  9170. condition : test,
  9171. step : step,
  9172. body : in_loop(function() { return statement(false, true); })
  9173. });
  9174. }
  9175. function for_of(init, is_await) {
  9176. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  9177. var obj = expression(true);
  9178. expect(")");
  9179. return new AST_ForOf({
  9180. await : is_await,
  9181. init : init,
  9182. name : lhs,
  9183. object : obj,
  9184. body : in_loop(function() { return statement(false, true); })
  9185. });
  9186. }
  9187. function for_in(init) {
  9188. var obj = expression(true);
  9189. expect(")");
  9190. return new AST_ForIn({
  9191. init : init,
  9192. object : obj,
  9193. body : in_loop(function() { return statement(false, true); })
  9194. });
  9195. }
  9196. var arrow_function = function(start, argnames, is_async) {
  9197. if (has_newline_before(S.token)) {
  9198. croak("Unexpected newline before arrow (=>)");
  9199. }
  9200. expect_token("arrow", "=>");
  9201. var body = _function_body(is("punc", "{"), false, is_async);
  9202. var end =
  9203. body instanceof Array && body.length ? body[body.length - 1].end :
  9204. body instanceof Array ? start :
  9205. body.end;
  9206. return new AST_Arrow({
  9207. start : start,
  9208. end : end,
  9209. async : is_async,
  9210. argnames : argnames,
  9211. body : body
  9212. });
  9213. };
  9214. var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
  9215. var in_statement = ctor === AST_Defun;
  9216. var is_generator = is("operator", "*");
  9217. if (is_generator) {
  9218. next();
  9219. }
  9220. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  9221. if (in_statement && !name) {
  9222. if (is_export_default) {
  9223. ctor = AST_Function;
  9224. } else {
  9225. unexpected();
  9226. }
  9227. }
  9228. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  9229. unexpected(prev());
  9230. var args = [];
  9231. var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
  9232. return new ctor({
  9233. start : args.start,
  9234. end : body.end,
  9235. is_generator: is_generator,
  9236. async : is_async,
  9237. name : name,
  9238. argnames: args,
  9239. body : body
  9240. });
  9241. };
  9242. function track_used_binding_identifiers(is_parameter, strict) {
  9243. var parameters = new Set();
  9244. var duplicate = false;
  9245. var default_assignment = false;
  9246. var spread = false;
  9247. var strict_mode = !!strict;
  9248. var tracker = {
  9249. add_parameter: function(token) {
  9250. if (parameters.has(token.value)) {
  9251. if (duplicate === false) {
  9252. duplicate = token;
  9253. }
  9254. tracker.check_strict();
  9255. } else {
  9256. parameters.add(token.value);
  9257. if (is_parameter) {
  9258. switch (token.value) {
  9259. case "arguments":
  9260. case "eval":
  9261. case "yield":
  9262. if (strict_mode) {
  9263. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  9264. }
  9265. break;
  9266. default:
  9267. if (RESERVED_WORDS.has(token.value)) {
  9268. unexpected();
  9269. }
  9270. }
  9271. }
  9272. }
  9273. },
  9274. mark_default_assignment: function(token) {
  9275. if (default_assignment === false) {
  9276. default_assignment = token;
  9277. }
  9278. },
  9279. mark_spread: function(token) {
  9280. if (spread === false) {
  9281. spread = token;
  9282. }
  9283. },
  9284. mark_strict_mode: function() {
  9285. strict_mode = true;
  9286. },
  9287. is_strict: function() {
  9288. return default_assignment !== false || spread !== false || strict_mode;
  9289. },
  9290. check_strict: function() {
  9291. if (tracker.is_strict() && duplicate !== false) {
  9292. token_error(duplicate, "Parameter " + duplicate.value + " was used already");
  9293. }
  9294. }
  9295. };
  9296. return tracker;
  9297. }
  9298. function parameters(params) {
  9299. var used_parameters = track_used_binding_identifiers(true, S.input.has_directive("use strict"));
  9300. expect("(");
  9301. while (!is("punc", ")")) {
  9302. var param = parameter(used_parameters);
  9303. params.push(param);
  9304. if (!is("punc", ")")) {
  9305. expect(",");
  9306. }
  9307. if (param instanceof AST_Expansion) {
  9308. break;
  9309. }
  9310. }
  9311. next();
  9312. }
  9313. function parameter(used_parameters, symbol_type) {
  9314. var param;
  9315. var expand = false;
  9316. if (used_parameters === undefined) {
  9317. used_parameters = track_used_binding_identifiers(true, S.input.has_directive("use strict"));
  9318. }
  9319. if (is("expand", "...")) {
  9320. expand = S.token;
  9321. used_parameters.mark_spread(S.token);
  9322. next();
  9323. }
  9324. param = binding_element(used_parameters, symbol_type);
  9325. if (is("operator", "=") && expand === false) {
  9326. used_parameters.mark_default_assignment(S.token);
  9327. next();
  9328. param = new AST_DefaultAssign({
  9329. start: param.start,
  9330. left: param,
  9331. operator: "=",
  9332. right: expression(false),
  9333. end: S.token
  9334. });
  9335. }
  9336. if (expand !== false) {
  9337. if (!is("punc", ")")) {
  9338. unexpected();
  9339. }
  9340. param = new AST_Expansion({
  9341. start: expand,
  9342. expression: param,
  9343. end: expand
  9344. });
  9345. }
  9346. used_parameters.check_strict();
  9347. return param;
  9348. }
  9349. function binding_element(used_parameters, symbol_type) {
  9350. var elements = [];
  9351. var first = true;
  9352. var is_expand = false;
  9353. var expand_token;
  9354. var first_token = S.token;
  9355. if (used_parameters === undefined) {
  9356. used_parameters = track_used_binding_identifiers(false, S.input.has_directive("use strict"));
  9357. }
  9358. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  9359. if (is("punc", "[")) {
  9360. next();
  9361. while (!is("punc", "]")) {
  9362. if (first) {
  9363. first = false;
  9364. } else {
  9365. expect(",");
  9366. }
  9367. if (is("expand", "...")) {
  9368. is_expand = true;
  9369. expand_token = S.token;
  9370. used_parameters.mark_spread(S.token);
  9371. next();
  9372. }
  9373. if (is("punc")) {
  9374. switch (S.token.value) {
  9375. case ",":
  9376. elements.push(new AST_Hole({
  9377. start: S.token,
  9378. end: S.token
  9379. }));
  9380. continue;
  9381. case "]": // Trailing comma after last element
  9382. break;
  9383. case "[":
  9384. case "{":
  9385. elements.push(binding_element(used_parameters, symbol_type));
  9386. break;
  9387. default:
  9388. unexpected();
  9389. }
  9390. } else if (is("name")) {
  9391. used_parameters.add_parameter(S.token);
  9392. elements.push(as_symbol(symbol_type));
  9393. } else {
  9394. croak("Invalid function parameter");
  9395. }
  9396. if (is("operator", "=") && is_expand === false) {
  9397. used_parameters.mark_default_assignment(S.token);
  9398. next();
  9399. elements[elements.length - 1] = new AST_DefaultAssign({
  9400. start: elements[elements.length - 1].start,
  9401. left: elements[elements.length - 1],
  9402. operator: "=",
  9403. right: expression(false),
  9404. end: S.token
  9405. });
  9406. }
  9407. if (is_expand) {
  9408. if (!is("punc", "]")) {
  9409. croak("Rest element must be last element");
  9410. }
  9411. elements[elements.length - 1] = new AST_Expansion({
  9412. start: expand_token,
  9413. expression: elements[elements.length - 1],
  9414. end: expand_token
  9415. });
  9416. }
  9417. }
  9418. expect("]");
  9419. used_parameters.check_strict();
  9420. return new AST_Destructuring({
  9421. start: first_token,
  9422. names: elements,
  9423. is_array: true,
  9424. end: prev()
  9425. });
  9426. } else if (is("punc", "{")) {
  9427. next();
  9428. while (!is("punc", "}")) {
  9429. if (first) {
  9430. first = false;
  9431. } else {
  9432. expect(",");
  9433. }
  9434. if (is("expand", "...")) {
  9435. is_expand = true;
  9436. expand_token = S.token;
  9437. used_parameters.mark_spread(S.token);
  9438. next();
  9439. }
  9440. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  9441. used_parameters.add_parameter(S.token);
  9442. var start = prev();
  9443. var value = as_symbol(symbol_type);
  9444. if (is_expand) {
  9445. elements.push(new AST_Expansion({
  9446. start: expand_token,
  9447. expression: value,
  9448. end: value.end,
  9449. }));
  9450. } else {
  9451. elements.push(new AST_ObjectKeyVal({
  9452. start: start,
  9453. key: value.name,
  9454. value: value,
  9455. end: value.end,
  9456. }));
  9457. }
  9458. } else if (is("punc", "}")) {
  9459. continue; // Allow trailing hole
  9460. } else {
  9461. var property_token = S.token;
  9462. var property = as_property_name();
  9463. if (property === null) {
  9464. unexpected(prev());
  9465. } else if (prev().type === "name" && !is("punc", ":")) {
  9466. elements.push(new AST_ObjectKeyVal({
  9467. start: prev(),
  9468. key: property,
  9469. value: new symbol_type({
  9470. start: prev(),
  9471. name: property,
  9472. end: prev()
  9473. }),
  9474. end: prev()
  9475. }));
  9476. } else {
  9477. expect(":");
  9478. elements.push(new AST_ObjectKeyVal({
  9479. start: property_token,
  9480. quote: property_token.quote,
  9481. key: property,
  9482. value: binding_element(used_parameters, symbol_type),
  9483. end: prev()
  9484. }));
  9485. }
  9486. }
  9487. if (is_expand) {
  9488. if (!is("punc", "}")) {
  9489. croak("Rest element must be last element");
  9490. }
  9491. } else if (is("operator", "=")) {
  9492. used_parameters.mark_default_assignment(S.token);
  9493. next();
  9494. elements[elements.length - 1].value = new AST_DefaultAssign({
  9495. start: elements[elements.length - 1].value.start,
  9496. left: elements[elements.length - 1].value,
  9497. operator: "=",
  9498. right: expression(false),
  9499. end: S.token
  9500. });
  9501. }
  9502. }
  9503. expect("}");
  9504. used_parameters.check_strict();
  9505. return new AST_Destructuring({
  9506. start: first_token,
  9507. names: elements,
  9508. is_array: false,
  9509. end: prev()
  9510. });
  9511. } else if (is("name")) {
  9512. used_parameters.add_parameter(S.token);
  9513. return as_symbol(symbol_type);
  9514. } else {
  9515. croak("Invalid function parameter");
  9516. }
  9517. }
  9518. function params_or_seq_(allow_arrows, maybe_sequence) {
  9519. var spread_token;
  9520. var invalid_sequence;
  9521. var trailing_comma;
  9522. var a = [];
  9523. expect("(");
  9524. while (!is("punc", ")")) {
  9525. if (spread_token) unexpected(spread_token);
  9526. if (is("expand", "...")) {
  9527. spread_token = S.token;
  9528. if (maybe_sequence) invalid_sequence = S.token;
  9529. next();
  9530. a.push(new AST_Expansion({
  9531. start: prev(),
  9532. expression: expression(),
  9533. end: S.token,
  9534. }));
  9535. } else {
  9536. a.push(expression());
  9537. }
  9538. if (!is("punc", ")")) {
  9539. expect(",");
  9540. if (is("punc", ")")) {
  9541. trailing_comma = prev();
  9542. if (maybe_sequence) invalid_sequence = trailing_comma;
  9543. }
  9544. }
  9545. }
  9546. expect(")");
  9547. if (allow_arrows && is("arrow", "=>")) {
  9548. if (spread_token && trailing_comma) unexpected(trailing_comma);
  9549. } else if (invalid_sequence) {
  9550. unexpected(invalid_sequence);
  9551. }
  9552. return a;
  9553. }
  9554. function _function_body(block, generator, is_async, name, args) {
  9555. var loop = S.in_loop;
  9556. var labels = S.labels;
  9557. var current_generator = S.in_generator;
  9558. var current_async = S.in_async;
  9559. ++S.in_function;
  9560. if (generator)
  9561. S.in_generator = S.in_function;
  9562. if (is_async)
  9563. S.in_async = S.in_function;
  9564. if (args) parameters(args);
  9565. if (block)
  9566. S.in_directives = true;
  9567. S.in_loop = 0;
  9568. S.labels = [];
  9569. if (block) {
  9570. S.input.push_directives_stack();
  9571. var a = block_();
  9572. if (name) _verify_symbol(name);
  9573. if (args) args.forEach(_verify_symbol);
  9574. S.input.pop_directives_stack();
  9575. } else {
  9576. var a = [new AST_Return({
  9577. start: S.token,
  9578. value: expression(false),
  9579. end: S.token
  9580. })];
  9581. }
  9582. --S.in_function;
  9583. S.in_loop = loop;
  9584. S.labels = labels;
  9585. S.in_generator = current_generator;
  9586. S.in_async = current_async;
  9587. return a;
  9588. }
  9589. function _await_expression() {
  9590. // Previous token must be "await" and not be interpreted as an identifier
  9591. if (!can_await()) {
  9592. croak("Unexpected await expression outside async function",
  9593. S.prev.line, S.prev.col, S.prev.pos);
  9594. }
  9595. // the await expression is parsed as a unary expression in Babel
  9596. return new AST_Await({
  9597. start: prev(),
  9598. end: S.token,
  9599. expression : maybe_unary(true),
  9600. });
  9601. }
  9602. function _yield_expression() {
  9603. // Previous token must be keyword yield and not be interpret as an identifier
  9604. if (!is_in_generator()) {
  9605. croak("Unexpected yield expression outside generator function",
  9606. S.prev.line, S.prev.col, S.prev.pos);
  9607. }
  9608. var start = S.token;
  9609. var star = false;
  9610. var has_expression = true;
  9611. // Attempt to get expression or star (and then the mandatory expression)
  9612. // behind yield on the same line.
  9613. //
  9614. // If nothing follows on the same line of the yieldExpression,
  9615. // it should default to the value `undefined` for yield to return.
  9616. // In that case, the `undefined` stored as `null` in ast.
  9617. //
  9618. // Note 1: It isn't allowed for yield* to close without an expression
  9619. // Note 2: If there is a nlb between yield and star, it is interpret as
  9620. // yield <explicit undefined> <inserted automatic semicolon> *
  9621. if (can_insert_semicolon() ||
  9622. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  9623. has_expression = false;
  9624. } else if (is("operator", "*")) {
  9625. star = true;
  9626. next();
  9627. }
  9628. return new AST_Yield({
  9629. start : start,
  9630. is_star : star,
  9631. expression : has_expression ? expression() : null,
  9632. end : prev()
  9633. });
  9634. }
  9635. function if_() {
  9636. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  9637. if (is("keyword", "else")) {
  9638. next();
  9639. belse = statement(false, false, true);
  9640. }
  9641. return new AST_If({
  9642. condition : cond,
  9643. body : body,
  9644. alternative : belse
  9645. });
  9646. }
  9647. function block_() {
  9648. expect("{");
  9649. var a = [];
  9650. while (!is("punc", "}")) {
  9651. if (is("eof")) unexpected();
  9652. a.push(statement());
  9653. }
  9654. next();
  9655. return a;
  9656. }
  9657. function switch_body_() {
  9658. expect("{");
  9659. var a = [], cur = null, branch = null, tmp;
  9660. while (!is("punc", "}")) {
  9661. if (is("eof")) unexpected();
  9662. if (is("keyword", "case")) {
  9663. if (branch) branch.end = prev();
  9664. cur = [];
  9665. branch = new AST_Case({
  9666. start : (tmp = S.token, next(), tmp),
  9667. expression : expression(true),
  9668. body : cur
  9669. });
  9670. a.push(branch);
  9671. expect(":");
  9672. } else if (is("keyword", "default")) {
  9673. if (branch) branch.end = prev();
  9674. cur = [];
  9675. branch = new AST_Default({
  9676. start : (tmp = S.token, next(), expect(":"), tmp),
  9677. body : cur
  9678. });
  9679. a.push(branch);
  9680. } else {
  9681. if (!cur) unexpected();
  9682. cur.push(statement());
  9683. }
  9684. }
  9685. if (branch) branch.end = prev();
  9686. next();
  9687. return a;
  9688. }
  9689. function try_() {
  9690. var body = block_(), bcatch = null, bfinally = null;
  9691. if (is("keyword", "catch")) {
  9692. var start = S.token;
  9693. next();
  9694. if (is("punc", "{")) {
  9695. var name = null;
  9696. } else {
  9697. expect("(");
  9698. var name = parameter(undefined, AST_SymbolCatch);
  9699. expect(")");
  9700. }
  9701. bcatch = new AST_Catch({
  9702. start : start,
  9703. argname : name,
  9704. body : block_(),
  9705. end : prev()
  9706. });
  9707. }
  9708. if (is("keyword", "finally")) {
  9709. var start = S.token;
  9710. next();
  9711. bfinally = new AST_Finally({
  9712. start : start,
  9713. body : block_(),
  9714. end : prev()
  9715. });
  9716. }
  9717. if (!bcatch && !bfinally)
  9718. croak("Missing catch/finally blocks");
  9719. return new AST_Try({
  9720. body : body,
  9721. bcatch : bcatch,
  9722. bfinally : bfinally
  9723. });
  9724. }
  9725. function vardefs(no_in, kind) {
  9726. var a = [];
  9727. var def;
  9728. for (;;) {
  9729. var sym_type =
  9730. kind === "var" ? AST_SymbolVar :
  9731. kind === "const" ? AST_SymbolConst :
  9732. kind === "let" ? AST_SymbolLet : null;
  9733. if (is("punc", "{") || is("punc", "[")) {
  9734. def = new AST_VarDef({
  9735. start: S.token,
  9736. name: binding_element(undefined ,sym_type),
  9737. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  9738. end: prev()
  9739. });
  9740. } else {
  9741. def = new AST_VarDef({
  9742. start : S.token,
  9743. name : as_symbol(sym_type),
  9744. value : is("operator", "=")
  9745. ? (next(), expression(false, no_in))
  9746. : !no_in && kind === "const"
  9747. ? croak("Missing initializer in const declaration") : null,
  9748. end : prev()
  9749. });
  9750. if (def.name.name == "import") croak("Unexpected token: import");
  9751. }
  9752. a.push(def);
  9753. if (!is("punc", ","))
  9754. break;
  9755. next();
  9756. }
  9757. return a;
  9758. }
  9759. var var_ = function(no_in) {
  9760. return new AST_Var({
  9761. start : prev(),
  9762. definitions : vardefs(no_in, "var"),
  9763. end : prev()
  9764. });
  9765. };
  9766. var let_ = function(no_in) {
  9767. return new AST_Let({
  9768. start : prev(),
  9769. definitions : vardefs(no_in, "let"),
  9770. end : prev()
  9771. });
  9772. };
  9773. var const_ = function(no_in) {
  9774. return new AST_Const({
  9775. start : prev(),
  9776. definitions : vardefs(no_in, "const"),
  9777. end : prev()
  9778. });
  9779. };
  9780. var new_ = function(allow_calls) {
  9781. var start = S.token;
  9782. expect_token("operator", "new");
  9783. if (is("punc", ".")) {
  9784. next();
  9785. expect_token("name", "target");
  9786. return subscripts(new AST_NewTarget({
  9787. start : start,
  9788. end : prev()
  9789. }), allow_calls);
  9790. }
  9791. var newexp = expr_atom(false), args;
  9792. if (is("punc", "(")) {
  9793. next();
  9794. args = expr_list(")", true);
  9795. } else {
  9796. args = [];
  9797. }
  9798. var call = new AST_New({
  9799. start : start,
  9800. expression : newexp,
  9801. args : args,
  9802. end : prev()
  9803. });
  9804. annotate(call);
  9805. return subscripts(call, allow_calls);
  9806. };
  9807. function as_atom_node() {
  9808. var tok = S.token, ret;
  9809. switch (tok.type) {
  9810. case "name":
  9811. ret = _make_symbol(AST_SymbolRef);
  9812. break;
  9813. case "num":
  9814. ret = new AST_Number({
  9815. start: tok,
  9816. end: tok,
  9817. value: tok.value,
  9818. raw: LATEST_RAW
  9819. });
  9820. break;
  9821. case "big_int":
  9822. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  9823. break;
  9824. case "string":
  9825. ret = new AST_String({
  9826. start : tok,
  9827. end : tok,
  9828. value : tok.value,
  9829. quote : tok.quote
  9830. });
  9831. break;
  9832. case "regexp":
  9833. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  9834. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  9835. break;
  9836. case "atom":
  9837. switch (tok.value) {
  9838. case "false":
  9839. ret = new AST_False({ start: tok, end: tok });
  9840. break;
  9841. case "true":
  9842. ret = new AST_True({ start: tok, end: tok });
  9843. break;
  9844. case "null":
  9845. ret = new AST_Null({ start: tok, end: tok });
  9846. break;
  9847. }
  9848. break;
  9849. }
  9850. next();
  9851. return ret;
  9852. }
  9853. function to_fun_args(ex, default_seen_above) {
  9854. var insert_default = function(ex, default_value) {
  9855. if (default_value) {
  9856. return new AST_DefaultAssign({
  9857. start: ex.start,
  9858. left: ex,
  9859. operator: "=",
  9860. right: default_value,
  9861. end: default_value.end
  9862. });
  9863. }
  9864. return ex;
  9865. };
  9866. if (ex instanceof AST_Object) {
  9867. return insert_default(new AST_Destructuring({
  9868. start: ex.start,
  9869. end: ex.end,
  9870. is_array: false,
  9871. names: ex.properties.map(prop => to_fun_args(prop))
  9872. }), default_seen_above);
  9873. } else if (ex instanceof AST_ObjectKeyVal) {
  9874. ex.value = to_fun_args(ex.value);
  9875. return insert_default(ex, default_seen_above);
  9876. } else if (ex instanceof AST_Hole) {
  9877. return ex;
  9878. } else if (ex instanceof AST_Destructuring) {
  9879. ex.names = ex.names.map(name => to_fun_args(name));
  9880. return insert_default(ex, default_seen_above);
  9881. } else if (ex instanceof AST_SymbolRef) {
  9882. return insert_default(new AST_SymbolFunarg({
  9883. name: ex.name,
  9884. start: ex.start,
  9885. end: ex.end
  9886. }), default_seen_above);
  9887. } else if (ex instanceof AST_Expansion) {
  9888. ex.expression = to_fun_args(ex.expression);
  9889. return insert_default(ex, default_seen_above);
  9890. } else if (ex instanceof AST_Array) {
  9891. return insert_default(new AST_Destructuring({
  9892. start: ex.start,
  9893. end: ex.end,
  9894. is_array: true,
  9895. names: ex.elements.map(elm => to_fun_args(elm))
  9896. }), default_seen_above);
  9897. } else if (ex instanceof AST_Assign) {
  9898. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  9899. } else if (ex instanceof AST_DefaultAssign) {
  9900. ex.left = to_fun_args(ex.left);
  9901. return ex;
  9902. } else {
  9903. croak("Invalid function parameter", ex.start.line, ex.start.col);
  9904. }
  9905. }
  9906. var expr_atom = function(allow_calls, allow_arrows) {
  9907. if (is("operator", "new")) {
  9908. return new_(allow_calls);
  9909. }
  9910. if (is("operator", "import")) {
  9911. return import_meta();
  9912. }
  9913. var start = S.token;
  9914. var peeked;
  9915. var async = is("name", "async")
  9916. && (peeked = peek()).value != "["
  9917. && peeked.type != "arrow"
  9918. && as_atom_node();
  9919. if (is("punc")) {
  9920. switch (S.token.value) {
  9921. case "(":
  9922. if (async && !allow_calls) break;
  9923. var exprs = params_or_seq_(allow_arrows, !async);
  9924. if (allow_arrows && is("arrow", "=>")) {
  9925. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  9926. }
  9927. var ex = async ? new AST_Call({
  9928. expression: async,
  9929. args: exprs
  9930. }) : exprs.length == 1 ? exprs[0] : new AST_Sequence({
  9931. expressions: exprs
  9932. });
  9933. if (ex.start) {
  9934. const outer_comments_before = start.comments_before.length;
  9935. outer_comments_before_counts.set(start, outer_comments_before);
  9936. ex.start.comments_before.unshift(...start.comments_before);
  9937. start.comments_before = ex.start.comments_before;
  9938. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  9939. var comment = start.comments_before[0];
  9940. if (!comment.nlb) {
  9941. comment.nlb = start.nlb;
  9942. start.nlb = false;
  9943. }
  9944. }
  9945. start.comments_after = ex.start.comments_after;
  9946. }
  9947. ex.start = start;
  9948. var end = prev();
  9949. if (ex.end) {
  9950. end.comments_before = ex.end.comments_before;
  9951. ex.end.comments_after.push(...end.comments_after);
  9952. end.comments_after = ex.end.comments_after;
  9953. }
  9954. ex.end = end;
  9955. if (ex instanceof AST_Call) annotate(ex);
  9956. return subscripts(ex, allow_calls);
  9957. case "[":
  9958. return subscripts(array_(), allow_calls);
  9959. case "{":
  9960. return subscripts(object_or_destructuring_(), allow_calls);
  9961. }
  9962. if (!async) unexpected();
  9963. }
  9964. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  9965. var param = new AST_SymbolFunarg({
  9966. name: S.token.value,
  9967. start: start,
  9968. end: start,
  9969. });
  9970. next();
  9971. return arrow_function(start, [param], !!async);
  9972. }
  9973. if (is("keyword", "function")) {
  9974. next();
  9975. var func = function_(AST_Function, false, !!async);
  9976. func.start = start;
  9977. func.end = prev();
  9978. return subscripts(func, allow_calls);
  9979. }
  9980. if (async) return subscripts(async, allow_calls);
  9981. if (is("keyword", "class")) {
  9982. next();
  9983. var cls = class_(AST_ClassExpression);
  9984. cls.start = start;
  9985. cls.end = prev();
  9986. return subscripts(cls, allow_calls);
  9987. }
  9988. if (is("template_head")) {
  9989. return subscripts(template_string(), allow_calls);
  9990. }
  9991. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  9992. return subscripts(as_atom_node(), allow_calls);
  9993. }
  9994. unexpected();
  9995. };
  9996. function template_string() {
  9997. var segments = [], start = S.token;
  9998. segments.push(new AST_TemplateSegment({
  9999. start: S.token,
  10000. raw: LATEST_RAW,
  10001. value: S.token.value,
  10002. end: S.token
  10003. }));
  10004. while (!LATEST_TEMPLATE_END) {
  10005. next();
  10006. handle_regexp();
  10007. segments.push(expression(true));
  10008. segments.push(new AST_TemplateSegment({
  10009. start: S.token,
  10010. raw: LATEST_RAW,
  10011. value: S.token.value,
  10012. end: S.token
  10013. }));
  10014. }
  10015. next();
  10016. return new AST_TemplateString({
  10017. start: start,
  10018. segments: segments,
  10019. end: S.token
  10020. });
  10021. }
  10022. function expr_list(closing, allow_trailing_comma, allow_empty) {
  10023. var first = true, a = [];
  10024. while (!is("punc", closing)) {
  10025. if (first) first = false; else expect(",");
  10026. if (allow_trailing_comma && is("punc", closing)) break;
  10027. if (is("punc", ",") && allow_empty) {
  10028. a.push(new AST_Hole({ start: S.token, end: S.token }));
  10029. } else if (is("expand", "...")) {
  10030. next();
  10031. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  10032. } else {
  10033. a.push(expression(false));
  10034. }
  10035. }
  10036. next();
  10037. return a;
  10038. }
  10039. var array_ = embed_tokens(function() {
  10040. expect("[");
  10041. return new AST_Array({
  10042. elements: expr_list("]", !options.strict, true)
  10043. });
  10044. });
  10045. var create_accessor = embed_tokens((is_generator, is_async) => {
  10046. return function_(AST_Accessor, is_generator, is_async);
  10047. });
  10048. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  10049. var start = S.token, first = true, a = [];
  10050. expect("{");
  10051. while (!is("punc", "}")) {
  10052. if (first) first = false; else expect(",");
  10053. if (!options.strict && is("punc", "}"))
  10054. // allow trailing comma
  10055. break;
  10056. start = S.token;
  10057. if (start.type == "expand") {
  10058. next();
  10059. a.push(new AST_Expansion({
  10060. start: start,
  10061. expression: expression(false),
  10062. end: prev(),
  10063. }));
  10064. continue;
  10065. }
  10066. var name = as_property_name();
  10067. var value;
  10068. // Check property and fetch value
  10069. if (!is("punc", ":")) {
  10070. var concise = concise_method_or_getset(name, start);
  10071. if (concise) {
  10072. a.push(concise);
  10073. continue;
  10074. }
  10075. value = new AST_SymbolRef({
  10076. start: prev(),
  10077. name: name,
  10078. end: prev()
  10079. });
  10080. } else if (name === null) {
  10081. unexpected(prev());
  10082. } else {
  10083. next(); // `:` - see first condition
  10084. value = expression(false);
  10085. }
  10086. // Check for default value and alter value accordingly if necessary
  10087. if (is("operator", "=")) {
  10088. next();
  10089. value = new AST_Assign({
  10090. start: start,
  10091. left: value,
  10092. operator: "=",
  10093. right: expression(false),
  10094. logical: false,
  10095. end: prev()
  10096. });
  10097. }
  10098. // Create property
  10099. a.push(new AST_ObjectKeyVal({
  10100. start: start,
  10101. quote: start.quote,
  10102. key: name instanceof AST_Node ? name : "" + name,
  10103. value: value,
  10104. end: prev()
  10105. }));
  10106. }
  10107. next();
  10108. return new AST_Object({ properties: a });
  10109. });
  10110. function class_(KindOfClass, is_export_default) {
  10111. var start, method, class_name, extends_, a = [];
  10112. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  10113. S.input.add_directive("use strict");
  10114. if (S.token.type == "name" && S.token.value != "extends") {
  10115. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  10116. }
  10117. if (KindOfClass === AST_DefClass && !class_name) {
  10118. if (is_export_default) {
  10119. KindOfClass = AST_ClassExpression;
  10120. } else {
  10121. unexpected();
  10122. }
  10123. }
  10124. if (S.token.value == "extends") {
  10125. next();
  10126. extends_ = expression(true);
  10127. }
  10128. expect("{");
  10129. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  10130. while (!is("punc", "}")) {
  10131. start = S.token;
  10132. method = concise_method_or_getset(as_property_name(), start, true);
  10133. if (!method) { unexpected(); }
  10134. a.push(method);
  10135. while (is("punc", ";")) { next(); }
  10136. }
  10137. S.input.pop_directives_stack();
  10138. next();
  10139. return new KindOfClass({
  10140. start: start,
  10141. name: class_name,
  10142. extends: extends_,
  10143. properties: a,
  10144. end: prev(),
  10145. });
  10146. }
  10147. function concise_method_or_getset(name, start, is_class) {
  10148. const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
  10149. if (typeof name === "string" || typeof name === "number") {
  10150. return new SymbolClass({
  10151. start,
  10152. name: "" + name,
  10153. end: prev()
  10154. });
  10155. } else if (name === null) {
  10156. unexpected();
  10157. }
  10158. return name;
  10159. };
  10160. const is_not_method_start = () =>
  10161. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("operator", "=");
  10162. var is_async = false;
  10163. var is_static = false;
  10164. var is_generator = false;
  10165. var is_private = false;
  10166. var accessor_type = null;
  10167. if (is_class && name === "static" && is_not_method_start()) {
  10168. is_static = true;
  10169. name = as_property_name();
  10170. }
  10171. if (name === "async" && is_not_method_start()) {
  10172. is_async = true;
  10173. name = as_property_name();
  10174. }
  10175. if (prev().type === "operator" && prev().value === "*") {
  10176. is_generator = true;
  10177. name = as_property_name();
  10178. }
  10179. if ((name === "get" || name === "set") && is_not_method_start()) {
  10180. accessor_type = name;
  10181. name = as_property_name();
  10182. }
  10183. if (prev().type === "privatename") {
  10184. is_private = true;
  10185. }
  10186. const property_token = prev();
  10187. if (accessor_type != null) {
  10188. if (!is_private) {
  10189. const AccessorClass = accessor_type === "get"
  10190. ? AST_ObjectGetter
  10191. : AST_ObjectSetter;
  10192. name = get_symbol_ast(name);
  10193. return new AccessorClass({
  10194. start,
  10195. static: is_static,
  10196. key: name,
  10197. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  10198. value: create_accessor(),
  10199. end: prev()
  10200. });
  10201. } else {
  10202. const AccessorClass = accessor_type === "get"
  10203. ? AST_PrivateGetter
  10204. : AST_PrivateSetter;
  10205. return new AccessorClass({
  10206. start,
  10207. static: is_static,
  10208. key: get_symbol_ast(name),
  10209. value: create_accessor(),
  10210. end: prev(),
  10211. });
  10212. }
  10213. }
  10214. if (is("punc", "(")) {
  10215. name = get_symbol_ast(name);
  10216. const AST_MethodVariant = is_private
  10217. ? AST_PrivateMethod
  10218. : AST_ConciseMethod;
  10219. var node = new AST_MethodVariant({
  10220. start : start,
  10221. static : is_static,
  10222. is_generator: is_generator,
  10223. async : is_async,
  10224. key : name,
  10225. quote : name instanceof AST_SymbolMethod ?
  10226. property_token.quote : undefined,
  10227. value : create_accessor(is_generator, is_async),
  10228. end : prev()
  10229. });
  10230. return node;
  10231. }
  10232. if (is_class) {
  10233. const key = get_symbol_ast(name, AST_SymbolClassProperty);
  10234. const quote = key instanceof AST_SymbolClassProperty
  10235. ? property_token.quote
  10236. : undefined;
  10237. const AST_ClassPropertyVariant = is_private
  10238. ? AST_ClassPrivateProperty
  10239. : AST_ClassProperty;
  10240. if (is("operator", "=")) {
  10241. next();
  10242. return new AST_ClassPropertyVariant({
  10243. start,
  10244. static: is_static,
  10245. quote,
  10246. key,
  10247. value: expression(false),
  10248. end: prev()
  10249. });
  10250. } else if (
  10251. is("name")
  10252. || is("privatename")
  10253. || is("operator", "*")
  10254. || is("punc", ";")
  10255. || is("punc", "}")
  10256. ) {
  10257. return new AST_ClassPropertyVariant({
  10258. start,
  10259. static: is_static,
  10260. quote,
  10261. key,
  10262. end: prev()
  10263. });
  10264. }
  10265. }
  10266. }
  10267. function import_() {
  10268. var start = prev();
  10269. var imported_name;
  10270. var imported_names;
  10271. if (is("name")) {
  10272. imported_name = as_symbol(AST_SymbolImport);
  10273. }
  10274. if (is("punc", ",")) {
  10275. next();
  10276. }
  10277. imported_names = map_names(true);
  10278. if (imported_names || imported_name) {
  10279. expect_token("name", "from");
  10280. }
  10281. var mod_str = S.token;
  10282. if (mod_str.type !== "string") {
  10283. unexpected();
  10284. }
  10285. next();
  10286. return new AST_Import({
  10287. start: start,
  10288. imported_name: imported_name,
  10289. imported_names: imported_names,
  10290. module_name: new AST_String({
  10291. start: mod_str,
  10292. value: mod_str.value,
  10293. quote: mod_str.quote,
  10294. end: mod_str,
  10295. }),
  10296. end: S.token,
  10297. });
  10298. }
  10299. function import_meta() {
  10300. var start = S.token;
  10301. expect_token("operator", "import");
  10302. expect_token("punc", ".");
  10303. expect_token("name", "meta");
  10304. return subscripts(new AST_ImportMeta({
  10305. start: start,
  10306. end: prev()
  10307. }), false);
  10308. }
  10309. function map_name(is_import) {
  10310. function make_symbol(type) {
  10311. return new type({
  10312. name: as_property_name(),
  10313. start: prev(),
  10314. end: prev()
  10315. });
  10316. }
  10317. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  10318. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  10319. var start = S.token;
  10320. var foreign_name;
  10321. var name;
  10322. if (is_import) {
  10323. foreign_name = make_symbol(foreign_type);
  10324. } else {
  10325. name = make_symbol(type);
  10326. }
  10327. if (is("name", "as")) {
  10328. next(); // The "as" word
  10329. if (is_import) {
  10330. name = make_symbol(type);
  10331. } else {
  10332. foreign_name = make_symbol(foreign_type);
  10333. }
  10334. } else if (is_import) {
  10335. name = new type(foreign_name);
  10336. } else {
  10337. foreign_name = new foreign_type(name);
  10338. }
  10339. return new AST_NameMapping({
  10340. start: start,
  10341. foreign_name: foreign_name,
  10342. name: name,
  10343. end: prev(),
  10344. });
  10345. }
  10346. function map_nameAsterisk(is_import, name) {
  10347. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  10348. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  10349. var start = S.token;
  10350. var foreign_name;
  10351. var end = prev();
  10352. name = name || new type({
  10353. name: "*",
  10354. start: start,
  10355. end: end,
  10356. });
  10357. foreign_name = new foreign_type({
  10358. name: "*",
  10359. start: start,
  10360. end: end,
  10361. });
  10362. return new AST_NameMapping({
  10363. start: start,
  10364. foreign_name: foreign_name,
  10365. name: name,
  10366. end: end,
  10367. });
  10368. }
  10369. function map_names(is_import) {
  10370. var names;
  10371. if (is("punc", "{")) {
  10372. next();
  10373. names = [];
  10374. while (!is("punc", "}")) {
  10375. names.push(map_name(is_import));
  10376. if (is("punc", ",")) {
  10377. next();
  10378. }
  10379. }
  10380. next();
  10381. } else if (is("operator", "*")) {
  10382. var name;
  10383. next();
  10384. if (is_import && is("name", "as")) {
  10385. next(); // The "as" word
  10386. name = as_symbol(is_import ? AST_SymbolImport : AST_SymbolExportForeign);
  10387. }
  10388. names = [map_nameAsterisk(is_import, name)];
  10389. }
  10390. return names;
  10391. }
  10392. function export_() {
  10393. var start = S.token;
  10394. var is_default;
  10395. var exported_names;
  10396. if (is("keyword", "default")) {
  10397. is_default = true;
  10398. next();
  10399. } else if (exported_names = map_names(false)) {
  10400. if (is("name", "from")) {
  10401. next();
  10402. var mod_str = S.token;
  10403. if (mod_str.type !== "string") {
  10404. unexpected();
  10405. }
  10406. next();
  10407. return new AST_Export({
  10408. start: start,
  10409. is_default: is_default,
  10410. exported_names: exported_names,
  10411. module_name: new AST_String({
  10412. start: mod_str,
  10413. value: mod_str.value,
  10414. quote: mod_str.quote,
  10415. end: mod_str,
  10416. }),
  10417. end: prev(),
  10418. });
  10419. } else {
  10420. return new AST_Export({
  10421. start: start,
  10422. is_default: is_default,
  10423. exported_names: exported_names,
  10424. end: prev(),
  10425. });
  10426. }
  10427. }
  10428. var node;
  10429. var exported_value;
  10430. var exported_definition;
  10431. if (is("punc", "{")
  10432. || is_default
  10433. && (is("keyword", "class") || is("keyword", "function"))
  10434. && is_token(peek(), "punc")) {
  10435. exported_value = expression(false);
  10436. semicolon();
  10437. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  10438. unexpected(node.start);
  10439. } else if (
  10440. node instanceof AST_Definitions
  10441. || node instanceof AST_Defun
  10442. || node instanceof AST_DefClass
  10443. ) {
  10444. exported_definition = node;
  10445. } else if (
  10446. node instanceof AST_ClassExpression
  10447. || node instanceof AST_Function
  10448. ) {
  10449. exported_value = node;
  10450. } else if (node instanceof AST_SimpleStatement) {
  10451. exported_value = node.body;
  10452. } else {
  10453. unexpected(node.start);
  10454. }
  10455. return new AST_Export({
  10456. start: start,
  10457. is_default: is_default,
  10458. exported_value: exported_value,
  10459. exported_definition: exported_definition,
  10460. end: prev(),
  10461. });
  10462. }
  10463. function as_property_name() {
  10464. var tmp = S.token;
  10465. switch (tmp.type) {
  10466. case "punc":
  10467. if (tmp.value === "[") {
  10468. next();
  10469. var ex = expression(false);
  10470. expect("]");
  10471. return ex;
  10472. } else unexpected(tmp);
  10473. case "operator":
  10474. if (tmp.value === "*") {
  10475. next();
  10476. return null;
  10477. }
  10478. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  10479. unexpected(tmp);
  10480. }
  10481. /* falls through */
  10482. case "name":
  10483. case "privatename":
  10484. case "string":
  10485. case "num":
  10486. case "big_int":
  10487. case "keyword":
  10488. case "atom":
  10489. next();
  10490. return tmp.value;
  10491. default:
  10492. unexpected(tmp);
  10493. }
  10494. }
  10495. function as_name() {
  10496. var tmp = S.token;
  10497. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  10498. next();
  10499. return tmp.value;
  10500. }
  10501. function _make_symbol(type) {
  10502. var name = S.token.value;
  10503. return new (name == "this" ? AST_This :
  10504. name == "super" ? AST_Super :
  10505. type)({
  10506. name : String(name),
  10507. start : S.token,
  10508. end : S.token
  10509. });
  10510. }
  10511. function _verify_symbol(sym) {
  10512. var name = sym.name;
  10513. if (is_in_generator() && name == "yield") {
  10514. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  10515. }
  10516. if (S.input.has_directive("use strict")) {
  10517. if (name == "yield") {
  10518. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  10519. }
  10520. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  10521. token_error(sym.start, "Unexpected " + name + " in strict mode");
  10522. }
  10523. }
  10524. }
  10525. function as_symbol(type, noerror) {
  10526. if (!is("name")) {
  10527. if (!noerror) croak("Name expected");
  10528. return null;
  10529. }
  10530. var sym = _make_symbol(type);
  10531. _verify_symbol(sym);
  10532. next();
  10533. return sym;
  10534. }
  10535. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  10536. function annotate(node) {
  10537. var start = node.start;
  10538. var comments = start.comments_before;
  10539. const comments_outside_parens = outer_comments_before_counts.get(start);
  10540. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  10541. while (--i >= 0) {
  10542. var comment = comments[i];
  10543. if (/[@#]__/.test(comment.value)) {
  10544. if (/[@#]__PURE__/.test(comment.value)) {
  10545. set_annotation(node, _PURE);
  10546. break;
  10547. }
  10548. if (/[@#]__INLINE__/.test(comment.value)) {
  10549. set_annotation(node, _INLINE);
  10550. break;
  10551. }
  10552. if (/[@#]__NOINLINE__/.test(comment.value)) {
  10553. set_annotation(node, _NOINLINE);
  10554. break;
  10555. }
  10556. }
  10557. }
  10558. }
  10559. var subscripts = function(expr, allow_calls, is_chain) {
  10560. var start = expr.start;
  10561. if (is("punc", ".")) {
  10562. next();
  10563. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  10564. return subscripts(new AST_DotVariant({
  10565. start : start,
  10566. expression : expr,
  10567. optional : false,
  10568. property : as_name(),
  10569. end : prev()
  10570. }), allow_calls, is_chain);
  10571. }
  10572. if (is("punc", "[")) {
  10573. next();
  10574. var prop = expression(true);
  10575. expect("]");
  10576. return subscripts(new AST_Sub({
  10577. start : start,
  10578. expression : expr,
  10579. optional : false,
  10580. property : prop,
  10581. end : prev()
  10582. }), allow_calls, is_chain);
  10583. }
  10584. if (allow_calls && is("punc", "(")) {
  10585. next();
  10586. var call = new AST_Call({
  10587. start : start,
  10588. expression : expr,
  10589. optional : false,
  10590. args : call_args(),
  10591. end : prev()
  10592. });
  10593. annotate(call);
  10594. return subscripts(call, true, is_chain);
  10595. }
  10596. if (is("punc", "?.")) {
  10597. next();
  10598. let chain_contents;
  10599. if (allow_calls && is("punc", "(")) {
  10600. next();
  10601. const call = new AST_Call({
  10602. start,
  10603. optional: true,
  10604. expression: expr,
  10605. args: call_args(),
  10606. end: prev()
  10607. });
  10608. annotate(call);
  10609. chain_contents = subscripts(call, true, true);
  10610. } else if (is("name") || is("privatename")) {
  10611. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  10612. chain_contents = subscripts(new AST_DotVariant({
  10613. start,
  10614. expression: expr,
  10615. optional: true,
  10616. property: as_name(),
  10617. end: prev()
  10618. }), allow_calls, true);
  10619. } else if (is("punc", "[")) {
  10620. next();
  10621. const property = expression(true);
  10622. expect("]");
  10623. chain_contents = subscripts(new AST_Sub({
  10624. start,
  10625. expression: expr,
  10626. optional: true,
  10627. property,
  10628. end: prev()
  10629. }), allow_calls, true);
  10630. }
  10631. if (!chain_contents) unexpected();
  10632. if (chain_contents instanceof AST_Chain) return chain_contents;
  10633. return new AST_Chain({
  10634. start,
  10635. expression: chain_contents,
  10636. end: prev()
  10637. });
  10638. }
  10639. if (is("template_head")) {
  10640. if (is_chain) {
  10641. // a?.b`c` is a syntax error
  10642. unexpected();
  10643. }
  10644. return subscripts(new AST_PrefixedTemplateString({
  10645. start: start,
  10646. prefix: expr,
  10647. template_string: template_string(),
  10648. end: prev()
  10649. }), allow_calls);
  10650. }
  10651. return expr;
  10652. };
  10653. function call_args() {
  10654. var args = [];
  10655. while (!is("punc", ")")) {
  10656. if (is("expand", "...")) {
  10657. next();
  10658. args.push(new AST_Expansion({
  10659. start: prev(),
  10660. expression: expression(false),
  10661. end: prev()
  10662. }));
  10663. } else {
  10664. args.push(expression(false));
  10665. }
  10666. if (!is("punc", ")")) {
  10667. expect(",");
  10668. }
  10669. }
  10670. next();
  10671. return args;
  10672. }
  10673. var maybe_unary = function(allow_calls, allow_arrows) {
  10674. var start = S.token;
  10675. if (start.type == "name" && start.value == "await" && can_await()) {
  10676. next();
  10677. return _await_expression();
  10678. }
  10679. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  10680. next();
  10681. handle_regexp();
  10682. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  10683. ex.start = start;
  10684. ex.end = prev();
  10685. return ex;
  10686. }
  10687. var val = expr_atom(allow_calls, allow_arrows);
  10688. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  10689. if (val instanceof AST_Arrow) unexpected();
  10690. val = make_unary(AST_UnaryPostfix, S.token, val);
  10691. val.start = start;
  10692. val.end = S.token;
  10693. next();
  10694. }
  10695. return val;
  10696. };
  10697. function make_unary(ctor, token, expr) {
  10698. var op = token.value;
  10699. switch (op) {
  10700. case "++":
  10701. case "--":
  10702. if (!is_assignable(expr))
  10703. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  10704. break;
  10705. case "delete":
  10706. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  10707. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  10708. break;
  10709. }
  10710. return new ctor({ operator: op, expression: expr });
  10711. }
  10712. var expr_op = function(left, min_prec, no_in) {
  10713. var op = is("operator") ? S.token.value : null;
  10714. if (op == "in" && no_in) op = null;
  10715. if (op == "**" && left instanceof AST_UnaryPrefix
  10716. /* unary token in front not allowed - parenthesis required */
  10717. && !is_token(left.start, "punc", "(")
  10718. && left.operator !== "--" && left.operator !== "++")
  10719. unexpected(left.start);
  10720. var prec = op != null ? PRECEDENCE[op] : null;
  10721. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  10722. next();
  10723. var right = expr_op(maybe_unary(true), prec, no_in);
  10724. return expr_op(new AST_Binary({
  10725. start : left.start,
  10726. left : left,
  10727. operator : op,
  10728. right : right,
  10729. end : right.end
  10730. }), min_prec, no_in);
  10731. }
  10732. return left;
  10733. };
  10734. function expr_ops(no_in) {
  10735. return expr_op(maybe_unary(true, true), 0, no_in);
  10736. }
  10737. var maybe_conditional = function(no_in) {
  10738. var start = S.token;
  10739. var expr = expr_ops(no_in);
  10740. if (is("operator", "?")) {
  10741. next();
  10742. var yes = expression(false);
  10743. expect(":");
  10744. return new AST_Conditional({
  10745. start : start,
  10746. condition : expr,
  10747. consequent : yes,
  10748. alternative : expression(false, no_in),
  10749. end : prev()
  10750. });
  10751. }
  10752. return expr;
  10753. };
  10754. function is_assignable(expr) {
  10755. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  10756. }
  10757. function to_destructuring(node) {
  10758. if (node instanceof AST_Object) {
  10759. node = new AST_Destructuring({
  10760. start: node.start,
  10761. names: node.properties.map(to_destructuring),
  10762. is_array: false,
  10763. end: node.end
  10764. });
  10765. } else if (node instanceof AST_Array) {
  10766. var names = [];
  10767. for (var i = 0; i < node.elements.length; i++) {
  10768. // Only allow expansion as last element
  10769. if (node.elements[i] instanceof AST_Expansion) {
  10770. if (i + 1 !== node.elements.length) {
  10771. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  10772. }
  10773. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  10774. }
  10775. names.push(to_destructuring(node.elements[i]));
  10776. }
  10777. node = new AST_Destructuring({
  10778. start: node.start,
  10779. names: names,
  10780. is_array: true,
  10781. end: node.end
  10782. });
  10783. } else if (node instanceof AST_ObjectProperty) {
  10784. node.value = to_destructuring(node.value);
  10785. } else if (node instanceof AST_Assign) {
  10786. node = new AST_DefaultAssign({
  10787. start: node.start,
  10788. left: node.left,
  10789. operator: "=",
  10790. right: node.right,
  10791. end: node.end
  10792. });
  10793. }
  10794. return node;
  10795. }
  10796. // In ES6, AssignmentExpression can also be an ArrowFunction
  10797. var maybe_assign = function(no_in) {
  10798. handle_regexp();
  10799. var start = S.token;
  10800. if (start.type == "name" && start.value == "yield") {
  10801. if (is_in_generator()) {
  10802. next();
  10803. return _yield_expression();
  10804. } else if (S.input.has_directive("use strict")) {
  10805. token_error(S.token, "Unexpected yield identifier inside strict mode");
  10806. }
  10807. }
  10808. var left = maybe_conditional(no_in);
  10809. var val = S.token.value;
  10810. if (is("operator") && ASSIGNMENT.has(val)) {
  10811. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  10812. next();
  10813. return new AST_Assign({
  10814. start : start,
  10815. left : left,
  10816. operator : val,
  10817. right : maybe_assign(no_in),
  10818. logical : LOGICAL_ASSIGNMENT.has(val),
  10819. end : prev()
  10820. });
  10821. }
  10822. croak("Invalid assignment");
  10823. }
  10824. return left;
  10825. };
  10826. var expression = function(commas, no_in) {
  10827. var start = S.token;
  10828. var exprs = [];
  10829. while (true) {
  10830. exprs.push(maybe_assign(no_in));
  10831. if (!commas || !is("punc", ",")) break;
  10832. next();
  10833. commas = true;
  10834. }
  10835. return exprs.length == 1 ? exprs[0] : new AST_Sequence({
  10836. start : start,
  10837. expressions : exprs,
  10838. end : peek()
  10839. });
  10840. };
  10841. function in_loop(cont) {
  10842. ++S.in_loop;
  10843. var ret = cont();
  10844. --S.in_loop;
  10845. return ret;
  10846. }
  10847. if (options.expression) {
  10848. return expression(true);
  10849. }
  10850. return (function parse_toplevel() {
  10851. var start = S.token;
  10852. var body = [];
  10853. S.input.push_directives_stack();
  10854. if (options.module) S.input.add_directive("use strict");
  10855. while (!is("eof")) {
  10856. body.push(statement());
  10857. }
  10858. S.input.pop_directives_stack();
  10859. var end = prev();
  10860. var toplevel = options.toplevel;
  10861. if (toplevel) {
  10862. toplevel.body = toplevel.body.concat(body);
  10863. toplevel.end = end;
  10864. } else {
  10865. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  10866. }
  10867. return toplevel;
  10868. })();
  10869. }
  10870. /***********************************************************************
  10871. A JavaScript tokenizer / parser / beautifier / compressor.
  10872. https://github.com/mishoo/UglifyJS2
  10873. -------------------------------- (C) ---------------------------------
  10874. Author: Mihai Bazon
  10875. <mihai.bazon@gmail.com>
  10876. http://mihai.bazon.net/blog
  10877. Distributed under the BSD license:
  10878. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10879. Redistribution and use in source and binary forms, with or without
  10880. modification, are permitted provided that the following conditions
  10881. are met:
  10882. * Redistributions of source code must retain the above
  10883. copyright notice, this list of conditions and the following
  10884. disclaimer.
  10885. * Redistributions in binary form must reproduce the above
  10886. copyright notice, this list of conditions and the following
  10887. disclaimer in the documentation and/or other materials
  10888. provided with the distribution.
  10889. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10890. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10891. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10892. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10893. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10894. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10895. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10896. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10897. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10898. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10899. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10900. SUCH DAMAGE.
  10901. ***********************************************************************/
  10902. function DEFNODE(type, props, methods, base = AST_Node) {
  10903. if (!props) props = [];
  10904. else props = props.split(/\s+/);
  10905. var self_props = props;
  10906. if (base && base.PROPS)
  10907. props = props.concat(base.PROPS);
  10908. var code = "return function AST_" + type + "(props){ if (props) { ";
  10909. for (var i = props.length; --i >= 0;) {
  10910. code += "this." + props[i] + " = props." + props[i] + ";";
  10911. }
  10912. const proto = base && Object.create(base.prototype);
  10913. if (proto && proto.initialize || (methods && methods.initialize))
  10914. code += "this.initialize();";
  10915. code += "}";
  10916. code += "this.flags = 0;";
  10917. code += "}";
  10918. var ctor = new Function(code)();
  10919. if (proto) {
  10920. ctor.prototype = proto;
  10921. ctor.BASE = base;
  10922. }
  10923. if (base) base.SUBCLASSES.push(ctor);
  10924. ctor.prototype.CTOR = ctor;
  10925. ctor.prototype.constructor = ctor;
  10926. ctor.PROPS = props || null;
  10927. ctor.SELF_PROPS = self_props;
  10928. ctor.SUBCLASSES = [];
  10929. if (type) {
  10930. ctor.prototype.TYPE = ctor.TYPE = type;
  10931. }
  10932. if (methods) for (i in methods) if (HOP(methods, i)) {
  10933. if (i[0] === "$") {
  10934. ctor[i.substr(1)] = methods[i];
  10935. } else {
  10936. ctor.prototype[i] = methods[i];
  10937. }
  10938. }
  10939. ctor.DEFMETHOD = function(name, method) {
  10940. this.prototype[name] = method;
  10941. };
  10942. return ctor;
  10943. }
  10944. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  10945. const set_tok_flag = (tok, flag, truth) => {
  10946. if (truth) {
  10947. tok.flags |= flag;
  10948. } else {
  10949. tok.flags &= ~flag;
  10950. }
  10951. };
  10952. const TOK_FLAG_NLB = 0b0001;
  10953. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  10954. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  10955. class AST_Token {
  10956. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  10957. this.flags = (nlb ? 1 : 0);
  10958. this.type = type;
  10959. this.value = value;
  10960. this.line = line;
  10961. this.col = col;
  10962. this.pos = pos;
  10963. this.comments_before = comments_before;
  10964. this.comments_after = comments_after;
  10965. this.file = file;
  10966. Object.seal(this);
  10967. }
  10968. get nlb() {
  10969. return has_tok_flag(this, TOK_FLAG_NLB);
  10970. }
  10971. set nlb(new_nlb) {
  10972. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  10973. }
  10974. get quote() {
  10975. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  10976. ? ""
  10977. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  10978. }
  10979. set quote(quote_type) {
  10980. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  10981. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  10982. }
  10983. }
  10984. var AST_Node = DEFNODE("Node", "start end", {
  10985. _clone: function(deep) {
  10986. if (deep) {
  10987. var self = this.clone();
  10988. return self.transform(new TreeTransformer(function(node) {
  10989. if (node !== self) {
  10990. return node.clone(true);
  10991. }
  10992. }));
  10993. }
  10994. return new this.CTOR(this);
  10995. },
  10996. clone: function(deep) {
  10997. return this._clone(deep);
  10998. },
  10999. $documentation: "Base class of all AST nodes",
  11000. $propdoc: {
  11001. start: "[AST_Token] The first token of this node",
  11002. end: "[AST_Token] The last token of this node"
  11003. },
  11004. _walk: function(visitor) {
  11005. return visitor._visit(this);
  11006. },
  11007. walk: function(visitor) {
  11008. return this._walk(visitor); // not sure the indirection will be any help
  11009. },
  11010. _children_backwards: () => {}
  11011. }, null);
  11012. /* -----[ statements ]----- */
  11013. var AST_Statement = DEFNODE("Statement", null, {
  11014. $documentation: "Base class of all statements",
  11015. });
  11016. var AST_Debugger = DEFNODE("Debugger", null, {
  11017. $documentation: "Represents a debugger statement",
  11018. }, AST_Statement);
  11019. var AST_Directive = DEFNODE("Directive", "value quote", {
  11020. $documentation: "Represents a directive, like \"use strict\";",
  11021. $propdoc: {
  11022. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  11023. quote: "[string] the original quote character"
  11024. },
  11025. }, AST_Statement);
  11026. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
  11027. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  11028. $propdoc: {
  11029. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  11030. },
  11031. _walk: function(visitor) {
  11032. return visitor._visit(this, function() {
  11033. this.body._walk(visitor);
  11034. });
  11035. },
  11036. _children_backwards(push) {
  11037. push(this.body);
  11038. }
  11039. }, AST_Statement);
  11040. function walk_body(node, visitor) {
  11041. const body = node.body;
  11042. for (var i = 0, len = body.length; i < len; i++) {
  11043. body[i]._walk(visitor);
  11044. }
  11045. }
  11046. function clone_block_scope(deep) {
  11047. var clone = this._clone(deep);
  11048. if (this.block_scope) {
  11049. clone.block_scope = this.block_scope.clone();
  11050. }
  11051. return clone;
  11052. }
  11053. var AST_Block = DEFNODE("Block", "body block_scope", {
  11054. $documentation: "A body of statements (usually braced)",
  11055. $propdoc: {
  11056. body: "[AST_Statement*] an array of statements",
  11057. block_scope: "[AST_Scope] the block scope"
  11058. },
  11059. _walk: function(visitor) {
  11060. return visitor._visit(this, function() {
  11061. walk_body(this, visitor);
  11062. });
  11063. },
  11064. _children_backwards(push) {
  11065. let i = this.body.length;
  11066. while (i--) push(this.body[i]);
  11067. },
  11068. clone: clone_block_scope
  11069. }, AST_Statement);
  11070. var AST_BlockStatement = DEFNODE("BlockStatement", null, {
  11071. $documentation: "A block statement",
  11072. }, AST_Block);
  11073. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, {
  11074. $documentation: "The empty statement (empty block or simply a semicolon)"
  11075. }, AST_Statement);
  11076. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", {
  11077. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  11078. $propdoc: {
  11079. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  11080. }
  11081. }, AST_Statement);
  11082. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
  11083. $documentation: "Statement with a label",
  11084. $propdoc: {
  11085. label: "[AST_Label] a label definition"
  11086. },
  11087. _walk: function(visitor) {
  11088. return visitor._visit(this, function() {
  11089. this.label._walk(visitor);
  11090. this.body._walk(visitor);
  11091. });
  11092. },
  11093. _children_backwards(push) {
  11094. push(this.body);
  11095. push(this.label);
  11096. },
  11097. clone: function(deep) {
  11098. var node = this._clone(deep);
  11099. if (deep) {
  11100. var label = node.label;
  11101. var def = this.label;
  11102. node.walk(new TreeWalker(function(node) {
  11103. if (node instanceof AST_LoopControl
  11104. && node.label && node.label.thedef === def) {
  11105. node.label.thedef = label;
  11106. label.references.push(node);
  11107. }
  11108. }));
  11109. }
  11110. return node;
  11111. }
  11112. }, AST_StatementWithBody);
  11113. var AST_IterationStatement = DEFNODE("IterationStatement", "block_scope", {
  11114. $documentation: "Internal class. All loops inherit from it.",
  11115. $propdoc: {
  11116. block_scope: "[AST_Scope] the block scope for this iteration statement."
  11117. },
  11118. clone: clone_block_scope
  11119. }, AST_StatementWithBody);
  11120. var AST_DWLoop = DEFNODE("DWLoop", "condition", {
  11121. $documentation: "Base class for do/while statements",
  11122. $propdoc: {
  11123. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  11124. }
  11125. }, AST_IterationStatement);
  11126. var AST_Do = DEFNODE("Do", null, {
  11127. $documentation: "A `do` statement",
  11128. _walk: function(visitor) {
  11129. return visitor._visit(this, function() {
  11130. this.body._walk(visitor);
  11131. this.condition._walk(visitor);
  11132. });
  11133. },
  11134. _children_backwards(push) {
  11135. push(this.condition);
  11136. push(this.body);
  11137. }
  11138. }, AST_DWLoop);
  11139. var AST_While = DEFNODE("While", null, {
  11140. $documentation: "A `while` statement",
  11141. _walk: function(visitor) {
  11142. return visitor._visit(this, function() {
  11143. this.condition._walk(visitor);
  11144. this.body._walk(visitor);
  11145. });
  11146. },
  11147. _children_backwards(push) {
  11148. push(this.body);
  11149. push(this.condition);
  11150. },
  11151. }, AST_DWLoop);
  11152. var AST_For = DEFNODE("For", "init condition step", {
  11153. $documentation: "A `for` statement",
  11154. $propdoc: {
  11155. init: "[AST_Node?] the `for` initialization code, or null if empty",
  11156. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  11157. step: "[AST_Node?] the `for` update clause, or null if empty"
  11158. },
  11159. _walk: function(visitor) {
  11160. return visitor._visit(this, function() {
  11161. if (this.init) this.init._walk(visitor);
  11162. if (this.condition) this.condition._walk(visitor);
  11163. if (this.step) this.step._walk(visitor);
  11164. this.body._walk(visitor);
  11165. });
  11166. },
  11167. _children_backwards(push) {
  11168. push(this.body);
  11169. if (this.step) push(this.step);
  11170. if (this.condition) push(this.condition);
  11171. if (this.init) push(this.init);
  11172. },
  11173. }, AST_IterationStatement);
  11174. var AST_ForIn = DEFNODE("ForIn", "init object", {
  11175. $documentation: "A `for ... in` statement",
  11176. $propdoc: {
  11177. init: "[AST_Node] the `for/in` initialization code",
  11178. object: "[AST_Node] the object that we're looping through"
  11179. },
  11180. _walk: function(visitor) {
  11181. return visitor._visit(this, function() {
  11182. this.init._walk(visitor);
  11183. this.object._walk(visitor);
  11184. this.body._walk(visitor);
  11185. });
  11186. },
  11187. _children_backwards(push) {
  11188. push(this.body);
  11189. if (this.object) push(this.object);
  11190. if (this.init) push(this.init);
  11191. },
  11192. }, AST_IterationStatement);
  11193. var AST_ForOf = DEFNODE("ForOf", "await", {
  11194. $documentation: "A `for ... of` statement",
  11195. }, AST_ForIn);
  11196. var AST_With = DEFNODE("With", "expression", {
  11197. $documentation: "A `with` statement",
  11198. $propdoc: {
  11199. expression: "[AST_Node] the `with` expression"
  11200. },
  11201. _walk: function(visitor) {
  11202. return visitor._visit(this, function() {
  11203. this.expression._walk(visitor);
  11204. this.body._walk(visitor);
  11205. });
  11206. },
  11207. _children_backwards(push) {
  11208. push(this.body);
  11209. push(this.expression);
  11210. },
  11211. }, AST_StatementWithBody);
  11212. /* -----[ scope and functions ]----- */
  11213. var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", {
  11214. $documentation: "Base class for all statements introducing a lexical scope",
  11215. $propdoc: {
  11216. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  11217. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  11218. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  11219. parent_scope: "[AST_Scope?/S] link to the parent scope",
  11220. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  11221. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  11222. },
  11223. get_defun_scope: function() {
  11224. var self = this;
  11225. while (self.is_block_scope()) {
  11226. self = self.parent_scope;
  11227. }
  11228. return self;
  11229. },
  11230. clone: function(deep, toplevel) {
  11231. var node = this._clone(deep);
  11232. if (deep && this.variables && toplevel && !this._block_scope) {
  11233. node.figure_out_scope({}, {
  11234. toplevel: toplevel,
  11235. parent_scope: this.parent_scope
  11236. });
  11237. } else {
  11238. if (this.variables) node.variables = new Map(this.variables);
  11239. if (this.enclosed) node.enclosed = this.enclosed.slice();
  11240. if (this._block_scope) node._block_scope = this._block_scope;
  11241. }
  11242. return node;
  11243. },
  11244. pinned: function() {
  11245. return this.uses_eval || this.uses_with;
  11246. }
  11247. }, AST_Block);
  11248. var AST_Toplevel = DEFNODE("Toplevel", "globals", {
  11249. $documentation: "The toplevel scope",
  11250. $propdoc: {
  11251. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  11252. },
  11253. wrap_commonjs: function(name) {
  11254. var body = this.body;
  11255. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  11256. wrapped_tl = parse(wrapped_tl);
  11257. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  11258. if (node instanceof AST_Directive && node.value == "$ORIG") {
  11259. return MAP.splice(body);
  11260. }
  11261. }));
  11262. return wrapped_tl;
  11263. },
  11264. wrap_enclose: function(args_values) {
  11265. if (typeof args_values != "string") args_values = "";
  11266. var index = args_values.indexOf(":");
  11267. if (index < 0) index = args_values.length;
  11268. var body = this.body;
  11269. return parse([
  11270. "(function(",
  11271. args_values.slice(0, index),
  11272. '){"$ORIG"})(',
  11273. args_values.slice(index + 1),
  11274. ")"
  11275. ].join("")).transform(new TreeTransformer(function(node) {
  11276. if (node instanceof AST_Directive && node.value == "$ORIG") {
  11277. return MAP.splice(body);
  11278. }
  11279. }));
  11280. }
  11281. }, AST_Scope);
  11282. var AST_Expansion = DEFNODE("Expansion", "expression", {
  11283. $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",
  11284. $propdoc: {
  11285. expression: "[AST_Node] the thing to be expanded"
  11286. },
  11287. _walk: function(visitor) {
  11288. return visitor._visit(this, function() {
  11289. this.expression.walk(visitor);
  11290. });
  11291. },
  11292. _children_backwards(push) {
  11293. push(this.expression);
  11294. },
  11295. });
  11296. var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments is_generator async", {
  11297. $documentation: "Base class for functions",
  11298. $propdoc: {
  11299. name: "[AST_SymbolDeclaration?] the name of this function",
  11300. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  11301. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  11302. is_generator: "[boolean] is this a generator method",
  11303. async: "[boolean] is this method async",
  11304. },
  11305. args_as_names: function () {
  11306. var out = [];
  11307. for (var i = 0; i < this.argnames.length; i++) {
  11308. if (this.argnames[i] instanceof AST_Destructuring) {
  11309. out.push(...this.argnames[i].all_symbols());
  11310. } else {
  11311. out.push(this.argnames[i]);
  11312. }
  11313. }
  11314. return out;
  11315. },
  11316. _walk: function(visitor) {
  11317. return visitor._visit(this, function() {
  11318. if (this.name) this.name._walk(visitor);
  11319. var argnames = this.argnames;
  11320. for (var i = 0, len = argnames.length; i < len; i++) {
  11321. argnames[i]._walk(visitor);
  11322. }
  11323. walk_body(this, visitor);
  11324. });
  11325. },
  11326. _children_backwards(push) {
  11327. let i = this.body.length;
  11328. while (i--) push(this.body[i]);
  11329. i = this.argnames.length;
  11330. while (i--) push(this.argnames[i]);
  11331. if (this.name) push(this.name);
  11332. },
  11333. is_braceless() {
  11334. return this.body[0] instanceof AST_Return && this.body[0].value;
  11335. },
  11336. // Default args and expansion don't count, so .argnames.length doesn't cut it
  11337. length_property() {
  11338. let length = 0;
  11339. for (const arg of this.argnames) {
  11340. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  11341. length++;
  11342. }
  11343. }
  11344. return length;
  11345. }
  11346. }, AST_Scope);
  11347. var AST_Accessor = DEFNODE("Accessor", null, {
  11348. $documentation: "A setter/getter function. The `name` property is always null."
  11349. }, AST_Lambda);
  11350. var AST_Function = DEFNODE("Function", null, {
  11351. $documentation: "A function expression"
  11352. }, AST_Lambda);
  11353. var AST_Arrow = DEFNODE("Arrow", null, {
  11354. $documentation: "An ES6 Arrow function ((a) => b)"
  11355. }, AST_Lambda);
  11356. var AST_Defun = DEFNODE("Defun", null, {
  11357. $documentation: "A function definition"
  11358. }, AST_Lambda);
  11359. /* -----[ DESTRUCTURING ]----- */
  11360. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", {
  11361. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  11362. $propdoc: {
  11363. "names": "[AST_Node*] Array of properties or elements",
  11364. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  11365. },
  11366. _walk: function(visitor) {
  11367. return visitor._visit(this, function() {
  11368. this.names.forEach(function(name) {
  11369. name._walk(visitor);
  11370. });
  11371. });
  11372. },
  11373. _children_backwards(push) {
  11374. let i = this.names.length;
  11375. while (i--) push(this.names[i]);
  11376. },
  11377. all_symbols: function() {
  11378. var out = [];
  11379. this.walk(new TreeWalker(function (node) {
  11380. if (node instanceof AST_Symbol) {
  11381. out.push(node);
  11382. }
  11383. }));
  11384. return out;
  11385. }
  11386. });
  11387. var AST_PrefixedTemplateString = DEFNODE("PrefixedTemplateString", "template_string prefix", {
  11388. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  11389. $propdoc: {
  11390. template_string: "[AST_TemplateString] The template string",
  11391. prefix: "[AST_Node] The prefix, which will get called."
  11392. },
  11393. _walk: function(visitor) {
  11394. return visitor._visit(this, function () {
  11395. this.prefix._walk(visitor);
  11396. this.template_string._walk(visitor);
  11397. });
  11398. },
  11399. _children_backwards(push) {
  11400. push(this.template_string);
  11401. push(this.prefix);
  11402. },
  11403. });
  11404. var AST_TemplateString = DEFNODE("TemplateString", "segments", {
  11405. $documentation: "A template string literal",
  11406. $propdoc: {
  11407. 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."
  11408. },
  11409. _walk: function(visitor) {
  11410. return visitor._visit(this, function() {
  11411. this.segments.forEach(function(seg) {
  11412. seg._walk(visitor);
  11413. });
  11414. });
  11415. },
  11416. _children_backwards(push) {
  11417. let i = this.segments.length;
  11418. while (i--) push(this.segments[i]);
  11419. }
  11420. });
  11421. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", {
  11422. $documentation: "A segment of a template string literal",
  11423. $propdoc: {
  11424. value: "Content of the segment",
  11425. raw: "Raw source of the segment",
  11426. }
  11427. });
  11428. /* -----[ JUMPS ]----- */
  11429. var AST_Jump = DEFNODE("Jump", null, {
  11430. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  11431. }, AST_Statement);
  11432. var AST_Exit = DEFNODE("Exit", "value", {
  11433. $documentation: "Base class for “exits” (`return` and `throw`)",
  11434. $propdoc: {
  11435. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  11436. },
  11437. _walk: function(visitor) {
  11438. return visitor._visit(this, this.value && function() {
  11439. this.value._walk(visitor);
  11440. });
  11441. },
  11442. _children_backwards(push) {
  11443. if (this.value) push(this.value);
  11444. },
  11445. }, AST_Jump);
  11446. var AST_Return = DEFNODE("Return", null, {
  11447. $documentation: "A `return` statement"
  11448. }, AST_Exit);
  11449. var AST_Throw = DEFNODE("Throw", null, {
  11450. $documentation: "A `throw` statement"
  11451. }, AST_Exit);
  11452. var AST_LoopControl = DEFNODE("LoopControl", "label", {
  11453. $documentation: "Base class for loop control statements (`break` and `continue`)",
  11454. $propdoc: {
  11455. label: "[AST_LabelRef?] the label, or null if none",
  11456. },
  11457. _walk: function(visitor) {
  11458. return visitor._visit(this, this.label && function() {
  11459. this.label._walk(visitor);
  11460. });
  11461. },
  11462. _children_backwards(push) {
  11463. if (this.label) push(this.label);
  11464. },
  11465. }, AST_Jump);
  11466. var AST_Break = DEFNODE("Break", null, {
  11467. $documentation: "A `break` statement"
  11468. }, AST_LoopControl);
  11469. var AST_Continue = DEFNODE("Continue", null, {
  11470. $documentation: "A `continue` statement"
  11471. }, AST_LoopControl);
  11472. var AST_Await = DEFNODE("Await", "expression", {
  11473. $documentation: "An `await` statement",
  11474. $propdoc: {
  11475. expression: "[AST_Node] the mandatory expression being awaited",
  11476. },
  11477. _walk: function(visitor) {
  11478. return visitor._visit(this, function() {
  11479. this.expression._walk(visitor);
  11480. });
  11481. },
  11482. _children_backwards(push) {
  11483. push(this.expression);
  11484. },
  11485. });
  11486. var AST_Yield = DEFNODE("Yield", "expression is_star", {
  11487. $documentation: "A `yield` statement",
  11488. $propdoc: {
  11489. 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",
  11490. is_star: "[Boolean] Whether this is a yield or yield* statement"
  11491. },
  11492. _walk: function(visitor) {
  11493. return visitor._visit(this, this.expression && function() {
  11494. this.expression._walk(visitor);
  11495. });
  11496. },
  11497. _children_backwards(push) {
  11498. if (this.expression) push(this.expression);
  11499. }
  11500. });
  11501. /* -----[ IF ]----- */
  11502. var AST_If = DEFNODE("If", "condition alternative", {
  11503. $documentation: "A `if` statement",
  11504. $propdoc: {
  11505. condition: "[AST_Node] the `if` condition",
  11506. alternative: "[AST_Statement?] the `else` part, or null if not present"
  11507. },
  11508. _walk: function(visitor) {
  11509. return visitor._visit(this, function() {
  11510. this.condition._walk(visitor);
  11511. this.body._walk(visitor);
  11512. if (this.alternative) this.alternative._walk(visitor);
  11513. });
  11514. },
  11515. _children_backwards(push) {
  11516. if (this.alternative) {
  11517. push(this.alternative);
  11518. }
  11519. push(this.body);
  11520. push(this.condition);
  11521. }
  11522. }, AST_StatementWithBody);
  11523. /* -----[ SWITCH ]----- */
  11524. var AST_Switch = DEFNODE("Switch", "expression", {
  11525. $documentation: "A `switch` statement",
  11526. $propdoc: {
  11527. expression: "[AST_Node] the `switch` “discriminant”"
  11528. },
  11529. _walk: function(visitor) {
  11530. return visitor._visit(this, function() {
  11531. this.expression._walk(visitor);
  11532. walk_body(this, visitor);
  11533. });
  11534. },
  11535. _children_backwards(push) {
  11536. let i = this.body.length;
  11537. while (i--) push(this.body[i]);
  11538. push(this.expression);
  11539. }
  11540. }, AST_Block);
  11541. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
  11542. $documentation: "Base class for `switch` branches",
  11543. }, AST_Block);
  11544. var AST_Default = DEFNODE("Default", null, {
  11545. $documentation: "A `default` switch branch",
  11546. }, AST_SwitchBranch);
  11547. var AST_Case = DEFNODE("Case", "expression", {
  11548. $documentation: "A `case` switch branch",
  11549. $propdoc: {
  11550. expression: "[AST_Node] the `case` expression"
  11551. },
  11552. _walk: function(visitor) {
  11553. return visitor._visit(this, function() {
  11554. this.expression._walk(visitor);
  11555. walk_body(this, visitor);
  11556. });
  11557. },
  11558. _children_backwards(push) {
  11559. let i = this.body.length;
  11560. while (i--) push(this.body[i]);
  11561. push(this.expression);
  11562. },
  11563. }, AST_SwitchBranch);
  11564. /* -----[ EXCEPTIONS ]----- */
  11565. var AST_Try = DEFNODE("Try", "bcatch bfinally", {
  11566. $documentation: "A `try` statement",
  11567. $propdoc: {
  11568. bcatch: "[AST_Catch?] the catch block, or null if not present",
  11569. bfinally: "[AST_Finally?] the finally block, or null if not present"
  11570. },
  11571. _walk: function(visitor) {
  11572. return visitor._visit(this, function() {
  11573. walk_body(this, visitor);
  11574. if (this.bcatch) this.bcatch._walk(visitor);
  11575. if (this.bfinally) this.bfinally._walk(visitor);
  11576. });
  11577. },
  11578. _children_backwards(push) {
  11579. if (this.bfinally) push(this.bfinally);
  11580. if (this.bcatch) push(this.bcatch);
  11581. let i = this.body.length;
  11582. while (i--) push(this.body[i]);
  11583. },
  11584. }, AST_Block);
  11585. var AST_Catch = DEFNODE("Catch", "argname", {
  11586. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  11587. $propdoc: {
  11588. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  11589. },
  11590. _walk: function(visitor) {
  11591. return visitor._visit(this, function() {
  11592. if (this.argname) this.argname._walk(visitor);
  11593. walk_body(this, visitor);
  11594. });
  11595. },
  11596. _children_backwards(push) {
  11597. let i = this.body.length;
  11598. while (i--) push(this.body[i]);
  11599. if (this.argname) push(this.argname);
  11600. },
  11601. }, AST_Block);
  11602. var AST_Finally = DEFNODE("Finally", null, {
  11603. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  11604. }, AST_Block);
  11605. /* -----[ VAR/CONST ]----- */
  11606. var AST_Definitions = DEFNODE("Definitions", "definitions", {
  11607. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  11608. $propdoc: {
  11609. definitions: "[AST_VarDef*] array of variable definitions"
  11610. },
  11611. _walk: function(visitor) {
  11612. return visitor._visit(this, function() {
  11613. var definitions = this.definitions;
  11614. for (var i = 0, len = definitions.length; i < len; i++) {
  11615. definitions[i]._walk(visitor);
  11616. }
  11617. });
  11618. },
  11619. _children_backwards(push) {
  11620. let i = this.definitions.length;
  11621. while (i--) push(this.definitions[i]);
  11622. },
  11623. }, AST_Statement);
  11624. var AST_Var = DEFNODE("Var", null, {
  11625. $documentation: "A `var` statement"
  11626. }, AST_Definitions);
  11627. var AST_Let = DEFNODE("Let", null, {
  11628. $documentation: "A `let` statement"
  11629. }, AST_Definitions);
  11630. var AST_Const = DEFNODE("Const", null, {
  11631. $documentation: "A `const` statement"
  11632. }, AST_Definitions);
  11633. var AST_VarDef = DEFNODE("VarDef", "name value", {
  11634. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  11635. $propdoc: {
  11636. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  11637. value: "[AST_Node?] initializer, or null of there's no initializer"
  11638. },
  11639. _walk: function(visitor) {
  11640. return visitor._visit(this, function() {
  11641. this.name._walk(visitor);
  11642. if (this.value) this.value._walk(visitor);
  11643. });
  11644. },
  11645. _children_backwards(push) {
  11646. if (this.value) push(this.value);
  11647. push(this.name);
  11648. },
  11649. });
  11650. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", {
  11651. $documentation: "The part of the export/import statement that declare names from a module.",
  11652. $propdoc: {
  11653. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  11654. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  11655. },
  11656. _walk: function (visitor) {
  11657. return visitor._visit(this, function() {
  11658. this.foreign_name._walk(visitor);
  11659. this.name._walk(visitor);
  11660. });
  11661. },
  11662. _children_backwards(push) {
  11663. push(this.name);
  11664. push(this.foreign_name);
  11665. },
  11666. });
  11667. var AST_Import = DEFNODE("Import", "imported_name imported_names module_name", {
  11668. $documentation: "An `import` statement",
  11669. $propdoc: {
  11670. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  11671. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  11672. module_name: "[AST_String] String literal describing where this module came from",
  11673. },
  11674. _walk: function(visitor) {
  11675. return visitor._visit(this, function() {
  11676. if (this.imported_name) {
  11677. this.imported_name._walk(visitor);
  11678. }
  11679. if (this.imported_names) {
  11680. this.imported_names.forEach(function(name_import) {
  11681. name_import._walk(visitor);
  11682. });
  11683. }
  11684. this.module_name._walk(visitor);
  11685. });
  11686. },
  11687. _children_backwards(push) {
  11688. push(this.module_name);
  11689. if (this.imported_names) {
  11690. let i = this.imported_names.length;
  11691. while (i--) push(this.imported_names[i]);
  11692. }
  11693. if (this.imported_name) push(this.imported_name);
  11694. },
  11695. });
  11696. var AST_ImportMeta = DEFNODE("ImportMeta", null, {
  11697. $documentation: "A reference to import.meta",
  11698. });
  11699. var AST_Export = DEFNODE("Export", "exported_definition exported_value is_default exported_names module_name", {
  11700. $documentation: "An `export` statement",
  11701. $propdoc: {
  11702. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  11703. exported_value: "[AST_Node?] An exported value",
  11704. exported_names: "[AST_NameMapping*?] List of exported names",
  11705. module_name: "[AST_String?] Name of the file to load exports from",
  11706. is_default: "[Boolean] Whether this is the default exported value of this module"
  11707. },
  11708. _walk: function (visitor) {
  11709. return visitor._visit(this, function () {
  11710. if (this.exported_definition) {
  11711. this.exported_definition._walk(visitor);
  11712. }
  11713. if (this.exported_value) {
  11714. this.exported_value._walk(visitor);
  11715. }
  11716. if (this.exported_names) {
  11717. this.exported_names.forEach(function(name_export) {
  11718. name_export._walk(visitor);
  11719. });
  11720. }
  11721. if (this.module_name) {
  11722. this.module_name._walk(visitor);
  11723. }
  11724. });
  11725. },
  11726. _children_backwards(push) {
  11727. if (this.module_name) push(this.module_name);
  11728. if (this.exported_names) {
  11729. let i = this.exported_names.length;
  11730. while (i--) push(this.exported_names[i]);
  11731. }
  11732. if (this.exported_value) push(this.exported_value);
  11733. if (this.exported_definition) push(this.exported_definition);
  11734. }
  11735. }, AST_Statement);
  11736. /* -----[ OTHER ]----- */
  11737. var AST_Call = DEFNODE("Call", "expression args optional _annotations", {
  11738. $documentation: "A function call expression",
  11739. $propdoc: {
  11740. expression: "[AST_Node] expression to invoke as function",
  11741. args: "[AST_Node*] array of arguments",
  11742. optional: "[boolean] whether this is an optional call (IE ?.() )",
  11743. _annotations: "[number] bitfield containing information about the call"
  11744. },
  11745. initialize() {
  11746. if (this._annotations == null) this._annotations = 0;
  11747. },
  11748. _walk(visitor) {
  11749. return visitor._visit(this, function() {
  11750. var args = this.args;
  11751. for (var i = 0, len = args.length; i < len; i++) {
  11752. args[i]._walk(visitor);
  11753. }
  11754. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  11755. });
  11756. },
  11757. _children_backwards(push) {
  11758. let i = this.args.length;
  11759. while (i--) push(this.args[i]);
  11760. push(this.expression);
  11761. },
  11762. });
  11763. var AST_New = DEFNODE("New", null, {
  11764. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  11765. }, AST_Call);
  11766. var AST_Sequence = DEFNODE("Sequence", "expressions", {
  11767. $documentation: "A sequence expression (comma-separated expressions)",
  11768. $propdoc: {
  11769. expressions: "[AST_Node*] array of expressions (at least two)"
  11770. },
  11771. _walk: function(visitor) {
  11772. return visitor._visit(this, function() {
  11773. this.expressions.forEach(function(node) {
  11774. node._walk(visitor);
  11775. });
  11776. });
  11777. },
  11778. _children_backwards(push) {
  11779. let i = this.expressions.length;
  11780. while (i--) push(this.expressions[i]);
  11781. },
  11782. });
  11783. var AST_PropAccess = DEFNODE("PropAccess", "expression property optional", {
  11784. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  11785. $propdoc: {
  11786. expression: "[AST_Node] the “container” expression",
  11787. 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",
  11788. optional: "[boolean] whether this is an optional property access (IE ?.)"
  11789. }
  11790. });
  11791. var AST_Dot = DEFNODE("Dot", "quote", {
  11792. $documentation: "A dotted property access expression",
  11793. $propdoc: {
  11794. quote: "[string] the original quote character when transformed from AST_Sub",
  11795. },
  11796. _walk: function(visitor) {
  11797. return visitor._visit(this, function() {
  11798. this.expression._walk(visitor);
  11799. });
  11800. },
  11801. _children_backwards(push) {
  11802. push(this.expression);
  11803. },
  11804. }, AST_PropAccess);
  11805. var AST_DotHash = DEFNODE("DotHash", "", {
  11806. $documentation: "A dotted property access to a private property",
  11807. _walk: function(visitor) {
  11808. return visitor._visit(this, function() {
  11809. this.expression._walk(visitor);
  11810. });
  11811. },
  11812. _children_backwards(push) {
  11813. push(this.expression);
  11814. },
  11815. }, AST_PropAccess);
  11816. var AST_Sub = DEFNODE("Sub", null, {
  11817. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  11818. _walk: function(visitor) {
  11819. return visitor._visit(this, function() {
  11820. this.expression._walk(visitor);
  11821. this.property._walk(visitor);
  11822. });
  11823. },
  11824. _children_backwards(push) {
  11825. push(this.property);
  11826. push(this.expression);
  11827. },
  11828. }, AST_PropAccess);
  11829. var AST_Chain = DEFNODE("Chain", "expression", {
  11830. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  11831. $propdoc: {
  11832. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  11833. },
  11834. _walk: function (visitor) {
  11835. return visitor._visit(this, function() {
  11836. this.expression._walk(visitor);
  11837. });
  11838. },
  11839. _children_backwards(push) {
  11840. push(this.expression);
  11841. },
  11842. });
  11843. var AST_Unary = DEFNODE("Unary", "operator expression", {
  11844. $documentation: "Base class for unary expressions",
  11845. $propdoc: {
  11846. operator: "[string] the operator",
  11847. expression: "[AST_Node] expression that this unary operator applies to"
  11848. },
  11849. _walk: function(visitor) {
  11850. return visitor._visit(this, function() {
  11851. this.expression._walk(visitor);
  11852. });
  11853. },
  11854. _children_backwards(push) {
  11855. push(this.expression);
  11856. },
  11857. });
  11858. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, {
  11859. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  11860. }, AST_Unary);
  11861. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, {
  11862. $documentation: "Unary postfix expression, i.e. `i++`"
  11863. }, AST_Unary);
  11864. var AST_Binary = DEFNODE("Binary", "operator left right", {
  11865. $documentation: "Binary expression, i.e. `a + b`",
  11866. $propdoc: {
  11867. left: "[AST_Node] left-hand side expression",
  11868. operator: "[string] the operator",
  11869. right: "[AST_Node] right-hand side expression"
  11870. },
  11871. _walk: function(visitor) {
  11872. return visitor._visit(this, function() {
  11873. this.left._walk(visitor);
  11874. this.right._walk(visitor);
  11875. });
  11876. },
  11877. _children_backwards(push) {
  11878. push(this.right);
  11879. push(this.left);
  11880. },
  11881. });
  11882. var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative", {
  11883. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  11884. $propdoc: {
  11885. condition: "[AST_Node]",
  11886. consequent: "[AST_Node]",
  11887. alternative: "[AST_Node]"
  11888. },
  11889. _walk: function(visitor) {
  11890. return visitor._visit(this, function() {
  11891. this.condition._walk(visitor);
  11892. this.consequent._walk(visitor);
  11893. this.alternative._walk(visitor);
  11894. });
  11895. },
  11896. _children_backwards(push) {
  11897. push(this.alternative);
  11898. push(this.consequent);
  11899. push(this.condition);
  11900. },
  11901. });
  11902. var AST_Assign = DEFNODE("Assign", "logical", {
  11903. $documentation: "An assignment expression — `a = b + 5`",
  11904. $propdoc: {
  11905. logical: "Whether it's a logical assignment"
  11906. }
  11907. }, AST_Binary);
  11908. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, {
  11909. $documentation: "A default assignment expression like in `(a = 3) => a`"
  11910. }, AST_Binary);
  11911. /* -----[ LITERALS ]----- */
  11912. var AST_Array = DEFNODE("Array", "elements", {
  11913. $documentation: "An array literal",
  11914. $propdoc: {
  11915. elements: "[AST_Node*] array of elements"
  11916. },
  11917. _walk: function(visitor) {
  11918. return visitor._visit(this, function() {
  11919. var elements = this.elements;
  11920. for (var i = 0, len = elements.length; i < len; i++) {
  11921. elements[i]._walk(visitor);
  11922. }
  11923. });
  11924. },
  11925. _children_backwards(push) {
  11926. let i = this.elements.length;
  11927. while (i--) push(this.elements[i]);
  11928. },
  11929. });
  11930. var AST_Object = DEFNODE("Object", "properties", {
  11931. $documentation: "An object literal",
  11932. $propdoc: {
  11933. properties: "[AST_ObjectProperty*] array of properties"
  11934. },
  11935. _walk: function(visitor) {
  11936. return visitor._visit(this, function() {
  11937. var properties = this.properties;
  11938. for (var i = 0, len = properties.length; i < len; i++) {
  11939. properties[i]._walk(visitor);
  11940. }
  11941. });
  11942. },
  11943. _children_backwards(push) {
  11944. let i = this.properties.length;
  11945. while (i--) push(this.properties[i]);
  11946. },
  11947. });
  11948. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
  11949. $documentation: "Base class for literal object properties",
  11950. $propdoc: {
  11951. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  11952. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  11953. },
  11954. _walk: function(visitor) {
  11955. return visitor._visit(this, function() {
  11956. if (this.key instanceof AST_Node)
  11957. this.key._walk(visitor);
  11958. this.value._walk(visitor);
  11959. });
  11960. },
  11961. _children_backwards(push) {
  11962. push(this.value);
  11963. if (this.key instanceof AST_Node) push(this.key);
  11964. }
  11965. });
  11966. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
  11967. $documentation: "A key: value object property",
  11968. $propdoc: {
  11969. quote: "[string] the original quote character"
  11970. },
  11971. computed_key() {
  11972. return this.key instanceof AST_Node;
  11973. }
  11974. }, AST_ObjectProperty);
  11975. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", {
  11976. $propdoc: {
  11977. static: "[boolean] whether this is a static private setter"
  11978. },
  11979. $documentation: "A private setter property",
  11980. computed_key() {
  11981. return false;
  11982. }
  11983. }, AST_ObjectProperty);
  11984. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", {
  11985. $propdoc: {
  11986. static: "[boolean] whether this is a static private getter"
  11987. },
  11988. $documentation: "A private getter property",
  11989. computed_key() {
  11990. return false;
  11991. }
  11992. }, AST_ObjectProperty);
  11993. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", {
  11994. $propdoc: {
  11995. quote: "[string|undefined] the original quote character, if any",
  11996. static: "[boolean] whether this is a static setter (classes only)"
  11997. },
  11998. $documentation: "An object setter property",
  11999. computed_key() {
  12000. return !(this.key instanceof AST_SymbolMethod);
  12001. }
  12002. }, AST_ObjectProperty);
  12003. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", {
  12004. $propdoc: {
  12005. quote: "[string|undefined] the original quote character, if any",
  12006. static: "[boolean] whether this is a static getter (classes only)"
  12007. },
  12008. $documentation: "An object getter property",
  12009. computed_key() {
  12010. return !(this.key instanceof AST_SymbolMethod);
  12011. }
  12012. }, AST_ObjectProperty);
  12013. var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator async", {
  12014. $propdoc: {
  12015. quote: "[string|undefined] the original quote character, if any",
  12016. static: "[boolean] is this method static (classes only)",
  12017. is_generator: "[boolean] is this a generator method",
  12018. async: "[boolean] is this method async",
  12019. },
  12020. $documentation: "An ES6 concise method inside an object or class",
  12021. computed_key() {
  12022. return !(this.key instanceof AST_SymbolMethod);
  12023. }
  12024. }, AST_ObjectProperty);
  12025. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", {
  12026. $documentation: "A private class method inside a class",
  12027. }, AST_ConciseMethod);
  12028. var AST_Class = DEFNODE("Class", "name extends properties", {
  12029. $propdoc: {
  12030. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  12031. extends: "[AST_Node]? optional parent class",
  12032. properties: "[AST_ObjectProperty*] array of properties"
  12033. },
  12034. $documentation: "An ES6 class",
  12035. _walk: function(visitor) {
  12036. return visitor._visit(this, function() {
  12037. if (this.name) {
  12038. this.name._walk(visitor);
  12039. }
  12040. if (this.extends) {
  12041. this.extends._walk(visitor);
  12042. }
  12043. this.properties.forEach((prop) => prop._walk(visitor));
  12044. });
  12045. },
  12046. _children_backwards(push) {
  12047. let i = this.properties.length;
  12048. while (i--) push(this.properties[i]);
  12049. if (this.extends) push(this.extends);
  12050. if (this.name) push(this.name);
  12051. },
  12052. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  12053. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", {
  12054. $documentation: "A class property",
  12055. $propdoc: {
  12056. static: "[boolean] whether this is a static key",
  12057. quote: "[string] which quote is being used"
  12058. },
  12059. _walk: function(visitor) {
  12060. return visitor._visit(this, function() {
  12061. if (this.key instanceof AST_Node)
  12062. this.key._walk(visitor);
  12063. if (this.value instanceof AST_Node)
  12064. this.value._walk(visitor);
  12065. });
  12066. },
  12067. _children_backwards(push) {
  12068. if (this.value instanceof AST_Node) push(this.value);
  12069. if (this.key instanceof AST_Node) push(this.key);
  12070. },
  12071. computed_key() {
  12072. return !(this.key instanceof AST_SymbolClassProperty);
  12073. }
  12074. }, AST_ObjectProperty);
  12075. var AST_ClassPrivateProperty = DEFNODE("ClassProperty", "", {
  12076. $documentation: "A class property for a private property",
  12077. }, AST_ClassProperty);
  12078. var AST_DefClass = DEFNODE("DefClass", null, {
  12079. $documentation: "A class definition",
  12080. }, AST_Class);
  12081. var AST_ClassExpression = DEFNODE("ClassExpression", null, {
  12082. $documentation: "A class expression."
  12083. }, AST_Class);
  12084. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
  12085. $propdoc: {
  12086. name: "[string] name of this symbol",
  12087. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  12088. thedef: "[SymbolDef/S] the definition of this symbol"
  12089. },
  12090. $documentation: "Base class for all symbols"
  12091. });
  12092. var AST_NewTarget = DEFNODE("NewTarget", null, {
  12093. $documentation: "A reference to new.target"
  12094. });
  12095. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
  12096. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  12097. }, AST_Symbol);
  12098. var AST_SymbolVar = DEFNODE("SymbolVar", null, {
  12099. $documentation: "Symbol defining a variable",
  12100. }, AST_SymbolDeclaration);
  12101. var AST_SymbolBlockDeclaration = DEFNODE("SymbolBlockDeclaration", null, {
  12102. $documentation: "Base class for block-scoped declaration symbols"
  12103. }, AST_SymbolDeclaration);
  12104. var AST_SymbolConst = DEFNODE("SymbolConst", null, {
  12105. $documentation: "A constant declaration"
  12106. }, AST_SymbolBlockDeclaration);
  12107. var AST_SymbolLet = DEFNODE("SymbolLet", null, {
  12108. $documentation: "A block-scoped `let` declaration"
  12109. }, AST_SymbolBlockDeclaration);
  12110. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
  12111. $documentation: "Symbol naming a function argument",
  12112. }, AST_SymbolVar);
  12113. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, {
  12114. $documentation: "Symbol defining a function",
  12115. }, AST_SymbolDeclaration);
  12116. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, {
  12117. $documentation: "Symbol in an object defining a method",
  12118. }, AST_Symbol);
  12119. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, {
  12120. $documentation: "Symbol for a class property",
  12121. }, AST_Symbol);
  12122. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, {
  12123. $documentation: "Symbol naming a function expression",
  12124. }, AST_SymbolDeclaration);
  12125. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, {
  12126. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  12127. }, AST_SymbolBlockDeclaration);
  12128. var AST_SymbolClass = DEFNODE("SymbolClass", null, {
  12129. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  12130. }, AST_SymbolDeclaration);
  12131. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, {
  12132. $documentation: "Symbol naming the exception in catch",
  12133. }, AST_SymbolBlockDeclaration);
  12134. var AST_SymbolImport = DEFNODE("SymbolImport", null, {
  12135. $documentation: "Symbol referring to an imported name",
  12136. }, AST_SymbolBlockDeclaration);
  12137. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, {
  12138. $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",
  12139. }, AST_Symbol);
  12140. var AST_Label = DEFNODE("Label", "references", {
  12141. $documentation: "Symbol naming a label (declaration)",
  12142. $propdoc: {
  12143. references: "[AST_LoopControl*] a list of nodes referring to this label"
  12144. },
  12145. initialize: function() {
  12146. this.references = [];
  12147. this.thedef = this;
  12148. }
  12149. }, AST_Symbol);
  12150. var AST_SymbolRef = DEFNODE("SymbolRef", null, {
  12151. $documentation: "Reference to some symbol (not definition/declaration)",
  12152. }, AST_Symbol);
  12153. var AST_SymbolExport = DEFNODE("SymbolExport", null, {
  12154. $documentation: "Symbol referring to a name to export",
  12155. }, AST_SymbolRef);
  12156. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, {
  12157. $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",
  12158. }, AST_Symbol);
  12159. var AST_LabelRef = DEFNODE("LabelRef", null, {
  12160. $documentation: "Reference to a label symbol",
  12161. }, AST_Symbol);
  12162. var AST_This = DEFNODE("This", null, {
  12163. $documentation: "The `this` symbol",
  12164. }, AST_Symbol);
  12165. var AST_Super = DEFNODE("Super", null, {
  12166. $documentation: "The `super` symbol",
  12167. }, AST_This);
  12168. var AST_Constant = DEFNODE("Constant", null, {
  12169. $documentation: "Base class for all constants",
  12170. getValue: function() {
  12171. return this.value;
  12172. }
  12173. });
  12174. var AST_String = DEFNODE("String", "value quote", {
  12175. $documentation: "A string literal",
  12176. $propdoc: {
  12177. value: "[string] the contents of this string",
  12178. quote: "[string] the original quote character"
  12179. }
  12180. }, AST_Constant);
  12181. var AST_Number = DEFNODE("Number", "value raw", {
  12182. $documentation: "A number literal",
  12183. $propdoc: {
  12184. value: "[number] the numeric value",
  12185. raw: "[string] numeric value as string"
  12186. }
  12187. }, AST_Constant);
  12188. var AST_BigInt = DEFNODE("BigInt", "value", {
  12189. $documentation: "A big int literal",
  12190. $propdoc: {
  12191. value: "[string] big int value"
  12192. }
  12193. }, AST_Constant);
  12194. var AST_RegExp = DEFNODE("RegExp", "value", {
  12195. $documentation: "A regexp literal",
  12196. $propdoc: {
  12197. value: "[RegExp] the actual regexp",
  12198. }
  12199. }, AST_Constant);
  12200. var AST_Atom = DEFNODE("Atom", null, {
  12201. $documentation: "Base class for atoms",
  12202. }, AST_Constant);
  12203. var AST_Null = DEFNODE("Null", null, {
  12204. $documentation: "The `null` atom",
  12205. value: null
  12206. }, AST_Atom);
  12207. var AST_NaN = DEFNODE("NaN", null, {
  12208. $documentation: "The impossible value",
  12209. value: 0/0
  12210. }, AST_Atom);
  12211. var AST_Undefined = DEFNODE("Undefined", null, {
  12212. $documentation: "The `undefined` value",
  12213. value: (function() {}())
  12214. }, AST_Atom);
  12215. var AST_Hole = DEFNODE("Hole", null, {
  12216. $documentation: "A hole in an array",
  12217. value: (function() {}())
  12218. }, AST_Atom);
  12219. var AST_Infinity = DEFNODE("Infinity", null, {
  12220. $documentation: "The `Infinity` value",
  12221. value: 1/0
  12222. }, AST_Atom);
  12223. var AST_Boolean = DEFNODE("Boolean", null, {
  12224. $documentation: "Base class for booleans",
  12225. }, AST_Atom);
  12226. var AST_False = DEFNODE("False", null, {
  12227. $documentation: "The `false` atom",
  12228. value: false
  12229. }, AST_Boolean);
  12230. var AST_True = DEFNODE("True", null, {
  12231. $documentation: "The `true` atom",
  12232. value: true
  12233. }, AST_Boolean);
  12234. /* -----[ Walk function ]---- */
  12235. /**
  12236. * Walk nodes in depth-first search fashion.
  12237. * Callback can return `walk_abort` symbol to stop iteration.
  12238. * It can also return `true` to stop iteration just for child nodes.
  12239. * Iteration can be stopped and continued by passing the `to_visit` argument,
  12240. * which is given to the callback in the second argument.
  12241. **/
  12242. function walk(node, cb, to_visit = [node]) {
  12243. const push = to_visit.push.bind(to_visit);
  12244. while (to_visit.length) {
  12245. const node = to_visit.pop();
  12246. const ret = cb(node, to_visit);
  12247. if (ret) {
  12248. if (ret === walk_abort) return true;
  12249. continue;
  12250. }
  12251. node._children_backwards(push);
  12252. }
  12253. return false;
  12254. }
  12255. function walk_parent(node, cb, initial_stack) {
  12256. const to_visit = [node];
  12257. const push = to_visit.push.bind(to_visit);
  12258. const stack = initial_stack ? initial_stack.slice() : [];
  12259. const parent_pop_indices = [];
  12260. let current;
  12261. const info = {
  12262. parent: (n = 0) => {
  12263. if (n === -1) {
  12264. return current;
  12265. }
  12266. // [ p1 p0 ] [ 1 0 ]
  12267. if (initial_stack && n >= stack.length) {
  12268. n -= stack.length;
  12269. return initial_stack[
  12270. initial_stack.length - (n + 1)
  12271. ];
  12272. }
  12273. return stack[stack.length - (1 + n)];
  12274. },
  12275. };
  12276. while (to_visit.length) {
  12277. current = to_visit.pop();
  12278. while (
  12279. parent_pop_indices.length &&
  12280. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  12281. ) {
  12282. stack.pop();
  12283. parent_pop_indices.pop();
  12284. }
  12285. const ret = cb(current, info);
  12286. if (ret) {
  12287. if (ret === walk_abort) return true;
  12288. continue;
  12289. }
  12290. const visit_length = to_visit.length;
  12291. current._children_backwards(push);
  12292. // Push only if we're going to traverse the children
  12293. if (to_visit.length > visit_length) {
  12294. stack.push(current);
  12295. parent_pop_indices.push(visit_length - 1);
  12296. }
  12297. }
  12298. return false;
  12299. }
  12300. const walk_abort = Symbol("abort walk");
  12301. /* -----[ TreeWalker ]----- */
  12302. class TreeWalker {
  12303. constructor(callback) {
  12304. this.visit = callback;
  12305. this.stack = [];
  12306. this.directives = Object.create(null);
  12307. }
  12308. _visit(node, descend) {
  12309. this.push(node);
  12310. var ret = this.visit(node, descend ? function() {
  12311. descend.call(node);
  12312. } : noop);
  12313. if (!ret && descend) {
  12314. descend.call(node);
  12315. }
  12316. this.pop();
  12317. return ret;
  12318. }
  12319. parent(n) {
  12320. return this.stack[this.stack.length - 2 - (n || 0)];
  12321. }
  12322. push(node) {
  12323. if (node instanceof AST_Lambda) {
  12324. this.directives = Object.create(this.directives);
  12325. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  12326. this.directives[node.value] = node;
  12327. } else if (node instanceof AST_Class) {
  12328. this.directives = Object.create(this.directives);
  12329. if (!this.directives["use strict"]) {
  12330. this.directives["use strict"] = node;
  12331. }
  12332. }
  12333. this.stack.push(node);
  12334. }
  12335. pop() {
  12336. var node = this.stack.pop();
  12337. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  12338. this.directives = Object.getPrototypeOf(this.directives);
  12339. }
  12340. }
  12341. self() {
  12342. return this.stack[this.stack.length - 1];
  12343. }
  12344. find_parent(type) {
  12345. var stack = this.stack;
  12346. for (var i = stack.length; --i >= 0;) {
  12347. var x = stack[i];
  12348. if (x instanceof type) return x;
  12349. }
  12350. }
  12351. has_directive(type) {
  12352. var dir = this.directives[type];
  12353. if (dir) return dir;
  12354. var node = this.stack[this.stack.length - 1];
  12355. if (node instanceof AST_Scope && node.body) {
  12356. for (var i = 0; i < node.body.length; ++i) {
  12357. var st = node.body[i];
  12358. if (!(st instanceof AST_Directive)) break;
  12359. if (st.value == type) return st;
  12360. }
  12361. }
  12362. }
  12363. loopcontrol_target(node) {
  12364. var stack = this.stack;
  12365. if (node.label) for (var i = stack.length; --i >= 0;) {
  12366. var x = stack[i];
  12367. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  12368. return x.body;
  12369. } else for (var i = stack.length; --i >= 0;) {
  12370. var x = stack[i];
  12371. if (x instanceof AST_IterationStatement
  12372. || node instanceof AST_Break && x instanceof AST_Switch)
  12373. return x;
  12374. }
  12375. }
  12376. }
  12377. // Tree transformer helpers.
  12378. class TreeTransformer extends TreeWalker {
  12379. constructor(before, after) {
  12380. super();
  12381. this.before = before;
  12382. this.after = after;
  12383. }
  12384. }
  12385. const _PURE = 0b00000001;
  12386. const _INLINE = 0b00000010;
  12387. const _NOINLINE = 0b00000100;
  12388. var ast = /*#__PURE__*/Object.freeze({
  12389. __proto__: null,
  12390. AST_Accessor: AST_Accessor,
  12391. AST_Array: AST_Array,
  12392. AST_Arrow: AST_Arrow,
  12393. AST_Assign: AST_Assign,
  12394. AST_Atom: AST_Atom,
  12395. AST_Await: AST_Await,
  12396. AST_BigInt: AST_BigInt,
  12397. AST_Binary: AST_Binary,
  12398. AST_Block: AST_Block,
  12399. AST_BlockStatement: AST_BlockStatement,
  12400. AST_Boolean: AST_Boolean,
  12401. AST_Break: AST_Break,
  12402. AST_Call: AST_Call,
  12403. AST_Case: AST_Case,
  12404. AST_Catch: AST_Catch,
  12405. AST_Chain: AST_Chain,
  12406. AST_Class: AST_Class,
  12407. AST_ClassExpression: AST_ClassExpression,
  12408. AST_ClassPrivateProperty: AST_ClassPrivateProperty,
  12409. AST_ClassProperty: AST_ClassProperty,
  12410. AST_ConciseMethod: AST_ConciseMethod,
  12411. AST_Conditional: AST_Conditional,
  12412. AST_Const: AST_Const,
  12413. AST_Constant: AST_Constant,
  12414. AST_Continue: AST_Continue,
  12415. AST_Debugger: AST_Debugger,
  12416. AST_Default: AST_Default,
  12417. AST_DefaultAssign: AST_DefaultAssign,
  12418. AST_DefClass: AST_DefClass,
  12419. AST_Definitions: AST_Definitions,
  12420. AST_Defun: AST_Defun,
  12421. AST_Destructuring: AST_Destructuring,
  12422. AST_Directive: AST_Directive,
  12423. AST_Do: AST_Do,
  12424. AST_Dot: AST_Dot,
  12425. AST_DotHash: AST_DotHash,
  12426. AST_DWLoop: AST_DWLoop,
  12427. AST_EmptyStatement: AST_EmptyStatement,
  12428. AST_Exit: AST_Exit,
  12429. AST_Expansion: AST_Expansion,
  12430. AST_Export: AST_Export,
  12431. AST_False: AST_False,
  12432. AST_Finally: AST_Finally,
  12433. AST_For: AST_For,
  12434. AST_ForIn: AST_ForIn,
  12435. AST_ForOf: AST_ForOf,
  12436. AST_Function: AST_Function,
  12437. AST_Hole: AST_Hole,
  12438. AST_If: AST_If,
  12439. AST_Import: AST_Import,
  12440. AST_ImportMeta: AST_ImportMeta,
  12441. AST_Infinity: AST_Infinity,
  12442. AST_IterationStatement: AST_IterationStatement,
  12443. AST_Jump: AST_Jump,
  12444. AST_Label: AST_Label,
  12445. AST_LabeledStatement: AST_LabeledStatement,
  12446. AST_LabelRef: AST_LabelRef,
  12447. AST_Lambda: AST_Lambda,
  12448. AST_Let: AST_Let,
  12449. AST_LoopControl: AST_LoopControl,
  12450. AST_NameMapping: AST_NameMapping,
  12451. AST_NaN: AST_NaN,
  12452. AST_New: AST_New,
  12453. AST_NewTarget: AST_NewTarget,
  12454. AST_Node: AST_Node,
  12455. AST_Null: AST_Null,
  12456. AST_Number: AST_Number,
  12457. AST_Object: AST_Object,
  12458. AST_ObjectGetter: AST_ObjectGetter,
  12459. AST_ObjectKeyVal: AST_ObjectKeyVal,
  12460. AST_ObjectProperty: AST_ObjectProperty,
  12461. AST_ObjectSetter: AST_ObjectSetter,
  12462. AST_PrefixedTemplateString: AST_PrefixedTemplateString,
  12463. AST_PrivateGetter: AST_PrivateGetter,
  12464. AST_PrivateMethod: AST_PrivateMethod,
  12465. AST_PrivateSetter: AST_PrivateSetter,
  12466. AST_PropAccess: AST_PropAccess,
  12467. AST_RegExp: AST_RegExp,
  12468. AST_Return: AST_Return,
  12469. AST_Scope: AST_Scope,
  12470. AST_Sequence: AST_Sequence,
  12471. AST_SimpleStatement: AST_SimpleStatement,
  12472. AST_Statement: AST_Statement,
  12473. AST_StatementWithBody: AST_StatementWithBody,
  12474. AST_String: AST_String,
  12475. AST_Sub: AST_Sub,
  12476. AST_Super: AST_Super,
  12477. AST_Switch: AST_Switch,
  12478. AST_SwitchBranch: AST_SwitchBranch,
  12479. AST_Symbol: AST_Symbol,
  12480. AST_SymbolBlockDeclaration: AST_SymbolBlockDeclaration,
  12481. AST_SymbolCatch: AST_SymbolCatch,
  12482. AST_SymbolClass: AST_SymbolClass,
  12483. AST_SymbolClassProperty: AST_SymbolClassProperty,
  12484. AST_SymbolConst: AST_SymbolConst,
  12485. AST_SymbolDeclaration: AST_SymbolDeclaration,
  12486. AST_SymbolDefClass: AST_SymbolDefClass,
  12487. AST_SymbolDefun: AST_SymbolDefun,
  12488. AST_SymbolExport: AST_SymbolExport,
  12489. AST_SymbolExportForeign: AST_SymbolExportForeign,
  12490. AST_SymbolFunarg: AST_SymbolFunarg,
  12491. AST_SymbolImport: AST_SymbolImport,
  12492. AST_SymbolImportForeign: AST_SymbolImportForeign,
  12493. AST_SymbolLambda: AST_SymbolLambda,
  12494. AST_SymbolLet: AST_SymbolLet,
  12495. AST_SymbolMethod: AST_SymbolMethod,
  12496. AST_SymbolRef: AST_SymbolRef,
  12497. AST_SymbolVar: AST_SymbolVar,
  12498. AST_TemplateSegment: AST_TemplateSegment,
  12499. AST_TemplateString: AST_TemplateString,
  12500. AST_This: AST_This,
  12501. AST_Throw: AST_Throw,
  12502. AST_Token: AST_Token,
  12503. AST_Toplevel: AST_Toplevel,
  12504. AST_True: AST_True,
  12505. AST_Try: AST_Try,
  12506. AST_Unary: AST_Unary,
  12507. AST_UnaryPostfix: AST_UnaryPostfix,
  12508. AST_UnaryPrefix: AST_UnaryPrefix,
  12509. AST_Undefined: AST_Undefined,
  12510. AST_Var: AST_Var,
  12511. AST_VarDef: AST_VarDef,
  12512. AST_While: AST_While,
  12513. AST_With: AST_With,
  12514. AST_Yield: AST_Yield,
  12515. TreeTransformer: TreeTransformer,
  12516. TreeWalker: TreeWalker,
  12517. walk: walk,
  12518. walk_abort: walk_abort,
  12519. walk_body: walk_body,
  12520. walk_parent: walk_parent,
  12521. _INLINE: _INLINE,
  12522. _NOINLINE: _NOINLINE,
  12523. _PURE: _PURE
  12524. });
  12525. /***********************************************************************
  12526. A JavaScript tokenizer / parser / beautifier / compressor.
  12527. https://github.com/mishoo/UglifyJS2
  12528. -------------------------------- (C) ---------------------------------
  12529. Author: Mihai Bazon
  12530. <mihai.bazon@gmail.com>
  12531. http://mihai.bazon.net/blog
  12532. Distributed under the BSD license:
  12533. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12534. Redistribution and use in source and binary forms, with or without
  12535. modification, are permitted provided that the following conditions
  12536. are met:
  12537. * Redistributions of source code must retain the above
  12538. copyright notice, this list of conditions and the following
  12539. disclaimer.
  12540. * Redistributions in binary form must reproduce the above
  12541. copyright notice, this list of conditions and the following
  12542. disclaimer in the documentation and/or other materials
  12543. provided with the distribution.
  12544. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12545. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12546. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12547. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12548. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12549. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12550. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12551. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12552. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12553. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12554. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12555. SUCH DAMAGE.
  12556. ***********************************************************************/
  12557. function def_transform(node, descend) {
  12558. node.DEFMETHOD("transform", function(tw, in_list) {
  12559. let transformed = undefined;
  12560. tw.push(this);
  12561. if (tw.before) transformed = tw.before(this, descend, in_list);
  12562. if (transformed === undefined) {
  12563. transformed = this;
  12564. descend(transformed, tw);
  12565. if (tw.after) {
  12566. const after_ret = tw.after(transformed, in_list);
  12567. if (after_ret !== undefined) transformed = after_ret;
  12568. }
  12569. }
  12570. tw.pop();
  12571. return transformed;
  12572. });
  12573. }
  12574. function do_list(list, tw) {
  12575. return MAP(list, function(node) {
  12576. return node.transform(tw, true);
  12577. });
  12578. }
  12579. def_transform(AST_Node, noop);
  12580. def_transform(AST_LabeledStatement, function(self, tw) {
  12581. self.label = self.label.transform(tw);
  12582. self.body = self.body.transform(tw);
  12583. });
  12584. def_transform(AST_SimpleStatement, function(self, tw) {
  12585. self.body = self.body.transform(tw);
  12586. });
  12587. def_transform(AST_Block, function(self, tw) {
  12588. self.body = do_list(self.body, tw);
  12589. });
  12590. def_transform(AST_Do, function(self, tw) {
  12591. self.body = self.body.transform(tw);
  12592. self.condition = self.condition.transform(tw);
  12593. });
  12594. def_transform(AST_While, function(self, tw) {
  12595. self.condition = self.condition.transform(tw);
  12596. self.body = self.body.transform(tw);
  12597. });
  12598. def_transform(AST_For, function(self, tw) {
  12599. if (self.init) self.init = self.init.transform(tw);
  12600. if (self.condition) self.condition = self.condition.transform(tw);
  12601. if (self.step) self.step = self.step.transform(tw);
  12602. self.body = self.body.transform(tw);
  12603. });
  12604. def_transform(AST_ForIn, function(self, tw) {
  12605. self.init = self.init.transform(tw);
  12606. self.object = self.object.transform(tw);
  12607. self.body = self.body.transform(tw);
  12608. });
  12609. def_transform(AST_With, function(self, tw) {
  12610. self.expression = self.expression.transform(tw);
  12611. self.body = self.body.transform(tw);
  12612. });
  12613. def_transform(AST_Exit, function(self, tw) {
  12614. if (self.value) self.value = self.value.transform(tw);
  12615. });
  12616. def_transform(AST_LoopControl, function(self, tw) {
  12617. if (self.label) self.label = self.label.transform(tw);
  12618. });
  12619. def_transform(AST_If, function(self, tw) {
  12620. self.condition = self.condition.transform(tw);
  12621. self.body = self.body.transform(tw);
  12622. if (self.alternative) self.alternative = self.alternative.transform(tw);
  12623. });
  12624. def_transform(AST_Switch, function(self, tw) {
  12625. self.expression = self.expression.transform(tw);
  12626. self.body = do_list(self.body, tw);
  12627. });
  12628. def_transform(AST_Case, function(self, tw) {
  12629. self.expression = self.expression.transform(tw);
  12630. self.body = do_list(self.body, tw);
  12631. });
  12632. def_transform(AST_Try, function(self, tw) {
  12633. self.body = do_list(self.body, tw);
  12634. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  12635. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  12636. });
  12637. def_transform(AST_Catch, function(self, tw) {
  12638. if (self.argname) self.argname = self.argname.transform(tw);
  12639. self.body = do_list(self.body, tw);
  12640. });
  12641. def_transform(AST_Definitions, function(self, tw) {
  12642. self.definitions = do_list(self.definitions, tw);
  12643. });
  12644. def_transform(AST_VarDef, function(self, tw) {
  12645. self.name = self.name.transform(tw);
  12646. if (self.value) self.value = self.value.transform(tw);
  12647. });
  12648. def_transform(AST_Destructuring, function(self, tw) {
  12649. self.names = do_list(self.names, tw);
  12650. });
  12651. def_transform(AST_Lambda, function(self, tw) {
  12652. if (self.name) self.name = self.name.transform(tw);
  12653. self.argnames = do_list(self.argnames, tw);
  12654. if (self.body instanceof AST_Node) {
  12655. self.body = self.body.transform(tw);
  12656. } else {
  12657. self.body = do_list(self.body, tw);
  12658. }
  12659. });
  12660. def_transform(AST_Call, function(self, tw) {
  12661. self.expression = self.expression.transform(tw);
  12662. self.args = do_list(self.args, tw);
  12663. });
  12664. def_transform(AST_Sequence, function(self, tw) {
  12665. const result = do_list(self.expressions, tw);
  12666. self.expressions = result.length
  12667. ? result
  12668. : [new AST_Number({ value: 0 })];
  12669. });
  12670. def_transform(AST_Dot, function(self, tw) {
  12671. self.expression = self.expression.transform(tw);
  12672. });
  12673. def_transform(AST_Sub, function(self, tw) {
  12674. self.expression = self.expression.transform(tw);
  12675. self.property = self.property.transform(tw);
  12676. });
  12677. def_transform(AST_Chain, function(self, tw) {
  12678. self.expression = self.expression.transform(tw);
  12679. });
  12680. def_transform(AST_Yield, function(self, tw) {
  12681. if (self.expression) self.expression = self.expression.transform(tw);
  12682. });
  12683. def_transform(AST_Await, function(self, tw) {
  12684. self.expression = self.expression.transform(tw);
  12685. });
  12686. def_transform(AST_Unary, function(self, tw) {
  12687. self.expression = self.expression.transform(tw);
  12688. });
  12689. def_transform(AST_Binary, function(self, tw) {
  12690. self.left = self.left.transform(tw);
  12691. self.right = self.right.transform(tw);
  12692. });
  12693. def_transform(AST_Conditional, function(self, tw) {
  12694. self.condition = self.condition.transform(tw);
  12695. self.consequent = self.consequent.transform(tw);
  12696. self.alternative = self.alternative.transform(tw);
  12697. });
  12698. def_transform(AST_Array, function(self, tw) {
  12699. self.elements = do_list(self.elements, tw);
  12700. });
  12701. def_transform(AST_Object, function(self, tw) {
  12702. self.properties = do_list(self.properties, tw);
  12703. });
  12704. def_transform(AST_ObjectProperty, function(self, tw) {
  12705. if (self.key instanceof AST_Node) {
  12706. self.key = self.key.transform(tw);
  12707. }
  12708. if (self.value) self.value = self.value.transform(tw);
  12709. });
  12710. def_transform(AST_Class, function(self, tw) {
  12711. if (self.name) self.name = self.name.transform(tw);
  12712. if (self.extends) self.extends = self.extends.transform(tw);
  12713. self.properties = do_list(self.properties, tw);
  12714. });
  12715. def_transform(AST_Expansion, function(self, tw) {
  12716. self.expression = self.expression.transform(tw);
  12717. });
  12718. def_transform(AST_NameMapping, function(self, tw) {
  12719. self.foreign_name = self.foreign_name.transform(tw);
  12720. self.name = self.name.transform(tw);
  12721. });
  12722. def_transform(AST_Import, function(self, tw) {
  12723. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  12724. if (self.imported_names) do_list(self.imported_names, tw);
  12725. self.module_name = self.module_name.transform(tw);
  12726. });
  12727. def_transform(AST_Export, function(self, tw) {
  12728. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  12729. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  12730. if (self.exported_names) do_list(self.exported_names, tw);
  12731. if (self.module_name) self.module_name = self.module_name.transform(tw);
  12732. });
  12733. def_transform(AST_TemplateString, function(self, tw) {
  12734. self.segments = do_list(self.segments, tw);
  12735. });
  12736. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  12737. self.prefix = self.prefix.transform(tw);
  12738. self.template_string = self.template_string.transform(tw);
  12739. });
  12740. /***********************************************************************
  12741. A JavaScript tokenizer / parser / beautifier / compressor.
  12742. https://github.com/mishoo/UglifyJS2
  12743. -------------------------------- (C) ---------------------------------
  12744. Author: Mihai Bazon
  12745. <mihai.bazon@gmail.com>
  12746. http://mihai.bazon.net/blog
  12747. Distributed under the BSD license:
  12748. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12749. Redistribution and use in source and binary forms, with or without
  12750. modification, are permitted provided that the following conditions
  12751. are met:
  12752. * Redistributions of source code must retain the above
  12753. copyright notice, this list of conditions and the following
  12754. disclaimer.
  12755. * Redistributions in binary form must reproduce the above
  12756. copyright notice, this list of conditions and the following
  12757. disclaimer in the documentation and/or other materials
  12758. provided with the distribution.
  12759. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12760. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12761. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12762. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12763. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12764. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12765. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12766. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12767. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12768. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12769. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12770. SUCH DAMAGE.
  12771. ***********************************************************************/
  12772. (function() {
  12773. var normalize_directives = function(body) {
  12774. var in_directive = true;
  12775. for (var i = 0; i < body.length; i++) {
  12776. if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  12777. body[i] = new AST_Directive({
  12778. start: body[i].start,
  12779. end: body[i].end,
  12780. value: body[i].body.value
  12781. });
  12782. } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
  12783. in_directive = false;
  12784. }
  12785. }
  12786. return body;
  12787. };
  12788. var MOZ_TO_ME = {
  12789. Program: function(M) {
  12790. return new AST_Toplevel({
  12791. start: my_start_token(M),
  12792. end: my_end_token(M),
  12793. body: normalize_directives(M.body.map(from_moz))
  12794. });
  12795. },
  12796. ArrayPattern: function(M) {
  12797. return new AST_Destructuring({
  12798. start: my_start_token(M),
  12799. end: my_end_token(M),
  12800. names: M.elements.map(function(elm) {
  12801. if (elm === null) {
  12802. return new AST_Hole();
  12803. }
  12804. return from_moz(elm);
  12805. }),
  12806. is_array: true
  12807. });
  12808. },
  12809. ObjectPattern: function(M) {
  12810. return new AST_Destructuring({
  12811. start: my_start_token(M),
  12812. end: my_end_token(M),
  12813. names: M.properties.map(from_moz),
  12814. is_array: false
  12815. });
  12816. },
  12817. AssignmentPattern: function(M) {
  12818. return new AST_DefaultAssign({
  12819. start: my_start_token(M),
  12820. end: my_end_token(M),
  12821. left: from_moz(M.left),
  12822. operator: "=",
  12823. right: from_moz(M.right)
  12824. });
  12825. },
  12826. SpreadElement: function(M) {
  12827. return new AST_Expansion({
  12828. start: my_start_token(M),
  12829. end: my_end_token(M),
  12830. expression: from_moz(M.argument)
  12831. });
  12832. },
  12833. RestElement: function(M) {
  12834. return new AST_Expansion({
  12835. start: my_start_token(M),
  12836. end: my_end_token(M),
  12837. expression: from_moz(M.argument)
  12838. });
  12839. },
  12840. TemplateElement: function(M) {
  12841. return new AST_TemplateSegment({
  12842. start: my_start_token(M),
  12843. end: my_end_token(M),
  12844. value: M.value.cooked,
  12845. raw: M.value.raw
  12846. });
  12847. },
  12848. TemplateLiteral: function(M) {
  12849. var segments = [];
  12850. for (var i = 0; i < M.quasis.length; i++) {
  12851. segments.push(from_moz(M.quasis[i]));
  12852. if (M.expressions[i]) {
  12853. segments.push(from_moz(M.expressions[i]));
  12854. }
  12855. }
  12856. return new AST_TemplateString({
  12857. start: my_start_token(M),
  12858. end: my_end_token(M),
  12859. segments: segments
  12860. });
  12861. },
  12862. TaggedTemplateExpression: function(M) {
  12863. return new AST_PrefixedTemplateString({
  12864. start: my_start_token(M),
  12865. end: my_end_token(M),
  12866. template_string: from_moz(M.quasi),
  12867. prefix: from_moz(M.tag)
  12868. });
  12869. },
  12870. FunctionDeclaration: function(M) {
  12871. return new AST_Defun({
  12872. start: my_start_token(M),
  12873. end: my_end_token(M),
  12874. name: from_moz(M.id),
  12875. argnames: M.params.map(from_moz),
  12876. is_generator: M.generator,
  12877. async: M.async,
  12878. body: normalize_directives(from_moz(M.body).body)
  12879. });
  12880. },
  12881. FunctionExpression: function(M) {
  12882. return new AST_Function({
  12883. start: my_start_token(M),
  12884. end: my_end_token(M),
  12885. name: from_moz(M.id),
  12886. argnames: M.params.map(from_moz),
  12887. is_generator: M.generator,
  12888. async: M.async,
  12889. body: normalize_directives(from_moz(M.body).body)
  12890. });
  12891. },
  12892. ArrowFunctionExpression: function(M) {
  12893. const body = M.body.type === "BlockStatement"
  12894. ? from_moz(M.body).body
  12895. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  12896. return new AST_Arrow({
  12897. start: my_start_token(M),
  12898. end: my_end_token(M),
  12899. argnames: M.params.map(from_moz),
  12900. body,
  12901. async: M.async,
  12902. });
  12903. },
  12904. ExpressionStatement: function(M) {
  12905. return new AST_SimpleStatement({
  12906. start: my_start_token(M),
  12907. end: my_end_token(M),
  12908. body: from_moz(M.expression)
  12909. });
  12910. },
  12911. TryStatement: function(M) {
  12912. var handlers = M.handlers || [M.handler];
  12913. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  12914. throw new Error("Multiple catch clauses are not supported.");
  12915. }
  12916. return new AST_Try({
  12917. start : my_start_token(M),
  12918. end : my_end_token(M),
  12919. body : from_moz(M.block).body,
  12920. bcatch : from_moz(handlers[0]),
  12921. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  12922. });
  12923. },
  12924. Property: function(M) {
  12925. var key = M.key;
  12926. var args = {
  12927. start : my_start_token(key || M.value),
  12928. end : my_end_token(M.value),
  12929. key : key.type == "Identifier" ? key.name : key.value,
  12930. value : from_moz(M.value)
  12931. };
  12932. if (M.computed) {
  12933. args.key = from_moz(M.key);
  12934. }
  12935. if (M.method) {
  12936. args.is_generator = M.value.generator;
  12937. args.async = M.value.async;
  12938. if (!M.computed) {
  12939. args.key = new AST_SymbolMethod({ name: args.key });
  12940. } else {
  12941. args.key = from_moz(M.key);
  12942. }
  12943. return new AST_ConciseMethod(args);
  12944. }
  12945. if (M.kind == "init") {
  12946. if (key.type != "Identifier" && key.type != "Literal") {
  12947. args.key = from_moz(key);
  12948. }
  12949. return new AST_ObjectKeyVal(args);
  12950. }
  12951. if (typeof args.key === "string" || typeof args.key === "number") {
  12952. args.key = new AST_SymbolMethod({
  12953. name: args.key
  12954. });
  12955. }
  12956. args.value = new AST_Accessor(args.value);
  12957. if (M.kind == "get") return new AST_ObjectGetter(args);
  12958. if (M.kind == "set") return new AST_ObjectSetter(args);
  12959. if (M.kind == "method") {
  12960. args.async = M.value.async;
  12961. args.is_generator = M.value.generator;
  12962. args.quote = M.computed ? "\"" : null;
  12963. return new AST_ConciseMethod(args);
  12964. }
  12965. },
  12966. MethodDefinition: function(M) {
  12967. var args = {
  12968. start : my_start_token(M),
  12969. end : my_end_token(M),
  12970. key : M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value }),
  12971. value : from_moz(M.value),
  12972. static : M.static,
  12973. };
  12974. if (M.kind == "get") {
  12975. return new AST_ObjectGetter(args);
  12976. }
  12977. if (M.kind == "set") {
  12978. return new AST_ObjectSetter(args);
  12979. }
  12980. args.is_generator = M.value.generator;
  12981. args.async = M.value.async;
  12982. return new AST_ConciseMethod(args);
  12983. },
  12984. FieldDefinition: function(M) {
  12985. let key;
  12986. if (M.computed) {
  12987. key = from_moz(M.key);
  12988. } else {
  12989. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  12990. key = from_moz(M.key);
  12991. }
  12992. return new AST_ClassProperty({
  12993. start : my_start_token(M),
  12994. end : my_end_token(M),
  12995. key,
  12996. value : from_moz(M.value),
  12997. static : M.static,
  12998. });
  12999. },
  13000. PropertyDefinition: function(M) {
  13001. let key;
  13002. if (M.computed) {
  13003. key = from_moz(M.key);
  13004. } else {
  13005. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in PropertyDefinition");
  13006. key = from_moz(M.key);
  13007. }
  13008. return new AST_ClassProperty({
  13009. start : my_start_token(M),
  13010. end : my_end_token(M),
  13011. key,
  13012. value : from_moz(M.value),
  13013. static : M.static,
  13014. });
  13015. },
  13016. ArrayExpression: function(M) {
  13017. return new AST_Array({
  13018. start : my_start_token(M),
  13019. end : my_end_token(M),
  13020. elements : M.elements.map(function(elem) {
  13021. return elem === null ? new AST_Hole() : from_moz(elem);
  13022. })
  13023. });
  13024. },
  13025. ObjectExpression: function(M) {
  13026. return new AST_Object({
  13027. start : my_start_token(M),
  13028. end : my_end_token(M),
  13029. properties : M.properties.map(function(prop) {
  13030. if (prop.type === "SpreadElement") {
  13031. return from_moz(prop);
  13032. }
  13033. prop.type = "Property";
  13034. return from_moz(prop);
  13035. })
  13036. });
  13037. },
  13038. SequenceExpression: function(M) {
  13039. return new AST_Sequence({
  13040. start : my_start_token(M),
  13041. end : my_end_token(M),
  13042. expressions: M.expressions.map(from_moz)
  13043. });
  13044. },
  13045. MemberExpression: function(M) {
  13046. return new (M.computed ? AST_Sub : AST_Dot)({
  13047. start : my_start_token(M),
  13048. end : my_end_token(M),
  13049. property : M.computed ? from_moz(M.property) : M.property.name,
  13050. expression : from_moz(M.object),
  13051. optional : M.optional || false
  13052. });
  13053. },
  13054. ChainExpression: function(M) {
  13055. return new AST_Chain({
  13056. start : my_start_token(M),
  13057. end : my_end_token(M),
  13058. expression : from_moz(M.expression)
  13059. });
  13060. },
  13061. SwitchCase: function(M) {
  13062. return new (M.test ? AST_Case : AST_Default)({
  13063. start : my_start_token(M),
  13064. end : my_end_token(M),
  13065. expression : from_moz(M.test),
  13066. body : M.consequent.map(from_moz)
  13067. });
  13068. },
  13069. VariableDeclaration: function(M) {
  13070. return new (M.kind === "const" ? AST_Const :
  13071. M.kind === "let" ? AST_Let : AST_Var)({
  13072. start : my_start_token(M),
  13073. end : my_end_token(M),
  13074. definitions : M.declarations.map(from_moz)
  13075. });
  13076. },
  13077. ImportDeclaration: function(M) {
  13078. var imported_name = null;
  13079. var imported_names = null;
  13080. M.specifiers.forEach(function (specifier) {
  13081. if (specifier.type === "ImportSpecifier") {
  13082. if (!imported_names) { imported_names = []; }
  13083. imported_names.push(new AST_NameMapping({
  13084. start: my_start_token(specifier),
  13085. end: my_end_token(specifier),
  13086. foreign_name: from_moz(specifier.imported),
  13087. name: from_moz(specifier.local)
  13088. }));
  13089. } else if (specifier.type === "ImportDefaultSpecifier") {
  13090. imported_name = from_moz(specifier.local);
  13091. } else if (specifier.type === "ImportNamespaceSpecifier") {
  13092. if (!imported_names) { imported_names = []; }
  13093. imported_names.push(new AST_NameMapping({
  13094. start: my_start_token(specifier),
  13095. end: my_end_token(specifier),
  13096. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  13097. name: from_moz(specifier.local)
  13098. }));
  13099. }
  13100. });
  13101. return new AST_Import({
  13102. start : my_start_token(M),
  13103. end : my_end_token(M),
  13104. imported_name: imported_name,
  13105. imported_names : imported_names,
  13106. module_name : from_moz(M.source)
  13107. });
  13108. },
  13109. ExportAllDeclaration: function(M) {
  13110. return new AST_Export({
  13111. start: my_start_token(M),
  13112. end: my_end_token(M),
  13113. exported_names: [
  13114. new AST_NameMapping({
  13115. name: new AST_SymbolExportForeign({ name: "*" }),
  13116. foreign_name: new AST_SymbolExportForeign({ name: "*" })
  13117. })
  13118. ],
  13119. module_name: from_moz(M.source)
  13120. });
  13121. },
  13122. ExportNamedDeclaration: function(M) {
  13123. return new AST_Export({
  13124. start: my_start_token(M),
  13125. end: my_end_token(M),
  13126. exported_definition: from_moz(M.declaration),
  13127. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(function (specifier) {
  13128. return new AST_NameMapping({
  13129. foreign_name: from_moz(specifier.exported),
  13130. name: from_moz(specifier.local)
  13131. });
  13132. }) : null,
  13133. module_name: from_moz(M.source)
  13134. });
  13135. },
  13136. ExportDefaultDeclaration: function(M) {
  13137. return new AST_Export({
  13138. start: my_start_token(M),
  13139. end: my_end_token(M),
  13140. exported_value: from_moz(M.declaration),
  13141. is_default: true
  13142. });
  13143. },
  13144. Literal: function(M) {
  13145. var val = M.value, args = {
  13146. start : my_start_token(M),
  13147. end : my_end_token(M)
  13148. };
  13149. var rx = M.regex;
  13150. if (rx && rx.pattern) {
  13151. // RegExpLiteral as per ESTree AST spec
  13152. args.value = {
  13153. source: rx.pattern,
  13154. flags: rx.flags
  13155. };
  13156. return new AST_RegExp(args);
  13157. } else if (rx) {
  13158. // support legacy RegExp
  13159. const rx_source = M.raw || val;
  13160. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  13161. if (!match) throw new Error("Invalid regex source " + rx_source);
  13162. const [_, source, flags] = match;
  13163. args.value = { source, flags };
  13164. return new AST_RegExp(args);
  13165. }
  13166. if (val === null) return new AST_Null(args);
  13167. switch (typeof val) {
  13168. case "string":
  13169. args.value = val;
  13170. return new AST_String(args);
  13171. case "number":
  13172. args.value = val;
  13173. args.raw = M.raw || val.toString();
  13174. return new AST_Number(args);
  13175. case "boolean":
  13176. return new (val ? AST_True : AST_False)(args);
  13177. }
  13178. },
  13179. MetaProperty: function(M) {
  13180. if (M.meta.name === "new" && M.property.name === "target") {
  13181. return new AST_NewTarget({
  13182. start: my_start_token(M),
  13183. end: my_end_token(M)
  13184. });
  13185. } else if (M.meta.name === "import" && M.property.name === "meta") {
  13186. return new AST_ImportMeta({
  13187. start: my_start_token(M),
  13188. end: my_end_token(M)
  13189. });
  13190. }
  13191. },
  13192. Identifier: function(M) {
  13193. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  13194. return new ( p.type == "LabeledStatement" ? AST_Label
  13195. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  13196. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  13197. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  13198. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  13199. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  13200. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  13201. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  13202. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  13203. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  13204. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  13205. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  13206. : p.type == "CatchClause" ? AST_SymbolCatch
  13207. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  13208. : AST_SymbolRef)({
  13209. start : my_start_token(M),
  13210. end : my_end_token(M),
  13211. name : M.name
  13212. });
  13213. },
  13214. BigIntLiteral(M) {
  13215. return new AST_BigInt({
  13216. start : my_start_token(M),
  13217. end : my_end_token(M),
  13218. value : M.value
  13219. });
  13220. }
  13221. };
  13222. MOZ_TO_ME.UpdateExpression =
  13223. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  13224. var prefix = "prefix" in M ? M.prefix
  13225. : M.type == "UnaryExpression" ? true : false;
  13226. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  13227. start : my_start_token(M),
  13228. end : my_end_token(M),
  13229. operator : M.operator,
  13230. expression : from_moz(M.argument)
  13231. });
  13232. };
  13233. MOZ_TO_ME.ClassDeclaration =
  13234. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  13235. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  13236. start : my_start_token(M),
  13237. end : my_end_token(M),
  13238. name : from_moz(M.id),
  13239. extends : from_moz(M.superClass),
  13240. properties: M.body.body.map(from_moz)
  13241. });
  13242. };
  13243. map("EmptyStatement", AST_EmptyStatement);
  13244. map("BlockStatement", AST_BlockStatement, "body@body");
  13245. map("IfStatement", AST_If, "test>condition, consequent>body, alternate>alternative");
  13246. map("LabeledStatement", AST_LabeledStatement, "label>label, body>body");
  13247. map("BreakStatement", AST_Break, "label>label");
  13248. map("ContinueStatement", AST_Continue, "label>label");
  13249. map("WithStatement", AST_With, "object>expression, body>body");
  13250. map("SwitchStatement", AST_Switch, "discriminant>expression, cases@body");
  13251. map("ReturnStatement", AST_Return, "argument>value");
  13252. map("ThrowStatement", AST_Throw, "argument>value");
  13253. map("WhileStatement", AST_While, "test>condition, body>body");
  13254. map("DoWhileStatement", AST_Do, "test>condition, body>body");
  13255. map("ForStatement", AST_For, "init>init, test>condition, update>step, body>body");
  13256. map("ForInStatement", AST_ForIn, "left>init, right>object, body>body");
  13257. map("ForOfStatement", AST_ForOf, "left>init, right>object, body>body, await=await");
  13258. map("AwaitExpression", AST_Await, "argument>expression");
  13259. map("YieldExpression", AST_Yield, "argument>expression, delegate=is_star");
  13260. map("DebuggerStatement", AST_Debugger);
  13261. map("VariableDeclarator", AST_VarDef, "id>name, init>value");
  13262. map("CatchClause", AST_Catch, "param>argname, body%body");
  13263. map("ThisExpression", AST_This);
  13264. map("Super", AST_Super);
  13265. map("BinaryExpression", AST_Binary, "operator=operator, left>left, right>right");
  13266. map("LogicalExpression", AST_Binary, "operator=operator, left>left, right>right");
  13267. map("AssignmentExpression", AST_Assign, "operator=operator, left>left, right>right");
  13268. map("ConditionalExpression", AST_Conditional, "test>condition, consequent>consequent, alternate>alternative");
  13269. map("NewExpression", AST_New, "callee>expression, arguments@args");
  13270. map("CallExpression", AST_Call, "callee>expression, optional=optional, arguments@args");
  13271. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  13272. return to_moz_scope("Program", M);
  13273. });
  13274. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  13275. return {
  13276. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  13277. argument: to_moz(M.expression)
  13278. };
  13279. });
  13280. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  13281. return {
  13282. type: "TaggedTemplateExpression",
  13283. tag: to_moz(M.prefix),
  13284. quasi: to_moz(M.template_string)
  13285. };
  13286. });
  13287. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  13288. var quasis = [];
  13289. var expressions = [];
  13290. for (var i = 0; i < M.segments.length; i++) {
  13291. if (i % 2 !== 0) {
  13292. expressions.push(to_moz(M.segments[i]));
  13293. } else {
  13294. quasis.push({
  13295. type: "TemplateElement",
  13296. value: {
  13297. raw: M.segments[i].raw,
  13298. cooked: M.segments[i].value
  13299. },
  13300. tail: i === M.segments.length - 1
  13301. });
  13302. }
  13303. }
  13304. return {
  13305. type: "TemplateLiteral",
  13306. quasis: quasis,
  13307. expressions: expressions
  13308. };
  13309. });
  13310. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  13311. return {
  13312. type: "FunctionDeclaration",
  13313. id: to_moz(M.name),
  13314. params: M.argnames.map(to_moz),
  13315. generator: M.is_generator,
  13316. async: M.async,
  13317. body: to_moz_scope("BlockStatement", M)
  13318. };
  13319. });
  13320. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  13321. var is_generator = parent.is_generator !== undefined ?
  13322. parent.is_generator : M.is_generator;
  13323. return {
  13324. type: "FunctionExpression",
  13325. id: to_moz(M.name),
  13326. params: M.argnames.map(to_moz),
  13327. generator: is_generator,
  13328. async: M.async,
  13329. body: to_moz_scope("BlockStatement", M)
  13330. };
  13331. });
  13332. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  13333. var body = {
  13334. type: "BlockStatement",
  13335. body: M.body.map(to_moz)
  13336. };
  13337. return {
  13338. type: "ArrowFunctionExpression",
  13339. params: M.argnames.map(to_moz),
  13340. async: M.async,
  13341. body: body
  13342. };
  13343. });
  13344. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  13345. if (M.is_array) {
  13346. return {
  13347. type: "ArrayPattern",
  13348. elements: M.names.map(to_moz)
  13349. };
  13350. }
  13351. return {
  13352. type: "ObjectPattern",
  13353. properties: M.names.map(to_moz)
  13354. };
  13355. });
  13356. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  13357. return {
  13358. type: "ExpressionStatement",
  13359. expression: {
  13360. type: "Literal",
  13361. value: M.value,
  13362. raw: M.print_to_string()
  13363. },
  13364. directive: M.value
  13365. };
  13366. });
  13367. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  13368. return {
  13369. type: "ExpressionStatement",
  13370. expression: to_moz(M.body)
  13371. };
  13372. });
  13373. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  13374. return {
  13375. type: "SwitchCase",
  13376. test: to_moz(M.expression),
  13377. consequent: M.body.map(to_moz)
  13378. };
  13379. });
  13380. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  13381. return {
  13382. type: "TryStatement",
  13383. block: to_moz_block(M),
  13384. handler: to_moz(M.bcatch),
  13385. guardedHandlers: [],
  13386. finalizer: to_moz(M.bfinally)
  13387. };
  13388. });
  13389. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  13390. return {
  13391. type: "CatchClause",
  13392. param: to_moz(M.argname),
  13393. guard: null,
  13394. body: to_moz_block(M)
  13395. };
  13396. });
  13397. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  13398. return {
  13399. type: "VariableDeclaration",
  13400. kind:
  13401. M instanceof AST_Const ? "const" :
  13402. M instanceof AST_Let ? "let" : "var",
  13403. declarations: M.definitions.map(to_moz)
  13404. };
  13405. });
  13406. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  13407. if (M.exported_names) {
  13408. if (M.exported_names[0].name.name === "*") {
  13409. return {
  13410. type: "ExportAllDeclaration",
  13411. source: to_moz(M.module_name)
  13412. };
  13413. }
  13414. return {
  13415. type: "ExportNamedDeclaration",
  13416. specifiers: M.exported_names.map(function (name_mapping) {
  13417. return {
  13418. type: "ExportSpecifier",
  13419. exported: to_moz(name_mapping.foreign_name),
  13420. local: to_moz(name_mapping.name)
  13421. };
  13422. }),
  13423. declaration: to_moz(M.exported_definition),
  13424. source: to_moz(M.module_name)
  13425. };
  13426. }
  13427. return {
  13428. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  13429. declaration: to_moz(M.exported_value || M.exported_definition)
  13430. };
  13431. });
  13432. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  13433. var specifiers = [];
  13434. if (M.imported_name) {
  13435. specifiers.push({
  13436. type: "ImportDefaultSpecifier",
  13437. local: to_moz(M.imported_name)
  13438. });
  13439. }
  13440. if (M.imported_names && M.imported_names[0].foreign_name.name === "*") {
  13441. specifiers.push({
  13442. type: "ImportNamespaceSpecifier",
  13443. local: to_moz(M.imported_names[0].name)
  13444. });
  13445. } else if (M.imported_names) {
  13446. M.imported_names.forEach(function(name_mapping) {
  13447. specifiers.push({
  13448. type: "ImportSpecifier",
  13449. local: to_moz(name_mapping.name),
  13450. imported: to_moz(name_mapping.foreign_name)
  13451. });
  13452. });
  13453. }
  13454. return {
  13455. type: "ImportDeclaration",
  13456. specifiers: specifiers,
  13457. source: to_moz(M.module_name)
  13458. };
  13459. });
  13460. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  13461. return {
  13462. type: "MetaProperty",
  13463. meta: {
  13464. type: "Identifier",
  13465. name: "import"
  13466. },
  13467. property: {
  13468. type: "Identifier",
  13469. name: "meta"
  13470. }
  13471. };
  13472. });
  13473. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  13474. return {
  13475. type: "SequenceExpression",
  13476. expressions: M.expressions.map(to_moz)
  13477. };
  13478. });
  13479. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  13480. return {
  13481. type: "MemberExpression",
  13482. object: to_moz(M.expression),
  13483. computed: false,
  13484. property: {
  13485. type: "PrivateIdentifier",
  13486. name: M.property
  13487. },
  13488. optional: M.optional
  13489. };
  13490. });
  13491. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  13492. var isComputed = M instanceof AST_Sub;
  13493. return {
  13494. type: "MemberExpression",
  13495. object: to_moz(M.expression),
  13496. computed: isComputed,
  13497. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  13498. optional: M.optional
  13499. };
  13500. });
  13501. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  13502. return {
  13503. type: "ChainExpression",
  13504. expression: to_moz(M.expression)
  13505. };
  13506. });
  13507. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  13508. return {
  13509. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  13510. operator: M.operator,
  13511. prefix: M instanceof AST_UnaryPrefix,
  13512. argument: to_moz(M.expression)
  13513. };
  13514. });
  13515. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  13516. if (M.operator == "=" && to_moz_in_destructuring()) {
  13517. return {
  13518. type: "AssignmentPattern",
  13519. left: to_moz(M.left),
  13520. right: to_moz(M.right)
  13521. };
  13522. }
  13523. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  13524. ? "LogicalExpression"
  13525. : "BinaryExpression";
  13526. return {
  13527. type,
  13528. left: to_moz(M.left),
  13529. operator: M.operator,
  13530. right: to_moz(M.right)
  13531. };
  13532. });
  13533. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  13534. return {
  13535. type: "ArrayExpression",
  13536. elements: M.elements.map(to_moz)
  13537. };
  13538. });
  13539. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  13540. return {
  13541. type: "ObjectExpression",
  13542. properties: M.properties.map(to_moz)
  13543. };
  13544. });
  13545. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  13546. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  13547. type: "Identifier",
  13548. value: M.key
  13549. };
  13550. if (typeof M.key === "number") {
  13551. key = {
  13552. type: "Literal",
  13553. value: Number(M.key)
  13554. };
  13555. }
  13556. if (typeof M.key === "string") {
  13557. key = {
  13558. type: "Identifier",
  13559. name: M.key
  13560. };
  13561. }
  13562. var kind;
  13563. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  13564. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  13565. if (M instanceof AST_ObjectKeyVal) {
  13566. kind = "init";
  13567. computed = !string_or_num;
  13568. } else
  13569. if (M instanceof AST_ObjectGetter) {
  13570. kind = "get";
  13571. } else
  13572. if (M instanceof AST_ObjectSetter) {
  13573. kind = "set";
  13574. }
  13575. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  13576. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  13577. return {
  13578. type: "MethodDefinition",
  13579. computed: false,
  13580. kind: kind,
  13581. static: M.static,
  13582. key: {
  13583. type: "PrivateIdentifier",
  13584. name: M.key.name
  13585. },
  13586. value: to_moz(M.value)
  13587. };
  13588. }
  13589. if (M instanceof AST_ClassPrivateProperty) {
  13590. return {
  13591. type: "PropertyDefinition",
  13592. key: {
  13593. type: "PrivateIdentifier",
  13594. name: M.key.name
  13595. },
  13596. value: to_moz(M.value),
  13597. computed: false,
  13598. static: M.static
  13599. };
  13600. }
  13601. if (M instanceof AST_ClassProperty) {
  13602. return {
  13603. type: "PropertyDefinition",
  13604. key,
  13605. value: to_moz(M.value),
  13606. computed,
  13607. static: M.static
  13608. };
  13609. }
  13610. if (parent instanceof AST_Class) {
  13611. return {
  13612. type: "MethodDefinition",
  13613. computed: computed,
  13614. kind: kind,
  13615. static: M.static,
  13616. key: to_moz(M.key),
  13617. value: to_moz(M.value)
  13618. };
  13619. }
  13620. return {
  13621. type: "Property",
  13622. computed: computed,
  13623. kind: kind,
  13624. key: key,
  13625. value: to_moz(M.value)
  13626. };
  13627. });
  13628. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  13629. if (parent instanceof AST_Object) {
  13630. return {
  13631. type: "Property",
  13632. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  13633. kind: "init",
  13634. method: true,
  13635. shorthand: false,
  13636. key: to_moz(M.key),
  13637. value: to_moz(M.value)
  13638. };
  13639. }
  13640. const key = M instanceof AST_PrivateMethod
  13641. ? {
  13642. type: "PrivateIdentifier",
  13643. name: M.key.name
  13644. }
  13645. : to_moz(M.key);
  13646. return {
  13647. type: "MethodDefinition",
  13648. kind: M.key === "constructor" ? "constructor" : "method",
  13649. key,
  13650. value: to_moz(M.value),
  13651. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  13652. static: M.static,
  13653. };
  13654. });
  13655. def_to_moz(AST_Class, function To_Moz_Class(M) {
  13656. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  13657. return {
  13658. type: type,
  13659. superClass: to_moz(M.extends),
  13660. id: M.name ? to_moz(M.name) : null,
  13661. body: {
  13662. type: "ClassBody",
  13663. body: M.properties.map(to_moz)
  13664. }
  13665. };
  13666. });
  13667. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  13668. return {
  13669. type: "MetaProperty",
  13670. meta: {
  13671. type: "Identifier",
  13672. name: "new"
  13673. },
  13674. property: {
  13675. type: "Identifier",
  13676. name: "target"
  13677. }
  13678. };
  13679. });
  13680. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  13681. if (M instanceof AST_SymbolMethod && parent.quote) {
  13682. return {
  13683. type: "Literal",
  13684. value: M.name
  13685. };
  13686. }
  13687. var def = M.definition();
  13688. return {
  13689. type: "Identifier",
  13690. name: def ? def.mangled_name || def.name : M.name
  13691. };
  13692. });
  13693. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  13694. const pattern = M.value.source;
  13695. const flags = M.value.flags;
  13696. return {
  13697. type: "Literal",
  13698. value: null,
  13699. raw: M.print_to_string(),
  13700. regex: { pattern, flags }
  13701. };
  13702. });
  13703. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  13704. var value = M.value;
  13705. return {
  13706. type: "Literal",
  13707. value: value,
  13708. raw: M.raw || M.print_to_string()
  13709. };
  13710. });
  13711. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  13712. return {
  13713. type: "Identifier",
  13714. name: String(M.value)
  13715. };
  13716. });
  13717. def_to_moz(AST_BigInt, M => ({
  13718. type: "BigIntLiteral",
  13719. value: M.value
  13720. }));
  13721. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  13722. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  13723. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  13724. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  13725. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  13726. /* -----[ tools ]----- */
  13727. function my_start_token(moznode) {
  13728. var loc = moznode.loc, start = loc && loc.start;
  13729. var range = moznode.range;
  13730. return new AST_Token(
  13731. "",
  13732. "",
  13733. start && start.line || 0,
  13734. start && start.column || 0,
  13735. range ? range [0] : moznode.start,
  13736. false,
  13737. [],
  13738. [],
  13739. loc && loc.source,
  13740. );
  13741. }
  13742. function my_end_token(moznode) {
  13743. var loc = moznode.loc, end = loc && loc.end;
  13744. var range = moznode.range;
  13745. return new AST_Token(
  13746. "",
  13747. "",
  13748. end && end.line || 0,
  13749. end && end.column || 0,
  13750. range ? range [0] : moznode.end,
  13751. false,
  13752. [],
  13753. [],
  13754. loc && loc.source,
  13755. );
  13756. }
  13757. function map(moztype, mytype, propmap) {
  13758. var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
  13759. moz_to_me += "return new U2." + mytype.name + "({\n" +
  13760. "start: my_start_token(M),\n" +
  13761. "end: my_end_token(M)";
  13762. var me_to_moz = "function To_Moz_" + moztype + "(M){\n";
  13763. me_to_moz += "return {\n" +
  13764. "type: " + JSON.stringify(moztype);
  13765. if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
  13766. var m = /([a-z0-9$_]+)([=@>%])([a-z0-9$_]+)/i.exec(prop);
  13767. if (!m) throw new Error("Can't understand property map: " + prop);
  13768. var moz = m[1], how = m[2], my = m[3];
  13769. moz_to_me += ",\n" + my + ": ";
  13770. me_to_moz += ",\n" + moz + ": ";
  13771. switch (how) {
  13772. case "@":
  13773. moz_to_me += "M." + moz + ".map(from_moz)";
  13774. me_to_moz += "M." + my + ".map(to_moz)";
  13775. break;
  13776. case ">":
  13777. moz_to_me += "from_moz(M." + moz + ")";
  13778. me_to_moz += "to_moz(M." + my + ")";
  13779. break;
  13780. case "=":
  13781. moz_to_me += "M." + moz;
  13782. me_to_moz += "M." + my;
  13783. break;
  13784. case "%":
  13785. moz_to_me += "from_moz(M." + moz + ").body";
  13786. me_to_moz += "to_moz_block(M)";
  13787. break;
  13788. default:
  13789. throw new Error("Can't understand operator in propmap: " + prop);
  13790. }
  13791. });
  13792. moz_to_me += "\n})\n}";
  13793. me_to_moz += "\n}\n}";
  13794. moz_to_me = new Function("U2", "my_start_token", "my_end_token", "from_moz", "return(" + moz_to_me + ")")(
  13795. ast, my_start_token, my_end_token, from_moz
  13796. );
  13797. me_to_moz = new Function("to_moz", "to_moz_block", "to_moz_scope", "return(" + me_to_moz + ")")(
  13798. to_moz, to_moz_block, to_moz_scope
  13799. );
  13800. MOZ_TO_ME[moztype] = moz_to_me;
  13801. def_to_moz(mytype, me_to_moz);
  13802. }
  13803. var FROM_MOZ_STACK = null;
  13804. function from_moz(node) {
  13805. FROM_MOZ_STACK.push(node);
  13806. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  13807. FROM_MOZ_STACK.pop();
  13808. return ret;
  13809. }
  13810. AST_Node.from_mozilla_ast = function(node) {
  13811. var save_stack = FROM_MOZ_STACK;
  13812. FROM_MOZ_STACK = [];
  13813. var ast = from_moz(node);
  13814. FROM_MOZ_STACK = save_stack;
  13815. return ast;
  13816. };
  13817. function set_moz_loc(mynode, moznode) {
  13818. var start = mynode.start;
  13819. var end = mynode.end;
  13820. if (!(start && end)) {
  13821. return moznode;
  13822. }
  13823. if (start.pos != null && end.endpos != null) {
  13824. moznode.range = [start.pos, end.endpos];
  13825. }
  13826. if (start.line) {
  13827. moznode.loc = {
  13828. start: {line: start.line, column: start.col},
  13829. end: end.endline ? {line: end.endline, column: end.endcol} : null
  13830. };
  13831. if (start.file) {
  13832. moznode.loc.source = start.file;
  13833. }
  13834. }
  13835. return moznode;
  13836. }
  13837. function def_to_moz(mytype, handler) {
  13838. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  13839. return set_moz_loc(this, handler(this, parent));
  13840. });
  13841. }
  13842. var TO_MOZ_STACK = null;
  13843. function to_moz(node) {
  13844. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  13845. TO_MOZ_STACK.push(node);
  13846. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  13847. TO_MOZ_STACK.pop();
  13848. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  13849. return ast;
  13850. }
  13851. function to_moz_in_destructuring() {
  13852. var i = TO_MOZ_STACK.length;
  13853. while (i--) {
  13854. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  13855. return true;
  13856. }
  13857. }
  13858. return false;
  13859. }
  13860. function to_moz_block(node) {
  13861. return {
  13862. type: "BlockStatement",
  13863. body: node.body.map(to_moz)
  13864. };
  13865. }
  13866. function to_moz_scope(type, node) {
  13867. var body = node.body.map(to_moz);
  13868. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  13869. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  13870. }
  13871. return {
  13872. type: type,
  13873. body: body
  13874. };
  13875. }
  13876. })();
  13877. // return true if the node at the top of the stack (that means the
  13878. // innermost node in the current output) is lexically the first in
  13879. // a statement.
  13880. function first_in_statement(stack) {
  13881. let node = stack.parent(-1);
  13882. for (let i = 0, p; p = stack.parent(i); i++) {
  13883. if (p instanceof AST_Statement && p.body === node)
  13884. return true;
  13885. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  13886. (p.TYPE === "Call" && p.expression === node) ||
  13887. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  13888. (p instanceof AST_Dot && p.expression === node) ||
  13889. (p instanceof AST_Sub && p.expression === node) ||
  13890. (p instanceof AST_Conditional && p.condition === node) ||
  13891. (p instanceof AST_Binary && p.left === node) ||
  13892. (p instanceof AST_UnaryPostfix && p.expression === node)
  13893. ) {
  13894. node = p;
  13895. } else {
  13896. return false;
  13897. }
  13898. }
  13899. }
  13900. // Returns whether the leftmost item in the expression is an object
  13901. function left_is_object(node) {
  13902. if (node instanceof AST_Object) return true;
  13903. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  13904. if (node.TYPE === "Call") return left_is_object(node.expression);
  13905. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  13906. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  13907. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  13908. if (node instanceof AST_Binary) return left_is_object(node.left);
  13909. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  13910. return false;
  13911. }
  13912. /***********************************************************************
  13913. A JavaScript tokenizer / parser / beautifier / compressor.
  13914. https://github.com/mishoo/UglifyJS2
  13915. -------------------------------- (C) ---------------------------------
  13916. Author: Mihai Bazon
  13917. <mihai.bazon@gmail.com>
  13918. http://mihai.bazon.net/blog
  13919. Distributed under the BSD license:
  13920. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13921. Redistribution and use in source and binary forms, with or without
  13922. modification, are permitted provided that the following conditions
  13923. are met:
  13924. * Redistributions of source code must retain the above
  13925. copyright notice, this list of conditions and the following
  13926. disclaimer.
  13927. * Redistributions in binary form must reproduce the above
  13928. copyright notice, this list of conditions and the following
  13929. disclaimer in the documentation and/or other materials
  13930. provided with the distribution.
  13931. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13932. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13933. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13934. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13935. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13936. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13937. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13938. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13939. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13940. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13941. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13942. SUCH DAMAGE.
  13943. ***********************************************************************/
  13944. const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
  13945. const CODE_LINE_BREAK = 10;
  13946. const CODE_SPACE = 32;
  13947. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/g;
  13948. function is_some_comments(comment) {
  13949. // multiline comment
  13950. return (
  13951. (comment.type === "comment2" || comment.type === "comment1")
  13952. && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
  13953. );
  13954. }
  13955. function OutputStream(options) {
  13956. var readonly = !options;
  13957. options = defaults(options, {
  13958. ascii_only : false,
  13959. beautify : false,
  13960. braces : false,
  13961. comments : "some",
  13962. ecma : 5,
  13963. ie8 : false,
  13964. indent_level : 4,
  13965. indent_start : 0,
  13966. inline_script : true,
  13967. keep_numbers : false,
  13968. keep_quoted_props : false,
  13969. max_line_len : false,
  13970. preamble : null,
  13971. preserve_annotations : false,
  13972. quote_keys : false,
  13973. quote_style : 0,
  13974. safari10 : false,
  13975. semicolons : true,
  13976. shebang : true,
  13977. shorthand : undefined,
  13978. source_map : null,
  13979. webkit : false,
  13980. width : 80,
  13981. wrap_iife : false,
  13982. wrap_func_args : true,
  13983. }, true);
  13984. if (options.shorthand === undefined)
  13985. options.shorthand = options.ecma > 5;
  13986. // Convert comment option to RegExp if neccessary and set up comments filter
  13987. var comment_filter = return_false; // Default case, throw all comments away
  13988. if (options.comments) {
  13989. let comments = options.comments;
  13990. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  13991. var regex_pos = options.comments.lastIndexOf("/");
  13992. comments = new RegExp(
  13993. options.comments.substr(1, regex_pos - 1),
  13994. options.comments.substr(regex_pos + 1)
  13995. );
  13996. }
  13997. if (comments instanceof RegExp) {
  13998. comment_filter = function(comment) {
  13999. return comment.type != "comment5" && comments.test(comment.value);
  14000. };
  14001. } else if (typeof comments === "function") {
  14002. comment_filter = function(comment) {
  14003. return comment.type != "comment5" && comments(this, comment);
  14004. };
  14005. } else if (comments === "some") {
  14006. comment_filter = is_some_comments;
  14007. } else { // NOTE includes "all" option
  14008. comment_filter = return_true;
  14009. }
  14010. }
  14011. var indentation = 0;
  14012. var current_col = 0;
  14013. var current_line = 1;
  14014. var current_pos = 0;
  14015. var OUTPUT = "";
  14016. let printed_comments = new Set();
  14017. var to_utf8 = options.ascii_only ? function(str, identifier) {
  14018. if (options.ecma >= 2015 && !options.safari10) {
  14019. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  14020. var code = get_full_char_code(ch, 0).toString(16);
  14021. return "\\u{" + code + "}";
  14022. });
  14023. }
  14024. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  14025. var code = ch.charCodeAt(0).toString(16);
  14026. if (code.length <= 2 && !identifier) {
  14027. while (code.length < 2) code = "0" + code;
  14028. return "\\x" + code;
  14029. } else {
  14030. while (code.length < 4) code = "0" + code;
  14031. return "\\u" + code;
  14032. }
  14033. });
  14034. } : function(str) {
  14035. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  14036. if (lone) {
  14037. return "\\u" + lone.charCodeAt(0).toString(16);
  14038. }
  14039. return match;
  14040. });
  14041. };
  14042. function make_string(str, quote) {
  14043. var dq = 0, sq = 0;
  14044. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  14045. function(s, i) {
  14046. switch (s) {
  14047. case '"': ++dq; return '"';
  14048. case "'": ++sq; return "'";
  14049. case "\\": return "\\\\";
  14050. case "\n": return "\\n";
  14051. case "\r": return "\\r";
  14052. case "\t": return "\\t";
  14053. case "\b": return "\\b";
  14054. case "\f": return "\\f";
  14055. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  14056. case "\u2028": return "\\u2028";
  14057. case "\u2029": return "\\u2029";
  14058. case "\ufeff": return "\\ufeff";
  14059. case "\0":
  14060. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  14061. }
  14062. return s;
  14063. });
  14064. function quote_single() {
  14065. return "'" + str.replace(/\x27/g, "\\'") + "'";
  14066. }
  14067. function quote_double() {
  14068. return '"' + str.replace(/\x22/g, '\\"') + '"';
  14069. }
  14070. function quote_template() {
  14071. return "`" + str.replace(/`/g, "\\`") + "`";
  14072. }
  14073. str = to_utf8(str);
  14074. if (quote === "`") return quote_template();
  14075. switch (options.quote_style) {
  14076. case 1:
  14077. return quote_single();
  14078. case 2:
  14079. return quote_double();
  14080. case 3:
  14081. return quote == "'" ? quote_single() : quote_double();
  14082. default:
  14083. return dq > sq ? quote_single() : quote_double();
  14084. }
  14085. }
  14086. function encode_string(str, quote) {
  14087. var ret = make_string(str, quote);
  14088. if (options.inline_script) {
  14089. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  14090. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  14091. ret = ret.replace(/--\x3e/g, "--\\x3e");
  14092. }
  14093. return ret;
  14094. }
  14095. function make_name(name) {
  14096. name = name.toString();
  14097. name = to_utf8(name, true);
  14098. return name;
  14099. }
  14100. function make_indent(back) {
  14101. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  14102. }
  14103. /* -----[ beautification/minification ]----- */
  14104. var has_parens = false;
  14105. var might_need_space = false;
  14106. var might_need_semicolon = false;
  14107. var might_add_newline = 0;
  14108. var need_newline_indented = false;
  14109. var need_space = false;
  14110. var newline_insert = -1;
  14111. var last = "";
  14112. var mapping_token, mapping_name, mappings = options.source_map && [];
  14113. var do_add_mapping = mappings ? function() {
  14114. mappings.forEach(function(mapping) {
  14115. try {
  14116. let name = !mapping.name && mapping.token.type == "name" ? mapping.token.value : mapping.name;
  14117. if (name instanceof AST_Symbol) {
  14118. name = name.name;
  14119. }
  14120. options.source_map.add(
  14121. mapping.token.file,
  14122. mapping.line, mapping.col,
  14123. mapping.token.line, mapping.token.col,
  14124. is_basic_identifier_string(name) ? name : undefined
  14125. );
  14126. } catch(ex) {
  14127. // Ignore bad mapping
  14128. }
  14129. });
  14130. mappings = [];
  14131. } : noop;
  14132. var ensure_line_len = options.max_line_len ? function() {
  14133. if (current_col > options.max_line_len) {
  14134. if (might_add_newline) {
  14135. var left = OUTPUT.slice(0, might_add_newline);
  14136. var right = OUTPUT.slice(might_add_newline);
  14137. if (mappings) {
  14138. var delta = right.length - current_col;
  14139. mappings.forEach(function(mapping) {
  14140. mapping.line++;
  14141. mapping.col += delta;
  14142. });
  14143. }
  14144. OUTPUT = left + "\n" + right;
  14145. current_line++;
  14146. current_pos++;
  14147. current_col = right.length;
  14148. }
  14149. }
  14150. if (might_add_newline) {
  14151. might_add_newline = 0;
  14152. do_add_mapping();
  14153. }
  14154. } : noop;
  14155. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  14156. function print(str) {
  14157. str = String(str);
  14158. var ch = get_full_char(str, 0);
  14159. if (need_newline_indented && ch) {
  14160. need_newline_indented = false;
  14161. if (ch !== "\n") {
  14162. print("\n");
  14163. indent();
  14164. }
  14165. }
  14166. if (need_space && ch) {
  14167. need_space = false;
  14168. if (!/[\s;})]/.test(ch)) {
  14169. space();
  14170. }
  14171. }
  14172. newline_insert = -1;
  14173. var prev = last.charAt(last.length - 1);
  14174. if (might_need_semicolon) {
  14175. might_need_semicolon = false;
  14176. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  14177. if (options.semicolons || requireSemicolonChars.has(ch)) {
  14178. OUTPUT += ";";
  14179. current_col++;
  14180. current_pos++;
  14181. } else {
  14182. ensure_line_len();
  14183. if (current_col > 0) {
  14184. OUTPUT += "\n";
  14185. current_pos++;
  14186. current_line++;
  14187. current_col = 0;
  14188. }
  14189. if (/^\s+$/.test(str)) {
  14190. // reset the semicolon flag, since we didn't print one
  14191. // now and might still have to later
  14192. might_need_semicolon = true;
  14193. }
  14194. }
  14195. if (!options.beautify)
  14196. might_need_space = false;
  14197. }
  14198. }
  14199. if (might_need_space) {
  14200. if ((is_identifier_char(prev)
  14201. && (is_identifier_char(ch) || ch == "\\"))
  14202. || (ch == "/" && ch == prev)
  14203. || ((ch == "+" || ch == "-") && ch == last)
  14204. ) {
  14205. OUTPUT += " ";
  14206. current_col++;
  14207. current_pos++;
  14208. }
  14209. might_need_space = false;
  14210. }
  14211. if (mapping_token) {
  14212. mappings.push({
  14213. token: mapping_token,
  14214. name: mapping_name,
  14215. line: current_line,
  14216. col: current_col
  14217. });
  14218. mapping_token = false;
  14219. if (!might_add_newline) do_add_mapping();
  14220. }
  14221. OUTPUT += str;
  14222. has_parens = str[str.length - 1] == "(";
  14223. current_pos += str.length;
  14224. var a = str.split(/\r?\n/), n = a.length - 1;
  14225. current_line += n;
  14226. current_col += a[0].length;
  14227. if (n > 0) {
  14228. ensure_line_len();
  14229. current_col = a[n].length;
  14230. }
  14231. last = str;
  14232. }
  14233. var star = function() {
  14234. print("*");
  14235. };
  14236. var space = options.beautify ? function() {
  14237. print(" ");
  14238. } : function() {
  14239. might_need_space = true;
  14240. };
  14241. var indent = options.beautify ? function(half) {
  14242. if (options.beautify) {
  14243. print(make_indent(half ? 0.5 : 0));
  14244. }
  14245. } : noop;
  14246. var with_indent = options.beautify ? function(col, cont) {
  14247. if (col === true) col = next_indent();
  14248. var save_indentation = indentation;
  14249. indentation = col;
  14250. var ret = cont();
  14251. indentation = save_indentation;
  14252. return ret;
  14253. } : function(col, cont) { return cont(); };
  14254. var newline = options.beautify ? function() {
  14255. if (newline_insert < 0) return print("\n");
  14256. if (OUTPUT[newline_insert] != "\n") {
  14257. OUTPUT = OUTPUT.slice(0, newline_insert) + "\n" + OUTPUT.slice(newline_insert);
  14258. current_pos++;
  14259. current_line++;
  14260. }
  14261. newline_insert++;
  14262. } : options.max_line_len ? function() {
  14263. ensure_line_len();
  14264. might_add_newline = OUTPUT.length;
  14265. } : noop;
  14266. var semicolon = options.beautify ? function() {
  14267. print(";");
  14268. } : function() {
  14269. might_need_semicolon = true;
  14270. };
  14271. function force_semicolon() {
  14272. might_need_semicolon = false;
  14273. print(";");
  14274. }
  14275. function next_indent() {
  14276. return indentation + options.indent_level;
  14277. }
  14278. function with_block(cont) {
  14279. var ret;
  14280. print("{");
  14281. newline();
  14282. with_indent(next_indent(), function() {
  14283. ret = cont();
  14284. });
  14285. indent();
  14286. print("}");
  14287. return ret;
  14288. }
  14289. function with_parens(cont) {
  14290. print("(");
  14291. //XXX: still nice to have that for argument lists
  14292. //var ret = with_indent(current_col, cont);
  14293. var ret = cont();
  14294. print(")");
  14295. return ret;
  14296. }
  14297. function with_square(cont) {
  14298. print("[");
  14299. //var ret = with_indent(current_col, cont);
  14300. var ret = cont();
  14301. print("]");
  14302. return ret;
  14303. }
  14304. function comma() {
  14305. print(",");
  14306. space();
  14307. }
  14308. function colon() {
  14309. print(":");
  14310. space();
  14311. }
  14312. var add_mapping = mappings ? function(token, name) {
  14313. mapping_token = token;
  14314. mapping_name = name;
  14315. } : noop;
  14316. function get() {
  14317. if (might_add_newline) {
  14318. ensure_line_len();
  14319. }
  14320. return OUTPUT;
  14321. }
  14322. function has_nlb() {
  14323. let n = OUTPUT.length - 1;
  14324. while (n >= 0) {
  14325. const code = OUTPUT.charCodeAt(n);
  14326. if (code === CODE_LINE_BREAK) {
  14327. return true;
  14328. }
  14329. if (code !== CODE_SPACE) {
  14330. return false;
  14331. }
  14332. n--;
  14333. }
  14334. return true;
  14335. }
  14336. function filter_comment(comment) {
  14337. if (!options.preserve_annotations) {
  14338. comment = comment.replace(r_annotation, " ");
  14339. }
  14340. if (/^\s*$/.test(comment)) {
  14341. return "";
  14342. }
  14343. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  14344. }
  14345. function prepend_comments(node) {
  14346. var self = this;
  14347. var start = node.start;
  14348. if (!start) return;
  14349. var printed_comments = self.printed_comments;
  14350. // There cannot be a newline between return and its value.
  14351. const return_with_value = node instanceof AST_Exit && node.value;
  14352. if (
  14353. start.comments_before
  14354. && printed_comments.has(start.comments_before)
  14355. ) {
  14356. if (return_with_value) {
  14357. start.comments_before = [];
  14358. } else {
  14359. return;
  14360. }
  14361. }
  14362. var comments = start.comments_before;
  14363. if (!comments) {
  14364. comments = start.comments_before = [];
  14365. }
  14366. printed_comments.add(comments);
  14367. if (return_with_value) {
  14368. var tw = new TreeWalker(function(node) {
  14369. var parent = tw.parent();
  14370. if (parent instanceof AST_Exit
  14371. || parent instanceof AST_Binary && parent.left === node
  14372. || parent.TYPE == "Call" && parent.expression === node
  14373. || parent instanceof AST_Conditional && parent.condition === node
  14374. || parent instanceof AST_Dot && parent.expression === node
  14375. || parent instanceof AST_Sequence && parent.expressions[0] === node
  14376. || parent instanceof AST_Sub && parent.expression === node
  14377. || parent instanceof AST_UnaryPostfix) {
  14378. if (!node.start) return;
  14379. var text = node.start.comments_before;
  14380. if (text && !printed_comments.has(text)) {
  14381. printed_comments.add(text);
  14382. comments = comments.concat(text);
  14383. }
  14384. } else {
  14385. return true;
  14386. }
  14387. });
  14388. tw.push(node);
  14389. node.value.walk(tw);
  14390. }
  14391. if (current_pos == 0) {
  14392. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  14393. && !printed_comments.has(comments[0])) {
  14394. print("#!" + comments.shift().value + "\n");
  14395. indent();
  14396. }
  14397. var preamble = options.preamble;
  14398. if (preamble) {
  14399. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  14400. }
  14401. }
  14402. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  14403. if (comments.length == 0) return;
  14404. var last_nlb = has_nlb();
  14405. comments.forEach(function(c, i) {
  14406. printed_comments.add(c);
  14407. if (!last_nlb) {
  14408. if (c.nlb) {
  14409. print("\n");
  14410. indent();
  14411. last_nlb = true;
  14412. } else if (i > 0) {
  14413. space();
  14414. }
  14415. }
  14416. if (/comment[134]/.test(c.type)) {
  14417. var value = filter_comment(c.value);
  14418. if (value) {
  14419. print("//" + value + "\n");
  14420. indent();
  14421. }
  14422. last_nlb = true;
  14423. } else if (c.type == "comment2") {
  14424. var value = filter_comment(c.value);
  14425. if (value) {
  14426. print("/*" + value + "*/");
  14427. }
  14428. last_nlb = false;
  14429. }
  14430. });
  14431. if (!last_nlb) {
  14432. if (start.nlb) {
  14433. print("\n");
  14434. indent();
  14435. } else {
  14436. space();
  14437. }
  14438. }
  14439. }
  14440. function append_comments(node, tail) {
  14441. var self = this;
  14442. var token = node.end;
  14443. if (!token) return;
  14444. var printed_comments = self.printed_comments;
  14445. var comments = token[tail ? "comments_before" : "comments_after"];
  14446. if (!comments || printed_comments.has(comments)) return;
  14447. if (!(node instanceof AST_Statement || comments.every((c) =>
  14448. !/comment[134]/.test(c.type)
  14449. ))) return;
  14450. printed_comments.add(comments);
  14451. var insert = OUTPUT.length;
  14452. comments.filter(comment_filter, node).forEach(function(c, i) {
  14453. if (printed_comments.has(c)) return;
  14454. printed_comments.add(c);
  14455. need_space = false;
  14456. if (need_newline_indented) {
  14457. print("\n");
  14458. indent();
  14459. need_newline_indented = false;
  14460. } else if (c.nlb && (i > 0 || !has_nlb())) {
  14461. print("\n");
  14462. indent();
  14463. } else if (i > 0 || !tail) {
  14464. space();
  14465. }
  14466. if (/comment[134]/.test(c.type)) {
  14467. const value = filter_comment(c.value);
  14468. if (value) {
  14469. print("//" + value);
  14470. }
  14471. need_newline_indented = true;
  14472. } else if (c.type == "comment2") {
  14473. const value = filter_comment(c.value);
  14474. if (value) {
  14475. print("/*" + value + "*/");
  14476. }
  14477. need_space = true;
  14478. }
  14479. });
  14480. if (OUTPUT.length > insert) newline_insert = insert;
  14481. }
  14482. var stack = [];
  14483. return {
  14484. get : get,
  14485. toString : get,
  14486. indent : indent,
  14487. in_directive : false,
  14488. use_asm : null,
  14489. active_scope : null,
  14490. indentation : function() { return indentation; },
  14491. current_width : function() { return current_col - indentation; },
  14492. should_break : function() { return options.width && this.current_width() >= options.width; },
  14493. has_parens : function() { return has_parens; },
  14494. newline : newline,
  14495. print : print,
  14496. star : star,
  14497. space : space,
  14498. comma : comma,
  14499. colon : colon,
  14500. last : function() { return last; },
  14501. semicolon : semicolon,
  14502. force_semicolon : force_semicolon,
  14503. to_utf8 : to_utf8,
  14504. print_name : function(name) { print(make_name(name)); },
  14505. print_string : function(str, quote, escape_directive) {
  14506. var encoded = encode_string(str, quote);
  14507. if (escape_directive === true && !encoded.includes("\\")) {
  14508. // Insert semicolons to break directive prologue
  14509. if (!EXPECT_DIRECTIVE.test(OUTPUT)) {
  14510. force_semicolon();
  14511. }
  14512. force_semicolon();
  14513. }
  14514. print(encoded);
  14515. },
  14516. print_template_string_chars: function(str) {
  14517. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  14518. return print(encoded.substr(1, encoded.length - 2));
  14519. },
  14520. encode_string : encode_string,
  14521. next_indent : next_indent,
  14522. with_indent : with_indent,
  14523. with_block : with_block,
  14524. with_parens : with_parens,
  14525. with_square : with_square,
  14526. add_mapping : add_mapping,
  14527. option : function(opt) { return options[opt]; },
  14528. printed_comments: printed_comments,
  14529. prepend_comments: readonly ? noop : prepend_comments,
  14530. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  14531. line : function() { return current_line; },
  14532. col : function() { return current_col; },
  14533. pos : function() { return current_pos; },
  14534. push_node : function(node) { stack.push(node); },
  14535. pop_node : function() { return stack.pop(); },
  14536. parent : function(n) {
  14537. return stack[stack.length - 2 - (n || 0)];
  14538. }
  14539. };
  14540. }
  14541. /* -----[ code generators ]----- */
  14542. (function() {
  14543. /* -----[ utils ]----- */
  14544. function DEFPRINT(nodetype, generator) {
  14545. nodetype.DEFMETHOD("_codegen", generator);
  14546. }
  14547. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  14548. var self = this, generator = self._codegen;
  14549. if (self instanceof AST_Scope) {
  14550. output.active_scope = self;
  14551. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  14552. output.use_asm = output.active_scope;
  14553. }
  14554. function doit() {
  14555. output.prepend_comments(self);
  14556. self.add_source_map(output);
  14557. generator(self, output);
  14558. output.append_comments(self);
  14559. }
  14560. output.push_node(self);
  14561. if (force_parens || self.needs_parens(output)) {
  14562. output.with_parens(doit);
  14563. } else {
  14564. doit();
  14565. }
  14566. output.pop_node();
  14567. if (self === output.use_asm) {
  14568. output.use_asm = null;
  14569. }
  14570. });
  14571. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  14572. AST_Node.DEFMETHOD("print_to_string", function(options) {
  14573. var output = OutputStream(options);
  14574. this.print(output);
  14575. return output.get();
  14576. });
  14577. /* -----[ PARENTHESES ]----- */
  14578. function PARENS(nodetype, func) {
  14579. if (Array.isArray(nodetype)) {
  14580. nodetype.forEach(function(nodetype) {
  14581. PARENS(nodetype, func);
  14582. });
  14583. } else {
  14584. nodetype.DEFMETHOD("needs_parens", func);
  14585. }
  14586. }
  14587. PARENS(AST_Node, return_false);
  14588. // a function expression needs parens around it when it's provably
  14589. // the first token to appear in a statement.
  14590. PARENS(AST_Function, function(output) {
  14591. if (!output.has_parens() && first_in_statement(output)) {
  14592. return true;
  14593. }
  14594. if (output.option("webkit")) {
  14595. var p = output.parent();
  14596. if (p instanceof AST_PropAccess && p.expression === this) {
  14597. return true;
  14598. }
  14599. }
  14600. if (output.option("wrap_iife")) {
  14601. var p = output.parent();
  14602. if (p instanceof AST_Call && p.expression === this) {
  14603. return true;
  14604. }
  14605. }
  14606. if (output.option("wrap_func_args")) {
  14607. var p = output.parent();
  14608. if (p instanceof AST_Call && p.args.includes(this)) {
  14609. return true;
  14610. }
  14611. }
  14612. return false;
  14613. });
  14614. PARENS(AST_Arrow, function(output) {
  14615. var p = output.parent();
  14616. if (
  14617. output.option("wrap_func_args")
  14618. && p instanceof AST_Call
  14619. && p.args.includes(this)
  14620. ) {
  14621. return true;
  14622. }
  14623. return p instanceof AST_PropAccess && p.expression === this;
  14624. });
  14625. // same goes for an object literal (as in AST_Function), because
  14626. // otherwise {...} would be interpreted as a block of code.
  14627. PARENS(AST_Object, function(output) {
  14628. return !output.has_parens() && first_in_statement(output);
  14629. });
  14630. PARENS(AST_ClassExpression, first_in_statement);
  14631. PARENS(AST_Unary, function(output) {
  14632. var p = output.parent();
  14633. return p instanceof AST_PropAccess && p.expression === this
  14634. || p instanceof AST_Call && p.expression === this
  14635. || p instanceof AST_Binary
  14636. && p.operator === "**"
  14637. && this instanceof AST_UnaryPrefix
  14638. && p.left === this
  14639. && this.operator !== "++"
  14640. && this.operator !== "--";
  14641. });
  14642. PARENS(AST_Await, function(output) {
  14643. var p = output.parent();
  14644. return p instanceof AST_PropAccess && p.expression === this
  14645. || p instanceof AST_Call && p.expression === this
  14646. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  14647. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  14648. });
  14649. PARENS(AST_Sequence, function(output) {
  14650. var p = output.parent();
  14651. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  14652. || p instanceof AST_Unary // !(foo, bar, baz)
  14653. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  14654. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  14655. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  14656. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  14657. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  14658. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  14659. * ==> 20 (side effect, set a := 10 and b := 20) */
  14660. || p instanceof AST_Arrow // x => (x, x)
  14661. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  14662. || p instanceof AST_Expansion // [...(a, b)]
  14663. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  14664. || p instanceof AST_Yield // yield (foo, bar)
  14665. || p instanceof AST_Export // export default (foo, bar)
  14666. ;
  14667. });
  14668. PARENS(AST_Binary, function(output) {
  14669. var p = output.parent();
  14670. // (foo && bar)()
  14671. if (p instanceof AST_Call && p.expression === this)
  14672. return true;
  14673. // typeof (foo && bar)
  14674. if (p instanceof AST_Unary)
  14675. return true;
  14676. // (foo && bar)["prop"], (foo && bar).prop
  14677. if (p instanceof AST_PropAccess && p.expression === this)
  14678. return true;
  14679. // this deals with precedence: 3 * (2 + 1)
  14680. if (p instanceof AST_Binary) {
  14681. const po = p.operator;
  14682. const so = this.operator;
  14683. if (so === "??" && (po === "||" || po === "&&")) {
  14684. return true;
  14685. }
  14686. if (po === "??" && (so === "||" || so === "&&")) {
  14687. return true;
  14688. }
  14689. const pp = PRECEDENCE[po];
  14690. const sp = PRECEDENCE[so];
  14691. if (pp > sp
  14692. || (pp == sp
  14693. && (this === p.right || po == "**"))) {
  14694. return true;
  14695. }
  14696. }
  14697. });
  14698. PARENS(AST_Yield, function(output) {
  14699. var p = output.parent();
  14700. // (yield 1) + (yield 2)
  14701. // a = yield 3
  14702. if (p instanceof AST_Binary && p.operator !== "=")
  14703. return true;
  14704. // (yield 1)()
  14705. // new (yield 1)()
  14706. if (p instanceof AST_Call && p.expression === this)
  14707. return true;
  14708. // (yield 1) ? yield 2 : yield 3
  14709. if (p instanceof AST_Conditional && p.condition === this)
  14710. return true;
  14711. // -(yield 4)
  14712. if (p instanceof AST_Unary)
  14713. return true;
  14714. // (yield x).foo
  14715. // (yield x)['foo']
  14716. if (p instanceof AST_PropAccess && p.expression === this)
  14717. return true;
  14718. });
  14719. PARENS(AST_PropAccess, function(output) {
  14720. var p = output.parent();
  14721. if (p instanceof AST_New && p.expression === this) {
  14722. // i.e. new (foo.bar().baz)
  14723. //
  14724. // if there's one call into this subtree, then we need
  14725. // parens around it too, otherwise the call will be
  14726. // interpreted as passing the arguments to the upper New
  14727. // expression.
  14728. return walk(this, node => {
  14729. if (node instanceof AST_Scope) return true;
  14730. if (node instanceof AST_Call) {
  14731. return walk_abort; // makes walk() return true.
  14732. }
  14733. });
  14734. }
  14735. });
  14736. PARENS(AST_Call, function(output) {
  14737. var p = output.parent(), p1;
  14738. if (p instanceof AST_New && p.expression === this
  14739. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  14740. return true;
  14741. // workaround for Safari bug.
  14742. // https://bugs.webkit.org/show_bug.cgi?id=123506
  14743. return this.expression instanceof AST_Function
  14744. && p instanceof AST_PropAccess
  14745. && p.expression === this
  14746. && (p1 = output.parent(1)) instanceof AST_Assign
  14747. && p1.left === p;
  14748. });
  14749. PARENS(AST_New, function(output) {
  14750. var p = output.parent();
  14751. if (this.args.length === 0
  14752. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  14753. || p instanceof AST_Call && p.expression === this)) // (new foo)(bar)
  14754. return true;
  14755. });
  14756. PARENS(AST_Number, function(output) {
  14757. var p = output.parent();
  14758. if (p instanceof AST_PropAccess && p.expression === this) {
  14759. var value = this.getValue();
  14760. if (value < 0 || /^0/.test(make_num(value))) {
  14761. return true;
  14762. }
  14763. }
  14764. });
  14765. PARENS(AST_BigInt, function(output) {
  14766. var p = output.parent();
  14767. if (p instanceof AST_PropAccess && p.expression === this) {
  14768. var value = this.getValue();
  14769. if (value.startsWith("-")) {
  14770. return true;
  14771. }
  14772. }
  14773. });
  14774. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  14775. var p = output.parent();
  14776. // !(a = false) → true
  14777. if (p instanceof AST_Unary)
  14778. return true;
  14779. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  14780. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  14781. return true;
  14782. // (a = func)() —or— new (a = Object)()
  14783. if (p instanceof AST_Call && p.expression === this)
  14784. return true;
  14785. // (a = foo) ? bar : baz
  14786. if (p instanceof AST_Conditional && p.condition === this)
  14787. return true;
  14788. // (a = foo)["prop"] —or— (a = foo).prop
  14789. if (p instanceof AST_PropAccess && p.expression === this)
  14790. return true;
  14791. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  14792. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  14793. return true;
  14794. });
  14795. /* -----[ PRINTERS ]----- */
  14796. DEFPRINT(AST_Directive, function(self, output) {
  14797. output.print_string(self.value, self.quote);
  14798. output.semicolon();
  14799. });
  14800. DEFPRINT(AST_Expansion, function (self, output) {
  14801. output.print("...");
  14802. self.expression.print(output);
  14803. });
  14804. DEFPRINT(AST_Destructuring, function (self, output) {
  14805. output.print(self.is_array ? "[" : "{");
  14806. var len = self.names.length;
  14807. self.names.forEach(function (name, i) {
  14808. if (i > 0) output.comma();
  14809. name.print(output);
  14810. // If the final element is a hole, we need to make sure it
  14811. // doesn't look like a trailing comma, by inserting an actual
  14812. // trailing comma.
  14813. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  14814. });
  14815. output.print(self.is_array ? "]" : "}");
  14816. });
  14817. DEFPRINT(AST_Debugger, function(self, output) {
  14818. output.print("debugger");
  14819. output.semicolon();
  14820. });
  14821. /* -----[ statements ]----- */
  14822. function display_body(body, is_toplevel, output, allow_directives) {
  14823. var last = body.length - 1;
  14824. output.in_directive = allow_directives;
  14825. body.forEach(function(stmt, i) {
  14826. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  14827. stmt instanceof AST_EmptyStatement ||
  14828. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  14829. )) {
  14830. output.in_directive = false;
  14831. }
  14832. if (!(stmt instanceof AST_EmptyStatement)) {
  14833. output.indent();
  14834. stmt.print(output);
  14835. if (!(i == last && is_toplevel)) {
  14836. output.newline();
  14837. if (is_toplevel) output.newline();
  14838. }
  14839. }
  14840. if (output.in_directive === true &&
  14841. stmt instanceof AST_SimpleStatement &&
  14842. stmt.body instanceof AST_String
  14843. ) {
  14844. output.in_directive = false;
  14845. }
  14846. });
  14847. output.in_directive = false;
  14848. }
  14849. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  14850. force_statement(this.body, output);
  14851. });
  14852. DEFPRINT(AST_Statement, function(self, output) {
  14853. self.body.print(output);
  14854. output.semicolon();
  14855. });
  14856. DEFPRINT(AST_Toplevel, function(self, output) {
  14857. display_body(self.body, true, output, true);
  14858. output.print("");
  14859. });
  14860. DEFPRINT(AST_LabeledStatement, function(self, output) {
  14861. self.label.print(output);
  14862. output.colon();
  14863. self.body.print(output);
  14864. });
  14865. DEFPRINT(AST_SimpleStatement, function(self, output) {
  14866. self.body.print(output);
  14867. output.semicolon();
  14868. });
  14869. function print_braced_empty(self, output) {
  14870. output.print("{");
  14871. output.with_indent(output.next_indent(), function() {
  14872. output.append_comments(self, true);
  14873. });
  14874. output.print("}");
  14875. }
  14876. function print_braced(self, output, allow_directives) {
  14877. if (self.body.length > 0) {
  14878. output.with_block(function() {
  14879. display_body(self.body, false, output, allow_directives);
  14880. });
  14881. } else print_braced_empty(self, output);
  14882. }
  14883. DEFPRINT(AST_BlockStatement, function(self, output) {
  14884. print_braced(self, output);
  14885. });
  14886. DEFPRINT(AST_EmptyStatement, function(self, output) {
  14887. output.semicolon();
  14888. });
  14889. DEFPRINT(AST_Do, function(self, output) {
  14890. output.print("do");
  14891. output.space();
  14892. make_block(self.body, output);
  14893. output.space();
  14894. output.print("while");
  14895. output.space();
  14896. output.with_parens(function() {
  14897. self.condition.print(output);
  14898. });
  14899. output.semicolon();
  14900. });
  14901. DEFPRINT(AST_While, function(self, output) {
  14902. output.print("while");
  14903. output.space();
  14904. output.with_parens(function() {
  14905. self.condition.print(output);
  14906. });
  14907. output.space();
  14908. self._do_print_body(output);
  14909. });
  14910. DEFPRINT(AST_For, function(self, output) {
  14911. output.print("for");
  14912. output.space();
  14913. output.with_parens(function() {
  14914. if (self.init) {
  14915. if (self.init instanceof AST_Definitions) {
  14916. self.init.print(output);
  14917. } else {
  14918. parenthesize_for_noin(self.init, output, true);
  14919. }
  14920. output.print(";");
  14921. output.space();
  14922. } else {
  14923. output.print(";");
  14924. }
  14925. if (self.condition) {
  14926. self.condition.print(output);
  14927. output.print(";");
  14928. output.space();
  14929. } else {
  14930. output.print(";");
  14931. }
  14932. if (self.step) {
  14933. self.step.print(output);
  14934. }
  14935. });
  14936. output.space();
  14937. self._do_print_body(output);
  14938. });
  14939. DEFPRINT(AST_ForIn, function(self, output) {
  14940. output.print("for");
  14941. if (self.await) {
  14942. output.space();
  14943. output.print("await");
  14944. }
  14945. output.space();
  14946. output.with_parens(function() {
  14947. self.init.print(output);
  14948. output.space();
  14949. output.print(self instanceof AST_ForOf ? "of" : "in");
  14950. output.space();
  14951. self.object.print(output);
  14952. });
  14953. output.space();
  14954. self._do_print_body(output);
  14955. });
  14956. DEFPRINT(AST_With, function(self, output) {
  14957. output.print("with");
  14958. output.space();
  14959. output.with_parens(function() {
  14960. self.expression.print(output);
  14961. });
  14962. output.space();
  14963. self._do_print_body(output);
  14964. });
  14965. /* -----[ functions ]----- */
  14966. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  14967. var self = this;
  14968. if (!nokeyword) {
  14969. if (self.async) {
  14970. output.print("async");
  14971. output.space();
  14972. }
  14973. output.print("function");
  14974. if (self.is_generator) {
  14975. output.star();
  14976. }
  14977. if (self.name) {
  14978. output.space();
  14979. }
  14980. }
  14981. if (self.name instanceof AST_Symbol) {
  14982. self.name.print(output);
  14983. } else if (nokeyword && self.name instanceof AST_Node) {
  14984. output.with_square(function() {
  14985. self.name.print(output); // Computed method name
  14986. });
  14987. }
  14988. output.with_parens(function() {
  14989. self.argnames.forEach(function(arg, i) {
  14990. if (i) output.comma();
  14991. arg.print(output);
  14992. });
  14993. });
  14994. output.space();
  14995. print_braced(self, output, true);
  14996. });
  14997. DEFPRINT(AST_Lambda, function(self, output) {
  14998. self._do_print(output);
  14999. });
  15000. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  15001. var tag = self.prefix;
  15002. var parenthesize_tag = tag instanceof AST_Lambda
  15003. || tag instanceof AST_Binary
  15004. || tag instanceof AST_Conditional
  15005. || tag instanceof AST_Sequence
  15006. || tag instanceof AST_Unary
  15007. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  15008. if (parenthesize_tag) output.print("(");
  15009. self.prefix.print(output);
  15010. if (parenthesize_tag) output.print(")");
  15011. self.template_string.print(output);
  15012. });
  15013. DEFPRINT(AST_TemplateString, function(self, output) {
  15014. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  15015. output.print("`");
  15016. for (var i = 0; i < self.segments.length; i++) {
  15017. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  15018. output.print("${");
  15019. self.segments[i].print(output);
  15020. output.print("}");
  15021. } else if (is_tagged) {
  15022. output.print(self.segments[i].raw);
  15023. } else {
  15024. output.print_template_string_chars(self.segments[i].value);
  15025. }
  15026. }
  15027. output.print("`");
  15028. });
  15029. DEFPRINT(AST_TemplateSegment, function(self, output) {
  15030. output.print_template_string_chars(self.value);
  15031. });
  15032. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  15033. var self = this;
  15034. var parent = output.parent();
  15035. var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
  15036. parent instanceof AST_Unary ||
  15037. (parent instanceof AST_Call && self === parent.expression);
  15038. if (needs_parens) { output.print("("); }
  15039. if (self.async) {
  15040. output.print("async");
  15041. output.space();
  15042. }
  15043. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  15044. self.argnames[0].print(output);
  15045. } else {
  15046. output.with_parens(function() {
  15047. self.argnames.forEach(function(arg, i) {
  15048. if (i) output.comma();
  15049. arg.print(output);
  15050. });
  15051. });
  15052. }
  15053. output.space();
  15054. output.print("=>");
  15055. output.space();
  15056. const first_statement = self.body[0];
  15057. if (
  15058. self.body.length === 1
  15059. && first_statement instanceof AST_Return
  15060. ) {
  15061. const returned = first_statement.value;
  15062. if (!returned) {
  15063. output.print("{}");
  15064. } else if (left_is_object(returned)) {
  15065. output.print("(");
  15066. returned.print(output);
  15067. output.print(")");
  15068. } else {
  15069. returned.print(output);
  15070. }
  15071. } else {
  15072. print_braced(self, output);
  15073. }
  15074. if (needs_parens) { output.print(")"); }
  15075. });
  15076. /* -----[ exits ]----- */
  15077. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  15078. output.print(kind);
  15079. if (this.value) {
  15080. output.space();
  15081. const comments = this.value.start.comments_before;
  15082. if (comments && comments.length && !output.printed_comments.has(comments)) {
  15083. output.print("(");
  15084. this.value.print(output);
  15085. output.print(")");
  15086. } else {
  15087. this.value.print(output);
  15088. }
  15089. }
  15090. output.semicolon();
  15091. });
  15092. DEFPRINT(AST_Return, function(self, output) {
  15093. self._do_print(output, "return");
  15094. });
  15095. DEFPRINT(AST_Throw, function(self, output) {
  15096. self._do_print(output, "throw");
  15097. });
  15098. /* -----[ yield ]----- */
  15099. DEFPRINT(AST_Yield, function(self, output) {
  15100. var star = self.is_star ? "*" : "";
  15101. output.print("yield" + star);
  15102. if (self.expression) {
  15103. output.space();
  15104. self.expression.print(output);
  15105. }
  15106. });
  15107. DEFPRINT(AST_Await, function(self, output) {
  15108. output.print("await");
  15109. output.space();
  15110. var e = self.expression;
  15111. var parens = !(
  15112. e instanceof AST_Call
  15113. || e instanceof AST_SymbolRef
  15114. || e instanceof AST_PropAccess
  15115. || e instanceof AST_Unary
  15116. || e instanceof AST_Constant
  15117. || e instanceof AST_Await
  15118. || e instanceof AST_Object
  15119. );
  15120. if (parens) output.print("(");
  15121. self.expression.print(output);
  15122. if (parens) output.print(")");
  15123. });
  15124. /* -----[ loop control ]----- */
  15125. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  15126. output.print(kind);
  15127. if (this.label) {
  15128. output.space();
  15129. this.label.print(output);
  15130. }
  15131. output.semicolon();
  15132. });
  15133. DEFPRINT(AST_Break, function(self, output) {
  15134. self._do_print(output, "break");
  15135. });
  15136. DEFPRINT(AST_Continue, function(self, output) {
  15137. self._do_print(output, "continue");
  15138. });
  15139. /* -----[ if ]----- */
  15140. function make_then(self, output) {
  15141. var b = self.body;
  15142. if (output.option("braces")
  15143. || output.option("ie8") && b instanceof AST_Do)
  15144. return make_block(b, output);
  15145. // The squeezer replaces "block"-s that contain only a single
  15146. // statement with the statement itself; technically, the AST
  15147. // is correct, but this can create problems when we output an
  15148. // IF having an ELSE clause where the THEN clause ends in an
  15149. // IF *without* an ELSE block (then the outer ELSE would refer
  15150. // to the inner IF). This function checks for this case and
  15151. // adds the block braces if needed.
  15152. if (!b) return output.force_semicolon();
  15153. while (true) {
  15154. if (b instanceof AST_If) {
  15155. if (!b.alternative) {
  15156. make_block(self.body, output);
  15157. return;
  15158. }
  15159. b = b.alternative;
  15160. } else if (b instanceof AST_StatementWithBody) {
  15161. b = b.body;
  15162. } else break;
  15163. }
  15164. force_statement(self.body, output);
  15165. }
  15166. DEFPRINT(AST_If, function(self, output) {
  15167. output.print("if");
  15168. output.space();
  15169. output.with_parens(function() {
  15170. self.condition.print(output);
  15171. });
  15172. output.space();
  15173. if (self.alternative) {
  15174. make_then(self, output);
  15175. output.space();
  15176. output.print("else");
  15177. output.space();
  15178. if (self.alternative instanceof AST_If)
  15179. self.alternative.print(output);
  15180. else
  15181. force_statement(self.alternative, output);
  15182. } else {
  15183. self._do_print_body(output);
  15184. }
  15185. });
  15186. /* -----[ switch ]----- */
  15187. DEFPRINT(AST_Switch, function(self, output) {
  15188. output.print("switch");
  15189. output.space();
  15190. output.with_parens(function() {
  15191. self.expression.print(output);
  15192. });
  15193. output.space();
  15194. var last = self.body.length - 1;
  15195. if (last < 0) print_braced_empty(self, output);
  15196. else output.with_block(function() {
  15197. self.body.forEach(function(branch, i) {
  15198. output.indent(true);
  15199. branch.print(output);
  15200. if (i < last && branch.body.length > 0)
  15201. output.newline();
  15202. });
  15203. });
  15204. });
  15205. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  15206. output.newline();
  15207. this.body.forEach(function(stmt) {
  15208. output.indent();
  15209. stmt.print(output);
  15210. output.newline();
  15211. });
  15212. });
  15213. DEFPRINT(AST_Default, function(self, output) {
  15214. output.print("default:");
  15215. self._do_print_body(output);
  15216. });
  15217. DEFPRINT(AST_Case, function(self, output) {
  15218. output.print("case");
  15219. output.space();
  15220. self.expression.print(output);
  15221. output.print(":");
  15222. self._do_print_body(output);
  15223. });
  15224. /* -----[ exceptions ]----- */
  15225. DEFPRINT(AST_Try, function(self, output) {
  15226. output.print("try");
  15227. output.space();
  15228. print_braced(self, output);
  15229. if (self.bcatch) {
  15230. output.space();
  15231. self.bcatch.print(output);
  15232. }
  15233. if (self.bfinally) {
  15234. output.space();
  15235. self.bfinally.print(output);
  15236. }
  15237. });
  15238. DEFPRINT(AST_Catch, function(self, output) {
  15239. output.print("catch");
  15240. if (self.argname) {
  15241. output.space();
  15242. output.with_parens(function() {
  15243. self.argname.print(output);
  15244. });
  15245. }
  15246. output.space();
  15247. print_braced(self, output);
  15248. });
  15249. DEFPRINT(AST_Finally, function(self, output) {
  15250. output.print("finally");
  15251. output.space();
  15252. print_braced(self, output);
  15253. });
  15254. /* -----[ var/const ]----- */
  15255. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  15256. output.print(kind);
  15257. output.space();
  15258. this.definitions.forEach(function(def, i) {
  15259. if (i) output.comma();
  15260. def.print(output);
  15261. });
  15262. var p = output.parent();
  15263. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  15264. var output_semicolon = !in_for || p && p.init !== this;
  15265. if (output_semicolon)
  15266. output.semicolon();
  15267. });
  15268. DEFPRINT(AST_Let, function(self, output) {
  15269. self._do_print(output, "let");
  15270. });
  15271. DEFPRINT(AST_Var, function(self, output) {
  15272. self._do_print(output, "var");
  15273. });
  15274. DEFPRINT(AST_Const, function(self, output) {
  15275. self._do_print(output, "const");
  15276. });
  15277. DEFPRINT(AST_Import, function(self, output) {
  15278. output.print("import");
  15279. output.space();
  15280. if (self.imported_name) {
  15281. self.imported_name.print(output);
  15282. }
  15283. if (self.imported_name && self.imported_names) {
  15284. output.print(",");
  15285. output.space();
  15286. }
  15287. if (self.imported_names) {
  15288. if (self.imported_names.length === 1 && self.imported_names[0].foreign_name.name === "*") {
  15289. self.imported_names[0].print(output);
  15290. } else {
  15291. output.print("{");
  15292. self.imported_names.forEach(function (name_import, i) {
  15293. output.space();
  15294. name_import.print(output);
  15295. if (i < self.imported_names.length - 1) {
  15296. output.print(",");
  15297. }
  15298. });
  15299. output.space();
  15300. output.print("}");
  15301. }
  15302. }
  15303. if (self.imported_name || self.imported_names) {
  15304. output.space();
  15305. output.print("from");
  15306. output.space();
  15307. }
  15308. self.module_name.print(output);
  15309. output.semicolon();
  15310. });
  15311. DEFPRINT(AST_ImportMeta, function(self, output) {
  15312. output.print("import.meta");
  15313. });
  15314. DEFPRINT(AST_NameMapping, function(self, output) {
  15315. var is_import = output.parent() instanceof AST_Import;
  15316. var definition = self.name.definition();
  15317. var names_are_different =
  15318. (definition && definition.mangled_name || self.name.name) !==
  15319. self.foreign_name.name;
  15320. if (names_are_different) {
  15321. if (is_import) {
  15322. output.print(self.foreign_name.name);
  15323. } else {
  15324. self.name.print(output);
  15325. }
  15326. output.space();
  15327. output.print("as");
  15328. output.space();
  15329. if (is_import) {
  15330. self.name.print(output);
  15331. } else {
  15332. output.print(self.foreign_name.name);
  15333. }
  15334. } else {
  15335. self.name.print(output);
  15336. }
  15337. });
  15338. DEFPRINT(AST_Export, function(self, output) {
  15339. output.print("export");
  15340. output.space();
  15341. if (self.is_default) {
  15342. output.print("default");
  15343. output.space();
  15344. }
  15345. if (self.exported_names) {
  15346. if (self.exported_names.length === 1 && self.exported_names[0].name.name === "*") {
  15347. self.exported_names[0].print(output);
  15348. } else {
  15349. output.print("{");
  15350. self.exported_names.forEach(function(name_export, i) {
  15351. output.space();
  15352. name_export.print(output);
  15353. if (i < self.exported_names.length - 1) {
  15354. output.print(",");
  15355. }
  15356. });
  15357. output.space();
  15358. output.print("}");
  15359. }
  15360. } else if (self.exported_value) {
  15361. self.exported_value.print(output);
  15362. } else if (self.exported_definition) {
  15363. self.exported_definition.print(output);
  15364. if (self.exported_definition instanceof AST_Definitions) return;
  15365. }
  15366. if (self.module_name) {
  15367. output.space();
  15368. output.print("from");
  15369. output.space();
  15370. self.module_name.print(output);
  15371. }
  15372. if (self.exported_value
  15373. && !(self.exported_value instanceof AST_Defun ||
  15374. self.exported_value instanceof AST_Function ||
  15375. self.exported_value instanceof AST_Class)
  15376. || self.module_name
  15377. || self.exported_names
  15378. ) {
  15379. output.semicolon();
  15380. }
  15381. });
  15382. function parenthesize_for_noin(node, output, noin) {
  15383. var parens = false;
  15384. // need to take some precautions here:
  15385. // https://github.com/mishoo/UglifyJS2/issues/60
  15386. if (noin) {
  15387. parens = walk(node, node => {
  15388. // Don't go into scopes -- except arrow functions:
  15389. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  15390. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  15391. return true;
  15392. }
  15393. if (node instanceof AST_Binary && node.operator == "in") {
  15394. return walk_abort; // makes walk() return true
  15395. }
  15396. });
  15397. }
  15398. node.print(output, parens);
  15399. }
  15400. DEFPRINT(AST_VarDef, function(self, output) {
  15401. self.name.print(output);
  15402. if (self.value) {
  15403. output.space();
  15404. output.print("=");
  15405. output.space();
  15406. var p = output.parent(1);
  15407. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  15408. parenthesize_for_noin(self.value, output, noin);
  15409. }
  15410. });
  15411. /* -----[ other expressions ]----- */
  15412. DEFPRINT(AST_Call, function(self, output) {
  15413. self.expression.print(output);
  15414. if (self instanceof AST_New && self.args.length === 0)
  15415. return;
  15416. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  15417. output.add_mapping(self.start);
  15418. }
  15419. if (self.optional) output.print("?.");
  15420. output.with_parens(function() {
  15421. self.args.forEach(function(expr, i) {
  15422. if (i) output.comma();
  15423. expr.print(output);
  15424. });
  15425. });
  15426. });
  15427. DEFPRINT(AST_New, function(self, output) {
  15428. output.print("new");
  15429. output.space();
  15430. AST_Call.prototype._codegen(self, output);
  15431. });
  15432. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  15433. this.expressions.forEach(function(node, index) {
  15434. if (index > 0) {
  15435. output.comma();
  15436. if (output.should_break()) {
  15437. output.newline();
  15438. output.indent();
  15439. }
  15440. }
  15441. node.print(output);
  15442. });
  15443. });
  15444. DEFPRINT(AST_Sequence, function(self, output) {
  15445. self._do_print(output);
  15446. // var p = output.parent();
  15447. // if (p instanceof AST_Statement) {
  15448. // output.with_indent(output.next_indent(), function(){
  15449. // self._do_print(output);
  15450. // });
  15451. // } else {
  15452. // self._do_print(output);
  15453. // }
  15454. });
  15455. DEFPRINT(AST_Dot, function(self, output) {
  15456. var expr = self.expression;
  15457. expr.print(output);
  15458. var prop = self.property;
  15459. var print_computed = ALL_RESERVED_WORDS.has(prop)
  15460. ? output.option("ie8")
  15461. : !is_identifier_string(
  15462. prop,
  15463. output.option("ecma") >= 2015 || output.option("safari10")
  15464. );
  15465. if (self.optional) output.print("?.");
  15466. if (print_computed) {
  15467. output.print("[");
  15468. output.add_mapping(self.end);
  15469. output.print_string(prop);
  15470. output.print("]");
  15471. } else {
  15472. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  15473. if (!/[xa-f.)]/i.test(output.last())) {
  15474. output.print(".");
  15475. }
  15476. }
  15477. if (!self.optional) output.print(".");
  15478. // the name after dot would be mapped about here.
  15479. output.add_mapping(self.end);
  15480. output.print_name(prop);
  15481. }
  15482. });
  15483. DEFPRINT(AST_DotHash, function(self, output) {
  15484. var expr = self.expression;
  15485. expr.print(output);
  15486. var prop = self.property;
  15487. if (self.optional) output.print("?");
  15488. output.print(".#");
  15489. output.print_name(prop);
  15490. });
  15491. DEFPRINT(AST_Sub, function(self, output) {
  15492. self.expression.print(output);
  15493. if (self.optional) output.print("?.");
  15494. output.print("[");
  15495. self.property.print(output);
  15496. output.print("]");
  15497. });
  15498. DEFPRINT(AST_Chain, function(self, output) {
  15499. self.expression.print(output);
  15500. });
  15501. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  15502. var op = self.operator;
  15503. output.print(op);
  15504. if (/^[a-z]/i.test(op)
  15505. || (/[+-]$/.test(op)
  15506. && self.expression instanceof AST_UnaryPrefix
  15507. && /^[+-]/.test(self.expression.operator))) {
  15508. output.space();
  15509. }
  15510. self.expression.print(output);
  15511. });
  15512. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  15513. self.expression.print(output);
  15514. output.print(self.operator);
  15515. });
  15516. DEFPRINT(AST_Binary, function(self, output) {
  15517. var op = self.operator;
  15518. self.left.print(output);
  15519. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  15520. && self.left instanceof AST_UnaryPostfix
  15521. && self.left.operator == "--") {
  15522. // space is mandatory to avoid outputting -->
  15523. output.print(" ");
  15524. } else {
  15525. // the space is optional depending on "beautify"
  15526. output.space();
  15527. }
  15528. output.print(op);
  15529. if ((op == "<" || op == "<<")
  15530. && self.right instanceof AST_UnaryPrefix
  15531. && self.right.operator == "!"
  15532. && self.right.expression instanceof AST_UnaryPrefix
  15533. && self.right.expression.operator == "--") {
  15534. // space is mandatory to avoid outputting <!--
  15535. output.print(" ");
  15536. } else {
  15537. // the space is optional depending on "beautify"
  15538. output.space();
  15539. }
  15540. self.right.print(output);
  15541. });
  15542. DEFPRINT(AST_Conditional, function(self, output) {
  15543. self.condition.print(output);
  15544. output.space();
  15545. output.print("?");
  15546. output.space();
  15547. self.consequent.print(output);
  15548. output.space();
  15549. output.colon();
  15550. self.alternative.print(output);
  15551. });
  15552. /* -----[ literals ]----- */
  15553. DEFPRINT(AST_Array, function(self, output) {
  15554. output.with_square(function() {
  15555. var a = self.elements, len = a.length;
  15556. if (len > 0) output.space();
  15557. a.forEach(function(exp, i) {
  15558. if (i) output.comma();
  15559. exp.print(output);
  15560. // If the final element is a hole, we need to make sure it
  15561. // doesn't look like a trailing comma, by inserting an actual
  15562. // trailing comma.
  15563. if (i === len - 1 && exp instanceof AST_Hole)
  15564. output.comma();
  15565. });
  15566. if (len > 0) output.space();
  15567. });
  15568. });
  15569. DEFPRINT(AST_Object, function(self, output) {
  15570. if (self.properties.length > 0) output.with_block(function() {
  15571. self.properties.forEach(function(prop, i) {
  15572. if (i) {
  15573. output.print(",");
  15574. output.newline();
  15575. }
  15576. output.indent();
  15577. prop.print(output);
  15578. });
  15579. output.newline();
  15580. });
  15581. else print_braced_empty(self, output);
  15582. });
  15583. DEFPRINT(AST_Class, function(self, output) {
  15584. output.print("class");
  15585. output.space();
  15586. if (self.name) {
  15587. self.name.print(output);
  15588. output.space();
  15589. }
  15590. if (self.extends) {
  15591. var parens = (
  15592. !(self.extends instanceof AST_SymbolRef)
  15593. && !(self.extends instanceof AST_PropAccess)
  15594. && !(self.extends instanceof AST_ClassExpression)
  15595. && !(self.extends instanceof AST_Function)
  15596. );
  15597. output.print("extends");
  15598. if (parens) {
  15599. output.print("(");
  15600. } else {
  15601. output.space();
  15602. }
  15603. self.extends.print(output);
  15604. if (parens) {
  15605. output.print(")");
  15606. } else {
  15607. output.space();
  15608. }
  15609. }
  15610. if (self.properties.length > 0) output.with_block(function() {
  15611. self.properties.forEach(function(prop, i) {
  15612. if (i) {
  15613. output.newline();
  15614. }
  15615. output.indent();
  15616. prop.print(output);
  15617. });
  15618. output.newline();
  15619. });
  15620. else output.print("{}");
  15621. });
  15622. DEFPRINT(AST_NewTarget, function(self, output) {
  15623. output.print("new.target");
  15624. });
  15625. function print_property_name(key, quote, output) {
  15626. if (output.option("quote_keys")) {
  15627. return output.print_string(key);
  15628. }
  15629. if ("" + +key == key && key >= 0) {
  15630. if (output.option("keep_numbers")) {
  15631. return output.print(key);
  15632. }
  15633. return output.print(make_num(key));
  15634. }
  15635. var print_string = ALL_RESERVED_WORDS.has(key)
  15636. ? output.option("ie8")
  15637. : (
  15638. output.option("ecma") < 2015 || output.option("safari10")
  15639. ? !is_basic_identifier_string(key)
  15640. : !is_identifier_string(key, true)
  15641. );
  15642. if (print_string || (quote && output.option("keep_quoted_props"))) {
  15643. return output.print_string(key, quote);
  15644. }
  15645. return output.print_name(key);
  15646. }
  15647. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  15648. function get_name(self) {
  15649. var def = self.definition();
  15650. return def ? def.mangled_name || def.name : self.name;
  15651. }
  15652. var allowShortHand = output.option("shorthand");
  15653. if (allowShortHand &&
  15654. self.value instanceof AST_Symbol &&
  15655. is_identifier_string(
  15656. self.key,
  15657. output.option("ecma") >= 2015 || output.option("safari10")
  15658. ) &&
  15659. get_name(self.value) === self.key &&
  15660. !ALL_RESERVED_WORDS.has(self.key)
  15661. ) {
  15662. print_property_name(self.key, self.quote, output);
  15663. } else if (allowShortHand &&
  15664. self.value instanceof AST_DefaultAssign &&
  15665. self.value.left instanceof AST_Symbol &&
  15666. is_identifier_string(
  15667. self.key,
  15668. output.option("ecma") >= 2015 || output.option("safari10")
  15669. ) &&
  15670. get_name(self.value.left) === self.key
  15671. ) {
  15672. print_property_name(self.key, self.quote, output);
  15673. output.space();
  15674. output.print("=");
  15675. output.space();
  15676. self.value.right.print(output);
  15677. } else {
  15678. if (!(self.key instanceof AST_Node)) {
  15679. print_property_name(self.key, self.quote, output);
  15680. } else {
  15681. output.with_square(function() {
  15682. self.key.print(output);
  15683. });
  15684. }
  15685. output.colon();
  15686. self.value.print(output);
  15687. }
  15688. });
  15689. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  15690. if (self.static) {
  15691. output.print("static");
  15692. output.space();
  15693. }
  15694. output.print("#");
  15695. print_property_name(self.key.name, self.quote, output);
  15696. if (self.value) {
  15697. output.print("=");
  15698. self.value.print(output);
  15699. }
  15700. output.semicolon();
  15701. });
  15702. DEFPRINT(AST_ClassProperty, (self, output) => {
  15703. if (self.static) {
  15704. output.print("static");
  15705. output.space();
  15706. }
  15707. if (self.key instanceof AST_SymbolClassProperty) {
  15708. print_property_name(self.key.name, self.quote, output);
  15709. } else {
  15710. output.print("[");
  15711. self.key.print(output);
  15712. output.print("]");
  15713. }
  15714. if (self.value) {
  15715. output.print("=");
  15716. self.value.print(output);
  15717. }
  15718. output.semicolon();
  15719. });
  15720. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  15721. var self = this;
  15722. if (self.static) {
  15723. output.print("static");
  15724. output.space();
  15725. }
  15726. if (type) {
  15727. output.print(type);
  15728. output.space();
  15729. }
  15730. if (self.key instanceof AST_SymbolMethod) {
  15731. if (is_private) output.print("#");
  15732. print_property_name(self.key.name, self.quote, output);
  15733. } else {
  15734. output.with_square(function() {
  15735. self.key.print(output);
  15736. });
  15737. }
  15738. self.value._do_print(output, true);
  15739. });
  15740. DEFPRINT(AST_ObjectSetter, function(self, output) {
  15741. self._print_getter_setter("set", false, output);
  15742. });
  15743. DEFPRINT(AST_ObjectGetter, function(self, output) {
  15744. self._print_getter_setter("get", false, output);
  15745. });
  15746. DEFPRINT(AST_PrivateSetter, function(self, output) {
  15747. self._print_getter_setter("set", true, output);
  15748. });
  15749. DEFPRINT(AST_PrivateGetter, function(self, output) {
  15750. self._print_getter_setter("get", true, output);
  15751. });
  15752. DEFPRINT(AST_PrivateMethod, function(self, output) {
  15753. var type;
  15754. if (self.is_generator && self.async) {
  15755. type = "async*";
  15756. } else if (self.is_generator) {
  15757. type = "*";
  15758. } else if (self.async) {
  15759. type = "async";
  15760. }
  15761. self._print_getter_setter(type, true, output);
  15762. });
  15763. DEFPRINT(AST_ConciseMethod, function(self, output) {
  15764. var type;
  15765. if (self.is_generator && self.async) {
  15766. type = "async*";
  15767. } else if (self.is_generator) {
  15768. type = "*";
  15769. } else if (self.async) {
  15770. type = "async";
  15771. }
  15772. self._print_getter_setter(type, false, output);
  15773. });
  15774. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  15775. var def = this.definition();
  15776. output.print_name(def ? def.mangled_name || def.name : this.name);
  15777. });
  15778. DEFPRINT(AST_Symbol, function (self, output) {
  15779. self._do_print(output);
  15780. });
  15781. DEFPRINT(AST_Hole, noop);
  15782. DEFPRINT(AST_This, function(self, output) {
  15783. output.print("this");
  15784. });
  15785. DEFPRINT(AST_Super, function(self, output) {
  15786. output.print("super");
  15787. });
  15788. DEFPRINT(AST_Constant, function(self, output) {
  15789. output.print(self.getValue());
  15790. });
  15791. DEFPRINT(AST_String, function(self, output) {
  15792. output.print_string(self.getValue(), self.quote, output.in_directive);
  15793. });
  15794. DEFPRINT(AST_Number, function(self, output) {
  15795. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  15796. output.print(self.raw);
  15797. } else {
  15798. output.print(make_num(self.getValue()));
  15799. }
  15800. });
  15801. DEFPRINT(AST_BigInt, function(self, output) {
  15802. output.print(self.getValue() + "n");
  15803. });
  15804. const r_slash_script = /(<\s*\/\s*script)/i;
  15805. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  15806. DEFPRINT(AST_RegExp, function(self, output) {
  15807. let { source, flags } = self.getValue();
  15808. source = regexp_source_fix(source);
  15809. flags = flags ? sort_regexp_flags(flags) : "";
  15810. source = source.replace(r_slash_script, slash_script_replace);
  15811. output.print(output.to_utf8(`/${source}/${flags}`));
  15812. const parent = output.parent();
  15813. if (
  15814. parent instanceof AST_Binary
  15815. && /^\w/.test(parent.operator)
  15816. && parent.left === self
  15817. ) {
  15818. output.print(" ");
  15819. }
  15820. });
  15821. function force_statement(stat, output) {
  15822. if (output.option("braces")) {
  15823. make_block(stat, output);
  15824. } else {
  15825. if (!stat || stat instanceof AST_EmptyStatement)
  15826. output.force_semicolon();
  15827. else
  15828. stat.print(output);
  15829. }
  15830. }
  15831. function best_of(a) {
  15832. var best = a[0], len = best.length;
  15833. for (var i = 1; i < a.length; ++i) {
  15834. if (a[i].length < len) {
  15835. best = a[i];
  15836. len = best.length;
  15837. }
  15838. }
  15839. return best;
  15840. }
  15841. function make_num(num) {
  15842. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  15843. var candidates = [ str ];
  15844. if (Math.floor(num) === num) {
  15845. if (num < 0) {
  15846. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  15847. } else {
  15848. candidates.push("0x" + num.toString(16).toLowerCase());
  15849. }
  15850. }
  15851. var match, len, digits;
  15852. if (match = /^\.0+/.exec(str)) {
  15853. len = match[0].length;
  15854. digits = str.slice(len);
  15855. candidates.push(digits + "e-" + (digits.length + len - 1));
  15856. } else if (match = /0+$/.exec(str)) {
  15857. len = match[0].length;
  15858. candidates.push(str.slice(0, -len) + "e" + len);
  15859. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  15860. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  15861. }
  15862. return best_of(candidates);
  15863. }
  15864. function make_block(stmt, output) {
  15865. if (!stmt || stmt instanceof AST_EmptyStatement)
  15866. output.print("{}");
  15867. else if (stmt instanceof AST_BlockStatement)
  15868. stmt.print(output);
  15869. else output.with_block(function() {
  15870. output.indent();
  15871. stmt.print(output);
  15872. output.newline();
  15873. });
  15874. }
  15875. /* -----[ source map generators ]----- */
  15876. function DEFMAP(nodetype, generator) {
  15877. nodetype.forEach(function(nodetype) {
  15878. nodetype.DEFMETHOD("add_source_map", generator);
  15879. });
  15880. }
  15881. DEFMAP([
  15882. // We could easily add info for ALL nodes, but it seems to me that
  15883. // would be quite wasteful, hence this noop in the base class.
  15884. AST_Node,
  15885. // since the label symbol will mark it
  15886. AST_LabeledStatement,
  15887. AST_Toplevel,
  15888. ], noop);
  15889. // XXX: I'm not exactly sure if we need it for all of these nodes,
  15890. // or if we should add even more.
  15891. DEFMAP([
  15892. AST_Array,
  15893. AST_BlockStatement,
  15894. AST_Catch,
  15895. AST_Class,
  15896. AST_Constant,
  15897. AST_Debugger,
  15898. AST_Definitions,
  15899. AST_Directive,
  15900. AST_Finally,
  15901. AST_Jump,
  15902. AST_Lambda,
  15903. AST_New,
  15904. AST_Object,
  15905. AST_StatementWithBody,
  15906. AST_Symbol,
  15907. AST_Switch,
  15908. AST_SwitchBranch,
  15909. AST_TemplateString,
  15910. AST_TemplateSegment,
  15911. AST_Try,
  15912. ], function(output) {
  15913. output.add_mapping(this.start);
  15914. });
  15915. DEFMAP([
  15916. AST_ObjectGetter,
  15917. AST_ObjectSetter,
  15918. ], function(output) {
  15919. output.add_mapping(this.start, this.key.name);
  15920. });
  15921. DEFMAP([ AST_ObjectProperty ], function(output) {
  15922. output.add_mapping(this.start, this.key);
  15923. });
  15924. })();
  15925. const shallow_cmp = (node1, node2) => {
  15926. return (
  15927. node1 === null && node2 === null
  15928. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  15929. );
  15930. };
  15931. const equivalent_to = (tree1, tree2) => {
  15932. if (!shallow_cmp(tree1, tree2)) return false;
  15933. const walk_1_state = [tree1];
  15934. const walk_2_state = [tree2];
  15935. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  15936. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  15937. while (walk_1_state.length && walk_2_state.length) {
  15938. const node_1 = walk_1_state.pop();
  15939. const node_2 = walk_2_state.pop();
  15940. if (!shallow_cmp(node_1, node_2)) return false;
  15941. node_1._children_backwards(walk_1_push);
  15942. node_2._children_backwards(walk_2_push);
  15943. if (walk_1_state.length !== walk_2_state.length) {
  15944. // Different number of children
  15945. return false;
  15946. }
  15947. }
  15948. return walk_1_state.length == 0 && walk_2_state.length == 0;
  15949. };
  15950. // Creates a shallow compare function
  15951. const mkshallow = (props) => {
  15952. const comparisons = Object
  15953. .keys(props)
  15954. .map(key => {
  15955. if (props[key] === "eq") {
  15956. return `this.${key} === other.${key}`;
  15957. } else if (props[key] === "exist") {
  15958. return `(this.${key} == null ? other.${key} == null : this.${key} === other.${key})`;
  15959. } else {
  15960. throw new Error(`mkshallow: Unexpected instruction: ${props[key]}`);
  15961. }
  15962. })
  15963. .join(" && ");
  15964. return new Function("other", "return " + comparisons);
  15965. };
  15966. const pass_through = () => true;
  15967. AST_Node.prototype.shallow_cmp = function () {
  15968. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  15969. };
  15970. AST_Debugger.prototype.shallow_cmp = pass_through;
  15971. AST_Directive.prototype.shallow_cmp = mkshallow({ value: "eq" });
  15972. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  15973. AST_Block.prototype.shallow_cmp = pass_through;
  15974. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  15975. AST_LabeledStatement.prototype.shallow_cmp = mkshallow({ "label.name": "eq" });
  15976. AST_Do.prototype.shallow_cmp = pass_through;
  15977. AST_While.prototype.shallow_cmp = pass_through;
  15978. AST_For.prototype.shallow_cmp = mkshallow({
  15979. init: "exist",
  15980. condition: "exist",
  15981. step: "exist"
  15982. });
  15983. AST_ForIn.prototype.shallow_cmp = pass_through;
  15984. AST_ForOf.prototype.shallow_cmp = pass_through;
  15985. AST_With.prototype.shallow_cmp = pass_through;
  15986. AST_Toplevel.prototype.shallow_cmp = pass_through;
  15987. AST_Expansion.prototype.shallow_cmp = pass_through;
  15988. AST_Lambda.prototype.shallow_cmp = mkshallow({
  15989. is_generator: "eq",
  15990. async: "eq"
  15991. });
  15992. AST_Destructuring.prototype.shallow_cmp = mkshallow({
  15993. is_array: "eq"
  15994. });
  15995. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  15996. AST_TemplateString.prototype.shallow_cmp = pass_through;
  15997. AST_TemplateSegment.prototype.shallow_cmp = mkshallow({
  15998. "value": "eq"
  15999. });
  16000. AST_Jump.prototype.shallow_cmp = pass_through;
  16001. AST_LoopControl.prototype.shallow_cmp = pass_through;
  16002. AST_Await.prototype.shallow_cmp = pass_through;
  16003. AST_Yield.prototype.shallow_cmp = mkshallow({
  16004. is_star: "eq"
  16005. });
  16006. AST_If.prototype.shallow_cmp = mkshallow({
  16007. alternative: "exist"
  16008. });
  16009. AST_Switch.prototype.shallow_cmp = pass_through;
  16010. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  16011. AST_Try.prototype.shallow_cmp = mkshallow({
  16012. bcatch: "exist",
  16013. bfinally: "exist"
  16014. });
  16015. AST_Catch.prototype.shallow_cmp = mkshallow({
  16016. argname: "exist"
  16017. });
  16018. AST_Finally.prototype.shallow_cmp = pass_through;
  16019. AST_Definitions.prototype.shallow_cmp = pass_through;
  16020. AST_VarDef.prototype.shallow_cmp = mkshallow({
  16021. value: "exist"
  16022. });
  16023. AST_NameMapping.prototype.shallow_cmp = pass_through;
  16024. AST_Import.prototype.shallow_cmp = mkshallow({
  16025. imported_name: "exist",
  16026. imported_names: "exist"
  16027. });
  16028. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  16029. AST_Export.prototype.shallow_cmp = mkshallow({
  16030. exported_definition: "exist",
  16031. exported_value: "exist",
  16032. exported_names: "exist",
  16033. module_name: "eq",
  16034. is_default: "eq",
  16035. });
  16036. AST_Call.prototype.shallow_cmp = pass_through;
  16037. AST_Sequence.prototype.shallow_cmp = pass_through;
  16038. AST_PropAccess.prototype.shallow_cmp = pass_through;
  16039. AST_Chain.prototype.shallow_cmp = pass_through;
  16040. AST_Dot.prototype.shallow_cmp = mkshallow({
  16041. property: "eq"
  16042. });
  16043. AST_DotHash.prototype.shallow_cmp = mkshallow({
  16044. property: "eq"
  16045. });
  16046. AST_Unary.prototype.shallow_cmp = mkshallow({
  16047. operator: "eq"
  16048. });
  16049. AST_Binary.prototype.shallow_cmp = mkshallow({
  16050. operator: "eq"
  16051. });
  16052. AST_Conditional.prototype.shallow_cmp = pass_through;
  16053. AST_Array.prototype.shallow_cmp = pass_through;
  16054. AST_Object.prototype.shallow_cmp = pass_through;
  16055. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  16056. AST_ObjectKeyVal.prototype.shallow_cmp = mkshallow({
  16057. key: "eq"
  16058. });
  16059. AST_ObjectSetter.prototype.shallow_cmp = mkshallow({
  16060. static: "eq"
  16061. });
  16062. AST_ObjectGetter.prototype.shallow_cmp = mkshallow({
  16063. static: "eq"
  16064. });
  16065. AST_ConciseMethod.prototype.shallow_cmp = mkshallow({
  16066. static: "eq",
  16067. is_generator: "eq",
  16068. async: "eq",
  16069. });
  16070. AST_Class.prototype.shallow_cmp = mkshallow({
  16071. name: "exist",
  16072. extends: "exist",
  16073. });
  16074. AST_ClassProperty.prototype.shallow_cmp = mkshallow({
  16075. static: "eq"
  16076. });
  16077. AST_Symbol.prototype.shallow_cmp = mkshallow({
  16078. name: "eq"
  16079. });
  16080. AST_NewTarget.prototype.shallow_cmp = pass_through;
  16081. AST_This.prototype.shallow_cmp = pass_through;
  16082. AST_Super.prototype.shallow_cmp = pass_through;
  16083. AST_String.prototype.shallow_cmp = mkshallow({
  16084. value: "eq"
  16085. });
  16086. AST_Number.prototype.shallow_cmp = mkshallow({
  16087. value: "eq"
  16088. });
  16089. AST_BigInt.prototype.shallow_cmp = mkshallow({
  16090. value: "eq"
  16091. });
  16092. AST_RegExp.prototype.shallow_cmp = function (other) {
  16093. return (
  16094. this.value.flags === other.value.flags
  16095. && this.value.source === other.value.source
  16096. );
  16097. };
  16098. AST_Atom.prototype.shallow_cmp = pass_through;
  16099. /***********************************************************************
  16100. A JavaScript tokenizer / parser / beautifier / compressor.
  16101. https://github.com/mishoo/UglifyJS2
  16102. -------------------------------- (C) ---------------------------------
  16103. Author: Mihai Bazon
  16104. <mihai.bazon@gmail.com>
  16105. http://mihai.bazon.net/blog
  16106. Distributed under the BSD license:
  16107. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16108. Redistribution and use in source and binary forms, with or without
  16109. modification, are permitted provided that the following conditions
  16110. are met:
  16111. * Redistributions of source code must retain the above
  16112. copyright notice, this list of conditions and the following
  16113. disclaimer.
  16114. * Redistributions in binary form must reproduce the above
  16115. copyright notice, this list of conditions and the following
  16116. disclaimer in the documentation and/or other materials
  16117. provided with the distribution.
  16118. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16119. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16120. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16121. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16122. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16123. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16124. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16125. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16126. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16127. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16128. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16129. SUCH DAMAGE.
  16130. ***********************************************************************/
  16131. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  16132. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  16133. let function_defs = null;
  16134. let unmangleable_names = null;
  16135. class SymbolDef {
  16136. constructor(scope, orig, init) {
  16137. this.name = orig.name;
  16138. this.orig = [ orig ];
  16139. this.init = init;
  16140. this.eliminated = 0;
  16141. this.assignments = 0;
  16142. this.scope = scope;
  16143. this.replaced = 0;
  16144. this.global = false;
  16145. this.export = 0;
  16146. this.mangled_name = null;
  16147. this.undeclared = false;
  16148. this.id = SymbolDef.next_id++;
  16149. this.chained = false;
  16150. this.direct_access = false;
  16151. this.escaped = 0;
  16152. this.recursive_refs = 0;
  16153. this.references = [];
  16154. this.should_replace = undefined;
  16155. this.single_use = false;
  16156. this.fixed = false;
  16157. Object.seal(this);
  16158. }
  16159. fixed_value() {
  16160. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  16161. return this.fixed();
  16162. }
  16163. unmangleable(options) {
  16164. if (!options) options = {};
  16165. if (
  16166. function_defs &&
  16167. function_defs.has(this.id) &&
  16168. keep_name(options.keep_fnames, this.orig[0].name)
  16169. ) return true;
  16170. return this.global && !options.toplevel
  16171. || (this.export & MASK_EXPORT_DONT_MANGLE)
  16172. || this.undeclared
  16173. || !options.eval && this.scope.pinned()
  16174. || (this.orig[0] instanceof AST_SymbolLambda
  16175. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  16176. || this.orig[0] instanceof AST_SymbolMethod
  16177. || (this.orig[0] instanceof AST_SymbolClass
  16178. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  16179. }
  16180. mangle(options) {
  16181. const cache = options.cache && options.cache.props;
  16182. if (this.global && cache && cache.has(this.name)) {
  16183. this.mangled_name = cache.get(this.name);
  16184. } else if (!this.mangled_name && !this.unmangleable(options)) {
  16185. var s = this.scope;
  16186. var sym = this.orig[0];
  16187. if (options.ie8 && sym instanceof AST_SymbolLambda)
  16188. s = s.parent_scope;
  16189. const redefinition = redefined_catch_def(this);
  16190. this.mangled_name = redefinition
  16191. ? redefinition.mangled_name || redefinition.name
  16192. : s.next_mangled(options, this);
  16193. if (this.global && cache) {
  16194. cache.set(this.name, this.mangled_name);
  16195. }
  16196. }
  16197. }
  16198. }
  16199. SymbolDef.next_id = 1;
  16200. function redefined_catch_def(def) {
  16201. if (def.orig[0] instanceof AST_SymbolCatch
  16202. && def.scope.is_block_scope()
  16203. ) {
  16204. return def.scope.get_defun_scope().variables.get(def.name);
  16205. }
  16206. }
  16207. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  16208. options = defaults(options, {
  16209. cache: null,
  16210. ie8: false,
  16211. safari10: false,
  16212. });
  16213. if (!(toplevel instanceof AST_Toplevel)) {
  16214. throw new Error("Invalid toplevel scope");
  16215. }
  16216. // pass 1: setup scope chaining and handle definitions
  16217. var scope = this.parent_scope = parent_scope;
  16218. var labels = new Map();
  16219. var defun = null;
  16220. var in_destructuring = null;
  16221. var for_scopes = [];
  16222. var tw = new TreeWalker((node, descend) => {
  16223. if (node.is_block_scope()) {
  16224. const save_scope = scope;
  16225. node.block_scope = scope = new AST_Scope(node);
  16226. scope._block_scope = true;
  16227. // AST_Try in the AST sadly *is* (not has) a body itself,
  16228. // and its catch and finally branches are children of the AST_Try itself
  16229. const parent_scope = node instanceof AST_Catch
  16230. ? save_scope.parent_scope
  16231. : save_scope;
  16232. scope.init_scope_vars(parent_scope);
  16233. scope.uses_with = save_scope.uses_with;
  16234. scope.uses_eval = save_scope.uses_eval;
  16235. if (options.safari10) {
  16236. if (node instanceof AST_For || node instanceof AST_ForIn) {
  16237. for_scopes.push(scope);
  16238. }
  16239. }
  16240. if (node instanceof AST_Switch) {
  16241. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  16242. // AST_Switch has a scope within the body, but it itself "is a block scope"
  16243. // This means the switched expression has to belong to the outer scope
  16244. // while the body inside belongs to the switch itself.
  16245. // This is pretty nasty and warrants an AST change similar to AST_Try (read above)
  16246. const the_block_scope = scope;
  16247. scope = save_scope;
  16248. node.expression.walk(tw);
  16249. scope = the_block_scope;
  16250. for (let i = 0; i < node.body.length; i++) {
  16251. node.body[i].walk(tw);
  16252. }
  16253. } else {
  16254. descend();
  16255. }
  16256. scope = save_scope;
  16257. return true;
  16258. }
  16259. if (node instanceof AST_Destructuring) {
  16260. const save_destructuring = in_destructuring;
  16261. in_destructuring = node;
  16262. descend();
  16263. in_destructuring = save_destructuring;
  16264. return true;
  16265. }
  16266. if (node instanceof AST_Scope) {
  16267. node.init_scope_vars(scope);
  16268. var save_scope = scope;
  16269. var save_defun = defun;
  16270. var save_labels = labels;
  16271. defun = scope = node;
  16272. labels = new Map();
  16273. descend();
  16274. scope = save_scope;
  16275. defun = save_defun;
  16276. labels = save_labels;
  16277. return true; // don't descend again in TreeWalker
  16278. }
  16279. if (node instanceof AST_LabeledStatement) {
  16280. var l = node.label;
  16281. if (labels.has(l.name)) {
  16282. throw new Error(string_template("Label {name} defined twice", l));
  16283. }
  16284. labels.set(l.name, l);
  16285. descend();
  16286. labels.delete(l.name);
  16287. return true; // no descend again
  16288. }
  16289. if (node instanceof AST_With) {
  16290. for (var s = scope; s; s = s.parent_scope)
  16291. s.uses_with = true;
  16292. return;
  16293. }
  16294. if (node instanceof AST_Symbol) {
  16295. node.scope = scope;
  16296. }
  16297. if (node instanceof AST_Label) {
  16298. node.thedef = node;
  16299. node.references = [];
  16300. }
  16301. if (node instanceof AST_SymbolLambda) {
  16302. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  16303. } else if (node instanceof AST_SymbolDefun) {
  16304. // Careful here, the scope where this should be defined is
  16305. // the parent scope. The reason is that we enter a new
  16306. // scope when we encounter the AST_Defun node (which is
  16307. // instanceof AST_Scope) but we get to the symbol a bit
  16308. // later.
  16309. const closest_scope = defun.parent_scope;
  16310. // In strict mode, function definitions are block-scoped
  16311. node.scope = tw.directives["use strict"]
  16312. ? closest_scope
  16313. : closest_scope.get_defun_scope();
  16314. mark_export(node.scope.def_function(node, defun), 1);
  16315. } else if (node instanceof AST_SymbolClass) {
  16316. mark_export(defun.def_variable(node, defun), 1);
  16317. } else if (node instanceof AST_SymbolImport) {
  16318. scope.def_variable(node);
  16319. } else if (node instanceof AST_SymbolDefClass) {
  16320. // This deals with the name of the class being available
  16321. // inside the class.
  16322. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  16323. } else if (
  16324. node instanceof AST_SymbolVar
  16325. || node instanceof AST_SymbolLet
  16326. || node instanceof AST_SymbolConst
  16327. || node instanceof AST_SymbolCatch
  16328. ) {
  16329. var def;
  16330. if (node instanceof AST_SymbolBlockDeclaration) {
  16331. def = scope.def_variable(node, null);
  16332. } else {
  16333. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  16334. }
  16335. if (!def.orig.every((sym) => {
  16336. if (sym === node) return true;
  16337. if (node instanceof AST_SymbolBlockDeclaration) {
  16338. return sym instanceof AST_SymbolLambda;
  16339. }
  16340. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  16341. })) {
  16342. js_error(
  16343. `"${node.name}" is redeclared`,
  16344. node.start.file,
  16345. node.start.line,
  16346. node.start.col,
  16347. node.start.pos
  16348. );
  16349. }
  16350. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  16351. if (defun !== scope) {
  16352. node.mark_enclosed();
  16353. var def = scope.find_variable(node);
  16354. if (node.thedef !== def) {
  16355. node.thedef = def;
  16356. node.reference();
  16357. }
  16358. }
  16359. } else if (node instanceof AST_LabelRef) {
  16360. var sym = labels.get(node.name);
  16361. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  16362. name: node.name,
  16363. line: node.start.line,
  16364. col: node.start.col
  16365. }));
  16366. node.thedef = sym;
  16367. }
  16368. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  16369. js_error(
  16370. `"${node.TYPE}" statement may only appear at the top level`,
  16371. node.start.file,
  16372. node.start.line,
  16373. node.start.col,
  16374. node.start.pos
  16375. );
  16376. }
  16377. });
  16378. this.walk(tw);
  16379. function mark_export(def, level) {
  16380. if (in_destructuring) {
  16381. var i = 0;
  16382. do {
  16383. level++;
  16384. } while (tw.parent(i++) !== in_destructuring);
  16385. }
  16386. var node = tw.parent(level);
  16387. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  16388. var exported = node.exported_definition;
  16389. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  16390. def.export = MASK_EXPORT_WANT_MANGLE;
  16391. }
  16392. }
  16393. }
  16394. // pass 2: find back references and eval
  16395. const is_toplevel = this instanceof AST_Toplevel;
  16396. if (is_toplevel) {
  16397. this.globals = new Map();
  16398. }
  16399. var tw = new TreeWalker(node => {
  16400. if (node instanceof AST_LoopControl && node.label) {
  16401. node.label.thedef.references.push(node);
  16402. return true;
  16403. }
  16404. if (node instanceof AST_SymbolRef) {
  16405. var name = node.name;
  16406. if (name == "eval" && tw.parent() instanceof AST_Call) {
  16407. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  16408. s.uses_eval = true;
  16409. }
  16410. }
  16411. var sym;
  16412. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  16413. || !(sym = node.scope.find_variable(name))) {
  16414. sym = toplevel.def_global(node);
  16415. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  16416. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  16417. sym.scope.uses_arguments = true;
  16418. }
  16419. node.thedef = sym;
  16420. node.reference();
  16421. if (node.scope.is_block_scope()
  16422. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  16423. node.scope = node.scope.get_defun_scope();
  16424. }
  16425. return true;
  16426. }
  16427. // ensure mangling works if catch reuses a scope variable
  16428. var def;
  16429. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  16430. var s = node.scope;
  16431. while (s) {
  16432. push_uniq(s.enclosed, def);
  16433. if (s === def.scope) break;
  16434. s = s.parent_scope;
  16435. }
  16436. }
  16437. });
  16438. this.walk(tw);
  16439. // pass 3: work around IE8 and Safari catch scope bugs
  16440. if (options.ie8 || options.safari10) {
  16441. walk(this, node => {
  16442. if (node instanceof AST_SymbolCatch) {
  16443. var name = node.name;
  16444. var refs = node.thedef.references;
  16445. var scope = node.scope.get_defun_scope();
  16446. var def = scope.find_variable(name)
  16447. || toplevel.globals.get(name)
  16448. || scope.def_variable(node);
  16449. refs.forEach(function(ref) {
  16450. ref.thedef = def;
  16451. ref.reference();
  16452. });
  16453. node.thedef = def;
  16454. node.reference();
  16455. return true;
  16456. }
  16457. });
  16458. }
  16459. // pass 4: add symbol definitions to loop scopes
  16460. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  16461. // https://github.com/mishoo/UglifyJS2/issues/1753
  16462. // https://bugs.webkit.org/show_bug.cgi?id=171041
  16463. if (options.safari10) {
  16464. for (const scope of for_scopes) {
  16465. scope.parent_scope.variables.forEach(function(def) {
  16466. push_uniq(scope.enclosed, def);
  16467. });
  16468. }
  16469. }
  16470. });
  16471. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  16472. var globals = this.globals, name = node.name;
  16473. if (globals.has(name)) {
  16474. return globals.get(name);
  16475. } else {
  16476. var g = new SymbolDef(this, node);
  16477. g.undeclared = true;
  16478. g.global = true;
  16479. globals.set(name, g);
  16480. return g;
  16481. }
  16482. });
  16483. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  16484. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  16485. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  16486. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  16487. this.parent_scope = parent_scope; // the parent scope
  16488. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  16489. this.cname = -1; // the current index for mangling functions/variables
  16490. });
  16491. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  16492. return (
  16493. this.enclosed.find(def => def.name === name)
  16494. || this.variables.has(name)
  16495. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  16496. );
  16497. });
  16498. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  16499. return (
  16500. this.enclosed.find(def => def.name === name)
  16501. || this.variables.has(name)
  16502. );
  16503. });
  16504. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  16505. // `scope` is going to be moved into `this` right now.
  16506. // Update the required scopes' information
  16507. if (scope.parent_scope === this) return;
  16508. scope.parent_scope = this;
  16509. // TODO uses_with, uses_eval, etc
  16510. const scope_ancestry = (() => {
  16511. const ancestry = [];
  16512. let cur = this;
  16513. do {
  16514. ancestry.push(cur);
  16515. } while ((cur = cur.parent_scope));
  16516. ancestry.reverse();
  16517. return ancestry;
  16518. })();
  16519. const new_scope_enclosed_set = new Set(scope.enclosed);
  16520. const to_enclose = [];
  16521. for (const scope_topdown of scope_ancestry) {
  16522. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  16523. for (const def of scope_topdown.variables.values()) {
  16524. if (new_scope_enclosed_set.has(def)) {
  16525. push_uniq(to_enclose, def);
  16526. push_uniq(scope_topdown.enclosed, def);
  16527. }
  16528. }
  16529. }
  16530. });
  16531. function find_scopes_visible_from(scopes) {
  16532. const found_scopes = new Set();
  16533. for (const scope of new Set(scopes)) {
  16534. (function bubble_up(scope) {
  16535. if (scope == null || found_scopes.has(scope)) return;
  16536. found_scopes.add(scope);
  16537. bubble_up(scope.parent_scope);
  16538. })(scope);
  16539. }
  16540. return [...found_scopes];
  16541. }
  16542. // Creates a symbol during compression
  16543. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  16544. source,
  16545. tentative_name,
  16546. scope,
  16547. conflict_scopes = [scope],
  16548. init = null
  16549. } = {}) {
  16550. let symbol_name;
  16551. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  16552. if (tentative_name) {
  16553. // Implement hygiene (no new names are conflicting with existing names)
  16554. tentative_name =
  16555. symbol_name =
  16556. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  16557. let i = 0;
  16558. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  16559. symbol_name = tentative_name + "$" + i++;
  16560. }
  16561. }
  16562. if (!symbol_name) {
  16563. throw new Error("No symbol name could be generated in create_symbol()");
  16564. }
  16565. const symbol = make_node(SymClass, source, {
  16566. name: symbol_name,
  16567. scope
  16568. });
  16569. this.def_variable(symbol, init || null);
  16570. symbol.mark_enclosed();
  16571. return symbol;
  16572. });
  16573. AST_Node.DEFMETHOD("is_block_scope", return_false);
  16574. AST_Class.DEFMETHOD("is_block_scope", return_false);
  16575. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  16576. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  16577. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  16578. AST_Block.DEFMETHOD("is_block_scope", return_true);
  16579. AST_Scope.DEFMETHOD("is_block_scope", function () {
  16580. return this._block_scope || false;
  16581. });
  16582. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  16583. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  16584. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  16585. this.uses_arguments = false;
  16586. this.def_variable(new AST_SymbolFunarg({
  16587. name: "arguments",
  16588. start: this.start,
  16589. end: this.end
  16590. }));
  16591. });
  16592. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  16593. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  16594. this.uses_arguments = false;
  16595. });
  16596. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  16597. var def = this.definition();
  16598. var s = this.scope;
  16599. while (s) {
  16600. push_uniq(s.enclosed, def);
  16601. if (s === def.scope) break;
  16602. s = s.parent_scope;
  16603. }
  16604. });
  16605. AST_Symbol.DEFMETHOD("reference", function() {
  16606. this.definition().references.push(this);
  16607. this.mark_enclosed();
  16608. });
  16609. AST_Scope.DEFMETHOD("find_variable", function(name) {
  16610. if (name instanceof AST_Symbol) name = name.name;
  16611. return this.variables.get(name)
  16612. || (this.parent_scope && this.parent_scope.find_variable(name));
  16613. });
  16614. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  16615. var def = this.def_variable(symbol, init);
  16616. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  16617. return def;
  16618. });
  16619. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  16620. var def = this.variables.get(symbol.name);
  16621. if (def) {
  16622. def.orig.push(symbol);
  16623. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  16624. def.init = init;
  16625. }
  16626. } else {
  16627. def = new SymbolDef(this, symbol, init);
  16628. this.variables.set(symbol.name, def);
  16629. def.global = !this.parent_scope;
  16630. }
  16631. return symbol.thedef = def;
  16632. });
  16633. function next_mangled(scope, options) {
  16634. var ext = scope.enclosed;
  16635. out: while (true) {
  16636. var m = base54(++scope.cname);
  16637. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  16638. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  16639. // shadow a name reserved from mangling.
  16640. if (options.reserved.has(m)) continue;
  16641. // Functions with short names might collide with base54 output
  16642. // and therefore cause collisions when keep_fnames is true.
  16643. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  16644. // we must ensure that the mangled name does not shadow a name
  16645. // from some parent scope that is referenced in this or in
  16646. // inner scopes.
  16647. for (let i = ext.length; --i >= 0;) {
  16648. const def = ext[i];
  16649. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  16650. if (m == name) continue out;
  16651. }
  16652. return m;
  16653. }
  16654. }
  16655. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  16656. return next_mangled(this, options);
  16657. });
  16658. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  16659. let name;
  16660. const mangled_names = this.mangled_names;
  16661. do {
  16662. name = next_mangled(this, options);
  16663. } while (mangled_names.has(name));
  16664. return name;
  16665. });
  16666. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  16667. // #179, #326
  16668. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  16669. // a function expression's argument cannot shadow the function expression's name
  16670. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  16671. // the function's mangled_name is null when keep_fnames is true
  16672. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  16673. while (true) {
  16674. var name = next_mangled(this, options);
  16675. if (!tricky_name || tricky_name != name)
  16676. return name;
  16677. }
  16678. });
  16679. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  16680. var def = this.definition();
  16681. return !def || def.unmangleable(options);
  16682. });
  16683. // labels are always mangleable
  16684. AST_Label.DEFMETHOD("unmangleable", return_false);
  16685. AST_Symbol.DEFMETHOD("unreferenced", function() {
  16686. return !this.definition().references.length && !this.scope.pinned();
  16687. });
  16688. AST_Symbol.DEFMETHOD("definition", function() {
  16689. return this.thedef;
  16690. });
  16691. AST_Symbol.DEFMETHOD("global", function() {
  16692. return this.thedef.global;
  16693. });
  16694. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  16695. options = defaults(options, {
  16696. eval : false,
  16697. ie8 : false,
  16698. keep_classnames: false,
  16699. keep_fnames : false,
  16700. module : false,
  16701. reserved : [],
  16702. toplevel : false,
  16703. });
  16704. if (options.module) options.toplevel = true;
  16705. if (!Array.isArray(options.reserved)
  16706. && !(options.reserved instanceof Set)
  16707. ) {
  16708. options.reserved = [];
  16709. }
  16710. options.reserved = new Set(options.reserved);
  16711. // Never mangle arguments
  16712. options.reserved.add("arguments");
  16713. return options;
  16714. });
  16715. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  16716. options = this._default_mangler_options(options);
  16717. // We only need to mangle declaration nodes. Special logic wired
  16718. // into the code generator will display the mangled name if it's
  16719. // present (and for AST_SymbolRef-s it'll use the mangled name of
  16720. // the AST_SymbolDeclaration that it points to).
  16721. var lname = -1;
  16722. var to_mangle = [];
  16723. if (options.keep_fnames) {
  16724. function_defs = new Set();
  16725. }
  16726. const mangled_names = this.mangled_names = new Set();
  16727. if (options.cache) {
  16728. this.globals.forEach(collect);
  16729. if (options.cache.props) {
  16730. options.cache.props.forEach(function(mangled_name) {
  16731. mangled_names.add(mangled_name);
  16732. });
  16733. }
  16734. }
  16735. var tw = new TreeWalker(function(node, descend) {
  16736. if (node instanceof AST_LabeledStatement) {
  16737. // lname is incremented when we get to the AST_Label
  16738. var save_nesting = lname;
  16739. descend();
  16740. lname = save_nesting;
  16741. return true; // don't descend again in TreeWalker
  16742. }
  16743. if (node instanceof AST_Scope) {
  16744. node.variables.forEach(collect);
  16745. return;
  16746. }
  16747. if (node.is_block_scope()) {
  16748. node.block_scope.variables.forEach(collect);
  16749. return;
  16750. }
  16751. if (
  16752. function_defs
  16753. && node instanceof AST_VarDef
  16754. && node.value instanceof AST_Lambda
  16755. && !node.value.name
  16756. && keep_name(options.keep_fnames, node.name.name)
  16757. ) {
  16758. function_defs.add(node.name.definition().id);
  16759. return;
  16760. }
  16761. if (node instanceof AST_Label) {
  16762. let name;
  16763. do {
  16764. name = base54(++lname);
  16765. } while (ALL_RESERVED_WORDS.has(name));
  16766. node.mangled_name = name;
  16767. return true;
  16768. }
  16769. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  16770. to_mangle.push(node.definition());
  16771. return;
  16772. }
  16773. });
  16774. this.walk(tw);
  16775. if (options.keep_fnames || options.keep_classnames) {
  16776. unmangleable_names = new Set();
  16777. // Collect a set of short names which are unmangleable,
  16778. // for use in avoiding collisions in next_mangled.
  16779. to_mangle.forEach(def => {
  16780. if (def.name.length < 6 && def.unmangleable(options)) {
  16781. unmangleable_names.add(def.name);
  16782. }
  16783. });
  16784. }
  16785. to_mangle.forEach(def => { def.mangle(options); });
  16786. function_defs = null;
  16787. unmangleable_names = null;
  16788. function collect(symbol) {
  16789. const should_mangle = !options.reserved.has(symbol.name)
  16790. && !(symbol.export & MASK_EXPORT_DONT_MANGLE);
  16791. if (should_mangle) {
  16792. to_mangle.push(symbol);
  16793. }
  16794. }
  16795. });
  16796. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  16797. const cache = options.cache && options.cache.props;
  16798. const avoid = new Set();
  16799. options.reserved.forEach(to_avoid);
  16800. this.globals.forEach(add_def);
  16801. this.walk(new TreeWalker(function(node) {
  16802. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  16803. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  16804. }));
  16805. return avoid;
  16806. function to_avoid(name) {
  16807. avoid.add(name);
  16808. }
  16809. function add_def(def) {
  16810. var name = def.name;
  16811. if (def.global && cache && cache.has(name)) name = cache.get(name);
  16812. else if (!def.unmangleable(options)) return;
  16813. to_avoid(name);
  16814. }
  16815. });
  16816. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  16817. base54.reset();
  16818. base54.sort();
  16819. options = this._default_mangler_options(options);
  16820. var avoid = this.find_colliding_names(options);
  16821. var cname = 0;
  16822. this.globals.forEach(rename);
  16823. this.walk(new TreeWalker(function(node) {
  16824. if (node instanceof AST_Scope) node.variables.forEach(rename);
  16825. if (node instanceof AST_SymbolCatch) rename(node.definition());
  16826. }));
  16827. function next_name() {
  16828. var name;
  16829. do {
  16830. name = base54(cname++);
  16831. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  16832. return name;
  16833. }
  16834. function rename(def) {
  16835. if (def.global && options.cache) return;
  16836. if (def.unmangleable(options)) return;
  16837. if (options.reserved.has(def.name)) return;
  16838. const redefinition = redefined_catch_def(def);
  16839. const name = def.name = redefinition ? redefinition.name : next_name();
  16840. def.orig.forEach(function(sym) {
  16841. sym.name = name;
  16842. });
  16843. def.references.forEach(function(sym) {
  16844. sym.name = name;
  16845. });
  16846. }
  16847. });
  16848. AST_Node.DEFMETHOD("tail_node", return_this);
  16849. AST_Sequence.DEFMETHOD("tail_node", function() {
  16850. return this.expressions[this.expressions.length - 1];
  16851. });
  16852. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  16853. options = this._default_mangler_options(options);
  16854. try {
  16855. AST_Node.prototype.print = function(stream, force_parens) {
  16856. this._print(stream, force_parens);
  16857. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  16858. base54.consider(this.name, -1);
  16859. } else if (options.properties) {
  16860. if (this instanceof AST_DotHash) {
  16861. base54.consider("#" + this.property, -1);
  16862. } else if (this instanceof AST_Dot) {
  16863. base54.consider(this.property, -1);
  16864. } else if (this instanceof AST_Sub) {
  16865. skip_string(this.property);
  16866. }
  16867. }
  16868. };
  16869. base54.consider(this.print_to_string(), 1);
  16870. } finally {
  16871. AST_Node.prototype.print = AST_Node.prototype._print;
  16872. }
  16873. base54.sort();
  16874. function skip_string(node) {
  16875. if (node instanceof AST_String) {
  16876. base54.consider(node.value, -1);
  16877. } else if (node instanceof AST_Conditional) {
  16878. skip_string(node.consequent);
  16879. skip_string(node.alternative);
  16880. } else if (node instanceof AST_Sequence) {
  16881. skip_string(node.tail_node());
  16882. }
  16883. }
  16884. });
  16885. const base54 = (() => {
  16886. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  16887. const digits = "0123456789".split("");
  16888. let chars;
  16889. let frequency;
  16890. function reset() {
  16891. frequency = new Map();
  16892. leading.forEach(function(ch) {
  16893. frequency.set(ch, 0);
  16894. });
  16895. digits.forEach(function(ch) {
  16896. frequency.set(ch, 0);
  16897. });
  16898. }
  16899. base54.consider = function(str, delta) {
  16900. for (var i = str.length; --i >= 0;) {
  16901. frequency.set(str[i], frequency.get(str[i]) + delta);
  16902. }
  16903. };
  16904. function compare(a, b) {
  16905. return frequency.get(b) - frequency.get(a);
  16906. }
  16907. base54.sort = function() {
  16908. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  16909. };
  16910. base54.reset = reset;
  16911. reset();
  16912. function base54(num) {
  16913. var ret = "", base = 54;
  16914. num++;
  16915. do {
  16916. num--;
  16917. ret += chars[num % base];
  16918. num = Math.floor(num / base);
  16919. base = 64;
  16920. } while (num > 0);
  16921. return ret;
  16922. }
  16923. return base54;
  16924. })();
  16925. let mangle_options = undefined;
  16926. AST_Node.prototype.size = function (compressor, stack) {
  16927. mangle_options = compressor && compressor.mangle_options;
  16928. let size = 0;
  16929. walk_parent(this, (node, info) => {
  16930. size += node._size(info);
  16931. // Braceless arrow functions have fake "return" statements
  16932. if (node instanceof AST_Arrow && node.is_braceless()) {
  16933. size += node.body[0].value._size(info);
  16934. return true;
  16935. }
  16936. }, stack || (compressor && compressor.stack));
  16937. // just to save a bit of memory
  16938. mangle_options = undefined;
  16939. return size;
  16940. };
  16941. AST_Node.prototype._size = () => 0;
  16942. AST_Debugger.prototype._size = () => 8;
  16943. AST_Directive.prototype._size = function () {
  16944. // TODO string encoding stuff
  16945. return 2 + this.value.length;
  16946. };
  16947. const list_overhead = (array) => array.length && array.length - 1;
  16948. AST_Block.prototype._size = function () {
  16949. return 2 + list_overhead(this.body);
  16950. };
  16951. AST_Toplevel.prototype._size = function() {
  16952. return list_overhead(this.body);
  16953. };
  16954. AST_EmptyStatement.prototype._size = () => 1;
  16955. AST_LabeledStatement.prototype._size = () => 2; // x:
  16956. AST_Do.prototype._size = () => 9;
  16957. AST_While.prototype._size = () => 7;
  16958. AST_For.prototype._size = () => 8;
  16959. AST_ForIn.prototype._size = () => 8;
  16960. // AST_ForOf inherits ^
  16961. AST_With.prototype._size = () => 6;
  16962. AST_Expansion.prototype._size = () => 3;
  16963. const lambda_modifiers = func =>
  16964. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  16965. AST_Accessor.prototype._size = function () {
  16966. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  16967. };
  16968. AST_Function.prototype._size = function (info) {
  16969. const first = !!first_in_statement(info);
  16970. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  16971. };
  16972. AST_Defun.prototype._size = function () {
  16973. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  16974. };
  16975. AST_Arrow.prototype._size = function () {
  16976. let args_and_arrow = 2 + list_overhead(this.argnames);
  16977. if (
  16978. !(
  16979. this.argnames.length === 1
  16980. && this.argnames[0] instanceof AST_Symbol
  16981. )
  16982. ) {
  16983. args_and_arrow += 2;
  16984. }
  16985. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  16986. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  16987. };
  16988. AST_Destructuring.prototype._size = () => 2;
  16989. AST_TemplateString.prototype._size = function () {
  16990. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  16991. };
  16992. AST_TemplateSegment.prototype._size = function () {
  16993. return this.value.length;
  16994. };
  16995. AST_Return.prototype._size = function () {
  16996. return this.value ? 7 : 6;
  16997. };
  16998. AST_Throw.prototype._size = () => 6;
  16999. AST_Break.prototype._size = function () {
  17000. return this.label ? 6 : 5;
  17001. };
  17002. AST_Continue.prototype._size = function () {
  17003. return this.label ? 9 : 8;
  17004. };
  17005. AST_If.prototype._size = () => 4;
  17006. AST_Switch.prototype._size = function () {
  17007. return 8 + list_overhead(this.body);
  17008. };
  17009. AST_Case.prototype._size = function () {
  17010. return 5 + list_overhead(this.body);
  17011. };
  17012. AST_Default.prototype._size = function () {
  17013. return 8 + list_overhead(this.body);
  17014. };
  17015. AST_Try.prototype._size = function () {
  17016. return 3 + list_overhead(this.body);
  17017. };
  17018. AST_Catch.prototype._size = function () {
  17019. let size = 7 + list_overhead(this.body);
  17020. if (this.argname) {
  17021. size += 2;
  17022. }
  17023. return size;
  17024. };
  17025. AST_Finally.prototype._size = function () {
  17026. return 7 + list_overhead(this.body);
  17027. };
  17028. /*#__INLINE__*/
  17029. const def_size = (size, def) => size + list_overhead(def.definitions);
  17030. AST_Var.prototype._size = function () {
  17031. return def_size(4, this);
  17032. };
  17033. AST_Let.prototype._size = function () {
  17034. return def_size(4, this);
  17035. };
  17036. AST_Const.prototype._size = function () {
  17037. return def_size(6, this);
  17038. };
  17039. AST_VarDef.prototype._size = function () {
  17040. return this.value ? 1 : 0;
  17041. };
  17042. AST_NameMapping.prototype._size = function () {
  17043. // foreign name isn't mangled
  17044. return this.name ? 4 : 0;
  17045. };
  17046. AST_Import.prototype._size = function () {
  17047. // import
  17048. let size = 6;
  17049. if (this.imported_name) size += 1;
  17050. // from
  17051. if (this.imported_name || this.imported_names) size += 5;
  17052. // braces, and the commas
  17053. if (this.imported_names) {
  17054. size += 2 + list_overhead(this.imported_names);
  17055. }
  17056. return size;
  17057. };
  17058. AST_ImportMeta.prototype._size = () => 11;
  17059. AST_Export.prototype._size = function () {
  17060. let size = 7 + (this.is_default ? 8 : 0);
  17061. if (this.exported_value) {
  17062. size += this.exported_value._size();
  17063. }
  17064. if (this.exported_names) {
  17065. // Braces and commas
  17066. size += 2 + list_overhead(this.exported_names);
  17067. }
  17068. if (this.module_name) {
  17069. // "from "
  17070. size += 5;
  17071. }
  17072. return size;
  17073. };
  17074. AST_Call.prototype._size = function () {
  17075. if (this.optional) {
  17076. return 4 + list_overhead(this.args);
  17077. }
  17078. return 2 + list_overhead(this.args);
  17079. };
  17080. AST_New.prototype._size = function () {
  17081. return 6 + list_overhead(this.args);
  17082. };
  17083. AST_Sequence.prototype._size = function () {
  17084. return list_overhead(this.expressions);
  17085. };
  17086. AST_Dot.prototype._size = function () {
  17087. if (this.optional) {
  17088. return this.property.length + 2;
  17089. }
  17090. return this.property.length + 1;
  17091. };
  17092. AST_DotHash.prototype._size = function () {
  17093. if (this.optional) {
  17094. return this.property.length + 3;
  17095. }
  17096. return this.property.length + 2;
  17097. };
  17098. AST_Sub.prototype._size = function () {
  17099. return this.optional ? 4 : 2;
  17100. };
  17101. AST_Unary.prototype._size = function () {
  17102. if (this.operator === "typeof") return 7;
  17103. if (this.operator === "void") return 5;
  17104. return this.operator.length;
  17105. };
  17106. AST_Binary.prototype._size = function (info) {
  17107. if (this.operator === "in") return 4;
  17108. let size = this.operator.length;
  17109. if (
  17110. (this.operator === "+" || this.operator === "-")
  17111. && this.right instanceof AST_Unary && this.right.operator === this.operator
  17112. ) {
  17113. // 1+ +a > needs space between the +
  17114. size += 1;
  17115. }
  17116. if (this.needs_parens(info)) {
  17117. size += 2;
  17118. }
  17119. return size;
  17120. };
  17121. AST_Conditional.prototype._size = () => 3;
  17122. AST_Array.prototype._size = function () {
  17123. return 2 + list_overhead(this.elements);
  17124. };
  17125. AST_Object.prototype._size = function (info) {
  17126. let base = 2;
  17127. if (first_in_statement(info)) {
  17128. base += 2; // parens
  17129. }
  17130. return base + list_overhead(this.properties);
  17131. };
  17132. /*#__INLINE__*/
  17133. const key_size = key =>
  17134. typeof key === "string" ? key.length : 0;
  17135. AST_ObjectKeyVal.prototype._size = function () {
  17136. return key_size(this.key) + 1;
  17137. };
  17138. /*#__INLINE__*/
  17139. const static_size = is_static => is_static ? 7 : 0;
  17140. AST_ObjectGetter.prototype._size = function () {
  17141. return 5 + static_size(this.static) + key_size(this.key);
  17142. };
  17143. AST_ObjectSetter.prototype._size = function () {
  17144. return 5 + static_size(this.static) + key_size(this.key);
  17145. };
  17146. AST_ConciseMethod.prototype._size = function () {
  17147. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  17148. };
  17149. AST_PrivateMethod.prototype._size = function () {
  17150. return AST_ConciseMethod.prototype._size.call(this) + 1;
  17151. };
  17152. AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
  17153. return AST_ConciseMethod.prototype._size.call(this) + 4;
  17154. };
  17155. AST_Class.prototype._size = function () {
  17156. return (
  17157. (this.name ? 8 : 7)
  17158. + (this.extends ? 8 : 0)
  17159. );
  17160. };
  17161. AST_ClassProperty.prototype._size = function () {
  17162. return (
  17163. static_size(this.static)
  17164. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  17165. + (this.value ? 1 : 0)
  17166. );
  17167. };
  17168. AST_ClassPrivateProperty.prototype._size = function () {
  17169. return AST_ClassProperty.prototype._size.call(this) + 1;
  17170. };
  17171. AST_Symbol.prototype._size = function () {
  17172. return !mangle_options || this.definition().unmangleable(mangle_options)
  17173. ? this.name.length
  17174. : 1;
  17175. };
  17176. // TODO take propmangle into account
  17177. AST_SymbolClassProperty.prototype._size = function () {
  17178. return this.name.length;
  17179. };
  17180. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  17181. const { name, thedef } = this;
  17182. if (thedef && thedef.global) return name.length;
  17183. if (name === "arguments") return 9;
  17184. return AST_Symbol.prototype._size.call(this);
  17185. };
  17186. AST_NewTarget.prototype._size = () => 10;
  17187. AST_SymbolImportForeign.prototype._size = function () {
  17188. return this.name.length;
  17189. };
  17190. AST_SymbolExportForeign.prototype._size = function () {
  17191. return this.name.length;
  17192. };
  17193. AST_This.prototype._size = () => 4;
  17194. AST_Super.prototype._size = () => 5;
  17195. AST_String.prototype._size = function () {
  17196. return this.value.length + 2;
  17197. };
  17198. AST_Number.prototype._size = function () {
  17199. const { value } = this;
  17200. if (value === 0) return 1;
  17201. if (value > 0 && Math.floor(value) === value) {
  17202. return Math.floor(Math.log10(value) + 1);
  17203. }
  17204. return value.toString().length;
  17205. };
  17206. AST_BigInt.prototype._size = function () {
  17207. return this.value.length;
  17208. };
  17209. AST_RegExp.prototype._size = function () {
  17210. return this.value.toString().length;
  17211. };
  17212. AST_Null.prototype._size = () => 4;
  17213. AST_NaN.prototype._size = () => 3;
  17214. AST_Undefined.prototype._size = () => 6; // "void 0"
  17215. AST_Hole.prototype._size = () => 0; // comma is taken into account
  17216. AST_Infinity.prototype._size = () => 8;
  17217. AST_True.prototype._size = () => 4;
  17218. AST_False.prototype._size = () => 5;
  17219. AST_Await.prototype._size = () => 6;
  17220. AST_Yield.prototype._size = () => 6;
  17221. /***********************************************************************
  17222. A JavaScript tokenizer / parser / beautifier / compressor.
  17223. https://github.com/mishoo/UglifyJS2
  17224. -------------------------------- (C) ---------------------------------
  17225. Author: Mihai Bazon
  17226. <mihai.bazon@gmail.com>
  17227. http://mihai.bazon.net/blog
  17228. Distributed under the BSD license:
  17229. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17230. Redistribution and use in source and binary forms, with or without
  17231. modification, are permitted provided that the following conditions
  17232. are met:
  17233. * Redistributions of source code must retain the above
  17234. copyright notice, this list of conditions and the following
  17235. disclaimer.
  17236. * Redistributions in binary form must reproduce the above
  17237. copyright notice, this list of conditions and the following
  17238. disclaimer in the documentation and/or other materials
  17239. provided with the distribution.
  17240. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17241. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17242. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17243. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17244. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17245. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17246. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17247. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17248. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17249. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17250. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17251. SUCH DAMAGE.
  17252. ***********************************************************************/
  17253. function merge_sequence(array, node) {
  17254. if (node instanceof AST_Sequence) {
  17255. array.push(...node.expressions);
  17256. } else {
  17257. array.push(node);
  17258. }
  17259. return array;
  17260. }
  17261. function make_sequence(orig, expressions) {
  17262. if (expressions.length == 1) return expressions[0];
  17263. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  17264. return make_node(AST_Sequence, orig, {
  17265. expressions: expressions.reduce(merge_sequence, [])
  17266. });
  17267. }
  17268. function make_node_from_constant(val, orig) {
  17269. switch (typeof val) {
  17270. case "string":
  17271. return make_node(AST_String, orig, {
  17272. value: val
  17273. });
  17274. case "number":
  17275. if (isNaN(val)) return make_node(AST_NaN, orig);
  17276. if (isFinite(val)) {
  17277. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  17278. operator: "-",
  17279. expression: make_node(AST_Number, orig, { value: -val })
  17280. }) : make_node(AST_Number, orig, { value: val });
  17281. }
  17282. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  17283. operator: "-",
  17284. expression: make_node(AST_Infinity, orig)
  17285. }) : make_node(AST_Infinity, orig);
  17286. case "boolean":
  17287. return make_node(val ? AST_True : AST_False, orig);
  17288. case "undefined":
  17289. return make_node(AST_Undefined, orig);
  17290. default:
  17291. if (val === null) {
  17292. return make_node(AST_Null, orig, { value: null });
  17293. }
  17294. if (val instanceof RegExp) {
  17295. return make_node(AST_RegExp, orig, {
  17296. value: {
  17297. source: regexp_source_fix(val.source),
  17298. flags: val.flags
  17299. }
  17300. });
  17301. }
  17302. throw new Error(string_template("Can't handle constant of type: {type}", {
  17303. type: typeof val
  17304. }));
  17305. }
  17306. }
  17307. function best_of_expression(ast1, ast2) {
  17308. return ast1.size() > ast2.size() ? ast2 : ast1;
  17309. }
  17310. function best_of_statement(ast1, ast2) {
  17311. return best_of_expression(
  17312. make_node(AST_SimpleStatement, ast1, {
  17313. body: ast1
  17314. }),
  17315. make_node(AST_SimpleStatement, ast2, {
  17316. body: ast2
  17317. })
  17318. ).body;
  17319. }
  17320. /** Find which node is smaller, and return that */
  17321. function best_of(compressor, ast1, ast2) {
  17322. if (first_in_statement(compressor)) {
  17323. return best_of_statement(ast1, ast2);
  17324. } else {
  17325. return best_of_expression(ast1, ast2);
  17326. }
  17327. }
  17328. /** Simplify an object property's key, if possible */
  17329. function get_simple_key(key) {
  17330. if (key instanceof AST_Constant) {
  17331. return key.getValue();
  17332. }
  17333. if (key instanceof AST_UnaryPrefix
  17334. && key.operator == "void"
  17335. && key.expression instanceof AST_Constant) {
  17336. return;
  17337. }
  17338. return key;
  17339. }
  17340. function read_property(obj, key) {
  17341. key = get_simple_key(key);
  17342. if (key instanceof AST_Node) return;
  17343. var value;
  17344. if (obj instanceof AST_Array) {
  17345. var elements = obj.elements;
  17346. if (key == "length") return make_node_from_constant(elements.length, obj);
  17347. if (typeof key == "number" && key in elements) value = elements[key];
  17348. } else if (obj instanceof AST_Object) {
  17349. key = "" + key;
  17350. var props = obj.properties;
  17351. for (var i = props.length; --i >= 0;) {
  17352. var prop = props[i];
  17353. if (!(prop instanceof AST_ObjectKeyVal)) return;
  17354. if (!value && props[i].key === key) value = props[i].value;
  17355. }
  17356. }
  17357. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  17358. }
  17359. function has_break_or_continue(loop, parent) {
  17360. var found = false;
  17361. var tw = new TreeWalker(function(node) {
  17362. if (found || node instanceof AST_Scope) return true;
  17363. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  17364. return found = true;
  17365. }
  17366. });
  17367. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  17368. tw.push(loop);
  17369. loop.body.walk(tw);
  17370. return found;
  17371. }
  17372. // we shouldn't compress (1,func)(something) to
  17373. // func(something) because that changes the meaning of
  17374. // the func (becomes lexical instead of global).
  17375. function maintain_this_binding(parent, orig, val) {
  17376. if (
  17377. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  17378. || parent instanceof AST_Call && parent.expression === orig
  17379. && (
  17380. val instanceof AST_PropAccess
  17381. || val instanceof AST_SymbolRef && val.name == "eval"
  17382. )
  17383. ) {
  17384. const zero = make_node(AST_Number, orig, { value: 0 });
  17385. return make_sequence(orig, [ zero, val ]);
  17386. } else {
  17387. return val;
  17388. }
  17389. }
  17390. function is_func_expr(node) {
  17391. return node instanceof AST_Arrow || node instanceof AST_Function;
  17392. }
  17393. function is_iife_call(node) {
  17394. // Used to determine whether the node can benefit from negation.
  17395. // Not the case with arrow functions (you need an extra set of parens).
  17396. if (node.TYPE != "Call") return false;
  17397. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  17398. }
  17399. const identifier_atom = makePredicate("Infinity NaN undefined");
  17400. function is_identifier_atom(node) {
  17401. return node instanceof AST_Infinity
  17402. || node instanceof AST_NaN
  17403. || node instanceof AST_Undefined;
  17404. }
  17405. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  17406. function is_ref_of(ref, type) {
  17407. if (!(ref instanceof AST_SymbolRef)) return false;
  17408. var orig = ref.definition().orig;
  17409. for (var i = orig.length; --i >= 0;) {
  17410. if (orig[i] instanceof type) return true;
  17411. }
  17412. }
  17413. // Can we turn { block contents... } into just the block contents ?
  17414. // Not if one of these is inside.
  17415. function can_be_evicted_from_block(node) {
  17416. return !(
  17417. node instanceof AST_DefClass ||
  17418. node instanceof AST_Defun ||
  17419. node instanceof AST_Let ||
  17420. node instanceof AST_Const ||
  17421. node instanceof AST_Export ||
  17422. node instanceof AST_Import
  17423. );
  17424. }
  17425. function as_statement_array(thing) {
  17426. if (thing === null) return [];
  17427. if (thing instanceof AST_BlockStatement) return thing.body;
  17428. if (thing instanceof AST_EmptyStatement) return [];
  17429. if (thing instanceof AST_Statement) return [ thing ];
  17430. throw new Error("Can't convert thing to statement array");
  17431. }
  17432. /** Check if a ref refers to the name of a function/class it's defined within */
  17433. function is_recursive_ref(compressor, def) {
  17434. var node;
  17435. for (var i = 0; node = compressor.parent(i); i++) {
  17436. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  17437. var name = node.name;
  17438. if (name && name.definition() === def) {
  17439. return true;
  17440. }
  17441. }
  17442. }
  17443. return false;
  17444. }
  17445. /***********************************************************************
  17446. A JavaScript tokenizer / parser / beautifier / compressor.
  17447. https://github.com/mishoo/UglifyJS2
  17448. -------------------------------- (C) ---------------------------------
  17449. Author: Mihai Bazon
  17450. <mihai.bazon@gmail.com>
  17451. http://mihai.bazon.net/blog
  17452. Distributed under the BSD license:
  17453. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17454. Redistribution and use in source and binary forms, with or without
  17455. modification, are permitted provided that the following conditions
  17456. are met:
  17457. * Redistributions of source code must retain the above
  17458. copyright notice, this list of conditions and the following
  17459. disclaimer.
  17460. * Redistributions in binary form must reproduce the above
  17461. copyright notice, this list of conditions and the following
  17462. disclaimer in the documentation and/or other materials
  17463. provided with the distribution.
  17464. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17465. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17466. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17467. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17468. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17469. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17470. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17471. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17472. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17473. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17474. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17475. SUCH DAMAGE.
  17476. ***********************************************************************/
  17477. // bitfield flags to be stored in node.flags.
  17478. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  17479. const UNUSED = 0b00000001;
  17480. const TRUTHY = 0b00000010;
  17481. const FALSY = 0b00000100;
  17482. const UNDEFINED = 0b00001000;
  17483. const INLINED = 0b00010000;
  17484. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  17485. const WRITE_ONLY = 0b00100000;
  17486. // information specific to a single compression pass
  17487. const SQUEEZED = 0b0000000100000000;
  17488. const OPTIMIZED = 0b0000001000000000;
  17489. const TOP = 0b0000010000000000;
  17490. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  17491. const has_flag = (node, flag) => node.flags & flag;
  17492. const set_flag = (node, flag) => { node.flags |= flag; };
  17493. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  17494. /***********************************************************************
  17495. A JavaScript tokenizer / parser / beautifier / compressor.
  17496. https://github.com/mishoo/UglifyJS2
  17497. -------------------------------- (C) ---------------------------------
  17498. Author: Mihai Bazon
  17499. <mihai.bazon@gmail.com>
  17500. http://mihai.bazon.net/blog
  17501. Distributed under the BSD license:
  17502. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17503. Redistribution and use in source and binary forms, with or without
  17504. modification, are permitted provided that the following conditions
  17505. are met:
  17506. * Redistributions of source code must retain the above
  17507. copyright notice, this list of conditions and the following
  17508. disclaimer.
  17509. * Redistributions in binary form must reproduce the above
  17510. copyright notice, this list of conditions and the following
  17511. disclaimer in the documentation and/or other materials
  17512. provided with the distribution.
  17513. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17514. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17515. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17516. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17517. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17518. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17519. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17520. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17521. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17522. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17523. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17524. SUCH DAMAGE.
  17525. ***********************************************************************/
  17526. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  17527. // Note: Lots of methods and functions are missing here, in case they aren't pure
  17528. // or not available in all JS environments.
  17529. function make_nested_lookup(obj) {
  17530. const out = new Map();
  17531. for (var key of Object.keys(obj)) {
  17532. out.set(key, makePredicate(obj[key]));
  17533. }
  17534. const does_have = (global_name, fname) => {
  17535. const inner_map = out.get(global_name);
  17536. return inner_map != null && inner_map.has(fname);
  17537. };
  17538. return does_have;
  17539. }
  17540. // Objects which are safe to access without throwing or causing a side effect.
  17541. // Usually we'd check the `unsafe` option first but these are way too common for that
  17542. const pure_prop_access_globals = new Set([
  17543. "Number",
  17544. "String",
  17545. "Array",
  17546. "Object",
  17547. "Function",
  17548. "Promise",
  17549. ]);
  17550. const object_methods = [
  17551. "constructor",
  17552. "toString",
  17553. "valueOf",
  17554. ];
  17555. const is_pure_native_method = make_nested_lookup({
  17556. Array: [
  17557. "indexOf",
  17558. "join",
  17559. "lastIndexOf",
  17560. "slice",
  17561. ...object_methods,
  17562. ],
  17563. Boolean: object_methods,
  17564. Function: object_methods,
  17565. Number: [
  17566. "toExponential",
  17567. "toFixed",
  17568. "toPrecision",
  17569. ...object_methods,
  17570. ],
  17571. Object: object_methods,
  17572. RegExp: [
  17573. "test",
  17574. ...object_methods,
  17575. ],
  17576. String: [
  17577. "charAt",
  17578. "charCodeAt",
  17579. "concat",
  17580. "indexOf",
  17581. "italics",
  17582. "lastIndexOf",
  17583. "match",
  17584. "replace",
  17585. "search",
  17586. "slice",
  17587. "split",
  17588. "substr",
  17589. "substring",
  17590. "toLowerCase",
  17591. "toUpperCase",
  17592. "trim",
  17593. ...object_methods,
  17594. ],
  17595. });
  17596. const is_pure_native_fn = make_nested_lookup({
  17597. Array: [
  17598. "isArray",
  17599. ],
  17600. Math: [
  17601. "abs",
  17602. "acos",
  17603. "asin",
  17604. "atan",
  17605. "ceil",
  17606. "cos",
  17607. "exp",
  17608. "floor",
  17609. "log",
  17610. "round",
  17611. "sin",
  17612. "sqrt",
  17613. "tan",
  17614. "atan2",
  17615. "pow",
  17616. "max",
  17617. "min",
  17618. ],
  17619. Number: [
  17620. "isFinite",
  17621. "isNaN",
  17622. ],
  17623. Object: [
  17624. "create",
  17625. "getOwnPropertyDescriptor",
  17626. "getOwnPropertyNames",
  17627. "getPrototypeOf",
  17628. "isExtensible",
  17629. "isFrozen",
  17630. "isSealed",
  17631. "keys",
  17632. ],
  17633. String: [
  17634. "fromCharCode",
  17635. ],
  17636. });
  17637. // Known numeric values which come with JS environments
  17638. const is_pure_native_value = make_nested_lookup({
  17639. Math: [
  17640. "E",
  17641. "LN10",
  17642. "LN2",
  17643. "LOG2E",
  17644. "LOG10E",
  17645. "PI",
  17646. "SQRT1_2",
  17647. "SQRT2",
  17648. ],
  17649. Number: [
  17650. "MAX_VALUE",
  17651. "MIN_VALUE",
  17652. "NaN",
  17653. "NEGATIVE_INFINITY",
  17654. "POSITIVE_INFINITY",
  17655. ],
  17656. });
  17657. /***********************************************************************
  17658. A JavaScript tokenizer / parser / beautifier / compressor.
  17659. https://github.com/mishoo/UglifyJS2
  17660. -------------------------------- (C) ---------------------------------
  17661. Author: Mihai Bazon
  17662. <mihai.bazon@gmail.com>
  17663. http://mihai.bazon.net/blog
  17664. Distributed under the BSD license:
  17665. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17666. Redistribution and use in source and binary forms, with or without
  17667. modification, are permitted provided that the following conditions
  17668. are met:
  17669. * Redistributions of source code must retain the above
  17670. copyright notice, this list of conditions and the following
  17671. disclaimer.
  17672. * Redistributions in binary form must reproduce the above
  17673. copyright notice, this list of conditions and the following
  17674. disclaimer in the documentation and/or other materials
  17675. provided with the distribution.
  17676. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17677. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17678. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17679. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17680. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17681. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17682. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17683. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17684. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17685. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17686. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17687. SUCH DAMAGE.
  17688. ***********************************************************************/
  17689. // Functions and methods to infer certain facts about expressions
  17690. // It's not always possible to be 100% sure about something just by static analysis,
  17691. // so `true` means yes, and `false` means maybe
  17692. const is_undeclared_ref = (node) =>
  17693. node instanceof AST_SymbolRef && node.definition().undeclared;
  17694. const lazy_op = makePredicate("&& || ??");
  17695. const unary_side_effects = makePredicate("delete ++ --");
  17696. // methods to determine whether an expression has a boolean result type
  17697. (function(def_is_boolean) {
  17698. const unary_bool = makePredicate("! delete");
  17699. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  17700. def_is_boolean(AST_Node, return_false);
  17701. def_is_boolean(AST_UnaryPrefix, function() {
  17702. return unary_bool.has(this.operator);
  17703. });
  17704. def_is_boolean(AST_Binary, function() {
  17705. return binary_bool.has(this.operator)
  17706. || lazy_op.has(this.operator)
  17707. && this.left.is_boolean()
  17708. && this.right.is_boolean();
  17709. });
  17710. def_is_boolean(AST_Conditional, function() {
  17711. return this.consequent.is_boolean() && this.alternative.is_boolean();
  17712. });
  17713. def_is_boolean(AST_Assign, function() {
  17714. return this.operator == "=" && this.right.is_boolean();
  17715. });
  17716. def_is_boolean(AST_Sequence, function() {
  17717. return this.tail_node().is_boolean();
  17718. });
  17719. def_is_boolean(AST_True, return_true);
  17720. def_is_boolean(AST_False, return_true);
  17721. })(function(node, func) {
  17722. node.DEFMETHOD("is_boolean", func);
  17723. });
  17724. // methods to determine if an expression has a numeric result type
  17725. (function(def_is_number) {
  17726. def_is_number(AST_Node, return_false);
  17727. def_is_number(AST_Number, return_true);
  17728. const unary = makePredicate("+ - ~ ++ --");
  17729. def_is_number(AST_Unary, function() {
  17730. return unary.has(this.operator);
  17731. });
  17732. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  17733. def_is_number(AST_Binary, function(compressor) {
  17734. return numeric_ops.has(this.operator) || this.operator == "+"
  17735. && this.left.is_number(compressor)
  17736. && this.right.is_number(compressor);
  17737. });
  17738. def_is_number(AST_Assign, function(compressor) {
  17739. return numeric_ops.has(this.operator.slice(0, -1))
  17740. || this.operator == "=" && this.right.is_number(compressor);
  17741. });
  17742. def_is_number(AST_Sequence, function(compressor) {
  17743. return this.tail_node().is_number(compressor);
  17744. });
  17745. def_is_number(AST_Conditional, function(compressor) {
  17746. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  17747. });
  17748. })(function(node, func) {
  17749. node.DEFMETHOD("is_number", func);
  17750. });
  17751. // methods to determine if an expression has a string result type
  17752. (function(def_is_string) {
  17753. def_is_string(AST_Node, return_false);
  17754. def_is_string(AST_String, return_true);
  17755. def_is_string(AST_TemplateString, return_true);
  17756. def_is_string(AST_UnaryPrefix, function() {
  17757. return this.operator == "typeof";
  17758. });
  17759. def_is_string(AST_Binary, function(compressor) {
  17760. return this.operator == "+" &&
  17761. (this.left.is_string(compressor) || this.right.is_string(compressor));
  17762. });
  17763. def_is_string(AST_Assign, function(compressor) {
  17764. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  17765. });
  17766. def_is_string(AST_Sequence, function(compressor) {
  17767. return this.tail_node().is_string(compressor);
  17768. });
  17769. def_is_string(AST_Conditional, function(compressor) {
  17770. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  17771. });
  17772. })(function(node, func) {
  17773. node.DEFMETHOD("is_string", func);
  17774. });
  17775. function is_undefined(node, compressor) {
  17776. return (
  17777. has_flag(node, UNDEFINED)
  17778. || node instanceof AST_Undefined
  17779. || node instanceof AST_UnaryPrefix
  17780. && node.operator == "void"
  17781. && !node.expression.has_side_effects(compressor)
  17782. );
  17783. }
  17784. // Find out if something is == null
  17785. // Used to optimize ?. and ??
  17786. function is_nullish(node, compressor) {
  17787. let fixed;
  17788. return (
  17789. node instanceof AST_Null
  17790. || is_undefined(node, compressor)
  17791. || (
  17792. node instanceof AST_SymbolRef
  17793. && (fixed = node.definition().fixed) instanceof AST_Node
  17794. && is_nullish(fixed, compressor)
  17795. )
  17796. // Recurse into those optional chains!
  17797. || node instanceof AST_PropAccess && node.optional && is_nullish(node.expression, compressor)
  17798. || node instanceof AST_Call && node.optional && is_nullish(node.expression, compressor)
  17799. || node instanceof AST_Chain && is_nullish(node.expression, compressor)
  17800. );
  17801. }
  17802. // Determine if expression might cause side effects
  17803. // If there's a possibility that a node may change something when it's executed, this returns true
  17804. (function(def_has_side_effects) {
  17805. def_has_side_effects(AST_Node, return_true);
  17806. def_has_side_effects(AST_EmptyStatement, return_false);
  17807. def_has_side_effects(AST_Constant, return_false);
  17808. def_has_side_effects(AST_This, return_false);
  17809. function any(list, compressor) {
  17810. for (var i = list.length; --i >= 0;)
  17811. if (list[i].has_side_effects(compressor))
  17812. return true;
  17813. return false;
  17814. }
  17815. def_has_side_effects(AST_Block, function(compressor) {
  17816. return any(this.body, compressor);
  17817. });
  17818. def_has_side_effects(AST_Call, function(compressor) {
  17819. if (
  17820. !this.is_callee_pure(compressor)
  17821. && (!this.expression.is_call_pure(compressor)
  17822. || this.expression.has_side_effects(compressor))
  17823. ) {
  17824. return true;
  17825. }
  17826. return any(this.args, compressor);
  17827. });
  17828. def_has_side_effects(AST_Switch, function(compressor) {
  17829. return this.expression.has_side_effects(compressor)
  17830. || any(this.body, compressor);
  17831. });
  17832. def_has_side_effects(AST_Case, function(compressor) {
  17833. return this.expression.has_side_effects(compressor)
  17834. || any(this.body, compressor);
  17835. });
  17836. def_has_side_effects(AST_Try, function(compressor) {
  17837. return any(this.body, compressor)
  17838. || this.bcatch && this.bcatch.has_side_effects(compressor)
  17839. || this.bfinally && this.bfinally.has_side_effects(compressor);
  17840. });
  17841. def_has_side_effects(AST_If, function(compressor) {
  17842. return this.condition.has_side_effects(compressor)
  17843. || this.body && this.body.has_side_effects(compressor)
  17844. || this.alternative && this.alternative.has_side_effects(compressor);
  17845. });
  17846. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  17847. return this.body.has_side_effects(compressor);
  17848. });
  17849. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  17850. return this.body.has_side_effects(compressor);
  17851. });
  17852. def_has_side_effects(AST_Lambda, return_false);
  17853. def_has_side_effects(AST_Class, function (compressor) {
  17854. if (this.extends && this.extends.has_side_effects(compressor)) {
  17855. return true;
  17856. }
  17857. return any(this.properties, compressor);
  17858. });
  17859. def_has_side_effects(AST_Binary, function(compressor) {
  17860. return this.left.has_side_effects(compressor)
  17861. || this.right.has_side_effects(compressor);
  17862. });
  17863. def_has_side_effects(AST_Assign, return_true);
  17864. def_has_side_effects(AST_Conditional, function(compressor) {
  17865. return this.condition.has_side_effects(compressor)
  17866. || this.consequent.has_side_effects(compressor)
  17867. || this.alternative.has_side_effects(compressor);
  17868. });
  17869. def_has_side_effects(AST_Unary, function(compressor) {
  17870. return unary_side_effects.has(this.operator)
  17871. || this.expression.has_side_effects(compressor);
  17872. });
  17873. def_has_side_effects(AST_SymbolRef, function(compressor) {
  17874. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  17875. });
  17876. def_has_side_effects(AST_SymbolClassProperty, return_false);
  17877. def_has_side_effects(AST_SymbolDeclaration, return_false);
  17878. def_has_side_effects(AST_Object, function(compressor) {
  17879. return any(this.properties, compressor);
  17880. });
  17881. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  17882. return (
  17883. this.computed_key() && this.key.has_side_effects(compressor)
  17884. || this.value && this.value.has_side_effects(compressor)
  17885. );
  17886. });
  17887. def_has_side_effects(AST_ClassProperty, function(compressor) {
  17888. return (
  17889. this.computed_key() && this.key.has_side_effects(compressor)
  17890. || this.static && this.value && this.value.has_side_effects(compressor)
  17891. );
  17892. });
  17893. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  17894. return this.computed_key() && this.key.has_side_effects(compressor);
  17895. });
  17896. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  17897. return this.computed_key() && this.key.has_side_effects(compressor);
  17898. });
  17899. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  17900. return this.computed_key() && this.key.has_side_effects(compressor);
  17901. });
  17902. def_has_side_effects(AST_Array, function(compressor) {
  17903. return any(this.elements, compressor);
  17904. });
  17905. def_has_side_effects(AST_Dot, function(compressor) {
  17906. return !this.optional && this.expression.may_throw_on_access(compressor)
  17907. || this.expression.has_side_effects(compressor);
  17908. });
  17909. def_has_side_effects(AST_Sub, function(compressor) {
  17910. if (this.optional && is_nullish(this.expression, compressor)) {
  17911. return false;
  17912. }
  17913. return !this.optional && this.expression.may_throw_on_access(compressor)
  17914. || this.expression.has_side_effects(compressor)
  17915. || this.property.has_side_effects(compressor);
  17916. });
  17917. def_has_side_effects(AST_Chain, function (compressor) {
  17918. return this.expression.has_side_effects(compressor);
  17919. });
  17920. def_has_side_effects(AST_Sequence, function(compressor) {
  17921. return any(this.expressions, compressor);
  17922. });
  17923. def_has_side_effects(AST_Definitions, function(compressor) {
  17924. return any(this.definitions, compressor);
  17925. });
  17926. def_has_side_effects(AST_VarDef, function() {
  17927. return this.value;
  17928. });
  17929. def_has_side_effects(AST_TemplateSegment, return_false);
  17930. def_has_side_effects(AST_TemplateString, function(compressor) {
  17931. return any(this.segments, compressor);
  17932. });
  17933. })(function(node, func) {
  17934. node.DEFMETHOD("has_side_effects", func);
  17935. });
  17936. // determine if expression may throw
  17937. (function(def_may_throw) {
  17938. def_may_throw(AST_Node, return_true);
  17939. def_may_throw(AST_Constant, return_false);
  17940. def_may_throw(AST_EmptyStatement, return_false);
  17941. def_may_throw(AST_Lambda, return_false);
  17942. def_may_throw(AST_SymbolDeclaration, return_false);
  17943. def_may_throw(AST_This, return_false);
  17944. function any(list, compressor) {
  17945. for (var i = list.length; --i >= 0;)
  17946. if (list[i].may_throw(compressor))
  17947. return true;
  17948. return false;
  17949. }
  17950. def_may_throw(AST_Class, function(compressor) {
  17951. if (this.extends && this.extends.may_throw(compressor)) return true;
  17952. return any(this.properties, compressor);
  17953. });
  17954. def_may_throw(AST_Array, function(compressor) {
  17955. return any(this.elements, compressor);
  17956. });
  17957. def_may_throw(AST_Assign, function(compressor) {
  17958. if (this.right.may_throw(compressor)) return true;
  17959. if (!compressor.has_directive("use strict")
  17960. && this.operator == "="
  17961. && this.left instanceof AST_SymbolRef) {
  17962. return false;
  17963. }
  17964. return this.left.may_throw(compressor);
  17965. });
  17966. def_may_throw(AST_Binary, function(compressor) {
  17967. return this.left.may_throw(compressor)
  17968. || this.right.may_throw(compressor);
  17969. });
  17970. def_may_throw(AST_Block, function(compressor) {
  17971. return any(this.body, compressor);
  17972. });
  17973. def_may_throw(AST_Call, function(compressor) {
  17974. if (this.optional && is_nullish(this.expression, compressor)) return false;
  17975. if (any(this.args, compressor)) return true;
  17976. if (this.is_callee_pure(compressor)) return false;
  17977. if (this.expression.may_throw(compressor)) return true;
  17978. return !(this.expression instanceof AST_Lambda)
  17979. || any(this.expression.body, compressor);
  17980. });
  17981. def_may_throw(AST_Case, function(compressor) {
  17982. return this.expression.may_throw(compressor)
  17983. || any(this.body, compressor);
  17984. });
  17985. def_may_throw(AST_Conditional, function(compressor) {
  17986. return this.condition.may_throw(compressor)
  17987. || this.consequent.may_throw(compressor)
  17988. || this.alternative.may_throw(compressor);
  17989. });
  17990. def_may_throw(AST_Definitions, function(compressor) {
  17991. return any(this.definitions, compressor);
  17992. });
  17993. def_may_throw(AST_If, function(compressor) {
  17994. return this.condition.may_throw(compressor)
  17995. || this.body && this.body.may_throw(compressor)
  17996. || this.alternative && this.alternative.may_throw(compressor);
  17997. });
  17998. def_may_throw(AST_LabeledStatement, function(compressor) {
  17999. return this.body.may_throw(compressor);
  18000. });
  18001. def_may_throw(AST_Object, function(compressor) {
  18002. return any(this.properties, compressor);
  18003. });
  18004. def_may_throw(AST_ObjectProperty, function(compressor) {
  18005. // TODO key may throw too
  18006. return this.value ? this.value.may_throw(compressor) : false;
  18007. });
  18008. def_may_throw(AST_ClassProperty, function(compressor) {
  18009. return (
  18010. this.computed_key() && this.key.may_throw(compressor)
  18011. || this.static && this.value && this.value.may_throw(compressor)
  18012. );
  18013. });
  18014. def_may_throw(AST_ConciseMethod, function(compressor) {
  18015. return this.computed_key() && this.key.may_throw(compressor);
  18016. });
  18017. def_may_throw(AST_ObjectGetter, function(compressor) {
  18018. return this.computed_key() && this.key.may_throw(compressor);
  18019. });
  18020. def_may_throw(AST_ObjectSetter, function(compressor) {
  18021. return this.computed_key() && this.key.may_throw(compressor);
  18022. });
  18023. def_may_throw(AST_Return, function(compressor) {
  18024. return this.value && this.value.may_throw(compressor);
  18025. });
  18026. def_may_throw(AST_Sequence, function(compressor) {
  18027. return any(this.expressions, compressor);
  18028. });
  18029. def_may_throw(AST_SimpleStatement, function(compressor) {
  18030. return this.body.may_throw(compressor);
  18031. });
  18032. def_may_throw(AST_Dot, function(compressor) {
  18033. return !this.optional && this.expression.may_throw_on_access(compressor)
  18034. || this.expression.may_throw(compressor);
  18035. });
  18036. def_may_throw(AST_Sub, function(compressor) {
  18037. if (this.optional && is_nullish(this.expression, compressor)) return false;
  18038. return !this.optional && this.expression.may_throw_on_access(compressor)
  18039. || this.expression.may_throw(compressor)
  18040. || this.property.may_throw(compressor);
  18041. });
  18042. def_may_throw(AST_Chain, function(compressor) {
  18043. return this.expression.may_throw(compressor);
  18044. });
  18045. def_may_throw(AST_Switch, function(compressor) {
  18046. return this.expression.may_throw(compressor)
  18047. || any(this.body, compressor);
  18048. });
  18049. def_may_throw(AST_SymbolRef, function(compressor) {
  18050. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  18051. });
  18052. def_may_throw(AST_SymbolClassProperty, return_false);
  18053. def_may_throw(AST_Try, function(compressor) {
  18054. return this.bcatch ? this.bcatch.may_throw(compressor) : any(this.body, compressor)
  18055. || this.bfinally && this.bfinally.may_throw(compressor);
  18056. });
  18057. def_may_throw(AST_Unary, function(compressor) {
  18058. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  18059. return false;
  18060. return this.expression.may_throw(compressor);
  18061. });
  18062. def_may_throw(AST_VarDef, function(compressor) {
  18063. if (!this.value) return false;
  18064. return this.value.may_throw(compressor);
  18065. });
  18066. })(function(node, func) {
  18067. node.DEFMETHOD("may_throw", func);
  18068. });
  18069. // determine if expression is constant
  18070. (function(def_is_constant_expression) {
  18071. function all_refs_local(scope) {
  18072. let result = true;
  18073. walk(this, node => {
  18074. if (node instanceof AST_SymbolRef) {
  18075. if (has_flag(this, INLINED)) {
  18076. result = false;
  18077. return walk_abort;
  18078. }
  18079. var def = node.definition();
  18080. if (
  18081. member(def, this.enclosed)
  18082. && !this.variables.has(def.name)
  18083. ) {
  18084. if (scope) {
  18085. var scope_def = scope.find_variable(node);
  18086. if (def.undeclared ? !scope_def : scope_def === def) {
  18087. result = "f";
  18088. return true;
  18089. }
  18090. }
  18091. result = false;
  18092. return walk_abort;
  18093. }
  18094. return true;
  18095. }
  18096. if (node instanceof AST_This && this instanceof AST_Arrow) {
  18097. // TODO check arguments too!
  18098. result = false;
  18099. return walk_abort;
  18100. }
  18101. });
  18102. return result;
  18103. }
  18104. def_is_constant_expression(AST_Node, return_false);
  18105. def_is_constant_expression(AST_Constant, return_true);
  18106. def_is_constant_expression(AST_Class, function(scope) {
  18107. if (this.extends && !this.extends.is_constant_expression(scope)) {
  18108. return false;
  18109. }
  18110. for (const prop of this.properties) {
  18111. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  18112. return false;
  18113. }
  18114. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  18115. return false;
  18116. }
  18117. }
  18118. return all_refs_local.call(this, scope);
  18119. });
  18120. def_is_constant_expression(AST_Lambda, all_refs_local);
  18121. def_is_constant_expression(AST_Unary, function() {
  18122. return this.expression.is_constant_expression();
  18123. });
  18124. def_is_constant_expression(AST_Binary, function() {
  18125. return this.left.is_constant_expression()
  18126. && this.right.is_constant_expression();
  18127. });
  18128. def_is_constant_expression(AST_Array, function() {
  18129. return this.elements.every((l) => l.is_constant_expression());
  18130. });
  18131. def_is_constant_expression(AST_Object, function() {
  18132. return this.properties.every((l) => l.is_constant_expression());
  18133. });
  18134. def_is_constant_expression(AST_ObjectProperty, function() {
  18135. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  18136. });
  18137. })(function(node, func) {
  18138. node.DEFMETHOD("is_constant_expression", func);
  18139. });
  18140. // may_throw_on_access()
  18141. // returns true if this node may be null, undefined or contain `AST_Accessor`
  18142. (function(def_may_throw_on_access) {
  18143. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  18144. return !compressor.option("pure_getters")
  18145. || this._dot_throw(compressor);
  18146. });
  18147. function is_strict(compressor) {
  18148. return /strict/.test(compressor.option("pure_getters"));
  18149. }
  18150. def_may_throw_on_access(AST_Node, is_strict);
  18151. def_may_throw_on_access(AST_Null, return_true);
  18152. def_may_throw_on_access(AST_Undefined, return_true);
  18153. def_may_throw_on_access(AST_Constant, return_false);
  18154. def_may_throw_on_access(AST_Array, return_false);
  18155. def_may_throw_on_access(AST_Object, function(compressor) {
  18156. if (!is_strict(compressor)) return false;
  18157. for (var i = this.properties.length; --i >=0;)
  18158. if (this.properties[i]._dot_throw(compressor)) return true;
  18159. return false;
  18160. });
  18161. // Do not be as strict with classes as we are with objects.
  18162. // Hopefully the community is not going to abuse static getters and setters.
  18163. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  18164. def_may_throw_on_access(AST_Class, return_false);
  18165. def_may_throw_on_access(AST_ObjectProperty, return_false);
  18166. def_may_throw_on_access(AST_ObjectGetter, return_true);
  18167. def_may_throw_on_access(AST_Expansion, function(compressor) {
  18168. return this.expression._dot_throw(compressor);
  18169. });
  18170. def_may_throw_on_access(AST_Function, return_false);
  18171. def_may_throw_on_access(AST_Arrow, return_false);
  18172. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  18173. def_may_throw_on_access(AST_UnaryPrefix, function() {
  18174. return this.operator == "void";
  18175. });
  18176. def_may_throw_on_access(AST_Binary, function(compressor) {
  18177. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  18178. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  18179. });
  18180. def_may_throw_on_access(AST_Assign, function(compressor) {
  18181. if (this.logical) return true;
  18182. return this.operator == "="
  18183. && this.right._dot_throw(compressor);
  18184. });
  18185. def_may_throw_on_access(AST_Conditional, function(compressor) {
  18186. return this.consequent._dot_throw(compressor)
  18187. || this.alternative._dot_throw(compressor);
  18188. });
  18189. def_may_throw_on_access(AST_Dot, function(compressor) {
  18190. if (!is_strict(compressor)) return false;
  18191. if (this.property == "prototype") {
  18192. return !(
  18193. this.expression instanceof AST_Function
  18194. || this.expression instanceof AST_Class
  18195. );
  18196. }
  18197. return true;
  18198. });
  18199. def_may_throw_on_access(AST_Chain, function(compressor) {
  18200. return this.expression._dot_throw(compressor);
  18201. });
  18202. def_may_throw_on_access(AST_Sequence, function(compressor) {
  18203. return this.tail_node()._dot_throw(compressor);
  18204. });
  18205. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  18206. if (this.name === "arguments") return false;
  18207. if (has_flag(this, UNDEFINED)) return true;
  18208. if (!is_strict(compressor)) return false;
  18209. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  18210. if (this.is_immutable()) return false;
  18211. var fixed = this.fixed_value();
  18212. return !fixed || fixed._dot_throw(compressor);
  18213. });
  18214. })(function(node, func) {
  18215. node.DEFMETHOD("_dot_throw", func);
  18216. });
  18217. function is_lhs(node, parent) {
  18218. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  18219. if (parent instanceof AST_Assign && parent.left === node) return node;
  18220. }
  18221. (function(def_find_defs) {
  18222. function to_node(value, orig) {
  18223. if (value instanceof AST_Node) {
  18224. if (!(value instanceof AST_Constant)) {
  18225. // Value may be a function, an array including functions and even a complex assign / block expression,
  18226. // so it should never be shared in different places.
  18227. // Otherwise wrong information may be used in the compression phase
  18228. value = value.clone(true);
  18229. }
  18230. return make_node(value.CTOR, orig, value);
  18231. }
  18232. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  18233. elements: value.map(function(value) {
  18234. return to_node(value, orig);
  18235. })
  18236. });
  18237. if (value && typeof value == "object") {
  18238. var props = [];
  18239. for (var key in value) if (HOP(value, key)) {
  18240. props.push(make_node(AST_ObjectKeyVal, orig, {
  18241. key: key,
  18242. value: to_node(value[key], orig)
  18243. }));
  18244. }
  18245. return make_node(AST_Object, orig, {
  18246. properties: props
  18247. });
  18248. }
  18249. return make_node_from_constant(value, orig);
  18250. }
  18251. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  18252. if (!compressor.option("global_defs")) return this;
  18253. this.figure_out_scope({ ie8: compressor.option("ie8") });
  18254. return this.transform(new TreeTransformer(function(node) {
  18255. var def = node._find_defs(compressor, "");
  18256. if (!def) return;
  18257. var level = 0, child = node, parent;
  18258. while (parent = this.parent(level++)) {
  18259. if (!(parent instanceof AST_PropAccess)) break;
  18260. if (parent.expression !== child) break;
  18261. child = parent;
  18262. }
  18263. if (is_lhs(child, parent)) {
  18264. return;
  18265. }
  18266. return def;
  18267. }));
  18268. });
  18269. def_find_defs(AST_Node, noop);
  18270. def_find_defs(AST_Chain, function(compressor, suffix) {
  18271. return this.expression._find_defs(compressor, suffix);
  18272. });
  18273. def_find_defs(AST_Dot, function(compressor, suffix) {
  18274. return this.expression._find_defs(compressor, "." + this.property + suffix);
  18275. });
  18276. def_find_defs(AST_SymbolDeclaration, function() {
  18277. if (!this.global()) return;
  18278. });
  18279. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  18280. if (!this.global()) return;
  18281. var defines = compressor.option("global_defs");
  18282. var name = this.name + suffix;
  18283. if (HOP(defines, name)) return to_node(defines[name], this);
  18284. });
  18285. })(function(node, func) {
  18286. node.DEFMETHOD("_find_defs", func);
  18287. });
  18288. // method to negate an expression
  18289. (function(def_negate) {
  18290. function basic_negation(exp) {
  18291. return make_node(AST_UnaryPrefix, exp, {
  18292. operator: "!",
  18293. expression: exp
  18294. });
  18295. }
  18296. function best(orig, alt, first_in_statement) {
  18297. var negated = basic_negation(orig);
  18298. if (first_in_statement) {
  18299. var stat = make_node(AST_SimpleStatement, alt, {
  18300. body: alt
  18301. });
  18302. return best_of_expression(negated, stat) === stat ? alt : negated;
  18303. }
  18304. return best_of_expression(negated, alt);
  18305. }
  18306. def_negate(AST_Node, function() {
  18307. return basic_negation(this);
  18308. });
  18309. def_negate(AST_Statement, function() {
  18310. throw new Error("Cannot negate a statement");
  18311. });
  18312. def_negate(AST_Function, function() {
  18313. return basic_negation(this);
  18314. });
  18315. def_negate(AST_Arrow, function() {
  18316. return basic_negation(this);
  18317. });
  18318. def_negate(AST_UnaryPrefix, function() {
  18319. if (this.operator == "!")
  18320. return this.expression;
  18321. return basic_negation(this);
  18322. });
  18323. def_negate(AST_Sequence, function(compressor) {
  18324. var expressions = this.expressions.slice();
  18325. expressions.push(expressions.pop().negate(compressor));
  18326. return make_sequence(this, expressions);
  18327. });
  18328. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  18329. var self = this.clone();
  18330. self.consequent = self.consequent.negate(compressor);
  18331. self.alternative = self.alternative.negate(compressor);
  18332. return best(this, self, first_in_statement);
  18333. });
  18334. def_negate(AST_Binary, function(compressor, first_in_statement) {
  18335. var self = this.clone(), op = this.operator;
  18336. if (compressor.option("unsafe_comps")) {
  18337. switch (op) {
  18338. case "<=" : self.operator = ">" ; return self;
  18339. case "<" : self.operator = ">=" ; return self;
  18340. case ">=" : self.operator = "<" ; return self;
  18341. case ">" : self.operator = "<=" ; return self;
  18342. }
  18343. }
  18344. switch (op) {
  18345. case "==" : self.operator = "!="; return self;
  18346. case "!=" : self.operator = "=="; return self;
  18347. case "===": self.operator = "!=="; return self;
  18348. case "!==": self.operator = "==="; return self;
  18349. case "&&":
  18350. self.operator = "||";
  18351. self.left = self.left.negate(compressor, first_in_statement);
  18352. self.right = self.right.negate(compressor);
  18353. return best(this, self, first_in_statement);
  18354. case "||":
  18355. self.operator = "&&";
  18356. self.left = self.left.negate(compressor, first_in_statement);
  18357. self.right = self.right.negate(compressor);
  18358. return best(this, self, first_in_statement);
  18359. }
  18360. return basic_negation(this);
  18361. });
  18362. })(function(node, func) {
  18363. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  18364. return func.call(this, compressor, first_in_statement);
  18365. });
  18366. });
  18367. // Is the callee of this function pure?
  18368. 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");
  18369. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  18370. if (compressor.option("unsafe")) {
  18371. var expr = this.expression;
  18372. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  18373. if (
  18374. expr.expression && expr.expression.name === "hasOwnProperty" &&
  18375. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  18376. ) {
  18377. return false;
  18378. }
  18379. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  18380. if (
  18381. expr instanceof AST_Dot
  18382. && is_undeclared_ref(expr.expression)
  18383. && is_pure_native_fn(expr.expression.name, expr.property)
  18384. ) {
  18385. return true;
  18386. }
  18387. }
  18388. return !!has_annotation(this, _PURE) || !compressor.pure_funcs(this);
  18389. });
  18390. // If I call this, is it a pure function?
  18391. AST_Node.DEFMETHOD("is_call_pure", return_false);
  18392. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  18393. if (!compressor.option("unsafe")) return;
  18394. const expr = this.expression;
  18395. let native_obj;
  18396. if (expr instanceof AST_Array) {
  18397. native_obj = "Array";
  18398. } else if (expr.is_boolean()) {
  18399. native_obj = "Boolean";
  18400. } else if (expr.is_number(compressor)) {
  18401. native_obj = "Number";
  18402. } else if (expr instanceof AST_RegExp) {
  18403. native_obj = "RegExp";
  18404. } else if (expr.is_string(compressor)) {
  18405. native_obj = "String";
  18406. } else if (!this.may_throw_on_access(compressor)) {
  18407. native_obj = "Object";
  18408. }
  18409. return native_obj != null && is_pure_native_method(native_obj, this.property);
  18410. });
  18411. // tell me if a statement aborts
  18412. const aborts = (thing) => thing && thing.aborts();
  18413. (function(def_aborts) {
  18414. def_aborts(AST_Statement, return_null);
  18415. def_aborts(AST_Jump, return_this);
  18416. function block_aborts() {
  18417. for (var i = 0; i < this.body.length; i++) {
  18418. if (aborts(this.body[i])) {
  18419. return this.body[i];
  18420. }
  18421. }
  18422. return null;
  18423. }
  18424. def_aborts(AST_Import, function() { return null; });
  18425. def_aborts(AST_BlockStatement, block_aborts);
  18426. def_aborts(AST_SwitchBranch, block_aborts);
  18427. def_aborts(AST_If, function() {
  18428. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  18429. });
  18430. })(function(node, func) {
  18431. node.DEFMETHOD("aborts", func);
  18432. });
  18433. function is_modified(compressor, tw, node, value, level, immutable) {
  18434. var parent = tw.parent(level);
  18435. var lhs = is_lhs(node, parent);
  18436. if (lhs) return lhs;
  18437. if (!immutable
  18438. && parent instanceof AST_Call
  18439. && parent.expression === node
  18440. && !(value instanceof AST_Arrow)
  18441. && !(value instanceof AST_Class)
  18442. && !parent.is_callee_pure(compressor)
  18443. && (!(value instanceof AST_Function)
  18444. || !(parent instanceof AST_New) && value.contains_this())) {
  18445. return true;
  18446. }
  18447. if (parent instanceof AST_Array) {
  18448. return is_modified(compressor, tw, parent, parent, level + 1);
  18449. }
  18450. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  18451. var obj = tw.parent(level + 1);
  18452. return is_modified(compressor, tw, obj, obj, level + 2);
  18453. }
  18454. if (parent instanceof AST_PropAccess && parent.expression === node) {
  18455. var prop = read_property(value, parent.property);
  18456. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  18457. }
  18458. }
  18459. /***********************************************************************
  18460. A JavaScript tokenizer / parser / beautifier / compressor.
  18461. https://github.com/mishoo/UglifyJS2
  18462. -------------------------------- (C) ---------------------------------
  18463. Author: Mihai Bazon
  18464. <mihai.bazon@gmail.com>
  18465. http://mihai.bazon.net/blog
  18466. Distributed under the BSD license:
  18467. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  18468. Redistribution and use in source and binary forms, with or without
  18469. modification, are permitted provided that the following conditions
  18470. are met:
  18471. * Redistributions of source code must retain the above
  18472. copyright notice, this list of conditions and the following
  18473. disclaimer.
  18474. * Redistributions in binary form must reproduce the above
  18475. copyright notice, this list of conditions and the following
  18476. disclaimer in the documentation and/or other materials
  18477. provided with the distribution.
  18478. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  18479. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18480. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18481. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  18482. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  18483. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18484. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  18485. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18486. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  18487. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  18488. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  18489. SUCH DAMAGE.
  18490. ***********************************************************************/
  18491. // methods to evaluate a constant expression
  18492. function def_eval(node, func) {
  18493. node.DEFMETHOD("_eval", func);
  18494. }
  18495. // If the node has been successfully reduced to a constant,
  18496. // then its value is returned; otherwise the element itself
  18497. // is returned.
  18498. // They can be distinguished as constant value is never a
  18499. // descendant of AST_Node.
  18500. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  18501. if (!compressor.option("evaluate"))
  18502. return this;
  18503. var val = this._eval(compressor, 1);
  18504. if (!val || val instanceof RegExp)
  18505. return val;
  18506. if (typeof val == "function" || typeof val == "object")
  18507. return this;
  18508. return val;
  18509. });
  18510. var unaryPrefix = makePredicate("! ~ - + void");
  18511. AST_Node.DEFMETHOD("is_constant", function () {
  18512. // Accomodate when compress option evaluate=false
  18513. // as well as the common constant expressions !0 and -1
  18514. if (this instanceof AST_Constant) {
  18515. return !(this instanceof AST_RegExp);
  18516. } else {
  18517. return this instanceof AST_UnaryPrefix
  18518. && this.expression instanceof AST_Constant
  18519. && unaryPrefix.has(this.operator);
  18520. }
  18521. });
  18522. def_eval(AST_Statement, function () {
  18523. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  18524. });
  18525. def_eval(AST_Lambda, return_this);
  18526. def_eval(AST_Class, return_this);
  18527. def_eval(AST_Node, return_this);
  18528. def_eval(AST_Constant, function () {
  18529. return this.getValue();
  18530. });
  18531. def_eval(AST_BigInt, return_this);
  18532. def_eval(AST_RegExp, function (compressor) {
  18533. let evaluated = compressor.evaluated_regexps.get(this);
  18534. if (evaluated === undefined) {
  18535. try {
  18536. evaluated = (0, eval)(this.print_to_string());
  18537. } catch (e) {
  18538. evaluated = null;
  18539. }
  18540. compressor.evaluated_regexps.set(this, evaluated);
  18541. }
  18542. return evaluated || this;
  18543. });
  18544. def_eval(AST_TemplateString, function () {
  18545. if (this.segments.length !== 1) return this;
  18546. return this.segments[0].value;
  18547. });
  18548. def_eval(AST_Function, function (compressor) {
  18549. if (compressor.option("unsafe")) {
  18550. var fn = function () { };
  18551. fn.node = this;
  18552. fn.toString = () => this.print_to_string();
  18553. return fn;
  18554. }
  18555. return this;
  18556. });
  18557. def_eval(AST_Array, function (compressor, depth) {
  18558. if (compressor.option("unsafe")) {
  18559. var elements = [];
  18560. for (var i = 0, len = this.elements.length; i < len; i++) {
  18561. var element = this.elements[i];
  18562. var value = element._eval(compressor, depth);
  18563. if (element === value)
  18564. return this;
  18565. elements.push(value);
  18566. }
  18567. return elements;
  18568. }
  18569. return this;
  18570. });
  18571. def_eval(AST_Object, function (compressor, depth) {
  18572. if (compressor.option("unsafe")) {
  18573. var val = {};
  18574. for (var i = 0, len = this.properties.length; i < len; i++) {
  18575. var prop = this.properties[i];
  18576. if (prop instanceof AST_Expansion)
  18577. return this;
  18578. var key = prop.key;
  18579. if (key instanceof AST_Symbol) {
  18580. key = key.name;
  18581. } else if (key instanceof AST_Node) {
  18582. key = key._eval(compressor, depth);
  18583. if (key === prop.key)
  18584. return this;
  18585. }
  18586. if (typeof Object.prototype[key] === "function") {
  18587. return this;
  18588. }
  18589. if (prop.value instanceof AST_Function)
  18590. continue;
  18591. val[key] = prop.value._eval(compressor, depth);
  18592. if (val[key] === prop.value)
  18593. return this;
  18594. }
  18595. return val;
  18596. }
  18597. return this;
  18598. });
  18599. var non_converting_unary = makePredicate("! typeof void");
  18600. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  18601. var e = this.expression;
  18602. // Function would be evaluated to an array and so typeof would
  18603. // incorrectly return 'object'. Hence making is a special case.
  18604. if (compressor.option("typeofs")
  18605. && this.operator == "typeof"
  18606. && (e instanceof AST_Lambda
  18607. || e instanceof AST_SymbolRef
  18608. && e.fixed_value() instanceof AST_Lambda)) {
  18609. return typeof function () { };
  18610. }
  18611. if (!non_converting_unary.has(this.operator))
  18612. depth++;
  18613. e = e._eval(compressor, depth);
  18614. if (e === this.expression)
  18615. return this;
  18616. switch (this.operator) {
  18617. case "!": return !e;
  18618. case "typeof":
  18619. // typeof <RegExp> returns "object" or "function" on different platforms
  18620. // so cannot evaluate reliably
  18621. if (e instanceof RegExp)
  18622. return this;
  18623. return typeof e;
  18624. case "void": return void e;
  18625. case "~": return ~e;
  18626. case "-": return -e;
  18627. case "+": return +e;
  18628. }
  18629. return this;
  18630. });
  18631. var non_converting_binary = makePredicate("&& || ?? === !==");
  18632. const identity_comparison = makePredicate("== != === !==");
  18633. const has_identity = value => typeof value === "object"
  18634. || typeof value === "function"
  18635. || typeof value === "symbol";
  18636. def_eval(AST_Binary, function (compressor, depth) {
  18637. if (!non_converting_binary.has(this.operator))
  18638. depth++;
  18639. var left = this.left._eval(compressor, depth);
  18640. if (left === this.left)
  18641. return this;
  18642. var right = this.right._eval(compressor, depth);
  18643. if (right === this.right)
  18644. return this;
  18645. var result;
  18646. if (left != null
  18647. && right != null
  18648. && identity_comparison.has(this.operator)
  18649. && has_identity(left)
  18650. && has_identity(right)
  18651. && typeof left === typeof right) {
  18652. // Do not compare by reference
  18653. return this;
  18654. }
  18655. switch (this.operator) {
  18656. case "&&": result = left && right; break;
  18657. case "||": result = left || right; break;
  18658. case "??": result = left != null ? left : right; break;
  18659. case "|": result = left | right; break;
  18660. case "&": result = left & right; break;
  18661. case "^": result = left ^ right; break;
  18662. case "+": result = left + right; break;
  18663. case "*": result = left * right; break;
  18664. case "**": result = Math.pow(left, right); break;
  18665. case "/": result = left / right; break;
  18666. case "%": result = left % right; break;
  18667. case "-": result = left - right; break;
  18668. case "<<": result = left << right; break;
  18669. case ">>": result = left >> right; break;
  18670. case ">>>": result = left >>> right; break;
  18671. case "==": result = left == right; break;
  18672. case "===": result = left === right; break;
  18673. case "!=": result = left != right; break;
  18674. case "!==": result = left !== right; break;
  18675. case "<": result = left < right; break;
  18676. case "<=": result = left <= right; break;
  18677. case ">": result = left > right; break;
  18678. case ">=": result = left >= right; break;
  18679. default:
  18680. return this;
  18681. }
  18682. if (isNaN(result) && compressor.find_parent(AST_With)) {
  18683. // leave original expression as is
  18684. return this;
  18685. }
  18686. return result;
  18687. });
  18688. def_eval(AST_Conditional, function (compressor, depth) {
  18689. var condition = this.condition._eval(compressor, depth);
  18690. if (condition === this.condition)
  18691. return this;
  18692. var node = condition ? this.consequent : this.alternative;
  18693. var value = node._eval(compressor, depth);
  18694. return value === node ? this : value;
  18695. });
  18696. // Set of AST_SymbolRef which are currently being evaluated.
  18697. // Avoids infinite recursion of ._eval()
  18698. const reentrant_ref_eval = new Set();
  18699. def_eval(AST_SymbolRef, function (compressor, depth) {
  18700. if (reentrant_ref_eval.has(this))
  18701. return this;
  18702. var fixed = this.fixed_value();
  18703. if (!fixed)
  18704. return this;
  18705. reentrant_ref_eval.add(this);
  18706. const value = fixed._eval(compressor, depth);
  18707. reentrant_ref_eval.delete(this);
  18708. if (value === fixed)
  18709. return this;
  18710. if (value && typeof value == "object") {
  18711. var escaped = this.definition().escaped;
  18712. if (escaped && depth > escaped)
  18713. return this;
  18714. }
  18715. return value;
  18716. });
  18717. const global_objs = { Array, Math, Number, Object, String };
  18718. const regexp_flags = new Set([
  18719. "dotAll",
  18720. "global",
  18721. "ignoreCase",
  18722. "multiline",
  18723. "sticky",
  18724. "unicode",
  18725. ]);
  18726. def_eval(AST_PropAccess, function (compressor, depth) {
  18727. if (this.optional) {
  18728. const obj = this.expression._eval(compressor, depth);
  18729. if (obj == null)
  18730. return undefined;
  18731. }
  18732. if (compressor.option("unsafe")) {
  18733. var key = this.property;
  18734. if (key instanceof AST_Node) {
  18735. key = key._eval(compressor, depth);
  18736. if (key === this.property)
  18737. return this;
  18738. }
  18739. var exp = this.expression;
  18740. var val;
  18741. if (is_undeclared_ref(exp)) {
  18742. var aa;
  18743. var first_arg = exp.name === "hasOwnProperty"
  18744. && key === "call"
  18745. && (aa = compressor.parent() && compressor.parent().args)
  18746. && (aa && aa[0]
  18747. && aa[0].evaluate(compressor));
  18748. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  18749. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  18750. return this.clone();
  18751. }
  18752. if (!is_pure_native_value(exp.name, key))
  18753. return this;
  18754. val = global_objs[exp.name];
  18755. } else {
  18756. val = exp._eval(compressor, depth + 1);
  18757. if (val instanceof RegExp) {
  18758. if (key == "source") {
  18759. return regexp_source_fix(val.source);
  18760. } else if (key == "flags" || regexp_flags.has(key)) {
  18761. return val[key];
  18762. }
  18763. }
  18764. if (!val || val === exp || !HOP(val, key))
  18765. return this;
  18766. if (typeof val == "function")
  18767. switch (key) {
  18768. case "name":
  18769. return val.node.name ? val.node.name.name : "";
  18770. case "length":
  18771. return val.node.length_property();
  18772. default:
  18773. return this;
  18774. }
  18775. }
  18776. return val[key];
  18777. }
  18778. return this;
  18779. });
  18780. def_eval(AST_Chain, function (compressor, depth) {
  18781. const evaluated = this.expression._eval(compressor, depth);
  18782. return evaluated === this.expression ? this : evaluated;
  18783. });
  18784. def_eval(AST_Call, function (compressor, depth) {
  18785. var exp = this.expression;
  18786. if (this.optional) {
  18787. const callee = this.expression._eval(compressor, depth);
  18788. if (callee == null)
  18789. return undefined;
  18790. }
  18791. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  18792. var key = exp.property;
  18793. if (key instanceof AST_Node) {
  18794. key = key._eval(compressor, depth);
  18795. if (key === exp.property)
  18796. return this;
  18797. }
  18798. var val;
  18799. var e = exp.expression;
  18800. if (is_undeclared_ref(e)) {
  18801. var first_arg = e.name === "hasOwnProperty" &&
  18802. key === "call" &&
  18803. (this.args[0] && this.args[0].evaluate(compressor));
  18804. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  18805. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  18806. return this.clone();
  18807. }
  18808. if (!is_pure_native_fn(e.name, key)) return this;
  18809. val = global_objs[e.name];
  18810. } else {
  18811. val = e._eval(compressor, depth + 1);
  18812. if (val === e || !val)
  18813. return this;
  18814. if (!is_pure_native_method(val.constructor.name, key))
  18815. return this;
  18816. }
  18817. var args = [];
  18818. for (var i = 0, len = this.args.length; i < len; i++) {
  18819. var arg = this.args[i];
  18820. var value = arg._eval(compressor, depth);
  18821. if (arg === value)
  18822. return this;
  18823. if (arg instanceof AST_Lambda)
  18824. return this;
  18825. args.push(value);
  18826. }
  18827. try {
  18828. return val[key].apply(val, args);
  18829. } catch (ex) {
  18830. // We don't really care
  18831. }
  18832. }
  18833. return this;
  18834. });
  18835. // Also a subclass of AST_Call
  18836. def_eval(AST_New, return_this);
  18837. /***********************************************************************
  18838. A JavaScript tokenizer / parser / beautifier / compressor.
  18839. https://github.com/mishoo/UglifyJS2
  18840. -------------------------------- (C) ---------------------------------
  18841. Author: Mihai Bazon
  18842. <mihai.bazon@gmail.com>
  18843. http://mihai.bazon.net/blog
  18844. Distributed under the BSD license:
  18845. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  18846. Redistribution and use in source and binary forms, with or without
  18847. modification, are permitted provided that the following conditions
  18848. are met:
  18849. * Redistributions of source code must retain the above
  18850. copyright notice, this list of conditions and the following
  18851. disclaimer.
  18852. * Redistributions in binary form must reproduce the above
  18853. copyright notice, this list of conditions and the following
  18854. disclaimer in the documentation and/or other materials
  18855. provided with the distribution.
  18856. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  18857. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18858. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18859. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  18860. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  18861. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18862. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  18863. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18864. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  18865. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  18866. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  18867. SUCH DAMAGE.
  18868. ***********************************************************************/
  18869. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  18870. // only about side effects. We'll be defining this method for each node type in this module
  18871. //
  18872. // Examples:
  18873. // foo++ -> foo++
  18874. // 1 + func() -> func()
  18875. // 10 -> (nothing)
  18876. // knownPureFunc(foo++) -> foo++
  18877. function def_drop_side_effect_free(node, func) {
  18878. node.DEFMETHOD("drop_side_effect_free", func);
  18879. }
  18880. // Drop side-effect-free elements from an array of expressions.
  18881. // Returns an array of expressions with side-effects or null
  18882. // if all elements were dropped. Note: original array may be
  18883. // returned if nothing changed.
  18884. function trim(nodes, compressor, first_in_statement) {
  18885. var len = nodes.length;
  18886. if (!len) return null;
  18887. var ret = [], changed = false;
  18888. for (var i = 0; i < len; i++) {
  18889. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  18890. changed |= node !== nodes[i];
  18891. if (node) {
  18892. ret.push(node);
  18893. first_in_statement = false;
  18894. }
  18895. }
  18896. return changed ? ret.length ? ret : null : nodes;
  18897. }
  18898. def_drop_side_effect_free(AST_Node, return_this);
  18899. def_drop_side_effect_free(AST_Constant, return_null);
  18900. def_drop_side_effect_free(AST_This, return_null);
  18901. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  18902. if (this.optional && is_nullish(this.expression, compressor)) {
  18903. return make_node(AST_Undefined, this);
  18904. }
  18905. if (!this.is_callee_pure(compressor)) {
  18906. if (this.expression.is_call_pure(compressor)) {
  18907. var exprs = this.args.slice();
  18908. exprs.unshift(this.expression.expression);
  18909. exprs = trim(exprs, compressor, first_in_statement);
  18910. return exprs && make_sequence(this, exprs);
  18911. }
  18912. if (is_func_expr(this.expression)
  18913. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  18914. var node = this.clone();
  18915. node.expression.process_expression(false, compressor);
  18916. return node;
  18917. }
  18918. return this;
  18919. }
  18920. var args = trim(this.args, compressor, first_in_statement);
  18921. return args && make_sequence(this, args);
  18922. });
  18923. def_drop_side_effect_free(AST_Accessor, return_null);
  18924. def_drop_side_effect_free(AST_Function, return_null);
  18925. def_drop_side_effect_free(AST_Arrow, return_null);
  18926. def_drop_side_effect_free(AST_Class, function (compressor) {
  18927. const with_effects = [];
  18928. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  18929. if (trimmed_extends)
  18930. with_effects.push(trimmed_extends);
  18931. for (const prop of this.properties) {
  18932. const trimmed_prop = prop.drop_side_effect_free(compressor);
  18933. if (trimmed_prop)
  18934. with_effects.push(trimmed_prop);
  18935. }
  18936. if (!with_effects.length)
  18937. return null;
  18938. return make_sequence(this, with_effects);
  18939. });
  18940. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  18941. var right = this.right.drop_side_effect_free(compressor);
  18942. if (!right)
  18943. return this.left.drop_side_effect_free(compressor, first_in_statement);
  18944. if (lazy_op.has(this.operator)) {
  18945. if (right === this.right)
  18946. return this;
  18947. var node = this.clone();
  18948. node.right = right;
  18949. return node;
  18950. } else {
  18951. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  18952. if (!left)
  18953. return this.right.drop_side_effect_free(compressor, first_in_statement);
  18954. return make_sequence(this, [left, right]);
  18955. }
  18956. });
  18957. def_drop_side_effect_free(AST_Assign, function (compressor) {
  18958. if (this.logical)
  18959. return this;
  18960. var left = this.left;
  18961. if (left.has_side_effects(compressor)
  18962. || compressor.has_directive("use strict")
  18963. && left instanceof AST_PropAccess
  18964. && left.expression.is_constant()) {
  18965. return this;
  18966. }
  18967. set_flag(this, WRITE_ONLY);
  18968. while (left instanceof AST_PropAccess) {
  18969. left = left.expression;
  18970. }
  18971. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  18972. return this.right.drop_side_effect_free(compressor);
  18973. }
  18974. return this;
  18975. });
  18976. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  18977. var consequent = this.consequent.drop_side_effect_free(compressor);
  18978. var alternative = this.alternative.drop_side_effect_free(compressor);
  18979. if (consequent === this.consequent && alternative === this.alternative)
  18980. return this;
  18981. if (!consequent)
  18982. return alternative ? make_node(AST_Binary, this, {
  18983. operator: "||",
  18984. left: this.condition,
  18985. right: alternative
  18986. }) : this.condition.drop_side_effect_free(compressor);
  18987. if (!alternative)
  18988. return make_node(AST_Binary, this, {
  18989. operator: "&&",
  18990. left: this.condition,
  18991. right: consequent
  18992. });
  18993. var node = this.clone();
  18994. node.consequent = consequent;
  18995. node.alternative = alternative;
  18996. return node;
  18997. });
  18998. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  18999. if (unary_side_effects.has(this.operator)) {
  19000. if (!this.expression.has_side_effects(compressor)) {
  19001. set_flag(this, WRITE_ONLY);
  19002. } else {
  19003. clear_flag(this, WRITE_ONLY);
  19004. }
  19005. return this;
  19006. }
  19007. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  19008. return null;
  19009. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  19010. if (first_in_statement && expression && is_iife_call(expression)) {
  19011. if (expression === this.expression && this.operator == "!")
  19012. return this;
  19013. return expression.negate(compressor, first_in_statement);
  19014. }
  19015. return expression;
  19016. });
  19017. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  19018. const safe_access = this.is_declared(compressor)
  19019. || pure_prop_access_globals.has(this.name);
  19020. return safe_access ? null : this;
  19021. });
  19022. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  19023. var values = trim(this.properties, compressor, first_in_statement);
  19024. return values && make_sequence(this, values);
  19025. });
  19026. def_drop_side_effect_free(AST_ObjectProperty, function (compressor, first_in_statement) {
  19027. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  19028. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  19029. const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
  19030. if (key && value) {
  19031. return make_sequence(this, [key, value]);
  19032. }
  19033. return key || value;
  19034. });
  19035. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  19036. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  19037. const value = this.static && this.value
  19038. && this.value.drop_side_effect_free(compressor);
  19039. if (key && value)
  19040. return make_sequence(this, [key, value]);
  19041. return key || value || null;
  19042. });
  19043. def_drop_side_effect_free(AST_ConciseMethod, function () {
  19044. return this.computed_key() ? this.key : null;
  19045. });
  19046. def_drop_side_effect_free(AST_ObjectGetter, function () {
  19047. return this.computed_key() ? this.key : null;
  19048. });
  19049. def_drop_side_effect_free(AST_ObjectSetter, function () {
  19050. return this.computed_key() ? this.key : null;
  19051. });
  19052. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  19053. var values = trim(this.elements, compressor, first_in_statement);
  19054. return values && make_sequence(this, values);
  19055. });
  19056. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  19057. if (this.optional) {
  19058. return is_nullish(this.expression, compressor) ? make_node(AST_Undefined, this) : this;
  19059. }
  19060. if (this.expression.may_throw_on_access(compressor))
  19061. return this;
  19062. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  19063. });
  19064. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  19065. if (this.optional) {
  19066. return is_nullish(this.expression, compressor) ? make_node(AST_Undefined, this) : this;
  19067. }
  19068. if (this.expression.may_throw_on_access(compressor))
  19069. return this;
  19070. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  19071. if (!expression)
  19072. return this.property.drop_side_effect_free(compressor, first_in_statement);
  19073. var property = this.property.drop_side_effect_free(compressor);
  19074. if (!property)
  19075. return expression;
  19076. return make_sequence(this, [expression, property]);
  19077. });
  19078. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  19079. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  19080. });
  19081. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  19082. var last = this.tail_node();
  19083. var expr = last.drop_side_effect_free(compressor);
  19084. if (expr === last)
  19085. return this;
  19086. var expressions = this.expressions.slice(0, -1);
  19087. if (expr)
  19088. expressions.push(expr);
  19089. if (!expressions.length) {
  19090. return make_node(AST_Number, this, { value: 0 });
  19091. }
  19092. return make_sequence(this, expressions);
  19093. });
  19094. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  19095. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  19096. });
  19097. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  19098. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  19099. var values = trim(this.segments, compressor, first_in_statement);
  19100. return values && make_sequence(this, values);
  19101. });
  19102. /***********************************************************************
  19103. A JavaScript tokenizer / parser / beautifier / compressor.
  19104. https://github.com/mishoo/UglifyJS2
  19105. -------------------------------- (C) ---------------------------------
  19106. Author: Mihai Bazon
  19107. <mihai.bazon@gmail.com>
  19108. http://mihai.bazon.net/blog
  19109. Distributed under the BSD license:
  19110. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  19111. Redistribution and use in source and binary forms, with or without
  19112. modification, are permitted provided that the following conditions
  19113. are met:
  19114. * Redistributions of source code must retain the above
  19115. copyright notice, this list of conditions and the following
  19116. disclaimer.
  19117. * Redistributions in binary form must reproduce the above
  19118. copyright notice, this list of conditions and the following
  19119. disclaimer in the documentation and/or other materials
  19120. provided with the distribution.
  19121. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  19122. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19123. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19124. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  19125. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  19126. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19127. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19128. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19129. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  19130. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  19131. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  19132. SUCH DAMAGE.
  19133. ***********************************************************************/
  19134. // Define the method AST_Node#reduce_vars, which goes through the AST in
  19135. // execution order to perform basic flow analysis
  19136. function def_reduce_vars(node, func) {
  19137. node.DEFMETHOD("reduce_vars", func);
  19138. }
  19139. def_reduce_vars(AST_Node, noop);
  19140. function reset_def(compressor, def) {
  19141. def.assignments = 0;
  19142. def.chained = false;
  19143. def.direct_access = false;
  19144. def.escaped = 0;
  19145. def.recursive_refs = 0;
  19146. def.references = [];
  19147. def.single_use = undefined;
  19148. if (def.scope.pinned()) {
  19149. def.fixed = false;
  19150. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  19151. def.fixed = def.init;
  19152. } else {
  19153. def.fixed = false;
  19154. }
  19155. }
  19156. function reset_variables(tw, compressor, node) {
  19157. node.variables.forEach(function(def) {
  19158. reset_def(compressor, def);
  19159. if (def.fixed === null) {
  19160. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  19161. mark(tw, def, true);
  19162. } else if (def.fixed) {
  19163. tw.loop_ids.set(def.id, tw.in_loop);
  19164. mark(tw, def, true);
  19165. }
  19166. });
  19167. }
  19168. function reset_block_variables(compressor, node) {
  19169. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  19170. reset_def(compressor, def);
  19171. });
  19172. }
  19173. function push(tw) {
  19174. tw.safe_ids = Object.create(tw.safe_ids);
  19175. }
  19176. function pop(tw) {
  19177. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  19178. }
  19179. function mark(tw, def, safe) {
  19180. tw.safe_ids[def.id] = safe;
  19181. }
  19182. function safe_to_read(tw, def) {
  19183. if (def.single_use == "m") return false;
  19184. if (tw.safe_ids[def.id]) {
  19185. if (def.fixed == null) {
  19186. var orig = def.orig[0];
  19187. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  19188. def.fixed = make_node(AST_Undefined, orig);
  19189. }
  19190. return true;
  19191. }
  19192. return def.fixed instanceof AST_Defun;
  19193. }
  19194. function safe_to_assign(tw, def, scope, value) {
  19195. if (def.fixed === undefined) return true;
  19196. let def_safe_ids;
  19197. if (def.fixed === null
  19198. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  19199. ) {
  19200. def_safe_ids[def.id] = false;
  19201. tw.defs_to_safe_ids.delete(def.id);
  19202. return true;
  19203. }
  19204. if (!HOP(tw.safe_ids, def.id)) return false;
  19205. if (!safe_to_read(tw, def)) return false;
  19206. if (def.fixed === false) return false;
  19207. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  19208. if (def.fixed instanceof AST_Defun) {
  19209. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  19210. }
  19211. return def.orig.every((sym) => {
  19212. return !(sym instanceof AST_SymbolConst
  19213. || sym instanceof AST_SymbolDefun
  19214. || sym instanceof AST_SymbolLambda);
  19215. });
  19216. }
  19217. function ref_once(tw, compressor, def) {
  19218. return compressor.option("unused")
  19219. && !def.scope.pinned()
  19220. && def.references.length - def.recursive_refs == 1
  19221. && tw.loop_ids.get(def.id) === tw.in_loop;
  19222. }
  19223. function is_immutable(value) {
  19224. if (!value) return false;
  19225. return value.is_constant()
  19226. || value instanceof AST_Lambda
  19227. || value instanceof AST_This;
  19228. }
  19229. // A definition "escapes" when its value can leave the point of use.
  19230. // Example: `a = b || c`
  19231. // In this example, "b" and "c" are escaping, because they're going into "a"
  19232. //
  19233. // def.escaped is != 0 when it escapes.
  19234. //
  19235. // When greater than 1, it means that N chained properties will be read off
  19236. // of that def before an escape occurs. This is useful for evaluating
  19237. // property accesses, where you need to know when to stop.
  19238. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  19239. var parent = tw.parent(level);
  19240. if (value) {
  19241. if (value.is_constant()) return;
  19242. if (value instanceof AST_ClassExpression) return;
  19243. }
  19244. if (
  19245. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  19246. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  19247. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  19248. || parent instanceof AST_VarDef && node === parent.value
  19249. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  19250. ) {
  19251. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  19252. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  19253. return;
  19254. } else if (
  19255. parent instanceof AST_Array
  19256. || parent instanceof AST_Await
  19257. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  19258. || parent instanceof AST_Conditional && node !== parent.condition
  19259. || parent instanceof AST_Expansion
  19260. || parent instanceof AST_Sequence && node === parent.tail_node()
  19261. ) {
  19262. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  19263. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  19264. var obj = tw.parent(level + 1);
  19265. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  19266. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  19267. value = read_property(value, parent.property);
  19268. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  19269. if (value) return;
  19270. }
  19271. if (level > 0) return;
  19272. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  19273. if (parent instanceof AST_SimpleStatement) return;
  19274. d.direct_access = true;
  19275. }
  19276. const suppress = node => walk(node, node => {
  19277. if (!(node instanceof AST_Symbol)) return;
  19278. var d = node.definition();
  19279. if (!d) return;
  19280. if (node instanceof AST_SymbolRef) d.references.push(node);
  19281. d.fixed = false;
  19282. });
  19283. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  19284. push(tw);
  19285. reset_variables(tw, compressor, this);
  19286. descend();
  19287. pop(tw);
  19288. return true;
  19289. });
  19290. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  19291. var node = this;
  19292. if (node.left instanceof AST_Destructuring) {
  19293. suppress(node.left);
  19294. return;
  19295. }
  19296. const finish_walk = () => {
  19297. if (node.logical) {
  19298. node.left.walk(tw);
  19299. push(tw);
  19300. node.right.walk(tw);
  19301. pop(tw);
  19302. return true;
  19303. }
  19304. };
  19305. var sym = node.left;
  19306. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  19307. var def = sym.definition();
  19308. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  19309. def.assignments++;
  19310. if (!safe) return finish_walk();
  19311. var fixed = def.fixed;
  19312. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  19313. var eq = node.operator == "=";
  19314. var value = eq ? node.right : node;
  19315. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  19316. def.references.push(sym);
  19317. if (!node.logical) {
  19318. if (!eq) def.chained = true;
  19319. def.fixed = eq ? function() {
  19320. return node.right;
  19321. } : function() {
  19322. return make_node(AST_Binary, node, {
  19323. operator: node.operator.slice(0, -1),
  19324. left: fixed instanceof AST_Node ? fixed : fixed(),
  19325. right: node.right
  19326. });
  19327. };
  19328. }
  19329. if (node.logical) {
  19330. mark(tw, def, false);
  19331. push(tw);
  19332. node.right.walk(tw);
  19333. pop(tw);
  19334. return true;
  19335. }
  19336. mark(tw, def, false);
  19337. node.right.walk(tw);
  19338. mark(tw, def, true);
  19339. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  19340. return true;
  19341. });
  19342. def_reduce_vars(AST_Binary, function(tw) {
  19343. if (!lazy_op.has(this.operator)) return;
  19344. this.left.walk(tw);
  19345. push(tw);
  19346. this.right.walk(tw);
  19347. pop(tw);
  19348. return true;
  19349. });
  19350. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  19351. reset_block_variables(compressor, this);
  19352. });
  19353. def_reduce_vars(AST_Case, function(tw) {
  19354. push(tw);
  19355. this.expression.walk(tw);
  19356. pop(tw);
  19357. push(tw);
  19358. walk_body(this, tw);
  19359. pop(tw);
  19360. return true;
  19361. });
  19362. def_reduce_vars(AST_Class, function(tw, descend) {
  19363. clear_flag(this, INLINED);
  19364. push(tw);
  19365. descend();
  19366. pop(tw);
  19367. return true;
  19368. });
  19369. def_reduce_vars(AST_Conditional, function(tw) {
  19370. this.condition.walk(tw);
  19371. push(tw);
  19372. this.consequent.walk(tw);
  19373. pop(tw);
  19374. push(tw);
  19375. this.alternative.walk(tw);
  19376. pop(tw);
  19377. return true;
  19378. });
  19379. def_reduce_vars(AST_Chain, function(tw, descend) {
  19380. // Chains' conditions apply left-to-right, cumulatively.
  19381. // If we walk normally we don't go in that order because we would pop before pushing again
  19382. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  19383. // Then we pop everything when they are done being walked.
  19384. const safe_ids = tw.safe_ids;
  19385. descend();
  19386. // Unroll back to start
  19387. tw.safe_ids = safe_ids;
  19388. return true;
  19389. });
  19390. def_reduce_vars(AST_Call, function (tw) {
  19391. this.expression.walk(tw);
  19392. if (this.optional) {
  19393. // Never pop -- it's popped at AST_Chain above
  19394. push(tw);
  19395. }
  19396. for (const arg of this.args) arg.walk(tw);
  19397. return true;
  19398. });
  19399. def_reduce_vars(AST_PropAccess, function (tw) {
  19400. if (!this.optional) return;
  19401. this.expression.walk(tw);
  19402. // Never pop -- it's popped at AST_Chain above
  19403. push(tw);
  19404. if (this.property instanceof AST_Node) this.property.walk(tw);
  19405. return true;
  19406. });
  19407. def_reduce_vars(AST_Default, function(tw, descend) {
  19408. push(tw);
  19409. descend();
  19410. pop(tw);
  19411. return true;
  19412. });
  19413. function mark_lambda(tw, descend, compressor) {
  19414. clear_flag(this, INLINED);
  19415. push(tw);
  19416. reset_variables(tw, compressor, this);
  19417. if (this.uses_arguments) {
  19418. descend();
  19419. pop(tw);
  19420. return;
  19421. }
  19422. var iife;
  19423. if (!this.name
  19424. && (iife = tw.parent()) instanceof AST_Call
  19425. && iife.expression === this
  19426. && !iife.args.some(arg => arg instanceof AST_Expansion)
  19427. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  19428. ) {
  19429. // Virtually turn IIFE parameters into variable definitions:
  19430. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  19431. // So existing transformation rules can work on them.
  19432. this.argnames.forEach((arg, i) => {
  19433. if (!arg.definition) return;
  19434. var d = arg.definition();
  19435. // Avoid setting fixed when there's more than one origin for a variable value
  19436. if (d.orig.length > 1) return;
  19437. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  19438. d.fixed = function() {
  19439. return iife.args[i] || make_node(AST_Undefined, iife);
  19440. };
  19441. tw.loop_ids.set(d.id, tw.in_loop);
  19442. mark(tw, d, true);
  19443. } else {
  19444. d.fixed = false;
  19445. }
  19446. });
  19447. }
  19448. descend();
  19449. pop(tw);
  19450. return true;
  19451. }
  19452. def_reduce_vars(AST_Lambda, mark_lambda);
  19453. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  19454. reset_block_variables(compressor, this);
  19455. const saved_loop = tw.in_loop;
  19456. tw.in_loop = this;
  19457. push(tw);
  19458. this.body.walk(tw);
  19459. if (has_break_or_continue(this)) {
  19460. pop(tw);
  19461. push(tw);
  19462. }
  19463. this.condition.walk(tw);
  19464. pop(tw);
  19465. tw.in_loop = saved_loop;
  19466. return true;
  19467. });
  19468. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  19469. reset_block_variables(compressor, this);
  19470. if (this.init) this.init.walk(tw);
  19471. const saved_loop = tw.in_loop;
  19472. tw.in_loop = this;
  19473. push(tw);
  19474. if (this.condition) this.condition.walk(tw);
  19475. this.body.walk(tw);
  19476. if (this.step) {
  19477. if (has_break_or_continue(this)) {
  19478. pop(tw);
  19479. push(tw);
  19480. }
  19481. this.step.walk(tw);
  19482. }
  19483. pop(tw);
  19484. tw.in_loop = saved_loop;
  19485. return true;
  19486. });
  19487. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  19488. reset_block_variables(compressor, this);
  19489. suppress(this.init);
  19490. this.object.walk(tw);
  19491. const saved_loop = tw.in_loop;
  19492. tw.in_loop = this;
  19493. push(tw);
  19494. this.body.walk(tw);
  19495. pop(tw);
  19496. tw.in_loop = saved_loop;
  19497. return true;
  19498. });
  19499. def_reduce_vars(AST_If, function(tw) {
  19500. this.condition.walk(tw);
  19501. push(tw);
  19502. this.body.walk(tw);
  19503. pop(tw);
  19504. if (this.alternative) {
  19505. push(tw);
  19506. this.alternative.walk(tw);
  19507. pop(tw);
  19508. }
  19509. return true;
  19510. });
  19511. def_reduce_vars(AST_LabeledStatement, function(tw) {
  19512. push(tw);
  19513. this.body.walk(tw);
  19514. pop(tw);
  19515. return true;
  19516. });
  19517. def_reduce_vars(AST_SymbolCatch, function() {
  19518. this.definition().fixed = false;
  19519. });
  19520. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  19521. var d = this.definition();
  19522. d.references.push(this);
  19523. if (d.references.length == 1
  19524. && !d.fixed
  19525. && d.orig[0] instanceof AST_SymbolDefun) {
  19526. tw.loop_ids.set(d.id, tw.in_loop);
  19527. }
  19528. var fixed_value;
  19529. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  19530. d.fixed = false;
  19531. } else if (d.fixed) {
  19532. fixed_value = this.fixed_value();
  19533. if (
  19534. fixed_value instanceof AST_Lambda
  19535. && is_recursive_ref(tw, d)
  19536. ) {
  19537. d.recursive_refs++;
  19538. } else if (fixed_value
  19539. && !compressor.exposed(d)
  19540. && ref_once(tw, compressor, d)
  19541. ) {
  19542. d.single_use =
  19543. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  19544. || fixed_value instanceof AST_Class
  19545. || d.scope === this.scope && fixed_value.is_constant_expression();
  19546. } else {
  19547. d.single_use = false;
  19548. }
  19549. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  19550. if (d.single_use) {
  19551. d.single_use = "m";
  19552. } else {
  19553. d.fixed = false;
  19554. }
  19555. }
  19556. }
  19557. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  19558. });
  19559. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  19560. this.globals.forEach(function(def) {
  19561. reset_def(compressor, def);
  19562. });
  19563. reset_variables(tw, compressor, this);
  19564. });
  19565. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  19566. reset_block_variables(compressor, this);
  19567. push(tw);
  19568. walk_body(this, tw);
  19569. pop(tw);
  19570. if (this.bcatch) {
  19571. push(tw);
  19572. this.bcatch.walk(tw);
  19573. pop(tw);
  19574. }
  19575. if (this.bfinally) this.bfinally.walk(tw);
  19576. return true;
  19577. });
  19578. def_reduce_vars(AST_Unary, function(tw) {
  19579. var node = this;
  19580. if (node.operator !== "++" && node.operator !== "--") return;
  19581. var exp = node.expression;
  19582. if (!(exp instanceof AST_SymbolRef)) return;
  19583. var def = exp.definition();
  19584. var safe = safe_to_assign(tw, def, exp.scope, true);
  19585. def.assignments++;
  19586. if (!safe) return;
  19587. var fixed = def.fixed;
  19588. if (!fixed) return;
  19589. def.references.push(exp);
  19590. def.chained = true;
  19591. def.fixed = function() {
  19592. return make_node(AST_Binary, node, {
  19593. operator: node.operator.slice(0, -1),
  19594. left: make_node(AST_UnaryPrefix, node, {
  19595. operator: "+",
  19596. expression: fixed instanceof AST_Node ? fixed : fixed()
  19597. }),
  19598. right: make_node(AST_Number, node, {
  19599. value: 1
  19600. })
  19601. });
  19602. };
  19603. mark(tw, def, true);
  19604. return true;
  19605. });
  19606. def_reduce_vars(AST_VarDef, function(tw, descend) {
  19607. var node = this;
  19608. if (node.name instanceof AST_Destructuring) {
  19609. suppress(node.name);
  19610. return;
  19611. }
  19612. var d = node.name.definition();
  19613. if (node.value) {
  19614. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  19615. d.fixed = function() {
  19616. return node.value;
  19617. };
  19618. tw.loop_ids.set(d.id, tw.in_loop);
  19619. mark(tw, d, false);
  19620. descend();
  19621. mark(tw, d, true);
  19622. return true;
  19623. } else {
  19624. d.fixed = false;
  19625. }
  19626. }
  19627. });
  19628. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  19629. reset_block_variables(compressor, this);
  19630. const saved_loop = tw.in_loop;
  19631. tw.in_loop = this;
  19632. push(tw);
  19633. descend();
  19634. pop(tw);
  19635. tw.in_loop = saved_loop;
  19636. return true;
  19637. });
  19638. /***********************************************************************
  19639. A JavaScript tokenizer / parser / beautifier / compressor.
  19640. https://github.com/mishoo/UglifyJS2
  19641. -------------------------------- (C) ---------------------------------
  19642. Author: Mihai Bazon
  19643. <mihai.bazon@gmail.com>
  19644. http://mihai.bazon.net/blog
  19645. Distributed under the BSD license:
  19646. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  19647. Redistribution and use in source and binary forms, with or without
  19648. modification, are permitted provided that the following conditions
  19649. are met:
  19650. * Redistributions of source code must retain the above
  19651. copyright notice, this list of conditions and the following
  19652. disclaimer.
  19653. * Redistributions in binary form must reproduce the above
  19654. copyright notice, this list of conditions and the following
  19655. disclaimer in the documentation and/or other materials
  19656. provided with the distribution.
  19657. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  19658. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19659. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19660. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  19661. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  19662. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19663. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19664. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19665. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  19666. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  19667. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  19668. SUCH DAMAGE.
  19669. ***********************************************************************/
  19670. function loop_body(x) {
  19671. if (x instanceof AST_IterationStatement) {
  19672. return x.body instanceof AST_BlockStatement ? x.body : x;
  19673. }
  19674. return x;
  19675. }
  19676. function is_lhs_read_only(lhs) {
  19677. if (lhs instanceof AST_This) return true;
  19678. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  19679. if (lhs instanceof AST_PropAccess) {
  19680. lhs = lhs.expression;
  19681. if (lhs instanceof AST_SymbolRef) {
  19682. if (lhs.is_immutable()) return false;
  19683. lhs = lhs.fixed_value();
  19684. }
  19685. if (!lhs) return true;
  19686. if (lhs instanceof AST_RegExp) return false;
  19687. if (lhs instanceof AST_Constant) return true;
  19688. return is_lhs_read_only(lhs);
  19689. }
  19690. return false;
  19691. }
  19692. // Remove code which we know is unreachable.
  19693. function trim_unreachable_code(compressor, stat, target) {
  19694. walk(stat, node => {
  19695. if (node instanceof AST_Var) {
  19696. node.remove_initializers();
  19697. target.push(node);
  19698. return true;
  19699. }
  19700. if (
  19701. node instanceof AST_Defun
  19702. && (node === stat || !compressor.has_directive("use strict"))
  19703. ) {
  19704. target.push(node === stat ? node : make_node(AST_Var, node, {
  19705. definitions: [
  19706. make_node(AST_VarDef, node, {
  19707. name: make_node(AST_SymbolVar, node.name, node.name),
  19708. value: null
  19709. })
  19710. ]
  19711. }));
  19712. return true;
  19713. }
  19714. if (node instanceof AST_Export || node instanceof AST_Import) {
  19715. target.push(node);
  19716. return true;
  19717. }
  19718. if (node instanceof AST_Scope) {
  19719. return true;
  19720. }
  19721. });
  19722. }
  19723. // Tighten a bunch of statements together, and perform statement-level optimization.
  19724. function tighten_body(statements, compressor) {
  19725. var in_loop, in_try;
  19726. var scope = compressor.find_parent(AST_Scope).get_defun_scope();
  19727. find_loop_scope_try();
  19728. var CHANGED, max_iter = 10;
  19729. do {
  19730. CHANGED = false;
  19731. eliminate_spurious_blocks(statements);
  19732. if (compressor.option("dead_code")) {
  19733. eliminate_dead_code(statements, compressor);
  19734. }
  19735. if (compressor.option("if_return")) {
  19736. handle_if_return(statements, compressor);
  19737. }
  19738. if (compressor.sequences_limit > 0) {
  19739. sequencesize(statements, compressor);
  19740. sequencesize_2(statements, compressor);
  19741. }
  19742. if (compressor.option("join_vars")) {
  19743. join_consecutive_vars(statements);
  19744. }
  19745. if (compressor.option("collapse_vars")) {
  19746. collapse(statements, compressor);
  19747. }
  19748. } while (CHANGED && max_iter-- > 0);
  19749. function find_loop_scope_try() {
  19750. var node = compressor.self(), level = 0;
  19751. do {
  19752. if (node instanceof AST_Catch || node instanceof AST_Finally) {
  19753. level++;
  19754. } else if (node instanceof AST_IterationStatement) {
  19755. in_loop = true;
  19756. } else if (node instanceof AST_Scope) {
  19757. scope = node;
  19758. break;
  19759. } else if (node instanceof AST_Try) {
  19760. in_try = true;
  19761. }
  19762. } while (node = compressor.parent(level++));
  19763. }
  19764. // Search from right to left for assignment-like expressions:
  19765. // - `var a = x;`
  19766. // - `a = x;`
  19767. // - `++a`
  19768. // For each candidate, scan from left to right for first usage, then try
  19769. // to fold assignment into the site for compression.
  19770. // Will not attempt to collapse assignments into or past code blocks
  19771. // which are not sequentially executed, e.g. loops and conditionals.
  19772. function collapse(statements, compressor) {
  19773. if (scope.pinned())
  19774. return statements;
  19775. var args;
  19776. var candidates = [];
  19777. var stat_index = statements.length;
  19778. var scanner = new TreeTransformer(function (node) {
  19779. if (abort)
  19780. return node;
  19781. // Skip nodes before `candidate` as quickly as possible
  19782. if (!hit) {
  19783. if (node !== hit_stack[hit_index])
  19784. return node;
  19785. hit_index++;
  19786. if (hit_index < hit_stack.length)
  19787. return handle_custom_scan_order(node);
  19788. hit = true;
  19789. stop_after = find_stop(node, 0);
  19790. if (stop_after === node)
  19791. abort = true;
  19792. return node;
  19793. }
  19794. // Stop immediately if these node types are encountered
  19795. var parent = scanner.parent();
  19796. if (node instanceof AST_Assign
  19797. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  19798. || node instanceof AST_Await
  19799. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  19800. || node instanceof AST_Debugger
  19801. || node instanceof AST_Destructuring
  19802. || node instanceof AST_Expansion
  19803. && node.expression instanceof AST_Symbol
  19804. && (
  19805. node.expression instanceof AST_This
  19806. || node.expression.definition().references.length > 1
  19807. )
  19808. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  19809. || node instanceof AST_LoopControl
  19810. || node instanceof AST_Try
  19811. || node instanceof AST_With
  19812. || node instanceof AST_Yield
  19813. || node instanceof AST_Export
  19814. || node instanceof AST_Class
  19815. || parent instanceof AST_For && node !== parent.init
  19816. || !replace_all
  19817. && (
  19818. node instanceof AST_SymbolRef
  19819. && !node.is_declared(compressor)
  19820. && !pure_prop_access_globals.has(node)
  19821. )
  19822. || node instanceof AST_SymbolRef
  19823. && parent instanceof AST_Call
  19824. && has_annotation(parent, _NOINLINE)
  19825. ) {
  19826. abort = true;
  19827. return node;
  19828. }
  19829. // Stop only if candidate is found within conditional branches
  19830. if (!stop_if_hit && (!lhs_local || !replace_all)
  19831. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  19832. || parent instanceof AST_Conditional && parent.condition !== node
  19833. || parent instanceof AST_If && parent.condition !== node)) {
  19834. stop_if_hit = parent;
  19835. }
  19836. // Replace variable with assignment when found
  19837. if (can_replace
  19838. && !(node instanceof AST_SymbolDeclaration)
  19839. && lhs.equivalent_to(node)) {
  19840. if (stop_if_hit) {
  19841. abort = true;
  19842. return node;
  19843. }
  19844. if (is_lhs(node, parent)) {
  19845. if (value_def)
  19846. replaced++;
  19847. return node;
  19848. } else {
  19849. replaced++;
  19850. if (value_def && candidate instanceof AST_VarDef)
  19851. return node;
  19852. }
  19853. CHANGED = abort = true;
  19854. if (candidate instanceof AST_UnaryPostfix) {
  19855. return make_node(AST_UnaryPrefix, candidate, candidate);
  19856. }
  19857. if (candidate instanceof AST_VarDef) {
  19858. var def = candidate.name.definition();
  19859. var value = candidate.value;
  19860. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  19861. def.replaced++;
  19862. if (funarg && is_identifier_atom(value)) {
  19863. return value.transform(compressor);
  19864. } else {
  19865. return maintain_this_binding(parent, node, value);
  19866. }
  19867. }
  19868. return make_node(AST_Assign, candidate, {
  19869. operator: "=",
  19870. logical: false,
  19871. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  19872. right: value
  19873. });
  19874. }
  19875. clear_flag(candidate, WRITE_ONLY);
  19876. return candidate;
  19877. }
  19878. // These node types have child nodes that execute sequentially,
  19879. // but are otherwise not safe to scan into or beyond them.
  19880. var sym;
  19881. if (node instanceof AST_Call
  19882. || node instanceof AST_Exit
  19883. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  19884. || node instanceof AST_PropAccess
  19885. && (side_effects || node.expression.may_throw_on_access(compressor))
  19886. || node instanceof AST_SymbolRef
  19887. && (lvalues.get(node.name) || side_effects && may_modify(node))
  19888. || node instanceof AST_VarDef && node.value
  19889. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  19890. || (sym = is_lhs(node.left, node))
  19891. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  19892. || may_throw
  19893. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  19894. stop_after = node;
  19895. if (node instanceof AST_Scope)
  19896. abort = true;
  19897. }
  19898. return handle_custom_scan_order(node);
  19899. }, function (node) {
  19900. if (abort)
  19901. return;
  19902. if (stop_after === node)
  19903. abort = true;
  19904. if (stop_if_hit === node)
  19905. stop_if_hit = null;
  19906. });
  19907. var multi_replacer = new TreeTransformer(function (node) {
  19908. if (abort)
  19909. return node;
  19910. // Skip nodes before `candidate` as quickly as possible
  19911. if (!hit) {
  19912. if (node !== hit_stack[hit_index])
  19913. return node;
  19914. hit_index++;
  19915. if (hit_index < hit_stack.length)
  19916. return;
  19917. hit = true;
  19918. return node;
  19919. }
  19920. // Replace variable when found
  19921. if (node instanceof AST_SymbolRef
  19922. && node.name == def.name) {
  19923. if (!--replaced)
  19924. abort = true;
  19925. if (is_lhs(node, multi_replacer.parent()))
  19926. return node;
  19927. def.replaced++;
  19928. value_def.replaced--;
  19929. return candidate.value;
  19930. }
  19931. // Skip (non-executed) functions and (leading) default case in switch statements
  19932. if (node instanceof AST_Default || node instanceof AST_Scope)
  19933. return node;
  19934. });
  19935. while (--stat_index >= 0) {
  19936. // Treat parameters as collapsible in IIFE, i.e.
  19937. // function(a, b){ ... }(x());
  19938. // would be translated into equivalent assignments:
  19939. // var a = x(), b = undefined;
  19940. if (stat_index == 0 && compressor.option("unused"))
  19941. extract_args();
  19942. // Find collapsible assignments
  19943. var hit_stack = [];
  19944. extract_candidates(statements[stat_index]);
  19945. while (candidates.length > 0) {
  19946. hit_stack = candidates.pop();
  19947. var hit_index = 0;
  19948. var candidate = hit_stack[hit_stack.length - 1];
  19949. var value_def = null;
  19950. var stop_after = null;
  19951. var stop_if_hit = null;
  19952. var lhs = get_lhs(candidate);
  19953. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  19954. continue;
  19955. // Locate symbols which may execute code outside of scanning range
  19956. var lvalues = get_lvalues(candidate);
  19957. var lhs_local = is_lhs_local(lhs);
  19958. if (lhs instanceof AST_SymbolRef)
  19959. lvalues.set(lhs.name, false);
  19960. var side_effects = value_has_side_effects(candidate);
  19961. var replace_all = replace_all_symbols();
  19962. var may_throw = candidate.may_throw(compressor);
  19963. var funarg = candidate.name instanceof AST_SymbolFunarg;
  19964. var hit = funarg;
  19965. var abort = false, replaced = 0, can_replace = !args || !hit;
  19966. if (!can_replace) {
  19967. for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
  19968. args[j].transform(scanner);
  19969. }
  19970. can_replace = true;
  19971. }
  19972. for (var i = stat_index; !abort && i < statements.length; i++) {
  19973. statements[i].transform(scanner);
  19974. }
  19975. if (value_def) {
  19976. var def = candidate.name.definition();
  19977. if (abort && def.references.length - def.replaced > replaced)
  19978. replaced = false;
  19979. else {
  19980. abort = false;
  19981. hit_index = 0;
  19982. hit = funarg;
  19983. for (var i = stat_index; !abort && i < statements.length; i++) {
  19984. statements[i].transform(multi_replacer);
  19985. }
  19986. value_def.single_use = false;
  19987. }
  19988. }
  19989. if (replaced && !remove_candidate(candidate))
  19990. statements.splice(stat_index, 1);
  19991. }
  19992. }
  19993. function handle_custom_scan_order(node) {
  19994. // Skip (non-executed) functions
  19995. if (node instanceof AST_Scope)
  19996. return node;
  19997. // Scan case expressions first in a switch statement
  19998. if (node instanceof AST_Switch) {
  19999. node.expression = node.expression.transform(scanner);
  20000. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  20001. var branch = node.body[i];
  20002. if (branch instanceof AST_Case) {
  20003. if (!hit) {
  20004. if (branch !== hit_stack[hit_index])
  20005. continue;
  20006. hit_index++;
  20007. }
  20008. branch.expression = branch.expression.transform(scanner);
  20009. if (!replace_all)
  20010. break;
  20011. }
  20012. }
  20013. abort = true;
  20014. return node;
  20015. }
  20016. }
  20017. function redefined_within_scope(def, scope) {
  20018. if (def.global)
  20019. return false;
  20020. let cur_scope = def.scope;
  20021. while (cur_scope && cur_scope !== scope) {
  20022. if (cur_scope.variables.has(def.name))
  20023. return true;
  20024. cur_scope = cur_scope.parent_scope;
  20025. }
  20026. return false;
  20027. }
  20028. function has_overlapping_symbol(fn, arg, fn_strict) {
  20029. var found = false, scan_this = !(fn instanceof AST_Arrow);
  20030. arg.walk(new TreeWalker(function (node, descend) {
  20031. if (found)
  20032. return true;
  20033. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  20034. var s = node.definition().scope;
  20035. if (s !== scope)
  20036. while (s = s.parent_scope) {
  20037. if (s === scope)
  20038. return true;
  20039. }
  20040. return found = true;
  20041. }
  20042. if ((fn_strict || scan_this) && node instanceof AST_This) {
  20043. return found = true;
  20044. }
  20045. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  20046. var prev = scan_this;
  20047. scan_this = false;
  20048. descend();
  20049. scan_this = prev;
  20050. return true;
  20051. }
  20052. }));
  20053. return found;
  20054. }
  20055. function extract_args() {
  20056. var iife, fn = compressor.self();
  20057. if (is_func_expr(fn)
  20058. && !fn.name
  20059. && !fn.uses_arguments
  20060. && !fn.pinned()
  20061. && (iife = compressor.parent()) instanceof AST_Call
  20062. && iife.expression === fn
  20063. && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
  20064. var fn_strict = compressor.has_directive("use strict");
  20065. if (fn_strict && !member(fn_strict, fn.body))
  20066. fn_strict = false;
  20067. var len = fn.argnames.length;
  20068. args = iife.args.slice(len);
  20069. var names = new Set();
  20070. for (var i = len; --i >= 0;) {
  20071. var sym = fn.argnames[i];
  20072. var arg = iife.args[i];
  20073. // The following two line fix is a duplicate of the fix at
  20074. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  20075. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  20076. // Might be doing the exact same thing.
  20077. const def = sym.definition && sym.definition();
  20078. const is_reassigned = def && def.orig.length > 1;
  20079. if (is_reassigned)
  20080. continue;
  20081. args.unshift(make_node(AST_VarDef, sym, {
  20082. name: sym,
  20083. value: arg
  20084. }));
  20085. if (names.has(sym.name))
  20086. continue;
  20087. names.add(sym.name);
  20088. if (sym instanceof AST_Expansion) {
  20089. var elements = iife.args.slice(i);
  20090. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  20091. )) {
  20092. candidates.unshift([make_node(AST_VarDef, sym, {
  20093. name: sym.expression,
  20094. value: make_node(AST_Array, iife, {
  20095. elements: elements
  20096. })
  20097. })]);
  20098. }
  20099. } else {
  20100. if (!arg) {
  20101. arg = make_node(AST_Undefined, sym).transform(compressor);
  20102. } else if (arg instanceof AST_Lambda && arg.pinned()
  20103. || has_overlapping_symbol(fn, arg, fn_strict)) {
  20104. arg = null;
  20105. }
  20106. if (arg)
  20107. candidates.unshift([make_node(AST_VarDef, sym, {
  20108. name: sym,
  20109. value: arg
  20110. })]);
  20111. }
  20112. }
  20113. }
  20114. }
  20115. function extract_candidates(expr) {
  20116. hit_stack.push(expr);
  20117. if (expr instanceof AST_Assign) {
  20118. if (!expr.left.has_side_effects(compressor)
  20119. && !(expr.right instanceof AST_Chain)) {
  20120. candidates.push(hit_stack.slice());
  20121. }
  20122. extract_candidates(expr.right);
  20123. } else if (expr instanceof AST_Binary) {
  20124. extract_candidates(expr.left);
  20125. extract_candidates(expr.right);
  20126. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  20127. extract_candidates(expr.expression);
  20128. expr.args.forEach(extract_candidates);
  20129. } else if (expr instanceof AST_Case) {
  20130. extract_candidates(expr.expression);
  20131. } else if (expr instanceof AST_Conditional) {
  20132. extract_candidates(expr.condition);
  20133. extract_candidates(expr.consequent);
  20134. extract_candidates(expr.alternative);
  20135. } else if (expr instanceof AST_Definitions) {
  20136. var len = expr.definitions.length;
  20137. // limit number of trailing variable definitions for consideration
  20138. var i = len - 200;
  20139. if (i < 0)
  20140. i = 0;
  20141. for (; i < len; i++) {
  20142. extract_candidates(expr.definitions[i]);
  20143. }
  20144. } else if (expr instanceof AST_DWLoop) {
  20145. extract_candidates(expr.condition);
  20146. if (!(expr.body instanceof AST_Block)) {
  20147. extract_candidates(expr.body);
  20148. }
  20149. } else if (expr instanceof AST_Exit) {
  20150. if (expr.value)
  20151. extract_candidates(expr.value);
  20152. } else if (expr instanceof AST_For) {
  20153. if (expr.init)
  20154. extract_candidates(expr.init);
  20155. if (expr.condition)
  20156. extract_candidates(expr.condition);
  20157. if (expr.step)
  20158. extract_candidates(expr.step);
  20159. if (!(expr.body instanceof AST_Block)) {
  20160. extract_candidates(expr.body);
  20161. }
  20162. } else if (expr instanceof AST_ForIn) {
  20163. extract_candidates(expr.object);
  20164. if (!(expr.body instanceof AST_Block)) {
  20165. extract_candidates(expr.body);
  20166. }
  20167. } else if (expr instanceof AST_If) {
  20168. extract_candidates(expr.condition);
  20169. if (!(expr.body instanceof AST_Block)) {
  20170. extract_candidates(expr.body);
  20171. }
  20172. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  20173. extract_candidates(expr.alternative);
  20174. }
  20175. } else if (expr instanceof AST_Sequence) {
  20176. expr.expressions.forEach(extract_candidates);
  20177. } else if (expr instanceof AST_SimpleStatement) {
  20178. extract_candidates(expr.body);
  20179. } else if (expr instanceof AST_Switch) {
  20180. extract_candidates(expr.expression);
  20181. expr.body.forEach(extract_candidates);
  20182. } else if (expr instanceof AST_Unary) {
  20183. if (expr.operator == "++" || expr.operator == "--") {
  20184. candidates.push(hit_stack.slice());
  20185. }
  20186. } else if (expr instanceof AST_VarDef) {
  20187. if (expr.value && !(expr.value instanceof AST_Chain)) {
  20188. candidates.push(hit_stack.slice());
  20189. extract_candidates(expr.value);
  20190. }
  20191. }
  20192. hit_stack.pop();
  20193. }
  20194. function find_stop(node, level, write_only) {
  20195. var parent = scanner.parent(level);
  20196. if (parent instanceof AST_Assign) {
  20197. if (write_only
  20198. && !parent.logical
  20199. && !(parent.left instanceof AST_PropAccess
  20200. || lvalues.has(parent.left.name))) {
  20201. return find_stop(parent, level + 1, write_only);
  20202. }
  20203. return node;
  20204. }
  20205. if (parent instanceof AST_Binary) {
  20206. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  20207. return find_stop(parent, level + 1, write_only);
  20208. }
  20209. return node;
  20210. }
  20211. if (parent instanceof AST_Call)
  20212. return node;
  20213. if (parent instanceof AST_Case)
  20214. return node;
  20215. if (parent instanceof AST_Conditional) {
  20216. if (write_only && parent.condition === node) {
  20217. return find_stop(parent, level + 1, write_only);
  20218. }
  20219. return node;
  20220. }
  20221. if (parent instanceof AST_Definitions) {
  20222. return find_stop(parent, level + 1, true);
  20223. }
  20224. if (parent instanceof AST_Exit) {
  20225. return write_only ? find_stop(parent, level + 1, write_only) : node;
  20226. }
  20227. if (parent instanceof AST_If) {
  20228. if (write_only && parent.condition === node) {
  20229. return find_stop(parent, level + 1, write_only);
  20230. }
  20231. return node;
  20232. }
  20233. if (parent instanceof AST_IterationStatement)
  20234. return node;
  20235. if (parent instanceof AST_Sequence) {
  20236. return find_stop(parent, level + 1, parent.tail_node() !== node);
  20237. }
  20238. if (parent instanceof AST_SimpleStatement) {
  20239. return find_stop(parent, level + 1, true);
  20240. }
  20241. if (parent instanceof AST_Switch)
  20242. return node;
  20243. if (parent instanceof AST_VarDef)
  20244. return node;
  20245. return null;
  20246. }
  20247. function mangleable_var(var_def) {
  20248. var value = var_def.value;
  20249. if (!(value instanceof AST_SymbolRef))
  20250. return;
  20251. if (value.name == "arguments")
  20252. return;
  20253. var def = value.definition();
  20254. if (def.undeclared)
  20255. return;
  20256. return value_def = def;
  20257. }
  20258. function get_lhs(expr) {
  20259. if (expr instanceof AST_Assign && expr.logical) {
  20260. return false;
  20261. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  20262. var def = expr.name.definition();
  20263. if (!member(expr.name, def.orig))
  20264. return;
  20265. var referenced = def.references.length - def.replaced;
  20266. if (!referenced)
  20267. return;
  20268. var declared = def.orig.length - def.eliminated;
  20269. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  20270. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  20271. return make_node(AST_SymbolRef, expr.name, expr.name);
  20272. }
  20273. } else {
  20274. const lhs = expr instanceof AST_Assign
  20275. ? expr.left
  20276. : expr.expression;
  20277. return !is_ref_of(lhs, AST_SymbolConst)
  20278. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  20279. }
  20280. }
  20281. function get_rvalue(expr) {
  20282. if (expr instanceof AST_Assign) {
  20283. return expr.right;
  20284. } else {
  20285. return expr.value;
  20286. }
  20287. }
  20288. function get_lvalues(expr) {
  20289. var lvalues = new Map();
  20290. if (expr instanceof AST_Unary)
  20291. return lvalues;
  20292. var tw = new TreeWalker(function (node) {
  20293. var sym = node;
  20294. while (sym instanceof AST_PropAccess)
  20295. sym = sym.expression;
  20296. if (sym instanceof AST_SymbolRef || sym instanceof AST_This) {
  20297. lvalues.set(sym.name, lvalues.get(sym.name) || is_modified(compressor, tw, node, node, 0));
  20298. }
  20299. });
  20300. get_rvalue(expr).walk(tw);
  20301. return lvalues;
  20302. }
  20303. function remove_candidate(expr) {
  20304. if (expr.name instanceof AST_SymbolFunarg) {
  20305. var iife = compressor.parent(), argnames = compressor.self().argnames;
  20306. var index = argnames.indexOf(expr.name);
  20307. if (index < 0) {
  20308. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  20309. } else {
  20310. var args = iife.args;
  20311. if (args[index])
  20312. args[index] = make_node(AST_Number, args[index], {
  20313. value: 0
  20314. });
  20315. }
  20316. return true;
  20317. }
  20318. var found = false;
  20319. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  20320. if (found)
  20321. return node;
  20322. if (node === expr || node.body === expr) {
  20323. found = true;
  20324. if (node instanceof AST_VarDef) {
  20325. node.value = node.name instanceof AST_SymbolConst
  20326. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  20327. : null;
  20328. return node;
  20329. }
  20330. return in_list ? MAP.skip : null;
  20331. }
  20332. }, function (node) {
  20333. if (node instanceof AST_Sequence)
  20334. switch (node.expressions.length) {
  20335. case 0: return null;
  20336. case 1: return node.expressions[0];
  20337. }
  20338. }));
  20339. }
  20340. function is_lhs_local(lhs) {
  20341. while (lhs instanceof AST_PropAccess)
  20342. lhs = lhs.expression;
  20343. return lhs instanceof AST_SymbolRef
  20344. && lhs.definition().scope === scope
  20345. && !(in_loop
  20346. && (lvalues.has(lhs.name)
  20347. || candidate instanceof AST_Unary
  20348. || (candidate instanceof AST_Assign
  20349. && !candidate.logical
  20350. && candidate.operator != "=")));
  20351. }
  20352. function value_has_side_effects(expr) {
  20353. if (expr instanceof AST_Unary)
  20354. return unary_side_effects.has(expr.operator);
  20355. return get_rvalue(expr).has_side_effects(compressor);
  20356. }
  20357. function replace_all_symbols() {
  20358. if (side_effects)
  20359. return false;
  20360. if (value_def)
  20361. return true;
  20362. if (lhs instanceof AST_SymbolRef) {
  20363. var def = lhs.definition();
  20364. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  20365. return true;
  20366. }
  20367. }
  20368. return false;
  20369. }
  20370. function may_modify(sym) {
  20371. if (!sym.definition)
  20372. return true; // AST_Destructuring
  20373. var def = sym.definition();
  20374. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  20375. return false;
  20376. if (def.scope.get_defun_scope() !== scope)
  20377. return true;
  20378. return !def.references.every((ref) => {
  20379. var s = ref.scope.get_defun_scope();
  20380. // "block" scope within AST_Catch
  20381. if (s.TYPE == "Scope")
  20382. s = s.parent_scope;
  20383. return s === scope;
  20384. });
  20385. }
  20386. function side_effects_external(node, lhs) {
  20387. if (node instanceof AST_Assign)
  20388. return side_effects_external(node.left, true);
  20389. if (node instanceof AST_Unary)
  20390. return side_effects_external(node.expression, true);
  20391. if (node instanceof AST_VarDef)
  20392. return node.value && side_effects_external(node.value);
  20393. if (lhs) {
  20394. if (node instanceof AST_Dot)
  20395. return side_effects_external(node.expression, true);
  20396. if (node instanceof AST_Sub)
  20397. return side_effects_external(node.expression, true);
  20398. if (node instanceof AST_SymbolRef)
  20399. return node.definition().scope !== scope;
  20400. }
  20401. return false;
  20402. }
  20403. }
  20404. function eliminate_spurious_blocks(statements) {
  20405. var seen_dirs = [];
  20406. for (var i = 0; i < statements.length;) {
  20407. var stat = statements[i];
  20408. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  20409. CHANGED = true;
  20410. eliminate_spurious_blocks(stat.body);
  20411. statements.splice(i, 1, ...stat.body);
  20412. i += stat.body.length;
  20413. } else if (stat instanceof AST_EmptyStatement) {
  20414. CHANGED = true;
  20415. statements.splice(i, 1);
  20416. } else if (stat instanceof AST_Directive) {
  20417. if (seen_dirs.indexOf(stat.value) < 0) {
  20418. i++;
  20419. seen_dirs.push(stat.value);
  20420. } else {
  20421. CHANGED = true;
  20422. statements.splice(i, 1);
  20423. }
  20424. } else
  20425. i++;
  20426. }
  20427. }
  20428. function handle_if_return(statements, compressor) {
  20429. var self = compressor.self();
  20430. var multiple_if_returns = has_multiple_if_returns(statements);
  20431. var in_lambda = self instanceof AST_Lambda;
  20432. for (var i = statements.length; --i >= 0;) {
  20433. var stat = statements[i];
  20434. var j = next_index(i);
  20435. var next = statements[j];
  20436. if (in_lambda && !next && stat instanceof AST_Return) {
  20437. if (!stat.value) {
  20438. CHANGED = true;
  20439. statements.splice(i, 1);
  20440. continue;
  20441. }
  20442. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  20443. CHANGED = true;
  20444. statements[i] = make_node(AST_SimpleStatement, stat, {
  20445. body: stat.value.expression
  20446. });
  20447. continue;
  20448. }
  20449. }
  20450. if (stat instanceof AST_If) {
  20451. var ab = aborts(stat.body);
  20452. if (can_merge_flow(ab)) {
  20453. if (ab.label) {
  20454. remove(ab.label.thedef.references, ab);
  20455. }
  20456. CHANGED = true;
  20457. stat = stat.clone();
  20458. stat.condition = stat.condition.negate(compressor);
  20459. var body = as_statement_array_with_return(stat.body, ab);
  20460. stat.body = make_node(AST_BlockStatement, stat, {
  20461. body: as_statement_array(stat.alternative).concat(extract_functions())
  20462. });
  20463. stat.alternative = make_node(AST_BlockStatement, stat, {
  20464. body: body
  20465. });
  20466. statements[i] = stat.transform(compressor);
  20467. continue;
  20468. }
  20469. var ab = aborts(stat.alternative);
  20470. if (can_merge_flow(ab)) {
  20471. if (ab.label) {
  20472. remove(ab.label.thedef.references, ab);
  20473. }
  20474. CHANGED = true;
  20475. stat = stat.clone();
  20476. stat.body = make_node(AST_BlockStatement, stat.body, {
  20477. body: as_statement_array(stat.body).concat(extract_functions())
  20478. });
  20479. var body = as_statement_array_with_return(stat.alternative, ab);
  20480. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  20481. body: body
  20482. });
  20483. statements[i] = stat.transform(compressor);
  20484. continue;
  20485. }
  20486. }
  20487. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  20488. var value = stat.body.value;
  20489. //---
  20490. // pretty silly case, but:
  20491. // if (foo()) return; return; ==> foo(); return;
  20492. if (!value && !stat.alternative
  20493. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  20494. CHANGED = true;
  20495. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  20496. body: stat.condition
  20497. });
  20498. continue;
  20499. }
  20500. //---
  20501. // if (foo()) return x; return y; ==> return foo() ? x : y;
  20502. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  20503. CHANGED = true;
  20504. stat = stat.clone();
  20505. stat.alternative = next;
  20506. statements[i] = stat.transform(compressor);
  20507. statements.splice(j, 1);
  20508. continue;
  20509. }
  20510. //---
  20511. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  20512. if (value && !stat.alternative
  20513. && (!next && in_lambda && multiple_if_returns
  20514. || next instanceof AST_Return)) {
  20515. CHANGED = true;
  20516. stat = stat.clone();
  20517. stat.alternative = next || make_node(AST_Return, stat, {
  20518. value: null
  20519. });
  20520. statements[i] = stat.transform(compressor);
  20521. if (next)
  20522. statements.splice(j, 1);
  20523. continue;
  20524. }
  20525. //---
  20526. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  20527. //
  20528. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  20529. // however, with sequences on this helps producing slightly better output for
  20530. // the example code.
  20531. var prev = statements[prev_index(i)];
  20532. if (compressor.option("sequences") && in_lambda && !stat.alternative
  20533. && prev instanceof AST_If && prev.body instanceof AST_Return
  20534. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  20535. CHANGED = true;
  20536. stat = stat.clone();
  20537. stat.alternative = make_node(AST_BlockStatement, next, {
  20538. body: [
  20539. next,
  20540. make_node(AST_Return, next, {
  20541. value: null
  20542. })
  20543. ]
  20544. });
  20545. statements[i] = stat.transform(compressor);
  20546. statements.splice(j, 1);
  20547. continue;
  20548. }
  20549. }
  20550. }
  20551. function has_multiple_if_returns(statements) {
  20552. var n = 0;
  20553. for (var i = statements.length; --i >= 0;) {
  20554. var stat = statements[i];
  20555. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  20556. if (++n > 1)
  20557. return true;
  20558. }
  20559. }
  20560. return false;
  20561. }
  20562. function is_return_void(value) {
  20563. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  20564. }
  20565. function can_merge_flow(ab) {
  20566. if (!ab)
  20567. return false;
  20568. for (var j = i + 1, len = statements.length; j < len; j++) {
  20569. var stat = statements[j];
  20570. if (stat instanceof AST_Const || stat instanceof AST_Let)
  20571. return false;
  20572. }
  20573. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  20574. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  20575. || ab instanceof AST_Continue && self === loop_body(lct)
  20576. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  20577. }
  20578. function extract_functions() {
  20579. var tail = statements.slice(i + 1);
  20580. statements.length = i + 1;
  20581. return tail.filter(function (stat) {
  20582. if (stat instanceof AST_Defun) {
  20583. statements.push(stat);
  20584. return false;
  20585. }
  20586. return true;
  20587. });
  20588. }
  20589. function as_statement_array_with_return(node, ab) {
  20590. var body = as_statement_array(node).slice(0, -1);
  20591. if (ab.value) {
  20592. body.push(make_node(AST_SimpleStatement, ab.value, {
  20593. body: ab.value.expression
  20594. }));
  20595. }
  20596. return body;
  20597. }
  20598. function next_index(i) {
  20599. for (var j = i + 1, len = statements.length; j < len; j++) {
  20600. var stat = statements[j];
  20601. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  20602. break;
  20603. }
  20604. }
  20605. return j;
  20606. }
  20607. function prev_index(i) {
  20608. for (var j = i; --j >= 0;) {
  20609. var stat = statements[j];
  20610. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  20611. break;
  20612. }
  20613. }
  20614. return j;
  20615. }
  20616. }
  20617. function eliminate_dead_code(statements, compressor) {
  20618. var has_quit;
  20619. var self = compressor.self();
  20620. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  20621. var stat = statements[i];
  20622. if (stat instanceof AST_LoopControl) {
  20623. var lct = compressor.loopcontrol_target(stat);
  20624. if (stat instanceof AST_Break
  20625. && !(lct instanceof AST_IterationStatement)
  20626. && loop_body(lct) === self
  20627. || stat instanceof AST_Continue
  20628. && loop_body(lct) === self) {
  20629. if (stat.label) {
  20630. remove(stat.label.thedef.references, stat);
  20631. }
  20632. } else {
  20633. statements[n++] = stat;
  20634. }
  20635. } else {
  20636. statements[n++] = stat;
  20637. }
  20638. if (aborts(stat)) {
  20639. has_quit = statements.slice(i + 1);
  20640. break;
  20641. }
  20642. }
  20643. statements.length = n;
  20644. CHANGED = n != len;
  20645. if (has_quit)
  20646. has_quit.forEach(function (stat) {
  20647. trim_unreachable_code(compressor, stat, statements);
  20648. });
  20649. }
  20650. function declarations_only(node) {
  20651. return node.definitions.every((var_def) => !var_def.value
  20652. );
  20653. }
  20654. function sequencesize(statements, compressor) {
  20655. if (statements.length < 2)
  20656. return;
  20657. var seq = [], n = 0;
  20658. function push_seq() {
  20659. if (!seq.length)
  20660. return;
  20661. var body = make_sequence(seq[0], seq);
  20662. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  20663. seq = [];
  20664. }
  20665. for (var i = 0, len = statements.length; i < len; i++) {
  20666. var stat = statements[i];
  20667. if (stat instanceof AST_SimpleStatement) {
  20668. if (seq.length >= compressor.sequences_limit)
  20669. push_seq();
  20670. var body = stat.body;
  20671. if (seq.length > 0)
  20672. body = body.drop_side_effect_free(compressor);
  20673. if (body)
  20674. merge_sequence(seq, body);
  20675. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  20676. || stat instanceof AST_Defun) {
  20677. statements[n++] = stat;
  20678. } else {
  20679. push_seq();
  20680. statements[n++] = stat;
  20681. }
  20682. }
  20683. push_seq();
  20684. statements.length = n;
  20685. if (n != len)
  20686. CHANGED = true;
  20687. }
  20688. function to_simple_statement(block, decls) {
  20689. if (!(block instanceof AST_BlockStatement))
  20690. return block;
  20691. var stat = null;
  20692. for (var i = 0, len = block.body.length; i < len; i++) {
  20693. var line = block.body[i];
  20694. if (line instanceof AST_Var && declarations_only(line)) {
  20695. decls.push(line);
  20696. } else if (stat) {
  20697. return false;
  20698. } else {
  20699. stat = line;
  20700. }
  20701. }
  20702. return stat;
  20703. }
  20704. function sequencesize_2(statements, compressor) {
  20705. function cons_seq(right) {
  20706. n--;
  20707. CHANGED = true;
  20708. var left = prev.body;
  20709. return make_sequence(left, [left, right]).transform(compressor);
  20710. }
  20711. var n = 0, prev;
  20712. for (var i = 0; i < statements.length; i++) {
  20713. var stat = statements[i];
  20714. if (prev) {
  20715. if (stat instanceof AST_Exit) {
  20716. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  20717. } else if (stat instanceof AST_For) {
  20718. if (!(stat.init instanceof AST_Definitions)) {
  20719. const abort = walk(prev.body, node => {
  20720. if (node instanceof AST_Scope)
  20721. return true;
  20722. if (node instanceof AST_Binary
  20723. && node.operator === "in") {
  20724. return walk_abort;
  20725. }
  20726. });
  20727. if (!abort) {
  20728. if (stat.init)
  20729. stat.init = cons_seq(stat.init);
  20730. else {
  20731. stat.init = prev.body;
  20732. n--;
  20733. CHANGED = true;
  20734. }
  20735. }
  20736. }
  20737. } else if (stat instanceof AST_ForIn) {
  20738. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  20739. stat.object = cons_seq(stat.object);
  20740. }
  20741. } else if (stat instanceof AST_If) {
  20742. stat.condition = cons_seq(stat.condition);
  20743. } else if (stat instanceof AST_Switch) {
  20744. stat.expression = cons_seq(stat.expression);
  20745. } else if (stat instanceof AST_With) {
  20746. stat.expression = cons_seq(stat.expression);
  20747. }
  20748. }
  20749. if (compressor.option("conditionals") && stat instanceof AST_If) {
  20750. var decls = [];
  20751. var body = to_simple_statement(stat.body, decls);
  20752. var alt = to_simple_statement(stat.alternative, decls);
  20753. if (body !== false && alt !== false && decls.length > 0) {
  20754. var len = decls.length;
  20755. decls.push(make_node(AST_If, stat, {
  20756. condition: stat.condition,
  20757. body: body || make_node(AST_EmptyStatement, stat.body),
  20758. alternative: alt
  20759. }));
  20760. decls.unshift(n, 1);
  20761. [].splice.apply(statements, decls);
  20762. i += len;
  20763. n += len + 1;
  20764. prev = null;
  20765. CHANGED = true;
  20766. continue;
  20767. }
  20768. }
  20769. statements[n++] = stat;
  20770. prev = stat instanceof AST_SimpleStatement ? stat : null;
  20771. }
  20772. statements.length = n;
  20773. }
  20774. function join_object_assignments(defn, body) {
  20775. if (!(defn instanceof AST_Definitions))
  20776. return;
  20777. var def = defn.definitions[defn.definitions.length - 1];
  20778. if (!(def.value instanceof AST_Object))
  20779. return;
  20780. var exprs;
  20781. if (body instanceof AST_Assign && !body.logical) {
  20782. exprs = [body];
  20783. } else if (body instanceof AST_Sequence) {
  20784. exprs = body.expressions.slice();
  20785. }
  20786. if (!exprs)
  20787. return;
  20788. var trimmed = false;
  20789. do {
  20790. var node = exprs[0];
  20791. if (!(node instanceof AST_Assign))
  20792. break;
  20793. if (node.operator != "=")
  20794. break;
  20795. if (!(node.left instanceof AST_PropAccess))
  20796. break;
  20797. var sym = node.left.expression;
  20798. if (!(sym instanceof AST_SymbolRef))
  20799. break;
  20800. if (def.name.name != sym.name)
  20801. break;
  20802. if (!node.right.is_constant_expression(scope))
  20803. break;
  20804. var prop = node.left.property;
  20805. if (prop instanceof AST_Node) {
  20806. prop = prop.evaluate(compressor);
  20807. }
  20808. if (prop instanceof AST_Node)
  20809. break;
  20810. prop = "" + prop;
  20811. var diff = compressor.option("ecma") < 2015
  20812. && compressor.has_directive("use strict") ? function (node) {
  20813. return node.key != prop && (node.key && node.key.name != prop);
  20814. } : function (node) {
  20815. return node.key && node.key.name != prop;
  20816. };
  20817. if (!def.value.properties.every(diff))
  20818. break;
  20819. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  20820. if (!p) {
  20821. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  20822. key: prop,
  20823. value: node.right
  20824. }));
  20825. } else {
  20826. p.value = new AST_Sequence({
  20827. start: p.start,
  20828. expressions: [p.value.clone(), node.right.clone()],
  20829. end: p.end
  20830. });
  20831. }
  20832. exprs.shift();
  20833. trimmed = true;
  20834. } while (exprs.length);
  20835. return trimmed && exprs;
  20836. }
  20837. function join_consecutive_vars(statements) {
  20838. var defs;
  20839. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  20840. var stat = statements[i];
  20841. var prev = statements[j];
  20842. if (stat instanceof AST_Definitions) {
  20843. if (prev && prev.TYPE == stat.TYPE) {
  20844. prev.definitions = prev.definitions.concat(stat.definitions);
  20845. CHANGED = true;
  20846. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  20847. defs.definitions = defs.definitions.concat(stat.definitions);
  20848. CHANGED = true;
  20849. } else {
  20850. statements[++j] = stat;
  20851. defs = stat;
  20852. }
  20853. } else if (stat instanceof AST_Exit) {
  20854. stat.value = extract_object_assignments(stat.value);
  20855. } else if (stat instanceof AST_For) {
  20856. var exprs = join_object_assignments(prev, stat.init);
  20857. if (exprs) {
  20858. CHANGED = true;
  20859. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  20860. statements[++j] = stat;
  20861. } else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  20862. if (stat.init) {
  20863. prev.definitions = prev.definitions.concat(stat.init.definitions);
  20864. }
  20865. stat.init = prev;
  20866. statements[j] = stat;
  20867. CHANGED = true;
  20868. } else if (defs && stat.init && defs.TYPE == stat.init.TYPE && declarations_only(stat.init)) {
  20869. defs.definitions = defs.definitions.concat(stat.init.definitions);
  20870. stat.init = null;
  20871. statements[++j] = stat;
  20872. CHANGED = true;
  20873. } else {
  20874. statements[++j] = stat;
  20875. }
  20876. } else if (stat instanceof AST_ForIn) {
  20877. stat.object = extract_object_assignments(stat.object);
  20878. } else if (stat instanceof AST_If) {
  20879. stat.condition = extract_object_assignments(stat.condition);
  20880. } else if (stat instanceof AST_SimpleStatement) {
  20881. var exprs = join_object_assignments(prev, stat.body);
  20882. if (exprs) {
  20883. CHANGED = true;
  20884. if (!exprs.length)
  20885. continue;
  20886. stat.body = make_sequence(stat.body, exprs);
  20887. }
  20888. statements[++j] = stat;
  20889. } else if (stat instanceof AST_Switch) {
  20890. stat.expression = extract_object_assignments(stat.expression);
  20891. } else if (stat instanceof AST_With) {
  20892. stat.expression = extract_object_assignments(stat.expression);
  20893. } else {
  20894. statements[++j] = stat;
  20895. }
  20896. }
  20897. statements.length = j + 1;
  20898. function extract_object_assignments(value) {
  20899. statements[++j] = stat;
  20900. var exprs = join_object_assignments(prev, value);
  20901. if (exprs) {
  20902. CHANGED = true;
  20903. if (exprs.length) {
  20904. return make_sequence(value, exprs);
  20905. } else if (value instanceof AST_Sequence) {
  20906. return value.tail_node().left;
  20907. } else {
  20908. return value.left;
  20909. }
  20910. }
  20911. return value;
  20912. }
  20913. }
  20914. }
  20915. /***********************************************************************
  20916. A JavaScript tokenizer / parser / beautifier / compressor.
  20917. https://github.com/mishoo/UglifyJS2
  20918. -------------------------------- (C) ---------------------------------
  20919. Author: Mihai Bazon
  20920. <mihai.bazon@gmail.com>
  20921. http://mihai.bazon.net/blog
  20922. Distributed under the BSD license:
  20923. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  20924. Redistribution and use in source and binary forms, with or without
  20925. modification, are permitted provided that the following conditions
  20926. are met:
  20927. * Redistributions of source code must retain the above
  20928. copyright notice, this list of conditions and the following
  20929. disclaimer.
  20930. * Redistributions in binary form must reproduce the above
  20931. copyright notice, this list of conditions and the following
  20932. disclaimer in the documentation and/or other materials
  20933. provided with the distribution.
  20934. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  20935. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20936. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20937. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  20938. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  20939. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20940. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20941. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20942. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  20943. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  20944. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  20945. SUCH DAMAGE.
  20946. ***********************************************************************/
  20947. class Compressor extends TreeWalker {
  20948. constructor(options, { false_by_default = false, mangle_options = false }) {
  20949. super();
  20950. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  20951. this.options = defaults(options, {
  20952. arguments : false,
  20953. arrows : !false_by_default,
  20954. booleans : !false_by_default,
  20955. booleans_as_integers : false,
  20956. collapse_vars : !false_by_default,
  20957. comparisons : !false_by_default,
  20958. computed_props: !false_by_default,
  20959. conditionals : !false_by_default,
  20960. dead_code : !false_by_default,
  20961. defaults : true,
  20962. directives : !false_by_default,
  20963. drop_console : false,
  20964. drop_debugger : !false_by_default,
  20965. ecma : 5,
  20966. evaluate : !false_by_default,
  20967. expression : false,
  20968. global_defs : false,
  20969. hoist_funs : false,
  20970. hoist_props : !false_by_default,
  20971. hoist_vars : false,
  20972. ie8 : false,
  20973. if_return : !false_by_default,
  20974. inline : !false_by_default,
  20975. join_vars : !false_by_default,
  20976. keep_classnames: false,
  20977. keep_fargs : true,
  20978. keep_fnames : false,
  20979. keep_infinity : false,
  20980. loops : !false_by_default,
  20981. module : false,
  20982. negate_iife : !false_by_default,
  20983. passes : 1,
  20984. properties : !false_by_default,
  20985. pure_getters : !false_by_default && "strict",
  20986. pure_funcs : null,
  20987. reduce_funcs : !false_by_default,
  20988. reduce_vars : !false_by_default,
  20989. sequences : !false_by_default,
  20990. side_effects : !false_by_default,
  20991. switches : !false_by_default,
  20992. top_retain : null,
  20993. toplevel : !!(options && options["top_retain"]),
  20994. typeofs : !false_by_default,
  20995. unsafe : false,
  20996. unsafe_arrows : false,
  20997. unsafe_comps : false,
  20998. unsafe_Function: false,
  20999. unsafe_math : false,
  21000. unsafe_symbols: false,
  21001. unsafe_methods: false,
  21002. unsafe_proto : false,
  21003. unsafe_regexp : false,
  21004. unsafe_undefined: false,
  21005. unused : !false_by_default,
  21006. warnings : false // legacy
  21007. }, true);
  21008. var global_defs = this.options["global_defs"];
  21009. if (typeof global_defs == "object") for (var key in global_defs) {
  21010. if (key[0] === "@" && HOP(global_defs, key)) {
  21011. global_defs[key.slice(1)] = parse(global_defs[key], {
  21012. expression: true
  21013. });
  21014. }
  21015. }
  21016. if (this.options["inline"] === true) this.options["inline"] = 3;
  21017. var pure_funcs = this.options["pure_funcs"];
  21018. if (typeof pure_funcs == "function") {
  21019. this.pure_funcs = pure_funcs;
  21020. } else {
  21021. this.pure_funcs = pure_funcs ? function(node) {
  21022. return !pure_funcs.includes(node.expression.print_to_string());
  21023. } : return_true;
  21024. }
  21025. var top_retain = this.options["top_retain"];
  21026. if (top_retain instanceof RegExp) {
  21027. this.top_retain = function(def) {
  21028. return top_retain.test(def.name);
  21029. };
  21030. } else if (typeof top_retain == "function") {
  21031. this.top_retain = top_retain;
  21032. } else if (top_retain) {
  21033. if (typeof top_retain == "string") {
  21034. top_retain = top_retain.split(/,/);
  21035. }
  21036. this.top_retain = function(def) {
  21037. return top_retain.includes(def.name);
  21038. };
  21039. }
  21040. if (this.options["module"]) {
  21041. this.directives["use strict"] = true;
  21042. this.options["toplevel"] = true;
  21043. }
  21044. var toplevel = this.options["toplevel"];
  21045. this.toplevel = typeof toplevel == "string" ? {
  21046. funcs: /funcs/.test(toplevel),
  21047. vars: /vars/.test(toplevel)
  21048. } : {
  21049. funcs: toplevel,
  21050. vars: toplevel
  21051. };
  21052. var sequences = this.options["sequences"];
  21053. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  21054. this.evaluated_regexps = new Map();
  21055. this._toplevel = undefined;
  21056. this.mangle_options = mangle_options;
  21057. }
  21058. option(key) {
  21059. return this.options[key];
  21060. }
  21061. exposed(def) {
  21062. if (def.export) return true;
  21063. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  21064. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  21065. return true;
  21066. return false;
  21067. }
  21068. in_boolean_context() {
  21069. if (!this.option("booleans")) return false;
  21070. var self = this.self();
  21071. for (var i = 0, p; p = this.parent(i); i++) {
  21072. if (p instanceof AST_SimpleStatement
  21073. || p instanceof AST_Conditional && p.condition === self
  21074. || p instanceof AST_DWLoop && p.condition === self
  21075. || p instanceof AST_For && p.condition === self
  21076. || p instanceof AST_If && p.condition === self
  21077. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  21078. return true;
  21079. }
  21080. if (
  21081. p instanceof AST_Binary
  21082. && (
  21083. p.operator == "&&"
  21084. || p.operator == "||"
  21085. || p.operator == "??"
  21086. )
  21087. || p instanceof AST_Conditional
  21088. || p.tail_node() === self
  21089. ) {
  21090. self = p;
  21091. } else {
  21092. return false;
  21093. }
  21094. }
  21095. }
  21096. get_toplevel() {
  21097. return this._toplevel;
  21098. }
  21099. compress(toplevel) {
  21100. toplevel = toplevel.resolve_defines(this);
  21101. this._toplevel = toplevel;
  21102. if (this.option("expression")) {
  21103. this._toplevel.process_expression(true);
  21104. }
  21105. var passes = +this.options.passes || 1;
  21106. var min_count = 1 / 0;
  21107. var stopping = false;
  21108. var mangle = { ie8: this.option("ie8") };
  21109. for (var pass = 0; pass < passes; pass++) {
  21110. this._toplevel.figure_out_scope(mangle);
  21111. if (pass === 0 && this.option("drop_console")) {
  21112. // must be run before reduce_vars and compress pass
  21113. this._toplevel = this._toplevel.drop_console();
  21114. }
  21115. if (pass > 0 || this.option("reduce_vars")) {
  21116. this._toplevel.reset_opt_flags(this);
  21117. }
  21118. this._toplevel = this._toplevel.transform(this);
  21119. if (passes > 1) {
  21120. let count = 0;
  21121. walk(this._toplevel, () => { count++; });
  21122. if (count < min_count) {
  21123. min_count = count;
  21124. stopping = false;
  21125. } else if (stopping) {
  21126. break;
  21127. } else {
  21128. stopping = true;
  21129. }
  21130. }
  21131. }
  21132. if (this.option("expression")) {
  21133. this._toplevel.process_expression(false);
  21134. }
  21135. toplevel = this._toplevel;
  21136. this._toplevel = undefined;
  21137. return toplevel;
  21138. }
  21139. before(node, descend) {
  21140. if (has_flag(node, SQUEEZED)) return node;
  21141. var was_scope = false;
  21142. if (node instanceof AST_Scope) {
  21143. node = node.hoist_properties(this);
  21144. node = node.hoist_declarations(this);
  21145. was_scope = true;
  21146. }
  21147. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  21148. // would call AST_Node.transform() if a different instance of AST_Node is
  21149. // produced after def_optimize().
  21150. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  21151. // Migrate and defer all children's AST_Node.transform() to below, which
  21152. // will now happen after this parent AST_Node has been properly substituted
  21153. // thus gives a consistent AST snapshot.
  21154. descend(node, this);
  21155. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  21156. // following replacement call would result in degraded efficiency of both
  21157. // output and performance.
  21158. descend(node, this);
  21159. var opt = node.optimize(this);
  21160. if (was_scope && opt instanceof AST_Scope) {
  21161. opt.drop_unused(this);
  21162. descend(opt, this);
  21163. }
  21164. if (opt === node) set_flag(opt, SQUEEZED);
  21165. return opt;
  21166. }
  21167. }
  21168. function def_optimize(node, optimizer) {
  21169. node.DEFMETHOD("optimize", function(compressor) {
  21170. var self = this;
  21171. if (has_flag(self, OPTIMIZED)) return self;
  21172. if (compressor.has_directive("use asm")) return self;
  21173. var opt = optimizer(self, compressor);
  21174. set_flag(opt, OPTIMIZED);
  21175. return opt;
  21176. });
  21177. }
  21178. def_optimize(AST_Node, function(self) {
  21179. return self;
  21180. });
  21181. AST_Toplevel.DEFMETHOD("drop_console", function() {
  21182. return this.transform(new TreeTransformer(function(self) {
  21183. if (self.TYPE == "Call") {
  21184. var exp = self.expression;
  21185. if (exp instanceof AST_PropAccess) {
  21186. var name = exp.expression;
  21187. while (name.expression) {
  21188. name = name.expression;
  21189. }
  21190. if (is_undeclared_ref(name) && name.name == "console") {
  21191. return make_node(AST_Undefined, self);
  21192. }
  21193. }
  21194. }
  21195. }));
  21196. });
  21197. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  21198. return equivalent_to(this, node);
  21199. });
  21200. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  21201. var self = this;
  21202. var tt = new TreeTransformer(function(node) {
  21203. if (insert && node instanceof AST_SimpleStatement) {
  21204. return make_node(AST_Return, node, {
  21205. value: node.body
  21206. });
  21207. }
  21208. if (!insert && node instanceof AST_Return) {
  21209. if (compressor) {
  21210. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  21211. return value
  21212. ? make_node(AST_SimpleStatement, node, { body: value })
  21213. : make_node(AST_EmptyStatement, node);
  21214. }
  21215. return make_node(AST_SimpleStatement, node, {
  21216. body: node.value || make_node(AST_UnaryPrefix, node, {
  21217. operator: "void",
  21218. expression: make_node(AST_Number, node, {
  21219. value: 0
  21220. })
  21221. })
  21222. });
  21223. }
  21224. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  21225. return node;
  21226. }
  21227. if (node instanceof AST_Block) {
  21228. var index = node.body.length - 1;
  21229. if (index >= 0) {
  21230. node.body[index] = node.body[index].transform(tt);
  21231. }
  21232. } else if (node instanceof AST_If) {
  21233. node.body = node.body.transform(tt);
  21234. if (node.alternative) {
  21235. node.alternative = node.alternative.transform(tt);
  21236. }
  21237. } else if (node instanceof AST_With) {
  21238. node.body = node.body.transform(tt);
  21239. }
  21240. return node;
  21241. });
  21242. self.transform(tt);
  21243. });
  21244. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  21245. const self = this;
  21246. const reduce_vars = compressor.option("reduce_vars");
  21247. const preparation = new TreeWalker(function(node, descend) {
  21248. clear_flag(node, CLEAR_BETWEEN_PASSES);
  21249. if (reduce_vars) {
  21250. if (compressor.top_retain
  21251. && node instanceof AST_Defun // Only functions are retained
  21252. && preparation.parent() === self
  21253. ) {
  21254. set_flag(node, TOP);
  21255. }
  21256. return node.reduce_vars(preparation, descend, compressor);
  21257. }
  21258. });
  21259. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  21260. // properly assigned before use:
  21261. // - `push()` & `pop()` when visiting conditional branches
  21262. preparation.safe_ids = Object.create(null);
  21263. preparation.in_loop = null;
  21264. preparation.loop_ids = new Map();
  21265. preparation.defs_to_safe_ids = new Map();
  21266. self.walk(preparation);
  21267. });
  21268. AST_Symbol.DEFMETHOD("fixed_value", function() {
  21269. var fixed = this.thedef.fixed;
  21270. if (!fixed || fixed instanceof AST_Node) return fixed;
  21271. return fixed();
  21272. });
  21273. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  21274. var orig = this.definition().orig;
  21275. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  21276. });
  21277. function find_scope(tw) {
  21278. for (let i = 0;;i++) {
  21279. const p = tw.parent(i);
  21280. if (p instanceof AST_Toplevel) return p;
  21281. if (p instanceof AST_Lambda) return p;
  21282. if (p.block_scope) return p.block_scope;
  21283. }
  21284. }
  21285. function find_variable(compressor, name) {
  21286. var scope, i = 0;
  21287. while (scope = compressor.parent(i++)) {
  21288. if (scope instanceof AST_Scope) break;
  21289. if (scope instanceof AST_Catch && scope.argname) {
  21290. scope = scope.argname.definition().scope;
  21291. break;
  21292. }
  21293. }
  21294. return scope.find_variable(name);
  21295. }
  21296. function is_empty(thing) {
  21297. if (thing === null) return true;
  21298. if (thing instanceof AST_EmptyStatement) return true;
  21299. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  21300. return false;
  21301. }
  21302. 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");
  21303. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  21304. return !this.definition().undeclared
  21305. || compressor.option("unsafe") && global_names.has(this.name);
  21306. });
  21307. /* -----[ optimizers ]----- */
  21308. var directives = new Set(["use asm", "use strict"]);
  21309. def_optimize(AST_Directive, function(self, compressor) {
  21310. if (compressor.option("directives")
  21311. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  21312. return make_node(AST_EmptyStatement, self);
  21313. }
  21314. return self;
  21315. });
  21316. def_optimize(AST_Debugger, function(self, compressor) {
  21317. if (compressor.option("drop_debugger"))
  21318. return make_node(AST_EmptyStatement, self);
  21319. return self;
  21320. });
  21321. def_optimize(AST_LabeledStatement, function(self, compressor) {
  21322. if (self.body instanceof AST_Break
  21323. && compressor.loopcontrol_target(self.body) === self.body) {
  21324. return make_node(AST_EmptyStatement, self);
  21325. }
  21326. return self.label.references.length == 0 ? self.body : self;
  21327. });
  21328. def_optimize(AST_Block, function(self, compressor) {
  21329. tighten_body(self.body, compressor);
  21330. return self;
  21331. });
  21332. function can_be_extracted_from_if_block(node) {
  21333. return !(
  21334. node instanceof AST_Const
  21335. || node instanceof AST_Let
  21336. || node instanceof AST_Class
  21337. );
  21338. }
  21339. def_optimize(AST_BlockStatement, function(self, compressor) {
  21340. tighten_body(self.body, compressor);
  21341. switch (self.body.length) {
  21342. case 1:
  21343. if (!compressor.has_directive("use strict")
  21344. && compressor.parent() instanceof AST_If
  21345. && can_be_extracted_from_if_block(self.body[0])
  21346. || can_be_evicted_from_block(self.body[0])) {
  21347. return self.body[0];
  21348. }
  21349. break;
  21350. case 0: return make_node(AST_EmptyStatement, self);
  21351. }
  21352. return self;
  21353. });
  21354. function opt_AST_Lambda(self, compressor) {
  21355. tighten_body(self.body, compressor);
  21356. if (compressor.option("side_effects")
  21357. && self.body.length == 1
  21358. && self.body[0] === compressor.has_directive("use strict")) {
  21359. self.body.length = 0;
  21360. }
  21361. return self;
  21362. }
  21363. def_optimize(AST_Lambda, opt_AST_Lambda);
  21364. const r_keep_assign = /keep_assign/;
  21365. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  21366. if (!compressor.option("unused")) return;
  21367. if (compressor.has_directive("use asm")) return;
  21368. var self = this;
  21369. if (self.pinned()) return;
  21370. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  21371. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  21372. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  21373. if (node instanceof AST_Assign
  21374. && !node.logical
  21375. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  21376. ) {
  21377. return node.left;
  21378. }
  21379. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  21380. return node.expression;
  21381. }
  21382. };
  21383. var in_use_ids = new Map();
  21384. var fixed_ids = new Map();
  21385. if (self instanceof AST_Toplevel && compressor.top_retain) {
  21386. self.variables.forEach(function(def) {
  21387. if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
  21388. in_use_ids.set(def.id, def);
  21389. }
  21390. });
  21391. }
  21392. var var_defs_by_id = new Map();
  21393. var initializations = new Map();
  21394. // pass 1: find out which symbols are directly used in
  21395. // this scope (not in nested scopes).
  21396. var scope = this;
  21397. var tw = new TreeWalker(function(node, descend) {
  21398. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  21399. node.argnames.forEach(function(argname) {
  21400. if (!(argname instanceof AST_SymbolDeclaration)) return;
  21401. var def = argname.definition();
  21402. if (!in_use_ids.has(def.id)) {
  21403. in_use_ids.set(def.id, def);
  21404. }
  21405. });
  21406. }
  21407. if (node === self) return;
  21408. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  21409. var node_def = node.name.definition();
  21410. const in_export = tw.parent() instanceof AST_Export;
  21411. if (in_export || !drop_funcs && scope === self) {
  21412. if (node_def.global && !in_use_ids.has(node_def.id)) {
  21413. in_use_ids.set(node_def.id, node_def);
  21414. }
  21415. }
  21416. if (node instanceof AST_DefClass) {
  21417. if (
  21418. node.extends
  21419. && (node.extends.has_side_effects(compressor)
  21420. || node.extends.may_throw(compressor))
  21421. ) {
  21422. node.extends.walk(tw);
  21423. }
  21424. for (const prop of node.properties) {
  21425. if (
  21426. prop.has_side_effects(compressor) ||
  21427. prop.may_throw(compressor)
  21428. ) {
  21429. prop.walk(tw);
  21430. }
  21431. }
  21432. }
  21433. map_add(initializations, node_def.id, node);
  21434. return true; // don't go in nested scopes
  21435. }
  21436. if (node instanceof AST_SymbolFunarg && scope === self) {
  21437. map_add(var_defs_by_id, node.definition().id, node);
  21438. }
  21439. if (node instanceof AST_Definitions && scope === self) {
  21440. const in_export = tw.parent() instanceof AST_Export;
  21441. node.definitions.forEach(function(def) {
  21442. if (def.name instanceof AST_SymbolVar) {
  21443. map_add(var_defs_by_id, def.name.definition().id, def);
  21444. }
  21445. if (in_export || !drop_vars) {
  21446. walk(def.name, node => {
  21447. if (node instanceof AST_SymbolDeclaration) {
  21448. const def = node.definition();
  21449. if (
  21450. (in_export || def.global)
  21451. && !in_use_ids.has(def.id)
  21452. ) {
  21453. in_use_ids.set(def.id, def);
  21454. }
  21455. }
  21456. });
  21457. }
  21458. if (def.value) {
  21459. if (def.name instanceof AST_Destructuring) {
  21460. def.walk(tw);
  21461. } else {
  21462. var node_def = def.name.definition();
  21463. map_add(initializations, node_def.id, def.value);
  21464. if (!node_def.chained && def.name.fixed_value() === def.value) {
  21465. fixed_ids.set(node_def.id, def);
  21466. }
  21467. }
  21468. if (def.value.has_side_effects(compressor)) {
  21469. def.value.walk(tw);
  21470. }
  21471. }
  21472. });
  21473. return true;
  21474. }
  21475. return scan_ref_scoped(node, descend);
  21476. });
  21477. self.walk(tw);
  21478. // pass 2: for every used symbol we need to walk its
  21479. // initialization code to figure out if it uses other
  21480. // symbols (that may not be in_use).
  21481. tw = new TreeWalker(scan_ref_scoped);
  21482. in_use_ids.forEach(function (def) {
  21483. var init = initializations.get(def.id);
  21484. if (init) init.forEach(function(init) {
  21485. init.walk(tw);
  21486. });
  21487. });
  21488. // pass 3: we should drop declarations not in_use
  21489. var tt = new TreeTransformer(
  21490. function before(node, descend, in_list) {
  21491. var parent = tt.parent();
  21492. if (drop_vars) {
  21493. const sym = assign_as_unused(node);
  21494. if (sym instanceof AST_SymbolRef) {
  21495. var def = sym.definition();
  21496. var in_use = in_use_ids.has(def.id);
  21497. if (node instanceof AST_Assign) {
  21498. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  21499. return maintain_this_binding(parent, node, node.right.transform(tt));
  21500. }
  21501. } else if (!in_use) return in_list ? MAP.skip : make_node(AST_Number, node, {
  21502. value: 0
  21503. });
  21504. }
  21505. }
  21506. if (scope !== self) return;
  21507. var def;
  21508. if (node.name
  21509. && (node instanceof AST_ClassExpression
  21510. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  21511. || node instanceof AST_Function
  21512. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  21513. // any declarations with same name will overshadow
  21514. // name of this anonymous function and can therefore
  21515. // never be used anywhere
  21516. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  21517. }
  21518. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  21519. var trim = !compressor.option("keep_fargs");
  21520. for (var a = node.argnames, i = a.length; --i >= 0;) {
  21521. var sym = a[i];
  21522. if (sym instanceof AST_Expansion) {
  21523. sym = sym.expression;
  21524. }
  21525. if (sym instanceof AST_DefaultAssign) {
  21526. sym = sym.left;
  21527. }
  21528. // Do not drop destructuring arguments.
  21529. // They constitute a type assertion, so dropping
  21530. // them would stop that TypeError which would happen
  21531. // if someone called it with an incorrectly formatted
  21532. // parameter.
  21533. if (!(sym instanceof AST_Destructuring) && !in_use_ids.has(sym.definition().id)) {
  21534. set_flag(sym, UNUSED);
  21535. if (trim) {
  21536. a.pop();
  21537. }
  21538. } else {
  21539. trim = false;
  21540. }
  21541. }
  21542. }
  21543. if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
  21544. const def = node.name.definition();
  21545. let keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  21546. if (!keep) {
  21547. def.eliminated++;
  21548. if (node instanceof AST_DefClass) {
  21549. // Classes might have extends with side effects
  21550. const side_effects = node.drop_side_effect_free(compressor);
  21551. if (side_effects) {
  21552. return make_node(AST_SimpleStatement, node, {
  21553. body: side_effects
  21554. });
  21555. }
  21556. }
  21557. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  21558. }
  21559. }
  21560. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  21561. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  21562. // place uninitialized names at the start
  21563. var body = [], head = [], tail = [];
  21564. // for unused names whose initialization has
  21565. // side effects, we can cascade the init. code
  21566. // into the next one, or next statement.
  21567. var side_effects = [];
  21568. node.definitions.forEach(function(def) {
  21569. if (def.value) def.value = def.value.transform(tt);
  21570. var is_destructure = def.name instanceof AST_Destructuring;
  21571. var sym = is_destructure
  21572. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  21573. : def.name.definition();
  21574. if (drop_block && sym.global) return tail.push(def);
  21575. if (!(drop_vars || drop_block)
  21576. || is_destructure
  21577. && (def.name.names.length
  21578. || def.name.is_array
  21579. || compressor.option("pure_getters") != true)
  21580. || in_use_ids.has(sym.id)
  21581. ) {
  21582. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  21583. def.value = def.value.drop_side_effect_free(compressor);
  21584. }
  21585. if (def.name instanceof AST_SymbolVar) {
  21586. var var_defs = var_defs_by_id.get(sym.id);
  21587. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  21588. if (def.value) {
  21589. var ref = make_node(AST_SymbolRef, def.name, def.name);
  21590. sym.references.push(ref);
  21591. var assign = make_node(AST_Assign, def, {
  21592. operator: "=",
  21593. logical: false,
  21594. left: ref,
  21595. right: def.value
  21596. });
  21597. if (fixed_ids.get(sym.id) === def) {
  21598. fixed_ids.set(sym.id, assign);
  21599. }
  21600. side_effects.push(assign.transform(tt));
  21601. }
  21602. remove(var_defs, def);
  21603. sym.eliminated++;
  21604. return;
  21605. }
  21606. }
  21607. if (def.value) {
  21608. if (side_effects.length > 0) {
  21609. if (tail.length > 0) {
  21610. side_effects.push(def.value);
  21611. def.value = make_sequence(def.value, side_effects);
  21612. } else {
  21613. body.push(make_node(AST_SimpleStatement, node, {
  21614. body: make_sequence(node, side_effects)
  21615. }));
  21616. }
  21617. side_effects = [];
  21618. }
  21619. tail.push(def);
  21620. } else {
  21621. head.push(def);
  21622. }
  21623. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  21624. var value = def.value && def.value.drop_side_effect_free(compressor);
  21625. if (value) side_effects.push(value);
  21626. def.value = null;
  21627. head.push(def);
  21628. } else {
  21629. var value = def.value && def.value.drop_side_effect_free(compressor);
  21630. if (value) {
  21631. side_effects.push(value);
  21632. }
  21633. sym.eliminated++;
  21634. }
  21635. });
  21636. if (head.length > 0 || tail.length > 0) {
  21637. node.definitions = head.concat(tail);
  21638. body.push(node);
  21639. }
  21640. if (side_effects.length > 0) {
  21641. body.push(make_node(AST_SimpleStatement, node, {
  21642. body: make_sequence(node, side_effects)
  21643. }));
  21644. }
  21645. switch (body.length) {
  21646. case 0:
  21647. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  21648. case 1:
  21649. return body[0];
  21650. default:
  21651. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  21652. body: body
  21653. });
  21654. }
  21655. }
  21656. // certain combination of unused name + side effect leads to:
  21657. // https://github.com/mishoo/UglifyJS2/issues/44
  21658. // https://github.com/mishoo/UglifyJS2/issues/1830
  21659. // https://github.com/mishoo/UglifyJS2/issues/1838
  21660. // that's an invalid AST.
  21661. // We fix it at this stage by moving the `var` outside the `for`.
  21662. if (node instanceof AST_For) {
  21663. descend(node, this);
  21664. var block;
  21665. if (node.init instanceof AST_BlockStatement) {
  21666. block = node.init;
  21667. node.init = block.body.pop();
  21668. block.body.push(node);
  21669. }
  21670. if (node.init instanceof AST_SimpleStatement) {
  21671. node.init = node.init.body;
  21672. } else if (is_empty(node.init)) {
  21673. node.init = null;
  21674. }
  21675. return !block ? node : in_list ? MAP.splice(block.body) : block;
  21676. }
  21677. if (node instanceof AST_LabeledStatement
  21678. && node.body instanceof AST_For
  21679. ) {
  21680. descend(node, this);
  21681. if (node.body instanceof AST_BlockStatement) {
  21682. var block = node.body;
  21683. node.body = block.body.pop();
  21684. block.body.push(node);
  21685. return in_list ? MAP.splice(block.body) : block;
  21686. }
  21687. return node;
  21688. }
  21689. if (node instanceof AST_BlockStatement) {
  21690. descend(node, this);
  21691. if (in_list && node.body.every(can_be_evicted_from_block)) {
  21692. return MAP.splice(node.body);
  21693. }
  21694. return node;
  21695. }
  21696. if (node instanceof AST_Scope) {
  21697. const save_scope = scope;
  21698. scope = node;
  21699. descend(node, this);
  21700. scope = save_scope;
  21701. return node;
  21702. }
  21703. }
  21704. );
  21705. self.transform(tt);
  21706. function scan_ref_scoped(node, descend) {
  21707. var node_def;
  21708. const sym = assign_as_unused(node);
  21709. if (sym instanceof AST_SymbolRef
  21710. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  21711. && self.variables.get(sym.name) === (node_def = sym.definition())
  21712. ) {
  21713. if (node instanceof AST_Assign) {
  21714. node.right.walk(tw);
  21715. if (!node_def.chained && node.left.fixed_value() === node.right) {
  21716. fixed_ids.set(node_def.id, node);
  21717. }
  21718. }
  21719. return true;
  21720. }
  21721. if (node instanceof AST_SymbolRef) {
  21722. node_def = node.definition();
  21723. if (!in_use_ids.has(node_def.id)) {
  21724. in_use_ids.set(node_def.id, node_def);
  21725. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  21726. const redef = node_def.scope.is_block_scope()
  21727. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  21728. if (redef) in_use_ids.set(redef.id, redef);
  21729. }
  21730. }
  21731. return true;
  21732. }
  21733. if (node instanceof AST_Scope) {
  21734. var save_scope = scope;
  21735. scope = node;
  21736. descend();
  21737. scope = save_scope;
  21738. return true;
  21739. }
  21740. }
  21741. });
  21742. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  21743. var self = this;
  21744. if (compressor.has_directive("use asm")) return self;
  21745. // Hoisting makes no sense in an arrow func
  21746. if (!Array.isArray(self.body)) return self;
  21747. var hoist_funs = compressor.option("hoist_funs");
  21748. var hoist_vars = compressor.option("hoist_vars");
  21749. if (hoist_funs || hoist_vars) {
  21750. var dirs = [];
  21751. var hoisted = [];
  21752. var vars = new Map(), vars_found = 0, var_decl = 0;
  21753. // let's count var_decl first, we seem to waste a lot of
  21754. // space if we hoist `var` when there's only one.
  21755. walk(self, node => {
  21756. if (node instanceof AST_Scope && node !== self)
  21757. return true;
  21758. if (node instanceof AST_Var) {
  21759. ++var_decl;
  21760. return true;
  21761. }
  21762. });
  21763. hoist_vars = hoist_vars && var_decl > 1;
  21764. var tt = new TreeTransformer(
  21765. function before(node) {
  21766. if (node !== self) {
  21767. if (node instanceof AST_Directive) {
  21768. dirs.push(node);
  21769. return make_node(AST_EmptyStatement, node);
  21770. }
  21771. if (hoist_funs && node instanceof AST_Defun
  21772. && !(tt.parent() instanceof AST_Export)
  21773. && tt.parent() === self) {
  21774. hoisted.push(node);
  21775. return make_node(AST_EmptyStatement, node);
  21776. }
  21777. if (
  21778. hoist_vars
  21779. && node instanceof AST_Var
  21780. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  21781. ) {
  21782. node.definitions.forEach(function(def) {
  21783. vars.set(def.name.name, def);
  21784. ++vars_found;
  21785. });
  21786. var seq = node.to_assignments(compressor);
  21787. var p = tt.parent();
  21788. if (p instanceof AST_ForIn && p.init === node) {
  21789. if (seq == null) {
  21790. var def = node.definitions[0].name;
  21791. return make_node(AST_SymbolRef, def, def);
  21792. }
  21793. return seq;
  21794. }
  21795. if (p instanceof AST_For && p.init === node) {
  21796. return seq;
  21797. }
  21798. if (!seq) return make_node(AST_EmptyStatement, node);
  21799. return make_node(AST_SimpleStatement, node, {
  21800. body: seq
  21801. });
  21802. }
  21803. if (node instanceof AST_Scope)
  21804. return node; // to avoid descending in nested scopes
  21805. }
  21806. }
  21807. );
  21808. self = self.transform(tt);
  21809. if (vars_found > 0) {
  21810. // collect only vars which don't show up in self's arguments list
  21811. var defs = [];
  21812. const is_lambda = self instanceof AST_Lambda;
  21813. const args_as_names = is_lambda ? self.args_as_names() : null;
  21814. vars.forEach((def, name) => {
  21815. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  21816. vars.delete(name);
  21817. } else {
  21818. def = def.clone();
  21819. def.value = null;
  21820. defs.push(def);
  21821. vars.set(name, def);
  21822. }
  21823. });
  21824. if (defs.length > 0) {
  21825. // try to merge in assignments
  21826. for (var i = 0; i < self.body.length;) {
  21827. if (self.body[i] instanceof AST_SimpleStatement) {
  21828. var expr = self.body[i].body, sym, assign;
  21829. if (expr instanceof AST_Assign
  21830. && expr.operator == "="
  21831. && (sym = expr.left) instanceof AST_Symbol
  21832. && vars.has(sym.name)
  21833. ) {
  21834. var def = vars.get(sym.name);
  21835. if (def.value) break;
  21836. def.value = expr.right;
  21837. remove(defs, def);
  21838. defs.push(def);
  21839. self.body.splice(i, 1);
  21840. continue;
  21841. }
  21842. if (expr instanceof AST_Sequence
  21843. && (assign = expr.expressions[0]) instanceof AST_Assign
  21844. && assign.operator == "="
  21845. && (sym = assign.left) instanceof AST_Symbol
  21846. && vars.has(sym.name)
  21847. ) {
  21848. var def = vars.get(sym.name);
  21849. if (def.value) break;
  21850. def.value = assign.right;
  21851. remove(defs, def);
  21852. defs.push(def);
  21853. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  21854. continue;
  21855. }
  21856. }
  21857. if (self.body[i] instanceof AST_EmptyStatement) {
  21858. self.body.splice(i, 1);
  21859. continue;
  21860. }
  21861. if (self.body[i] instanceof AST_BlockStatement) {
  21862. self.body.splice(i, 1, ...self.body[i].body);
  21863. continue;
  21864. }
  21865. break;
  21866. }
  21867. defs = make_node(AST_Var, self, {
  21868. definitions: defs
  21869. });
  21870. hoisted.push(defs);
  21871. }
  21872. }
  21873. self.body = dirs.concat(hoisted, self.body);
  21874. }
  21875. return self;
  21876. });
  21877. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  21878. var self = this;
  21879. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  21880. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  21881. var defs_by_id = new Map();
  21882. var hoister = new TreeTransformer(function(node, descend) {
  21883. if (node instanceof AST_Definitions
  21884. && hoister.parent() instanceof AST_Export) return node;
  21885. if (node instanceof AST_VarDef) {
  21886. const sym = node.name;
  21887. let def;
  21888. let value;
  21889. if (sym.scope === self
  21890. && (def = sym.definition()).escaped != 1
  21891. && !def.assignments
  21892. && !def.direct_access
  21893. && !def.single_use
  21894. && !compressor.exposed(def)
  21895. && !top_retain(def)
  21896. && (value = sym.fixed_value()) === node.value
  21897. && value instanceof AST_Object
  21898. && !value.properties.some(prop =>
  21899. prop instanceof AST_Expansion || prop.computed_key()
  21900. )
  21901. ) {
  21902. descend(node, this);
  21903. const defs = new Map();
  21904. const assignments = [];
  21905. value.properties.forEach(({ key, value }) => {
  21906. const scope = find_scope(hoister);
  21907. const symbol = self.create_symbol(sym.CTOR, {
  21908. source: sym,
  21909. scope,
  21910. conflict_scopes: new Set([
  21911. scope,
  21912. ...sym.definition().references.map(ref => ref.scope)
  21913. ]),
  21914. tentative_name: sym.name + "_" + key
  21915. });
  21916. defs.set(String(key), symbol.definition());
  21917. assignments.push(make_node(AST_VarDef, node, {
  21918. name: symbol,
  21919. value
  21920. }));
  21921. });
  21922. defs_by_id.set(def.id, defs);
  21923. return MAP.splice(assignments);
  21924. }
  21925. } else if (node instanceof AST_PropAccess
  21926. && node.expression instanceof AST_SymbolRef
  21927. ) {
  21928. const defs = defs_by_id.get(node.expression.definition().id);
  21929. if (defs) {
  21930. const def = defs.get(String(get_simple_key(node.property)));
  21931. const sym = make_node(AST_SymbolRef, node, {
  21932. name: def.name,
  21933. scope: node.expression.scope,
  21934. thedef: def
  21935. });
  21936. sym.reference({});
  21937. return sym;
  21938. }
  21939. }
  21940. });
  21941. return self.transform(hoister);
  21942. });
  21943. def_optimize(AST_SimpleStatement, function(self, compressor) {
  21944. if (compressor.option("side_effects")) {
  21945. var body = self.body;
  21946. var node = body.drop_side_effect_free(compressor, true);
  21947. if (!node) {
  21948. return make_node(AST_EmptyStatement, self);
  21949. }
  21950. if (node !== body) {
  21951. return make_node(AST_SimpleStatement, self, { body: node });
  21952. }
  21953. }
  21954. return self;
  21955. });
  21956. def_optimize(AST_While, function(self, compressor) {
  21957. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  21958. });
  21959. def_optimize(AST_Do, function(self, compressor) {
  21960. if (!compressor.option("loops")) return self;
  21961. var cond = self.condition.tail_node().evaluate(compressor);
  21962. if (!(cond instanceof AST_Node)) {
  21963. if (cond) return make_node(AST_For, self, {
  21964. body: make_node(AST_BlockStatement, self.body, {
  21965. body: [
  21966. self.body,
  21967. make_node(AST_SimpleStatement, self.condition, {
  21968. body: self.condition
  21969. })
  21970. ]
  21971. })
  21972. }).optimize(compressor);
  21973. if (!has_break_or_continue(self, compressor.parent())) {
  21974. return make_node(AST_BlockStatement, self.body, {
  21975. body: [
  21976. self.body,
  21977. make_node(AST_SimpleStatement, self.condition, {
  21978. body: self.condition
  21979. })
  21980. ]
  21981. }).optimize(compressor);
  21982. }
  21983. }
  21984. return self;
  21985. });
  21986. function if_break_in_loop(self, compressor) {
  21987. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  21988. if (compressor.option("dead_code") && is_break(first)) {
  21989. var body = [];
  21990. if (self.init instanceof AST_Statement) {
  21991. body.push(self.init);
  21992. } else if (self.init) {
  21993. body.push(make_node(AST_SimpleStatement, self.init, {
  21994. body: self.init
  21995. }));
  21996. }
  21997. if (self.condition) {
  21998. body.push(make_node(AST_SimpleStatement, self.condition, {
  21999. body: self.condition
  22000. }));
  22001. }
  22002. trim_unreachable_code(compressor, self.body, body);
  22003. return make_node(AST_BlockStatement, self, {
  22004. body: body
  22005. });
  22006. }
  22007. if (first instanceof AST_If) {
  22008. if (is_break(first.body)) {
  22009. if (self.condition) {
  22010. self.condition = make_node(AST_Binary, self.condition, {
  22011. left: self.condition,
  22012. operator: "&&",
  22013. right: first.condition.negate(compressor),
  22014. });
  22015. } else {
  22016. self.condition = first.condition.negate(compressor);
  22017. }
  22018. drop_it(first.alternative);
  22019. } else if (is_break(first.alternative)) {
  22020. if (self.condition) {
  22021. self.condition = make_node(AST_Binary, self.condition, {
  22022. left: self.condition,
  22023. operator: "&&",
  22024. right: first.condition,
  22025. });
  22026. } else {
  22027. self.condition = first.condition;
  22028. }
  22029. drop_it(first.body);
  22030. }
  22031. }
  22032. return self;
  22033. function is_break(node) {
  22034. return node instanceof AST_Break
  22035. && compressor.loopcontrol_target(node) === compressor.self();
  22036. }
  22037. function drop_it(rest) {
  22038. rest = as_statement_array(rest);
  22039. if (self.body instanceof AST_BlockStatement) {
  22040. self.body = self.body.clone();
  22041. self.body.body = rest.concat(self.body.body.slice(1));
  22042. self.body = self.body.transform(compressor);
  22043. } else {
  22044. self.body = make_node(AST_BlockStatement, self.body, {
  22045. body: rest
  22046. }).transform(compressor);
  22047. }
  22048. self = if_break_in_loop(self, compressor);
  22049. }
  22050. }
  22051. def_optimize(AST_For, function(self, compressor) {
  22052. if (!compressor.option("loops")) return self;
  22053. if (compressor.option("side_effects") && self.init) {
  22054. self.init = self.init.drop_side_effect_free(compressor);
  22055. }
  22056. if (self.condition) {
  22057. var cond = self.condition.evaluate(compressor);
  22058. if (!(cond instanceof AST_Node)) {
  22059. if (cond) self.condition = null;
  22060. else if (!compressor.option("dead_code")) {
  22061. var orig = self.condition;
  22062. self.condition = make_node_from_constant(cond, self.condition);
  22063. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  22064. }
  22065. }
  22066. if (compressor.option("dead_code")) {
  22067. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  22068. if (!cond) {
  22069. var body = [];
  22070. trim_unreachable_code(compressor, self.body, body);
  22071. if (self.init instanceof AST_Statement) {
  22072. body.push(self.init);
  22073. } else if (self.init) {
  22074. body.push(make_node(AST_SimpleStatement, self.init, {
  22075. body: self.init
  22076. }));
  22077. }
  22078. body.push(make_node(AST_SimpleStatement, self.condition, {
  22079. body: self.condition
  22080. }));
  22081. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  22082. }
  22083. }
  22084. }
  22085. return if_break_in_loop(self, compressor);
  22086. });
  22087. def_optimize(AST_If, function(self, compressor) {
  22088. if (is_empty(self.alternative)) self.alternative = null;
  22089. if (!compressor.option("conditionals")) return self;
  22090. // if condition can be statically determined, drop
  22091. // one of the blocks. note, statically determined implies
  22092. // “has no side effects”; also it doesn't work for cases like
  22093. // `x && true`, though it probably should.
  22094. var cond = self.condition.evaluate(compressor);
  22095. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  22096. var orig = self.condition;
  22097. self.condition = make_node_from_constant(cond, orig);
  22098. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  22099. }
  22100. if (compressor.option("dead_code")) {
  22101. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  22102. if (!cond) {
  22103. var body = [];
  22104. trim_unreachable_code(compressor, self.body, body);
  22105. body.push(make_node(AST_SimpleStatement, self.condition, {
  22106. body: self.condition
  22107. }));
  22108. if (self.alternative) body.push(self.alternative);
  22109. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  22110. } else if (!(cond instanceof AST_Node)) {
  22111. var body = [];
  22112. body.push(make_node(AST_SimpleStatement, self.condition, {
  22113. body: self.condition
  22114. }));
  22115. body.push(self.body);
  22116. if (self.alternative) {
  22117. trim_unreachable_code(compressor, self.alternative, body);
  22118. }
  22119. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  22120. }
  22121. }
  22122. var negated = self.condition.negate(compressor);
  22123. var self_condition_length = self.condition.size();
  22124. var negated_length = negated.size();
  22125. var negated_is_best = negated_length < self_condition_length;
  22126. if (self.alternative && negated_is_best) {
  22127. negated_is_best = false; // because we already do the switch here.
  22128. // no need to swap values of self_condition_length and negated_length
  22129. // here because they are only used in an equality comparison later on.
  22130. self.condition = negated;
  22131. var tmp = self.body;
  22132. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  22133. self.alternative = tmp;
  22134. }
  22135. if (is_empty(self.body) && is_empty(self.alternative)) {
  22136. return make_node(AST_SimpleStatement, self.condition, {
  22137. body: self.condition.clone()
  22138. }).optimize(compressor);
  22139. }
  22140. if (self.body instanceof AST_SimpleStatement
  22141. && self.alternative instanceof AST_SimpleStatement) {
  22142. return make_node(AST_SimpleStatement, self, {
  22143. body: make_node(AST_Conditional, self, {
  22144. condition : self.condition,
  22145. consequent : self.body.body,
  22146. alternative : self.alternative.body
  22147. })
  22148. }).optimize(compressor);
  22149. }
  22150. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  22151. if (self_condition_length === negated_length && !negated_is_best
  22152. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  22153. // although the code length of self.condition and negated are the same,
  22154. // negated does not require additional surrounding parentheses.
  22155. // see https://github.com/mishoo/UglifyJS2/issues/979
  22156. negated_is_best = true;
  22157. }
  22158. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  22159. body: make_node(AST_Binary, self, {
  22160. operator : "||",
  22161. left : negated,
  22162. right : self.body.body
  22163. })
  22164. }).optimize(compressor);
  22165. return make_node(AST_SimpleStatement, self, {
  22166. body: make_node(AST_Binary, self, {
  22167. operator : "&&",
  22168. left : self.condition,
  22169. right : self.body.body
  22170. })
  22171. }).optimize(compressor);
  22172. }
  22173. if (self.body instanceof AST_EmptyStatement
  22174. && self.alternative instanceof AST_SimpleStatement) {
  22175. return make_node(AST_SimpleStatement, self, {
  22176. body: make_node(AST_Binary, self, {
  22177. operator : "||",
  22178. left : self.condition,
  22179. right : self.alternative.body
  22180. })
  22181. }).optimize(compressor);
  22182. }
  22183. if (self.body instanceof AST_Exit
  22184. && self.alternative instanceof AST_Exit
  22185. && self.body.TYPE == self.alternative.TYPE) {
  22186. return make_node(self.body.CTOR, self, {
  22187. value: make_node(AST_Conditional, self, {
  22188. condition : self.condition,
  22189. consequent : self.body.value || make_node(AST_Undefined, self.body),
  22190. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  22191. }).transform(compressor)
  22192. }).optimize(compressor);
  22193. }
  22194. if (self.body instanceof AST_If
  22195. && !self.body.alternative
  22196. && !self.alternative) {
  22197. self = make_node(AST_If, self, {
  22198. condition: make_node(AST_Binary, self.condition, {
  22199. operator: "&&",
  22200. left: self.condition,
  22201. right: self.body.condition
  22202. }),
  22203. body: self.body.body,
  22204. alternative: null
  22205. });
  22206. }
  22207. if (aborts(self.body)) {
  22208. if (self.alternative) {
  22209. var alt = self.alternative;
  22210. self.alternative = null;
  22211. return make_node(AST_BlockStatement, self, {
  22212. body: [ self, alt ]
  22213. }).optimize(compressor);
  22214. }
  22215. }
  22216. if (aborts(self.alternative)) {
  22217. var body = self.body;
  22218. self.body = self.alternative;
  22219. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  22220. self.alternative = null;
  22221. return make_node(AST_BlockStatement, self, {
  22222. body: [ self, body ]
  22223. }).optimize(compressor);
  22224. }
  22225. return self;
  22226. });
  22227. def_optimize(AST_Switch, function(self, compressor) {
  22228. if (!compressor.option("switches")) return self;
  22229. var branch;
  22230. var value = self.expression.evaluate(compressor);
  22231. if (!(value instanceof AST_Node)) {
  22232. var orig = self.expression;
  22233. self.expression = make_node_from_constant(value, orig);
  22234. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  22235. }
  22236. if (!compressor.option("dead_code")) return self;
  22237. if (value instanceof AST_Node) {
  22238. value = self.expression.tail_node().evaluate(compressor);
  22239. }
  22240. var decl = [];
  22241. var body = [];
  22242. var default_branch;
  22243. var exact_match;
  22244. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  22245. branch = self.body[i];
  22246. if (branch instanceof AST_Default) {
  22247. if (!default_branch) {
  22248. default_branch = branch;
  22249. } else {
  22250. eliminate_branch(branch, body[body.length - 1]);
  22251. }
  22252. } else if (!(value instanceof AST_Node)) {
  22253. var exp = branch.expression.evaluate(compressor);
  22254. if (!(exp instanceof AST_Node) && exp !== value) {
  22255. eliminate_branch(branch, body[body.length - 1]);
  22256. continue;
  22257. }
  22258. if (exp instanceof AST_Node) exp = branch.expression.tail_node().evaluate(compressor);
  22259. if (exp === value) {
  22260. exact_match = branch;
  22261. if (default_branch) {
  22262. var default_index = body.indexOf(default_branch);
  22263. body.splice(default_index, 1);
  22264. eliminate_branch(default_branch, body[default_index - 1]);
  22265. default_branch = null;
  22266. }
  22267. }
  22268. }
  22269. if (aborts(branch)) {
  22270. var prev = body[body.length - 1];
  22271. if (aborts(prev) && prev.body.length == branch.body.length
  22272. && make_node(AST_BlockStatement, prev, prev).equivalent_to(make_node(AST_BlockStatement, branch, branch))) {
  22273. prev.body = [];
  22274. }
  22275. }
  22276. body.push(branch);
  22277. }
  22278. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  22279. if (body.length > 0) {
  22280. body[0].body = decl.concat(body[0].body);
  22281. }
  22282. self.body = body;
  22283. while (branch = body[body.length - 1]) {
  22284. var stat = branch.body[branch.body.length - 1];
  22285. if (stat instanceof AST_Break && compressor.loopcontrol_target(stat) === self)
  22286. branch.body.pop();
  22287. if (branch.body.length || branch instanceof AST_Case
  22288. && (default_branch || branch.expression.has_side_effects(compressor))) break;
  22289. if (body.pop() === default_branch) default_branch = null;
  22290. }
  22291. if (body.length == 0) {
  22292. return make_node(AST_BlockStatement, self, {
  22293. body: decl.concat(make_node(AST_SimpleStatement, self.expression, {
  22294. body: self.expression
  22295. }))
  22296. }).optimize(compressor);
  22297. }
  22298. if (body.length == 1 && (body[0] === exact_match || body[0] === default_branch)) {
  22299. var has_break = false;
  22300. var tw = new TreeWalker(function(node) {
  22301. if (has_break
  22302. || node instanceof AST_Lambda
  22303. || node instanceof AST_SimpleStatement) return true;
  22304. if (node instanceof AST_Break && tw.loopcontrol_target(node) === self)
  22305. has_break = true;
  22306. });
  22307. self.walk(tw);
  22308. if (!has_break) {
  22309. var statements = body[0].body.slice();
  22310. var exp = body[0].expression;
  22311. if (exp) statements.unshift(make_node(AST_SimpleStatement, exp, {
  22312. body: exp
  22313. }));
  22314. statements.unshift(make_node(AST_SimpleStatement, self.expression, {
  22315. body:self.expression
  22316. }));
  22317. return make_node(AST_BlockStatement, self, {
  22318. body: statements
  22319. }).optimize(compressor);
  22320. }
  22321. }
  22322. return self;
  22323. function eliminate_branch(branch, prev) {
  22324. if (prev && !aborts(prev)) {
  22325. prev.body = prev.body.concat(branch.body);
  22326. } else {
  22327. trim_unreachable_code(compressor, branch, decl);
  22328. }
  22329. }
  22330. });
  22331. def_optimize(AST_Try, function(self, compressor) {
  22332. tighten_body(self.body, compressor);
  22333. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  22334. if (compressor.option("dead_code") && self.body.every(is_empty)) {
  22335. var body = [];
  22336. if (self.bcatch) {
  22337. trim_unreachable_code(compressor, self.bcatch, body);
  22338. }
  22339. if (self.bfinally) body.push(...self.bfinally.body);
  22340. return make_node(AST_BlockStatement, self, {
  22341. body: body
  22342. }).optimize(compressor);
  22343. }
  22344. return self;
  22345. });
  22346. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  22347. var decls = [];
  22348. this.definitions.forEach(function(def) {
  22349. if (def.name instanceof AST_SymbolDeclaration) {
  22350. def.value = null;
  22351. decls.push(def);
  22352. } else {
  22353. walk(def.name, node => {
  22354. if (node instanceof AST_SymbolDeclaration) {
  22355. decls.push(make_node(AST_VarDef, def, {
  22356. name: node,
  22357. value: null
  22358. }));
  22359. }
  22360. });
  22361. }
  22362. });
  22363. this.definitions = decls;
  22364. });
  22365. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  22366. var reduce_vars = compressor.option("reduce_vars");
  22367. var assignments = [];
  22368. for (const def of this.definitions) {
  22369. if (def.value) {
  22370. var name = make_node(AST_SymbolRef, def.name, def.name);
  22371. assignments.push(make_node(AST_Assign, def, {
  22372. operator : "=",
  22373. logical: false,
  22374. left : name,
  22375. right : def.value
  22376. }));
  22377. if (reduce_vars) name.definition().fixed = false;
  22378. } else if (def.value) {
  22379. // Because it's a destructuring, do not turn into an assignment.
  22380. var varDef = make_node(AST_VarDef, def, {
  22381. name: def.name,
  22382. value: def.value
  22383. });
  22384. var var_ = make_node(AST_Var, def, {
  22385. definitions: [ varDef ]
  22386. });
  22387. assignments.push(var_);
  22388. }
  22389. const thedef = def.name.definition();
  22390. thedef.eliminated++;
  22391. thedef.replaced--;
  22392. }
  22393. if (assignments.length == 0) return null;
  22394. return make_sequence(this, assignments);
  22395. });
  22396. def_optimize(AST_Definitions, function(self) {
  22397. if (self.definitions.length == 0)
  22398. return make_node(AST_EmptyStatement, self);
  22399. return self;
  22400. });
  22401. def_optimize(AST_VarDef, function(self, compressor) {
  22402. if (
  22403. self.name instanceof AST_SymbolLet
  22404. && self.value != null
  22405. && is_undefined(self.value, compressor)
  22406. ) {
  22407. self.value = null;
  22408. }
  22409. return self;
  22410. });
  22411. def_optimize(AST_Import, function(self) {
  22412. return self;
  22413. });
  22414. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  22415. function retain_top_func(fn, compressor) {
  22416. return compressor.top_retain
  22417. && fn instanceof AST_Defun
  22418. && has_flag(fn, TOP)
  22419. && fn.name
  22420. && compressor.top_retain(fn.name);
  22421. }
  22422. def_optimize(AST_Call, function(self, compressor) {
  22423. var exp = self.expression;
  22424. var fn = exp;
  22425. inline_array_like_spread(self.args);
  22426. var simple_args = self.args.every((arg) =>
  22427. !(arg instanceof AST_Expansion)
  22428. );
  22429. if (compressor.option("reduce_vars")
  22430. && fn instanceof AST_SymbolRef
  22431. && !has_annotation(self, _NOINLINE)
  22432. ) {
  22433. const fixed = fn.fixed_value();
  22434. if (!retain_top_func(fixed, compressor)) {
  22435. fn = fixed;
  22436. }
  22437. }
  22438. if (self.optional && is_nullish(fn, compressor)) {
  22439. return make_node(AST_Undefined, self);
  22440. }
  22441. var is_func = fn instanceof AST_Lambda;
  22442. if (is_func && fn.pinned()) return self;
  22443. if (compressor.option("unused")
  22444. && simple_args
  22445. && is_func
  22446. && !fn.uses_arguments) {
  22447. var pos = 0, last = 0;
  22448. for (var i = 0, len = self.args.length; i < len; i++) {
  22449. if (fn.argnames[i] instanceof AST_Expansion) {
  22450. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  22451. var node = self.args[i++].drop_side_effect_free(compressor);
  22452. if (node) {
  22453. self.args[pos++] = node;
  22454. }
  22455. } else while (i < len) {
  22456. self.args[pos++] = self.args[i++];
  22457. }
  22458. last = pos;
  22459. break;
  22460. }
  22461. var trim = i >= fn.argnames.length;
  22462. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  22463. var node = self.args[i].drop_side_effect_free(compressor);
  22464. if (node) {
  22465. self.args[pos++] = node;
  22466. } else if (!trim) {
  22467. self.args[pos++] = make_node(AST_Number, self.args[i], {
  22468. value: 0
  22469. });
  22470. continue;
  22471. }
  22472. } else {
  22473. self.args[pos++] = self.args[i];
  22474. }
  22475. last = pos;
  22476. }
  22477. self.args.length = last;
  22478. }
  22479. if (compressor.option("unsafe")) {
  22480. if (is_undeclared_ref(exp)) switch (exp.name) {
  22481. case "Array":
  22482. if (self.args.length != 1) {
  22483. return make_node(AST_Array, self, {
  22484. elements: self.args
  22485. }).optimize(compressor);
  22486. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  22487. const elements = [];
  22488. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  22489. return new AST_Array({ elements });
  22490. }
  22491. break;
  22492. case "Object":
  22493. if (self.args.length == 0) {
  22494. return make_node(AST_Object, self, {
  22495. properties: []
  22496. });
  22497. }
  22498. break;
  22499. case "String":
  22500. if (self.args.length == 0) return make_node(AST_String, self, {
  22501. value: ""
  22502. });
  22503. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  22504. left: self.args[0],
  22505. operator: "+",
  22506. right: make_node(AST_String, self, { value: "" })
  22507. }).optimize(compressor);
  22508. break;
  22509. case "Number":
  22510. if (self.args.length == 0) return make_node(AST_Number, self, {
  22511. value: 0
  22512. });
  22513. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  22514. return make_node(AST_UnaryPrefix, self, {
  22515. expression: self.args[0],
  22516. operator: "+"
  22517. }).optimize(compressor);
  22518. }
  22519. break;
  22520. case "Symbol":
  22521. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  22522. self.args.length = 0;
  22523. break;
  22524. case "Boolean":
  22525. if (self.args.length == 0) return make_node(AST_False, self);
  22526. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  22527. expression: make_node(AST_UnaryPrefix, self, {
  22528. expression: self.args[0],
  22529. operator: "!"
  22530. }),
  22531. operator: "!"
  22532. }).optimize(compressor);
  22533. break;
  22534. case "RegExp":
  22535. var params = [];
  22536. if (self.args.length >= 1
  22537. && self.args.length <= 2
  22538. && self.args.every((arg) => {
  22539. var value = arg.evaluate(compressor);
  22540. params.push(value);
  22541. return arg !== value;
  22542. })
  22543. ) {
  22544. let [ source, flags ] = params;
  22545. source = regexp_source_fix(new RegExp(source).source);
  22546. const rx = make_node(AST_RegExp, self, {
  22547. value: { source, flags }
  22548. });
  22549. if (rx._eval(compressor) !== rx) {
  22550. return rx;
  22551. }
  22552. }
  22553. break;
  22554. } else if (exp instanceof AST_Dot) switch(exp.property) {
  22555. case "toString":
  22556. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  22557. return make_node(AST_Binary, self, {
  22558. left: make_node(AST_String, self, { value: "" }),
  22559. operator: "+",
  22560. right: exp.expression
  22561. }).optimize(compressor);
  22562. }
  22563. break;
  22564. case "join":
  22565. if (exp.expression instanceof AST_Array) EXIT: {
  22566. var separator;
  22567. if (self.args.length > 0) {
  22568. separator = self.args[0].evaluate(compressor);
  22569. if (separator === self.args[0]) break EXIT; // not a constant
  22570. }
  22571. var elements = [];
  22572. var consts = [];
  22573. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  22574. var el = exp.expression.elements[i];
  22575. if (el instanceof AST_Expansion) break EXIT;
  22576. var value = el.evaluate(compressor);
  22577. if (value !== el) {
  22578. consts.push(value);
  22579. } else {
  22580. if (consts.length > 0) {
  22581. elements.push(make_node(AST_String, self, {
  22582. value: consts.join(separator)
  22583. }));
  22584. consts.length = 0;
  22585. }
  22586. elements.push(el);
  22587. }
  22588. }
  22589. if (consts.length > 0) {
  22590. elements.push(make_node(AST_String, self, {
  22591. value: consts.join(separator)
  22592. }));
  22593. }
  22594. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  22595. if (elements.length == 1) {
  22596. if (elements[0].is_string(compressor)) {
  22597. return elements[0];
  22598. }
  22599. return make_node(AST_Binary, elements[0], {
  22600. operator : "+",
  22601. left : make_node(AST_String, self, { value: "" }),
  22602. right : elements[0]
  22603. });
  22604. }
  22605. if (separator == "") {
  22606. var first;
  22607. if (elements[0].is_string(compressor)
  22608. || elements[1].is_string(compressor)) {
  22609. first = elements.shift();
  22610. } else {
  22611. first = make_node(AST_String, self, { value: "" });
  22612. }
  22613. return elements.reduce(function(prev, el) {
  22614. return make_node(AST_Binary, el, {
  22615. operator : "+",
  22616. left : prev,
  22617. right : el
  22618. });
  22619. }, first).optimize(compressor);
  22620. }
  22621. // need this awkward cloning to not affect original element
  22622. // best_of will decide which one to get through.
  22623. var node = self.clone();
  22624. node.expression = node.expression.clone();
  22625. node.expression.expression = node.expression.expression.clone();
  22626. node.expression.expression.elements = elements;
  22627. return best_of(compressor, self, node);
  22628. }
  22629. break;
  22630. case "charAt":
  22631. if (exp.expression.is_string(compressor)) {
  22632. var arg = self.args[0];
  22633. var index = arg ? arg.evaluate(compressor) : 0;
  22634. if (index !== arg) {
  22635. return make_node(AST_Sub, exp, {
  22636. expression: exp.expression,
  22637. property: make_node_from_constant(index | 0, arg || exp)
  22638. }).optimize(compressor);
  22639. }
  22640. }
  22641. break;
  22642. case "apply":
  22643. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  22644. var args = self.args[1].elements.slice();
  22645. args.unshift(self.args[0]);
  22646. return make_node(AST_Call, self, {
  22647. expression: make_node(AST_Dot, exp, {
  22648. expression: exp.expression,
  22649. optional: false,
  22650. property: "call"
  22651. }),
  22652. args: args
  22653. }).optimize(compressor);
  22654. }
  22655. break;
  22656. case "call":
  22657. var func = exp.expression;
  22658. if (func instanceof AST_SymbolRef) {
  22659. func = func.fixed_value();
  22660. }
  22661. if (func instanceof AST_Lambda && !func.contains_this()) {
  22662. return (self.args.length ? make_sequence(this, [
  22663. self.args[0],
  22664. make_node(AST_Call, self, {
  22665. expression: exp.expression,
  22666. args: self.args.slice(1)
  22667. })
  22668. ]) : make_node(AST_Call, self, {
  22669. expression: exp.expression,
  22670. args: []
  22671. })).optimize(compressor);
  22672. }
  22673. break;
  22674. }
  22675. }
  22676. if (compressor.option("unsafe_Function")
  22677. && is_undeclared_ref(exp)
  22678. && exp.name == "Function") {
  22679. // new Function() => function(){}
  22680. if (self.args.length == 0) return make_node(AST_Function, self, {
  22681. argnames: [],
  22682. body: []
  22683. }).optimize(compressor);
  22684. if (self.args.every((x) => x instanceof AST_String)) {
  22685. // quite a corner-case, but we can handle it:
  22686. // https://github.com/mishoo/UglifyJS2/issues/203
  22687. // if the code argument is a constant, then we can minify it.
  22688. try {
  22689. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  22690. return arg.value;
  22691. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  22692. var ast = parse(code);
  22693. var mangle = { ie8: compressor.option("ie8") };
  22694. ast.figure_out_scope(mangle);
  22695. var comp = new Compressor(compressor.options, {
  22696. mangle_options: compressor.mangle_options
  22697. });
  22698. ast = ast.transform(comp);
  22699. ast.figure_out_scope(mangle);
  22700. base54.reset();
  22701. ast.compute_char_frequency(mangle);
  22702. ast.mangle_names(mangle);
  22703. var fun;
  22704. walk(ast, node => {
  22705. if (is_func_expr(node)) {
  22706. fun = node;
  22707. return walk_abort;
  22708. }
  22709. });
  22710. var code = OutputStream();
  22711. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  22712. self.args = [
  22713. make_node(AST_String, self, {
  22714. value: fun.argnames.map(function(arg) {
  22715. return arg.print_to_string();
  22716. }).join(",")
  22717. }),
  22718. make_node(AST_String, self.args[self.args.length - 1], {
  22719. value: code.get().replace(/^{|}$/g, "")
  22720. })
  22721. ];
  22722. return self;
  22723. } catch (ex) {
  22724. if (!(ex instanceof JS_Parse_Error)) {
  22725. throw ex;
  22726. }
  22727. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  22728. }
  22729. }
  22730. }
  22731. var stat = is_func && fn.body[0];
  22732. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  22733. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  22734. if (can_inline && stat instanceof AST_Return) {
  22735. let returned = stat.value;
  22736. if (!returned || returned.is_constant_expression()) {
  22737. if (returned) {
  22738. returned = returned.clone(true);
  22739. } else {
  22740. returned = make_node(AST_Undefined, self);
  22741. }
  22742. const args = self.args.concat(returned);
  22743. return make_sequence(self, args).optimize(compressor);
  22744. }
  22745. // optimize identity function
  22746. if (
  22747. fn.argnames.length === 1
  22748. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  22749. && self.args.length < 2
  22750. && returned instanceof AST_SymbolRef
  22751. && returned.name === fn.argnames[0].name
  22752. ) {
  22753. const replacement =
  22754. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  22755. let parent;
  22756. if (
  22757. replacement instanceof AST_PropAccess
  22758. && (parent = compressor.parent()) instanceof AST_Call
  22759. && parent.expression === self
  22760. ) {
  22761. // identity function was being used to remove `this`, like in
  22762. //
  22763. // id(bag.no_this)(...)
  22764. //
  22765. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  22766. return make_sequence(self, [
  22767. make_node(AST_Number, self, { value: 0 }),
  22768. replacement
  22769. ]);
  22770. }
  22771. // replace call with first argument or undefined if none passed
  22772. return replacement;
  22773. }
  22774. }
  22775. if (can_inline) {
  22776. var scope, in_loop, level = -1;
  22777. let def;
  22778. let returned_value;
  22779. let nearest_scope;
  22780. if (simple_args
  22781. && !fn.uses_arguments
  22782. && !(compressor.parent() instanceof AST_Class)
  22783. && !(fn.name && fn instanceof AST_Function)
  22784. && (returned_value = can_flatten_body(stat))
  22785. && (exp === fn
  22786. || has_annotation(self, _INLINE)
  22787. || compressor.option("unused")
  22788. && (def = exp.definition()).references.length == 1
  22789. && !is_recursive_ref(compressor, def)
  22790. && fn.is_constant_expression(exp.scope))
  22791. && !has_annotation(self, _PURE | _NOINLINE)
  22792. && !fn.contains_this()
  22793. && can_inject_symbols()
  22794. && (nearest_scope = find_scope(compressor))
  22795. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  22796. && !(function in_default_assign() {
  22797. // Due to the fact function parameters have their own scope
  22798. // which can't use `var something` in the function body within,
  22799. // we simply don't inline into DefaultAssign.
  22800. let i = 0;
  22801. let p;
  22802. while ((p = compressor.parent(i++))) {
  22803. if (p instanceof AST_DefaultAssign) return true;
  22804. if (p instanceof AST_Block) break;
  22805. }
  22806. return false;
  22807. })()
  22808. && !(scope instanceof AST_Class)
  22809. ) {
  22810. set_flag(fn, SQUEEZED);
  22811. nearest_scope.add_child_scope(fn);
  22812. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  22813. }
  22814. }
  22815. if (can_inline && has_annotation(self, _INLINE)) {
  22816. set_flag(fn, SQUEEZED);
  22817. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  22818. fn.figure_out_scope({}, {
  22819. parent_scope: find_scope(compressor),
  22820. toplevel: compressor.get_toplevel()
  22821. });
  22822. return make_node(AST_Call, self, {
  22823. expression: fn,
  22824. args: self.args,
  22825. }).optimize(compressor);
  22826. }
  22827. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  22828. if (can_drop_this_call) {
  22829. var args = self.args.concat(make_node(AST_Undefined, self));
  22830. return make_sequence(self, args).optimize(compressor);
  22831. }
  22832. if (compressor.option("negate_iife")
  22833. && compressor.parent() instanceof AST_SimpleStatement
  22834. && is_iife_call(self)) {
  22835. return self.negate(compressor, true);
  22836. }
  22837. var ev = self.evaluate(compressor);
  22838. if (ev !== self) {
  22839. ev = make_node_from_constant(ev, self).optimize(compressor);
  22840. return best_of(compressor, ev, self);
  22841. }
  22842. return self;
  22843. function return_value(stat) {
  22844. if (!stat) return make_node(AST_Undefined, self);
  22845. if (stat instanceof AST_Return) {
  22846. if (!stat.value) return make_node(AST_Undefined, self);
  22847. return stat.value.clone(true);
  22848. }
  22849. if (stat instanceof AST_SimpleStatement) {
  22850. return make_node(AST_UnaryPrefix, stat, {
  22851. operator: "void",
  22852. expression: stat.body.clone(true)
  22853. });
  22854. }
  22855. }
  22856. function can_flatten_body(stat) {
  22857. var body = fn.body;
  22858. var len = body.length;
  22859. if (compressor.option("inline") < 3) {
  22860. return len == 1 && return_value(stat);
  22861. }
  22862. stat = null;
  22863. for (var i = 0; i < len; i++) {
  22864. var line = body[i];
  22865. if (line instanceof AST_Var) {
  22866. if (stat && !line.definitions.every((var_def) =>
  22867. !var_def.value
  22868. )) {
  22869. return false;
  22870. }
  22871. } else if (stat) {
  22872. return false;
  22873. } else if (!(line instanceof AST_EmptyStatement)) {
  22874. stat = line;
  22875. }
  22876. }
  22877. return return_value(stat);
  22878. }
  22879. function can_inject_args(block_scoped, safe_to_inject) {
  22880. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  22881. var arg = fn.argnames[i];
  22882. if (arg instanceof AST_DefaultAssign) {
  22883. if (has_flag(arg.left, UNUSED)) continue;
  22884. return false;
  22885. }
  22886. if (arg instanceof AST_Destructuring) return false;
  22887. if (arg instanceof AST_Expansion) {
  22888. if (has_flag(arg.expression, UNUSED)) continue;
  22889. return false;
  22890. }
  22891. if (has_flag(arg, UNUSED)) continue;
  22892. if (!safe_to_inject
  22893. || block_scoped.has(arg.name)
  22894. || identifier_atom.has(arg.name)
  22895. || scope.conflicting_def(arg.name)) {
  22896. return false;
  22897. }
  22898. if (in_loop) in_loop.push(arg.definition());
  22899. }
  22900. return true;
  22901. }
  22902. function can_inject_vars(block_scoped, safe_to_inject) {
  22903. var len = fn.body.length;
  22904. for (var i = 0; i < len; i++) {
  22905. var stat = fn.body[i];
  22906. if (!(stat instanceof AST_Var)) continue;
  22907. if (!safe_to_inject) return false;
  22908. for (var j = stat.definitions.length; --j >= 0;) {
  22909. var name = stat.definitions[j].name;
  22910. if (name instanceof AST_Destructuring
  22911. || block_scoped.has(name.name)
  22912. || identifier_atom.has(name.name)
  22913. || scope.conflicting_def(name.name)) {
  22914. return false;
  22915. }
  22916. if (in_loop) in_loop.push(name.definition());
  22917. }
  22918. }
  22919. return true;
  22920. }
  22921. function can_inject_symbols() {
  22922. var block_scoped = new Set();
  22923. do {
  22924. scope = compressor.parent(++level);
  22925. if (scope.is_block_scope() && scope.block_scope) {
  22926. // TODO this is sometimes undefined during compression.
  22927. // But it should always have a value!
  22928. scope.block_scope.variables.forEach(function (variable) {
  22929. block_scoped.add(variable.name);
  22930. });
  22931. }
  22932. if (scope instanceof AST_Catch) {
  22933. // TODO can we delete? AST_Catch is a block scope.
  22934. if (scope.argname) {
  22935. block_scoped.add(scope.argname.name);
  22936. }
  22937. } else if (scope instanceof AST_IterationStatement) {
  22938. in_loop = [];
  22939. } else if (scope instanceof AST_SymbolRef) {
  22940. if (scope.fixed_value() instanceof AST_Scope) return false;
  22941. }
  22942. } while (!(scope instanceof AST_Scope));
  22943. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  22944. var inline = compressor.option("inline");
  22945. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  22946. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  22947. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  22948. }
  22949. function append_var(decls, expressions, name, value) {
  22950. var def = name.definition();
  22951. // Name already exists, only when a function argument had the same name
  22952. const already_appended = scope.variables.has(name.name);
  22953. if (!already_appended) {
  22954. scope.variables.set(name.name, def);
  22955. scope.enclosed.push(def);
  22956. decls.push(make_node(AST_VarDef, name, {
  22957. name: name,
  22958. value: null
  22959. }));
  22960. }
  22961. var sym = make_node(AST_SymbolRef, name, name);
  22962. def.references.push(sym);
  22963. if (value) expressions.push(make_node(AST_Assign, self, {
  22964. operator: "=",
  22965. logical: false,
  22966. left: sym,
  22967. right: value.clone()
  22968. }));
  22969. }
  22970. function flatten_args(decls, expressions) {
  22971. var len = fn.argnames.length;
  22972. for (var i = self.args.length; --i >= len;) {
  22973. expressions.push(self.args[i]);
  22974. }
  22975. for (i = len; --i >= 0;) {
  22976. var name = fn.argnames[i];
  22977. var value = self.args[i];
  22978. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  22979. if (value) expressions.push(value);
  22980. } else {
  22981. var symbol = make_node(AST_SymbolVar, name, name);
  22982. name.definition().orig.push(symbol);
  22983. if (!value && in_loop) value = make_node(AST_Undefined, self);
  22984. append_var(decls, expressions, symbol, value);
  22985. }
  22986. }
  22987. decls.reverse();
  22988. expressions.reverse();
  22989. }
  22990. function flatten_vars(decls, expressions) {
  22991. var pos = expressions.length;
  22992. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  22993. var stat = fn.body[i];
  22994. if (!(stat instanceof AST_Var)) continue;
  22995. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  22996. var var_def = stat.definitions[j];
  22997. var name = var_def.name;
  22998. append_var(decls, expressions, name, var_def.value);
  22999. if (in_loop && fn.argnames.every((argname) =>
  23000. argname.name != name.name
  23001. )) {
  23002. var def = fn.variables.get(name.name);
  23003. var sym = make_node(AST_SymbolRef, name, name);
  23004. def.references.push(sym);
  23005. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  23006. operator: "=",
  23007. logical: false,
  23008. left: sym,
  23009. right: make_node(AST_Undefined, name)
  23010. }));
  23011. }
  23012. }
  23013. }
  23014. }
  23015. function flatten_fn(returned_value) {
  23016. var decls = [];
  23017. var expressions = [];
  23018. flatten_args(decls, expressions);
  23019. flatten_vars(decls, expressions);
  23020. expressions.push(returned_value);
  23021. if (decls.length) {
  23022. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  23023. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  23024. definitions: decls
  23025. }));
  23026. }
  23027. return expressions.map(exp => exp.clone(true));
  23028. }
  23029. });
  23030. def_optimize(AST_New, function(self, compressor) {
  23031. if (
  23032. compressor.option("unsafe") &&
  23033. is_undeclared_ref(self.expression) &&
  23034. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  23035. ) return make_node(AST_Call, self, self).transform(compressor);
  23036. return self;
  23037. });
  23038. def_optimize(AST_Sequence, function(self, compressor) {
  23039. if (!compressor.option("side_effects")) return self;
  23040. var expressions = [];
  23041. filter_for_side_effects();
  23042. var end = expressions.length - 1;
  23043. trim_right_for_undefined();
  23044. if (end == 0) {
  23045. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  23046. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  23047. return self;
  23048. }
  23049. self.expressions = expressions;
  23050. return self;
  23051. function filter_for_side_effects() {
  23052. var first = first_in_statement(compressor);
  23053. var last = self.expressions.length - 1;
  23054. self.expressions.forEach(function(expr, index) {
  23055. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  23056. if (expr) {
  23057. merge_sequence(expressions, expr);
  23058. first = false;
  23059. }
  23060. });
  23061. }
  23062. function trim_right_for_undefined() {
  23063. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  23064. if (end < expressions.length - 1) {
  23065. expressions[end] = make_node(AST_UnaryPrefix, self, {
  23066. operator : "void",
  23067. expression : expressions[end]
  23068. });
  23069. expressions.length = end + 1;
  23070. }
  23071. }
  23072. });
  23073. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  23074. if (compressor.option("sequences")) {
  23075. if (this.expression instanceof AST_Sequence) {
  23076. var x = this.expression.expressions.slice();
  23077. var e = this.clone();
  23078. e.expression = x.pop();
  23079. x.push(e);
  23080. return make_sequence(this, x).optimize(compressor);
  23081. }
  23082. }
  23083. return this;
  23084. });
  23085. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  23086. return self.lift_sequences(compressor);
  23087. });
  23088. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  23089. var e = self.expression;
  23090. if (self.operator == "delete"
  23091. && !(e instanceof AST_SymbolRef
  23092. || e instanceof AST_PropAccess
  23093. || is_identifier_atom(e))) {
  23094. if (e instanceof AST_Sequence) {
  23095. const exprs = e.expressions.slice();
  23096. exprs.push(make_node(AST_True, self));
  23097. return make_sequence(self, exprs).optimize(compressor);
  23098. }
  23099. return make_sequence(self, [ e, make_node(AST_True, self) ]).optimize(compressor);
  23100. }
  23101. var seq = self.lift_sequences(compressor);
  23102. if (seq !== self) {
  23103. return seq;
  23104. }
  23105. if (compressor.option("side_effects") && self.operator == "void") {
  23106. e = e.drop_side_effect_free(compressor);
  23107. if (e) {
  23108. self.expression = e;
  23109. return self;
  23110. } else {
  23111. return make_node(AST_Undefined, self).optimize(compressor);
  23112. }
  23113. }
  23114. if (compressor.in_boolean_context()) {
  23115. switch (self.operator) {
  23116. case "!":
  23117. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  23118. // !!foo ==> foo, if we're in boolean context
  23119. return e.expression;
  23120. }
  23121. if (e instanceof AST_Binary) {
  23122. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  23123. }
  23124. break;
  23125. case "typeof":
  23126. // typeof always returns a non-empty string, thus it's
  23127. // always true in booleans
  23128. // And we don't need to check if it's undeclared, because in typeof, that's OK
  23129. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  23130. e,
  23131. make_node(AST_True, self)
  23132. ])).optimize(compressor);
  23133. }
  23134. }
  23135. if (self.operator == "-" && e instanceof AST_Infinity) {
  23136. e = e.transform(compressor);
  23137. }
  23138. if (e instanceof AST_Binary
  23139. && (self.operator == "+" || self.operator == "-")
  23140. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  23141. return make_node(AST_Binary, self, {
  23142. operator: e.operator,
  23143. left: make_node(AST_UnaryPrefix, e.left, {
  23144. operator: self.operator,
  23145. expression: e.left
  23146. }),
  23147. right: e.right
  23148. });
  23149. }
  23150. // avoids infinite recursion of numerals
  23151. if (self.operator != "-"
  23152. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)) {
  23153. var ev = self.evaluate(compressor);
  23154. if (ev !== self) {
  23155. ev = make_node_from_constant(ev, self).optimize(compressor);
  23156. return best_of(compressor, ev, self);
  23157. }
  23158. }
  23159. return self;
  23160. });
  23161. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  23162. if (compressor.option("sequences")) {
  23163. if (this.left instanceof AST_Sequence) {
  23164. var x = this.left.expressions.slice();
  23165. var e = this.clone();
  23166. e.left = x.pop();
  23167. x.push(e);
  23168. return make_sequence(this, x).optimize(compressor);
  23169. }
  23170. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  23171. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  23172. var x = this.right.expressions;
  23173. var last = x.length - 1;
  23174. for (var i = 0; i < last; i++) {
  23175. if (!assign && x[i].has_side_effects(compressor)) break;
  23176. }
  23177. if (i == last) {
  23178. x = x.slice();
  23179. var e = this.clone();
  23180. e.right = x.pop();
  23181. x.push(e);
  23182. return make_sequence(this, x).optimize(compressor);
  23183. } else if (i > 0) {
  23184. var e = this.clone();
  23185. e.right = make_sequence(this.right, x.slice(i));
  23186. x = x.slice(0, i);
  23187. x.push(e);
  23188. return make_sequence(this, x).optimize(compressor);
  23189. }
  23190. }
  23191. }
  23192. return this;
  23193. });
  23194. var commutativeOperators = makePredicate("== === != !== * & | ^");
  23195. function is_object(node) {
  23196. return node instanceof AST_Array
  23197. || node instanceof AST_Lambda
  23198. || node instanceof AST_Object
  23199. || node instanceof AST_Class;
  23200. }
  23201. def_optimize(AST_Binary, function(self, compressor) {
  23202. function reversible() {
  23203. return self.left.is_constant()
  23204. || self.right.is_constant()
  23205. || !self.left.has_side_effects(compressor)
  23206. && !self.right.has_side_effects(compressor);
  23207. }
  23208. function reverse(op) {
  23209. if (reversible()) {
  23210. if (op) self.operator = op;
  23211. var tmp = self.left;
  23212. self.left = self.right;
  23213. self.right = tmp;
  23214. }
  23215. }
  23216. if (commutativeOperators.has(self.operator)) {
  23217. if (self.right.is_constant()
  23218. && !self.left.is_constant()) {
  23219. // if right is a constant, whatever side effects the
  23220. // left side might have could not influence the
  23221. // result. hence, force switch.
  23222. if (!(self.left instanceof AST_Binary
  23223. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  23224. reverse();
  23225. }
  23226. }
  23227. }
  23228. self = self.lift_sequences(compressor);
  23229. if (compressor.option("comparisons")) switch (self.operator) {
  23230. case "===":
  23231. case "!==":
  23232. var is_strict_comparison = true;
  23233. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  23234. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  23235. (self.left.is_boolean() && self.right.is_boolean()) ||
  23236. self.left.equivalent_to(self.right)) {
  23237. self.operator = self.operator.substr(0, 2);
  23238. }
  23239. // XXX: intentionally falling down to the next case
  23240. case "==":
  23241. case "!=":
  23242. // void 0 == x => null == x
  23243. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  23244. self.left = make_node(AST_Null, self.left);
  23245. } else if (compressor.option("typeofs")
  23246. // "undefined" == typeof x => undefined === x
  23247. && self.left instanceof AST_String
  23248. && self.left.value == "undefined"
  23249. && self.right instanceof AST_UnaryPrefix
  23250. && self.right.operator == "typeof") {
  23251. var expr = self.right.expression;
  23252. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  23253. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  23254. self.right = expr;
  23255. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  23256. if (self.operator.length == 2) self.operator += "=";
  23257. }
  23258. } else if (self.left instanceof AST_SymbolRef
  23259. // obj !== obj => false
  23260. && self.right instanceof AST_SymbolRef
  23261. && self.left.definition() === self.right.definition()
  23262. && is_object(self.left.fixed_value())) {
  23263. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  23264. }
  23265. break;
  23266. case "&&":
  23267. case "||":
  23268. var lhs = self.left;
  23269. if (lhs.operator == self.operator) {
  23270. lhs = lhs.right;
  23271. }
  23272. if (lhs instanceof AST_Binary
  23273. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  23274. && self.right instanceof AST_Binary
  23275. && lhs.operator == self.right.operator
  23276. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  23277. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  23278. && !lhs.right.has_side_effects(compressor)
  23279. && lhs.right.equivalent_to(self.right.right)) {
  23280. var combined = make_node(AST_Binary, self, {
  23281. operator: lhs.operator.slice(0, -1),
  23282. left: make_node(AST_Null, self),
  23283. right: lhs.right
  23284. });
  23285. if (lhs !== self.left) {
  23286. combined = make_node(AST_Binary, self, {
  23287. operator: self.operator,
  23288. left: self.left.left,
  23289. right: combined
  23290. });
  23291. }
  23292. return combined;
  23293. }
  23294. break;
  23295. }
  23296. if (self.operator == "+" && compressor.in_boolean_context()) {
  23297. var ll = self.left.evaluate(compressor);
  23298. var rr = self.right.evaluate(compressor);
  23299. if (ll && typeof ll == "string") {
  23300. return make_sequence(self, [
  23301. self.right,
  23302. make_node(AST_True, self)
  23303. ]).optimize(compressor);
  23304. }
  23305. if (rr && typeof rr == "string") {
  23306. return make_sequence(self, [
  23307. self.left,
  23308. make_node(AST_True, self)
  23309. ]).optimize(compressor);
  23310. }
  23311. }
  23312. if (compressor.option("comparisons") && self.is_boolean()) {
  23313. if (!(compressor.parent() instanceof AST_Binary)
  23314. || compressor.parent() instanceof AST_Assign) {
  23315. var negated = make_node(AST_UnaryPrefix, self, {
  23316. operator: "!",
  23317. expression: self.negate(compressor, first_in_statement(compressor))
  23318. });
  23319. self = best_of(compressor, self, negated);
  23320. }
  23321. if (compressor.option("unsafe_comps")) {
  23322. switch (self.operator) {
  23323. case "<": reverse(">"); break;
  23324. case "<=": reverse(">="); break;
  23325. }
  23326. }
  23327. }
  23328. if (self.operator == "+") {
  23329. if (self.right instanceof AST_String
  23330. && self.right.getValue() == ""
  23331. && self.left.is_string(compressor)) {
  23332. return self.left;
  23333. }
  23334. if (self.left instanceof AST_String
  23335. && self.left.getValue() == ""
  23336. && self.right.is_string(compressor)) {
  23337. return self.right;
  23338. }
  23339. if (self.left instanceof AST_Binary
  23340. && self.left.operator == "+"
  23341. && self.left.left instanceof AST_String
  23342. && self.left.left.getValue() == ""
  23343. && self.right.is_string(compressor)) {
  23344. self.left = self.left.right;
  23345. return self;
  23346. }
  23347. }
  23348. if (compressor.option("evaluate")) {
  23349. switch (self.operator) {
  23350. case "&&":
  23351. var ll = has_flag(self.left, TRUTHY)
  23352. ? true
  23353. : has_flag(self.left, FALSY)
  23354. ? false
  23355. : self.left.evaluate(compressor);
  23356. if (!ll) {
  23357. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  23358. } else if (!(ll instanceof AST_Node)) {
  23359. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  23360. }
  23361. var rr = self.right.evaluate(compressor);
  23362. if (!rr) {
  23363. if (compressor.in_boolean_context()) {
  23364. return make_sequence(self, [
  23365. self.left,
  23366. make_node(AST_False, self)
  23367. ]).optimize(compressor);
  23368. } else {
  23369. set_flag(self, FALSY);
  23370. }
  23371. } else if (!(rr instanceof AST_Node)) {
  23372. var parent = compressor.parent();
  23373. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  23374. return self.left.optimize(compressor);
  23375. }
  23376. }
  23377. // x || false && y ---> x ? y : false
  23378. if (self.left.operator == "||") {
  23379. var lr = self.left.right.evaluate(compressor);
  23380. if (!lr) return make_node(AST_Conditional, self, {
  23381. condition: self.left.left,
  23382. consequent: self.right,
  23383. alternative: self.left.right
  23384. }).optimize(compressor);
  23385. }
  23386. break;
  23387. case "||":
  23388. var ll = has_flag(self.left, TRUTHY)
  23389. ? true
  23390. : has_flag(self.left, FALSY)
  23391. ? false
  23392. : self.left.evaluate(compressor);
  23393. if (!ll) {
  23394. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  23395. } else if (!(ll instanceof AST_Node)) {
  23396. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  23397. }
  23398. var rr = self.right.evaluate(compressor);
  23399. if (!rr) {
  23400. var parent = compressor.parent();
  23401. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  23402. return self.left.optimize(compressor);
  23403. }
  23404. } else if (!(rr instanceof AST_Node)) {
  23405. if (compressor.in_boolean_context()) {
  23406. return make_sequence(self, [
  23407. self.left,
  23408. make_node(AST_True, self)
  23409. ]).optimize(compressor);
  23410. } else {
  23411. set_flag(self, TRUTHY);
  23412. }
  23413. }
  23414. if (self.left.operator == "&&") {
  23415. var lr = self.left.right.evaluate(compressor);
  23416. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  23417. condition: self.left.left,
  23418. consequent: self.left.right,
  23419. alternative: self.right
  23420. }).optimize(compressor);
  23421. }
  23422. break;
  23423. case "??":
  23424. if (is_nullish(self.left, compressor)) {
  23425. return self.right;
  23426. }
  23427. var ll = self.left.evaluate(compressor);
  23428. if (!(ll instanceof AST_Node)) {
  23429. // if we know the value for sure we can simply compute right away.
  23430. return ll == null ? self.right : self.left;
  23431. }
  23432. if (compressor.in_boolean_context()) {
  23433. const rr = self.right.evaluate(compressor);
  23434. if (!(rr instanceof AST_Node) && !rr) {
  23435. return self.left;
  23436. }
  23437. }
  23438. }
  23439. var associative = true;
  23440. switch (self.operator) {
  23441. case "+":
  23442. // (x + "foo") + "bar" => x + "foobar"
  23443. if (self.right instanceof AST_Constant
  23444. && self.left instanceof AST_Binary
  23445. && self.left.operator == "+"
  23446. && self.left.is_string(compressor)) {
  23447. var binary = make_node(AST_Binary, self, {
  23448. operator: "+",
  23449. left: self.left.right,
  23450. right: self.right,
  23451. });
  23452. var r = binary.optimize(compressor);
  23453. if (binary !== r) {
  23454. self = make_node(AST_Binary, self, {
  23455. operator: "+",
  23456. left: self.left.left,
  23457. right: r
  23458. });
  23459. }
  23460. }
  23461. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  23462. if (self.left instanceof AST_Binary
  23463. && self.left.operator == "+"
  23464. && self.left.is_string(compressor)
  23465. && self.right instanceof AST_Binary
  23466. && self.right.operator == "+"
  23467. && self.right.is_string(compressor)) {
  23468. var binary = make_node(AST_Binary, self, {
  23469. operator: "+",
  23470. left: self.left.right,
  23471. right: self.right.left,
  23472. });
  23473. var m = binary.optimize(compressor);
  23474. if (binary !== m) {
  23475. self = make_node(AST_Binary, self, {
  23476. operator: "+",
  23477. left: make_node(AST_Binary, self.left, {
  23478. operator: "+",
  23479. left: self.left.left,
  23480. right: m
  23481. }),
  23482. right: self.right.right
  23483. });
  23484. }
  23485. }
  23486. // a + -b => a - b
  23487. if (self.right instanceof AST_UnaryPrefix
  23488. && self.right.operator == "-"
  23489. && self.left.is_number(compressor)) {
  23490. self = make_node(AST_Binary, self, {
  23491. operator: "-",
  23492. left: self.left,
  23493. right: self.right.expression
  23494. });
  23495. break;
  23496. }
  23497. // -a + b => b - a
  23498. if (self.left instanceof AST_UnaryPrefix
  23499. && self.left.operator == "-"
  23500. && reversible()
  23501. && self.right.is_number(compressor)) {
  23502. self = make_node(AST_Binary, self, {
  23503. operator: "-",
  23504. left: self.right,
  23505. right: self.left.expression
  23506. });
  23507. break;
  23508. }
  23509. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  23510. if (self.left instanceof AST_TemplateString) {
  23511. var l = self.left;
  23512. var r = self.right.evaluate(compressor);
  23513. if (r != self.right) {
  23514. l.segments[l.segments.length - 1].value += String(r);
  23515. return l;
  23516. }
  23517. }
  23518. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  23519. if (self.right instanceof AST_TemplateString) {
  23520. var r = self.right;
  23521. var l = self.left.evaluate(compressor);
  23522. if (l != self.left) {
  23523. r.segments[0].value = String(l) + r.segments[0].value;
  23524. return r;
  23525. }
  23526. }
  23527. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  23528. if (self.left instanceof AST_TemplateString
  23529. && self.right instanceof AST_TemplateString) {
  23530. var l = self.left;
  23531. var segments = l.segments;
  23532. var r = self.right;
  23533. segments[segments.length - 1].value += r.segments[0].value;
  23534. for (var i = 1; i < r.segments.length; i++) {
  23535. segments.push(r.segments[i]);
  23536. }
  23537. return l;
  23538. }
  23539. case "*":
  23540. associative = compressor.option("unsafe_math");
  23541. case "&":
  23542. case "|":
  23543. case "^":
  23544. // a + +b => +b + a
  23545. if (self.left.is_number(compressor)
  23546. && self.right.is_number(compressor)
  23547. && reversible()
  23548. && !(self.left instanceof AST_Binary
  23549. && self.left.operator != self.operator
  23550. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  23551. var reversed = make_node(AST_Binary, self, {
  23552. operator: self.operator,
  23553. left: self.right,
  23554. right: self.left
  23555. });
  23556. if (self.right instanceof AST_Constant
  23557. && !(self.left instanceof AST_Constant)) {
  23558. self = best_of(compressor, reversed, self);
  23559. } else {
  23560. self = best_of(compressor, self, reversed);
  23561. }
  23562. }
  23563. if (associative && self.is_number(compressor)) {
  23564. // a + (b + c) => (a + b) + c
  23565. if (self.right instanceof AST_Binary
  23566. && self.right.operator == self.operator) {
  23567. self = make_node(AST_Binary, self, {
  23568. operator: self.operator,
  23569. left: make_node(AST_Binary, self.left, {
  23570. operator: self.operator,
  23571. left: self.left,
  23572. right: self.right.left,
  23573. start: self.left.start,
  23574. end: self.right.left.end
  23575. }),
  23576. right: self.right.right
  23577. });
  23578. }
  23579. // (n + 2) + 3 => 5 + n
  23580. // (2 * n) * 3 => 6 + n
  23581. if (self.right instanceof AST_Constant
  23582. && self.left instanceof AST_Binary
  23583. && self.left.operator == self.operator) {
  23584. if (self.left.left instanceof AST_Constant) {
  23585. self = make_node(AST_Binary, self, {
  23586. operator: self.operator,
  23587. left: make_node(AST_Binary, self.left, {
  23588. operator: self.operator,
  23589. left: self.left.left,
  23590. right: self.right,
  23591. start: self.left.left.start,
  23592. end: self.right.end
  23593. }),
  23594. right: self.left.right
  23595. });
  23596. } else if (self.left.right instanceof AST_Constant) {
  23597. self = make_node(AST_Binary, self, {
  23598. operator: self.operator,
  23599. left: make_node(AST_Binary, self.left, {
  23600. operator: self.operator,
  23601. left: self.left.right,
  23602. right: self.right,
  23603. start: self.left.right.start,
  23604. end: self.right.end
  23605. }),
  23606. right: self.left.left
  23607. });
  23608. }
  23609. }
  23610. // (a | 1) | (2 | d) => (3 | a) | b
  23611. if (self.left instanceof AST_Binary
  23612. && self.left.operator == self.operator
  23613. && self.left.right instanceof AST_Constant
  23614. && self.right instanceof AST_Binary
  23615. && self.right.operator == self.operator
  23616. && self.right.left instanceof AST_Constant) {
  23617. self = make_node(AST_Binary, self, {
  23618. operator: self.operator,
  23619. left: make_node(AST_Binary, self.left, {
  23620. operator: self.operator,
  23621. left: make_node(AST_Binary, self.left.left, {
  23622. operator: self.operator,
  23623. left: self.left.right,
  23624. right: self.right.left,
  23625. start: self.left.right.start,
  23626. end: self.right.left.end
  23627. }),
  23628. right: self.left.left
  23629. }),
  23630. right: self.right.right
  23631. });
  23632. }
  23633. }
  23634. }
  23635. }
  23636. // x && (y && z) ==> x && y && z
  23637. // x || (y || z) ==> x || y || z
  23638. // x + ("y" + z) ==> x + "y" + z
  23639. // "x" + (y + "z")==> "x" + y + "z"
  23640. if (self.right instanceof AST_Binary
  23641. && self.right.operator == self.operator
  23642. && (lazy_op.has(self.operator)
  23643. || (self.operator == "+"
  23644. && (self.right.left.is_string(compressor)
  23645. || (self.left.is_string(compressor)
  23646. && self.right.right.is_string(compressor)))))
  23647. ) {
  23648. self.left = make_node(AST_Binary, self.left, {
  23649. operator : self.operator,
  23650. left : self.left.transform(compressor),
  23651. right : self.right.left.transform(compressor)
  23652. });
  23653. self.right = self.right.right.transform(compressor);
  23654. return self.transform(compressor);
  23655. }
  23656. var ev = self.evaluate(compressor);
  23657. if (ev !== self) {
  23658. ev = make_node_from_constant(ev, self).optimize(compressor);
  23659. return best_of(compressor, ev, self);
  23660. }
  23661. return self;
  23662. });
  23663. def_optimize(AST_SymbolExport, function(self) {
  23664. return self;
  23665. });
  23666. function within_array_or_object_literal(compressor) {
  23667. var node, level = 0;
  23668. while (node = compressor.parent(level++)) {
  23669. if (node instanceof AST_Statement) return false;
  23670. if (node instanceof AST_Array
  23671. || node instanceof AST_ObjectKeyVal
  23672. || node instanceof AST_Object) {
  23673. return true;
  23674. }
  23675. }
  23676. return false;
  23677. }
  23678. def_optimize(AST_SymbolRef, function(self, compressor) {
  23679. if (
  23680. !compressor.option("ie8")
  23681. && is_undeclared_ref(self)
  23682. && !compressor.find_parent(AST_With)
  23683. ) {
  23684. switch (self.name) {
  23685. case "undefined":
  23686. return make_node(AST_Undefined, self).optimize(compressor);
  23687. case "NaN":
  23688. return make_node(AST_NaN, self).optimize(compressor);
  23689. case "Infinity":
  23690. return make_node(AST_Infinity, self).optimize(compressor);
  23691. }
  23692. }
  23693. const parent = compressor.parent();
  23694. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  23695. const def = self.definition();
  23696. const nearest_scope = find_scope(compressor);
  23697. if (compressor.top_retain && def.global && compressor.top_retain(def)) {
  23698. def.fixed = false;
  23699. def.single_use = false;
  23700. return self;
  23701. }
  23702. let fixed = self.fixed_value();
  23703. let single_use = def.single_use
  23704. && !(parent instanceof AST_Call
  23705. && (parent.is_callee_pure(compressor))
  23706. || has_annotation(parent, _NOINLINE))
  23707. && !(parent instanceof AST_Export
  23708. && fixed instanceof AST_Lambda
  23709. && fixed.name);
  23710. if (single_use && fixed instanceof AST_Node) {
  23711. single_use =
  23712. !fixed.has_side_effects(compressor)
  23713. && !fixed.may_throw(compressor);
  23714. }
  23715. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  23716. if (retain_top_func(fixed, compressor)) {
  23717. single_use = false;
  23718. } else if (def.scope !== self.scope
  23719. && (def.escaped == 1
  23720. || has_flag(fixed, INLINED)
  23721. || within_array_or_object_literal(compressor)
  23722. || !compressor.option("reduce_funcs"))) {
  23723. single_use = false;
  23724. } else if (is_recursive_ref(compressor, def)) {
  23725. single_use = false;
  23726. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  23727. single_use = fixed.is_constant_expression(self.scope);
  23728. if (single_use == "f") {
  23729. var scope = self.scope;
  23730. do {
  23731. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  23732. set_flag(scope, INLINED);
  23733. }
  23734. } while (scope = scope.parent_scope);
  23735. }
  23736. }
  23737. }
  23738. if (single_use && fixed instanceof AST_Lambda) {
  23739. single_use =
  23740. def.scope === self.scope
  23741. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  23742. || parent instanceof AST_Call
  23743. && parent.expression === self
  23744. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  23745. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  23746. }
  23747. if (single_use && fixed) {
  23748. if (fixed instanceof AST_DefClass) {
  23749. set_flag(fixed, SQUEEZED);
  23750. fixed = make_node(AST_ClassExpression, fixed, fixed);
  23751. }
  23752. if (fixed instanceof AST_Defun) {
  23753. set_flag(fixed, SQUEEZED);
  23754. fixed = make_node(AST_Function, fixed, fixed);
  23755. }
  23756. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  23757. const defun_def = fixed.name.definition();
  23758. let lambda_def = fixed.variables.get(fixed.name.name);
  23759. let name = lambda_def && lambda_def.orig[0];
  23760. if (!(name instanceof AST_SymbolLambda)) {
  23761. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  23762. name.scope = fixed;
  23763. fixed.name = name;
  23764. lambda_def = fixed.def_function(name);
  23765. }
  23766. walk(fixed, node => {
  23767. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  23768. node.thedef = lambda_def;
  23769. lambda_def.references.push(node);
  23770. }
  23771. });
  23772. }
  23773. if (
  23774. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  23775. && fixed.parent_scope !== nearest_scope
  23776. ) {
  23777. fixed = fixed.clone(true, compressor.get_toplevel());
  23778. nearest_scope.add_child_scope(fixed);
  23779. }
  23780. return fixed.optimize(compressor);
  23781. }
  23782. // multiple uses
  23783. if (fixed) {
  23784. let replace;
  23785. if (fixed instanceof AST_This) {
  23786. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  23787. && def.references.every((ref) =>
  23788. def.scope === ref.scope
  23789. )) {
  23790. replace = fixed;
  23791. }
  23792. } else {
  23793. var ev = fixed.evaluate(compressor);
  23794. if (
  23795. ev !== fixed
  23796. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  23797. ) {
  23798. replace = make_node_from_constant(ev, fixed);
  23799. }
  23800. }
  23801. if (replace) {
  23802. const name_length = self.size(compressor);
  23803. const replace_size = replace.size(compressor);
  23804. let overhead = 0;
  23805. if (compressor.option("unused") && !compressor.exposed(def)) {
  23806. overhead =
  23807. (name_length + 2 + replace_size) /
  23808. (def.references.length - def.assignments);
  23809. }
  23810. if (replace_size <= name_length + overhead) {
  23811. return replace;
  23812. }
  23813. }
  23814. }
  23815. }
  23816. return self;
  23817. });
  23818. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  23819. for (const enclosed of pulled_scope.enclosed) {
  23820. if (pulled_scope.variables.has(enclosed.name)) {
  23821. continue;
  23822. }
  23823. const looked_up = scope.find_variable(enclosed.name);
  23824. if (looked_up) {
  23825. if (looked_up === enclosed) continue;
  23826. return true;
  23827. }
  23828. }
  23829. return false;
  23830. }
  23831. function is_atomic(lhs, self) {
  23832. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  23833. }
  23834. def_optimize(AST_Undefined, function(self, compressor) {
  23835. if (compressor.option("unsafe_undefined")) {
  23836. var undef = find_variable(compressor, "undefined");
  23837. if (undef) {
  23838. var ref = make_node(AST_SymbolRef, self, {
  23839. name : "undefined",
  23840. scope : undef.scope,
  23841. thedef : undef
  23842. });
  23843. set_flag(ref, UNDEFINED);
  23844. return ref;
  23845. }
  23846. }
  23847. var lhs = is_lhs(compressor.self(), compressor.parent());
  23848. if (lhs && is_atomic(lhs, self)) return self;
  23849. return make_node(AST_UnaryPrefix, self, {
  23850. operator: "void",
  23851. expression: make_node(AST_Number, self, {
  23852. value: 0
  23853. })
  23854. });
  23855. });
  23856. def_optimize(AST_Infinity, function(self, compressor) {
  23857. var lhs = is_lhs(compressor.self(), compressor.parent());
  23858. if (lhs && is_atomic(lhs, self)) return self;
  23859. if (
  23860. compressor.option("keep_infinity")
  23861. && !(lhs && !is_atomic(lhs, self))
  23862. && !find_variable(compressor, "Infinity")
  23863. ) {
  23864. return self;
  23865. }
  23866. return make_node(AST_Binary, self, {
  23867. operator: "/",
  23868. left: make_node(AST_Number, self, {
  23869. value: 1
  23870. }),
  23871. right: make_node(AST_Number, self, {
  23872. value: 0
  23873. })
  23874. });
  23875. });
  23876. def_optimize(AST_NaN, function(self, compressor) {
  23877. var lhs = is_lhs(compressor.self(), compressor.parent());
  23878. if (lhs && !is_atomic(lhs, self)
  23879. || find_variable(compressor, "NaN")) {
  23880. return make_node(AST_Binary, self, {
  23881. operator: "/",
  23882. left: make_node(AST_Number, self, {
  23883. value: 0
  23884. }),
  23885. right: make_node(AST_Number, self, {
  23886. value: 0
  23887. })
  23888. });
  23889. }
  23890. return self;
  23891. });
  23892. function is_reachable(self, defs) {
  23893. const find_ref = node => {
  23894. if (node instanceof AST_SymbolRef && member(node.definition(), defs)) {
  23895. return walk_abort;
  23896. }
  23897. };
  23898. return walk_parent(self, (node, info) => {
  23899. if (node instanceof AST_Scope && node !== self) {
  23900. var parent = info.parent();
  23901. if (parent instanceof AST_Call && parent.expression === node) return;
  23902. if (walk(node, find_ref)) return walk_abort;
  23903. return true;
  23904. }
  23905. });
  23906. }
  23907. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  23908. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  23909. def_optimize(AST_Assign, function(self, compressor) {
  23910. if (self.logical) {
  23911. return self.lift_sequences(compressor);
  23912. }
  23913. var def;
  23914. if (compressor.option("dead_code")
  23915. && self.left instanceof AST_SymbolRef
  23916. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  23917. var level = 0, node, parent = self;
  23918. do {
  23919. node = parent;
  23920. parent = compressor.parent(level++);
  23921. if (parent instanceof AST_Exit) {
  23922. if (in_try(level, parent)) break;
  23923. if (is_reachable(def.scope, [ def ])) break;
  23924. if (self.operator == "=") return self.right;
  23925. def.fixed = false;
  23926. return make_node(AST_Binary, self, {
  23927. operator: self.operator.slice(0, -1),
  23928. left: self.left,
  23929. right: self.right
  23930. }).optimize(compressor);
  23931. }
  23932. } while (parent instanceof AST_Binary && parent.right === node
  23933. || parent instanceof AST_Sequence && parent.tail_node() === node);
  23934. }
  23935. self = self.lift_sequences(compressor);
  23936. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  23937. // x = expr1 OP expr2
  23938. if (self.right.left instanceof AST_SymbolRef
  23939. && self.right.left.name == self.left.name
  23940. && ASSIGN_OPS.has(self.right.operator)) {
  23941. // x = x - 2 ---> x -= 2
  23942. self.operator = self.right.operator + "=";
  23943. self.right = self.right.right;
  23944. } else if (self.right.right instanceof AST_SymbolRef
  23945. && self.right.right.name == self.left.name
  23946. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  23947. && !self.right.left.has_side_effects(compressor)) {
  23948. // x = 2 & x ---> x &= 2
  23949. self.operator = self.right.operator + "=";
  23950. self.right = self.right.left;
  23951. }
  23952. }
  23953. return self;
  23954. function in_try(level, node) {
  23955. var right = self.right;
  23956. self.right = make_node(AST_Null, right);
  23957. var may_throw = node.may_throw(compressor);
  23958. self.right = right;
  23959. var scope = self.left.definition().scope;
  23960. var parent;
  23961. while ((parent = compressor.parent(level++)) !== scope) {
  23962. if (parent instanceof AST_Try) {
  23963. if (parent.bfinally) return true;
  23964. if (may_throw && parent.bcatch) return true;
  23965. }
  23966. }
  23967. }
  23968. });
  23969. def_optimize(AST_DefaultAssign, function(self, compressor) {
  23970. if (!compressor.option("evaluate")) {
  23971. return self;
  23972. }
  23973. var evaluateRight = self.right.evaluate(compressor);
  23974. // `[x = undefined] = foo` ---> `[x] = foo`
  23975. if (evaluateRight === undefined) {
  23976. self = self.left;
  23977. } else if (evaluateRight !== self.right) {
  23978. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  23979. self.right = best_of_expression(evaluateRight, self.right);
  23980. }
  23981. return self;
  23982. });
  23983. function is_nullish_check(check, check_subject, compressor) {
  23984. if (check_subject.may_throw(compressor)) return false;
  23985. let nullish_side;
  23986. // foo == null
  23987. if (
  23988. check instanceof AST_Binary
  23989. && check.operator === "=="
  23990. // which side is nullish?
  23991. && (
  23992. (nullish_side = is_nullish(check.left, compressor) && check.left)
  23993. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  23994. )
  23995. // is the other side the same as the check_subject
  23996. && (
  23997. nullish_side === check.left
  23998. ? check.right
  23999. : check.left
  24000. ).equivalent_to(check_subject)
  24001. ) {
  24002. return true;
  24003. }
  24004. // foo === null || foo === undefined
  24005. if (check instanceof AST_Binary && check.operator === "||") {
  24006. let null_cmp;
  24007. let undefined_cmp;
  24008. const find_comparison = cmp => {
  24009. if (!(
  24010. cmp instanceof AST_Binary
  24011. && (cmp.operator === "===" || cmp.operator === "==")
  24012. )) {
  24013. return false;
  24014. }
  24015. let found = 0;
  24016. let defined_side;
  24017. if (cmp.left instanceof AST_Null) {
  24018. found++;
  24019. null_cmp = cmp;
  24020. defined_side = cmp.right;
  24021. }
  24022. if (cmp.right instanceof AST_Null) {
  24023. found++;
  24024. null_cmp = cmp;
  24025. defined_side = cmp.left;
  24026. }
  24027. if (is_undefined(cmp.left, compressor)) {
  24028. found++;
  24029. undefined_cmp = cmp;
  24030. defined_side = cmp.right;
  24031. }
  24032. if (is_undefined(cmp.right, compressor)) {
  24033. found++;
  24034. undefined_cmp = cmp;
  24035. defined_side = cmp.left;
  24036. }
  24037. if (found !== 1) {
  24038. return false;
  24039. }
  24040. if (!defined_side.equivalent_to(check_subject)) {
  24041. return false;
  24042. }
  24043. return true;
  24044. };
  24045. if (!find_comparison(check.left)) return false;
  24046. if (!find_comparison(check.right)) return false;
  24047. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  24048. return true;
  24049. }
  24050. }
  24051. return false;
  24052. }
  24053. def_optimize(AST_Conditional, function(self, compressor) {
  24054. if (!compressor.option("conditionals")) return self;
  24055. // This looks like lift_sequences(), should probably be under "sequences"
  24056. if (self.condition instanceof AST_Sequence) {
  24057. var expressions = self.condition.expressions.slice();
  24058. self.condition = expressions.pop();
  24059. expressions.push(self);
  24060. return make_sequence(self, expressions);
  24061. }
  24062. var cond = self.condition.evaluate(compressor);
  24063. if (cond !== self.condition) {
  24064. if (cond) {
  24065. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  24066. } else {
  24067. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  24068. }
  24069. }
  24070. var negated = cond.negate(compressor, first_in_statement(compressor));
  24071. if (best_of(compressor, cond, negated) === negated) {
  24072. self = make_node(AST_Conditional, self, {
  24073. condition: negated,
  24074. consequent: self.alternative,
  24075. alternative: self.consequent
  24076. });
  24077. }
  24078. var condition = self.condition;
  24079. var consequent = self.consequent;
  24080. var alternative = self.alternative;
  24081. // x?x:y --> x||y
  24082. if (condition instanceof AST_SymbolRef
  24083. && consequent instanceof AST_SymbolRef
  24084. && condition.definition() === consequent.definition()) {
  24085. return make_node(AST_Binary, self, {
  24086. operator: "||",
  24087. left: condition,
  24088. right: alternative
  24089. });
  24090. }
  24091. // if (foo) exp = something; else exp = something_else;
  24092. // |
  24093. // v
  24094. // exp = foo ? something : something_else;
  24095. if (
  24096. consequent instanceof AST_Assign
  24097. && alternative instanceof AST_Assign
  24098. && consequent.operator === alternative.operator
  24099. && consequent.logical === alternative.logical
  24100. && consequent.left.equivalent_to(alternative.left)
  24101. && (!self.condition.has_side_effects(compressor)
  24102. || consequent.operator == "="
  24103. && !consequent.left.has_side_effects(compressor))
  24104. ) {
  24105. return make_node(AST_Assign, self, {
  24106. operator: consequent.operator,
  24107. left: consequent.left,
  24108. logical: consequent.logical,
  24109. right: make_node(AST_Conditional, self, {
  24110. condition: self.condition,
  24111. consequent: consequent.right,
  24112. alternative: alternative.right
  24113. })
  24114. });
  24115. }
  24116. // x ? y(a) : y(b) --> y(x ? a : b)
  24117. var arg_index;
  24118. if (consequent instanceof AST_Call
  24119. && alternative.TYPE === consequent.TYPE
  24120. && consequent.args.length > 0
  24121. && consequent.args.length == alternative.args.length
  24122. && consequent.expression.equivalent_to(alternative.expression)
  24123. && !self.condition.has_side_effects(compressor)
  24124. && !consequent.expression.has_side_effects(compressor)
  24125. && typeof (arg_index = single_arg_diff()) == "number") {
  24126. var node = consequent.clone();
  24127. node.args[arg_index] = make_node(AST_Conditional, self, {
  24128. condition: self.condition,
  24129. consequent: consequent.args[arg_index],
  24130. alternative: alternative.args[arg_index]
  24131. });
  24132. return node;
  24133. }
  24134. // a ? b : c ? b : d --> (a || c) ? b : d
  24135. if (alternative instanceof AST_Conditional
  24136. && consequent.equivalent_to(alternative.consequent)) {
  24137. return make_node(AST_Conditional, self, {
  24138. condition: make_node(AST_Binary, self, {
  24139. operator: "||",
  24140. left: condition,
  24141. right: alternative.condition
  24142. }),
  24143. consequent: consequent,
  24144. alternative: alternative.alternative
  24145. }).optimize(compressor);
  24146. }
  24147. // a == null ? b : a -> a ?? b
  24148. if (
  24149. compressor.option("ecma") >= 2020 &&
  24150. is_nullish_check(condition, alternative, compressor)
  24151. ) {
  24152. return make_node(AST_Binary, self, {
  24153. operator: "??",
  24154. left: alternative,
  24155. right: consequent
  24156. }).optimize(compressor);
  24157. }
  24158. // a ? b : (c, b) --> (a || c), b
  24159. if (alternative instanceof AST_Sequence
  24160. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  24161. return make_sequence(self, [
  24162. make_node(AST_Binary, self, {
  24163. operator: "||",
  24164. left: condition,
  24165. right: make_sequence(self, alternative.expressions.slice(0, -1))
  24166. }),
  24167. consequent
  24168. ]).optimize(compressor);
  24169. }
  24170. // a ? b : (c && b) --> (a || c) && b
  24171. if (alternative instanceof AST_Binary
  24172. && alternative.operator == "&&"
  24173. && consequent.equivalent_to(alternative.right)) {
  24174. return make_node(AST_Binary, self, {
  24175. operator: "&&",
  24176. left: make_node(AST_Binary, self, {
  24177. operator: "||",
  24178. left: condition,
  24179. right: alternative.left
  24180. }),
  24181. right: consequent
  24182. }).optimize(compressor);
  24183. }
  24184. // x?y?z:a:a --> x&&y?z:a
  24185. if (consequent instanceof AST_Conditional
  24186. && consequent.alternative.equivalent_to(alternative)) {
  24187. return make_node(AST_Conditional, self, {
  24188. condition: make_node(AST_Binary, self, {
  24189. left: self.condition,
  24190. operator: "&&",
  24191. right: consequent.condition
  24192. }),
  24193. consequent: consequent.consequent,
  24194. alternative: alternative
  24195. });
  24196. }
  24197. // x ? y : y --> x, y
  24198. if (consequent.equivalent_to(alternative)) {
  24199. return make_sequence(self, [
  24200. self.condition,
  24201. consequent
  24202. ]).optimize(compressor);
  24203. }
  24204. // x ? y || z : z --> x && y || z
  24205. if (consequent instanceof AST_Binary
  24206. && consequent.operator == "||"
  24207. && consequent.right.equivalent_to(alternative)) {
  24208. return make_node(AST_Binary, self, {
  24209. operator: "||",
  24210. left: make_node(AST_Binary, self, {
  24211. operator: "&&",
  24212. left: self.condition,
  24213. right: consequent.left
  24214. }),
  24215. right: alternative
  24216. }).optimize(compressor);
  24217. }
  24218. const in_bool = compressor.in_boolean_context();
  24219. if (is_true(self.consequent)) {
  24220. if (is_false(self.alternative)) {
  24221. // c ? true : false ---> !!c
  24222. return booleanize(self.condition);
  24223. }
  24224. // c ? true : x ---> !!c || x
  24225. return make_node(AST_Binary, self, {
  24226. operator: "||",
  24227. left: booleanize(self.condition),
  24228. right: self.alternative
  24229. });
  24230. }
  24231. if (is_false(self.consequent)) {
  24232. if (is_true(self.alternative)) {
  24233. // c ? false : true ---> !c
  24234. return booleanize(self.condition.negate(compressor));
  24235. }
  24236. // c ? false : x ---> !c && x
  24237. return make_node(AST_Binary, self, {
  24238. operator: "&&",
  24239. left: booleanize(self.condition.negate(compressor)),
  24240. right: self.alternative
  24241. });
  24242. }
  24243. if (is_true(self.alternative)) {
  24244. // c ? x : true ---> !c || x
  24245. return make_node(AST_Binary, self, {
  24246. operator: "||",
  24247. left: booleanize(self.condition.negate(compressor)),
  24248. right: self.consequent
  24249. });
  24250. }
  24251. if (is_false(self.alternative)) {
  24252. // c ? x : false ---> !!c && x
  24253. return make_node(AST_Binary, self, {
  24254. operator: "&&",
  24255. left: booleanize(self.condition),
  24256. right: self.consequent
  24257. });
  24258. }
  24259. return self;
  24260. function booleanize(node) {
  24261. if (node.is_boolean()) return node;
  24262. // !!expression
  24263. return make_node(AST_UnaryPrefix, node, {
  24264. operator: "!",
  24265. expression: node.negate(compressor)
  24266. });
  24267. }
  24268. // AST_True or !0
  24269. function is_true(node) {
  24270. return node instanceof AST_True
  24271. || in_bool
  24272. && node instanceof AST_Constant
  24273. && node.getValue()
  24274. || (node instanceof AST_UnaryPrefix
  24275. && node.operator == "!"
  24276. && node.expression instanceof AST_Constant
  24277. && !node.expression.getValue());
  24278. }
  24279. // AST_False or !1
  24280. function is_false(node) {
  24281. return node instanceof AST_False
  24282. || in_bool
  24283. && node instanceof AST_Constant
  24284. && !node.getValue()
  24285. || (node instanceof AST_UnaryPrefix
  24286. && node.operator == "!"
  24287. && node.expression instanceof AST_Constant
  24288. && node.expression.getValue());
  24289. }
  24290. function single_arg_diff() {
  24291. var a = consequent.args;
  24292. var b = alternative.args;
  24293. for (var i = 0, len = a.length; i < len; i++) {
  24294. if (a[i] instanceof AST_Expansion) return;
  24295. if (!a[i].equivalent_to(b[i])) {
  24296. if (b[i] instanceof AST_Expansion) return;
  24297. for (var j = i + 1; j < len; j++) {
  24298. if (a[j] instanceof AST_Expansion) return;
  24299. if (!a[j].equivalent_to(b[j])) return;
  24300. }
  24301. return i;
  24302. }
  24303. }
  24304. }
  24305. });
  24306. def_optimize(AST_Boolean, function(self, compressor) {
  24307. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  24308. value: +self.value
  24309. });
  24310. var p = compressor.parent();
  24311. if (compressor.option("booleans_as_integers")) {
  24312. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  24313. p.operator = p.operator.replace(/=$/, "");
  24314. }
  24315. return make_node(AST_Number, self, {
  24316. value: +self.value
  24317. });
  24318. }
  24319. if (compressor.option("booleans")) {
  24320. if (p instanceof AST_Binary && (p.operator == "=="
  24321. || p.operator == "!=")) {
  24322. return make_node(AST_Number, self, {
  24323. value: +self.value
  24324. });
  24325. }
  24326. return make_node(AST_UnaryPrefix, self, {
  24327. operator: "!",
  24328. expression: make_node(AST_Number, self, {
  24329. value: 1 - self.value
  24330. })
  24331. });
  24332. }
  24333. return self;
  24334. });
  24335. function safe_to_flatten(value, compressor) {
  24336. if (value instanceof AST_SymbolRef) {
  24337. value = value.fixed_value();
  24338. }
  24339. if (!value) return false;
  24340. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  24341. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  24342. return compressor.parent() instanceof AST_New;
  24343. }
  24344. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  24345. if (!compressor.option("properties")) return;
  24346. if (key === "__proto__") return;
  24347. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  24348. var expr = this.expression;
  24349. if (expr instanceof AST_Object) {
  24350. var props = expr.properties;
  24351. for (var i = props.length; --i >= 0;) {
  24352. var prop = props[i];
  24353. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  24354. const all_props_flattenable = props.every((p) =>
  24355. (p instanceof AST_ObjectKeyVal
  24356. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  24357. )
  24358. && !p.computed_key()
  24359. );
  24360. if (!all_props_flattenable) return;
  24361. if (!safe_to_flatten(prop.value, compressor)) return;
  24362. return make_node(AST_Sub, this, {
  24363. expression: make_node(AST_Array, expr, {
  24364. elements: props.map(function(prop) {
  24365. var v = prop.value;
  24366. if (v instanceof AST_Accessor) {
  24367. v = make_node(AST_Function, v, v);
  24368. }
  24369. var k = prop.key;
  24370. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  24371. return make_sequence(prop, [ k, v ]);
  24372. }
  24373. return v;
  24374. })
  24375. }),
  24376. property: make_node(AST_Number, this, {
  24377. value: i
  24378. })
  24379. });
  24380. }
  24381. }
  24382. }
  24383. });
  24384. def_optimize(AST_Sub, function(self, compressor) {
  24385. var expr = self.expression;
  24386. var prop = self.property;
  24387. if (compressor.option("properties")) {
  24388. var key = prop.evaluate(compressor);
  24389. if (key !== prop) {
  24390. if (typeof key == "string") {
  24391. if (key == "undefined") {
  24392. key = undefined;
  24393. } else {
  24394. var value = parseFloat(key);
  24395. if (value.toString() == key) {
  24396. key = value;
  24397. }
  24398. }
  24399. }
  24400. prop = self.property = best_of_expression(prop, make_node_from_constant(key, prop).transform(compressor));
  24401. var property = "" + key;
  24402. if (is_basic_identifier_string(property)
  24403. && property.length <= prop.size() + 1) {
  24404. return make_node(AST_Dot, self, {
  24405. expression: expr,
  24406. optional: self.optional,
  24407. property: property,
  24408. quote: prop.quote,
  24409. }).optimize(compressor);
  24410. }
  24411. }
  24412. }
  24413. var fn;
  24414. OPT_ARGUMENTS: if (compressor.option("arguments")
  24415. && expr instanceof AST_SymbolRef
  24416. && expr.name == "arguments"
  24417. && expr.definition().orig.length == 1
  24418. && (fn = expr.scope) instanceof AST_Lambda
  24419. && fn.uses_arguments
  24420. && !(fn instanceof AST_Arrow)
  24421. && prop instanceof AST_Number) {
  24422. var index = prop.getValue();
  24423. var params = new Set();
  24424. var argnames = fn.argnames;
  24425. for (var n = 0; n < argnames.length; n++) {
  24426. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  24427. break OPT_ARGUMENTS; // destructuring parameter - bail
  24428. }
  24429. var param = argnames[n].name;
  24430. if (params.has(param)) {
  24431. break OPT_ARGUMENTS; // duplicate parameter - bail
  24432. }
  24433. params.add(param);
  24434. }
  24435. var argname = fn.argnames[index];
  24436. if (argname && compressor.has_directive("use strict")) {
  24437. var def = argname.definition();
  24438. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  24439. argname = null;
  24440. }
  24441. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  24442. while (index >= fn.argnames.length) {
  24443. argname = fn.create_symbol(AST_SymbolFunarg, {
  24444. source: fn,
  24445. scope: fn,
  24446. tentative_name: "argument_" + fn.argnames.length,
  24447. });
  24448. fn.argnames.push(argname);
  24449. }
  24450. }
  24451. if (argname) {
  24452. var sym = make_node(AST_SymbolRef, self, argname);
  24453. sym.reference({});
  24454. clear_flag(argname, UNUSED);
  24455. return sym;
  24456. }
  24457. }
  24458. if (is_lhs(self, compressor.parent())) return self;
  24459. if (key !== prop) {
  24460. var sub = self.flatten_object(property, compressor);
  24461. if (sub) {
  24462. expr = self.expression = sub.expression;
  24463. prop = self.property = sub.property;
  24464. }
  24465. }
  24466. if (compressor.option("properties") && compressor.option("side_effects")
  24467. && prop instanceof AST_Number && expr instanceof AST_Array) {
  24468. var index = prop.getValue();
  24469. var elements = expr.elements;
  24470. var retValue = elements[index];
  24471. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  24472. var flatten = true;
  24473. var values = [];
  24474. for (var i = elements.length; --i > index;) {
  24475. var value = elements[i].drop_side_effect_free(compressor);
  24476. if (value) {
  24477. values.unshift(value);
  24478. if (flatten && value.has_side_effects(compressor)) flatten = false;
  24479. }
  24480. }
  24481. if (retValue instanceof AST_Expansion) break FLATTEN;
  24482. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  24483. if (!flatten) values.unshift(retValue);
  24484. while (--i >= 0) {
  24485. var value = elements[i];
  24486. if (value instanceof AST_Expansion) break FLATTEN;
  24487. value = value.drop_side_effect_free(compressor);
  24488. if (value) values.unshift(value);
  24489. else index--;
  24490. }
  24491. if (flatten) {
  24492. values.push(retValue);
  24493. return make_sequence(self, values).optimize(compressor);
  24494. } else return make_node(AST_Sub, self, {
  24495. expression: make_node(AST_Array, expr, {
  24496. elements: values
  24497. }),
  24498. property: make_node(AST_Number, prop, {
  24499. value: index
  24500. })
  24501. });
  24502. }
  24503. }
  24504. var ev = self.evaluate(compressor);
  24505. if (ev !== self) {
  24506. ev = make_node_from_constant(ev, self).optimize(compressor);
  24507. return best_of(compressor, ev, self);
  24508. }
  24509. if (self.optional && is_nullish(self.expression, compressor)) {
  24510. return make_node(AST_Undefined, self);
  24511. }
  24512. return self;
  24513. });
  24514. def_optimize(AST_Chain, function (self, compressor) {
  24515. self.expression = self.expression.optimize(compressor);
  24516. return self;
  24517. });
  24518. AST_Lambda.DEFMETHOD("contains_this", function() {
  24519. return walk(this, node => {
  24520. if (node instanceof AST_This) return walk_abort;
  24521. if (
  24522. node !== this
  24523. && node instanceof AST_Scope
  24524. && !(node instanceof AST_Arrow)
  24525. ) {
  24526. return true;
  24527. }
  24528. });
  24529. });
  24530. def_optimize(AST_Dot, function(self, compressor) {
  24531. const parent = compressor.parent();
  24532. if (is_lhs(self, parent)) return self;
  24533. if (compressor.option("unsafe_proto")
  24534. && self.expression instanceof AST_Dot
  24535. && self.expression.property == "prototype") {
  24536. var exp = self.expression.expression;
  24537. if (is_undeclared_ref(exp)) switch (exp.name) {
  24538. case "Array":
  24539. self.expression = make_node(AST_Array, self.expression, {
  24540. elements: []
  24541. });
  24542. break;
  24543. case "Function":
  24544. self.expression = make_node(AST_Function, self.expression, {
  24545. argnames: [],
  24546. body: []
  24547. });
  24548. break;
  24549. case "Number":
  24550. self.expression = make_node(AST_Number, self.expression, {
  24551. value: 0
  24552. });
  24553. break;
  24554. case "Object":
  24555. self.expression = make_node(AST_Object, self.expression, {
  24556. properties: []
  24557. });
  24558. break;
  24559. case "RegExp":
  24560. self.expression = make_node(AST_RegExp, self.expression, {
  24561. value: { source: "t", flags: "" }
  24562. });
  24563. break;
  24564. case "String":
  24565. self.expression = make_node(AST_String, self.expression, {
  24566. value: ""
  24567. });
  24568. break;
  24569. }
  24570. }
  24571. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  24572. const sub = self.flatten_object(self.property, compressor);
  24573. if (sub) return sub.optimize(compressor);
  24574. }
  24575. let ev = self.evaluate(compressor);
  24576. if (ev !== self) {
  24577. ev = make_node_from_constant(ev, self).optimize(compressor);
  24578. return best_of(compressor, ev, self);
  24579. }
  24580. if (self.optional && is_nullish(self.expression, compressor)) {
  24581. return make_node(AST_Undefined, self);
  24582. }
  24583. return self;
  24584. });
  24585. function literals_in_boolean_context(self, compressor) {
  24586. if (compressor.in_boolean_context()) {
  24587. return best_of(compressor, self, make_sequence(self, [
  24588. self,
  24589. make_node(AST_True, self)
  24590. ]).optimize(compressor));
  24591. }
  24592. return self;
  24593. }
  24594. function inline_array_like_spread(elements) {
  24595. for (var i = 0; i < elements.length; i++) {
  24596. var el = elements[i];
  24597. if (el instanceof AST_Expansion) {
  24598. var expr = el.expression;
  24599. if (
  24600. expr instanceof AST_Array
  24601. && !expr.elements.some(elm => elm instanceof AST_Hole)
  24602. ) {
  24603. elements.splice(i, 1, ...expr.elements);
  24604. // Step back one, as the element at i is now new.
  24605. i--;
  24606. }
  24607. // In array-like spread, spreading a non-iterable value is TypeError.
  24608. // We therefore can’t optimize anything else, unlike with object spread.
  24609. }
  24610. }
  24611. }
  24612. def_optimize(AST_Array, function(self, compressor) {
  24613. var optimized = literals_in_boolean_context(self, compressor);
  24614. if (optimized !== self) {
  24615. return optimized;
  24616. }
  24617. inline_array_like_spread(self.elements);
  24618. return self;
  24619. });
  24620. function inline_object_prop_spread(props, compressor) {
  24621. for (var i = 0; i < props.length; i++) {
  24622. var prop = props[i];
  24623. if (prop instanceof AST_Expansion) {
  24624. const expr = prop.expression;
  24625. if (
  24626. expr instanceof AST_Object
  24627. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  24628. ) {
  24629. props.splice(i, 1, ...expr.properties);
  24630. // Step back one, as the property at i is now new.
  24631. i--;
  24632. } else if (expr instanceof AST_Constant
  24633. && !(expr instanceof AST_String)) {
  24634. // Unlike array-like spread, in object spread, spreading a
  24635. // non-iterable value silently does nothing; it is thus safe
  24636. // to remove. AST_String is the only iterable AST_Constant.
  24637. props.splice(i, 1);
  24638. } else if (is_nullish(expr, compressor)) {
  24639. // Likewise, null and undefined can be silently removed.
  24640. props.splice(i, 1);
  24641. }
  24642. }
  24643. }
  24644. }
  24645. def_optimize(AST_Object, function(self, compressor) {
  24646. var optimized = literals_in_boolean_context(self, compressor);
  24647. if (optimized !== self) {
  24648. return optimized;
  24649. }
  24650. inline_object_prop_spread(self.properties, compressor);
  24651. return self;
  24652. });
  24653. def_optimize(AST_RegExp, literals_in_boolean_context);
  24654. def_optimize(AST_Return, function(self, compressor) {
  24655. if (self.value && is_undefined(self.value, compressor)) {
  24656. self.value = null;
  24657. }
  24658. return self;
  24659. });
  24660. def_optimize(AST_Arrow, opt_AST_Lambda);
  24661. def_optimize(AST_Function, function(self, compressor) {
  24662. self = opt_AST_Lambda(self, compressor);
  24663. if (compressor.option("unsafe_arrows")
  24664. && compressor.option("ecma") >= 2015
  24665. && !self.name
  24666. && !self.is_generator
  24667. && !self.uses_arguments
  24668. && !self.pinned()) {
  24669. const uses_this = walk(self, node => {
  24670. if (node instanceof AST_This) return walk_abort;
  24671. });
  24672. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  24673. }
  24674. return self;
  24675. });
  24676. def_optimize(AST_Class, function(self) {
  24677. // HACK to avoid compress failure.
  24678. // AST_Class is not really an AST_Scope/AST_Block as it lacks a body.
  24679. return self;
  24680. });
  24681. def_optimize(AST_Yield, function(self, compressor) {
  24682. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  24683. self.expression = null;
  24684. }
  24685. return self;
  24686. });
  24687. def_optimize(AST_TemplateString, function(self, compressor) {
  24688. if (
  24689. !compressor.option("evaluate")
  24690. || compressor.parent() instanceof AST_PrefixedTemplateString
  24691. ) {
  24692. return self;
  24693. }
  24694. var segments = [];
  24695. for (var i = 0; i < self.segments.length; i++) {
  24696. var segment = self.segments[i];
  24697. if (segment instanceof AST_Node) {
  24698. var result = segment.evaluate(compressor);
  24699. // Evaluate to constant value
  24700. // Constant value shorter than ${segment}
  24701. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  24702. // There should always be a previous and next segment if segment is a node
  24703. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  24704. continue;
  24705. }
  24706. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  24707. // TODO:
  24708. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  24709. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  24710. if (segment instanceof AST_TemplateString) {
  24711. var inners = segment.segments;
  24712. segments[segments.length - 1].value += inners[0].value;
  24713. for (var j = 1; j < inners.length; j++) {
  24714. segment = inners[j];
  24715. segments.push(segment);
  24716. }
  24717. continue;
  24718. }
  24719. }
  24720. segments.push(segment);
  24721. }
  24722. self.segments = segments;
  24723. // `foo` => "foo"
  24724. if (segments.length == 1) {
  24725. return make_node(AST_String, self, segments[0]);
  24726. }
  24727. if (
  24728. segments.length === 3
  24729. && segments[1] instanceof AST_Node
  24730. && (
  24731. segments[1].is_string(compressor)
  24732. || segments[1].is_number(compressor)
  24733. || is_nullish(segments[1], compressor)
  24734. || compressor.option("unsafe")
  24735. )
  24736. ) {
  24737. // `foo${bar}` => "foo" + bar
  24738. if (segments[2].value === "") {
  24739. return make_node(AST_Binary, self, {
  24740. operator: "+",
  24741. left: make_node(AST_String, self, {
  24742. value: segments[0].value,
  24743. }),
  24744. right: segments[1],
  24745. });
  24746. }
  24747. // `${bar}baz` => bar + "baz"
  24748. if (segments[0].value === "") {
  24749. return make_node(AST_Binary, self, {
  24750. operator: "+",
  24751. left: segments[1],
  24752. right: make_node(AST_String, self, {
  24753. value: segments[2].value,
  24754. }),
  24755. });
  24756. }
  24757. }
  24758. return self;
  24759. });
  24760. def_optimize(AST_PrefixedTemplateString, function(self) {
  24761. return self;
  24762. });
  24763. // ["p"]:1 ---> p:1
  24764. // [42]:1 ---> 42:1
  24765. function lift_key(self, compressor) {
  24766. if (!compressor.option("computed_props")) return self;
  24767. // save a comparison in the typical case
  24768. if (!(self.key instanceof AST_Constant)) return self;
  24769. // allow certain acceptable props as not all AST_Constants are true constants
  24770. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  24771. if (self.key.value === "__proto__") return self;
  24772. if (self.key.value == "constructor"
  24773. && compressor.parent() instanceof AST_Class) return self;
  24774. if (self instanceof AST_ObjectKeyVal) {
  24775. self.key = self.key.value;
  24776. } else if (self instanceof AST_ClassProperty) {
  24777. self.key = make_node(AST_SymbolClassProperty, self.key, {
  24778. name: self.key.value
  24779. });
  24780. } else {
  24781. self.key = make_node(AST_SymbolMethod, self.key, {
  24782. name: self.key.value
  24783. });
  24784. }
  24785. }
  24786. return self;
  24787. }
  24788. def_optimize(AST_ObjectProperty, lift_key);
  24789. def_optimize(AST_ConciseMethod, function(self, compressor) {
  24790. lift_key(self, compressor);
  24791. // p(){return x;} ---> p:()=>x
  24792. if (compressor.option("arrows")
  24793. && compressor.parent() instanceof AST_Object
  24794. && !self.is_generator
  24795. && !self.value.uses_arguments
  24796. && !self.value.pinned()
  24797. && self.value.body.length == 1
  24798. && self.value.body[0] instanceof AST_Return
  24799. && self.value.body[0].value
  24800. && !self.value.contains_this()) {
  24801. var arrow = make_node(AST_Arrow, self.value, self.value);
  24802. arrow.async = self.async;
  24803. arrow.is_generator = self.is_generator;
  24804. return make_node(AST_ObjectKeyVal, self, {
  24805. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  24806. value: arrow,
  24807. quote: self.quote,
  24808. });
  24809. }
  24810. return self;
  24811. });
  24812. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  24813. lift_key(self, compressor);
  24814. // p:function(){} ---> p(){}
  24815. // p:function*(){} ---> *p(){}
  24816. // p:async function(){} ---> async p(){}
  24817. // p:()=>{} ---> p(){}
  24818. // p:async()=>{} ---> async p(){}
  24819. var unsafe_methods = compressor.option("unsafe_methods");
  24820. if (unsafe_methods
  24821. && compressor.option("ecma") >= 2015
  24822. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  24823. var key = self.key;
  24824. var value = self.value;
  24825. var is_arrow_with_block = value instanceof AST_Arrow
  24826. && Array.isArray(value.body)
  24827. && !value.contains_this();
  24828. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  24829. return make_node(AST_ConciseMethod, self, {
  24830. async: value.async,
  24831. is_generator: value.is_generator,
  24832. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  24833. name: key,
  24834. }),
  24835. value: make_node(AST_Accessor, value, value),
  24836. quote: self.quote,
  24837. });
  24838. }
  24839. }
  24840. return self;
  24841. });
  24842. def_optimize(AST_Destructuring, function(self, compressor) {
  24843. if (compressor.option("pure_getters") == true
  24844. && compressor.option("unused")
  24845. && !self.is_array
  24846. && Array.isArray(self.names)
  24847. && !is_destructuring_export_decl(compressor)
  24848. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  24849. var keep = [];
  24850. for (var i = 0; i < self.names.length; i++) {
  24851. var elem = self.names[i];
  24852. if (!(elem instanceof AST_ObjectKeyVal
  24853. && typeof elem.key == "string"
  24854. && elem.value instanceof AST_SymbolDeclaration
  24855. && !should_retain(compressor, elem.value.definition()))) {
  24856. keep.push(elem);
  24857. }
  24858. }
  24859. if (keep.length != self.names.length) {
  24860. self.names = keep;
  24861. }
  24862. }
  24863. return self;
  24864. function is_destructuring_export_decl(compressor) {
  24865. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  24866. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  24867. var parent = compressor.parent(p);
  24868. if (!parent) return false;
  24869. if (a === 0 && parent.TYPE == "Destructuring") continue;
  24870. if (!ancestors[a].test(parent.TYPE)) {
  24871. return false;
  24872. }
  24873. a++;
  24874. }
  24875. return true;
  24876. }
  24877. function should_retain(compressor, def) {
  24878. if (def.references.length) return true;
  24879. if (!def.global) return false;
  24880. if (compressor.toplevel.vars) {
  24881. if (compressor.top_retain) {
  24882. return compressor.top_retain(def);
  24883. }
  24884. return false;
  24885. }
  24886. return true;
  24887. }
  24888. });
  24889. /***********************************************************************
  24890. A JavaScript tokenizer / parser / beautifier / compressor.
  24891. https://github.com/mishoo/UglifyJS2
  24892. -------------------------------- (C) ---------------------------------
  24893. Author: Mihai Bazon
  24894. <mihai.bazon@gmail.com>
  24895. http://mihai.bazon.net/blog
  24896. Distributed under the BSD license:
  24897. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  24898. Redistribution and use in source and binary forms, with or without
  24899. modification, are permitted provided that the following conditions
  24900. are met:
  24901. * Redistributions of source code must retain the above
  24902. copyright notice, this list of conditions and the following
  24903. disclaimer.
  24904. * Redistributions in binary form must reproduce the above
  24905. copyright notice, this list of conditions and the following
  24906. disclaimer in the documentation and/or other materials
  24907. provided with the distribution.
  24908. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  24909. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24910. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  24911. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  24912. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  24913. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24914. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24915. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24916. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  24917. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  24918. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24919. SUCH DAMAGE.
  24920. ***********************************************************************/
  24921. // a small wrapper around fitzgen's source-map library
  24922. async function SourceMap(options) {
  24923. options = defaults(options, {
  24924. file : null,
  24925. root : null,
  24926. orig : null,
  24927. orig_line_diff : 0,
  24928. dest_line_diff : 0,
  24929. });
  24930. var orig_map;
  24931. var generator = new MOZ_SourceMap__default['default'].SourceMapGenerator({
  24932. file : options.file,
  24933. sourceRoot : options.root
  24934. });
  24935. if (options.orig) {
  24936. orig_map = await new MOZ_SourceMap__default['default'].SourceMapConsumer(options.orig);
  24937. orig_map.sources.forEach(function(source) {
  24938. var sourceContent = orig_map.sourceContentFor(source, true);
  24939. if (sourceContent) {
  24940. generator.setSourceContent(source, sourceContent);
  24941. }
  24942. });
  24943. }
  24944. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  24945. if (orig_map) {
  24946. var info = orig_map.originalPositionFor({
  24947. line: orig_line,
  24948. column: orig_col
  24949. });
  24950. if (info.source === null) {
  24951. return;
  24952. }
  24953. source = info.source;
  24954. orig_line = info.line;
  24955. orig_col = info.column;
  24956. name = info.name || name;
  24957. }
  24958. generator.addMapping({
  24959. generated : { line: gen_line + options.dest_line_diff, column: gen_col },
  24960. original : { line: orig_line + options.orig_line_diff, column: orig_col },
  24961. source : source,
  24962. name : name
  24963. });
  24964. }
  24965. return {
  24966. add : add,
  24967. get : function() { return generator; },
  24968. toString : function() { return generator.toString(); },
  24969. destroy : function () {
  24970. if (orig_map && orig_map.destroy) {
  24971. orig_map.destroy();
  24972. }
  24973. }
  24974. };
  24975. }
  24976. var domprops = [
  24977. "$&",
  24978. "$'",
  24979. "$*",
  24980. "$+",
  24981. "$1",
  24982. "$2",
  24983. "$3",
  24984. "$4",
  24985. "$5",
  24986. "$6",
  24987. "$7",
  24988. "$8",
  24989. "$9",
  24990. "$_",
  24991. "$`",
  24992. "$input",
  24993. "-moz-animation",
  24994. "-moz-animation-delay",
  24995. "-moz-animation-direction",
  24996. "-moz-animation-duration",
  24997. "-moz-animation-fill-mode",
  24998. "-moz-animation-iteration-count",
  24999. "-moz-animation-name",
  25000. "-moz-animation-play-state",
  25001. "-moz-animation-timing-function",
  25002. "-moz-appearance",
  25003. "-moz-backface-visibility",
  25004. "-moz-border-end",
  25005. "-moz-border-end-color",
  25006. "-moz-border-end-style",
  25007. "-moz-border-end-width",
  25008. "-moz-border-image",
  25009. "-moz-border-start",
  25010. "-moz-border-start-color",
  25011. "-moz-border-start-style",
  25012. "-moz-border-start-width",
  25013. "-moz-box-align",
  25014. "-moz-box-direction",
  25015. "-moz-box-flex",
  25016. "-moz-box-ordinal-group",
  25017. "-moz-box-orient",
  25018. "-moz-box-pack",
  25019. "-moz-box-sizing",
  25020. "-moz-float-edge",
  25021. "-moz-font-feature-settings",
  25022. "-moz-font-language-override",
  25023. "-moz-force-broken-image-icon",
  25024. "-moz-hyphens",
  25025. "-moz-image-region",
  25026. "-moz-margin-end",
  25027. "-moz-margin-start",
  25028. "-moz-orient",
  25029. "-moz-osx-font-smoothing",
  25030. "-moz-outline-radius",
  25031. "-moz-outline-radius-bottomleft",
  25032. "-moz-outline-radius-bottomright",
  25033. "-moz-outline-radius-topleft",
  25034. "-moz-outline-radius-topright",
  25035. "-moz-padding-end",
  25036. "-moz-padding-start",
  25037. "-moz-perspective",
  25038. "-moz-perspective-origin",
  25039. "-moz-tab-size",
  25040. "-moz-text-size-adjust",
  25041. "-moz-transform",
  25042. "-moz-transform-origin",
  25043. "-moz-transform-style",
  25044. "-moz-transition",
  25045. "-moz-transition-delay",
  25046. "-moz-transition-duration",
  25047. "-moz-transition-property",
  25048. "-moz-transition-timing-function",
  25049. "-moz-user-focus",
  25050. "-moz-user-input",
  25051. "-moz-user-modify",
  25052. "-moz-user-select",
  25053. "-moz-window-dragging",
  25054. "-webkit-align-content",
  25055. "-webkit-align-items",
  25056. "-webkit-align-self",
  25057. "-webkit-animation",
  25058. "-webkit-animation-delay",
  25059. "-webkit-animation-direction",
  25060. "-webkit-animation-duration",
  25061. "-webkit-animation-fill-mode",
  25062. "-webkit-animation-iteration-count",
  25063. "-webkit-animation-name",
  25064. "-webkit-animation-play-state",
  25065. "-webkit-animation-timing-function",
  25066. "-webkit-appearance",
  25067. "-webkit-backface-visibility",
  25068. "-webkit-background-clip",
  25069. "-webkit-background-origin",
  25070. "-webkit-background-size",
  25071. "-webkit-border-bottom-left-radius",
  25072. "-webkit-border-bottom-right-radius",
  25073. "-webkit-border-image",
  25074. "-webkit-border-radius",
  25075. "-webkit-border-top-left-radius",
  25076. "-webkit-border-top-right-radius",
  25077. "-webkit-box-align",
  25078. "-webkit-box-direction",
  25079. "-webkit-box-flex",
  25080. "-webkit-box-ordinal-group",
  25081. "-webkit-box-orient",
  25082. "-webkit-box-pack",
  25083. "-webkit-box-shadow",
  25084. "-webkit-box-sizing",
  25085. "-webkit-filter",
  25086. "-webkit-flex",
  25087. "-webkit-flex-basis",
  25088. "-webkit-flex-direction",
  25089. "-webkit-flex-flow",
  25090. "-webkit-flex-grow",
  25091. "-webkit-flex-shrink",
  25092. "-webkit-flex-wrap",
  25093. "-webkit-justify-content",
  25094. "-webkit-line-clamp",
  25095. "-webkit-mask",
  25096. "-webkit-mask-clip",
  25097. "-webkit-mask-composite",
  25098. "-webkit-mask-image",
  25099. "-webkit-mask-origin",
  25100. "-webkit-mask-position",
  25101. "-webkit-mask-position-x",
  25102. "-webkit-mask-position-y",
  25103. "-webkit-mask-repeat",
  25104. "-webkit-mask-size",
  25105. "-webkit-order",
  25106. "-webkit-perspective",
  25107. "-webkit-perspective-origin",
  25108. "-webkit-text-fill-color",
  25109. "-webkit-text-size-adjust",
  25110. "-webkit-text-stroke",
  25111. "-webkit-text-stroke-color",
  25112. "-webkit-text-stroke-width",
  25113. "-webkit-transform",
  25114. "-webkit-transform-origin",
  25115. "-webkit-transform-style",
  25116. "-webkit-transition",
  25117. "-webkit-transition-delay",
  25118. "-webkit-transition-duration",
  25119. "-webkit-transition-property",
  25120. "-webkit-transition-timing-function",
  25121. "-webkit-user-select",
  25122. "0",
  25123. "1",
  25124. "10",
  25125. "11",
  25126. "12",
  25127. "13",
  25128. "14",
  25129. "15",
  25130. "16",
  25131. "17",
  25132. "18",
  25133. "19",
  25134. "2",
  25135. "20",
  25136. "3",
  25137. "4",
  25138. "5",
  25139. "6",
  25140. "7",
  25141. "8",
  25142. "9",
  25143. "@@iterator",
  25144. "ABORT_ERR",
  25145. "ACTIVE",
  25146. "ACTIVE_ATTRIBUTES",
  25147. "ACTIVE_TEXTURE",
  25148. "ACTIVE_UNIFORMS",
  25149. "ACTIVE_UNIFORM_BLOCKS",
  25150. "ADDITION",
  25151. "ALIASED_LINE_WIDTH_RANGE",
  25152. "ALIASED_POINT_SIZE_RANGE",
  25153. "ALLOW_KEYBOARD_INPUT",
  25154. "ALLPASS",
  25155. "ALPHA",
  25156. "ALPHA_BITS",
  25157. "ALREADY_SIGNALED",
  25158. "ALT_MASK",
  25159. "ALWAYS",
  25160. "ANY_SAMPLES_PASSED",
  25161. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  25162. "ANY_TYPE",
  25163. "ANY_UNORDERED_NODE_TYPE",
  25164. "ARRAY_BUFFER",
  25165. "ARRAY_BUFFER_BINDING",
  25166. "ATTACHED_SHADERS",
  25167. "ATTRIBUTE_NODE",
  25168. "AT_TARGET",
  25169. "AbortController",
  25170. "AbortSignal",
  25171. "AbsoluteOrientationSensor",
  25172. "AbstractRange",
  25173. "Accelerometer",
  25174. "AddSearchProvider",
  25175. "AggregateError",
  25176. "AnalyserNode",
  25177. "Animation",
  25178. "AnimationEffect",
  25179. "AnimationEvent",
  25180. "AnimationPlaybackEvent",
  25181. "AnimationTimeline",
  25182. "AnonXMLHttpRequest",
  25183. "Any",
  25184. "ApplicationCache",
  25185. "ApplicationCacheErrorEvent",
  25186. "Array",
  25187. "ArrayBuffer",
  25188. "ArrayType",
  25189. "Atomics",
  25190. "Attr",
  25191. "Audio",
  25192. "AudioBuffer",
  25193. "AudioBufferSourceNode",
  25194. "AudioContext",
  25195. "AudioDestinationNode",
  25196. "AudioListener",
  25197. "AudioNode",
  25198. "AudioParam",
  25199. "AudioParamMap",
  25200. "AudioProcessingEvent",
  25201. "AudioScheduledSourceNode",
  25202. "AudioStreamTrack",
  25203. "AudioWorklet",
  25204. "AudioWorkletNode",
  25205. "AuthenticatorAssertionResponse",
  25206. "AuthenticatorAttestationResponse",
  25207. "AuthenticatorResponse",
  25208. "AutocompleteErrorEvent",
  25209. "BACK",
  25210. "BAD_BOUNDARYPOINTS_ERR",
  25211. "BAD_REQUEST",
  25212. "BANDPASS",
  25213. "BLEND",
  25214. "BLEND_COLOR",
  25215. "BLEND_DST_ALPHA",
  25216. "BLEND_DST_RGB",
  25217. "BLEND_EQUATION",
  25218. "BLEND_EQUATION_ALPHA",
  25219. "BLEND_EQUATION_RGB",
  25220. "BLEND_SRC_ALPHA",
  25221. "BLEND_SRC_RGB",
  25222. "BLUE_BITS",
  25223. "BLUR",
  25224. "BOOL",
  25225. "BOOLEAN_TYPE",
  25226. "BOOL_VEC2",
  25227. "BOOL_VEC3",
  25228. "BOOL_VEC4",
  25229. "BOTH",
  25230. "BROWSER_DEFAULT_WEBGL",
  25231. "BUBBLING_PHASE",
  25232. "BUFFER_SIZE",
  25233. "BUFFER_USAGE",
  25234. "BYTE",
  25235. "BYTES_PER_ELEMENT",
  25236. "BackgroundFetchManager",
  25237. "BackgroundFetchRecord",
  25238. "BackgroundFetchRegistration",
  25239. "BarProp",
  25240. "BarcodeDetector",
  25241. "BaseAudioContext",
  25242. "BaseHref",
  25243. "BatteryManager",
  25244. "BeforeInstallPromptEvent",
  25245. "BeforeLoadEvent",
  25246. "BeforeUnloadEvent",
  25247. "BigInt",
  25248. "BigInt64Array",
  25249. "BigUint64Array",
  25250. "BiquadFilterNode",
  25251. "Blob",
  25252. "BlobEvent",
  25253. "Bluetooth",
  25254. "BluetoothCharacteristicProperties",
  25255. "BluetoothDevice",
  25256. "BluetoothRemoteGATTCharacteristic",
  25257. "BluetoothRemoteGATTDescriptor",
  25258. "BluetoothRemoteGATTServer",
  25259. "BluetoothRemoteGATTService",
  25260. "BluetoothUUID",
  25261. "Boolean",
  25262. "BroadcastChannel",
  25263. "ByteLengthQueuingStrategy",
  25264. "CAPTURING_PHASE",
  25265. "CCW",
  25266. "CDATASection",
  25267. "CDATA_SECTION_NODE",
  25268. "CHANGE",
  25269. "CHARSET_RULE",
  25270. "CHECKING",
  25271. "CLAMP_TO_EDGE",
  25272. "CLICK",
  25273. "CLOSED",
  25274. "CLOSING",
  25275. "COLOR",
  25276. "COLOR_ATTACHMENT0",
  25277. "COLOR_ATTACHMENT1",
  25278. "COLOR_ATTACHMENT10",
  25279. "COLOR_ATTACHMENT11",
  25280. "COLOR_ATTACHMENT12",
  25281. "COLOR_ATTACHMENT13",
  25282. "COLOR_ATTACHMENT14",
  25283. "COLOR_ATTACHMENT15",
  25284. "COLOR_ATTACHMENT2",
  25285. "COLOR_ATTACHMENT3",
  25286. "COLOR_ATTACHMENT4",
  25287. "COLOR_ATTACHMENT5",
  25288. "COLOR_ATTACHMENT6",
  25289. "COLOR_ATTACHMENT7",
  25290. "COLOR_ATTACHMENT8",
  25291. "COLOR_ATTACHMENT9",
  25292. "COLOR_BUFFER_BIT",
  25293. "COLOR_CLEAR_VALUE",
  25294. "COLOR_WRITEMASK",
  25295. "COMMENT_NODE",
  25296. "COMPARE_REF_TO_TEXTURE",
  25297. "COMPILE_STATUS",
  25298. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  25299. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  25300. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  25301. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  25302. "COMPRESSED_TEXTURE_FORMATS",
  25303. "CONDITION_SATISFIED",
  25304. "CONFIGURATION_UNSUPPORTED",
  25305. "CONNECTING",
  25306. "CONSTANT_ALPHA",
  25307. "CONSTANT_COLOR",
  25308. "CONSTRAINT_ERR",
  25309. "CONTEXT_LOST_WEBGL",
  25310. "CONTROL_MASK",
  25311. "COPY_READ_BUFFER",
  25312. "COPY_READ_BUFFER_BINDING",
  25313. "COPY_WRITE_BUFFER",
  25314. "COPY_WRITE_BUFFER_BINDING",
  25315. "COUNTER_STYLE_RULE",
  25316. "CSS",
  25317. "CSS2Properties",
  25318. "CSSAnimation",
  25319. "CSSCharsetRule",
  25320. "CSSConditionRule",
  25321. "CSSCounterStyleRule",
  25322. "CSSFontFaceRule",
  25323. "CSSFontFeatureValuesRule",
  25324. "CSSGroupingRule",
  25325. "CSSImageValue",
  25326. "CSSImportRule",
  25327. "CSSKeyframeRule",
  25328. "CSSKeyframesRule",
  25329. "CSSKeywordValue",
  25330. "CSSMathInvert",
  25331. "CSSMathMax",
  25332. "CSSMathMin",
  25333. "CSSMathNegate",
  25334. "CSSMathProduct",
  25335. "CSSMathSum",
  25336. "CSSMathValue",
  25337. "CSSMatrixComponent",
  25338. "CSSMediaRule",
  25339. "CSSMozDocumentRule",
  25340. "CSSNameSpaceRule",
  25341. "CSSNamespaceRule",
  25342. "CSSNumericArray",
  25343. "CSSNumericValue",
  25344. "CSSPageRule",
  25345. "CSSPerspective",
  25346. "CSSPositionValue",
  25347. "CSSPrimitiveValue",
  25348. "CSSRotate",
  25349. "CSSRule",
  25350. "CSSRuleList",
  25351. "CSSScale",
  25352. "CSSSkew",
  25353. "CSSSkewX",
  25354. "CSSSkewY",
  25355. "CSSStyleDeclaration",
  25356. "CSSStyleRule",
  25357. "CSSStyleSheet",
  25358. "CSSStyleValue",
  25359. "CSSSupportsRule",
  25360. "CSSTransformComponent",
  25361. "CSSTransformValue",
  25362. "CSSTransition",
  25363. "CSSTranslate",
  25364. "CSSUnitValue",
  25365. "CSSUnknownRule",
  25366. "CSSUnparsedValue",
  25367. "CSSValue",
  25368. "CSSValueList",
  25369. "CSSVariableReferenceValue",
  25370. "CSSVariablesDeclaration",
  25371. "CSSVariablesRule",
  25372. "CSSViewportRule",
  25373. "CSS_ATTR",
  25374. "CSS_CM",
  25375. "CSS_COUNTER",
  25376. "CSS_CUSTOM",
  25377. "CSS_DEG",
  25378. "CSS_DIMENSION",
  25379. "CSS_EMS",
  25380. "CSS_EXS",
  25381. "CSS_FILTER_BLUR",
  25382. "CSS_FILTER_BRIGHTNESS",
  25383. "CSS_FILTER_CONTRAST",
  25384. "CSS_FILTER_CUSTOM",
  25385. "CSS_FILTER_DROP_SHADOW",
  25386. "CSS_FILTER_GRAYSCALE",
  25387. "CSS_FILTER_HUE_ROTATE",
  25388. "CSS_FILTER_INVERT",
  25389. "CSS_FILTER_OPACITY",
  25390. "CSS_FILTER_REFERENCE",
  25391. "CSS_FILTER_SATURATE",
  25392. "CSS_FILTER_SEPIA",
  25393. "CSS_GRAD",
  25394. "CSS_HZ",
  25395. "CSS_IDENT",
  25396. "CSS_IN",
  25397. "CSS_INHERIT",
  25398. "CSS_KHZ",
  25399. "CSS_MATRIX",
  25400. "CSS_MATRIX3D",
  25401. "CSS_MM",
  25402. "CSS_MS",
  25403. "CSS_NUMBER",
  25404. "CSS_PC",
  25405. "CSS_PERCENTAGE",
  25406. "CSS_PERSPECTIVE",
  25407. "CSS_PRIMITIVE_VALUE",
  25408. "CSS_PT",
  25409. "CSS_PX",
  25410. "CSS_RAD",
  25411. "CSS_RECT",
  25412. "CSS_RGBCOLOR",
  25413. "CSS_ROTATE",
  25414. "CSS_ROTATE3D",
  25415. "CSS_ROTATEX",
  25416. "CSS_ROTATEY",
  25417. "CSS_ROTATEZ",
  25418. "CSS_S",
  25419. "CSS_SCALE",
  25420. "CSS_SCALE3D",
  25421. "CSS_SCALEX",
  25422. "CSS_SCALEY",
  25423. "CSS_SCALEZ",
  25424. "CSS_SKEW",
  25425. "CSS_SKEWX",
  25426. "CSS_SKEWY",
  25427. "CSS_STRING",
  25428. "CSS_TRANSLATE",
  25429. "CSS_TRANSLATE3D",
  25430. "CSS_TRANSLATEX",
  25431. "CSS_TRANSLATEY",
  25432. "CSS_TRANSLATEZ",
  25433. "CSS_UNKNOWN",
  25434. "CSS_URI",
  25435. "CSS_VALUE_LIST",
  25436. "CSS_VH",
  25437. "CSS_VMAX",
  25438. "CSS_VMIN",
  25439. "CSS_VW",
  25440. "CULL_FACE",
  25441. "CULL_FACE_MODE",
  25442. "CURRENT_PROGRAM",
  25443. "CURRENT_QUERY",
  25444. "CURRENT_VERTEX_ATTRIB",
  25445. "CUSTOM",
  25446. "CW",
  25447. "Cache",
  25448. "CacheStorage",
  25449. "CanvasCaptureMediaStream",
  25450. "CanvasCaptureMediaStreamTrack",
  25451. "CanvasGradient",
  25452. "CanvasPattern",
  25453. "CanvasRenderingContext2D",
  25454. "CaretPosition",
  25455. "ChannelMergerNode",
  25456. "ChannelSplitterNode",
  25457. "CharacterData",
  25458. "ClientRect",
  25459. "ClientRectList",
  25460. "Clipboard",
  25461. "ClipboardEvent",
  25462. "ClipboardItem",
  25463. "CloseEvent",
  25464. "Collator",
  25465. "CommandEvent",
  25466. "Comment",
  25467. "CompileError",
  25468. "CompositionEvent",
  25469. "CompressionStream",
  25470. "Console",
  25471. "ConstantSourceNode",
  25472. "Controllers",
  25473. "ConvolverNode",
  25474. "CountQueuingStrategy",
  25475. "Counter",
  25476. "Credential",
  25477. "CredentialsContainer",
  25478. "Crypto",
  25479. "CryptoKey",
  25480. "CustomElementRegistry",
  25481. "CustomEvent",
  25482. "DATABASE_ERR",
  25483. "DATA_CLONE_ERR",
  25484. "DATA_ERR",
  25485. "DBLCLICK",
  25486. "DECR",
  25487. "DECR_WRAP",
  25488. "DELETE_STATUS",
  25489. "DEPTH",
  25490. "DEPTH24_STENCIL8",
  25491. "DEPTH32F_STENCIL8",
  25492. "DEPTH_ATTACHMENT",
  25493. "DEPTH_BITS",
  25494. "DEPTH_BUFFER_BIT",
  25495. "DEPTH_CLEAR_VALUE",
  25496. "DEPTH_COMPONENT",
  25497. "DEPTH_COMPONENT16",
  25498. "DEPTH_COMPONENT24",
  25499. "DEPTH_COMPONENT32F",
  25500. "DEPTH_FUNC",
  25501. "DEPTH_RANGE",
  25502. "DEPTH_STENCIL",
  25503. "DEPTH_STENCIL_ATTACHMENT",
  25504. "DEPTH_TEST",
  25505. "DEPTH_WRITEMASK",
  25506. "DEVICE_INELIGIBLE",
  25507. "DIRECTION_DOWN",
  25508. "DIRECTION_LEFT",
  25509. "DIRECTION_RIGHT",
  25510. "DIRECTION_UP",
  25511. "DISABLED",
  25512. "DISPATCH_REQUEST_ERR",
  25513. "DITHER",
  25514. "DOCUMENT_FRAGMENT_NODE",
  25515. "DOCUMENT_NODE",
  25516. "DOCUMENT_POSITION_CONTAINED_BY",
  25517. "DOCUMENT_POSITION_CONTAINS",
  25518. "DOCUMENT_POSITION_DISCONNECTED",
  25519. "DOCUMENT_POSITION_FOLLOWING",
  25520. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  25521. "DOCUMENT_POSITION_PRECEDING",
  25522. "DOCUMENT_TYPE_NODE",
  25523. "DOMCursor",
  25524. "DOMError",
  25525. "DOMException",
  25526. "DOMImplementation",
  25527. "DOMImplementationLS",
  25528. "DOMMatrix",
  25529. "DOMMatrixReadOnly",
  25530. "DOMParser",
  25531. "DOMPoint",
  25532. "DOMPointReadOnly",
  25533. "DOMQuad",
  25534. "DOMRect",
  25535. "DOMRectList",
  25536. "DOMRectReadOnly",
  25537. "DOMRequest",
  25538. "DOMSTRING_SIZE_ERR",
  25539. "DOMSettableTokenList",
  25540. "DOMStringList",
  25541. "DOMStringMap",
  25542. "DOMTokenList",
  25543. "DOMTransactionEvent",
  25544. "DOM_DELTA_LINE",
  25545. "DOM_DELTA_PAGE",
  25546. "DOM_DELTA_PIXEL",
  25547. "DOM_INPUT_METHOD_DROP",
  25548. "DOM_INPUT_METHOD_HANDWRITING",
  25549. "DOM_INPUT_METHOD_IME",
  25550. "DOM_INPUT_METHOD_KEYBOARD",
  25551. "DOM_INPUT_METHOD_MULTIMODAL",
  25552. "DOM_INPUT_METHOD_OPTION",
  25553. "DOM_INPUT_METHOD_PASTE",
  25554. "DOM_INPUT_METHOD_SCRIPT",
  25555. "DOM_INPUT_METHOD_UNKNOWN",
  25556. "DOM_INPUT_METHOD_VOICE",
  25557. "DOM_KEY_LOCATION_JOYSTICK",
  25558. "DOM_KEY_LOCATION_LEFT",
  25559. "DOM_KEY_LOCATION_MOBILE",
  25560. "DOM_KEY_LOCATION_NUMPAD",
  25561. "DOM_KEY_LOCATION_RIGHT",
  25562. "DOM_KEY_LOCATION_STANDARD",
  25563. "DOM_VK_0",
  25564. "DOM_VK_1",
  25565. "DOM_VK_2",
  25566. "DOM_VK_3",
  25567. "DOM_VK_4",
  25568. "DOM_VK_5",
  25569. "DOM_VK_6",
  25570. "DOM_VK_7",
  25571. "DOM_VK_8",
  25572. "DOM_VK_9",
  25573. "DOM_VK_A",
  25574. "DOM_VK_ACCEPT",
  25575. "DOM_VK_ADD",
  25576. "DOM_VK_ALT",
  25577. "DOM_VK_ALTGR",
  25578. "DOM_VK_AMPERSAND",
  25579. "DOM_VK_ASTERISK",
  25580. "DOM_VK_AT",
  25581. "DOM_VK_ATTN",
  25582. "DOM_VK_B",
  25583. "DOM_VK_BACKSPACE",
  25584. "DOM_VK_BACK_QUOTE",
  25585. "DOM_VK_BACK_SLASH",
  25586. "DOM_VK_BACK_SPACE",
  25587. "DOM_VK_C",
  25588. "DOM_VK_CANCEL",
  25589. "DOM_VK_CAPS_LOCK",
  25590. "DOM_VK_CIRCUMFLEX",
  25591. "DOM_VK_CLEAR",
  25592. "DOM_VK_CLOSE_BRACKET",
  25593. "DOM_VK_CLOSE_CURLY_BRACKET",
  25594. "DOM_VK_CLOSE_PAREN",
  25595. "DOM_VK_COLON",
  25596. "DOM_VK_COMMA",
  25597. "DOM_VK_CONTEXT_MENU",
  25598. "DOM_VK_CONTROL",
  25599. "DOM_VK_CONVERT",
  25600. "DOM_VK_CRSEL",
  25601. "DOM_VK_CTRL",
  25602. "DOM_VK_D",
  25603. "DOM_VK_DECIMAL",
  25604. "DOM_VK_DELETE",
  25605. "DOM_VK_DIVIDE",
  25606. "DOM_VK_DOLLAR",
  25607. "DOM_VK_DOUBLE_QUOTE",
  25608. "DOM_VK_DOWN",
  25609. "DOM_VK_E",
  25610. "DOM_VK_EISU",
  25611. "DOM_VK_END",
  25612. "DOM_VK_ENTER",
  25613. "DOM_VK_EQUALS",
  25614. "DOM_VK_EREOF",
  25615. "DOM_VK_ESCAPE",
  25616. "DOM_VK_EXCLAMATION",
  25617. "DOM_VK_EXECUTE",
  25618. "DOM_VK_EXSEL",
  25619. "DOM_VK_F",
  25620. "DOM_VK_F1",
  25621. "DOM_VK_F10",
  25622. "DOM_VK_F11",
  25623. "DOM_VK_F12",
  25624. "DOM_VK_F13",
  25625. "DOM_VK_F14",
  25626. "DOM_VK_F15",
  25627. "DOM_VK_F16",
  25628. "DOM_VK_F17",
  25629. "DOM_VK_F18",
  25630. "DOM_VK_F19",
  25631. "DOM_VK_F2",
  25632. "DOM_VK_F20",
  25633. "DOM_VK_F21",
  25634. "DOM_VK_F22",
  25635. "DOM_VK_F23",
  25636. "DOM_VK_F24",
  25637. "DOM_VK_F25",
  25638. "DOM_VK_F26",
  25639. "DOM_VK_F27",
  25640. "DOM_VK_F28",
  25641. "DOM_VK_F29",
  25642. "DOM_VK_F3",
  25643. "DOM_VK_F30",
  25644. "DOM_VK_F31",
  25645. "DOM_VK_F32",
  25646. "DOM_VK_F33",
  25647. "DOM_VK_F34",
  25648. "DOM_VK_F35",
  25649. "DOM_VK_F36",
  25650. "DOM_VK_F4",
  25651. "DOM_VK_F5",
  25652. "DOM_VK_F6",
  25653. "DOM_VK_F7",
  25654. "DOM_VK_F8",
  25655. "DOM_VK_F9",
  25656. "DOM_VK_FINAL",
  25657. "DOM_VK_FRONT",
  25658. "DOM_VK_G",
  25659. "DOM_VK_GREATER_THAN",
  25660. "DOM_VK_H",
  25661. "DOM_VK_HANGUL",
  25662. "DOM_VK_HANJA",
  25663. "DOM_VK_HASH",
  25664. "DOM_VK_HELP",
  25665. "DOM_VK_HK_TOGGLE",
  25666. "DOM_VK_HOME",
  25667. "DOM_VK_HYPHEN_MINUS",
  25668. "DOM_VK_I",
  25669. "DOM_VK_INSERT",
  25670. "DOM_VK_J",
  25671. "DOM_VK_JUNJA",
  25672. "DOM_VK_K",
  25673. "DOM_VK_KANA",
  25674. "DOM_VK_KANJI",
  25675. "DOM_VK_L",
  25676. "DOM_VK_LEFT",
  25677. "DOM_VK_LEFT_TAB",
  25678. "DOM_VK_LESS_THAN",
  25679. "DOM_VK_M",
  25680. "DOM_VK_META",
  25681. "DOM_VK_MODECHANGE",
  25682. "DOM_VK_MULTIPLY",
  25683. "DOM_VK_N",
  25684. "DOM_VK_NONCONVERT",
  25685. "DOM_VK_NUMPAD0",
  25686. "DOM_VK_NUMPAD1",
  25687. "DOM_VK_NUMPAD2",
  25688. "DOM_VK_NUMPAD3",
  25689. "DOM_VK_NUMPAD4",
  25690. "DOM_VK_NUMPAD5",
  25691. "DOM_VK_NUMPAD6",
  25692. "DOM_VK_NUMPAD7",
  25693. "DOM_VK_NUMPAD8",
  25694. "DOM_VK_NUMPAD9",
  25695. "DOM_VK_NUM_LOCK",
  25696. "DOM_VK_O",
  25697. "DOM_VK_OEM_1",
  25698. "DOM_VK_OEM_102",
  25699. "DOM_VK_OEM_2",
  25700. "DOM_VK_OEM_3",
  25701. "DOM_VK_OEM_4",
  25702. "DOM_VK_OEM_5",
  25703. "DOM_VK_OEM_6",
  25704. "DOM_VK_OEM_7",
  25705. "DOM_VK_OEM_8",
  25706. "DOM_VK_OEM_COMMA",
  25707. "DOM_VK_OEM_MINUS",
  25708. "DOM_VK_OEM_PERIOD",
  25709. "DOM_VK_OEM_PLUS",
  25710. "DOM_VK_OPEN_BRACKET",
  25711. "DOM_VK_OPEN_CURLY_BRACKET",
  25712. "DOM_VK_OPEN_PAREN",
  25713. "DOM_VK_P",
  25714. "DOM_VK_PA1",
  25715. "DOM_VK_PAGEDOWN",
  25716. "DOM_VK_PAGEUP",
  25717. "DOM_VK_PAGE_DOWN",
  25718. "DOM_VK_PAGE_UP",
  25719. "DOM_VK_PAUSE",
  25720. "DOM_VK_PERCENT",
  25721. "DOM_VK_PERIOD",
  25722. "DOM_VK_PIPE",
  25723. "DOM_VK_PLAY",
  25724. "DOM_VK_PLUS",
  25725. "DOM_VK_PRINT",
  25726. "DOM_VK_PRINTSCREEN",
  25727. "DOM_VK_PROCESSKEY",
  25728. "DOM_VK_PROPERITES",
  25729. "DOM_VK_Q",
  25730. "DOM_VK_QUESTION_MARK",
  25731. "DOM_VK_QUOTE",
  25732. "DOM_VK_R",
  25733. "DOM_VK_REDO",
  25734. "DOM_VK_RETURN",
  25735. "DOM_VK_RIGHT",
  25736. "DOM_VK_S",
  25737. "DOM_VK_SCROLL_LOCK",
  25738. "DOM_VK_SELECT",
  25739. "DOM_VK_SEMICOLON",
  25740. "DOM_VK_SEPARATOR",
  25741. "DOM_VK_SHIFT",
  25742. "DOM_VK_SLASH",
  25743. "DOM_VK_SLEEP",
  25744. "DOM_VK_SPACE",
  25745. "DOM_VK_SUBTRACT",
  25746. "DOM_VK_T",
  25747. "DOM_VK_TAB",
  25748. "DOM_VK_TILDE",
  25749. "DOM_VK_U",
  25750. "DOM_VK_UNDERSCORE",
  25751. "DOM_VK_UNDO",
  25752. "DOM_VK_UNICODE",
  25753. "DOM_VK_UP",
  25754. "DOM_VK_V",
  25755. "DOM_VK_VOLUME_DOWN",
  25756. "DOM_VK_VOLUME_MUTE",
  25757. "DOM_VK_VOLUME_UP",
  25758. "DOM_VK_W",
  25759. "DOM_VK_WIN",
  25760. "DOM_VK_WINDOW",
  25761. "DOM_VK_WIN_ICO_00",
  25762. "DOM_VK_WIN_ICO_CLEAR",
  25763. "DOM_VK_WIN_ICO_HELP",
  25764. "DOM_VK_WIN_OEM_ATTN",
  25765. "DOM_VK_WIN_OEM_AUTO",
  25766. "DOM_VK_WIN_OEM_BACKTAB",
  25767. "DOM_VK_WIN_OEM_CLEAR",
  25768. "DOM_VK_WIN_OEM_COPY",
  25769. "DOM_VK_WIN_OEM_CUSEL",
  25770. "DOM_VK_WIN_OEM_ENLW",
  25771. "DOM_VK_WIN_OEM_FINISH",
  25772. "DOM_VK_WIN_OEM_FJ_JISHO",
  25773. "DOM_VK_WIN_OEM_FJ_LOYA",
  25774. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  25775. "DOM_VK_WIN_OEM_FJ_ROYA",
  25776. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  25777. "DOM_VK_WIN_OEM_JUMP",
  25778. "DOM_VK_WIN_OEM_PA1",
  25779. "DOM_VK_WIN_OEM_PA2",
  25780. "DOM_VK_WIN_OEM_PA3",
  25781. "DOM_VK_WIN_OEM_RESET",
  25782. "DOM_VK_WIN_OEM_WSCTRL",
  25783. "DOM_VK_X",
  25784. "DOM_VK_XF86XK_ADD_FAVORITE",
  25785. "DOM_VK_XF86XK_APPLICATION_LEFT",
  25786. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  25787. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  25788. "DOM_VK_XF86XK_AUDIO_FORWARD",
  25789. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  25790. "DOM_VK_XF86XK_AUDIO_MEDIA",
  25791. "DOM_VK_XF86XK_AUDIO_MUTE",
  25792. "DOM_VK_XF86XK_AUDIO_NEXT",
  25793. "DOM_VK_XF86XK_AUDIO_PAUSE",
  25794. "DOM_VK_XF86XK_AUDIO_PLAY",
  25795. "DOM_VK_XF86XK_AUDIO_PREV",
  25796. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  25797. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  25798. "DOM_VK_XF86XK_AUDIO_RECORD",
  25799. "DOM_VK_XF86XK_AUDIO_REPEAT",
  25800. "DOM_VK_XF86XK_AUDIO_REWIND",
  25801. "DOM_VK_XF86XK_AUDIO_STOP",
  25802. "DOM_VK_XF86XK_AWAY",
  25803. "DOM_VK_XF86XK_BACK",
  25804. "DOM_VK_XF86XK_BACK_FORWARD",
  25805. "DOM_VK_XF86XK_BATTERY",
  25806. "DOM_VK_XF86XK_BLUE",
  25807. "DOM_VK_XF86XK_BLUETOOTH",
  25808. "DOM_VK_XF86XK_BOOK",
  25809. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  25810. "DOM_VK_XF86XK_CALCULATOR",
  25811. "DOM_VK_XF86XK_CALENDAR",
  25812. "DOM_VK_XF86XK_CD",
  25813. "DOM_VK_XF86XK_CLOSE",
  25814. "DOM_VK_XF86XK_COMMUNITY",
  25815. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  25816. "DOM_VK_XF86XK_COPY",
  25817. "DOM_VK_XF86XK_CUT",
  25818. "DOM_VK_XF86XK_CYCLE_ANGLE",
  25819. "DOM_VK_XF86XK_DISPLAY",
  25820. "DOM_VK_XF86XK_DOCUMENTS",
  25821. "DOM_VK_XF86XK_DOS",
  25822. "DOM_VK_XF86XK_EJECT",
  25823. "DOM_VK_XF86XK_EXCEL",
  25824. "DOM_VK_XF86XK_EXPLORER",
  25825. "DOM_VK_XF86XK_FAVORITES",
  25826. "DOM_VK_XF86XK_FINANCE",
  25827. "DOM_VK_XF86XK_FORWARD",
  25828. "DOM_VK_XF86XK_FRAME_BACK",
  25829. "DOM_VK_XF86XK_FRAME_FORWARD",
  25830. "DOM_VK_XF86XK_GAME",
  25831. "DOM_VK_XF86XK_GO",
  25832. "DOM_VK_XF86XK_GREEN",
  25833. "DOM_VK_XF86XK_HIBERNATE",
  25834. "DOM_VK_XF86XK_HISTORY",
  25835. "DOM_VK_XF86XK_HOME_PAGE",
  25836. "DOM_VK_XF86XK_HOT_LINKS",
  25837. "DOM_VK_XF86XK_I_TOUCH",
  25838. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  25839. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  25840. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  25841. "DOM_VK_XF86XK_LAUNCH0",
  25842. "DOM_VK_XF86XK_LAUNCH1",
  25843. "DOM_VK_XF86XK_LAUNCH2",
  25844. "DOM_VK_XF86XK_LAUNCH3",
  25845. "DOM_VK_XF86XK_LAUNCH4",
  25846. "DOM_VK_XF86XK_LAUNCH5",
  25847. "DOM_VK_XF86XK_LAUNCH6",
  25848. "DOM_VK_XF86XK_LAUNCH7",
  25849. "DOM_VK_XF86XK_LAUNCH8",
  25850. "DOM_VK_XF86XK_LAUNCH9",
  25851. "DOM_VK_XF86XK_LAUNCH_A",
  25852. "DOM_VK_XF86XK_LAUNCH_B",
  25853. "DOM_VK_XF86XK_LAUNCH_C",
  25854. "DOM_VK_XF86XK_LAUNCH_D",
  25855. "DOM_VK_XF86XK_LAUNCH_E",
  25856. "DOM_VK_XF86XK_LAUNCH_F",
  25857. "DOM_VK_XF86XK_LIGHT_BULB",
  25858. "DOM_VK_XF86XK_LOG_OFF",
  25859. "DOM_VK_XF86XK_MAIL",
  25860. "DOM_VK_XF86XK_MAIL_FORWARD",
  25861. "DOM_VK_XF86XK_MARKET",
  25862. "DOM_VK_XF86XK_MEETING",
  25863. "DOM_VK_XF86XK_MEMO",
  25864. "DOM_VK_XF86XK_MENU_KB",
  25865. "DOM_VK_XF86XK_MENU_PB",
  25866. "DOM_VK_XF86XK_MESSENGER",
  25867. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  25868. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  25869. "DOM_VK_XF86XK_MUSIC",
  25870. "DOM_VK_XF86XK_MY_COMPUTER",
  25871. "DOM_VK_XF86XK_MY_SITES",
  25872. "DOM_VK_XF86XK_NEW",
  25873. "DOM_VK_XF86XK_NEWS",
  25874. "DOM_VK_XF86XK_OFFICE_HOME",
  25875. "DOM_VK_XF86XK_OPEN",
  25876. "DOM_VK_XF86XK_OPEN_URL",
  25877. "DOM_VK_XF86XK_OPTION",
  25878. "DOM_VK_XF86XK_PASTE",
  25879. "DOM_VK_XF86XK_PHONE",
  25880. "DOM_VK_XF86XK_PICTURES",
  25881. "DOM_VK_XF86XK_POWER_DOWN",
  25882. "DOM_VK_XF86XK_POWER_OFF",
  25883. "DOM_VK_XF86XK_RED",
  25884. "DOM_VK_XF86XK_REFRESH",
  25885. "DOM_VK_XF86XK_RELOAD",
  25886. "DOM_VK_XF86XK_REPLY",
  25887. "DOM_VK_XF86XK_ROCKER_DOWN",
  25888. "DOM_VK_XF86XK_ROCKER_ENTER",
  25889. "DOM_VK_XF86XK_ROCKER_UP",
  25890. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  25891. "DOM_VK_XF86XK_ROTATION_KB",
  25892. "DOM_VK_XF86XK_ROTATION_PB",
  25893. "DOM_VK_XF86XK_SAVE",
  25894. "DOM_VK_XF86XK_SCREEN_SAVER",
  25895. "DOM_VK_XF86XK_SCROLL_CLICK",
  25896. "DOM_VK_XF86XK_SCROLL_DOWN",
  25897. "DOM_VK_XF86XK_SCROLL_UP",
  25898. "DOM_VK_XF86XK_SEARCH",
  25899. "DOM_VK_XF86XK_SEND",
  25900. "DOM_VK_XF86XK_SHOP",
  25901. "DOM_VK_XF86XK_SPELL",
  25902. "DOM_VK_XF86XK_SPLIT_SCREEN",
  25903. "DOM_VK_XF86XK_STANDBY",
  25904. "DOM_VK_XF86XK_START",
  25905. "DOM_VK_XF86XK_STOP",
  25906. "DOM_VK_XF86XK_SUBTITLE",
  25907. "DOM_VK_XF86XK_SUPPORT",
  25908. "DOM_VK_XF86XK_SUSPEND",
  25909. "DOM_VK_XF86XK_TASK_PANE",
  25910. "DOM_VK_XF86XK_TERMINAL",
  25911. "DOM_VK_XF86XK_TIME",
  25912. "DOM_VK_XF86XK_TOOLS",
  25913. "DOM_VK_XF86XK_TOP_MENU",
  25914. "DOM_VK_XF86XK_TO_DO_LIST",
  25915. "DOM_VK_XF86XK_TRAVEL",
  25916. "DOM_VK_XF86XK_USER1KB",
  25917. "DOM_VK_XF86XK_USER2KB",
  25918. "DOM_VK_XF86XK_USER_PB",
  25919. "DOM_VK_XF86XK_UWB",
  25920. "DOM_VK_XF86XK_VENDOR_HOME",
  25921. "DOM_VK_XF86XK_VIDEO",
  25922. "DOM_VK_XF86XK_VIEW",
  25923. "DOM_VK_XF86XK_WAKE_UP",
  25924. "DOM_VK_XF86XK_WEB_CAM",
  25925. "DOM_VK_XF86XK_WHEEL_BUTTON",
  25926. "DOM_VK_XF86XK_WLAN",
  25927. "DOM_VK_XF86XK_WORD",
  25928. "DOM_VK_XF86XK_WWW",
  25929. "DOM_VK_XF86XK_XFER",
  25930. "DOM_VK_XF86XK_YELLOW",
  25931. "DOM_VK_XF86XK_ZOOM_IN",
  25932. "DOM_VK_XF86XK_ZOOM_OUT",
  25933. "DOM_VK_Y",
  25934. "DOM_VK_Z",
  25935. "DOM_VK_ZOOM",
  25936. "DONE",
  25937. "DONT_CARE",
  25938. "DOWNLOADING",
  25939. "DRAGDROP",
  25940. "DRAW_BUFFER0",
  25941. "DRAW_BUFFER1",
  25942. "DRAW_BUFFER10",
  25943. "DRAW_BUFFER11",
  25944. "DRAW_BUFFER12",
  25945. "DRAW_BUFFER13",
  25946. "DRAW_BUFFER14",
  25947. "DRAW_BUFFER15",
  25948. "DRAW_BUFFER2",
  25949. "DRAW_BUFFER3",
  25950. "DRAW_BUFFER4",
  25951. "DRAW_BUFFER5",
  25952. "DRAW_BUFFER6",
  25953. "DRAW_BUFFER7",
  25954. "DRAW_BUFFER8",
  25955. "DRAW_BUFFER9",
  25956. "DRAW_FRAMEBUFFER",
  25957. "DRAW_FRAMEBUFFER_BINDING",
  25958. "DST_ALPHA",
  25959. "DST_COLOR",
  25960. "DYNAMIC_COPY",
  25961. "DYNAMIC_DRAW",
  25962. "DYNAMIC_READ",
  25963. "DataChannel",
  25964. "DataTransfer",
  25965. "DataTransferItem",
  25966. "DataTransferItemList",
  25967. "DataView",
  25968. "Date",
  25969. "DateTimeFormat",
  25970. "DecompressionStream",
  25971. "DelayNode",
  25972. "DeprecationReportBody",
  25973. "DesktopNotification",
  25974. "DesktopNotificationCenter",
  25975. "DeviceLightEvent",
  25976. "DeviceMotionEvent",
  25977. "DeviceMotionEventAcceleration",
  25978. "DeviceMotionEventRotationRate",
  25979. "DeviceOrientationEvent",
  25980. "DeviceProximityEvent",
  25981. "DeviceStorage",
  25982. "DeviceStorageChangeEvent",
  25983. "Directory",
  25984. "DisplayNames",
  25985. "Document",
  25986. "DocumentFragment",
  25987. "DocumentTimeline",
  25988. "DocumentType",
  25989. "DragEvent",
  25990. "DynamicsCompressorNode",
  25991. "E",
  25992. "ELEMENT_ARRAY_BUFFER",
  25993. "ELEMENT_ARRAY_BUFFER_BINDING",
  25994. "ELEMENT_NODE",
  25995. "EMPTY",
  25996. "ENCODING_ERR",
  25997. "ENDED",
  25998. "END_TO_END",
  25999. "END_TO_START",
  26000. "ENTITY_NODE",
  26001. "ENTITY_REFERENCE_NODE",
  26002. "EPSILON",
  26003. "EQUAL",
  26004. "EQUALPOWER",
  26005. "ERROR",
  26006. "EXPONENTIAL_DISTANCE",
  26007. "Element",
  26008. "ElementInternals",
  26009. "ElementQuery",
  26010. "EnterPictureInPictureEvent",
  26011. "Entity",
  26012. "EntityReference",
  26013. "Error",
  26014. "ErrorEvent",
  26015. "EvalError",
  26016. "Event",
  26017. "EventException",
  26018. "EventSource",
  26019. "EventTarget",
  26020. "External",
  26021. "FASTEST",
  26022. "FIDOSDK",
  26023. "FILTER_ACCEPT",
  26024. "FILTER_INTERRUPT",
  26025. "FILTER_REJECT",
  26026. "FILTER_SKIP",
  26027. "FINISHED_STATE",
  26028. "FIRST_ORDERED_NODE_TYPE",
  26029. "FLOAT",
  26030. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  26031. "FLOAT_MAT2",
  26032. "FLOAT_MAT2x3",
  26033. "FLOAT_MAT2x4",
  26034. "FLOAT_MAT3",
  26035. "FLOAT_MAT3x2",
  26036. "FLOAT_MAT3x4",
  26037. "FLOAT_MAT4",
  26038. "FLOAT_MAT4x2",
  26039. "FLOAT_MAT4x3",
  26040. "FLOAT_VEC2",
  26041. "FLOAT_VEC3",
  26042. "FLOAT_VEC4",
  26043. "FOCUS",
  26044. "FONT_FACE_RULE",
  26045. "FONT_FEATURE_VALUES_RULE",
  26046. "FRAGMENT_SHADER",
  26047. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  26048. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  26049. "FRAMEBUFFER",
  26050. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  26051. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  26052. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  26053. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  26054. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  26055. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  26056. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  26057. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  26058. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  26059. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  26060. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  26061. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  26062. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  26063. "FRAMEBUFFER_BINDING",
  26064. "FRAMEBUFFER_COMPLETE",
  26065. "FRAMEBUFFER_DEFAULT",
  26066. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  26067. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  26068. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  26069. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  26070. "FRAMEBUFFER_UNSUPPORTED",
  26071. "FRONT",
  26072. "FRONT_AND_BACK",
  26073. "FRONT_FACE",
  26074. "FUNC_ADD",
  26075. "FUNC_REVERSE_SUBTRACT",
  26076. "FUNC_SUBTRACT",
  26077. "FeaturePolicy",
  26078. "FeaturePolicyViolationReportBody",
  26079. "FederatedCredential",
  26080. "Feed",
  26081. "FeedEntry",
  26082. "File",
  26083. "FileError",
  26084. "FileList",
  26085. "FileReader",
  26086. "FileSystem",
  26087. "FileSystemDirectoryEntry",
  26088. "FileSystemDirectoryReader",
  26089. "FileSystemEntry",
  26090. "FileSystemFileEntry",
  26091. "FinalizationRegistry",
  26092. "FindInPage",
  26093. "Float32Array",
  26094. "Float64Array",
  26095. "FocusEvent",
  26096. "FontFace",
  26097. "FontFaceSet",
  26098. "FontFaceSetLoadEvent",
  26099. "FormData",
  26100. "FormDataEvent",
  26101. "FragmentDirective",
  26102. "Function",
  26103. "GENERATE_MIPMAP_HINT",
  26104. "GEQUAL",
  26105. "GREATER",
  26106. "GREEN_BITS",
  26107. "GainNode",
  26108. "Gamepad",
  26109. "GamepadAxisMoveEvent",
  26110. "GamepadButton",
  26111. "GamepadButtonEvent",
  26112. "GamepadEvent",
  26113. "GamepadHapticActuator",
  26114. "GamepadPose",
  26115. "Geolocation",
  26116. "GeolocationCoordinates",
  26117. "GeolocationPosition",
  26118. "GeolocationPositionError",
  26119. "GestureEvent",
  26120. "Global",
  26121. "Gyroscope",
  26122. "HALF_FLOAT",
  26123. "HAVE_CURRENT_DATA",
  26124. "HAVE_ENOUGH_DATA",
  26125. "HAVE_FUTURE_DATA",
  26126. "HAVE_METADATA",
  26127. "HAVE_NOTHING",
  26128. "HEADERS_RECEIVED",
  26129. "HIDDEN",
  26130. "HIERARCHY_REQUEST_ERR",
  26131. "HIGHPASS",
  26132. "HIGHSHELF",
  26133. "HIGH_FLOAT",
  26134. "HIGH_INT",
  26135. "HORIZONTAL",
  26136. "HORIZONTAL_AXIS",
  26137. "HRTF",
  26138. "HTMLAllCollection",
  26139. "HTMLAnchorElement",
  26140. "HTMLAppletElement",
  26141. "HTMLAreaElement",
  26142. "HTMLAudioElement",
  26143. "HTMLBRElement",
  26144. "HTMLBaseElement",
  26145. "HTMLBaseFontElement",
  26146. "HTMLBlockquoteElement",
  26147. "HTMLBodyElement",
  26148. "HTMLButtonElement",
  26149. "HTMLCanvasElement",
  26150. "HTMLCollection",
  26151. "HTMLCommandElement",
  26152. "HTMLContentElement",
  26153. "HTMLDListElement",
  26154. "HTMLDataElement",
  26155. "HTMLDataListElement",
  26156. "HTMLDetailsElement",
  26157. "HTMLDialogElement",
  26158. "HTMLDirectoryElement",
  26159. "HTMLDivElement",
  26160. "HTMLDocument",
  26161. "HTMLElement",
  26162. "HTMLEmbedElement",
  26163. "HTMLFieldSetElement",
  26164. "HTMLFontElement",
  26165. "HTMLFormControlsCollection",
  26166. "HTMLFormElement",
  26167. "HTMLFrameElement",
  26168. "HTMLFrameSetElement",
  26169. "HTMLHRElement",
  26170. "HTMLHeadElement",
  26171. "HTMLHeadingElement",
  26172. "HTMLHtmlElement",
  26173. "HTMLIFrameElement",
  26174. "HTMLImageElement",
  26175. "HTMLInputElement",
  26176. "HTMLIsIndexElement",
  26177. "HTMLKeygenElement",
  26178. "HTMLLIElement",
  26179. "HTMLLabelElement",
  26180. "HTMLLegendElement",
  26181. "HTMLLinkElement",
  26182. "HTMLMapElement",
  26183. "HTMLMarqueeElement",
  26184. "HTMLMediaElement",
  26185. "HTMLMenuElement",
  26186. "HTMLMenuItemElement",
  26187. "HTMLMetaElement",
  26188. "HTMLMeterElement",
  26189. "HTMLModElement",
  26190. "HTMLOListElement",
  26191. "HTMLObjectElement",
  26192. "HTMLOptGroupElement",
  26193. "HTMLOptionElement",
  26194. "HTMLOptionsCollection",
  26195. "HTMLOutputElement",
  26196. "HTMLParagraphElement",
  26197. "HTMLParamElement",
  26198. "HTMLPictureElement",
  26199. "HTMLPreElement",
  26200. "HTMLProgressElement",
  26201. "HTMLPropertiesCollection",
  26202. "HTMLQuoteElement",
  26203. "HTMLScriptElement",
  26204. "HTMLSelectElement",
  26205. "HTMLShadowElement",
  26206. "HTMLSlotElement",
  26207. "HTMLSourceElement",
  26208. "HTMLSpanElement",
  26209. "HTMLStyleElement",
  26210. "HTMLTableCaptionElement",
  26211. "HTMLTableCellElement",
  26212. "HTMLTableColElement",
  26213. "HTMLTableElement",
  26214. "HTMLTableRowElement",
  26215. "HTMLTableSectionElement",
  26216. "HTMLTemplateElement",
  26217. "HTMLTextAreaElement",
  26218. "HTMLTimeElement",
  26219. "HTMLTitleElement",
  26220. "HTMLTrackElement",
  26221. "HTMLUListElement",
  26222. "HTMLUnknownElement",
  26223. "HTMLVideoElement",
  26224. "HashChangeEvent",
  26225. "Headers",
  26226. "History",
  26227. "Hz",
  26228. "ICE_CHECKING",
  26229. "ICE_CLOSED",
  26230. "ICE_COMPLETED",
  26231. "ICE_CONNECTED",
  26232. "ICE_FAILED",
  26233. "ICE_GATHERING",
  26234. "ICE_WAITING",
  26235. "IDBCursor",
  26236. "IDBCursorWithValue",
  26237. "IDBDatabase",
  26238. "IDBDatabaseException",
  26239. "IDBFactory",
  26240. "IDBFileHandle",
  26241. "IDBFileRequest",
  26242. "IDBIndex",
  26243. "IDBKeyRange",
  26244. "IDBMutableFile",
  26245. "IDBObjectStore",
  26246. "IDBOpenDBRequest",
  26247. "IDBRequest",
  26248. "IDBTransaction",
  26249. "IDBVersionChangeEvent",
  26250. "IDLE",
  26251. "IIRFilterNode",
  26252. "IMPLEMENTATION_COLOR_READ_FORMAT",
  26253. "IMPLEMENTATION_COLOR_READ_TYPE",
  26254. "IMPORT_RULE",
  26255. "INCR",
  26256. "INCR_WRAP",
  26257. "INDEX_SIZE_ERR",
  26258. "INT",
  26259. "INTERLEAVED_ATTRIBS",
  26260. "INT_2_10_10_10_REV",
  26261. "INT_SAMPLER_2D",
  26262. "INT_SAMPLER_2D_ARRAY",
  26263. "INT_SAMPLER_3D",
  26264. "INT_SAMPLER_CUBE",
  26265. "INT_VEC2",
  26266. "INT_VEC3",
  26267. "INT_VEC4",
  26268. "INUSE_ATTRIBUTE_ERR",
  26269. "INVALID_ACCESS_ERR",
  26270. "INVALID_CHARACTER_ERR",
  26271. "INVALID_ENUM",
  26272. "INVALID_EXPRESSION_ERR",
  26273. "INVALID_FRAMEBUFFER_OPERATION",
  26274. "INVALID_INDEX",
  26275. "INVALID_MODIFICATION_ERR",
  26276. "INVALID_NODE_TYPE_ERR",
  26277. "INVALID_OPERATION",
  26278. "INVALID_STATE_ERR",
  26279. "INVALID_VALUE",
  26280. "INVERSE_DISTANCE",
  26281. "INVERT",
  26282. "IceCandidate",
  26283. "IdleDeadline",
  26284. "Image",
  26285. "ImageBitmap",
  26286. "ImageBitmapRenderingContext",
  26287. "ImageCapture",
  26288. "ImageData",
  26289. "Infinity",
  26290. "InputDeviceCapabilities",
  26291. "InputDeviceInfo",
  26292. "InputEvent",
  26293. "InputMethodContext",
  26294. "InstallTrigger",
  26295. "InstallTriggerImpl",
  26296. "Instance",
  26297. "Int16Array",
  26298. "Int32Array",
  26299. "Int8Array",
  26300. "Intent",
  26301. "InternalError",
  26302. "IntersectionObserver",
  26303. "IntersectionObserverEntry",
  26304. "Intl",
  26305. "IsSearchProviderInstalled",
  26306. "Iterator",
  26307. "JSON",
  26308. "KEEP",
  26309. "KEYDOWN",
  26310. "KEYFRAMES_RULE",
  26311. "KEYFRAME_RULE",
  26312. "KEYPRESS",
  26313. "KEYUP",
  26314. "KeyEvent",
  26315. "Keyboard",
  26316. "KeyboardEvent",
  26317. "KeyboardLayoutMap",
  26318. "KeyframeEffect",
  26319. "LENGTHADJUST_SPACING",
  26320. "LENGTHADJUST_SPACINGANDGLYPHS",
  26321. "LENGTHADJUST_UNKNOWN",
  26322. "LEQUAL",
  26323. "LESS",
  26324. "LINEAR",
  26325. "LINEAR_DISTANCE",
  26326. "LINEAR_MIPMAP_LINEAR",
  26327. "LINEAR_MIPMAP_NEAREST",
  26328. "LINES",
  26329. "LINE_LOOP",
  26330. "LINE_STRIP",
  26331. "LINE_WIDTH",
  26332. "LINK_STATUS",
  26333. "LIVE",
  26334. "LN10",
  26335. "LN2",
  26336. "LOADED",
  26337. "LOADING",
  26338. "LOG10E",
  26339. "LOG2E",
  26340. "LOWPASS",
  26341. "LOWSHELF",
  26342. "LOW_FLOAT",
  26343. "LOW_INT",
  26344. "LSException",
  26345. "LSParserFilter",
  26346. "LUMINANCE",
  26347. "LUMINANCE_ALPHA",
  26348. "LargestContentfulPaint",
  26349. "LayoutShift",
  26350. "LayoutShiftAttribution",
  26351. "LinearAccelerationSensor",
  26352. "LinkError",
  26353. "ListFormat",
  26354. "LocalMediaStream",
  26355. "Locale",
  26356. "Location",
  26357. "Lock",
  26358. "LockManager",
  26359. "MAX",
  26360. "MAX_3D_TEXTURE_SIZE",
  26361. "MAX_ARRAY_TEXTURE_LAYERS",
  26362. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  26363. "MAX_COLOR_ATTACHMENTS",
  26364. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  26365. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  26366. "MAX_COMBINED_UNIFORM_BLOCKS",
  26367. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  26368. "MAX_CUBE_MAP_TEXTURE_SIZE",
  26369. "MAX_DRAW_BUFFERS",
  26370. "MAX_ELEMENTS_INDICES",
  26371. "MAX_ELEMENTS_VERTICES",
  26372. "MAX_ELEMENT_INDEX",
  26373. "MAX_FRAGMENT_INPUT_COMPONENTS",
  26374. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  26375. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  26376. "MAX_FRAGMENT_UNIFORM_VECTORS",
  26377. "MAX_PROGRAM_TEXEL_OFFSET",
  26378. "MAX_RENDERBUFFER_SIZE",
  26379. "MAX_SAFE_INTEGER",
  26380. "MAX_SAMPLES",
  26381. "MAX_SERVER_WAIT_TIMEOUT",
  26382. "MAX_TEXTURE_IMAGE_UNITS",
  26383. "MAX_TEXTURE_LOD_BIAS",
  26384. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  26385. "MAX_TEXTURE_SIZE",
  26386. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  26387. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  26388. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  26389. "MAX_UNIFORM_BLOCK_SIZE",
  26390. "MAX_UNIFORM_BUFFER_BINDINGS",
  26391. "MAX_VALUE",
  26392. "MAX_VARYING_COMPONENTS",
  26393. "MAX_VARYING_VECTORS",
  26394. "MAX_VERTEX_ATTRIBS",
  26395. "MAX_VERTEX_OUTPUT_COMPONENTS",
  26396. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  26397. "MAX_VERTEX_UNIFORM_BLOCKS",
  26398. "MAX_VERTEX_UNIFORM_COMPONENTS",
  26399. "MAX_VERTEX_UNIFORM_VECTORS",
  26400. "MAX_VIEWPORT_DIMS",
  26401. "MEDIA_ERR_ABORTED",
  26402. "MEDIA_ERR_DECODE",
  26403. "MEDIA_ERR_ENCRYPTED",
  26404. "MEDIA_ERR_NETWORK",
  26405. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  26406. "MEDIA_KEYERR_CLIENT",
  26407. "MEDIA_KEYERR_DOMAIN",
  26408. "MEDIA_KEYERR_HARDWARECHANGE",
  26409. "MEDIA_KEYERR_OUTPUT",
  26410. "MEDIA_KEYERR_SERVICE",
  26411. "MEDIA_KEYERR_UNKNOWN",
  26412. "MEDIA_RULE",
  26413. "MEDIUM_FLOAT",
  26414. "MEDIUM_INT",
  26415. "META_MASK",
  26416. "MIDIAccess",
  26417. "MIDIConnectionEvent",
  26418. "MIDIInput",
  26419. "MIDIInputMap",
  26420. "MIDIMessageEvent",
  26421. "MIDIOutput",
  26422. "MIDIOutputMap",
  26423. "MIDIPort",
  26424. "MIN",
  26425. "MIN_PROGRAM_TEXEL_OFFSET",
  26426. "MIN_SAFE_INTEGER",
  26427. "MIN_VALUE",
  26428. "MIRRORED_REPEAT",
  26429. "MODE_ASYNCHRONOUS",
  26430. "MODE_SYNCHRONOUS",
  26431. "MODIFICATION",
  26432. "MOUSEDOWN",
  26433. "MOUSEDRAG",
  26434. "MOUSEMOVE",
  26435. "MOUSEOUT",
  26436. "MOUSEOVER",
  26437. "MOUSEUP",
  26438. "MOZ_KEYFRAMES_RULE",
  26439. "MOZ_KEYFRAME_RULE",
  26440. "MOZ_SOURCE_CURSOR",
  26441. "MOZ_SOURCE_ERASER",
  26442. "MOZ_SOURCE_KEYBOARD",
  26443. "MOZ_SOURCE_MOUSE",
  26444. "MOZ_SOURCE_PEN",
  26445. "MOZ_SOURCE_TOUCH",
  26446. "MOZ_SOURCE_UNKNOWN",
  26447. "MSGESTURE_FLAG_BEGIN",
  26448. "MSGESTURE_FLAG_CANCEL",
  26449. "MSGESTURE_FLAG_END",
  26450. "MSGESTURE_FLAG_INERTIA",
  26451. "MSGESTURE_FLAG_NONE",
  26452. "MSPOINTER_TYPE_MOUSE",
  26453. "MSPOINTER_TYPE_PEN",
  26454. "MSPOINTER_TYPE_TOUCH",
  26455. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  26456. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  26457. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  26458. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  26459. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  26460. "MS_ASYNC_OP_STATUS_CANCELED",
  26461. "MS_ASYNC_OP_STATUS_ERROR",
  26462. "MS_ASYNC_OP_STATUS_SUCCESS",
  26463. "MS_MANIPULATION_STATE_ACTIVE",
  26464. "MS_MANIPULATION_STATE_CANCELLED",
  26465. "MS_MANIPULATION_STATE_COMMITTED",
  26466. "MS_MANIPULATION_STATE_DRAGGING",
  26467. "MS_MANIPULATION_STATE_INERTIA",
  26468. "MS_MANIPULATION_STATE_PRESELECT",
  26469. "MS_MANIPULATION_STATE_SELECTING",
  26470. "MS_MANIPULATION_STATE_STOPPED",
  26471. "MS_MEDIA_ERR_ENCRYPTED",
  26472. "MS_MEDIA_KEYERR_CLIENT",
  26473. "MS_MEDIA_KEYERR_DOMAIN",
  26474. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  26475. "MS_MEDIA_KEYERR_OUTPUT",
  26476. "MS_MEDIA_KEYERR_SERVICE",
  26477. "MS_MEDIA_KEYERR_UNKNOWN",
  26478. "Map",
  26479. "Math",
  26480. "MathMLElement",
  26481. "MediaCapabilities",
  26482. "MediaCapabilitiesInfo",
  26483. "MediaController",
  26484. "MediaDeviceInfo",
  26485. "MediaDevices",
  26486. "MediaElementAudioSourceNode",
  26487. "MediaEncryptedEvent",
  26488. "MediaError",
  26489. "MediaKeyError",
  26490. "MediaKeyEvent",
  26491. "MediaKeyMessageEvent",
  26492. "MediaKeyNeededEvent",
  26493. "MediaKeySession",
  26494. "MediaKeyStatusMap",
  26495. "MediaKeySystemAccess",
  26496. "MediaKeys",
  26497. "MediaList",
  26498. "MediaMetadata",
  26499. "MediaQueryList",
  26500. "MediaQueryListEvent",
  26501. "MediaRecorder",
  26502. "MediaRecorderErrorEvent",
  26503. "MediaSession",
  26504. "MediaSettingsRange",
  26505. "MediaSource",
  26506. "MediaStream",
  26507. "MediaStreamAudioDestinationNode",
  26508. "MediaStreamAudioSourceNode",
  26509. "MediaStreamEvent",
  26510. "MediaStreamTrack",
  26511. "MediaStreamTrackAudioSourceNode",
  26512. "MediaStreamTrackEvent",
  26513. "Memory",
  26514. "MessageChannel",
  26515. "MessageEvent",
  26516. "MessagePort",
  26517. "Methods",
  26518. "MimeType",
  26519. "MimeTypeArray",
  26520. "Module",
  26521. "MouseEvent",
  26522. "MouseScrollEvent",
  26523. "MozAnimation",
  26524. "MozAnimationDelay",
  26525. "MozAnimationDirection",
  26526. "MozAnimationDuration",
  26527. "MozAnimationFillMode",
  26528. "MozAnimationIterationCount",
  26529. "MozAnimationName",
  26530. "MozAnimationPlayState",
  26531. "MozAnimationTimingFunction",
  26532. "MozAppearance",
  26533. "MozBackfaceVisibility",
  26534. "MozBinding",
  26535. "MozBorderBottomColors",
  26536. "MozBorderEnd",
  26537. "MozBorderEndColor",
  26538. "MozBorderEndStyle",
  26539. "MozBorderEndWidth",
  26540. "MozBorderImage",
  26541. "MozBorderLeftColors",
  26542. "MozBorderRightColors",
  26543. "MozBorderStart",
  26544. "MozBorderStartColor",
  26545. "MozBorderStartStyle",
  26546. "MozBorderStartWidth",
  26547. "MozBorderTopColors",
  26548. "MozBoxAlign",
  26549. "MozBoxDirection",
  26550. "MozBoxFlex",
  26551. "MozBoxOrdinalGroup",
  26552. "MozBoxOrient",
  26553. "MozBoxPack",
  26554. "MozBoxSizing",
  26555. "MozCSSKeyframeRule",
  26556. "MozCSSKeyframesRule",
  26557. "MozColumnCount",
  26558. "MozColumnFill",
  26559. "MozColumnGap",
  26560. "MozColumnRule",
  26561. "MozColumnRuleColor",
  26562. "MozColumnRuleStyle",
  26563. "MozColumnRuleWidth",
  26564. "MozColumnWidth",
  26565. "MozColumns",
  26566. "MozContactChangeEvent",
  26567. "MozFloatEdge",
  26568. "MozFontFeatureSettings",
  26569. "MozFontLanguageOverride",
  26570. "MozForceBrokenImageIcon",
  26571. "MozHyphens",
  26572. "MozImageRegion",
  26573. "MozMarginEnd",
  26574. "MozMarginStart",
  26575. "MozMmsEvent",
  26576. "MozMmsMessage",
  26577. "MozMobileMessageThread",
  26578. "MozOSXFontSmoothing",
  26579. "MozOrient",
  26580. "MozOsxFontSmoothing",
  26581. "MozOutlineRadius",
  26582. "MozOutlineRadiusBottomleft",
  26583. "MozOutlineRadiusBottomright",
  26584. "MozOutlineRadiusTopleft",
  26585. "MozOutlineRadiusTopright",
  26586. "MozPaddingEnd",
  26587. "MozPaddingStart",
  26588. "MozPerspective",
  26589. "MozPerspectiveOrigin",
  26590. "MozPowerManager",
  26591. "MozSettingsEvent",
  26592. "MozSmsEvent",
  26593. "MozSmsMessage",
  26594. "MozStackSizing",
  26595. "MozTabSize",
  26596. "MozTextAlignLast",
  26597. "MozTextDecorationColor",
  26598. "MozTextDecorationLine",
  26599. "MozTextDecorationStyle",
  26600. "MozTextSizeAdjust",
  26601. "MozTransform",
  26602. "MozTransformOrigin",
  26603. "MozTransformStyle",
  26604. "MozTransition",
  26605. "MozTransitionDelay",
  26606. "MozTransitionDuration",
  26607. "MozTransitionProperty",
  26608. "MozTransitionTimingFunction",
  26609. "MozUserFocus",
  26610. "MozUserInput",
  26611. "MozUserModify",
  26612. "MozUserSelect",
  26613. "MozWindowDragging",
  26614. "MozWindowShadow",
  26615. "MutationEvent",
  26616. "MutationObserver",
  26617. "MutationRecord",
  26618. "NAMESPACE_ERR",
  26619. "NAMESPACE_RULE",
  26620. "NEAREST",
  26621. "NEAREST_MIPMAP_LINEAR",
  26622. "NEAREST_MIPMAP_NEAREST",
  26623. "NEGATIVE_INFINITY",
  26624. "NETWORK_EMPTY",
  26625. "NETWORK_ERR",
  26626. "NETWORK_IDLE",
  26627. "NETWORK_LOADED",
  26628. "NETWORK_LOADING",
  26629. "NETWORK_NO_SOURCE",
  26630. "NEVER",
  26631. "NEW",
  26632. "NEXT",
  26633. "NEXT_NO_DUPLICATE",
  26634. "NICEST",
  26635. "NODE_AFTER",
  26636. "NODE_BEFORE",
  26637. "NODE_BEFORE_AND_AFTER",
  26638. "NODE_INSIDE",
  26639. "NONE",
  26640. "NON_TRANSIENT_ERR",
  26641. "NOTATION_NODE",
  26642. "NOTCH",
  26643. "NOTEQUAL",
  26644. "NOT_ALLOWED_ERR",
  26645. "NOT_FOUND_ERR",
  26646. "NOT_READABLE_ERR",
  26647. "NOT_SUPPORTED_ERR",
  26648. "NO_DATA_ALLOWED_ERR",
  26649. "NO_ERR",
  26650. "NO_ERROR",
  26651. "NO_MODIFICATION_ALLOWED_ERR",
  26652. "NUMBER_TYPE",
  26653. "NUM_COMPRESSED_TEXTURE_FORMATS",
  26654. "NaN",
  26655. "NamedNodeMap",
  26656. "NavigationPreloadManager",
  26657. "Navigator",
  26658. "NearbyLinks",
  26659. "NetworkInformation",
  26660. "Node",
  26661. "NodeFilter",
  26662. "NodeIterator",
  26663. "NodeList",
  26664. "Notation",
  26665. "Notification",
  26666. "NotifyPaintEvent",
  26667. "Number",
  26668. "NumberFormat",
  26669. "OBJECT_TYPE",
  26670. "OBSOLETE",
  26671. "OK",
  26672. "ONE",
  26673. "ONE_MINUS_CONSTANT_ALPHA",
  26674. "ONE_MINUS_CONSTANT_COLOR",
  26675. "ONE_MINUS_DST_ALPHA",
  26676. "ONE_MINUS_DST_COLOR",
  26677. "ONE_MINUS_SRC_ALPHA",
  26678. "ONE_MINUS_SRC_COLOR",
  26679. "OPEN",
  26680. "OPENED",
  26681. "OPENING",
  26682. "ORDERED_NODE_ITERATOR_TYPE",
  26683. "ORDERED_NODE_SNAPSHOT_TYPE",
  26684. "OTHER_ERROR",
  26685. "OUT_OF_MEMORY",
  26686. "Object",
  26687. "OfflineAudioCompletionEvent",
  26688. "OfflineAudioContext",
  26689. "OfflineResourceList",
  26690. "OffscreenCanvas",
  26691. "OffscreenCanvasRenderingContext2D",
  26692. "Option",
  26693. "OrientationSensor",
  26694. "OscillatorNode",
  26695. "OverconstrainedError",
  26696. "OverflowEvent",
  26697. "PACK_ALIGNMENT",
  26698. "PACK_ROW_LENGTH",
  26699. "PACK_SKIP_PIXELS",
  26700. "PACK_SKIP_ROWS",
  26701. "PAGE_RULE",
  26702. "PARSE_ERR",
  26703. "PATHSEG_ARC_ABS",
  26704. "PATHSEG_ARC_REL",
  26705. "PATHSEG_CLOSEPATH",
  26706. "PATHSEG_CURVETO_CUBIC_ABS",
  26707. "PATHSEG_CURVETO_CUBIC_REL",
  26708. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  26709. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  26710. "PATHSEG_CURVETO_QUADRATIC_ABS",
  26711. "PATHSEG_CURVETO_QUADRATIC_REL",
  26712. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  26713. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  26714. "PATHSEG_LINETO_ABS",
  26715. "PATHSEG_LINETO_HORIZONTAL_ABS",
  26716. "PATHSEG_LINETO_HORIZONTAL_REL",
  26717. "PATHSEG_LINETO_REL",
  26718. "PATHSEG_LINETO_VERTICAL_ABS",
  26719. "PATHSEG_LINETO_VERTICAL_REL",
  26720. "PATHSEG_MOVETO_ABS",
  26721. "PATHSEG_MOVETO_REL",
  26722. "PATHSEG_UNKNOWN",
  26723. "PATH_EXISTS_ERR",
  26724. "PEAKING",
  26725. "PERMISSION_DENIED",
  26726. "PERSISTENT",
  26727. "PI",
  26728. "PIXEL_PACK_BUFFER",
  26729. "PIXEL_PACK_BUFFER_BINDING",
  26730. "PIXEL_UNPACK_BUFFER",
  26731. "PIXEL_UNPACK_BUFFER_BINDING",
  26732. "PLAYING_STATE",
  26733. "POINTS",
  26734. "POLYGON_OFFSET_FACTOR",
  26735. "POLYGON_OFFSET_FILL",
  26736. "POLYGON_OFFSET_UNITS",
  26737. "POSITION_UNAVAILABLE",
  26738. "POSITIVE_INFINITY",
  26739. "PREV",
  26740. "PREV_NO_DUPLICATE",
  26741. "PROCESSING_INSTRUCTION_NODE",
  26742. "PageChangeEvent",
  26743. "PageTransitionEvent",
  26744. "PaintRequest",
  26745. "PaintRequestList",
  26746. "PannerNode",
  26747. "PasswordCredential",
  26748. "Path2D",
  26749. "PaymentAddress",
  26750. "PaymentInstruments",
  26751. "PaymentManager",
  26752. "PaymentMethodChangeEvent",
  26753. "PaymentRequest",
  26754. "PaymentRequestUpdateEvent",
  26755. "PaymentResponse",
  26756. "Performance",
  26757. "PerformanceElementTiming",
  26758. "PerformanceEntry",
  26759. "PerformanceEventTiming",
  26760. "PerformanceLongTaskTiming",
  26761. "PerformanceMark",
  26762. "PerformanceMeasure",
  26763. "PerformanceNavigation",
  26764. "PerformanceNavigationTiming",
  26765. "PerformanceObserver",
  26766. "PerformanceObserverEntryList",
  26767. "PerformancePaintTiming",
  26768. "PerformanceResourceTiming",
  26769. "PerformanceServerTiming",
  26770. "PerformanceTiming",
  26771. "PeriodicSyncManager",
  26772. "PeriodicWave",
  26773. "PermissionStatus",
  26774. "Permissions",
  26775. "PhotoCapabilities",
  26776. "PictureInPictureWindow",
  26777. "Plugin",
  26778. "PluginArray",
  26779. "PluralRules",
  26780. "PointerEvent",
  26781. "PopStateEvent",
  26782. "PopupBlockedEvent",
  26783. "Presentation",
  26784. "PresentationAvailability",
  26785. "PresentationConnection",
  26786. "PresentationConnectionAvailableEvent",
  26787. "PresentationConnectionCloseEvent",
  26788. "PresentationConnectionList",
  26789. "PresentationReceiver",
  26790. "PresentationRequest",
  26791. "ProcessingInstruction",
  26792. "ProgressEvent",
  26793. "Promise",
  26794. "PromiseRejectionEvent",
  26795. "PropertyNodeList",
  26796. "Proxy",
  26797. "PublicKeyCredential",
  26798. "PushManager",
  26799. "PushSubscription",
  26800. "PushSubscriptionOptions",
  26801. "Q",
  26802. "QUERY_RESULT",
  26803. "QUERY_RESULT_AVAILABLE",
  26804. "QUOTA_ERR",
  26805. "QUOTA_EXCEEDED_ERR",
  26806. "QueryInterface",
  26807. "R11F_G11F_B10F",
  26808. "R16F",
  26809. "R16I",
  26810. "R16UI",
  26811. "R32F",
  26812. "R32I",
  26813. "R32UI",
  26814. "R8",
  26815. "R8I",
  26816. "R8UI",
  26817. "R8_SNORM",
  26818. "RASTERIZER_DISCARD",
  26819. "READ_BUFFER",
  26820. "READ_FRAMEBUFFER",
  26821. "READ_FRAMEBUFFER_BINDING",
  26822. "READ_ONLY",
  26823. "READ_ONLY_ERR",
  26824. "READ_WRITE",
  26825. "RED",
  26826. "RED_BITS",
  26827. "RED_INTEGER",
  26828. "REMOVAL",
  26829. "RENDERBUFFER",
  26830. "RENDERBUFFER_ALPHA_SIZE",
  26831. "RENDERBUFFER_BINDING",
  26832. "RENDERBUFFER_BLUE_SIZE",
  26833. "RENDERBUFFER_DEPTH_SIZE",
  26834. "RENDERBUFFER_GREEN_SIZE",
  26835. "RENDERBUFFER_HEIGHT",
  26836. "RENDERBUFFER_INTERNAL_FORMAT",
  26837. "RENDERBUFFER_RED_SIZE",
  26838. "RENDERBUFFER_SAMPLES",
  26839. "RENDERBUFFER_STENCIL_SIZE",
  26840. "RENDERBUFFER_WIDTH",
  26841. "RENDERER",
  26842. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  26843. "RENDERING_INTENT_AUTO",
  26844. "RENDERING_INTENT_PERCEPTUAL",
  26845. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  26846. "RENDERING_INTENT_SATURATION",
  26847. "RENDERING_INTENT_UNKNOWN",
  26848. "REPEAT",
  26849. "REPLACE",
  26850. "RG",
  26851. "RG16F",
  26852. "RG16I",
  26853. "RG16UI",
  26854. "RG32F",
  26855. "RG32I",
  26856. "RG32UI",
  26857. "RG8",
  26858. "RG8I",
  26859. "RG8UI",
  26860. "RG8_SNORM",
  26861. "RGB",
  26862. "RGB10_A2",
  26863. "RGB10_A2UI",
  26864. "RGB16F",
  26865. "RGB16I",
  26866. "RGB16UI",
  26867. "RGB32F",
  26868. "RGB32I",
  26869. "RGB32UI",
  26870. "RGB565",
  26871. "RGB5_A1",
  26872. "RGB8",
  26873. "RGB8I",
  26874. "RGB8UI",
  26875. "RGB8_SNORM",
  26876. "RGB9_E5",
  26877. "RGBA",
  26878. "RGBA16F",
  26879. "RGBA16I",
  26880. "RGBA16UI",
  26881. "RGBA32F",
  26882. "RGBA32I",
  26883. "RGBA32UI",
  26884. "RGBA4",
  26885. "RGBA8",
  26886. "RGBA8I",
  26887. "RGBA8UI",
  26888. "RGBA8_SNORM",
  26889. "RGBA_INTEGER",
  26890. "RGBColor",
  26891. "RGB_INTEGER",
  26892. "RG_INTEGER",
  26893. "ROTATION_CLOCKWISE",
  26894. "ROTATION_COUNTERCLOCKWISE",
  26895. "RTCCertificate",
  26896. "RTCDTMFSender",
  26897. "RTCDTMFToneChangeEvent",
  26898. "RTCDataChannel",
  26899. "RTCDataChannelEvent",
  26900. "RTCDtlsTransport",
  26901. "RTCError",
  26902. "RTCErrorEvent",
  26903. "RTCIceCandidate",
  26904. "RTCIceTransport",
  26905. "RTCPeerConnection",
  26906. "RTCPeerConnectionIceErrorEvent",
  26907. "RTCPeerConnectionIceEvent",
  26908. "RTCRtpReceiver",
  26909. "RTCRtpSender",
  26910. "RTCRtpTransceiver",
  26911. "RTCSctpTransport",
  26912. "RTCSessionDescription",
  26913. "RTCStatsReport",
  26914. "RTCTrackEvent",
  26915. "RadioNodeList",
  26916. "Range",
  26917. "RangeError",
  26918. "RangeException",
  26919. "ReadableStream",
  26920. "ReadableStreamDefaultReader",
  26921. "RecordErrorEvent",
  26922. "Rect",
  26923. "ReferenceError",
  26924. "Reflect",
  26925. "RegExp",
  26926. "RelativeOrientationSensor",
  26927. "RelativeTimeFormat",
  26928. "RemotePlayback",
  26929. "Report",
  26930. "ReportBody",
  26931. "ReportingObserver",
  26932. "Request",
  26933. "ResizeObserver",
  26934. "ResizeObserverEntry",
  26935. "ResizeObserverSize",
  26936. "Response",
  26937. "RuntimeError",
  26938. "SAMPLER_2D",
  26939. "SAMPLER_2D_ARRAY",
  26940. "SAMPLER_2D_ARRAY_SHADOW",
  26941. "SAMPLER_2D_SHADOW",
  26942. "SAMPLER_3D",
  26943. "SAMPLER_BINDING",
  26944. "SAMPLER_CUBE",
  26945. "SAMPLER_CUBE_SHADOW",
  26946. "SAMPLES",
  26947. "SAMPLE_ALPHA_TO_COVERAGE",
  26948. "SAMPLE_BUFFERS",
  26949. "SAMPLE_COVERAGE",
  26950. "SAMPLE_COVERAGE_INVERT",
  26951. "SAMPLE_COVERAGE_VALUE",
  26952. "SAWTOOTH",
  26953. "SCHEDULED_STATE",
  26954. "SCISSOR_BOX",
  26955. "SCISSOR_TEST",
  26956. "SCROLL_PAGE_DOWN",
  26957. "SCROLL_PAGE_UP",
  26958. "SDP_ANSWER",
  26959. "SDP_OFFER",
  26960. "SDP_PRANSWER",
  26961. "SECURITY_ERR",
  26962. "SELECT",
  26963. "SEPARATE_ATTRIBS",
  26964. "SERIALIZE_ERR",
  26965. "SEVERITY_ERROR",
  26966. "SEVERITY_FATAL_ERROR",
  26967. "SEVERITY_WARNING",
  26968. "SHADER_COMPILER",
  26969. "SHADER_TYPE",
  26970. "SHADING_LANGUAGE_VERSION",
  26971. "SHIFT_MASK",
  26972. "SHORT",
  26973. "SHOWING",
  26974. "SHOW_ALL",
  26975. "SHOW_ATTRIBUTE",
  26976. "SHOW_CDATA_SECTION",
  26977. "SHOW_COMMENT",
  26978. "SHOW_DOCUMENT",
  26979. "SHOW_DOCUMENT_FRAGMENT",
  26980. "SHOW_DOCUMENT_TYPE",
  26981. "SHOW_ELEMENT",
  26982. "SHOW_ENTITY",
  26983. "SHOW_ENTITY_REFERENCE",
  26984. "SHOW_NOTATION",
  26985. "SHOW_PROCESSING_INSTRUCTION",
  26986. "SHOW_TEXT",
  26987. "SIGNALED",
  26988. "SIGNED_NORMALIZED",
  26989. "SINE",
  26990. "SOUNDFIELD",
  26991. "SQLException",
  26992. "SQRT1_2",
  26993. "SQRT2",
  26994. "SQUARE",
  26995. "SRC_ALPHA",
  26996. "SRC_ALPHA_SATURATE",
  26997. "SRC_COLOR",
  26998. "SRGB",
  26999. "SRGB8",
  27000. "SRGB8_ALPHA8",
  27001. "START_TO_END",
  27002. "START_TO_START",
  27003. "STATIC_COPY",
  27004. "STATIC_DRAW",
  27005. "STATIC_READ",
  27006. "STENCIL",
  27007. "STENCIL_ATTACHMENT",
  27008. "STENCIL_BACK_FAIL",
  27009. "STENCIL_BACK_FUNC",
  27010. "STENCIL_BACK_PASS_DEPTH_FAIL",
  27011. "STENCIL_BACK_PASS_DEPTH_PASS",
  27012. "STENCIL_BACK_REF",
  27013. "STENCIL_BACK_VALUE_MASK",
  27014. "STENCIL_BACK_WRITEMASK",
  27015. "STENCIL_BITS",
  27016. "STENCIL_BUFFER_BIT",
  27017. "STENCIL_CLEAR_VALUE",
  27018. "STENCIL_FAIL",
  27019. "STENCIL_FUNC",
  27020. "STENCIL_INDEX",
  27021. "STENCIL_INDEX8",
  27022. "STENCIL_PASS_DEPTH_FAIL",
  27023. "STENCIL_PASS_DEPTH_PASS",
  27024. "STENCIL_REF",
  27025. "STENCIL_TEST",
  27026. "STENCIL_VALUE_MASK",
  27027. "STENCIL_WRITEMASK",
  27028. "STREAM_COPY",
  27029. "STREAM_DRAW",
  27030. "STREAM_READ",
  27031. "STRING_TYPE",
  27032. "STYLE_RULE",
  27033. "SUBPIXEL_BITS",
  27034. "SUPPORTS_RULE",
  27035. "SVGAElement",
  27036. "SVGAltGlyphDefElement",
  27037. "SVGAltGlyphElement",
  27038. "SVGAltGlyphItemElement",
  27039. "SVGAngle",
  27040. "SVGAnimateColorElement",
  27041. "SVGAnimateElement",
  27042. "SVGAnimateMotionElement",
  27043. "SVGAnimateTransformElement",
  27044. "SVGAnimatedAngle",
  27045. "SVGAnimatedBoolean",
  27046. "SVGAnimatedEnumeration",
  27047. "SVGAnimatedInteger",
  27048. "SVGAnimatedLength",
  27049. "SVGAnimatedLengthList",
  27050. "SVGAnimatedNumber",
  27051. "SVGAnimatedNumberList",
  27052. "SVGAnimatedPreserveAspectRatio",
  27053. "SVGAnimatedRect",
  27054. "SVGAnimatedString",
  27055. "SVGAnimatedTransformList",
  27056. "SVGAnimationElement",
  27057. "SVGCircleElement",
  27058. "SVGClipPathElement",
  27059. "SVGColor",
  27060. "SVGComponentTransferFunctionElement",
  27061. "SVGCursorElement",
  27062. "SVGDefsElement",
  27063. "SVGDescElement",
  27064. "SVGDiscardElement",
  27065. "SVGDocument",
  27066. "SVGElement",
  27067. "SVGElementInstance",
  27068. "SVGElementInstanceList",
  27069. "SVGEllipseElement",
  27070. "SVGException",
  27071. "SVGFEBlendElement",
  27072. "SVGFEColorMatrixElement",
  27073. "SVGFEComponentTransferElement",
  27074. "SVGFECompositeElement",
  27075. "SVGFEConvolveMatrixElement",
  27076. "SVGFEDiffuseLightingElement",
  27077. "SVGFEDisplacementMapElement",
  27078. "SVGFEDistantLightElement",
  27079. "SVGFEDropShadowElement",
  27080. "SVGFEFloodElement",
  27081. "SVGFEFuncAElement",
  27082. "SVGFEFuncBElement",
  27083. "SVGFEFuncGElement",
  27084. "SVGFEFuncRElement",
  27085. "SVGFEGaussianBlurElement",
  27086. "SVGFEImageElement",
  27087. "SVGFEMergeElement",
  27088. "SVGFEMergeNodeElement",
  27089. "SVGFEMorphologyElement",
  27090. "SVGFEOffsetElement",
  27091. "SVGFEPointLightElement",
  27092. "SVGFESpecularLightingElement",
  27093. "SVGFESpotLightElement",
  27094. "SVGFETileElement",
  27095. "SVGFETurbulenceElement",
  27096. "SVGFilterElement",
  27097. "SVGFontElement",
  27098. "SVGFontFaceElement",
  27099. "SVGFontFaceFormatElement",
  27100. "SVGFontFaceNameElement",
  27101. "SVGFontFaceSrcElement",
  27102. "SVGFontFaceUriElement",
  27103. "SVGForeignObjectElement",
  27104. "SVGGElement",
  27105. "SVGGeometryElement",
  27106. "SVGGlyphElement",
  27107. "SVGGlyphRefElement",
  27108. "SVGGradientElement",
  27109. "SVGGraphicsElement",
  27110. "SVGHKernElement",
  27111. "SVGImageElement",
  27112. "SVGLength",
  27113. "SVGLengthList",
  27114. "SVGLineElement",
  27115. "SVGLinearGradientElement",
  27116. "SVGMPathElement",
  27117. "SVGMarkerElement",
  27118. "SVGMaskElement",
  27119. "SVGMatrix",
  27120. "SVGMetadataElement",
  27121. "SVGMissingGlyphElement",
  27122. "SVGNumber",
  27123. "SVGNumberList",
  27124. "SVGPaint",
  27125. "SVGPathElement",
  27126. "SVGPathSeg",
  27127. "SVGPathSegArcAbs",
  27128. "SVGPathSegArcRel",
  27129. "SVGPathSegClosePath",
  27130. "SVGPathSegCurvetoCubicAbs",
  27131. "SVGPathSegCurvetoCubicRel",
  27132. "SVGPathSegCurvetoCubicSmoothAbs",
  27133. "SVGPathSegCurvetoCubicSmoothRel",
  27134. "SVGPathSegCurvetoQuadraticAbs",
  27135. "SVGPathSegCurvetoQuadraticRel",
  27136. "SVGPathSegCurvetoQuadraticSmoothAbs",
  27137. "SVGPathSegCurvetoQuadraticSmoothRel",
  27138. "SVGPathSegLinetoAbs",
  27139. "SVGPathSegLinetoHorizontalAbs",
  27140. "SVGPathSegLinetoHorizontalRel",
  27141. "SVGPathSegLinetoRel",
  27142. "SVGPathSegLinetoVerticalAbs",
  27143. "SVGPathSegLinetoVerticalRel",
  27144. "SVGPathSegList",
  27145. "SVGPathSegMovetoAbs",
  27146. "SVGPathSegMovetoRel",
  27147. "SVGPatternElement",
  27148. "SVGPoint",
  27149. "SVGPointList",
  27150. "SVGPolygonElement",
  27151. "SVGPolylineElement",
  27152. "SVGPreserveAspectRatio",
  27153. "SVGRadialGradientElement",
  27154. "SVGRect",
  27155. "SVGRectElement",
  27156. "SVGRenderingIntent",
  27157. "SVGSVGElement",
  27158. "SVGScriptElement",
  27159. "SVGSetElement",
  27160. "SVGStopElement",
  27161. "SVGStringList",
  27162. "SVGStyleElement",
  27163. "SVGSwitchElement",
  27164. "SVGSymbolElement",
  27165. "SVGTRefElement",
  27166. "SVGTSpanElement",
  27167. "SVGTextContentElement",
  27168. "SVGTextElement",
  27169. "SVGTextPathElement",
  27170. "SVGTextPositioningElement",
  27171. "SVGTitleElement",
  27172. "SVGTransform",
  27173. "SVGTransformList",
  27174. "SVGUnitTypes",
  27175. "SVGUseElement",
  27176. "SVGVKernElement",
  27177. "SVGViewElement",
  27178. "SVGViewSpec",
  27179. "SVGZoomAndPan",
  27180. "SVGZoomEvent",
  27181. "SVG_ANGLETYPE_DEG",
  27182. "SVG_ANGLETYPE_GRAD",
  27183. "SVG_ANGLETYPE_RAD",
  27184. "SVG_ANGLETYPE_UNKNOWN",
  27185. "SVG_ANGLETYPE_UNSPECIFIED",
  27186. "SVG_CHANNEL_A",
  27187. "SVG_CHANNEL_B",
  27188. "SVG_CHANNEL_G",
  27189. "SVG_CHANNEL_R",
  27190. "SVG_CHANNEL_UNKNOWN",
  27191. "SVG_COLORTYPE_CURRENTCOLOR",
  27192. "SVG_COLORTYPE_RGBCOLOR",
  27193. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  27194. "SVG_COLORTYPE_UNKNOWN",
  27195. "SVG_EDGEMODE_DUPLICATE",
  27196. "SVG_EDGEMODE_NONE",
  27197. "SVG_EDGEMODE_UNKNOWN",
  27198. "SVG_EDGEMODE_WRAP",
  27199. "SVG_FEBLEND_MODE_COLOR",
  27200. "SVG_FEBLEND_MODE_COLOR_BURN",
  27201. "SVG_FEBLEND_MODE_COLOR_DODGE",
  27202. "SVG_FEBLEND_MODE_DARKEN",
  27203. "SVG_FEBLEND_MODE_DIFFERENCE",
  27204. "SVG_FEBLEND_MODE_EXCLUSION",
  27205. "SVG_FEBLEND_MODE_HARD_LIGHT",
  27206. "SVG_FEBLEND_MODE_HUE",
  27207. "SVG_FEBLEND_MODE_LIGHTEN",
  27208. "SVG_FEBLEND_MODE_LUMINOSITY",
  27209. "SVG_FEBLEND_MODE_MULTIPLY",
  27210. "SVG_FEBLEND_MODE_NORMAL",
  27211. "SVG_FEBLEND_MODE_OVERLAY",
  27212. "SVG_FEBLEND_MODE_SATURATION",
  27213. "SVG_FEBLEND_MODE_SCREEN",
  27214. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  27215. "SVG_FEBLEND_MODE_UNKNOWN",
  27216. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  27217. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  27218. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  27219. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  27220. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  27221. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  27222. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  27223. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  27224. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  27225. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  27226. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  27227. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  27228. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  27229. "SVG_FECOMPOSITE_OPERATOR_IN",
  27230. "SVG_FECOMPOSITE_OPERATOR_OUT",
  27231. "SVG_FECOMPOSITE_OPERATOR_OVER",
  27232. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  27233. "SVG_FECOMPOSITE_OPERATOR_XOR",
  27234. "SVG_INVALID_VALUE_ERR",
  27235. "SVG_LENGTHTYPE_CM",
  27236. "SVG_LENGTHTYPE_EMS",
  27237. "SVG_LENGTHTYPE_EXS",
  27238. "SVG_LENGTHTYPE_IN",
  27239. "SVG_LENGTHTYPE_MM",
  27240. "SVG_LENGTHTYPE_NUMBER",
  27241. "SVG_LENGTHTYPE_PC",
  27242. "SVG_LENGTHTYPE_PERCENTAGE",
  27243. "SVG_LENGTHTYPE_PT",
  27244. "SVG_LENGTHTYPE_PX",
  27245. "SVG_LENGTHTYPE_UNKNOWN",
  27246. "SVG_MARKERUNITS_STROKEWIDTH",
  27247. "SVG_MARKERUNITS_UNKNOWN",
  27248. "SVG_MARKERUNITS_USERSPACEONUSE",
  27249. "SVG_MARKER_ORIENT_ANGLE",
  27250. "SVG_MARKER_ORIENT_AUTO",
  27251. "SVG_MARKER_ORIENT_UNKNOWN",
  27252. "SVG_MASKTYPE_ALPHA",
  27253. "SVG_MASKTYPE_LUMINANCE",
  27254. "SVG_MATRIX_NOT_INVERTABLE",
  27255. "SVG_MEETORSLICE_MEET",
  27256. "SVG_MEETORSLICE_SLICE",
  27257. "SVG_MEETORSLICE_UNKNOWN",
  27258. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  27259. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  27260. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  27261. "SVG_PAINTTYPE_CURRENTCOLOR",
  27262. "SVG_PAINTTYPE_NONE",
  27263. "SVG_PAINTTYPE_RGBCOLOR",
  27264. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  27265. "SVG_PAINTTYPE_UNKNOWN",
  27266. "SVG_PAINTTYPE_URI",
  27267. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  27268. "SVG_PAINTTYPE_URI_NONE",
  27269. "SVG_PAINTTYPE_URI_RGBCOLOR",
  27270. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  27271. "SVG_PRESERVEASPECTRATIO_NONE",
  27272. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  27273. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  27274. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  27275. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  27276. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  27277. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  27278. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  27279. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  27280. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  27281. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  27282. "SVG_SPREADMETHOD_PAD",
  27283. "SVG_SPREADMETHOD_REFLECT",
  27284. "SVG_SPREADMETHOD_REPEAT",
  27285. "SVG_SPREADMETHOD_UNKNOWN",
  27286. "SVG_STITCHTYPE_NOSTITCH",
  27287. "SVG_STITCHTYPE_STITCH",
  27288. "SVG_STITCHTYPE_UNKNOWN",
  27289. "SVG_TRANSFORM_MATRIX",
  27290. "SVG_TRANSFORM_ROTATE",
  27291. "SVG_TRANSFORM_SCALE",
  27292. "SVG_TRANSFORM_SKEWX",
  27293. "SVG_TRANSFORM_SKEWY",
  27294. "SVG_TRANSFORM_TRANSLATE",
  27295. "SVG_TRANSFORM_UNKNOWN",
  27296. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  27297. "SVG_TURBULENCE_TYPE_TURBULENCE",
  27298. "SVG_TURBULENCE_TYPE_UNKNOWN",
  27299. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  27300. "SVG_UNIT_TYPE_UNKNOWN",
  27301. "SVG_UNIT_TYPE_USERSPACEONUSE",
  27302. "SVG_WRONG_TYPE_ERR",
  27303. "SVG_ZOOMANDPAN_DISABLE",
  27304. "SVG_ZOOMANDPAN_MAGNIFY",
  27305. "SVG_ZOOMANDPAN_UNKNOWN",
  27306. "SYNC_CONDITION",
  27307. "SYNC_FENCE",
  27308. "SYNC_FLAGS",
  27309. "SYNC_FLUSH_COMMANDS_BIT",
  27310. "SYNC_GPU_COMMANDS_COMPLETE",
  27311. "SYNC_STATUS",
  27312. "SYNTAX_ERR",
  27313. "SavedPages",
  27314. "Screen",
  27315. "ScreenOrientation",
  27316. "Script",
  27317. "ScriptProcessorNode",
  27318. "ScrollAreaEvent",
  27319. "SecurityPolicyViolationEvent",
  27320. "Selection",
  27321. "Sensor",
  27322. "SensorErrorEvent",
  27323. "ServiceWorker",
  27324. "ServiceWorkerContainer",
  27325. "ServiceWorkerRegistration",
  27326. "SessionDescription",
  27327. "Set",
  27328. "ShadowRoot",
  27329. "SharedArrayBuffer",
  27330. "SharedWorker",
  27331. "SimpleGestureEvent",
  27332. "SourceBuffer",
  27333. "SourceBufferList",
  27334. "SpeechSynthesis",
  27335. "SpeechSynthesisErrorEvent",
  27336. "SpeechSynthesisEvent",
  27337. "SpeechSynthesisUtterance",
  27338. "SpeechSynthesisVoice",
  27339. "StaticRange",
  27340. "StereoPannerNode",
  27341. "StopIteration",
  27342. "Storage",
  27343. "StorageEvent",
  27344. "StorageManager",
  27345. "String",
  27346. "StructType",
  27347. "StylePropertyMap",
  27348. "StylePropertyMapReadOnly",
  27349. "StyleSheet",
  27350. "StyleSheetList",
  27351. "SubmitEvent",
  27352. "SubtleCrypto",
  27353. "Symbol",
  27354. "SyncManager",
  27355. "SyntaxError",
  27356. "TEMPORARY",
  27357. "TEXTPATH_METHODTYPE_ALIGN",
  27358. "TEXTPATH_METHODTYPE_STRETCH",
  27359. "TEXTPATH_METHODTYPE_UNKNOWN",
  27360. "TEXTPATH_SPACINGTYPE_AUTO",
  27361. "TEXTPATH_SPACINGTYPE_EXACT",
  27362. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  27363. "TEXTURE",
  27364. "TEXTURE0",
  27365. "TEXTURE1",
  27366. "TEXTURE10",
  27367. "TEXTURE11",
  27368. "TEXTURE12",
  27369. "TEXTURE13",
  27370. "TEXTURE14",
  27371. "TEXTURE15",
  27372. "TEXTURE16",
  27373. "TEXTURE17",
  27374. "TEXTURE18",
  27375. "TEXTURE19",
  27376. "TEXTURE2",
  27377. "TEXTURE20",
  27378. "TEXTURE21",
  27379. "TEXTURE22",
  27380. "TEXTURE23",
  27381. "TEXTURE24",
  27382. "TEXTURE25",
  27383. "TEXTURE26",
  27384. "TEXTURE27",
  27385. "TEXTURE28",
  27386. "TEXTURE29",
  27387. "TEXTURE3",
  27388. "TEXTURE30",
  27389. "TEXTURE31",
  27390. "TEXTURE4",
  27391. "TEXTURE5",
  27392. "TEXTURE6",
  27393. "TEXTURE7",
  27394. "TEXTURE8",
  27395. "TEXTURE9",
  27396. "TEXTURE_2D",
  27397. "TEXTURE_2D_ARRAY",
  27398. "TEXTURE_3D",
  27399. "TEXTURE_BASE_LEVEL",
  27400. "TEXTURE_BINDING_2D",
  27401. "TEXTURE_BINDING_2D_ARRAY",
  27402. "TEXTURE_BINDING_3D",
  27403. "TEXTURE_BINDING_CUBE_MAP",
  27404. "TEXTURE_COMPARE_FUNC",
  27405. "TEXTURE_COMPARE_MODE",
  27406. "TEXTURE_CUBE_MAP",
  27407. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  27408. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  27409. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  27410. "TEXTURE_CUBE_MAP_POSITIVE_X",
  27411. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  27412. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  27413. "TEXTURE_IMMUTABLE_FORMAT",
  27414. "TEXTURE_IMMUTABLE_LEVELS",
  27415. "TEXTURE_MAG_FILTER",
  27416. "TEXTURE_MAX_ANISOTROPY_EXT",
  27417. "TEXTURE_MAX_LEVEL",
  27418. "TEXTURE_MAX_LOD",
  27419. "TEXTURE_MIN_FILTER",
  27420. "TEXTURE_MIN_LOD",
  27421. "TEXTURE_WRAP_R",
  27422. "TEXTURE_WRAP_S",
  27423. "TEXTURE_WRAP_T",
  27424. "TEXT_NODE",
  27425. "TIMEOUT",
  27426. "TIMEOUT_ERR",
  27427. "TIMEOUT_EXPIRED",
  27428. "TIMEOUT_IGNORED",
  27429. "TOO_LARGE_ERR",
  27430. "TRANSACTION_INACTIVE_ERR",
  27431. "TRANSFORM_FEEDBACK",
  27432. "TRANSFORM_FEEDBACK_ACTIVE",
  27433. "TRANSFORM_FEEDBACK_BINDING",
  27434. "TRANSFORM_FEEDBACK_BUFFER",
  27435. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  27436. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  27437. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  27438. "TRANSFORM_FEEDBACK_BUFFER_START",
  27439. "TRANSFORM_FEEDBACK_PAUSED",
  27440. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  27441. "TRANSFORM_FEEDBACK_VARYINGS",
  27442. "TRIANGLE",
  27443. "TRIANGLES",
  27444. "TRIANGLE_FAN",
  27445. "TRIANGLE_STRIP",
  27446. "TYPE_BACK_FORWARD",
  27447. "TYPE_ERR",
  27448. "TYPE_MISMATCH_ERR",
  27449. "TYPE_NAVIGATE",
  27450. "TYPE_RELOAD",
  27451. "TYPE_RESERVED",
  27452. "Table",
  27453. "TaskAttributionTiming",
  27454. "Text",
  27455. "TextDecoder",
  27456. "TextDecoderStream",
  27457. "TextEncoder",
  27458. "TextEncoderStream",
  27459. "TextEvent",
  27460. "TextMetrics",
  27461. "TextTrack",
  27462. "TextTrackCue",
  27463. "TextTrackCueList",
  27464. "TextTrackList",
  27465. "TimeEvent",
  27466. "TimeRanges",
  27467. "Touch",
  27468. "TouchEvent",
  27469. "TouchList",
  27470. "TrackEvent",
  27471. "TransformStream",
  27472. "TransitionEvent",
  27473. "TreeWalker",
  27474. "TrustedHTML",
  27475. "TrustedScript",
  27476. "TrustedScriptURL",
  27477. "TrustedTypePolicy",
  27478. "TrustedTypePolicyFactory",
  27479. "TypeError",
  27480. "TypedObject",
  27481. "U2F",
  27482. "UIEvent",
  27483. "UNCACHED",
  27484. "UNIFORM_ARRAY_STRIDE",
  27485. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  27486. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  27487. "UNIFORM_BLOCK_BINDING",
  27488. "UNIFORM_BLOCK_DATA_SIZE",
  27489. "UNIFORM_BLOCK_INDEX",
  27490. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  27491. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  27492. "UNIFORM_BUFFER",
  27493. "UNIFORM_BUFFER_BINDING",
  27494. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  27495. "UNIFORM_BUFFER_SIZE",
  27496. "UNIFORM_BUFFER_START",
  27497. "UNIFORM_IS_ROW_MAJOR",
  27498. "UNIFORM_MATRIX_STRIDE",
  27499. "UNIFORM_OFFSET",
  27500. "UNIFORM_SIZE",
  27501. "UNIFORM_TYPE",
  27502. "UNKNOWN_ERR",
  27503. "UNKNOWN_RULE",
  27504. "UNMASKED_RENDERER_WEBGL",
  27505. "UNMASKED_VENDOR_WEBGL",
  27506. "UNORDERED_NODE_ITERATOR_TYPE",
  27507. "UNORDERED_NODE_SNAPSHOT_TYPE",
  27508. "UNPACK_ALIGNMENT",
  27509. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  27510. "UNPACK_FLIP_Y_WEBGL",
  27511. "UNPACK_IMAGE_HEIGHT",
  27512. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  27513. "UNPACK_ROW_LENGTH",
  27514. "UNPACK_SKIP_IMAGES",
  27515. "UNPACK_SKIP_PIXELS",
  27516. "UNPACK_SKIP_ROWS",
  27517. "UNSCHEDULED_STATE",
  27518. "UNSENT",
  27519. "UNSIGNALED",
  27520. "UNSIGNED_BYTE",
  27521. "UNSIGNED_INT",
  27522. "UNSIGNED_INT_10F_11F_11F_REV",
  27523. "UNSIGNED_INT_24_8",
  27524. "UNSIGNED_INT_2_10_10_10_REV",
  27525. "UNSIGNED_INT_5_9_9_9_REV",
  27526. "UNSIGNED_INT_SAMPLER_2D",
  27527. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  27528. "UNSIGNED_INT_SAMPLER_3D",
  27529. "UNSIGNED_INT_SAMPLER_CUBE",
  27530. "UNSIGNED_INT_VEC2",
  27531. "UNSIGNED_INT_VEC3",
  27532. "UNSIGNED_INT_VEC4",
  27533. "UNSIGNED_NORMALIZED",
  27534. "UNSIGNED_SHORT",
  27535. "UNSIGNED_SHORT_4_4_4_4",
  27536. "UNSIGNED_SHORT_5_5_5_1",
  27537. "UNSIGNED_SHORT_5_6_5",
  27538. "UNSPECIFIED_EVENT_TYPE_ERR",
  27539. "UPDATEREADY",
  27540. "URIError",
  27541. "URL",
  27542. "URLSearchParams",
  27543. "URLUnencoded",
  27544. "URL_MISMATCH_ERR",
  27545. "USB",
  27546. "USBAlternateInterface",
  27547. "USBConfiguration",
  27548. "USBConnectionEvent",
  27549. "USBDevice",
  27550. "USBEndpoint",
  27551. "USBInTransferResult",
  27552. "USBInterface",
  27553. "USBIsochronousInTransferPacket",
  27554. "USBIsochronousInTransferResult",
  27555. "USBIsochronousOutTransferPacket",
  27556. "USBIsochronousOutTransferResult",
  27557. "USBOutTransferResult",
  27558. "UTC",
  27559. "Uint16Array",
  27560. "Uint32Array",
  27561. "Uint8Array",
  27562. "Uint8ClampedArray",
  27563. "UserActivation",
  27564. "UserMessageHandler",
  27565. "UserMessageHandlersNamespace",
  27566. "UserProximityEvent",
  27567. "VALIDATE_STATUS",
  27568. "VALIDATION_ERR",
  27569. "VARIABLES_RULE",
  27570. "VENDOR",
  27571. "VERSION",
  27572. "VERSION_CHANGE",
  27573. "VERSION_ERR",
  27574. "VERTEX_ARRAY_BINDING",
  27575. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  27576. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  27577. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  27578. "VERTEX_ATTRIB_ARRAY_ENABLED",
  27579. "VERTEX_ATTRIB_ARRAY_INTEGER",
  27580. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  27581. "VERTEX_ATTRIB_ARRAY_POINTER",
  27582. "VERTEX_ATTRIB_ARRAY_SIZE",
  27583. "VERTEX_ATTRIB_ARRAY_STRIDE",
  27584. "VERTEX_ATTRIB_ARRAY_TYPE",
  27585. "VERTEX_SHADER",
  27586. "VERTICAL",
  27587. "VERTICAL_AXIS",
  27588. "VER_ERR",
  27589. "VIEWPORT",
  27590. "VIEWPORT_RULE",
  27591. "VRDisplay",
  27592. "VRDisplayCapabilities",
  27593. "VRDisplayEvent",
  27594. "VREyeParameters",
  27595. "VRFieldOfView",
  27596. "VRFrameData",
  27597. "VRPose",
  27598. "VRStageParameters",
  27599. "VTTCue",
  27600. "VTTRegion",
  27601. "ValidityState",
  27602. "VideoPlaybackQuality",
  27603. "VideoStreamTrack",
  27604. "VisualViewport",
  27605. "WAIT_FAILED",
  27606. "WEBKIT_FILTER_RULE",
  27607. "WEBKIT_KEYFRAMES_RULE",
  27608. "WEBKIT_KEYFRAME_RULE",
  27609. "WEBKIT_REGION_RULE",
  27610. "WRONG_DOCUMENT_ERR",
  27611. "WakeLock",
  27612. "WakeLockSentinel",
  27613. "WasmAnyRef",
  27614. "WaveShaperNode",
  27615. "WeakMap",
  27616. "WeakRef",
  27617. "WeakSet",
  27618. "WebAssembly",
  27619. "WebGL2RenderingContext",
  27620. "WebGLActiveInfo",
  27621. "WebGLBuffer",
  27622. "WebGLContextEvent",
  27623. "WebGLFramebuffer",
  27624. "WebGLProgram",
  27625. "WebGLQuery",
  27626. "WebGLRenderbuffer",
  27627. "WebGLRenderingContext",
  27628. "WebGLSampler",
  27629. "WebGLShader",
  27630. "WebGLShaderPrecisionFormat",
  27631. "WebGLSync",
  27632. "WebGLTexture",
  27633. "WebGLTransformFeedback",
  27634. "WebGLUniformLocation",
  27635. "WebGLVertexArray",
  27636. "WebGLVertexArrayObject",
  27637. "WebKitAnimationEvent",
  27638. "WebKitBlobBuilder",
  27639. "WebKitCSSFilterRule",
  27640. "WebKitCSSFilterValue",
  27641. "WebKitCSSKeyframeRule",
  27642. "WebKitCSSKeyframesRule",
  27643. "WebKitCSSMatrix",
  27644. "WebKitCSSRegionRule",
  27645. "WebKitCSSTransformValue",
  27646. "WebKitDataCue",
  27647. "WebKitGamepad",
  27648. "WebKitMediaKeyError",
  27649. "WebKitMediaKeyMessageEvent",
  27650. "WebKitMediaKeySession",
  27651. "WebKitMediaKeys",
  27652. "WebKitMediaSource",
  27653. "WebKitMutationObserver",
  27654. "WebKitNamespace",
  27655. "WebKitPlaybackTargetAvailabilityEvent",
  27656. "WebKitPoint",
  27657. "WebKitShadowRoot",
  27658. "WebKitSourceBuffer",
  27659. "WebKitSourceBufferList",
  27660. "WebKitTransitionEvent",
  27661. "WebSocket",
  27662. "WebkitAlignContent",
  27663. "WebkitAlignItems",
  27664. "WebkitAlignSelf",
  27665. "WebkitAnimation",
  27666. "WebkitAnimationDelay",
  27667. "WebkitAnimationDirection",
  27668. "WebkitAnimationDuration",
  27669. "WebkitAnimationFillMode",
  27670. "WebkitAnimationIterationCount",
  27671. "WebkitAnimationName",
  27672. "WebkitAnimationPlayState",
  27673. "WebkitAnimationTimingFunction",
  27674. "WebkitAppearance",
  27675. "WebkitBackfaceVisibility",
  27676. "WebkitBackgroundClip",
  27677. "WebkitBackgroundOrigin",
  27678. "WebkitBackgroundSize",
  27679. "WebkitBorderBottomLeftRadius",
  27680. "WebkitBorderBottomRightRadius",
  27681. "WebkitBorderImage",
  27682. "WebkitBorderRadius",
  27683. "WebkitBorderTopLeftRadius",
  27684. "WebkitBorderTopRightRadius",
  27685. "WebkitBoxAlign",
  27686. "WebkitBoxDirection",
  27687. "WebkitBoxFlex",
  27688. "WebkitBoxOrdinalGroup",
  27689. "WebkitBoxOrient",
  27690. "WebkitBoxPack",
  27691. "WebkitBoxShadow",
  27692. "WebkitBoxSizing",
  27693. "WebkitFilter",
  27694. "WebkitFlex",
  27695. "WebkitFlexBasis",
  27696. "WebkitFlexDirection",
  27697. "WebkitFlexFlow",
  27698. "WebkitFlexGrow",
  27699. "WebkitFlexShrink",
  27700. "WebkitFlexWrap",
  27701. "WebkitJustifyContent",
  27702. "WebkitLineClamp",
  27703. "WebkitMask",
  27704. "WebkitMaskClip",
  27705. "WebkitMaskComposite",
  27706. "WebkitMaskImage",
  27707. "WebkitMaskOrigin",
  27708. "WebkitMaskPosition",
  27709. "WebkitMaskPositionX",
  27710. "WebkitMaskPositionY",
  27711. "WebkitMaskRepeat",
  27712. "WebkitMaskSize",
  27713. "WebkitOrder",
  27714. "WebkitPerspective",
  27715. "WebkitPerspectiveOrigin",
  27716. "WebkitTextFillColor",
  27717. "WebkitTextSizeAdjust",
  27718. "WebkitTextStroke",
  27719. "WebkitTextStrokeColor",
  27720. "WebkitTextStrokeWidth",
  27721. "WebkitTransform",
  27722. "WebkitTransformOrigin",
  27723. "WebkitTransformStyle",
  27724. "WebkitTransition",
  27725. "WebkitTransitionDelay",
  27726. "WebkitTransitionDuration",
  27727. "WebkitTransitionProperty",
  27728. "WebkitTransitionTimingFunction",
  27729. "WebkitUserSelect",
  27730. "WheelEvent",
  27731. "Window",
  27732. "Worker",
  27733. "Worklet",
  27734. "WritableStream",
  27735. "WritableStreamDefaultWriter",
  27736. "XMLDocument",
  27737. "XMLHttpRequest",
  27738. "XMLHttpRequestEventTarget",
  27739. "XMLHttpRequestException",
  27740. "XMLHttpRequestProgressEvent",
  27741. "XMLHttpRequestUpload",
  27742. "XMLSerializer",
  27743. "XMLStylesheetProcessingInstruction",
  27744. "XPathEvaluator",
  27745. "XPathException",
  27746. "XPathExpression",
  27747. "XPathNSResolver",
  27748. "XPathResult",
  27749. "XRBoundedReferenceSpace",
  27750. "XRDOMOverlayState",
  27751. "XRFrame",
  27752. "XRHitTestResult",
  27753. "XRHitTestSource",
  27754. "XRInputSource",
  27755. "XRInputSourceArray",
  27756. "XRInputSourceEvent",
  27757. "XRInputSourcesChangeEvent",
  27758. "XRLayer",
  27759. "XRPose",
  27760. "XRRay",
  27761. "XRReferenceSpace",
  27762. "XRReferenceSpaceEvent",
  27763. "XRRenderState",
  27764. "XRRigidTransform",
  27765. "XRSession",
  27766. "XRSessionEvent",
  27767. "XRSpace",
  27768. "XRSystem",
  27769. "XRTransientInputHitTestResult",
  27770. "XRTransientInputHitTestSource",
  27771. "XRView",
  27772. "XRViewerPose",
  27773. "XRViewport",
  27774. "XRWebGLLayer",
  27775. "XSLTProcessor",
  27776. "ZERO",
  27777. "_XD0M_",
  27778. "_YD0M_",
  27779. "__defineGetter__",
  27780. "__defineSetter__",
  27781. "__lookupGetter__",
  27782. "__lookupSetter__",
  27783. "__opera",
  27784. "__proto__",
  27785. "_browserjsran",
  27786. "a",
  27787. "aLink",
  27788. "abbr",
  27789. "abort",
  27790. "aborted",
  27791. "abs",
  27792. "absolute",
  27793. "acceleration",
  27794. "accelerationIncludingGravity",
  27795. "accelerator",
  27796. "accept",
  27797. "acceptCharset",
  27798. "acceptNode",
  27799. "accessKey",
  27800. "accessKeyLabel",
  27801. "accuracy",
  27802. "acos",
  27803. "acosh",
  27804. "action",
  27805. "actionURL",
  27806. "actions",
  27807. "activated",
  27808. "active",
  27809. "activeCues",
  27810. "activeElement",
  27811. "activeSourceBuffers",
  27812. "activeSourceCount",
  27813. "activeTexture",
  27814. "activeVRDisplays",
  27815. "actualBoundingBoxAscent",
  27816. "actualBoundingBoxDescent",
  27817. "actualBoundingBoxLeft",
  27818. "actualBoundingBoxRight",
  27819. "add",
  27820. "addAll",
  27821. "addBehavior",
  27822. "addCandidate",
  27823. "addColorStop",
  27824. "addCue",
  27825. "addElement",
  27826. "addEventListener",
  27827. "addFilter",
  27828. "addFromString",
  27829. "addFromUri",
  27830. "addIceCandidate",
  27831. "addImport",
  27832. "addListener",
  27833. "addModule",
  27834. "addNamed",
  27835. "addPageRule",
  27836. "addPath",
  27837. "addPointer",
  27838. "addRange",
  27839. "addRegion",
  27840. "addRule",
  27841. "addSearchEngine",
  27842. "addSourceBuffer",
  27843. "addStream",
  27844. "addTextTrack",
  27845. "addTrack",
  27846. "addTransceiver",
  27847. "addWakeLockListener",
  27848. "added",
  27849. "addedNodes",
  27850. "additionalName",
  27851. "additiveSymbols",
  27852. "addons",
  27853. "address",
  27854. "addressLine",
  27855. "adoptNode",
  27856. "adoptedStyleSheets",
  27857. "adr",
  27858. "advance",
  27859. "after",
  27860. "album",
  27861. "alert",
  27862. "algorithm",
  27863. "align",
  27864. "align-content",
  27865. "align-items",
  27866. "align-self",
  27867. "alignContent",
  27868. "alignItems",
  27869. "alignSelf",
  27870. "alignmentBaseline",
  27871. "alinkColor",
  27872. "all",
  27873. "allSettled",
  27874. "allow",
  27875. "allowFullscreen",
  27876. "allowPaymentRequest",
  27877. "allowedDirections",
  27878. "allowedFeatures",
  27879. "allowedToPlay",
  27880. "allowsFeature",
  27881. "alpha",
  27882. "alt",
  27883. "altGraphKey",
  27884. "altHtml",
  27885. "altKey",
  27886. "altLeft",
  27887. "alternate",
  27888. "alternateSetting",
  27889. "alternates",
  27890. "altitude",
  27891. "altitudeAccuracy",
  27892. "amplitude",
  27893. "ancestorOrigins",
  27894. "anchor",
  27895. "anchorNode",
  27896. "anchorOffset",
  27897. "anchors",
  27898. "and",
  27899. "angle",
  27900. "angularAcceleration",
  27901. "angularVelocity",
  27902. "animVal",
  27903. "animate",
  27904. "animatedInstanceRoot",
  27905. "animatedNormalizedPathSegList",
  27906. "animatedPathSegList",
  27907. "animatedPoints",
  27908. "animation",
  27909. "animation-delay",
  27910. "animation-direction",
  27911. "animation-duration",
  27912. "animation-fill-mode",
  27913. "animation-iteration-count",
  27914. "animation-name",
  27915. "animation-play-state",
  27916. "animation-timing-function",
  27917. "animationDelay",
  27918. "animationDirection",
  27919. "animationDuration",
  27920. "animationFillMode",
  27921. "animationIterationCount",
  27922. "animationName",
  27923. "animationPlayState",
  27924. "animationStartTime",
  27925. "animationTimingFunction",
  27926. "animationsPaused",
  27927. "anniversary",
  27928. "antialias",
  27929. "anticipatedRemoval",
  27930. "any",
  27931. "app",
  27932. "appCodeName",
  27933. "appMinorVersion",
  27934. "appName",
  27935. "appNotifications",
  27936. "appVersion",
  27937. "appearance",
  27938. "append",
  27939. "appendBuffer",
  27940. "appendChild",
  27941. "appendData",
  27942. "appendItem",
  27943. "appendMedium",
  27944. "appendNamed",
  27945. "appendRule",
  27946. "appendStream",
  27947. "appendWindowEnd",
  27948. "appendWindowStart",
  27949. "applets",
  27950. "applicationCache",
  27951. "applicationServerKey",
  27952. "apply",
  27953. "applyConstraints",
  27954. "applyElement",
  27955. "arc",
  27956. "arcTo",
  27957. "archive",
  27958. "areas",
  27959. "arguments",
  27960. "ariaAtomic",
  27961. "ariaAutoComplete",
  27962. "ariaBusy",
  27963. "ariaChecked",
  27964. "ariaColCount",
  27965. "ariaColIndex",
  27966. "ariaColSpan",
  27967. "ariaCurrent",
  27968. "ariaDescription",
  27969. "ariaDisabled",
  27970. "ariaExpanded",
  27971. "ariaHasPopup",
  27972. "ariaHidden",
  27973. "ariaKeyShortcuts",
  27974. "ariaLabel",
  27975. "ariaLevel",
  27976. "ariaLive",
  27977. "ariaModal",
  27978. "ariaMultiLine",
  27979. "ariaMultiSelectable",
  27980. "ariaOrientation",
  27981. "ariaPlaceholder",
  27982. "ariaPosInSet",
  27983. "ariaPressed",
  27984. "ariaReadOnly",
  27985. "ariaRelevant",
  27986. "ariaRequired",
  27987. "ariaRoleDescription",
  27988. "ariaRowCount",
  27989. "ariaRowIndex",
  27990. "ariaRowSpan",
  27991. "ariaSelected",
  27992. "ariaSetSize",
  27993. "ariaSort",
  27994. "ariaValueMax",
  27995. "ariaValueMin",
  27996. "ariaValueNow",
  27997. "ariaValueText",
  27998. "arrayBuffer",
  27999. "artist",
  28000. "artwork",
  28001. "as",
  28002. "asIntN",
  28003. "asUintN",
  28004. "asin",
  28005. "asinh",
  28006. "assert",
  28007. "assign",
  28008. "assignedElements",
  28009. "assignedNodes",
  28010. "assignedSlot",
  28011. "async",
  28012. "asyncIterator",
  28013. "atEnd",
  28014. "atan",
  28015. "atan2",
  28016. "atanh",
  28017. "atob",
  28018. "attachEvent",
  28019. "attachInternals",
  28020. "attachShader",
  28021. "attachShadow",
  28022. "attachments",
  28023. "attack",
  28024. "attestationObject",
  28025. "attrChange",
  28026. "attrName",
  28027. "attributeFilter",
  28028. "attributeName",
  28029. "attributeNamespace",
  28030. "attributeOldValue",
  28031. "attributeStyleMap",
  28032. "attributes",
  28033. "attribution",
  28034. "audioBitsPerSecond",
  28035. "audioTracks",
  28036. "audioWorklet",
  28037. "authenticatedSignedWrites",
  28038. "authenticatorData",
  28039. "autoIncrement",
  28040. "autobuffer",
  28041. "autocapitalize",
  28042. "autocomplete",
  28043. "autocorrect",
  28044. "autofocus",
  28045. "automationRate",
  28046. "autoplay",
  28047. "availHeight",
  28048. "availLeft",
  28049. "availTop",
  28050. "availWidth",
  28051. "availability",
  28052. "available",
  28053. "aversion",
  28054. "ax",
  28055. "axes",
  28056. "axis",
  28057. "ay",
  28058. "azimuth",
  28059. "b",
  28060. "back",
  28061. "backface-visibility",
  28062. "backfaceVisibility",
  28063. "background",
  28064. "background-attachment",
  28065. "background-blend-mode",
  28066. "background-clip",
  28067. "background-color",
  28068. "background-image",
  28069. "background-origin",
  28070. "background-position",
  28071. "background-position-x",
  28072. "background-position-y",
  28073. "background-repeat",
  28074. "background-size",
  28075. "backgroundAttachment",
  28076. "backgroundBlendMode",
  28077. "backgroundClip",
  28078. "backgroundColor",
  28079. "backgroundFetch",
  28080. "backgroundImage",
  28081. "backgroundOrigin",
  28082. "backgroundPosition",
  28083. "backgroundPositionX",
  28084. "backgroundPositionY",
  28085. "backgroundRepeat",
  28086. "backgroundSize",
  28087. "badInput",
  28088. "badge",
  28089. "balance",
  28090. "baseFrequencyX",
  28091. "baseFrequencyY",
  28092. "baseLatency",
  28093. "baseLayer",
  28094. "baseNode",
  28095. "baseOffset",
  28096. "baseURI",
  28097. "baseVal",
  28098. "baselineShift",
  28099. "battery",
  28100. "bday",
  28101. "before",
  28102. "beginElement",
  28103. "beginElementAt",
  28104. "beginPath",
  28105. "beginQuery",
  28106. "beginTransformFeedback",
  28107. "behavior",
  28108. "behaviorCookie",
  28109. "behaviorPart",
  28110. "behaviorUrns",
  28111. "beta",
  28112. "bezierCurveTo",
  28113. "bgColor",
  28114. "bgProperties",
  28115. "bias",
  28116. "big",
  28117. "bigint64",
  28118. "biguint64",
  28119. "binaryType",
  28120. "bind",
  28121. "bindAttribLocation",
  28122. "bindBuffer",
  28123. "bindBufferBase",
  28124. "bindBufferRange",
  28125. "bindFramebuffer",
  28126. "bindRenderbuffer",
  28127. "bindSampler",
  28128. "bindTexture",
  28129. "bindTransformFeedback",
  28130. "bindVertexArray",
  28131. "blendColor",
  28132. "blendEquation",
  28133. "blendEquationSeparate",
  28134. "blendFunc",
  28135. "blendFuncSeparate",
  28136. "blink",
  28137. "blitFramebuffer",
  28138. "blob",
  28139. "block-size",
  28140. "blockDirection",
  28141. "blockSize",
  28142. "blockedURI",
  28143. "blue",
  28144. "bluetooth",
  28145. "blur",
  28146. "body",
  28147. "bodyUsed",
  28148. "bold",
  28149. "bookmarks",
  28150. "booleanValue",
  28151. "border",
  28152. "border-block",
  28153. "border-block-color",
  28154. "border-block-end",
  28155. "border-block-end-color",
  28156. "border-block-end-style",
  28157. "border-block-end-width",
  28158. "border-block-start",
  28159. "border-block-start-color",
  28160. "border-block-start-style",
  28161. "border-block-start-width",
  28162. "border-block-style",
  28163. "border-block-width",
  28164. "border-bottom",
  28165. "border-bottom-color",
  28166. "border-bottom-left-radius",
  28167. "border-bottom-right-radius",
  28168. "border-bottom-style",
  28169. "border-bottom-width",
  28170. "border-collapse",
  28171. "border-color",
  28172. "border-end-end-radius",
  28173. "border-end-start-radius",
  28174. "border-image",
  28175. "border-image-outset",
  28176. "border-image-repeat",
  28177. "border-image-slice",
  28178. "border-image-source",
  28179. "border-image-width",
  28180. "border-inline",
  28181. "border-inline-color",
  28182. "border-inline-end",
  28183. "border-inline-end-color",
  28184. "border-inline-end-style",
  28185. "border-inline-end-width",
  28186. "border-inline-start",
  28187. "border-inline-start-color",
  28188. "border-inline-start-style",
  28189. "border-inline-start-width",
  28190. "border-inline-style",
  28191. "border-inline-width",
  28192. "border-left",
  28193. "border-left-color",
  28194. "border-left-style",
  28195. "border-left-width",
  28196. "border-radius",
  28197. "border-right",
  28198. "border-right-color",
  28199. "border-right-style",
  28200. "border-right-width",
  28201. "border-spacing",
  28202. "border-start-end-radius",
  28203. "border-start-start-radius",
  28204. "border-style",
  28205. "border-top",
  28206. "border-top-color",
  28207. "border-top-left-radius",
  28208. "border-top-right-radius",
  28209. "border-top-style",
  28210. "border-top-width",
  28211. "border-width",
  28212. "borderBlock",
  28213. "borderBlockColor",
  28214. "borderBlockEnd",
  28215. "borderBlockEndColor",
  28216. "borderBlockEndStyle",
  28217. "borderBlockEndWidth",
  28218. "borderBlockStart",
  28219. "borderBlockStartColor",
  28220. "borderBlockStartStyle",
  28221. "borderBlockStartWidth",
  28222. "borderBlockStyle",
  28223. "borderBlockWidth",
  28224. "borderBottom",
  28225. "borderBottomColor",
  28226. "borderBottomLeftRadius",
  28227. "borderBottomRightRadius",
  28228. "borderBottomStyle",
  28229. "borderBottomWidth",
  28230. "borderBoxSize",
  28231. "borderCollapse",
  28232. "borderColor",
  28233. "borderColorDark",
  28234. "borderColorLight",
  28235. "borderEndEndRadius",
  28236. "borderEndStartRadius",
  28237. "borderImage",
  28238. "borderImageOutset",
  28239. "borderImageRepeat",
  28240. "borderImageSlice",
  28241. "borderImageSource",
  28242. "borderImageWidth",
  28243. "borderInline",
  28244. "borderInlineColor",
  28245. "borderInlineEnd",
  28246. "borderInlineEndColor",
  28247. "borderInlineEndStyle",
  28248. "borderInlineEndWidth",
  28249. "borderInlineStart",
  28250. "borderInlineStartColor",
  28251. "borderInlineStartStyle",
  28252. "borderInlineStartWidth",
  28253. "borderInlineStyle",
  28254. "borderInlineWidth",
  28255. "borderLeft",
  28256. "borderLeftColor",
  28257. "borderLeftStyle",
  28258. "borderLeftWidth",
  28259. "borderRadius",
  28260. "borderRight",
  28261. "borderRightColor",
  28262. "borderRightStyle",
  28263. "borderRightWidth",
  28264. "borderSpacing",
  28265. "borderStartEndRadius",
  28266. "borderStartStartRadius",
  28267. "borderStyle",
  28268. "borderTop",
  28269. "borderTopColor",
  28270. "borderTopLeftRadius",
  28271. "borderTopRightRadius",
  28272. "borderTopStyle",
  28273. "borderTopWidth",
  28274. "borderWidth",
  28275. "bottom",
  28276. "bottomMargin",
  28277. "bound",
  28278. "boundElements",
  28279. "boundingClientRect",
  28280. "boundingHeight",
  28281. "boundingLeft",
  28282. "boundingTop",
  28283. "boundingWidth",
  28284. "bounds",
  28285. "boundsGeometry",
  28286. "box-decoration-break",
  28287. "box-shadow",
  28288. "box-sizing",
  28289. "boxDecorationBreak",
  28290. "boxShadow",
  28291. "boxSizing",
  28292. "break-after",
  28293. "break-before",
  28294. "break-inside",
  28295. "breakAfter",
  28296. "breakBefore",
  28297. "breakInside",
  28298. "broadcast",
  28299. "browserLanguage",
  28300. "btoa",
  28301. "bubbles",
  28302. "buffer",
  28303. "bufferData",
  28304. "bufferDepth",
  28305. "bufferSize",
  28306. "bufferSubData",
  28307. "buffered",
  28308. "bufferedAmount",
  28309. "bufferedAmountLowThreshold",
  28310. "buildID",
  28311. "buildNumber",
  28312. "button",
  28313. "buttonID",
  28314. "buttons",
  28315. "byteLength",
  28316. "byteOffset",
  28317. "bytesWritten",
  28318. "c",
  28319. "cache",
  28320. "caches",
  28321. "call",
  28322. "caller",
  28323. "canBeFormatted",
  28324. "canBeMounted",
  28325. "canBeShared",
  28326. "canHaveChildren",
  28327. "canHaveHTML",
  28328. "canInsertDTMF",
  28329. "canMakePayment",
  28330. "canPlayType",
  28331. "canPresent",
  28332. "canTrickleIceCandidates",
  28333. "cancel",
  28334. "cancelAndHoldAtTime",
  28335. "cancelAnimationFrame",
  28336. "cancelBubble",
  28337. "cancelIdleCallback",
  28338. "cancelScheduledValues",
  28339. "cancelVideoFrameCallback",
  28340. "cancelWatchAvailability",
  28341. "cancelable",
  28342. "candidate",
  28343. "canonicalUUID",
  28344. "canvas",
  28345. "capabilities",
  28346. "caption",
  28347. "caption-side",
  28348. "captionSide",
  28349. "capture",
  28350. "captureEvents",
  28351. "captureStackTrace",
  28352. "captureStream",
  28353. "caret-color",
  28354. "caretBidiLevel",
  28355. "caretColor",
  28356. "caretPositionFromPoint",
  28357. "caretRangeFromPoint",
  28358. "cast",
  28359. "catch",
  28360. "category",
  28361. "cbrt",
  28362. "cd",
  28363. "ceil",
  28364. "cellIndex",
  28365. "cellPadding",
  28366. "cellSpacing",
  28367. "cells",
  28368. "ch",
  28369. "chOff",
  28370. "chain",
  28371. "challenge",
  28372. "changeType",
  28373. "changedTouches",
  28374. "channel",
  28375. "channelCount",
  28376. "channelCountMode",
  28377. "channelInterpretation",
  28378. "char",
  28379. "charAt",
  28380. "charCode",
  28381. "charCodeAt",
  28382. "charIndex",
  28383. "charLength",
  28384. "characterData",
  28385. "characterDataOldValue",
  28386. "characterSet",
  28387. "characteristic",
  28388. "charging",
  28389. "chargingTime",
  28390. "charset",
  28391. "check",
  28392. "checkEnclosure",
  28393. "checkFramebufferStatus",
  28394. "checkIntersection",
  28395. "checkValidity",
  28396. "checked",
  28397. "childElementCount",
  28398. "childList",
  28399. "childNodes",
  28400. "children",
  28401. "chrome",
  28402. "ciphertext",
  28403. "cite",
  28404. "city",
  28405. "claimInterface",
  28406. "claimed",
  28407. "classList",
  28408. "className",
  28409. "classid",
  28410. "clear",
  28411. "clearAppBadge",
  28412. "clearAttributes",
  28413. "clearBufferfi",
  28414. "clearBufferfv",
  28415. "clearBufferiv",
  28416. "clearBufferuiv",
  28417. "clearColor",
  28418. "clearData",
  28419. "clearDepth",
  28420. "clearHalt",
  28421. "clearImmediate",
  28422. "clearInterval",
  28423. "clearLiveSeekableRange",
  28424. "clearMarks",
  28425. "clearMaxGCPauseAccumulator",
  28426. "clearMeasures",
  28427. "clearParameters",
  28428. "clearRect",
  28429. "clearResourceTimings",
  28430. "clearShadow",
  28431. "clearStencil",
  28432. "clearTimeout",
  28433. "clearWatch",
  28434. "click",
  28435. "clickCount",
  28436. "clientDataJSON",
  28437. "clientHeight",
  28438. "clientInformation",
  28439. "clientLeft",
  28440. "clientRect",
  28441. "clientRects",
  28442. "clientTop",
  28443. "clientWaitSync",
  28444. "clientWidth",
  28445. "clientX",
  28446. "clientY",
  28447. "clip",
  28448. "clip-path",
  28449. "clip-rule",
  28450. "clipBottom",
  28451. "clipLeft",
  28452. "clipPath",
  28453. "clipPathUnits",
  28454. "clipRight",
  28455. "clipRule",
  28456. "clipTop",
  28457. "clipboard",
  28458. "clipboardData",
  28459. "clone",
  28460. "cloneContents",
  28461. "cloneNode",
  28462. "cloneRange",
  28463. "close",
  28464. "closePath",
  28465. "closed",
  28466. "closest",
  28467. "clz",
  28468. "clz32",
  28469. "cm",
  28470. "cmp",
  28471. "code",
  28472. "codeBase",
  28473. "codePointAt",
  28474. "codeType",
  28475. "colSpan",
  28476. "collapse",
  28477. "collapseToEnd",
  28478. "collapseToStart",
  28479. "collapsed",
  28480. "collect",
  28481. "colno",
  28482. "color",
  28483. "color-adjust",
  28484. "color-interpolation",
  28485. "color-interpolation-filters",
  28486. "colorAdjust",
  28487. "colorDepth",
  28488. "colorInterpolation",
  28489. "colorInterpolationFilters",
  28490. "colorMask",
  28491. "colorType",
  28492. "cols",
  28493. "column-count",
  28494. "column-fill",
  28495. "column-gap",
  28496. "column-rule",
  28497. "column-rule-color",
  28498. "column-rule-style",
  28499. "column-rule-width",
  28500. "column-span",
  28501. "column-width",
  28502. "columnCount",
  28503. "columnFill",
  28504. "columnGap",
  28505. "columnNumber",
  28506. "columnRule",
  28507. "columnRuleColor",
  28508. "columnRuleStyle",
  28509. "columnRuleWidth",
  28510. "columnSpan",
  28511. "columnWidth",
  28512. "columns",
  28513. "command",
  28514. "commit",
  28515. "commitPreferences",
  28516. "commitStyles",
  28517. "commonAncestorContainer",
  28518. "compact",
  28519. "compareBoundaryPoints",
  28520. "compareDocumentPosition",
  28521. "compareEndPoints",
  28522. "compareExchange",
  28523. "compareNode",
  28524. "comparePoint",
  28525. "compatMode",
  28526. "compatible",
  28527. "compile",
  28528. "compileShader",
  28529. "compileStreaming",
  28530. "complete",
  28531. "component",
  28532. "componentFromPoint",
  28533. "composed",
  28534. "composedPath",
  28535. "composite",
  28536. "compositionEndOffset",
  28537. "compositionStartOffset",
  28538. "compressedTexImage2D",
  28539. "compressedTexImage3D",
  28540. "compressedTexSubImage2D",
  28541. "compressedTexSubImage3D",
  28542. "computedStyleMap",
  28543. "concat",
  28544. "conditionText",
  28545. "coneInnerAngle",
  28546. "coneOuterAngle",
  28547. "coneOuterGain",
  28548. "configuration",
  28549. "configurationName",
  28550. "configurationValue",
  28551. "configurations",
  28552. "confirm",
  28553. "confirmComposition",
  28554. "confirmSiteSpecificTrackingException",
  28555. "confirmWebWideTrackingException",
  28556. "connect",
  28557. "connectEnd",
  28558. "connectShark",
  28559. "connectStart",
  28560. "connected",
  28561. "connection",
  28562. "connectionList",
  28563. "connectionSpeed",
  28564. "connectionState",
  28565. "connections",
  28566. "console",
  28567. "consolidate",
  28568. "constraint",
  28569. "constrictionActive",
  28570. "construct",
  28571. "constructor",
  28572. "contactID",
  28573. "contain",
  28574. "containerId",
  28575. "containerName",
  28576. "containerSrc",
  28577. "containerType",
  28578. "contains",
  28579. "containsNode",
  28580. "content",
  28581. "contentBoxSize",
  28582. "contentDocument",
  28583. "contentEditable",
  28584. "contentHint",
  28585. "contentOverflow",
  28586. "contentRect",
  28587. "contentScriptType",
  28588. "contentStyleType",
  28589. "contentType",
  28590. "contentWindow",
  28591. "context",
  28592. "contextMenu",
  28593. "contextmenu",
  28594. "continue",
  28595. "continuePrimaryKey",
  28596. "continuous",
  28597. "control",
  28598. "controlTransferIn",
  28599. "controlTransferOut",
  28600. "controller",
  28601. "controls",
  28602. "controlsList",
  28603. "convertPointFromNode",
  28604. "convertQuadFromNode",
  28605. "convertRectFromNode",
  28606. "convertToBlob",
  28607. "convertToSpecifiedUnits",
  28608. "cookie",
  28609. "cookieEnabled",
  28610. "coords",
  28611. "copyBufferSubData",
  28612. "copyFromChannel",
  28613. "copyTexImage2D",
  28614. "copyTexSubImage2D",
  28615. "copyTexSubImage3D",
  28616. "copyToChannel",
  28617. "copyWithin",
  28618. "correspondingElement",
  28619. "correspondingUseElement",
  28620. "corruptedVideoFrames",
  28621. "cos",
  28622. "cosh",
  28623. "count",
  28624. "countReset",
  28625. "counter-increment",
  28626. "counter-reset",
  28627. "counter-set",
  28628. "counterIncrement",
  28629. "counterReset",
  28630. "counterSet",
  28631. "country",
  28632. "cpuClass",
  28633. "cpuSleepAllowed",
  28634. "create",
  28635. "createAnalyser",
  28636. "createAnswer",
  28637. "createAttribute",
  28638. "createAttributeNS",
  28639. "createBiquadFilter",
  28640. "createBuffer",
  28641. "createBufferSource",
  28642. "createCDATASection",
  28643. "createCSSStyleSheet",
  28644. "createCaption",
  28645. "createChannelMerger",
  28646. "createChannelSplitter",
  28647. "createComment",
  28648. "createConstantSource",
  28649. "createContextualFragment",
  28650. "createControlRange",
  28651. "createConvolver",
  28652. "createDTMFSender",
  28653. "createDataChannel",
  28654. "createDelay",
  28655. "createDelayNode",
  28656. "createDocument",
  28657. "createDocumentFragment",
  28658. "createDocumentType",
  28659. "createDynamicsCompressor",
  28660. "createElement",
  28661. "createElementNS",
  28662. "createEntityReference",
  28663. "createEvent",
  28664. "createEventObject",
  28665. "createExpression",
  28666. "createFramebuffer",
  28667. "createFunction",
  28668. "createGain",
  28669. "createGainNode",
  28670. "createHTML",
  28671. "createHTMLDocument",
  28672. "createIIRFilter",
  28673. "createImageBitmap",
  28674. "createImageData",
  28675. "createIndex",
  28676. "createJavaScriptNode",
  28677. "createLinearGradient",
  28678. "createMediaElementSource",
  28679. "createMediaKeys",
  28680. "createMediaStreamDestination",
  28681. "createMediaStreamSource",
  28682. "createMediaStreamTrackSource",
  28683. "createMutableFile",
  28684. "createNSResolver",
  28685. "createNodeIterator",
  28686. "createNotification",
  28687. "createObjectStore",
  28688. "createObjectURL",
  28689. "createOffer",
  28690. "createOscillator",
  28691. "createPanner",
  28692. "createPattern",
  28693. "createPeriodicWave",
  28694. "createPolicy",
  28695. "createPopup",
  28696. "createProcessingInstruction",
  28697. "createProgram",
  28698. "createQuery",
  28699. "createRadialGradient",
  28700. "createRange",
  28701. "createRangeCollection",
  28702. "createReader",
  28703. "createRenderbuffer",
  28704. "createSVGAngle",
  28705. "createSVGLength",
  28706. "createSVGMatrix",
  28707. "createSVGNumber",
  28708. "createSVGPathSegArcAbs",
  28709. "createSVGPathSegArcRel",
  28710. "createSVGPathSegClosePath",
  28711. "createSVGPathSegCurvetoCubicAbs",
  28712. "createSVGPathSegCurvetoCubicRel",
  28713. "createSVGPathSegCurvetoCubicSmoothAbs",
  28714. "createSVGPathSegCurvetoCubicSmoothRel",
  28715. "createSVGPathSegCurvetoQuadraticAbs",
  28716. "createSVGPathSegCurvetoQuadraticRel",
  28717. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  28718. "createSVGPathSegCurvetoQuadraticSmoothRel",
  28719. "createSVGPathSegLinetoAbs",
  28720. "createSVGPathSegLinetoHorizontalAbs",
  28721. "createSVGPathSegLinetoHorizontalRel",
  28722. "createSVGPathSegLinetoRel",
  28723. "createSVGPathSegLinetoVerticalAbs",
  28724. "createSVGPathSegLinetoVerticalRel",
  28725. "createSVGPathSegMovetoAbs",
  28726. "createSVGPathSegMovetoRel",
  28727. "createSVGPoint",
  28728. "createSVGRect",
  28729. "createSVGTransform",
  28730. "createSVGTransformFromMatrix",
  28731. "createSampler",
  28732. "createScript",
  28733. "createScriptProcessor",
  28734. "createScriptURL",
  28735. "createSession",
  28736. "createShader",
  28737. "createShadowRoot",
  28738. "createStereoPanner",
  28739. "createStyleSheet",
  28740. "createTBody",
  28741. "createTFoot",
  28742. "createTHead",
  28743. "createTextNode",
  28744. "createTextRange",
  28745. "createTexture",
  28746. "createTouch",
  28747. "createTouchList",
  28748. "createTransformFeedback",
  28749. "createTreeWalker",
  28750. "createVertexArray",
  28751. "createWaveShaper",
  28752. "creationTime",
  28753. "credentials",
  28754. "crossOrigin",
  28755. "crossOriginIsolated",
  28756. "crypto",
  28757. "csi",
  28758. "csp",
  28759. "cssFloat",
  28760. "cssRules",
  28761. "cssText",
  28762. "cssValueType",
  28763. "ctrlKey",
  28764. "ctrlLeft",
  28765. "cues",
  28766. "cullFace",
  28767. "currentDirection",
  28768. "currentLocalDescription",
  28769. "currentNode",
  28770. "currentPage",
  28771. "currentRect",
  28772. "currentRemoteDescription",
  28773. "currentScale",
  28774. "currentScript",
  28775. "currentSrc",
  28776. "currentState",
  28777. "currentStyle",
  28778. "currentTarget",
  28779. "currentTime",
  28780. "currentTranslate",
  28781. "currentView",
  28782. "cursor",
  28783. "curve",
  28784. "customElements",
  28785. "customError",
  28786. "cx",
  28787. "cy",
  28788. "d",
  28789. "data",
  28790. "dataFld",
  28791. "dataFormatAs",
  28792. "dataLoss",
  28793. "dataLossMessage",
  28794. "dataPageSize",
  28795. "dataSrc",
  28796. "dataTransfer",
  28797. "database",
  28798. "databases",
  28799. "dataset",
  28800. "dateTime",
  28801. "db",
  28802. "debug",
  28803. "debuggerEnabled",
  28804. "declare",
  28805. "decode",
  28806. "decodeAudioData",
  28807. "decodeURI",
  28808. "decodeURIComponent",
  28809. "decodedBodySize",
  28810. "decoding",
  28811. "decodingInfo",
  28812. "decrypt",
  28813. "default",
  28814. "defaultCharset",
  28815. "defaultChecked",
  28816. "defaultMuted",
  28817. "defaultPlaybackRate",
  28818. "defaultPolicy",
  28819. "defaultPrevented",
  28820. "defaultRequest",
  28821. "defaultSelected",
  28822. "defaultStatus",
  28823. "defaultURL",
  28824. "defaultValue",
  28825. "defaultView",
  28826. "defaultstatus",
  28827. "defer",
  28828. "define",
  28829. "defineMagicFunction",
  28830. "defineMagicVariable",
  28831. "defineProperties",
  28832. "defineProperty",
  28833. "deg",
  28834. "delay",
  28835. "delayTime",
  28836. "delegatesFocus",
  28837. "delete",
  28838. "deleteBuffer",
  28839. "deleteCaption",
  28840. "deleteCell",
  28841. "deleteContents",
  28842. "deleteData",
  28843. "deleteDatabase",
  28844. "deleteFramebuffer",
  28845. "deleteFromDocument",
  28846. "deleteIndex",
  28847. "deleteMedium",
  28848. "deleteObjectStore",
  28849. "deleteProgram",
  28850. "deleteProperty",
  28851. "deleteQuery",
  28852. "deleteRenderbuffer",
  28853. "deleteRow",
  28854. "deleteRule",
  28855. "deleteSampler",
  28856. "deleteShader",
  28857. "deleteSync",
  28858. "deleteTFoot",
  28859. "deleteTHead",
  28860. "deleteTexture",
  28861. "deleteTransformFeedback",
  28862. "deleteVertexArray",
  28863. "deliverChangeRecords",
  28864. "delivery",
  28865. "deliveryInfo",
  28866. "deliveryStatus",
  28867. "deliveryTimestamp",
  28868. "delta",
  28869. "deltaMode",
  28870. "deltaX",
  28871. "deltaY",
  28872. "deltaZ",
  28873. "dependentLocality",
  28874. "depthFar",
  28875. "depthFunc",
  28876. "depthMask",
  28877. "depthNear",
  28878. "depthRange",
  28879. "deref",
  28880. "deriveBits",
  28881. "deriveKey",
  28882. "description",
  28883. "deselectAll",
  28884. "designMode",
  28885. "desiredSize",
  28886. "destination",
  28887. "destinationURL",
  28888. "detach",
  28889. "detachEvent",
  28890. "detachShader",
  28891. "detail",
  28892. "details",
  28893. "detect",
  28894. "detune",
  28895. "device",
  28896. "deviceClass",
  28897. "deviceId",
  28898. "deviceMemory",
  28899. "devicePixelContentBoxSize",
  28900. "devicePixelRatio",
  28901. "deviceProtocol",
  28902. "deviceSubclass",
  28903. "deviceVersionMajor",
  28904. "deviceVersionMinor",
  28905. "deviceVersionSubminor",
  28906. "deviceXDPI",
  28907. "deviceYDPI",
  28908. "didTimeout",
  28909. "diffuseConstant",
  28910. "digest",
  28911. "dimensions",
  28912. "dir",
  28913. "dirName",
  28914. "direction",
  28915. "dirxml",
  28916. "disable",
  28917. "disablePictureInPicture",
  28918. "disableRemotePlayback",
  28919. "disableVertexAttribArray",
  28920. "disabled",
  28921. "dischargingTime",
  28922. "disconnect",
  28923. "disconnectShark",
  28924. "dispatchEvent",
  28925. "display",
  28926. "displayId",
  28927. "displayName",
  28928. "disposition",
  28929. "distanceModel",
  28930. "div",
  28931. "divisor",
  28932. "djsapi",
  28933. "djsproxy",
  28934. "doImport",
  28935. "doNotTrack",
  28936. "doScroll",
  28937. "doctype",
  28938. "document",
  28939. "documentElement",
  28940. "documentMode",
  28941. "documentURI",
  28942. "dolphin",
  28943. "dolphinGameCenter",
  28944. "dolphininfo",
  28945. "dolphinmeta",
  28946. "domComplete",
  28947. "domContentLoadedEventEnd",
  28948. "domContentLoadedEventStart",
  28949. "domInteractive",
  28950. "domLoading",
  28951. "domOverlayState",
  28952. "domain",
  28953. "domainLookupEnd",
  28954. "domainLookupStart",
  28955. "dominant-baseline",
  28956. "dominantBaseline",
  28957. "done",
  28958. "dopplerFactor",
  28959. "dotAll",
  28960. "downDegrees",
  28961. "downlink",
  28962. "download",
  28963. "downloadTotal",
  28964. "downloaded",
  28965. "dpcm",
  28966. "dpi",
  28967. "dppx",
  28968. "dragDrop",
  28969. "draggable",
  28970. "drawArrays",
  28971. "drawArraysInstanced",
  28972. "drawArraysInstancedANGLE",
  28973. "drawBuffers",
  28974. "drawCustomFocusRing",
  28975. "drawElements",
  28976. "drawElementsInstanced",
  28977. "drawElementsInstancedANGLE",
  28978. "drawFocusIfNeeded",
  28979. "drawImage",
  28980. "drawImageFromRect",
  28981. "drawRangeElements",
  28982. "drawSystemFocusRing",
  28983. "drawingBufferHeight",
  28984. "drawingBufferWidth",
  28985. "dropEffect",
  28986. "droppedVideoFrames",
  28987. "dropzone",
  28988. "dtmf",
  28989. "dump",
  28990. "dumpProfile",
  28991. "duplicate",
  28992. "durability",
  28993. "duration",
  28994. "dvname",
  28995. "dvnum",
  28996. "dx",
  28997. "dy",
  28998. "dynsrc",
  28999. "e",
  29000. "edgeMode",
  29001. "effect",
  29002. "effectAllowed",
  29003. "effectiveDirective",
  29004. "effectiveType",
  29005. "elapsedTime",
  29006. "element",
  29007. "elementFromPoint",
  29008. "elementTiming",
  29009. "elements",
  29010. "elementsFromPoint",
  29011. "elevation",
  29012. "ellipse",
  29013. "em",
  29014. "email",
  29015. "embeds",
  29016. "emma",
  29017. "empty",
  29018. "empty-cells",
  29019. "emptyCells",
  29020. "emptyHTML",
  29021. "emptyScript",
  29022. "emulatedPosition",
  29023. "enable",
  29024. "enableBackground",
  29025. "enableDelegations",
  29026. "enableStyleSheetsForSet",
  29027. "enableVertexAttribArray",
  29028. "enabled",
  29029. "enabledPlugin",
  29030. "encode",
  29031. "encodeInto",
  29032. "encodeURI",
  29033. "encodeURIComponent",
  29034. "encodedBodySize",
  29035. "encoding",
  29036. "encodingInfo",
  29037. "encrypt",
  29038. "enctype",
  29039. "end",
  29040. "endContainer",
  29041. "endElement",
  29042. "endElementAt",
  29043. "endOfStream",
  29044. "endOffset",
  29045. "endQuery",
  29046. "endTime",
  29047. "endTransformFeedback",
  29048. "ended",
  29049. "endpoint",
  29050. "endpointNumber",
  29051. "endpoints",
  29052. "endsWith",
  29053. "enterKeyHint",
  29054. "entities",
  29055. "entries",
  29056. "entryType",
  29057. "enumerate",
  29058. "enumerateDevices",
  29059. "enumerateEditable",
  29060. "environmentBlendMode",
  29061. "equals",
  29062. "error",
  29063. "errorCode",
  29064. "errorDetail",
  29065. "errorText",
  29066. "escape",
  29067. "estimate",
  29068. "eval",
  29069. "evaluate",
  29070. "event",
  29071. "eventPhase",
  29072. "every",
  29073. "ex",
  29074. "exception",
  29075. "exchange",
  29076. "exec",
  29077. "execCommand",
  29078. "execCommandShowHelp",
  29079. "execScript",
  29080. "exitFullscreen",
  29081. "exitPictureInPicture",
  29082. "exitPointerLock",
  29083. "exitPresent",
  29084. "exp",
  29085. "expand",
  29086. "expandEntityReferences",
  29087. "expando",
  29088. "expansion",
  29089. "expiration",
  29090. "expirationTime",
  29091. "expires",
  29092. "expiryDate",
  29093. "explicitOriginalTarget",
  29094. "expm1",
  29095. "exponent",
  29096. "exponentialRampToValueAtTime",
  29097. "exportKey",
  29098. "exports",
  29099. "extend",
  29100. "extensions",
  29101. "extentNode",
  29102. "extentOffset",
  29103. "external",
  29104. "externalResourcesRequired",
  29105. "extractContents",
  29106. "extractable",
  29107. "eye",
  29108. "f",
  29109. "face",
  29110. "factoryReset",
  29111. "failureReason",
  29112. "fallback",
  29113. "family",
  29114. "familyName",
  29115. "farthestViewportElement",
  29116. "fastSeek",
  29117. "fatal",
  29118. "featureId",
  29119. "featurePolicy",
  29120. "featureSettings",
  29121. "features",
  29122. "fenceSync",
  29123. "fetch",
  29124. "fetchStart",
  29125. "fftSize",
  29126. "fgColor",
  29127. "fieldOfView",
  29128. "file",
  29129. "fileCreatedDate",
  29130. "fileHandle",
  29131. "fileModifiedDate",
  29132. "fileName",
  29133. "fileSize",
  29134. "fileUpdatedDate",
  29135. "filename",
  29136. "files",
  29137. "filesystem",
  29138. "fill",
  29139. "fill-opacity",
  29140. "fill-rule",
  29141. "fillLightMode",
  29142. "fillOpacity",
  29143. "fillRect",
  29144. "fillRule",
  29145. "fillStyle",
  29146. "fillText",
  29147. "filter",
  29148. "filterResX",
  29149. "filterResY",
  29150. "filterUnits",
  29151. "filters",
  29152. "finally",
  29153. "find",
  29154. "findIndex",
  29155. "findRule",
  29156. "findText",
  29157. "finish",
  29158. "finished",
  29159. "fireEvent",
  29160. "firesTouchEvents",
  29161. "firstChild",
  29162. "firstElementChild",
  29163. "firstPage",
  29164. "fixed",
  29165. "flags",
  29166. "flat",
  29167. "flatMap",
  29168. "flex",
  29169. "flex-basis",
  29170. "flex-direction",
  29171. "flex-flow",
  29172. "flex-grow",
  29173. "flex-shrink",
  29174. "flex-wrap",
  29175. "flexBasis",
  29176. "flexDirection",
  29177. "flexFlow",
  29178. "flexGrow",
  29179. "flexShrink",
  29180. "flexWrap",
  29181. "flipX",
  29182. "flipY",
  29183. "float",
  29184. "float32",
  29185. "float64",
  29186. "flood-color",
  29187. "flood-opacity",
  29188. "floodColor",
  29189. "floodOpacity",
  29190. "floor",
  29191. "flush",
  29192. "focus",
  29193. "focusNode",
  29194. "focusOffset",
  29195. "font",
  29196. "font-family",
  29197. "font-feature-settings",
  29198. "font-kerning",
  29199. "font-language-override",
  29200. "font-optical-sizing",
  29201. "font-size",
  29202. "font-size-adjust",
  29203. "font-stretch",
  29204. "font-style",
  29205. "font-synthesis",
  29206. "font-variant",
  29207. "font-variant-alternates",
  29208. "font-variant-caps",
  29209. "font-variant-east-asian",
  29210. "font-variant-ligatures",
  29211. "font-variant-numeric",
  29212. "font-variant-position",
  29213. "font-variation-settings",
  29214. "font-weight",
  29215. "fontFamily",
  29216. "fontFeatureSettings",
  29217. "fontKerning",
  29218. "fontLanguageOverride",
  29219. "fontOpticalSizing",
  29220. "fontSize",
  29221. "fontSizeAdjust",
  29222. "fontSmoothingEnabled",
  29223. "fontStretch",
  29224. "fontStyle",
  29225. "fontSynthesis",
  29226. "fontVariant",
  29227. "fontVariantAlternates",
  29228. "fontVariantCaps",
  29229. "fontVariantEastAsian",
  29230. "fontVariantLigatures",
  29231. "fontVariantNumeric",
  29232. "fontVariantPosition",
  29233. "fontVariationSettings",
  29234. "fontWeight",
  29235. "fontcolor",
  29236. "fontfaces",
  29237. "fonts",
  29238. "fontsize",
  29239. "for",
  29240. "forEach",
  29241. "force",
  29242. "forceRedraw",
  29243. "form",
  29244. "formAction",
  29245. "formData",
  29246. "formEnctype",
  29247. "formMethod",
  29248. "formNoValidate",
  29249. "formTarget",
  29250. "format",
  29251. "formatToParts",
  29252. "forms",
  29253. "forward",
  29254. "forwardX",
  29255. "forwardY",
  29256. "forwardZ",
  29257. "foundation",
  29258. "fr",
  29259. "fragmentDirective",
  29260. "frame",
  29261. "frameBorder",
  29262. "frameElement",
  29263. "frameSpacing",
  29264. "framebuffer",
  29265. "framebufferHeight",
  29266. "framebufferRenderbuffer",
  29267. "framebufferTexture2D",
  29268. "framebufferTextureLayer",
  29269. "framebufferWidth",
  29270. "frames",
  29271. "freeSpace",
  29272. "freeze",
  29273. "frequency",
  29274. "frequencyBinCount",
  29275. "from",
  29276. "fromCharCode",
  29277. "fromCodePoint",
  29278. "fromElement",
  29279. "fromEntries",
  29280. "fromFloat32Array",
  29281. "fromFloat64Array",
  29282. "fromMatrix",
  29283. "fromPoint",
  29284. "fromQuad",
  29285. "fromRect",
  29286. "frontFace",
  29287. "fround",
  29288. "fullPath",
  29289. "fullScreen",
  29290. "fullscreen",
  29291. "fullscreenElement",
  29292. "fullscreenEnabled",
  29293. "fx",
  29294. "fy",
  29295. "gain",
  29296. "gamepad",
  29297. "gamma",
  29298. "gap",
  29299. "gatheringState",
  29300. "gatt",
  29301. "genderIdentity",
  29302. "generateCertificate",
  29303. "generateKey",
  29304. "generateMipmap",
  29305. "generateRequest",
  29306. "geolocation",
  29307. "gestureObject",
  29308. "get",
  29309. "getActiveAttrib",
  29310. "getActiveUniform",
  29311. "getActiveUniformBlockName",
  29312. "getActiveUniformBlockParameter",
  29313. "getActiveUniforms",
  29314. "getAdjacentText",
  29315. "getAll",
  29316. "getAllKeys",
  29317. "getAllResponseHeaders",
  29318. "getAllowlistForFeature",
  29319. "getAnimations",
  29320. "getAsFile",
  29321. "getAsString",
  29322. "getAttachedShaders",
  29323. "getAttribLocation",
  29324. "getAttribute",
  29325. "getAttributeNS",
  29326. "getAttributeNames",
  29327. "getAttributeNode",
  29328. "getAttributeNodeNS",
  29329. "getAttributeType",
  29330. "getAudioTracks",
  29331. "getAvailability",
  29332. "getBBox",
  29333. "getBattery",
  29334. "getBigInt64",
  29335. "getBigUint64",
  29336. "getBlob",
  29337. "getBookmark",
  29338. "getBoundingClientRect",
  29339. "getBounds",
  29340. "getBoxQuads",
  29341. "getBufferParameter",
  29342. "getBufferSubData",
  29343. "getByteFrequencyData",
  29344. "getByteTimeDomainData",
  29345. "getCSSCanvasContext",
  29346. "getCTM",
  29347. "getCandidateWindowClientRect",
  29348. "getCanonicalLocales",
  29349. "getCapabilities",
  29350. "getChannelData",
  29351. "getCharNumAtPosition",
  29352. "getCharacteristic",
  29353. "getCharacteristics",
  29354. "getClientExtensionResults",
  29355. "getClientRect",
  29356. "getClientRects",
  29357. "getCoalescedEvents",
  29358. "getCompositionAlternatives",
  29359. "getComputedStyle",
  29360. "getComputedTextLength",
  29361. "getComputedTiming",
  29362. "getConfiguration",
  29363. "getConstraints",
  29364. "getContext",
  29365. "getContextAttributes",
  29366. "getContributingSources",
  29367. "getCounterValue",
  29368. "getCueAsHTML",
  29369. "getCueById",
  29370. "getCurrentPosition",
  29371. "getCurrentTime",
  29372. "getData",
  29373. "getDatabaseNames",
  29374. "getDate",
  29375. "getDay",
  29376. "getDefaultComputedStyle",
  29377. "getDescriptor",
  29378. "getDescriptors",
  29379. "getDestinationInsertionPoints",
  29380. "getDevices",
  29381. "getDirectory",
  29382. "getDisplayMedia",
  29383. "getDistributedNodes",
  29384. "getEditable",
  29385. "getElementById",
  29386. "getElementsByClassName",
  29387. "getElementsByName",
  29388. "getElementsByTagName",
  29389. "getElementsByTagNameNS",
  29390. "getEnclosureList",
  29391. "getEndPositionOfChar",
  29392. "getEntries",
  29393. "getEntriesByName",
  29394. "getEntriesByType",
  29395. "getError",
  29396. "getExtension",
  29397. "getExtentOfChar",
  29398. "getEyeParameters",
  29399. "getFeature",
  29400. "getFile",
  29401. "getFiles",
  29402. "getFilesAndDirectories",
  29403. "getFingerprints",
  29404. "getFloat32",
  29405. "getFloat64",
  29406. "getFloatFrequencyData",
  29407. "getFloatTimeDomainData",
  29408. "getFloatValue",
  29409. "getFragDataLocation",
  29410. "getFrameData",
  29411. "getFramebufferAttachmentParameter",
  29412. "getFrequencyResponse",
  29413. "getFullYear",
  29414. "getGamepads",
  29415. "getHitTestResults",
  29416. "getHitTestResultsForTransientInput",
  29417. "getHours",
  29418. "getIdentityAssertion",
  29419. "getIds",
  29420. "getImageData",
  29421. "getIndexedParameter",
  29422. "getInstalledRelatedApps",
  29423. "getInt16",
  29424. "getInt32",
  29425. "getInt8",
  29426. "getInternalformatParameter",
  29427. "getIntersectionList",
  29428. "getItem",
  29429. "getItems",
  29430. "getKey",
  29431. "getKeyframes",
  29432. "getLayers",
  29433. "getLayoutMap",
  29434. "getLineDash",
  29435. "getLocalCandidates",
  29436. "getLocalParameters",
  29437. "getLocalStreams",
  29438. "getMarks",
  29439. "getMatchedCSSRules",
  29440. "getMaxGCPauseSinceClear",
  29441. "getMeasures",
  29442. "getMetadata",
  29443. "getMilliseconds",
  29444. "getMinutes",
  29445. "getModifierState",
  29446. "getMonth",
  29447. "getNamedItem",
  29448. "getNamedItemNS",
  29449. "getNativeFramebufferScaleFactor",
  29450. "getNotifications",
  29451. "getNotifier",
  29452. "getNumberOfChars",
  29453. "getOffsetReferenceSpace",
  29454. "getOutputTimestamp",
  29455. "getOverrideHistoryNavigationMode",
  29456. "getOverrideStyle",
  29457. "getOwnPropertyDescriptor",
  29458. "getOwnPropertyDescriptors",
  29459. "getOwnPropertyNames",
  29460. "getOwnPropertySymbols",
  29461. "getParameter",
  29462. "getParameters",
  29463. "getParent",
  29464. "getPathSegAtLength",
  29465. "getPhotoCapabilities",
  29466. "getPhotoSettings",
  29467. "getPointAtLength",
  29468. "getPose",
  29469. "getPredictedEvents",
  29470. "getPreference",
  29471. "getPreferenceDefault",
  29472. "getPresentationAttribute",
  29473. "getPreventDefault",
  29474. "getPrimaryService",
  29475. "getPrimaryServices",
  29476. "getProgramInfoLog",
  29477. "getProgramParameter",
  29478. "getPropertyCSSValue",
  29479. "getPropertyPriority",
  29480. "getPropertyShorthand",
  29481. "getPropertyType",
  29482. "getPropertyValue",
  29483. "getPrototypeOf",
  29484. "getQuery",
  29485. "getQueryParameter",
  29486. "getRGBColorValue",
  29487. "getRandomValues",
  29488. "getRangeAt",
  29489. "getReader",
  29490. "getReceivers",
  29491. "getRectValue",
  29492. "getRegistration",
  29493. "getRegistrations",
  29494. "getRemoteCandidates",
  29495. "getRemoteCertificates",
  29496. "getRemoteParameters",
  29497. "getRemoteStreams",
  29498. "getRenderbufferParameter",
  29499. "getResponseHeader",
  29500. "getRoot",
  29501. "getRootNode",
  29502. "getRotationOfChar",
  29503. "getSVGDocument",
  29504. "getSamplerParameter",
  29505. "getScreenCTM",
  29506. "getSeconds",
  29507. "getSelectedCandidatePair",
  29508. "getSelection",
  29509. "getSenders",
  29510. "getService",
  29511. "getSettings",
  29512. "getShaderInfoLog",
  29513. "getShaderParameter",
  29514. "getShaderPrecisionFormat",
  29515. "getShaderSource",
  29516. "getSimpleDuration",
  29517. "getSiteIcons",
  29518. "getSources",
  29519. "getSpeculativeParserUrls",
  29520. "getStartPositionOfChar",
  29521. "getStartTime",
  29522. "getState",
  29523. "getStats",
  29524. "getStatusForPolicy",
  29525. "getStorageUpdates",
  29526. "getStreamById",
  29527. "getStringValue",
  29528. "getSubStringLength",
  29529. "getSubscription",
  29530. "getSupportedConstraints",
  29531. "getSupportedExtensions",
  29532. "getSupportedFormats",
  29533. "getSyncParameter",
  29534. "getSynchronizationSources",
  29535. "getTags",
  29536. "getTargetRanges",
  29537. "getTexParameter",
  29538. "getTime",
  29539. "getTimezoneOffset",
  29540. "getTiming",
  29541. "getTotalLength",
  29542. "getTrackById",
  29543. "getTracks",
  29544. "getTransceivers",
  29545. "getTransform",
  29546. "getTransformFeedbackVarying",
  29547. "getTransformToElement",
  29548. "getTransports",
  29549. "getType",
  29550. "getTypeMapping",
  29551. "getUTCDate",
  29552. "getUTCDay",
  29553. "getUTCFullYear",
  29554. "getUTCHours",
  29555. "getUTCMilliseconds",
  29556. "getUTCMinutes",
  29557. "getUTCMonth",
  29558. "getUTCSeconds",
  29559. "getUint16",
  29560. "getUint32",
  29561. "getUint8",
  29562. "getUniform",
  29563. "getUniformBlockIndex",
  29564. "getUniformIndices",
  29565. "getUniformLocation",
  29566. "getUserMedia",
  29567. "getVRDisplays",
  29568. "getValues",
  29569. "getVarDate",
  29570. "getVariableValue",
  29571. "getVertexAttrib",
  29572. "getVertexAttribOffset",
  29573. "getVideoPlaybackQuality",
  29574. "getVideoTracks",
  29575. "getViewerPose",
  29576. "getViewport",
  29577. "getVoices",
  29578. "getWakeLockState",
  29579. "getWriter",
  29580. "getYear",
  29581. "givenName",
  29582. "global",
  29583. "globalAlpha",
  29584. "globalCompositeOperation",
  29585. "globalThis",
  29586. "glyphOrientationHorizontal",
  29587. "glyphOrientationVertical",
  29588. "glyphRef",
  29589. "go",
  29590. "grabFrame",
  29591. "grad",
  29592. "gradientTransform",
  29593. "gradientUnits",
  29594. "grammars",
  29595. "green",
  29596. "grid",
  29597. "grid-area",
  29598. "grid-auto-columns",
  29599. "grid-auto-flow",
  29600. "grid-auto-rows",
  29601. "grid-column",
  29602. "grid-column-end",
  29603. "grid-column-gap",
  29604. "grid-column-start",
  29605. "grid-gap",
  29606. "grid-row",
  29607. "grid-row-end",
  29608. "grid-row-gap",
  29609. "grid-row-start",
  29610. "grid-template",
  29611. "grid-template-areas",
  29612. "grid-template-columns",
  29613. "grid-template-rows",
  29614. "gridArea",
  29615. "gridAutoColumns",
  29616. "gridAutoFlow",
  29617. "gridAutoRows",
  29618. "gridColumn",
  29619. "gridColumnEnd",
  29620. "gridColumnGap",
  29621. "gridColumnStart",
  29622. "gridGap",
  29623. "gridRow",
  29624. "gridRowEnd",
  29625. "gridRowGap",
  29626. "gridRowStart",
  29627. "gridTemplate",
  29628. "gridTemplateAreas",
  29629. "gridTemplateColumns",
  29630. "gridTemplateRows",
  29631. "gripSpace",
  29632. "group",
  29633. "groupCollapsed",
  29634. "groupEnd",
  29635. "groupId",
  29636. "hadRecentInput",
  29637. "hand",
  29638. "handedness",
  29639. "hapticActuators",
  29640. "hardwareConcurrency",
  29641. "has",
  29642. "hasAttribute",
  29643. "hasAttributeNS",
  29644. "hasAttributes",
  29645. "hasBeenActive",
  29646. "hasChildNodes",
  29647. "hasComposition",
  29648. "hasEnrolledInstrument",
  29649. "hasExtension",
  29650. "hasExternalDisplay",
  29651. "hasFeature",
  29652. "hasFocus",
  29653. "hasInstance",
  29654. "hasLayout",
  29655. "hasOrientation",
  29656. "hasOwnProperty",
  29657. "hasPointerCapture",
  29658. "hasPosition",
  29659. "hasReading",
  29660. "hasStorageAccess",
  29661. "hash",
  29662. "head",
  29663. "headers",
  29664. "heading",
  29665. "height",
  29666. "hidden",
  29667. "hide",
  29668. "hideFocus",
  29669. "high",
  29670. "highWaterMark",
  29671. "hint",
  29672. "history",
  29673. "honorificPrefix",
  29674. "honorificSuffix",
  29675. "horizontalOverflow",
  29676. "host",
  29677. "hostCandidate",
  29678. "hostname",
  29679. "href",
  29680. "hrefTranslate",
  29681. "hreflang",
  29682. "hspace",
  29683. "html5TagCheckInerface",
  29684. "htmlFor",
  29685. "htmlText",
  29686. "httpEquiv",
  29687. "httpRequestStatusCode",
  29688. "hwTimestamp",
  29689. "hyphens",
  29690. "hypot",
  29691. "iccId",
  29692. "iceConnectionState",
  29693. "iceGatheringState",
  29694. "iceTransport",
  29695. "icon",
  29696. "iconURL",
  29697. "id",
  29698. "identifier",
  29699. "identity",
  29700. "idpLoginUrl",
  29701. "ignoreBOM",
  29702. "ignoreCase",
  29703. "ignoreDepthValues",
  29704. "image-orientation",
  29705. "image-rendering",
  29706. "imageHeight",
  29707. "imageOrientation",
  29708. "imageRendering",
  29709. "imageSizes",
  29710. "imageSmoothingEnabled",
  29711. "imageSmoothingQuality",
  29712. "imageSrcset",
  29713. "imageWidth",
  29714. "images",
  29715. "ime-mode",
  29716. "imeMode",
  29717. "implementation",
  29718. "importKey",
  29719. "importNode",
  29720. "importStylesheet",
  29721. "imports",
  29722. "impp",
  29723. "imul",
  29724. "in",
  29725. "in1",
  29726. "in2",
  29727. "inBandMetadataTrackDispatchType",
  29728. "inRange",
  29729. "includes",
  29730. "incremental",
  29731. "indeterminate",
  29732. "index",
  29733. "indexNames",
  29734. "indexOf",
  29735. "indexedDB",
  29736. "indicate",
  29737. "inertiaDestinationX",
  29738. "inertiaDestinationY",
  29739. "info",
  29740. "init",
  29741. "initAnimationEvent",
  29742. "initBeforeLoadEvent",
  29743. "initClipboardEvent",
  29744. "initCloseEvent",
  29745. "initCommandEvent",
  29746. "initCompositionEvent",
  29747. "initCustomEvent",
  29748. "initData",
  29749. "initDataType",
  29750. "initDeviceMotionEvent",
  29751. "initDeviceOrientationEvent",
  29752. "initDragEvent",
  29753. "initErrorEvent",
  29754. "initEvent",
  29755. "initFocusEvent",
  29756. "initGestureEvent",
  29757. "initHashChangeEvent",
  29758. "initKeyEvent",
  29759. "initKeyboardEvent",
  29760. "initMSManipulationEvent",
  29761. "initMessageEvent",
  29762. "initMouseEvent",
  29763. "initMouseScrollEvent",
  29764. "initMouseWheelEvent",
  29765. "initMutationEvent",
  29766. "initNSMouseEvent",
  29767. "initOverflowEvent",
  29768. "initPageEvent",
  29769. "initPageTransitionEvent",
  29770. "initPointerEvent",
  29771. "initPopStateEvent",
  29772. "initProgressEvent",
  29773. "initScrollAreaEvent",
  29774. "initSimpleGestureEvent",
  29775. "initStorageEvent",
  29776. "initTextEvent",
  29777. "initTimeEvent",
  29778. "initTouchEvent",
  29779. "initTransitionEvent",
  29780. "initUIEvent",
  29781. "initWebKitAnimationEvent",
  29782. "initWebKitTransitionEvent",
  29783. "initWebKitWheelEvent",
  29784. "initWheelEvent",
  29785. "initialTime",
  29786. "initialize",
  29787. "initiatorType",
  29788. "inline-size",
  29789. "inlineSize",
  29790. "inlineVerticalFieldOfView",
  29791. "inner",
  29792. "innerHTML",
  29793. "innerHeight",
  29794. "innerText",
  29795. "innerWidth",
  29796. "input",
  29797. "inputBuffer",
  29798. "inputEncoding",
  29799. "inputMethod",
  29800. "inputMode",
  29801. "inputSource",
  29802. "inputSources",
  29803. "inputType",
  29804. "inputs",
  29805. "insertAdjacentElement",
  29806. "insertAdjacentHTML",
  29807. "insertAdjacentText",
  29808. "insertBefore",
  29809. "insertCell",
  29810. "insertDTMF",
  29811. "insertData",
  29812. "insertItemBefore",
  29813. "insertNode",
  29814. "insertRow",
  29815. "insertRule",
  29816. "inset",
  29817. "inset-block",
  29818. "inset-block-end",
  29819. "inset-block-start",
  29820. "inset-inline",
  29821. "inset-inline-end",
  29822. "inset-inline-start",
  29823. "insetBlock",
  29824. "insetBlockEnd",
  29825. "insetBlockStart",
  29826. "insetInline",
  29827. "insetInlineEnd",
  29828. "insetInlineStart",
  29829. "installing",
  29830. "instanceRoot",
  29831. "instantiate",
  29832. "instantiateStreaming",
  29833. "instruments",
  29834. "int16",
  29835. "int32",
  29836. "int8",
  29837. "integrity",
  29838. "interactionMode",
  29839. "intercept",
  29840. "interfaceClass",
  29841. "interfaceName",
  29842. "interfaceNumber",
  29843. "interfaceProtocol",
  29844. "interfaceSubclass",
  29845. "interfaces",
  29846. "interimResults",
  29847. "internalSubset",
  29848. "interpretation",
  29849. "intersectionRatio",
  29850. "intersectionRect",
  29851. "intersectsNode",
  29852. "interval",
  29853. "invalidIteratorState",
  29854. "invalidateFramebuffer",
  29855. "invalidateSubFramebuffer",
  29856. "inverse",
  29857. "invertSelf",
  29858. "is",
  29859. "is2D",
  29860. "isActive",
  29861. "isAlternate",
  29862. "isArray",
  29863. "isBingCurrentSearchDefault",
  29864. "isBuffer",
  29865. "isCandidateWindowVisible",
  29866. "isChar",
  29867. "isCollapsed",
  29868. "isComposing",
  29869. "isConcatSpreadable",
  29870. "isConnected",
  29871. "isContentEditable",
  29872. "isContentHandlerRegistered",
  29873. "isContextLost",
  29874. "isDefaultNamespace",
  29875. "isDirectory",
  29876. "isDisabled",
  29877. "isEnabled",
  29878. "isEqual",
  29879. "isEqualNode",
  29880. "isExtensible",
  29881. "isExternalCTAP2SecurityKeySupported",
  29882. "isFile",
  29883. "isFinite",
  29884. "isFramebuffer",
  29885. "isFrozen",
  29886. "isGenerator",
  29887. "isHTML",
  29888. "isHistoryNavigation",
  29889. "isId",
  29890. "isIdentity",
  29891. "isInjected",
  29892. "isInteger",
  29893. "isIntersecting",
  29894. "isLockFree",
  29895. "isMap",
  29896. "isMultiLine",
  29897. "isNaN",
  29898. "isOpen",
  29899. "isPointInFill",
  29900. "isPointInPath",
  29901. "isPointInRange",
  29902. "isPointInStroke",
  29903. "isPrefAlternate",
  29904. "isPresenting",
  29905. "isPrimary",
  29906. "isProgram",
  29907. "isPropertyImplicit",
  29908. "isProtocolHandlerRegistered",
  29909. "isPrototypeOf",
  29910. "isQuery",
  29911. "isRenderbuffer",
  29912. "isSafeInteger",
  29913. "isSameNode",
  29914. "isSampler",
  29915. "isScript",
  29916. "isScriptURL",
  29917. "isSealed",
  29918. "isSecureContext",
  29919. "isSessionSupported",
  29920. "isShader",
  29921. "isSupported",
  29922. "isSync",
  29923. "isTextEdit",
  29924. "isTexture",
  29925. "isTransformFeedback",
  29926. "isTrusted",
  29927. "isTypeSupported",
  29928. "isUserVerifyingPlatformAuthenticatorAvailable",
  29929. "isVertexArray",
  29930. "isView",
  29931. "isVisible",
  29932. "isochronousTransferIn",
  29933. "isochronousTransferOut",
  29934. "isolation",
  29935. "italics",
  29936. "item",
  29937. "itemId",
  29938. "itemProp",
  29939. "itemRef",
  29940. "itemScope",
  29941. "itemType",
  29942. "itemValue",
  29943. "items",
  29944. "iterateNext",
  29945. "iterationComposite",
  29946. "iterator",
  29947. "javaEnabled",
  29948. "jobTitle",
  29949. "join",
  29950. "json",
  29951. "justify-content",
  29952. "justify-items",
  29953. "justify-self",
  29954. "justifyContent",
  29955. "justifyItems",
  29956. "justifySelf",
  29957. "k1",
  29958. "k2",
  29959. "k3",
  29960. "k4",
  29961. "kHz",
  29962. "keepalive",
  29963. "kernelMatrix",
  29964. "kernelUnitLengthX",
  29965. "kernelUnitLengthY",
  29966. "kerning",
  29967. "key",
  29968. "keyCode",
  29969. "keyFor",
  29970. "keyIdentifier",
  29971. "keyLightEnabled",
  29972. "keyLocation",
  29973. "keyPath",
  29974. "keyStatuses",
  29975. "keySystem",
  29976. "keyText",
  29977. "keyUsage",
  29978. "keyboard",
  29979. "keys",
  29980. "keytype",
  29981. "kind",
  29982. "knee",
  29983. "label",
  29984. "labels",
  29985. "lang",
  29986. "language",
  29987. "languages",
  29988. "largeArcFlag",
  29989. "lastChild",
  29990. "lastElementChild",
  29991. "lastEventId",
  29992. "lastIndex",
  29993. "lastIndexOf",
  29994. "lastInputTime",
  29995. "lastMatch",
  29996. "lastMessageSubject",
  29997. "lastMessageType",
  29998. "lastModified",
  29999. "lastModifiedDate",
  30000. "lastPage",
  30001. "lastParen",
  30002. "lastState",
  30003. "lastStyleSheetSet",
  30004. "latitude",
  30005. "layerX",
  30006. "layerY",
  30007. "layoutFlow",
  30008. "layoutGrid",
  30009. "layoutGridChar",
  30010. "layoutGridLine",
  30011. "layoutGridMode",
  30012. "layoutGridType",
  30013. "lbound",
  30014. "left",
  30015. "leftContext",
  30016. "leftDegrees",
  30017. "leftMargin",
  30018. "leftProjectionMatrix",
  30019. "leftViewMatrix",
  30020. "length",
  30021. "lengthAdjust",
  30022. "lengthComputable",
  30023. "letter-spacing",
  30024. "letterSpacing",
  30025. "level",
  30026. "lighting-color",
  30027. "lightingColor",
  30028. "limitingConeAngle",
  30029. "line",
  30030. "line-break",
  30031. "line-height",
  30032. "lineAlign",
  30033. "lineBreak",
  30034. "lineCap",
  30035. "lineDashOffset",
  30036. "lineHeight",
  30037. "lineJoin",
  30038. "lineNumber",
  30039. "lineTo",
  30040. "lineWidth",
  30041. "linearAcceleration",
  30042. "linearRampToValueAtTime",
  30043. "linearVelocity",
  30044. "lineno",
  30045. "lines",
  30046. "link",
  30047. "linkColor",
  30048. "linkProgram",
  30049. "links",
  30050. "list",
  30051. "list-style",
  30052. "list-style-image",
  30053. "list-style-position",
  30054. "list-style-type",
  30055. "listStyle",
  30056. "listStyleImage",
  30057. "listStylePosition",
  30058. "listStyleType",
  30059. "listener",
  30060. "load",
  30061. "loadEventEnd",
  30062. "loadEventStart",
  30063. "loadTime",
  30064. "loadTimes",
  30065. "loaded",
  30066. "loading",
  30067. "localDescription",
  30068. "localName",
  30069. "localService",
  30070. "localStorage",
  30071. "locale",
  30072. "localeCompare",
  30073. "location",
  30074. "locationbar",
  30075. "lock",
  30076. "locked",
  30077. "lockedFile",
  30078. "locks",
  30079. "log",
  30080. "log10",
  30081. "log1p",
  30082. "log2",
  30083. "logicalXDPI",
  30084. "logicalYDPI",
  30085. "longDesc",
  30086. "longitude",
  30087. "lookupNamespaceURI",
  30088. "lookupPrefix",
  30089. "loop",
  30090. "loopEnd",
  30091. "loopStart",
  30092. "looping",
  30093. "low",
  30094. "lower",
  30095. "lowerBound",
  30096. "lowerOpen",
  30097. "lowsrc",
  30098. "m11",
  30099. "m12",
  30100. "m13",
  30101. "m14",
  30102. "m21",
  30103. "m22",
  30104. "m23",
  30105. "m24",
  30106. "m31",
  30107. "m32",
  30108. "m33",
  30109. "m34",
  30110. "m41",
  30111. "m42",
  30112. "m43",
  30113. "m44",
  30114. "makeXRCompatible",
  30115. "manifest",
  30116. "manufacturer",
  30117. "manufacturerName",
  30118. "map",
  30119. "mapping",
  30120. "margin",
  30121. "margin-block",
  30122. "margin-block-end",
  30123. "margin-block-start",
  30124. "margin-bottom",
  30125. "margin-inline",
  30126. "margin-inline-end",
  30127. "margin-inline-start",
  30128. "margin-left",
  30129. "margin-right",
  30130. "margin-top",
  30131. "marginBlock",
  30132. "marginBlockEnd",
  30133. "marginBlockStart",
  30134. "marginBottom",
  30135. "marginHeight",
  30136. "marginInline",
  30137. "marginInlineEnd",
  30138. "marginInlineStart",
  30139. "marginLeft",
  30140. "marginRight",
  30141. "marginTop",
  30142. "marginWidth",
  30143. "mark",
  30144. "marker",
  30145. "marker-end",
  30146. "marker-mid",
  30147. "marker-offset",
  30148. "marker-start",
  30149. "markerEnd",
  30150. "markerHeight",
  30151. "markerMid",
  30152. "markerOffset",
  30153. "markerStart",
  30154. "markerUnits",
  30155. "markerWidth",
  30156. "marks",
  30157. "mask",
  30158. "mask-clip",
  30159. "mask-composite",
  30160. "mask-image",
  30161. "mask-mode",
  30162. "mask-origin",
  30163. "mask-position",
  30164. "mask-position-x",
  30165. "mask-position-y",
  30166. "mask-repeat",
  30167. "mask-size",
  30168. "mask-type",
  30169. "maskClip",
  30170. "maskComposite",
  30171. "maskContentUnits",
  30172. "maskImage",
  30173. "maskMode",
  30174. "maskOrigin",
  30175. "maskPosition",
  30176. "maskPositionX",
  30177. "maskPositionY",
  30178. "maskRepeat",
  30179. "maskSize",
  30180. "maskType",
  30181. "maskUnits",
  30182. "match",
  30183. "matchAll",
  30184. "matchMedia",
  30185. "matchMedium",
  30186. "matches",
  30187. "matrix",
  30188. "matrixTransform",
  30189. "max",
  30190. "max-block-size",
  30191. "max-height",
  30192. "max-inline-size",
  30193. "max-width",
  30194. "maxActions",
  30195. "maxAlternatives",
  30196. "maxBlockSize",
  30197. "maxChannelCount",
  30198. "maxChannels",
  30199. "maxConnectionsPerServer",
  30200. "maxDecibels",
  30201. "maxDistance",
  30202. "maxHeight",
  30203. "maxInlineSize",
  30204. "maxLayers",
  30205. "maxLength",
  30206. "maxMessageSize",
  30207. "maxPacketLifeTime",
  30208. "maxRetransmits",
  30209. "maxTouchPoints",
  30210. "maxValue",
  30211. "maxWidth",
  30212. "measure",
  30213. "measureText",
  30214. "media",
  30215. "mediaCapabilities",
  30216. "mediaDevices",
  30217. "mediaElement",
  30218. "mediaGroup",
  30219. "mediaKeys",
  30220. "mediaSession",
  30221. "mediaStream",
  30222. "mediaText",
  30223. "meetOrSlice",
  30224. "memory",
  30225. "menubar",
  30226. "mergeAttributes",
  30227. "message",
  30228. "messageClass",
  30229. "messageHandlers",
  30230. "messageType",
  30231. "metaKey",
  30232. "metadata",
  30233. "method",
  30234. "methodDetails",
  30235. "methodName",
  30236. "mid",
  30237. "mimeType",
  30238. "mimeTypes",
  30239. "min",
  30240. "min-block-size",
  30241. "min-height",
  30242. "min-inline-size",
  30243. "min-width",
  30244. "minBlockSize",
  30245. "minDecibels",
  30246. "minHeight",
  30247. "minInlineSize",
  30248. "minLength",
  30249. "minValue",
  30250. "minWidth",
  30251. "miterLimit",
  30252. "mix-blend-mode",
  30253. "mixBlendMode",
  30254. "mm",
  30255. "mode",
  30256. "modify",
  30257. "mount",
  30258. "move",
  30259. "moveBy",
  30260. "moveEnd",
  30261. "moveFirst",
  30262. "moveFocusDown",
  30263. "moveFocusLeft",
  30264. "moveFocusRight",
  30265. "moveFocusUp",
  30266. "moveNext",
  30267. "moveRow",
  30268. "moveStart",
  30269. "moveTo",
  30270. "moveToBookmark",
  30271. "moveToElementText",
  30272. "moveToPoint",
  30273. "movementX",
  30274. "movementY",
  30275. "mozAdd",
  30276. "mozAnimationStartTime",
  30277. "mozAnon",
  30278. "mozApps",
  30279. "mozAudioCaptured",
  30280. "mozAudioChannelType",
  30281. "mozAutoplayEnabled",
  30282. "mozCancelAnimationFrame",
  30283. "mozCancelFullScreen",
  30284. "mozCancelRequestAnimationFrame",
  30285. "mozCaptureStream",
  30286. "mozCaptureStreamUntilEnded",
  30287. "mozClearDataAt",
  30288. "mozContact",
  30289. "mozContacts",
  30290. "mozCreateFileHandle",
  30291. "mozCurrentTransform",
  30292. "mozCurrentTransformInverse",
  30293. "mozCursor",
  30294. "mozDash",
  30295. "mozDashOffset",
  30296. "mozDecodedFrames",
  30297. "mozExitPointerLock",
  30298. "mozFillRule",
  30299. "mozFragmentEnd",
  30300. "mozFrameDelay",
  30301. "mozFullScreen",
  30302. "mozFullScreenElement",
  30303. "mozFullScreenEnabled",
  30304. "mozGetAll",
  30305. "mozGetAllKeys",
  30306. "mozGetAsFile",
  30307. "mozGetDataAt",
  30308. "mozGetMetadata",
  30309. "mozGetUserMedia",
  30310. "mozHasAudio",
  30311. "mozHasItem",
  30312. "mozHidden",
  30313. "mozImageSmoothingEnabled",
  30314. "mozIndexedDB",
  30315. "mozInnerScreenX",
  30316. "mozInnerScreenY",
  30317. "mozInputSource",
  30318. "mozIsTextField",
  30319. "mozItem",
  30320. "mozItemCount",
  30321. "mozItems",
  30322. "mozLength",
  30323. "mozLockOrientation",
  30324. "mozMatchesSelector",
  30325. "mozMovementX",
  30326. "mozMovementY",
  30327. "mozOpaque",
  30328. "mozOrientation",
  30329. "mozPaintCount",
  30330. "mozPaintedFrames",
  30331. "mozParsedFrames",
  30332. "mozPay",
  30333. "mozPointerLockElement",
  30334. "mozPresentedFrames",
  30335. "mozPreservesPitch",
  30336. "mozPressure",
  30337. "mozPrintCallback",
  30338. "mozRTCIceCandidate",
  30339. "mozRTCPeerConnection",
  30340. "mozRTCSessionDescription",
  30341. "mozRemove",
  30342. "mozRequestAnimationFrame",
  30343. "mozRequestFullScreen",
  30344. "mozRequestPointerLock",
  30345. "mozSetDataAt",
  30346. "mozSetImageElement",
  30347. "mozSourceNode",
  30348. "mozSrcObject",
  30349. "mozSystem",
  30350. "mozTCPSocket",
  30351. "mozTextStyle",
  30352. "mozTypesAt",
  30353. "mozUnlockOrientation",
  30354. "mozUserCancelled",
  30355. "mozVisibilityState",
  30356. "ms",
  30357. "msAnimation",
  30358. "msAnimationDelay",
  30359. "msAnimationDirection",
  30360. "msAnimationDuration",
  30361. "msAnimationFillMode",
  30362. "msAnimationIterationCount",
  30363. "msAnimationName",
  30364. "msAnimationPlayState",
  30365. "msAnimationStartTime",
  30366. "msAnimationTimingFunction",
  30367. "msBackfaceVisibility",
  30368. "msBlockProgression",
  30369. "msCSSOMElementFloatMetrics",
  30370. "msCaching",
  30371. "msCachingEnabled",
  30372. "msCancelRequestAnimationFrame",
  30373. "msCapsLockWarningOff",
  30374. "msClearImmediate",
  30375. "msClose",
  30376. "msContentZoomChaining",
  30377. "msContentZoomFactor",
  30378. "msContentZoomLimit",
  30379. "msContentZoomLimitMax",
  30380. "msContentZoomLimitMin",
  30381. "msContentZoomSnap",
  30382. "msContentZoomSnapPoints",
  30383. "msContentZoomSnapType",
  30384. "msContentZooming",
  30385. "msConvertURL",
  30386. "msCrypto",
  30387. "msDoNotTrack",
  30388. "msElementsFromPoint",
  30389. "msElementsFromRect",
  30390. "msExitFullscreen",
  30391. "msExtendedCode",
  30392. "msFillRule",
  30393. "msFirstPaint",
  30394. "msFlex",
  30395. "msFlexAlign",
  30396. "msFlexDirection",
  30397. "msFlexFlow",
  30398. "msFlexItemAlign",
  30399. "msFlexLinePack",
  30400. "msFlexNegative",
  30401. "msFlexOrder",
  30402. "msFlexPack",
  30403. "msFlexPositive",
  30404. "msFlexPreferredSize",
  30405. "msFlexWrap",
  30406. "msFlowFrom",
  30407. "msFlowInto",
  30408. "msFontFeatureSettings",
  30409. "msFullscreenElement",
  30410. "msFullscreenEnabled",
  30411. "msGetInputContext",
  30412. "msGetRegionContent",
  30413. "msGetUntransformedBounds",
  30414. "msGraphicsTrustStatus",
  30415. "msGridColumn",
  30416. "msGridColumnAlign",
  30417. "msGridColumnSpan",
  30418. "msGridColumns",
  30419. "msGridRow",
  30420. "msGridRowAlign",
  30421. "msGridRowSpan",
  30422. "msGridRows",
  30423. "msHidden",
  30424. "msHighContrastAdjust",
  30425. "msHyphenateLimitChars",
  30426. "msHyphenateLimitLines",
  30427. "msHyphenateLimitZone",
  30428. "msHyphens",
  30429. "msImageSmoothingEnabled",
  30430. "msImeAlign",
  30431. "msIndexedDB",
  30432. "msInterpolationMode",
  30433. "msIsStaticHTML",
  30434. "msKeySystem",
  30435. "msKeys",
  30436. "msLaunchUri",
  30437. "msLockOrientation",
  30438. "msManipulationViewsEnabled",
  30439. "msMatchMedia",
  30440. "msMatchesSelector",
  30441. "msMaxTouchPoints",
  30442. "msOrientation",
  30443. "msOverflowStyle",
  30444. "msPerspective",
  30445. "msPerspectiveOrigin",
  30446. "msPlayToDisabled",
  30447. "msPlayToPreferredSourceUri",
  30448. "msPlayToPrimary",
  30449. "msPointerEnabled",
  30450. "msRegionOverflow",
  30451. "msReleasePointerCapture",
  30452. "msRequestAnimationFrame",
  30453. "msRequestFullscreen",
  30454. "msSaveBlob",
  30455. "msSaveOrOpenBlob",
  30456. "msScrollChaining",
  30457. "msScrollLimit",
  30458. "msScrollLimitXMax",
  30459. "msScrollLimitXMin",
  30460. "msScrollLimitYMax",
  30461. "msScrollLimitYMin",
  30462. "msScrollRails",
  30463. "msScrollSnapPointsX",
  30464. "msScrollSnapPointsY",
  30465. "msScrollSnapType",
  30466. "msScrollSnapX",
  30467. "msScrollSnapY",
  30468. "msScrollTranslation",
  30469. "msSetImmediate",
  30470. "msSetMediaKeys",
  30471. "msSetPointerCapture",
  30472. "msTextCombineHorizontal",
  30473. "msTextSizeAdjust",
  30474. "msToBlob",
  30475. "msTouchAction",
  30476. "msTouchSelect",
  30477. "msTraceAsyncCallbackCompleted",
  30478. "msTraceAsyncCallbackStarting",
  30479. "msTraceAsyncOperationCompleted",
  30480. "msTraceAsyncOperationStarting",
  30481. "msTransform",
  30482. "msTransformOrigin",
  30483. "msTransformStyle",
  30484. "msTransition",
  30485. "msTransitionDelay",
  30486. "msTransitionDuration",
  30487. "msTransitionProperty",
  30488. "msTransitionTimingFunction",
  30489. "msUnlockOrientation",
  30490. "msUpdateAsyncCallbackRelation",
  30491. "msUserSelect",
  30492. "msVisibilityState",
  30493. "msWrapFlow",
  30494. "msWrapMargin",
  30495. "msWrapThrough",
  30496. "msWriteProfilerMark",
  30497. "msZoom",
  30498. "msZoomTo",
  30499. "mt",
  30500. "mul",
  30501. "multiEntry",
  30502. "multiSelectionObj",
  30503. "multiline",
  30504. "multiple",
  30505. "multiply",
  30506. "multiplySelf",
  30507. "mutableFile",
  30508. "muted",
  30509. "n",
  30510. "name",
  30511. "nameProp",
  30512. "namedItem",
  30513. "namedRecordset",
  30514. "names",
  30515. "namespaceURI",
  30516. "namespaces",
  30517. "naturalHeight",
  30518. "naturalWidth",
  30519. "navigate",
  30520. "navigation",
  30521. "navigationMode",
  30522. "navigationPreload",
  30523. "navigationStart",
  30524. "navigator",
  30525. "near",
  30526. "nearestViewportElement",
  30527. "negative",
  30528. "negotiated",
  30529. "netscape",
  30530. "networkState",
  30531. "newScale",
  30532. "newTranslate",
  30533. "newURL",
  30534. "newValue",
  30535. "newValueSpecifiedUnits",
  30536. "newVersion",
  30537. "newhome",
  30538. "next",
  30539. "nextElementSibling",
  30540. "nextHopProtocol",
  30541. "nextNode",
  30542. "nextPage",
  30543. "nextSibling",
  30544. "nickname",
  30545. "noHref",
  30546. "noModule",
  30547. "noResize",
  30548. "noShade",
  30549. "noValidate",
  30550. "noWrap",
  30551. "node",
  30552. "nodeName",
  30553. "nodeType",
  30554. "nodeValue",
  30555. "nonce",
  30556. "normalize",
  30557. "normalizedPathSegList",
  30558. "notationName",
  30559. "notations",
  30560. "note",
  30561. "noteGrainOn",
  30562. "noteOff",
  30563. "noteOn",
  30564. "notify",
  30565. "now",
  30566. "numOctaves",
  30567. "number",
  30568. "numberOfChannels",
  30569. "numberOfInputs",
  30570. "numberOfItems",
  30571. "numberOfOutputs",
  30572. "numberValue",
  30573. "oMatchesSelector",
  30574. "object",
  30575. "object-fit",
  30576. "object-position",
  30577. "objectFit",
  30578. "objectPosition",
  30579. "objectStore",
  30580. "objectStoreNames",
  30581. "objectType",
  30582. "observe",
  30583. "of",
  30584. "offscreenBuffering",
  30585. "offset",
  30586. "offset-anchor",
  30587. "offset-distance",
  30588. "offset-path",
  30589. "offset-rotate",
  30590. "offsetAnchor",
  30591. "offsetDistance",
  30592. "offsetHeight",
  30593. "offsetLeft",
  30594. "offsetNode",
  30595. "offsetParent",
  30596. "offsetPath",
  30597. "offsetRotate",
  30598. "offsetTop",
  30599. "offsetWidth",
  30600. "offsetX",
  30601. "offsetY",
  30602. "ok",
  30603. "oldURL",
  30604. "oldValue",
  30605. "oldVersion",
  30606. "olderShadowRoot",
  30607. "onLine",
  30608. "onabort",
  30609. "onabsolutedeviceorientation",
  30610. "onactivate",
  30611. "onactive",
  30612. "onaddsourcebuffer",
  30613. "onaddstream",
  30614. "onaddtrack",
  30615. "onafterprint",
  30616. "onafterscriptexecute",
  30617. "onafterupdate",
  30618. "onanimationcancel",
  30619. "onanimationend",
  30620. "onanimationiteration",
  30621. "onanimationstart",
  30622. "onappinstalled",
  30623. "onaudioend",
  30624. "onaudioprocess",
  30625. "onaudiostart",
  30626. "onautocomplete",
  30627. "onautocompleteerror",
  30628. "onauxclick",
  30629. "onbeforeactivate",
  30630. "onbeforecopy",
  30631. "onbeforecut",
  30632. "onbeforedeactivate",
  30633. "onbeforeeditfocus",
  30634. "onbeforeinstallprompt",
  30635. "onbeforepaste",
  30636. "onbeforeprint",
  30637. "onbeforescriptexecute",
  30638. "onbeforeunload",
  30639. "onbeforeupdate",
  30640. "onbeforexrselect",
  30641. "onbegin",
  30642. "onblocked",
  30643. "onblur",
  30644. "onbounce",
  30645. "onboundary",
  30646. "onbufferedamountlow",
  30647. "oncached",
  30648. "oncancel",
  30649. "oncandidatewindowhide",
  30650. "oncandidatewindowshow",
  30651. "oncandidatewindowupdate",
  30652. "oncanplay",
  30653. "oncanplaythrough",
  30654. "once",
  30655. "oncellchange",
  30656. "onchange",
  30657. "oncharacteristicvaluechanged",
  30658. "onchargingchange",
  30659. "onchargingtimechange",
  30660. "onchecking",
  30661. "onclick",
  30662. "onclose",
  30663. "onclosing",
  30664. "oncompassneedscalibration",
  30665. "oncomplete",
  30666. "onconnect",
  30667. "onconnecting",
  30668. "onconnectionavailable",
  30669. "onconnectionstatechange",
  30670. "oncontextmenu",
  30671. "oncontrollerchange",
  30672. "oncontrolselect",
  30673. "oncopy",
  30674. "oncuechange",
  30675. "oncut",
  30676. "ondataavailable",
  30677. "ondatachannel",
  30678. "ondatasetchanged",
  30679. "ondatasetcomplete",
  30680. "ondblclick",
  30681. "ondeactivate",
  30682. "ondevicechange",
  30683. "ondevicelight",
  30684. "ondevicemotion",
  30685. "ondeviceorientation",
  30686. "ondeviceorientationabsolute",
  30687. "ondeviceproximity",
  30688. "ondischargingtimechange",
  30689. "ondisconnect",
  30690. "ondisplay",
  30691. "ondownloading",
  30692. "ondrag",
  30693. "ondragend",
  30694. "ondragenter",
  30695. "ondragexit",
  30696. "ondragleave",
  30697. "ondragover",
  30698. "ondragstart",
  30699. "ondrop",
  30700. "ondurationchange",
  30701. "onemptied",
  30702. "onencrypted",
  30703. "onend",
  30704. "onended",
  30705. "onenter",
  30706. "onenterpictureinpicture",
  30707. "onerror",
  30708. "onerrorupdate",
  30709. "onexit",
  30710. "onfilterchange",
  30711. "onfinish",
  30712. "onfocus",
  30713. "onfocusin",
  30714. "onfocusout",
  30715. "onformdata",
  30716. "onfreeze",
  30717. "onfullscreenchange",
  30718. "onfullscreenerror",
  30719. "ongatheringstatechange",
  30720. "ongattserverdisconnected",
  30721. "ongesturechange",
  30722. "ongestureend",
  30723. "ongesturestart",
  30724. "ongotpointercapture",
  30725. "onhashchange",
  30726. "onhelp",
  30727. "onicecandidate",
  30728. "onicecandidateerror",
  30729. "oniceconnectionstatechange",
  30730. "onicegatheringstatechange",
  30731. "oninactive",
  30732. "oninput",
  30733. "oninputsourceschange",
  30734. "oninvalid",
  30735. "onkeydown",
  30736. "onkeypress",
  30737. "onkeystatuseschange",
  30738. "onkeyup",
  30739. "onlanguagechange",
  30740. "onlayoutcomplete",
  30741. "onleavepictureinpicture",
  30742. "onlevelchange",
  30743. "onload",
  30744. "onloadeddata",
  30745. "onloadedmetadata",
  30746. "onloadend",
  30747. "onloading",
  30748. "onloadingdone",
  30749. "onloadingerror",
  30750. "onloadstart",
  30751. "onlosecapture",
  30752. "onlostpointercapture",
  30753. "only",
  30754. "onmark",
  30755. "onmessage",
  30756. "onmessageerror",
  30757. "onmidimessage",
  30758. "onmousedown",
  30759. "onmouseenter",
  30760. "onmouseleave",
  30761. "onmousemove",
  30762. "onmouseout",
  30763. "onmouseover",
  30764. "onmouseup",
  30765. "onmousewheel",
  30766. "onmove",
  30767. "onmoveend",
  30768. "onmovestart",
  30769. "onmozfullscreenchange",
  30770. "onmozfullscreenerror",
  30771. "onmozorientationchange",
  30772. "onmozpointerlockchange",
  30773. "onmozpointerlockerror",
  30774. "onmscontentzoom",
  30775. "onmsfullscreenchange",
  30776. "onmsfullscreenerror",
  30777. "onmsgesturechange",
  30778. "onmsgesturedoubletap",
  30779. "onmsgestureend",
  30780. "onmsgesturehold",
  30781. "onmsgesturestart",
  30782. "onmsgesturetap",
  30783. "onmsgotpointercapture",
  30784. "onmsinertiastart",
  30785. "onmslostpointercapture",
  30786. "onmsmanipulationstatechanged",
  30787. "onmsneedkey",
  30788. "onmsorientationchange",
  30789. "onmspointercancel",
  30790. "onmspointerdown",
  30791. "onmspointerenter",
  30792. "onmspointerhover",
  30793. "onmspointerleave",
  30794. "onmspointermove",
  30795. "onmspointerout",
  30796. "onmspointerover",
  30797. "onmspointerup",
  30798. "onmssitemodejumplistitemremoved",
  30799. "onmsthumbnailclick",
  30800. "onmute",
  30801. "onnegotiationneeded",
  30802. "onnomatch",
  30803. "onnoupdate",
  30804. "onobsolete",
  30805. "onoffline",
  30806. "ononline",
  30807. "onopen",
  30808. "onorientationchange",
  30809. "onpagechange",
  30810. "onpagehide",
  30811. "onpageshow",
  30812. "onpaste",
  30813. "onpause",
  30814. "onpayerdetailchange",
  30815. "onpaymentmethodchange",
  30816. "onplay",
  30817. "onplaying",
  30818. "onpluginstreamstart",
  30819. "onpointercancel",
  30820. "onpointerdown",
  30821. "onpointerenter",
  30822. "onpointerleave",
  30823. "onpointerlockchange",
  30824. "onpointerlockerror",
  30825. "onpointermove",
  30826. "onpointerout",
  30827. "onpointerover",
  30828. "onpointerrawupdate",
  30829. "onpointerup",
  30830. "onpopstate",
  30831. "onprocessorerror",
  30832. "onprogress",
  30833. "onpropertychange",
  30834. "onratechange",
  30835. "onreading",
  30836. "onreadystatechange",
  30837. "onrejectionhandled",
  30838. "onrelease",
  30839. "onremove",
  30840. "onremovesourcebuffer",
  30841. "onremovestream",
  30842. "onremovetrack",
  30843. "onrepeat",
  30844. "onreset",
  30845. "onresize",
  30846. "onresizeend",
  30847. "onresizestart",
  30848. "onresourcetimingbufferfull",
  30849. "onresult",
  30850. "onresume",
  30851. "onrowenter",
  30852. "onrowexit",
  30853. "onrowsdelete",
  30854. "onrowsinserted",
  30855. "onscroll",
  30856. "onsearch",
  30857. "onsecuritypolicyviolation",
  30858. "onseeked",
  30859. "onseeking",
  30860. "onselect",
  30861. "onselectedcandidatepairchange",
  30862. "onselectend",
  30863. "onselectionchange",
  30864. "onselectstart",
  30865. "onshippingaddresschange",
  30866. "onshippingoptionchange",
  30867. "onshow",
  30868. "onsignalingstatechange",
  30869. "onsoundend",
  30870. "onsoundstart",
  30871. "onsourceclose",
  30872. "onsourceclosed",
  30873. "onsourceended",
  30874. "onsourceopen",
  30875. "onspeechend",
  30876. "onspeechstart",
  30877. "onsqueeze",
  30878. "onsqueezeend",
  30879. "onsqueezestart",
  30880. "onstalled",
  30881. "onstart",
  30882. "onstatechange",
  30883. "onstop",
  30884. "onstorage",
  30885. "onstoragecommit",
  30886. "onsubmit",
  30887. "onsuccess",
  30888. "onsuspend",
  30889. "onterminate",
  30890. "ontextinput",
  30891. "ontimeout",
  30892. "ontimeupdate",
  30893. "ontoggle",
  30894. "ontonechange",
  30895. "ontouchcancel",
  30896. "ontouchend",
  30897. "ontouchmove",
  30898. "ontouchstart",
  30899. "ontrack",
  30900. "ontransitioncancel",
  30901. "ontransitionend",
  30902. "ontransitionrun",
  30903. "ontransitionstart",
  30904. "onunhandledrejection",
  30905. "onunload",
  30906. "onunmute",
  30907. "onupdate",
  30908. "onupdateend",
  30909. "onupdatefound",
  30910. "onupdateready",
  30911. "onupdatestart",
  30912. "onupgradeneeded",
  30913. "onuserproximity",
  30914. "onversionchange",
  30915. "onvisibilitychange",
  30916. "onvoiceschanged",
  30917. "onvolumechange",
  30918. "onvrdisplayactivate",
  30919. "onvrdisplayconnect",
  30920. "onvrdisplaydeactivate",
  30921. "onvrdisplaydisconnect",
  30922. "onvrdisplaypresentchange",
  30923. "onwaiting",
  30924. "onwaitingforkey",
  30925. "onwarning",
  30926. "onwebkitanimationend",
  30927. "onwebkitanimationiteration",
  30928. "onwebkitanimationstart",
  30929. "onwebkitcurrentplaybacktargetiswirelesschanged",
  30930. "onwebkitfullscreenchange",
  30931. "onwebkitfullscreenerror",
  30932. "onwebkitkeyadded",
  30933. "onwebkitkeyerror",
  30934. "onwebkitkeymessage",
  30935. "onwebkitneedkey",
  30936. "onwebkitorientationchange",
  30937. "onwebkitplaybacktargetavailabilitychanged",
  30938. "onwebkitpointerlockchange",
  30939. "onwebkitpointerlockerror",
  30940. "onwebkitresourcetimingbufferfull",
  30941. "onwebkittransitionend",
  30942. "onwheel",
  30943. "onzoom",
  30944. "opacity",
  30945. "open",
  30946. "openCursor",
  30947. "openDatabase",
  30948. "openKeyCursor",
  30949. "opened",
  30950. "opener",
  30951. "opera",
  30952. "operationType",
  30953. "operator",
  30954. "opr",
  30955. "optimum",
  30956. "options",
  30957. "or",
  30958. "order",
  30959. "orderX",
  30960. "orderY",
  30961. "ordered",
  30962. "org",
  30963. "organization",
  30964. "orient",
  30965. "orientAngle",
  30966. "orientType",
  30967. "orientation",
  30968. "orientationX",
  30969. "orientationY",
  30970. "orientationZ",
  30971. "origin",
  30972. "originalPolicy",
  30973. "originalTarget",
  30974. "orphans",
  30975. "oscpu",
  30976. "outerHTML",
  30977. "outerHeight",
  30978. "outerText",
  30979. "outerWidth",
  30980. "outline",
  30981. "outline-color",
  30982. "outline-offset",
  30983. "outline-style",
  30984. "outline-width",
  30985. "outlineColor",
  30986. "outlineOffset",
  30987. "outlineStyle",
  30988. "outlineWidth",
  30989. "outputBuffer",
  30990. "outputLatency",
  30991. "outputs",
  30992. "overflow",
  30993. "overflow-anchor",
  30994. "overflow-block",
  30995. "overflow-inline",
  30996. "overflow-wrap",
  30997. "overflow-x",
  30998. "overflow-y",
  30999. "overflowAnchor",
  31000. "overflowBlock",
  31001. "overflowInline",
  31002. "overflowWrap",
  31003. "overflowX",
  31004. "overflowY",
  31005. "overrideMimeType",
  31006. "oversample",
  31007. "overscroll-behavior",
  31008. "overscroll-behavior-block",
  31009. "overscroll-behavior-inline",
  31010. "overscroll-behavior-x",
  31011. "overscroll-behavior-y",
  31012. "overscrollBehavior",
  31013. "overscrollBehaviorBlock",
  31014. "overscrollBehaviorInline",
  31015. "overscrollBehaviorX",
  31016. "overscrollBehaviorY",
  31017. "ownKeys",
  31018. "ownerDocument",
  31019. "ownerElement",
  31020. "ownerNode",
  31021. "ownerRule",
  31022. "ownerSVGElement",
  31023. "owningElement",
  31024. "p1",
  31025. "p2",
  31026. "p3",
  31027. "p4",
  31028. "packetSize",
  31029. "packets",
  31030. "pad",
  31031. "padEnd",
  31032. "padStart",
  31033. "padding",
  31034. "padding-block",
  31035. "padding-block-end",
  31036. "padding-block-start",
  31037. "padding-bottom",
  31038. "padding-inline",
  31039. "padding-inline-end",
  31040. "padding-inline-start",
  31041. "padding-left",
  31042. "padding-right",
  31043. "padding-top",
  31044. "paddingBlock",
  31045. "paddingBlockEnd",
  31046. "paddingBlockStart",
  31047. "paddingBottom",
  31048. "paddingInline",
  31049. "paddingInlineEnd",
  31050. "paddingInlineStart",
  31051. "paddingLeft",
  31052. "paddingRight",
  31053. "paddingTop",
  31054. "page",
  31055. "page-break-after",
  31056. "page-break-before",
  31057. "page-break-inside",
  31058. "pageBreakAfter",
  31059. "pageBreakBefore",
  31060. "pageBreakInside",
  31061. "pageCount",
  31062. "pageLeft",
  31063. "pageTop",
  31064. "pageX",
  31065. "pageXOffset",
  31066. "pageY",
  31067. "pageYOffset",
  31068. "pages",
  31069. "paint-order",
  31070. "paintOrder",
  31071. "paintRequests",
  31072. "paintType",
  31073. "paintWorklet",
  31074. "palette",
  31075. "pan",
  31076. "panningModel",
  31077. "parameters",
  31078. "parent",
  31079. "parentElement",
  31080. "parentNode",
  31081. "parentRule",
  31082. "parentStyleSheet",
  31083. "parentTextEdit",
  31084. "parentWindow",
  31085. "parse",
  31086. "parseAll",
  31087. "parseFloat",
  31088. "parseFromString",
  31089. "parseInt",
  31090. "part",
  31091. "participants",
  31092. "passive",
  31093. "password",
  31094. "pasteHTML",
  31095. "path",
  31096. "pathLength",
  31097. "pathSegList",
  31098. "pathSegType",
  31099. "pathSegTypeAsLetter",
  31100. "pathname",
  31101. "pattern",
  31102. "patternContentUnits",
  31103. "patternMismatch",
  31104. "patternTransform",
  31105. "patternUnits",
  31106. "pause",
  31107. "pauseAnimations",
  31108. "pauseOnExit",
  31109. "pauseProfilers",
  31110. "pauseTransformFeedback",
  31111. "paused",
  31112. "payerEmail",
  31113. "payerName",
  31114. "payerPhone",
  31115. "paymentManager",
  31116. "pc",
  31117. "peerIdentity",
  31118. "pending",
  31119. "pendingLocalDescription",
  31120. "pendingRemoteDescription",
  31121. "percent",
  31122. "performance",
  31123. "periodicSync",
  31124. "permission",
  31125. "permissionState",
  31126. "permissions",
  31127. "persist",
  31128. "persisted",
  31129. "personalbar",
  31130. "perspective",
  31131. "perspective-origin",
  31132. "perspectiveOrigin",
  31133. "phone",
  31134. "phoneticFamilyName",
  31135. "phoneticGivenName",
  31136. "photo",
  31137. "pictureInPictureElement",
  31138. "pictureInPictureEnabled",
  31139. "pictureInPictureWindow",
  31140. "ping",
  31141. "pipeThrough",
  31142. "pipeTo",
  31143. "pitch",
  31144. "pixelBottom",
  31145. "pixelDepth",
  31146. "pixelHeight",
  31147. "pixelLeft",
  31148. "pixelRight",
  31149. "pixelStorei",
  31150. "pixelTop",
  31151. "pixelUnitToMillimeterX",
  31152. "pixelUnitToMillimeterY",
  31153. "pixelWidth",
  31154. "place-content",
  31155. "place-items",
  31156. "place-self",
  31157. "placeContent",
  31158. "placeItems",
  31159. "placeSelf",
  31160. "placeholder",
  31161. "platform",
  31162. "platforms",
  31163. "play",
  31164. "playEffect",
  31165. "playState",
  31166. "playbackRate",
  31167. "playbackState",
  31168. "playbackTime",
  31169. "played",
  31170. "playoutDelayHint",
  31171. "playsInline",
  31172. "plugins",
  31173. "pluginspage",
  31174. "pname",
  31175. "pointer-events",
  31176. "pointerBeforeReferenceNode",
  31177. "pointerEnabled",
  31178. "pointerEvents",
  31179. "pointerId",
  31180. "pointerLockElement",
  31181. "pointerType",
  31182. "points",
  31183. "pointsAtX",
  31184. "pointsAtY",
  31185. "pointsAtZ",
  31186. "polygonOffset",
  31187. "pop",
  31188. "populateMatrix",
  31189. "popupWindowFeatures",
  31190. "popupWindowName",
  31191. "popupWindowURI",
  31192. "port",
  31193. "port1",
  31194. "port2",
  31195. "ports",
  31196. "posBottom",
  31197. "posHeight",
  31198. "posLeft",
  31199. "posRight",
  31200. "posTop",
  31201. "posWidth",
  31202. "pose",
  31203. "position",
  31204. "positionAlign",
  31205. "positionX",
  31206. "positionY",
  31207. "positionZ",
  31208. "postError",
  31209. "postMessage",
  31210. "postalCode",
  31211. "poster",
  31212. "pow",
  31213. "powerEfficient",
  31214. "powerOff",
  31215. "preMultiplySelf",
  31216. "precision",
  31217. "preferredStyleSheetSet",
  31218. "preferredStylesheetSet",
  31219. "prefix",
  31220. "preload",
  31221. "prepend",
  31222. "presentation",
  31223. "preserveAlpha",
  31224. "preserveAspectRatio",
  31225. "preserveAspectRatioString",
  31226. "pressed",
  31227. "pressure",
  31228. "prevValue",
  31229. "preventDefault",
  31230. "preventExtensions",
  31231. "preventSilentAccess",
  31232. "previousElementSibling",
  31233. "previousNode",
  31234. "previousPage",
  31235. "previousRect",
  31236. "previousScale",
  31237. "previousSibling",
  31238. "previousTranslate",
  31239. "primaryKey",
  31240. "primitiveType",
  31241. "primitiveUnits",
  31242. "principals",
  31243. "print",
  31244. "priority",
  31245. "privateKey",
  31246. "probablySupportsContext",
  31247. "process",
  31248. "processIceMessage",
  31249. "processingEnd",
  31250. "processingStart",
  31251. "product",
  31252. "productId",
  31253. "productName",
  31254. "productSub",
  31255. "profile",
  31256. "profileEnd",
  31257. "profiles",
  31258. "projectionMatrix",
  31259. "promise",
  31260. "prompt",
  31261. "properties",
  31262. "propertyIsEnumerable",
  31263. "propertyName",
  31264. "protocol",
  31265. "protocolLong",
  31266. "prototype",
  31267. "provider",
  31268. "pseudoClass",
  31269. "pseudoElement",
  31270. "pt",
  31271. "publicId",
  31272. "publicKey",
  31273. "published",
  31274. "pulse",
  31275. "push",
  31276. "pushManager",
  31277. "pushNotification",
  31278. "pushState",
  31279. "put",
  31280. "putImageData",
  31281. "px",
  31282. "quadraticCurveTo",
  31283. "qualifier",
  31284. "quaternion",
  31285. "query",
  31286. "queryCommandEnabled",
  31287. "queryCommandIndeterm",
  31288. "queryCommandState",
  31289. "queryCommandSupported",
  31290. "queryCommandText",
  31291. "queryCommandValue",
  31292. "querySelector",
  31293. "querySelectorAll",
  31294. "queueMicrotask",
  31295. "quote",
  31296. "quotes",
  31297. "r",
  31298. "r1",
  31299. "r2",
  31300. "race",
  31301. "rad",
  31302. "radiogroup",
  31303. "radiusX",
  31304. "radiusY",
  31305. "random",
  31306. "range",
  31307. "rangeCount",
  31308. "rangeMax",
  31309. "rangeMin",
  31310. "rangeOffset",
  31311. "rangeOverflow",
  31312. "rangeParent",
  31313. "rangeUnderflow",
  31314. "rate",
  31315. "ratio",
  31316. "raw",
  31317. "rawId",
  31318. "read",
  31319. "readAsArrayBuffer",
  31320. "readAsBinaryString",
  31321. "readAsBlob",
  31322. "readAsDataURL",
  31323. "readAsText",
  31324. "readBuffer",
  31325. "readEntries",
  31326. "readOnly",
  31327. "readPixels",
  31328. "readReportRequested",
  31329. "readText",
  31330. "readValue",
  31331. "readable",
  31332. "ready",
  31333. "readyState",
  31334. "reason",
  31335. "reboot",
  31336. "receivedAlert",
  31337. "receiver",
  31338. "receivers",
  31339. "recipient",
  31340. "reconnect",
  31341. "recordNumber",
  31342. "recordsAvailable",
  31343. "recordset",
  31344. "rect",
  31345. "red",
  31346. "redEyeReduction",
  31347. "redirect",
  31348. "redirectCount",
  31349. "redirectEnd",
  31350. "redirectStart",
  31351. "redirected",
  31352. "reduce",
  31353. "reduceRight",
  31354. "reduction",
  31355. "refDistance",
  31356. "refX",
  31357. "refY",
  31358. "referenceNode",
  31359. "referenceSpace",
  31360. "referrer",
  31361. "referrerPolicy",
  31362. "refresh",
  31363. "region",
  31364. "regionAnchorX",
  31365. "regionAnchorY",
  31366. "regionId",
  31367. "regions",
  31368. "register",
  31369. "registerContentHandler",
  31370. "registerElement",
  31371. "registerProperty",
  31372. "registerProtocolHandler",
  31373. "reject",
  31374. "rel",
  31375. "relList",
  31376. "relatedAddress",
  31377. "relatedNode",
  31378. "relatedPort",
  31379. "relatedTarget",
  31380. "release",
  31381. "releaseCapture",
  31382. "releaseEvents",
  31383. "releaseInterface",
  31384. "releaseLock",
  31385. "releasePointerCapture",
  31386. "releaseShaderCompiler",
  31387. "reliable",
  31388. "reliableWrite",
  31389. "reload",
  31390. "rem",
  31391. "remainingSpace",
  31392. "remote",
  31393. "remoteDescription",
  31394. "remove",
  31395. "removeAllRanges",
  31396. "removeAttribute",
  31397. "removeAttributeNS",
  31398. "removeAttributeNode",
  31399. "removeBehavior",
  31400. "removeChild",
  31401. "removeCue",
  31402. "removeEventListener",
  31403. "removeFilter",
  31404. "removeImport",
  31405. "removeItem",
  31406. "removeListener",
  31407. "removeNamedItem",
  31408. "removeNamedItemNS",
  31409. "removeNode",
  31410. "removeParameter",
  31411. "removeProperty",
  31412. "removeRange",
  31413. "removeRegion",
  31414. "removeRule",
  31415. "removeSiteSpecificTrackingException",
  31416. "removeSourceBuffer",
  31417. "removeStream",
  31418. "removeTrack",
  31419. "removeVariable",
  31420. "removeWakeLockListener",
  31421. "removeWebWideTrackingException",
  31422. "removed",
  31423. "removedNodes",
  31424. "renderHeight",
  31425. "renderState",
  31426. "renderTime",
  31427. "renderWidth",
  31428. "renderbufferStorage",
  31429. "renderbufferStorageMultisample",
  31430. "renderedBuffer",
  31431. "renderingMode",
  31432. "renotify",
  31433. "repeat",
  31434. "replace",
  31435. "replaceAdjacentText",
  31436. "replaceAll",
  31437. "replaceChild",
  31438. "replaceChildren",
  31439. "replaceData",
  31440. "replaceId",
  31441. "replaceItem",
  31442. "replaceNode",
  31443. "replaceState",
  31444. "replaceSync",
  31445. "replaceTrack",
  31446. "replaceWholeText",
  31447. "replaceWith",
  31448. "reportValidity",
  31449. "request",
  31450. "requestAnimationFrame",
  31451. "requestAutocomplete",
  31452. "requestData",
  31453. "requestDevice",
  31454. "requestFrame",
  31455. "requestFullscreen",
  31456. "requestHitTestSource",
  31457. "requestHitTestSourceForTransientInput",
  31458. "requestId",
  31459. "requestIdleCallback",
  31460. "requestMIDIAccess",
  31461. "requestMediaKeySystemAccess",
  31462. "requestPermission",
  31463. "requestPictureInPicture",
  31464. "requestPointerLock",
  31465. "requestPresent",
  31466. "requestReferenceSpace",
  31467. "requestSession",
  31468. "requestStart",
  31469. "requestStorageAccess",
  31470. "requestSubmit",
  31471. "requestVideoFrameCallback",
  31472. "requestingWindow",
  31473. "requireInteraction",
  31474. "required",
  31475. "requiredExtensions",
  31476. "requiredFeatures",
  31477. "reset",
  31478. "resetPose",
  31479. "resetTransform",
  31480. "resize",
  31481. "resizeBy",
  31482. "resizeTo",
  31483. "resolve",
  31484. "response",
  31485. "responseBody",
  31486. "responseEnd",
  31487. "responseReady",
  31488. "responseStart",
  31489. "responseText",
  31490. "responseType",
  31491. "responseURL",
  31492. "responseXML",
  31493. "restartIce",
  31494. "restore",
  31495. "result",
  31496. "resultIndex",
  31497. "resultType",
  31498. "results",
  31499. "resume",
  31500. "resumeProfilers",
  31501. "resumeTransformFeedback",
  31502. "retry",
  31503. "returnValue",
  31504. "rev",
  31505. "reverse",
  31506. "reversed",
  31507. "revocable",
  31508. "revokeObjectURL",
  31509. "rgbColor",
  31510. "right",
  31511. "rightContext",
  31512. "rightDegrees",
  31513. "rightMargin",
  31514. "rightProjectionMatrix",
  31515. "rightViewMatrix",
  31516. "role",
  31517. "rolloffFactor",
  31518. "root",
  31519. "rootBounds",
  31520. "rootElement",
  31521. "rootMargin",
  31522. "rotate",
  31523. "rotateAxisAngle",
  31524. "rotateAxisAngleSelf",
  31525. "rotateFromVector",
  31526. "rotateFromVectorSelf",
  31527. "rotateSelf",
  31528. "rotation",
  31529. "rotationAngle",
  31530. "rotationRate",
  31531. "round",
  31532. "row-gap",
  31533. "rowGap",
  31534. "rowIndex",
  31535. "rowSpan",
  31536. "rows",
  31537. "rtcpTransport",
  31538. "rtt",
  31539. "ruby-align",
  31540. "ruby-position",
  31541. "rubyAlign",
  31542. "rubyOverhang",
  31543. "rubyPosition",
  31544. "rules",
  31545. "runtime",
  31546. "runtimeStyle",
  31547. "rx",
  31548. "ry",
  31549. "s",
  31550. "safari",
  31551. "sample",
  31552. "sampleCoverage",
  31553. "sampleRate",
  31554. "samplerParameterf",
  31555. "samplerParameteri",
  31556. "sandbox",
  31557. "save",
  31558. "saveData",
  31559. "scale",
  31560. "scale3d",
  31561. "scale3dSelf",
  31562. "scaleNonUniform",
  31563. "scaleNonUniformSelf",
  31564. "scaleSelf",
  31565. "scheme",
  31566. "scissor",
  31567. "scope",
  31568. "scopeName",
  31569. "scoped",
  31570. "screen",
  31571. "screenBrightness",
  31572. "screenEnabled",
  31573. "screenLeft",
  31574. "screenPixelToMillimeterX",
  31575. "screenPixelToMillimeterY",
  31576. "screenTop",
  31577. "screenX",
  31578. "screenY",
  31579. "scriptURL",
  31580. "scripts",
  31581. "scroll",
  31582. "scroll-behavior",
  31583. "scroll-margin",
  31584. "scroll-margin-block",
  31585. "scroll-margin-block-end",
  31586. "scroll-margin-block-start",
  31587. "scroll-margin-bottom",
  31588. "scroll-margin-inline",
  31589. "scroll-margin-inline-end",
  31590. "scroll-margin-inline-start",
  31591. "scroll-margin-left",
  31592. "scroll-margin-right",
  31593. "scroll-margin-top",
  31594. "scroll-padding",
  31595. "scroll-padding-block",
  31596. "scroll-padding-block-end",
  31597. "scroll-padding-block-start",
  31598. "scroll-padding-bottom",
  31599. "scroll-padding-inline",
  31600. "scroll-padding-inline-end",
  31601. "scroll-padding-inline-start",
  31602. "scroll-padding-left",
  31603. "scroll-padding-right",
  31604. "scroll-padding-top",
  31605. "scroll-snap-align",
  31606. "scroll-snap-type",
  31607. "scrollAmount",
  31608. "scrollBehavior",
  31609. "scrollBy",
  31610. "scrollByLines",
  31611. "scrollByPages",
  31612. "scrollDelay",
  31613. "scrollHeight",
  31614. "scrollIntoView",
  31615. "scrollIntoViewIfNeeded",
  31616. "scrollLeft",
  31617. "scrollLeftMax",
  31618. "scrollMargin",
  31619. "scrollMarginBlock",
  31620. "scrollMarginBlockEnd",
  31621. "scrollMarginBlockStart",
  31622. "scrollMarginBottom",
  31623. "scrollMarginInline",
  31624. "scrollMarginInlineEnd",
  31625. "scrollMarginInlineStart",
  31626. "scrollMarginLeft",
  31627. "scrollMarginRight",
  31628. "scrollMarginTop",
  31629. "scrollMaxX",
  31630. "scrollMaxY",
  31631. "scrollPadding",
  31632. "scrollPaddingBlock",
  31633. "scrollPaddingBlockEnd",
  31634. "scrollPaddingBlockStart",
  31635. "scrollPaddingBottom",
  31636. "scrollPaddingInline",
  31637. "scrollPaddingInlineEnd",
  31638. "scrollPaddingInlineStart",
  31639. "scrollPaddingLeft",
  31640. "scrollPaddingRight",
  31641. "scrollPaddingTop",
  31642. "scrollRestoration",
  31643. "scrollSnapAlign",
  31644. "scrollSnapType",
  31645. "scrollTo",
  31646. "scrollTop",
  31647. "scrollTopMax",
  31648. "scrollWidth",
  31649. "scrollX",
  31650. "scrollY",
  31651. "scrollbar-color",
  31652. "scrollbar-width",
  31653. "scrollbar3dLightColor",
  31654. "scrollbarArrowColor",
  31655. "scrollbarBaseColor",
  31656. "scrollbarColor",
  31657. "scrollbarDarkShadowColor",
  31658. "scrollbarFaceColor",
  31659. "scrollbarHighlightColor",
  31660. "scrollbarShadowColor",
  31661. "scrollbarTrackColor",
  31662. "scrollbarWidth",
  31663. "scrollbars",
  31664. "scrolling",
  31665. "scrollingElement",
  31666. "sctp",
  31667. "sctpCauseCode",
  31668. "sdp",
  31669. "sdpLineNumber",
  31670. "sdpMLineIndex",
  31671. "sdpMid",
  31672. "seal",
  31673. "search",
  31674. "searchBox",
  31675. "searchBoxJavaBridge_",
  31676. "searchParams",
  31677. "sectionRowIndex",
  31678. "secureConnectionStart",
  31679. "security",
  31680. "seed",
  31681. "seekToNextFrame",
  31682. "seekable",
  31683. "seeking",
  31684. "select",
  31685. "selectAllChildren",
  31686. "selectAlternateInterface",
  31687. "selectConfiguration",
  31688. "selectNode",
  31689. "selectNodeContents",
  31690. "selectNodes",
  31691. "selectSingleNode",
  31692. "selectSubString",
  31693. "selected",
  31694. "selectedIndex",
  31695. "selectedOptions",
  31696. "selectedStyleSheetSet",
  31697. "selectedStylesheetSet",
  31698. "selection",
  31699. "selectionDirection",
  31700. "selectionEnd",
  31701. "selectionStart",
  31702. "selector",
  31703. "selectorText",
  31704. "self",
  31705. "send",
  31706. "sendAsBinary",
  31707. "sendBeacon",
  31708. "sender",
  31709. "sentAlert",
  31710. "sentTimestamp",
  31711. "separator",
  31712. "serialNumber",
  31713. "serializeToString",
  31714. "serverTiming",
  31715. "service",
  31716. "serviceWorker",
  31717. "session",
  31718. "sessionId",
  31719. "sessionStorage",
  31720. "set",
  31721. "setActionHandler",
  31722. "setActive",
  31723. "setAlpha",
  31724. "setAppBadge",
  31725. "setAttribute",
  31726. "setAttributeNS",
  31727. "setAttributeNode",
  31728. "setAttributeNodeNS",
  31729. "setBaseAndExtent",
  31730. "setBigInt64",
  31731. "setBigUint64",
  31732. "setBingCurrentSearchDefault",
  31733. "setCapture",
  31734. "setCodecPreferences",
  31735. "setColor",
  31736. "setCompositeOperation",
  31737. "setConfiguration",
  31738. "setCurrentTime",
  31739. "setCustomValidity",
  31740. "setData",
  31741. "setDate",
  31742. "setDragImage",
  31743. "setEnd",
  31744. "setEndAfter",
  31745. "setEndBefore",
  31746. "setEndPoint",
  31747. "setFillColor",
  31748. "setFilterRes",
  31749. "setFloat32",
  31750. "setFloat64",
  31751. "setFloatValue",
  31752. "setFormValue",
  31753. "setFullYear",
  31754. "setHeaderValue",
  31755. "setHours",
  31756. "setIdentityProvider",
  31757. "setImmediate",
  31758. "setInt16",
  31759. "setInt32",
  31760. "setInt8",
  31761. "setInterval",
  31762. "setItem",
  31763. "setKeyframes",
  31764. "setLineCap",
  31765. "setLineDash",
  31766. "setLineJoin",
  31767. "setLineWidth",
  31768. "setLiveSeekableRange",
  31769. "setLocalDescription",
  31770. "setMatrix",
  31771. "setMatrixValue",
  31772. "setMediaKeys",
  31773. "setMilliseconds",
  31774. "setMinutes",
  31775. "setMiterLimit",
  31776. "setMonth",
  31777. "setNamedItem",
  31778. "setNamedItemNS",
  31779. "setNonUserCodeExceptions",
  31780. "setOrientToAngle",
  31781. "setOrientToAuto",
  31782. "setOrientation",
  31783. "setOverrideHistoryNavigationMode",
  31784. "setPaint",
  31785. "setParameter",
  31786. "setParameters",
  31787. "setPeriodicWave",
  31788. "setPointerCapture",
  31789. "setPosition",
  31790. "setPositionState",
  31791. "setPreference",
  31792. "setProperty",
  31793. "setPrototypeOf",
  31794. "setRGBColor",
  31795. "setRGBColorICCColor",
  31796. "setRadius",
  31797. "setRangeText",
  31798. "setRemoteDescription",
  31799. "setRequestHeader",
  31800. "setResizable",
  31801. "setResourceTimingBufferSize",
  31802. "setRotate",
  31803. "setScale",
  31804. "setSeconds",
  31805. "setSelectionRange",
  31806. "setServerCertificate",
  31807. "setShadow",
  31808. "setSinkId",
  31809. "setSkewX",
  31810. "setSkewY",
  31811. "setStart",
  31812. "setStartAfter",
  31813. "setStartBefore",
  31814. "setStdDeviation",
  31815. "setStreams",
  31816. "setStringValue",
  31817. "setStrokeColor",
  31818. "setSuggestResult",
  31819. "setTargetAtTime",
  31820. "setTargetValueAtTime",
  31821. "setTime",
  31822. "setTimeout",
  31823. "setTransform",
  31824. "setTranslate",
  31825. "setUTCDate",
  31826. "setUTCFullYear",
  31827. "setUTCHours",
  31828. "setUTCMilliseconds",
  31829. "setUTCMinutes",
  31830. "setUTCMonth",
  31831. "setUTCSeconds",
  31832. "setUint16",
  31833. "setUint32",
  31834. "setUint8",
  31835. "setUri",
  31836. "setValidity",
  31837. "setValueAtTime",
  31838. "setValueCurveAtTime",
  31839. "setVariable",
  31840. "setVelocity",
  31841. "setVersion",
  31842. "setYear",
  31843. "settingName",
  31844. "settingValue",
  31845. "sex",
  31846. "shaderSource",
  31847. "shadowBlur",
  31848. "shadowColor",
  31849. "shadowOffsetX",
  31850. "shadowOffsetY",
  31851. "shadowRoot",
  31852. "shape",
  31853. "shape-image-threshold",
  31854. "shape-margin",
  31855. "shape-outside",
  31856. "shape-rendering",
  31857. "shapeImageThreshold",
  31858. "shapeMargin",
  31859. "shapeOutside",
  31860. "shapeRendering",
  31861. "sheet",
  31862. "shift",
  31863. "shiftKey",
  31864. "shiftLeft",
  31865. "shippingAddress",
  31866. "shippingOption",
  31867. "shippingType",
  31868. "show",
  31869. "showHelp",
  31870. "showModal",
  31871. "showModalDialog",
  31872. "showModelessDialog",
  31873. "showNotification",
  31874. "sidebar",
  31875. "sign",
  31876. "signal",
  31877. "signalingState",
  31878. "signature",
  31879. "silent",
  31880. "sin",
  31881. "singleNodeValue",
  31882. "sinh",
  31883. "sinkId",
  31884. "sittingToStandingTransform",
  31885. "size",
  31886. "sizeToContent",
  31887. "sizeX",
  31888. "sizeZ",
  31889. "sizes",
  31890. "skewX",
  31891. "skewXSelf",
  31892. "skewY",
  31893. "skewYSelf",
  31894. "slice",
  31895. "slope",
  31896. "slot",
  31897. "small",
  31898. "smil",
  31899. "smooth",
  31900. "smoothingTimeConstant",
  31901. "snapToLines",
  31902. "snapshotItem",
  31903. "snapshotLength",
  31904. "some",
  31905. "sort",
  31906. "sortingCode",
  31907. "source",
  31908. "sourceBuffer",
  31909. "sourceBuffers",
  31910. "sourceCapabilities",
  31911. "sourceFile",
  31912. "sourceIndex",
  31913. "sources",
  31914. "spacing",
  31915. "span",
  31916. "speak",
  31917. "speakAs",
  31918. "speaking",
  31919. "species",
  31920. "specified",
  31921. "specularConstant",
  31922. "specularExponent",
  31923. "speechSynthesis",
  31924. "speed",
  31925. "speedOfSound",
  31926. "spellcheck",
  31927. "splice",
  31928. "split",
  31929. "splitText",
  31930. "spreadMethod",
  31931. "sqrt",
  31932. "src",
  31933. "srcElement",
  31934. "srcFilter",
  31935. "srcObject",
  31936. "srcUrn",
  31937. "srcdoc",
  31938. "srclang",
  31939. "srcset",
  31940. "stack",
  31941. "stackTraceLimit",
  31942. "stacktrace",
  31943. "stageParameters",
  31944. "standalone",
  31945. "standby",
  31946. "start",
  31947. "startContainer",
  31948. "startIce",
  31949. "startMessages",
  31950. "startNotifications",
  31951. "startOffset",
  31952. "startProfiling",
  31953. "startRendering",
  31954. "startShark",
  31955. "startTime",
  31956. "startsWith",
  31957. "state",
  31958. "status",
  31959. "statusCode",
  31960. "statusMessage",
  31961. "statusText",
  31962. "statusbar",
  31963. "stdDeviationX",
  31964. "stdDeviationY",
  31965. "stencilFunc",
  31966. "stencilFuncSeparate",
  31967. "stencilMask",
  31968. "stencilMaskSeparate",
  31969. "stencilOp",
  31970. "stencilOpSeparate",
  31971. "step",
  31972. "stepDown",
  31973. "stepMismatch",
  31974. "stepUp",
  31975. "sticky",
  31976. "stitchTiles",
  31977. "stop",
  31978. "stop-color",
  31979. "stop-opacity",
  31980. "stopColor",
  31981. "stopImmediatePropagation",
  31982. "stopNotifications",
  31983. "stopOpacity",
  31984. "stopProfiling",
  31985. "stopPropagation",
  31986. "stopShark",
  31987. "stopped",
  31988. "storage",
  31989. "storageArea",
  31990. "storageName",
  31991. "storageStatus",
  31992. "store",
  31993. "storeSiteSpecificTrackingException",
  31994. "storeWebWideTrackingException",
  31995. "stpVersion",
  31996. "stream",
  31997. "streams",
  31998. "stretch",
  31999. "strike",
  32000. "string",
  32001. "stringValue",
  32002. "stringify",
  32003. "stroke",
  32004. "stroke-dasharray",
  32005. "stroke-dashoffset",
  32006. "stroke-linecap",
  32007. "stroke-linejoin",
  32008. "stroke-miterlimit",
  32009. "stroke-opacity",
  32010. "stroke-width",
  32011. "strokeDasharray",
  32012. "strokeDashoffset",
  32013. "strokeLinecap",
  32014. "strokeLinejoin",
  32015. "strokeMiterlimit",
  32016. "strokeOpacity",
  32017. "strokeRect",
  32018. "strokeStyle",
  32019. "strokeText",
  32020. "strokeWidth",
  32021. "style",
  32022. "styleFloat",
  32023. "styleMap",
  32024. "styleMedia",
  32025. "styleSheet",
  32026. "styleSheetSets",
  32027. "styleSheets",
  32028. "sub",
  32029. "subarray",
  32030. "subject",
  32031. "submit",
  32032. "submitFrame",
  32033. "submitter",
  32034. "subscribe",
  32035. "substr",
  32036. "substring",
  32037. "substringData",
  32038. "subtle",
  32039. "subtree",
  32040. "suffix",
  32041. "suffixes",
  32042. "summary",
  32043. "sup",
  32044. "supported",
  32045. "supportedContentEncodings",
  32046. "supportedEntryTypes",
  32047. "supports",
  32048. "supportsSession",
  32049. "surfaceScale",
  32050. "surroundContents",
  32051. "suspend",
  32052. "suspendRedraw",
  32053. "swapCache",
  32054. "swapNode",
  32055. "sweepFlag",
  32056. "symbols",
  32057. "sync",
  32058. "sysexEnabled",
  32059. "system",
  32060. "systemCode",
  32061. "systemId",
  32062. "systemLanguage",
  32063. "systemXDPI",
  32064. "systemYDPI",
  32065. "tBodies",
  32066. "tFoot",
  32067. "tHead",
  32068. "tabIndex",
  32069. "table",
  32070. "table-layout",
  32071. "tableLayout",
  32072. "tableValues",
  32073. "tag",
  32074. "tagName",
  32075. "tagUrn",
  32076. "tags",
  32077. "taintEnabled",
  32078. "takePhoto",
  32079. "takeRecords",
  32080. "tan",
  32081. "tangentialPressure",
  32082. "tanh",
  32083. "target",
  32084. "targetElement",
  32085. "targetRayMode",
  32086. "targetRaySpace",
  32087. "targetTouches",
  32088. "targetX",
  32089. "targetY",
  32090. "tcpType",
  32091. "tee",
  32092. "tel",
  32093. "terminate",
  32094. "test",
  32095. "texImage2D",
  32096. "texImage3D",
  32097. "texParameterf",
  32098. "texParameteri",
  32099. "texStorage2D",
  32100. "texStorage3D",
  32101. "texSubImage2D",
  32102. "texSubImage3D",
  32103. "text",
  32104. "text-align",
  32105. "text-align-last",
  32106. "text-anchor",
  32107. "text-combine-upright",
  32108. "text-decoration",
  32109. "text-decoration-color",
  32110. "text-decoration-line",
  32111. "text-decoration-skip-ink",
  32112. "text-decoration-style",
  32113. "text-decoration-thickness",
  32114. "text-emphasis",
  32115. "text-emphasis-color",
  32116. "text-emphasis-position",
  32117. "text-emphasis-style",
  32118. "text-indent",
  32119. "text-justify",
  32120. "text-orientation",
  32121. "text-overflow",
  32122. "text-rendering",
  32123. "text-shadow",
  32124. "text-transform",
  32125. "text-underline-offset",
  32126. "text-underline-position",
  32127. "textAlign",
  32128. "textAlignLast",
  32129. "textAnchor",
  32130. "textAutospace",
  32131. "textBaseline",
  32132. "textCombineUpright",
  32133. "textContent",
  32134. "textDecoration",
  32135. "textDecorationBlink",
  32136. "textDecorationColor",
  32137. "textDecorationLine",
  32138. "textDecorationLineThrough",
  32139. "textDecorationNone",
  32140. "textDecorationOverline",
  32141. "textDecorationSkipInk",
  32142. "textDecorationStyle",
  32143. "textDecorationThickness",
  32144. "textDecorationUnderline",
  32145. "textEmphasis",
  32146. "textEmphasisColor",
  32147. "textEmphasisPosition",
  32148. "textEmphasisStyle",
  32149. "textIndent",
  32150. "textJustify",
  32151. "textJustifyTrim",
  32152. "textKashida",
  32153. "textKashidaSpace",
  32154. "textLength",
  32155. "textOrientation",
  32156. "textOverflow",
  32157. "textRendering",
  32158. "textShadow",
  32159. "textTracks",
  32160. "textTransform",
  32161. "textUnderlineOffset",
  32162. "textUnderlinePosition",
  32163. "then",
  32164. "threadId",
  32165. "threshold",
  32166. "thresholds",
  32167. "tiltX",
  32168. "tiltY",
  32169. "time",
  32170. "timeEnd",
  32171. "timeLog",
  32172. "timeOrigin",
  32173. "timeRemaining",
  32174. "timeStamp",
  32175. "timecode",
  32176. "timeline",
  32177. "timelineTime",
  32178. "timeout",
  32179. "timestamp",
  32180. "timestampOffset",
  32181. "timing",
  32182. "title",
  32183. "to",
  32184. "toArray",
  32185. "toBlob",
  32186. "toDataURL",
  32187. "toDateString",
  32188. "toElement",
  32189. "toExponential",
  32190. "toFixed",
  32191. "toFloat32Array",
  32192. "toFloat64Array",
  32193. "toGMTString",
  32194. "toISOString",
  32195. "toJSON",
  32196. "toLocaleDateString",
  32197. "toLocaleFormat",
  32198. "toLocaleLowerCase",
  32199. "toLocaleString",
  32200. "toLocaleTimeString",
  32201. "toLocaleUpperCase",
  32202. "toLowerCase",
  32203. "toMatrix",
  32204. "toMethod",
  32205. "toPrecision",
  32206. "toPrimitive",
  32207. "toSdp",
  32208. "toSource",
  32209. "toStaticHTML",
  32210. "toString",
  32211. "toStringTag",
  32212. "toSum",
  32213. "toTimeString",
  32214. "toUTCString",
  32215. "toUpperCase",
  32216. "toggle",
  32217. "toggleAttribute",
  32218. "toggleLongPressEnabled",
  32219. "tone",
  32220. "toneBuffer",
  32221. "tooLong",
  32222. "tooShort",
  32223. "toolbar",
  32224. "top",
  32225. "topMargin",
  32226. "total",
  32227. "totalFrameDelay",
  32228. "totalVideoFrames",
  32229. "touch-action",
  32230. "touchAction",
  32231. "touched",
  32232. "touches",
  32233. "trace",
  32234. "track",
  32235. "trackVisibility",
  32236. "transaction",
  32237. "transactions",
  32238. "transceiver",
  32239. "transferControlToOffscreen",
  32240. "transferFromImageBitmap",
  32241. "transferImageBitmap",
  32242. "transferIn",
  32243. "transferOut",
  32244. "transferSize",
  32245. "transferToImageBitmap",
  32246. "transform",
  32247. "transform-box",
  32248. "transform-origin",
  32249. "transform-style",
  32250. "transformBox",
  32251. "transformFeedbackVaryings",
  32252. "transformOrigin",
  32253. "transformPoint",
  32254. "transformString",
  32255. "transformStyle",
  32256. "transformToDocument",
  32257. "transformToFragment",
  32258. "transition",
  32259. "transition-delay",
  32260. "transition-duration",
  32261. "transition-property",
  32262. "transition-timing-function",
  32263. "transitionDelay",
  32264. "transitionDuration",
  32265. "transitionProperty",
  32266. "transitionTimingFunction",
  32267. "translate",
  32268. "translateSelf",
  32269. "translationX",
  32270. "translationY",
  32271. "transport",
  32272. "trim",
  32273. "trimEnd",
  32274. "trimLeft",
  32275. "trimRight",
  32276. "trimStart",
  32277. "trueSpeed",
  32278. "trunc",
  32279. "truncate",
  32280. "trustedTypes",
  32281. "turn",
  32282. "twist",
  32283. "type",
  32284. "typeDetail",
  32285. "typeMismatch",
  32286. "typeMustMatch",
  32287. "types",
  32288. "u2f",
  32289. "ubound",
  32290. "uint16",
  32291. "uint32",
  32292. "uint8",
  32293. "uint8Clamped",
  32294. "undefined",
  32295. "unescape",
  32296. "uneval",
  32297. "unicode",
  32298. "unicode-bidi",
  32299. "unicodeBidi",
  32300. "unicodeRange",
  32301. "uniform1f",
  32302. "uniform1fv",
  32303. "uniform1i",
  32304. "uniform1iv",
  32305. "uniform1ui",
  32306. "uniform1uiv",
  32307. "uniform2f",
  32308. "uniform2fv",
  32309. "uniform2i",
  32310. "uniform2iv",
  32311. "uniform2ui",
  32312. "uniform2uiv",
  32313. "uniform3f",
  32314. "uniform3fv",
  32315. "uniform3i",
  32316. "uniform3iv",
  32317. "uniform3ui",
  32318. "uniform3uiv",
  32319. "uniform4f",
  32320. "uniform4fv",
  32321. "uniform4i",
  32322. "uniform4iv",
  32323. "uniform4ui",
  32324. "uniform4uiv",
  32325. "uniformBlockBinding",
  32326. "uniformMatrix2fv",
  32327. "uniformMatrix2x3fv",
  32328. "uniformMatrix2x4fv",
  32329. "uniformMatrix3fv",
  32330. "uniformMatrix3x2fv",
  32331. "uniformMatrix3x4fv",
  32332. "uniformMatrix4fv",
  32333. "uniformMatrix4x2fv",
  32334. "uniformMatrix4x3fv",
  32335. "unique",
  32336. "uniqueID",
  32337. "uniqueNumber",
  32338. "unit",
  32339. "unitType",
  32340. "units",
  32341. "unloadEventEnd",
  32342. "unloadEventStart",
  32343. "unlock",
  32344. "unmount",
  32345. "unobserve",
  32346. "unpause",
  32347. "unpauseAnimations",
  32348. "unreadCount",
  32349. "unregister",
  32350. "unregisterContentHandler",
  32351. "unregisterProtocolHandler",
  32352. "unscopables",
  32353. "unselectable",
  32354. "unshift",
  32355. "unsubscribe",
  32356. "unsuspendRedraw",
  32357. "unsuspendRedrawAll",
  32358. "unwatch",
  32359. "unwrapKey",
  32360. "upDegrees",
  32361. "upX",
  32362. "upY",
  32363. "upZ",
  32364. "update",
  32365. "updateCommands",
  32366. "updateIce",
  32367. "updateInterval",
  32368. "updatePlaybackRate",
  32369. "updateRenderState",
  32370. "updateSettings",
  32371. "updateTiming",
  32372. "updateViaCache",
  32373. "updateWith",
  32374. "updated",
  32375. "updating",
  32376. "upgrade",
  32377. "upload",
  32378. "uploadTotal",
  32379. "uploaded",
  32380. "upper",
  32381. "upperBound",
  32382. "upperOpen",
  32383. "uri",
  32384. "url",
  32385. "urn",
  32386. "urns",
  32387. "usages",
  32388. "usb",
  32389. "usbVersionMajor",
  32390. "usbVersionMinor",
  32391. "usbVersionSubminor",
  32392. "useCurrentView",
  32393. "useMap",
  32394. "useProgram",
  32395. "usedSpace",
  32396. "user-select",
  32397. "userActivation",
  32398. "userAgent",
  32399. "userChoice",
  32400. "userHandle",
  32401. "userHint",
  32402. "userLanguage",
  32403. "userSelect",
  32404. "userVisibleOnly",
  32405. "username",
  32406. "usernameFragment",
  32407. "utterance",
  32408. "uuid",
  32409. "v8BreakIterator",
  32410. "vAlign",
  32411. "vLink",
  32412. "valid",
  32413. "validate",
  32414. "validateProgram",
  32415. "validationMessage",
  32416. "validity",
  32417. "value",
  32418. "valueAsDate",
  32419. "valueAsNumber",
  32420. "valueAsString",
  32421. "valueInSpecifiedUnits",
  32422. "valueMissing",
  32423. "valueOf",
  32424. "valueText",
  32425. "valueType",
  32426. "values",
  32427. "variable",
  32428. "variant",
  32429. "variationSettings",
  32430. "vector-effect",
  32431. "vectorEffect",
  32432. "velocityAngular",
  32433. "velocityExpansion",
  32434. "velocityX",
  32435. "velocityY",
  32436. "vendor",
  32437. "vendorId",
  32438. "vendorSub",
  32439. "verify",
  32440. "version",
  32441. "vertexAttrib1f",
  32442. "vertexAttrib1fv",
  32443. "vertexAttrib2f",
  32444. "vertexAttrib2fv",
  32445. "vertexAttrib3f",
  32446. "vertexAttrib3fv",
  32447. "vertexAttrib4f",
  32448. "vertexAttrib4fv",
  32449. "vertexAttribDivisor",
  32450. "vertexAttribDivisorANGLE",
  32451. "vertexAttribI4i",
  32452. "vertexAttribI4iv",
  32453. "vertexAttribI4ui",
  32454. "vertexAttribI4uiv",
  32455. "vertexAttribIPointer",
  32456. "vertexAttribPointer",
  32457. "vertical",
  32458. "vertical-align",
  32459. "verticalAlign",
  32460. "verticalOverflow",
  32461. "vh",
  32462. "vibrate",
  32463. "vibrationActuator",
  32464. "videoBitsPerSecond",
  32465. "videoHeight",
  32466. "videoTracks",
  32467. "videoWidth",
  32468. "view",
  32469. "viewBox",
  32470. "viewBoxString",
  32471. "viewTarget",
  32472. "viewTargetString",
  32473. "viewport",
  32474. "viewportAnchorX",
  32475. "viewportAnchorY",
  32476. "viewportElement",
  32477. "views",
  32478. "violatedDirective",
  32479. "visibility",
  32480. "visibilityState",
  32481. "visible",
  32482. "visualViewport",
  32483. "vlinkColor",
  32484. "vmax",
  32485. "vmin",
  32486. "voice",
  32487. "voiceURI",
  32488. "volume",
  32489. "vrml",
  32490. "vspace",
  32491. "vw",
  32492. "w",
  32493. "wait",
  32494. "waitSync",
  32495. "waiting",
  32496. "wake",
  32497. "wakeLock",
  32498. "wand",
  32499. "warn",
  32500. "wasClean",
  32501. "wasDiscarded",
  32502. "watch",
  32503. "watchAvailability",
  32504. "watchPosition",
  32505. "webdriver",
  32506. "webkitAddKey",
  32507. "webkitAlignContent",
  32508. "webkitAlignItems",
  32509. "webkitAlignSelf",
  32510. "webkitAnimation",
  32511. "webkitAnimationDelay",
  32512. "webkitAnimationDirection",
  32513. "webkitAnimationDuration",
  32514. "webkitAnimationFillMode",
  32515. "webkitAnimationIterationCount",
  32516. "webkitAnimationName",
  32517. "webkitAnimationPlayState",
  32518. "webkitAnimationTimingFunction",
  32519. "webkitAppearance",
  32520. "webkitAudioContext",
  32521. "webkitAudioDecodedByteCount",
  32522. "webkitAudioPannerNode",
  32523. "webkitBackfaceVisibility",
  32524. "webkitBackground",
  32525. "webkitBackgroundAttachment",
  32526. "webkitBackgroundClip",
  32527. "webkitBackgroundColor",
  32528. "webkitBackgroundImage",
  32529. "webkitBackgroundOrigin",
  32530. "webkitBackgroundPosition",
  32531. "webkitBackgroundPositionX",
  32532. "webkitBackgroundPositionY",
  32533. "webkitBackgroundRepeat",
  32534. "webkitBackgroundSize",
  32535. "webkitBackingStorePixelRatio",
  32536. "webkitBorderBottomLeftRadius",
  32537. "webkitBorderBottomRightRadius",
  32538. "webkitBorderImage",
  32539. "webkitBorderImageOutset",
  32540. "webkitBorderImageRepeat",
  32541. "webkitBorderImageSlice",
  32542. "webkitBorderImageSource",
  32543. "webkitBorderImageWidth",
  32544. "webkitBorderRadius",
  32545. "webkitBorderTopLeftRadius",
  32546. "webkitBorderTopRightRadius",
  32547. "webkitBoxAlign",
  32548. "webkitBoxDirection",
  32549. "webkitBoxFlex",
  32550. "webkitBoxOrdinalGroup",
  32551. "webkitBoxOrient",
  32552. "webkitBoxPack",
  32553. "webkitBoxShadow",
  32554. "webkitBoxSizing",
  32555. "webkitCancelAnimationFrame",
  32556. "webkitCancelFullScreen",
  32557. "webkitCancelKeyRequest",
  32558. "webkitCancelRequestAnimationFrame",
  32559. "webkitClearResourceTimings",
  32560. "webkitClosedCaptionsVisible",
  32561. "webkitConvertPointFromNodeToPage",
  32562. "webkitConvertPointFromPageToNode",
  32563. "webkitCreateShadowRoot",
  32564. "webkitCurrentFullScreenElement",
  32565. "webkitCurrentPlaybackTargetIsWireless",
  32566. "webkitDecodedFrameCount",
  32567. "webkitDirectionInvertedFromDevice",
  32568. "webkitDisplayingFullscreen",
  32569. "webkitDroppedFrameCount",
  32570. "webkitEnterFullScreen",
  32571. "webkitEnterFullscreen",
  32572. "webkitEntries",
  32573. "webkitExitFullScreen",
  32574. "webkitExitFullscreen",
  32575. "webkitExitPointerLock",
  32576. "webkitFilter",
  32577. "webkitFlex",
  32578. "webkitFlexBasis",
  32579. "webkitFlexDirection",
  32580. "webkitFlexFlow",
  32581. "webkitFlexGrow",
  32582. "webkitFlexShrink",
  32583. "webkitFlexWrap",
  32584. "webkitFullScreenKeyboardInputAllowed",
  32585. "webkitFullscreenElement",
  32586. "webkitFullscreenEnabled",
  32587. "webkitGenerateKeyRequest",
  32588. "webkitGetAsEntry",
  32589. "webkitGetDatabaseNames",
  32590. "webkitGetEntries",
  32591. "webkitGetEntriesByName",
  32592. "webkitGetEntriesByType",
  32593. "webkitGetFlowByName",
  32594. "webkitGetGamepads",
  32595. "webkitGetImageDataHD",
  32596. "webkitGetNamedFlows",
  32597. "webkitGetRegionFlowRanges",
  32598. "webkitGetUserMedia",
  32599. "webkitHasClosedCaptions",
  32600. "webkitHidden",
  32601. "webkitIDBCursor",
  32602. "webkitIDBDatabase",
  32603. "webkitIDBDatabaseError",
  32604. "webkitIDBDatabaseException",
  32605. "webkitIDBFactory",
  32606. "webkitIDBIndex",
  32607. "webkitIDBKeyRange",
  32608. "webkitIDBObjectStore",
  32609. "webkitIDBRequest",
  32610. "webkitIDBTransaction",
  32611. "webkitImageSmoothingEnabled",
  32612. "webkitIndexedDB",
  32613. "webkitInitMessageEvent",
  32614. "webkitIsFullScreen",
  32615. "webkitJustifyContent",
  32616. "webkitKeys",
  32617. "webkitLineClamp",
  32618. "webkitLineDashOffset",
  32619. "webkitLockOrientation",
  32620. "webkitMask",
  32621. "webkitMaskClip",
  32622. "webkitMaskComposite",
  32623. "webkitMaskImage",
  32624. "webkitMaskOrigin",
  32625. "webkitMaskPosition",
  32626. "webkitMaskPositionX",
  32627. "webkitMaskPositionY",
  32628. "webkitMaskRepeat",
  32629. "webkitMaskSize",
  32630. "webkitMatchesSelector",
  32631. "webkitMediaStream",
  32632. "webkitNotifications",
  32633. "webkitOfflineAudioContext",
  32634. "webkitOrder",
  32635. "webkitOrientation",
  32636. "webkitPeerConnection00",
  32637. "webkitPersistentStorage",
  32638. "webkitPerspective",
  32639. "webkitPerspectiveOrigin",
  32640. "webkitPointerLockElement",
  32641. "webkitPostMessage",
  32642. "webkitPreservesPitch",
  32643. "webkitPutImageDataHD",
  32644. "webkitRTCPeerConnection",
  32645. "webkitRegionOverset",
  32646. "webkitRelativePath",
  32647. "webkitRequestAnimationFrame",
  32648. "webkitRequestFileSystem",
  32649. "webkitRequestFullScreen",
  32650. "webkitRequestFullscreen",
  32651. "webkitRequestPointerLock",
  32652. "webkitResolveLocalFileSystemURL",
  32653. "webkitSetMediaKeys",
  32654. "webkitSetResourceTimingBufferSize",
  32655. "webkitShadowRoot",
  32656. "webkitShowPlaybackTargetPicker",
  32657. "webkitSlice",
  32658. "webkitSpeechGrammar",
  32659. "webkitSpeechGrammarList",
  32660. "webkitSpeechRecognition",
  32661. "webkitSpeechRecognitionError",
  32662. "webkitSpeechRecognitionEvent",
  32663. "webkitStorageInfo",
  32664. "webkitSupportsFullscreen",
  32665. "webkitTemporaryStorage",
  32666. "webkitTextFillColor",
  32667. "webkitTextSizeAdjust",
  32668. "webkitTextStroke",
  32669. "webkitTextStrokeColor",
  32670. "webkitTextStrokeWidth",
  32671. "webkitTransform",
  32672. "webkitTransformOrigin",
  32673. "webkitTransformStyle",
  32674. "webkitTransition",
  32675. "webkitTransitionDelay",
  32676. "webkitTransitionDuration",
  32677. "webkitTransitionProperty",
  32678. "webkitTransitionTimingFunction",
  32679. "webkitURL",
  32680. "webkitUnlockOrientation",
  32681. "webkitUserSelect",
  32682. "webkitVideoDecodedByteCount",
  32683. "webkitVisibilityState",
  32684. "webkitWirelessVideoPlaybackDisabled",
  32685. "webkitdirectory",
  32686. "webkitdropzone",
  32687. "webstore",
  32688. "weight",
  32689. "whatToShow",
  32690. "wheelDelta",
  32691. "wheelDeltaX",
  32692. "wheelDeltaY",
  32693. "whenDefined",
  32694. "which",
  32695. "white-space",
  32696. "whiteSpace",
  32697. "wholeText",
  32698. "widows",
  32699. "width",
  32700. "will-change",
  32701. "willChange",
  32702. "willValidate",
  32703. "window",
  32704. "withCredentials",
  32705. "word-break",
  32706. "word-spacing",
  32707. "word-wrap",
  32708. "wordBreak",
  32709. "wordSpacing",
  32710. "wordWrap",
  32711. "workerStart",
  32712. "wrap",
  32713. "wrapKey",
  32714. "writable",
  32715. "writableAuxiliaries",
  32716. "write",
  32717. "writeText",
  32718. "writeValue",
  32719. "writeWithoutResponse",
  32720. "writeln",
  32721. "writing-mode",
  32722. "writingMode",
  32723. "x",
  32724. "x1",
  32725. "x2",
  32726. "xChannelSelector",
  32727. "xmlEncoding",
  32728. "xmlStandalone",
  32729. "xmlVersion",
  32730. "xmlbase",
  32731. "xmllang",
  32732. "xmlspace",
  32733. "xor",
  32734. "xr",
  32735. "y",
  32736. "y1",
  32737. "y2",
  32738. "yChannelSelector",
  32739. "yandex",
  32740. "z",
  32741. "z-index",
  32742. "zIndex",
  32743. "zoom",
  32744. "zoomAndPan",
  32745. "zoomRectScreen",
  32746. ];
  32747. /***********************************************************************
  32748. A JavaScript tokenizer / parser / beautifier / compressor.
  32749. https://github.com/mishoo/UglifyJS2
  32750. -------------------------------- (C) ---------------------------------
  32751. Author: Mihai Bazon
  32752. <mihai.bazon@gmail.com>
  32753. http://mihai.bazon.net/blog
  32754. Distributed under the BSD license:
  32755. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  32756. Redistribution and use in source and binary forms, with or without
  32757. modification, are permitted provided that the following conditions
  32758. are met:
  32759. * Redistributions of source code must retain the above
  32760. copyright notice, this list of conditions and the following
  32761. disclaimer.
  32762. * Redistributions in binary form must reproduce the above
  32763. copyright notice, this list of conditions and the following
  32764. disclaimer in the documentation and/or other materials
  32765. provided with the distribution.
  32766. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  32767. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32768. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  32769. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  32770. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  32771. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  32772. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  32773. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32774. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  32775. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  32776. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32777. SUCH DAMAGE.
  32778. ***********************************************************************/
  32779. function find_builtins(reserved) {
  32780. domprops.forEach(add);
  32781. // Compatibility fix for some standard defined globals not defined on every js environment
  32782. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  32783. var objects = {};
  32784. var global_ref = typeof commonjsGlobal === "object" ? commonjsGlobal : self;
  32785. new_globals.forEach(function (new_global) {
  32786. objects[new_global] = global_ref[new_global] || new Function();
  32787. });
  32788. [
  32789. "null",
  32790. "true",
  32791. "false",
  32792. "NaN",
  32793. "Infinity",
  32794. "-Infinity",
  32795. "undefined",
  32796. ].forEach(add);
  32797. [ Object, Array, Function, Number,
  32798. String, Boolean, Error, Math,
  32799. Date, RegExp, objects.Symbol, ArrayBuffer,
  32800. DataView, decodeURI, decodeURIComponent,
  32801. encodeURI, encodeURIComponent, eval, EvalError,
  32802. Float32Array, Float64Array, Int8Array, Int16Array,
  32803. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  32804. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  32805. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  32806. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  32807. objects.WeakMap, objects.WeakSet
  32808. ].forEach(function(ctor) {
  32809. Object.getOwnPropertyNames(ctor).map(add);
  32810. if (ctor.prototype) {
  32811. Object.getOwnPropertyNames(ctor.prototype).map(add);
  32812. }
  32813. });
  32814. function add(name) {
  32815. reserved.add(name);
  32816. }
  32817. }
  32818. function reserve_quoted_keys(ast, reserved) {
  32819. function add(name) {
  32820. push_uniq(reserved, name);
  32821. }
  32822. ast.walk(new TreeWalker(function(node) {
  32823. if (node instanceof AST_ObjectKeyVal && node.quote) {
  32824. add(node.key);
  32825. } else if (node instanceof AST_ObjectProperty && node.quote) {
  32826. add(node.key.name);
  32827. } else if (node instanceof AST_Sub) {
  32828. addStrings(node.property, add);
  32829. }
  32830. }));
  32831. }
  32832. function addStrings(node, add) {
  32833. node.walk(new TreeWalker(function(node) {
  32834. if (node instanceof AST_Sequence) {
  32835. addStrings(node.tail_node(), add);
  32836. } else if (node instanceof AST_String) {
  32837. add(node.value);
  32838. } else if (node instanceof AST_Conditional) {
  32839. addStrings(node.consequent, add);
  32840. addStrings(node.alternative, add);
  32841. }
  32842. return true;
  32843. }));
  32844. }
  32845. function mangle_properties(ast, options) {
  32846. options = defaults(options, {
  32847. builtins: false,
  32848. cache: null,
  32849. debug: false,
  32850. keep_quoted: false,
  32851. only_cache: false,
  32852. regex: null,
  32853. reserved: null,
  32854. undeclared: false,
  32855. }, true);
  32856. var reserved_option = options.reserved;
  32857. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  32858. var reserved = new Set(reserved_option);
  32859. if (!options.builtins) find_builtins(reserved);
  32860. var cname = -1;
  32861. var cprivate = -1;
  32862. var cache;
  32863. var private_cache = new Map();
  32864. if (options.cache) {
  32865. cache = options.cache.props;
  32866. cache.forEach(function(mangled_name) {
  32867. reserved.add(mangled_name);
  32868. });
  32869. } else {
  32870. cache = new Map();
  32871. }
  32872. var regex = options.regex && new RegExp(options.regex);
  32873. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  32874. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  32875. // the same as passing an empty string.
  32876. var debug = options.debug !== false;
  32877. var debug_name_suffix;
  32878. if (debug) {
  32879. debug_name_suffix = (options.debug === true ? "" : options.debug);
  32880. }
  32881. var names_to_mangle = new Set();
  32882. var unmangleable = new Set();
  32883. var private_properties = new Set();
  32884. var keep_quoted_strict = options.keep_quoted === "strict";
  32885. // step 1: find candidates to mangle
  32886. ast.walk(new TreeWalker(function(node) {
  32887. if (
  32888. node instanceof AST_ClassPrivateProperty
  32889. || node instanceof AST_PrivateMethod
  32890. ) {
  32891. private_properties.add(node.key.name);
  32892. } else if (node instanceof AST_DotHash) {
  32893. private_properties.add(node.property);
  32894. } else if (node instanceof AST_ObjectKeyVal) {
  32895. if (typeof node.key == "string" &&
  32896. (!keep_quoted_strict || !node.quote)) {
  32897. add(node.key);
  32898. }
  32899. } else if (node instanceof AST_ObjectProperty) {
  32900. // setter or getter, since KeyVal is handled above
  32901. if (!keep_quoted_strict || !node.key.end.quote) {
  32902. add(node.key.name);
  32903. }
  32904. } else if (node instanceof AST_Dot) {
  32905. var declared = !!options.undeclared;
  32906. if (!declared) {
  32907. var root = node;
  32908. while (root.expression) {
  32909. root = root.expression;
  32910. }
  32911. declared = !(root.thedef && root.thedef.undeclared);
  32912. }
  32913. if (declared &&
  32914. (!keep_quoted_strict || !node.quote)) {
  32915. add(node.property);
  32916. }
  32917. } else if (node instanceof AST_Sub) {
  32918. if (!keep_quoted_strict) {
  32919. addStrings(node.property, add);
  32920. }
  32921. } else if (node instanceof AST_Call
  32922. && node.expression.print_to_string() == "Object.defineProperty") {
  32923. addStrings(node.args[1], add);
  32924. } else if (node instanceof AST_Binary && node.operator === "in") {
  32925. addStrings(node.left, add);
  32926. }
  32927. }));
  32928. // step 2: transform the tree, renaming properties
  32929. return ast.transform(new TreeTransformer(function(node) {
  32930. if (
  32931. node instanceof AST_ClassPrivateProperty
  32932. || node instanceof AST_PrivateMethod
  32933. ) {
  32934. node.key.name = mangle_private(node.key.name);
  32935. } else if (node instanceof AST_DotHash) {
  32936. node.property = mangle_private(node.property);
  32937. } else if (node instanceof AST_ObjectKeyVal) {
  32938. if (typeof node.key == "string" &&
  32939. (!keep_quoted_strict || !node.quote)) {
  32940. node.key = mangle(node.key);
  32941. }
  32942. } else if (node instanceof AST_ObjectProperty) {
  32943. // setter, getter, method or class field
  32944. if (!keep_quoted_strict || !node.key.end.quote) {
  32945. node.key.name = mangle(node.key.name);
  32946. }
  32947. } else if (node instanceof AST_Dot) {
  32948. if (!keep_quoted_strict || !node.quote) {
  32949. node.property = mangle(node.property);
  32950. }
  32951. } else if (!options.keep_quoted && node instanceof AST_Sub) {
  32952. node.property = mangleStrings(node.property);
  32953. } else if (node instanceof AST_Call
  32954. && node.expression.print_to_string() == "Object.defineProperty") {
  32955. node.args[1] = mangleStrings(node.args[1]);
  32956. } else if (node instanceof AST_Binary && node.operator === "in") {
  32957. node.left = mangleStrings(node.left);
  32958. }
  32959. }));
  32960. // only function declarations after this line
  32961. function can_mangle(name) {
  32962. if (unmangleable.has(name)) return false;
  32963. if (reserved.has(name)) return false;
  32964. if (options.only_cache) {
  32965. return cache.has(name);
  32966. }
  32967. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  32968. return true;
  32969. }
  32970. function should_mangle(name) {
  32971. if (regex && !regex.test(name)) return false;
  32972. if (reserved.has(name)) return false;
  32973. return cache.has(name)
  32974. || names_to_mangle.has(name);
  32975. }
  32976. function add(name) {
  32977. if (can_mangle(name))
  32978. names_to_mangle.add(name);
  32979. if (!should_mangle(name)) {
  32980. unmangleable.add(name);
  32981. }
  32982. }
  32983. function mangle(name) {
  32984. if (!should_mangle(name)) {
  32985. return name;
  32986. }
  32987. var mangled = cache.get(name);
  32988. if (!mangled) {
  32989. if (debug) {
  32990. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  32991. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  32992. if (can_mangle(debug_mangled)) {
  32993. mangled = debug_mangled;
  32994. }
  32995. }
  32996. // either debug mode is off, or it is on and we could not use the mangled name
  32997. if (!mangled) {
  32998. do {
  32999. mangled = base54(++cname);
  33000. } while (!can_mangle(mangled));
  33001. }
  33002. cache.set(name, mangled);
  33003. }
  33004. return mangled;
  33005. }
  33006. function mangle_private(name) {
  33007. let mangled = private_cache.get(name);
  33008. if (!mangled) {
  33009. mangled = base54(++cprivate);
  33010. private_cache.set(name, mangled);
  33011. }
  33012. return mangled;
  33013. }
  33014. function mangleStrings(node) {
  33015. return node.transform(new TreeTransformer(function(node) {
  33016. if (node instanceof AST_Sequence) {
  33017. var last = node.expressions.length - 1;
  33018. node.expressions[last] = mangleStrings(node.expressions[last]);
  33019. } else if (node instanceof AST_String) {
  33020. node.value = mangle(node.value);
  33021. } else if (node instanceof AST_Conditional) {
  33022. node.consequent = mangleStrings(node.consequent);
  33023. node.alternative = mangleStrings(node.alternative);
  33024. }
  33025. return node;
  33026. }));
  33027. }
  33028. }
  33029. var to_ascii = typeof atob == "undefined" ? function(b64) {
  33030. return Buffer.from(b64, "base64").toString();
  33031. } : atob;
  33032. var to_base64 = typeof btoa == "undefined" ? function(str) {
  33033. return Buffer.from(str).toString("base64");
  33034. } : btoa;
  33035. function read_source_map(code) {
  33036. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  33037. if (!match) {
  33038. console.warn("inline source map not found");
  33039. return null;
  33040. }
  33041. return to_ascii(match[2]);
  33042. }
  33043. function set_shorthand(name, options, keys) {
  33044. if (options[name]) {
  33045. keys.forEach(function(key) {
  33046. if (options[key]) {
  33047. if (typeof options[key] != "object") options[key] = {};
  33048. if (!(name in options[key])) options[key][name] = options[name];
  33049. }
  33050. });
  33051. }
  33052. }
  33053. function init_cache(cache) {
  33054. if (!cache) return;
  33055. if (!("props" in cache)) {
  33056. cache.props = new Map();
  33057. } else if (!(cache.props instanceof Map)) {
  33058. cache.props = map_from_object(cache.props);
  33059. }
  33060. }
  33061. function cache_to_json(cache) {
  33062. return {
  33063. props: map_to_object(cache.props)
  33064. };
  33065. }
  33066. async function minify(files, options) {
  33067. options = defaults(options, {
  33068. compress: {},
  33069. ecma: undefined,
  33070. enclose: false,
  33071. ie8: false,
  33072. keep_classnames: undefined,
  33073. keep_fnames: false,
  33074. mangle: {},
  33075. module: false,
  33076. nameCache: null,
  33077. output: null,
  33078. format: null,
  33079. parse: {},
  33080. rename: undefined,
  33081. safari10: false,
  33082. sourceMap: false,
  33083. spidermonkey: false,
  33084. timings: false,
  33085. toplevel: false,
  33086. warnings: false,
  33087. wrap: false,
  33088. }, true);
  33089. var timings = options.timings && {
  33090. start: Date.now()
  33091. };
  33092. if (options.keep_classnames === undefined) {
  33093. options.keep_classnames = options.keep_fnames;
  33094. }
  33095. if (options.rename === undefined) {
  33096. options.rename = options.compress && options.mangle;
  33097. }
  33098. if (options.output && options.format) {
  33099. throw new Error("Please only specify either output or format option, preferrably format.");
  33100. }
  33101. options.format = options.format || options.output || {};
  33102. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  33103. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  33104. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  33105. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  33106. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  33107. set_shorthand("safari10", options, [ "mangle", "format" ]);
  33108. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  33109. set_shorthand("warnings", options, [ "compress" ]); // legacy
  33110. var quoted_props;
  33111. if (options.mangle) {
  33112. options.mangle = defaults(options.mangle, {
  33113. cache: options.nameCache && (options.nameCache.vars || {}),
  33114. eval: false,
  33115. ie8: false,
  33116. keep_classnames: false,
  33117. keep_fnames: false,
  33118. module: false,
  33119. properties: false,
  33120. reserved: [],
  33121. safari10: false,
  33122. toplevel: false,
  33123. }, true);
  33124. if (options.mangle.properties) {
  33125. if (typeof options.mangle.properties != "object") {
  33126. options.mangle.properties = {};
  33127. }
  33128. if (options.mangle.properties.keep_quoted) {
  33129. quoted_props = options.mangle.properties.reserved;
  33130. if (!Array.isArray(quoted_props)) quoted_props = [];
  33131. options.mangle.properties.reserved = quoted_props;
  33132. }
  33133. if (options.nameCache && !("cache" in options.mangle.properties)) {
  33134. options.mangle.properties.cache = options.nameCache.props || {};
  33135. }
  33136. }
  33137. init_cache(options.mangle.cache);
  33138. init_cache(options.mangle.properties.cache);
  33139. }
  33140. if (options.sourceMap) {
  33141. options.sourceMap = defaults(options.sourceMap, {
  33142. asObject: false,
  33143. content: null,
  33144. filename: null,
  33145. includeSources: false,
  33146. root: null,
  33147. url: null,
  33148. }, true);
  33149. }
  33150. if (timings) timings.parse = Date.now();
  33151. var toplevel;
  33152. if (files instanceof AST_Toplevel) {
  33153. toplevel = files;
  33154. } else {
  33155. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  33156. files = [ files ];
  33157. }
  33158. options.parse = options.parse || {};
  33159. options.parse.toplevel = null;
  33160. if (options.parse.spidermonkey) {
  33161. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  33162. if (!toplevel) return files[name];
  33163. toplevel.body = toplevel.body.concat(files[name].body);
  33164. return toplevel;
  33165. }, null));
  33166. } else {
  33167. delete options.parse.spidermonkey;
  33168. for (var name in files) if (HOP(files, name)) {
  33169. options.parse.filename = name;
  33170. options.parse.toplevel = parse(files[name], options.parse);
  33171. if (options.sourceMap && options.sourceMap.content == "inline") {
  33172. if (Object.keys(files).length > 1)
  33173. throw new Error("inline source map only works with singular input");
  33174. options.sourceMap.content = read_source_map(files[name]);
  33175. }
  33176. }
  33177. }
  33178. toplevel = options.parse.toplevel;
  33179. }
  33180. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  33181. reserve_quoted_keys(toplevel, quoted_props);
  33182. }
  33183. if (options.wrap) {
  33184. toplevel = toplevel.wrap_commonjs(options.wrap);
  33185. }
  33186. if (options.enclose) {
  33187. toplevel = toplevel.wrap_enclose(options.enclose);
  33188. }
  33189. if (timings) timings.rename = Date.now();
  33190. if (timings) timings.compress = Date.now();
  33191. if (options.compress) {
  33192. toplevel = new Compressor(options.compress, {
  33193. mangle_options: options.mangle
  33194. }).compress(toplevel);
  33195. }
  33196. if (timings) timings.scope = Date.now();
  33197. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  33198. if (timings) timings.mangle = Date.now();
  33199. if (options.mangle) {
  33200. base54.reset();
  33201. toplevel.compute_char_frequency(options.mangle);
  33202. toplevel.mangle_names(options.mangle);
  33203. }
  33204. if (timings) timings.properties = Date.now();
  33205. if (options.mangle && options.mangle.properties) {
  33206. toplevel = mangle_properties(toplevel, options.mangle.properties);
  33207. }
  33208. if (timings) timings.format = Date.now();
  33209. var result = {};
  33210. if (options.format.ast) {
  33211. result.ast = toplevel;
  33212. }
  33213. if (options.format.spidermonkey) {
  33214. result.ast = toplevel.to_mozilla_ast();
  33215. }
  33216. if (!HOP(options.format, "code") || options.format.code) {
  33217. if (options.sourceMap) {
  33218. options.format.source_map = await SourceMap({
  33219. file: options.sourceMap.filename,
  33220. orig: options.sourceMap.content,
  33221. root: options.sourceMap.root
  33222. });
  33223. if (options.sourceMap.includeSources) {
  33224. if (files instanceof AST_Toplevel) {
  33225. throw new Error("original source content unavailable");
  33226. } else for (var name in files) if (HOP(files, name)) {
  33227. options.format.source_map.get().setSourceContent(name, files[name]);
  33228. }
  33229. }
  33230. }
  33231. delete options.format.ast;
  33232. delete options.format.code;
  33233. delete options.format.spidermonkey;
  33234. var stream = OutputStream(options.format);
  33235. toplevel.print(stream);
  33236. result.code = stream.get();
  33237. if (options.sourceMap) {
  33238. if(options.sourceMap.asObject) {
  33239. result.map = options.format.source_map.get().toJSON();
  33240. } else {
  33241. result.map = options.format.source_map.toString();
  33242. }
  33243. if (options.sourceMap.url == "inline") {
  33244. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  33245. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  33246. } else if (options.sourceMap.url) {
  33247. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  33248. }
  33249. }
  33250. }
  33251. if (options.nameCache && options.mangle) {
  33252. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  33253. if (options.mangle.properties && options.mangle.properties.cache) {
  33254. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  33255. }
  33256. }
  33257. if (options.format && options.format.source_map) {
  33258. options.format.source_map.destroy();
  33259. }
  33260. if (timings) {
  33261. timings.end = Date.now();
  33262. result.timings = {
  33263. parse: 1e-3 * (timings.rename - timings.parse),
  33264. rename: 1e-3 * (timings.compress - timings.rename),
  33265. compress: 1e-3 * (timings.scope - timings.compress),
  33266. scope: 1e-3 * (timings.mangle - timings.scope),
  33267. mangle: 1e-3 * (timings.properties - timings.mangle),
  33268. properties: 1e-3 * (timings.format - timings.properties),
  33269. format: 1e-3 * (timings.end - timings.format),
  33270. total: 1e-3 * (timings.end - timings.start)
  33271. };
  33272. }
  33273. return result;
  33274. }
  33275. async function run_cli({ program, packageJson, fs, path }) {
  33276. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  33277. var files = {};
  33278. var options = {
  33279. compress: false,
  33280. mangle: false
  33281. };
  33282. const default_options = await _default_options();
  33283. program.version(packageJson.name + " " + packageJson.version);
  33284. program.parseArgv = program.parse;
  33285. program.parse = undefined;
  33286. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  33287. else if (process.argv.includes("options")) program.helpInformation = function() {
  33288. var text = [];
  33289. for (var option in default_options) {
  33290. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  33291. text.push(format_object(default_options[option]));
  33292. text.push("");
  33293. }
  33294. return text.join("\n");
  33295. };
  33296. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  33297. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  33298. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  33299. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  33300. program.option("-f, --format [options]", "Format options.", parse_js());
  33301. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  33302. program.option("-o, --output <file>", "Output file (default STDOUT).");
  33303. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  33304. program.option("--config-file <file>", "Read minify() options from JSON file.");
  33305. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  33306. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  33307. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  33308. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  33309. program.option("--keep-classnames", "Do not mangle/drop class names.");
  33310. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  33311. program.option("--module", "Input is an ES6 module");
  33312. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  33313. program.option("--rename", "Force symbol expansion.");
  33314. program.option("--no-rename", "Disable symbol expansion.");
  33315. program.option("--safari10", "Support non-standard Safari 10.");
  33316. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  33317. program.option("--timings", "Display operations run time on STDERR.");
  33318. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  33319. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  33320. program.arguments("[files...]").parseArgv(process.argv);
  33321. if (program.configFile) {
  33322. options = JSON.parse(read_file(program.configFile));
  33323. }
  33324. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  33325. fatal("ERROR: cannot write source map to STDOUT");
  33326. }
  33327. [
  33328. "compress",
  33329. "enclose",
  33330. "ie8",
  33331. "mangle",
  33332. "module",
  33333. "safari10",
  33334. "sourceMap",
  33335. "toplevel",
  33336. "wrap"
  33337. ].forEach(function(name) {
  33338. if (name in program) {
  33339. options[name] = program[name];
  33340. }
  33341. });
  33342. if ("ecma" in program) {
  33343. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  33344. const ecma = program.ecma | 0;
  33345. if (ecma > 5 && ecma < 2015)
  33346. options.ecma = ecma + 2009;
  33347. else
  33348. options.ecma = ecma;
  33349. }
  33350. if (program.format || program.beautify) {
  33351. const chosenOption = program.format || program.beautify;
  33352. options.format = typeof chosenOption === "object" ? chosenOption : {};
  33353. }
  33354. if (program.comments) {
  33355. if (typeof options.format != "object") options.format = {};
  33356. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  33357. }
  33358. if (program.define) {
  33359. if (typeof options.compress != "object") options.compress = {};
  33360. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  33361. for (var expr in program.define) {
  33362. options.compress.global_defs[expr] = program.define[expr];
  33363. }
  33364. }
  33365. if (program.keepClassnames) {
  33366. options.keep_classnames = true;
  33367. }
  33368. if (program.keepFnames) {
  33369. options.keep_fnames = true;
  33370. }
  33371. if (program.mangleProps) {
  33372. if (program.mangleProps.domprops) {
  33373. delete program.mangleProps.domprops;
  33374. } else {
  33375. if (typeof program.mangleProps != "object") program.mangleProps = {};
  33376. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  33377. }
  33378. if (typeof options.mangle != "object") options.mangle = {};
  33379. options.mangle.properties = program.mangleProps;
  33380. }
  33381. if (program.nameCache) {
  33382. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  33383. }
  33384. if (program.output == "ast") {
  33385. options.format = {
  33386. ast: true,
  33387. code: false
  33388. };
  33389. }
  33390. if (program.parse) {
  33391. if (!program.parse.acorn && !program.parse.spidermonkey) {
  33392. options.parse = program.parse;
  33393. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  33394. fatal("ERROR: inline source map only works with built-in parser");
  33395. }
  33396. }
  33397. if (~program.rawArgs.indexOf("--rename")) {
  33398. options.rename = true;
  33399. } else if (!program.rename) {
  33400. options.rename = false;
  33401. }
  33402. let convert_path = name => name;
  33403. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  33404. convert_path = function() {
  33405. var base = program.sourceMap.base;
  33406. delete options.sourceMap.base;
  33407. return function(name) {
  33408. return path.relative(base, name);
  33409. };
  33410. }();
  33411. }
  33412. let filesList;
  33413. if (options.files && options.files.length) {
  33414. filesList = options.files;
  33415. delete options.files;
  33416. } else if (program.args.length) {
  33417. filesList = program.args;
  33418. }
  33419. if (filesList) {
  33420. simple_glob(filesList).forEach(function(name) {
  33421. files[convert_path(name)] = read_file(name);
  33422. });
  33423. } else {
  33424. await new Promise((resolve) => {
  33425. var chunks = [];
  33426. process.stdin.setEncoding("utf8");
  33427. process.stdin.on("data", function(chunk) {
  33428. chunks.push(chunk);
  33429. }).on("end", function() {
  33430. files = [ chunks.join("") ];
  33431. resolve();
  33432. });
  33433. process.stdin.resume();
  33434. });
  33435. }
  33436. await run_cli();
  33437. function convert_ast(fn) {
  33438. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  33439. }
  33440. async function run_cli() {
  33441. var content = program.sourceMap && program.sourceMap.content;
  33442. if (content && content !== "inline") {
  33443. options.sourceMap.content = read_file(content, content);
  33444. }
  33445. if (program.timings) options.timings = true;
  33446. try {
  33447. if (program.parse) {
  33448. if (program.parse.acorn) {
  33449. files = convert_ast(function(toplevel, name) {
  33450. return acorn.exports.parse(files[name], {
  33451. ecmaVersion: 2018,
  33452. locations: true,
  33453. program: toplevel,
  33454. sourceFile: name,
  33455. sourceType: options.module || program.parse.module ? "module" : "script"
  33456. });
  33457. });
  33458. } else if (program.parse.spidermonkey) {
  33459. files = convert_ast(function(toplevel, name) {
  33460. var obj = JSON.parse(files[name]);
  33461. if (!toplevel) return obj;
  33462. toplevel.body = toplevel.body.concat(obj.body);
  33463. return toplevel;
  33464. });
  33465. }
  33466. }
  33467. } catch (ex) {
  33468. fatal(ex);
  33469. }
  33470. let result;
  33471. try {
  33472. result = await minify(files, options);
  33473. } catch (ex) {
  33474. if (ex.name == "SyntaxError") {
  33475. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  33476. var col = ex.col;
  33477. var lines = files[ex.filename].split(/\r?\n/);
  33478. var line = lines[ex.line - 1];
  33479. if (!line && !col) {
  33480. line = lines[ex.line - 2];
  33481. col = line.length;
  33482. }
  33483. if (line) {
  33484. var limit = 70;
  33485. if (col > limit) {
  33486. line = line.slice(col - limit);
  33487. col = limit;
  33488. }
  33489. print_error(line.slice(0, 80));
  33490. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  33491. }
  33492. }
  33493. if (ex.defs) {
  33494. print_error("Supported options:");
  33495. print_error(format_object(ex.defs));
  33496. }
  33497. fatal(ex);
  33498. return;
  33499. }
  33500. if (program.output == "ast") {
  33501. if (!options.compress && !options.mangle) {
  33502. result.ast.figure_out_scope({});
  33503. }
  33504. console.log(JSON.stringify(result.ast, function(key, value) {
  33505. if (value) switch (key) {
  33506. case "thedef":
  33507. return symdef(value);
  33508. case "enclosed":
  33509. return value.length ? value.map(symdef) : undefined;
  33510. case "variables":
  33511. case "globals":
  33512. return value.size ? collect_from_map(value, symdef) : undefined;
  33513. }
  33514. if (skip_keys.has(key)) return;
  33515. if (value instanceof AST_Token) return;
  33516. if (value instanceof Map) return;
  33517. if (value instanceof AST_Node) {
  33518. var result = {
  33519. _class: "AST_" + value.TYPE
  33520. };
  33521. if (value.block_scope) {
  33522. result.variables = value.block_scope.variables;
  33523. result.enclosed = value.block_scope.enclosed;
  33524. }
  33525. value.CTOR.PROPS.forEach(function(prop) {
  33526. result[prop] = value[prop];
  33527. });
  33528. return result;
  33529. }
  33530. return value;
  33531. }, 2));
  33532. } else if (program.output == "spidermonkey") {
  33533. try {
  33534. const minified = await minify(result.code, {
  33535. compress: false,
  33536. mangle: false,
  33537. format: {
  33538. ast: true,
  33539. code: false
  33540. }
  33541. });
  33542. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  33543. } catch (ex) {
  33544. fatal(ex);
  33545. return;
  33546. }
  33547. } else if (program.output) {
  33548. fs.writeFileSync(program.output, result.code);
  33549. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  33550. fs.writeFileSync(program.output + ".map", result.map);
  33551. }
  33552. } else {
  33553. console.log(result.code);
  33554. }
  33555. if (program.nameCache) {
  33556. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  33557. }
  33558. if (result.timings) for (var phase in result.timings) {
  33559. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  33560. }
  33561. }
  33562. function fatal(message) {
  33563. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  33564. print_error(message);
  33565. process.exit(1);
  33566. }
  33567. // A file glob function that only supports "*" and "?" wildcards in the basename.
  33568. // Example: "foo/bar/*baz??.*.js"
  33569. // Argument `glob` may be a string or an array of strings.
  33570. // Returns an array of strings. Garbage in, garbage out.
  33571. function simple_glob(glob) {
  33572. if (Array.isArray(glob)) {
  33573. return [].concat.apply([], glob.map(simple_glob));
  33574. }
  33575. if (glob && glob.match(/[*?]/)) {
  33576. var dir = path.dirname(glob);
  33577. try {
  33578. var entries = fs.readdirSync(dir);
  33579. } catch (ex) {}
  33580. if (entries) {
  33581. var pattern = "^" + path.basename(glob)
  33582. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  33583. .replace(/\*/g, "[^/\\\\]*")
  33584. .replace(/\?/g, "[^/\\\\]") + "$";
  33585. var mod = process.platform === "win32" ? "i" : "";
  33586. var rx = new RegExp(pattern, mod);
  33587. var results = entries.filter(function(name) {
  33588. return rx.test(name);
  33589. }).map(function(name) {
  33590. return path.join(dir, name);
  33591. });
  33592. if (results.length) return results;
  33593. }
  33594. }
  33595. return [ glob ];
  33596. }
  33597. function read_file(path, default_value) {
  33598. try {
  33599. return fs.readFileSync(path, "utf8");
  33600. } catch (ex) {
  33601. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  33602. fatal(ex);
  33603. }
  33604. }
  33605. function parse_js(flag) {
  33606. return function(value, options) {
  33607. options = options || {};
  33608. try {
  33609. walk(parse(value, { expression: true }), node => {
  33610. if (node instanceof AST_Assign) {
  33611. var name = node.left.print_to_string();
  33612. var value = node.right;
  33613. if (flag) {
  33614. options[name] = value;
  33615. } else if (value instanceof AST_Array) {
  33616. options[name] = value.elements.map(to_string);
  33617. } else if (value instanceof AST_RegExp) {
  33618. value = value.value;
  33619. options[name] = new RegExp(value.source, value.flags);
  33620. } else {
  33621. options[name] = to_string(value);
  33622. }
  33623. return true;
  33624. }
  33625. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  33626. var name = node.print_to_string();
  33627. options[name] = true;
  33628. return true;
  33629. }
  33630. if (!(node instanceof AST_Sequence)) throw node;
  33631. function to_string(value) {
  33632. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  33633. quote_keys: true
  33634. });
  33635. }
  33636. });
  33637. } catch(ex) {
  33638. if (flag) {
  33639. fatal("Error parsing arguments for '" + flag + "': " + value);
  33640. } else {
  33641. options[value] = null;
  33642. }
  33643. }
  33644. return options;
  33645. };
  33646. }
  33647. function symdef(def) {
  33648. var ret = (1e6 + def.id) + " " + def.name;
  33649. if (def.mangled_name) ret += " " + def.mangled_name;
  33650. return ret;
  33651. }
  33652. function collect_from_map(map, callback) {
  33653. var result = [];
  33654. map.forEach(function (def) {
  33655. result.push(callback(def));
  33656. });
  33657. return result;
  33658. }
  33659. function format_object(obj) {
  33660. var lines = [];
  33661. var padding = "";
  33662. Object.keys(obj).map(function(name) {
  33663. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  33664. return [ name, JSON.stringify(obj[name]) ];
  33665. }).forEach(function(tokens) {
  33666. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  33667. });
  33668. return lines.join("\n");
  33669. }
  33670. function print_error(msg) {
  33671. process.stderr.write(msg);
  33672. process.stderr.write("\n");
  33673. }
  33674. function describe_ast() {
  33675. var out = OutputStream({ beautify: true });
  33676. function doitem(ctor) {
  33677. out.print("AST_" + ctor.TYPE);
  33678. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  33679. if (props.length > 0) {
  33680. out.space();
  33681. out.with_parens(function() {
  33682. props.forEach(function(prop, i) {
  33683. if (i) out.space();
  33684. out.print(prop);
  33685. });
  33686. });
  33687. }
  33688. if (ctor.documentation) {
  33689. out.space();
  33690. out.print_string(ctor.documentation);
  33691. }
  33692. if (ctor.SUBCLASSES.length > 0) {
  33693. out.space();
  33694. out.with_block(function() {
  33695. ctor.SUBCLASSES.forEach(function(ctor) {
  33696. out.indent();
  33697. doitem(ctor);
  33698. out.newline();
  33699. });
  33700. });
  33701. }
  33702. }
  33703. doitem(AST_Node);
  33704. return out + "\n";
  33705. }
  33706. }
  33707. async function _default_options() {
  33708. const defs = {};
  33709. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  33710. const options = infer_options({
  33711. [component]: {0: 0}
  33712. });
  33713. if (options) defs[component] = options;
  33714. });
  33715. return defs;
  33716. }
  33717. async function infer_options(options) {
  33718. try {
  33719. await minify("", options);
  33720. } catch (error) {
  33721. return error.defs;
  33722. }
  33723. }
  33724. exports._default_options = _default_options;
  33725. exports._run_cli = run_cli;
  33726. exports.minify = minify;
  33727. })));
  33728. }(bundle_min$1, bundle_min$1.exports));
  33729. var bundle_min = bundle_min$1.exports;
  33730. module.exports = bundle_min;
  33731. //# sourceMappingURL=terser.js.map