publicUtils.cjs 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318
  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 rollup = require('rollup');
  7. var os$1 = require('node:os');
  8. var node_util = require('node:util');
  9. var node_module = require('node:module');
  10. var require$$0 = require('tty');
  11. var require$$1 = require('util');
  12. var require$$0$1 = require('path');
  13. var require$$0$2 = require('crypto');
  14. var require$$1$1 = require('fs');
  15. var readline = require('node:readline');
  16. var require$$2 = require('os');
  17. const { version: version$2 } = JSON.parse(fs$1.readFileSync(new URL('../../package.json', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString());
  18. const VERSION = version$2;
  19. const VITE_PACKAGE_DIR = path$3.resolve(
  20. // import.meta.url is `dist/node/constants.js` after bundle
  21. node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))), '../../..');
  22. const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
  23. path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
  24. path$3.dirname(CLIENT_ENTRY);
  25. // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
  26. // copy from constants.ts
  27. const CSS_LANGS_RE =
  28. // eslint-disable-next-line regexp/no-unused-capturing-group
  29. /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
  30. const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
  31. // Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
  32. // We don't recommend using this strategy as a general solution moving forward
  33. // splitVendorChunk is a simple index/vendor strategy that was used in Vite
  34. // until v2.8. It is exposed to let people continue to use it in case it was
  35. // working well for their setups.
  36. // The cache needs to be reset on buildStart for watch mode to work correctly
  37. // Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
  38. class SplitVendorChunkCache {
  39. constructor() {
  40. this.cache = new Map();
  41. }
  42. reset() {
  43. this.cache = new Map();
  44. }
  45. }
  46. function splitVendorChunk(options = {}) {
  47. const cache = options.cache ?? new SplitVendorChunkCache();
  48. return (id, { getModuleInfo }) => {
  49. if (id.includes('node_modules') &&
  50. !isCSSRequest(id) &&
  51. staticImportedByEntry(id, getModuleInfo, cache.cache)) {
  52. return 'vendor';
  53. }
  54. };
  55. }
  56. function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
  57. if (cache.has(id)) {
  58. return cache.get(id);
  59. }
  60. if (importStack.includes(id)) {
  61. // circular deps!
  62. cache.set(id, false);
  63. return false;
  64. }
  65. const mod = getModuleInfo(id);
  66. if (!mod) {
  67. cache.set(id, false);
  68. return false;
  69. }
  70. if (mod.isEntry) {
  71. cache.set(id, true);
  72. return true;
  73. }
  74. const someImporterIs = mod.importers.some((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
  75. cache.set(id, someImporterIs);
  76. return someImporterIs;
  77. }
  78. function splitVendorChunkPlugin() {
  79. const caches = [];
  80. function createSplitVendorChunk(output, config) {
  81. const cache = new SplitVendorChunkCache();
  82. caches.push(cache);
  83. const build = config.build ?? {};
  84. const format = output?.format;
  85. if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
  86. return splitVendorChunk({ cache });
  87. }
  88. }
  89. return {
  90. name: 'vite:split-vendor-chunk',
  91. config(config) {
  92. let outputs = config?.build?.rollupOptions?.output;
  93. if (outputs) {
  94. outputs = Array.isArray(outputs) ? outputs : [outputs];
  95. for (const output of outputs) {
  96. const viteManualChunks = createSplitVendorChunk(output, config);
  97. if (viteManualChunks) {
  98. if (output.manualChunks) {
  99. if (typeof output.manualChunks === 'function') {
  100. const userManualChunks = output.manualChunks;
  101. output.manualChunks = (id, api) => {
  102. return userManualChunks(id, api) ?? viteManualChunks(id, api);
  103. };
  104. }
  105. // else, leave the object form of manualChunks untouched, as
  106. // we can't safely replicate rollup handling.
  107. }
  108. else {
  109. output.manualChunks = viteManualChunks;
  110. }
  111. }
  112. }
  113. }
  114. else {
  115. return {
  116. build: {
  117. rollupOptions: {
  118. output: {
  119. manualChunks: createSplitVendorChunk({}, config),
  120. },
  121. },
  122. },
  123. };
  124. }
  125. },
  126. buildStart() {
  127. caches.forEach((cache) => cache.reset());
  128. },
  129. };
  130. }
  131. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  132. const intToChar = new Uint8Array(64); // 64 possible chars.
  133. const charToInt = new Uint8Array(128); // z is 122 in ASCII
  134. for (let i = 0; i < chars.length; i++) {
  135. const c = chars.charCodeAt(i);
  136. intToChar[i] = c;
  137. charToInt[c] = i;
  138. }
  139. // Matches the scheme of a URL, eg "http://"
  140. var UrlType;
  141. (function (UrlType) {
  142. UrlType[UrlType["Empty"] = 1] = "Empty";
  143. UrlType[UrlType["Hash"] = 2] = "Hash";
  144. UrlType[UrlType["Query"] = 3] = "Query";
  145. UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
  146. UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
  147. UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
  148. UrlType[UrlType["Absolute"] = 7] = "Absolute";
  149. })(UrlType || (UrlType = {}));
  150. function getDefaultExportFromCjs (x) {
  151. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  152. }
  153. var picocolorsExports = {};
  154. var picocolors = {
  155. get exports(){ return picocolorsExports; },
  156. set exports(v){ picocolorsExports = v; },
  157. };
  158. let tty = require$$0;
  159. let isColorSupported =
  160. !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
  161. ("FORCE_COLOR" in process.env ||
  162. process.argv.includes("--color") ||
  163. process.platform === "win32" ||
  164. (tty.isatty(1) && process.env.TERM !== "dumb") ||
  165. "CI" in process.env);
  166. let formatter =
  167. (open, close, replace = open) =>
  168. input => {
  169. let string = "" + input;
  170. let index = string.indexOf(close, open.length);
  171. return ~index
  172. ? open + replaceClose(string, close, replace, index) + close
  173. : open + string + close
  174. };
  175. let replaceClose = (string, close, replace, index) => {
  176. let start = string.substring(0, index) + replace;
  177. let end = string.substring(index + close.length);
  178. let nextIndex = end.indexOf(close);
  179. return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
  180. };
  181. let createColors = (enabled = isColorSupported) => ({
  182. isColorSupported: enabled,
  183. reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
  184. bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
  185. dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
  186. italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
  187. underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
  188. inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
  189. hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
  190. strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
  191. black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
  192. red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
  193. green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
  194. yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
  195. blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
  196. magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
  197. cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
  198. white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
  199. gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
  200. bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
  201. bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
  202. bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
  203. bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
  204. bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
  205. bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
  206. bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
  207. bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
  208. });
  209. picocolors.exports = createColors();
  210. picocolorsExports.createColors = createColors;
  211. var srcExports = {};
  212. var src = {
  213. get exports(){ return srcExports; },
  214. set exports(v){ srcExports = v; },
  215. };
  216. var browserExports = {};
  217. var browser = {
  218. get exports(){ return browserExports; },
  219. set exports(v){ browserExports = v; },
  220. };
  221. /**
  222. * Helpers.
  223. */
  224. var ms;
  225. var hasRequiredMs;
  226. function requireMs () {
  227. if (hasRequiredMs) return ms;
  228. hasRequiredMs = 1;
  229. var s = 1000;
  230. var m = s * 60;
  231. var h = m * 60;
  232. var d = h * 24;
  233. var w = d * 7;
  234. var y = d * 365.25;
  235. /**
  236. * Parse or format the given `val`.
  237. *
  238. * Options:
  239. *
  240. * - `long` verbose formatting [false]
  241. *
  242. * @param {String|Number} val
  243. * @param {Object} [options]
  244. * @throws {Error} throw an error if val is not a non-empty string or a number
  245. * @return {String|Number}
  246. * @api public
  247. */
  248. ms = function(val, options) {
  249. options = options || {};
  250. var type = typeof val;
  251. if (type === 'string' && val.length > 0) {
  252. return parse(val);
  253. } else if (type === 'number' && isFinite(val)) {
  254. return options.long ? fmtLong(val) : fmtShort(val);
  255. }
  256. throw new Error(
  257. 'val is not a non-empty string or a valid number. val=' +
  258. JSON.stringify(val)
  259. );
  260. };
  261. /**
  262. * Parse the given `str` and return milliseconds.
  263. *
  264. * @param {String} str
  265. * @return {Number}
  266. * @api private
  267. */
  268. function parse(str) {
  269. str = String(str);
  270. if (str.length > 100) {
  271. return;
  272. }
  273. 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(
  274. str
  275. );
  276. if (!match) {
  277. return;
  278. }
  279. var n = parseFloat(match[1]);
  280. var type = (match[2] || 'ms').toLowerCase();
  281. switch (type) {
  282. case 'years':
  283. case 'year':
  284. case 'yrs':
  285. case 'yr':
  286. case 'y':
  287. return n * y;
  288. case 'weeks':
  289. case 'week':
  290. case 'w':
  291. return n * w;
  292. case 'days':
  293. case 'day':
  294. case 'd':
  295. return n * d;
  296. case 'hours':
  297. case 'hour':
  298. case 'hrs':
  299. case 'hr':
  300. case 'h':
  301. return n * h;
  302. case 'minutes':
  303. case 'minute':
  304. case 'mins':
  305. case 'min':
  306. case 'm':
  307. return n * m;
  308. case 'seconds':
  309. case 'second':
  310. case 'secs':
  311. case 'sec':
  312. case 's':
  313. return n * s;
  314. case 'milliseconds':
  315. case 'millisecond':
  316. case 'msecs':
  317. case 'msec':
  318. case 'ms':
  319. return n;
  320. default:
  321. return undefined;
  322. }
  323. }
  324. /**
  325. * Short format for `ms`.
  326. *
  327. * @param {Number} ms
  328. * @return {String}
  329. * @api private
  330. */
  331. function fmtShort(ms) {
  332. var msAbs = Math.abs(ms);
  333. if (msAbs >= d) {
  334. return Math.round(ms / d) + 'd';
  335. }
  336. if (msAbs >= h) {
  337. return Math.round(ms / h) + 'h';
  338. }
  339. if (msAbs >= m) {
  340. return Math.round(ms / m) + 'm';
  341. }
  342. if (msAbs >= s) {
  343. return Math.round(ms / s) + 's';
  344. }
  345. return ms + 'ms';
  346. }
  347. /**
  348. * Long format for `ms`.
  349. *
  350. * @param {Number} ms
  351. * @return {String}
  352. * @api private
  353. */
  354. function fmtLong(ms) {
  355. var msAbs = Math.abs(ms);
  356. if (msAbs >= d) {
  357. return plural(ms, msAbs, d, 'day');
  358. }
  359. if (msAbs >= h) {
  360. return plural(ms, msAbs, h, 'hour');
  361. }
  362. if (msAbs >= m) {
  363. return plural(ms, msAbs, m, 'minute');
  364. }
  365. if (msAbs >= s) {
  366. return plural(ms, msAbs, s, 'second');
  367. }
  368. return ms + ' ms';
  369. }
  370. /**
  371. * Pluralization helper.
  372. */
  373. function plural(ms, msAbs, n, name) {
  374. var isPlural = msAbs >= n * 1.5;
  375. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  376. }
  377. return ms;
  378. }
  379. var common;
  380. var hasRequiredCommon;
  381. function requireCommon () {
  382. if (hasRequiredCommon) return common;
  383. hasRequiredCommon = 1;
  384. /**
  385. * This is the common logic for both the Node.js and web browser
  386. * implementations of `debug()`.
  387. */
  388. function setup(env) {
  389. createDebug.debug = createDebug;
  390. createDebug.default = createDebug;
  391. createDebug.coerce = coerce;
  392. createDebug.disable = disable;
  393. createDebug.enable = enable;
  394. createDebug.enabled = enabled;
  395. createDebug.humanize = requireMs();
  396. createDebug.destroy = destroy;
  397. Object.keys(env).forEach(key => {
  398. createDebug[key] = env[key];
  399. });
  400. /**
  401. * The currently active debug mode names, and names to skip.
  402. */
  403. createDebug.names = [];
  404. createDebug.skips = [];
  405. /**
  406. * Map of special "%n" handling functions, for the debug "format" argument.
  407. *
  408. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  409. */
  410. createDebug.formatters = {};
  411. /**
  412. * Selects a color for a debug namespace
  413. * @param {String} namespace The namespace string for the debug instance to be colored
  414. * @return {Number|String} An ANSI color code for the given namespace
  415. * @api private
  416. */
  417. function selectColor(namespace) {
  418. let hash = 0;
  419. for (let i = 0; i < namespace.length; i++) {
  420. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  421. hash |= 0; // Convert to 32bit integer
  422. }
  423. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  424. }
  425. createDebug.selectColor = selectColor;
  426. /**
  427. * Create a debugger with the given `namespace`.
  428. *
  429. * @param {String} namespace
  430. * @return {Function}
  431. * @api public
  432. */
  433. function createDebug(namespace) {
  434. let prevTime;
  435. let enableOverride = null;
  436. let namespacesCache;
  437. let enabledCache;
  438. function debug(...args) {
  439. // Disabled?
  440. if (!debug.enabled) {
  441. return;
  442. }
  443. const self = debug;
  444. // Set `diff` timestamp
  445. const curr = Number(new Date());
  446. const ms = curr - (prevTime || curr);
  447. self.diff = ms;
  448. self.prev = prevTime;
  449. self.curr = curr;
  450. prevTime = curr;
  451. args[0] = createDebug.coerce(args[0]);
  452. if (typeof args[0] !== 'string') {
  453. // Anything else let's inspect with %O
  454. args.unshift('%O');
  455. }
  456. // Apply any `formatters` transformations
  457. let index = 0;
  458. args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
  459. // If we encounter an escaped % then don't increase the array index
  460. if (match === '%%') {
  461. return '%';
  462. }
  463. index++;
  464. const formatter = createDebug.formatters[format];
  465. if (typeof formatter === 'function') {
  466. const val = args[index];
  467. match = formatter.call(self, val);
  468. // Now we need to remove `args[index]` since it's inlined in the `format`
  469. args.splice(index, 1);
  470. index--;
  471. }
  472. return match;
  473. });
  474. // Apply env-specific formatting (colors, etc.)
  475. createDebug.formatArgs.call(self, args);
  476. const logFn = self.log || createDebug.log;
  477. logFn.apply(self, args);
  478. }
  479. debug.namespace = namespace;
  480. debug.useColors = createDebug.useColors();
  481. debug.color = createDebug.selectColor(namespace);
  482. debug.extend = extend;
  483. debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
  484. Object.defineProperty(debug, 'enabled', {
  485. enumerable: true,
  486. configurable: false,
  487. get: () => {
  488. if (enableOverride !== null) {
  489. return enableOverride;
  490. }
  491. if (namespacesCache !== createDebug.namespaces) {
  492. namespacesCache = createDebug.namespaces;
  493. enabledCache = createDebug.enabled(namespace);
  494. }
  495. return enabledCache;
  496. },
  497. set: v => {
  498. enableOverride = v;
  499. }
  500. });
  501. // Env-specific initialization logic for debug instances
  502. if (typeof createDebug.init === 'function') {
  503. createDebug.init(debug);
  504. }
  505. return debug;
  506. }
  507. function extend(namespace, delimiter) {
  508. const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  509. newDebug.log = this.log;
  510. return newDebug;
  511. }
  512. /**
  513. * Enables a debug mode by namespaces. This can include modes
  514. * separated by a colon and wildcards.
  515. *
  516. * @param {String} namespaces
  517. * @api public
  518. */
  519. function enable(namespaces) {
  520. createDebug.save(namespaces);
  521. createDebug.namespaces = namespaces;
  522. createDebug.names = [];
  523. createDebug.skips = [];
  524. let i;
  525. const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  526. const len = split.length;
  527. for (i = 0; i < len; i++) {
  528. if (!split[i]) {
  529. // ignore empty strings
  530. continue;
  531. }
  532. namespaces = split[i].replace(/\*/g, '.*?');
  533. if (namespaces[0] === '-') {
  534. createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
  535. } else {
  536. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  537. }
  538. }
  539. }
  540. /**
  541. * Disable debug output.
  542. *
  543. * @return {String} namespaces
  544. * @api public
  545. */
  546. function disable() {
  547. const namespaces = [
  548. ...createDebug.names.map(toNamespace),
  549. ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
  550. ].join(',');
  551. createDebug.enable('');
  552. return namespaces;
  553. }
  554. /**
  555. * Returns true if the given mode name is enabled, false otherwise.
  556. *
  557. * @param {String} name
  558. * @return {Boolean}
  559. * @api public
  560. */
  561. function enabled(name) {
  562. if (name[name.length - 1] === '*') {
  563. return true;
  564. }
  565. let i;
  566. let len;
  567. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  568. if (createDebug.skips[i].test(name)) {
  569. return false;
  570. }
  571. }
  572. for (i = 0, len = createDebug.names.length; i < len; i++) {
  573. if (createDebug.names[i].test(name)) {
  574. return true;
  575. }
  576. }
  577. return false;
  578. }
  579. /**
  580. * Convert regexp to namespace
  581. *
  582. * @param {RegExp} regxep
  583. * @return {String} namespace
  584. * @api private
  585. */
  586. function toNamespace(regexp) {
  587. return regexp.toString()
  588. .substring(2, regexp.toString().length - 2)
  589. .replace(/\.\*\?$/, '*');
  590. }
  591. /**
  592. * Coerce `val`.
  593. *
  594. * @param {Mixed} val
  595. * @return {Mixed}
  596. * @api private
  597. */
  598. function coerce(val) {
  599. if (val instanceof Error) {
  600. return val.stack || val.message;
  601. }
  602. return val;
  603. }
  604. /**
  605. * XXX DO NOT USE. This is a temporary stub function.
  606. * XXX It WILL be removed in the next major release.
  607. */
  608. function destroy() {
  609. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  610. }
  611. createDebug.enable(createDebug.load());
  612. return createDebug;
  613. }
  614. common = setup;
  615. return common;
  616. }
  617. /* eslint-env browser */
  618. var hasRequiredBrowser;
  619. function requireBrowser () {
  620. if (hasRequiredBrowser) return browserExports;
  621. hasRequiredBrowser = 1;
  622. (function (module, exports) {
  623. /**
  624. * This is the web browser implementation of `debug()`.
  625. */
  626. exports.formatArgs = formatArgs;
  627. exports.save = save;
  628. exports.load = load;
  629. exports.useColors = useColors;
  630. exports.storage = localstorage();
  631. exports.destroy = (() => {
  632. let warned = false;
  633. return () => {
  634. if (!warned) {
  635. warned = true;
  636. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  637. }
  638. };
  639. })();
  640. /**
  641. * Colors.
  642. */
  643. exports.colors = [
  644. '#0000CC',
  645. '#0000FF',
  646. '#0033CC',
  647. '#0033FF',
  648. '#0066CC',
  649. '#0066FF',
  650. '#0099CC',
  651. '#0099FF',
  652. '#00CC00',
  653. '#00CC33',
  654. '#00CC66',
  655. '#00CC99',
  656. '#00CCCC',
  657. '#00CCFF',
  658. '#3300CC',
  659. '#3300FF',
  660. '#3333CC',
  661. '#3333FF',
  662. '#3366CC',
  663. '#3366FF',
  664. '#3399CC',
  665. '#3399FF',
  666. '#33CC00',
  667. '#33CC33',
  668. '#33CC66',
  669. '#33CC99',
  670. '#33CCCC',
  671. '#33CCFF',
  672. '#6600CC',
  673. '#6600FF',
  674. '#6633CC',
  675. '#6633FF',
  676. '#66CC00',
  677. '#66CC33',
  678. '#9900CC',
  679. '#9900FF',
  680. '#9933CC',
  681. '#9933FF',
  682. '#99CC00',
  683. '#99CC33',
  684. '#CC0000',
  685. '#CC0033',
  686. '#CC0066',
  687. '#CC0099',
  688. '#CC00CC',
  689. '#CC00FF',
  690. '#CC3300',
  691. '#CC3333',
  692. '#CC3366',
  693. '#CC3399',
  694. '#CC33CC',
  695. '#CC33FF',
  696. '#CC6600',
  697. '#CC6633',
  698. '#CC9900',
  699. '#CC9933',
  700. '#CCCC00',
  701. '#CCCC33',
  702. '#FF0000',
  703. '#FF0033',
  704. '#FF0066',
  705. '#FF0099',
  706. '#FF00CC',
  707. '#FF00FF',
  708. '#FF3300',
  709. '#FF3333',
  710. '#FF3366',
  711. '#FF3399',
  712. '#FF33CC',
  713. '#FF33FF',
  714. '#FF6600',
  715. '#FF6633',
  716. '#FF9900',
  717. '#FF9933',
  718. '#FFCC00',
  719. '#FFCC33'
  720. ];
  721. /**
  722. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  723. * and the Firebug extension (any Firefox version) are known
  724. * to support "%c" CSS customizations.
  725. *
  726. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  727. */
  728. // eslint-disable-next-line complexity
  729. function useColors() {
  730. // NB: In an Electron preload script, document will be defined but not fully
  731. // initialized. Since we know we're in Chrome, we'll just detect this case
  732. // explicitly
  733. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  734. return true;
  735. }
  736. // Internet Explorer and Edge do not support colors.
  737. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  738. return false;
  739. }
  740. // Is webkit? http://stackoverflow.com/a/16459606/376773
  741. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  742. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  743. // Is firebug? http://stackoverflow.com/a/398120/376773
  744. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  745. // Is firefox >= v31?
  746. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  747. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  748. // Double check webkit in userAgent just in case we are in a worker
  749. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  750. }
  751. /**
  752. * Colorize log arguments if enabled.
  753. *
  754. * @api public
  755. */
  756. function formatArgs(args) {
  757. args[0] = (this.useColors ? '%c' : '') +
  758. this.namespace +
  759. (this.useColors ? ' %c' : ' ') +
  760. args[0] +
  761. (this.useColors ? '%c ' : ' ') +
  762. '+' + module.exports.humanize(this.diff);
  763. if (!this.useColors) {
  764. return;
  765. }
  766. const c = 'color: ' + this.color;
  767. args.splice(1, 0, c, 'color: inherit');
  768. // The final "%c" is somewhat tricky, because there could be other
  769. // arguments passed either before or after the %c, so we need to
  770. // figure out the correct index to insert the CSS into
  771. let index = 0;
  772. let lastC = 0;
  773. args[0].replace(/%[a-zA-Z%]/g, match => {
  774. if (match === '%%') {
  775. return;
  776. }
  777. index++;
  778. if (match === '%c') {
  779. // We only are interested in the *last* %c
  780. // (the user may have provided their own)
  781. lastC = index;
  782. }
  783. });
  784. args.splice(lastC, 0, c);
  785. }
  786. /**
  787. * Invokes `console.debug()` when available.
  788. * No-op when `console.debug` is not a "function".
  789. * If `console.debug` is not available, falls back
  790. * to `console.log`.
  791. *
  792. * @api public
  793. */
  794. exports.log = console.debug || console.log || (() => {});
  795. /**
  796. * Save `namespaces`.
  797. *
  798. * @param {String} namespaces
  799. * @api private
  800. */
  801. function save(namespaces) {
  802. try {
  803. if (namespaces) {
  804. exports.storage.setItem('debug', namespaces);
  805. } else {
  806. exports.storage.removeItem('debug');
  807. }
  808. } catch (error) {
  809. // Swallow
  810. // XXX (@Qix-) should we be logging these?
  811. }
  812. }
  813. /**
  814. * Load `namespaces`.
  815. *
  816. * @return {String} returns the previously persisted debug modes
  817. * @api private
  818. */
  819. function load() {
  820. let r;
  821. try {
  822. r = exports.storage.getItem('debug');
  823. } catch (error) {
  824. // Swallow
  825. // XXX (@Qix-) should we be logging these?
  826. }
  827. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  828. if (!r && typeof process !== 'undefined' && 'env' in process) {
  829. r = process.env.DEBUG;
  830. }
  831. return r;
  832. }
  833. /**
  834. * Localstorage attempts to return the localstorage.
  835. *
  836. * This is necessary because safari throws
  837. * when a user disables cookies/localstorage
  838. * and you attempt to access it.
  839. *
  840. * @return {LocalStorage}
  841. * @api private
  842. */
  843. function localstorage() {
  844. try {
  845. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  846. // The Browser also has localStorage in the global context.
  847. return localStorage;
  848. } catch (error) {
  849. // Swallow
  850. // XXX (@Qix-) should we be logging these?
  851. }
  852. }
  853. module.exports = requireCommon()(exports);
  854. const {formatters} = module.exports;
  855. /**
  856. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  857. */
  858. formatters.j = function (v) {
  859. try {
  860. return JSON.stringify(v);
  861. } catch (error) {
  862. return '[UnexpectedJSONParseError]: ' + error.message;
  863. }
  864. };
  865. } (browser, browserExports));
  866. return browserExports;
  867. }
  868. var nodeExports = {};
  869. var node = {
  870. get exports(){ return nodeExports; },
  871. set exports(v){ nodeExports = v; },
  872. };
  873. /**
  874. * Module dependencies.
  875. */
  876. var hasRequiredNode;
  877. function requireNode () {
  878. if (hasRequiredNode) return nodeExports;
  879. hasRequiredNode = 1;
  880. (function (module, exports) {
  881. const tty = require$$0;
  882. const util = require$$1;
  883. /**
  884. * This is the Node.js implementation of `debug()`.
  885. */
  886. exports.init = init;
  887. exports.log = log;
  888. exports.formatArgs = formatArgs;
  889. exports.save = save;
  890. exports.load = load;
  891. exports.useColors = useColors;
  892. exports.destroy = util.deprecate(
  893. () => {},
  894. 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
  895. );
  896. /**
  897. * Colors.
  898. */
  899. exports.colors = [6, 2, 3, 4, 5, 1];
  900. try {
  901. // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
  902. // eslint-disable-next-line import/no-extraneous-dependencies
  903. const supportsColor = require('supports-color');
  904. if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
  905. exports.colors = [
  906. 20,
  907. 21,
  908. 26,
  909. 27,
  910. 32,
  911. 33,
  912. 38,
  913. 39,
  914. 40,
  915. 41,
  916. 42,
  917. 43,
  918. 44,
  919. 45,
  920. 56,
  921. 57,
  922. 62,
  923. 63,
  924. 68,
  925. 69,
  926. 74,
  927. 75,
  928. 76,
  929. 77,
  930. 78,
  931. 79,
  932. 80,
  933. 81,
  934. 92,
  935. 93,
  936. 98,
  937. 99,
  938. 112,
  939. 113,
  940. 128,
  941. 129,
  942. 134,
  943. 135,
  944. 148,
  945. 149,
  946. 160,
  947. 161,
  948. 162,
  949. 163,
  950. 164,
  951. 165,
  952. 166,
  953. 167,
  954. 168,
  955. 169,
  956. 170,
  957. 171,
  958. 172,
  959. 173,
  960. 178,
  961. 179,
  962. 184,
  963. 185,
  964. 196,
  965. 197,
  966. 198,
  967. 199,
  968. 200,
  969. 201,
  970. 202,
  971. 203,
  972. 204,
  973. 205,
  974. 206,
  975. 207,
  976. 208,
  977. 209,
  978. 214,
  979. 215,
  980. 220,
  981. 221
  982. ];
  983. }
  984. } catch (error) {
  985. // Swallow - we only care if `supports-color` is available; it doesn't have to be.
  986. }
  987. /**
  988. * Build up the default `inspectOpts` object from the environment variables.
  989. *
  990. * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
  991. */
  992. exports.inspectOpts = Object.keys(process.env).filter(key => {
  993. return /^debug_/i.test(key);
  994. }).reduce((obj, key) => {
  995. // Camel-case
  996. const prop = key
  997. .substring(6)
  998. .toLowerCase()
  999. .replace(/_([a-z])/g, (_, k) => {
  1000. return k.toUpperCase();
  1001. });
  1002. // Coerce string value into JS value
  1003. let val = process.env[key];
  1004. if (/^(yes|on|true|enabled)$/i.test(val)) {
  1005. val = true;
  1006. } else if (/^(no|off|false|disabled)$/i.test(val)) {
  1007. val = false;
  1008. } else if (val === 'null') {
  1009. val = null;
  1010. } else {
  1011. val = Number(val);
  1012. }
  1013. obj[prop] = val;
  1014. return obj;
  1015. }, {});
  1016. /**
  1017. * Is stdout a TTY? Colored output is enabled when `true`.
  1018. */
  1019. function useColors() {
  1020. return 'colors' in exports.inspectOpts ?
  1021. Boolean(exports.inspectOpts.colors) :
  1022. tty.isatty(process.stderr.fd);
  1023. }
  1024. /**
  1025. * Adds ANSI color escape codes if enabled.
  1026. *
  1027. * @api public
  1028. */
  1029. function formatArgs(args) {
  1030. const {namespace: name, useColors} = this;
  1031. if (useColors) {
  1032. const c = this.color;
  1033. const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
  1034. const prefix = ` ${colorCode};1m${name} \u001B[0m`;
  1035. args[0] = prefix + args[0].split('\n').join('\n' + prefix);
  1036. args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
  1037. } else {
  1038. args[0] = getDate() + name + ' ' + args[0];
  1039. }
  1040. }
  1041. function getDate() {
  1042. if (exports.inspectOpts.hideDate) {
  1043. return '';
  1044. }
  1045. return new Date().toISOString() + ' ';
  1046. }
  1047. /**
  1048. * Invokes `util.format()` with the specified arguments and writes to stderr.
  1049. */
  1050. function log(...args) {
  1051. return process.stderr.write(util.format(...args) + '\n');
  1052. }
  1053. /**
  1054. * Save `namespaces`.
  1055. *
  1056. * @param {String} namespaces
  1057. * @api private
  1058. */
  1059. function save(namespaces) {
  1060. if (namespaces) {
  1061. process.env.DEBUG = namespaces;
  1062. } else {
  1063. // If you set a process.env field to null or undefined, it gets cast to the
  1064. // string 'null' or 'undefined'. Just delete instead.
  1065. delete process.env.DEBUG;
  1066. }
  1067. }
  1068. /**
  1069. * Load `namespaces`.
  1070. *
  1071. * @return {String} returns the previously persisted debug modes
  1072. * @api private
  1073. */
  1074. function load() {
  1075. return process.env.DEBUG;
  1076. }
  1077. /**
  1078. * Init logic for `debug` instances.
  1079. *
  1080. * Create a new `inspectOpts` object in case `useColors` is set
  1081. * differently for a particular `debug` instance.
  1082. */
  1083. function init(debug) {
  1084. debug.inspectOpts = {};
  1085. const keys = Object.keys(exports.inspectOpts);
  1086. for (let i = 0; i < keys.length; i++) {
  1087. debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
  1088. }
  1089. }
  1090. module.exports = requireCommon()(exports);
  1091. const {formatters} = module.exports;
  1092. /**
  1093. * Map %o to `util.inspect()`, all on a single line.
  1094. */
  1095. formatters.o = function (v) {
  1096. this.inspectOpts.colors = this.useColors;
  1097. return util.inspect(v, this.inspectOpts)
  1098. .split('\n')
  1099. .map(str => str.trim())
  1100. .join(' ');
  1101. };
  1102. /**
  1103. * Map %O to `util.inspect()`, allowing multiple lines if needed.
  1104. */
  1105. formatters.O = function (v) {
  1106. this.inspectOpts.colors = this.useColors;
  1107. return util.inspect(v, this.inspectOpts);
  1108. };
  1109. } (node, nodeExports));
  1110. return nodeExports;
  1111. }
  1112. /**
  1113. * Detect Electron renderer / nwjs process, which is node, but we should
  1114. * treat as a browser.
  1115. */
  1116. (function (module) {
  1117. if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
  1118. module.exports = requireBrowser();
  1119. } else {
  1120. module.exports = requireNode();
  1121. }
  1122. } (src));
  1123. var debug = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
  1124. var picomatchExports = {};
  1125. var picomatch$1 = {
  1126. get exports(){ return picomatchExports; },
  1127. set exports(v){ picomatchExports = v; },
  1128. };
  1129. var utils$3 = {};
  1130. const path$2 = require$$0$1;
  1131. const WIN_SLASH = '\\\\/';
  1132. const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
  1133. /**
  1134. * Posix glob regex
  1135. */
  1136. const DOT_LITERAL = '\\.';
  1137. const PLUS_LITERAL = '\\+';
  1138. const QMARK_LITERAL = '\\?';
  1139. const SLASH_LITERAL = '\\/';
  1140. const ONE_CHAR = '(?=.)';
  1141. const QMARK = '[^/]';
  1142. const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
  1143. const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
  1144. const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
  1145. const NO_DOT = `(?!${DOT_LITERAL})`;
  1146. const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
  1147. const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
  1148. const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
  1149. const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
  1150. const STAR = `${QMARK}*?`;
  1151. const POSIX_CHARS = {
  1152. DOT_LITERAL,
  1153. PLUS_LITERAL,
  1154. QMARK_LITERAL,
  1155. SLASH_LITERAL,
  1156. ONE_CHAR,
  1157. QMARK,
  1158. END_ANCHOR,
  1159. DOTS_SLASH,
  1160. NO_DOT,
  1161. NO_DOTS,
  1162. NO_DOT_SLASH,
  1163. NO_DOTS_SLASH,
  1164. QMARK_NO_DOT,
  1165. STAR,
  1166. START_ANCHOR
  1167. };
  1168. /**
  1169. * Windows glob regex
  1170. */
  1171. const WINDOWS_CHARS = {
  1172. ...POSIX_CHARS,
  1173. SLASH_LITERAL: `[${WIN_SLASH}]`,
  1174. QMARK: WIN_NO_SLASH,
  1175. STAR: `${WIN_NO_SLASH}*?`,
  1176. DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
  1177. NO_DOT: `(?!${DOT_LITERAL})`,
  1178. NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  1179. NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
  1180. NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  1181. QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
  1182. START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
  1183. END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
  1184. };
  1185. /**
  1186. * POSIX Bracket Regex
  1187. */
  1188. const POSIX_REGEX_SOURCE$1 = {
  1189. alnum: 'a-zA-Z0-9',
  1190. alpha: 'a-zA-Z',
  1191. ascii: '\\x00-\\x7F',
  1192. blank: ' \\t',
  1193. cntrl: '\\x00-\\x1F\\x7F',
  1194. digit: '0-9',
  1195. graph: '\\x21-\\x7E',
  1196. lower: 'a-z',
  1197. print: '\\x20-\\x7E ',
  1198. punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
  1199. space: ' \\t\\r\\n\\v\\f',
  1200. upper: 'A-Z',
  1201. word: 'A-Za-z0-9_',
  1202. xdigit: 'A-Fa-f0-9'
  1203. };
  1204. var constants$2 = {
  1205. MAX_LENGTH: 1024 * 64,
  1206. POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
  1207. // regular expressions
  1208. REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
  1209. REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
  1210. REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
  1211. REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
  1212. REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
  1213. REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
  1214. // Replace globs with equivalent patterns to reduce parsing time.
  1215. REPLACEMENTS: {
  1216. '***': '*',
  1217. '**/**': '**',
  1218. '**/**/**': '**'
  1219. },
  1220. // Digits
  1221. CHAR_0: 48, /* 0 */
  1222. CHAR_9: 57, /* 9 */
  1223. // Alphabet chars.
  1224. CHAR_UPPERCASE_A: 65, /* A */
  1225. CHAR_LOWERCASE_A: 97, /* a */
  1226. CHAR_UPPERCASE_Z: 90, /* Z */
  1227. CHAR_LOWERCASE_Z: 122, /* z */
  1228. CHAR_LEFT_PARENTHESES: 40, /* ( */
  1229. CHAR_RIGHT_PARENTHESES: 41, /* ) */
  1230. CHAR_ASTERISK: 42, /* * */
  1231. // Non-alphabetic chars.
  1232. CHAR_AMPERSAND: 38, /* & */
  1233. CHAR_AT: 64, /* @ */
  1234. CHAR_BACKWARD_SLASH: 92, /* \ */
  1235. CHAR_CARRIAGE_RETURN: 13, /* \r */
  1236. CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
  1237. CHAR_COLON: 58, /* : */
  1238. CHAR_COMMA: 44, /* , */
  1239. CHAR_DOT: 46, /* . */
  1240. CHAR_DOUBLE_QUOTE: 34, /* " */
  1241. CHAR_EQUAL: 61, /* = */
  1242. CHAR_EXCLAMATION_MARK: 33, /* ! */
  1243. CHAR_FORM_FEED: 12, /* \f */
  1244. CHAR_FORWARD_SLASH: 47, /* / */
  1245. CHAR_GRAVE_ACCENT: 96, /* ` */
  1246. CHAR_HASH: 35, /* # */
  1247. CHAR_HYPHEN_MINUS: 45, /* - */
  1248. CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
  1249. CHAR_LEFT_CURLY_BRACE: 123, /* { */
  1250. CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
  1251. CHAR_LINE_FEED: 10, /* \n */
  1252. CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
  1253. CHAR_PERCENT: 37, /* % */
  1254. CHAR_PLUS: 43, /* + */
  1255. CHAR_QUESTION_MARK: 63, /* ? */
  1256. CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
  1257. CHAR_RIGHT_CURLY_BRACE: 125, /* } */
  1258. CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
  1259. CHAR_SEMICOLON: 59, /* ; */
  1260. CHAR_SINGLE_QUOTE: 39, /* ' */
  1261. CHAR_SPACE: 32, /* */
  1262. CHAR_TAB: 9, /* \t */
  1263. CHAR_UNDERSCORE: 95, /* _ */
  1264. CHAR_VERTICAL_LINE: 124, /* | */
  1265. CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
  1266. SEP: path$2.sep,
  1267. /**
  1268. * Create EXTGLOB_CHARS
  1269. */
  1270. extglobChars(chars) {
  1271. return {
  1272. '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
  1273. '?': { type: 'qmark', open: '(?:', close: ')?' },
  1274. '+': { type: 'plus', open: '(?:', close: ')+' },
  1275. '*': { type: 'star', open: '(?:', close: ')*' },
  1276. '@': { type: 'at', open: '(?:', close: ')' }
  1277. };
  1278. },
  1279. /**
  1280. * Create GLOB_CHARS
  1281. */
  1282. globChars(win32) {
  1283. return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
  1284. }
  1285. };
  1286. (function (exports) {
  1287. const path = require$$0$1;
  1288. const win32 = process.platform === 'win32';
  1289. const {
  1290. REGEX_BACKSLASH,
  1291. REGEX_REMOVE_BACKSLASH,
  1292. REGEX_SPECIAL_CHARS,
  1293. REGEX_SPECIAL_CHARS_GLOBAL
  1294. } = constants$2;
  1295. exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  1296. exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
  1297. exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
  1298. exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
  1299. exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
  1300. exports.removeBackslashes = str => {
  1301. return str.replace(REGEX_REMOVE_BACKSLASH, match => {
  1302. return match === '\\' ? '' : match;
  1303. });
  1304. };
  1305. exports.supportsLookbehinds = () => {
  1306. const segs = process.version.slice(1).split('.').map(Number);
  1307. if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
  1308. return true;
  1309. }
  1310. return false;
  1311. };
  1312. exports.isWindows = options => {
  1313. if (options && typeof options.windows === 'boolean') {
  1314. return options.windows;
  1315. }
  1316. return win32 === true || path.sep === '\\';
  1317. };
  1318. exports.escapeLast = (input, char, lastIdx) => {
  1319. const idx = input.lastIndexOf(char, lastIdx);
  1320. if (idx === -1) return input;
  1321. if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
  1322. return `${input.slice(0, idx)}\\${input.slice(idx)}`;
  1323. };
  1324. exports.removePrefix = (input, state = {}) => {
  1325. let output = input;
  1326. if (output.startsWith('./')) {
  1327. output = output.slice(2);
  1328. state.prefix = './';
  1329. }
  1330. return output;
  1331. };
  1332. exports.wrapOutput = (input, state = {}, options = {}) => {
  1333. const prepend = options.contains ? '' : '^';
  1334. const append = options.contains ? '' : '$';
  1335. let output = `${prepend}(?:${input})${append}`;
  1336. if (state.negated === true) {
  1337. output = `(?:^(?!${output}).*$)`;
  1338. }
  1339. return output;
  1340. };
  1341. } (utils$3));
  1342. const utils$2 = utils$3;
  1343. const {
  1344. CHAR_ASTERISK, /* * */
  1345. CHAR_AT, /* @ */
  1346. CHAR_BACKWARD_SLASH, /* \ */
  1347. CHAR_COMMA, /* , */
  1348. CHAR_DOT, /* . */
  1349. CHAR_EXCLAMATION_MARK, /* ! */
  1350. CHAR_FORWARD_SLASH, /* / */
  1351. CHAR_LEFT_CURLY_BRACE, /* { */
  1352. CHAR_LEFT_PARENTHESES, /* ( */
  1353. CHAR_LEFT_SQUARE_BRACKET, /* [ */
  1354. CHAR_PLUS, /* + */
  1355. CHAR_QUESTION_MARK, /* ? */
  1356. CHAR_RIGHT_CURLY_BRACE, /* } */
  1357. CHAR_RIGHT_PARENTHESES, /* ) */
  1358. CHAR_RIGHT_SQUARE_BRACKET /* ] */
  1359. } = constants$2;
  1360. const isPathSeparator = code => {
  1361. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  1362. };
  1363. const depth = token => {
  1364. if (token.isPrefix !== true) {
  1365. token.depth = token.isGlobstar ? Infinity : 1;
  1366. }
  1367. };
  1368. /**
  1369. * Quickly scans a glob pattern and returns an object with a handful of
  1370. * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
  1371. * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
  1372. * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
  1373. *
  1374. * ```js
  1375. * const pm = require('picomatch');
  1376. * console.log(pm.scan('foo/bar/*.js'));
  1377. * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
  1378. * ```
  1379. * @param {String} `str`
  1380. * @param {Object} `options`
  1381. * @return {Object} Returns an object with tokens and regex source string.
  1382. * @api public
  1383. */
  1384. const scan$1 = (input, options) => {
  1385. const opts = options || {};
  1386. const length = input.length - 1;
  1387. const scanToEnd = opts.parts === true || opts.scanToEnd === true;
  1388. const slashes = [];
  1389. const tokens = [];
  1390. const parts = [];
  1391. let str = input;
  1392. let index = -1;
  1393. let start = 0;
  1394. let lastIndex = 0;
  1395. let isBrace = false;
  1396. let isBracket = false;
  1397. let isGlob = false;
  1398. let isExtglob = false;
  1399. let isGlobstar = false;
  1400. let braceEscaped = false;
  1401. let backslashes = false;
  1402. let negated = false;
  1403. let negatedExtglob = false;
  1404. let finished = false;
  1405. let braces = 0;
  1406. let prev;
  1407. let code;
  1408. let token = { value: '', depth: 0, isGlob: false };
  1409. const eos = () => index >= length;
  1410. const peek = () => str.charCodeAt(index + 1);
  1411. const advance = () => {
  1412. prev = code;
  1413. return str.charCodeAt(++index);
  1414. };
  1415. while (index < length) {
  1416. code = advance();
  1417. let next;
  1418. if (code === CHAR_BACKWARD_SLASH) {
  1419. backslashes = token.backslashes = true;
  1420. code = advance();
  1421. if (code === CHAR_LEFT_CURLY_BRACE) {
  1422. braceEscaped = true;
  1423. }
  1424. continue;
  1425. }
  1426. if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
  1427. braces++;
  1428. while (eos() !== true && (code = advance())) {
  1429. if (code === CHAR_BACKWARD_SLASH) {
  1430. backslashes = token.backslashes = true;
  1431. advance();
  1432. continue;
  1433. }
  1434. if (code === CHAR_LEFT_CURLY_BRACE) {
  1435. braces++;
  1436. continue;
  1437. }
  1438. if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
  1439. isBrace = token.isBrace = true;
  1440. isGlob = token.isGlob = true;
  1441. finished = true;
  1442. if (scanToEnd === true) {
  1443. continue;
  1444. }
  1445. break;
  1446. }
  1447. if (braceEscaped !== true && code === CHAR_COMMA) {
  1448. isBrace = token.isBrace = true;
  1449. isGlob = token.isGlob = true;
  1450. finished = true;
  1451. if (scanToEnd === true) {
  1452. continue;
  1453. }
  1454. break;
  1455. }
  1456. if (code === CHAR_RIGHT_CURLY_BRACE) {
  1457. braces--;
  1458. if (braces === 0) {
  1459. braceEscaped = false;
  1460. isBrace = token.isBrace = true;
  1461. finished = true;
  1462. break;
  1463. }
  1464. }
  1465. }
  1466. if (scanToEnd === true) {
  1467. continue;
  1468. }
  1469. break;
  1470. }
  1471. if (code === CHAR_FORWARD_SLASH) {
  1472. slashes.push(index);
  1473. tokens.push(token);
  1474. token = { value: '', depth: 0, isGlob: false };
  1475. if (finished === true) continue;
  1476. if (prev === CHAR_DOT && index === (start + 1)) {
  1477. start += 2;
  1478. continue;
  1479. }
  1480. lastIndex = index + 1;
  1481. continue;
  1482. }
  1483. if (opts.noext !== true) {
  1484. const isExtglobChar = code === CHAR_PLUS
  1485. || code === CHAR_AT
  1486. || code === CHAR_ASTERISK
  1487. || code === CHAR_QUESTION_MARK
  1488. || code === CHAR_EXCLAMATION_MARK;
  1489. if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
  1490. isGlob = token.isGlob = true;
  1491. isExtglob = token.isExtglob = true;
  1492. finished = true;
  1493. if (code === CHAR_EXCLAMATION_MARK && index === start) {
  1494. negatedExtglob = true;
  1495. }
  1496. if (scanToEnd === true) {
  1497. while (eos() !== true && (code = advance())) {
  1498. if (code === CHAR_BACKWARD_SLASH) {
  1499. backslashes = token.backslashes = true;
  1500. code = advance();
  1501. continue;
  1502. }
  1503. if (code === CHAR_RIGHT_PARENTHESES) {
  1504. isGlob = token.isGlob = true;
  1505. finished = true;
  1506. break;
  1507. }
  1508. }
  1509. continue;
  1510. }
  1511. break;
  1512. }
  1513. }
  1514. if (code === CHAR_ASTERISK) {
  1515. if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
  1516. isGlob = token.isGlob = true;
  1517. finished = true;
  1518. if (scanToEnd === true) {
  1519. continue;
  1520. }
  1521. break;
  1522. }
  1523. if (code === CHAR_QUESTION_MARK) {
  1524. isGlob = token.isGlob = true;
  1525. finished = true;
  1526. if (scanToEnd === true) {
  1527. continue;
  1528. }
  1529. break;
  1530. }
  1531. if (code === CHAR_LEFT_SQUARE_BRACKET) {
  1532. while (eos() !== true && (next = advance())) {
  1533. if (next === CHAR_BACKWARD_SLASH) {
  1534. backslashes = token.backslashes = true;
  1535. advance();
  1536. continue;
  1537. }
  1538. if (next === CHAR_RIGHT_SQUARE_BRACKET) {
  1539. isBracket = token.isBracket = true;
  1540. isGlob = token.isGlob = true;
  1541. finished = true;
  1542. break;
  1543. }
  1544. }
  1545. if (scanToEnd === true) {
  1546. continue;
  1547. }
  1548. break;
  1549. }
  1550. if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
  1551. negated = token.negated = true;
  1552. start++;
  1553. continue;
  1554. }
  1555. if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
  1556. isGlob = token.isGlob = true;
  1557. if (scanToEnd === true) {
  1558. while (eos() !== true && (code = advance())) {
  1559. if (code === CHAR_LEFT_PARENTHESES) {
  1560. backslashes = token.backslashes = true;
  1561. code = advance();
  1562. continue;
  1563. }
  1564. if (code === CHAR_RIGHT_PARENTHESES) {
  1565. finished = true;
  1566. break;
  1567. }
  1568. }
  1569. continue;
  1570. }
  1571. break;
  1572. }
  1573. if (isGlob === true) {
  1574. finished = true;
  1575. if (scanToEnd === true) {
  1576. continue;
  1577. }
  1578. break;
  1579. }
  1580. }
  1581. if (opts.noext === true) {
  1582. isExtglob = false;
  1583. isGlob = false;
  1584. }
  1585. let base = str;
  1586. let prefix = '';
  1587. let glob = '';
  1588. if (start > 0) {
  1589. prefix = str.slice(0, start);
  1590. str = str.slice(start);
  1591. lastIndex -= start;
  1592. }
  1593. if (base && isGlob === true && lastIndex > 0) {
  1594. base = str.slice(0, lastIndex);
  1595. glob = str.slice(lastIndex);
  1596. } else if (isGlob === true) {
  1597. base = '';
  1598. glob = str;
  1599. } else {
  1600. base = str;
  1601. }
  1602. if (base && base !== '' && base !== '/' && base !== str) {
  1603. if (isPathSeparator(base.charCodeAt(base.length - 1))) {
  1604. base = base.slice(0, -1);
  1605. }
  1606. }
  1607. if (opts.unescape === true) {
  1608. if (glob) glob = utils$2.removeBackslashes(glob);
  1609. if (base && backslashes === true) {
  1610. base = utils$2.removeBackslashes(base);
  1611. }
  1612. }
  1613. const state = {
  1614. prefix,
  1615. input,
  1616. start,
  1617. base,
  1618. glob,
  1619. isBrace,
  1620. isBracket,
  1621. isGlob,
  1622. isExtglob,
  1623. isGlobstar,
  1624. negated,
  1625. negatedExtglob
  1626. };
  1627. if (opts.tokens === true) {
  1628. state.maxDepth = 0;
  1629. if (!isPathSeparator(code)) {
  1630. tokens.push(token);
  1631. }
  1632. state.tokens = tokens;
  1633. }
  1634. if (opts.parts === true || opts.tokens === true) {
  1635. let prevIndex;
  1636. for (let idx = 0; idx < slashes.length; idx++) {
  1637. const n = prevIndex ? prevIndex + 1 : start;
  1638. const i = slashes[idx];
  1639. const value = input.slice(n, i);
  1640. if (opts.tokens) {
  1641. if (idx === 0 && start !== 0) {
  1642. tokens[idx].isPrefix = true;
  1643. tokens[idx].value = prefix;
  1644. } else {
  1645. tokens[idx].value = value;
  1646. }
  1647. depth(tokens[idx]);
  1648. state.maxDepth += tokens[idx].depth;
  1649. }
  1650. if (idx !== 0 || value !== '') {
  1651. parts.push(value);
  1652. }
  1653. prevIndex = i;
  1654. }
  1655. if (prevIndex && prevIndex + 1 < input.length) {
  1656. const value = input.slice(prevIndex + 1);
  1657. parts.push(value);
  1658. if (opts.tokens) {
  1659. tokens[tokens.length - 1].value = value;
  1660. depth(tokens[tokens.length - 1]);
  1661. state.maxDepth += tokens[tokens.length - 1].depth;
  1662. }
  1663. }
  1664. state.slashes = slashes;
  1665. state.parts = parts;
  1666. }
  1667. return state;
  1668. };
  1669. var scan_1 = scan$1;
  1670. const constants$1 = constants$2;
  1671. const utils$1 = utils$3;
  1672. /**
  1673. * Constants
  1674. */
  1675. const {
  1676. MAX_LENGTH,
  1677. POSIX_REGEX_SOURCE,
  1678. REGEX_NON_SPECIAL_CHARS,
  1679. REGEX_SPECIAL_CHARS_BACKREF,
  1680. REPLACEMENTS
  1681. } = constants$1;
  1682. /**
  1683. * Helpers
  1684. */
  1685. const expandRange = (args, options) => {
  1686. if (typeof options.expandRange === 'function') {
  1687. return options.expandRange(...args, options);
  1688. }
  1689. args.sort();
  1690. const value = `[${args.join('-')}]`;
  1691. return value;
  1692. };
  1693. /**
  1694. * Create the message for a syntax error
  1695. */
  1696. const syntaxError = (type, char) => {
  1697. return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
  1698. };
  1699. /**
  1700. * Parse the given input string.
  1701. * @param {String} input
  1702. * @param {Object} options
  1703. * @return {Object}
  1704. */
  1705. const parse$2 = (input, options) => {
  1706. if (typeof input !== 'string') {
  1707. throw new TypeError('Expected a string');
  1708. }
  1709. input = REPLACEMENTS[input] || input;
  1710. const opts = { ...options };
  1711. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  1712. let len = input.length;
  1713. if (len > max) {
  1714. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  1715. }
  1716. const bos = { type: 'bos', value: '', output: opts.prepend || '' };
  1717. const tokens = [bos];
  1718. const capture = opts.capture ? '' : '?:';
  1719. const win32 = utils$1.isWindows(options);
  1720. // create constants based on platform, for windows or posix
  1721. const PLATFORM_CHARS = constants$1.globChars(win32);
  1722. const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
  1723. const {
  1724. DOT_LITERAL,
  1725. PLUS_LITERAL,
  1726. SLASH_LITERAL,
  1727. ONE_CHAR,
  1728. DOTS_SLASH,
  1729. NO_DOT,
  1730. NO_DOT_SLASH,
  1731. NO_DOTS_SLASH,
  1732. QMARK,
  1733. QMARK_NO_DOT,
  1734. STAR,
  1735. START_ANCHOR
  1736. } = PLATFORM_CHARS;
  1737. const globstar = opts => {
  1738. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  1739. };
  1740. const nodot = opts.dot ? '' : NO_DOT;
  1741. const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
  1742. let star = opts.bash === true ? globstar(opts) : STAR;
  1743. if (opts.capture) {
  1744. star = `(${star})`;
  1745. }
  1746. // minimatch options support
  1747. if (typeof opts.noext === 'boolean') {
  1748. opts.noextglob = opts.noext;
  1749. }
  1750. const state = {
  1751. input,
  1752. index: -1,
  1753. start: 0,
  1754. dot: opts.dot === true,
  1755. consumed: '',
  1756. output: '',
  1757. prefix: '',
  1758. backtrack: false,
  1759. negated: false,
  1760. brackets: 0,
  1761. braces: 0,
  1762. parens: 0,
  1763. quotes: 0,
  1764. globstar: false,
  1765. tokens
  1766. };
  1767. input = utils$1.removePrefix(input, state);
  1768. len = input.length;
  1769. const extglobs = [];
  1770. const braces = [];
  1771. const stack = [];
  1772. let prev = bos;
  1773. let value;
  1774. /**
  1775. * Tokenizing helpers
  1776. */
  1777. const eos = () => state.index === len - 1;
  1778. const peek = state.peek = (n = 1) => input[state.index + n];
  1779. const advance = state.advance = () => input[++state.index] || '';
  1780. const remaining = () => input.slice(state.index + 1);
  1781. const consume = (value = '', num = 0) => {
  1782. state.consumed += value;
  1783. state.index += num;
  1784. };
  1785. const append = token => {
  1786. state.output += token.output != null ? token.output : token.value;
  1787. consume(token.value);
  1788. };
  1789. const negate = () => {
  1790. let count = 1;
  1791. while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
  1792. advance();
  1793. state.start++;
  1794. count++;
  1795. }
  1796. if (count % 2 === 0) {
  1797. return false;
  1798. }
  1799. state.negated = true;
  1800. state.start++;
  1801. return true;
  1802. };
  1803. const increment = type => {
  1804. state[type]++;
  1805. stack.push(type);
  1806. };
  1807. const decrement = type => {
  1808. state[type]--;
  1809. stack.pop();
  1810. };
  1811. /**
  1812. * Push tokens onto the tokens array. This helper speeds up
  1813. * tokenizing by 1) helping us avoid backtracking as much as possible,
  1814. * and 2) helping us avoid creating extra tokens when consecutive
  1815. * characters are plain text. This improves performance and simplifies
  1816. * lookbehinds.
  1817. */
  1818. const push = tok => {
  1819. if (prev.type === 'globstar') {
  1820. const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
  1821. const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
  1822. if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
  1823. state.output = state.output.slice(0, -prev.output.length);
  1824. prev.type = 'star';
  1825. prev.value = '*';
  1826. prev.output = star;
  1827. state.output += prev.output;
  1828. }
  1829. }
  1830. if (extglobs.length && tok.type !== 'paren') {
  1831. extglobs[extglobs.length - 1].inner += tok.value;
  1832. }
  1833. if (tok.value || tok.output) append(tok);
  1834. if (prev && prev.type === 'text' && tok.type === 'text') {
  1835. prev.value += tok.value;
  1836. prev.output = (prev.output || '') + tok.value;
  1837. return;
  1838. }
  1839. tok.prev = prev;
  1840. tokens.push(tok);
  1841. prev = tok;
  1842. };
  1843. const extglobOpen = (type, value) => {
  1844. const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
  1845. token.prev = prev;
  1846. token.parens = state.parens;
  1847. token.output = state.output;
  1848. const output = (opts.capture ? '(' : '') + token.open;
  1849. increment('parens');
  1850. push({ type, value, output: state.output ? '' : ONE_CHAR });
  1851. push({ type: 'paren', extglob: true, value: advance(), output });
  1852. extglobs.push(token);
  1853. };
  1854. const extglobClose = token => {
  1855. let output = token.close + (opts.capture ? ')' : '');
  1856. let rest;
  1857. if (token.type === 'negate') {
  1858. let extglobStar = star;
  1859. if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
  1860. extglobStar = globstar(opts);
  1861. }
  1862. if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
  1863. output = token.close = `)$))${extglobStar}`;
  1864. }
  1865. if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
  1866. // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
  1867. // In this case, we need to parse the string and use it in the output of the original pattern.
  1868. // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
  1869. //
  1870. // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
  1871. const expression = parse$2(rest, { ...options, fastpaths: false }).output;
  1872. output = token.close = `)${expression})${extglobStar})`;
  1873. }
  1874. if (token.prev.type === 'bos') {
  1875. state.negatedExtglob = true;
  1876. }
  1877. }
  1878. push({ type: 'paren', extglob: true, value, output });
  1879. decrement('parens');
  1880. };
  1881. /**
  1882. * Fast paths
  1883. */
  1884. if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
  1885. let backslashes = false;
  1886. let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
  1887. if (first === '\\') {
  1888. backslashes = true;
  1889. return m;
  1890. }
  1891. if (first === '?') {
  1892. if (esc) {
  1893. return esc + first + (rest ? QMARK.repeat(rest.length) : '');
  1894. }
  1895. if (index === 0) {
  1896. return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
  1897. }
  1898. return QMARK.repeat(chars.length);
  1899. }
  1900. if (first === '.') {
  1901. return DOT_LITERAL.repeat(chars.length);
  1902. }
  1903. if (first === '*') {
  1904. if (esc) {
  1905. return esc + first + (rest ? star : '');
  1906. }
  1907. return star;
  1908. }
  1909. return esc ? m : `\\${m}`;
  1910. });
  1911. if (backslashes === true) {
  1912. if (opts.unescape === true) {
  1913. output = output.replace(/\\/g, '');
  1914. } else {
  1915. output = output.replace(/\\+/g, m => {
  1916. return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
  1917. });
  1918. }
  1919. }
  1920. if (output === input && opts.contains === true) {
  1921. state.output = input;
  1922. return state;
  1923. }
  1924. state.output = utils$1.wrapOutput(output, state, options);
  1925. return state;
  1926. }
  1927. /**
  1928. * Tokenize input until we reach end-of-string
  1929. */
  1930. while (!eos()) {
  1931. value = advance();
  1932. if (value === '\u0000') {
  1933. continue;
  1934. }
  1935. /**
  1936. * Escaped characters
  1937. */
  1938. if (value === '\\') {
  1939. const next = peek();
  1940. if (next === '/' && opts.bash !== true) {
  1941. continue;
  1942. }
  1943. if (next === '.' || next === ';') {
  1944. continue;
  1945. }
  1946. if (!next) {
  1947. value += '\\';
  1948. push({ type: 'text', value });
  1949. continue;
  1950. }
  1951. // collapse slashes to reduce potential for exploits
  1952. const match = /^\\+/.exec(remaining());
  1953. let slashes = 0;
  1954. if (match && match[0].length > 2) {
  1955. slashes = match[0].length;
  1956. state.index += slashes;
  1957. if (slashes % 2 !== 0) {
  1958. value += '\\';
  1959. }
  1960. }
  1961. if (opts.unescape === true) {
  1962. value = advance();
  1963. } else {
  1964. value += advance();
  1965. }
  1966. if (state.brackets === 0) {
  1967. push({ type: 'text', value });
  1968. continue;
  1969. }
  1970. }
  1971. /**
  1972. * If we're inside a regex character class, continue
  1973. * until we reach the closing bracket.
  1974. */
  1975. if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
  1976. if (opts.posix !== false && value === ':') {
  1977. const inner = prev.value.slice(1);
  1978. if (inner.includes('[')) {
  1979. prev.posix = true;
  1980. if (inner.includes(':')) {
  1981. const idx = prev.value.lastIndexOf('[');
  1982. const pre = prev.value.slice(0, idx);
  1983. const rest = prev.value.slice(idx + 2);
  1984. const posix = POSIX_REGEX_SOURCE[rest];
  1985. if (posix) {
  1986. prev.value = pre + posix;
  1987. state.backtrack = true;
  1988. advance();
  1989. if (!bos.output && tokens.indexOf(prev) === 1) {
  1990. bos.output = ONE_CHAR;
  1991. }
  1992. continue;
  1993. }
  1994. }
  1995. }
  1996. }
  1997. if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
  1998. value = `\\${value}`;
  1999. }
  2000. if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
  2001. value = `\\${value}`;
  2002. }
  2003. if (opts.posix === true && value === '!' && prev.value === '[') {
  2004. value = '^';
  2005. }
  2006. prev.value += value;
  2007. append({ value });
  2008. continue;
  2009. }
  2010. /**
  2011. * If we're inside a quoted string, continue
  2012. * until we reach the closing double quote.
  2013. */
  2014. if (state.quotes === 1 && value !== '"') {
  2015. value = utils$1.escapeRegex(value);
  2016. prev.value += value;
  2017. append({ value });
  2018. continue;
  2019. }
  2020. /**
  2021. * Double quotes
  2022. */
  2023. if (value === '"') {
  2024. state.quotes = state.quotes === 1 ? 0 : 1;
  2025. if (opts.keepQuotes === true) {
  2026. push({ type: 'text', value });
  2027. }
  2028. continue;
  2029. }
  2030. /**
  2031. * Parentheses
  2032. */
  2033. if (value === '(') {
  2034. increment('parens');
  2035. push({ type: 'paren', value });
  2036. continue;
  2037. }
  2038. if (value === ')') {
  2039. if (state.parens === 0 && opts.strictBrackets === true) {
  2040. throw new SyntaxError(syntaxError('opening', '('));
  2041. }
  2042. const extglob = extglobs[extglobs.length - 1];
  2043. if (extglob && state.parens === extglob.parens + 1) {
  2044. extglobClose(extglobs.pop());
  2045. continue;
  2046. }
  2047. push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
  2048. decrement('parens');
  2049. continue;
  2050. }
  2051. /**
  2052. * Square brackets
  2053. */
  2054. if (value === '[') {
  2055. if (opts.nobracket === true || !remaining().includes(']')) {
  2056. if (opts.nobracket !== true && opts.strictBrackets === true) {
  2057. throw new SyntaxError(syntaxError('closing', ']'));
  2058. }
  2059. value = `\\${value}`;
  2060. } else {
  2061. increment('brackets');
  2062. }
  2063. push({ type: 'bracket', value });
  2064. continue;
  2065. }
  2066. if (value === ']') {
  2067. if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
  2068. push({ type: 'text', value, output: `\\${value}` });
  2069. continue;
  2070. }
  2071. if (state.brackets === 0) {
  2072. if (opts.strictBrackets === true) {
  2073. throw new SyntaxError(syntaxError('opening', '['));
  2074. }
  2075. push({ type: 'text', value, output: `\\${value}` });
  2076. continue;
  2077. }
  2078. decrement('brackets');
  2079. const prevValue = prev.value.slice(1);
  2080. if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
  2081. value = `/${value}`;
  2082. }
  2083. prev.value += value;
  2084. append({ value });
  2085. // when literal brackets are explicitly disabled
  2086. // assume we should match with a regex character class
  2087. if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
  2088. continue;
  2089. }
  2090. const escaped = utils$1.escapeRegex(prev.value);
  2091. state.output = state.output.slice(0, -prev.value.length);
  2092. // when literal brackets are explicitly enabled
  2093. // assume we should escape the brackets to match literal characters
  2094. if (opts.literalBrackets === true) {
  2095. state.output += escaped;
  2096. prev.value = escaped;
  2097. continue;
  2098. }
  2099. // when the user specifies nothing, try to match both
  2100. prev.value = `(${capture}${escaped}|${prev.value})`;
  2101. state.output += prev.value;
  2102. continue;
  2103. }
  2104. /**
  2105. * Braces
  2106. */
  2107. if (value === '{' && opts.nobrace !== true) {
  2108. increment('braces');
  2109. const open = {
  2110. type: 'brace',
  2111. value,
  2112. output: '(',
  2113. outputIndex: state.output.length,
  2114. tokensIndex: state.tokens.length
  2115. };
  2116. braces.push(open);
  2117. push(open);
  2118. continue;
  2119. }
  2120. if (value === '}') {
  2121. const brace = braces[braces.length - 1];
  2122. if (opts.nobrace === true || !brace) {
  2123. push({ type: 'text', value, output: value });
  2124. continue;
  2125. }
  2126. let output = ')';
  2127. if (brace.dots === true) {
  2128. const arr = tokens.slice();
  2129. const range = [];
  2130. for (let i = arr.length - 1; i >= 0; i--) {
  2131. tokens.pop();
  2132. if (arr[i].type === 'brace') {
  2133. break;
  2134. }
  2135. if (arr[i].type !== 'dots') {
  2136. range.unshift(arr[i].value);
  2137. }
  2138. }
  2139. output = expandRange(range, opts);
  2140. state.backtrack = true;
  2141. }
  2142. if (brace.comma !== true && brace.dots !== true) {
  2143. const out = state.output.slice(0, brace.outputIndex);
  2144. const toks = state.tokens.slice(brace.tokensIndex);
  2145. brace.value = brace.output = '\\{';
  2146. value = output = '\\}';
  2147. state.output = out;
  2148. for (const t of toks) {
  2149. state.output += (t.output || t.value);
  2150. }
  2151. }
  2152. push({ type: 'brace', value, output });
  2153. decrement('braces');
  2154. braces.pop();
  2155. continue;
  2156. }
  2157. /**
  2158. * Pipes
  2159. */
  2160. if (value === '|') {
  2161. if (extglobs.length > 0) {
  2162. extglobs[extglobs.length - 1].conditions++;
  2163. }
  2164. push({ type: 'text', value });
  2165. continue;
  2166. }
  2167. /**
  2168. * Commas
  2169. */
  2170. if (value === ',') {
  2171. let output = value;
  2172. const brace = braces[braces.length - 1];
  2173. if (brace && stack[stack.length - 1] === 'braces') {
  2174. brace.comma = true;
  2175. output = '|';
  2176. }
  2177. push({ type: 'comma', value, output });
  2178. continue;
  2179. }
  2180. /**
  2181. * Slashes
  2182. */
  2183. if (value === '/') {
  2184. // if the beginning of the glob is "./", advance the start
  2185. // to the current index, and don't add the "./" characters
  2186. // to the state. This greatly simplifies lookbehinds when
  2187. // checking for BOS characters like "!" and "." (not "./")
  2188. if (prev.type === 'dot' && state.index === state.start + 1) {
  2189. state.start = state.index + 1;
  2190. state.consumed = '';
  2191. state.output = '';
  2192. tokens.pop();
  2193. prev = bos; // reset "prev" to the first token
  2194. continue;
  2195. }
  2196. push({ type: 'slash', value, output: SLASH_LITERAL });
  2197. continue;
  2198. }
  2199. /**
  2200. * Dots
  2201. */
  2202. if (value === '.') {
  2203. if (state.braces > 0 && prev.type === 'dot') {
  2204. if (prev.value === '.') prev.output = DOT_LITERAL;
  2205. const brace = braces[braces.length - 1];
  2206. prev.type = 'dots';
  2207. prev.output += value;
  2208. prev.value += value;
  2209. brace.dots = true;
  2210. continue;
  2211. }
  2212. if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
  2213. push({ type: 'text', value, output: DOT_LITERAL });
  2214. continue;
  2215. }
  2216. push({ type: 'dot', value, output: DOT_LITERAL });
  2217. continue;
  2218. }
  2219. /**
  2220. * Question marks
  2221. */
  2222. if (value === '?') {
  2223. const isGroup = prev && prev.value === '(';
  2224. if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  2225. extglobOpen('qmark', value);
  2226. continue;
  2227. }
  2228. if (prev && prev.type === 'paren') {
  2229. const next = peek();
  2230. let output = value;
  2231. if (next === '<' && !utils$1.supportsLookbehinds()) {
  2232. throw new Error('Node.js v10 or higher is required for regex lookbehinds');
  2233. }
  2234. if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
  2235. output = `\\${value}`;
  2236. }
  2237. push({ type: 'text', value, output });
  2238. continue;
  2239. }
  2240. if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
  2241. push({ type: 'qmark', value, output: QMARK_NO_DOT });
  2242. continue;
  2243. }
  2244. push({ type: 'qmark', value, output: QMARK });
  2245. continue;
  2246. }
  2247. /**
  2248. * Exclamation
  2249. */
  2250. if (value === '!') {
  2251. if (opts.noextglob !== true && peek() === '(') {
  2252. if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
  2253. extglobOpen('negate', value);
  2254. continue;
  2255. }
  2256. }
  2257. if (opts.nonegate !== true && state.index === 0) {
  2258. negate();
  2259. continue;
  2260. }
  2261. }
  2262. /**
  2263. * Plus
  2264. */
  2265. if (value === '+') {
  2266. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  2267. extglobOpen('plus', value);
  2268. continue;
  2269. }
  2270. if ((prev && prev.value === '(') || opts.regex === false) {
  2271. push({ type: 'plus', value, output: PLUS_LITERAL });
  2272. continue;
  2273. }
  2274. if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
  2275. push({ type: 'plus', value });
  2276. continue;
  2277. }
  2278. push({ type: 'plus', value: PLUS_LITERAL });
  2279. continue;
  2280. }
  2281. /**
  2282. * Plain text
  2283. */
  2284. if (value === '@') {
  2285. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  2286. push({ type: 'at', extglob: true, value, output: '' });
  2287. continue;
  2288. }
  2289. push({ type: 'text', value });
  2290. continue;
  2291. }
  2292. /**
  2293. * Plain text
  2294. */
  2295. if (value !== '*') {
  2296. if (value === '$' || value === '^') {
  2297. value = `\\${value}`;
  2298. }
  2299. const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
  2300. if (match) {
  2301. value += match[0];
  2302. state.index += match[0].length;
  2303. }
  2304. push({ type: 'text', value });
  2305. continue;
  2306. }
  2307. /**
  2308. * Stars
  2309. */
  2310. if (prev && (prev.type === 'globstar' || prev.star === true)) {
  2311. prev.type = 'star';
  2312. prev.star = true;
  2313. prev.value += value;
  2314. prev.output = star;
  2315. state.backtrack = true;
  2316. state.globstar = true;
  2317. consume(value);
  2318. continue;
  2319. }
  2320. let rest = remaining();
  2321. if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
  2322. extglobOpen('star', value);
  2323. continue;
  2324. }
  2325. if (prev.type === 'star') {
  2326. if (opts.noglobstar === true) {
  2327. consume(value);
  2328. continue;
  2329. }
  2330. const prior = prev.prev;
  2331. const before = prior.prev;
  2332. const isStart = prior.type === 'slash' || prior.type === 'bos';
  2333. const afterStar = before && (before.type === 'star' || before.type === 'globstar');
  2334. if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
  2335. push({ type: 'star', value, output: '' });
  2336. continue;
  2337. }
  2338. const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
  2339. const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
  2340. if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
  2341. push({ type: 'star', value, output: '' });
  2342. continue;
  2343. }
  2344. // strip consecutive `/**/`
  2345. while (rest.slice(0, 3) === '/**') {
  2346. const after = input[state.index + 4];
  2347. if (after && after !== '/') {
  2348. break;
  2349. }
  2350. rest = rest.slice(3);
  2351. consume('/**', 3);
  2352. }
  2353. if (prior.type === 'bos' && eos()) {
  2354. prev.type = 'globstar';
  2355. prev.value += value;
  2356. prev.output = globstar(opts);
  2357. state.output = prev.output;
  2358. state.globstar = true;
  2359. consume(value);
  2360. continue;
  2361. }
  2362. if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
  2363. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  2364. prior.output = `(?:${prior.output}`;
  2365. prev.type = 'globstar';
  2366. prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
  2367. prev.value += value;
  2368. state.globstar = true;
  2369. state.output += prior.output + prev.output;
  2370. consume(value);
  2371. continue;
  2372. }
  2373. if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
  2374. const end = rest[1] !== void 0 ? '|$' : '';
  2375. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  2376. prior.output = `(?:${prior.output}`;
  2377. prev.type = 'globstar';
  2378. prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
  2379. prev.value += value;
  2380. state.output += prior.output + prev.output;
  2381. state.globstar = true;
  2382. consume(value + advance());
  2383. push({ type: 'slash', value: '/', output: '' });
  2384. continue;
  2385. }
  2386. if (prior.type === 'bos' && rest[0] === '/') {
  2387. prev.type = 'globstar';
  2388. prev.value += value;
  2389. prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
  2390. state.output = prev.output;
  2391. state.globstar = true;
  2392. consume(value + advance());
  2393. push({ type: 'slash', value: '/', output: '' });
  2394. continue;
  2395. }
  2396. // remove single star from output
  2397. state.output = state.output.slice(0, -prev.output.length);
  2398. // reset previous token to globstar
  2399. prev.type = 'globstar';
  2400. prev.output = globstar(opts);
  2401. prev.value += value;
  2402. // reset output with globstar
  2403. state.output += prev.output;
  2404. state.globstar = true;
  2405. consume(value);
  2406. continue;
  2407. }
  2408. const token = { type: 'star', value, output: star };
  2409. if (opts.bash === true) {
  2410. token.output = '.*?';
  2411. if (prev.type === 'bos' || prev.type === 'slash') {
  2412. token.output = nodot + token.output;
  2413. }
  2414. push(token);
  2415. continue;
  2416. }
  2417. if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
  2418. token.output = value;
  2419. push(token);
  2420. continue;
  2421. }
  2422. if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
  2423. if (prev.type === 'dot') {
  2424. state.output += NO_DOT_SLASH;
  2425. prev.output += NO_DOT_SLASH;
  2426. } else if (opts.dot === true) {
  2427. state.output += NO_DOTS_SLASH;
  2428. prev.output += NO_DOTS_SLASH;
  2429. } else {
  2430. state.output += nodot;
  2431. prev.output += nodot;
  2432. }
  2433. if (peek() !== '*') {
  2434. state.output += ONE_CHAR;
  2435. prev.output += ONE_CHAR;
  2436. }
  2437. }
  2438. push(token);
  2439. }
  2440. while (state.brackets > 0) {
  2441. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
  2442. state.output = utils$1.escapeLast(state.output, '[');
  2443. decrement('brackets');
  2444. }
  2445. while (state.parens > 0) {
  2446. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
  2447. state.output = utils$1.escapeLast(state.output, '(');
  2448. decrement('parens');
  2449. }
  2450. while (state.braces > 0) {
  2451. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
  2452. state.output = utils$1.escapeLast(state.output, '{');
  2453. decrement('braces');
  2454. }
  2455. if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
  2456. push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
  2457. }
  2458. // rebuild the output if we had to backtrack at any point
  2459. if (state.backtrack === true) {
  2460. state.output = '';
  2461. for (const token of state.tokens) {
  2462. state.output += token.output != null ? token.output : token.value;
  2463. if (token.suffix) {
  2464. state.output += token.suffix;
  2465. }
  2466. }
  2467. }
  2468. return state;
  2469. };
  2470. /**
  2471. * Fast paths for creating regular expressions for common glob patterns.
  2472. * This can significantly speed up processing and has very little downside
  2473. * impact when none of the fast paths match.
  2474. */
  2475. parse$2.fastpaths = (input, options) => {
  2476. const opts = { ...options };
  2477. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  2478. const len = input.length;
  2479. if (len > max) {
  2480. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  2481. }
  2482. input = REPLACEMENTS[input] || input;
  2483. const win32 = utils$1.isWindows(options);
  2484. // create constants based on platform, for windows or posix
  2485. const {
  2486. DOT_LITERAL,
  2487. SLASH_LITERAL,
  2488. ONE_CHAR,
  2489. DOTS_SLASH,
  2490. NO_DOT,
  2491. NO_DOTS,
  2492. NO_DOTS_SLASH,
  2493. STAR,
  2494. START_ANCHOR
  2495. } = constants$1.globChars(win32);
  2496. const nodot = opts.dot ? NO_DOTS : NO_DOT;
  2497. const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
  2498. const capture = opts.capture ? '' : '?:';
  2499. const state = { negated: false, prefix: '' };
  2500. let star = opts.bash === true ? '.*?' : STAR;
  2501. if (opts.capture) {
  2502. star = `(${star})`;
  2503. }
  2504. const globstar = opts => {
  2505. if (opts.noglobstar === true) return star;
  2506. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  2507. };
  2508. const create = str => {
  2509. switch (str) {
  2510. case '*':
  2511. return `${nodot}${ONE_CHAR}${star}`;
  2512. case '.*':
  2513. return `${DOT_LITERAL}${ONE_CHAR}${star}`;
  2514. case '*.*':
  2515. return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  2516. case '*/*':
  2517. return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
  2518. case '**':
  2519. return nodot + globstar(opts);
  2520. case '**/*':
  2521. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
  2522. case '**/*.*':
  2523. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  2524. case '**/.*':
  2525. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
  2526. default: {
  2527. const match = /^(.*?)\.(\w+)$/.exec(str);
  2528. if (!match) return;
  2529. const source = create(match[1]);
  2530. if (!source) return;
  2531. return source + DOT_LITERAL + match[2];
  2532. }
  2533. }
  2534. };
  2535. const output = utils$1.removePrefix(input, state);
  2536. let source = create(output);
  2537. if (source && opts.strictSlashes !== true) {
  2538. source += `${SLASH_LITERAL}?`;
  2539. }
  2540. return source;
  2541. };
  2542. var parse_1$1 = parse$2;
  2543. const path$1 = require$$0$1;
  2544. const scan = scan_1;
  2545. const parse$1 = parse_1$1;
  2546. const utils = utils$3;
  2547. const constants = constants$2;
  2548. const isObject$1 = val => val && typeof val === 'object' && !Array.isArray(val);
  2549. /**
  2550. * Creates a matcher function from one or more glob patterns. The
  2551. * returned function takes a string to match as its first argument,
  2552. * and returns true if the string is a match. The returned matcher
  2553. * function also takes a boolean as the second argument that, when true,
  2554. * returns an object with additional information.
  2555. *
  2556. * ```js
  2557. * const picomatch = require('picomatch');
  2558. * // picomatch(glob[, options]);
  2559. *
  2560. * const isMatch = picomatch('*.!(*a)');
  2561. * console.log(isMatch('a.a')); //=> false
  2562. * console.log(isMatch('a.b')); //=> true
  2563. * ```
  2564. * @name picomatch
  2565. * @param {String|Array} `globs` One or more glob patterns.
  2566. * @param {Object=} `options`
  2567. * @return {Function=} Returns a matcher function.
  2568. * @api public
  2569. */
  2570. const picomatch = (glob, options, returnState = false) => {
  2571. if (Array.isArray(glob)) {
  2572. const fns = glob.map(input => picomatch(input, options, returnState));
  2573. const arrayMatcher = str => {
  2574. for (const isMatch of fns) {
  2575. const state = isMatch(str);
  2576. if (state) return state;
  2577. }
  2578. return false;
  2579. };
  2580. return arrayMatcher;
  2581. }
  2582. const isState = isObject$1(glob) && glob.tokens && glob.input;
  2583. if (glob === '' || (typeof glob !== 'string' && !isState)) {
  2584. throw new TypeError('Expected pattern to be a non-empty string');
  2585. }
  2586. const opts = options || {};
  2587. const posix = utils.isWindows(options);
  2588. const regex = isState
  2589. ? picomatch.compileRe(glob, options)
  2590. : picomatch.makeRe(glob, options, false, true);
  2591. const state = regex.state;
  2592. delete regex.state;
  2593. let isIgnored = () => false;
  2594. if (opts.ignore) {
  2595. const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
  2596. isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
  2597. }
  2598. const matcher = (input, returnObject = false) => {
  2599. const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
  2600. const result = { glob, state, regex, posix, input, output, match, isMatch };
  2601. if (typeof opts.onResult === 'function') {
  2602. opts.onResult(result);
  2603. }
  2604. if (isMatch === false) {
  2605. result.isMatch = false;
  2606. return returnObject ? result : false;
  2607. }
  2608. if (isIgnored(input)) {
  2609. if (typeof opts.onIgnore === 'function') {
  2610. opts.onIgnore(result);
  2611. }
  2612. result.isMatch = false;
  2613. return returnObject ? result : false;
  2614. }
  2615. if (typeof opts.onMatch === 'function') {
  2616. opts.onMatch(result);
  2617. }
  2618. return returnObject ? result : true;
  2619. };
  2620. if (returnState) {
  2621. matcher.state = state;
  2622. }
  2623. return matcher;
  2624. };
  2625. /**
  2626. * Test `input` with the given `regex`. This is used by the main
  2627. * `picomatch()` function to test the input string.
  2628. *
  2629. * ```js
  2630. * const picomatch = require('picomatch');
  2631. * // picomatch.test(input, regex[, options]);
  2632. *
  2633. * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
  2634. * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
  2635. * ```
  2636. * @param {String} `input` String to test.
  2637. * @param {RegExp} `regex`
  2638. * @return {Object} Returns an object with matching info.
  2639. * @api public
  2640. */
  2641. picomatch.test = (input, regex, options, { glob, posix } = {}) => {
  2642. if (typeof input !== 'string') {
  2643. throw new TypeError('Expected input to be a string');
  2644. }
  2645. if (input === '') {
  2646. return { isMatch: false, output: '' };
  2647. }
  2648. const opts = options || {};
  2649. const format = opts.format || (posix ? utils.toPosixSlashes : null);
  2650. let match = input === glob;
  2651. let output = (match && format) ? format(input) : input;
  2652. if (match === false) {
  2653. output = format ? format(input) : input;
  2654. match = output === glob;
  2655. }
  2656. if (match === false || opts.capture === true) {
  2657. if (opts.matchBase === true || opts.basename === true) {
  2658. match = picomatch.matchBase(input, regex, options, posix);
  2659. } else {
  2660. match = regex.exec(output);
  2661. }
  2662. }
  2663. return { isMatch: Boolean(match), match, output };
  2664. };
  2665. /**
  2666. * Match the basename of a filepath.
  2667. *
  2668. * ```js
  2669. * const picomatch = require('picomatch');
  2670. * // picomatch.matchBase(input, glob[, options]);
  2671. * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
  2672. * ```
  2673. * @param {String} `input` String to test.
  2674. * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
  2675. * @return {Boolean}
  2676. * @api public
  2677. */
  2678. picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
  2679. const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
  2680. return regex.test(path$1.basename(input));
  2681. };
  2682. /**
  2683. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  2684. *
  2685. * ```js
  2686. * const picomatch = require('picomatch');
  2687. * // picomatch.isMatch(string, patterns[, options]);
  2688. *
  2689. * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
  2690. * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
  2691. * ```
  2692. * @param {String|Array} str The string to test.
  2693. * @param {String|Array} patterns One or more glob patterns to use for matching.
  2694. * @param {Object} [options] See available [options](#options).
  2695. * @return {Boolean} Returns true if any patterns match `str`
  2696. * @api public
  2697. */
  2698. picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
  2699. /**
  2700. * Parse a glob pattern to create the source string for a regular
  2701. * expression.
  2702. *
  2703. * ```js
  2704. * const picomatch = require('picomatch');
  2705. * const result = picomatch.parse(pattern[, options]);
  2706. * ```
  2707. * @param {String} `pattern`
  2708. * @param {Object} `options`
  2709. * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
  2710. * @api public
  2711. */
  2712. picomatch.parse = (pattern, options) => {
  2713. if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
  2714. return parse$1(pattern, { ...options, fastpaths: false });
  2715. };
  2716. /**
  2717. * Scan a glob pattern to separate the pattern into segments.
  2718. *
  2719. * ```js
  2720. * const picomatch = require('picomatch');
  2721. * // picomatch.scan(input[, options]);
  2722. *
  2723. * const result = picomatch.scan('!./foo/*.js');
  2724. * console.log(result);
  2725. * { prefix: '!./',
  2726. * input: '!./foo/*.js',
  2727. * start: 3,
  2728. * base: 'foo',
  2729. * glob: '*.js',
  2730. * isBrace: false,
  2731. * isBracket: false,
  2732. * isGlob: true,
  2733. * isExtglob: false,
  2734. * isGlobstar: false,
  2735. * negated: true }
  2736. * ```
  2737. * @param {String} `input` Glob pattern to scan.
  2738. * @param {Object} `options`
  2739. * @return {Object} Returns an object with
  2740. * @api public
  2741. */
  2742. picomatch.scan = (input, options) => scan(input, options);
  2743. /**
  2744. * Compile a regular expression from the `state` object returned by the
  2745. * [parse()](#parse) method.
  2746. *
  2747. * @param {Object} `state`
  2748. * @param {Object} `options`
  2749. * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
  2750. * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
  2751. * @return {RegExp}
  2752. * @api public
  2753. */
  2754. picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
  2755. if (returnOutput === true) {
  2756. return state.output;
  2757. }
  2758. const opts = options || {};
  2759. const prepend = opts.contains ? '' : '^';
  2760. const append = opts.contains ? '' : '$';
  2761. let source = `${prepend}(?:${state.output})${append}`;
  2762. if (state && state.negated === true) {
  2763. source = `^(?!${source}).*$`;
  2764. }
  2765. const regex = picomatch.toRegex(source, options);
  2766. if (returnState === true) {
  2767. regex.state = state;
  2768. }
  2769. return regex;
  2770. };
  2771. /**
  2772. * Create a regular expression from a parsed glob pattern.
  2773. *
  2774. * ```js
  2775. * const picomatch = require('picomatch');
  2776. * const state = picomatch.parse('*.js');
  2777. * // picomatch.compileRe(state[, options]);
  2778. *
  2779. * console.log(picomatch.compileRe(state));
  2780. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  2781. * ```
  2782. * @param {String} `state` The object returned from the `.parse` method.
  2783. * @param {Object} `options`
  2784. * @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.
  2785. * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
  2786. * @return {RegExp} Returns a regex created from the given pattern.
  2787. * @api public
  2788. */
  2789. picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
  2790. if (!input || typeof input !== 'string') {
  2791. throw new TypeError('Expected a non-empty string');
  2792. }
  2793. let parsed = { negated: false, fastpaths: true };
  2794. if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
  2795. parsed.output = parse$1.fastpaths(input, options);
  2796. }
  2797. if (!parsed.output) {
  2798. parsed = parse$1(input, options);
  2799. }
  2800. return picomatch.compileRe(parsed, options, returnOutput, returnState);
  2801. };
  2802. /**
  2803. * Create a regular expression from the given regex source string.
  2804. *
  2805. * ```js
  2806. * const picomatch = require('picomatch');
  2807. * // picomatch.toRegex(source[, options]);
  2808. *
  2809. * const { output } = picomatch.parse('*.js');
  2810. * console.log(picomatch.toRegex(output));
  2811. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  2812. * ```
  2813. * @param {String} `source` Regular expression source string.
  2814. * @param {Object} `options`
  2815. * @return {RegExp}
  2816. * @api public
  2817. */
  2818. picomatch.toRegex = (source, options) => {
  2819. try {
  2820. const opts = options || {};
  2821. return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
  2822. } catch (err) {
  2823. if (options && options.debug === true) throw err;
  2824. return /$^/;
  2825. }
  2826. };
  2827. /**
  2828. * Picomatch constants.
  2829. * @return {Object}
  2830. */
  2831. picomatch.constants = constants;
  2832. /**
  2833. * Expose "picomatch"
  2834. */
  2835. var picomatch_1 = picomatch;
  2836. (function (module) {
  2837. module.exports = picomatch_1;
  2838. } (picomatch$1));
  2839. var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
  2840. // Helper since Typescript can't detect readonly arrays with Array.isArray
  2841. function isArray(arg) {
  2842. return Array.isArray(arg);
  2843. }
  2844. function ensureArray(thing) {
  2845. if (isArray(thing))
  2846. return thing;
  2847. if (thing == null)
  2848. return [];
  2849. return [thing];
  2850. }
  2851. const normalizePath$1 = function normalizePath(filename) {
  2852. return filename.split(require$$0$1.win32.sep).join(require$$0$1.posix.sep);
  2853. };
  2854. function getMatcherString(id, resolutionBase) {
  2855. if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('*')) {
  2856. return normalizePath$1(id);
  2857. }
  2858. // resolve('') is valid and will default to process.cwd()
  2859. const basePath = normalizePath$1(require$$0$1.resolve(resolutionBase || ''))
  2860. // escape all possible (posix + win) path characters that might interfere with regex
  2861. .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
  2862. // Note that we use posix.join because:
  2863. // 1. the basePath has been normalized to use /
  2864. // 2. the incoming glob (id) matcher, also uses /
  2865. // otherwise Node will force backslash (\) on windows
  2866. return require$$0$1.posix.join(basePath, normalizePath$1(id));
  2867. }
  2868. const createFilter$1 = function createFilter(include, exclude, options) {
  2869. const resolutionBase = options && options.resolve;
  2870. const getMatcher = (id) => id instanceof RegExp
  2871. ? id
  2872. : {
  2873. test: (what) => {
  2874. // this refactor is a tad overly verbose but makes for easy debugging
  2875. const pattern = getMatcherString(id, resolutionBase);
  2876. const fn = pm(pattern, { dot: true });
  2877. const result = fn(what);
  2878. return result;
  2879. }
  2880. };
  2881. const includeMatchers = ensureArray(include).map(getMatcher);
  2882. const excludeMatchers = ensureArray(exclude).map(getMatcher);
  2883. return function result(id) {
  2884. if (typeof id !== 'string')
  2885. return false;
  2886. if (/\0/.test(id))
  2887. return false;
  2888. const pathId = normalizePath$1(id);
  2889. for (let i = 0; i < excludeMatchers.length; ++i) {
  2890. const matcher = excludeMatchers[i];
  2891. if (matcher.test(pathId))
  2892. return false;
  2893. }
  2894. for (let i = 0; i < includeMatchers.length; ++i) {
  2895. const matcher = includeMatchers[i];
  2896. if (matcher.test(pathId))
  2897. return true;
  2898. }
  2899. return !includeMatchers.length;
  2900. };
  2901. };
  2902. 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';
  2903. 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';
  2904. const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
  2905. forbiddenIdentifiers.add('');
  2906. const createFilter = createFilter$1;
  2907. function slash(p) {
  2908. return p.replace(/\\/g, '/');
  2909. }
  2910. // TODO: use import()
  2911. const _require = node_module.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
  2912. try {
  2913. Boolean(_require('pnpapi'));
  2914. }
  2915. catch { }
  2916. // set in bin/vite.js
  2917. const filter = process.env.VITE_DEBUG_FILTER;
  2918. const DEBUG = process.env.DEBUG;
  2919. function createDebugger(namespace, options = {}) {
  2920. const log = debug(namespace);
  2921. const { onlyWhenFocused } = options;
  2922. const focus = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : namespace;
  2923. return (msg, ...args) => {
  2924. if (filter && !msg.includes(filter)) {
  2925. return;
  2926. }
  2927. if (onlyWhenFocused && !DEBUG?.includes(focus)) {
  2928. return;
  2929. }
  2930. log(msg, ...args);
  2931. };
  2932. }
  2933. function testCaseInsensitiveFS() {
  2934. if (!CLIENT_ENTRY.endsWith('client.mjs')) {
  2935. throw new Error(`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`);
  2936. }
  2937. if (!fs$1.existsSync(CLIENT_ENTRY)) {
  2938. throw new Error('cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: ' +
  2939. CLIENT_ENTRY);
  2940. }
  2941. return fs$1.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs'));
  2942. }
  2943. testCaseInsensitiveFS();
  2944. const isWindows = os$1.platform() === 'win32';
  2945. function normalizePath(id) {
  2946. return path$3.posix.normalize(isWindows ? slash(id) : id);
  2947. }
  2948. function isObject(value) {
  2949. return Object.prototype.toString.call(value) === '[object Object]';
  2950. }
  2951. function lookupFile(dir, formats, options) {
  2952. for (const format of formats) {
  2953. const fullPath = path$3.join(dir, format);
  2954. if (fs$1.existsSync(fullPath) && fs$1.statSync(fullPath).isFile()) {
  2955. const result = options?.pathOnly
  2956. ? fullPath
  2957. : fs$1.readFileSync(fullPath, 'utf-8');
  2958. if (!options?.predicate || options.predicate(result)) {
  2959. return result;
  2960. }
  2961. }
  2962. }
  2963. const parentDir = path$3.dirname(dir);
  2964. if (parentDir !== dir &&
  2965. (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
  2966. return lookupFile(parentDir, formats, options);
  2967. }
  2968. }
  2969. function isFileReadable(filename) {
  2970. try {
  2971. fs$1.accessSync(filename, fs$1.constants.R_OK);
  2972. return true;
  2973. }
  2974. catch {
  2975. return false;
  2976. }
  2977. }
  2978. isWindows
  2979. ? node_util.promisify(gracefulRemoveDir)
  2980. : function removeDirSync(dir) {
  2981. // when removing `.vite/deps`, if it doesn't exist, nodejs may also remove
  2982. // other directories within `.vite/`, including `.vite/deps_temp` (bug).
  2983. // workaround by checking for directory existence before removing for now.
  2984. if (fs$1.existsSync(dir)) {
  2985. fs$1.rmSync(dir, { recursive: true, force: true });
  2986. }
  2987. };
  2988. isWindows ? node_util.promisify(gracefulRename) : fs$1.renameSync;
  2989. function arraify(target) {
  2990. return Array.isArray(target) ? target : [target];
  2991. }
  2992. // @ts-expect-error jest only exists when running Jest
  2993. const usingDynamicImport = typeof jest === 'undefined';
  2994. /**
  2995. * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
  2996. *
  2997. * As a temporary workaround for Jest's lack of stable ESM support, we fallback to require
  2998. * if we're in a Jest environment.
  2999. * See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
  3000. *
  3001. * @param file File path to import.
  3002. */
  3003. usingDynamicImport
  3004. ? new Function('file', 'return import(file)')
  3005. : _require;
  3006. // Based on node-graceful-fs
  3007. // The ISC License
  3008. // Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
  3009. // https://github.com/isaacs/node-graceful-fs/blob/main/LICENSE
  3010. // On Windows, A/V software can lock the directory, causing this
  3011. // to fail with an EACCES or EPERM if the directory contains newly
  3012. // created files. The original tried for up to 60 seconds, we only
  3013. // wait for 5 seconds, as a longer time would be seen as an error
  3014. const GRACEFUL_RENAME_TIMEOUT = 5000;
  3015. function gracefulRename(from, to, cb) {
  3016. const start = Date.now();
  3017. let backoff = 0;
  3018. fs$1.rename(from, to, function CB(er) {
  3019. if (er &&
  3020. (er.code === 'EACCES' || er.code === 'EPERM') &&
  3021. Date.now() - start < GRACEFUL_RENAME_TIMEOUT) {
  3022. setTimeout(function () {
  3023. fs$1.stat(to, function (stater, st) {
  3024. if (stater && stater.code === 'ENOENT')
  3025. fs$1.rename(from, to, CB);
  3026. else
  3027. CB(er);
  3028. });
  3029. }, backoff);
  3030. if (backoff < 100)
  3031. backoff += 10;
  3032. return;
  3033. }
  3034. if (cb)
  3035. cb(er);
  3036. });
  3037. }
  3038. const GRACEFUL_REMOVE_DIR_TIMEOUT = 5000;
  3039. function gracefulRemoveDir(dir, cb) {
  3040. const start = Date.now();
  3041. let backoff = 0;
  3042. fs$1.rm(dir, { recursive: true }, function CB(er) {
  3043. if (er) {
  3044. if ((er.code === 'ENOTEMPTY' ||
  3045. er.code === 'EACCES' ||
  3046. er.code === 'EPERM') &&
  3047. Date.now() - start < GRACEFUL_REMOVE_DIR_TIMEOUT) {
  3048. setTimeout(function () {
  3049. fs$1.rm(dir, { recursive: true }, CB);
  3050. }, backoff);
  3051. if (backoff < 100)
  3052. backoff += 10;
  3053. return;
  3054. }
  3055. if (er.code === 'ENOENT') {
  3056. er = null;
  3057. }
  3058. }
  3059. if (cb)
  3060. cb(er);
  3061. });
  3062. }
  3063. function mergeConfigRecursively(defaults, overrides, rootPath) {
  3064. const merged = { ...defaults };
  3065. for (const key in overrides) {
  3066. const value = overrides[key];
  3067. if (value == null) {
  3068. continue;
  3069. }
  3070. const existing = merged[key];
  3071. if (existing == null) {
  3072. merged[key] = value;
  3073. continue;
  3074. }
  3075. // fields that require special handling
  3076. if (key === 'alias' && (rootPath === 'resolve' || rootPath === '')) {
  3077. merged[key] = mergeAlias(existing, value);
  3078. continue;
  3079. }
  3080. else if (key === 'assetsInclude' && rootPath === '') {
  3081. merged[key] = [].concat(existing, value);
  3082. continue;
  3083. }
  3084. else if (key === 'noExternal' &&
  3085. rootPath === 'ssr' &&
  3086. (existing === true || value === true)) {
  3087. merged[key] = true;
  3088. continue;
  3089. }
  3090. if (Array.isArray(existing) || Array.isArray(value)) {
  3091. merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
  3092. continue;
  3093. }
  3094. if (isObject(existing) && isObject(value)) {
  3095. merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
  3096. continue;
  3097. }
  3098. merged[key] = value;
  3099. }
  3100. return merged;
  3101. }
  3102. function mergeConfig(defaults, overrides, isRoot = true) {
  3103. return mergeConfigRecursively(defaults, overrides, isRoot ? '' : '.');
  3104. }
  3105. function mergeAlias(a, b) {
  3106. if (!a)
  3107. return b;
  3108. if (!b)
  3109. return a;
  3110. if (isObject(a) && isObject(b)) {
  3111. return { ...a, ...b };
  3112. }
  3113. // the order is flipped because the alias is resolved from top-down,
  3114. // where the later should have higher priority
  3115. return [...normalizeAlias(b), ...normalizeAlias(a)];
  3116. }
  3117. function normalizeAlias(o = []) {
  3118. return Array.isArray(o)
  3119. ? o.map(normalizeSingleAlias)
  3120. : Object.keys(o).map((find) => normalizeSingleAlias({
  3121. find,
  3122. replacement: o[find],
  3123. }));
  3124. }
  3125. // https://github.com/vitejs/vite/issues/1363
  3126. // work around https://github.com/rollup/plugins/issues/759
  3127. function normalizeSingleAlias({ find, replacement, customResolver, }) {
  3128. if (typeof find === 'string' &&
  3129. find.endsWith('/') &&
  3130. replacement.endsWith('/')) {
  3131. find = find.slice(0, find.length - 1);
  3132. replacement = replacement.slice(0, replacement.length - 1);
  3133. }
  3134. const alias = {
  3135. find,
  3136. replacement,
  3137. };
  3138. if (customResolver) {
  3139. alias.customResolver = customResolver;
  3140. }
  3141. return alias;
  3142. }
  3143. /*!
  3144. * etag
  3145. * Copyright(c) 2014-2016 Douglas Christopher Wilson
  3146. * MIT Licensed
  3147. */
  3148. /**
  3149. * Module exports.
  3150. * @public
  3151. */
  3152. var etag_1 = etag;
  3153. /**
  3154. * Module dependencies.
  3155. * @private
  3156. */
  3157. var crypto = require$$0$2;
  3158. var Stats = require$$1$1.Stats;
  3159. /**
  3160. * Module variables.
  3161. * @private
  3162. */
  3163. var toString = Object.prototype.toString;
  3164. /**
  3165. * Generate an entity tag.
  3166. *
  3167. * @param {Buffer|string} entity
  3168. * @return {string}
  3169. * @private
  3170. */
  3171. function entitytag (entity) {
  3172. if (entity.length === 0) {
  3173. // fast-path empty
  3174. return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"'
  3175. }
  3176. // compute hash of entity
  3177. var hash = crypto
  3178. .createHash('sha1')
  3179. .update(entity, 'utf8')
  3180. .digest('base64')
  3181. .substring(0, 27);
  3182. // compute length of entity
  3183. var len = typeof entity === 'string'
  3184. ? Buffer.byteLength(entity, 'utf8')
  3185. : entity.length;
  3186. return '"' + len.toString(16) + '-' + hash + '"'
  3187. }
  3188. /**
  3189. * Create a simple ETag.
  3190. *
  3191. * @param {string|Buffer|Stats} entity
  3192. * @param {object} [options]
  3193. * @param {boolean} [options.weak]
  3194. * @return {String}
  3195. * @public
  3196. */
  3197. function etag (entity, options) {
  3198. if (entity == null) {
  3199. throw new TypeError('argument entity is required')
  3200. }
  3201. // support fs.Stats object
  3202. var isStats = isstats(entity);
  3203. var weak = options && typeof options.weak === 'boolean'
  3204. ? options.weak
  3205. : isStats;
  3206. // validate argument
  3207. if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
  3208. throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
  3209. }
  3210. // generate entity tag
  3211. var tag = isStats
  3212. ? stattag(entity)
  3213. : entitytag(entity);
  3214. return weak
  3215. ? 'W/' + tag
  3216. : tag
  3217. }
  3218. /**
  3219. * Determine if object is a Stats object.
  3220. *
  3221. * @param {object} obj
  3222. * @return {boolean}
  3223. * @api private
  3224. */
  3225. function isstats (obj) {
  3226. // genuine fs.Stats
  3227. if (typeof Stats === 'function' && obj instanceof Stats) {
  3228. return true
  3229. }
  3230. // quack quack
  3231. return obj && typeof obj === 'object' &&
  3232. 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' &&
  3233. 'mtime' in obj && toString.call(obj.mtime) === '[object Date]' &&
  3234. 'ino' in obj && typeof obj.ino === 'number' &&
  3235. 'size' in obj && typeof obj.size === 'number'
  3236. }
  3237. /**
  3238. * Generate a tag for a stat.
  3239. *
  3240. * @param {object} stat
  3241. * @return {string}
  3242. * @private
  3243. */
  3244. function stattag (stat) {
  3245. var mtime = stat.mtime.getTime().toString(16);
  3246. var size = stat.size.toString(16);
  3247. return '"' + size + '-' + mtime + '"'
  3248. }
  3249. const isDebug = !!process.env.DEBUG;
  3250. createDebugger('vite:sourcemap', {
  3251. onlyWhenFocused: true,
  3252. });
  3253. function genSourceMapUrl(map) {
  3254. if (typeof map !== 'string') {
  3255. map = JSON.stringify(map);
  3256. }
  3257. return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
  3258. }
  3259. function getCodeWithSourcemap(type, code, map) {
  3260. if (isDebug) {
  3261. code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
  3262. }
  3263. if (type === 'js') {
  3264. code += `\n//# sourceMappingURL=${genSourceMapUrl(map)}`;
  3265. }
  3266. else if (type === 'css') {
  3267. code += `\n/*# sourceMappingURL=${genSourceMapUrl(map)} */`;
  3268. }
  3269. return code;
  3270. }
  3271. const alias = {
  3272. js: 'application/javascript',
  3273. css: 'text/css',
  3274. html: 'text/html',
  3275. json: 'application/json',
  3276. };
  3277. function send(req, res, content, type, options) {
  3278. const { etag = etag_1(content, { weak: true }), cacheControl = 'no-cache', headers, map, } = options;
  3279. if (res.writableEnded) {
  3280. return;
  3281. }
  3282. if (req.headers['if-none-match'] === etag) {
  3283. res.statusCode = 304;
  3284. res.end();
  3285. return;
  3286. }
  3287. res.setHeader('Content-Type', alias[type] || type);
  3288. res.setHeader('Cache-Control', cacheControl);
  3289. res.setHeader('Etag', etag);
  3290. if (headers) {
  3291. for (const name in headers) {
  3292. res.setHeader(name, headers[name]);
  3293. }
  3294. }
  3295. // inject source map reference
  3296. if (map && map.mappings) {
  3297. if (type === 'js' || type === 'css') {
  3298. content = getCodeWithSourcemap(type, content.toString(), map);
  3299. }
  3300. }
  3301. res.statusCode = 200;
  3302. res.end(content);
  3303. return;
  3304. }
  3305. /* eslint no-console: 0 */
  3306. const LogLevels = {
  3307. silent: 0,
  3308. error: 1,
  3309. warn: 2,
  3310. info: 3,
  3311. };
  3312. let lastType;
  3313. let lastMsg;
  3314. let sameCount = 0;
  3315. function clearScreen() {
  3316. const repeatCount = process.stdout.rows - 2;
  3317. const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : '';
  3318. console.log(blank);
  3319. readline.cursorTo(process.stdout, 0, 0);
  3320. readline.clearScreenDown(process.stdout);
  3321. }
  3322. function createLogger(level = 'info', options = {}) {
  3323. if (options.customLogger) {
  3324. return options.customLogger;
  3325. }
  3326. const loggedErrors = new WeakSet();
  3327. const { prefix = '[vite]', allowClearScreen = true } = options;
  3328. const thresh = LogLevels[level];
  3329. const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
  3330. const clear = canClearScreen ? clearScreen : () => { };
  3331. function output(type, msg, options = {}) {
  3332. if (thresh >= LogLevels[type]) {
  3333. const method = type === 'info' ? 'log' : type;
  3334. const format = () => {
  3335. if (options.timestamp) {
  3336. const tag = type === 'info'
  3337. ? picocolorsExports.cyan(picocolorsExports.bold(prefix))
  3338. : type === 'warn'
  3339. ? picocolorsExports.yellow(picocolorsExports.bold(prefix))
  3340. : picocolorsExports.red(picocolorsExports.bold(prefix));
  3341. return `${picocolorsExports.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`;
  3342. }
  3343. else {
  3344. return msg;
  3345. }
  3346. };
  3347. if (options.error) {
  3348. loggedErrors.add(options.error);
  3349. }
  3350. if (canClearScreen) {
  3351. if (type === lastType && msg === lastMsg) {
  3352. sameCount++;
  3353. clear();
  3354. console[method](format(), picocolorsExports.yellow(`(x${sameCount + 1})`));
  3355. }
  3356. else {
  3357. sameCount = 0;
  3358. lastMsg = msg;
  3359. lastType = type;
  3360. if (options.clear) {
  3361. clear();
  3362. }
  3363. console[method](format());
  3364. }
  3365. }
  3366. else {
  3367. console[method](format());
  3368. }
  3369. }
  3370. }
  3371. const warnedMessages = new Set();
  3372. const logger = {
  3373. hasWarned: false,
  3374. info(msg, opts) {
  3375. output('info', msg, opts);
  3376. },
  3377. warn(msg, opts) {
  3378. logger.hasWarned = true;
  3379. output('warn', msg, opts);
  3380. },
  3381. warnOnce(msg, opts) {
  3382. if (warnedMessages.has(msg))
  3383. return;
  3384. logger.hasWarned = true;
  3385. output('warn', msg, opts);
  3386. warnedMessages.add(msg);
  3387. },
  3388. error(msg, opts) {
  3389. logger.hasWarned = true;
  3390. output('error', msg, opts);
  3391. },
  3392. clearScreen(type) {
  3393. if (thresh >= LogLevels[type]) {
  3394. clear();
  3395. }
  3396. },
  3397. hasErrorLogged(error) {
  3398. return loggedErrors.has(error);
  3399. },
  3400. };
  3401. return logger;
  3402. }
  3403. // https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
  3404. const ROOT_FILES = [
  3405. // '.git',
  3406. // https://pnpm.js.org/workspaces/
  3407. 'pnpm-workspace.yaml',
  3408. // https://rushjs.io/pages/advanced/config_files/
  3409. // 'rush.json',
  3410. // https://nx.dev/latest/react/getting-started/nx-setup
  3411. // 'workspace.json',
  3412. // 'nx.json',
  3413. // https://github.com/lerna/lerna#lernajson
  3414. 'lerna.json',
  3415. ];
  3416. // npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
  3417. // yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
  3418. function hasWorkspacePackageJSON(root) {
  3419. const path = path$3.join(root, 'package.json');
  3420. if (!isFileReadable(path)) {
  3421. return false;
  3422. }
  3423. const content = JSON.parse(fs$1.readFileSync(path, 'utf-8')) || {};
  3424. return !!content.workspaces;
  3425. }
  3426. function hasRootFile(root) {
  3427. return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
  3428. }
  3429. function hasPackageJSON(root) {
  3430. const path = path$3.join(root, 'package.json');
  3431. return fs$1.existsSync(path);
  3432. }
  3433. /**
  3434. * Search up for the nearest `package.json`
  3435. */
  3436. function searchForPackageRoot(current, root = current) {
  3437. if (hasPackageJSON(current))
  3438. return current;
  3439. const dir = path$3.dirname(current);
  3440. // reach the fs root
  3441. if (!dir || dir === current)
  3442. return root;
  3443. return searchForPackageRoot(dir, root);
  3444. }
  3445. /**
  3446. * Search up for the nearest workspace root
  3447. */
  3448. function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
  3449. if (hasRootFile(current))
  3450. return current;
  3451. if (hasWorkspacePackageJSON(current))
  3452. return current;
  3453. const dir = path$3.dirname(current);
  3454. // reach the fs root
  3455. if (!dir || dir === current)
  3456. return root;
  3457. return searchForWorkspaceRoot(dir, root);
  3458. }
  3459. var mainExports = {};
  3460. var main$1 = {
  3461. get exports(){ return mainExports; },
  3462. set exports(v){ mainExports = v; },
  3463. };
  3464. var name = "dotenv";
  3465. var version$1 = "16.0.3";
  3466. var description = "Loads environment variables from .env file";
  3467. var main = "lib/main.js";
  3468. var types = "lib/main.d.ts";
  3469. var exports$1 = {
  3470. ".": {
  3471. require: "./lib/main.js",
  3472. types: "./lib/main.d.ts",
  3473. "default": "./lib/main.js"
  3474. },
  3475. "./config": "./config.js",
  3476. "./config.js": "./config.js",
  3477. "./lib/env-options": "./lib/env-options.js",
  3478. "./lib/env-options.js": "./lib/env-options.js",
  3479. "./lib/cli-options": "./lib/cli-options.js",
  3480. "./lib/cli-options.js": "./lib/cli-options.js",
  3481. "./package.json": "./package.json"
  3482. };
  3483. var scripts = {
  3484. "dts-check": "tsc --project tests/types/tsconfig.json",
  3485. lint: "standard",
  3486. "lint-readme": "standard-markdown",
  3487. pretest: "npm run lint && npm run dts-check",
  3488. test: "tap tests/*.js --100 -Rspec",
  3489. prerelease: "npm test",
  3490. release: "standard-version"
  3491. };
  3492. var repository = {
  3493. type: "git",
  3494. url: "git://github.com/motdotla/dotenv.git"
  3495. };
  3496. var keywords = [
  3497. "dotenv",
  3498. "env",
  3499. ".env",
  3500. "environment",
  3501. "variables",
  3502. "config",
  3503. "settings"
  3504. ];
  3505. var readmeFilename = "README.md";
  3506. var license = "BSD-2-Clause";
  3507. var devDependencies = {
  3508. "@types/node": "^17.0.9",
  3509. decache: "^4.6.1",
  3510. dtslint: "^3.7.0",
  3511. sinon: "^12.0.1",
  3512. standard: "^16.0.4",
  3513. "standard-markdown": "^7.1.0",
  3514. "standard-version": "^9.3.2",
  3515. tap: "^15.1.6",
  3516. tar: "^6.1.11",
  3517. typescript: "^4.5.4"
  3518. };
  3519. var engines = {
  3520. node: ">=12"
  3521. };
  3522. var require$$3 = {
  3523. name: name,
  3524. version: version$1,
  3525. description: description,
  3526. main: main,
  3527. types: types,
  3528. exports: exports$1,
  3529. scripts: scripts,
  3530. repository: repository,
  3531. keywords: keywords,
  3532. readmeFilename: readmeFilename,
  3533. license: license,
  3534. devDependencies: devDependencies,
  3535. engines: engines
  3536. };
  3537. const fs = require$$1$1;
  3538. const path = require$$0$1;
  3539. const os = require$$2;
  3540. const packageJson = require$$3;
  3541. const version = packageJson.version;
  3542. const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
  3543. // Parser src into an Object
  3544. function parse (src) {
  3545. const obj = {};
  3546. // Convert buffer to string
  3547. let lines = src.toString();
  3548. // Convert line breaks to same format
  3549. lines = lines.replace(/\r\n?/mg, '\n');
  3550. let match;
  3551. while ((match = LINE.exec(lines)) != null) {
  3552. const key = match[1];
  3553. // Default undefined or null to empty string
  3554. let value = (match[2] || '');
  3555. // Remove whitespace
  3556. value = value.trim();
  3557. // Check if double quoted
  3558. const maybeQuote = value[0];
  3559. // Remove surrounding quotes
  3560. value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
  3561. // Expand newlines if double quoted
  3562. if (maybeQuote === '"') {
  3563. value = value.replace(/\\n/g, '\n');
  3564. value = value.replace(/\\r/g, '\r');
  3565. }
  3566. // Add to object
  3567. obj[key] = value;
  3568. }
  3569. return obj
  3570. }
  3571. function _log (message) {
  3572. console.log(`[dotenv@${version}][DEBUG] ${message}`);
  3573. }
  3574. function _resolveHome (envPath) {
  3575. return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
  3576. }
  3577. // Populates process.env from .env file
  3578. function config (options) {
  3579. let dotenvPath = path.resolve(process.cwd(), '.env');
  3580. let encoding = 'utf8';
  3581. const debug = Boolean(options && options.debug);
  3582. const override = Boolean(options && options.override);
  3583. if (options) {
  3584. if (options.path != null) {
  3585. dotenvPath = _resolveHome(options.path);
  3586. }
  3587. if (options.encoding != null) {
  3588. encoding = options.encoding;
  3589. }
  3590. }
  3591. try {
  3592. // Specifying an encoding returns a string instead of a buffer
  3593. const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
  3594. Object.keys(parsed).forEach(function (key) {
  3595. if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
  3596. process.env[key] = parsed[key];
  3597. } else {
  3598. if (override === true) {
  3599. process.env[key] = parsed[key];
  3600. }
  3601. if (debug) {
  3602. if (override === true) {
  3603. _log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
  3604. } else {
  3605. _log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
  3606. }
  3607. }
  3608. }
  3609. });
  3610. return { parsed }
  3611. } catch (e) {
  3612. if (debug) {
  3613. _log(`Failed to load ${dotenvPath} ${e.message}`);
  3614. }
  3615. return { error: e }
  3616. }
  3617. }
  3618. const DotenvModule = {
  3619. config,
  3620. parse
  3621. };
  3622. mainExports.config = DotenvModule.config;
  3623. var parse_1 = mainExports.parse = DotenvModule.parse;
  3624. main$1.exports = DotenvModule;
  3625. function _interpolate (envValue, environment, config) {
  3626. const matches = envValue.match(/(.?\${*[\w]*(?::-[\w/]*)?}*)/g) || [];
  3627. return matches.reduce(function (newEnv, match, index) {
  3628. const parts = /(.?)\${*([\w]*(?::-[\w/]*)?)?}*/g.exec(match);
  3629. if (!parts || parts.length === 0) {
  3630. return newEnv
  3631. }
  3632. const prefix = parts[1];
  3633. let value, replacePart;
  3634. if (prefix === '\\') {
  3635. replacePart = parts[0];
  3636. value = replacePart.replace('\\$', '$');
  3637. } else {
  3638. // PATCH: compatible with env variables ended with unescaped $
  3639. if(!parts[2]) {
  3640. return newEnv
  3641. }
  3642. const keyParts = parts[2].split(':-');
  3643. const key = keyParts[0];
  3644. replacePart = parts[0].substring(prefix.length);
  3645. // process.env value 'wins' over .env file's value
  3646. value = Object.prototype.hasOwnProperty.call(environment, key)
  3647. ? environment[key]
  3648. : (config.parsed[key] || keyParts[1] || '');
  3649. // If the value is found, remove nested expansions.
  3650. if (keyParts.length > 1 && value) {
  3651. const replaceNested = matches[index + 1];
  3652. matches[index + 1] = '';
  3653. newEnv = newEnv.replace(replaceNested, '');
  3654. }
  3655. // Resolve recursive interpolations
  3656. value = _interpolate(value, environment, config);
  3657. }
  3658. return newEnv.replace(replacePart, value)
  3659. }, envValue)
  3660. }
  3661. function expand (config) {
  3662. // if ignoring process.env, use a blank object
  3663. const environment = config.ignoreProcessEnv ? {} : process.env;
  3664. for (const configKey in config.parsed) {
  3665. const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey];
  3666. config.parsed[configKey] = _interpolate(value, environment, config);
  3667. }
  3668. // PATCH: don't write to process.env
  3669. // for (const processKey in config.parsed) {
  3670. // environment[processKey] = config.parsed[processKey]
  3671. // }
  3672. return config
  3673. }
  3674. var expand_1 = expand;
  3675. function loadEnv(mode, envDir, prefixes = 'VITE_') {
  3676. if (mode === 'local') {
  3677. throw new Error(`"local" cannot be used as a mode name because it conflicts with ` +
  3678. `the .local postfix for .env files.`);
  3679. }
  3680. prefixes = arraify(prefixes);
  3681. const env = {};
  3682. const envFiles = [
  3683. /** default file */ `.env`,
  3684. /** local file */ `.env.local`,
  3685. /** mode file */ `.env.${mode}`,
  3686. /** mode local file */ `.env.${mode}.local`,
  3687. ];
  3688. const parsed = Object.fromEntries(envFiles.flatMap((file) => {
  3689. const path = lookupFile(envDir, [file], {
  3690. pathOnly: true,
  3691. rootDir: envDir,
  3692. });
  3693. if (!path)
  3694. return [];
  3695. return Object.entries(parse_1(fs$1.readFileSync(path)));
  3696. }));
  3697. // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this
  3698. if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {
  3699. process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
  3700. }
  3701. // support BROWSER and BROWSER_ARGS env variables
  3702. if (parsed.BROWSER && process.env.BROWSER === undefined) {
  3703. process.env.BROWSER = parsed.BROWSER;
  3704. }
  3705. if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === undefined) {
  3706. process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
  3707. }
  3708. // let environment variables use each other
  3709. // `expand` patched in patches/dotenv-expand@9.0.0.patch
  3710. expand_1({ parsed });
  3711. // only keys that start with prefix are exposed to client
  3712. for (const [key, value] of Object.entries(parsed)) {
  3713. if (prefixes.some((prefix) => key.startsWith(prefix))) {
  3714. env[key] = value;
  3715. }
  3716. }
  3717. // check if there are actual env variables starting with VITE_*
  3718. // these are typically provided inline and should be prioritized
  3719. for (const key in process.env) {
  3720. if (prefixes.some((prefix) => key.startsWith(prefix))) {
  3721. env[key] = process.env[key];
  3722. }
  3723. }
  3724. return env;
  3725. }
  3726. function resolveEnvPrefix({ envPrefix = 'VITE_', }) {
  3727. envPrefix = arraify(envPrefix);
  3728. if (envPrefix.some((prefix) => prefix === '')) {
  3729. throw new Error(`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`);
  3730. }
  3731. return envPrefix;
  3732. }
  3733. exports.esbuildVersion = esbuild.version;
  3734. exports.rollupVersion = rollup.VERSION;
  3735. exports.createFilter = createFilter;
  3736. exports.createLogger = createLogger;
  3737. exports.isCSSRequest = isCSSRequest;
  3738. exports.loadEnv = loadEnv;
  3739. exports.mergeAlias = mergeAlias;
  3740. exports.mergeConfig = mergeConfig;
  3741. exports.normalizePath = normalizePath;
  3742. exports.resolveEnvPrefix = resolveEnvPrefix;
  3743. exports.searchForWorkspaceRoot = searchForWorkspaceRoot;
  3744. exports.send = send;
  3745. exports.splitVendorChunk = splitVendorChunk;
  3746. exports.splitVendorChunkPlugin = splitVendorChunkPlugin;
  3747. exports.version = VERSION;