publicUtils.cjs 156 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165
  1. 'use strict';
  2. var path$3 = require('node:path');
  3. var node_url = require('node:url');
  4. var fs$1 = require('node:fs');
  5. var esbuild = require('esbuild');
  6. var node_module = require('node:module');
  7. var require$$0 = require('tty');
  8. var require$$1 = require('util');
  9. var require$$0$1 = require('path');
  10. var require$$0$2 = require('crypto');
  11. var fs$2 = require('fs');
  12. var readline = require('node:readline');
  13. var require$$2 = require('os');
  14. var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
  15. const { version: version$2 } = JSON.parse(
  16. fs$1.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString()
  17. );
  18. const VERSION = version$2;
  19. const FS_PREFIX = `/@fs/`;
  20. const VITE_PACKAGE_DIR = path$3.resolve(
  21. // import.meta.url is `dist/node/constants.js` after bundle
  22. node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))),
  23. "../../.."
  24. );
  25. const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
  26. path$3.resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
  27. path$3.dirname(CLIENT_ENTRY);
  28. const comma = ','.charCodeAt(0);
  29. const semicolon = ';'.charCodeAt(0);
  30. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  31. const intToChar = new Uint8Array(64); // 64 possible chars.
  32. const charToInt = new Uint8Array(128); // z is 122 in ASCII
  33. for (let i = 0; i < chars.length; i++) {
  34. const c = chars.charCodeAt(i);
  35. intToChar[i] = c;
  36. charToInt[c] = i;
  37. }
  38. function encodeInteger(builder, num, relative) {
  39. let delta = num - relative;
  40. delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
  41. do {
  42. let clamped = delta & 0b011111;
  43. delta >>>= 5;
  44. if (delta > 0)
  45. clamped |= 0b100000;
  46. builder.write(intToChar[clamped]);
  47. } while (delta > 0);
  48. return num;
  49. }
  50. const bufLength = 1024 * 16;
  51. // Provide a fallback for older environments.
  52. const td = typeof TextDecoder !== 'undefined'
  53. ? /* #__PURE__ */ new TextDecoder()
  54. : typeof Buffer !== 'undefined'
  55. ? {
  56. decode(buf) {
  57. const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
  58. return out.toString();
  59. },
  60. }
  61. : {
  62. decode(buf) {
  63. let out = '';
  64. for (let i = 0; i < buf.length; i++) {
  65. out += String.fromCharCode(buf[i]);
  66. }
  67. return out;
  68. },
  69. };
  70. class StringWriter {
  71. constructor() {
  72. this.pos = 0;
  73. this.out = '';
  74. this.buffer = new Uint8Array(bufLength);
  75. }
  76. write(v) {
  77. const { buffer } = this;
  78. buffer[this.pos++] = v;
  79. if (this.pos === bufLength) {
  80. this.out += td.decode(buffer);
  81. this.pos = 0;
  82. }
  83. }
  84. flush() {
  85. const { buffer, out, pos } = this;
  86. return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
  87. }
  88. }
  89. function encode(decoded) {
  90. const writer = new StringWriter();
  91. let sourcesIndex = 0;
  92. let sourceLine = 0;
  93. let sourceColumn = 0;
  94. let namesIndex = 0;
  95. for (let i = 0; i < decoded.length; i++) {
  96. const line = decoded[i];
  97. if (i > 0)
  98. writer.write(semicolon);
  99. if (line.length === 0)
  100. continue;
  101. let genColumn = 0;
  102. for (let j = 0; j < line.length; j++) {
  103. const segment = line[j];
  104. if (j > 0)
  105. writer.write(comma);
  106. genColumn = encodeInteger(writer, segment[0], genColumn);
  107. if (segment.length === 1)
  108. continue;
  109. sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
  110. sourceLine = encodeInteger(writer, segment[2], sourceLine);
  111. sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
  112. if (segment.length === 4)
  113. continue;
  114. namesIndex = encodeInteger(writer, segment[4], namesIndex);
  115. }
  116. }
  117. return writer.flush();
  118. }
  119. function getDefaultExportFromCjs (x) {
  120. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  121. }
  122. function commonjsRequire(path) {
  123. throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
  124. }
  125. var picocolors = {exports: {}};
  126. let argv = process.argv || [],
  127. env = process.env;
  128. let isColorSupported =
  129. !("NO_COLOR" in env || argv.includes("--no-color")) &&
  130. ("FORCE_COLOR" in env ||
  131. argv.includes("--color") ||
  132. process.platform === "win32" ||
  133. (commonjsRequire != null && require$$0.isatty(1) && env.TERM !== "dumb") ||
  134. "CI" in env);
  135. let formatter =
  136. (open, close, replace = open) =>
  137. input => {
  138. let string = "" + input;
  139. let index = string.indexOf(close, open.length);
  140. return ~index
  141. ? open + replaceClose(string, close, replace, index) + close
  142. : open + string + close
  143. };
  144. let replaceClose = (string, close, replace, index) => {
  145. let result = "";
  146. let cursor = 0;
  147. do {
  148. result += string.substring(cursor, index) + replace;
  149. cursor = index + close.length;
  150. index = string.indexOf(close, cursor);
  151. } while (~index)
  152. return result + string.substring(cursor)
  153. };
  154. let createColors = (enabled = isColorSupported) => {
  155. let init = enabled ? formatter : () => String;
  156. return {
  157. isColorSupported: enabled,
  158. reset: init("\x1b[0m", "\x1b[0m"),
  159. bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
  160. dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
  161. italic: init("\x1b[3m", "\x1b[23m"),
  162. underline: init("\x1b[4m", "\x1b[24m"),
  163. inverse: init("\x1b[7m", "\x1b[27m"),
  164. hidden: init("\x1b[8m", "\x1b[28m"),
  165. strikethrough: init("\x1b[9m", "\x1b[29m"),
  166. black: init("\x1b[30m", "\x1b[39m"),
  167. red: init("\x1b[31m", "\x1b[39m"),
  168. green: init("\x1b[32m", "\x1b[39m"),
  169. yellow: init("\x1b[33m", "\x1b[39m"),
  170. blue: init("\x1b[34m", "\x1b[39m"),
  171. magenta: init("\x1b[35m", "\x1b[39m"),
  172. cyan: init("\x1b[36m", "\x1b[39m"),
  173. white: init("\x1b[37m", "\x1b[39m"),
  174. gray: init("\x1b[90m", "\x1b[39m"),
  175. bgBlack: init("\x1b[40m", "\x1b[49m"),
  176. bgRed: init("\x1b[41m", "\x1b[49m"),
  177. bgGreen: init("\x1b[42m", "\x1b[49m"),
  178. bgYellow: init("\x1b[43m", "\x1b[49m"),
  179. bgBlue: init("\x1b[44m", "\x1b[49m"),
  180. bgMagenta: init("\x1b[45m", "\x1b[49m"),
  181. bgCyan: init("\x1b[46m", "\x1b[49m"),
  182. bgWhite: init("\x1b[47m", "\x1b[49m"),
  183. }
  184. };
  185. picocolors.exports = createColors();
  186. picocolors.exports.createColors = createColors;
  187. var picocolorsExports = picocolors.exports;
  188. var colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
  189. var src = {exports: {}};
  190. var browser$1 = {exports: {}};
  191. /**
  192. * Helpers.
  193. */
  194. var ms;
  195. var hasRequiredMs;
  196. function requireMs () {
  197. if (hasRequiredMs) return ms;
  198. hasRequiredMs = 1;
  199. var s = 1000;
  200. var m = s * 60;
  201. var h = m * 60;
  202. var d = h * 24;
  203. var w = d * 7;
  204. var y = d * 365.25;
  205. /**
  206. * Parse or format the given `val`.
  207. *
  208. * Options:
  209. *
  210. * - `long` verbose formatting [false]
  211. *
  212. * @param {String|Number} val
  213. * @param {Object} [options]
  214. * @throws {Error} throw an error if val is not a non-empty string or a number
  215. * @return {String|Number}
  216. * @api public
  217. */
  218. ms = function(val, options) {
  219. options = options || {};
  220. var type = typeof val;
  221. if (type === 'string' && val.length > 0) {
  222. return parse(val);
  223. } else if (type === 'number' && isFinite(val)) {
  224. return options.long ? fmtLong(val) : fmtShort(val);
  225. }
  226. throw new Error(
  227. 'val is not a non-empty string or a valid number. val=' +
  228. JSON.stringify(val)
  229. );
  230. };
  231. /**
  232. * Parse the given `str` and return milliseconds.
  233. *
  234. * @param {String} str
  235. * @return {Number}
  236. * @api private
  237. */
  238. function parse(str) {
  239. str = String(str);
  240. if (str.length > 100) {
  241. return;
  242. }
  243. var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
  244. str
  245. );
  246. if (!match) {
  247. return;
  248. }
  249. var n = parseFloat(match[1]);
  250. var type = (match[2] || 'ms').toLowerCase();
  251. switch (type) {
  252. case 'years':
  253. case 'year':
  254. case 'yrs':
  255. case 'yr':
  256. case 'y':
  257. return n * y;
  258. case 'weeks':
  259. case 'week':
  260. case 'w':
  261. return n * w;
  262. case 'days':
  263. case 'day':
  264. case 'd':
  265. return n * d;
  266. case 'hours':
  267. case 'hour':
  268. case 'hrs':
  269. case 'hr':
  270. case 'h':
  271. return n * h;
  272. case 'minutes':
  273. case 'minute':
  274. case 'mins':
  275. case 'min':
  276. case 'm':
  277. return n * m;
  278. case 'seconds':
  279. case 'second':
  280. case 'secs':
  281. case 'sec':
  282. case 's':
  283. return n * s;
  284. case 'milliseconds':
  285. case 'millisecond':
  286. case 'msecs':
  287. case 'msec':
  288. case 'ms':
  289. return n;
  290. default:
  291. return undefined;
  292. }
  293. }
  294. /**
  295. * Short format for `ms`.
  296. *
  297. * @param {Number} ms
  298. * @return {String}
  299. * @api private
  300. */
  301. function fmtShort(ms) {
  302. var msAbs = Math.abs(ms);
  303. if (msAbs >= d) {
  304. return Math.round(ms / d) + 'd';
  305. }
  306. if (msAbs >= h) {
  307. return Math.round(ms / h) + 'h';
  308. }
  309. if (msAbs >= m) {
  310. return Math.round(ms / m) + 'm';
  311. }
  312. if (msAbs >= s) {
  313. return Math.round(ms / s) + 's';
  314. }
  315. return ms + 'ms';
  316. }
  317. /**
  318. * Long format for `ms`.
  319. *
  320. * @param {Number} ms
  321. * @return {String}
  322. * @api private
  323. */
  324. function fmtLong(ms) {
  325. var msAbs = Math.abs(ms);
  326. if (msAbs >= d) {
  327. return plural(ms, msAbs, d, 'day');
  328. }
  329. if (msAbs >= h) {
  330. return plural(ms, msAbs, h, 'hour');
  331. }
  332. if (msAbs >= m) {
  333. return plural(ms, msAbs, m, 'minute');
  334. }
  335. if (msAbs >= s) {
  336. return plural(ms, msAbs, s, 'second');
  337. }
  338. return ms + ' ms';
  339. }
  340. /**
  341. * Pluralization helper.
  342. */
  343. function plural(ms, msAbs, n, name) {
  344. var isPlural = msAbs >= n * 1.5;
  345. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  346. }
  347. return ms;
  348. }
  349. var common;
  350. var hasRequiredCommon;
  351. function requireCommon () {
  352. if (hasRequiredCommon) return common;
  353. hasRequiredCommon = 1;
  354. /**
  355. * This is the common logic for both the Node.js and web browser
  356. * implementations of `debug()`.
  357. */
  358. function setup(env) {
  359. createDebug.debug = createDebug;
  360. createDebug.default = createDebug;
  361. createDebug.coerce = coerce;
  362. createDebug.disable = disable;
  363. createDebug.enable = enable;
  364. createDebug.enabled = enabled;
  365. createDebug.humanize = requireMs();
  366. createDebug.destroy = destroy;
  367. Object.keys(env).forEach(key => {
  368. createDebug[key] = env[key];
  369. });
  370. /**
  371. * The currently active debug mode names, and names to skip.
  372. */
  373. createDebug.names = [];
  374. createDebug.skips = [];
  375. /**
  376. * Map of special "%n" handling functions, for the debug "format" argument.
  377. *
  378. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  379. */
  380. createDebug.formatters = {};
  381. /**
  382. * Selects a color for a debug namespace
  383. * @param {String} namespace The namespace string for the debug instance to be colored
  384. * @return {Number|String} An ANSI color code for the given namespace
  385. * @api private
  386. */
  387. function selectColor(namespace) {
  388. let hash = 0;
  389. for (let i = 0; i < namespace.length; i++) {
  390. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  391. hash |= 0; // Convert to 32bit integer
  392. }
  393. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  394. }
  395. createDebug.selectColor = selectColor;
  396. /**
  397. * Create a debugger with the given `namespace`.
  398. *
  399. * @param {String} namespace
  400. * @return {Function}
  401. * @api public
  402. */
  403. function createDebug(namespace) {
  404. let prevTime;
  405. let enableOverride = null;
  406. let namespacesCache;
  407. let enabledCache;
  408. function debug(...args) {
  409. // Disabled?
  410. if (!debug.enabled) {
  411. return;
  412. }
  413. const self = debug;
  414. // Set `diff` timestamp
  415. const curr = Number(new Date());
  416. const ms = curr - (prevTime || curr);
  417. self.diff = ms;
  418. self.prev = prevTime;
  419. self.curr = curr;
  420. prevTime = curr;
  421. args[0] = createDebug.coerce(args[0]);
  422. if (typeof args[0] !== 'string') {
  423. // Anything else let's inspect with %O
  424. args.unshift('%O');
  425. }
  426. // Apply any `formatters` transformations
  427. let index = 0;
  428. args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
  429. // If we encounter an escaped % then don't increase the array index
  430. if (match === '%%') {
  431. return '%';
  432. }
  433. index++;
  434. const formatter = createDebug.formatters[format];
  435. if (typeof formatter === 'function') {
  436. const val = args[index];
  437. match = formatter.call(self, val);
  438. // Now we need to remove `args[index]` since it's inlined in the `format`
  439. args.splice(index, 1);
  440. index--;
  441. }
  442. return match;
  443. });
  444. // Apply env-specific formatting (colors, etc.)
  445. createDebug.formatArgs.call(self, args);
  446. const logFn = self.log || createDebug.log;
  447. logFn.apply(self, args);
  448. }
  449. debug.namespace = namespace;
  450. debug.useColors = createDebug.useColors();
  451. debug.color = createDebug.selectColor(namespace);
  452. debug.extend = extend;
  453. debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
  454. Object.defineProperty(debug, 'enabled', {
  455. enumerable: true,
  456. configurable: false,
  457. get: () => {
  458. if (enableOverride !== null) {
  459. return enableOverride;
  460. }
  461. if (namespacesCache !== createDebug.namespaces) {
  462. namespacesCache = createDebug.namespaces;
  463. enabledCache = createDebug.enabled(namespace);
  464. }
  465. return enabledCache;
  466. },
  467. set: v => {
  468. enableOverride = v;
  469. }
  470. });
  471. // Env-specific initialization logic for debug instances
  472. if (typeof createDebug.init === 'function') {
  473. createDebug.init(debug);
  474. }
  475. return debug;
  476. }
  477. function extend(namespace, delimiter) {
  478. const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  479. newDebug.log = this.log;
  480. return newDebug;
  481. }
  482. /**
  483. * Enables a debug mode by namespaces. This can include modes
  484. * separated by a colon and wildcards.
  485. *
  486. * @param {String} namespaces
  487. * @api public
  488. */
  489. function enable(namespaces) {
  490. createDebug.save(namespaces);
  491. createDebug.namespaces = namespaces;
  492. createDebug.names = [];
  493. createDebug.skips = [];
  494. let i;
  495. const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  496. const len = split.length;
  497. for (i = 0; i < len; i++) {
  498. if (!split[i]) {
  499. // ignore empty strings
  500. continue;
  501. }
  502. namespaces = split[i].replace(/\*/g, '.*?');
  503. if (namespaces[0] === '-') {
  504. createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
  505. } else {
  506. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  507. }
  508. }
  509. }
  510. /**
  511. * Disable debug output.
  512. *
  513. * @return {String} namespaces
  514. * @api public
  515. */
  516. function disable() {
  517. const namespaces = [
  518. ...createDebug.names.map(toNamespace),
  519. ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
  520. ].join(',');
  521. createDebug.enable('');
  522. return namespaces;
  523. }
  524. /**
  525. * Returns true if the given mode name is enabled, false otherwise.
  526. *
  527. * @param {String} name
  528. * @return {Boolean}
  529. * @api public
  530. */
  531. function enabled(name) {
  532. if (name[name.length - 1] === '*') {
  533. return true;
  534. }
  535. let i;
  536. let len;
  537. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  538. if (createDebug.skips[i].test(name)) {
  539. return false;
  540. }
  541. }
  542. for (i = 0, len = createDebug.names.length; i < len; i++) {
  543. if (createDebug.names[i].test(name)) {
  544. return true;
  545. }
  546. }
  547. return false;
  548. }
  549. /**
  550. * Convert regexp to namespace
  551. *
  552. * @param {RegExp} regxep
  553. * @return {String} namespace
  554. * @api private
  555. */
  556. function toNamespace(regexp) {
  557. return regexp.toString()
  558. .substring(2, regexp.toString().length - 2)
  559. .replace(/\.\*\?$/, '*');
  560. }
  561. /**
  562. * Coerce `val`.
  563. *
  564. * @param {Mixed} val
  565. * @return {Mixed}
  566. * @api private
  567. */
  568. function coerce(val) {
  569. if (val instanceof Error) {
  570. return val.stack || val.message;
  571. }
  572. return val;
  573. }
  574. /**
  575. * XXX DO NOT USE. This is a temporary stub function.
  576. * XXX It WILL be removed in the next major release.
  577. */
  578. function destroy() {
  579. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  580. }
  581. createDebug.enable(createDebug.load());
  582. return createDebug;
  583. }
  584. common = setup;
  585. return common;
  586. }
  587. /* eslint-env browser */
  588. var hasRequiredBrowser;
  589. function requireBrowser () {
  590. if (hasRequiredBrowser) return browser$1.exports;
  591. hasRequiredBrowser = 1;
  592. (function (module, exports) {
  593. /**
  594. * This is the web browser implementation of `debug()`.
  595. */
  596. exports.formatArgs = formatArgs;
  597. exports.save = save;
  598. exports.load = load;
  599. exports.useColors = useColors;
  600. exports.storage = localstorage();
  601. exports.destroy = (() => {
  602. let warned = false;
  603. return () => {
  604. if (!warned) {
  605. warned = true;
  606. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  607. }
  608. };
  609. })();
  610. /**
  611. * Colors.
  612. */
  613. exports.colors = [
  614. '#0000CC',
  615. '#0000FF',
  616. '#0033CC',
  617. '#0033FF',
  618. '#0066CC',
  619. '#0066FF',
  620. '#0099CC',
  621. '#0099FF',
  622. '#00CC00',
  623. '#00CC33',
  624. '#00CC66',
  625. '#00CC99',
  626. '#00CCCC',
  627. '#00CCFF',
  628. '#3300CC',
  629. '#3300FF',
  630. '#3333CC',
  631. '#3333FF',
  632. '#3366CC',
  633. '#3366FF',
  634. '#3399CC',
  635. '#3399FF',
  636. '#33CC00',
  637. '#33CC33',
  638. '#33CC66',
  639. '#33CC99',
  640. '#33CCCC',
  641. '#33CCFF',
  642. '#6600CC',
  643. '#6600FF',
  644. '#6633CC',
  645. '#6633FF',
  646. '#66CC00',
  647. '#66CC33',
  648. '#9900CC',
  649. '#9900FF',
  650. '#9933CC',
  651. '#9933FF',
  652. '#99CC00',
  653. '#99CC33',
  654. '#CC0000',
  655. '#CC0033',
  656. '#CC0066',
  657. '#CC0099',
  658. '#CC00CC',
  659. '#CC00FF',
  660. '#CC3300',
  661. '#CC3333',
  662. '#CC3366',
  663. '#CC3399',
  664. '#CC33CC',
  665. '#CC33FF',
  666. '#CC6600',
  667. '#CC6633',
  668. '#CC9900',
  669. '#CC9933',
  670. '#CCCC00',
  671. '#CCCC33',
  672. '#FF0000',
  673. '#FF0033',
  674. '#FF0066',
  675. '#FF0099',
  676. '#FF00CC',
  677. '#FF00FF',
  678. '#FF3300',
  679. '#FF3333',
  680. '#FF3366',
  681. '#FF3399',
  682. '#FF33CC',
  683. '#FF33FF',
  684. '#FF6600',
  685. '#FF6633',
  686. '#FF9900',
  687. '#FF9933',
  688. '#FFCC00',
  689. '#FFCC33'
  690. ];
  691. /**
  692. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  693. * and the Firebug extension (any Firefox version) are known
  694. * to support "%c" CSS customizations.
  695. *
  696. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  697. */
  698. // eslint-disable-next-line complexity
  699. function useColors() {
  700. // NB: In an Electron preload script, document will be defined but not fully
  701. // initialized. Since we know we're in Chrome, we'll just detect this case
  702. // explicitly
  703. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  704. return true;
  705. }
  706. // Internet Explorer and Edge do not support colors.
  707. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  708. return false;
  709. }
  710. let m;
  711. // Is webkit? http://stackoverflow.com/a/16459606/376773
  712. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  713. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  714. // Is firebug? http://stackoverflow.com/a/398120/376773
  715. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  716. // Is firefox >= v31?
  717. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  718. (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
  719. // Double check webkit in userAgent just in case we are in a worker
  720. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  721. }
  722. /**
  723. * Colorize log arguments if enabled.
  724. *
  725. * @api public
  726. */
  727. function formatArgs(args) {
  728. args[0] = (this.useColors ? '%c' : '') +
  729. this.namespace +
  730. (this.useColors ? ' %c' : ' ') +
  731. args[0] +
  732. (this.useColors ? '%c ' : ' ') +
  733. '+' + module.exports.humanize(this.diff);
  734. if (!this.useColors) {
  735. return;
  736. }
  737. const c = 'color: ' + this.color;
  738. args.splice(1, 0, c, 'color: inherit');
  739. // The final "%c" is somewhat tricky, because there could be other
  740. // arguments passed either before or after the %c, so we need to
  741. // figure out the correct index to insert the CSS into
  742. let index = 0;
  743. let lastC = 0;
  744. args[0].replace(/%[a-zA-Z%]/g, match => {
  745. if (match === '%%') {
  746. return;
  747. }
  748. index++;
  749. if (match === '%c') {
  750. // We only are interested in the *last* %c
  751. // (the user may have provided their own)
  752. lastC = index;
  753. }
  754. });
  755. args.splice(lastC, 0, c);
  756. }
  757. /**
  758. * Invokes `console.debug()` when available.
  759. * No-op when `console.debug` is not a "function".
  760. * If `console.debug` is not available, falls back
  761. * to `console.log`.
  762. *
  763. * @api public
  764. */
  765. exports.log = console.debug || console.log || (() => {});
  766. /**
  767. * Save `namespaces`.
  768. *
  769. * @param {String} namespaces
  770. * @api private
  771. */
  772. function save(namespaces) {
  773. try {
  774. if (namespaces) {
  775. exports.storage.setItem('debug', namespaces);
  776. } else {
  777. exports.storage.removeItem('debug');
  778. }
  779. } catch (error) {
  780. // Swallow
  781. // XXX (@Qix-) should we be logging these?
  782. }
  783. }
  784. /**
  785. * Load `namespaces`.
  786. *
  787. * @return {String} returns the previously persisted debug modes
  788. * @api private
  789. */
  790. function load() {
  791. let r;
  792. try {
  793. r = exports.storage.getItem('debug');
  794. } catch (error) {
  795. // Swallow
  796. // XXX (@Qix-) should we be logging these?
  797. }
  798. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  799. if (!r && typeof process !== 'undefined' && 'env' in process) {
  800. r = process.env.DEBUG;
  801. }
  802. return r;
  803. }
  804. /**
  805. * Localstorage attempts to return the localstorage.
  806. *
  807. * This is necessary because safari throws
  808. * when a user disables cookies/localstorage
  809. * and you attempt to access it.
  810. *
  811. * @return {LocalStorage}
  812. * @api private
  813. */
  814. function localstorage() {
  815. try {
  816. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  817. // The Browser also has localStorage in the global context.
  818. return localStorage;
  819. } catch (error) {
  820. // Swallow
  821. // XXX (@Qix-) should we be logging these?
  822. }
  823. }
  824. module.exports = requireCommon()(exports);
  825. const {formatters} = module.exports;
  826. /**
  827. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  828. */
  829. formatters.j = function (v) {
  830. try {
  831. return JSON.stringify(v);
  832. } catch (error) {
  833. return '[UnexpectedJSONParseError]: ' + error.message;
  834. }
  835. };
  836. } (browser$1, browser$1.exports));
  837. return browser$1.exports;
  838. }
  839. var node = {exports: {}};
  840. /**
  841. * Module dependencies.
  842. */
  843. var hasRequiredNode;
  844. function requireNode () {
  845. if (hasRequiredNode) return node.exports;
  846. hasRequiredNode = 1;
  847. (function (module, exports) {
  848. const tty = require$$0;
  849. const util = require$$1;
  850. /**
  851. * This is the Node.js implementation of `debug()`.
  852. */
  853. exports.init = init;
  854. exports.log = log;
  855. exports.formatArgs = formatArgs;
  856. exports.save = save;
  857. exports.load = load;
  858. exports.useColors = useColors;
  859. exports.destroy = util.deprecate(
  860. () => {},
  861. 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
  862. );
  863. /**
  864. * Colors.
  865. */
  866. exports.colors = [6, 2, 3, 4, 5, 1];
  867. try {
  868. // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
  869. // eslint-disable-next-line import/no-extraneous-dependencies
  870. const supportsColor = require('supports-color');
  871. if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
  872. exports.colors = [
  873. 20,
  874. 21,
  875. 26,
  876. 27,
  877. 32,
  878. 33,
  879. 38,
  880. 39,
  881. 40,
  882. 41,
  883. 42,
  884. 43,
  885. 44,
  886. 45,
  887. 56,
  888. 57,
  889. 62,
  890. 63,
  891. 68,
  892. 69,
  893. 74,
  894. 75,
  895. 76,
  896. 77,
  897. 78,
  898. 79,
  899. 80,
  900. 81,
  901. 92,
  902. 93,
  903. 98,
  904. 99,
  905. 112,
  906. 113,
  907. 128,
  908. 129,
  909. 134,
  910. 135,
  911. 148,
  912. 149,
  913. 160,
  914. 161,
  915. 162,
  916. 163,
  917. 164,
  918. 165,
  919. 166,
  920. 167,
  921. 168,
  922. 169,
  923. 170,
  924. 171,
  925. 172,
  926. 173,
  927. 178,
  928. 179,
  929. 184,
  930. 185,
  931. 196,
  932. 197,
  933. 198,
  934. 199,
  935. 200,
  936. 201,
  937. 202,
  938. 203,
  939. 204,
  940. 205,
  941. 206,
  942. 207,
  943. 208,
  944. 209,
  945. 214,
  946. 215,
  947. 220,
  948. 221
  949. ];
  950. }
  951. } catch (error) {
  952. // Swallow - we only care if `supports-color` is available; it doesn't have to be.
  953. }
  954. /**
  955. * Build up the default `inspectOpts` object from the environment variables.
  956. *
  957. * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
  958. */
  959. exports.inspectOpts = Object.keys(process.env).filter(key => {
  960. return /^debug_/i.test(key);
  961. }).reduce((obj, key) => {
  962. // Camel-case
  963. const prop = key
  964. .substring(6)
  965. .toLowerCase()
  966. .replace(/_([a-z])/g, (_, k) => {
  967. return k.toUpperCase();
  968. });
  969. // Coerce string value into JS value
  970. let val = process.env[key];
  971. if (/^(yes|on|true|enabled)$/i.test(val)) {
  972. val = true;
  973. } else if (/^(no|off|false|disabled)$/i.test(val)) {
  974. val = false;
  975. } else if (val === 'null') {
  976. val = null;
  977. } else {
  978. val = Number(val);
  979. }
  980. obj[prop] = val;
  981. return obj;
  982. }, {});
  983. /**
  984. * Is stdout a TTY? Colored output is enabled when `true`.
  985. */
  986. function useColors() {
  987. return 'colors' in exports.inspectOpts ?
  988. Boolean(exports.inspectOpts.colors) :
  989. tty.isatty(process.stderr.fd);
  990. }
  991. /**
  992. * Adds ANSI color escape codes if enabled.
  993. *
  994. * @api public
  995. */
  996. function formatArgs(args) {
  997. const {namespace: name, useColors} = this;
  998. if (useColors) {
  999. const c = this.color;
  1000. const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
  1001. const prefix = ` ${colorCode};1m${name} \u001B[0m`;
  1002. args[0] = prefix + args[0].split('\n').join('\n' + prefix);
  1003. args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
  1004. } else {
  1005. args[0] = getDate() + name + ' ' + args[0];
  1006. }
  1007. }
  1008. function getDate() {
  1009. if (exports.inspectOpts.hideDate) {
  1010. return '';
  1011. }
  1012. return new Date().toISOString() + ' ';
  1013. }
  1014. /**
  1015. * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
  1016. */
  1017. function log(...args) {
  1018. return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
  1019. }
  1020. /**
  1021. * Save `namespaces`.
  1022. *
  1023. * @param {String} namespaces
  1024. * @api private
  1025. */
  1026. function save(namespaces) {
  1027. if (namespaces) {
  1028. process.env.DEBUG = namespaces;
  1029. } else {
  1030. // If you set a process.env field to null or undefined, it gets cast to the
  1031. // string 'null' or 'undefined'. Just delete instead.
  1032. delete process.env.DEBUG;
  1033. }
  1034. }
  1035. /**
  1036. * Load `namespaces`.
  1037. *
  1038. * @return {String} returns the previously persisted debug modes
  1039. * @api private
  1040. */
  1041. function load() {
  1042. return process.env.DEBUG;
  1043. }
  1044. /**
  1045. * Init logic for `debug` instances.
  1046. *
  1047. * Create a new `inspectOpts` object in case `useColors` is set
  1048. * differently for a particular `debug` instance.
  1049. */
  1050. function init(debug) {
  1051. debug.inspectOpts = {};
  1052. const keys = Object.keys(exports.inspectOpts);
  1053. for (let i = 0; i < keys.length; i++) {
  1054. debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
  1055. }
  1056. }
  1057. module.exports = requireCommon()(exports);
  1058. const {formatters} = module.exports;
  1059. /**
  1060. * Map %o to `util.inspect()`, all on a single line.
  1061. */
  1062. formatters.o = function (v) {
  1063. this.inspectOpts.colors = this.useColors;
  1064. return util.inspect(v, this.inspectOpts)
  1065. .split('\n')
  1066. .map(str => str.trim())
  1067. .join(' ');
  1068. };
  1069. /**
  1070. * Map %O to `util.inspect()`, allowing multiple lines if needed.
  1071. */
  1072. formatters.O = function (v) {
  1073. this.inspectOpts.colors = this.useColors;
  1074. return util.inspect(v, this.inspectOpts);
  1075. };
  1076. } (node, node.exports));
  1077. return node.exports;
  1078. }
  1079. /**
  1080. * Detect Electron renderer / nwjs process, which is node, but we should
  1081. * treat as a browser.
  1082. */
  1083. if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
  1084. src.exports = requireBrowser();
  1085. } else {
  1086. src.exports = requireNode();
  1087. }
  1088. var srcExports = src.exports;
  1089. var debug$2 = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
  1090. var utils$3 = {};
  1091. const path$2 = require$$0$1;
  1092. const WIN_SLASH = '\\\\/';
  1093. const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
  1094. /**
  1095. * Posix glob regex
  1096. */
  1097. const DOT_LITERAL = '\\.';
  1098. const PLUS_LITERAL = '\\+';
  1099. const QMARK_LITERAL = '\\?';
  1100. const SLASH_LITERAL = '\\/';
  1101. const ONE_CHAR = '(?=.)';
  1102. const QMARK = '[^/]';
  1103. const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
  1104. const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
  1105. const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
  1106. const NO_DOT = `(?!${DOT_LITERAL})`;
  1107. const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
  1108. const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
  1109. const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
  1110. const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
  1111. const STAR = `${QMARK}*?`;
  1112. const POSIX_CHARS = {
  1113. DOT_LITERAL,
  1114. PLUS_LITERAL,
  1115. QMARK_LITERAL,
  1116. SLASH_LITERAL,
  1117. ONE_CHAR,
  1118. QMARK,
  1119. END_ANCHOR,
  1120. DOTS_SLASH,
  1121. NO_DOT,
  1122. NO_DOTS,
  1123. NO_DOT_SLASH,
  1124. NO_DOTS_SLASH,
  1125. QMARK_NO_DOT,
  1126. STAR,
  1127. START_ANCHOR
  1128. };
  1129. /**
  1130. * Windows glob regex
  1131. */
  1132. const WINDOWS_CHARS = {
  1133. ...POSIX_CHARS,
  1134. SLASH_LITERAL: `[${WIN_SLASH}]`,
  1135. QMARK: WIN_NO_SLASH,
  1136. STAR: `${WIN_NO_SLASH}*?`,
  1137. DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
  1138. NO_DOT: `(?!${DOT_LITERAL})`,
  1139. NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  1140. NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
  1141. NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  1142. QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
  1143. START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
  1144. END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
  1145. };
  1146. /**
  1147. * POSIX Bracket Regex
  1148. */
  1149. const POSIX_REGEX_SOURCE$1 = {
  1150. alnum: 'a-zA-Z0-9',
  1151. alpha: 'a-zA-Z',
  1152. ascii: '\\x00-\\x7F',
  1153. blank: ' \\t',
  1154. cntrl: '\\x00-\\x1F\\x7F',
  1155. digit: '0-9',
  1156. graph: '\\x21-\\x7E',
  1157. lower: 'a-z',
  1158. print: '\\x20-\\x7E ',
  1159. punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
  1160. space: ' \\t\\r\\n\\v\\f',
  1161. upper: 'A-Z',
  1162. word: 'A-Za-z0-9_',
  1163. xdigit: 'A-Fa-f0-9'
  1164. };
  1165. var constants$2 = {
  1166. MAX_LENGTH: 1024 * 64,
  1167. POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
  1168. // regular expressions
  1169. REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
  1170. REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
  1171. REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
  1172. REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
  1173. REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
  1174. REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
  1175. // Replace globs with equivalent patterns to reduce parsing time.
  1176. REPLACEMENTS: {
  1177. '***': '*',
  1178. '**/**': '**',
  1179. '**/**/**': '**'
  1180. },
  1181. // Digits
  1182. CHAR_0: 48, /* 0 */
  1183. CHAR_9: 57, /* 9 */
  1184. // Alphabet chars.
  1185. CHAR_UPPERCASE_A: 65, /* A */
  1186. CHAR_LOWERCASE_A: 97, /* a */
  1187. CHAR_UPPERCASE_Z: 90, /* Z */
  1188. CHAR_LOWERCASE_Z: 122, /* z */
  1189. CHAR_LEFT_PARENTHESES: 40, /* ( */
  1190. CHAR_RIGHT_PARENTHESES: 41, /* ) */
  1191. CHAR_ASTERISK: 42, /* * */
  1192. // Non-alphabetic chars.
  1193. CHAR_AMPERSAND: 38, /* & */
  1194. CHAR_AT: 64, /* @ */
  1195. CHAR_BACKWARD_SLASH: 92, /* \ */
  1196. CHAR_CARRIAGE_RETURN: 13, /* \r */
  1197. CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
  1198. CHAR_COLON: 58, /* : */
  1199. CHAR_COMMA: 44, /* , */
  1200. CHAR_DOT: 46, /* . */
  1201. CHAR_DOUBLE_QUOTE: 34, /* " */
  1202. CHAR_EQUAL: 61, /* = */
  1203. CHAR_EXCLAMATION_MARK: 33, /* ! */
  1204. CHAR_FORM_FEED: 12, /* \f */
  1205. CHAR_FORWARD_SLASH: 47, /* / */
  1206. CHAR_GRAVE_ACCENT: 96, /* ` */
  1207. CHAR_HASH: 35, /* # */
  1208. CHAR_HYPHEN_MINUS: 45, /* - */
  1209. CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
  1210. CHAR_LEFT_CURLY_BRACE: 123, /* { */
  1211. CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
  1212. CHAR_LINE_FEED: 10, /* \n */
  1213. CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
  1214. CHAR_PERCENT: 37, /* % */
  1215. CHAR_PLUS: 43, /* + */
  1216. CHAR_QUESTION_MARK: 63, /* ? */
  1217. CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
  1218. CHAR_RIGHT_CURLY_BRACE: 125, /* } */
  1219. CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
  1220. CHAR_SEMICOLON: 59, /* ; */
  1221. CHAR_SINGLE_QUOTE: 39, /* ' */
  1222. CHAR_SPACE: 32, /* */
  1223. CHAR_TAB: 9, /* \t */
  1224. CHAR_UNDERSCORE: 95, /* _ */
  1225. CHAR_VERTICAL_LINE: 124, /* | */
  1226. CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
  1227. SEP: path$2.sep,
  1228. /**
  1229. * Create EXTGLOB_CHARS
  1230. */
  1231. extglobChars(chars) {
  1232. return {
  1233. '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
  1234. '?': { type: 'qmark', open: '(?:', close: ')?' },
  1235. '+': { type: 'plus', open: '(?:', close: ')+' },
  1236. '*': { type: 'star', open: '(?:', close: ')*' },
  1237. '@': { type: 'at', open: '(?:', close: ')' }
  1238. };
  1239. },
  1240. /**
  1241. * Create GLOB_CHARS
  1242. */
  1243. globChars(win32) {
  1244. return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
  1245. }
  1246. };
  1247. (function (exports) {
  1248. const path = require$$0$1;
  1249. const win32 = process.platform === 'win32';
  1250. const {
  1251. REGEX_BACKSLASH,
  1252. REGEX_REMOVE_BACKSLASH,
  1253. REGEX_SPECIAL_CHARS,
  1254. REGEX_SPECIAL_CHARS_GLOBAL
  1255. } = constants$2;
  1256. exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  1257. exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
  1258. exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
  1259. exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
  1260. exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
  1261. exports.removeBackslashes = str => {
  1262. return str.replace(REGEX_REMOVE_BACKSLASH, match => {
  1263. return match === '\\' ? '' : match;
  1264. });
  1265. };
  1266. exports.supportsLookbehinds = () => {
  1267. const segs = process.version.slice(1).split('.').map(Number);
  1268. if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
  1269. return true;
  1270. }
  1271. return false;
  1272. };
  1273. exports.isWindows = options => {
  1274. if (options && typeof options.windows === 'boolean') {
  1275. return options.windows;
  1276. }
  1277. return win32 === true || path.sep === '\\';
  1278. };
  1279. exports.escapeLast = (input, char, lastIdx) => {
  1280. const idx = input.lastIndexOf(char, lastIdx);
  1281. if (idx === -1) return input;
  1282. if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
  1283. return `${input.slice(0, idx)}\\${input.slice(idx)}`;
  1284. };
  1285. exports.removePrefix = (input, state = {}) => {
  1286. let output = input;
  1287. if (output.startsWith('./')) {
  1288. output = output.slice(2);
  1289. state.prefix = './';
  1290. }
  1291. return output;
  1292. };
  1293. exports.wrapOutput = (input, state = {}, options = {}) => {
  1294. const prepend = options.contains ? '' : '^';
  1295. const append = options.contains ? '' : '$';
  1296. let output = `${prepend}(?:${input})${append}`;
  1297. if (state.negated === true) {
  1298. output = `(?:^(?!${output}).*$)`;
  1299. }
  1300. return output;
  1301. };
  1302. } (utils$3));
  1303. const utils$2 = utils$3;
  1304. const {
  1305. CHAR_ASTERISK, /* * */
  1306. CHAR_AT, /* @ */
  1307. CHAR_BACKWARD_SLASH, /* \ */
  1308. CHAR_COMMA, /* , */
  1309. CHAR_DOT, /* . */
  1310. CHAR_EXCLAMATION_MARK, /* ! */
  1311. CHAR_FORWARD_SLASH, /* / */
  1312. CHAR_LEFT_CURLY_BRACE, /* { */
  1313. CHAR_LEFT_PARENTHESES, /* ( */
  1314. CHAR_LEFT_SQUARE_BRACKET, /* [ */
  1315. CHAR_PLUS, /* + */
  1316. CHAR_QUESTION_MARK, /* ? */
  1317. CHAR_RIGHT_CURLY_BRACE, /* } */
  1318. CHAR_RIGHT_PARENTHESES, /* ) */
  1319. CHAR_RIGHT_SQUARE_BRACKET /* ] */
  1320. } = constants$2;
  1321. const isPathSeparator = code => {
  1322. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  1323. };
  1324. const depth = token => {
  1325. if (token.isPrefix !== true) {
  1326. token.depth = token.isGlobstar ? Infinity : 1;
  1327. }
  1328. };
  1329. /**
  1330. * Quickly scans a glob pattern and returns an object with a handful of
  1331. * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
  1332. * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
  1333. * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
  1334. *
  1335. * ```js
  1336. * const pm = require('picomatch');
  1337. * console.log(pm.scan('foo/bar/*.js'));
  1338. * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
  1339. * ```
  1340. * @param {String} `str`
  1341. * @param {Object} `options`
  1342. * @return {Object} Returns an object with tokens and regex source string.
  1343. * @api public
  1344. */
  1345. const scan$1 = (input, options) => {
  1346. const opts = options || {};
  1347. const length = input.length - 1;
  1348. const scanToEnd = opts.parts === true || opts.scanToEnd === true;
  1349. const slashes = [];
  1350. const tokens = [];
  1351. const parts = [];
  1352. let str = input;
  1353. let index = -1;
  1354. let start = 0;
  1355. let lastIndex = 0;
  1356. let isBrace = false;
  1357. let isBracket = false;
  1358. let isGlob = false;
  1359. let isExtglob = false;
  1360. let isGlobstar = false;
  1361. let braceEscaped = false;
  1362. let backslashes = false;
  1363. let negated = false;
  1364. let negatedExtglob = false;
  1365. let finished = false;
  1366. let braces = 0;
  1367. let prev;
  1368. let code;
  1369. let token = { value: '', depth: 0, isGlob: false };
  1370. const eos = () => index >= length;
  1371. const peek = () => str.charCodeAt(index + 1);
  1372. const advance = () => {
  1373. prev = code;
  1374. return str.charCodeAt(++index);
  1375. };
  1376. while (index < length) {
  1377. code = advance();
  1378. let next;
  1379. if (code === CHAR_BACKWARD_SLASH) {
  1380. backslashes = token.backslashes = true;
  1381. code = advance();
  1382. if (code === CHAR_LEFT_CURLY_BRACE) {
  1383. braceEscaped = true;
  1384. }
  1385. continue;
  1386. }
  1387. if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
  1388. braces++;
  1389. while (eos() !== true && (code = advance())) {
  1390. if (code === CHAR_BACKWARD_SLASH) {
  1391. backslashes = token.backslashes = true;
  1392. advance();
  1393. continue;
  1394. }
  1395. if (code === CHAR_LEFT_CURLY_BRACE) {
  1396. braces++;
  1397. continue;
  1398. }
  1399. if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
  1400. isBrace = token.isBrace = true;
  1401. isGlob = token.isGlob = true;
  1402. finished = true;
  1403. if (scanToEnd === true) {
  1404. continue;
  1405. }
  1406. break;
  1407. }
  1408. if (braceEscaped !== true && code === CHAR_COMMA) {
  1409. isBrace = token.isBrace = true;
  1410. isGlob = token.isGlob = true;
  1411. finished = true;
  1412. if (scanToEnd === true) {
  1413. continue;
  1414. }
  1415. break;
  1416. }
  1417. if (code === CHAR_RIGHT_CURLY_BRACE) {
  1418. braces--;
  1419. if (braces === 0) {
  1420. braceEscaped = false;
  1421. isBrace = token.isBrace = true;
  1422. finished = true;
  1423. break;
  1424. }
  1425. }
  1426. }
  1427. if (scanToEnd === true) {
  1428. continue;
  1429. }
  1430. break;
  1431. }
  1432. if (code === CHAR_FORWARD_SLASH) {
  1433. slashes.push(index);
  1434. tokens.push(token);
  1435. token = { value: '', depth: 0, isGlob: false };
  1436. if (finished === true) continue;
  1437. if (prev === CHAR_DOT && index === (start + 1)) {
  1438. start += 2;
  1439. continue;
  1440. }
  1441. lastIndex = index + 1;
  1442. continue;
  1443. }
  1444. if (opts.noext !== true) {
  1445. const isExtglobChar = code === CHAR_PLUS
  1446. || code === CHAR_AT
  1447. || code === CHAR_ASTERISK
  1448. || code === CHAR_QUESTION_MARK
  1449. || code === CHAR_EXCLAMATION_MARK;
  1450. if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
  1451. isGlob = token.isGlob = true;
  1452. isExtglob = token.isExtglob = true;
  1453. finished = true;
  1454. if (code === CHAR_EXCLAMATION_MARK && index === start) {
  1455. negatedExtglob = true;
  1456. }
  1457. if (scanToEnd === true) {
  1458. while (eos() !== true && (code = advance())) {
  1459. if (code === CHAR_BACKWARD_SLASH) {
  1460. backslashes = token.backslashes = true;
  1461. code = advance();
  1462. continue;
  1463. }
  1464. if (code === CHAR_RIGHT_PARENTHESES) {
  1465. isGlob = token.isGlob = true;
  1466. finished = true;
  1467. break;
  1468. }
  1469. }
  1470. continue;
  1471. }
  1472. break;
  1473. }
  1474. }
  1475. if (code === CHAR_ASTERISK) {
  1476. if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
  1477. isGlob = token.isGlob = true;
  1478. finished = true;
  1479. if (scanToEnd === true) {
  1480. continue;
  1481. }
  1482. break;
  1483. }
  1484. if (code === CHAR_QUESTION_MARK) {
  1485. isGlob = token.isGlob = true;
  1486. finished = true;
  1487. if (scanToEnd === true) {
  1488. continue;
  1489. }
  1490. break;
  1491. }
  1492. if (code === CHAR_LEFT_SQUARE_BRACKET) {
  1493. while (eos() !== true && (next = advance())) {
  1494. if (next === CHAR_BACKWARD_SLASH) {
  1495. backslashes = token.backslashes = true;
  1496. advance();
  1497. continue;
  1498. }
  1499. if (next === CHAR_RIGHT_SQUARE_BRACKET) {
  1500. isBracket = token.isBracket = true;
  1501. isGlob = token.isGlob = true;
  1502. finished = true;
  1503. break;
  1504. }
  1505. }
  1506. if (scanToEnd === true) {
  1507. continue;
  1508. }
  1509. break;
  1510. }
  1511. if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
  1512. negated = token.negated = true;
  1513. start++;
  1514. continue;
  1515. }
  1516. if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
  1517. isGlob = token.isGlob = true;
  1518. if (scanToEnd === true) {
  1519. while (eos() !== true && (code = advance())) {
  1520. if (code === CHAR_LEFT_PARENTHESES) {
  1521. backslashes = token.backslashes = true;
  1522. code = advance();
  1523. continue;
  1524. }
  1525. if (code === CHAR_RIGHT_PARENTHESES) {
  1526. finished = true;
  1527. break;
  1528. }
  1529. }
  1530. continue;
  1531. }
  1532. break;
  1533. }
  1534. if (isGlob === true) {
  1535. finished = true;
  1536. if (scanToEnd === true) {
  1537. continue;
  1538. }
  1539. break;
  1540. }
  1541. }
  1542. if (opts.noext === true) {
  1543. isExtglob = false;
  1544. isGlob = false;
  1545. }
  1546. let base = str;
  1547. let prefix = '';
  1548. let glob = '';
  1549. if (start > 0) {
  1550. prefix = str.slice(0, start);
  1551. str = str.slice(start);
  1552. lastIndex -= start;
  1553. }
  1554. if (base && isGlob === true && lastIndex > 0) {
  1555. base = str.slice(0, lastIndex);
  1556. glob = str.slice(lastIndex);
  1557. } else if (isGlob === true) {
  1558. base = '';
  1559. glob = str;
  1560. } else {
  1561. base = str;
  1562. }
  1563. if (base && base !== '' && base !== '/' && base !== str) {
  1564. if (isPathSeparator(base.charCodeAt(base.length - 1))) {
  1565. base = base.slice(0, -1);
  1566. }
  1567. }
  1568. if (opts.unescape === true) {
  1569. if (glob) glob = utils$2.removeBackslashes(glob);
  1570. if (base && backslashes === true) {
  1571. base = utils$2.removeBackslashes(base);
  1572. }
  1573. }
  1574. const state = {
  1575. prefix,
  1576. input,
  1577. start,
  1578. base,
  1579. glob,
  1580. isBrace,
  1581. isBracket,
  1582. isGlob,
  1583. isExtglob,
  1584. isGlobstar,
  1585. negated,
  1586. negatedExtglob
  1587. };
  1588. if (opts.tokens === true) {
  1589. state.maxDepth = 0;
  1590. if (!isPathSeparator(code)) {
  1591. tokens.push(token);
  1592. }
  1593. state.tokens = tokens;
  1594. }
  1595. if (opts.parts === true || opts.tokens === true) {
  1596. let prevIndex;
  1597. for (let idx = 0; idx < slashes.length; idx++) {
  1598. const n = prevIndex ? prevIndex + 1 : start;
  1599. const i = slashes[idx];
  1600. const value = input.slice(n, i);
  1601. if (opts.tokens) {
  1602. if (idx === 0 && start !== 0) {
  1603. tokens[idx].isPrefix = true;
  1604. tokens[idx].value = prefix;
  1605. } else {
  1606. tokens[idx].value = value;
  1607. }
  1608. depth(tokens[idx]);
  1609. state.maxDepth += tokens[idx].depth;
  1610. }
  1611. if (idx !== 0 || value !== '') {
  1612. parts.push(value);
  1613. }
  1614. prevIndex = i;
  1615. }
  1616. if (prevIndex && prevIndex + 1 < input.length) {
  1617. const value = input.slice(prevIndex + 1);
  1618. parts.push(value);
  1619. if (opts.tokens) {
  1620. tokens[tokens.length - 1].value = value;
  1621. depth(tokens[tokens.length - 1]);
  1622. state.maxDepth += tokens[tokens.length - 1].depth;
  1623. }
  1624. }
  1625. state.slashes = slashes;
  1626. state.parts = parts;
  1627. }
  1628. return state;
  1629. };
  1630. var scan_1 = scan$1;
  1631. const constants$1 = constants$2;
  1632. const utils$1 = utils$3;
  1633. /**
  1634. * Constants
  1635. */
  1636. const {
  1637. MAX_LENGTH,
  1638. POSIX_REGEX_SOURCE,
  1639. REGEX_NON_SPECIAL_CHARS,
  1640. REGEX_SPECIAL_CHARS_BACKREF,
  1641. REPLACEMENTS
  1642. } = constants$1;
  1643. /**
  1644. * Helpers
  1645. */
  1646. const expandRange = (args, options) => {
  1647. if (typeof options.expandRange === 'function') {
  1648. return options.expandRange(...args, options);
  1649. }
  1650. args.sort();
  1651. const value = `[${args.join('-')}]`;
  1652. return value;
  1653. };
  1654. /**
  1655. * Create the message for a syntax error
  1656. */
  1657. const syntaxError = (type, char) => {
  1658. return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
  1659. };
  1660. /**
  1661. * Parse the given input string.
  1662. * @param {String} input
  1663. * @param {Object} options
  1664. * @return {Object}
  1665. */
  1666. const parse$2 = (input, options) => {
  1667. if (typeof input !== 'string') {
  1668. throw new TypeError('Expected a string');
  1669. }
  1670. input = REPLACEMENTS[input] || input;
  1671. const opts = { ...options };
  1672. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  1673. let len = input.length;
  1674. if (len > max) {
  1675. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  1676. }
  1677. const bos = { type: 'bos', value: '', output: opts.prepend || '' };
  1678. const tokens = [bos];
  1679. const capture = opts.capture ? '' : '?:';
  1680. const win32 = utils$1.isWindows(options);
  1681. // create constants based on platform, for windows or posix
  1682. const PLATFORM_CHARS = constants$1.globChars(win32);
  1683. const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
  1684. const {
  1685. DOT_LITERAL,
  1686. PLUS_LITERAL,
  1687. SLASH_LITERAL,
  1688. ONE_CHAR,
  1689. DOTS_SLASH,
  1690. NO_DOT,
  1691. NO_DOT_SLASH,
  1692. NO_DOTS_SLASH,
  1693. QMARK,
  1694. QMARK_NO_DOT,
  1695. STAR,
  1696. START_ANCHOR
  1697. } = PLATFORM_CHARS;
  1698. const globstar = opts => {
  1699. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  1700. };
  1701. const nodot = opts.dot ? '' : NO_DOT;
  1702. const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
  1703. let star = opts.bash === true ? globstar(opts) : STAR;
  1704. if (opts.capture) {
  1705. star = `(${star})`;
  1706. }
  1707. // minimatch options support
  1708. if (typeof opts.noext === 'boolean') {
  1709. opts.noextglob = opts.noext;
  1710. }
  1711. const state = {
  1712. input,
  1713. index: -1,
  1714. start: 0,
  1715. dot: opts.dot === true,
  1716. consumed: '',
  1717. output: '',
  1718. prefix: '',
  1719. backtrack: false,
  1720. negated: false,
  1721. brackets: 0,
  1722. braces: 0,
  1723. parens: 0,
  1724. quotes: 0,
  1725. globstar: false,
  1726. tokens
  1727. };
  1728. input = utils$1.removePrefix(input, state);
  1729. len = input.length;
  1730. const extglobs = [];
  1731. const braces = [];
  1732. const stack = [];
  1733. let prev = bos;
  1734. let value;
  1735. /**
  1736. * Tokenizing helpers
  1737. */
  1738. const eos = () => state.index === len - 1;
  1739. const peek = state.peek = (n = 1) => input[state.index + n];
  1740. const advance = state.advance = () => input[++state.index] || '';
  1741. const remaining = () => input.slice(state.index + 1);
  1742. const consume = (value = '', num = 0) => {
  1743. state.consumed += value;
  1744. state.index += num;
  1745. };
  1746. const append = token => {
  1747. state.output += token.output != null ? token.output : token.value;
  1748. consume(token.value);
  1749. };
  1750. const negate = () => {
  1751. let count = 1;
  1752. while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
  1753. advance();
  1754. state.start++;
  1755. count++;
  1756. }
  1757. if (count % 2 === 0) {
  1758. return false;
  1759. }
  1760. state.negated = true;
  1761. state.start++;
  1762. return true;
  1763. };
  1764. const increment = type => {
  1765. state[type]++;
  1766. stack.push(type);
  1767. };
  1768. const decrement = type => {
  1769. state[type]--;
  1770. stack.pop();
  1771. };
  1772. /**
  1773. * Push tokens onto the tokens array. This helper speeds up
  1774. * tokenizing by 1) helping us avoid backtracking as much as possible,
  1775. * and 2) helping us avoid creating extra tokens when consecutive
  1776. * characters are plain text. This improves performance and simplifies
  1777. * lookbehinds.
  1778. */
  1779. const push = tok => {
  1780. if (prev.type === 'globstar') {
  1781. const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
  1782. const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
  1783. if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
  1784. state.output = state.output.slice(0, -prev.output.length);
  1785. prev.type = 'star';
  1786. prev.value = '*';
  1787. prev.output = star;
  1788. state.output += prev.output;
  1789. }
  1790. }
  1791. if (extglobs.length && tok.type !== 'paren') {
  1792. extglobs[extglobs.length - 1].inner += tok.value;
  1793. }
  1794. if (tok.value || tok.output) append(tok);
  1795. if (prev && prev.type === 'text' && tok.type === 'text') {
  1796. prev.value += tok.value;
  1797. prev.output = (prev.output || '') + tok.value;
  1798. return;
  1799. }
  1800. tok.prev = prev;
  1801. tokens.push(tok);
  1802. prev = tok;
  1803. };
  1804. const extglobOpen = (type, value) => {
  1805. const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
  1806. token.prev = prev;
  1807. token.parens = state.parens;
  1808. token.output = state.output;
  1809. const output = (opts.capture ? '(' : '') + token.open;
  1810. increment('parens');
  1811. push({ type, value, output: state.output ? '' : ONE_CHAR });
  1812. push({ type: 'paren', extglob: true, value: advance(), output });
  1813. extglobs.push(token);
  1814. };
  1815. const extglobClose = token => {
  1816. let output = token.close + (opts.capture ? ')' : '');
  1817. let rest;
  1818. if (token.type === 'negate') {
  1819. let extglobStar = star;
  1820. if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
  1821. extglobStar = globstar(opts);
  1822. }
  1823. if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
  1824. output = token.close = `)$))${extglobStar}`;
  1825. }
  1826. if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
  1827. // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
  1828. // In this case, we need to parse the string and use it in the output of the original pattern.
  1829. // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
  1830. //
  1831. // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
  1832. const expression = parse$2(rest, { ...options, fastpaths: false }).output;
  1833. output = token.close = `)${expression})${extglobStar})`;
  1834. }
  1835. if (token.prev.type === 'bos') {
  1836. state.negatedExtglob = true;
  1837. }
  1838. }
  1839. push({ type: 'paren', extglob: true, value, output });
  1840. decrement('parens');
  1841. };
  1842. /**
  1843. * Fast paths
  1844. */
  1845. if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
  1846. let backslashes = false;
  1847. let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
  1848. if (first === '\\') {
  1849. backslashes = true;
  1850. return m;
  1851. }
  1852. if (first === '?') {
  1853. if (esc) {
  1854. return esc + first + (rest ? QMARK.repeat(rest.length) : '');
  1855. }
  1856. if (index === 0) {
  1857. return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
  1858. }
  1859. return QMARK.repeat(chars.length);
  1860. }
  1861. if (first === '.') {
  1862. return DOT_LITERAL.repeat(chars.length);
  1863. }
  1864. if (first === '*') {
  1865. if (esc) {
  1866. return esc + first + (rest ? star : '');
  1867. }
  1868. return star;
  1869. }
  1870. return esc ? m : `\\${m}`;
  1871. });
  1872. if (backslashes === true) {
  1873. if (opts.unescape === true) {
  1874. output = output.replace(/\\/g, '');
  1875. } else {
  1876. output = output.replace(/\\+/g, m => {
  1877. return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
  1878. });
  1879. }
  1880. }
  1881. if (output === input && opts.contains === true) {
  1882. state.output = input;
  1883. return state;
  1884. }
  1885. state.output = utils$1.wrapOutput(output, state, options);
  1886. return state;
  1887. }
  1888. /**
  1889. * Tokenize input until we reach end-of-string
  1890. */
  1891. while (!eos()) {
  1892. value = advance();
  1893. if (value === '\u0000') {
  1894. continue;
  1895. }
  1896. /**
  1897. * Escaped characters
  1898. */
  1899. if (value === '\\') {
  1900. const next = peek();
  1901. if (next === '/' && opts.bash !== true) {
  1902. continue;
  1903. }
  1904. if (next === '.' || next === ';') {
  1905. continue;
  1906. }
  1907. if (!next) {
  1908. value += '\\';
  1909. push({ type: 'text', value });
  1910. continue;
  1911. }
  1912. // collapse slashes to reduce potential for exploits
  1913. const match = /^\\+/.exec(remaining());
  1914. let slashes = 0;
  1915. if (match && match[0].length > 2) {
  1916. slashes = match[0].length;
  1917. state.index += slashes;
  1918. if (slashes % 2 !== 0) {
  1919. value += '\\';
  1920. }
  1921. }
  1922. if (opts.unescape === true) {
  1923. value = advance();
  1924. } else {
  1925. value += advance();
  1926. }
  1927. if (state.brackets === 0) {
  1928. push({ type: 'text', value });
  1929. continue;
  1930. }
  1931. }
  1932. /**
  1933. * If we're inside a regex character class, continue
  1934. * until we reach the closing bracket.
  1935. */
  1936. if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
  1937. if (opts.posix !== false && value === ':') {
  1938. const inner = prev.value.slice(1);
  1939. if (inner.includes('[')) {
  1940. prev.posix = true;
  1941. if (inner.includes(':')) {
  1942. const idx = prev.value.lastIndexOf('[');
  1943. const pre = prev.value.slice(0, idx);
  1944. const rest = prev.value.slice(idx + 2);
  1945. const posix = POSIX_REGEX_SOURCE[rest];
  1946. if (posix) {
  1947. prev.value = pre + posix;
  1948. state.backtrack = true;
  1949. advance();
  1950. if (!bos.output && tokens.indexOf(prev) === 1) {
  1951. bos.output = ONE_CHAR;
  1952. }
  1953. continue;
  1954. }
  1955. }
  1956. }
  1957. }
  1958. if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
  1959. value = `\\${value}`;
  1960. }
  1961. if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
  1962. value = `\\${value}`;
  1963. }
  1964. if (opts.posix === true && value === '!' && prev.value === '[') {
  1965. value = '^';
  1966. }
  1967. prev.value += value;
  1968. append({ value });
  1969. continue;
  1970. }
  1971. /**
  1972. * If we're inside a quoted string, continue
  1973. * until we reach the closing double quote.
  1974. */
  1975. if (state.quotes === 1 && value !== '"') {
  1976. value = utils$1.escapeRegex(value);
  1977. prev.value += value;
  1978. append({ value });
  1979. continue;
  1980. }
  1981. /**
  1982. * Double quotes
  1983. */
  1984. if (value === '"') {
  1985. state.quotes = state.quotes === 1 ? 0 : 1;
  1986. if (opts.keepQuotes === true) {
  1987. push({ type: 'text', value });
  1988. }
  1989. continue;
  1990. }
  1991. /**
  1992. * Parentheses
  1993. */
  1994. if (value === '(') {
  1995. increment('parens');
  1996. push({ type: 'paren', value });
  1997. continue;
  1998. }
  1999. if (value === ')') {
  2000. if (state.parens === 0 && opts.strictBrackets === true) {
  2001. throw new SyntaxError(syntaxError('opening', '('));
  2002. }
  2003. const extglob = extglobs[extglobs.length - 1];
  2004. if (extglob && state.parens === extglob.parens + 1) {
  2005. extglobClose(extglobs.pop());
  2006. continue;
  2007. }
  2008. push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
  2009. decrement('parens');
  2010. continue;
  2011. }
  2012. /**
  2013. * Square brackets
  2014. */
  2015. if (value === '[') {
  2016. if (opts.nobracket === true || !remaining().includes(']')) {
  2017. if (opts.nobracket !== true && opts.strictBrackets === true) {
  2018. throw new SyntaxError(syntaxError('closing', ']'));
  2019. }
  2020. value = `\\${value}`;
  2021. } else {
  2022. increment('brackets');
  2023. }
  2024. push({ type: 'bracket', value });
  2025. continue;
  2026. }
  2027. if (value === ']') {
  2028. if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
  2029. push({ type: 'text', value, output: `\\${value}` });
  2030. continue;
  2031. }
  2032. if (state.brackets === 0) {
  2033. if (opts.strictBrackets === true) {
  2034. throw new SyntaxError(syntaxError('opening', '['));
  2035. }
  2036. push({ type: 'text', value, output: `\\${value}` });
  2037. continue;
  2038. }
  2039. decrement('brackets');
  2040. const prevValue = prev.value.slice(1);
  2041. if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
  2042. value = `/${value}`;
  2043. }
  2044. prev.value += value;
  2045. append({ value });
  2046. // when literal brackets are explicitly disabled
  2047. // assume we should match with a regex character class
  2048. if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
  2049. continue;
  2050. }
  2051. const escaped = utils$1.escapeRegex(prev.value);
  2052. state.output = state.output.slice(0, -prev.value.length);
  2053. // when literal brackets are explicitly enabled
  2054. // assume we should escape the brackets to match literal characters
  2055. if (opts.literalBrackets === true) {
  2056. state.output += escaped;
  2057. prev.value = escaped;
  2058. continue;
  2059. }
  2060. // when the user specifies nothing, try to match both
  2061. prev.value = `(${capture}${escaped}|${prev.value})`;
  2062. state.output += prev.value;
  2063. continue;
  2064. }
  2065. /**
  2066. * Braces
  2067. */
  2068. if (value === '{' && opts.nobrace !== true) {
  2069. increment('braces');
  2070. const open = {
  2071. type: 'brace',
  2072. value,
  2073. output: '(',
  2074. outputIndex: state.output.length,
  2075. tokensIndex: state.tokens.length
  2076. };
  2077. braces.push(open);
  2078. push(open);
  2079. continue;
  2080. }
  2081. if (value === '}') {
  2082. const brace = braces[braces.length - 1];
  2083. if (opts.nobrace === true || !brace) {
  2084. push({ type: 'text', value, output: value });
  2085. continue;
  2086. }
  2087. let output = ')';
  2088. if (brace.dots === true) {
  2089. const arr = tokens.slice();
  2090. const range = [];
  2091. for (let i = arr.length - 1; i >= 0; i--) {
  2092. tokens.pop();
  2093. if (arr[i].type === 'brace') {
  2094. break;
  2095. }
  2096. if (arr[i].type !== 'dots') {
  2097. range.unshift(arr[i].value);
  2098. }
  2099. }
  2100. output = expandRange(range, opts);
  2101. state.backtrack = true;
  2102. }
  2103. if (brace.comma !== true && brace.dots !== true) {
  2104. const out = state.output.slice(0, brace.outputIndex);
  2105. const toks = state.tokens.slice(brace.tokensIndex);
  2106. brace.value = brace.output = '\\{';
  2107. value = output = '\\}';
  2108. state.output = out;
  2109. for (const t of toks) {
  2110. state.output += (t.output || t.value);
  2111. }
  2112. }
  2113. push({ type: 'brace', value, output });
  2114. decrement('braces');
  2115. braces.pop();
  2116. continue;
  2117. }
  2118. /**
  2119. * Pipes
  2120. */
  2121. if (value === '|') {
  2122. if (extglobs.length > 0) {
  2123. extglobs[extglobs.length - 1].conditions++;
  2124. }
  2125. push({ type: 'text', value });
  2126. continue;
  2127. }
  2128. /**
  2129. * Commas
  2130. */
  2131. if (value === ',') {
  2132. let output = value;
  2133. const brace = braces[braces.length - 1];
  2134. if (brace && stack[stack.length - 1] === 'braces') {
  2135. brace.comma = true;
  2136. output = '|';
  2137. }
  2138. push({ type: 'comma', value, output });
  2139. continue;
  2140. }
  2141. /**
  2142. * Slashes
  2143. */
  2144. if (value === '/') {
  2145. // if the beginning of the glob is "./", advance the start
  2146. // to the current index, and don't add the "./" characters
  2147. // to the state. This greatly simplifies lookbehinds when
  2148. // checking for BOS characters like "!" and "." (not "./")
  2149. if (prev.type === 'dot' && state.index === state.start + 1) {
  2150. state.start = state.index + 1;
  2151. state.consumed = '';
  2152. state.output = '';
  2153. tokens.pop();
  2154. prev = bos; // reset "prev" to the first token
  2155. continue;
  2156. }
  2157. push({ type: 'slash', value, output: SLASH_LITERAL });
  2158. continue;
  2159. }
  2160. /**
  2161. * Dots
  2162. */
  2163. if (value === '.') {
  2164. if (state.braces > 0 && prev.type === 'dot') {
  2165. if (prev.value === '.') prev.output = DOT_LITERAL;
  2166. const brace = braces[braces.length - 1];
  2167. prev.type = 'dots';
  2168. prev.output += value;
  2169. prev.value += value;
  2170. brace.dots = true;
  2171. continue;
  2172. }
  2173. if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
  2174. push({ type: 'text', value, output: DOT_LITERAL });
  2175. continue;
  2176. }
  2177. push({ type: 'dot', value, output: DOT_LITERAL });
  2178. continue;
  2179. }
  2180. /**
  2181. * Question marks
  2182. */
  2183. if (value === '?') {
  2184. const isGroup = prev && prev.value === '(';
  2185. if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  2186. extglobOpen('qmark', value);
  2187. continue;
  2188. }
  2189. if (prev && prev.type === 'paren') {
  2190. const next = peek();
  2191. let output = value;
  2192. if (next === '<' && !utils$1.supportsLookbehinds()) {
  2193. throw new Error('Node.js v10 or higher is required for regex lookbehinds');
  2194. }
  2195. if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
  2196. output = `\\${value}`;
  2197. }
  2198. push({ type: 'text', value, output });
  2199. continue;
  2200. }
  2201. if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
  2202. push({ type: 'qmark', value, output: QMARK_NO_DOT });
  2203. continue;
  2204. }
  2205. push({ type: 'qmark', value, output: QMARK });
  2206. continue;
  2207. }
  2208. /**
  2209. * Exclamation
  2210. */
  2211. if (value === '!') {
  2212. if (opts.noextglob !== true && peek() === '(') {
  2213. if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
  2214. extglobOpen('negate', value);
  2215. continue;
  2216. }
  2217. }
  2218. if (opts.nonegate !== true && state.index === 0) {
  2219. negate();
  2220. continue;
  2221. }
  2222. }
  2223. /**
  2224. * Plus
  2225. */
  2226. if (value === '+') {
  2227. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  2228. extglobOpen('plus', value);
  2229. continue;
  2230. }
  2231. if ((prev && prev.value === '(') || opts.regex === false) {
  2232. push({ type: 'plus', value, output: PLUS_LITERAL });
  2233. continue;
  2234. }
  2235. if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
  2236. push({ type: 'plus', value });
  2237. continue;
  2238. }
  2239. push({ type: 'plus', value: PLUS_LITERAL });
  2240. continue;
  2241. }
  2242. /**
  2243. * Plain text
  2244. */
  2245. if (value === '@') {
  2246. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  2247. push({ type: 'at', extglob: true, value, output: '' });
  2248. continue;
  2249. }
  2250. push({ type: 'text', value });
  2251. continue;
  2252. }
  2253. /**
  2254. * Plain text
  2255. */
  2256. if (value !== '*') {
  2257. if (value === '$' || value === '^') {
  2258. value = `\\${value}`;
  2259. }
  2260. const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
  2261. if (match) {
  2262. value += match[0];
  2263. state.index += match[0].length;
  2264. }
  2265. push({ type: 'text', value });
  2266. continue;
  2267. }
  2268. /**
  2269. * Stars
  2270. */
  2271. if (prev && (prev.type === 'globstar' || prev.star === true)) {
  2272. prev.type = 'star';
  2273. prev.star = true;
  2274. prev.value += value;
  2275. prev.output = star;
  2276. state.backtrack = true;
  2277. state.globstar = true;
  2278. consume(value);
  2279. continue;
  2280. }
  2281. let rest = remaining();
  2282. if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
  2283. extglobOpen('star', value);
  2284. continue;
  2285. }
  2286. if (prev.type === 'star') {
  2287. if (opts.noglobstar === true) {
  2288. consume(value);
  2289. continue;
  2290. }
  2291. const prior = prev.prev;
  2292. const before = prior.prev;
  2293. const isStart = prior.type === 'slash' || prior.type === 'bos';
  2294. const afterStar = before && (before.type === 'star' || before.type === 'globstar');
  2295. if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
  2296. push({ type: 'star', value, output: '' });
  2297. continue;
  2298. }
  2299. const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
  2300. const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
  2301. if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
  2302. push({ type: 'star', value, output: '' });
  2303. continue;
  2304. }
  2305. // strip consecutive `/**/`
  2306. while (rest.slice(0, 3) === '/**') {
  2307. const after = input[state.index + 4];
  2308. if (after && after !== '/') {
  2309. break;
  2310. }
  2311. rest = rest.slice(3);
  2312. consume('/**', 3);
  2313. }
  2314. if (prior.type === 'bos' && eos()) {
  2315. prev.type = 'globstar';
  2316. prev.value += value;
  2317. prev.output = globstar(opts);
  2318. state.output = prev.output;
  2319. state.globstar = true;
  2320. consume(value);
  2321. continue;
  2322. }
  2323. if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
  2324. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  2325. prior.output = `(?:${prior.output}`;
  2326. prev.type = 'globstar';
  2327. prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
  2328. prev.value += value;
  2329. state.globstar = true;
  2330. state.output += prior.output + prev.output;
  2331. consume(value);
  2332. continue;
  2333. }
  2334. if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
  2335. const end = rest[1] !== void 0 ? '|$' : '';
  2336. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  2337. prior.output = `(?:${prior.output}`;
  2338. prev.type = 'globstar';
  2339. prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
  2340. prev.value += value;
  2341. state.output += prior.output + prev.output;
  2342. state.globstar = true;
  2343. consume(value + advance());
  2344. push({ type: 'slash', value: '/', output: '' });
  2345. continue;
  2346. }
  2347. if (prior.type === 'bos' && rest[0] === '/') {
  2348. prev.type = 'globstar';
  2349. prev.value += value;
  2350. prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
  2351. state.output = prev.output;
  2352. state.globstar = true;
  2353. consume(value + advance());
  2354. push({ type: 'slash', value: '/', output: '' });
  2355. continue;
  2356. }
  2357. // remove single star from output
  2358. state.output = state.output.slice(0, -prev.output.length);
  2359. // reset previous token to globstar
  2360. prev.type = 'globstar';
  2361. prev.output = globstar(opts);
  2362. prev.value += value;
  2363. // reset output with globstar
  2364. state.output += prev.output;
  2365. state.globstar = true;
  2366. consume(value);
  2367. continue;
  2368. }
  2369. const token = { type: 'star', value, output: star };
  2370. if (opts.bash === true) {
  2371. token.output = '.*?';
  2372. if (prev.type === 'bos' || prev.type === 'slash') {
  2373. token.output = nodot + token.output;
  2374. }
  2375. push(token);
  2376. continue;
  2377. }
  2378. if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
  2379. token.output = value;
  2380. push(token);
  2381. continue;
  2382. }
  2383. if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
  2384. if (prev.type === 'dot') {
  2385. state.output += NO_DOT_SLASH;
  2386. prev.output += NO_DOT_SLASH;
  2387. } else if (opts.dot === true) {
  2388. state.output += NO_DOTS_SLASH;
  2389. prev.output += NO_DOTS_SLASH;
  2390. } else {
  2391. state.output += nodot;
  2392. prev.output += nodot;
  2393. }
  2394. if (peek() !== '*') {
  2395. state.output += ONE_CHAR;
  2396. prev.output += ONE_CHAR;
  2397. }
  2398. }
  2399. push(token);
  2400. }
  2401. while (state.brackets > 0) {
  2402. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
  2403. state.output = utils$1.escapeLast(state.output, '[');
  2404. decrement('brackets');
  2405. }
  2406. while (state.parens > 0) {
  2407. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
  2408. state.output = utils$1.escapeLast(state.output, '(');
  2409. decrement('parens');
  2410. }
  2411. while (state.braces > 0) {
  2412. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
  2413. state.output = utils$1.escapeLast(state.output, '{');
  2414. decrement('braces');
  2415. }
  2416. if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
  2417. push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
  2418. }
  2419. // rebuild the output if we had to backtrack at any point
  2420. if (state.backtrack === true) {
  2421. state.output = '';
  2422. for (const token of state.tokens) {
  2423. state.output += token.output != null ? token.output : token.value;
  2424. if (token.suffix) {
  2425. state.output += token.suffix;
  2426. }
  2427. }
  2428. }
  2429. return state;
  2430. };
  2431. /**
  2432. * Fast paths for creating regular expressions for common glob patterns.
  2433. * This can significantly speed up processing and has very little downside
  2434. * impact when none of the fast paths match.
  2435. */
  2436. parse$2.fastpaths = (input, options) => {
  2437. const opts = { ...options };
  2438. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  2439. const len = input.length;
  2440. if (len > max) {
  2441. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  2442. }
  2443. input = REPLACEMENTS[input] || input;
  2444. const win32 = utils$1.isWindows(options);
  2445. // create constants based on platform, for windows or posix
  2446. const {
  2447. DOT_LITERAL,
  2448. SLASH_LITERAL,
  2449. ONE_CHAR,
  2450. DOTS_SLASH,
  2451. NO_DOT,
  2452. NO_DOTS,
  2453. NO_DOTS_SLASH,
  2454. STAR,
  2455. START_ANCHOR
  2456. } = constants$1.globChars(win32);
  2457. const nodot = opts.dot ? NO_DOTS : NO_DOT;
  2458. const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
  2459. const capture = opts.capture ? '' : '?:';
  2460. const state = { negated: false, prefix: '' };
  2461. let star = opts.bash === true ? '.*?' : STAR;
  2462. if (opts.capture) {
  2463. star = `(${star})`;
  2464. }
  2465. const globstar = opts => {
  2466. if (opts.noglobstar === true) return star;
  2467. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  2468. };
  2469. const create = str => {
  2470. switch (str) {
  2471. case '*':
  2472. return `${nodot}${ONE_CHAR}${star}`;
  2473. case '.*':
  2474. return `${DOT_LITERAL}${ONE_CHAR}${star}`;
  2475. case '*.*':
  2476. return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  2477. case '*/*':
  2478. return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
  2479. case '**':
  2480. return nodot + globstar(opts);
  2481. case '**/*':
  2482. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
  2483. case '**/*.*':
  2484. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  2485. case '**/.*':
  2486. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
  2487. default: {
  2488. const match = /^(.*?)\.(\w+)$/.exec(str);
  2489. if (!match) return;
  2490. const source = create(match[1]);
  2491. if (!source) return;
  2492. return source + DOT_LITERAL + match[2];
  2493. }
  2494. }
  2495. };
  2496. const output = utils$1.removePrefix(input, state);
  2497. let source = create(output);
  2498. if (source && opts.strictSlashes !== true) {
  2499. source += `${SLASH_LITERAL}?`;
  2500. }
  2501. return source;
  2502. };
  2503. var parse_1$1 = parse$2;
  2504. const path$1 = require$$0$1;
  2505. const scan = scan_1;
  2506. const parse$1 = parse_1$1;
  2507. const utils = utils$3;
  2508. const constants = constants$2;
  2509. const isObject$2 = val => val && typeof val === 'object' && !Array.isArray(val);
  2510. /**
  2511. * Creates a matcher function from one or more glob patterns. The
  2512. * returned function takes a string to match as its first argument,
  2513. * and returns true if the string is a match. The returned matcher
  2514. * function also takes a boolean as the second argument that, when true,
  2515. * returns an object with additional information.
  2516. *
  2517. * ```js
  2518. * const picomatch = require('picomatch');
  2519. * // picomatch(glob[, options]);
  2520. *
  2521. * const isMatch = picomatch('*.!(*a)');
  2522. * console.log(isMatch('a.a')); //=> false
  2523. * console.log(isMatch('a.b')); //=> true
  2524. * ```
  2525. * @name picomatch
  2526. * @param {String|Array} `globs` One or more glob patterns.
  2527. * @param {Object=} `options`
  2528. * @return {Function=} Returns a matcher function.
  2529. * @api public
  2530. */
  2531. const picomatch$1 = (glob, options, returnState = false) => {
  2532. if (Array.isArray(glob)) {
  2533. const fns = glob.map(input => picomatch$1(input, options, returnState));
  2534. const arrayMatcher = str => {
  2535. for (const isMatch of fns) {
  2536. const state = isMatch(str);
  2537. if (state) return state;
  2538. }
  2539. return false;
  2540. };
  2541. return arrayMatcher;
  2542. }
  2543. const isState = isObject$2(glob) && glob.tokens && glob.input;
  2544. if (glob === '' || (typeof glob !== 'string' && !isState)) {
  2545. throw new TypeError('Expected pattern to be a non-empty string');
  2546. }
  2547. const opts = options || {};
  2548. const posix = utils.isWindows(options);
  2549. const regex = isState
  2550. ? picomatch$1.compileRe(glob, options)
  2551. : picomatch$1.makeRe(glob, options, false, true);
  2552. const state = regex.state;
  2553. delete regex.state;
  2554. let isIgnored = () => false;
  2555. if (opts.ignore) {
  2556. const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
  2557. isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
  2558. }
  2559. const matcher = (input, returnObject = false) => {
  2560. const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
  2561. const result = { glob, state, regex, posix, input, output, match, isMatch };
  2562. if (typeof opts.onResult === 'function') {
  2563. opts.onResult(result);
  2564. }
  2565. if (isMatch === false) {
  2566. result.isMatch = false;
  2567. return returnObject ? result : false;
  2568. }
  2569. if (isIgnored(input)) {
  2570. if (typeof opts.onIgnore === 'function') {
  2571. opts.onIgnore(result);
  2572. }
  2573. result.isMatch = false;
  2574. return returnObject ? result : false;
  2575. }
  2576. if (typeof opts.onMatch === 'function') {
  2577. opts.onMatch(result);
  2578. }
  2579. return returnObject ? result : true;
  2580. };
  2581. if (returnState) {
  2582. matcher.state = state;
  2583. }
  2584. return matcher;
  2585. };
  2586. /**
  2587. * Test `input` with the given `regex`. This is used by the main
  2588. * `picomatch()` function to test the input string.
  2589. *
  2590. * ```js
  2591. * const picomatch = require('picomatch');
  2592. * // picomatch.test(input, regex[, options]);
  2593. *
  2594. * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
  2595. * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
  2596. * ```
  2597. * @param {String} `input` String to test.
  2598. * @param {RegExp} `regex`
  2599. * @return {Object} Returns an object with matching info.
  2600. * @api public
  2601. */
  2602. picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
  2603. if (typeof input !== 'string') {
  2604. throw new TypeError('Expected input to be a string');
  2605. }
  2606. if (input === '') {
  2607. return { isMatch: false, output: '' };
  2608. }
  2609. const opts = options || {};
  2610. const format = opts.format || (posix ? utils.toPosixSlashes : null);
  2611. let match = input === glob;
  2612. let output = (match && format) ? format(input) : input;
  2613. if (match === false) {
  2614. output = format ? format(input) : input;
  2615. match = output === glob;
  2616. }
  2617. if (match === false || opts.capture === true) {
  2618. if (opts.matchBase === true || opts.basename === true) {
  2619. match = picomatch$1.matchBase(input, regex, options, posix);
  2620. } else {
  2621. match = regex.exec(output);
  2622. }
  2623. }
  2624. return { isMatch: Boolean(match), match, output };
  2625. };
  2626. /**
  2627. * Match the basename of a filepath.
  2628. *
  2629. * ```js
  2630. * const picomatch = require('picomatch');
  2631. * // picomatch.matchBase(input, glob[, options]);
  2632. * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
  2633. * ```
  2634. * @param {String} `input` String to test.
  2635. * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
  2636. * @return {Boolean}
  2637. * @api public
  2638. */
  2639. picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
  2640. const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
  2641. return regex.test(path$1.basename(input));
  2642. };
  2643. /**
  2644. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  2645. *
  2646. * ```js
  2647. * const picomatch = require('picomatch');
  2648. * // picomatch.isMatch(string, patterns[, options]);
  2649. *
  2650. * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
  2651. * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
  2652. * ```
  2653. * @param {String|Array} str The string to test.
  2654. * @param {String|Array} patterns One or more glob patterns to use for matching.
  2655. * @param {Object} [options] See available [options](#options).
  2656. * @return {Boolean} Returns true if any patterns match `str`
  2657. * @api public
  2658. */
  2659. picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
  2660. /**
  2661. * Parse a glob pattern to create the source string for a regular
  2662. * expression.
  2663. *
  2664. * ```js
  2665. * const picomatch = require('picomatch');
  2666. * const result = picomatch.parse(pattern[, options]);
  2667. * ```
  2668. * @param {String} `pattern`
  2669. * @param {Object} `options`
  2670. * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
  2671. * @api public
  2672. */
  2673. picomatch$1.parse = (pattern, options) => {
  2674. if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
  2675. return parse$1(pattern, { ...options, fastpaths: false });
  2676. };
  2677. /**
  2678. * Scan a glob pattern to separate the pattern into segments.
  2679. *
  2680. * ```js
  2681. * const picomatch = require('picomatch');
  2682. * // picomatch.scan(input[, options]);
  2683. *
  2684. * const result = picomatch.scan('!./foo/*.js');
  2685. * console.log(result);
  2686. * { prefix: '!./',
  2687. * input: '!./foo/*.js',
  2688. * start: 3,
  2689. * base: 'foo',
  2690. * glob: '*.js',
  2691. * isBrace: false,
  2692. * isBracket: false,
  2693. * isGlob: true,
  2694. * isExtglob: false,
  2695. * isGlobstar: false,
  2696. * negated: true }
  2697. * ```
  2698. * @param {String} `input` Glob pattern to scan.
  2699. * @param {Object} `options`
  2700. * @return {Object} Returns an object with
  2701. * @api public
  2702. */
  2703. picomatch$1.scan = (input, options) => scan(input, options);
  2704. /**
  2705. * Compile a regular expression from the `state` object returned by the
  2706. * [parse()](#parse) method.
  2707. *
  2708. * @param {Object} `state`
  2709. * @param {Object} `options`
  2710. * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
  2711. * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
  2712. * @return {RegExp}
  2713. * @api public
  2714. */
  2715. picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
  2716. if (returnOutput === true) {
  2717. return state.output;
  2718. }
  2719. const opts = options || {};
  2720. const prepend = opts.contains ? '' : '^';
  2721. const append = opts.contains ? '' : '$';
  2722. let source = `${prepend}(?:${state.output})${append}`;
  2723. if (state && state.negated === true) {
  2724. source = `^(?!${source}).*$`;
  2725. }
  2726. const regex = picomatch$1.toRegex(source, options);
  2727. if (returnState === true) {
  2728. regex.state = state;
  2729. }
  2730. return regex;
  2731. };
  2732. /**
  2733. * Create a regular expression from a parsed glob pattern.
  2734. *
  2735. * ```js
  2736. * const picomatch = require('picomatch');
  2737. * const state = picomatch.parse('*.js');
  2738. * // picomatch.compileRe(state[, options]);
  2739. *
  2740. * console.log(picomatch.compileRe(state));
  2741. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  2742. * ```
  2743. * @param {String} `state` The object returned from the `.parse` method.
  2744. * @param {Object} `options`
  2745. * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
  2746. * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
  2747. * @return {RegExp} Returns a regex created from the given pattern.
  2748. * @api public
  2749. */
  2750. picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
  2751. if (!input || typeof input !== 'string') {
  2752. throw new TypeError('Expected a non-empty string');
  2753. }
  2754. let parsed = { negated: false, fastpaths: true };
  2755. if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
  2756. parsed.output = parse$1.fastpaths(input, options);
  2757. }
  2758. if (!parsed.output) {
  2759. parsed = parse$1(input, options);
  2760. }
  2761. return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
  2762. };
  2763. /**
  2764. * Create a regular expression from the given regex source string.
  2765. *
  2766. * ```js
  2767. * const picomatch = require('picomatch');
  2768. * // picomatch.toRegex(source[, options]);
  2769. *
  2770. * const { output } = picomatch.parse('*.js');
  2771. * console.log(picomatch.toRegex(output));
  2772. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  2773. * ```
  2774. * @param {String} `source` Regular expression source string.
  2775. * @param {Object} `options`
  2776. * @return {RegExp}
  2777. * @api public
  2778. */
  2779. picomatch$1.toRegex = (source, options) => {
  2780. try {
  2781. const opts = options || {};
  2782. return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
  2783. } catch (err) {
  2784. if (options && options.debug === true) throw err;
  2785. return /$^/;
  2786. }
  2787. };
  2788. /**
  2789. * Picomatch constants.
  2790. * @return {Object}
  2791. */
  2792. picomatch$1.constants = constants;
  2793. /**
  2794. * Expose "picomatch"
  2795. */
  2796. var picomatch_1 = picomatch$1;
  2797. var picomatch = picomatch_1;
  2798. var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
  2799. // Helper since Typescript can't detect readonly arrays with Array.isArray
  2800. function isArray(arg) {
  2801. return Array.isArray(arg);
  2802. }
  2803. function ensureArray(thing) {
  2804. if (isArray(thing))
  2805. return thing;
  2806. if (thing == null)
  2807. return [];
  2808. return [thing];
  2809. }
  2810. const normalizePath$1 = function normalizePath(filename) {
  2811. return filename.split(require$$0$1.win32.sep).join(require$$0$1.posix.sep);
  2812. };
  2813. function getMatcherString(id, resolutionBase) {
  2814. if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('**')) {
  2815. return normalizePath$1(id);
  2816. }
  2817. // resolve('') is valid and will default to process.cwd()
  2818. const basePath = normalizePath$1(require$$0$1.resolve(resolutionBase || ''))
  2819. // escape all possible (posix + win) path characters that might interfere with regex
  2820. .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
  2821. // Note that we use posix.join because:
  2822. // 1. the basePath has been normalized to use /
  2823. // 2. the incoming glob (id) matcher, also uses /
  2824. // otherwise Node will force backslash (\) on windows
  2825. return require$$0$1.posix.join(basePath, normalizePath$1(id));
  2826. }
  2827. const createFilter$1 = function createFilter(include, exclude, options) {
  2828. const resolutionBase = options && options.resolve;
  2829. const getMatcher = (id) => id instanceof RegExp
  2830. ? id
  2831. : {
  2832. test: (what) => {
  2833. // this refactor is a tad overly verbose but makes for easy debugging
  2834. const pattern = getMatcherString(id, resolutionBase);
  2835. const fn = pm(pattern, { dot: true });
  2836. const result = fn(what);
  2837. return result;
  2838. }
  2839. };
  2840. const includeMatchers = ensureArray(include).map(getMatcher);
  2841. const excludeMatchers = ensureArray(exclude).map(getMatcher);
  2842. return function result(id) {
  2843. if (typeof id !== 'string')
  2844. return false;
  2845. if (/\0/.test(id))
  2846. return false;
  2847. const pathId = normalizePath$1(id);
  2848. for (let i = 0; i < excludeMatchers.length; ++i) {
  2849. const matcher = excludeMatchers[i];
  2850. if (matcher.test(pathId))
  2851. return false;
  2852. }
  2853. for (let i = 0; i < includeMatchers.length; ++i) {
  2854. const matcher = includeMatchers[i];
  2855. if (matcher.test(pathId))
  2856. return true;
  2857. }
  2858. return !includeMatchers.length;
  2859. };
  2860. };
  2861. const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
  2862. const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
  2863. const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
  2864. forbiddenIdentifiers.add('');
  2865. const isWindows = typeof process !== "undefined" && process.platform === "win32";
  2866. const windowsSlashRE = /\\/g;
  2867. function slash(p) {
  2868. return p.replace(windowsSlashRE, "/");
  2869. }
  2870. const postfixRE = /[?#].*$/;
  2871. function cleanUrl(url) {
  2872. return url.replace(postfixRE, "");
  2873. }
  2874. function withTrailingSlash(path) {
  2875. if (path[path.length - 1] !== "/") {
  2876. return `${path}/`;
  2877. }
  2878. return path;
  2879. }
  2880. if (process.versions.pnp) {
  2881. try {
  2882. node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))("pnpapi");
  2883. } catch {
  2884. }
  2885. }
  2886. const createFilter = createFilter$1;
  2887. node_module.builtinModules.filter((id) => !id.includes(":"));
  2888. function isInNodeModules(id) {
  2889. return id.includes("node_modules");
  2890. }
  2891. const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
  2892. function resolveDependencyVersion(dep, pkgRelativePath = "../../package.json") {
  2893. const pkgPath = path$3.resolve(_require.resolve(dep), pkgRelativePath);
  2894. return JSON.parse(fs$1.readFileSync(pkgPath, "utf-8")).version;
  2895. }
  2896. const rollupVersion = resolveDependencyVersion("rollup");
  2897. const filter = process.env.VITE_DEBUG_FILTER;
  2898. const DEBUG = process.env.DEBUG;
  2899. function createDebugger(namespace, options = {}) {
  2900. const log = debug$2(namespace);
  2901. const { onlyWhenFocused } = options;
  2902. let enabled = log.enabled;
  2903. if (enabled && onlyWhenFocused) {
  2904. const ns = typeof onlyWhenFocused === "string" ? onlyWhenFocused : namespace;
  2905. enabled = !!DEBUG?.includes(ns);
  2906. }
  2907. if (enabled) {
  2908. return (...args) => {
  2909. if (!filter || args.some((a) => a?.includes?.(filter))) {
  2910. log(...args);
  2911. }
  2912. };
  2913. }
  2914. }
  2915. function testCaseInsensitiveFS() {
  2916. if (!CLIENT_ENTRY.endsWith("client.mjs")) {
  2917. throw new Error(
  2918. `cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`
  2919. );
  2920. }
  2921. if (!fs$1.existsSync(CLIENT_ENTRY)) {
  2922. throw new Error(
  2923. "cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: " + CLIENT_ENTRY
  2924. );
  2925. }
  2926. return fs$1.existsSync(CLIENT_ENTRY.replace("client.mjs", "cLiEnT.mjs"));
  2927. }
  2928. const isCaseInsensitiveFS = testCaseInsensitiveFS();
  2929. const VOLUME_RE = /^[A-Z]:/i;
  2930. function normalizePath(id) {
  2931. return path$3.posix.normalize(isWindows ? slash(id) : id);
  2932. }
  2933. function fsPathFromId(id) {
  2934. const fsPath = normalizePath(
  2935. id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id
  2936. );
  2937. return fsPath[0] === "/" || VOLUME_RE.test(fsPath) ? fsPath : `/${fsPath}`;
  2938. }
  2939. function fsPathFromUrl(url) {
  2940. return fsPathFromId(cleanUrl(url));
  2941. }
  2942. function isParentDirectory(dir, file) {
  2943. dir = withTrailingSlash(dir);
  2944. return file.startsWith(dir) || isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase());
  2945. }
  2946. function isSameFileUri(file1, file2) {
  2947. return file1 === file2 || isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase();
  2948. }
  2949. const trailingSeparatorRE = /[?&]$/;
  2950. const timestampRE = /\bt=\d{13}&?\b/;
  2951. function removeTimestampQuery(url) {
  2952. return url.replace(timestampRE, "").replace(trailingSeparatorRE, "");
  2953. }
  2954. function isObject$1(value) {
  2955. return Object.prototype.toString.call(value) === "[object Object]";
  2956. }
  2957. function tryStatSync(file) {
  2958. try {
  2959. return fs$1.statSync(file, { throwIfNoEntry: false });
  2960. } catch {
  2961. }
  2962. }
  2963. function isFileReadable(filename) {
  2964. if (!tryStatSync(filename)) {
  2965. return false;
  2966. }
  2967. try {
  2968. fs$1.accessSync(filename, fs$1.constants.R_OK);
  2969. return true;
  2970. } catch {
  2971. return false;
  2972. }
  2973. }
  2974. function arraify(target) {
  2975. return Array.isArray(target) ? target : [target];
  2976. }
  2977. path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))));
  2978. function backwardCompatibleWorkerPlugins(plugins) {
  2979. if (Array.isArray(plugins)) {
  2980. return plugins;
  2981. }
  2982. if (typeof plugins === "function") {
  2983. return plugins();
  2984. }
  2985. return [];
  2986. }
  2987. function mergeConfigRecursively(defaults, overrides, rootPath) {
  2988. const merged = { ...defaults };
  2989. for (const key in overrides) {
  2990. const value = overrides[key];
  2991. if (value == null) {
  2992. continue;
  2993. }
  2994. const existing = merged[key];
  2995. if (existing == null) {
  2996. merged[key] = value;
  2997. continue;
  2998. }
  2999. if (key === "alias" && (rootPath === "resolve" || rootPath === "")) {
  3000. merged[key] = mergeAlias(existing, value);
  3001. continue;
  3002. } else if (key === "assetsInclude" && rootPath === "") {
  3003. merged[key] = [].concat(existing, value);
  3004. continue;
  3005. } else if (key === "noExternal" && rootPath === "ssr" && (existing === true || value === true)) {
  3006. merged[key] = true;
  3007. continue;
  3008. } else if (key === "plugins" && rootPath === "worker") {
  3009. merged[key] = () => [
  3010. ...backwardCompatibleWorkerPlugins(existing),
  3011. ...backwardCompatibleWorkerPlugins(value)
  3012. ];
  3013. continue;
  3014. } else if (key === "server" && rootPath === "server.hmr") {
  3015. merged[key] = value;
  3016. continue;
  3017. }
  3018. if (Array.isArray(existing) || Array.isArray(value)) {
  3019. merged[key] = [...arraify(existing), ...arraify(value)];
  3020. continue;
  3021. }
  3022. if (isObject$1(existing) && isObject$1(value)) {
  3023. merged[key] = mergeConfigRecursively(
  3024. existing,
  3025. value,
  3026. rootPath ? `${rootPath}.${key}` : key
  3027. );
  3028. continue;
  3029. }
  3030. merged[key] = value;
  3031. }
  3032. return merged;
  3033. }
  3034. function mergeConfig(defaults, overrides, isRoot = true) {
  3035. if (typeof defaults === "function" || typeof overrides === "function") {
  3036. throw new Error(`Cannot merge config in form of callback`);
  3037. }
  3038. return mergeConfigRecursively(defaults, overrides, isRoot ? "" : ".");
  3039. }
  3040. function mergeAlias(a, b) {
  3041. if (!a) return b;
  3042. if (!b) return a;
  3043. if (isObject$1(a) && isObject$1(b)) {
  3044. return { ...a, ...b };
  3045. }
  3046. return [...normalizeAlias(b), ...normalizeAlias(a)];
  3047. }
  3048. function normalizeAlias(o = []) {
  3049. return Array.isArray(o) ? o.map(normalizeSingleAlias) : Object.keys(o).map(
  3050. (find) => normalizeSingleAlias({
  3051. find,
  3052. replacement: o[find]
  3053. })
  3054. );
  3055. }
  3056. function normalizeSingleAlias({
  3057. find,
  3058. replacement,
  3059. customResolver
  3060. }) {
  3061. if (typeof find === "string" && find[find.length - 1] === "/" && replacement[replacement.length - 1] === "/") {
  3062. find = find.slice(0, find.length - 1);
  3063. replacement = replacement.slice(0, replacement.length - 1);
  3064. }
  3065. const alias = {
  3066. find,
  3067. replacement
  3068. };
  3069. if (customResolver) {
  3070. alias.customResolver = customResolver;
  3071. }
  3072. return alias;
  3073. }
  3074. const CSS_LANGS_RE = (
  3075. // eslint-disable-next-line regexp/no-unused-capturing-group
  3076. /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
  3077. );
  3078. const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
  3079. class SplitVendorChunkCache {
  3080. cache;
  3081. constructor() {
  3082. this.cache = /* @__PURE__ */ new Map();
  3083. }
  3084. reset() {
  3085. this.cache = /* @__PURE__ */ new Map();
  3086. }
  3087. }
  3088. function splitVendorChunk(options = {}) {
  3089. const cache = options.cache ?? new SplitVendorChunkCache();
  3090. return (id, { getModuleInfo }) => {
  3091. if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
  3092. return "vendor";
  3093. }
  3094. };
  3095. }
  3096. function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
  3097. if (cache.has(id)) {
  3098. return cache.get(id);
  3099. }
  3100. if (importStack.includes(id)) {
  3101. cache.set(id, false);
  3102. return false;
  3103. }
  3104. const mod = getModuleInfo(id);
  3105. if (!mod) {
  3106. cache.set(id, false);
  3107. return false;
  3108. }
  3109. if (mod.isEntry) {
  3110. cache.set(id, true);
  3111. return true;
  3112. }
  3113. const someImporterIs = mod.importers.some(
  3114. (importer) => staticImportedByEntry(
  3115. importer,
  3116. getModuleInfo,
  3117. cache,
  3118. importStack.concat(id)
  3119. )
  3120. );
  3121. cache.set(id, someImporterIs);
  3122. return someImporterIs;
  3123. }
  3124. function splitVendorChunkPlugin() {
  3125. const caches = [];
  3126. function createSplitVendorChunk(output, config) {
  3127. const cache = new SplitVendorChunkCache();
  3128. caches.push(cache);
  3129. const build = config.build ?? {};
  3130. const format = output?.format;
  3131. if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
  3132. return splitVendorChunk({ cache });
  3133. }
  3134. }
  3135. return {
  3136. name: "vite:split-vendor-chunk",
  3137. config(config) {
  3138. let outputs = config?.build?.rollupOptions?.output;
  3139. if (outputs) {
  3140. outputs = arraify(outputs);
  3141. for (const output of outputs) {
  3142. const viteManualChunks = createSplitVendorChunk(output, config);
  3143. if (viteManualChunks) {
  3144. if (output.manualChunks) {
  3145. if (typeof output.manualChunks === "function") {
  3146. const userManualChunks = output.manualChunks;
  3147. output.manualChunks = (id, api) => {
  3148. return userManualChunks(id, api) ?? viteManualChunks(id, api);
  3149. };
  3150. } else {
  3151. console.warn(
  3152. "(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
  3153. );
  3154. }
  3155. } else {
  3156. output.manualChunks = viteManualChunks;
  3157. }
  3158. }
  3159. }
  3160. } else {
  3161. return {
  3162. build: {
  3163. rollupOptions: {
  3164. output: {
  3165. manualChunks: createSplitVendorChunk({}, config)
  3166. }
  3167. }
  3168. }
  3169. };
  3170. }
  3171. },
  3172. buildStart() {
  3173. caches.forEach((cache) => cache.reset());
  3174. }
  3175. };
  3176. }
  3177. var convertSourceMap$1 = {};
  3178. (function (exports) {
  3179. Object.defineProperty(exports, 'commentRegex', {
  3180. get: function getCommentRegex () {
  3181. // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
  3182. return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
  3183. }
  3184. });
  3185. Object.defineProperty(exports, 'mapFileCommentRegex', {
  3186. get: function getMapFileCommentRegex () {
  3187. // Matches sourceMappingURL in either // or /* comment styles.
  3188. return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
  3189. }
  3190. });
  3191. var decodeBase64;
  3192. if (typeof Buffer !== 'undefined') {
  3193. if (typeof Buffer.from === 'function') {
  3194. decodeBase64 = decodeBase64WithBufferFrom;
  3195. } else {
  3196. decodeBase64 = decodeBase64WithNewBuffer;
  3197. }
  3198. } else {
  3199. decodeBase64 = decodeBase64WithAtob;
  3200. }
  3201. function decodeBase64WithBufferFrom(base64) {
  3202. return Buffer.from(base64, 'base64').toString();
  3203. }
  3204. function decodeBase64WithNewBuffer(base64) {
  3205. if (typeof value === 'number') {
  3206. throw new TypeError('The value to decode must not be of type number.');
  3207. }
  3208. return new Buffer(base64, 'base64').toString();
  3209. }
  3210. function decodeBase64WithAtob(base64) {
  3211. return decodeURIComponent(escape(atob(base64)));
  3212. }
  3213. function stripComment(sm) {
  3214. return sm.split(',').pop();
  3215. }
  3216. function readFromFileMap(sm, read) {
  3217. var r = exports.mapFileCommentRegex.exec(sm);
  3218. // for some odd reason //# .. captures in 1 and /* .. */ in 2
  3219. var filename = r[1] || r[2];
  3220. try {
  3221. var sm = read(filename);
  3222. if (sm != null && typeof sm.catch === 'function') {
  3223. return sm.catch(throwError);
  3224. } else {
  3225. return sm;
  3226. }
  3227. } catch (e) {
  3228. throwError(e);
  3229. }
  3230. function throwError(e) {
  3231. throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack);
  3232. }
  3233. }
  3234. function Converter (sm, opts) {
  3235. opts = opts || {};
  3236. if (opts.hasComment) {
  3237. sm = stripComment(sm);
  3238. }
  3239. if (opts.encoding === 'base64') {
  3240. sm = decodeBase64(sm);
  3241. } else if (opts.encoding === 'uri') {
  3242. sm = decodeURIComponent(sm);
  3243. }
  3244. if (opts.isJSON || opts.encoding) {
  3245. sm = JSON.parse(sm);
  3246. }
  3247. this.sourcemap = sm;
  3248. }
  3249. Converter.prototype.toJSON = function (space) {
  3250. return JSON.stringify(this.sourcemap, null, space);
  3251. };
  3252. if (typeof Buffer !== 'undefined') {
  3253. if (typeof Buffer.from === 'function') {
  3254. Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
  3255. } else {
  3256. Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
  3257. }
  3258. } else {
  3259. Converter.prototype.toBase64 = encodeBase64WithBtoa;
  3260. }
  3261. function encodeBase64WithBufferFrom() {
  3262. var json = this.toJSON();
  3263. return Buffer.from(json, 'utf8').toString('base64');
  3264. }
  3265. function encodeBase64WithNewBuffer() {
  3266. var json = this.toJSON();
  3267. if (typeof json === 'number') {
  3268. throw new TypeError('The json to encode must not be of type number.');
  3269. }
  3270. return new Buffer(json, 'utf8').toString('base64');
  3271. }
  3272. function encodeBase64WithBtoa() {
  3273. var json = this.toJSON();
  3274. return btoa(unescape(encodeURIComponent(json)));
  3275. }
  3276. Converter.prototype.toURI = function () {
  3277. var json = this.toJSON();
  3278. return encodeURIComponent(json);
  3279. };
  3280. Converter.prototype.toComment = function (options) {
  3281. var encoding, content, data;
  3282. if (options != null && options.encoding === 'uri') {
  3283. encoding = '';
  3284. content = this.toURI();
  3285. } else {
  3286. encoding = ';base64';
  3287. content = this.toBase64();
  3288. }
  3289. data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
  3290. return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
  3291. };
  3292. // returns copy instead of original
  3293. Converter.prototype.toObject = function () {
  3294. return JSON.parse(this.toJSON());
  3295. };
  3296. Converter.prototype.addProperty = function (key, value) {
  3297. if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
  3298. return this.setProperty(key, value);
  3299. };
  3300. Converter.prototype.setProperty = function (key, value) {
  3301. this.sourcemap[key] = value;
  3302. return this;
  3303. };
  3304. Converter.prototype.getProperty = function (key) {
  3305. return this.sourcemap[key];
  3306. };
  3307. exports.fromObject = function (obj) {
  3308. return new Converter(obj);
  3309. };
  3310. exports.fromJSON = function (json) {
  3311. return new Converter(json, { isJSON: true });
  3312. };
  3313. exports.fromURI = function (uri) {
  3314. return new Converter(uri, { encoding: 'uri' });
  3315. };
  3316. exports.fromBase64 = function (base64) {
  3317. return new Converter(base64, { encoding: 'base64' });
  3318. };
  3319. exports.fromComment = function (comment) {
  3320. var m, encoding;
  3321. comment = comment
  3322. .replace(/^\/\*/g, '//')
  3323. .replace(/\*\/$/g, '');
  3324. m = exports.commentRegex.exec(comment);
  3325. encoding = m && m[4] || 'uri';
  3326. return new Converter(comment, { encoding: encoding, hasComment: true });
  3327. };
  3328. function makeConverter(sm) {
  3329. return new Converter(sm, { isJSON: true });
  3330. }
  3331. exports.fromMapFileComment = function (comment, read) {
  3332. if (typeof read === 'string') {
  3333. throw new Error(
  3334. 'String directory paths are no longer supported with `fromMapFileComment`\n' +
  3335. 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
  3336. )
  3337. }
  3338. var sm = readFromFileMap(comment, read);
  3339. if (sm != null && typeof sm.then === 'function') {
  3340. return sm.then(makeConverter);
  3341. } else {
  3342. return makeConverter(sm);
  3343. }
  3344. };
  3345. // Finds last sourcemap comment in file or returns null if none was found
  3346. exports.fromSource = function (content) {
  3347. var m = content.match(exports.commentRegex);
  3348. return m ? exports.fromComment(m.pop()) : null;
  3349. };
  3350. // Finds last sourcemap comment in file or returns null if none was found
  3351. exports.fromMapFileSource = function (content, read) {
  3352. if (typeof read === 'string') {
  3353. throw new Error(
  3354. 'String directory paths are no longer supported with `fromMapFileSource`\n' +
  3355. 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
  3356. )
  3357. }
  3358. var m = content.match(exports.mapFileCommentRegex);
  3359. return m ? exports.fromMapFileComment(m.pop(), read) : null;
  3360. };
  3361. exports.removeComments = function (src) {
  3362. return src.replace(exports.commentRegex, '');
  3363. };
  3364. exports.removeMapFileComments = function (src) {
  3365. return src.replace(exports.mapFileCommentRegex, '');
  3366. };
  3367. exports.generateMapFileComment = function (file, options) {
  3368. var data = 'sourceMappingURL=' + file;
  3369. return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
  3370. };
  3371. } (convertSourceMap$1));
  3372. var convertSourceMap = /*@__PURE__*/getDefaultExportFromCjs(convertSourceMap$1);
  3373. /*!
  3374. * etag
  3375. * Copyright(c) 2014-2016 Douglas Christopher Wilson
  3376. * MIT Licensed
  3377. */
  3378. /**
  3379. * Module exports.
  3380. * @public
  3381. */
  3382. var etag_1 = etag;
  3383. /**
  3384. * Module dependencies.
  3385. * @private
  3386. */
  3387. var crypto$1 = require$$0$2;
  3388. var Stats = fs$2.Stats;
  3389. /**
  3390. * Module variables.
  3391. * @private
  3392. */
  3393. var toString$1 = Object.prototype.toString;
  3394. /**
  3395. * Generate an entity tag.
  3396. *
  3397. * @param {Buffer|string} entity
  3398. * @return {string}
  3399. * @private
  3400. */
  3401. function entitytag (entity) {
  3402. if (entity.length === 0) {
  3403. // fast-path empty
  3404. return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"'
  3405. }
  3406. // compute hash of entity
  3407. var hash = crypto$1
  3408. .createHash('sha1')
  3409. .update(entity, 'utf8')
  3410. .digest('base64')
  3411. .substring(0, 27);
  3412. // compute length of entity
  3413. var len = typeof entity === 'string'
  3414. ? Buffer.byteLength(entity, 'utf8')
  3415. : entity.length;
  3416. return '"' + len.toString(16) + '-' + hash + '"'
  3417. }
  3418. /**
  3419. * Create a simple ETag.
  3420. *
  3421. * @param {string|Buffer|Stats} entity
  3422. * @param {object} [options]
  3423. * @param {boolean} [options.weak]
  3424. * @return {String}
  3425. * @public
  3426. */
  3427. function etag (entity, options) {
  3428. if (entity == null) {
  3429. throw new TypeError('argument entity is required')
  3430. }
  3431. // support fs.Stats object
  3432. var isStats = isstats(entity);
  3433. var weak = options && typeof options.weak === 'boolean'
  3434. ? options.weak
  3435. : isStats;
  3436. // validate argument
  3437. if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
  3438. throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
  3439. }
  3440. // generate entity tag
  3441. var tag = isStats
  3442. ? stattag(entity)
  3443. : entitytag(entity);
  3444. return weak
  3445. ? 'W/' + tag
  3446. : tag
  3447. }
  3448. /**
  3449. * Determine if object is a Stats object.
  3450. *
  3451. * @param {object} obj
  3452. * @return {boolean}
  3453. * @api private
  3454. */
  3455. function isstats (obj) {
  3456. // genuine fs.Stats
  3457. if (typeof Stats === 'function' && obj instanceof Stats) {
  3458. return true
  3459. }
  3460. // quack quack
  3461. return obj && typeof obj === 'object' &&
  3462. 'ctime' in obj && toString$1.call(obj.ctime) === '[object Date]' &&
  3463. 'mtime' in obj && toString$1.call(obj.mtime) === '[object Date]' &&
  3464. 'ino' in obj && typeof obj.ino === 'number' &&
  3465. 'size' in obj && typeof obj.size === 'number'
  3466. }
  3467. /**
  3468. * Generate a tag for a stat.
  3469. *
  3470. * @param {object} stat
  3471. * @return {string}
  3472. * @private
  3473. */
  3474. function stattag (stat) {
  3475. var mtime = stat.mtime.getTime().toString(16);
  3476. var size = stat.size.toString(16);
  3477. return '"' + size + '-' + mtime + '"'
  3478. }
  3479. var getEtag = /*@__PURE__*/getDefaultExportFromCjs(etag_1);
  3480. class BitSet {
  3481. constructor(arg) {
  3482. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  3483. }
  3484. add(n) {
  3485. this.bits[n >> 5] |= 1 << (n & 31);
  3486. }
  3487. has(n) {
  3488. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  3489. }
  3490. }
  3491. class Chunk {
  3492. constructor(start, end, content) {
  3493. this.start = start;
  3494. this.end = end;
  3495. this.original = content;
  3496. this.intro = '';
  3497. this.outro = '';
  3498. this.content = content;
  3499. this.storeName = false;
  3500. this.edited = false;
  3501. {
  3502. this.previous = null;
  3503. this.next = null;
  3504. }
  3505. }
  3506. appendLeft(content) {
  3507. this.outro += content;
  3508. }
  3509. appendRight(content) {
  3510. this.intro = this.intro + content;
  3511. }
  3512. clone() {
  3513. const chunk = new Chunk(this.start, this.end, this.original);
  3514. chunk.intro = this.intro;
  3515. chunk.outro = this.outro;
  3516. chunk.content = this.content;
  3517. chunk.storeName = this.storeName;
  3518. chunk.edited = this.edited;
  3519. return chunk;
  3520. }
  3521. contains(index) {
  3522. return this.start < index && index < this.end;
  3523. }
  3524. eachNext(fn) {
  3525. let chunk = this;
  3526. while (chunk) {
  3527. fn(chunk);
  3528. chunk = chunk.next;
  3529. }
  3530. }
  3531. eachPrevious(fn) {
  3532. let chunk = this;
  3533. while (chunk) {
  3534. fn(chunk);
  3535. chunk = chunk.previous;
  3536. }
  3537. }
  3538. edit(content, storeName, contentOnly) {
  3539. this.content = content;
  3540. if (!contentOnly) {
  3541. this.intro = '';
  3542. this.outro = '';
  3543. }
  3544. this.storeName = storeName;
  3545. this.edited = true;
  3546. return this;
  3547. }
  3548. prependLeft(content) {
  3549. this.outro = content + this.outro;
  3550. }
  3551. prependRight(content) {
  3552. this.intro = content + this.intro;
  3553. }
  3554. reset() {
  3555. this.intro = '';
  3556. this.outro = '';
  3557. if (this.edited) {
  3558. this.content = this.original;
  3559. this.storeName = false;
  3560. this.edited = false;
  3561. }
  3562. }
  3563. split(index) {
  3564. const sliceIndex = index - this.start;
  3565. const originalBefore = this.original.slice(0, sliceIndex);
  3566. const originalAfter = this.original.slice(sliceIndex);
  3567. this.original = originalBefore;
  3568. const newChunk = new Chunk(index, this.end, originalAfter);
  3569. newChunk.outro = this.outro;
  3570. this.outro = '';
  3571. this.end = index;
  3572. if (this.edited) {
  3573. // after split we should save the edit content record into the correct chunk
  3574. // to make sure sourcemap correct
  3575. // For example:
  3576. // ' test'.trim()
  3577. // split -> ' ' + 'test'
  3578. // ✔️ edit -> '' + 'test'
  3579. // ✖️ edit -> 'test' + ''
  3580. // TODO is this block necessary?...
  3581. newChunk.edit('', false);
  3582. this.content = '';
  3583. } else {
  3584. this.content = originalBefore;
  3585. }
  3586. newChunk.next = this.next;
  3587. if (newChunk.next) newChunk.next.previous = newChunk;
  3588. newChunk.previous = this;
  3589. this.next = newChunk;
  3590. return newChunk;
  3591. }
  3592. toString() {
  3593. return this.intro + this.content + this.outro;
  3594. }
  3595. trimEnd(rx) {
  3596. this.outro = this.outro.replace(rx, '');
  3597. if (this.outro.length) return true;
  3598. const trimmed = this.content.replace(rx, '');
  3599. if (trimmed.length) {
  3600. if (trimmed !== this.content) {
  3601. this.split(this.start + trimmed.length).edit('', undefined, true);
  3602. if (this.edited) {
  3603. // save the change, if it has been edited
  3604. this.edit(trimmed, this.storeName, true);
  3605. }
  3606. }
  3607. return true;
  3608. } else {
  3609. this.edit('', undefined, true);
  3610. this.intro = this.intro.replace(rx, '');
  3611. if (this.intro.length) return true;
  3612. }
  3613. }
  3614. trimStart(rx) {
  3615. this.intro = this.intro.replace(rx, '');
  3616. if (this.intro.length) return true;
  3617. const trimmed = this.content.replace(rx, '');
  3618. if (trimmed.length) {
  3619. if (trimmed !== this.content) {
  3620. const newChunk = this.split(this.end - trimmed.length);
  3621. if (this.edited) {
  3622. // save the change, if it has been edited
  3623. newChunk.edit(trimmed, this.storeName, true);
  3624. }
  3625. this.edit('', undefined, true);
  3626. }
  3627. return true;
  3628. } else {
  3629. this.edit('', undefined, true);
  3630. this.outro = this.outro.replace(rx, '');
  3631. if (this.outro.length) return true;
  3632. }
  3633. }
  3634. }
  3635. function getBtoa() {
  3636. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  3637. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  3638. } else if (typeof Buffer === 'function') {
  3639. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  3640. } else {
  3641. return () => {
  3642. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  3643. };
  3644. }
  3645. }
  3646. const btoa$1 = /*#__PURE__*/ getBtoa();
  3647. class SourceMap {
  3648. constructor(properties) {
  3649. this.version = 3;
  3650. this.file = properties.file;
  3651. this.sources = properties.sources;
  3652. this.sourcesContent = properties.sourcesContent;
  3653. this.names = properties.names;
  3654. this.mappings = encode(properties.mappings);
  3655. if (typeof properties.x_google_ignoreList !== 'undefined') {
  3656. this.x_google_ignoreList = properties.x_google_ignoreList;
  3657. }
  3658. }
  3659. toString() {
  3660. return JSON.stringify(this);
  3661. }
  3662. toUrl() {
  3663. return 'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString());
  3664. }
  3665. }
  3666. function guessIndent(code) {
  3667. const lines = code.split('\n');
  3668. const tabbed = lines.filter((line) => /^\t+/.test(line));
  3669. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  3670. if (tabbed.length === 0 && spaced.length === 0) {
  3671. return null;
  3672. }
  3673. // More lines tabbed than spaced? Assume tabs, and
  3674. // default to tabs in the case of a tie (or nothing
  3675. // to go on)
  3676. if (tabbed.length >= spaced.length) {
  3677. return '\t';
  3678. }
  3679. // Otherwise, we need to guess the multiple
  3680. const min = spaced.reduce((previous, current) => {
  3681. const numSpaces = /^ +/.exec(current)[0].length;
  3682. return Math.min(numSpaces, previous);
  3683. }, Infinity);
  3684. return new Array(min + 1).join(' ');
  3685. }
  3686. function getRelativePath(from, to) {
  3687. const fromParts = from.split(/[/\\]/);
  3688. const toParts = to.split(/[/\\]/);
  3689. fromParts.pop(); // get dirname
  3690. while (fromParts[0] === toParts[0]) {
  3691. fromParts.shift();
  3692. toParts.shift();
  3693. }
  3694. if (fromParts.length) {
  3695. let i = fromParts.length;
  3696. while (i--) fromParts[i] = '..';
  3697. }
  3698. return fromParts.concat(toParts).join('/');
  3699. }
  3700. const toString = Object.prototype.toString;
  3701. function isObject(thing) {
  3702. return toString.call(thing) === '[object Object]';
  3703. }
  3704. function getLocator(source) {
  3705. const originalLines = source.split('\n');
  3706. const lineOffsets = [];
  3707. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  3708. lineOffsets.push(pos);
  3709. pos += originalLines[i].length + 1;
  3710. }
  3711. return function locate(index) {
  3712. let i = 0;
  3713. let j = lineOffsets.length;
  3714. while (i < j) {
  3715. const m = (i + j) >> 1;
  3716. if (index < lineOffsets[m]) {
  3717. j = m;
  3718. } else {
  3719. i = m + 1;
  3720. }
  3721. }
  3722. const line = i - 1;
  3723. const column = index - lineOffsets[line];
  3724. return { line, column };
  3725. };
  3726. }
  3727. const wordRegex = /\w/;
  3728. class Mappings {
  3729. constructor(hires) {
  3730. this.hires = hires;
  3731. this.generatedCodeLine = 0;
  3732. this.generatedCodeColumn = 0;
  3733. this.raw = [];
  3734. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  3735. this.pending = null;
  3736. }
  3737. addEdit(sourceIndex, content, loc, nameIndex) {
  3738. if (content.length) {
  3739. const contentLengthMinusOne = content.length - 1;
  3740. let contentLineEnd = content.indexOf('\n', 0);
  3741. let previousContentLineEnd = -1;
  3742. // Loop through each line in the content and add a segment, but stop if the last line is empty,
  3743. // else code afterwards would fill one line too many
  3744. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  3745. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  3746. if (nameIndex >= 0) {
  3747. segment.push(nameIndex);
  3748. }
  3749. this.rawSegments.push(segment);
  3750. this.generatedCodeLine += 1;
  3751. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  3752. this.generatedCodeColumn = 0;
  3753. previousContentLineEnd = contentLineEnd;
  3754. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  3755. }
  3756. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  3757. if (nameIndex >= 0) {
  3758. segment.push(nameIndex);
  3759. }
  3760. this.rawSegments.push(segment);
  3761. this.advance(content.slice(previousContentLineEnd + 1));
  3762. } else if (this.pending) {
  3763. this.rawSegments.push(this.pending);
  3764. this.advance(content);
  3765. }
  3766. this.pending = null;
  3767. }
  3768. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  3769. let originalCharIndex = chunk.start;
  3770. let first = true;
  3771. // when iterating each char, check if it's in a word boundary
  3772. let charInHiresBoundary = false;
  3773. while (originalCharIndex < chunk.end) {
  3774. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  3775. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  3776. if (this.hires === 'boundary') {
  3777. // in hires "boundary", group segments per word boundary than per char
  3778. if (wordRegex.test(original[originalCharIndex])) {
  3779. // for first char in the boundary found, start the boundary by pushing a segment
  3780. if (!charInHiresBoundary) {
  3781. this.rawSegments.push(segment);
  3782. charInHiresBoundary = true;
  3783. }
  3784. } else {
  3785. // for non-word char, end the boundary by pushing a segment
  3786. this.rawSegments.push(segment);
  3787. charInHiresBoundary = false;
  3788. }
  3789. } else {
  3790. this.rawSegments.push(segment);
  3791. }
  3792. }
  3793. if (original[originalCharIndex] === '\n') {
  3794. loc.line += 1;
  3795. loc.column = 0;
  3796. this.generatedCodeLine += 1;
  3797. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  3798. this.generatedCodeColumn = 0;
  3799. first = true;
  3800. } else {
  3801. loc.column += 1;
  3802. this.generatedCodeColumn += 1;
  3803. first = false;
  3804. }
  3805. originalCharIndex += 1;
  3806. }
  3807. this.pending = null;
  3808. }
  3809. advance(str) {
  3810. if (!str) return;
  3811. const lines = str.split('\n');
  3812. if (lines.length > 1) {
  3813. for (let i = 0; i < lines.length - 1; i++) {
  3814. this.generatedCodeLine++;
  3815. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  3816. }
  3817. this.generatedCodeColumn = 0;
  3818. }
  3819. this.generatedCodeColumn += lines[lines.length - 1].length;
  3820. }
  3821. }
  3822. const n = '\n';
  3823. const warned = {
  3824. insertLeft: false,
  3825. insertRight: false,
  3826. storeName: false,
  3827. };
  3828. class MagicString {
  3829. constructor(string, options = {}) {
  3830. const chunk = new Chunk(0, string.length, string);
  3831. Object.defineProperties(this, {
  3832. original: { writable: true, value: string },
  3833. outro: { writable: true, value: '' },
  3834. intro: { writable: true, value: '' },
  3835. firstChunk: { writable: true, value: chunk },
  3836. lastChunk: { writable: true, value: chunk },
  3837. lastSearchedChunk: { writable: true, value: chunk },
  3838. byStart: { writable: true, value: {} },
  3839. byEnd: { writable: true, value: {} },
  3840. filename: { writable: true, value: options.filename },
  3841. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  3842. sourcemapLocations: { writable: true, value: new BitSet() },
  3843. storedNames: { writable: true, value: {} },
  3844. indentStr: { writable: true, value: undefined },
  3845. ignoreList: { writable: true, value: options.ignoreList },
  3846. });
  3847. this.byStart[0] = chunk;
  3848. this.byEnd[string.length] = chunk;
  3849. }
  3850. addSourcemapLocation(char) {
  3851. this.sourcemapLocations.add(char);
  3852. }
  3853. append(content) {
  3854. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  3855. this.outro += content;
  3856. return this;
  3857. }
  3858. appendLeft(index, content) {
  3859. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  3860. this._split(index);
  3861. const chunk = this.byEnd[index];
  3862. if (chunk) {
  3863. chunk.appendLeft(content);
  3864. } else {
  3865. this.intro += content;
  3866. }
  3867. return this;
  3868. }
  3869. appendRight(index, content) {
  3870. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  3871. this._split(index);
  3872. const chunk = this.byStart[index];
  3873. if (chunk) {
  3874. chunk.appendRight(content);
  3875. } else {
  3876. this.outro += content;
  3877. }
  3878. return this;
  3879. }
  3880. clone() {
  3881. const cloned = new MagicString(this.original, { filename: this.filename });
  3882. let originalChunk = this.firstChunk;
  3883. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  3884. while (originalChunk) {
  3885. cloned.byStart[clonedChunk.start] = clonedChunk;
  3886. cloned.byEnd[clonedChunk.end] = clonedChunk;
  3887. const nextOriginalChunk = originalChunk.next;
  3888. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  3889. if (nextClonedChunk) {
  3890. clonedChunk.next = nextClonedChunk;
  3891. nextClonedChunk.previous = clonedChunk;
  3892. clonedChunk = nextClonedChunk;
  3893. }
  3894. originalChunk = nextOriginalChunk;
  3895. }
  3896. cloned.lastChunk = clonedChunk;
  3897. if (this.indentExclusionRanges) {
  3898. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  3899. }
  3900. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  3901. cloned.intro = this.intro;
  3902. cloned.outro = this.outro;
  3903. return cloned;
  3904. }
  3905. generateDecodedMap(options) {
  3906. options = options || {};
  3907. const sourceIndex = 0;
  3908. const names = Object.keys(this.storedNames);
  3909. const mappings = new Mappings(options.hires);
  3910. const locate = getLocator(this.original);
  3911. if (this.intro) {
  3912. mappings.advance(this.intro);
  3913. }
  3914. this.firstChunk.eachNext((chunk) => {
  3915. const loc = locate(chunk.start);
  3916. if (chunk.intro.length) mappings.advance(chunk.intro);
  3917. if (chunk.edited) {
  3918. mappings.addEdit(
  3919. sourceIndex,
  3920. chunk.content,
  3921. loc,
  3922. chunk.storeName ? names.indexOf(chunk.original) : -1,
  3923. );
  3924. } else {
  3925. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  3926. }
  3927. if (chunk.outro.length) mappings.advance(chunk.outro);
  3928. });
  3929. return {
  3930. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  3931. sources: [
  3932. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  3933. ],
  3934. sourcesContent: options.includeContent ? [this.original] : undefined,
  3935. names,
  3936. mappings: mappings.raw,
  3937. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  3938. };
  3939. }
  3940. generateMap(options) {
  3941. return new SourceMap(this.generateDecodedMap(options));
  3942. }
  3943. _ensureindentStr() {
  3944. if (this.indentStr === undefined) {
  3945. this.indentStr = guessIndent(this.original);
  3946. }
  3947. }
  3948. _getRawIndentString() {
  3949. this._ensureindentStr();
  3950. return this.indentStr;
  3951. }
  3952. getIndentString() {
  3953. this._ensureindentStr();
  3954. return this.indentStr === null ? '\t' : this.indentStr;
  3955. }
  3956. indent(indentStr, options) {
  3957. const pattern = /^[^\r\n]/gm;
  3958. if (isObject(indentStr)) {
  3959. options = indentStr;
  3960. indentStr = undefined;
  3961. }
  3962. if (indentStr === undefined) {
  3963. this._ensureindentStr();
  3964. indentStr = this.indentStr || '\t';
  3965. }
  3966. if (indentStr === '') return this; // noop
  3967. options = options || {};
  3968. // Process exclusion ranges
  3969. const isExcluded = {};
  3970. if (options.exclude) {
  3971. const exclusions =
  3972. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  3973. exclusions.forEach((exclusion) => {
  3974. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  3975. isExcluded[i] = true;
  3976. }
  3977. });
  3978. }
  3979. let shouldIndentNextCharacter = options.indentStart !== false;
  3980. const replacer = (match) => {
  3981. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  3982. shouldIndentNextCharacter = true;
  3983. return match;
  3984. };
  3985. this.intro = this.intro.replace(pattern, replacer);
  3986. let charIndex = 0;
  3987. let chunk = this.firstChunk;
  3988. while (chunk) {
  3989. const end = chunk.end;
  3990. if (chunk.edited) {
  3991. if (!isExcluded[charIndex]) {
  3992. chunk.content = chunk.content.replace(pattern, replacer);
  3993. if (chunk.content.length) {
  3994. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  3995. }
  3996. }
  3997. } else {
  3998. charIndex = chunk.start;
  3999. while (charIndex < end) {
  4000. if (!isExcluded[charIndex]) {
  4001. const char = this.original[charIndex];
  4002. if (char === '\n') {
  4003. shouldIndentNextCharacter = true;
  4004. } else if (char !== '\r' && shouldIndentNextCharacter) {
  4005. shouldIndentNextCharacter = false;
  4006. if (charIndex === chunk.start) {
  4007. chunk.prependRight(indentStr);
  4008. } else {
  4009. this._splitChunk(chunk, charIndex);
  4010. chunk = chunk.next;
  4011. chunk.prependRight(indentStr);
  4012. }
  4013. }
  4014. }
  4015. charIndex += 1;
  4016. }
  4017. }
  4018. charIndex = chunk.end;
  4019. chunk = chunk.next;
  4020. }
  4021. this.outro = this.outro.replace(pattern, replacer);
  4022. return this;
  4023. }
  4024. insert() {
  4025. throw new Error(
  4026. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  4027. );
  4028. }
  4029. insertLeft(index, content) {
  4030. if (!warned.insertLeft) {
  4031. console.warn(
  4032. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  4033. ); // eslint-disable-line no-console
  4034. warned.insertLeft = true;
  4035. }
  4036. return this.appendLeft(index, content);
  4037. }
  4038. insertRight(index, content) {
  4039. if (!warned.insertRight) {
  4040. console.warn(
  4041. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  4042. ); // eslint-disable-line no-console
  4043. warned.insertRight = true;
  4044. }
  4045. return this.prependRight(index, content);
  4046. }
  4047. move(start, end, index) {
  4048. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  4049. this._split(start);
  4050. this._split(end);
  4051. this._split(index);
  4052. const first = this.byStart[start];
  4053. const last = this.byEnd[end];
  4054. const oldLeft = first.previous;
  4055. const oldRight = last.next;
  4056. const newRight = this.byStart[index];
  4057. if (!newRight && last === this.lastChunk) return this;
  4058. const newLeft = newRight ? newRight.previous : this.lastChunk;
  4059. if (oldLeft) oldLeft.next = oldRight;
  4060. if (oldRight) oldRight.previous = oldLeft;
  4061. if (newLeft) newLeft.next = first;
  4062. if (newRight) newRight.previous = last;
  4063. if (!first.previous) this.firstChunk = last.next;
  4064. if (!last.next) {
  4065. this.lastChunk = first.previous;
  4066. this.lastChunk.next = null;
  4067. }
  4068. first.previous = newLeft;
  4069. last.next = newRight || null;
  4070. if (!newLeft) this.firstChunk = first;
  4071. if (!newRight) this.lastChunk = last;
  4072. return this;
  4073. }
  4074. overwrite(start, end, content, options) {
  4075. options = options || {};
  4076. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  4077. }
  4078. update(start, end, content, options) {
  4079. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  4080. if (this.original.length !== 0) {
  4081. while (start < 0) start += this.original.length;
  4082. while (end < 0) end += this.original.length;
  4083. }
  4084. if (end > this.original.length) throw new Error('end is out of bounds');
  4085. if (start === end)
  4086. throw new Error(
  4087. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  4088. );
  4089. this._split(start);
  4090. this._split(end);
  4091. if (options === true) {
  4092. if (!warned.storeName) {
  4093. console.warn(
  4094. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  4095. ); // eslint-disable-line no-console
  4096. warned.storeName = true;
  4097. }
  4098. options = { storeName: true };
  4099. }
  4100. const storeName = options !== undefined ? options.storeName : false;
  4101. const overwrite = options !== undefined ? options.overwrite : false;
  4102. if (storeName) {
  4103. const original = this.original.slice(start, end);
  4104. Object.defineProperty(this.storedNames, original, {
  4105. writable: true,
  4106. value: true,
  4107. enumerable: true,
  4108. });
  4109. }
  4110. const first = this.byStart[start];
  4111. const last = this.byEnd[end];
  4112. if (first) {
  4113. let chunk = first;
  4114. while (chunk !== last) {
  4115. if (chunk.next !== this.byStart[chunk.end]) {
  4116. throw new Error('Cannot overwrite across a split point');
  4117. }
  4118. chunk = chunk.next;
  4119. chunk.edit('', false);
  4120. }
  4121. first.edit(content, storeName, !overwrite);
  4122. } else {
  4123. // must be inserting at the end
  4124. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  4125. // TODO last chunk in the array may not be the last chunk, if it's moved...
  4126. last.next = newChunk;
  4127. newChunk.previous = last;
  4128. }
  4129. return this;
  4130. }
  4131. prepend(content) {
  4132. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  4133. this.intro = content + this.intro;
  4134. return this;
  4135. }
  4136. prependLeft(index, content) {
  4137. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  4138. this._split(index);
  4139. const chunk = this.byEnd[index];
  4140. if (chunk) {
  4141. chunk.prependLeft(content);
  4142. } else {
  4143. this.intro = content + this.intro;
  4144. }
  4145. return this;
  4146. }
  4147. prependRight(index, content) {
  4148. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  4149. this._split(index);
  4150. const chunk = this.byStart[index];
  4151. if (chunk) {
  4152. chunk.prependRight(content);
  4153. } else {
  4154. this.outro = content + this.outro;
  4155. }
  4156. return this;
  4157. }
  4158. remove(start, end) {
  4159. if (this.original.length !== 0) {
  4160. while (start < 0) start += this.original.length;
  4161. while (end < 0) end += this.original.length;
  4162. }
  4163. if (start === end) return this;
  4164. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  4165. if (start > end) throw new Error('end must be greater than start');
  4166. this._split(start);
  4167. this._split(end);
  4168. let chunk = this.byStart[start];
  4169. while (chunk) {
  4170. chunk.intro = '';
  4171. chunk.outro = '';
  4172. chunk.edit('');
  4173. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  4174. }
  4175. return this;
  4176. }
  4177. reset(start, end) {
  4178. if (this.original.length !== 0) {
  4179. while (start < 0) start += this.original.length;
  4180. while (end < 0) end += this.original.length;
  4181. }
  4182. if (start === end) return this;
  4183. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  4184. if (start > end) throw new Error('end must be greater than start');
  4185. this._split(start);
  4186. this._split(end);
  4187. let chunk = this.byStart[start];
  4188. while (chunk) {
  4189. chunk.reset();
  4190. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  4191. }
  4192. return this;
  4193. }
  4194. lastChar() {
  4195. if (this.outro.length) return this.outro[this.outro.length - 1];
  4196. let chunk = this.lastChunk;
  4197. do {
  4198. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  4199. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  4200. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  4201. } while ((chunk = chunk.previous));
  4202. if (this.intro.length) return this.intro[this.intro.length - 1];
  4203. return '';
  4204. }
  4205. lastLine() {
  4206. let lineIndex = this.outro.lastIndexOf(n);
  4207. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  4208. let lineStr = this.outro;
  4209. let chunk = this.lastChunk;
  4210. do {
  4211. if (chunk.outro.length > 0) {
  4212. lineIndex = chunk.outro.lastIndexOf(n);
  4213. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  4214. lineStr = chunk.outro + lineStr;
  4215. }
  4216. if (chunk.content.length > 0) {
  4217. lineIndex = chunk.content.lastIndexOf(n);
  4218. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  4219. lineStr = chunk.content + lineStr;
  4220. }
  4221. if (chunk.intro.length > 0) {
  4222. lineIndex = chunk.intro.lastIndexOf(n);
  4223. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  4224. lineStr = chunk.intro + lineStr;
  4225. }
  4226. } while ((chunk = chunk.previous));
  4227. lineIndex = this.intro.lastIndexOf(n);
  4228. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  4229. return this.intro + lineStr;
  4230. }
  4231. slice(start = 0, end = this.original.length) {
  4232. if (this.original.length !== 0) {
  4233. while (start < 0) start += this.original.length;
  4234. while (end < 0) end += this.original.length;
  4235. }
  4236. let result = '';
  4237. // find start chunk
  4238. let chunk = this.firstChunk;
  4239. while (chunk && (chunk.start > start || chunk.end <= start)) {
  4240. // found end chunk before start
  4241. if (chunk.start < end && chunk.end >= end) {
  4242. return result;
  4243. }
  4244. chunk = chunk.next;
  4245. }
  4246. if (chunk && chunk.edited && chunk.start !== start)
  4247. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  4248. const startChunk = chunk;
  4249. while (chunk) {
  4250. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  4251. result += chunk.intro;
  4252. }
  4253. const containsEnd = chunk.start < end && chunk.end >= end;
  4254. if (containsEnd && chunk.edited && chunk.end !== end)
  4255. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  4256. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  4257. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  4258. result += chunk.content.slice(sliceStart, sliceEnd);
  4259. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  4260. result += chunk.outro;
  4261. }
  4262. if (containsEnd) {
  4263. break;
  4264. }
  4265. chunk = chunk.next;
  4266. }
  4267. return result;
  4268. }
  4269. // TODO deprecate this? not really very useful
  4270. snip(start, end) {
  4271. const clone = this.clone();
  4272. clone.remove(0, start);
  4273. clone.remove(end, clone.original.length);
  4274. return clone;
  4275. }
  4276. _split(index) {
  4277. if (this.byStart[index] || this.byEnd[index]) return;
  4278. let chunk = this.lastSearchedChunk;
  4279. const searchForward = index > chunk.end;
  4280. while (chunk) {
  4281. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  4282. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  4283. }
  4284. }
  4285. _splitChunk(chunk, index) {
  4286. if (chunk.edited && chunk.content.length) {
  4287. // zero-length edited chunks are a special case (overlapping replacements)
  4288. const loc = getLocator(this.original)(index);
  4289. throw new Error(
  4290. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  4291. );
  4292. }
  4293. const newChunk = chunk.split(index);
  4294. this.byEnd[index] = chunk;
  4295. this.byStart[index] = newChunk;
  4296. this.byEnd[newChunk.end] = newChunk;
  4297. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  4298. this.lastSearchedChunk = chunk;
  4299. return true;
  4300. }
  4301. toString() {
  4302. let str = this.intro;
  4303. let chunk = this.firstChunk;
  4304. while (chunk) {
  4305. str += chunk.toString();
  4306. chunk = chunk.next;
  4307. }
  4308. return str + this.outro;
  4309. }
  4310. isEmpty() {
  4311. let chunk = this.firstChunk;
  4312. do {
  4313. if (
  4314. (chunk.intro.length && chunk.intro.trim()) ||
  4315. (chunk.content.length && chunk.content.trim()) ||
  4316. (chunk.outro.length && chunk.outro.trim())
  4317. )
  4318. return false;
  4319. } while ((chunk = chunk.next));
  4320. return true;
  4321. }
  4322. length() {
  4323. let chunk = this.firstChunk;
  4324. let length = 0;
  4325. do {
  4326. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  4327. } while ((chunk = chunk.next));
  4328. return length;
  4329. }
  4330. trimLines() {
  4331. return this.trim('[\\r\\n]');
  4332. }
  4333. trim(charType) {
  4334. return this.trimStart(charType).trimEnd(charType);
  4335. }
  4336. trimEndAborted(charType) {
  4337. const rx = new RegExp((charType || '\\s') + '+$');
  4338. this.outro = this.outro.replace(rx, '');
  4339. if (this.outro.length) return true;
  4340. let chunk = this.lastChunk;
  4341. do {
  4342. const end = chunk.end;
  4343. const aborted = chunk.trimEnd(rx);
  4344. // if chunk was trimmed, we have a new lastChunk
  4345. if (chunk.end !== end) {
  4346. if (this.lastChunk === chunk) {
  4347. this.lastChunk = chunk.next;
  4348. }
  4349. this.byEnd[chunk.end] = chunk;
  4350. this.byStart[chunk.next.start] = chunk.next;
  4351. this.byEnd[chunk.next.end] = chunk.next;
  4352. }
  4353. if (aborted) return true;
  4354. chunk = chunk.previous;
  4355. } while (chunk);
  4356. return false;
  4357. }
  4358. trimEnd(charType) {
  4359. this.trimEndAborted(charType);
  4360. return this;
  4361. }
  4362. trimStartAborted(charType) {
  4363. const rx = new RegExp('^' + (charType || '\\s') + '+');
  4364. this.intro = this.intro.replace(rx, '');
  4365. if (this.intro.length) return true;
  4366. let chunk = this.firstChunk;
  4367. do {
  4368. const end = chunk.end;
  4369. const aborted = chunk.trimStart(rx);
  4370. if (chunk.end !== end) {
  4371. // special case...
  4372. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  4373. this.byEnd[chunk.end] = chunk;
  4374. this.byStart[chunk.next.start] = chunk.next;
  4375. this.byEnd[chunk.next.end] = chunk.next;
  4376. }
  4377. if (aborted) return true;
  4378. chunk = chunk.next;
  4379. } while (chunk);
  4380. return false;
  4381. }
  4382. trimStart(charType) {
  4383. this.trimStartAborted(charType);
  4384. return this;
  4385. }
  4386. hasChanged() {
  4387. return this.original !== this.toString();
  4388. }
  4389. _replaceRegexp(searchValue, replacement) {
  4390. function getReplacement(match, str) {
  4391. if (typeof replacement === 'string') {
  4392. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  4393. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  4394. if (i === '$') return '$';
  4395. if (i === '&') return match[0];
  4396. const num = +i;
  4397. if (num < match.length) return match[+i];
  4398. return `$${i}`;
  4399. });
  4400. } else {
  4401. return replacement(...match, match.index, str, match.groups);
  4402. }
  4403. }
  4404. function matchAll(re, str) {
  4405. let match;
  4406. const matches = [];
  4407. while ((match = re.exec(str))) {
  4408. matches.push(match);
  4409. }
  4410. return matches;
  4411. }
  4412. if (searchValue.global) {
  4413. const matches = matchAll(searchValue, this.original);
  4414. matches.forEach((match) => {
  4415. if (match.index != null) {
  4416. const replacement = getReplacement(match, this.original);
  4417. if (replacement !== match[0]) {
  4418. this.overwrite(
  4419. match.index,
  4420. match.index + match[0].length,
  4421. replacement
  4422. );
  4423. }
  4424. }
  4425. });
  4426. } else {
  4427. const match = this.original.match(searchValue);
  4428. if (match && match.index != null) {
  4429. const replacement = getReplacement(match, this.original);
  4430. if (replacement !== match[0]) {
  4431. this.overwrite(
  4432. match.index,
  4433. match.index + match[0].length,
  4434. replacement
  4435. );
  4436. }
  4437. }
  4438. }
  4439. return this;
  4440. }
  4441. _replaceString(string, replacement) {
  4442. const { original } = this;
  4443. const index = original.indexOf(string);
  4444. if (index !== -1) {
  4445. this.overwrite(index, index + string.length, replacement);
  4446. }
  4447. return this;
  4448. }
  4449. replace(searchValue, replacement) {
  4450. if (typeof searchValue === 'string') {
  4451. return this._replaceString(searchValue, replacement);
  4452. }
  4453. return this._replaceRegexp(searchValue, replacement);
  4454. }
  4455. _replaceAllString(string, replacement) {
  4456. const { original } = this;
  4457. const stringLength = string.length;
  4458. for (
  4459. let index = original.indexOf(string);
  4460. index !== -1;
  4461. index = original.indexOf(string, index + stringLength)
  4462. ) {
  4463. const previous = original.slice(index, index + stringLength);
  4464. if (previous !== replacement)
  4465. this.overwrite(index, index + stringLength, replacement);
  4466. }
  4467. return this;
  4468. }
  4469. replaceAll(searchValue, replacement) {
  4470. if (typeof searchValue === 'string') {
  4471. return this._replaceAllString(searchValue, replacement);
  4472. }
  4473. if (!searchValue.global) {
  4474. throw new TypeError(
  4475. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  4476. );
  4477. }
  4478. return this._replaceRegexp(searchValue, replacement);
  4479. }
  4480. }
  4481. const debug$1 = createDebugger("vite:sourcemap", {
  4482. onlyWhenFocused: true
  4483. });
  4484. function genSourceMapUrl(map) {
  4485. if (typeof map !== "string") {
  4486. map = JSON.stringify(map);
  4487. }
  4488. return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
  4489. }
  4490. function getCodeWithSourcemap(type, code, map) {
  4491. if (debug$1) {
  4492. code += `
  4493. /*${JSON.stringify(map, null, 2).replace(/\*\//g, "*\\/")}*/
  4494. `;
  4495. }
  4496. if (type === "js") {
  4497. code += `
  4498. //# sourceMappingURL=${genSourceMapUrl(map)}`;
  4499. } else if (type === "css") {
  4500. code += `
  4501. /*# sourceMappingURL=${genSourceMapUrl(map)} */`;
  4502. }
  4503. return code;
  4504. }
  4505. const debug = createDebugger("vite:send", {
  4506. onlyWhenFocused: true
  4507. });
  4508. const alias = {
  4509. js: "text/javascript",
  4510. css: "text/css",
  4511. html: "text/html",
  4512. json: "application/json"
  4513. };
  4514. function send(req, res, content, type, options) {
  4515. const {
  4516. etag = getEtag(content, { weak: true }),
  4517. cacheControl = "no-cache",
  4518. headers,
  4519. map
  4520. } = options;
  4521. if (res.writableEnded) {
  4522. return;
  4523. }
  4524. if (req.headers["if-none-match"] === etag) {
  4525. res.statusCode = 304;
  4526. res.end();
  4527. return;
  4528. }
  4529. res.setHeader("Content-Type", alias[type] || type);
  4530. res.setHeader("Cache-Control", cacheControl);
  4531. res.setHeader("Etag", etag);
  4532. if (headers) {
  4533. for (const name in headers) {
  4534. res.setHeader(name, headers[name]);
  4535. }
  4536. }
  4537. if (map && "version" in map && map.mappings) {
  4538. if (type === "js" || type === "css") {
  4539. content = getCodeWithSourcemap(type, content.toString(), map);
  4540. }
  4541. } else if (type === "js" && (!map || map.mappings !== "")) {
  4542. const code = content.toString();
  4543. if (convertSourceMap.mapFileCommentRegex.test(code)) {
  4544. debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
  4545. } else {
  4546. const urlWithoutTimestamp = removeTimestampQuery(req.url);
  4547. const ms = new MagicString(code);
  4548. content = getCodeWithSourcemap(
  4549. type,
  4550. code,
  4551. ms.generateMap({
  4552. source: path$3.basename(urlWithoutTimestamp),
  4553. hires: "boundary",
  4554. includeContent: true
  4555. })
  4556. );
  4557. }
  4558. }
  4559. res.statusCode = 200;
  4560. res.end(content);
  4561. return;
  4562. }
  4563. const LogLevels = {
  4564. silent: 0,
  4565. error: 1,
  4566. warn: 2,
  4567. info: 3
  4568. };
  4569. let lastType;
  4570. let lastMsg;
  4571. let sameCount = 0;
  4572. function clearScreen() {
  4573. const repeatCount = process.stdout.rows - 2;
  4574. const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
  4575. console.log(blank);
  4576. readline.cursorTo(process.stdout, 0, 0);
  4577. readline.clearScreenDown(process.stdout);
  4578. }
  4579. let timeFormatter;
  4580. function getTimeFormatter() {
  4581. timeFormatter ??= new Intl.DateTimeFormat(void 0, {
  4582. hour: "numeric",
  4583. minute: "numeric",
  4584. second: "numeric"
  4585. });
  4586. return timeFormatter;
  4587. }
  4588. function createLogger(level = "info", options = {}) {
  4589. if (options.customLogger) {
  4590. return options.customLogger;
  4591. }
  4592. const loggedErrors = /* @__PURE__ */ new WeakSet();
  4593. const { prefix = "[vite]", allowClearScreen = true } = options;
  4594. const thresh = LogLevels[level];
  4595. const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
  4596. const clear = canClearScreen ? clearScreen : () => {
  4597. };
  4598. function format(type, msg, options2 = {}) {
  4599. if (options2.timestamp) {
  4600. let tag = "";
  4601. if (type === "info") {
  4602. tag = colors.cyan(colors.bold(prefix));
  4603. } else if (type === "warn") {
  4604. tag = colors.yellow(colors.bold(prefix));
  4605. } else {
  4606. tag = colors.red(colors.bold(prefix));
  4607. }
  4608. return `${colors.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${msg}`;
  4609. } else {
  4610. return msg;
  4611. }
  4612. }
  4613. function output(type, msg, options2 = {}) {
  4614. if (thresh >= LogLevels[type]) {
  4615. const method = type === "info" ? "log" : type;
  4616. if (options2.error) {
  4617. loggedErrors.add(options2.error);
  4618. }
  4619. if (canClearScreen) {
  4620. if (type === lastType && msg === lastMsg) {
  4621. sameCount++;
  4622. clear();
  4623. console[method](
  4624. format(type, msg, options2),
  4625. colors.yellow(`(x${sameCount + 1})`)
  4626. );
  4627. } else {
  4628. sameCount = 0;
  4629. lastMsg = msg;
  4630. lastType = type;
  4631. if (options2.clear) {
  4632. clear();
  4633. }
  4634. console[method](format(type, msg, options2));
  4635. }
  4636. } else {
  4637. console[method](format(type, msg, options2));
  4638. }
  4639. }
  4640. }
  4641. const warnedMessages = /* @__PURE__ */ new Set();
  4642. const logger = {
  4643. hasWarned: false,
  4644. info(msg, opts) {
  4645. output("info", msg, opts);
  4646. },
  4647. warn(msg, opts) {
  4648. logger.hasWarned = true;
  4649. output("warn", msg, opts);
  4650. },
  4651. warnOnce(msg, opts) {
  4652. if (warnedMessages.has(msg)) return;
  4653. logger.hasWarned = true;
  4654. output("warn", msg, opts);
  4655. warnedMessages.add(msg);
  4656. },
  4657. error(msg, opts) {
  4658. logger.hasWarned = true;
  4659. output("error", msg, opts);
  4660. },
  4661. clearScreen(type) {
  4662. if (thresh >= LogLevels[type]) {
  4663. clear();
  4664. }
  4665. },
  4666. hasErrorLogged(error) {
  4667. return loggedErrors.has(error);
  4668. }
  4669. };
  4670. return logger;
  4671. }
  4672. const ROOT_FILES = [
  4673. // '.git',
  4674. // https://pnpm.io/workspaces/
  4675. "pnpm-workspace.yaml",
  4676. // https://rushjs.io/pages/advanced/config_files/
  4677. // 'rush.json',
  4678. // https://nx.dev/latest/react/getting-started/nx-setup
  4679. // 'workspace.json',
  4680. // 'nx.json',
  4681. // https://github.com/lerna/lerna#lernajson
  4682. "lerna.json"
  4683. ];
  4684. function hasWorkspacePackageJSON(root) {
  4685. const path = path$3.join(root, "package.json");
  4686. if (!isFileReadable(path)) {
  4687. return false;
  4688. }
  4689. try {
  4690. const content = JSON.parse(fs$1.readFileSync(path, "utf-8")) || {};
  4691. return !!content.workspaces;
  4692. } catch {
  4693. return false;
  4694. }
  4695. }
  4696. function hasRootFile(root) {
  4697. return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
  4698. }
  4699. function hasPackageJSON(root) {
  4700. const path = path$3.join(root, "package.json");
  4701. return fs$1.existsSync(path);
  4702. }
  4703. function searchForPackageRoot(current, root = current) {
  4704. if (hasPackageJSON(current)) return current;
  4705. const dir = path$3.dirname(current);
  4706. if (!dir || dir === current) return root;
  4707. return searchForPackageRoot(dir, root);
  4708. }
  4709. function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
  4710. if (hasRootFile(current)) return current;
  4711. if (hasWorkspacePackageJSON(current)) return current;
  4712. const dir = path$3.dirname(current);
  4713. if (!dir || dir === current) return root;
  4714. return searchForWorkspaceRoot(dir, root);
  4715. }
  4716. function isFileServingAllowed(url, server) {
  4717. if (!server.config.server.fs.strict) return true;
  4718. const file = fsPathFromUrl(url);
  4719. if (server._fsDenyGlob(file)) return false;
  4720. if (server.moduleGraph.safeModulesPath.has(file)) return true;
  4721. if (server.config.server.fs.allow.some(
  4722. (uri) => isSameFileUri(uri, file) || isParentDirectory(uri, file)
  4723. ))
  4724. return true;
  4725. return false;
  4726. }
  4727. var main$1 = {exports: {}};
  4728. var name = "dotenv";
  4729. var version$1 = "16.4.5";
  4730. var description = "Loads environment variables from .env file";
  4731. var main = "lib/main.js";
  4732. var types = "lib/main.d.ts";
  4733. var exports$1 = {
  4734. ".": {
  4735. types: "./lib/main.d.ts",
  4736. require: "./lib/main.js",
  4737. "default": "./lib/main.js"
  4738. },
  4739. "./config": "./config.js",
  4740. "./config.js": "./config.js",
  4741. "./lib/env-options": "./lib/env-options.js",
  4742. "./lib/env-options.js": "./lib/env-options.js",
  4743. "./lib/cli-options": "./lib/cli-options.js",
  4744. "./lib/cli-options.js": "./lib/cli-options.js",
  4745. "./package.json": "./package.json"
  4746. };
  4747. var scripts = {
  4748. "dts-check": "tsc --project tests/types/tsconfig.json",
  4749. lint: "standard",
  4750. "lint-readme": "standard-markdown",
  4751. pretest: "npm run lint && npm run dts-check",
  4752. test: "tap tests/*.js --100 -Rspec",
  4753. "test:coverage": "tap --coverage-report=lcov",
  4754. prerelease: "npm test",
  4755. release: "standard-version"
  4756. };
  4757. var repository = {
  4758. type: "git",
  4759. url: "git://github.com/motdotla/dotenv.git"
  4760. };
  4761. var funding = "https://dotenvx.com";
  4762. var keywords = [
  4763. "dotenv",
  4764. "env",
  4765. ".env",
  4766. "environment",
  4767. "variables",
  4768. "config",
  4769. "settings"
  4770. ];
  4771. var readmeFilename = "README.md";
  4772. var license = "BSD-2-Clause";
  4773. var devDependencies = {
  4774. "@definitelytyped/dtslint": "^0.0.133",
  4775. "@types/node": "^18.11.3",
  4776. decache: "^4.6.1",
  4777. sinon: "^14.0.1",
  4778. standard: "^17.0.0",
  4779. "standard-markdown": "^7.1.0",
  4780. "standard-version": "^9.5.0",
  4781. tap: "^16.3.0",
  4782. tar: "^6.1.11",
  4783. typescript: "^4.8.4"
  4784. };
  4785. var engines = {
  4786. node: ">=12"
  4787. };
  4788. var browser = {
  4789. fs: false
  4790. };
  4791. var require$$4 = {
  4792. name: name,
  4793. version: version$1,
  4794. description: description,
  4795. main: main,
  4796. types: types,
  4797. exports: exports$1,
  4798. scripts: scripts,
  4799. repository: repository,
  4800. funding: funding,
  4801. keywords: keywords,
  4802. readmeFilename: readmeFilename,
  4803. license: license,
  4804. devDependencies: devDependencies,
  4805. engines: engines,
  4806. browser: browser
  4807. };
  4808. const fs = fs$2;
  4809. const path = require$$0$1;
  4810. const os = require$$2;
  4811. const crypto = require$$0$2;
  4812. const packageJson = require$$4;
  4813. const version = packageJson.version;
  4814. const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
  4815. // Parse src into an Object
  4816. function parse (src) {
  4817. const obj = {};
  4818. // Convert buffer to string
  4819. let lines = src.toString();
  4820. // Convert line breaks to same format
  4821. lines = lines.replace(/\r\n?/mg, '\n');
  4822. let match;
  4823. while ((match = LINE.exec(lines)) != null) {
  4824. const key = match[1];
  4825. // Default undefined or null to empty string
  4826. let value = (match[2] || '');
  4827. // Remove whitespace
  4828. value = value.trim();
  4829. // Check if double quoted
  4830. const maybeQuote = value[0];
  4831. // Remove surrounding quotes
  4832. value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
  4833. // Expand newlines if double quoted
  4834. if (maybeQuote === '"') {
  4835. value = value.replace(/\\n/g, '\n');
  4836. value = value.replace(/\\r/g, '\r');
  4837. }
  4838. // Add to object
  4839. obj[key] = value;
  4840. }
  4841. return obj
  4842. }
  4843. function _parseVault (options) {
  4844. const vaultPath = _vaultPath(options);
  4845. // Parse .env.vault
  4846. const result = DotenvModule.configDotenv({ path: vaultPath });
  4847. if (!result.parsed) {
  4848. const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
  4849. err.code = 'MISSING_DATA';
  4850. throw err
  4851. }
  4852. // handle scenario for comma separated keys - for use with key rotation
  4853. // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
  4854. const keys = _dotenvKey(options).split(',');
  4855. const length = keys.length;
  4856. let decrypted;
  4857. for (let i = 0; i < length; i++) {
  4858. try {
  4859. // Get full key
  4860. const key = keys[i].trim();
  4861. // Get instructions for decrypt
  4862. const attrs = _instructions(result, key);
  4863. // Decrypt
  4864. decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
  4865. break
  4866. } catch (error) {
  4867. // last key
  4868. if (i + 1 >= length) {
  4869. throw error
  4870. }
  4871. // try next key
  4872. }
  4873. }
  4874. // Parse decrypted .env string
  4875. return DotenvModule.parse(decrypted)
  4876. }
  4877. function _log (message) {
  4878. console.log(`[dotenv@${version}][INFO] ${message}`);
  4879. }
  4880. function _warn (message) {
  4881. console.log(`[dotenv@${version}][WARN] ${message}`);
  4882. }
  4883. function _debug (message) {
  4884. console.log(`[dotenv@${version}][DEBUG] ${message}`);
  4885. }
  4886. function _dotenvKey (options) {
  4887. // prioritize developer directly setting options.DOTENV_KEY
  4888. if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
  4889. return options.DOTENV_KEY
  4890. }
  4891. // secondary infra already contains a DOTENV_KEY environment variable
  4892. if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
  4893. return process.env.DOTENV_KEY
  4894. }
  4895. // fallback to empty string
  4896. return ''
  4897. }
  4898. function _instructions (result, dotenvKey) {
  4899. // Parse DOTENV_KEY. Format is a URI
  4900. let uri;
  4901. try {
  4902. uri = new URL(dotenvKey);
  4903. } catch (error) {
  4904. if (error.code === 'ERR_INVALID_URL') {
  4905. const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development');
  4906. err.code = 'INVALID_DOTENV_KEY';
  4907. throw err
  4908. }
  4909. throw error
  4910. }
  4911. // Get decrypt key
  4912. const key = uri.password;
  4913. if (!key) {
  4914. const err = new Error('INVALID_DOTENV_KEY: Missing key part');
  4915. err.code = 'INVALID_DOTENV_KEY';
  4916. throw err
  4917. }
  4918. // Get environment
  4919. const environment = uri.searchParams.get('environment');
  4920. if (!environment) {
  4921. const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
  4922. err.code = 'INVALID_DOTENV_KEY';
  4923. throw err
  4924. }
  4925. // Get ciphertext payload
  4926. const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
  4927. const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
  4928. if (!ciphertext) {
  4929. const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
  4930. err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
  4931. throw err
  4932. }
  4933. return { ciphertext, key }
  4934. }
  4935. function _vaultPath (options) {
  4936. let possibleVaultPath = null;
  4937. if (options && options.path && options.path.length > 0) {
  4938. if (Array.isArray(options.path)) {
  4939. for (const filepath of options.path) {
  4940. if (fs.existsSync(filepath)) {
  4941. possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
  4942. }
  4943. }
  4944. } else {
  4945. possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
  4946. }
  4947. } else {
  4948. possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
  4949. }
  4950. if (fs.existsSync(possibleVaultPath)) {
  4951. return possibleVaultPath
  4952. }
  4953. return null
  4954. }
  4955. function _resolveHome (envPath) {
  4956. return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
  4957. }
  4958. function _configVault (options) {
  4959. _log('Loading env from encrypted .env.vault');
  4960. const parsed = DotenvModule._parseVault(options);
  4961. let processEnv = process.env;
  4962. if (options && options.processEnv != null) {
  4963. processEnv = options.processEnv;
  4964. }
  4965. DotenvModule.populate(processEnv, parsed, options);
  4966. return { parsed }
  4967. }
  4968. function configDotenv (options) {
  4969. const dotenvPath = path.resolve(process.cwd(), '.env');
  4970. let encoding = 'utf8';
  4971. const debug = Boolean(options && options.debug);
  4972. if (options && options.encoding) {
  4973. encoding = options.encoding;
  4974. } else {
  4975. if (debug) {
  4976. _debug('No encoding is specified. UTF-8 is used by default');
  4977. }
  4978. }
  4979. let optionPaths = [dotenvPath]; // default, look for .env
  4980. if (options && options.path) {
  4981. if (!Array.isArray(options.path)) {
  4982. optionPaths = [_resolveHome(options.path)];
  4983. } else {
  4984. optionPaths = []; // reset default
  4985. for (const filepath of options.path) {
  4986. optionPaths.push(_resolveHome(filepath));
  4987. }
  4988. }
  4989. }
  4990. // Build the parsed data in a temporary object (because we need to return it). Once we have the final
  4991. // parsed data, we will combine it with process.env (or options.processEnv if provided).
  4992. let lastError;
  4993. const parsedAll = {};
  4994. for (const path of optionPaths) {
  4995. try {
  4996. // Specifying an encoding returns a string instead of a buffer
  4997. const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
  4998. DotenvModule.populate(parsedAll, parsed, options);
  4999. } catch (e) {
  5000. if (debug) {
  5001. _debug(`Failed to load ${path} ${e.message}`);
  5002. }
  5003. lastError = e;
  5004. }
  5005. }
  5006. let processEnv = process.env;
  5007. if (options && options.processEnv != null) {
  5008. processEnv = options.processEnv;
  5009. }
  5010. DotenvModule.populate(processEnv, parsedAll, options);
  5011. if (lastError) {
  5012. return { parsed: parsedAll, error: lastError }
  5013. } else {
  5014. return { parsed: parsedAll }
  5015. }
  5016. }
  5017. // Populates process.env from .env file
  5018. function config (options) {
  5019. // fallback to original dotenv if DOTENV_KEY is not set
  5020. if (_dotenvKey(options).length === 0) {
  5021. return DotenvModule.configDotenv(options)
  5022. }
  5023. const vaultPath = _vaultPath(options);
  5024. // dotenvKey exists but .env.vault file does not exist
  5025. if (!vaultPath) {
  5026. _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
  5027. return DotenvModule.configDotenv(options)
  5028. }
  5029. return DotenvModule._configVault(options)
  5030. }
  5031. function decrypt (encrypted, keyStr) {
  5032. const key = Buffer.from(keyStr.slice(-64), 'hex');
  5033. let ciphertext = Buffer.from(encrypted, 'base64');
  5034. const nonce = ciphertext.subarray(0, 12);
  5035. const authTag = ciphertext.subarray(-16);
  5036. ciphertext = ciphertext.subarray(12, -16);
  5037. try {
  5038. const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
  5039. aesgcm.setAuthTag(authTag);
  5040. return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
  5041. } catch (error) {
  5042. const isRange = error instanceof RangeError;
  5043. const invalidKeyLength = error.message === 'Invalid key length';
  5044. const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
  5045. if (isRange || invalidKeyLength) {
  5046. const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
  5047. err.code = 'INVALID_DOTENV_KEY';
  5048. throw err
  5049. } else if (decryptionFailed) {
  5050. const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
  5051. err.code = 'DECRYPTION_FAILED';
  5052. throw err
  5053. } else {
  5054. throw error
  5055. }
  5056. }
  5057. }
  5058. // Populate process.env with parsed values
  5059. function populate (processEnv, parsed, options = {}) {
  5060. const debug = Boolean(options && options.debug);
  5061. const override = Boolean(options && options.override);
  5062. if (typeof parsed !== 'object') {
  5063. const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
  5064. err.code = 'OBJECT_REQUIRED';
  5065. throw err
  5066. }
  5067. // Set process.env
  5068. for (const key of Object.keys(parsed)) {
  5069. if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
  5070. if (override === true) {
  5071. processEnv[key] = parsed[key];
  5072. }
  5073. if (debug) {
  5074. if (override === true) {
  5075. _debug(`"${key}" is already defined and WAS overwritten`);
  5076. } else {
  5077. _debug(`"${key}" is already defined and was NOT overwritten`);
  5078. }
  5079. }
  5080. } else {
  5081. processEnv[key] = parsed[key];
  5082. }
  5083. }
  5084. }
  5085. const DotenvModule = {
  5086. configDotenv,
  5087. _configVault,
  5088. _parseVault,
  5089. config,
  5090. decrypt,
  5091. parse,
  5092. populate
  5093. };
  5094. main$1.exports.configDotenv = DotenvModule.configDotenv;
  5095. main$1.exports._configVault = DotenvModule._configVault;
  5096. main$1.exports._parseVault = DotenvModule._parseVault;
  5097. main$1.exports.config = DotenvModule.config;
  5098. main$1.exports.decrypt = DotenvModule.decrypt;
  5099. var parse_1 = main$1.exports.parse = DotenvModule.parse;
  5100. main$1.exports.populate = DotenvModule.populate;
  5101. main$1.exports = DotenvModule;
  5102. // * /
  5103. // * (\\)? # is it escaped with a backslash?
  5104. // * (\$) # literal $
  5105. // * (?!\() # shouldnt be followed by parenthesis
  5106. // * (\{?) # first brace wrap opening
  5107. // * ([\w.]+) # key
  5108. // * (?::-((?:\$\{(?:\$\{(?:\$\{[^}]*\}|[^}])*}|[^}])*}|[^}])+))? # optional default nested 3 times
  5109. // * (\}?) # last brace warp closing
  5110. // * /xi
  5111. const DOTENV_SUBSTITUTION_REGEX = /(\\)?(\$)(?!\()(\{?)([\w.]+)(?::?-((?:\$\{(?:\$\{(?:\$\{[^}]*\}|[^}])*}|[^}])*}|[^}])+))?(\}?)/gi;
  5112. function _resolveEscapeSequences (value) {
  5113. return value.replace(/\\\$/g, '$')
  5114. }
  5115. function interpolate (value, processEnv, parsed) {
  5116. return value.replace(DOTENV_SUBSTITUTION_REGEX, (match, escaped, dollarSign, openBrace, key, defaultValue, closeBrace) => {
  5117. if (escaped === '\\') {
  5118. return match.slice(1)
  5119. } else {
  5120. if (processEnv[key]) {
  5121. if (processEnv[key] === parsed[key]) {
  5122. return processEnv[key]
  5123. } else {
  5124. // scenario: PASSWORD_EXPAND_NESTED=${PASSWORD_EXPAND}
  5125. return interpolate(processEnv[key], processEnv, parsed)
  5126. }
  5127. }
  5128. if (parsed[key]) {
  5129. // avoid recursion from EXPAND_SELF=$EXPAND_SELF
  5130. if (parsed[key] === value) {
  5131. return parsed[key]
  5132. } else {
  5133. return interpolate(parsed[key], processEnv, parsed)
  5134. }
  5135. }
  5136. if (defaultValue) {
  5137. if (defaultValue.startsWith('$')) {
  5138. return interpolate(defaultValue, processEnv, parsed)
  5139. } else {
  5140. return defaultValue
  5141. }
  5142. }
  5143. return ''
  5144. }
  5145. })
  5146. }
  5147. function expand (options) {
  5148. let processEnv = process.env;
  5149. if (options && options.processEnv != null) {
  5150. processEnv = options.processEnv;
  5151. }
  5152. for (const key in options.parsed) {
  5153. let value = options.parsed[key];
  5154. const inProcessEnv = Object.prototype.hasOwnProperty.call(processEnv, key);
  5155. if (inProcessEnv) {
  5156. if (processEnv[key] === options.parsed[key]) {
  5157. // assume was set to processEnv from the .env file if the values match and therefore interpolate
  5158. value = interpolate(value, processEnv, options.parsed);
  5159. } else {
  5160. // do not interpolate - assume processEnv had the intended value even if containing a $.
  5161. value = processEnv[key];
  5162. }
  5163. } else {
  5164. // not inProcessEnv so assume interpolation for this .env key
  5165. value = interpolate(value, processEnv, options.parsed);
  5166. }
  5167. options.parsed[key] = _resolveEscapeSequences(value);
  5168. }
  5169. for (const processKey in options.parsed) {
  5170. processEnv[processKey] = options.parsed[processKey];
  5171. }
  5172. return options
  5173. }
  5174. var expand_1 = expand;
  5175. function getEnvFilesForMode(mode, envDir) {
  5176. return [
  5177. /** default file */
  5178. `.env`,
  5179. /** local file */
  5180. `.env.local`,
  5181. /** mode file */
  5182. `.env.${mode}`,
  5183. /** mode local file */
  5184. `.env.${mode}.local`
  5185. ].map((file) => normalizePath(path$3.join(envDir, file)));
  5186. }
  5187. function loadEnv(mode, envDir, prefixes = "VITE_") {
  5188. if (mode === "local") {
  5189. throw new Error(
  5190. `"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`
  5191. );
  5192. }
  5193. prefixes = arraify(prefixes);
  5194. const env = {};
  5195. const envFiles = getEnvFilesForMode(mode, envDir);
  5196. const parsed = Object.fromEntries(
  5197. envFiles.flatMap((filePath) => {
  5198. if (!tryStatSync(filePath)?.isFile()) return [];
  5199. return Object.entries(parse_1(fs$1.readFileSync(filePath)));
  5200. })
  5201. );
  5202. if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0) {
  5203. process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
  5204. }
  5205. if (parsed.BROWSER && process.env.BROWSER === void 0) {
  5206. process.env.BROWSER = parsed.BROWSER;
  5207. }
  5208. if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0) {
  5209. process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
  5210. }
  5211. const processEnv = { ...process.env };
  5212. expand_1({ parsed, processEnv });
  5213. for (const [key, value] of Object.entries(parsed)) {
  5214. if (prefixes.some((prefix) => key.startsWith(prefix))) {
  5215. env[key] = value;
  5216. }
  5217. }
  5218. for (const key in process.env) {
  5219. if (prefixes.some((prefix) => key.startsWith(prefix))) {
  5220. env[key] = process.env[key];
  5221. }
  5222. }
  5223. return env;
  5224. }
  5225. function resolveEnvPrefix({
  5226. envPrefix = "VITE_"
  5227. }) {
  5228. envPrefix = arraify(envPrefix);
  5229. if (envPrefix.includes("")) {
  5230. throw new Error(
  5231. `envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`
  5232. );
  5233. }
  5234. return envPrefix;
  5235. }
  5236. exports.esbuildVersion = esbuild.version;
  5237. exports.createFilter = createFilter;
  5238. exports.createLogger = createLogger;
  5239. exports.isCSSRequest = isCSSRequest;
  5240. exports.isFileServingAllowed = isFileServingAllowed;
  5241. exports.loadEnv = loadEnv;
  5242. exports.mergeAlias = mergeAlias;
  5243. exports.mergeConfig = mergeConfig;
  5244. exports.normalizePath = normalizePath;
  5245. exports.resolveEnvPrefix = resolveEnvPrefix;
  5246. exports.rollupVersion = rollupVersion;
  5247. exports.searchForWorkspaceRoot = searchForWorkspaceRoot;
  5248. exports.send = send;
  5249. exports.splitVendorChunk = splitVendorChunk;
  5250. exports.splitVendorChunkPlugin = splitVendorChunkPlugin;
  5251. exports.version = VERSION;