12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445 |
- import { s as slash, j as notNullish } from './chunk-mock-date.2917be60.mjs';
- import { p as picocolors } from './chunk-constants.71e8a211.mjs';
- var build = {};
- var ansiStyles$1 = {exports: {}};
- (function (module) {
- const ANSI_BACKGROUND_OFFSET = 10;
- const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
- function assembleStyles() {
- const codes = new Map();
- const styles = {
- modifier: {
- reset: [0, 0],
- // 21 isn't widely supported and 22 does the same thing
- bold: [1, 22],
- dim: [2, 22],
- italic: [3, 23],
- underline: [4, 24],
- overline: [53, 55],
- inverse: [7, 27],
- hidden: [8, 28],
- strikethrough: [9, 29]
- },
- color: {
- black: [30, 39],
- red: [31, 39],
- green: [32, 39],
- yellow: [33, 39],
- blue: [34, 39],
- magenta: [35, 39],
- cyan: [36, 39],
- white: [37, 39],
- // Bright color
- blackBright: [90, 39],
- redBright: [91, 39],
- greenBright: [92, 39],
- yellowBright: [93, 39],
- blueBright: [94, 39],
- magentaBright: [95, 39],
- cyanBright: [96, 39],
- whiteBright: [97, 39]
- },
- bgColor: {
- bgBlack: [40, 49],
- bgRed: [41, 49],
- bgGreen: [42, 49],
- bgYellow: [43, 49],
- bgBlue: [44, 49],
- bgMagenta: [45, 49],
- bgCyan: [46, 49],
- bgWhite: [47, 49],
- // Bright color
- bgBlackBright: [100, 49],
- bgRedBright: [101, 49],
- bgGreenBright: [102, 49],
- bgYellowBright: [103, 49],
- bgBlueBright: [104, 49],
- bgMagentaBright: [105, 49],
- bgCyanBright: [106, 49],
- bgWhiteBright: [107, 49]
- }
- };
- // Alias bright black as gray (and grey)
- styles.color.gray = styles.color.blackBright;
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
- styles.color.grey = styles.color.blackBright;
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
- for (const [groupName, group] of Object.entries(styles)) {
- for (const [styleName, style] of Object.entries(group)) {
- styles[styleName] = {
- open: `\u001B[${style[0]}m`,
- close: `\u001B[${style[1]}m`
- };
- group[styleName] = styles[styleName];
- codes.set(style[0], style[1]);
- }
- Object.defineProperty(styles, groupName, {
- value: group,
- enumerable: false
- });
- }
- Object.defineProperty(styles, 'codes', {
- value: codes,
- enumerable: false
- });
- styles.color.close = '\u001B[39m';
- styles.bgColor.close = '\u001B[49m';
- styles.color.ansi256 = wrapAnsi256();
- styles.color.ansi16m = wrapAnsi16m();
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
- // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
- Object.defineProperties(styles, {
- rgbToAnsi256: {
- value: (red, green, blue) => {
- // We use the extended greyscale palette here, with the exception of
- // black and white. normal palette only has 4 greyscale shades.
- if (red === green && green === blue) {
- if (red < 8) {
- return 16;
- }
- if (red > 248) {
- return 231;
- }
- return Math.round(((red - 8) / 247) * 24) + 232;
- }
- return 16 +
- (36 * Math.round(red / 255 * 5)) +
- (6 * Math.round(green / 255 * 5)) +
- Math.round(blue / 255 * 5);
- },
- enumerable: false
- },
- hexToRgb: {
- value: hex => {
- const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
- if (!matches) {
- return [0, 0, 0];
- }
- let {colorString} = matches.groups;
- if (colorString.length === 3) {
- colorString = colorString.split('').map(character => character + character).join('');
- }
- const integer = Number.parseInt(colorString, 16);
- return [
- (integer >> 16) & 0xFF,
- (integer >> 8) & 0xFF,
- integer & 0xFF
- ];
- },
- enumerable: false
- },
- hexToAnsi256: {
- value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
- enumerable: false
- }
- });
- return styles;
- }
- // Make the export immutable
- Object.defineProperty(module, 'exports', {
- enumerable: true,
- get: assembleStyles
- });
- } (ansiStyles$1));
- var collections = {};
- Object.defineProperty(collections, '__esModule', {
- value: true
- });
- collections.printIteratorEntries = printIteratorEntries;
- collections.printIteratorValues = printIteratorValues;
- collections.printListItems = printListItems;
- collections.printObjectProperties = printObjectProperties;
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
- const getKeysOfEnumerableProperties = (object, compareKeys) => {
- const keys = Object.keys(object).sort(compareKeys);
- if (Object.getOwnPropertySymbols) {
- Object.getOwnPropertySymbols(object).forEach(symbol => {
- if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
- keys.push(symbol);
- }
- });
- }
- return keys;
- };
- /**
- * Return entries (for example, of a map)
- * with spacing, indentation, and comma
- * without surrounding punctuation (for example, braces)
- */
- function printIteratorEntries(
- iterator,
- config,
- indentation,
- depth,
- refs,
- printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
- // What a distracting diff if you change a data structure to/from
- // ECMAScript Object or Immutable.Map/OrderedMap which use the default.
- separator = ': '
- ) {
- let result = '';
- let current = iterator.next();
- if (!current.done) {
- result += config.spacingOuter;
- const indentationNext = indentation + config.indent;
- while (!current.done) {
- const name = printer(
- current.value[0],
- config,
- indentationNext,
- depth,
- refs
- );
- const value = printer(
- current.value[1],
- config,
- indentationNext,
- depth,
- refs
- );
- result += indentationNext + name + separator + value;
- current = iterator.next();
- if (!current.done) {
- result += ',' + config.spacingInner;
- } else if (!config.min) {
- result += ',';
- }
- }
- result += config.spacingOuter + indentation;
- }
- return result;
- }
- /**
- * Return values (for example, of a set)
- * with spacing, indentation, and comma
- * without surrounding punctuation (braces or brackets)
- */
- function printIteratorValues(
- iterator,
- config,
- indentation,
- depth,
- refs,
- printer
- ) {
- let result = '';
- let current = iterator.next();
- if (!current.done) {
- result += config.spacingOuter;
- const indentationNext = indentation + config.indent;
- while (!current.done) {
- result +=
- indentationNext +
- printer(current.value, config, indentationNext, depth, refs);
- current = iterator.next();
- if (!current.done) {
- result += ',' + config.spacingInner;
- } else if (!config.min) {
- result += ',';
- }
- }
- result += config.spacingOuter + indentation;
- }
- return result;
- }
- /**
- * Return items (for example, of an array)
- * with spacing, indentation, and comma
- * without surrounding punctuation (for example, brackets)
- **/
- function printListItems(list, config, indentation, depth, refs, printer) {
- let result = '';
- if (list.length) {
- result += config.spacingOuter;
- const indentationNext = indentation + config.indent;
- for (let i = 0; i < list.length; i++) {
- result += indentationNext;
- if (i in list) {
- result += printer(list[i], config, indentationNext, depth, refs);
- }
- if (i < list.length - 1) {
- result += ',' + config.spacingInner;
- } else if (!config.min) {
- result += ',';
- }
- }
- result += config.spacingOuter + indentation;
- }
- return result;
- }
- /**
- * Return properties of an object
- * with spacing, indentation, and comma
- * without surrounding punctuation (for example, braces)
- */
- function printObjectProperties(val, config, indentation, depth, refs, printer) {
- let result = '';
- const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
- if (keys.length) {
- result += config.spacingOuter;
- const indentationNext = indentation + config.indent;
- for (let i = 0; i < keys.length; i++) {
- const key = keys[i];
- const name = printer(key, config, indentationNext, depth, refs);
- const value = printer(val[key], config, indentationNext, depth, refs);
- result += indentationNext + name + ': ' + value;
- if (i < keys.length - 1) {
- result += ',' + config.spacingInner;
- } else if (!config.min) {
- result += ',';
- }
- }
- result += config.spacingOuter + indentation;
- }
- return result;
- }
- var AsymmetricMatcher$1 = {};
- Object.defineProperty(AsymmetricMatcher$1, '__esModule', {
- value: true
- });
- AsymmetricMatcher$1.test = AsymmetricMatcher$1.serialize = AsymmetricMatcher$1.default = void 0;
- var _collections$3 = collections;
- var global$1 = (function () {
- if (typeof globalThis !== 'undefined') {
- return globalThis;
- } else if (typeof global$1 !== 'undefined') {
- return global$1;
- } else if (typeof self !== 'undefined') {
- return self;
- } else if (typeof window !== 'undefined') {
- return window;
- } else {
- return Function('return this')();
- }
- })();
- var Symbol$2 = global$1['jest-symbol-do-not-touch'] || global$1.Symbol;
- const asymmetricMatcher =
- typeof Symbol$2 === 'function' && Symbol$2.for
- ? Symbol$2.for('jest.asymmetricMatcher')
- : 0x1357a5;
- const SPACE$2 = ' ';
- const serialize$6 = (val, config, indentation, depth, refs, printer) => {
- const stringedValue = val.toString();
- if (
- stringedValue === 'ArrayContaining' ||
- stringedValue === 'ArrayNotContaining'
- ) {
- if (++depth > config.maxDepth) {
- return '[' + stringedValue + ']';
- }
- return (
- stringedValue +
- SPACE$2 +
- '[' +
- (0, _collections$3.printListItems)(
- val.sample,
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- ']'
- );
- }
- if (
- stringedValue === 'ObjectContaining' ||
- stringedValue === 'ObjectNotContaining'
- ) {
- if (++depth > config.maxDepth) {
- return '[' + stringedValue + ']';
- }
- return (
- stringedValue +
- SPACE$2 +
- '{' +
- (0, _collections$3.printObjectProperties)(
- val.sample,
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- '}'
- );
- }
- if (
- stringedValue === 'StringMatching' ||
- stringedValue === 'StringNotMatching'
- ) {
- return (
- stringedValue +
- SPACE$2 +
- printer(val.sample, config, indentation, depth, refs)
- );
- }
- if (
- stringedValue === 'StringContaining' ||
- stringedValue === 'StringNotContaining'
- ) {
- return (
- stringedValue +
- SPACE$2 +
- printer(val.sample, config, indentation, depth, refs)
- );
- }
- return val.toAsymmetricMatcher();
- };
- AsymmetricMatcher$1.serialize = serialize$6;
- const test$6 = val => val && val.$$typeof === asymmetricMatcher;
- AsymmetricMatcher$1.test = test$6;
- const plugin$6 = {
- serialize: serialize$6,
- test: test$6
- };
- var _default$7 = plugin$6;
- AsymmetricMatcher$1.default = _default$7;
- var ConvertAnsi = {};
- var ansiRegex$1 = ({onlyFirst = false} = {}) => {
- const pattern = [
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
- ].join('|');
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
- };
- Object.defineProperty(ConvertAnsi, '__esModule', {
- value: true
- });
- ConvertAnsi.test = ConvertAnsi.serialize = ConvertAnsi.default = void 0;
- var _ansiRegex = _interopRequireDefault$2(ansiRegex$1);
- var _ansiStyles$1 = _interopRequireDefault$2(ansiStyles$1.exports);
- function _interopRequireDefault$2(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- const toHumanReadableAnsi = text =>
- text.replace((0, _ansiRegex.default)(), match => {
- switch (match) {
- case _ansiStyles$1.default.red.close:
- case _ansiStyles$1.default.green.close:
- case _ansiStyles$1.default.cyan.close:
- case _ansiStyles$1.default.gray.close:
- case _ansiStyles$1.default.white.close:
- case _ansiStyles$1.default.yellow.close:
- case _ansiStyles$1.default.bgRed.close:
- case _ansiStyles$1.default.bgGreen.close:
- case _ansiStyles$1.default.bgYellow.close:
- case _ansiStyles$1.default.inverse.close:
- case _ansiStyles$1.default.dim.close:
- case _ansiStyles$1.default.bold.close:
- case _ansiStyles$1.default.reset.open:
- case _ansiStyles$1.default.reset.close:
- return '</>';
- case _ansiStyles$1.default.red.open:
- return '<red>';
- case _ansiStyles$1.default.green.open:
- return '<green>';
- case _ansiStyles$1.default.cyan.open:
- return '<cyan>';
- case _ansiStyles$1.default.gray.open:
- return '<gray>';
- case _ansiStyles$1.default.white.open:
- return '<white>';
- case _ansiStyles$1.default.yellow.open:
- return '<yellow>';
- case _ansiStyles$1.default.bgRed.open:
- return '<bgRed>';
- case _ansiStyles$1.default.bgGreen.open:
- return '<bgGreen>';
- case _ansiStyles$1.default.bgYellow.open:
- return '<bgYellow>';
- case _ansiStyles$1.default.inverse.open:
- return '<inverse>';
- case _ansiStyles$1.default.dim.open:
- return '<dim>';
- case _ansiStyles$1.default.bold.open:
- return '<bold>';
- default:
- return '';
- }
- });
- const test$5 = val =>
- typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
- ConvertAnsi.test = test$5;
- const serialize$5 = (val, config, indentation, depth, refs, printer) =>
- printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
- ConvertAnsi.serialize = serialize$5;
- const plugin$5 = {
- serialize: serialize$5,
- test: test$5
- };
- var _default$6 = plugin$5;
- ConvertAnsi.default = _default$6;
- var DOMCollection$1 = {};
- Object.defineProperty(DOMCollection$1, '__esModule', {
- value: true
- });
- DOMCollection$1.test = DOMCollection$1.serialize = DOMCollection$1.default = void 0;
- var _collections$2 = collections;
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- /* eslint-disable local/ban-types-eventually */
- const SPACE$1 = ' ';
- const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
- const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
- const testName = name =>
- OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
- const test$4 = val =>
- val &&
- val.constructor &&
- !!val.constructor.name &&
- testName(val.constructor.name);
- DOMCollection$1.test = test$4;
- const isNamedNodeMap = collection =>
- collection.constructor.name === 'NamedNodeMap';
- const serialize$4 = (collection, config, indentation, depth, refs, printer) => {
- const name = collection.constructor.name;
- if (++depth > config.maxDepth) {
- return '[' + name + ']';
- }
- return (
- (config.min ? '' : name + SPACE$1) +
- (OBJECT_NAMES.indexOf(name) !== -1
- ? '{' +
- (0, _collections$2.printObjectProperties)(
- isNamedNodeMap(collection)
- ? Array.from(collection).reduce((props, attribute) => {
- props[attribute.name] = attribute.value;
- return props;
- }, {})
- : {...collection},
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- '}'
- : '[' +
- (0, _collections$2.printListItems)(
- Array.from(collection),
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- ']')
- );
- };
- DOMCollection$1.serialize = serialize$4;
- const plugin$4 = {
- serialize: serialize$4,
- test: test$4
- };
- var _default$5 = plugin$4;
- DOMCollection$1.default = _default$5;
- var DOMElement$1 = {};
- var markup = {};
- var escapeHTML$1 = {};
- Object.defineProperty(escapeHTML$1, '__esModule', {
- value: true
- });
- escapeHTML$1.default = escapeHTML;
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- function escapeHTML(str) {
- return str.replace(/</g, '<').replace(/>/g, '>');
- }
- Object.defineProperty(markup, '__esModule', {
- value: true
- });
- markup.printText =
- markup.printProps =
- markup.printElementAsLeaf =
- markup.printElement =
- markup.printComment =
- markup.printChildren =
- void 0;
- var _escapeHTML = _interopRequireDefault$1(escapeHTML$1);
- function _interopRequireDefault$1(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- // Return empty string if keys is empty.
- const printProps = (keys, props, config, indentation, depth, refs, printer) => {
- const indentationNext = indentation + config.indent;
- const colors = config.colors;
- return keys
- .map(key => {
- const value = props[key];
- let printed = printer(value, config, indentationNext, depth, refs);
- if (typeof value !== 'string') {
- if (printed.indexOf('\n') !== -1) {
- printed =
- config.spacingOuter +
- indentationNext +
- printed +
- config.spacingOuter +
- indentation;
- }
- printed = '{' + printed + '}';
- }
- return (
- config.spacingInner +
- indentation +
- colors.prop.open +
- key +
- colors.prop.close +
- '=' +
- colors.value.open +
- printed +
- colors.value.close
- );
- })
- .join('');
- }; // Return empty string if children is empty.
- markup.printProps = printProps;
- const printChildren = (children, config, indentation, depth, refs, printer) =>
- children
- .map(
- child =>
- config.spacingOuter +
- indentation +
- (typeof child === 'string'
- ? printText(child, config)
- : printer(child, config, indentation, depth, refs))
- )
- .join('');
- markup.printChildren = printChildren;
- const printText = (text, config) => {
- const contentColor = config.colors.content;
- return (
- contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
- );
- };
- markup.printText = printText;
- const printComment = (comment, config) => {
- const commentColor = config.colors.comment;
- return (
- commentColor.open +
- '<!--' +
- (0, _escapeHTML.default)(comment) +
- '-->' +
- commentColor.close
- );
- }; // Separate the functions to format props, children, and element,
- // so a plugin could override a particular function, if needed.
- // Too bad, so sad: the traditional (but unnecessary) space
- // in a self-closing tagColor requires a second test of printedProps.
- markup.printComment = printComment;
- const printElement = (
- type,
- printedProps,
- printedChildren,
- config,
- indentation
- ) => {
- const tagColor = config.colors.tag;
- return (
- tagColor.open +
- '<' +
- type +
- (printedProps &&
- tagColor.close +
- printedProps +
- config.spacingOuter +
- indentation +
- tagColor.open) +
- (printedChildren
- ? '>' +
- tagColor.close +
- printedChildren +
- config.spacingOuter +
- indentation +
- tagColor.open +
- '</' +
- type
- : (printedProps && !config.min ? '' : ' ') + '/') +
- '>' +
- tagColor.close
- );
- };
- markup.printElement = printElement;
- const printElementAsLeaf = (type, config) => {
- const tagColor = config.colors.tag;
- return (
- tagColor.open +
- '<' +
- type +
- tagColor.close +
- ' …' +
- tagColor.open +
- ' />' +
- tagColor.close
- );
- };
- markup.printElementAsLeaf = printElementAsLeaf;
- Object.defineProperty(DOMElement$1, '__esModule', {
- value: true
- });
- DOMElement$1.test = DOMElement$1.serialize = DOMElement$1.default = void 0;
- var _markup$2 = markup;
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- const ELEMENT_NODE = 1;
- const TEXT_NODE = 3;
- const COMMENT_NODE = 8;
- const FRAGMENT_NODE = 11;
- const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
- const testHasAttribute = val => {
- try {
- return typeof val.hasAttribute === 'function' && val.hasAttribute('is');
- } catch {
- return false;
- }
- };
- const testNode = val => {
- const constructorName = val.constructor.name;
- const {nodeType, tagName} = val;
- const isCustomElement =
- (typeof tagName === 'string' && tagName.includes('-')) ||
- testHasAttribute(val);
- return (
- (nodeType === ELEMENT_NODE &&
- (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||
- (nodeType === TEXT_NODE && constructorName === 'Text') ||
- (nodeType === COMMENT_NODE && constructorName === 'Comment') ||
- (nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment')
- );
- };
- const test$3 = val => {
- var _val$constructor;
- return (
- (val === null || val === void 0
- ? void 0
- : (_val$constructor = val.constructor) === null ||
- _val$constructor === void 0
- ? void 0
- : _val$constructor.name) && testNode(val)
- );
- };
- DOMElement$1.test = test$3;
- function nodeIsText(node) {
- return node.nodeType === TEXT_NODE;
- }
- function nodeIsComment(node) {
- return node.nodeType === COMMENT_NODE;
- }
- function nodeIsFragment(node) {
- return node.nodeType === FRAGMENT_NODE;
- }
- const serialize$3 = (node, config, indentation, depth, refs, printer) => {
- if (nodeIsText(node)) {
- return (0, _markup$2.printText)(node.data, config);
- }
- if (nodeIsComment(node)) {
- return (0, _markup$2.printComment)(node.data, config);
- }
- const type = nodeIsFragment(node)
- ? 'DocumentFragment'
- : node.tagName.toLowerCase();
- if (++depth > config.maxDepth) {
- return (0, _markup$2.printElementAsLeaf)(type, config);
- }
- return (0, _markup$2.printElement)(
- type,
- (0, _markup$2.printProps)(
- nodeIsFragment(node)
- ? []
- : Array.from(node.attributes)
- .map(attr => attr.name)
- .sort(),
- nodeIsFragment(node)
- ? {}
- : Array.from(node.attributes).reduce((props, attribute) => {
- props[attribute.name] = attribute.value;
- return props;
- }, {}),
- config,
- indentation + config.indent,
- depth,
- refs,
- printer
- ),
- (0, _markup$2.printChildren)(
- Array.prototype.slice.call(node.childNodes || node.children),
- config,
- indentation + config.indent,
- depth,
- refs,
- printer
- ),
- config,
- indentation
- );
- };
- DOMElement$1.serialize = serialize$3;
- const plugin$3 = {
- serialize: serialize$3,
- test: test$3
- };
- var _default$4 = plugin$3;
- DOMElement$1.default = _default$4;
- var Immutable$1 = {};
- Object.defineProperty(Immutable$1, '__esModule', {
- value: true
- });
- Immutable$1.test = Immutable$1.serialize = Immutable$1.default = void 0;
- var _collections$1 = collections;
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- // SENTINEL constants are from https://github.com/facebook/immutable-js
- const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
- const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
- const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
- const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
- const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
- const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
- const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
- const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
- const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
- const getImmutableName = name => 'Immutable.' + name;
- const printAsLeaf = name => '[' + name + ']';
- const SPACE = ' ';
- const LAZY = '…'; // Seq is lazy if it calls a method like filter
- const printImmutableEntries = (
- val,
- config,
- indentation,
- depth,
- refs,
- printer,
- type
- ) =>
- ++depth > config.maxDepth
- ? printAsLeaf(getImmutableName(type))
- : getImmutableName(type) +
- SPACE +
- '{' +
- (0, _collections$1.printIteratorEntries)(
- val.entries(),
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- '}'; // Record has an entries method because it is a collection in immutable v3.
- // Return an iterator for Immutable Record from version v3 or v4.
- function getRecordEntries(val) {
- let i = 0;
- return {
- next() {
- if (i < val._keys.length) {
- const key = val._keys[i++];
- return {
- done: false,
- value: [key, val.get(key)]
- };
- }
- return {
- done: true,
- value: undefined
- };
- }
- };
- }
- const printImmutableRecord = (
- val,
- config,
- indentation,
- depth,
- refs,
- printer
- ) => {
- // _name property is defined only for an Immutable Record instance
- // which was constructed with a second optional descriptive name arg
- const name = getImmutableName(val._name || 'Record');
- return ++depth > config.maxDepth
- ? printAsLeaf(name)
- : name +
- SPACE +
- '{' +
- (0, _collections$1.printIteratorEntries)(
- getRecordEntries(val),
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- '}';
- };
- const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
- const name = getImmutableName('Seq');
- if (++depth > config.maxDepth) {
- return printAsLeaf(name);
- }
- if (val[IS_KEYED_SENTINEL]) {
- return (
- name +
- SPACE +
- '{' + // from Immutable collection of entries or from ECMAScript object
- (val._iter || val._object
- ? (0, _collections$1.printIteratorEntries)(
- val.entries(),
- config,
- indentation,
- depth,
- refs,
- printer
- )
- : LAZY) +
- '}'
- );
- }
- return (
- name +
- SPACE +
- '[' +
- (val._iter || // from Immutable collection of values
- val._array || // from ECMAScript array
- val._collection || // from ECMAScript collection in immutable v4
- val._iterable // from ECMAScript collection in immutable v3
- ? (0, _collections$1.printIteratorValues)(
- val.values(),
- config,
- indentation,
- depth,
- refs,
- printer
- )
- : LAZY) +
- ']'
- );
- };
- const printImmutableValues = (
- val,
- config,
- indentation,
- depth,
- refs,
- printer,
- type
- ) =>
- ++depth > config.maxDepth
- ? printAsLeaf(getImmutableName(type))
- : getImmutableName(type) +
- SPACE +
- '[' +
- (0, _collections$1.printIteratorValues)(
- val.values(),
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- ']';
- const serialize$2 = (val, config, indentation, depth, refs, printer) => {
- if (val[IS_MAP_SENTINEL]) {
- return printImmutableEntries(
- val,
- config,
- indentation,
- depth,
- refs,
- printer,
- val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
- );
- }
- if (val[IS_LIST_SENTINEL]) {
- return printImmutableValues(
- val,
- config,
- indentation,
- depth,
- refs,
- printer,
- 'List'
- );
- }
- if (val[IS_SET_SENTINEL]) {
- return printImmutableValues(
- val,
- config,
- indentation,
- depth,
- refs,
- printer,
- val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
- );
- }
- if (val[IS_STACK_SENTINEL]) {
- return printImmutableValues(
- val,
- config,
- indentation,
- depth,
- refs,
- printer,
- 'Stack'
- );
- }
- if (val[IS_SEQ_SENTINEL]) {
- return printImmutableSeq(val, config, indentation, depth, refs, printer);
- } // For compatibility with immutable v3 and v4, let record be the default.
- return printImmutableRecord(val, config, indentation, depth, refs, printer);
- }; // Explicitly comparing sentinel properties to true avoids false positive
- // when mock identity-obj-proxy returns the key as the value for any key.
- Immutable$1.serialize = serialize$2;
- const test$2 = val =>
- val &&
- (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
- Immutable$1.test = test$2;
- const plugin$2 = {
- serialize: serialize$2,
- test: test$2
- };
- var _default$3 = plugin$2;
- Immutable$1.default = _default$3;
- var ReactElement$1 = {};
- var reactIs = {exports: {}};
- var reactIs_production_min = {};
- /** @license React v17.0.2
- * react-is.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var hasRequiredReactIs_production_min;
- function requireReactIs_production_min () {
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
- hasRequiredReactIs_production_min = 1;
- var b=60103,c=60106,d=60107,e=60108,f=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131;
- if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden");}
- function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f,H=e,I=l;reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=z;reactIs_production_min.Element=A;reactIs_production_min.ForwardRef=B;reactIs_production_min.Fragment=C;reactIs_production_min.Lazy=D;reactIs_production_min.Memo=E;reactIs_production_min.Portal=F;reactIs_production_min.Profiler=G;reactIs_production_min.StrictMode=H;
- reactIs_production_min.Suspense=I;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return y(a)===h};reactIs_production_min.isContextProvider=function(a){return y(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return y(a)===k};reactIs_production_min.isFragment=function(a){return y(a)===d};reactIs_production_min.isLazy=function(a){return y(a)===p};reactIs_production_min.isMemo=function(a){return y(a)===n};
- reactIs_production_min.isPortal=function(a){return y(a)===c};reactIs_production_min.isProfiler=function(a){return y(a)===f};reactIs_production_min.isStrictMode=function(a){return y(a)===e};reactIs_production_min.isSuspense=function(a){return y(a)===l};reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1};
- reactIs_production_min.typeOf=y;
- return reactIs_production_min;
- }
- var reactIs_development = {};
- /** @license React v17.0.2
- * react-is.development.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var hasRequiredReactIs_development;
- function requireReactIs_development () {
- if (hasRequiredReactIs_development) return reactIs_development;
- hasRequiredReactIs_development = 1;
- if (process.env.NODE_ENV !== "production") {
- (function() {
- // ATTENTION
- // When adding new symbols to this file,
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
- // nor polyfill, then a plain number is used for performance.
- var REACT_ELEMENT_TYPE = 0xeac7;
- var REACT_PORTAL_TYPE = 0xeaca;
- var REACT_FRAGMENT_TYPE = 0xeacb;
- var REACT_STRICT_MODE_TYPE = 0xeacc;
- var REACT_PROFILER_TYPE = 0xead2;
- var REACT_PROVIDER_TYPE = 0xeacd;
- var REACT_CONTEXT_TYPE = 0xeace;
- var REACT_FORWARD_REF_TYPE = 0xead0;
- var REACT_SUSPENSE_TYPE = 0xead1;
- var REACT_SUSPENSE_LIST_TYPE = 0xead8;
- var REACT_MEMO_TYPE = 0xead3;
- var REACT_LAZY_TYPE = 0xead4;
- var REACT_BLOCK_TYPE = 0xead9;
- var REACT_SERVER_BLOCK_TYPE = 0xeada;
- var REACT_FUNDAMENTAL_TYPE = 0xead5;
- var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
- var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
- if (typeof Symbol === 'function' && Symbol.for) {
- var symbolFor = Symbol.for;
- REACT_ELEMENT_TYPE = symbolFor('react.element');
- REACT_PORTAL_TYPE = symbolFor('react.portal');
- REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
- REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
- REACT_PROFILER_TYPE = symbolFor('react.profiler');
- REACT_PROVIDER_TYPE = symbolFor('react.provider');
- REACT_CONTEXT_TYPE = symbolFor('react.context');
- REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
- REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
- REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
- REACT_MEMO_TYPE = symbolFor('react.memo');
- REACT_LAZY_TYPE = symbolFor('react.lazy');
- REACT_BLOCK_TYPE = symbolFor('react.block');
- REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
- REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
- symbolFor('react.scope');
- symbolFor('react.opaque.id');
- REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
- symbolFor('react.offscreen');
- REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
- }
- // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
- var enableScopeAPI = false; // Experimental Create Event Handle API.
- function isValidElementType(type) {
- if (typeof type === 'string' || typeof type === 'function') {
- return true;
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
- return true;
- }
- if (typeof type === 'object' && type !== null) {
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
- return true;
- }
- }
- return false;
- }
- function typeOf(object) {
- if (typeof object === 'object' && object !== null) {
- var $$typeof = object.$$typeof;
- switch ($$typeof) {
- case REACT_ELEMENT_TYPE:
- var type = object.type;
- switch (type) {
- case REACT_FRAGMENT_TYPE:
- case REACT_PROFILER_TYPE:
- case REACT_STRICT_MODE_TYPE:
- case REACT_SUSPENSE_TYPE:
- case REACT_SUSPENSE_LIST_TYPE:
- return type;
- default:
- var $$typeofType = type && type.$$typeof;
- switch ($$typeofType) {
- case REACT_CONTEXT_TYPE:
- case REACT_FORWARD_REF_TYPE:
- case REACT_LAZY_TYPE:
- case REACT_MEMO_TYPE:
- case REACT_PROVIDER_TYPE:
- return $$typeofType;
- default:
- return $$typeof;
- }
- }
- case REACT_PORTAL_TYPE:
- return $$typeof;
- }
- }
- return undefined;
- }
- var ContextConsumer = REACT_CONTEXT_TYPE;
- var ContextProvider = REACT_PROVIDER_TYPE;
- var Element = REACT_ELEMENT_TYPE;
- var ForwardRef = REACT_FORWARD_REF_TYPE;
- var Fragment = REACT_FRAGMENT_TYPE;
- var Lazy = REACT_LAZY_TYPE;
- var Memo = REACT_MEMO_TYPE;
- var Portal = REACT_PORTAL_TYPE;
- var Profiler = REACT_PROFILER_TYPE;
- var StrictMode = REACT_STRICT_MODE_TYPE;
- var Suspense = REACT_SUSPENSE_TYPE;
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
- var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
- function isAsyncMode(object) {
- {
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
- }
- }
- return false;
- }
- function isConcurrentMode(object) {
- {
- if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
- hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
- console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
- }
- }
- return false;
- }
- function isContextConsumer(object) {
- return typeOf(object) === REACT_CONTEXT_TYPE;
- }
- function isContextProvider(object) {
- return typeOf(object) === REACT_PROVIDER_TYPE;
- }
- function isElement(object) {
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
- }
- function isForwardRef(object) {
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
- }
- function isFragment(object) {
- return typeOf(object) === REACT_FRAGMENT_TYPE;
- }
- function isLazy(object) {
- return typeOf(object) === REACT_LAZY_TYPE;
- }
- function isMemo(object) {
- return typeOf(object) === REACT_MEMO_TYPE;
- }
- function isPortal(object) {
- return typeOf(object) === REACT_PORTAL_TYPE;
- }
- function isProfiler(object) {
- return typeOf(object) === REACT_PROFILER_TYPE;
- }
- function isStrictMode(object) {
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
- }
- function isSuspense(object) {
- return typeOf(object) === REACT_SUSPENSE_TYPE;
- }
- reactIs_development.ContextConsumer = ContextConsumer;
- reactIs_development.ContextProvider = ContextProvider;
- reactIs_development.Element = Element;
- reactIs_development.ForwardRef = ForwardRef;
- reactIs_development.Fragment = Fragment;
- reactIs_development.Lazy = Lazy;
- reactIs_development.Memo = Memo;
- reactIs_development.Portal = Portal;
- reactIs_development.Profiler = Profiler;
- reactIs_development.StrictMode = StrictMode;
- reactIs_development.Suspense = Suspense;
- reactIs_development.isAsyncMode = isAsyncMode;
- reactIs_development.isConcurrentMode = isConcurrentMode;
- reactIs_development.isContextConsumer = isContextConsumer;
- reactIs_development.isContextProvider = isContextProvider;
- reactIs_development.isElement = isElement;
- reactIs_development.isForwardRef = isForwardRef;
- reactIs_development.isFragment = isFragment;
- reactIs_development.isLazy = isLazy;
- reactIs_development.isMemo = isMemo;
- reactIs_development.isPortal = isPortal;
- reactIs_development.isProfiler = isProfiler;
- reactIs_development.isStrictMode = isStrictMode;
- reactIs_development.isSuspense = isSuspense;
- reactIs_development.isValidElementType = isValidElementType;
- reactIs_development.typeOf = typeOf;
- })();
- }
- return reactIs_development;
- }
- (function (module) {
- if (process.env.NODE_ENV === 'production') {
- module.exports = requireReactIs_production_min();
- } else {
- module.exports = requireReactIs_development();
- }
- } (reactIs));
- Object.defineProperty(ReactElement$1, '__esModule', {
- value: true
- });
- ReactElement$1.test = ReactElement$1.serialize = ReactElement$1.default = void 0;
- var ReactIs = _interopRequireWildcard(reactIs.exports);
- var _markup$1 = markup;
- function _getRequireWildcardCache(nodeInterop) {
- if (typeof WeakMap !== 'function') return null;
- var cacheBabelInterop = new WeakMap();
- var cacheNodeInterop = new WeakMap();
- return (_getRequireWildcardCache = function (nodeInterop) {
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
- })(nodeInterop);
- }
- function _interopRequireWildcard(obj, nodeInterop) {
- if (!nodeInterop && obj && obj.__esModule) {
- return obj;
- }
- if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
- return {default: obj};
- }
- var cache = _getRequireWildcardCache(nodeInterop);
- if (cache && cache.has(obj)) {
- return cache.get(obj);
- }
- var newObj = {};
- var hasPropertyDescriptor =
- Object.defineProperty && Object.getOwnPropertyDescriptor;
- for (var key in obj) {
- if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
- var desc = hasPropertyDescriptor
- ? Object.getOwnPropertyDescriptor(obj, key)
- : null;
- if (desc && (desc.get || desc.set)) {
- Object.defineProperty(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- newObj.default = obj;
- if (cache) {
- cache.set(obj, newObj);
- }
- return newObj;
- }
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- // Given element.props.children, or subtree during recursive traversal,
- // return flattened array of children.
- const getChildren = (arg, children = []) => {
- if (Array.isArray(arg)) {
- arg.forEach(item => {
- getChildren(item, children);
- });
- } else if (arg != null && arg !== false) {
- children.push(arg);
- }
- return children;
- };
- const getType = element => {
- const type = element.type;
- if (typeof type === 'string') {
- return type;
- }
- if (typeof type === 'function') {
- return type.displayName || type.name || 'Unknown';
- }
- if (ReactIs.isFragment(element)) {
- return 'React.Fragment';
- }
- if (ReactIs.isSuspense(element)) {
- return 'React.Suspense';
- }
- if (typeof type === 'object' && type !== null) {
- if (ReactIs.isContextProvider(element)) {
- return 'Context.Provider';
- }
- if (ReactIs.isContextConsumer(element)) {
- return 'Context.Consumer';
- }
- if (ReactIs.isForwardRef(element)) {
- if (type.displayName) {
- return type.displayName;
- }
- const functionName = type.render.displayName || type.render.name || '';
- return functionName !== ''
- ? 'ForwardRef(' + functionName + ')'
- : 'ForwardRef';
- }
- if (ReactIs.isMemo(element)) {
- const functionName =
- type.displayName || type.type.displayName || type.type.name || '';
- return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
- }
- }
- return 'UNDEFINED';
- };
- const getPropKeys$1 = element => {
- const {props} = element;
- return Object.keys(props)
- .filter(key => key !== 'children' && props[key] !== undefined)
- .sort();
- };
- const serialize$1 = (element, config, indentation, depth, refs, printer) =>
- ++depth > config.maxDepth
- ? (0, _markup$1.printElementAsLeaf)(getType(element), config)
- : (0, _markup$1.printElement)(
- getType(element),
- (0, _markup$1.printProps)(
- getPropKeys$1(element),
- element.props,
- config,
- indentation + config.indent,
- depth,
- refs,
- printer
- ),
- (0, _markup$1.printChildren)(
- getChildren(element.props.children),
- config,
- indentation + config.indent,
- depth,
- refs,
- printer
- ),
- config,
- indentation
- );
- ReactElement$1.serialize = serialize$1;
- const test$1 = val => val != null && ReactIs.isElement(val);
- ReactElement$1.test = test$1;
- const plugin$1 = {
- serialize: serialize$1,
- test: test$1
- };
- var _default$2 = plugin$1;
- ReactElement$1.default = _default$2;
- var ReactTestComponent$1 = {};
- Object.defineProperty(ReactTestComponent$1, '__esModule', {
- value: true
- });
- ReactTestComponent$1.test = ReactTestComponent$1.serialize = ReactTestComponent$1.default = void 0;
- var _markup = markup;
- var global = (function () {
- if (typeof globalThis !== 'undefined') {
- return globalThis;
- } else if (typeof global !== 'undefined') {
- return global;
- } else if (typeof self !== 'undefined') {
- return self;
- } else if (typeof window !== 'undefined') {
- return window;
- } else {
- return Function('return this')();
- }
- })();
- var Symbol$1 = global['jest-symbol-do-not-touch'] || global.Symbol;
- const testSymbol =
- typeof Symbol$1 === 'function' && Symbol$1.for
- ? Symbol$1.for('react.test.json')
- : 0xea71357;
- const getPropKeys = object => {
- const {props} = object;
- return props
- ? Object.keys(props)
- .filter(key => props[key] !== undefined)
- .sort()
- : [];
- };
- const serialize = (object, config, indentation, depth, refs, printer) =>
- ++depth > config.maxDepth
- ? (0, _markup.printElementAsLeaf)(object.type, config)
- : (0, _markup.printElement)(
- object.type,
- object.props
- ? (0, _markup.printProps)(
- getPropKeys(object),
- object.props,
- config,
- indentation + config.indent,
- depth,
- refs,
- printer
- )
- : '',
- object.children
- ? (0, _markup.printChildren)(
- object.children,
- config,
- indentation + config.indent,
- depth,
- refs,
- printer
- )
- : '',
- config,
- indentation
- );
- ReactTestComponent$1.serialize = serialize;
- const test = val => val && val.$$typeof === testSymbol;
- ReactTestComponent$1.test = test;
- const plugin = {
- serialize,
- test
- };
- var _default$1 = plugin;
- ReactTestComponent$1.default = _default$1;
- Object.defineProperty(build, '__esModule', {
- value: true
- });
- build.default = build.DEFAULT_OPTIONS = void 0;
- var format_1 = build.format = format;
- var plugins_1 = build.plugins = void 0;
- var _ansiStyles = _interopRequireDefault(ansiStyles$1.exports);
- var _collections = collections;
- var _AsymmetricMatcher = _interopRequireDefault(
- AsymmetricMatcher$1
- );
- var _ConvertAnsi = _interopRequireDefault(ConvertAnsi);
- var _DOMCollection = _interopRequireDefault(DOMCollection$1);
- var _DOMElement = _interopRequireDefault(DOMElement$1);
- var _Immutable = _interopRequireDefault(Immutable$1);
- var _ReactElement = _interopRequireDefault(ReactElement$1);
- var _ReactTestComponent = _interopRequireDefault(
- ReactTestComponent$1
- );
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- /* eslint-disable local/ban-types-eventually */
- const toString = Object.prototype.toString;
- const toISOString = Date.prototype.toISOString;
- const errorToString = Error.prototype.toString;
- const regExpToString = RegExp.prototype.toString;
- /**
- * Explicitly comparing typeof constructor to function avoids undefined as name
- * when mock identity-obj-proxy returns the key as the value for any key.
- */
- const getConstructorName = val =>
- (typeof val.constructor === 'function' && val.constructor.name) || 'Object';
- /* global window */
- /** Is val is equal to global window object? Works even if it does not exist :) */
- const isWindow = val => typeof window !== 'undefined' && val === window;
- const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
- const NEWLINE_REGEXP = /\n/gi;
- class PrettyFormatPluginError extends Error {
- constructor(message, stack) {
- super(message);
- this.stack = stack;
- this.name = this.constructor.name;
- }
- }
- function isToStringedArrayType(toStringed) {
- return (
- toStringed === '[object Array]' ||
- toStringed === '[object ArrayBuffer]' ||
- toStringed === '[object DataView]' ||
- toStringed === '[object Float32Array]' ||
- toStringed === '[object Float64Array]' ||
- toStringed === '[object Int8Array]' ||
- toStringed === '[object Int16Array]' ||
- toStringed === '[object Int32Array]' ||
- toStringed === '[object Uint8Array]' ||
- toStringed === '[object Uint8ClampedArray]' ||
- toStringed === '[object Uint16Array]' ||
- toStringed === '[object Uint32Array]'
- );
- }
- function printNumber(val) {
- return Object.is(val, -0) ? '-0' : String(val);
- }
- function printBigInt(val) {
- return String(`${val}n`);
- }
- function printFunction(val, printFunctionName) {
- if (!printFunctionName) {
- return '[Function]';
- }
- return '[Function ' + (val.name || 'anonymous') + ']';
- }
- function printSymbol(val) {
- return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
- }
- function printError(val) {
- return '[' + errorToString.call(val) + ']';
- }
- /**
- * The first port of call for printing an object, handles most of the
- * data-types in JS.
- */
- function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
- if (val === true || val === false) {
- return '' + val;
- }
- if (val === undefined) {
- return 'undefined';
- }
- if (val === null) {
- return 'null';
- }
- const typeOf = typeof val;
- if (typeOf === 'number') {
- return printNumber(val);
- }
- if (typeOf === 'bigint') {
- return printBigInt(val);
- }
- if (typeOf === 'string') {
- if (escapeString) {
- return '"' + val.replace(/"|\\/g, '\\$&') + '"';
- }
- return '"' + val + '"';
- }
- if (typeOf === 'function') {
- return printFunction(val, printFunctionName);
- }
- if (typeOf === 'symbol') {
- return printSymbol(val);
- }
- const toStringed = toString.call(val);
- if (toStringed === '[object WeakMap]') {
- return 'WeakMap {}';
- }
- if (toStringed === '[object WeakSet]') {
- return 'WeakSet {}';
- }
- if (
- toStringed === '[object Function]' ||
- toStringed === '[object GeneratorFunction]'
- ) {
- return printFunction(val, printFunctionName);
- }
- if (toStringed === '[object Symbol]') {
- return printSymbol(val);
- }
- if (toStringed === '[object Date]') {
- return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
- }
- if (toStringed === '[object Error]') {
- return printError(val);
- }
- if (toStringed === '[object RegExp]') {
- if (escapeRegex) {
- // https://github.com/benjamingr/RegExp.escape/blob/main/polyfill.js
- return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
- }
- return regExpToString.call(val);
- }
- if (val instanceof Error) {
- return printError(val);
- }
- return null;
- }
- /**
- * Handles more complex objects ( such as objects with circular references.
- * maps and sets etc )
- */
- function printComplexValue(
- val,
- config,
- indentation,
- depth,
- refs,
- hasCalledToJSON
- ) {
- if (refs.indexOf(val) !== -1) {
- return '[Circular]';
- }
- refs = refs.slice();
- refs.push(val);
- const hitMaxDepth = ++depth > config.maxDepth;
- const min = config.min;
- if (
- config.callToJSON &&
- !hitMaxDepth &&
- val.toJSON &&
- typeof val.toJSON === 'function' &&
- !hasCalledToJSON
- ) {
- return printer(val.toJSON(), config, indentation, depth, refs, true);
- }
- const toStringed = toString.call(val);
- if (toStringed === '[object Arguments]') {
- return hitMaxDepth
- ? '[Arguments]'
- : (min ? '' : 'Arguments ') +
- '[' +
- (0, _collections.printListItems)(
- val,
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- ']';
- }
- if (isToStringedArrayType(toStringed)) {
- return hitMaxDepth
- ? '[' + val.constructor.name + ']'
- : (min
- ? ''
- : !config.printBasicPrototype && val.constructor.name === 'Array'
- ? ''
- : val.constructor.name + ' ') +
- '[' +
- (0, _collections.printListItems)(
- val,
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- ']';
- }
- if (toStringed === '[object Map]') {
- return hitMaxDepth
- ? '[Map]'
- : 'Map {' +
- (0, _collections.printIteratorEntries)(
- val.entries(),
- config,
- indentation,
- depth,
- refs,
- printer,
- ' => '
- ) +
- '}';
- }
- if (toStringed === '[object Set]') {
- return hitMaxDepth
- ? '[Set]'
- : 'Set {' +
- (0, _collections.printIteratorValues)(
- val.values(),
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- '}';
- } // Avoid failure to serialize global window object in jsdom test environment.
- // For example, not even relevant if window is prop of React element.
- return hitMaxDepth || isWindow(val)
- ? '[' + getConstructorName(val) + ']'
- : (min
- ? ''
- : !config.printBasicPrototype && getConstructorName(val) === 'Object'
- ? ''
- : getConstructorName(val) + ' ') +
- '{' +
- (0, _collections.printObjectProperties)(
- val,
- config,
- indentation,
- depth,
- refs,
- printer
- ) +
- '}';
- }
- function isNewPlugin(plugin) {
- return plugin.serialize != null;
- }
- function printPlugin(plugin, val, config, indentation, depth, refs) {
- let printed;
- try {
- printed = isNewPlugin(plugin)
- ? plugin.serialize(val, config, indentation, depth, refs, printer)
- : plugin.print(
- val,
- valChild => printer(valChild, config, indentation, depth, refs),
- str => {
- const indentationNext = indentation + config.indent;
- return (
- indentationNext +
- str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
- );
- },
- {
- edgeSpacing: config.spacingOuter,
- min: config.min,
- spacing: config.spacingInner
- },
- config.colors
- );
- } catch (error) {
- throw new PrettyFormatPluginError(error.message, error.stack);
- }
- if (typeof printed !== 'string') {
- throw new Error(
- `pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
- );
- }
- return printed;
- }
- function findPlugin(plugins, val) {
- for (let p = 0; p < plugins.length; p++) {
- try {
- if (plugins[p].test(val)) {
- return plugins[p];
- }
- } catch (error) {
- throw new PrettyFormatPluginError(error.message, error.stack);
- }
- }
- return null;
- }
- function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
- const plugin = findPlugin(config.plugins, val);
- if (plugin !== null) {
- return printPlugin(plugin, val, config, indentation, depth, refs);
- }
- const basicResult = printBasicValue(
- val,
- config.printFunctionName,
- config.escapeRegex,
- config.escapeString
- );
- if (basicResult !== null) {
- return basicResult;
- }
- return printComplexValue(
- val,
- config,
- indentation,
- depth,
- refs,
- hasCalledToJSON
- );
- }
- const DEFAULT_THEME = {
- comment: 'gray',
- content: 'reset',
- prop: 'yellow',
- tag: 'cyan',
- value: 'green'
- };
- const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
- const DEFAULT_OPTIONS = {
- callToJSON: true,
- compareKeys: undefined,
- escapeRegex: false,
- escapeString: true,
- highlight: false,
- indent: 2,
- maxDepth: Infinity,
- min: false,
- plugins: [],
- printBasicPrototype: true,
- printFunctionName: true,
- theme: DEFAULT_THEME
- };
- build.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
- function validateOptions(options) {
- Object.keys(options).forEach(key => {
- if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
- throw new Error(`pretty-format: Unknown option "${key}".`);
- }
- });
- if (options.min && options.indent !== undefined && options.indent !== 0) {
- throw new Error(
- 'pretty-format: Options "min" and "indent" cannot be used together.'
- );
- }
- if (options.theme !== undefined) {
- if (options.theme === null) {
- throw new Error('pretty-format: Option "theme" must not be null.');
- }
- if (typeof options.theme !== 'object') {
- throw new Error(
- `pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
- );
- }
- }
- }
- const getColorsHighlight = options =>
- DEFAULT_THEME_KEYS.reduce((colors, key) => {
- const value =
- options.theme && options.theme[key] !== undefined
- ? options.theme[key]
- : DEFAULT_THEME[key];
- const color = value && _ansiStyles.default[value];
- if (
- color &&
- typeof color.close === 'string' &&
- typeof color.open === 'string'
- ) {
- colors[key] = color;
- } else {
- throw new Error(
- `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
- );
- }
- return colors;
- }, Object.create(null));
- const getColorsEmpty = () =>
- DEFAULT_THEME_KEYS.reduce((colors, key) => {
- colors[key] = {
- close: '',
- open: ''
- };
- return colors;
- }, Object.create(null));
- const getPrintFunctionName = options =>
- options && options.printFunctionName !== undefined
- ? options.printFunctionName
- : DEFAULT_OPTIONS.printFunctionName;
- const getEscapeRegex = options =>
- options && options.escapeRegex !== undefined
- ? options.escapeRegex
- : DEFAULT_OPTIONS.escapeRegex;
- const getEscapeString = options =>
- options && options.escapeString !== undefined
- ? options.escapeString
- : DEFAULT_OPTIONS.escapeString;
- const getConfig = options => {
- var _options$printBasicPr;
- return {
- callToJSON:
- options && options.callToJSON !== undefined
- ? options.callToJSON
- : DEFAULT_OPTIONS.callToJSON,
- colors:
- options && options.highlight
- ? getColorsHighlight(options)
- : getColorsEmpty(),
- compareKeys:
- options && typeof options.compareKeys === 'function'
- ? options.compareKeys
- : DEFAULT_OPTIONS.compareKeys,
- escapeRegex: getEscapeRegex(options),
- escapeString: getEscapeString(options),
- indent:
- options && options.min
- ? ''
- : createIndent(
- options && options.indent !== undefined
- ? options.indent
- : DEFAULT_OPTIONS.indent
- ),
- maxDepth:
- options && options.maxDepth !== undefined
- ? options.maxDepth
- : DEFAULT_OPTIONS.maxDepth,
- min:
- options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
- plugins:
- options && options.plugins !== undefined
- ? options.plugins
- : DEFAULT_OPTIONS.plugins,
- printBasicPrototype:
- (_options$printBasicPr =
- options === null || options === void 0
- ? void 0
- : options.printBasicPrototype) !== null &&
- _options$printBasicPr !== void 0
- ? _options$printBasicPr
- : true,
- printFunctionName: getPrintFunctionName(options),
- spacingInner: options && options.min ? ' ' : '\n',
- spacingOuter: options && options.min ? '' : '\n'
- };
- };
- function createIndent(indent) {
- return new Array(indent + 1).join(' ');
- }
- /**
- * Returns a presentation string of your `val` object
- * @param val any potential JavaScript object
- * @param options Custom settings
- */
- function format(val, options) {
- if (options) {
- validateOptions(options);
- if (options.plugins) {
- const plugin = findPlugin(options.plugins, val);
- if (plugin !== null) {
- return printPlugin(plugin, val, getConfig(options), '', 0, []);
- }
- }
- }
- const basicResult = printBasicValue(
- val,
- getPrintFunctionName(options),
- getEscapeRegex(options),
- getEscapeString(options)
- );
- if (basicResult !== null) {
- return basicResult;
- }
- return printComplexValue(val, getConfig(options), '', 0, []);
- }
- const plugins = {
- AsymmetricMatcher: _AsymmetricMatcher.default,
- ConvertAnsi: _ConvertAnsi.default,
- DOMCollection: _DOMCollection.default,
- DOMElement: _DOMElement.default,
- Immutable: _Immutable.default,
- ReactElement: _ReactElement.default,
- ReactTestComponent: _ReactTestComponent.default
- };
- plugins_1 = build.plugins = plugins;
- var _default = format;
- build.default = _default;
- var sourceMapGenerator = {};
- var base64Vlq = {};
- var base64$1 = {};
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
- /**
- * Encode an integer in the range of 0 to 63 to a single base 64 digit.
- */
- base64$1.encode = function (number) {
- if (0 <= number && number < intToCharMap.length) {
- return intToCharMap[number];
- }
- throw new TypeError("Must be between 0 and 63: " + number);
- };
- /**
- * Decode a single base 64 character code digit to an integer. Returns -1 on
- * failure.
- */
- base64$1.decode = function (charCode) {
- var bigA = 65; // 'A'
- var bigZ = 90; // 'Z'
- var littleA = 97; // 'a'
- var littleZ = 122; // 'z'
- var zero = 48; // '0'
- var nine = 57; // '9'
- var plus = 43; // '+'
- var slash = 47; // '/'
- var littleOffset = 26;
- var numberOffset = 52;
- // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
- if (bigA <= charCode && charCode <= bigZ) {
- return (charCode - bigA);
- }
- // 26 - 51: abcdefghijklmnopqrstuvwxyz
- if (littleA <= charCode && charCode <= littleZ) {
- return (charCode - littleA + littleOffset);
- }
- // 52 - 61: 0123456789
- if (zero <= charCode && charCode <= nine) {
- return (charCode - zero + numberOffset);
- }
- // 62: +
- if (charCode == plus) {
- return 62;
- }
- // 63: /
- if (charCode == slash) {
- return 63;
- }
- // Invalid base64 digit.
- return -1;
- };
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- *
- * Based on the Base 64 VLQ implementation in Closure Compiler:
- * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
- *
- * Copyright 2011 The Closure Compiler Authors. All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- var base64 = base64$1;
- // A single base 64 digit can contain 6 bits of data. For the base 64 variable
- // length quantities we use in the source map spec, the first bit is the sign,
- // the next four bits are the actual value, and the 6th bit is the
- // continuation bit. The continuation bit tells us whether there are more
- // digits in this value following this digit.
- //
- // Continuation
- // | Sign
- // | |
- // V V
- // 101011
- var VLQ_BASE_SHIFT = 5;
- // binary: 100000
- var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
- // binary: 011111
- var VLQ_BASE_MASK = VLQ_BASE - 1;
- // binary: 100000
- var VLQ_CONTINUATION_BIT = VLQ_BASE;
- /**
- * Converts from a two-complement value to a value where the sign bit is
- * placed in the least significant bit. For example, as decimals:
- * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
- * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
- */
- function toVLQSigned(aValue) {
- return aValue < 0
- ? ((-aValue) << 1) + 1
- : (aValue << 1) + 0;
- }
- /**
- * Converts to a two-complement value from a value where the sign bit is
- * placed in the least significant bit. For example, as decimals:
- * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
- * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
- */
- function fromVLQSigned(aValue) {
- var isNegative = (aValue & 1) === 1;
- var shifted = aValue >> 1;
- return isNegative
- ? -shifted
- : shifted;
- }
- /**
- * Returns the base 64 VLQ encoded value.
- */
- base64Vlq.encode = function base64VLQ_encode(aValue) {
- var encoded = "";
- var digit;
- var vlq = toVLQSigned(aValue);
- do {
- digit = vlq & VLQ_BASE_MASK;
- vlq >>>= VLQ_BASE_SHIFT;
- if (vlq > 0) {
- // There are still more digits in this value, so we must make sure the
- // continuation bit is marked.
- digit |= VLQ_CONTINUATION_BIT;
- }
- encoded += base64.encode(digit);
- } while (vlq > 0);
- return encoded;
- };
- /**
- * Decodes the next base 64 VLQ value from the given string and returns the
- * value and the rest of the string via the out parameter.
- */
- base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
- var strLen = aStr.length;
- var result = 0;
- var shift = 0;
- var continuation, digit;
- do {
- if (aIndex >= strLen) {
- throw new Error("Expected more digits in base 64 VLQ value.");
- }
- digit = base64.decode(aStr.charCodeAt(aIndex++));
- if (digit === -1) {
- throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
- }
- continuation = !!(digit & VLQ_CONTINUATION_BIT);
- digit &= VLQ_BASE_MASK;
- result = result + (digit << shift);
- shift += VLQ_BASE_SHIFT;
- } while (continuation);
- aOutParam.value = fromVLQSigned(result);
- aOutParam.rest = aIndex;
- };
- var util$5 = {};
- /* -*- Mode: js; js-indent-level: 2; -*- */
- (function (exports) {
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- /**
- * This is a helper function for getting values from parameter/options
- * objects.
- *
- * @param args The object we are extracting values from
- * @param name The name of the property we are getting.
- * @param defaultValue An optional value to return if the property is missing
- * from the object. If this is not specified and the property is missing, an
- * error will be thrown.
- */
- function getArg(aArgs, aName, aDefaultValue) {
- if (aName in aArgs) {
- return aArgs[aName];
- } else if (arguments.length === 3) {
- return aDefaultValue;
- } else {
- throw new Error('"' + aName + '" is a required argument.');
- }
- }
- exports.getArg = getArg;
- var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
- var dataUrlRegexp = /^data:.+\,.+$/;
- function urlParse(aUrl) {
- var match = aUrl.match(urlRegexp);
- if (!match) {
- return null;
- }
- return {
- scheme: match[1],
- auth: match[2],
- host: match[3],
- port: match[4],
- path: match[5]
- };
- }
- exports.urlParse = urlParse;
- function urlGenerate(aParsedUrl) {
- var url = '';
- if (aParsedUrl.scheme) {
- url += aParsedUrl.scheme + ':';
- }
- url += '//';
- if (aParsedUrl.auth) {
- url += aParsedUrl.auth + '@';
- }
- if (aParsedUrl.host) {
- url += aParsedUrl.host;
- }
- if (aParsedUrl.port) {
- url += ":" + aParsedUrl.port;
- }
- if (aParsedUrl.path) {
- url += aParsedUrl.path;
- }
- return url;
- }
- exports.urlGenerate = urlGenerate;
- var MAX_CACHED_INPUTS = 32;
- /**
- * Takes some function `f(input) -> result` and returns a memoized version of
- * `f`.
- *
- * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
- * memoization is a dumb-simple, linear least-recently-used cache.
- */
- function lruMemoize(f) {
- var cache = [];
- return function(input) {
- for (var i = 0; i < cache.length; i++) {
- if (cache[i].input === input) {
- var temp = cache[0];
- cache[0] = cache[i];
- cache[i] = temp;
- return cache[0].result;
- }
- }
- var result = f(input);
- cache.unshift({
- input,
- result,
- });
- if (cache.length > MAX_CACHED_INPUTS) {
- cache.pop();
- }
- return result;
- };
- }
- /**
- * Normalizes a path, or the path portion of a URL:
- *
- * - Replaces consecutive slashes with one slash.
- * - Removes unnecessary '.' parts.
- * - Removes unnecessary '<dir>/..' parts.
- *
- * Based on code in the Node.js 'path' core module.
- *
- * @param aPath The path or url to normalize.
- */
- var normalize = lruMemoize(function normalize(aPath) {
- var path = aPath;
- var url = urlParse(aPath);
- if (url) {
- if (!url.path) {
- return aPath;
- }
- path = url.path;
- }
- var isAbsolute = exports.isAbsolute(path);
- // Split the path into parts between `/` characters. This is much faster than
- // using `.split(/\/+/g)`.
- var parts = [];
- var start = 0;
- var i = 0;
- while (true) {
- start = i;
- i = path.indexOf("/", start);
- if (i === -1) {
- parts.push(path.slice(start));
- break;
- } else {
- parts.push(path.slice(start, i));
- while (i < path.length && path[i] === "/") {
- i++;
- }
- }
- }
- for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
- part = parts[i];
- if (part === '.') {
- parts.splice(i, 1);
- } else if (part === '..') {
- up++;
- } else if (up > 0) {
- if (part === '') {
- // The first part is blank if the path is absolute. Trying to go
- // above the root is a no-op. Therefore we can remove all '..' parts
- // directly after the root.
- parts.splice(i + 1, up);
- up = 0;
- } else {
- parts.splice(i, 2);
- up--;
- }
- }
- }
- path = parts.join('/');
- if (path === '') {
- path = isAbsolute ? '/' : '.';
- }
- if (url) {
- url.path = path;
- return urlGenerate(url);
- }
- return path;
- });
- exports.normalize = normalize;
- /**
- * Joins two paths/URLs.
- *
- * @param aRoot The root path or URL.
- * @param aPath The path or URL to be joined with the root.
- *
- * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
- * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
- * first.
- * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
- * is updated with the result and aRoot is returned. Otherwise the result
- * is returned.
- * - If aPath is absolute, the result is aPath.
- * - Otherwise the two paths are joined with a slash.
- * - Joining for example 'http://' and 'www.example.com' is also supported.
- */
- function join(aRoot, aPath) {
- if (aRoot === "") {
- aRoot = ".";
- }
- if (aPath === "") {
- aPath = ".";
- }
- var aPathUrl = urlParse(aPath);
- var aRootUrl = urlParse(aRoot);
- if (aRootUrl) {
- aRoot = aRootUrl.path || '/';
- }
- // `join(foo, '//www.example.org')`
- if (aPathUrl && !aPathUrl.scheme) {
- if (aRootUrl) {
- aPathUrl.scheme = aRootUrl.scheme;
- }
- return urlGenerate(aPathUrl);
- }
- if (aPathUrl || aPath.match(dataUrlRegexp)) {
- return aPath;
- }
- // `join('http://', 'www.example.com')`
- if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
- aRootUrl.host = aPath;
- return urlGenerate(aRootUrl);
- }
- var joined = aPath.charAt(0) === '/'
- ? aPath
- : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
- if (aRootUrl) {
- aRootUrl.path = joined;
- return urlGenerate(aRootUrl);
- }
- return joined;
- }
- exports.join = join;
- exports.isAbsolute = function (aPath) {
- return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
- };
- /**
- * Make a path relative to a URL or another path.
- *
- * @param aRoot The root path or URL.
- * @param aPath The path or URL to be made relative to aRoot.
- */
- function relative(aRoot, aPath) {
- if (aRoot === "") {
- aRoot = ".";
- }
- aRoot = aRoot.replace(/\/$/, '');
- // It is possible for the path to be above the root. In this case, simply
- // checking whether the root is a prefix of the path won't work. Instead, we
- // need to remove components from the root one by one, until either we find
- // a prefix that fits, or we run out of components to remove.
- var level = 0;
- while (aPath.indexOf(aRoot + '/') !== 0) {
- var index = aRoot.lastIndexOf("/");
- if (index < 0) {
- return aPath;
- }
- // If the only part of the root that is left is the scheme (i.e. http://,
- // file:///, etc.), one or more slashes (/), or simply nothing at all, we
- // have exhausted all components, so the path is not relative to the root.
- aRoot = aRoot.slice(0, index);
- if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
- return aPath;
- }
- ++level;
- }
- // Make sure we add a "../" for each component we removed from the root.
- return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
- }
- exports.relative = relative;
- var supportsNullProto = (function () {
- var obj = Object.create(null);
- return !('__proto__' in obj);
- }());
- function identity (s) {
- return s;
- }
- /**
- * Because behavior goes wacky when you set `__proto__` on objects, we
- * have to prefix all the strings in our set with an arbitrary character.
- *
- * See https://github.com/mozilla/source-map/pull/31 and
- * https://github.com/mozilla/source-map/issues/30
- *
- * @param String aStr
- */
- function toSetString(aStr) {
- if (isProtoString(aStr)) {
- return '$' + aStr;
- }
- return aStr;
- }
- exports.toSetString = supportsNullProto ? identity : toSetString;
- function fromSetString(aStr) {
- if (isProtoString(aStr)) {
- return aStr.slice(1);
- }
- return aStr;
- }
- exports.fromSetString = supportsNullProto ? identity : fromSetString;
- function isProtoString(s) {
- if (!s) {
- return false;
- }
- var length = s.length;
- if (length < 9 /* "__proto__".length */) {
- return false;
- }
- if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
- s.charCodeAt(length - 2) !== 95 /* '_' */ ||
- s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
- s.charCodeAt(length - 4) !== 116 /* 't' */ ||
- s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
- s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
- s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
- s.charCodeAt(length - 8) !== 95 /* '_' */ ||
- s.charCodeAt(length - 9) !== 95 /* '_' */) {
- return false;
- }
- for (var i = length - 10; i >= 0; i--) {
- if (s.charCodeAt(i) !== 36 /* '$' */) {
- return false;
- }
- }
- return true;
- }
- /**
- * Comparator between two mappings where the original positions are compared.
- *
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
- * mappings with the same original source/line/column, but different generated
- * line and column the same. Useful when searching for a mapping with a
- * stubbed out mapping.
- */
- function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
- var cmp = strcmp(mappingA.source, mappingB.source);
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalLine - mappingB.originalLine;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalColumn - mappingB.originalColumn;
- if (cmp !== 0 || onlyCompareOriginal) {
- return cmp;
- }
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.generatedLine - mappingB.generatedLine;
- if (cmp !== 0) {
- return cmp;
- }
- return strcmp(mappingA.name, mappingB.name);
- }
- exports.compareByOriginalPositions = compareByOriginalPositions;
- function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
- var cmp;
- cmp = mappingA.originalLine - mappingB.originalLine;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalColumn - mappingB.originalColumn;
- if (cmp !== 0 || onlyCompareOriginal) {
- return cmp;
- }
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.generatedLine - mappingB.generatedLine;
- if (cmp !== 0) {
- return cmp;
- }
- return strcmp(mappingA.name, mappingB.name);
- }
- exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
- /**
- * Comparator between two mappings with deflated source and name indices where
- * the generated positions are compared.
- *
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
- * mappings with the same generated line and column, but different
- * source/name/original line and column the same. Useful when searching for a
- * mapping with a stubbed out mapping.
- */
- function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
- var cmp = mappingA.generatedLine - mappingB.generatedLine;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
- if (cmp !== 0 || onlyCompareGenerated) {
- return cmp;
- }
- cmp = strcmp(mappingA.source, mappingB.source);
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalLine - mappingB.originalLine;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalColumn - mappingB.originalColumn;
- if (cmp !== 0) {
- return cmp;
- }
- return strcmp(mappingA.name, mappingB.name);
- }
- exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
- function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
- var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
- if (cmp !== 0 || onlyCompareGenerated) {
- return cmp;
- }
- cmp = strcmp(mappingA.source, mappingB.source);
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalLine - mappingB.originalLine;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalColumn - mappingB.originalColumn;
- if (cmp !== 0) {
- return cmp;
- }
- return strcmp(mappingA.name, mappingB.name);
- }
- exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
- function strcmp(aStr1, aStr2) {
- if (aStr1 === aStr2) {
- return 0;
- }
- if (aStr1 === null) {
- return 1; // aStr2 !== null
- }
- if (aStr2 === null) {
- return -1; // aStr1 !== null
- }
- if (aStr1 > aStr2) {
- return 1;
- }
- return -1;
- }
- /**
- * Comparator between two mappings with inflated source and name strings where
- * the generated positions are compared.
- */
- function compareByGeneratedPositionsInflated(mappingA, mappingB) {
- var cmp = mappingA.generatedLine - mappingB.generatedLine;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = strcmp(mappingA.source, mappingB.source);
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalLine - mappingB.originalLine;
- if (cmp !== 0) {
- return cmp;
- }
- cmp = mappingA.originalColumn - mappingB.originalColumn;
- if (cmp !== 0) {
- return cmp;
- }
- return strcmp(mappingA.name, mappingB.name);
- }
- exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
- /**
- * Strip any JSON XSSI avoidance prefix from the string (as documented
- * in the source maps specification), and then parse the string as
- * JSON.
- */
- function parseSourceMapInput(str) {
- return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
- }
- exports.parseSourceMapInput = parseSourceMapInput;
- /**
- * Compute the URL of a source given the the source root, the source's
- * URL, and the source map's URL.
- */
- function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
- sourceURL = sourceURL || '';
- if (sourceRoot) {
- // This follows what Chrome does.
- if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
- sourceRoot += '/';
- }
- // The spec says:
- // Line 4: An optional source root, useful for relocating source
- // files on a server or removing repeated values in the
- // “sources” entry. This value is prepended to the individual
- // entries in the “source” field.
- sourceURL = sourceRoot + sourceURL;
- }
- // Historically, SourceMapConsumer did not take the sourceMapURL as
- // a parameter. This mode is still somewhat supported, which is why
- // this code block is conditional. However, it's preferable to pass
- // the source map URL to SourceMapConsumer, so that this function
- // can implement the source URL resolution algorithm as outlined in
- // the spec. This block is basically the equivalent of:
- // new URL(sourceURL, sourceMapURL).toString()
- // ... except it avoids using URL, which wasn't available in the
- // older releases of node still supported by this library.
- //
- // The spec says:
- // If the sources are not absolute URLs after prepending of the
- // “sourceRoot”, the sources are resolved relative to the
- // SourceMap (like resolving script src in a html document).
- if (sourceMapURL) {
- var parsed = urlParse(sourceMapURL);
- if (!parsed) {
- throw new Error("sourceMapURL could not be parsed");
- }
- if (parsed.path) {
- // Strip the last path component, but keep the "/".
- var index = parsed.path.lastIndexOf('/');
- if (index >= 0) {
- parsed.path = parsed.path.substring(0, index + 1);
- }
- }
- sourceURL = join(urlGenerate(parsed), sourceURL);
- }
- return normalize(sourceURL);
- }
- exports.computeSourceURL = computeSourceURL;
- } (util$5));
- var arraySet = {};
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- var util$4 = util$5;
- var has = Object.prototype.hasOwnProperty;
- var hasNativeMap = typeof Map !== "undefined";
- /**
- * A data structure which is a combination of an array and a set. Adding a new
- * member is O(1), testing for membership is O(1), and finding the index of an
- * element is O(1). Removing elements from the set is not supported. Only
- * strings are supported for membership.
- */
- function ArraySet$2() {
- this._array = [];
- this._set = hasNativeMap ? new Map() : Object.create(null);
- }
- /**
- * Static method for creating ArraySet instances from an existing array.
- */
- ArraySet$2.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
- var set = new ArraySet$2();
- for (var i = 0, len = aArray.length; i < len; i++) {
- set.add(aArray[i], aAllowDuplicates);
- }
- return set;
- };
- /**
- * Return how many unique items are in this ArraySet. If duplicates have been
- * added, than those do not count towards the size.
- *
- * @returns Number
- */
- ArraySet$2.prototype.size = function ArraySet_size() {
- return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
- };
- /**
- * Add the given string to this set.
- *
- * @param String aStr
- */
- ArraySet$2.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
- var sStr = hasNativeMap ? aStr : util$4.toSetString(aStr);
- var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
- var idx = this._array.length;
- if (!isDuplicate || aAllowDuplicates) {
- this._array.push(aStr);
- }
- if (!isDuplicate) {
- if (hasNativeMap) {
- this._set.set(aStr, idx);
- } else {
- this._set[sStr] = idx;
- }
- }
- };
- /**
- * Is the given string a member of this set?
- *
- * @param String aStr
- */
- ArraySet$2.prototype.has = function ArraySet_has(aStr) {
- if (hasNativeMap) {
- return this._set.has(aStr);
- } else {
- var sStr = util$4.toSetString(aStr);
- return has.call(this._set, sStr);
- }
- };
- /**
- * What is the index of the given string in the array?
- *
- * @param String aStr
- */
- ArraySet$2.prototype.indexOf = function ArraySet_indexOf(aStr) {
- if (hasNativeMap) {
- var idx = this._set.get(aStr);
- if (idx >= 0) {
- return idx;
- }
- } else {
- var sStr = util$4.toSetString(aStr);
- if (has.call(this._set, sStr)) {
- return this._set[sStr];
- }
- }
- throw new Error('"' + aStr + '" is not in the set.');
- };
- /**
- * What is the element at the given index?
- *
- * @param Number aIdx
- */
- ArraySet$2.prototype.at = function ArraySet_at(aIdx) {
- if (aIdx >= 0 && aIdx < this._array.length) {
- return this._array[aIdx];
- }
- throw new Error('No element indexed by ' + aIdx);
- };
- /**
- * Returns the array representation of this set (which has the proper indices
- * indicated by indexOf). Note that this is a copy of the internal array used
- * for storing the members so that no one can mess with internal state.
- */
- ArraySet$2.prototype.toArray = function ArraySet_toArray() {
- return this._array.slice();
- };
- arraySet.ArraySet = ArraySet$2;
- var mappingList = {};
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2014 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- var util$3 = util$5;
- /**
- * Determine whether mappingB is after mappingA with respect to generated
- * position.
- */
- function generatedPositionAfter(mappingA, mappingB) {
- // Optimized for most common case
- var lineA = mappingA.generatedLine;
- var lineB = mappingB.generatedLine;
- var columnA = mappingA.generatedColumn;
- var columnB = mappingB.generatedColumn;
- return lineB > lineA || lineB == lineA && columnB >= columnA ||
- util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
- }
- /**
- * A data structure to provide a sorted view of accumulated mappings in a
- * performance conscious manner. It trades a neglibable overhead in general
- * case for a large speedup in case of mappings being added in order.
- */
- function MappingList$1() {
- this._array = [];
- this._sorted = true;
- // Serves as infimum
- this._last = {generatedLine: -1, generatedColumn: 0};
- }
- /**
- * Iterate through internal items. This method takes the same arguments that
- * `Array.prototype.forEach` takes.
- *
- * NOTE: The order of the mappings is NOT guaranteed.
- */
- MappingList$1.prototype.unsortedForEach =
- function MappingList_forEach(aCallback, aThisArg) {
- this._array.forEach(aCallback, aThisArg);
- };
- /**
- * Add the given source mapping.
- *
- * @param Object aMapping
- */
- MappingList$1.prototype.add = function MappingList_add(aMapping) {
- if (generatedPositionAfter(this._last, aMapping)) {
- this._last = aMapping;
- this._array.push(aMapping);
- } else {
- this._sorted = false;
- this._array.push(aMapping);
- }
- };
- /**
- * Returns the flat, sorted array of mappings. The mappings are sorted by
- * generated position.
- *
- * WARNING: This method returns internal data without copying, for
- * performance. The return value must NOT be mutated, and should be treated as
- * an immutable borrow. If you want to take ownership, you must make your own
- * copy.
- */
- MappingList$1.prototype.toArray = function MappingList_toArray() {
- if (!this._sorted) {
- this._array.sort(util$3.compareByGeneratedPositionsInflated);
- this._sorted = true;
- }
- return this._array;
- };
- mappingList.MappingList = MappingList$1;
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- var base64VLQ$1 = base64Vlq;
- var util$2 = util$5;
- var ArraySet$1 = arraySet.ArraySet;
- var MappingList = mappingList.MappingList;
- /**
- * An instance of the SourceMapGenerator represents a source map which is
- * being built incrementally. You may pass an object with the following
- * properties:
- *
- * - file: The filename of the generated source.
- * - sourceRoot: A root for all relative URLs in this source map.
- */
- function SourceMapGenerator$1(aArgs) {
- if (!aArgs) {
- aArgs = {};
- }
- this._file = util$2.getArg(aArgs, 'file', null);
- this._sourceRoot = util$2.getArg(aArgs, 'sourceRoot', null);
- this._skipValidation = util$2.getArg(aArgs, 'skipValidation', false);
- this._sources = new ArraySet$1();
- this._names = new ArraySet$1();
- this._mappings = new MappingList();
- this._sourcesContents = null;
- }
- SourceMapGenerator$1.prototype._version = 3;
- /**
- * Creates a new SourceMapGenerator based on a SourceMapConsumer
- *
- * @param aSourceMapConsumer The SourceMap.
- */
- SourceMapGenerator$1.fromSourceMap =
- function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
- var sourceRoot = aSourceMapConsumer.sourceRoot;
- var generator = new SourceMapGenerator$1({
- file: aSourceMapConsumer.file,
- sourceRoot: sourceRoot
- });
- aSourceMapConsumer.eachMapping(function (mapping) {
- var newMapping = {
- generated: {
- line: mapping.generatedLine,
- column: mapping.generatedColumn
- }
- };
- if (mapping.source != null) {
- newMapping.source = mapping.source;
- if (sourceRoot != null) {
- newMapping.source = util$2.relative(sourceRoot, newMapping.source);
- }
- newMapping.original = {
- line: mapping.originalLine,
- column: mapping.originalColumn
- };
- if (mapping.name != null) {
- newMapping.name = mapping.name;
- }
- }
- generator.addMapping(newMapping);
- });
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
- var sourceRelative = sourceFile;
- if (sourceRoot !== null) {
- sourceRelative = util$2.relative(sourceRoot, sourceFile);
- }
- if (!generator._sources.has(sourceRelative)) {
- generator._sources.add(sourceRelative);
- }
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
- generator.setSourceContent(sourceFile, content);
- }
- });
- return generator;
- };
- /**
- * Add a single mapping from original source line and column to the generated
- * source's line and column for this source map being created. The mapping
- * object should have the following properties:
- *
- * - generated: An object with the generated line and column positions.
- * - original: An object with the original line and column positions.
- * - source: The original source file (relative to the sourceRoot).
- * - name: An optional original token name for this mapping.
- */
- SourceMapGenerator$1.prototype.addMapping =
- function SourceMapGenerator_addMapping(aArgs) {
- var generated = util$2.getArg(aArgs, 'generated');
- var original = util$2.getArg(aArgs, 'original', null);
- var source = util$2.getArg(aArgs, 'source', null);
- var name = util$2.getArg(aArgs, 'name', null);
- if (!this._skipValidation) {
- this._validateMapping(generated, original, source, name);
- }
- if (source != null) {
- source = String(source);
- if (!this._sources.has(source)) {
- this._sources.add(source);
- }
- }
- if (name != null) {
- name = String(name);
- if (!this._names.has(name)) {
- this._names.add(name);
- }
- }
- this._mappings.add({
- generatedLine: generated.line,
- generatedColumn: generated.column,
- originalLine: original != null && original.line,
- originalColumn: original != null && original.column,
- source: source,
- name: name
- });
- };
- /**
- * Set the source content for a source file.
- */
- SourceMapGenerator$1.prototype.setSourceContent =
- function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
- var source = aSourceFile;
- if (this._sourceRoot != null) {
- source = util$2.relative(this._sourceRoot, source);
- }
- if (aSourceContent != null) {
- // Add the source content to the _sourcesContents map.
- // Create a new _sourcesContents map if the property is null.
- if (!this._sourcesContents) {
- this._sourcesContents = Object.create(null);
- }
- this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
- } else if (this._sourcesContents) {
- // Remove the source file from the _sourcesContents map.
- // If the _sourcesContents map is empty, set the property to null.
- delete this._sourcesContents[util$2.toSetString(source)];
- if (Object.keys(this._sourcesContents).length === 0) {
- this._sourcesContents = null;
- }
- }
- };
- /**
- * Applies the mappings of a sub-source-map for a specific source file to the
- * source map being generated. Each mapping to the supplied source file is
- * rewritten using the supplied source map. Note: The resolution for the
- * resulting mappings is the minimium of this map and the supplied map.
- *
- * @param aSourceMapConsumer The source map to be applied.
- * @param aSourceFile Optional. The filename of the source file.
- * If omitted, SourceMapConsumer's file property will be used.
- * @param aSourceMapPath Optional. The dirname of the path to the source map
- * to be applied. If relative, it is relative to the SourceMapConsumer.
- * This parameter is needed when the two source maps aren't in the same
- * directory, and the source map to be applied contains relative source
- * paths. If so, those relative source paths need to be rewritten
- * relative to the SourceMapGenerator.
- */
- SourceMapGenerator$1.prototype.applySourceMap =
- function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
- var sourceFile = aSourceFile;
- // If aSourceFile is omitted, we will use the file property of the SourceMap
- if (aSourceFile == null) {
- if (aSourceMapConsumer.file == null) {
- throw new Error(
- 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
- 'or the source map\'s "file" property. Both were omitted.'
- );
- }
- sourceFile = aSourceMapConsumer.file;
- }
- var sourceRoot = this._sourceRoot;
- // Make "sourceFile" relative if an absolute Url is passed.
- if (sourceRoot != null) {
- sourceFile = util$2.relative(sourceRoot, sourceFile);
- }
- // Applying the SourceMap can add and remove items from the sources and
- // the names array.
- var newSources = new ArraySet$1();
- var newNames = new ArraySet$1();
- // Find mappings for the "sourceFile"
- this._mappings.unsortedForEach(function (mapping) {
- if (mapping.source === sourceFile && mapping.originalLine != null) {
- // Check if it can be mapped by the source map, then update the mapping.
- var original = aSourceMapConsumer.originalPositionFor({
- line: mapping.originalLine,
- column: mapping.originalColumn
- });
- if (original.source != null) {
- // Copy mapping
- mapping.source = original.source;
- if (aSourceMapPath != null) {
- mapping.source = util$2.join(aSourceMapPath, mapping.source);
- }
- if (sourceRoot != null) {
- mapping.source = util$2.relative(sourceRoot, mapping.source);
- }
- mapping.originalLine = original.line;
- mapping.originalColumn = original.column;
- if (original.name != null) {
- mapping.name = original.name;
- }
- }
- }
- var source = mapping.source;
- if (source != null && !newSources.has(source)) {
- newSources.add(source);
- }
- var name = mapping.name;
- if (name != null && !newNames.has(name)) {
- newNames.add(name);
- }
- }, this);
- this._sources = newSources;
- this._names = newNames;
- // Copy sourcesContents of applied map.
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
- if (aSourceMapPath != null) {
- sourceFile = util$2.join(aSourceMapPath, sourceFile);
- }
- if (sourceRoot != null) {
- sourceFile = util$2.relative(sourceRoot, sourceFile);
- }
- this.setSourceContent(sourceFile, content);
- }
- }, this);
- };
- /**
- * A mapping can have one of the three levels of data:
- *
- * 1. Just the generated position.
- * 2. The Generated position, original position, and original source.
- * 3. Generated and original position, original source, as well as a name
- * token.
- *
- * To maintain consistency, we validate that any new mapping being added falls
- * in to one of these categories.
- */
- SourceMapGenerator$1.prototype._validateMapping =
- function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
- aName) {
- // When aOriginal is truthy but has empty values for .line and .column,
- // it is most likely a programmer error. In this case we throw a very
- // specific error message to try to guide them the right way.
- // For example: https://github.com/Polymer/polymer-bundler/pull/519
- if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
- throw new Error(
- 'original.line and original.column are not numbers -- you probably meant to omit ' +
- 'the original mapping entirely and only map the generated position. If so, pass ' +
- 'null for the original mapping instead of an object with empty or null values.'
- );
- }
- if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
- && aGenerated.line > 0 && aGenerated.column >= 0
- && !aOriginal && !aSource && !aName) {
- // Case 1.
- return;
- }
- else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
- && aOriginal && 'line' in aOriginal && 'column' in aOriginal
- && aGenerated.line > 0 && aGenerated.column >= 0
- && aOriginal.line > 0 && aOriginal.column >= 0
- && aSource) {
- // Cases 2 and 3.
- return;
- }
- else {
- throw new Error('Invalid mapping: ' + JSON.stringify({
- generated: aGenerated,
- source: aSource,
- original: aOriginal,
- name: aName
- }));
- }
- };
- /**
- * Serialize the accumulated mappings in to the stream of base 64 VLQs
- * specified by the source map format.
- */
- SourceMapGenerator$1.prototype._serializeMappings =
- function SourceMapGenerator_serializeMappings() {
- var previousGeneratedColumn = 0;
- var previousGeneratedLine = 1;
- var previousOriginalColumn = 0;
- var previousOriginalLine = 0;
- var previousName = 0;
- var previousSource = 0;
- var result = '';
- var next;
- var mapping;
- var nameIdx;
- var sourceIdx;
- var mappings = this._mappings.toArray();
- for (var i = 0, len = mappings.length; i < len; i++) {
- mapping = mappings[i];
- next = '';
- if (mapping.generatedLine !== previousGeneratedLine) {
- previousGeneratedColumn = 0;
- while (mapping.generatedLine !== previousGeneratedLine) {
- next += ';';
- previousGeneratedLine++;
- }
- }
- else {
- if (i > 0) {
- if (!util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
- continue;
- }
- next += ',';
- }
- }
- next += base64VLQ$1.encode(mapping.generatedColumn
- - previousGeneratedColumn);
- previousGeneratedColumn = mapping.generatedColumn;
- if (mapping.source != null) {
- sourceIdx = this._sources.indexOf(mapping.source);
- next += base64VLQ$1.encode(sourceIdx - previousSource);
- previousSource = sourceIdx;
- // lines are stored 0-based in SourceMap spec version 3
- next += base64VLQ$1.encode(mapping.originalLine - 1
- - previousOriginalLine);
- previousOriginalLine = mapping.originalLine - 1;
- next += base64VLQ$1.encode(mapping.originalColumn
- - previousOriginalColumn);
- previousOriginalColumn = mapping.originalColumn;
- if (mapping.name != null) {
- nameIdx = this._names.indexOf(mapping.name);
- next += base64VLQ$1.encode(nameIdx - previousName);
- previousName = nameIdx;
- }
- }
- result += next;
- }
- return result;
- };
- SourceMapGenerator$1.prototype._generateSourcesContent =
- function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
- return aSources.map(function (source) {
- if (!this._sourcesContents) {
- return null;
- }
- if (aSourceRoot != null) {
- source = util$2.relative(aSourceRoot, source);
- }
- var key = util$2.toSetString(source);
- return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
- ? this._sourcesContents[key]
- : null;
- }, this);
- };
- /**
- * Externalize the source map.
- */
- SourceMapGenerator$1.prototype.toJSON =
- function SourceMapGenerator_toJSON() {
- var map = {
- version: this._version,
- sources: this._sources.toArray(),
- names: this._names.toArray(),
- mappings: this._serializeMappings()
- };
- if (this._file != null) {
- map.file = this._file;
- }
- if (this._sourceRoot != null) {
- map.sourceRoot = this._sourceRoot;
- }
- if (this._sourcesContents) {
- map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
- }
- return map;
- };
- /**
- * Render the source map being generated to a string.
- */
- SourceMapGenerator$1.prototype.toString =
- function SourceMapGenerator_toString() {
- return JSON.stringify(this.toJSON());
- };
- sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$1;
- var sourceMapConsumer = {};
- var binarySearch$1 = {};
- /* -*- Mode: js; js-indent-level: 2; -*- */
- (function (exports) {
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- exports.GREATEST_LOWER_BOUND = 1;
- exports.LEAST_UPPER_BOUND = 2;
- /**
- * Recursive implementation of binary search.
- *
- * @param aLow Indices here and lower do not contain the needle.
- * @param aHigh Indices here and higher do not contain the needle.
- * @param aNeedle The element being searched for.
- * @param aHaystack The non-empty array being searched.
- * @param aCompare Function which takes two elements and returns -1, 0, or 1.
- * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
- * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- */
- function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
- // This function terminates when one of the following is true:
- //
- // 1. We find the exact element we are looking for.
- //
- // 2. We did not find the exact element, but we can return the index of
- // the next-closest element.
- //
- // 3. We did not find the exact element, and there is no next-closest
- // element than the one we are searching for, so we return -1.
- var mid = Math.floor((aHigh - aLow) / 2) + aLow;
- var cmp = aCompare(aNeedle, aHaystack[mid], true);
- if (cmp === 0) {
- // Found the element we are looking for.
- return mid;
- }
- else if (cmp > 0) {
- // Our needle is greater than aHaystack[mid].
- if (aHigh - mid > 1) {
- // The element is in the upper half.
- return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
- }
- // The exact needle element was not found in this haystack. Determine if
- // we are in termination case (3) or (2) and return the appropriate thing.
- if (aBias == exports.LEAST_UPPER_BOUND) {
- return aHigh < aHaystack.length ? aHigh : -1;
- } else {
- return mid;
- }
- }
- else {
- // Our needle is less than aHaystack[mid].
- if (mid - aLow > 1) {
- // The element is in the lower half.
- return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
- }
- // we are in termination case (3) or (2) and return the appropriate thing.
- if (aBias == exports.LEAST_UPPER_BOUND) {
- return mid;
- } else {
- return aLow < 0 ? -1 : aLow;
- }
- }
- }
- /**
- * This is an implementation of binary search which will always try and return
- * the index of the closest element if there is no exact hit. This is because
- * mappings between original and generated line/col pairs are single points,
- * and there is an implicit region between each of them, so a miss just means
- * that you aren't on the very start of a region.
- *
- * @param aNeedle The element you are looking for.
- * @param aHaystack The array that is being searched.
- * @param aCompare A function which takes the needle and an element in the
- * array and returns -1, 0, or 1 depending on whether the needle is less
- * than, equal to, or greater than the element, respectively.
- * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
- * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
- */
- exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
- if (aHaystack.length === 0) {
- return -1;
- }
- var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
- aCompare, aBias || exports.GREATEST_LOWER_BOUND);
- if (index < 0) {
- return -1;
- }
- // We have found either the exact element, or the next-closest element than
- // the one we are searching for. However, there may be more than one such
- // element. Make sure we always return the smallest of these.
- while (index - 1 >= 0) {
- if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
- break;
- }
- --index;
- }
- return index;
- };
- } (binarySearch$1));
- var quickSort$1 = {};
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- // It turns out that some (most?) JavaScript engines don't self-host
- // `Array.prototype.sort`. This makes sense because C++ will likely remain
- // faster than JS when doing raw CPU-intensive sorting. However, when using a
- // custom comparator function, calling back and forth between the VM's C++ and
- // JIT'd JS is rather slow *and* loses JIT type information, resulting in
- // worse generated code for the comparator function than would be optimal. In
- // fact, when sorting with a comparator, these costs outweigh the benefits of
- // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
- // a ~3500ms mean speed-up in `bench/bench.html`.
- function SortTemplate(comparator) {
- /**
- * Swap the elements indexed by `x` and `y` in the array `ary`.
- *
- * @param {Array} ary
- * The array.
- * @param {Number} x
- * The index of the first item.
- * @param {Number} y
- * The index of the second item.
- */
- function swap(ary, x, y) {
- var temp = ary[x];
- ary[x] = ary[y];
- ary[y] = temp;
- }
- /**
- * Returns a random integer within the range `low .. high` inclusive.
- *
- * @param {Number} low
- * The lower bound on the range.
- * @param {Number} high
- * The upper bound on the range.
- */
- function randomIntInRange(low, high) {
- return Math.round(low + (Math.random() * (high - low)));
- }
- /**
- * The Quick Sort algorithm.
- *
- * @param {Array} ary
- * An array to sort.
- * @param {function} comparator
- * Function to use to compare two items.
- * @param {Number} p
- * Start index of the array
- * @param {Number} r
- * End index of the array
- */
- function doQuickSort(ary, comparator, p, r) {
- // If our lower bound is less than our upper bound, we (1) partition the
- // array into two pieces and (2) recurse on each half. If it is not, this is
- // the empty array and our base case.
- if (p < r) {
- // (1) Partitioning.
- //
- // The partitioning chooses a pivot between `p` and `r` and moves all
- // elements that are less than or equal to the pivot to the before it, and
- // all the elements that are greater than it after it. The effect is that
- // once partition is done, the pivot is in the exact place it will be when
- // the array is put in sorted order, and it will not need to be moved
- // again. This runs in O(n) time.
- // Always choose a random pivot so that an input array which is reverse
- // sorted does not cause O(n^2) running time.
- var pivotIndex = randomIntInRange(p, r);
- var i = p - 1;
- swap(ary, pivotIndex, r);
- var pivot = ary[r];
- // Immediately after `j` is incremented in this loop, the following hold
- // true:
- //
- // * Every element in `ary[p .. i]` is less than or equal to the pivot.
- //
- // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
- for (var j = p; j < r; j++) {
- if (comparator(ary[j], pivot, false) <= 0) {
- i += 1;
- swap(ary, i, j);
- }
- }
- swap(ary, i + 1, j);
- var q = i + 1;
- // (2) Recurse on each half.
- doQuickSort(ary, comparator, p, q - 1);
- doQuickSort(ary, comparator, q + 1, r);
- }
- }
- return doQuickSort;
- }
- function cloneSort(comparator) {
- let template = SortTemplate.toString();
- let templateFn = new Function(`return ${template}`)();
- return templateFn(comparator);
- }
- /**
- * Sort the given array in-place with the given comparator function.
- *
- * @param {Array} ary
- * An array to sort.
- * @param {function} comparator
- * Function to use to compare two items.
- */
- let sortCache = new WeakMap();
- quickSort$1.quickSort = function (ary, comparator, start = 0) {
- let doQuickSort = sortCache.get(comparator);
- if (doQuickSort === void 0) {
- doQuickSort = cloneSort(comparator);
- sortCache.set(comparator, doQuickSort);
- }
- doQuickSort(ary, comparator, start, ary.length - 1);
- };
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- var util$1 = util$5;
- var binarySearch = binarySearch$1;
- var ArraySet = arraySet.ArraySet;
- var base64VLQ = base64Vlq;
- var quickSort = quickSort$1.quickSort;
- function SourceMapConsumer$1(aSourceMap, aSourceMapURL) {
- var sourceMap = aSourceMap;
- if (typeof aSourceMap === 'string') {
- sourceMap = util$1.parseSourceMapInput(aSourceMap);
- }
- return sourceMap.sections != null
- ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
- : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
- }
- SourceMapConsumer$1.fromSourceMap = function(aSourceMap, aSourceMapURL) {
- return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
- };
- /**
- * The version of the source mapping spec that we are consuming.
- */
- SourceMapConsumer$1.prototype._version = 3;
- // `__generatedMappings` and `__originalMappings` are arrays that hold the
- // parsed mapping coordinates from the source map's "mappings" attribute. They
- // are lazily instantiated, accessed via the `_generatedMappings` and
- // `_originalMappings` getters respectively, and we only parse the mappings
- // and create these arrays once queried for a source location. We jump through
- // these hoops because there can be many thousands of mappings, and parsing
- // them is expensive, so we only want to do it if we must.
- //
- // Each object in the arrays is of the form:
- //
- // {
- // generatedLine: The line number in the generated code,
- // generatedColumn: The column number in the generated code,
- // source: The path to the original source file that generated this
- // chunk of code,
- // originalLine: The line number in the original source that
- // corresponds to this chunk of generated code,
- // originalColumn: The column number in the original source that
- // corresponds to this chunk of generated code,
- // name: The name of the original symbol which generated this chunk of
- // code.
- // }
- //
- // All properties except for `generatedLine` and `generatedColumn` can be
- // `null`.
- //
- // `_generatedMappings` is ordered by the generated positions.
- //
- // `_originalMappings` is ordered by the original positions.
- SourceMapConsumer$1.prototype.__generatedMappings = null;
- Object.defineProperty(SourceMapConsumer$1.prototype, '_generatedMappings', {
- configurable: true,
- enumerable: true,
- get: function () {
- if (!this.__generatedMappings) {
- this._parseMappings(this._mappings, this.sourceRoot);
- }
- return this.__generatedMappings;
- }
- });
- SourceMapConsumer$1.prototype.__originalMappings = null;
- Object.defineProperty(SourceMapConsumer$1.prototype, '_originalMappings', {
- configurable: true,
- enumerable: true,
- get: function () {
- if (!this.__originalMappings) {
- this._parseMappings(this._mappings, this.sourceRoot);
- }
- return this.__originalMappings;
- }
- });
- SourceMapConsumer$1.prototype._charIsMappingSeparator =
- function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
- var c = aStr.charAt(index);
- return c === ";" || c === ",";
- };
- /**
- * Parse the mappings in a string in to a data structure which we can easily
- * query (the ordered arrays in the `this.__generatedMappings` and
- * `this.__originalMappings` properties).
- */
- SourceMapConsumer$1.prototype._parseMappings =
- function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
- throw new Error("Subclasses must implement _parseMappings");
- };
- SourceMapConsumer$1.GENERATED_ORDER = 1;
- SourceMapConsumer$1.ORIGINAL_ORDER = 2;
- SourceMapConsumer$1.GREATEST_LOWER_BOUND = 1;
- SourceMapConsumer$1.LEAST_UPPER_BOUND = 2;
- /**
- * Iterate over each mapping between an original source/line/column and a
- * generated line/column in this source map.
- *
- * @param Function aCallback
- * The function that is called with each mapping.
- * @param Object aContext
- * Optional. If specified, this object will be the value of `this` every
- * time that `aCallback` is called.
- * @param aOrder
- * Either `SourceMapConsumer.GENERATED_ORDER` or
- * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
- * iterate over the mappings sorted by the generated file's line/column
- * order or the original's source/line/column order, respectively. Defaults to
- * `SourceMapConsumer.GENERATED_ORDER`.
- */
- SourceMapConsumer$1.prototype.eachMapping =
- function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
- var context = aContext || null;
- var order = aOrder || SourceMapConsumer$1.GENERATED_ORDER;
- var mappings;
- switch (order) {
- case SourceMapConsumer$1.GENERATED_ORDER:
- mappings = this._generatedMappings;
- break;
- case SourceMapConsumer$1.ORIGINAL_ORDER:
- mappings = this._originalMappings;
- break;
- default:
- throw new Error("Unknown order of iteration.");
- }
- var sourceRoot = this.sourceRoot;
- var boundCallback = aCallback.bind(context);
- var names = this._names;
- var sources = this._sources;
- var sourceMapURL = this._sourceMapURL;
- for (var i = 0, n = mappings.length; i < n; i++) {
- var mapping = mappings[i];
- var source = mapping.source === null ? null : sources.at(mapping.source);
- source = util$1.computeSourceURL(sourceRoot, source, sourceMapURL);
- boundCallback({
- source: source,
- generatedLine: mapping.generatedLine,
- generatedColumn: mapping.generatedColumn,
- originalLine: mapping.originalLine,
- originalColumn: mapping.originalColumn,
- name: mapping.name === null ? null : names.at(mapping.name)
- });
- }
- };
- /**
- * Returns all generated line and column information for the original source,
- * line, and column provided. If no column is provided, returns all mappings
- * corresponding to a either the line we are searching for or the next
- * closest line that has any mappings. Otherwise, returns all mappings
- * corresponding to the given line and either the column we are searching for
- * or the next closest column that has any offsets.
- *
- * The only argument is an object with the following properties:
- *
- * - source: The filename of the original source.
- * - line: The line number in the original source. The line number is 1-based.
- * - column: Optional. the column number in the original source.
- * The column number is 0-based.
- *
- * and an array of objects is returned, each with the following properties:
- *
- * - line: The line number in the generated source, or null. The
- * line number is 1-based.
- * - column: The column number in the generated source, or null.
- * The column number is 0-based.
- */
- SourceMapConsumer$1.prototype.allGeneratedPositionsFor =
- function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
- var line = util$1.getArg(aArgs, 'line');
- // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
- // returns the index of the closest mapping less than the needle. By
- // setting needle.originalColumn to 0, we thus find the last mapping for
- // the given line, provided such a mapping exists.
- var needle = {
- source: util$1.getArg(aArgs, 'source'),
- originalLine: line,
- originalColumn: util$1.getArg(aArgs, 'column', 0)
- };
- needle.source = this._findSourceIndex(needle.source);
- if (needle.source < 0) {
- return [];
- }
- var mappings = [];
- var index = this._findMapping(needle,
- this._originalMappings,
- "originalLine",
- "originalColumn",
- util$1.compareByOriginalPositions,
- binarySearch.LEAST_UPPER_BOUND);
- if (index >= 0) {
- var mapping = this._originalMappings[index];
- if (aArgs.column === undefined) {
- var originalLine = mapping.originalLine;
- // Iterate until either we run out of mappings, or we run into
- // a mapping for a different line than the one we found. Since
- // mappings are sorted, this is guaranteed to find all mappings for
- // the line we found.
- while (mapping && mapping.originalLine === originalLine) {
- mappings.push({
- line: util$1.getArg(mapping, 'generatedLine', null),
- column: util$1.getArg(mapping, 'generatedColumn', null),
- lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
- });
- mapping = this._originalMappings[++index];
- }
- } else {
- var originalColumn = mapping.originalColumn;
- // Iterate until either we run out of mappings, or we run into
- // a mapping for a different line than the one we were searching for.
- // Since mappings are sorted, this is guaranteed to find all mappings for
- // the line we are searching for.
- while (mapping &&
- mapping.originalLine === line &&
- mapping.originalColumn == originalColumn) {
- mappings.push({
- line: util$1.getArg(mapping, 'generatedLine', null),
- column: util$1.getArg(mapping, 'generatedColumn', null),
- lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
- });
- mapping = this._originalMappings[++index];
- }
- }
- }
- return mappings;
- };
- sourceMapConsumer.SourceMapConsumer = SourceMapConsumer$1;
- /**
- * A BasicSourceMapConsumer instance represents a parsed source map which we can
- * query for information about the original file positions by giving it a file
- * position in the generated source.
- *
- * The first parameter is the raw source map (either as a JSON string, or
- * already parsed to an object). According to the spec, source maps have the
- * following attributes:
- *
- * - version: Which version of the source map spec this map is following.
- * - sources: An array of URLs to the original source files.
- * - names: An array of identifiers which can be referrenced by individual mappings.
- * - sourceRoot: Optional. The URL root from which all sources are relative.
- * - sourcesContent: Optional. An array of contents of the original source files.
- * - mappings: A string of base64 VLQs which contain the actual mappings.
- * - file: Optional. The generated file this source map is associated with.
- *
- * Here is an example source map, taken from the source map spec[0]:
- *
- * {
- * version : 3,
- * file: "out.js",
- * sourceRoot : "",
- * sources: ["foo.js", "bar.js"],
- * names: ["src", "maps", "are", "fun"],
- * mappings: "AA,AB;;ABCDE;"
- * }
- *
- * The second parameter, if given, is a string whose value is the URL
- * at which the source map was found. This URL is used to compute the
- * sources array.
- *
- * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
- */
- function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
- var sourceMap = aSourceMap;
- if (typeof aSourceMap === 'string') {
- sourceMap = util$1.parseSourceMapInput(aSourceMap);
- }
- var version = util$1.getArg(sourceMap, 'version');
- var sources = util$1.getArg(sourceMap, 'sources');
- // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
- // requires the array) to play nice here.
- var names = util$1.getArg(sourceMap, 'names', []);
- var sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
- var sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
- var mappings = util$1.getArg(sourceMap, 'mappings');
- var file = util$1.getArg(sourceMap, 'file', null);
- // Once again, Sass deviates from the spec and supplies the version as a
- // string rather than a number, so we use loose equality checking here.
- if (version != this._version) {
- throw new Error('Unsupported version: ' + version);
- }
- if (sourceRoot) {
- sourceRoot = util$1.normalize(sourceRoot);
- }
- sources = sources
- .map(String)
- // Some source maps produce relative source paths like "./foo.js" instead of
- // "foo.js". Normalize these first so that future comparisons will succeed.
- // See bugzil.la/1090768.
- .map(util$1.normalize)
- // Always ensure that absolute sources are internally stored relative to
- // the source root, if the source root is absolute. Not doing this would
- // be particularly problematic when the source root is a prefix of the
- // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
- .map(function (source) {
- return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
- ? util$1.relative(sourceRoot, source)
- : source;
- });
- // Pass `true` below to allow duplicate names and sources. While source maps
- // are intended to be compressed and deduplicated, the TypeScript compiler
- // sometimes generates source maps with duplicates in them. See Github issue
- // #72 and bugzil.la/889492.
- this._names = ArraySet.fromArray(names.map(String), true);
- this._sources = ArraySet.fromArray(sources, true);
- this._absoluteSources = this._sources.toArray().map(function (s) {
- return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
- });
- this.sourceRoot = sourceRoot;
- this.sourcesContent = sourcesContent;
- this._mappings = mappings;
- this._sourceMapURL = aSourceMapURL;
- this.file = file;
- }
- BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
- BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer$1;
- /**
- * Utility function to find the index of a source. Returns -1 if not
- * found.
- */
- BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
- var relativeSource = aSource;
- if (this.sourceRoot != null) {
- relativeSource = util$1.relative(this.sourceRoot, relativeSource);
- }
- if (this._sources.has(relativeSource)) {
- return this._sources.indexOf(relativeSource);
- }
- // Maybe aSource is an absolute URL as returned by |sources|. In
- // this case we can't simply undo the transform.
- var i;
- for (i = 0; i < this._absoluteSources.length; ++i) {
- if (this._absoluteSources[i] == aSource) {
- return i;
- }
- }
- return -1;
- };
- /**
- * Create a BasicSourceMapConsumer from a SourceMapGenerator.
- *
- * @param SourceMapGenerator aSourceMap
- * The source map that will be consumed.
- * @param String aSourceMapURL
- * The URL at which the source map can be found (optional)
- * @returns BasicSourceMapConsumer
- */
- BasicSourceMapConsumer.fromSourceMap =
- function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
- var smc = Object.create(BasicSourceMapConsumer.prototype);
- var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
- var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
- smc.sourceRoot = aSourceMap._sourceRoot;
- smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
- smc.sourceRoot);
- smc.file = aSourceMap._file;
- smc._sourceMapURL = aSourceMapURL;
- smc._absoluteSources = smc._sources.toArray().map(function (s) {
- return util$1.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
- });
- // Because we are modifying the entries (by converting string sources and
- // names to indices into the sources and names ArraySets), we have to make
- // a copy of the entry or else bad things happen. Shared mutable state
- // strikes again! See github issue #191.
- var generatedMappings = aSourceMap._mappings.toArray().slice();
- var destGeneratedMappings = smc.__generatedMappings = [];
- var destOriginalMappings = smc.__originalMappings = [];
- for (var i = 0, length = generatedMappings.length; i < length; i++) {
- var srcMapping = generatedMappings[i];
- var destMapping = new Mapping;
- destMapping.generatedLine = srcMapping.generatedLine;
- destMapping.generatedColumn = srcMapping.generatedColumn;
- if (srcMapping.source) {
- destMapping.source = sources.indexOf(srcMapping.source);
- destMapping.originalLine = srcMapping.originalLine;
- destMapping.originalColumn = srcMapping.originalColumn;
- if (srcMapping.name) {
- destMapping.name = names.indexOf(srcMapping.name);
- }
- destOriginalMappings.push(destMapping);
- }
- destGeneratedMappings.push(destMapping);
- }
- quickSort(smc.__originalMappings, util$1.compareByOriginalPositions);
- return smc;
- };
- /**
- * The version of the source mapping spec that we are consuming.
- */
- BasicSourceMapConsumer.prototype._version = 3;
- /**
- * The list of original sources.
- */
- Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
- get: function () {
- return this._absoluteSources.slice();
- }
- });
- /**
- * Provide the JIT with a nice shape / hidden class.
- */
- function Mapping() {
- this.generatedLine = 0;
- this.generatedColumn = 0;
- this.source = null;
- this.originalLine = null;
- this.originalColumn = null;
- this.name = null;
- }
- /**
- * Parse the mappings in a string in to a data structure which we can easily
- * query (the ordered arrays in the `this.__generatedMappings` and
- * `this.__originalMappings` properties).
- */
- const compareGenerated = util$1.compareByGeneratedPositionsDeflatedNoLine;
- function sortGenerated(array, start) {
- let l = array.length;
- let n = array.length - start;
- if (n <= 1) {
- return;
- } else if (n == 2) {
- let a = array[start];
- let b = array[start + 1];
- if (compareGenerated(a, b) > 0) {
- array[start] = b;
- array[start + 1] = a;
- }
- } else if (n < 20) {
- for (let i = start; i < l; i++) {
- for (let j = i; j > start; j--) {
- let a = array[j - 1];
- let b = array[j];
- if (compareGenerated(a, b) <= 0) {
- break;
- }
- array[j - 1] = b;
- array[j] = a;
- }
- }
- } else {
- quickSort(array, compareGenerated, start);
- }
- }
- BasicSourceMapConsumer.prototype._parseMappings =
- function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
- var generatedLine = 1;
- var previousGeneratedColumn = 0;
- var previousOriginalLine = 0;
- var previousOriginalColumn = 0;
- var previousSource = 0;
- var previousName = 0;
- var length = aStr.length;
- var index = 0;
- var temp = {};
- var originalMappings = [];
- var generatedMappings = [];
- var mapping, segment, end, value;
- let subarrayStart = 0;
- while (index < length) {
- if (aStr.charAt(index) === ';') {
- generatedLine++;
- index++;
- previousGeneratedColumn = 0;
- sortGenerated(generatedMappings, subarrayStart);
- subarrayStart = generatedMappings.length;
- }
- else if (aStr.charAt(index) === ',') {
- index++;
- }
- else {
- mapping = new Mapping();
- mapping.generatedLine = generatedLine;
- for (end = index; end < length; end++) {
- if (this._charIsMappingSeparator(aStr, end)) {
- break;
- }
- }
- aStr.slice(index, end);
- segment = [];
- while (index < end) {
- base64VLQ.decode(aStr, index, temp);
- value = temp.value;
- index = temp.rest;
- segment.push(value);
- }
- if (segment.length === 2) {
- throw new Error('Found a source, but no line and column');
- }
- if (segment.length === 3) {
- throw new Error('Found a source and line, but no column');
- }
- // Generated column.
- mapping.generatedColumn = previousGeneratedColumn + segment[0];
- previousGeneratedColumn = mapping.generatedColumn;
- if (segment.length > 1) {
- // Original source.
- mapping.source = previousSource + segment[1];
- previousSource += segment[1];
- // Original line.
- mapping.originalLine = previousOriginalLine + segment[2];
- previousOriginalLine = mapping.originalLine;
- // Lines are stored 0-based
- mapping.originalLine += 1;
- // Original column.
- mapping.originalColumn = previousOriginalColumn + segment[3];
- previousOriginalColumn = mapping.originalColumn;
- if (segment.length > 4) {
- // Original name.
- mapping.name = previousName + segment[4];
- previousName += segment[4];
- }
- }
- generatedMappings.push(mapping);
- if (typeof mapping.originalLine === 'number') {
- let currentSource = mapping.source;
- while (originalMappings.length <= currentSource) {
- originalMappings.push(null);
- }
- if (originalMappings[currentSource] === null) {
- originalMappings[currentSource] = [];
- }
- originalMappings[currentSource].push(mapping);
- }
- }
- }
- sortGenerated(generatedMappings, subarrayStart);
- this.__generatedMappings = generatedMappings;
- for (var i = 0; i < originalMappings.length; i++) {
- if (originalMappings[i] != null) {
- quickSort(originalMappings[i], util$1.compareByOriginalPositionsNoSource);
- }
- }
- this.__originalMappings = [].concat(...originalMappings);
- };
- /**
- * Find the mapping that best matches the hypothetical "needle" mapping that
- * we are searching for in the given "haystack" of mappings.
- */
- BasicSourceMapConsumer.prototype._findMapping =
- function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
- aColumnName, aComparator, aBias) {
- // To return the position we are searching for, we must first find the
- // mapping for the given position and then return the opposite position it
- // points to. Because the mappings are sorted, we can use binary search to
- // find the best mapping.
- if (aNeedle[aLineName] <= 0) {
- throw new TypeError('Line must be greater than or equal to 1, got '
- + aNeedle[aLineName]);
- }
- if (aNeedle[aColumnName] < 0) {
- throw new TypeError('Column must be greater than or equal to 0, got '
- + aNeedle[aColumnName]);
- }
- return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
- };
- /**
- * Compute the last column for each generated mapping. The last column is
- * inclusive.
- */
- BasicSourceMapConsumer.prototype.computeColumnSpans =
- function SourceMapConsumer_computeColumnSpans() {
- for (var index = 0; index < this._generatedMappings.length; ++index) {
- var mapping = this._generatedMappings[index];
- // Mappings do not contain a field for the last generated columnt. We
- // can come up with an optimistic estimate, however, by assuming that
- // mappings are contiguous (i.e. given two consecutive mappings, the
- // first mapping ends where the second one starts).
- if (index + 1 < this._generatedMappings.length) {
- var nextMapping = this._generatedMappings[index + 1];
- if (mapping.generatedLine === nextMapping.generatedLine) {
- mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
- continue;
- }
- }
- // The last mapping for each line spans the entire line.
- mapping.lastGeneratedColumn = Infinity;
- }
- };
- /**
- * Returns the original source, line, and column information for the generated
- * source's line and column positions provided. The only argument is an object
- * with the following properties:
- *
- * - line: The line number in the generated source. The line number
- * is 1-based.
- * - column: The column number in the generated source. The column
- * number is 0-based.
- * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
- * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
- *
- * and an object is returned with the following properties:
- *
- * - source: The original source file, or null.
- * - line: The line number in the original source, or null. The
- * line number is 1-based.
- * - column: The column number in the original source, or null. The
- * column number is 0-based.
- * - name: The original identifier, or null.
- */
- BasicSourceMapConsumer.prototype.originalPositionFor =
- function SourceMapConsumer_originalPositionFor(aArgs) {
- var needle = {
- generatedLine: util$1.getArg(aArgs, 'line'),
- generatedColumn: util$1.getArg(aArgs, 'column')
- };
- var index = this._findMapping(
- needle,
- this._generatedMappings,
- "generatedLine",
- "generatedColumn",
- util$1.compareByGeneratedPositionsDeflated,
- util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
- );
- if (index >= 0) {
- var mapping = this._generatedMappings[index];
- if (mapping.generatedLine === needle.generatedLine) {
- var source = util$1.getArg(mapping, 'source', null);
- if (source !== null) {
- source = this._sources.at(source);
- source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
- }
- var name = util$1.getArg(mapping, 'name', null);
- if (name !== null) {
- name = this._names.at(name);
- }
- return {
- source: source,
- line: util$1.getArg(mapping, 'originalLine', null),
- column: util$1.getArg(mapping, 'originalColumn', null),
- name: name
- };
- }
- }
- return {
- source: null,
- line: null,
- column: null,
- name: null
- };
- };
- /**
- * Return true if we have the source content for every source in the source
- * map, false otherwise.
- */
- BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
- function BasicSourceMapConsumer_hasContentsOfAllSources() {
- if (!this.sourcesContent) {
- return false;
- }
- return this.sourcesContent.length >= this._sources.size() &&
- !this.sourcesContent.some(function (sc) { return sc == null; });
- };
- /**
- * Returns the original source content. The only argument is the url of the
- * original source file. Returns null if no original source content is
- * available.
- */
- BasicSourceMapConsumer.prototype.sourceContentFor =
- function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
- if (!this.sourcesContent) {
- return null;
- }
- var index = this._findSourceIndex(aSource);
- if (index >= 0) {
- return this.sourcesContent[index];
- }
- var relativeSource = aSource;
- if (this.sourceRoot != null) {
- relativeSource = util$1.relative(this.sourceRoot, relativeSource);
- }
- var url;
- if (this.sourceRoot != null
- && (url = util$1.urlParse(this.sourceRoot))) {
- // XXX: file:// URIs and absolute paths lead to unexpected behavior for
- // many users. We can help them out when they expect file:// URIs to
- // behave like it would if they were running a local HTTP server. See
- // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
- var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
- if (url.scheme == "file"
- && this._sources.has(fileUriAbsPath)) {
- return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
- }
- if ((!url.path || url.path == "/")
- && this._sources.has("/" + relativeSource)) {
- return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
- }
- }
- // This function is used recursively from
- // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
- // don't want to throw if we can't find the source - we just want to
- // return null, so we provide a flag to exit gracefully.
- if (nullOnMissing) {
- return null;
- }
- else {
- throw new Error('"' + relativeSource + '" is not in the SourceMap.');
- }
- };
- /**
- * Returns the generated line and column information for the original source,
- * line, and column positions provided. The only argument is an object with
- * the following properties:
- *
- * - source: The filename of the original source.
- * - line: The line number in the original source. The line number
- * is 1-based.
- * - column: The column number in the original source. The column
- * number is 0-based.
- * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
- * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
- *
- * and an object is returned with the following properties:
- *
- * - line: The line number in the generated source, or null. The
- * line number is 1-based.
- * - column: The column number in the generated source, or null.
- * The column number is 0-based.
- */
- BasicSourceMapConsumer.prototype.generatedPositionFor =
- function SourceMapConsumer_generatedPositionFor(aArgs) {
- var source = util$1.getArg(aArgs, 'source');
- source = this._findSourceIndex(source);
- if (source < 0) {
- return {
- line: null,
- column: null,
- lastColumn: null
- };
- }
- var needle = {
- source: source,
- originalLine: util$1.getArg(aArgs, 'line'),
- originalColumn: util$1.getArg(aArgs, 'column')
- };
- var index = this._findMapping(
- needle,
- this._originalMappings,
- "originalLine",
- "originalColumn",
- util$1.compareByOriginalPositions,
- util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
- );
- if (index >= 0) {
- var mapping = this._originalMappings[index];
- if (mapping.source === needle.source) {
- return {
- line: util$1.getArg(mapping, 'generatedLine', null),
- column: util$1.getArg(mapping, 'generatedColumn', null),
- lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
- };
- }
- }
- return {
- line: null,
- column: null,
- lastColumn: null
- };
- };
- sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
- /**
- * An IndexedSourceMapConsumer instance represents a parsed source map which
- * we can query for information. It differs from BasicSourceMapConsumer in
- * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
- * input.
- *
- * The first parameter is a raw source map (either as a JSON string, or already
- * parsed to an object). According to the spec for indexed source maps, they
- * have the following attributes:
- *
- * - version: Which version of the source map spec this map is following.
- * - file: Optional. The generated file this source map is associated with.
- * - sections: A list of section definitions.
- *
- * Each value under the "sections" field has two fields:
- * - offset: The offset into the original specified at which this section
- * begins to apply, defined as an object with a "line" and "column"
- * field.
- * - map: A source map definition. This source map could also be indexed,
- * but doesn't have to be.
- *
- * Instead of the "map" field, it's also possible to have a "url" field
- * specifying a URL to retrieve a source map from, but that's currently
- * unsupported.
- *
- * Here's an example source map, taken from the source map spec[0], but
- * modified to omit a section which uses the "url" field.
- *
- * {
- * version : 3,
- * file: "app.js",
- * sections: [{
- * offset: {line:100, column:10},
- * map: {
- * version : 3,
- * file: "section.js",
- * sources: ["foo.js", "bar.js"],
- * names: ["src", "maps", "are", "fun"],
- * mappings: "AAAA,E;;ABCDE;"
- * }
- * }],
- * }
- *
- * The second parameter, if given, is a string whose value is the URL
- * at which the source map was found. This URL is used to compute the
- * sources array.
- *
- * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
- */
- function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
- var sourceMap = aSourceMap;
- if (typeof aSourceMap === 'string') {
- sourceMap = util$1.parseSourceMapInput(aSourceMap);
- }
- var version = util$1.getArg(sourceMap, 'version');
- var sections = util$1.getArg(sourceMap, 'sections');
- if (version != this._version) {
- throw new Error('Unsupported version: ' + version);
- }
- this._sources = new ArraySet();
- this._names = new ArraySet();
- var lastOffset = {
- line: -1,
- column: 0
- };
- this._sections = sections.map(function (s) {
- if (s.url) {
- // The url field will require support for asynchronicity.
- // See https://github.com/mozilla/source-map/issues/16
- throw new Error('Support for url field in sections not implemented.');
- }
- var offset = util$1.getArg(s, 'offset');
- var offsetLine = util$1.getArg(offset, 'line');
- var offsetColumn = util$1.getArg(offset, 'column');
- if (offsetLine < lastOffset.line ||
- (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
- throw new Error('Section offsets must be ordered and non-overlapping.');
- }
- lastOffset = offset;
- return {
- generatedOffset: {
- // The offset fields are 0-based, but we use 1-based indices when
- // encoding/decoding from VLQ.
- generatedLine: offsetLine + 1,
- generatedColumn: offsetColumn + 1
- },
- consumer: new SourceMapConsumer$1(util$1.getArg(s, 'map'), aSourceMapURL)
- }
- });
- }
- IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
- IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer$1;
- /**
- * The version of the source mapping spec that we are consuming.
- */
- IndexedSourceMapConsumer.prototype._version = 3;
- /**
- * The list of original sources.
- */
- Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
- get: function () {
- var sources = [];
- for (var i = 0; i < this._sections.length; i++) {
- for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
- sources.push(this._sections[i].consumer.sources[j]);
- }
- }
- return sources;
- }
- });
- /**
- * Returns the original source, line, and column information for the generated
- * source's line and column positions provided. The only argument is an object
- * with the following properties:
- *
- * - line: The line number in the generated source. The line number
- * is 1-based.
- * - column: The column number in the generated source. The column
- * number is 0-based.
- *
- * and an object is returned with the following properties:
- *
- * - source: The original source file, or null.
- * - line: The line number in the original source, or null. The
- * line number is 1-based.
- * - column: The column number in the original source, or null. The
- * column number is 0-based.
- * - name: The original identifier, or null.
- */
- IndexedSourceMapConsumer.prototype.originalPositionFor =
- function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
- var needle = {
- generatedLine: util$1.getArg(aArgs, 'line'),
- generatedColumn: util$1.getArg(aArgs, 'column')
- };
- // Find the section containing the generated position we're trying to map
- // to an original position.
- var sectionIndex = binarySearch.search(needle, this._sections,
- function(needle, section) {
- var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
- if (cmp) {
- return cmp;
- }
- return (needle.generatedColumn -
- section.generatedOffset.generatedColumn);
- });
- var section = this._sections[sectionIndex];
- if (!section) {
- return {
- source: null,
- line: null,
- column: null,
- name: null
- };
- }
- return section.consumer.originalPositionFor({
- line: needle.generatedLine -
- (section.generatedOffset.generatedLine - 1),
- column: needle.generatedColumn -
- (section.generatedOffset.generatedLine === needle.generatedLine
- ? section.generatedOffset.generatedColumn - 1
- : 0),
- bias: aArgs.bias
- });
- };
- /**
- * Return true if we have the source content for every source in the source
- * map, false otherwise.
- */
- IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
- function IndexedSourceMapConsumer_hasContentsOfAllSources() {
- return this._sections.every(function (s) {
- return s.consumer.hasContentsOfAllSources();
- });
- };
- /**
- * Returns the original source content. The only argument is the url of the
- * original source file. Returns null if no original source content is
- * available.
- */
- IndexedSourceMapConsumer.prototype.sourceContentFor =
- function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
- var content = section.consumer.sourceContentFor(aSource, true);
- if (content) {
- return content;
- }
- }
- if (nullOnMissing) {
- return null;
- }
- else {
- throw new Error('"' + aSource + '" is not in the SourceMap.');
- }
- };
- /**
- * Returns the generated line and column information for the original source,
- * line, and column positions provided. The only argument is an object with
- * the following properties:
- *
- * - source: The filename of the original source.
- * - line: The line number in the original source. The line number
- * is 1-based.
- * - column: The column number in the original source. The column
- * number is 0-based.
- *
- * and an object is returned with the following properties:
- *
- * - line: The line number in the generated source, or null. The
- * line number is 1-based.
- * - column: The column number in the generated source, or null.
- * The column number is 0-based.
- */
- IndexedSourceMapConsumer.prototype.generatedPositionFor =
- function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
- // Only consider this section if the requested source is in the list of
- // sources of the consumer.
- if (section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1) {
- continue;
- }
- var generatedPosition = section.consumer.generatedPositionFor(aArgs);
- if (generatedPosition) {
- var ret = {
- line: generatedPosition.line +
- (section.generatedOffset.generatedLine - 1),
- column: generatedPosition.column +
- (section.generatedOffset.generatedLine === generatedPosition.line
- ? section.generatedOffset.generatedColumn - 1
- : 0)
- };
- return ret;
- }
- }
- return {
- line: null,
- column: null
- };
- };
- /**
- * Parse the mappings in a string in to a data structure which we can easily
- * query (the ordered arrays in the `this.__generatedMappings` and
- * `this.__originalMappings` properties).
- */
- IndexedSourceMapConsumer.prototype._parseMappings =
- function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
- this.__generatedMappings = [];
- this.__originalMappings = [];
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
- var sectionMappings = section.consumer._generatedMappings;
- for (var j = 0; j < sectionMappings.length; j++) {
- var mapping = sectionMappings[j];
- var source = section.consumer._sources.at(mapping.source);
- source = util$1.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
- this._sources.add(source);
- source = this._sources.indexOf(source);
- var name = null;
- if (mapping.name) {
- name = section.consumer._names.at(mapping.name);
- this._names.add(name);
- name = this._names.indexOf(name);
- }
- // The mappings coming from the consumer for the section have
- // generated positions relative to the start of the section, so we
- // need to offset them to be relative to the start of the concatenated
- // generated file.
- var adjustedMapping = {
- source: source,
- generatedLine: mapping.generatedLine +
- (section.generatedOffset.generatedLine - 1),
- generatedColumn: mapping.generatedColumn +
- (section.generatedOffset.generatedLine === mapping.generatedLine
- ? section.generatedOffset.generatedColumn - 1
- : 0),
- originalLine: mapping.originalLine,
- originalColumn: mapping.originalColumn,
- name: name
- };
- this.__generatedMappings.push(adjustedMapping);
- if (typeof adjustedMapping.originalLine === 'number') {
- this.__originalMappings.push(adjustedMapping);
- }
- }
- }
- quickSort(this.__generatedMappings, util$1.compareByGeneratedPositionsDeflated);
- quickSort(this.__originalMappings, util$1.compareByOriginalPositions);
- };
- sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- var SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
- var util = util$5;
- // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
- // operating systems these days (capturing the result).
- var REGEX_NEWLINE = /(\r?\n)/;
- // Newline character code for charCodeAt() comparisons
- var NEWLINE_CODE = 10;
- // Private symbol for identifying `SourceNode`s when multiple versions of
- // the source-map library are loaded. This MUST NOT CHANGE across
- // versions!
- var isSourceNode = "$$$isSourceNode$$$";
- /**
- * SourceNodes provide a way to abstract over interpolating/concatenating
- * snippets of generated JavaScript source code while maintaining the line and
- * column information associated with the original source code.
- *
- * @param aLine The original line number.
- * @param aColumn The original column number.
- * @param aSource The original source's filename.
- * @param aChunks Optional. An array of strings which are snippets of
- * generated JS, or other SourceNodes.
- * @param aName The original identifier.
- */
- function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
- this.children = [];
- this.sourceContents = {};
- this.line = aLine == null ? null : aLine;
- this.column = aColumn == null ? null : aColumn;
- this.source = aSource == null ? null : aSource;
- this.name = aName == null ? null : aName;
- this[isSourceNode] = true;
- if (aChunks != null) this.add(aChunks);
- }
- /**
- * Creates a SourceNode from generated code and a SourceMapConsumer.
- *
- * @param aGeneratedCode The generated code
- * @param aSourceMapConsumer The SourceMap for the generated code
- * @param aRelativePath Optional. The path that relative sources in the
- * SourceMapConsumer should be relative to.
- */
- SourceNode.fromStringWithSourceMap =
- function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
- // The SourceNode we want to fill with the generated code
- // and the SourceMap
- var node = new SourceNode();
- // All even indices of this array are one line of the generated code,
- // while all odd indices are the newlines between two adjacent lines
- // (since `REGEX_NEWLINE` captures its match).
- // Processed fragments are accessed by calling `shiftNextLine`.
- var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
- var remainingLinesIndex = 0;
- var shiftNextLine = function() {
- var lineContents = getNextLine();
- // The last line of a file might not have a newline.
- var newLine = getNextLine() || "";
- return lineContents + newLine;
- function getNextLine() {
- return remainingLinesIndex < remainingLines.length ?
- remainingLines[remainingLinesIndex++] : undefined;
- }
- };
- // We need to remember the position of "remainingLines"
- var lastGeneratedLine = 1, lastGeneratedColumn = 0;
- // The generate SourceNodes we need a code range.
- // To extract it current and last mapping is used.
- // Here we store the last mapping.
- var lastMapping = null;
- aSourceMapConsumer.eachMapping(function (mapping) {
- if (lastMapping !== null) {
- // We add the code from "lastMapping" to "mapping":
- // First check if there is a new line in between.
- if (lastGeneratedLine < mapping.generatedLine) {
- // Associate first line with "lastMapping"
- addMappingWithCode(lastMapping, shiftNextLine());
- lastGeneratedLine++;
- lastGeneratedColumn = 0;
- // The remaining code is added without mapping
- } else {
- // There is no new line in between.
- // Associate the code between "lastGeneratedColumn" and
- // "mapping.generatedColumn" with "lastMapping"
- var nextLine = remainingLines[remainingLinesIndex] || '';
- var code = nextLine.substr(0, mapping.generatedColumn -
- lastGeneratedColumn);
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
- lastGeneratedColumn);
- lastGeneratedColumn = mapping.generatedColumn;
- addMappingWithCode(lastMapping, code);
- // No more remaining code, continue
- lastMapping = mapping;
- return;
- }
- }
- // We add the generated code until the first mapping
- // to the SourceNode without any mapping.
- // Each line is added as separate string.
- while (lastGeneratedLine < mapping.generatedLine) {
- node.add(shiftNextLine());
- lastGeneratedLine++;
- }
- if (lastGeneratedColumn < mapping.generatedColumn) {
- var nextLine = remainingLines[remainingLinesIndex] || '';
- node.add(nextLine.substr(0, mapping.generatedColumn));
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
- lastGeneratedColumn = mapping.generatedColumn;
- }
- lastMapping = mapping;
- }, this);
- // We have processed all mappings.
- if (remainingLinesIndex < remainingLines.length) {
- if (lastMapping) {
- // Associate the remaining code in the current line with "lastMapping"
- addMappingWithCode(lastMapping, shiftNextLine());
- }
- // and add the remaining lines without any mapping
- node.add(remainingLines.splice(remainingLinesIndex).join(""));
- }
- // Copy sourcesContent into SourceNode
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
- if (aRelativePath != null) {
- sourceFile = util.join(aRelativePath, sourceFile);
- }
- node.setSourceContent(sourceFile, content);
- }
- });
- return node;
- function addMappingWithCode(mapping, code) {
- if (mapping === null || mapping.source === undefined) {
- node.add(code);
- } else {
- var source = aRelativePath
- ? util.join(aRelativePath, mapping.source)
- : mapping.source;
- node.add(new SourceNode(mapping.originalLine,
- mapping.originalColumn,
- source,
- code,
- mapping.name));
- }
- }
- };
- /**
- * Add a chunk of generated JS to this source node.
- *
- * @param aChunk A string snippet of generated JS code, another instance of
- * SourceNode, or an array where each member is one of those things.
- */
- SourceNode.prototype.add = function SourceNode_add(aChunk) {
- if (Array.isArray(aChunk)) {
- aChunk.forEach(function (chunk) {
- this.add(chunk);
- }, this);
- }
- else if (aChunk[isSourceNode] || typeof aChunk === "string") {
- if (aChunk) {
- this.children.push(aChunk);
- }
- }
- else {
- throw new TypeError(
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
- );
- }
- return this;
- };
- /**
- * Add a chunk of generated JS to the beginning of this source node.
- *
- * @param aChunk A string snippet of generated JS code, another instance of
- * SourceNode, or an array where each member is one of those things.
- */
- SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
- if (Array.isArray(aChunk)) {
- for (var i = aChunk.length-1; i >= 0; i--) {
- this.prepend(aChunk[i]);
- }
- }
- else if (aChunk[isSourceNode] || typeof aChunk === "string") {
- this.children.unshift(aChunk);
- }
- else {
- throw new TypeError(
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
- );
- }
- return this;
- };
- /**
- * Walk over the tree of JS snippets in this node and its children. The
- * walking function is called once for each snippet of JS and is passed that
- * snippet and the its original associated source's line/column location.
- *
- * @param aFn The traversal function.
- */
- SourceNode.prototype.walk = function SourceNode_walk(aFn) {
- var chunk;
- for (var i = 0, len = this.children.length; i < len; i++) {
- chunk = this.children[i];
- if (chunk[isSourceNode]) {
- chunk.walk(aFn);
- }
- else {
- if (chunk !== '') {
- aFn(chunk, { source: this.source,
- line: this.line,
- column: this.column,
- name: this.name });
- }
- }
- }
- };
- /**
- * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
- * each of `this.children`.
- *
- * @param aSep The separator.
- */
- SourceNode.prototype.join = function SourceNode_join(aSep) {
- var newChildren;
- var i;
- var len = this.children.length;
- if (len > 0) {
- newChildren = [];
- for (i = 0; i < len-1; i++) {
- newChildren.push(this.children[i]);
- newChildren.push(aSep);
- }
- newChildren.push(this.children[i]);
- this.children = newChildren;
- }
- return this;
- };
- /**
- * Call String.prototype.replace on the very right-most source snippet. Useful
- * for trimming whitespace from the end of a source node, etc.
- *
- * @param aPattern The pattern to replace.
- * @param aReplacement The thing to replace the pattern with.
- */
- SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
- var lastChild = this.children[this.children.length - 1];
- if (lastChild[isSourceNode]) {
- lastChild.replaceRight(aPattern, aReplacement);
- }
- else if (typeof lastChild === 'string') {
- this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
- }
- else {
- this.children.push(''.replace(aPattern, aReplacement));
- }
- return this;
- };
- /**
- * Set the source content for a source file. This will be added to the SourceMapGenerator
- * in the sourcesContent field.
- *
- * @param aSourceFile The filename of the source file
- * @param aSourceContent The content of the source file
- */
- SourceNode.prototype.setSourceContent =
- function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
- this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
- };
- /**
- * Walk over the tree of SourceNodes. The walking function is called for each
- * source file content and is passed the filename and source content.
- *
- * @param aFn The traversal function.
- */
- SourceNode.prototype.walkSourceContents =
- function SourceNode_walkSourceContents(aFn) {
- for (var i = 0, len = this.children.length; i < len; i++) {
- if (this.children[i][isSourceNode]) {
- this.children[i].walkSourceContents(aFn);
- }
- }
- var sources = Object.keys(this.sourceContents);
- for (var i = 0, len = sources.length; i < len; i++) {
- aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
- }
- };
- /**
- * Return the string representation of this source node. Walks over the tree
- * and concatenates all the various snippets together to one string.
- */
- SourceNode.prototype.toString = function SourceNode_toString() {
- var str = "";
- this.walk(function (chunk) {
- str += chunk;
- });
- return str;
- };
- /**
- * Returns the string representation of this source node along with a source
- * map.
- */
- SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
- var generated = {
- code: "",
- line: 1,
- column: 0
- };
- var map = new SourceMapGenerator(aArgs);
- var sourceMappingActive = false;
- var lastOriginalSource = null;
- var lastOriginalLine = null;
- var lastOriginalColumn = null;
- var lastOriginalName = null;
- this.walk(function (chunk, original) {
- generated.code += chunk;
- if (original.source !== null
- && original.line !== null
- && original.column !== null) {
- if(lastOriginalSource !== original.source
- || lastOriginalLine !== original.line
- || lastOriginalColumn !== original.column
- || lastOriginalName !== original.name) {
- map.addMapping({
- source: original.source,
- original: {
- line: original.line,
- column: original.column
- },
- generated: {
- line: generated.line,
- column: generated.column
- },
- name: original.name
- });
- }
- lastOriginalSource = original.source;
- lastOriginalLine = original.line;
- lastOriginalColumn = original.column;
- lastOriginalName = original.name;
- sourceMappingActive = true;
- } else if (sourceMappingActive) {
- map.addMapping({
- generated: {
- line: generated.line,
- column: generated.column
- }
- });
- lastOriginalSource = null;
- sourceMappingActive = false;
- }
- for (var idx = 0, length = chunk.length; idx < length; idx++) {
- if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
- generated.line++;
- generated.column = 0;
- // Mappings end at eol
- if (idx + 1 === length) {
- lastOriginalSource = null;
- sourceMappingActive = false;
- } else if (sourceMappingActive) {
- map.addMapping({
- source: original.source,
- original: {
- line: original.line,
- column: original.column
- },
- generated: {
- line: generated.line,
- column: generated.column
- },
- name: original.name
- });
- }
- } else {
- generated.column++;
- }
- }
- });
- this.walkSourceContents(function (sourceFile, sourceContent) {
- map.setSourceContent(sourceFile, sourceContent);
- });
- return { code: generated.code, map: map };
- };
- /*
- * Copyright 2009-2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE.txt or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- var SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
- const lineSplitRE = /\r?\n/;
- function getOriginalPos(map, { line, column }) {
- return new Promise((resolve) => {
- if (!map)
- return resolve(null);
- const consumer = new SourceMapConsumer(map);
- const pos = consumer.originalPositionFor({ line, column });
- if (pos.line != null && pos.column != null)
- resolve(pos);
- else
- resolve(null);
- });
- }
- async function interpretSourcePos(stackFrames, ctx) {
- var _a;
- for (const frame of stackFrames) {
- if ("sourcePos" in frame)
- continue;
- const transformResult = (_a = ctx.server.moduleGraph.getModuleById(frame.file)) == null ? void 0 : _a.ssrTransformResult;
- if (!transformResult)
- continue;
- const sourcePos = await getOriginalPos(transformResult.map, frame);
- if (sourcePos)
- frame.sourcePos = sourcePos;
- }
- return stackFrames;
- }
- const stackIgnorePatterns = [
- "node:internal",
- "/vitest/dist/",
- "/node_modules/chai/",
- "/node_modules/tinypool/",
- "/node_modules/tinyspy/"
- ];
- function extractLocation(urlLike) {
- if (!urlLike.includes(":"))
- return [urlLike];
- const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
- const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
- if (!parts)
- return [urlLike];
- return [parts[1], parts[2] || void 0, parts[3] || void 0];
- }
- function parseStacktrace(e, full = false) {
- if (e.stacks)
- return e.stacks;
- const stackStr = e.stack || e.stackStr || "";
- const stackFrames = stackStr.split("\n").map((raw) => {
- let line = raw.trim();
- if (line.includes("(eval "))
- line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
- let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
- const location = sanitizedLine.match(/ (\(.+\)$)/);
- sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
- const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
- let method = location && sanitizedLine || "";
- let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
- if (!file || !lineNumber || !columnNumber)
- return null;
- if (method.startsWith("async "))
- method = method.slice(6);
- if (file.startsWith("file://"))
- file = file.slice(7);
- if (!full && stackIgnorePatterns.some((p) => file && file.includes(p)))
- return null;
- return {
- method,
- file: slash(file),
- line: parseInt(lineNumber),
- column: parseInt(columnNumber)
- };
- }).filter(notNullish);
- e.stacks = stackFrames;
- return stackFrames;
- }
- function posToNumber(source, pos) {
- if (typeof pos === "number")
- return pos;
- const lines = source.split(lineSplitRE);
- const { line, column } = pos;
- let start = 0;
- if (line > lines.length)
- return source.length;
- for (let i = 0; i < line - 1; i++)
- start += lines[i].length + 1;
- return start + column;
- }
- function numberToPos(source, offset) {
- if (typeof offset !== "number")
- return offset;
- if (offset > source.length) {
- throw new Error(
- `offset is longer than source length! offset ${offset} > length ${source.length}`
- );
- }
- const lines = source.split(lineSplitRE);
- let counted = 0;
- let line = 0;
- let column = 0;
- for (; line < lines.length; line++) {
- const lineLength = lines[line].length + 1;
- if (counted + lineLength >= offset) {
- column = offset - counted + 1;
- break;
- }
- counted += lineLength;
- }
- return { line: line + 1, column };
- }
- function Diff() {}
- Diff.prototype = {
- diff: function diff(oldString, newString) {
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var callback = options.callback;
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- this.options = options;
- var self = this;
- function done(value) {
- if (callback) {
- setTimeout(function () {
- callback(undefined, value);
- }, 0);
- return true;
- } else {
- return value;
- }
- } // Allow subclasses to massage the input prior to running
- oldString = this.castInput(oldString);
- newString = this.castInput(newString);
- oldString = this.removeEmpty(this.tokenize(oldString));
- newString = this.removeEmpty(this.tokenize(newString));
- var newLen = newString.length,
- oldLen = oldString.length;
- var editLength = 1;
- var maxEditLength = newLen + oldLen;
- if (options.maxEditLength) {
- maxEditLength = Math.min(maxEditLength, options.maxEditLength);
- }
- var bestPath = [{
- newPos: -1,
- components: []
- }]; // Seed editLength = 0, i.e. the content starts with the same values
- var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
- if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
- // Identity per the equality and tokenizer
- return done([{
- value: this.join(newString),
- count: newString.length
- }]);
- } // Main worker method. checks all permutations of a given edit length for acceptance.
- function execEditLength() {
- for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
- var basePath = void 0;
- var addPath = bestPath[diagonalPath - 1],
- removePath = bestPath[diagonalPath + 1],
- _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
- if (addPath) {
- // No one else is going to attempt to use this value, clear it
- bestPath[diagonalPath - 1] = undefined;
- }
- var canAdd = addPath && addPath.newPos + 1 < newLen,
- canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
- if (!canAdd && !canRemove) {
- // If this path is a terminal then prune
- bestPath[diagonalPath] = undefined;
- continue;
- } // Select the diagonal that we want to branch from. We select the prior
- // path whose position in the new string is the farthest from the origin
- // and does not pass the bounds of the diff graph
- if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
- basePath = clonePath(removePath);
- self.pushComponent(basePath.components, undefined, true);
- } else {
- basePath = addPath; // No need to clone, we've pulled it from the list
- basePath.newPos++;
- self.pushComponent(basePath.components, true, undefined);
- }
- _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
- if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
- return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
- } else {
- // Otherwise track this path as a potential candidate and continue.
- bestPath[diagonalPath] = basePath;
- }
- }
- editLength++;
- } // Performs the length of edit iteration. Is a bit fugly as this has to support the
- // sync and async mode which is never fun. Loops over execEditLength until a value
- // is produced, or until the edit length exceeds options.maxEditLength (if given),
- // in which case it will return undefined.
- if (callback) {
- (function exec() {
- setTimeout(function () {
- if (editLength > maxEditLength) {
- return callback();
- }
- if (!execEditLength()) {
- exec();
- }
- }, 0);
- })();
- } else {
- while (editLength <= maxEditLength) {
- var ret = execEditLength();
- if (ret) {
- return ret;
- }
- }
- }
- },
- pushComponent: function pushComponent(components, added, removed) {
- var last = components[components.length - 1];
- if (last && last.added === added && last.removed === removed) {
- // We need to clone here as the component clone operation is just
- // as shallow array clone
- components[components.length - 1] = {
- count: last.count + 1,
- added: added,
- removed: removed
- };
- } else {
- components.push({
- count: 1,
- added: added,
- removed: removed
- });
- }
- },
- extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
- var newLen = newString.length,
- oldLen = oldString.length,
- newPos = basePath.newPos,
- oldPos = newPos - diagonalPath,
- commonCount = 0;
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
- newPos++;
- oldPos++;
- commonCount++;
- }
- if (commonCount) {
- basePath.components.push({
- count: commonCount
- });
- }
- basePath.newPos = newPos;
- return oldPos;
- },
- equals: function equals(left, right) {
- if (this.options.comparator) {
- return this.options.comparator(left, right);
- } else {
- return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
- }
- },
- removeEmpty: function removeEmpty(array) {
- var ret = [];
- for (var i = 0; i < array.length; i++) {
- if (array[i]) {
- ret.push(array[i]);
- }
- }
- return ret;
- },
- castInput: function castInput(value) {
- return value;
- },
- tokenize: function tokenize(value) {
- return value.split('');
- },
- join: function join(chars) {
- return chars.join('');
- }
- };
- function buildValues(diff, components, newString, oldString, useLongestToken) {
- var componentPos = 0,
- componentLen = components.length,
- newPos = 0,
- oldPos = 0;
- for (; componentPos < componentLen; componentPos++) {
- var component = components[componentPos];
- if (!component.removed) {
- if (!component.added && useLongestToken) {
- var value = newString.slice(newPos, newPos + component.count);
- value = value.map(function (value, i) {
- var oldValue = oldString[oldPos + i];
- return oldValue.length > value.length ? oldValue : value;
- });
- component.value = diff.join(value);
- } else {
- component.value = diff.join(newString.slice(newPos, newPos + component.count));
- }
- newPos += component.count; // Common case
- if (!component.added) {
- oldPos += component.count;
- }
- } else {
- component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
- oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
- // The diffing algorithm is tied to add then remove output and this is the simplest
- // route to get the desired output with minimal overhead.
- if (componentPos && components[componentPos - 1].added) {
- var tmp = components[componentPos - 1];
- components[componentPos - 1] = components[componentPos];
- components[componentPos] = tmp;
- }
- }
- } // Special case handle for when one terminal is ignored (i.e. whitespace).
- // For this case we merge the terminal into the prior string and drop the change.
- // This is only available for string mode.
- var lastComponent = components[componentLen - 1];
- if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
- components[componentLen - 2].value += lastComponent.value;
- components.pop();
- }
- return components;
- }
- function clonePath(path) {
- return {
- newPos: path.newPos,
- components: path.components.slice(0)
- };
- }
- //
- // Ranges and exceptions:
- // Latin-1 Supplement, 0080–00FF
- // - U+00D7 × Multiplication sign
- // - U+00F7 ÷ Division sign
- // Latin Extended-A, 0100–017F
- // Latin Extended-B, 0180–024F
- // IPA Extensions, 0250–02AF
- // Spacing Modifier Letters, 02B0–02FF
- // - U+02C7 ˇ ˇ Caron
- // - U+02D8 ˘ ˘ Breve
- // - U+02D9 ˙ ˙ Dot Above
- // - U+02DA ˚ ˚ Ring Above
- // - U+02DB ˛ ˛ Ogonek
- // - U+02DC ˜ ˜ Small Tilde
- // - U+02DD ˝ ˝ Double Acute Accent
- // Latin Extended Additional, 1E00–1EFF
- var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
- var reWhitespace = /\S/;
- var wordDiff = new Diff();
- wordDiff.equals = function (left, right) {
- if (this.options.ignoreCase) {
- left = left.toLowerCase();
- right = right.toLowerCase();
- }
- return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
- };
- wordDiff.tokenize = function (value) {
- // All whitespace symbols except newline group into one token, each newline - in separate token
- var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
- for (var i = 0; i < tokens.length - 1; i++) {
- // If we have an empty string in the next field and we have only word chars before and after, merge
- if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
- tokens[i] += tokens[i + 2];
- tokens.splice(i + 1, 2);
- i--;
- }
- }
- return tokens;
- };
- var lineDiff = new Diff();
- lineDiff.tokenize = function (value) {
- var retLines = [],
- linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
- linesAndNewlines.pop();
- } // Merge the content and line separators into single tokens
- for (var i = 0; i < linesAndNewlines.length; i++) {
- var line = linesAndNewlines[i];
- if (i % 2 && !this.options.newlineIsToken) {
- retLines[retLines.length - 1] += line;
- } else {
- if (this.options.ignoreWhitespace) {
- line = line.trim();
- }
- retLines.push(line);
- }
- }
- return retLines;
- };
- function diffLines(oldStr, newStr, callback) {
- return lineDiff.diff(oldStr, newStr, callback);
- }
- var sentenceDiff = new Diff();
- sentenceDiff.tokenize = function (value) {
- return value.split(/(\S.+?[.!?])(?=\s+|$)/);
- };
- var cssDiff = new Diff();
- cssDiff.tokenize = function (value) {
- return value.split(/([{}:;,]|\s+)/);
- };
- function _typeof(obj) {
- "@babel/helpers - typeof";
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- _typeof = function (obj) {
- return typeof obj;
- };
- } else {
- _typeof = function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
- return _typeof(obj);
- }
- function _toConsumableArray(arr) {
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
- }
- function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
- }
- function _iterableToArray(iter) {
- if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
- }
- function _unsupportedIterableToArray(o, minLen) {
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = Object.prototype.toString.call(o).slice(8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return Array.from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
- return arr2;
- }
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var objectPrototypeToString = Object.prototype.toString;
- var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
- // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
- jsonDiff.useLongestToken = true;
- jsonDiff.tokenize = lineDiff.tokenize;
- jsonDiff.castInput = function (value) {
- var _this$options = this.options,
- undefinedReplacement = _this$options.undefinedReplacement,
- _this$options$stringi = _this$options.stringifyReplacer,
- stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) {
- return typeof v === 'undefined' ? undefinedReplacement : v;
- } : _this$options$stringi;
- return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
- };
- jsonDiff.equals = function (left, right) {
- return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
- };
- // object that is already on the "stack" of items being processed. Accepts an optional replacer
- function canonicalize(obj, stack, replacementStack, replacer, key) {
- stack = stack || [];
- replacementStack = replacementStack || [];
- if (replacer) {
- obj = replacer(key, obj);
- }
- var i;
- for (i = 0; i < stack.length; i += 1) {
- if (stack[i] === obj) {
- return replacementStack[i];
- }
- }
- var canonicalizedObj;
- if ('[object Array]' === objectPrototypeToString.call(obj)) {
- stack.push(obj);
- canonicalizedObj = new Array(obj.length);
- replacementStack.push(canonicalizedObj);
- for (i = 0; i < obj.length; i += 1) {
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
- }
- stack.pop();
- replacementStack.pop();
- return canonicalizedObj;
- }
- if (obj && obj.toJSON) {
- obj = obj.toJSON();
- }
- if (_typeof(obj) === 'object' && obj !== null) {
- stack.push(obj);
- canonicalizedObj = {};
- replacementStack.push(canonicalizedObj);
- var sortedKeys = [],
- _key;
- for (_key in obj) {
- /* istanbul ignore else */
- if (obj.hasOwnProperty(_key)) {
- sortedKeys.push(_key);
- }
- }
- sortedKeys.sort();
- for (i = 0; i < sortedKeys.length; i += 1) {
- _key = sortedKeys[i];
- canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
- }
- stack.pop();
- replacementStack.pop();
- } else {
- canonicalizedObj = obj;
- }
- return canonicalizedObj;
- }
- var arrayDiff = new Diff();
- arrayDiff.tokenize = function (value) {
- return value.slice();
- };
- arrayDiff.join = arrayDiff.removeEmpty = function (value) {
- return value;
- };
- function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
- if (!options) {
- options = {};
- }
- if (typeof options.context === 'undefined') {
- options.context = 4;
- }
- var diff = diffLines(oldStr, newStr, options);
- if (!diff) {
- return;
- }
- diff.push({
- value: '',
- lines: []
- }); // Append an empty value to make cleanup easier
- function contextLines(lines) {
- return lines.map(function (entry) {
- return ' ' + entry;
- });
- }
- var hunks = [];
- var oldRangeStart = 0,
- newRangeStart = 0,
- curRange = [],
- oldLine = 1,
- newLine = 1;
- var _loop = function _loop(i) {
- var current = diff[i],
- lines = current.lines || current.value.replace(/\n$/, '').split('\n');
- current.lines = lines;
- if (current.added || current.removed) {
- var _curRange;
- // If we have previous context, start with that
- if (!oldRangeStart) {
- var prev = diff[i - 1];
- oldRangeStart = oldLine;
- newRangeStart = newLine;
- if (prev) {
- curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
- oldRangeStart -= curRange.length;
- newRangeStart -= curRange.length;
- }
- } // Output our changes
- (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
- return (current.added ? '+' : '-') + entry;
- }))); // Track the updated file position
- if (current.added) {
- newLine += lines.length;
- } else {
- oldLine += lines.length;
- }
- } else {
- // Identical context lines. Track line changes
- if (oldRangeStart) {
- // Close out any changes that have been output (or join overlapping)
- if (lines.length <= options.context * 2 && i < diff.length - 2) {
- var _curRange2;
- // Overlapping
- (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
- } else {
- var _curRange3;
- // end the range and output
- var contextSize = Math.min(lines.length, options.context);
- (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
- var hunk = {
- oldStart: oldRangeStart,
- oldLines: oldLine - oldRangeStart + contextSize,
- newStart: newRangeStart,
- newLines: newLine - newRangeStart + contextSize,
- lines: curRange
- };
- if (i >= diff.length - 2 && lines.length <= options.context) {
- // EOF is inside this hunk
- var oldEOFNewline = /\n$/.test(oldStr);
- var newEOFNewline = /\n$/.test(newStr);
- var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
- if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
- // special case: old has no eol and no trailing context; no-nl can end up before adds
- // however, if the old file is empty, do not output the no-nl line
- curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
- }
- if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
- curRange.push('\\ No newline at end of file');
- }
- }
- hunks.push(hunk);
- oldRangeStart = 0;
- newRangeStart = 0;
- curRange = [];
- }
- }
- oldLine += lines.length;
- newLine += lines.length;
- }
- };
- for (var i = 0; i < diff.length; i++) {
- _loop(i);
- }
- return {
- oldFileName: oldFileName,
- newFileName: newFileName,
- oldHeader: oldHeader,
- newHeader: newHeader,
- hunks: hunks
- };
- }
- function formatPatch(diff) {
- var ret = [];
- if (diff.oldFileName == diff.newFileName) {
- ret.push('Index: ' + diff.oldFileName);
- }
- ret.push('===================================================================');
- ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
- ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
- for (var i = 0; i < diff.hunks.length; i++) {
- var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
- // the first number is one lower than one would expect.
- // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
- if (hunk.oldLines === 0) {
- hunk.oldStart -= 1;
- }
- if (hunk.newLines === 0) {
- hunk.newStart -= 1;
- }
- ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
- ret.push.apply(ret, hunk.lines);
- }
- return ret.join('\n') + '\n';
- }
- function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
- return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
- }
- function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
- return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
- }
- /* eslint-disable yoda */
- function isFullwidthCodePoint(codePoint) {
- if (!Number.isInteger(codePoint)) {
- return false;
- }
- // Code points are derived from:
- // https://unicode.org/Public/UNIDATA/EastAsianWidth.txt
- return codePoint >= 0x1100 && (
- codePoint <= 0x115F || // Hangul Jamo
- codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
- codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
- // CJK Radicals Supplement .. Enclosed CJK Letters and Months
- (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) ||
- // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
- (0x3250 <= codePoint && codePoint <= 0x4DBF) ||
- // CJK Unified Ideographs .. Yi Radicals
- (0x4E00 <= codePoint && codePoint <= 0xA4C6) ||
- // Hangul Jamo Extended-A
- (0xA960 <= codePoint && codePoint <= 0xA97C) ||
- // Hangul Syllables
- (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
- // CJK Compatibility Ideographs
- (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
- // Vertical Forms
- (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
- // CJK Compatibility Forms .. Small Form Variants
- (0xFE30 <= codePoint && codePoint <= 0xFE6B) ||
- // Halfwidth and Fullwidth Forms
- (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
- (0xFFE0 <= codePoint && codePoint <= 0xFFE6) ||
- // Kana Supplement
- (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
- // Enclosed Ideographic Supplement
- (0x1F200 <= codePoint && codePoint <= 0x1F251) ||
- // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
- (0x20000 <= codePoint && codePoint <= 0x3FFFD)
- );
- }
- const ANSI_BACKGROUND_OFFSET = 10;
- const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
- const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
- function assembleStyles() {
- const codes = new Map();
- const styles = {
- modifier: {
- reset: [0, 0],
- // 21 isn't widely supported and 22 does the same thing
- bold: [1, 22],
- dim: [2, 22],
- italic: [3, 23],
- underline: [4, 24],
- overline: [53, 55],
- inverse: [7, 27],
- hidden: [8, 28],
- strikethrough: [9, 29]
- },
- color: {
- black: [30, 39],
- red: [31, 39],
- green: [32, 39],
- yellow: [33, 39],
- blue: [34, 39],
- magenta: [35, 39],
- cyan: [36, 39],
- white: [37, 39],
- // Bright color
- blackBright: [90, 39],
- redBright: [91, 39],
- greenBright: [92, 39],
- yellowBright: [93, 39],
- blueBright: [94, 39],
- magentaBright: [95, 39],
- cyanBright: [96, 39],
- whiteBright: [97, 39]
- },
- bgColor: {
- bgBlack: [40, 49],
- bgRed: [41, 49],
- bgGreen: [42, 49],
- bgYellow: [43, 49],
- bgBlue: [44, 49],
- bgMagenta: [45, 49],
- bgCyan: [46, 49],
- bgWhite: [47, 49],
- // Bright color
- bgBlackBright: [100, 49],
- bgRedBright: [101, 49],
- bgGreenBright: [102, 49],
- bgYellowBright: [103, 49],
- bgBlueBright: [104, 49],
- bgMagentaBright: [105, 49],
- bgCyanBright: [106, 49],
- bgWhiteBright: [107, 49]
- }
- };
- // Alias bright black as gray (and grey)
- styles.color.gray = styles.color.blackBright;
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
- styles.color.grey = styles.color.blackBright;
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
- for (const [groupName, group] of Object.entries(styles)) {
- for (const [styleName, style] of Object.entries(group)) {
- styles[styleName] = {
- open: `\u001B[${style[0]}m`,
- close: `\u001B[${style[1]}m`
- };
- group[styleName] = styles[styleName];
- codes.set(style[0], style[1]);
- }
- Object.defineProperty(styles, groupName, {
- value: group,
- enumerable: false
- });
- }
- Object.defineProperty(styles, 'codes', {
- value: codes,
- enumerable: false
- });
- styles.color.close = '\u001B[39m';
- styles.bgColor.close = '\u001B[49m';
- styles.color.ansi = wrapAnsi16();
- styles.color.ansi256 = wrapAnsi256();
- styles.color.ansi16m = wrapAnsi16m();
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
- // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
- Object.defineProperties(styles, {
- rgbToAnsi256: {
- value: (red, green, blue) => {
- // We use the extended greyscale palette here, with the exception of
- // black and white. normal palette only has 4 greyscale shades.
- if (red === green && green === blue) {
- if (red < 8) {
- return 16;
- }
- if (red > 248) {
- return 231;
- }
- return Math.round(((red - 8) / 247) * 24) + 232;
- }
- return 16 +
- (36 * Math.round(red / 255 * 5)) +
- (6 * Math.round(green / 255 * 5)) +
- Math.round(blue / 255 * 5);
- },
- enumerable: false
- },
- hexToRgb: {
- value: hex => {
- const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
- if (!matches) {
- return [0, 0, 0];
- }
- let {colorString} = matches.groups;
- if (colorString.length === 3) {
- colorString = colorString.split('').map(character => character + character).join('');
- }
- const integer = Number.parseInt(colorString, 16);
- return [
- (integer >> 16) & 0xFF,
- (integer >> 8) & 0xFF,
- integer & 0xFF
- ];
- },
- enumerable: false
- },
- hexToAnsi256: {
- value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
- enumerable: false
- },
- ansi256ToAnsi: {
- value: code => {
- if (code < 8) {
- return 30 + code;
- }
- if (code < 16) {
- return 90 + (code - 8);
- }
- let red;
- let green;
- let blue;
- if (code >= 232) {
- red = (((code - 232) * 10) + 8) / 255;
- green = red;
- blue = red;
- } else {
- code -= 16;
- const remainder = code % 36;
- red = Math.floor(code / 36) / 5;
- green = Math.floor(remainder / 6) / 5;
- blue = (remainder % 6) / 5;
- }
- const value = Math.max(red, green, blue) * 2;
- if (value === 0) {
- return 30;
- }
- let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
- if (value === 2) {
- result += 60;
- }
- return result;
- },
- enumerable: false
- },
- rgbToAnsi: {
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
- enumerable: false
- },
- hexToAnsi: {
- value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
- enumerable: false
- }
- });
- return styles;
- }
- const ansiStyles = assembleStyles();
- const astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/;
- const ESCAPES = [
- '\u001B',
- '\u009B'
- ];
- const wrapAnsi = code => `${ESCAPES[0]}[${code}m`;
- const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => {
- let output = [];
- ansiCodes = [...ansiCodes];
- for (let ansiCode of ansiCodes) {
- const ansiCodeOrigin = ansiCode;
- if (ansiCode.includes(';')) {
- ansiCode = ansiCode.split(';')[0][0] + '0';
- }
- const item = ansiStyles.codes.get(Number.parseInt(ansiCode, 10));
- if (item) {
- const indexEscape = ansiCodes.indexOf(item.toString());
- if (indexEscape === -1) {
- output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin));
- } else {
- ansiCodes.splice(indexEscape, 1);
- }
- } else if (isEscapes) {
- output.push(wrapAnsi(0));
- break;
- } else {
- output.push(wrapAnsi(ansiCodeOrigin));
- }
- }
- if (isEscapes) {
- output = output.filter((element, index) => output.indexOf(element) === index);
- if (endAnsiCode !== undefined) {
- const fistEscapeCode = wrapAnsi(ansiStyles.codes.get(Number.parseInt(endAnsiCode, 10)));
- // TODO: Remove the use of `.reduce` here.
- // eslint-disable-next-line unicorn/no-array-reduce
- output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
- }
- }
- return output.join('');
- };
- function sliceAnsi(string, begin, end) {
- const characters = [...string];
- const ansiCodes = [];
- let stringEnd = typeof end === 'number' ? end : characters.length;
- let isInsideEscape = false;
- let ansiCode;
- let visible = 0;
- let output = '';
- for (const [index, character] of characters.entries()) {
- let leftEscape = false;
- if (ESCAPES.includes(character)) {
- const code = /\d[^m]*/.exec(string.slice(index, index + 18));
- ansiCode = code && code.length > 0 ? code[0] : undefined;
- if (visible < stringEnd) {
- isInsideEscape = true;
- if (ansiCode !== undefined) {
- ansiCodes.push(ansiCode);
- }
- }
- } else if (isInsideEscape && character === 'm') {
- isInsideEscape = false;
- leftEscape = true;
- }
- if (!isInsideEscape && !leftEscape) {
- visible++;
- }
- if (!astralRegex.test(character) && isFullwidthCodePoint(character.codePointAt())) {
- visible++;
- if (typeof end !== 'number') {
- stringEnd++;
- }
- }
- if (visible > begin && visible <= stringEnd) {
- output += character;
- } else if (visible === begin && !isInsideEscape && ansiCode !== undefined) {
- output = checkAnsi(ansiCodes);
- } else if (visible >= stringEnd) {
- output += checkAnsi(ansiCodes, true, ansiCode);
- break;
- }
- }
- return output;
- }
- function ansiRegex({onlyFirst = false} = {}) {
- const pattern = [
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
- ].join('|');
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
- }
- function stripAnsi(string) {
- if (typeof string !== 'string') {
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
- }
- return string.replace(ansiRegex(), '');
- }
- var eastasianwidth = {exports: {}};
- (function (module) {
- var eaw = {};
- {
- module.exports = eaw;
- }
- eaw.eastAsianWidth = function(character) {
- var x = character.charCodeAt(0);
- var y = (character.length == 2) ? character.charCodeAt(1) : 0;
- var codePoint = x;
- if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
- x &= 0x3FF;
- y &= 0x3FF;
- codePoint = (x << 10) | y;
- codePoint += 0x10000;
- }
- if ((0x3000 == codePoint) ||
- (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
- (0xFFE0 <= codePoint && codePoint <= 0xFFE6)) {
- return 'F';
- }
- if ((0x20A9 == codePoint) ||
- (0xFF61 <= codePoint && codePoint <= 0xFFBE) ||
- (0xFFC2 <= codePoint && codePoint <= 0xFFC7) ||
- (0xFFCA <= codePoint && codePoint <= 0xFFCF) ||
- (0xFFD2 <= codePoint && codePoint <= 0xFFD7) ||
- (0xFFDA <= codePoint && codePoint <= 0xFFDC) ||
- (0xFFE8 <= codePoint && codePoint <= 0xFFEE)) {
- return 'H';
- }
- if ((0x1100 <= codePoint && codePoint <= 0x115F) ||
- (0x11A3 <= codePoint && codePoint <= 0x11A7) ||
- (0x11FA <= codePoint && codePoint <= 0x11FF) ||
- (0x2329 <= codePoint && codePoint <= 0x232A) ||
- (0x2E80 <= codePoint && codePoint <= 0x2E99) ||
- (0x2E9B <= codePoint && codePoint <= 0x2EF3) ||
- (0x2F00 <= codePoint && codePoint <= 0x2FD5) ||
- (0x2FF0 <= codePoint && codePoint <= 0x2FFB) ||
- (0x3001 <= codePoint && codePoint <= 0x303E) ||
- (0x3041 <= codePoint && codePoint <= 0x3096) ||
- (0x3099 <= codePoint && codePoint <= 0x30FF) ||
- (0x3105 <= codePoint && codePoint <= 0x312D) ||
- (0x3131 <= codePoint && codePoint <= 0x318E) ||
- (0x3190 <= codePoint && codePoint <= 0x31BA) ||
- (0x31C0 <= codePoint && codePoint <= 0x31E3) ||
- (0x31F0 <= codePoint && codePoint <= 0x321E) ||
- (0x3220 <= codePoint && codePoint <= 0x3247) ||
- (0x3250 <= codePoint && codePoint <= 0x32FE) ||
- (0x3300 <= codePoint && codePoint <= 0x4DBF) ||
- (0x4E00 <= codePoint && codePoint <= 0xA48C) ||
- (0xA490 <= codePoint && codePoint <= 0xA4C6) ||
- (0xA960 <= codePoint && codePoint <= 0xA97C) ||
- (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
- (0xD7B0 <= codePoint && codePoint <= 0xD7C6) ||
- (0xD7CB <= codePoint && codePoint <= 0xD7FB) ||
- (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
- (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
- (0xFE30 <= codePoint && codePoint <= 0xFE52) ||
- (0xFE54 <= codePoint && codePoint <= 0xFE66) ||
- (0xFE68 <= codePoint && codePoint <= 0xFE6B) ||
- (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
- (0x1F200 <= codePoint && codePoint <= 0x1F202) ||
- (0x1F210 <= codePoint && codePoint <= 0x1F23A) ||
- (0x1F240 <= codePoint && codePoint <= 0x1F248) ||
- (0x1F250 <= codePoint && codePoint <= 0x1F251) ||
- (0x20000 <= codePoint && codePoint <= 0x2F73F) ||
- (0x2B740 <= codePoint && codePoint <= 0x2FFFD) ||
- (0x30000 <= codePoint && codePoint <= 0x3FFFD)) {
- return 'W';
- }
- if ((0x0020 <= codePoint && codePoint <= 0x007E) ||
- (0x00A2 <= codePoint && codePoint <= 0x00A3) ||
- (0x00A5 <= codePoint && codePoint <= 0x00A6) ||
- (0x00AC == codePoint) ||
- (0x00AF == codePoint) ||
- (0x27E6 <= codePoint && codePoint <= 0x27ED) ||
- (0x2985 <= codePoint && codePoint <= 0x2986)) {
- return 'Na';
- }
- if ((0x00A1 == codePoint) ||
- (0x00A4 == codePoint) ||
- (0x00A7 <= codePoint && codePoint <= 0x00A8) ||
- (0x00AA == codePoint) ||
- (0x00AD <= codePoint && codePoint <= 0x00AE) ||
- (0x00B0 <= codePoint && codePoint <= 0x00B4) ||
- (0x00B6 <= codePoint && codePoint <= 0x00BA) ||
- (0x00BC <= codePoint && codePoint <= 0x00BF) ||
- (0x00C6 == codePoint) ||
- (0x00D0 == codePoint) ||
- (0x00D7 <= codePoint && codePoint <= 0x00D8) ||
- (0x00DE <= codePoint && codePoint <= 0x00E1) ||
- (0x00E6 == codePoint) ||
- (0x00E8 <= codePoint && codePoint <= 0x00EA) ||
- (0x00EC <= codePoint && codePoint <= 0x00ED) ||
- (0x00F0 == codePoint) ||
- (0x00F2 <= codePoint && codePoint <= 0x00F3) ||
- (0x00F7 <= codePoint && codePoint <= 0x00FA) ||
- (0x00FC == codePoint) ||
- (0x00FE == codePoint) ||
- (0x0101 == codePoint) ||
- (0x0111 == codePoint) ||
- (0x0113 == codePoint) ||
- (0x011B == codePoint) ||
- (0x0126 <= codePoint && codePoint <= 0x0127) ||
- (0x012B == codePoint) ||
- (0x0131 <= codePoint && codePoint <= 0x0133) ||
- (0x0138 == codePoint) ||
- (0x013F <= codePoint && codePoint <= 0x0142) ||
- (0x0144 == codePoint) ||
- (0x0148 <= codePoint && codePoint <= 0x014B) ||
- (0x014D == codePoint) ||
- (0x0152 <= codePoint && codePoint <= 0x0153) ||
- (0x0166 <= codePoint && codePoint <= 0x0167) ||
- (0x016B == codePoint) ||
- (0x01CE == codePoint) ||
- (0x01D0 == codePoint) ||
- (0x01D2 == codePoint) ||
- (0x01D4 == codePoint) ||
- (0x01D6 == codePoint) ||
- (0x01D8 == codePoint) ||
- (0x01DA == codePoint) ||
- (0x01DC == codePoint) ||
- (0x0251 == codePoint) ||
- (0x0261 == codePoint) ||
- (0x02C4 == codePoint) ||
- (0x02C7 == codePoint) ||
- (0x02C9 <= codePoint && codePoint <= 0x02CB) ||
- (0x02CD == codePoint) ||
- (0x02D0 == codePoint) ||
- (0x02D8 <= codePoint && codePoint <= 0x02DB) ||
- (0x02DD == codePoint) ||
- (0x02DF == codePoint) ||
- (0x0300 <= codePoint && codePoint <= 0x036F) ||
- (0x0391 <= codePoint && codePoint <= 0x03A1) ||
- (0x03A3 <= codePoint && codePoint <= 0x03A9) ||
- (0x03B1 <= codePoint && codePoint <= 0x03C1) ||
- (0x03C3 <= codePoint && codePoint <= 0x03C9) ||
- (0x0401 == codePoint) ||
- (0x0410 <= codePoint && codePoint <= 0x044F) ||
- (0x0451 == codePoint) ||
- (0x2010 == codePoint) ||
- (0x2013 <= codePoint && codePoint <= 0x2016) ||
- (0x2018 <= codePoint && codePoint <= 0x2019) ||
- (0x201C <= codePoint && codePoint <= 0x201D) ||
- (0x2020 <= codePoint && codePoint <= 0x2022) ||
- (0x2024 <= codePoint && codePoint <= 0x2027) ||
- (0x2030 == codePoint) ||
- (0x2032 <= codePoint && codePoint <= 0x2033) ||
- (0x2035 == codePoint) ||
- (0x203B == codePoint) ||
- (0x203E == codePoint) ||
- (0x2074 == codePoint) ||
- (0x207F == codePoint) ||
- (0x2081 <= codePoint && codePoint <= 0x2084) ||
- (0x20AC == codePoint) ||
- (0x2103 == codePoint) ||
- (0x2105 == codePoint) ||
- (0x2109 == codePoint) ||
- (0x2113 == codePoint) ||
- (0x2116 == codePoint) ||
- (0x2121 <= codePoint && codePoint <= 0x2122) ||
- (0x2126 == codePoint) ||
- (0x212B == codePoint) ||
- (0x2153 <= codePoint && codePoint <= 0x2154) ||
- (0x215B <= codePoint && codePoint <= 0x215E) ||
- (0x2160 <= codePoint && codePoint <= 0x216B) ||
- (0x2170 <= codePoint && codePoint <= 0x2179) ||
- (0x2189 == codePoint) ||
- (0x2190 <= codePoint && codePoint <= 0x2199) ||
- (0x21B8 <= codePoint && codePoint <= 0x21B9) ||
- (0x21D2 == codePoint) ||
- (0x21D4 == codePoint) ||
- (0x21E7 == codePoint) ||
- (0x2200 == codePoint) ||
- (0x2202 <= codePoint && codePoint <= 0x2203) ||
- (0x2207 <= codePoint && codePoint <= 0x2208) ||
- (0x220B == codePoint) ||
- (0x220F == codePoint) ||
- (0x2211 == codePoint) ||
- (0x2215 == codePoint) ||
- (0x221A == codePoint) ||
- (0x221D <= codePoint && codePoint <= 0x2220) ||
- (0x2223 == codePoint) ||
- (0x2225 == codePoint) ||
- (0x2227 <= codePoint && codePoint <= 0x222C) ||
- (0x222E == codePoint) ||
- (0x2234 <= codePoint && codePoint <= 0x2237) ||
- (0x223C <= codePoint && codePoint <= 0x223D) ||
- (0x2248 == codePoint) ||
- (0x224C == codePoint) ||
- (0x2252 == codePoint) ||
- (0x2260 <= codePoint && codePoint <= 0x2261) ||
- (0x2264 <= codePoint && codePoint <= 0x2267) ||
- (0x226A <= codePoint && codePoint <= 0x226B) ||
- (0x226E <= codePoint && codePoint <= 0x226F) ||
- (0x2282 <= codePoint && codePoint <= 0x2283) ||
- (0x2286 <= codePoint && codePoint <= 0x2287) ||
- (0x2295 == codePoint) ||
- (0x2299 == codePoint) ||
- (0x22A5 == codePoint) ||
- (0x22BF == codePoint) ||
- (0x2312 == codePoint) ||
- (0x2460 <= codePoint && codePoint <= 0x24E9) ||
- (0x24EB <= codePoint && codePoint <= 0x254B) ||
- (0x2550 <= codePoint && codePoint <= 0x2573) ||
- (0x2580 <= codePoint && codePoint <= 0x258F) ||
- (0x2592 <= codePoint && codePoint <= 0x2595) ||
- (0x25A0 <= codePoint && codePoint <= 0x25A1) ||
- (0x25A3 <= codePoint && codePoint <= 0x25A9) ||
- (0x25B2 <= codePoint && codePoint <= 0x25B3) ||
- (0x25B6 <= codePoint && codePoint <= 0x25B7) ||
- (0x25BC <= codePoint && codePoint <= 0x25BD) ||
- (0x25C0 <= codePoint && codePoint <= 0x25C1) ||
- (0x25C6 <= codePoint && codePoint <= 0x25C8) ||
- (0x25CB == codePoint) ||
- (0x25CE <= codePoint && codePoint <= 0x25D1) ||
- (0x25E2 <= codePoint && codePoint <= 0x25E5) ||
- (0x25EF == codePoint) ||
- (0x2605 <= codePoint && codePoint <= 0x2606) ||
- (0x2609 == codePoint) ||
- (0x260E <= codePoint && codePoint <= 0x260F) ||
- (0x2614 <= codePoint && codePoint <= 0x2615) ||
- (0x261C == codePoint) ||
- (0x261E == codePoint) ||
- (0x2640 == codePoint) ||
- (0x2642 == codePoint) ||
- (0x2660 <= codePoint && codePoint <= 0x2661) ||
- (0x2663 <= codePoint && codePoint <= 0x2665) ||
- (0x2667 <= codePoint && codePoint <= 0x266A) ||
- (0x266C <= codePoint && codePoint <= 0x266D) ||
- (0x266F == codePoint) ||
- (0x269E <= codePoint && codePoint <= 0x269F) ||
- (0x26BE <= codePoint && codePoint <= 0x26BF) ||
- (0x26C4 <= codePoint && codePoint <= 0x26CD) ||
- (0x26CF <= codePoint && codePoint <= 0x26E1) ||
- (0x26E3 == codePoint) ||
- (0x26E8 <= codePoint && codePoint <= 0x26FF) ||
- (0x273D == codePoint) ||
- (0x2757 == codePoint) ||
- (0x2776 <= codePoint && codePoint <= 0x277F) ||
- (0x2B55 <= codePoint && codePoint <= 0x2B59) ||
- (0x3248 <= codePoint && codePoint <= 0x324F) ||
- (0xE000 <= codePoint && codePoint <= 0xF8FF) ||
- (0xFE00 <= codePoint && codePoint <= 0xFE0F) ||
- (0xFFFD == codePoint) ||
- (0x1F100 <= codePoint && codePoint <= 0x1F10A) ||
- (0x1F110 <= codePoint && codePoint <= 0x1F12D) ||
- (0x1F130 <= codePoint && codePoint <= 0x1F169) ||
- (0x1F170 <= codePoint && codePoint <= 0x1F19A) ||
- (0xE0100 <= codePoint && codePoint <= 0xE01EF) ||
- (0xF0000 <= codePoint && codePoint <= 0xFFFFD) ||
- (0x100000 <= codePoint && codePoint <= 0x10FFFD)) {
- return 'A';
- }
- return 'N';
- };
- eaw.characterLength = function(character) {
- var code = this.eastAsianWidth(character);
- if (code == 'F' || code == 'W' || code == 'A') {
- return 2;
- } else {
- return 1;
- }
- };
- // Split a string considering surrogate-pairs.
- function stringToArray(string) {
- return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
- }
- eaw.length = function(string) {
- var characters = stringToArray(string);
- var len = 0;
- for (var i = 0; i < characters.length; i++) {
- len = len + this.characterLength(characters[i]);
- }
- return len;
- };
- eaw.slice = function(text, start, end) {
- textLen = eaw.length(text);
- start = start ? start : 0;
- end = end ? end : 1;
- if (start < 0) {
- start = textLen + start;
- }
- if (end < 0) {
- end = textLen + end;
- }
- var result = '';
- var eawLen = 0;
- var chars = stringToArray(text);
- for (var i = 0; i < chars.length; i++) {
- var char = chars[i];
- var charLen = eaw.length(char);
- if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
- if (eawLen + charLen <= end) {
- result += char;
- } else {
- break;
- }
- }
- eawLen += charLen;
- }
- return result;
- };
- } (eastasianwidth));
- var eastAsianWidth = eastasianwidth.exports;
- var emojiRegex = function () {
- // https://mths.be/emoji
- return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
- };
- function stringWidth(string, options = {}) {
- if (typeof string !== 'string' || string.length === 0) {
- return 0;
- }
- options = {
- ambiguousIsNarrow: true,
- ...options
- };
- string = stripAnsi(string);
- if (string.length === 0) {
- return 0;
- }
- string = string.replace(emojiRegex(), ' ');
- const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
- let width = 0;
- for (const character of string) {
- const codePoint = character.codePointAt(0);
- // Ignore control characters
- if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
- continue;
- }
- // Ignore combining characters
- if (codePoint >= 0x300 && codePoint <= 0x36F) {
- continue;
- }
- const code = eastAsianWidth.eastAsianWidth(character);
- switch (code) {
- case 'F':
- case 'W':
- width += 2;
- break;
- case 'A':
- width += ambiguousCharacterWidth;
- break;
- default:
- width += 1;
- }
- }
- return width;
- }
- function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
- if (string.charAt(wantedIndex) === ' ') {
- return wantedIndex;
- }
- for (let index = 1; index <= 3; index++) {
- if (shouldSearchRight) {
- if (string.charAt(wantedIndex + index) === ' ') {
- return wantedIndex + index;
- }
- } else if (string.charAt(wantedIndex - index) === ' ') {
- return wantedIndex - index;
- }
- }
- return wantedIndex;
- }
- function cliTruncate(text, columns, options) {
- options = {
- position: 'end',
- preferTruncationOnSpace: false,
- truncationCharacter: '…',
- ...options,
- };
- const {position, space, preferTruncationOnSpace} = options;
- let {truncationCharacter} = options;
- if (typeof text !== 'string') {
- throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
- }
- if (typeof columns !== 'number') {
- throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
- }
- if (columns < 1) {
- return '';
- }
- if (columns === 1) {
- return truncationCharacter;
- }
- const length = stringWidth(text);
- if (length <= columns) {
- return text;
- }
- if (position === 'start') {
- if (preferTruncationOnSpace) {
- const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
- return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim();
- }
- if (space === true) {
- truncationCharacter += ' ';
- }
- return truncationCharacter + sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
- }
- if (position === 'middle') {
- if (space === true) {
- truncationCharacter = ` ${truncationCharacter} `;
- }
- const half = Math.floor(columns / 2);
- if (preferTruncationOnSpace) {
- const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
- const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
- return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
- }
- return (
- sliceAnsi(text, 0, half)
- + truncationCharacter
- + sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length)
- );
- }
- if (position === 'end') {
- if (preferTruncationOnSpace) {
- const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
- return sliceAnsi(text, 0, nearestSpace) + truncationCharacter;
- }
- if (space === true) {
- truncationCharacter = ` ${truncationCharacter}`;
- }
- return sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
- }
- throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
- }
- function formatLine(line, outputTruncateLength) {
- var _a;
- return cliTruncate(line, (outputTruncateLength ?? (((_a = process.stdout) == null ? void 0 : _a.columns) || 80)) - 4);
- }
- function unifiedDiff(actual, expected, options = {}) {
- if (actual === expected)
- return "";
- const { outputTruncateLength, outputDiffLines, showLegend = true } = options;
- const indent = " ";
- const diffLimit = outputDiffLines || 15;
- const counts = {
- "+": 0,
- "-": 0
- };
- let previousState = null;
- let previousCount = 0;
- function preprocess(line) {
- if (!line || line.match(/\\ No newline/))
- return;
- const char = line[0];
- if ("-+".includes(char)) {
- if (previousState !== char) {
- previousState = char;
- previousCount = 0;
- }
- previousCount++;
- counts[char]++;
- if (previousCount === diffLimit)
- return picocolors.exports.dim(`${char} ...`);
- else if (previousCount > diffLimit)
- return;
- }
- return line;
- }
- const msg = createPatch("string", expected, actual);
- const lines = msg.split("\n").slice(5).map(preprocess).filter(Boolean);
- const isCompact = counts["+"] === 1 && counts["-"] === 1 && lines.length === 2;
- let formatted = lines.map((line) => {
- line = line.replace(/\\"/g, '"');
- if (line[0] === "-") {
- line = formatLine(line.slice(1), outputTruncateLength);
- if (isCompact)
- return picocolors.exports.green(line);
- return picocolors.exports.green(`- ${formatLine(line, outputTruncateLength)}`);
- }
- if (line[0] === "+") {
- line = formatLine(line.slice(1), outputTruncateLength);
- if (isCompact)
- return picocolors.exports.red(line);
- return picocolors.exports.red(`+ ${formatLine(line, outputTruncateLength)}`);
- }
- if (line.match(/@@/))
- return "--";
- return ` ${line}`;
- });
- if (showLegend) {
- if (isCompact) {
- formatted = [
- `${picocolors.exports.green("- Expected")} ${formatted[0]}`,
- `${picocolors.exports.red("+ Received")} ${formatted[1]}`
- ];
- } else {
- if (formatted[0].includes('"'))
- formatted[0] = formatted[0].replace('"', "");
- const last = formatted.length - 1;
- if (formatted[last].endsWith('"'))
- formatted[last] = formatted[last].slice(0, formatted[last].length - 1);
- formatted.unshift(
- picocolors.exports.green(`- Expected - ${counts["-"]}`),
- picocolors.exports.red(`+ Received + ${counts["+"]}`),
- ""
- );
- }
- }
- return formatted.map((i) => indent + i).join("\n");
- }
- const EXPECTED_COLOR = picocolors.exports.green;
- const RECEIVED_COLOR = picocolors.exports.red;
- const INVERTED_COLOR = picocolors.exports.inverse;
- const BOLD_WEIGHT = picocolors.exports.bold;
- const DIM_COLOR = picocolors.exports.dim;
- const {
- AsymmetricMatcher,
- DOMCollection,
- DOMElement,
- Immutable,
- ReactElement,
- ReactTestComponent
- } = plugins_1;
- const PLUGINS = [
- ReactTestComponent,
- ReactElement,
- DOMElement,
- DOMCollection,
- Immutable,
- AsymmetricMatcher
- ];
- function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
- const {
- comment = "",
- expectedColor = EXPECTED_COLOR,
- isDirectExpectCall = false,
- isNot = false,
- promise = "",
- receivedColor = RECEIVED_COLOR,
- secondArgument = "",
- secondArgumentColor = EXPECTED_COLOR
- } = options;
- let hint = "";
- let dimString = "expect";
- if (!isDirectExpectCall && received !== "") {
- hint += DIM_COLOR(`${dimString}(`) + receivedColor(received);
- dimString = ")";
- }
- if (promise !== "") {
- hint += DIM_COLOR(`${dimString}.`) + promise;
- dimString = "";
- }
- if (isNot) {
- hint += `${DIM_COLOR(`${dimString}.`)}not`;
- dimString = "";
- }
- if (matcherName.includes(".")) {
- dimString += matcherName;
- } else {
- hint += DIM_COLOR(`${dimString}.`) + matcherName;
- dimString = "";
- }
- if (expected === "") {
- dimString += "()";
- } else {
- hint += DIM_COLOR(`${dimString}(`) + expectedColor(expected);
- if (secondArgument)
- hint += DIM_COLOR(", ") + secondArgumentColor(secondArgument);
- dimString = ")";
- }
- if (comment !== "")
- dimString += ` // ${comment}`;
- if (dimString !== "")
- hint += DIM_COLOR(dimString);
- return hint;
- }
- const SPACE_SYMBOL = "\xB7";
- const replaceTrailingSpaces = (text) => text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
- function stringify(object, maxDepth = 10, options) {
- const MAX_LENGTH = 1e4;
- let result;
- try {
- result = format_1(object, {
- maxDepth,
- plugins: PLUGINS,
- ...options
- });
- } catch {
- result = format_1(object, {
- callToJSON: false,
- maxDepth,
- plugins: PLUGINS,
- ...options
- });
- }
- return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
- }
- const printReceived = (object) => RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)));
- const printExpected = (value) => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)));
- function diff(a, b, options) {
- return unifiedDiff(stringify(b), stringify(a));
- }
- var matcherUtils = /*#__PURE__*/Object.freeze({
- __proto__: null,
- EXPECTED_COLOR: EXPECTED_COLOR,
- RECEIVED_COLOR: RECEIVED_COLOR,
- INVERTED_COLOR: INVERTED_COLOR,
- BOLD_WEIGHT: BOLD_WEIGHT,
- DIM_COLOR: DIM_COLOR,
- matcherHint: matcherHint,
- stringify: stringify,
- printReceived: printReceived,
- printExpected: printExpected,
- diff: diff
- });
- export { plugins_1 as a, posToNumber as b, stripAnsi as c, cliTruncate as d, stringWidth as e, format_1 as f, getOriginalPos as g, ansiStyles as h, interpretSourcePos as i, sliceAnsi as j, lineSplitRE as l, matcherUtils as m, numberToPos as n, parseStacktrace as p, stringify as s, unifiedDiff as u };
|