@forsakringskassan/docs-generator 2.38.5 → 2.38.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{create-markdown-renderer-3vzQq-PG.mjs → create-markdown-renderer-B7yrXROV.mjs} +3 -3
- package/dist/{create-markdown-renderer-3vzQq-PG.mjs.map → create-markdown-renderer-B7yrXROV.mjs.map} +1 -1
- package/dist/{format-code.worker-i_fzVsDn.mjs → format-code.worker-346miAdg.mjs} +2 -2
- package/dist/{format-code.worker-i_fzVsDn.mjs.map → format-code.worker-346miAdg.mjs.map} +1 -1
- package/dist/index.d.mts +0 -7
- package/dist/index.mjs +6 -27
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.mjs +2 -2
- package/dist/runtime.mjs +3 -0
- package/dist/style/core.css +0 -29
- package/dist/style/index.css +1 -29
- package/dist/style/site.css +1 -0
- package/dist/style/theme/fkui.css +4 -0
- package/dist/{vendor-BnFYrp5U.mjs → vendor-DgbU8VP_.mjs} +119 -2521
- package/dist/{vendor-BnFYrp5U.mjs.map → vendor-DgbU8VP_.mjs.map} +1 -1
- package/package.json +1 -1
- package/templates/partials/theme-render-blocker.html +0 -11
- package/templates/partials/theme-select.html +0 -49
|
@@ -3,8 +3,8 @@ import { createRequire as $createRequire } from "node:module";
|
|
|
3
3
|
const require = $createRequire(import.meta.url);
|
|
4
4
|
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
-
import * as path
|
|
7
|
-
import path__default, { win32, posix, resolve, join as join$1, relative, sep
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import path__default, { win32, posix, resolve, join as join$1, relative, sep } from 'node:path';
|
|
8
8
|
import require$$0$3, { realpathSync, readlinkSync, readdirSync, readdir as readdir$1, lstatSync, statSync } from 'fs';
|
|
9
9
|
import * as fs$8 from 'node:fs';
|
|
10
10
|
import fs__default, { readFileSync, unwatchFile, watchFile, watch as watch$2, stat as stat$2 } from 'node:fs';
|
|
@@ -613,7 +613,7 @@ var xmlDecodeTree = new Uint16Array(
|
|
|
613
613
|
.map((c) => c.charCodeAt(0)));
|
|
614
614
|
|
|
615
615
|
// Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
|
|
616
|
-
var _a$
|
|
616
|
+
var _a$5;
|
|
617
617
|
const decodeMap = new Map([
|
|
618
618
|
[0, 65533],
|
|
619
619
|
// C1 Unicode control character reference replacements
|
|
@@ -650,7 +650,7 @@ const decodeMap = new Map([
|
|
|
650
650
|
*/
|
|
651
651
|
const fromCodePoint$1 =
|
|
652
652
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
|
|
653
|
-
(_a$
|
|
653
|
+
(_a$5 = String.fromCodePoint) !== null && _a$5 !== void 0 ? _a$5 : function (codePoint) {
|
|
654
654
|
let output = "";
|
|
655
655
|
if (codePoint > 0xffff) {
|
|
656
656
|
codePoint -= 0x10000;
|
|
@@ -5213,7 +5213,7 @@ for (let i = 0; i < 256; i++) { ESCAPED.push(0); }
|
|
|
5213
5213
|
'\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
|
|
5214
5214
|
.split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
|
|
5215
5215
|
|
|
5216
|
-
function escape$
|
|
5216
|
+
function escape$3 (state, silent) {
|
|
5217
5217
|
let pos = state.pos;
|
|
5218
5218
|
const max = state.posMax;
|
|
5219
5219
|
|
|
@@ -6212,7 +6212,7 @@ const _rules = [
|
|
|
6212
6212
|
['text', text],
|
|
6213
6213
|
['linkify', linkify],
|
|
6214
6214
|
['newline', newline],
|
|
6215
|
-
['escape', escape$
|
|
6215
|
+
['escape', escape$3],
|
|
6216
6216
|
['backticks', backtick],
|
|
6217
6217
|
['strikethrough', r_strikethrough.tokenize],
|
|
6218
6218
|
['emphasis', r_emphasis.tokenize],
|
|
@@ -8407,2408 +8407,6 @@ var Gt$7=(n,t,e)=>{let s=n instanceof RegExp?ce$8(n,e):n,i=t instanceof RegExp?c
|
|
|
8407
8407
|
globstar while`,t,d,e,f,m),this.matchOne(t.slice(d),e.slice(f),s))return this.debug("globstar found match!",d,a,m),true;if(m==="."||m===".."||!i.dot&&m.charAt(0)==="."){this.debug("dot detected!",t,d,e,f);break}this.debug("globstar swallow a segment, and continue"),d++;}return !!(s&&(this.debug(`
|
|
8408
8408
|
>>> no match, partial?`,t,d,e,f),d===a))}let p;if(typeof u=="string"?(p=c===u,this.debug("string match",u,c,p)):(p=u.test(c),this.debug("pattern match",u,c,p)),!p)return false}if(o===a&&h===l)return true;if(o===a)return s;if(h===l)return o===a-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return ke$a(this.pattern,this.options)}parse(t){at$a(t);let e=this.options;if(t==="**")return A$7;if(t==="")return "";let s,i=null;(s=t.match(js$8))?i=e.dot?zs$7:Is$7:(s=t.match(Rs$8))?i=(e.nocase?e.dot?Ms$7:Ds$6:e.dot?Fs$8:Os$6)(s[1]):(s=t.match(Bs$9))?i=(e.nocase?e.dot?$s$8:Us$8:e.dot?Gs$7:Hs$8)(s):(s=t.match(Ns$6))?i=e.dot?Ls$6:_s$5:(s=t.match(Ws$7))&&(i=Ps$8);let r=Q$9.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let t=this.set;if(!t.length)return this.regexp=false,this.regexp;let e=this.options,s=e.noglobstar?Vs$6:e.dot?Ys$8:Xs$7,i=new Set(e.nocase?["i"]:[]),r=t.map(a=>{let l=a.map(c=>{if(c instanceof RegExp)for(let d of c.flags.split(""))i.add(d);return typeof c=="string"?ei$9(c):c===A$7?A$7:c._src});l.forEach((c,d)=>{let f=l[d+1],m=l[d-1];c!==A$7||m===A$7||(m===void 0?f!==void 0&&f!==A$7?l[d+1]="(?:\\/|"+s+"\\/)?"+f:l[d]=s:f===void 0?l[d-1]=m+"(?:\\/|\\/"+s+")?":f!==A$7&&(l[d-1]=m+"(?:\\/|\\/"+s+"\\/)"+f,l[d+1]=A$7));});let u=l.filter(c=>c!==A$7);if(this.partial&&u.length>=1){let c=[];for(let d=1;d<=u.length;d++)c.push(u.slice(0,d).join("/"));return "(?:"+c.join("|")+")"}return u.join("/")}).join("|"),[o,h]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+h+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+h+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return false;if(this.empty)return t==="";if(t==="/"&&e)return true;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let h=i.length-2;!o&&h>=0;h--)o=i[h];for(let h=0;h<r.length;h++){let a=r[h],l=i;if(s.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,e))return s.flipNegate?true:!this.negate}return s.flipNegate?false:this.negate}static defaults(t){return O$5.defaults(t).Minimatch}};O$5.AST=Q$9;O$5.Minimatch=D$4;O$5.escape=tt$a;O$5.unescape=W$9;var si$9=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Oe$a=new Set,Vt$a=typeof process=="object"&&process?process:{},Fe$9=(n,t,e,s)=>{typeof Vt$a.emitWarning=="function"?Vt$a.emitWarning(n,t,e,s):console.error(`[${e}] ${t}: ${n}`);},At$b=globalThis.AbortController,Re$a=globalThis.AbortSignal;if(typeof At$b>"u"){Re$a=class{onabort;_onabort=[];reason;aborted=false;addEventListener(e,s){this._onabort.push(s);}},At$b=class{constructor(){t();}signal=new Re$a;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let s of this.signal._onabort)s(e);this.signal.onabort?.(e);}}};let n=Vt$a.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{n&&(n=false,Fe$9("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var ii$9=n=>!Oe$a.has(n);var q$a=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),De$a=n=>q$a(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Tt$b:null:null,Tt$b=class Tt extends Array{constructor(n){super(n),this.fill(0);}},ri$9=class ct{heap;length;static#t=false;static create(t){let e=De$a(t);if(!e)return [];ct.#t=true;let s=new ct(t,e);return ct.#t=false,s}constructor(t,e){if(!ct.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},ft$9=class Me{#t;#s;#n;#r;#o;#S;#w;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#h;#u;#f;#a;#i;#d;#E;#b;#p;#R;#m;#C;#T;#g;#y;#x;#A;#e;#_;static unsafeExposeInternals(t){return {starts:t.#T,ttls:t.#g,autopurgeTimers:t.#y,sizes:t.#C,keyMap:t.#f,keyList:t.#a,valList:t.#i,next:t.#d,prev:t.#E,get head(){return t.#b},get tail(){return t.#p},free:t.#R,isBackgroundFetch:e=>t.#l(e),backgroundFetch:(e,s,i,r)=>t.#U(e,s,i,r),moveToTail:e=>t.#W(e),indexes:e=>t.#F(e),rindexes:e=>t.#D(e),isStale:e=>t.#v(e)}}get max(){return this.#t}get maxSize(){return this.#s}get calculatedSize(){return this.#u}get size(){return this.#h}get fetchMethod(){return this.#S}get memoMethod(){return this.#w}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#o}constructor(t){let{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:a,dispose:l,onInsert:u,disposeAfter:c,noDisposeOnSet:d,noUpdateTTL:f,maxSize:m=0,maxEntrySize:p=0,sizeCalculation:w,fetchMethod:g,memoMethod:S,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:z,ignoreFetchAbort:$,perf:J}=t;if(J!==void 0&&typeof J?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=J??si$9,e!==0&&!q$a(e))throw new TypeError("max option must be a nonnegative integer");let Z=e?De$a(e):Array;if(!Z)throw new Error("invalid max value: "+e);if(this.#t=e,this.#s=m,this.maxEntrySize=p||this.#s,this.sizeCalculation=w,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#w=S,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#S=g,this.#A=!!g,this.#f=new Map,this.#a=new Array(e).fill(void 0),this.#i=new Array(e).fill(void 0),this.#d=new Z(e),this.#E=new Z(e),this.#b=0,this.#p=0,this.#R=ri$9.create(e),this.#h=0,this.#u=0,typeof l=="function"&&(this.#n=l),typeof u=="function"&&(this.#r=u),typeof c=="function"?(this.#o=c,this.#m=[]):(this.#o=void 0,this.#m=void 0),this.#x=!!this.#n,this.#_=!!this.#r,this.#e=!!this.#o,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!z,this.ignoreFetchAbort=!!$,this.maxEntrySize!==0){if(this.#s!==0&&!q$a(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!q$a(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G();}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=q$a(i)||i===0?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!q$a(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#M();}if(this.#t===0&&this.ttl===0&&this.#s===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#s){let $t="LRU_CACHE_UNBOUNDED";ii$9($t)&&(Oe$a.add($t),Fe$9("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",$t,Me));}}getRemainingTTL(t){return this.#f.has(t)?1/0:0}#M(){let t=new Tt$b(this.#t),e=new Tt$b(this.#t);this.#g=t,this.#T=e;let s=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=s,this.#j=(o,h,a=this.#c.now())=>{if(e[o]=h!==0?a:0,t[o]=h,s?.[o]&&(clearTimeout(s[o]),s[o]=void 0),h!==0&&s){let l=setTimeout(()=>{this.#v(o)&&this.#O(this.#a[o],"expire");},h+1);l.unref&&l.unref(),s[o]=l;}},this.#k=o=>{e[o]=t[o]!==0?this.#c.now():0;},this.#N=(o,h)=>{if(t[h]){let a=t[h],l=e[h];if(!a||!l)return;o.ttl=a,o.start=l,o.now=i||r();let u=o.now-l;o.remainingTTL=a-u;}};let i=0,r=()=>{let o=this.#c.now();if(this.ttlResolution>0){i=o;let h=setTimeout(()=>i=0,this.ttlResolution);h.unref&&h.unref();}return o};this.getRemainingTTL=o=>{let h=this.#f.get(o);if(h===void 0)return 0;let a=t[h],l=e[h];if(!a||!l)return 1/0;let u=(i||r())-l;return a-u},this.#v=o=>{let h=e[o],a=t[o];return !!a&&!!h&&(i||r())-h>a};}#k=()=>{};#N=()=>{};#j=()=>{};#v=()=>false;#G(){let t=new Tt$b(this.#t);this.#u=0,this.#C=t,this.#P=e=>{this.#u-=t[e],t[e]=0;},this.#I=(e,s,i,r)=>{if(this.#l(s))return 0;if(!q$a(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(s,e),!q$a(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#L=(e,s,i)=>{if(t[e]=s,this.#s){let r=this.#s-t[e];for(;this.#u>r;)this.#B(true);}this.#u+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#u);};}#P=t=>{};#L=(t,e,s)=>{};#I=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#F({allowStale:t=this.allowStale}={}){if(this.#h)for(let e=this.#p;!(!this.#z(e)||((t||!this.#v(e))&&(yield e),e===this.#b));)e=this.#E[e];}*#D({allowStale:t=this.allowStale}={}){if(this.#h)for(let e=this.#b;!(!this.#z(e)||((t||!this.#v(e))&&(yield e),e===this.#p));)e=this.#d[e];}#z(t){return t!==void 0&&this.#f.get(this.#a[t])===t}*entries(){for(let t of this.#F())this.#i[t]!==void 0&&this.#a[t]!==void 0&&!this.#l(this.#i[t])&&(yield [this.#a[t],this.#i[t]]);}*rentries(){for(let t of this.#D())this.#i[t]!==void 0&&this.#a[t]!==void 0&&!this.#l(this.#i[t])&&(yield [this.#a[t],this.#i[t]]);}*keys(){for(let t of this.#F()){let e=this.#a[t];e!==void 0&&!this.#l(this.#i[t])&&(yield e);}}*rkeys(){for(let t of this.#D()){let e=this.#a[t];e!==void 0&&!this.#l(this.#i[t])&&(yield e);}}*values(){for(let t of this.#F())this.#i[t]!==void 0&&!this.#l(this.#i[t])&&(yield this.#i[t]);}*rvalues(){for(let t of this.#D())this.#i[t]!==void 0&&!this.#l(this.#i[t])&&(yield this.#i[t]);}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let s of this.#F()){let i=this.#i[s],r=this.#l(i)?i.__staleWhileFetching:i;if(r!==void 0&&t(r,this.#a[s],this))return this.get(this.#a[s],e)}}forEach(t,e=this){for(let s of this.#F()){let i=this.#i[s],r=this.#l(i)?i.__staleWhileFetching:i;r!==void 0&&t.call(e,r,this.#a[s],this);}}rforEach(t,e=this){for(let s of this.#D()){let i=this.#i[s],r=this.#l(i)?i.__staleWhileFetching:i;r!==void 0&&t.call(e,r,this.#a[s],this);}}purgeStale(){let t=false;for(let e of this.#D({allowStale:true}))this.#v(e)&&(this.#O(this.#a[e],"expire"),t=true);return t}info(t){let e=this.#f.get(t);if(e===void 0)return;let s=this.#i[e],i=this.#l(s)?s.__staleWhileFetching:s;if(i===void 0)return;let r={value:i};if(this.#g&&this.#T){let o=this.#g[e],h=this.#T[e];if(o&&h){let a=o-(this.#c.now()-h);r.ttl=a,r.start=Date.now();}}return this.#C&&(r.size=this.#C[e]),r}dump(){let t=[];for(let e of this.#F({allowStale:true})){let s=this.#a[e],i=this.#i[e],r=this.#l(i)?i.__staleWhileFetching:i;if(r===void 0||s===void 0)continue;let o={value:r};if(this.#g&&this.#T){o.ttl=this.#g[e];let h=this.#c.now()-this.#T[e];o.start=Math.floor(Date.now()-h);}this.#C&&(o.size=this.#C[e]),t.unshift([s,o]);}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let i=Date.now()-s.start;s.start=this.#c.now()-i;}this.set(e,s.value,s);}}set(t,e,s={}){if(e===void 0)return this.delete(t),this;let{ttl:i=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:a}=s,{noUpdateTTL:l=this.noUpdateTTL}=s,u=this.#I(t,e,s.size||0,h);if(this.maxEntrySize&&u>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=true),this.#O(t,"set"),this;let c=this.#h===0?void 0:this.#f.get(t);if(c===void 0)c=this.#h===0?this.#p:this.#R.length!==0?this.#R.pop():this.#h===this.#t?this.#B(false):this.#h,this.#a[c]=t,this.#i[c]=e,this.#f.set(t,c),this.#d[this.#p]=c,this.#E[c]=this.#p,this.#p=c,this.#h++,this.#L(c,u,a),a&&(a.set="add"),l=false,this.#_&&this.#r?.(e,t,"add");else {this.#W(c);let d=this.#i[c];if(e!==d){if(this.#A&&this.#l(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=d;f!==void 0&&!o&&(this.#x&&this.#n?.(f,t,"set"),this.#e&&this.#m?.push([f,t,"set"]));}else o||(this.#x&&this.#n?.(d,t,"set"),this.#e&&this.#m?.push([d,t,"set"]));if(this.#P(c),this.#L(c,u,a),this.#i[c]=e,a){a.set="replace";let f=d&&this.#l(d)?d.__staleWhileFetching:d;f!==void 0&&(a.oldValue=f);}}else a&&(a.set="update");this.#_&&this.onInsert?.(e,t,e===d?"update":"replace");}if(i!==0&&!this.#g&&this.#M(),this.#g&&(l||this.#j(c,i,r),a&&this.#N(a,c)),!o&&this.#e&&this.#m){let d=this.#m,f;for(;f=d?.shift();)this.#o?.(...f);}return this}pop(){try{for(;this.#h;){let t=this.#i[this.#b];if(this.#B(!0),this.#l(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,e;for(;e=t?.shift();)this.#o?.(...e);}}}#B(t){let e=this.#b,s=this.#a[e],i=this.#i[e];return this.#A&&this.#l(i)?i.__abortController.abort(new Error("evicted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(i,s,"evict"),this.#e&&this.#m?.push([i,s,"evict"])),this.#P(e),this.#y?.[e]&&(clearTimeout(this.#y[e]),this.#y[e]=void 0),t&&(this.#a[e]=void 0,this.#i[e]=void 0,this.#R.push(e)),this.#h===1?(this.#b=this.#p=0,this.#R.length=0):this.#b=this.#d[e],this.#f.delete(s),this.#h--,e}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,r=this.#f.get(t);if(r!==void 0){let o=this.#i[r];if(this.#l(o)&&o.__staleWhileFetching===void 0)return false;if(this.#v(r))i&&(i.has="stale",this.#N(i,r));else return s&&this.#k(r),i&&(i.has="hit",this.#N(i,r)),true}else i&&(i.has="miss");return false}peek(t,e={}){let{allowStale:s=this.allowStale}=e,i=this.#f.get(t);if(i===void 0||!s&&this.#v(i))return;let r=this.#i[i];return this.#l(r)?r.__staleWhileFetching:r}#U(t,e,s,i){let r=e===void 0?void 0:this.#i[e];if(this.#l(r))return r;let o=new At$b,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let a={signal:o.signal,options:s,context:i},l=(p,w=false)=>{let{aborted:g}=o.signal,S=s.ignoreFetchAbort&&p!==void 0,E=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&p!==void 0);if(s.status&&(g&&!w?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,S&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!S&&!w)return c(o.signal.reason,E);let y=f,b=this.#i[e];return (b===f||S&&w&&b===void 0)&&(p===void 0?y.__staleWhileFetching!==void 0?this.#i[e]=y.__staleWhileFetching:this.#O(t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,p,a.options))),p},u=p=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=p),c(p,false)),c=(p,w)=>{let{aborted:g}=o.signal,S=g&&s.allowStaleOnFetchAbort,E=S||s.allowStaleOnFetchRejection,y=E||s.noDeleteOnFetchRejection,b=f;if(this.#i[e]===f&&(!y||!w&&b.__staleWhileFetching===void 0?this.#O(t,"fetch"):S||(this.#i[e]=b.__staleWhileFetching)),E)return s.status&&b.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),b.__staleWhileFetching;if(b.__returned===b)throw p},d=(p,w)=>{let g=this.#S?.(t,r,a);g&&g instanceof Promise&&g.then(S=>p(S===void 0?void 0:S),w),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(p(void 0),s.allowStaleOnFetchAbort&&(p=S=>l(S,true)));});};s.status&&(s.status.fetchDispatched=true);let f=new Promise(d).then(l,u),m=Object.assign(f,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,m,{...a.options,status:void 0}),e=this.#f.get(t)):this.#i[e]=m,m}#l(t){if(!this.#A)return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof At$b}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:p,forceRefresh:w=false,status:g,signal:S}=e;if(!this.#A)return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});let E={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:h,size:a,sizeCalculation:l,noUpdateTTL:u,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:m,ignoreFetchAbort:f,status:g,signal:S},y=this.#f.get(t);if(y===void 0){g&&(g.fetch="miss");let b=this.#U(t,y,E,p);return b.__returned=b}else {let b=this.#i[y];if(this.#l(b)){let Z=s&&b.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Z&&(g.returnedStale=true)),Z?b.__staleWhileFetching:b.__returned=b}let z=this.#v(y);if(!w&&!z)return g&&(g.fetch="hit"),this.#W(y),i&&this.#k(y),g&&this.#N(g,y),b;let $=this.#U(t,y,E,p),J=$.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=z?"stale":"refresh",J&&z&&(g.returnedStale=true)),J?$.__staleWhileFetching:$.__returned=$}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=this.#w;if(!s)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:r,...o}=e,h=this.get(t,o);if(!r&&h!==void 0)return h;let a=s(t,h,{options:o,context:i});return this.set(t,a,o),a}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=e,h=this.#f.get(t);if(h!==void 0){let a=this.#i[h],l=this.#l(a);return o&&this.#N(o,h),this.#v(h)?(o&&(o.get="stale"),l?(o&&s&&a.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?a.__staleWhileFetching:void 0):(r||this.#O(t,"expire"),o&&s&&(o.returnedStale=true),s?a:void 0)):(o&&(o.get="hit"),l?a.__staleWhileFetching:(this.#W(h),i&&this.#k(h),a))}else o&&(o.get="miss");}#$(t,e){this.#E[e]=t,this.#d[t]=e;}#W(t){t!==this.#p&&(t===this.#b?this.#b=this.#d[t]:this.#$(this.#E[t],this.#d[t]),this.#$(this.#p,t),this.#p=t);}delete(t){return this.#O(t,"delete")}#O(t,e){let s=false;if(this.#h!==0){let i=this.#f.get(t);if(i!==void 0)if(this.#y?.[i]&&(clearTimeout(this.#y?.[i]),this.#y[i]=void 0),s=true,this.#h===1)this.#H(e);else {this.#P(i);let r=this.#i[i];if(this.#l(r)?r.__abortController.abort(new Error("deleted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(r,t,e),this.#e&&this.#m?.push([r,t,e])),this.#f.delete(t),this.#a[i]=void 0,this.#i[i]=void 0,i===this.#p)this.#p=this.#E[i];else if(i===this.#b)this.#b=this.#d[i];else {let o=this.#E[i];this.#d[o]=this.#d[i];let h=this.#d[i];this.#E[h]=this.#E[i];}this.#h--,this.#R.push(i);}}if(this.#e&&this.#m?.length){let i=this.#m,r;for(;r=i?.shift();)this.#o?.(...r);}return s}clear(){return this.#H("delete")}#H(t){for(let e of this.#D({allowStale:true})){let s=this.#i[e];if(this.#l(s))s.__abortController.abort(new Error("deleted"));else {let i=this.#a[e];this.#x&&this.#n?.(s,i,t),this.#e&&this.#m?.push([s,i,t]);}}if(this.#f.clear(),this.#i.fill(void 0),this.#a.fill(void 0),this.#g&&this.#T){this.#g.fill(0),this.#T.fill(0);for(let e of this.#y??[])e!==void 0&&clearTimeout(e);this.#y?.fill(void 0);}if(this.#C&&this.#C.fill(0),this.#b=0,this.#p=0,this.#R.length=0,this.#u=0,this.#h=0,this.#e&&this.#m){let e=this.#m,s;for(;s=e?.shift();)this.#o?.(...s);}}};var Ne$9=typeof process=="object"&&process?process:{stdout:null,stderr:null},oi$9=n=>!!n&&typeof n=="object"&&(n instanceof V$a||n instanceof Pe$9||hi$a(n)||ai$9(n)),hi$a=n=>!!n&&typeof n=="object"&&n instanceof EventEmitter$1&&typeof n.pipe=="function"&&n.pipe!==Pe$9.Writable.prototype.pipe,ai$9=n=>!!n&&typeof n=="object"&&n instanceof EventEmitter$1&&typeof n.write=="function"&&typeof n.end=="function",G$9=Symbol("EOF"),H$9=Symbol("maybeEmitEnd"),K$a=Symbol("emittedEnd"),kt$b=Symbol("emittingEnd"),ut$9=Symbol("emittedError"),Rt$a=Symbol("closed"),_e$a=Symbol("read"),Ot$b=Symbol("flush"),Le$a=Symbol("flushChunk"),P$7=Symbol("encoding"),et$a=Symbol("decoder"),v$7=Symbol("flowing"),dt$7=Symbol("paused"),st$7=Symbol("resume"),C$7=Symbol("buffer"),F$9=Symbol("pipes"),T$5=Symbol("bufferLength"),Yt$7=Symbol("bufferPush"),Ft$a=Symbol("bufferShift"),k$7=Symbol("objectMode"),x$7=Symbol("destroyed"),Xt$a=Symbol("error"),Jt$8=Symbol("emitData"),We$a=Symbol("emitEnd"),Zt$a=Symbol("emitEnd2"),B$6=Symbol("async"),Qt$9=Symbol("abort"),Dt$9=Symbol("aborted"),pt$9=Symbol("signal"),Y$6=Symbol("dataListeners"),M$8=Symbol("discarded"),mt$9=n=>Promise.resolve().then(n),li$9=n=>n(),ci$9=n=>n==="end"||n==="finish"||n==="prefinish",fi$a=n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,ui$a=n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),Mt$b=class Mt{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[st$7](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},te$b=class te extends Mt$b{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(t,e,s){super(t,e,s),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors);}},di$a=n=>!!n.objectMode,pi$a=n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer",V$a=class V extends EventEmitter$1{[v$7]=false;[dt$7]=false;[F$9]=[];[C$7]=[];[k$7];[P$7];[B$6];[et$a];[G$9]=false;[K$a]=false;[kt$b]=false;[Rt$a]=false;[ut$9]=null;[T$5]=0;[x$7]=false;[pt$9];[Dt$9]=false;[Y$6]=0;[M$8]=false;writable=true;readable=true;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");di$a(e)?(this[k$7]=true,this[P$7]=null):pi$a(e)?(this[P$7]=e.encoding,this[k$7]=false):(this[k$7]=false,this[P$7]=null),this[B$6]=!!e.async,this[et$a]=this[P$7]?new StringDecoder(this[P$7]):null,e&&e.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[C$7]}),e&&e.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[F$9]});let{signal:s}=e;s&&(this[pt$9]=s,s.aborted?this[Qt$9]():s.addEventListener("abort",()=>this[Qt$9]()));}get bufferLength(){return this[T$5]}get encoding(){return this[P$7]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[k$7]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[B$6]}set async(t){this[B$6]=this[B$6]||!!t;}[Qt$9](){this[Dt$9]=true,this.emit("abort",this[pt$9]?.reason),this.destroy(this[pt$9]?.reason);}get aborted(){return this[Dt$9]}set aborted(t){}write(t,e,s){if(this[Dt$9])return false;if(this[G$9])throw new Error("write after end");if(this[x$7])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let i=this[B$6]?mt$9:li$9;if(!this[k$7]&&!Buffer.isBuffer(t)){if(ui$a(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(fi$a(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[k$7]?(this[v$7]&&this[T$5]!==0&&this[Ot$b](true),this[v$7]?this.emit("data",t):this[Yt$7](t),this[T$5]!==0&&this.emit("readable"),s&&i(s),this[v$7]):t.length?(typeof t=="string"&&!(e===this[P$7]&&!this[et$a]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[P$7]&&(t=this[et$a].write(t)),this[v$7]&&this[T$5]!==0&&this[Ot$b](true),this[v$7]?this.emit("data",t):this[Yt$7](t),this[T$5]!==0&&this.emit("readable"),s&&i(s),this[v$7]):(this[T$5]!==0&&this.emit("readable"),s&&i(s),this[v$7])}read(t){if(this[x$7])return null;if(this[M$8]=false,this[T$5]===0||t===0||t&&t>this[T$5])return this[H$9](),null;this[k$7]&&(t=null),this[C$7].length>1&&!this[k$7]&&(this[C$7]=[this[P$7]?this[C$7].join(""):Buffer.concat(this[C$7],this[T$5])]);let e=this[_e$a](t||null,this[C$7][0]);return this[H$9](),e}[_e$a](t,e){if(this[k$7])this[Ft$a]();else {let s=e;t===s.length||t===null?this[Ft$a]():typeof s=="string"?(this[C$7][0]=s.slice(t),e=s.slice(0,t),this[T$5]-=t):(this[C$7][0]=s.subarray(t),e=s.subarray(0,t),this[T$5]-=t);}return this.emit("data",e),!this[C$7].length&&!this[G$9]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[G$9]=true,this.writable=false,(this[v$7]||!this[dt$7])&&this[H$9](),this}[st$7](){this[x$7]||(!this[Y$6]&&!this[F$9].length&&(this[M$8]=true),this[dt$7]=false,this[v$7]=true,this.emit("resume"),this[C$7].length?this[Ot$b]():this[G$9]?this[H$9]():this.emit("drain"));}resume(){return this[st$7]()}pause(){this[v$7]=false,this[dt$7]=true,this[M$8]=false;}get destroyed(){return this[x$7]}get flowing(){return this[v$7]}get paused(){return this[dt$7]}[Yt$7](t){this[k$7]?this[T$5]+=1:this[T$5]+=t.length,this[C$7].push(t);}[Ft$a](){return this[k$7]?this[T$5]-=1:this[T$5]-=this[C$7][0].length,this[C$7].shift()}[Ot$b](t=false){do;while(this[Le$a](this[Ft$a]())&&this[C$7].length);!t&&!this[C$7].length&&!this[G$9]&&this.emit("drain");}[Le$a](t){return this.emit("data",t),this[v$7]}pipe(t,e){if(this[x$7])return t;this[M$8]=false;let s=this[K$a];return e=e||{},t===Ne$9.stdout||t===Ne$9.stderr?e.end=false:e.end=e.end!==false,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[F$9].push(e.proxyErrors?new te$b(this,t,e):new Mt$b(this,t,e)),this[B$6]?mt$9(()=>this[st$7]()):this[st$7]()),t}unpipe(t){let e=this[F$9].find(s=>s.dest===t);e&&(this[F$9].length===1?(this[v$7]&&this[Y$6]===0&&(this[v$7]=false),this[F$9]=[]):this[F$9].splice(this[F$9].indexOf(e),1),e.unpipe());}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[M$8]=false,this[Y$6]++,!this[F$9].length&&!this[v$7]&&this[st$7]();else if(t==="readable"&&this[T$5]!==0)super.emit("readable");else if(ci$9(t)&&this[K$a])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ut$9]){let i=e;this[B$6]?mt$9(()=>i.call(this,this[ut$9])):i.call(this,this[ut$9]);}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[Y$6]=this.listeners("data").length,this[Y$6]===0&&!this[M$8]&&!this[F$9].length&&(this[v$7]=false)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[Y$6]=0,!this[M$8]&&!this[F$9].length&&(this[v$7]=false)),e}get emittedEnd(){return this[K$a]}[H$9](){!this[kt$b]&&!this[K$a]&&!this[x$7]&&this[C$7].length===0&&this[G$9]&&(this[kt$b]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Rt$a]&&this.emit("close"),this[kt$b]=false);}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==x$7&&this[x$7])return false;if(t==="data")return !this[k$7]&&!s?false:this[B$6]?(mt$9(()=>this[Jt$8](s)),true):this[Jt$8](s);if(t==="end")return this[We$a]();if(t==="close"){if(this[Rt$a]=true,!this[K$a]&&!this[x$7])return false;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[ut$9]=s,super.emit(Xt$a,s);let r=!this[pt$9]||this.listeners("error").length?super.emit("error",s):false;return this[H$9](),r}else if(t==="resume"){let r=super.emit("resume");return this[H$9](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let i=super.emit(t,...e);return this[H$9](),i}[Jt$8](t){for(let s of this[F$9])s.dest.write(t)===false&&this.pause();let e=this[M$8]?false:super.emit("data",t);return this[H$9](),e}[We$a](){return this[K$a]?false:(this[K$a]=true,this.readable=false,this[B$6]?(mt$9(()=>this[Zt$a]()),true):this[Zt$a]())}[Zt$a](){if(this[et$a]){let e=this[et$a].end();if(e){for(let s of this[F$9])s.dest.write(e);this[M$8]||super.emit("data",e);}}for(let e of this[F$9])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[k$7]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[k$7]||(t.dataLength+=s.length);}),await e,t}async concat(){if(this[k$7])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[P$7]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(x$7,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[M$8]=false;let t=false,e=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:false,value:i});if(this[G$9])return e();let r,o,h=c=>{this.off("data",a),this.off("end",l),this.off(x$7,u),e(),o(c);},a=c=>{this.off("error",h),this.off("end",l),this.off(x$7,u),this.pause(),r({value:c,done:!!this[G$9]});},l=()=>{this.off("error",h),this.off("data",a),this.off(x$7,u),e(),r({done:true,value:void 0});},u=()=>h(new Error("stream destroyed"));return new Promise((c,d)=>{o=d,r=c,this.once(x$7,u),this.once("error",h),this.once("end",l),this.once("data",a);})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[M$8]=false;let t=false,e=()=>(this.pause(),this.off(Xt$a,e),this.off(x$7,e),this.off("end",e),t=true,{done:true,value:void 0}),s=()=>{if(t)return e();let i=this.read();return i===null?e():{done:false,value:i}};return this.once("end",e),this.once(Xt$a,e),this.once(x$7,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[x$7])return t?this.emit("error",t):this.emit(x$7),this;this[x$7]=true,this[M$8]=true,this[C$7].length=0,this[T$5]=0;let e=this;return typeof e.close=="function"&&!this[Rt$a]&&e.close(),t?this.emit("error",t):this.emit(x$7),this}static get isStream(){return oi$9}};var vi$a=realpathSync.native,wt$a={lstatSync:lstatSync,readdir:readdir$1,readdirSync:readdirSync,readlinkSync:readlinkSync,realpathSync:vi$a,promises:{lstat:lstat,readdir:readdir,readlink:readlink,realpath:realpath}},Ue$9=n=>!n||n===wt$a||n===fs$8?wt$a:{...wt$a,...n,promises:{...wt$a.promises,...n.promises||{}}},$e$a=/^\\\\\?\\([a-z]:)\\?$/i,Ri$7=n=>n.replace(/\//g,"\\").replace($e$a,"$1\\"),Oi$8=/[\\\/]/,L$8=0,Ge$a=1,He$9=2,U$8=4,qe$a=6,Ke$b=8,X$a=10,Ve$8=12,_$8=15,gt$9=~_$8,se$a=16,je$a=32,yt$9=64,j$8=128,Nt$b=256,Lt$9=512,Ie$a=yt$9|j$8|Lt$9,Fi$7=1023,ie$a=n=>n.isFile()?Ke$b:n.isDirectory()?U$8:n.isSymbolicLink()?X$a:n.isCharacterDevice()?He$9:n.isBlockDevice()?qe$a:n.isSocket()?Ve$8:n.isFIFO()?Ge$a:L$8,ze$a=new ft$9({max:2**12}),bt$c=n=>{let t=ze$a.get(n);if(t)return t;let e=n.normalize("NFKD");return ze$a.set(n,e),e},Be$9=new ft$9({max:2**12}),_t$8=n=>{let t=Be$9.get(n);if(t)return t;let e=bt$c(n.toLowerCase());return Be$9.set(n,e),e},Wt$9=class Wt extends ft$9{constructor(){super({max:256});}},ne$9=class ne extends ft$9{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1});}},Ye$9=Symbol("PathScurry setAsCwd"),R$9=class R{name;root;roots;parent;nocase;isCWD=false;#t;#s;get dev(){return this.#s}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#o;get uid(){return this.#o}#S;get gid(){return this.#S}#w;get rdev(){return this.#w}#c;get blksize(){return this.#c}#h;get ino(){return this.#h}#u;get size(){return this.#u}#f;get blocks(){return this.#f}#a;get atimeMs(){return this.#a}#i;get mtimeMs(){return this.#i}#d;get ctimeMs(){return this.#d}#E;get birthtimeMs(){return this.#E}#b;get atime(){return this.#b}#p;get mtime(){return this.#p}#R;get ctime(){return this.#R}#m;get birthtime(){return this.#m}#C;#T;#g;#y;#x;#A;#e;#_;#M;#k;get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=L$8,s,i,r,o,h){this.name=t,this.#C=r?_t$8(t):bt$c(t),this.#e=e&Fi$7,this.nocase=r,this.roots=i,this.root=s||this,this.#_=o,this.#g=h.fullpath,this.#x=h.relative,this.#A=h.relativePosix,this.parent=h.parent,this.parent?this.#t=this.parent.#t:this.#t=Ue$9(h.fs);}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#_}resolve(t){if(!t)return this;let e=this.getRootString(t),i=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#N(i):this.#N(i)}#N(t){let e=this;for(let s of t)e=e.child(s);return e}children(){let t=this.#_.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#_.set(this,e),this.#e&=~se$a,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?_t$8(t):bt$c(t);for(let a of s)if(a.#C===i)return a;let r=this.parent?this.sep:"",o=this.#g?this.#g+r+t:void 0,h=this.newChild(t,L$8,{...e,parent:this,fullpath:o});return this.canReaddir()||(h.#e|=j$8),s.push(h),h}relative(){if(this.isCWD)return "";if(this.#x!==void 0)return this.#x;let t=this.name,e=this.parent;if(!e)return this.#x=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(this.#A!==void 0)return this.#A;let t=this.name,e=this.parent;if(!e)return this.#A=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(this.#g!==void 0)return this.#g;let t=this.name,e=this.parent;if(!e)return this.#g=this.name;let i=e.fullpath()+(e.parent?this.sep:"")+t;return this.#g=i}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?this.#y=`//?/${i}`:this.#y=i}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return this.#y=s}isUnknown(){return (this.#e&_$8)===L$8}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return (this.#e&_$8)===Ke$b}isDirectory(){return (this.#e&_$8)===U$8}isCharacterDevice(){return (this.#e&_$8)===He$9}isBlockDevice(){return (this.#e&_$8)===qe$a}isFIFO(){return (this.#e&_$8)===Ge$a}isSocket(){return (this.#e&_$8)===Ve$8}isSymbolicLink(){return (this.#e&X$a)===X$a}lstatCached(){return this.#e&je$a?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#k}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#M)return true;if(!this.parent)return false;let t=this.#e&_$8;return !(t!==L$8&&t!==X$a||this.#e&Nt$b||this.#e&j$8)}calledReaddir(){return !!(this.#e&se$a)}isENOENT(){return !!(this.#e&j$8)}isNamed(t){return this.nocase?this.#C===_t$8(t):this.#C===bt$c(t)}async readlink(){let t=this.#M;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#M=s}catch(e){this.#D(e.code);return}}readlinkSync(){let t=this.#M;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#M=s}catch(e){this.#D(e.code);return}}#j(t){this.#e|=se$a;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#v();}}#v(){this.#e&j$8||(this.#e=(this.#e|j$8)>$9,this.#G());}#G(){let t=this.children();t.provisional=0;for(let e of t)e.#v();}#P(){this.#e|=Lt$9,this.#L();}#L(){if(this.#e&yt$9)return;let t=this.#e;(t&_$8)===U$8&&(t&=gt$9),this.#e=t|yt$9,this.#G();}#I(t=""){t==="ENOTDIR"||t==="EPERM"?this.#L():t==="ENOENT"?this.#v():this.children().provisional=0;}#F(t=""){t==="ENOTDIR"?this.parent.#L():t==="ENOENT"&&this.#v();}#D(t=""){let e=this.#e;e|=Nt$b,t==="ENOENT"&&(e|=j$8),(t==="EINVAL"||t==="UNKNOWN")&&(e&=gt$9),this.#e=e,t==="ENOTDIR"&&this.parent&&this.parent.#L();}#z(t,e){return this.#U(t,e)||this.#B(t,e)}#B(t,e){let s=ie$a(t),i=this.newChild(t.name,s,{parent:this}),r=i.#e&_$8;return r!==U$8&&r!==X$a&&r!==L$8&&(i.#e|=yt$9),e.unshift(i),e.provisional++,i}#U(t,e){for(let s=e.provisional;s<e.length;s++){let i=e[s];if((this.nocase?_t$8(t.name):bt$c(t.name))===i.#C)return this.#l(t,i,s,e)}}#l(t,e,s,i){let r=e.name;return e.#e=e.#e>$9|ie$a(t),r!==t.name&&(e.name=t.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(e)),i.provisional++,e}async lstat(){if((this.#e&j$8)===0)try{return this.#$(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#F(t.code);}}lstatSync(){if((this.#e&j$8)===0)try{return this.#$(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#F(t.code);}}#$(t){let{atime:e,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:o,blocks:h,ctime:a,ctimeMs:l,dev:u,gid:c,ino:d,mode:f,mtime:m,mtimeMs:p,nlink:w,rdev:g,size:S,uid:E}=t;this.#b=e,this.#a=s,this.#m=i,this.#E=r,this.#c=o,this.#f=h,this.#R=a,this.#d=l,this.#s=u,this.#S=c,this.#h=d,this.#n=f,this.#p=m,this.#i=p,this.#r=w,this.#w=g,this.#u=S,this.#o=E;let y=ie$a(t);this.#e=this.#e>$9|y|je$a,y!==L$8&&y!==U$8&&y!==X$a&&(this.#e|=yt$9);}#W=[];#O=false;#H(t){this.#O=false;let e=this.#W.slice();this.#W.length=0,e.forEach(s=>s(null,t));}readdirCB(t,e=false){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);e?t(null,r):queueMicrotask(()=>t(null,r));return}if(this.#W.push(t),this.#O)return;this.#O=true;let i=this.fullpath();this.#t.readdir(i,{withFileTypes:true},(r,o)=>{if(r)this.#I(r.code),s.provisional=0;else {for(let h of o)this.#z(h,s);this.#j(s);}this.#H(s.slice(0,s.provisional));});}#q;async readdir(){if(!this.canReaddir())return [];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#q)await this.#q;else {let s=()=>{};this.#q=new Promise(i=>s=i);try{for(let i of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#z(i,t);this.#j(t);}catch(i){this.#I(i.code),t.provisional=0;}this.#q=void 0,s();}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return [];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let s of this.#t.readdirSync(e,{withFileTypes:!0}))this.#z(s,t);this.#j(t);}catch(s){this.#I(s.code),t.provisional=0;}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&Ie$a)return false;let t=_$8&this.#e;return t===L$8||t===U$8||t===X$a}shouldWalk(t,e){return (this.#e&U$8)===U$8&&!(this.#e&Ie$a)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#k)return this.#k;if(!((Lt$9|Nt$b|j$8)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#k=this.resolve(t)}catch{this.#P();}}realpathSync(){if(this.#k)return this.#k;if(!((Lt$9|Nt$b|j$8)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#k=this.resolve(t)}catch{this.#P();}}[Ye$9](t){if(t===this)return;t.isCWD=false,this.isCWD=true;let e=new Set([]),s=[],i=this;for(;i&&i.parent;)e.add(i),i.#x=s.join(this.sep),i.#A=s.join("/"),i=i.parent,s.push("..");for(i=t;i&&i.parent&&!e.has(i);)i.#x=void 0,i.#A=void 0,i=i.parent;}},Pt$b=class n extends R$9{sep="\\";splitSep=Oi$8;constructor(t,e=L$8,s,i,r,o,h){super(t,e,s,i,r,o,h);}newChild(t,e=L$8,s={}){return new n(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return win32.parse(t).root}getRoot(t){if(t=Ri$7(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,s]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=s;return this.roots[t]=new it$8(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace($e$a,"$1\\"),t===e}},jt$7=class n extends R$9{splitSep="/";sep="/";constructor(t,e=L$8,s,i,r,o,h){super(t,e,s,i,r,o,h);}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=L$8,s={}){return new n(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},It$a=class It{root;rootPath;roots;cwd;#t;#s;#n;nocase;#r;constructor(t=process.cwd(),e,s,{nocase:i,childrenCacheSize:r=16*1024,fs:o=wt$a}={}){this.#r=Ue$9(o),(t instanceof URL||t.startsWith("file://"))&&(t=fileURLToPath(t));let h=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(h),this.#t=new Wt$9,this.#s=new Wt$9,this.#n=new ne$9(r);let a=h.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let l=this.root,u=a.length-1,c=e.sep,d=this.rootPath,f=false;for(let m of a){let p=u--;l=l.child(m,{relative:new Array(p).fill("..").join(c),relativePosix:new Array(p).fill("..").join("/"),fullpath:d+=(f?"":c)+m}),f=true;}this.cwd=l;}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#t.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpath();return this.#t.set(e,i),i}resolvePosix(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#s.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpathPosix();return this.#s.set(e,i),i}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:true}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let i=await t.readdir();return s?i:i.map(r=>r.name)}else return []}readdirSync(t=this.cwd,e={withFileTypes:true}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd);let{withFileTypes:s=true}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(i=>i.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:r,walkFilter:o}=e,h=[];(!r||r(t))&&h.push(s?t:t.fullpath());let a=new Set,l=(c,d)=>{a.add(c),c.readdirCB((f,m)=>{if(f)return d(f);let p=m.length;if(!p)return d();let w=()=>{--p===0&&d();};for(let g of m)(!r||r(g))&&h.push(s?g:g.fullpath()),i&&g.isSymbolicLink()?g.realpath().then(S=>S?.isUnknown()?S.lstat():S).then(S=>S?.shouldWalk(a,o)?l(S,w):w()):g.shouldWalk(a,o)?l(g,w):w();},true);},u=t;return new Promise((c,d)=>{l(u,f=>{if(f)return d(f);c(h);});})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:r,walkFilter:o}=e,h=[];(!r||r(t))&&h.push(s?t:t.fullpath());let a=new Set([t]);for(let l of a){let u=l.readdirSync();for(let c of u){(!r||r(c))&&h.push(s?c:c.fullpath());let d=c;if(c.isSymbolicLink()){if(!(i&&(d=c.realpathSync())))continue;d.isUnknown()&&d.lstatSync();}d.shouldWalk(a,o)&&a.add(d);}}return h}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:r,walkFilter:o}=e;(!r||r(t))&&(yield s?t:t.fullpath());let h=new Set([t]);for(let a of h){let l=a.readdirSync();for(let u of l){(!r||r(u))&&(yield s?u:u.fullpath());let c=u;if(u.isSymbolicLink()){if(!(i&&(c=u.realpathSync())))continue;c.isUnknown()&&c.lstatSync();}c.shouldWalk(h,o)&&h.add(c);}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:r,walkFilter:o}=e,h=new V$a({objectMode:true});(!r||r(t))&&h.write(s?t:t.fullpath());let a=new Set,l=[t],u=0,c=()=>{let d=false;for(;!d;){let f=l.shift();if(!f){u===0&&h.end();return}u++,a.add(f);let m=(w,g,S=false)=>{if(w)return h.emit("error",w);if(i&&!S){let E=[];for(let y of g)y.isSymbolicLink()&&E.push(y.realpath().then(b=>b?.isUnknown()?b.lstat():b));if(E.length){Promise.all(E).then(()=>m(null,g,true));return}}for(let E of g)E&&(!r||r(E))&&(h.write(s?E:E.fullpath())||(d=true));u--;for(let E of g){let y=E.realpathCached()||E;y.shouldWalk(a,o)&&l.push(y);}d&&!h.flowing?h.once("drain",c):p||c();},p=true;f.readdirCB(m,true),p=false;}};return c(),h}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof R$9||(e=t,t=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:r,walkFilter:o}=e,h=new V$a({objectMode:true}),a=new Set;(!r||r(t))&&h.write(s?t:t.fullpath());let l=[t],u=0,c=()=>{let d=false;for(;!d;){let f=l.shift();if(!f){u===0&&h.end();return}u++,a.add(f);let m=f.readdirSync();for(let p of m)(!r||r(p))&&(h.write(s?p:p.fullpath())||(d=true));u--;for(let p of m){let w=p;if(p.isSymbolicLink()){if(!(i&&(w=p.realpathSync())))continue;w.isUnknown()&&w.lstatSync();}w.shouldWalk(a,o)&&l.push(w);}}d&&!h.flowing&&h.once("drain",c);};return c(),h}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[Ye$9](e);}},it$8=class it extends It$a{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=true}=e;super(t,win32,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase;}parseRootPath(t){return win32.parse(t).root.toUpperCase()}newRoot(t){return new Pt$b(this.rootPath,U$8,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},rt$b=class rt extends It$a{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=false}=e;super(t,posix,"/",{...e,nocase:s}),this.nocase=s;}parseRootPath(t){return "/"}newRoot(t){return new jt$7(this.rootPath,U$8,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},St$b=class St extends rt$b{constructor(t=process.cwd(),e={}){let{nocase:s=true}=e;super(t,{...e,nocase:s});}};process.platform==="win32"?Pt$b:jt$7;var Xe$a=process.platform==="win32"?it$8:process.platform==="darwin"?St$b:rt$b;var Di$7=n=>n.length>=1,Mi$6=n=>n.length>=1,Ni$8=Symbol.for("nodejs.util.inspect.custom"),nt$a=class n{#t;#s;#n;length;#r;#o;#S;#w;#c;#h;#u=true;constructor(t,e,s,i){if(!Di$7(t))throw new TypeError("empty pattern list");if(!Mi$6(e))throw new TypeError("empty glob list");if(e.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#s=e,this.#n=s,this.#r=i,this.#n===0){if(this.isUNC()){let[r,o,h,a,...l]=this.#t,[u,c,d,f,...m]=this.#s;l[0]===""&&(l.shift(),m.shift());let p=[r,o,h,a,""].join("/"),w=[u,c,d,f,""].join("/");this.#t=[p,...l],this.#s=[w,...m],this.length=this.#t.length;}else if(this.isDrive()||this.isAbsolute()){let[r,...o]=this.#t,[h,...a]=this.#s;o[0]===""&&(o.shift(),a.shift());let l=r+"/",u=h+"/";this.#t=[l,...o],this.#s=[u,...a],this.length=this.#t.length;}}}[Ni$8](){return "Pattern <"+this.#s.slice(this.#n).join("/")+">"}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===A$7}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#S=this.#S||(this.#n===0?this.isAbsolute()?this.#s[0]+this.#s.slice(1).join("/"):this.#s.join("/"):this.#s.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new n(this.#t,this.#s,this.#n+1,this.#r),this.#o.#h=this.#h,this.#o.#c=this.#c,this.#o.#w=this.#w,this.#o):this.#o=null}isUNC(){let t=this.#t;return this.#c!==void 0?this.#c:this.#c=this.#r==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#w!==void 0?this.#w:this.#w=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#h!==void 0?this.#h:this.#h=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return !(this.#n===0||!this.isGlobstar()||!this.#u)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#u?false:(this.#u=false,true)}};var _i$8=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ot$7=class ot{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:s,noext:i,noglobstar:r,platform:o=_i$8}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:true,nobrace:e,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let h of t)this.add(h);}add(t){let e=new D$4(t,this.mmopts);for(let s=0;s<e.set.length;s++){let i=e.set[s],r=e.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let o=new nt$a(i,r,0,this.platform),h=new D$4(o.globString(),this.mmopts),a=r[r.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(h):this.relative.push(h),a&&(l?this.absoluteChildren.push(h):this.relativeChildren.push(h));}}ignored(t){let e=t.fullpath(),s=`${e}/`,i=t.relative()||".",r=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(r))return true;for(let o of this.absolute)if(o.match(e)||o.match(s))return true;return false}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return true;for(let i of this.absoluteChildren)if(i.match(e))return true;return false}};var oe$9=class n{store;constructor(t=new Map){this.store=t;}copy(){return new n(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),i=this.store.get(s);i?i.add(e.globString()):this.store.set(s,new Set([e.globString()]));}},he$a=class he{store=new Map;add(t,e,s){let i=(e?2:0)|(s?1:0),r=this.store.get(t);this.store.set(t,r===void 0?i:i&r);}entries(){return [...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},ae$8=class ae{store=new Map;add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(i=>i.globString()===e.globString())||s.push(e):this.store.set(t,[e]);}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return [...this.store.keys()].filter(t=>t.canReaddir())}},Et$c=class n{hasWalkedCache;matches=new he$a;subwalks=new ae$8;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new oe$9;}processPatterns(t,e){this.patterns=e;let s=e.map(i=>[t,i]);for(let[i,r]of s){this.hasWalkedCache.storeWalked(i,r);let o=r.root(),h=r.isAbsolute()&&this.opts.absolute!==false;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let c=r.rest();if(c)r=c;else {this.matches.add(i,true,false);continue}}if(i.isENOENT())continue;let a,l,u=false;for(;typeof(a=r.pattern())=="string"&&(l=r.rest());)i=i.resolve(a),r=l,u=true;if(a=r.pattern(),l=r.rest(),u){if(this.hasWalkedCache.hasWalked(i,r))continue;this.hasWalkedCache.storeWalked(i,r);}if(typeof a=="string"){let c=a===".."||a===""||a===".";this.matches.add(i.resolve(a),h,c);continue}else if(a===A$7){(!i.isSymbolicLink()||this.follow||r.checkFollowGlobstar())&&this.subwalks.add(i,r);let c=l?.pattern(),d=l?.rest();if(!l||(c===""||c===".")&&!d)this.matches.add(i,h,c===""||c===".");else if(c===".."){let f=i.parent||i;d?this.hasWalkedCache.hasWalked(f,d)||this.subwalks.add(f,d):this.matches.add(f,h,true);}}else a instanceof RegExp&&this.subwalks.add(i,r);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new n(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),i=this.child();for(let r of e)for(let o of s){let h=o.isAbsolute(),a=o.pattern(),l=o.rest();a===A$7?i.testGlobstar(r,o,l,h):a instanceof RegExp?i.testRegExp(r,a,l,h):i.testString(r,a,l,h);}return i}testGlobstar(t,e,s,i){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,i,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let r=s.pattern();if(typeof r=="string"&&r!==".."&&r!==""&&r!==".")this.testString(t,r,s.rest(),i);else if(r===".."){let o=t.parent||t;this.subwalks.add(o,s);}else r instanceof RegExp&&this.testRegExp(t,r,s.rest(),i);}}testRegExp(t,e,s,i){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,false));}testString(t,e,s,i){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,false));}};var Li$7=(n,t)=>typeof n=="string"?new ot$7([n],t):Array.isArray(n)?new ot$7(n,t):n,zt$8=class zt{path;patterns;opts;seen=new Set;paused=false;aborted=false;#t=[];#s;#n;signal;maxDepth;includeChildMatches;constructor(t,e,s){if(this.patterns=t,this.path=e,this.opts=s,this.#n=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==false,(s.ignore||!this.includeChildMatches)&&(this.#s=Li$7(s.ignore??[],s),!this.includeChildMatches&&typeof this.#s.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0;}));}#r(t){return this.seen.has(t)||!!this.#s?.ignored?.(t)}#o(t){return !!this.#s?.childrenIgnored?.(t)}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let t;for(;!this.paused&&(t=this.#t.shift());)t();}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t());}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s;}let r=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=await r.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat();}return this.matchCheckTest(r,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#r(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s;}let r=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=r.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync();}return this.matchCheckTest(r,e)}matchFinish(t,e){if(this.#r(t))return;if(!this.includeChildMatches&&this.#s?.add){let r=`${t.relativePosix()}/**`;this.#s.add(r);}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let i=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let r=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(r+i);}else {let r=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(r?o+r+i:"."+i);}}async match(t,e,s){let i=await this.matchCheck(t,s);i&&this.matchFinish(i,e);}matchSync(t,e,s){let i=this.matchCheckSync(t,s);i&&this.matchFinish(i,e);}walkCB(t,e,s){this.signal?.aborted&&s(),this.walkCB2(t,e,new Et$c(this.opts),s);}walkCB2(t,e,s,i){if(this.#o(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,i));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&i();};for(let[h,a,l]of s.matches.entries())this.#r(h)||(r++,this.match(h,a,l).then(()=>o()));for(let h of s.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;r++;let a=h.readdirCached();h.calledReaddir()?this.walkCB3(h,a,s,o):h.readdirCB((l,u)=>this.walkCB3(h,u,s,o),true);}o();}walkCB3(t,e,s,i){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&i();};for(let[h,a,l]of s.matches.entries())this.#r(h)||(r++,this.match(h,a,l).then(()=>o()));for(let[h,a]of s.subwalks.entries())r++,this.walkCB2(h,a,s.child(),o);o();}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new Et$c(this.opts),s);}walkCB2Sync(t,e,s,i){if(this.#o(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,i));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&i();};for(let[h,a,l]of s.matches.entries())this.#r(h)||this.matchSync(h,a,l);for(let h of s.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;r++;let a=h.readdirSync();this.walkCB3Sync(h,a,s,o);}o();}walkCB3Sync(t,e,s,i){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&i();};for(let[h,a,l]of s.matches.entries())this.#r(h)||this.matchSync(h,a,l);for(let[h,a]of s.subwalks.entries())r++,this.walkCB2Sync(h,a,s.child(),o);o();}},xt$9=class xt extends zt$8{matches=new Set;constructor(t,e,s){super(t,e,s);}matchEmit(t){this.matches.add(t);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(this.matches);});}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},vt$b=class vt extends zt$8{results;constructor(t,e,s){super(t,e,s),this.results=new V$a({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(t){this.results.write(t),this.results.flowing||this.pause();}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end());}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var Pi$7=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",I$7=class I{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=fileURLToPath(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==false,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===false,this.windowsPathsNoEscape&&(t=t.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(a=>a.includes("/")?a:`./**/${a}`);}if(this.pattern=t,this.platform=e.platform||Pi$7,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let a=e.platform==="win32"?it$8:e.platform==="darwin"?St$b:e.platform?rt$b:Xe$a;this.scurry=new a(this.cwd,{nocase:e.nocase,fs:e.fs});}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={braceExpandMax:1e4,...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(a=>new D$4(a,i)),[o,h]=r.reduce((a,l)=>(a[0].push(...l.set),a[1].push(...l.globParts),a),[[],[]]);this.patterns=o.map((a,l)=>{let u=h[l];if(!u)throw new Error("invalid pattern object");return new nt$a(a,u,0,this.platform)});}async walk(){return [...await new xt$9(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return [...new xt$9(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new vt$b(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new vt$b(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var le$8=(n,t={})=>{Array.isArray(n)||(n=[n]);for(let e of n)if(new D$4(e,t).hasMagic())return true;return false};function Bt$8(n,t={}){return new I$7(n,t).streamSync()}function Qe$a(n,t={}){return new I$7(n,t).stream()}function ts$7(n,t={}){return new I$7(n,t).walkSync()}async function Je$a(n,t={}){return new I$7(n,t).walk()}function Ut$a(n,t={}){return new I$7(n,t).iterateSync()}function es$7(n,t={}){return new I$7(n,t).iterate()}var ji$6=Bt$8,Ii$7=Object.assign(Qe$a,{sync:Bt$8}),zi$7=Ut$a,Bi$7=Object.assign(es$7,{sync:Ut$a}),Ui$7=Object.assign(ts$7,{stream:Bt$8,iterate:Ut$a}),Ze$a=Object.assign(Je$a,{glob:Je$a,globSync:ts$7,sync:Ui$7,globStream:Qe$a,stream:Ii$7,globStreamSync:Bt$8,streamSync:ji$6,globIterate:es$7,iterate:Bi$7,globIterateSync:Ut$a,iterateSync:zi$7,Glob:I$7,hasMagic:le$8,escape:tt$a,unescape:W$9});Ze$a.glob=Ze$a;
|
|
8409
8409
|
|
|
8410
|
-
const balanced = (a, b, str) => {
|
|
8411
|
-
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
8412
|
-
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
8413
|
-
const r = ma !== null && mb != null && range$1(ma, mb, str);
|
|
8414
|
-
return (r && {
|
|
8415
|
-
start: r[0],
|
|
8416
|
-
end: r[1],
|
|
8417
|
-
pre: str.slice(0, r[0]),
|
|
8418
|
-
body: str.slice(r[0] + ma.length, r[1]),
|
|
8419
|
-
post: str.slice(r[1] + mb.length),
|
|
8420
|
-
});
|
|
8421
|
-
};
|
|
8422
|
-
const maybeMatch = (reg, str) => {
|
|
8423
|
-
const m = str.match(reg);
|
|
8424
|
-
return m ? m[0] : null;
|
|
8425
|
-
};
|
|
8426
|
-
const range$1 = (a, b, str) => {
|
|
8427
|
-
let begs, beg, left, right = undefined, result;
|
|
8428
|
-
let ai = str.indexOf(a);
|
|
8429
|
-
let bi = str.indexOf(b, ai + 1);
|
|
8430
|
-
let i = ai;
|
|
8431
|
-
if (ai >= 0 && bi > 0) {
|
|
8432
|
-
if (a === b) {
|
|
8433
|
-
return [ai, bi];
|
|
8434
|
-
}
|
|
8435
|
-
begs = [];
|
|
8436
|
-
left = str.length;
|
|
8437
|
-
while (i >= 0 && !result) {
|
|
8438
|
-
if (i === ai) {
|
|
8439
|
-
begs.push(i);
|
|
8440
|
-
ai = str.indexOf(a, i + 1);
|
|
8441
|
-
}
|
|
8442
|
-
else if (begs.length === 1) {
|
|
8443
|
-
const r = begs.pop();
|
|
8444
|
-
if (r !== undefined)
|
|
8445
|
-
result = [r, bi];
|
|
8446
|
-
}
|
|
8447
|
-
else {
|
|
8448
|
-
beg = begs.pop();
|
|
8449
|
-
if (beg !== undefined && beg < left) {
|
|
8450
|
-
left = beg;
|
|
8451
|
-
right = bi;
|
|
8452
|
-
}
|
|
8453
|
-
bi = str.indexOf(b, i + 1);
|
|
8454
|
-
}
|
|
8455
|
-
i = ai < bi && ai >= 0 ? ai : bi;
|
|
8456
|
-
}
|
|
8457
|
-
if (begs.length && right !== undefined) {
|
|
8458
|
-
result = [left, right];
|
|
8459
|
-
}
|
|
8460
|
-
}
|
|
8461
|
-
return result;
|
|
8462
|
-
};
|
|
8463
|
-
|
|
8464
|
-
const escSlash = '\0SLASH' + Math.random() + '\0';
|
|
8465
|
-
const escOpen = '\0OPEN' + Math.random() + '\0';
|
|
8466
|
-
const escClose = '\0CLOSE' + Math.random() + '\0';
|
|
8467
|
-
const escComma = '\0COMMA' + Math.random() + '\0';
|
|
8468
|
-
const escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
8469
|
-
const escSlashPattern = new RegExp(escSlash, 'g');
|
|
8470
|
-
const escOpenPattern = new RegExp(escOpen, 'g');
|
|
8471
|
-
const escClosePattern = new RegExp(escClose, 'g');
|
|
8472
|
-
const escCommaPattern = new RegExp(escComma, 'g');
|
|
8473
|
-
const escPeriodPattern = new RegExp(escPeriod, 'g');
|
|
8474
|
-
const slashPattern = /\\\\/g;
|
|
8475
|
-
const openPattern = /\\{/g;
|
|
8476
|
-
const closePattern = /\\}/g;
|
|
8477
|
-
const commaPattern = /\\,/g;
|
|
8478
|
-
const periodPattern = /\\\./g;
|
|
8479
|
-
const EXPANSION_MAX = 100_000;
|
|
8480
|
-
function numeric(str) {
|
|
8481
|
-
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
8482
|
-
}
|
|
8483
|
-
function escapeBraces(str) {
|
|
8484
|
-
return str
|
|
8485
|
-
.replace(slashPattern, escSlash)
|
|
8486
|
-
.replace(openPattern, escOpen)
|
|
8487
|
-
.replace(closePattern, escClose)
|
|
8488
|
-
.replace(commaPattern, escComma)
|
|
8489
|
-
.replace(periodPattern, escPeriod);
|
|
8490
|
-
}
|
|
8491
|
-
function unescapeBraces(str) {
|
|
8492
|
-
return str
|
|
8493
|
-
.replace(escSlashPattern, '\\')
|
|
8494
|
-
.replace(escOpenPattern, '{')
|
|
8495
|
-
.replace(escClosePattern, '}')
|
|
8496
|
-
.replace(escCommaPattern, ',')
|
|
8497
|
-
.replace(escPeriodPattern, '.');
|
|
8498
|
-
}
|
|
8499
|
-
/**
|
|
8500
|
-
* Basically just str.split(","), but handling cases
|
|
8501
|
-
* where we have nested braced sections, which should be
|
|
8502
|
-
* treated as individual members, like {a,{b,c},d}
|
|
8503
|
-
*/
|
|
8504
|
-
function parseCommaParts(str) {
|
|
8505
|
-
if (!str) {
|
|
8506
|
-
return [''];
|
|
8507
|
-
}
|
|
8508
|
-
const parts = [];
|
|
8509
|
-
const m = balanced('{', '}', str);
|
|
8510
|
-
if (!m) {
|
|
8511
|
-
return str.split(',');
|
|
8512
|
-
}
|
|
8513
|
-
const { pre, body, post } = m;
|
|
8514
|
-
const p = pre.split(',');
|
|
8515
|
-
p[p.length - 1] += '{' + body + '}';
|
|
8516
|
-
const postParts = parseCommaParts(post);
|
|
8517
|
-
if (post.length) {
|
|
8518
|
-
p[p.length - 1] += postParts.shift();
|
|
8519
|
-
p.push.apply(p, postParts);
|
|
8520
|
-
}
|
|
8521
|
-
parts.push.apply(parts, p);
|
|
8522
|
-
return parts;
|
|
8523
|
-
}
|
|
8524
|
-
function expand(str, options = {}) {
|
|
8525
|
-
if (!str) {
|
|
8526
|
-
return [];
|
|
8527
|
-
}
|
|
8528
|
-
const { max = EXPANSION_MAX } = options;
|
|
8529
|
-
// I don't know why Bash 4.3 does this, but it does.
|
|
8530
|
-
// Anything starting with {} will have the first two bytes preserved
|
|
8531
|
-
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
8532
|
-
// but a{},b}c will be expanded to [a}c,abc].
|
|
8533
|
-
// One could argue that this is a bug in Bash, but since the goal of
|
|
8534
|
-
// this module is to match Bash's rules, we escape a leading {}
|
|
8535
|
-
if (str.slice(0, 2) === '{}') {
|
|
8536
|
-
str = '\\{\\}' + str.slice(2);
|
|
8537
|
-
}
|
|
8538
|
-
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
8539
|
-
}
|
|
8540
|
-
function embrace(str) {
|
|
8541
|
-
return '{' + str + '}';
|
|
8542
|
-
}
|
|
8543
|
-
function isPadded(el) {
|
|
8544
|
-
return /^-?0\d/.test(el);
|
|
8545
|
-
}
|
|
8546
|
-
function lte(i, y) {
|
|
8547
|
-
return i <= y;
|
|
8548
|
-
}
|
|
8549
|
-
function gte(i, y) {
|
|
8550
|
-
return i >= y;
|
|
8551
|
-
}
|
|
8552
|
-
function expand_(str, max, isTop) {
|
|
8553
|
-
/** @type {string[]} */
|
|
8554
|
-
const expansions = [];
|
|
8555
|
-
const m = balanced('{', '}', str);
|
|
8556
|
-
if (!m)
|
|
8557
|
-
return [str];
|
|
8558
|
-
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
8559
|
-
const pre = m.pre;
|
|
8560
|
-
const post = m.post.length ? expand_(m.post, max, false) : [''];
|
|
8561
|
-
if (/\$$/.test(m.pre)) {
|
|
8562
|
-
for (let k = 0; k < post.length && k < max; k++) {
|
|
8563
|
-
const expansion = pre + '{' + m.body + '}' + post[k];
|
|
8564
|
-
expansions.push(expansion);
|
|
8565
|
-
}
|
|
8566
|
-
}
|
|
8567
|
-
else {
|
|
8568
|
-
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
8569
|
-
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
8570
|
-
const isSequence = isNumericSequence || isAlphaSequence;
|
|
8571
|
-
const isOptions = m.body.indexOf(',') >= 0;
|
|
8572
|
-
if (!isSequence && !isOptions) {
|
|
8573
|
-
// {a},b}
|
|
8574
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
8575
|
-
str = m.pre + '{' + m.body + escClose + m.post;
|
|
8576
|
-
return expand_(str, max, true);
|
|
8577
|
-
}
|
|
8578
|
-
return [str];
|
|
8579
|
-
}
|
|
8580
|
-
let n;
|
|
8581
|
-
if (isSequence) {
|
|
8582
|
-
n = m.body.split(/\.\./);
|
|
8583
|
-
}
|
|
8584
|
-
else {
|
|
8585
|
-
n = parseCommaParts(m.body);
|
|
8586
|
-
if (n.length === 1 && n[0] !== undefined) {
|
|
8587
|
-
// x{{a,b}}y ==> x{a}y x{b}y
|
|
8588
|
-
n = expand_(n[0], max, false).map(embrace);
|
|
8589
|
-
//XXX is this necessary? Can't seem to hit it in tests.
|
|
8590
|
-
/* c8 ignore start */
|
|
8591
|
-
if (n.length === 1) {
|
|
8592
|
-
return post.map(p => m.pre + n[0] + p);
|
|
8593
|
-
}
|
|
8594
|
-
/* c8 ignore stop */
|
|
8595
|
-
}
|
|
8596
|
-
}
|
|
8597
|
-
// at this point, n is the parts, and we know it's not a comma set
|
|
8598
|
-
// with a single entry.
|
|
8599
|
-
let N;
|
|
8600
|
-
if (isSequence && n[0] !== undefined && n[1] !== undefined) {
|
|
8601
|
-
const x = numeric(n[0]);
|
|
8602
|
-
const y = numeric(n[1]);
|
|
8603
|
-
const width = Math.max(n[0].length, n[1].length);
|
|
8604
|
-
let incr = n.length === 3 && n[2] !== undefined ? Math.abs(numeric(n[2])) : 1;
|
|
8605
|
-
let test = lte;
|
|
8606
|
-
const reverse = y < x;
|
|
8607
|
-
if (reverse) {
|
|
8608
|
-
incr *= -1;
|
|
8609
|
-
test = gte;
|
|
8610
|
-
}
|
|
8611
|
-
const pad = n.some(isPadded);
|
|
8612
|
-
N = [];
|
|
8613
|
-
for (let i = x; test(i, y); i += incr) {
|
|
8614
|
-
let c;
|
|
8615
|
-
if (isAlphaSequence) {
|
|
8616
|
-
c = String.fromCharCode(i);
|
|
8617
|
-
if (c === '\\') {
|
|
8618
|
-
c = '';
|
|
8619
|
-
}
|
|
8620
|
-
}
|
|
8621
|
-
else {
|
|
8622
|
-
c = String(i);
|
|
8623
|
-
if (pad) {
|
|
8624
|
-
const need = width - c.length;
|
|
8625
|
-
if (need > 0) {
|
|
8626
|
-
const z = new Array(need + 1).join('0');
|
|
8627
|
-
if (i < 0) {
|
|
8628
|
-
c = '-' + z + c.slice(1);
|
|
8629
|
-
}
|
|
8630
|
-
else {
|
|
8631
|
-
c = z + c;
|
|
8632
|
-
}
|
|
8633
|
-
}
|
|
8634
|
-
}
|
|
8635
|
-
}
|
|
8636
|
-
N.push(c);
|
|
8637
|
-
}
|
|
8638
|
-
}
|
|
8639
|
-
else {
|
|
8640
|
-
N = [];
|
|
8641
|
-
for (let j = 0; j < n.length; j++) {
|
|
8642
|
-
N.push.apply(N, expand_(n[j], max, false));
|
|
8643
|
-
}
|
|
8644
|
-
}
|
|
8645
|
-
for (let j = 0; j < N.length; j++) {
|
|
8646
|
-
for (let k = 0; k < post.length && expansions.length < max; k++) {
|
|
8647
|
-
const expansion = pre + N[j] + post[k];
|
|
8648
|
-
if (!isTop || isSequence || expansion) {
|
|
8649
|
-
expansions.push(expansion);
|
|
8650
|
-
}
|
|
8651
|
-
}
|
|
8652
|
-
}
|
|
8653
|
-
}
|
|
8654
|
-
return expansions;
|
|
8655
|
-
}
|
|
8656
|
-
|
|
8657
|
-
const MAX_PATTERN_LENGTH = 1024 * 64;
|
|
8658
|
-
const assertValidPattern = (pattern) => {
|
|
8659
|
-
if (typeof pattern !== 'string') {
|
|
8660
|
-
throw new TypeError('invalid pattern');
|
|
8661
|
-
}
|
|
8662
|
-
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
8663
|
-
throw new TypeError('pattern is too long');
|
|
8664
|
-
}
|
|
8665
|
-
};
|
|
8666
|
-
|
|
8667
|
-
// translate the various posix character classes into unicode properties
|
|
8668
|
-
// this works across all unicode locales
|
|
8669
|
-
// { <posix class>: [<translation>, /u flag required, negated]
|
|
8670
|
-
const posixClasses = {
|
|
8671
|
-
'[:alnum:]': ['\\p{L}\\p{Nl}\\p{Nd}', true],
|
|
8672
|
-
'[:alpha:]': ['\\p{L}\\p{Nl}', true],
|
|
8673
|
-
'[:ascii:]': ['\\x' + '00-\\x' + '7f', false],
|
|
8674
|
-
'[:blank:]': ['\\p{Zs}\\t', true],
|
|
8675
|
-
'[:cntrl:]': ['\\p{Cc}', true],
|
|
8676
|
-
'[:digit:]': ['\\p{Nd}', true],
|
|
8677
|
-
'[:graph:]': ['\\p{Z}\\p{C}', true, true],
|
|
8678
|
-
'[:lower:]': ['\\p{Ll}', true],
|
|
8679
|
-
'[:print:]': ['\\p{C}', true],
|
|
8680
|
-
'[:punct:]': ['\\p{P}', true],
|
|
8681
|
-
'[:space:]': ['\\p{Z}\\t\\r\\n\\v\\f', true],
|
|
8682
|
-
'[:upper:]': ['\\p{Lu}', true],
|
|
8683
|
-
'[:word:]': ['\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}', true],
|
|
8684
|
-
'[:xdigit:]': ['A-Fa-f0-9', false],
|
|
8685
|
-
};
|
|
8686
|
-
// only need to escape a few things inside of brace expressions
|
|
8687
|
-
// escapes: [ \ ] -
|
|
8688
|
-
const braceEscape = (s) => s.replace(/[[\]\\-]/g, '\\$&');
|
|
8689
|
-
// escape all regexp magic characters
|
|
8690
|
-
const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
8691
|
-
// everything has already been escaped, we just have to join
|
|
8692
|
-
const rangesToString = (ranges) => ranges.join('');
|
|
8693
|
-
// takes a glob string at a posix brace expression, and returns
|
|
8694
|
-
// an equivalent regular expression source, and boolean indicating
|
|
8695
|
-
// whether the /u flag needs to be applied, and the number of chars
|
|
8696
|
-
// consumed to parse the character class.
|
|
8697
|
-
// This also removes out of order ranges, and returns ($.) if the
|
|
8698
|
-
// entire class just no good.
|
|
8699
|
-
const parseClass = (glob, position) => {
|
|
8700
|
-
const pos = position;
|
|
8701
|
-
/* c8 ignore start */
|
|
8702
|
-
if (glob.charAt(pos) !== '[') {
|
|
8703
|
-
throw new Error('not in a brace expression');
|
|
8704
|
-
}
|
|
8705
|
-
/* c8 ignore stop */
|
|
8706
|
-
const ranges = [];
|
|
8707
|
-
const negs = [];
|
|
8708
|
-
let i = pos + 1;
|
|
8709
|
-
let sawStart = false;
|
|
8710
|
-
let uflag = false;
|
|
8711
|
-
let escaping = false;
|
|
8712
|
-
let negate = false;
|
|
8713
|
-
let endPos = pos;
|
|
8714
|
-
let rangeStart = '';
|
|
8715
|
-
WHILE: while (i < glob.length) {
|
|
8716
|
-
const c = glob.charAt(i);
|
|
8717
|
-
if ((c === '!' || c === '^') && i === pos + 1) {
|
|
8718
|
-
negate = true;
|
|
8719
|
-
i++;
|
|
8720
|
-
continue;
|
|
8721
|
-
}
|
|
8722
|
-
if (c === ']' && sawStart && !escaping) {
|
|
8723
|
-
endPos = i + 1;
|
|
8724
|
-
break;
|
|
8725
|
-
}
|
|
8726
|
-
sawStart = true;
|
|
8727
|
-
if (c === '\\') {
|
|
8728
|
-
if (!escaping) {
|
|
8729
|
-
escaping = true;
|
|
8730
|
-
i++;
|
|
8731
|
-
continue;
|
|
8732
|
-
}
|
|
8733
|
-
// escaped \ char, fall through and treat like normal char
|
|
8734
|
-
}
|
|
8735
|
-
if (c === '[' && !escaping) {
|
|
8736
|
-
// either a posix class, a collation equivalent, or just a [
|
|
8737
|
-
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
8738
|
-
if (glob.startsWith(cls, i)) {
|
|
8739
|
-
// invalid, [a-[] is fine, but not [a-[:alpha]]
|
|
8740
|
-
if (rangeStart) {
|
|
8741
|
-
return ['$.', false, glob.length - pos, true];
|
|
8742
|
-
}
|
|
8743
|
-
i += cls.length;
|
|
8744
|
-
if (neg)
|
|
8745
|
-
negs.push(unip);
|
|
8746
|
-
else
|
|
8747
|
-
ranges.push(unip);
|
|
8748
|
-
uflag = uflag || u;
|
|
8749
|
-
continue WHILE;
|
|
8750
|
-
}
|
|
8751
|
-
}
|
|
8752
|
-
}
|
|
8753
|
-
// now it's just a normal character, effectively
|
|
8754
|
-
escaping = false;
|
|
8755
|
-
if (rangeStart) {
|
|
8756
|
-
// throw this range away if it's not valid, but others
|
|
8757
|
-
// can still match.
|
|
8758
|
-
if (c > rangeStart) {
|
|
8759
|
-
ranges.push(braceEscape(rangeStart) + '-' + braceEscape(c));
|
|
8760
|
-
}
|
|
8761
|
-
else if (c === rangeStart) {
|
|
8762
|
-
ranges.push(braceEscape(c));
|
|
8763
|
-
}
|
|
8764
|
-
rangeStart = '';
|
|
8765
|
-
i++;
|
|
8766
|
-
continue;
|
|
8767
|
-
}
|
|
8768
|
-
// now might be the start of a range.
|
|
8769
|
-
// can be either c-d or c-] or c<more...>] or c] at this point
|
|
8770
|
-
if (glob.startsWith('-]', i + 1)) {
|
|
8771
|
-
ranges.push(braceEscape(c + '-'));
|
|
8772
|
-
i += 2;
|
|
8773
|
-
continue;
|
|
8774
|
-
}
|
|
8775
|
-
if (glob.startsWith('-', i + 1)) {
|
|
8776
|
-
rangeStart = c;
|
|
8777
|
-
i += 2;
|
|
8778
|
-
continue;
|
|
8779
|
-
}
|
|
8780
|
-
// not the start of a range, just a single character
|
|
8781
|
-
ranges.push(braceEscape(c));
|
|
8782
|
-
i++;
|
|
8783
|
-
}
|
|
8784
|
-
if (endPos < i) {
|
|
8785
|
-
// didn't see the end of the class, not a valid class,
|
|
8786
|
-
// but might still be valid as a literal match.
|
|
8787
|
-
return ['', false, 0, false];
|
|
8788
|
-
}
|
|
8789
|
-
// if we got no ranges and no negates, then we have a range that
|
|
8790
|
-
// cannot possibly match anything, and that poisons the whole glob
|
|
8791
|
-
if (!ranges.length && !negs.length) {
|
|
8792
|
-
return ['$.', false, glob.length - pos, true];
|
|
8793
|
-
}
|
|
8794
|
-
// if we got one positive range, and it's a single character, then that's
|
|
8795
|
-
// not actually a magic pattern, it's just that one literal character.
|
|
8796
|
-
// we should not treat that as "magic", we should just return the literal
|
|
8797
|
-
// character. [_] is a perfectly valid way to escape glob magic chars.
|
|
8798
|
-
if (negs.length === 0 &&
|
|
8799
|
-
ranges.length === 1 &&
|
|
8800
|
-
/^\\?.$/.test(ranges[0]) &&
|
|
8801
|
-
!negate) {
|
|
8802
|
-
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
8803
|
-
return [regexpEscape(r), false, endPos - pos, false];
|
|
8804
|
-
}
|
|
8805
|
-
const sranges = '[' + (negate ? '^' : '') + rangesToString(ranges) + ']';
|
|
8806
|
-
const snegs = '[' + (negate ? '' : '^') + rangesToString(negs) + ']';
|
|
8807
|
-
const comb = ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'
|
|
8808
|
-
: ranges.length ? sranges
|
|
8809
|
-
: snegs;
|
|
8810
|
-
return [comb, uflag, endPos - pos, true];
|
|
8811
|
-
};
|
|
8812
|
-
|
|
8813
|
-
/**
|
|
8814
|
-
* Un-escape a string that has been escaped with {@link escape}.
|
|
8815
|
-
*
|
|
8816
|
-
* If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
|
|
8817
|
-
* square-bracket escapes are removed, but not backslash escapes.
|
|
8818
|
-
*
|
|
8819
|
-
* For example, it will turn the string `'[*]'` into `*`, but it will not
|
|
8820
|
-
* turn `'\\*'` into `'*'`, because `\` is a path separator in
|
|
8821
|
-
* `windowsPathsNoEscape` mode.
|
|
8822
|
-
*
|
|
8823
|
-
* When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
|
|
8824
|
-
* backslash escapes are removed.
|
|
8825
|
-
*
|
|
8826
|
-
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
|
8827
|
-
* or unescaped.
|
|
8828
|
-
*
|
|
8829
|
-
* When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
|
|
8830
|
-
* unescaped.
|
|
8831
|
-
*/
|
|
8832
|
-
const unescape$1 = (s, { windowsPathsNoEscape = false, magicalBraces = true, } = {}) => {
|
|
8833
|
-
if (magicalBraces) {
|
|
8834
|
-
return windowsPathsNoEscape ?
|
|
8835
|
-
s.replace(/\[([^\/\\])\]/g, '$1')
|
|
8836
|
-
: s
|
|
8837
|
-
.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2')
|
|
8838
|
-
.replace(/\\([^\/])/g, '$1');
|
|
8839
|
-
}
|
|
8840
|
-
return windowsPathsNoEscape ?
|
|
8841
|
-
s.replace(/\[([^\/\\{}])\]/g, '$1')
|
|
8842
|
-
: s
|
|
8843
|
-
.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, '$1$2')
|
|
8844
|
-
.replace(/\\([^\/{}])/g, '$1');
|
|
8845
|
-
};
|
|
8846
|
-
|
|
8847
|
-
// parse a single path portion
|
|
8848
|
-
var _a$5;
|
|
8849
|
-
const types = new Set(['!', '?', '+', '*', '@']);
|
|
8850
|
-
const isExtglobType = (c) => types.has(c);
|
|
8851
|
-
const isExtglobAST = (c) => isExtglobType(c.type);
|
|
8852
|
-
// Map of which extglob types can adopt the children of a nested extglob
|
|
8853
|
-
//
|
|
8854
|
-
// anything but ! can adopt a matching type:
|
|
8855
|
-
// +(a|+(b|c)|d) => +(a|b|c|d)
|
|
8856
|
-
// *(a|*(b|c)|d) => *(a|b|c|d)
|
|
8857
|
-
// @(a|@(b|c)|d) => @(a|b|c|d)
|
|
8858
|
-
// ?(a|?(b|c)|d) => ?(a|b|c|d)
|
|
8859
|
-
//
|
|
8860
|
-
// * can adopt anything, because 0 or repetition is allowed
|
|
8861
|
-
// *(a|?(b|c)|d) => *(a|b|c|d)
|
|
8862
|
-
// *(a|+(b|c)|d) => *(a|b|c|d)
|
|
8863
|
-
// *(a|@(b|c)|d) => *(a|b|c|d)
|
|
8864
|
-
//
|
|
8865
|
-
// + can adopt @, because 1 or repetition is allowed
|
|
8866
|
-
// +(a|@(b|c)|d) => +(a|b|c|d)
|
|
8867
|
-
//
|
|
8868
|
-
// + and @ CANNOT adopt *, because 0 would be allowed
|
|
8869
|
-
// +(a|*(b|c)|d) => would match "", on *(b|c)
|
|
8870
|
-
// @(a|*(b|c)|d) => would match "", on *(b|c)
|
|
8871
|
-
//
|
|
8872
|
-
// + and @ CANNOT adopt ?, because 0 would be allowed
|
|
8873
|
-
// +(a|?(b|c)|d) => would match "", on ?(b|c)
|
|
8874
|
-
// @(a|?(b|c)|d) => would match "", on ?(b|c)
|
|
8875
|
-
//
|
|
8876
|
-
// ? can adopt @, because 0 or 1 is allowed
|
|
8877
|
-
// ?(a|@(b|c)|d) => ?(a|b|c|d)
|
|
8878
|
-
//
|
|
8879
|
-
// ? and @ CANNOT adopt * or +, because >1 would be allowed
|
|
8880
|
-
// ?(a|*(b|c)|d) => would match bbb on *(b|c)
|
|
8881
|
-
// @(a|*(b|c)|d) => would match bbb on *(b|c)
|
|
8882
|
-
// ?(a|+(b|c)|d) => would match bbb on +(b|c)
|
|
8883
|
-
// @(a|+(b|c)|d) => would match bbb on +(b|c)
|
|
8884
|
-
//
|
|
8885
|
-
// ! CANNOT adopt ! (nothing else can either)
|
|
8886
|
-
// !(a|!(b|c)|d) => !(a|b|c|d) would fail to match on b (not not b|c)
|
|
8887
|
-
//
|
|
8888
|
-
// ! can adopt @
|
|
8889
|
-
// !(a|@(b|c)|d) => !(a|b|c|d)
|
|
8890
|
-
//
|
|
8891
|
-
// ! CANNOT adopt *
|
|
8892
|
-
// !(a|*(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
|
|
8893
|
-
//
|
|
8894
|
-
// ! CANNOT adopt +
|
|
8895
|
-
// !(a|+(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
|
|
8896
|
-
//
|
|
8897
|
-
// ! CANNOT adopt ?
|
|
8898
|
-
// x!(a|?(b|c)|d) => x!(a|b|c|d) would fail to match "x"
|
|
8899
|
-
const adoptionMap = new Map([
|
|
8900
|
-
['!', ['@']],
|
|
8901
|
-
['?', ['?', '@']],
|
|
8902
|
-
['@', ['@']],
|
|
8903
|
-
['*', ['*', '+', '?', '@']],
|
|
8904
|
-
['+', ['+', '@']],
|
|
8905
|
-
]);
|
|
8906
|
-
// nested extglobs that can be adopted in, but with the addition of
|
|
8907
|
-
// a blank '' element.
|
|
8908
|
-
const adoptionWithSpaceMap = new Map([
|
|
8909
|
-
['!', ['?']],
|
|
8910
|
-
['@', ['?']],
|
|
8911
|
-
['+', ['?', '*']],
|
|
8912
|
-
]);
|
|
8913
|
-
// union of the previous two maps
|
|
8914
|
-
const adoptionAnyMap = new Map([
|
|
8915
|
-
['!', ['?', '@']],
|
|
8916
|
-
['?', ['?', '@']],
|
|
8917
|
-
['@', ['?', '@']],
|
|
8918
|
-
['*', ['*', '+', '?', '@']],
|
|
8919
|
-
['+', ['+', '@', '?', '*']],
|
|
8920
|
-
]);
|
|
8921
|
-
// Extglobs that can take over their parent if they are the only child
|
|
8922
|
-
// the key is parent, value maps child to resulting extglob parent type
|
|
8923
|
-
// '@' is omitted because it's a special case. An `@` extglob with a single
|
|
8924
|
-
// member can always be usurped by that subpattern.
|
|
8925
|
-
const usurpMap = new Map([
|
|
8926
|
-
['!', new Map([['!', '@']])],
|
|
8927
|
-
[
|
|
8928
|
-
'?',
|
|
8929
|
-
new Map([
|
|
8930
|
-
['*', '*'],
|
|
8931
|
-
['+', '*'],
|
|
8932
|
-
]),
|
|
8933
|
-
],
|
|
8934
|
-
[
|
|
8935
|
-
'@',
|
|
8936
|
-
new Map([
|
|
8937
|
-
['!', '!'],
|
|
8938
|
-
['?', '?'],
|
|
8939
|
-
['@', '@'],
|
|
8940
|
-
['*', '*'],
|
|
8941
|
-
['+', '+'],
|
|
8942
|
-
]),
|
|
8943
|
-
],
|
|
8944
|
-
[
|
|
8945
|
-
'+',
|
|
8946
|
-
new Map([
|
|
8947
|
-
['?', '*'],
|
|
8948
|
-
['*', '*'],
|
|
8949
|
-
]),
|
|
8950
|
-
],
|
|
8951
|
-
]);
|
|
8952
|
-
// Patterns that get prepended to bind to the start of either the
|
|
8953
|
-
// entire string, or just a single path portion, to prevent dots
|
|
8954
|
-
// and/or traversal patterns, when needed.
|
|
8955
|
-
// Exts don't need the ^ or / bit, because the root binds that already.
|
|
8956
|
-
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
|
|
8957
|
-
const startNoDot = '(?!\\.)';
|
|
8958
|
-
// characters that indicate a start of pattern needs the "no dots" bit,
|
|
8959
|
-
// because a dot *might* be matched. ( is not in the list, because in
|
|
8960
|
-
// the case of a child extglob, it will handle the prevention itself.
|
|
8961
|
-
const addPatternStart = new Set(['[', '.']);
|
|
8962
|
-
// cases where traversal is A-OK, no dot prevention needed
|
|
8963
|
-
const justDots = new Set(['..', '.']);
|
|
8964
|
-
const reSpecials = new Set('().*{}+?[]^$\\!');
|
|
8965
|
-
const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
8966
|
-
// any single thing other than /
|
|
8967
|
-
const qmark$1 = '[^/]';
|
|
8968
|
-
// * => any number of characters
|
|
8969
|
-
const star$1 = qmark$1 + '*?';
|
|
8970
|
-
// use + when we need to ensure that *something* matches, because the * is
|
|
8971
|
-
// the only thing in the path portion.
|
|
8972
|
-
const starNoEmpty = qmark$1 + '+?';
|
|
8973
|
-
// remove the \ chars that we added if we end up doing a nonmagic compare
|
|
8974
|
-
// const deslash = (s: string) => s.replace(/\\(.)/g, '$1')
|
|
8975
|
-
let ID = 0;
|
|
8976
|
-
class AST {
|
|
8977
|
-
type;
|
|
8978
|
-
#root;
|
|
8979
|
-
#hasMagic;
|
|
8980
|
-
#uflag = false;
|
|
8981
|
-
#parts = [];
|
|
8982
|
-
#parent;
|
|
8983
|
-
#parentIndex;
|
|
8984
|
-
#negs;
|
|
8985
|
-
#filledNegs = false;
|
|
8986
|
-
#options;
|
|
8987
|
-
#toString;
|
|
8988
|
-
// set to true if it's an extglob with no children
|
|
8989
|
-
// (which really means one child of '')
|
|
8990
|
-
#emptyExt = false;
|
|
8991
|
-
id = ++ID;
|
|
8992
|
-
get depth() {
|
|
8993
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
8994
|
-
}
|
|
8995
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
8996
|
-
return {
|
|
8997
|
-
'@@type': 'AST',
|
|
8998
|
-
id: this.id,
|
|
8999
|
-
type: this.type,
|
|
9000
|
-
root: this.#root.id,
|
|
9001
|
-
parent: this.#parent?.id,
|
|
9002
|
-
depth: this.depth,
|
|
9003
|
-
partsLength: this.#parts.length,
|
|
9004
|
-
parts: this.#parts,
|
|
9005
|
-
};
|
|
9006
|
-
}
|
|
9007
|
-
constructor(type, parent, options = {}) {
|
|
9008
|
-
this.type = type;
|
|
9009
|
-
// extglobs are inherently magical
|
|
9010
|
-
if (type)
|
|
9011
|
-
this.#hasMagic = true;
|
|
9012
|
-
this.#parent = parent;
|
|
9013
|
-
this.#root = this.#parent ? this.#parent.#root : this;
|
|
9014
|
-
this.#options = this.#root === this ? options : this.#root.#options;
|
|
9015
|
-
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
9016
|
-
if (type === '!' && !this.#root.#filledNegs)
|
|
9017
|
-
this.#negs.push(this);
|
|
9018
|
-
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
9019
|
-
}
|
|
9020
|
-
get hasMagic() {
|
|
9021
|
-
/* c8 ignore start */
|
|
9022
|
-
if (this.#hasMagic !== undefined)
|
|
9023
|
-
return this.#hasMagic;
|
|
9024
|
-
/* c8 ignore stop */
|
|
9025
|
-
for (const p of this.#parts) {
|
|
9026
|
-
if (typeof p === 'string')
|
|
9027
|
-
continue;
|
|
9028
|
-
if (p.type || p.hasMagic)
|
|
9029
|
-
return (this.#hasMagic = true);
|
|
9030
|
-
}
|
|
9031
|
-
// note: will be undefined until we generate the regexp src and find out
|
|
9032
|
-
return this.#hasMagic;
|
|
9033
|
-
}
|
|
9034
|
-
// reconstructs the pattern
|
|
9035
|
-
toString() {
|
|
9036
|
-
if (this.#toString !== undefined)
|
|
9037
|
-
return this.#toString;
|
|
9038
|
-
if (!this.type) {
|
|
9039
|
-
return (this.#toString = this.#parts.map(p => String(p)).join(''));
|
|
9040
|
-
}
|
|
9041
|
-
else {
|
|
9042
|
-
return (this.#toString =
|
|
9043
|
-
this.type + '(' + this.#parts.map(p => String(p)).join('|') + ')');
|
|
9044
|
-
}
|
|
9045
|
-
}
|
|
9046
|
-
#fillNegs() {
|
|
9047
|
-
/* c8 ignore start */
|
|
9048
|
-
if (this !== this.#root)
|
|
9049
|
-
throw new Error('should only call on root');
|
|
9050
|
-
if (this.#filledNegs)
|
|
9051
|
-
return this;
|
|
9052
|
-
/* c8 ignore stop */
|
|
9053
|
-
// call toString() once to fill this out
|
|
9054
|
-
this.toString();
|
|
9055
|
-
this.#filledNegs = true;
|
|
9056
|
-
let n;
|
|
9057
|
-
while ((n = this.#negs.pop())) {
|
|
9058
|
-
if (n.type !== '!')
|
|
9059
|
-
continue;
|
|
9060
|
-
// walk up the tree, appending everthing that comes AFTER parentIndex
|
|
9061
|
-
let p = n;
|
|
9062
|
-
let pp = p.#parent;
|
|
9063
|
-
while (pp) {
|
|
9064
|
-
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
|
9065
|
-
for (const part of n.#parts) {
|
|
9066
|
-
/* c8 ignore start */
|
|
9067
|
-
if (typeof part === 'string') {
|
|
9068
|
-
throw new Error('string part in extglob AST??');
|
|
9069
|
-
}
|
|
9070
|
-
/* c8 ignore stop */
|
|
9071
|
-
part.copyIn(pp.#parts[i]);
|
|
9072
|
-
}
|
|
9073
|
-
}
|
|
9074
|
-
p = pp;
|
|
9075
|
-
pp = p.#parent;
|
|
9076
|
-
}
|
|
9077
|
-
}
|
|
9078
|
-
return this;
|
|
9079
|
-
}
|
|
9080
|
-
push(...parts) {
|
|
9081
|
-
for (const p of parts) {
|
|
9082
|
-
if (p === '')
|
|
9083
|
-
continue;
|
|
9084
|
-
/* c8 ignore start */
|
|
9085
|
-
if (typeof p !== 'string' &&
|
|
9086
|
-
!(p instanceof _a$5 && p.#parent === this)) {
|
|
9087
|
-
throw new Error('invalid part: ' + p);
|
|
9088
|
-
}
|
|
9089
|
-
/* c8 ignore stop */
|
|
9090
|
-
this.#parts.push(p);
|
|
9091
|
-
}
|
|
9092
|
-
}
|
|
9093
|
-
toJSON() {
|
|
9094
|
-
const ret = this.type === null ?
|
|
9095
|
-
this.#parts
|
|
9096
|
-
.slice()
|
|
9097
|
-
.map(p => (typeof p === 'string' ? p : p.toJSON()))
|
|
9098
|
-
: [this.type, ...this.#parts.map(p => p.toJSON())];
|
|
9099
|
-
if (this.isStart() && !this.type)
|
|
9100
|
-
ret.unshift([]);
|
|
9101
|
-
if (this.isEnd() &&
|
|
9102
|
-
(this === this.#root ||
|
|
9103
|
-
(this.#root.#filledNegs && this.#parent?.type === '!'))) {
|
|
9104
|
-
ret.push({});
|
|
9105
|
-
}
|
|
9106
|
-
return ret;
|
|
9107
|
-
}
|
|
9108
|
-
isStart() {
|
|
9109
|
-
if (this.#root === this)
|
|
9110
|
-
return true;
|
|
9111
|
-
// if (this.type) return !!this.#parent?.isStart()
|
|
9112
|
-
if (!this.#parent?.isStart())
|
|
9113
|
-
return false;
|
|
9114
|
-
if (this.#parentIndex === 0)
|
|
9115
|
-
return true;
|
|
9116
|
-
// if everything AHEAD of this is a negation, then it's still the "start"
|
|
9117
|
-
const p = this.#parent;
|
|
9118
|
-
for (let i = 0; i < this.#parentIndex; i++) {
|
|
9119
|
-
const pp = p.#parts[i];
|
|
9120
|
-
if (!(pp instanceof _a$5 && pp.type === '!')) {
|
|
9121
|
-
return false;
|
|
9122
|
-
}
|
|
9123
|
-
}
|
|
9124
|
-
return true;
|
|
9125
|
-
}
|
|
9126
|
-
isEnd() {
|
|
9127
|
-
if (this.#root === this)
|
|
9128
|
-
return true;
|
|
9129
|
-
if (this.#parent?.type === '!')
|
|
9130
|
-
return true;
|
|
9131
|
-
if (!this.#parent?.isEnd())
|
|
9132
|
-
return false;
|
|
9133
|
-
if (!this.type)
|
|
9134
|
-
return this.#parent?.isEnd();
|
|
9135
|
-
// if not root, it'll always have a parent
|
|
9136
|
-
/* c8 ignore start */
|
|
9137
|
-
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
9138
|
-
/* c8 ignore stop */
|
|
9139
|
-
return this.#parentIndex === pl - 1;
|
|
9140
|
-
}
|
|
9141
|
-
copyIn(part) {
|
|
9142
|
-
if (typeof part === 'string')
|
|
9143
|
-
this.push(part);
|
|
9144
|
-
else
|
|
9145
|
-
this.push(part.clone(this));
|
|
9146
|
-
}
|
|
9147
|
-
clone(parent) {
|
|
9148
|
-
const c = new _a$5(this.type, parent);
|
|
9149
|
-
for (const p of this.#parts) {
|
|
9150
|
-
c.copyIn(p);
|
|
9151
|
-
}
|
|
9152
|
-
return c;
|
|
9153
|
-
}
|
|
9154
|
-
static #parseAST(str, ast, pos, opt, extDepth) {
|
|
9155
|
-
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
9156
|
-
let escaping = false;
|
|
9157
|
-
let inBrace = false;
|
|
9158
|
-
let braceStart = -1;
|
|
9159
|
-
let braceNeg = false;
|
|
9160
|
-
if (ast.type === null) {
|
|
9161
|
-
// outside of a extglob, append until we find a start
|
|
9162
|
-
let i = pos;
|
|
9163
|
-
let acc = '';
|
|
9164
|
-
while (i < str.length) {
|
|
9165
|
-
const c = str.charAt(i++);
|
|
9166
|
-
// still accumulate escapes at this point, but we do ignore
|
|
9167
|
-
// starts that are escaped
|
|
9168
|
-
if (escaping || c === '\\') {
|
|
9169
|
-
escaping = !escaping;
|
|
9170
|
-
acc += c;
|
|
9171
|
-
continue;
|
|
9172
|
-
}
|
|
9173
|
-
if (inBrace) {
|
|
9174
|
-
if (i === braceStart + 1) {
|
|
9175
|
-
if (c === '^' || c === '!') {
|
|
9176
|
-
braceNeg = true;
|
|
9177
|
-
}
|
|
9178
|
-
}
|
|
9179
|
-
else if (c === ']' && !(i === braceStart + 2 && braceNeg)) {
|
|
9180
|
-
inBrace = false;
|
|
9181
|
-
}
|
|
9182
|
-
acc += c;
|
|
9183
|
-
continue;
|
|
9184
|
-
}
|
|
9185
|
-
else if (c === '[') {
|
|
9186
|
-
inBrace = true;
|
|
9187
|
-
braceStart = i;
|
|
9188
|
-
braceNeg = false;
|
|
9189
|
-
acc += c;
|
|
9190
|
-
continue;
|
|
9191
|
-
}
|
|
9192
|
-
// we don't have to check for adoption here, because that's
|
|
9193
|
-
// done at the other recursion point.
|
|
9194
|
-
const doRecurse = !opt.noext &&
|
|
9195
|
-
isExtglobType(c) &&
|
|
9196
|
-
str.charAt(i) === '(' &&
|
|
9197
|
-
extDepth <= maxDepth;
|
|
9198
|
-
if (doRecurse) {
|
|
9199
|
-
ast.push(acc);
|
|
9200
|
-
acc = '';
|
|
9201
|
-
const ext = new _a$5(c, ast);
|
|
9202
|
-
i = _a$5.#parseAST(str, ext, i, opt, extDepth + 1);
|
|
9203
|
-
ast.push(ext);
|
|
9204
|
-
continue;
|
|
9205
|
-
}
|
|
9206
|
-
acc += c;
|
|
9207
|
-
}
|
|
9208
|
-
ast.push(acc);
|
|
9209
|
-
return i;
|
|
9210
|
-
}
|
|
9211
|
-
// some kind of extglob, pos is at the (
|
|
9212
|
-
// find the next | or )
|
|
9213
|
-
let i = pos + 1;
|
|
9214
|
-
let part = new _a$5(null, ast);
|
|
9215
|
-
const parts = [];
|
|
9216
|
-
let acc = '';
|
|
9217
|
-
while (i < str.length) {
|
|
9218
|
-
const c = str.charAt(i++);
|
|
9219
|
-
// still accumulate escapes at this point, but we do ignore
|
|
9220
|
-
// starts that are escaped
|
|
9221
|
-
if (escaping || c === '\\') {
|
|
9222
|
-
escaping = !escaping;
|
|
9223
|
-
acc += c;
|
|
9224
|
-
continue;
|
|
9225
|
-
}
|
|
9226
|
-
if (inBrace) {
|
|
9227
|
-
if (i === braceStart + 1) {
|
|
9228
|
-
if (c === '^' || c === '!') {
|
|
9229
|
-
braceNeg = true;
|
|
9230
|
-
}
|
|
9231
|
-
}
|
|
9232
|
-
else if (c === ']' && !(i === braceStart + 2 && braceNeg)) {
|
|
9233
|
-
inBrace = false;
|
|
9234
|
-
}
|
|
9235
|
-
acc += c;
|
|
9236
|
-
continue;
|
|
9237
|
-
}
|
|
9238
|
-
else if (c === '[') {
|
|
9239
|
-
inBrace = true;
|
|
9240
|
-
braceStart = i;
|
|
9241
|
-
braceNeg = false;
|
|
9242
|
-
acc += c;
|
|
9243
|
-
continue;
|
|
9244
|
-
}
|
|
9245
|
-
const doRecurse = !opt.noext &&
|
|
9246
|
-
isExtglobType(c) &&
|
|
9247
|
-
str.charAt(i) === '(' &&
|
|
9248
|
-
/* c8 ignore start - the maxDepth is sufficient here */
|
|
9249
|
-
(extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
|
|
9250
|
-
/* c8 ignore stop */
|
|
9251
|
-
if (doRecurse) {
|
|
9252
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
9253
|
-
part.push(acc);
|
|
9254
|
-
acc = '';
|
|
9255
|
-
const ext = new _a$5(c, part);
|
|
9256
|
-
part.push(ext);
|
|
9257
|
-
i = _a$5.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
|
9258
|
-
continue;
|
|
9259
|
-
}
|
|
9260
|
-
if (c === '|') {
|
|
9261
|
-
part.push(acc);
|
|
9262
|
-
acc = '';
|
|
9263
|
-
parts.push(part);
|
|
9264
|
-
part = new _a$5(null, ast);
|
|
9265
|
-
continue;
|
|
9266
|
-
}
|
|
9267
|
-
if (c === ')') {
|
|
9268
|
-
if (acc === '' && ast.#parts.length === 0) {
|
|
9269
|
-
ast.#emptyExt = true;
|
|
9270
|
-
}
|
|
9271
|
-
part.push(acc);
|
|
9272
|
-
acc = '';
|
|
9273
|
-
ast.push(...parts, part);
|
|
9274
|
-
return i;
|
|
9275
|
-
}
|
|
9276
|
-
acc += c;
|
|
9277
|
-
}
|
|
9278
|
-
// unfinished extglob
|
|
9279
|
-
// if we got here, it was a malformed extglob! not an extglob, but
|
|
9280
|
-
// maybe something else in there.
|
|
9281
|
-
ast.type = null;
|
|
9282
|
-
ast.#hasMagic = undefined;
|
|
9283
|
-
ast.#parts = [str.substring(pos - 1)];
|
|
9284
|
-
return i;
|
|
9285
|
-
}
|
|
9286
|
-
#canAdoptWithSpace(child) {
|
|
9287
|
-
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
9288
|
-
}
|
|
9289
|
-
#canAdopt(child, map = adoptionMap) {
|
|
9290
|
-
if (!child ||
|
|
9291
|
-
typeof child !== 'object' ||
|
|
9292
|
-
child.type !== null ||
|
|
9293
|
-
child.#parts.length !== 1 ||
|
|
9294
|
-
this.type === null) {
|
|
9295
|
-
return false;
|
|
9296
|
-
}
|
|
9297
|
-
const gc = child.#parts[0];
|
|
9298
|
-
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
|
9299
|
-
return false;
|
|
9300
|
-
}
|
|
9301
|
-
return this.#canAdoptType(gc.type, map);
|
|
9302
|
-
}
|
|
9303
|
-
#canAdoptType(c, map = adoptionAnyMap) {
|
|
9304
|
-
return !!map.get(this.type)?.includes(c);
|
|
9305
|
-
}
|
|
9306
|
-
#adoptWithSpace(child, index) {
|
|
9307
|
-
const gc = child.#parts[0];
|
|
9308
|
-
const blank = new _a$5(null, gc, this.options);
|
|
9309
|
-
blank.#parts.push('');
|
|
9310
|
-
gc.push(blank);
|
|
9311
|
-
this.#adopt(child, index);
|
|
9312
|
-
}
|
|
9313
|
-
#adopt(child, index) {
|
|
9314
|
-
const gc = child.#parts[0];
|
|
9315
|
-
this.#parts.splice(index, 1, ...gc.#parts);
|
|
9316
|
-
for (const p of gc.#parts) {
|
|
9317
|
-
if (typeof p === 'object')
|
|
9318
|
-
p.#parent = this;
|
|
9319
|
-
}
|
|
9320
|
-
this.#toString = undefined;
|
|
9321
|
-
}
|
|
9322
|
-
#canUsurpType(c) {
|
|
9323
|
-
const m = usurpMap.get(this.type);
|
|
9324
|
-
return !!(m?.has(c));
|
|
9325
|
-
}
|
|
9326
|
-
#canUsurp(child) {
|
|
9327
|
-
if (!child ||
|
|
9328
|
-
typeof child !== 'object' ||
|
|
9329
|
-
child.type !== null ||
|
|
9330
|
-
child.#parts.length !== 1 ||
|
|
9331
|
-
this.type === null ||
|
|
9332
|
-
this.#parts.length !== 1) {
|
|
9333
|
-
return false;
|
|
9334
|
-
}
|
|
9335
|
-
const gc = child.#parts[0];
|
|
9336
|
-
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
|
9337
|
-
return false;
|
|
9338
|
-
}
|
|
9339
|
-
return this.#canUsurpType(gc.type);
|
|
9340
|
-
}
|
|
9341
|
-
#usurp(child) {
|
|
9342
|
-
const m = usurpMap.get(this.type);
|
|
9343
|
-
const gc = child.#parts[0];
|
|
9344
|
-
const nt = m?.get(gc.type);
|
|
9345
|
-
/* c8 ignore start - impossible */
|
|
9346
|
-
if (!nt)
|
|
9347
|
-
return false;
|
|
9348
|
-
/* c8 ignore stop */
|
|
9349
|
-
this.#parts = gc.#parts;
|
|
9350
|
-
for (const p of this.#parts) {
|
|
9351
|
-
if (typeof p === 'object') {
|
|
9352
|
-
p.#parent = this;
|
|
9353
|
-
}
|
|
9354
|
-
}
|
|
9355
|
-
this.type = nt;
|
|
9356
|
-
this.#toString = undefined;
|
|
9357
|
-
this.#emptyExt = false;
|
|
9358
|
-
}
|
|
9359
|
-
static fromGlob(pattern, options = {}) {
|
|
9360
|
-
const ast = new _a$5(null, undefined, options);
|
|
9361
|
-
_a$5.#parseAST(pattern, ast, 0, options, 0);
|
|
9362
|
-
return ast;
|
|
9363
|
-
}
|
|
9364
|
-
// returns the regular expression if there's magic, or the unescaped
|
|
9365
|
-
// string if not.
|
|
9366
|
-
toMMPattern() {
|
|
9367
|
-
// should only be called on root
|
|
9368
|
-
/* c8 ignore start */
|
|
9369
|
-
if (this !== this.#root)
|
|
9370
|
-
return this.#root.toMMPattern();
|
|
9371
|
-
/* c8 ignore stop */
|
|
9372
|
-
const glob = this.toString();
|
|
9373
|
-
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
9374
|
-
// if we're in nocase mode, and not nocaseMagicOnly, then we do
|
|
9375
|
-
// still need a regular expression if we have to case-insensitively
|
|
9376
|
-
// match capital/lowercase characters.
|
|
9377
|
-
const anyMagic = hasMagic ||
|
|
9378
|
-
this.#hasMagic ||
|
|
9379
|
-
(this.#options.nocase &&
|
|
9380
|
-
!this.#options.nocaseMagicOnly &&
|
|
9381
|
-
glob.toUpperCase() !== glob.toLowerCase());
|
|
9382
|
-
if (!anyMagic) {
|
|
9383
|
-
return body;
|
|
9384
|
-
}
|
|
9385
|
-
const flags = (this.#options.nocase ? 'i' : '') + (uflag ? 'u' : '');
|
|
9386
|
-
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
9387
|
-
_src: re,
|
|
9388
|
-
_glob: glob,
|
|
9389
|
-
});
|
|
9390
|
-
}
|
|
9391
|
-
get options() {
|
|
9392
|
-
return this.#options;
|
|
9393
|
-
}
|
|
9394
|
-
// returns the string match, the regexp source, whether there's magic
|
|
9395
|
-
// in the regexp (so a regular expression is required) and whether or
|
|
9396
|
-
// not the uflag is needed for the regular expression (for posix classes)
|
|
9397
|
-
// TODO: instead of injecting the start/end at this point, just return
|
|
9398
|
-
// the BODY of the regexp, along with the start/end portions suitable
|
|
9399
|
-
// for binding the start/end in either a joined full-path makeRe context
|
|
9400
|
-
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
9401
|
-
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
9402
|
-
//
|
|
9403
|
-
// In part-matching mode, the start is:
|
|
9404
|
-
// - if not isStart: nothing
|
|
9405
|
-
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
9406
|
-
// - if dots allowed or not possible: ^
|
|
9407
|
-
// - if dots possible and not allowed: ^(?!\.)
|
|
9408
|
-
// end is:
|
|
9409
|
-
// - if not isEnd(): nothing
|
|
9410
|
-
// - else: $
|
|
9411
|
-
//
|
|
9412
|
-
// In full-path matching mode, we put the slash at the START of the
|
|
9413
|
-
// pattern, so start is:
|
|
9414
|
-
// - if first pattern: same as part-matching mode
|
|
9415
|
-
// - if not isStart(): nothing
|
|
9416
|
-
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
9417
|
-
// - if dots allowed or not possible: /
|
|
9418
|
-
// - if dots possible and not allowed: /(?!\.)
|
|
9419
|
-
// end is:
|
|
9420
|
-
// - if last pattern, same as part-matching mode
|
|
9421
|
-
// - else nothing
|
|
9422
|
-
//
|
|
9423
|
-
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
9424
|
-
// there to bind the end of the negated pattern portion, and it's easier to
|
|
9425
|
-
// just stick it in now rather than try to inject it later in the middle of
|
|
9426
|
-
// the pattern.
|
|
9427
|
-
//
|
|
9428
|
-
// We can just always return the same end, and leave it up to the caller
|
|
9429
|
-
// to know whether it's going to be used joined or in parts.
|
|
9430
|
-
// And, if the start is adjusted slightly, can do the same there:
|
|
9431
|
-
// - if not isStart: nothing
|
|
9432
|
-
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
9433
|
-
// - if dots allowed or not possible: (?:/|^)
|
|
9434
|
-
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
9435
|
-
//
|
|
9436
|
-
// But it's better to have a simpler binding without a conditional, for
|
|
9437
|
-
// performance, so probably better to return both start options.
|
|
9438
|
-
//
|
|
9439
|
-
// Then the caller just ignores the end if it's not the first pattern,
|
|
9440
|
-
// and the start always gets applied.
|
|
9441
|
-
//
|
|
9442
|
-
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
9443
|
-
// so the caller can just attach $ at the end of the pattern when building.
|
|
9444
|
-
//
|
|
9445
|
-
// So the todo is:
|
|
9446
|
-
// - better detect what kind of start is needed
|
|
9447
|
-
// - return both flavors of starting pattern
|
|
9448
|
-
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
9449
|
-
//
|
|
9450
|
-
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
9451
|
-
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
9452
|
-
// that dot prevention biz to live in the extglob portions, because eg
|
|
9453
|
-
// +(*|.x*) can match .xy but not .yx.
|
|
9454
|
-
//
|
|
9455
|
-
// So, return the two flavors if it's #root and the first child is not an
|
|
9456
|
-
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
9457
|
-
// use the (?:^|/) style of start binding.
|
|
9458
|
-
//
|
|
9459
|
-
// Even simplified further:
|
|
9460
|
-
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
9461
|
-
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
9462
|
-
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
9463
|
-
toRegExpSource(allowDot) {
|
|
9464
|
-
const dot = allowDot ?? !!this.#options.dot;
|
|
9465
|
-
if (this.#root === this) {
|
|
9466
|
-
this.#flatten();
|
|
9467
|
-
this.#fillNegs();
|
|
9468
|
-
}
|
|
9469
|
-
if (!isExtglobAST(this)) {
|
|
9470
|
-
const noEmpty = this.isStart() &&
|
|
9471
|
-
this.isEnd() &&
|
|
9472
|
-
!this.#parts.some(s => typeof s !== 'string');
|
|
9473
|
-
const src = this.#parts
|
|
9474
|
-
.map(p => {
|
|
9475
|
-
const [re, _, hasMagic, uflag] = typeof p === 'string' ?
|
|
9476
|
-
_a$5.#parseGlob(p, this.#hasMagic, noEmpty)
|
|
9477
|
-
: p.toRegExpSource(allowDot);
|
|
9478
|
-
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
9479
|
-
this.#uflag = this.#uflag || uflag;
|
|
9480
|
-
return re;
|
|
9481
|
-
})
|
|
9482
|
-
.join('');
|
|
9483
|
-
let start = '';
|
|
9484
|
-
if (this.isStart()) {
|
|
9485
|
-
if (typeof this.#parts[0] === 'string') {
|
|
9486
|
-
// this is the string that will match the start of the pattern,
|
|
9487
|
-
// so we need to protect against dots and such.
|
|
9488
|
-
// '.' and '..' cannot match unless the pattern is that exactly,
|
|
9489
|
-
// even if it starts with . or dot:true is set.
|
|
9490
|
-
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
9491
|
-
if (!dotTravAllowed) {
|
|
9492
|
-
const aps = addPatternStart;
|
|
9493
|
-
// check if we have a possibility of matching . or ..,
|
|
9494
|
-
// and prevent that.
|
|
9495
|
-
const needNoTrav =
|
|
9496
|
-
// dots are allowed, and the pattern starts with [ or .
|
|
9497
|
-
(dot && aps.has(src.charAt(0))) ||
|
|
9498
|
-
// the pattern starts with \., and then [ or .
|
|
9499
|
-
(src.startsWith('\\.') && aps.has(src.charAt(2))) ||
|
|
9500
|
-
// the pattern starts with \.\., and then [ or .
|
|
9501
|
-
(src.startsWith('\\.\\.') && aps.has(src.charAt(4)));
|
|
9502
|
-
// no need to prevent dots if it can't match a dot, or if a
|
|
9503
|
-
// sub-pattern will be preventing it anyway.
|
|
9504
|
-
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
9505
|
-
start =
|
|
9506
|
-
needNoTrav ? startNoTraversal
|
|
9507
|
-
: needNoDot ? startNoDot
|
|
9508
|
-
: '';
|
|
9509
|
-
}
|
|
9510
|
-
}
|
|
9511
|
-
}
|
|
9512
|
-
// append the "end of path portion" pattern to negation tails
|
|
9513
|
-
let end = '';
|
|
9514
|
-
if (this.isEnd() &&
|
|
9515
|
-
this.#root.#filledNegs &&
|
|
9516
|
-
this.#parent?.type === '!') {
|
|
9517
|
-
end = '(?:$|\\/)';
|
|
9518
|
-
}
|
|
9519
|
-
const final = start + src + end;
|
|
9520
|
-
return [
|
|
9521
|
-
final,
|
|
9522
|
-
unescape$1(src),
|
|
9523
|
-
(this.#hasMagic = !!this.#hasMagic),
|
|
9524
|
-
this.#uflag,
|
|
9525
|
-
];
|
|
9526
|
-
}
|
|
9527
|
-
// We need to calculate the body *twice* if it's a repeat pattern
|
|
9528
|
-
// at the start, once in nodot mode, then again in dot mode, so a
|
|
9529
|
-
// pattern like *(?) can match 'x.y'
|
|
9530
|
-
const repeated = this.type === '*' || this.type === '+';
|
|
9531
|
-
// some kind of extglob
|
|
9532
|
-
const start = this.type === '!' ? '(?:(?!(?:' : '(?:';
|
|
9533
|
-
let body = this.#partsToRegExp(dot);
|
|
9534
|
-
if (this.isStart() && this.isEnd() && !body && this.type !== '!') {
|
|
9535
|
-
// invalid extglob, has to at least be *something* present, if it's
|
|
9536
|
-
// the entire path portion.
|
|
9537
|
-
const s = this.toString();
|
|
9538
|
-
const me = this;
|
|
9539
|
-
me.#parts = [s];
|
|
9540
|
-
me.type = null;
|
|
9541
|
-
me.#hasMagic = undefined;
|
|
9542
|
-
return [s, unescape$1(this.toString()), false, false];
|
|
9543
|
-
}
|
|
9544
|
-
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ?
|
|
9545
|
-
''
|
|
9546
|
-
: this.#partsToRegExp(true);
|
|
9547
|
-
if (bodyDotAllowed === body) {
|
|
9548
|
-
bodyDotAllowed = '';
|
|
9549
|
-
}
|
|
9550
|
-
if (bodyDotAllowed) {
|
|
9551
|
-
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
9552
|
-
}
|
|
9553
|
-
// an empty !() is exactly equivalent to a starNoEmpty
|
|
9554
|
-
let final = '';
|
|
9555
|
-
if (this.type === '!' && this.#emptyExt) {
|
|
9556
|
-
final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
|
|
9557
|
-
}
|
|
9558
|
-
else {
|
|
9559
|
-
const close = this.type === '!' ?
|
|
9560
|
-
// !() must match something,but !(x) can match ''
|
|
9561
|
-
'))' +
|
|
9562
|
-
(this.isStart() && !dot && !allowDot ? startNoDot : '') +
|
|
9563
|
-
star$1 +
|
|
9564
|
-
')'
|
|
9565
|
-
: this.type === '@' ? ')'
|
|
9566
|
-
: this.type === '?' ? ')?'
|
|
9567
|
-
: this.type === '+' && bodyDotAllowed ? ')'
|
|
9568
|
-
: this.type === '*' && bodyDotAllowed ? `)?`
|
|
9569
|
-
: `)${this.type}`;
|
|
9570
|
-
final = start + body + close;
|
|
9571
|
-
}
|
|
9572
|
-
return [
|
|
9573
|
-
final,
|
|
9574
|
-
unescape$1(body),
|
|
9575
|
-
(this.#hasMagic = !!this.#hasMagic),
|
|
9576
|
-
this.#uflag,
|
|
9577
|
-
];
|
|
9578
|
-
}
|
|
9579
|
-
#flatten() {
|
|
9580
|
-
if (!isExtglobAST(this)) {
|
|
9581
|
-
for (const p of this.#parts) {
|
|
9582
|
-
if (typeof p === 'object') {
|
|
9583
|
-
p.#flatten();
|
|
9584
|
-
}
|
|
9585
|
-
}
|
|
9586
|
-
}
|
|
9587
|
-
else {
|
|
9588
|
-
// do up to 10 passes to flatten as much as possible
|
|
9589
|
-
let iterations = 0;
|
|
9590
|
-
let done = false;
|
|
9591
|
-
do {
|
|
9592
|
-
done = true;
|
|
9593
|
-
for (let i = 0; i < this.#parts.length; i++) {
|
|
9594
|
-
const c = this.#parts[i];
|
|
9595
|
-
if (typeof c === 'object') {
|
|
9596
|
-
c.#flatten();
|
|
9597
|
-
if (this.#canAdopt(c)) {
|
|
9598
|
-
done = false;
|
|
9599
|
-
this.#adopt(c, i);
|
|
9600
|
-
}
|
|
9601
|
-
else if (this.#canAdoptWithSpace(c)) {
|
|
9602
|
-
done = false;
|
|
9603
|
-
this.#adoptWithSpace(c, i);
|
|
9604
|
-
}
|
|
9605
|
-
else if (this.#canUsurp(c)) {
|
|
9606
|
-
done = false;
|
|
9607
|
-
this.#usurp(c);
|
|
9608
|
-
}
|
|
9609
|
-
}
|
|
9610
|
-
}
|
|
9611
|
-
} while (!done && ++iterations < 10);
|
|
9612
|
-
}
|
|
9613
|
-
this.#toString = undefined;
|
|
9614
|
-
}
|
|
9615
|
-
#partsToRegExp(dot) {
|
|
9616
|
-
return this.#parts
|
|
9617
|
-
.map(p => {
|
|
9618
|
-
// extglob ASTs should only contain parent ASTs
|
|
9619
|
-
/* c8 ignore start */
|
|
9620
|
-
if (typeof p === 'string') {
|
|
9621
|
-
throw new Error('string type in extglob ast??');
|
|
9622
|
-
}
|
|
9623
|
-
/* c8 ignore stop */
|
|
9624
|
-
// can ignore hasMagic, because extglobs are already always magic
|
|
9625
|
-
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
9626
|
-
this.#uflag = this.#uflag || uflag;
|
|
9627
|
-
return re;
|
|
9628
|
-
})
|
|
9629
|
-
.filter(p => !(this.isStart() && this.isEnd()) || !!p)
|
|
9630
|
-
.join('|');
|
|
9631
|
-
}
|
|
9632
|
-
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
9633
|
-
let escaping = false;
|
|
9634
|
-
let re = '';
|
|
9635
|
-
let uflag = false;
|
|
9636
|
-
// multiple stars that aren't globstars coalesce into one *
|
|
9637
|
-
let inStar = false;
|
|
9638
|
-
for (let i = 0; i < glob.length; i++) {
|
|
9639
|
-
const c = glob.charAt(i);
|
|
9640
|
-
if (escaping) {
|
|
9641
|
-
escaping = false;
|
|
9642
|
-
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
9643
|
-
continue;
|
|
9644
|
-
}
|
|
9645
|
-
if (c === '*') {
|
|
9646
|
-
if (inStar)
|
|
9647
|
-
continue;
|
|
9648
|
-
inStar = true;
|
|
9649
|
-
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star$1;
|
|
9650
|
-
hasMagic = true;
|
|
9651
|
-
continue;
|
|
9652
|
-
}
|
|
9653
|
-
else {
|
|
9654
|
-
inStar = false;
|
|
9655
|
-
}
|
|
9656
|
-
if (c === '\\') {
|
|
9657
|
-
if (i === glob.length - 1) {
|
|
9658
|
-
re += '\\\\';
|
|
9659
|
-
}
|
|
9660
|
-
else {
|
|
9661
|
-
escaping = true;
|
|
9662
|
-
}
|
|
9663
|
-
continue;
|
|
9664
|
-
}
|
|
9665
|
-
if (c === '[') {
|
|
9666
|
-
const [src, needUflag, consumed, magic] = parseClass(glob, i);
|
|
9667
|
-
if (consumed) {
|
|
9668
|
-
re += src;
|
|
9669
|
-
uflag = uflag || needUflag;
|
|
9670
|
-
i += consumed - 1;
|
|
9671
|
-
hasMagic = hasMagic || magic;
|
|
9672
|
-
continue;
|
|
9673
|
-
}
|
|
9674
|
-
}
|
|
9675
|
-
if (c === '?') {
|
|
9676
|
-
re += qmark$1;
|
|
9677
|
-
hasMagic = true;
|
|
9678
|
-
continue;
|
|
9679
|
-
}
|
|
9680
|
-
re += regExpEscape$1(c);
|
|
9681
|
-
}
|
|
9682
|
-
return [re, unescape$1(glob), !!hasMagic, uflag];
|
|
9683
|
-
}
|
|
9684
|
-
}
|
|
9685
|
-
_a$5 = AST;
|
|
9686
|
-
|
|
9687
|
-
/**
|
|
9688
|
-
* Escape all magic characters in a glob pattern.
|
|
9689
|
-
*
|
|
9690
|
-
* If the {@link MinimatchOptions.windowsPathsNoEscape}
|
|
9691
|
-
* option is used, then characters are escaped by wrapping in `[]`, because
|
|
9692
|
-
* a magic character wrapped in a character class can only be satisfied by
|
|
9693
|
-
* that exact character. In this mode, `\` is _not_ escaped, because it is
|
|
9694
|
-
* not interpreted as a magic character, but instead as a path separator.
|
|
9695
|
-
*
|
|
9696
|
-
* If the {@link MinimatchOptions.magicalBraces} option is used,
|
|
9697
|
-
* then braces (`{` and `}`) will be escaped.
|
|
9698
|
-
*/
|
|
9699
|
-
const escape$3 = (s, { windowsPathsNoEscape = false, magicalBraces = false, } = {}) => {
|
|
9700
|
-
// don't need to escape +@! because we escape the parens
|
|
9701
|
-
// that make those magic, and escaping ! as [!] isn't valid,
|
|
9702
|
-
// because [!]] is a valid glob class meaning not ']'.
|
|
9703
|
-
if (magicalBraces) {
|
|
9704
|
-
return windowsPathsNoEscape ?
|
|
9705
|
-
s.replace(/[?*()[\]{}]/g, '[$&]')
|
|
9706
|
-
: s.replace(/[?*()[\]\\{}]/g, '\\$&');
|
|
9707
|
-
}
|
|
9708
|
-
return windowsPathsNoEscape ?
|
|
9709
|
-
s.replace(/[?*()[\]]/g, '[$&]')
|
|
9710
|
-
: s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
9711
|
-
};
|
|
9712
|
-
|
|
9713
|
-
const minimatch = (p, pattern, options = {}) => {
|
|
9714
|
-
assertValidPattern(pattern);
|
|
9715
|
-
// shortcut: comments match nothing.
|
|
9716
|
-
if (!options.nocomment && pattern.charAt(0) === '#') {
|
|
9717
|
-
return false;
|
|
9718
|
-
}
|
|
9719
|
-
return new Minimatch(pattern, options).match(p);
|
|
9720
|
-
};
|
|
9721
|
-
// Optimized checking for the most common glob patterns.
|
|
9722
|
-
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
9723
|
-
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext);
|
|
9724
|
-
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
|
|
9725
|
-
const starDotExtTestNocase = (ext) => {
|
|
9726
|
-
ext = ext.toLowerCase();
|
|
9727
|
-
return (f) => !f.startsWith('.') && f.toLowerCase().endsWith(ext);
|
|
9728
|
-
};
|
|
9729
|
-
const starDotExtTestNocaseDot = (ext) => {
|
|
9730
|
-
ext = ext.toLowerCase();
|
|
9731
|
-
return (f) => f.toLowerCase().endsWith(ext);
|
|
9732
|
-
};
|
|
9733
|
-
const starDotStarRE = /^\*+\.\*+$/;
|
|
9734
|
-
const starDotStarTest = (f) => !f.startsWith('.') && f.includes('.');
|
|
9735
|
-
const starDotStarTestDot = (f) => f !== '.' && f !== '..' && f.includes('.');
|
|
9736
|
-
const dotStarRE = /^\.\*+$/;
|
|
9737
|
-
const dotStarTest = (f) => f !== '.' && f !== '..' && f.startsWith('.');
|
|
9738
|
-
const starRE = /^\*+$/;
|
|
9739
|
-
const starTest = (f) => f.length !== 0 && !f.startsWith('.');
|
|
9740
|
-
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..';
|
|
9741
|
-
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
9742
|
-
const qmarksTestNocase = ([$0, ext = '']) => {
|
|
9743
|
-
const noext = qmarksTestNoExt([$0]);
|
|
9744
|
-
if (!ext)
|
|
9745
|
-
return noext;
|
|
9746
|
-
ext = ext.toLowerCase();
|
|
9747
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
9748
|
-
};
|
|
9749
|
-
const qmarksTestNocaseDot = ([$0, ext = '']) => {
|
|
9750
|
-
const noext = qmarksTestNoExtDot([$0]);
|
|
9751
|
-
if (!ext)
|
|
9752
|
-
return noext;
|
|
9753
|
-
ext = ext.toLowerCase();
|
|
9754
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
9755
|
-
};
|
|
9756
|
-
const qmarksTestDot = ([$0, ext = '']) => {
|
|
9757
|
-
const noext = qmarksTestNoExtDot([$0]);
|
|
9758
|
-
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
9759
|
-
};
|
|
9760
|
-
const qmarksTest = ([$0, ext = '']) => {
|
|
9761
|
-
const noext = qmarksTestNoExt([$0]);
|
|
9762
|
-
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
9763
|
-
};
|
|
9764
|
-
const qmarksTestNoExt = ([$0]) => {
|
|
9765
|
-
const len = $0.length;
|
|
9766
|
-
return (f) => f.length === len && !f.startsWith('.');
|
|
9767
|
-
};
|
|
9768
|
-
const qmarksTestNoExtDot = ([$0]) => {
|
|
9769
|
-
const len = $0.length;
|
|
9770
|
-
return (f) => f.length === len && f !== '.' && f !== '..';
|
|
9771
|
-
};
|
|
9772
|
-
/* c8 ignore start */
|
|
9773
|
-
const defaultPlatform = (typeof process === 'object' && process ?
|
|
9774
|
-
(typeof process.env === 'object' &&
|
|
9775
|
-
process.env &&
|
|
9776
|
-
process.env.__MINIMATCH_TESTING_PLATFORM__) ||
|
|
9777
|
-
process.platform
|
|
9778
|
-
: 'posix');
|
|
9779
|
-
const path = {
|
|
9780
|
-
win32: { sep: '\\' },
|
|
9781
|
-
posix: { sep: '/' },
|
|
9782
|
-
};
|
|
9783
|
-
/* c8 ignore stop */
|
|
9784
|
-
const sep = defaultPlatform === 'win32' ? path.win32.sep : path.posix.sep;
|
|
9785
|
-
minimatch.sep = sep;
|
|
9786
|
-
const GLOBSTAR = Symbol('globstar **');
|
|
9787
|
-
minimatch.GLOBSTAR = GLOBSTAR;
|
|
9788
|
-
// any single thing other than /
|
|
9789
|
-
// don't need to escape / when using new RegExp()
|
|
9790
|
-
const qmark = '[^/]';
|
|
9791
|
-
// * => any number of characters
|
|
9792
|
-
const star = qmark + '*?';
|
|
9793
|
-
// ** when dots are allowed. Anything goes, except .. and .
|
|
9794
|
-
// not (^ or / followed by one or two dots followed by $ or /),
|
|
9795
|
-
// followed by anything, any number of times.
|
|
9796
|
-
const twoStarDot = '(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?';
|
|
9797
|
-
// not a ^ or / followed by a dot,
|
|
9798
|
-
// followed by anything, any number of times.
|
|
9799
|
-
const twoStarNoDot = '(?:(?!(?:\\/|^)\\.).)*?';
|
|
9800
|
-
const filter$1 = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
9801
|
-
minimatch.filter = filter$1;
|
|
9802
|
-
const ext = (a, b = {}) => Object.assign({}, a, b);
|
|
9803
|
-
const defaults = (def) => {
|
|
9804
|
-
if (!def || typeof def !== 'object' || !Object.keys(def).length) {
|
|
9805
|
-
return minimatch;
|
|
9806
|
-
}
|
|
9807
|
-
const orig = minimatch;
|
|
9808
|
-
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
9809
|
-
return Object.assign(m, {
|
|
9810
|
-
Minimatch: class Minimatch extends orig.Minimatch {
|
|
9811
|
-
constructor(pattern, options = {}) {
|
|
9812
|
-
super(pattern, ext(def, options));
|
|
9813
|
-
}
|
|
9814
|
-
static defaults(options) {
|
|
9815
|
-
return orig.defaults(ext(def, options)).Minimatch;
|
|
9816
|
-
}
|
|
9817
|
-
},
|
|
9818
|
-
AST: class AST extends orig.AST {
|
|
9819
|
-
/* c8 ignore start */
|
|
9820
|
-
constructor(type, parent, options = {}) {
|
|
9821
|
-
super(type, parent, ext(def, options));
|
|
9822
|
-
}
|
|
9823
|
-
/* c8 ignore stop */
|
|
9824
|
-
static fromGlob(pattern, options = {}) {
|
|
9825
|
-
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
9826
|
-
}
|
|
9827
|
-
},
|
|
9828
|
-
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
9829
|
-
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
9830
|
-
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
9831
|
-
defaults: (options) => orig.defaults(ext(def, options)),
|
|
9832
|
-
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
9833
|
-
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
9834
|
-
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
9835
|
-
sep: orig.sep,
|
|
9836
|
-
GLOBSTAR: GLOBSTAR,
|
|
9837
|
-
});
|
|
9838
|
-
};
|
|
9839
|
-
minimatch.defaults = defaults;
|
|
9840
|
-
// Brace expansion:
|
|
9841
|
-
// a{b,c}d -> abd acd
|
|
9842
|
-
// a{b,}c -> abc ac
|
|
9843
|
-
// a{0..3}d -> a0d a1d a2d a3d
|
|
9844
|
-
// a{b,c{d,e}f}g -> abg acdfg acefg
|
|
9845
|
-
// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
|
|
9846
|
-
//
|
|
9847
|
-
// Invalid sets are not expanded.
|
|
9848
|
-
// a{2..}b -> a{2..}b
|
|
9849
|
-
// a{b}c -> a{b}c
|
|
9850
|
-
const braceExpand = (pattern, options = {}) => {
|
|
9851
|
-
assertValidPattern(pattern);
|
|
9852
|
-
// Thanks to Yeting Li <https://github.com/yetingli> for
|
|
9853
|
-
// improving this regexp to avoid a ReDOS vulnerability.
|
|
9854
|
-
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
9855
|
-
// shortcut. no need to expand.
|
|
9856
|
-
return [pattern];
|
|
9857
|
-
}
|
|
9858
|
-
return expand(pattern, { max: options.braceExpandMax });
|
|
9859
|
-
};
|
|
9860
|
-
minimatch.braceExpand = braceExpand;
|
|
9861
|
-
// parse a component of the expanded set.
|
|
9862
|
-
// At this point, no pattern may contain "/" in it
|
|
9863
|
-
// so we're going to return a 2d array, where each entry is the full
|
|
9864
|
-
// pattern, split on '/', and then turned into a regular expression.
|
|
9865
|
-
// A regexp is made at the end which joins each array with an
|
|
9866
|
-
// escaped /, and another full one which joins each regexp with |.
|
|
9867
|
-
//
|
|
9868
|
-
// Following the lead of Bash 4.1, note that "**" only has special meaning
|
|
9869
|
-
// when it is the *only* thing in a path portion. Otherwise, any series
|
|
9870
|
-
// of * is equivalent to a single *. Globstar behavior is enabled by
|
|
9871
|
-
// default, and can be disabled by setting options.noglobstar.
|
|
9872
|
-
const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
9873
|
-
minimatch.makeRe = makeRe;
|
|
9874
|
-
const match = (list, pattern, options = {}) => {
|
|
9875
|
-
const mm = new Minimatch(pattern, options);
|
|
9876
|
-
list = list.filter(f => mm.match(f));
|
|
9877
|
-
if (mm.options.nonull && !list.length) {
|
|
9878
|
-
list.push(pattern);
|
|
9879
|
-
}
|
|
9880
|
-
return list;
|
|
9881
|
-
};
|
|
9882
|
-
minimatch.match = match;
|
|
9883
|
-
// replace stuff like \* with *
|
|
9884
|
-
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
9885
|
-
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
9886
|
-
class Minimatch {
|
|
9887
|
-
options;
|
|
9888
|
-
set;
|
|
9889
|
-
pattern;
|
|
9890
|
-
windowsPathsNoEscape;
|
|
9891
|
-
nonegate;
|
|
9892
|
-
negate;
|
|
9893
|
-
comment;
|
|
9894
|
-
empty;
|
|
9895
|
-
preserveMultipleSlashes;
|
|
9896
|
-
partial;
|
|
9897
|
-
globSet;
|
|
9898
|
-
globParts;
|
|
9899
|
-
nocase;
|
|
9900
|
-
isWindows;
|
|
9901
|
-
platform;
|
|
9902
|
-
windowsNoMagicRoot;
|
|
9903
|
-
maxGlobstarRecursion;
|
|
9904
|
-
regexp;
|
|
9905
|
-
constructor(pattern, options = {}) {
|
|
9906
|
-
assertValidPattern(pattern);
|
|
9907
|
-
options = options || {};
|
|
9908
|
-
this.options = options;
|
|
9909
|
-
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
9910
|
-
this.pattern = pattern;
|
|
9911
|
-
this.platform = options.platform || defaultPlatform;
|
|
9912
|
-
this.isWindows = this.platform === 'win32';
|
|
9913
|
-
// avoid the annoying deprecation flag lol
|
|
9914
|
-
const awe = ('allowWindow' + 'sEscape');
|
|
9915
|
-
this.windowsPathsNoEscape =
|
|
9916
|
-
!!options.windowsPathsNoEscape || options[awe] === false;
|
|
9917
|
-
if (this.windowsPathsNoEscape) {
|
|
9918
|
-
this.pattern = this.pattern.replace(/\\/g, '/');
|
|
9919
|
-
}
|
|
9920
|
-
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
9921
|
-
this.regexp = null;
|
|
9922
|
-
this.negate = false;
|
|
9923
|
-
this.nonegate = !!options.nonegate;
|
|
9924
|
-
this.comment = false;
|
|
9925
|
-
this.empty = false;
|
|
9926
|
-
this.partial = !!options.partial;
|
|
9927
|
-
this.nocase = !!this.options.nocase;
|
|
9928
|
-
this.windowsNoMagicRoot =
|
|
9929
|
-
options.windowsNoMagicRoot !== undefined ?
|
|
9930
|
-
options.windowsNoMagicRoot
|
|
9931
|
-
: !!(this.isWindows && this.nocase);
|
|
9932
|
-
this.globSet = [];
|
|
9933
|
-
this.globParts = [];
|
|
9934
|
-
this.set = [];
|
|
9935
|
-
// make the set of regexps etc.
|
|
9936
|
-
this.make();
|
|
9937
|
-
}
|
|
9938
|
-
hasMagic() {
|
|
9939
|
-
if (this.options.magicalBraces && this.set.length > 1) {
|
|
9940
|
-
return true;
|
|
9941
|
-
}
|
|
9942
|
-
for (const pattern of this.set) {
|
|
9943
|
-
for (const part of pattern) {
|
|
9944
|
-
if (typeof part !== 'string')
|
|
9945
|
-
return true;
|
|
9946
|
-
}
|
|
9947
|
-
}
|
|
9948
|
-
return false;
|
|
9949
|
-
}
|
|
9950
|
-
debug(..._) { }
|
|
9951
|
-
make() {
|
|
9952
|
-
const pattern = this.pattern;
|
|
9953
|
-
const options = this.options;
|
|
9954
|
-
// empty patterns and comments match nothing.
|
|
9955
|
-
if (!options.nocomment && pattern.charAt(0) === '#') {
|
|
9956
|
-
this.comment = true;
|
|
9957
|
-
return;
|
|
9958
|
-
}
|
|
9959
|
-
if (!pattern) {
|
|
9960
|
-
this.empty = true;
|
|
9961
|
-
return;
|
|
9962
|
-
}
|
|
9963
|
-
// step 1: figure out negation, etc.
|
|
9964
|
-
this.parseNegate();
|
|
9965
|
-
// step 2: expand braces
|
|
9966
|
-
this.globSet = [...new Set(this.braceExpand())];
|
|
9967
|
-
if (options.debug) {
|
|
9968
|
-
this.debug = (...args) => console.error(...args);
|
|
9969
|
-
}
|
|
9970
|
-
this.debug(this.pattern, this.globSet);
|
|
9971
|
-
// step 3: now we have a set, so turn each one into a series of
|
|
9972
|
-
// path-portion matching patterns.
|
|
9973
|
-
// These will be regexps, except in the case of "**", which is
|
|
9974
|
-
// set to the GLOBSTAR object for globstar behavior,
|
|
9975
|
-
// and will not contain any / characters
|
|
9976
|
-
//
|
|
9977
|
-
// First, we preprocess to make the glob pattern sets a bit simpler
|
|
9978
|
-
// and deduped. There are some perf-killing patterns that can cause
|
|
9979
|
-
// problems with a glob walk, but we can simplify them down a bit.
|
|
9980
|
-
const rawGlobParts = this.globSet.map(s => this.slashSplit(s));
|
|
9981
|
-
this.globParts = this.preprocess(rawGlobParts);
|
|
9982
|
-
this.debug(this.pattern, this.globParts);
|
|
9983
|
-
// glob --> regexps
|
|
9984
|
-
let set = this.globParts.map((s, _, __) => {
|
|
9985
|
-
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
9986
|
-
// check if it's a drive or unc path.
|
|
9987
|
-
const isUNC = s[0] === '' &&
|
|
9988
|
-
s[1] === '' &&
|
|
9989
|
-
(s[2] === '?' || !globMagic.test(s[2])) &&
|
|
9990
|
-
!globMagic.test(s[3]);
|
|
9991
|
-
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
9992
|
-
if (isUNC) {
|
|
9993
|
-
return [
|
|
9994
|
-
...s.slice(0, 4),
|
|
9995
|
-
...s.slice(4).map(ss => this.parse(ss)),
|
|
9996
|
-
];
|
|
9997
|
-
}
|
|
9998
|
-
else if (isDrive) {
|
|
9999
|
-
return [s[0], ...s.slice(1).map(ss => this.parse(ss))];
|
|
10000
|
-
}
|
|
10001
|
-
}
|
|
10002
|
-
return s.map(ss => this.parse(ss));
|
|
10003
|
-
});
|
|
10004
|
-
this.debug(this.pattern, set);
|
|
10005
|
-
// filter out everything that didn't compile properly.
|
|
10006
|
-
this.set = set.filter(s => s.indexOf(false) === -1);
|
|
10007
|
-
// do not treat the ? in UNC paths as magic
|
|
10008
|
-
if (this.isWindows) {
|
|
10009
|
-
for (let i = 0; i < this.set.length; i++) {
|
|
10010
|
-
const p = this.set[i];
|
|
10011
|
-
if (p[0] === '' &&
|
|
10012
|
-
p[1] === '' &&
|
|
10013
|
-
this.globParts[i][2] === '?' &&
|
|
10014
|
-
typeof p[3] === 'string' &&
|
|
10015
|
-
/^[a-z]:$/i.test(p[3])) {
|
|
10016
|
-
p[2] = '?';
|
|
10017
|
-
}
|
|
10018
|
-
}
|
|
10019
|
-
}
|
|
10020
|
-
this.debug(this.pattern, this.set);
|
|
10021
|
-
}
|
|
10022
|
-
// various transforms to equivalent pattern sets that are
|
|
10023
|
-
// faster to process in a filesystem walk. The goal is to
|
|
10024
|
-
// eliminate what we can, and push all ** patterns as far
|
|
10025
|
-
// to the right as possible, even if it increases the number
|
|
10026
|
-
// of patterns that we have to process.
|
|
10027
|
-
preprocess(globParts) {
|
|
10028
|
-
// if we're not in globstar mode, then turn ** into *
|
|
10029
|
-
if (this.options.noglobstar) {
|
|
10030
|
-
for (let i = 0; i < globParts.length; i++) {
|
|
10031
|
-
for (let j = 0; j < globParts[i].length; j++) {
|
|
10032
|
-
if (globParts[i][j] === '**') {
|
|
10033
|
-
globParts[i][j] = '*';
|
|
10034
|
-
}
|
|
10035
|
-
}
|
|
10036
|
-
}
|
|
10037
|
-
}
|
|
10038
|
-
const { optimizationLevel = 1 } = this.options;
|
|
10039
|
-
if (optimizationLevel >= 2) {
|
|
10040
|
-
// aggressive optimization for the purpose of fs walking
|
|
10041
|
-
globParts = this.firstPhasePreProcess(globParts);
|
|
10042
|
-
globParts = this.secondPhasePreProcess(globParts);
|
|
10043
|
-
}
|
|
10044
|
-
else if (optimizationLevel >= 1) {
|
|
10045
|
-
// just basic optimizations to remove some .. parts
|
|
10046
|
-
globParts = this.levelOneOptimize(globParts);
|
|
10047
|
-
}
|
|
10048
|
-
else {
|
|
10049
|
-
// just collapse multiple ** portions into one
|
|
10050
|
-
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
10051
|
-
}
|
|
10052
|
-
return globParts;
|
|
10053
|
-
}
|
|
10054
|
-
// just get rid of adjascent ** portions
|
|
10055
|
-
adjascentGlobstarOptimize(globParts) {
|
|
10056
|
-
return globParts.map(parts => {
|
|
10057
|
-
let gs = -1;
|
|
10058
|
-
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
|
|
10059
|
-
let i = gs;
|
|
10060
|
-
while (parts[i + 1] === '**') {
|
|
10061
|
-
i++;
|
|
10062
|
-
}
|
|
10063
|
-
if (i !== gs) {
|
|
10064
|
-
parts.splice(gs, i - gs);
|
|
10065
|
-
}
|
|
10066
|
-
}
|
|
10067
|
-
return parts;
|
|
10068
|
-
});
|
|
10069
|
-
}
|
|
10070
|
-
// get rid of adjascent ** and resolve .. portions
|
|
10071
|
-
levelOneOptimize(globParts) {
|
|
10072
|
-
return globParts.map(parts => {
|
|
10073
|
-
parts = parts.reduce((set, part) => {
|
|
10074
|
-
const prev = set[set.length - 1];
|
|
10075
|
-
if (part === '**' && prev === '**') {
|
|
10076
|
-
return set;
|
|
10077
|
-
}
|
|
10078
|
-
if (part === '..') {
|
|
10079
|
-
if (prev && prev !== '..' && prev !== '.' && prev !== '**') {
|
|
10080
|
-
set.pop();
|
|
10081
|
-
return set;
|
|
10082
|
-
}
|
|
10083
|
-
}
|
|
10084
|
-
set.push(part);
|
|
10085
|
-
return set;
|
|
10086
|
-
}, []);
|
|
10087
|
-
return parts.length === 0 ? [''] : parts;
|
|
10088
|
-
});
|
|
10089
|
-
}
|
|
10090
|
-
levelTwoFileOptimize(parts) {
|
|
10091
|
-
if (!Array.isArray(parts)) {
|
|
10092
|
-
parts = this.slashSplit(parts);
|
|
10093
|
-
}
|
|
10094
|
-
let didSomething = false;
|
|
10095
|
-
do {
|
|
10096
|
-
didSomething = false;
|
|
10097
|
-
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
10098
|
-
if (!this.preserveMultipleSlashes) {
|
|
10099
|
-
for (let i = 1; i < parts.length - 1; i++) {
|
|
10100
|
-
const p = parts[i];
|
|
10101
|
-
// don't squeeze out UNC patterns
|
|
10102
|
-
if (i === 1 && p === '' && parts[0] === '')
|
|
10103
|
-
continue;
|
|
10104
|
-
if (p === '.' || p === '') {
|
|
10105
|
-
didSomething = true;
|
|
10106
|
-
parts.splice(i, 1);
|
|
10107
|
-
i--;
|
|
10108
|
-
}
|
|
10109
|
-
}
|
|
10110
|
-
if (parts[0] === '.' &&
|
|
10111
|
-
parts.length === 2 &&
|
|
10112
|
-
(parts[1] === '.' || parts[1] === '')) {
|
|
10113
|
-
didSomething = true;
|
|
10114
|
-
parts.pop();
|
|
10115
|
-
}
|
|
10116
|
-
}
|
|
10117
|
-
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
10118
|
-
let dd = 0;
|
|
10119
|
-
while (-1 !== (dd = parts.indexOf('..', dd + 1))) {
|
|
10120
|
-
const p = parts[dd - 1];
|
|
10121
|
-
if (p && p !== '.' && p !== '..' && p !== '**') {
|
|
10122
|
-
didSomething = true;
|
|
10123
|
-
parts.splice(dd - 1, 2);
|
|
10124
|
-
dd -= 2;
|
|
10125
|
-
}
|
|
10126
|
-
}
|
|
10127
|
-
} while (didSomething);
|
|
10128
|
-
return parts.length === 0 ? [''] : parts;
|
|
10129
|
-
}
|
|
10130
|
-
// First phase: single-pattern processing
|
|
10131
|
-
// <pre> is 1 or more portions
|
|
10132
|
-
// <rest> is 1 or more portions
|
|
10133
|
-
// <p> is any portion other than ., .., '', or **
|
|
10134
|
-
// <e> is . or ''
|
|
10135
|
-
//
|
|
10136
|
-
// **/.. is *brutal* for filesystem walking performance, because
|
|
10137
|
-
// it effectively resets the recursive walk each time it occurs,
|
|
10138
|
-
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
10139
|
-
// or most strings (other than .., ., and '') can be.
|
|
10140
|
-
//
|
|
10141
|
-
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
10142
|
-
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
10143
|
-
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
10144
|
-
// **/**/<rest> -> **/<rest>
|
|
10145
|
-
//
|
|
10146
|
-
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
10147
|
-
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
10148
|
-
firstPhasePreProcess(globParts) {
|
|
10149
|
-
let didSomething = false;
|
|
10150
|
-
do {
|
|
10151
|
-
didSomething = false;
|
|
10152
|
-
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
10153
|
-
for (let parts of globParts) {
|
|
10154
|
-
let gs = -1;
|
|
10155
|
-
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
|
|
10156
|
-
let gss = gs;
|
|
10157
|
-
while (parts[gss + 1] === '**') {
|
|
10158
|
-
// <pre>/**/**/<rest> -> <pre>/**/<rest>
|
|
10159
|
-
gss++;
|
|
10160
|
-
}
|
|
10161
|
-
// eg, if gs is 2 and gss is 4, that means we have 3 **
|
|
10162
|
-
// parts, and can remove 2 of them.
|
|
10163
|
-
if (gss > gs) {
|
|
10164
|
-
parts.splice(gs + 1, gss - gs);
|
|
10165
|
-
}
|
|
10166
|
-
let next = parts[gs + 1];
|
|
10167
|
-
const p = parts[gs + 2];
|
|
10168
|
-
const p2 = parts[gs + 3];
|
|
10169
|
-
if (next !== '..')
|
|
10170
|
-
continue;
|
|
10171
|
-
if (!p ||
|
|
10172
|
-
p === '.' ||
|
|
10173
|
-
p === '..' ||
|
|
10174
|
-
!p2 ||
|
|
10175
|
-
p2 === '.' ||
|
|
10176
|
-
p2 === '..') {
|
|
10177
|
-
continue;
|
|
10178
|
-
}
|
|
10179
|
-
didSomething = true;
|
|
10180
|
-
// edit parts in place, and push the new one
|
|
10181
|
-
parts.splice(gs, 1);
|
|
10182
|
-
const other = parts.slice(0);
|
|
10183
|
-
other[gs] = '**';
|
|
10184
|
-
globParts.push(other);
|
|
10185
|
-
gs--;
|
|
10186
|
-
}
|
|
10187
|
-
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
10188
|
-
if (!this.preserveMultipleSlashes) {
|
|
10189
|
-
for (let i = 1; i < parts.length - 1; i++) {
|
|
10190
|
-
const p = parts[i];
|
|
10191
|
-
// don't squeeze out UNC patterns
|
|
10192
|
-
if (i === 1 && p === '' && parts[0] === '')
|
|
10193
|
-
continue;
|
|
10194
|
-
if (p === '.' || p === '') {
|
|
10195
|
-
didSomething = true;
|
|
10196
|
-
parts.splice(i, 1);
|
|
10197
|
-
i--;
|
|
10198
|
-
}
|
|
10199
|
-
}
|
|
10200
|
-
if (parts[0] === '.' &&
|
|
10201
|
-
parts.length === 2 &&
|
|
10202
|
-
(parts[1] === '.' || parts[1] === '')) {
|
|
10203
|
-
didSomething = true;
|
|
10204
|
-
parts.pop();
|
|
10205
|
-
}
|
|
10206
|
-
}
|
|
10207
|
-
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
10208
|
-
let dd = 0;
|
|
10209
|
-
while (-1 !== (dd = parts.indexOf('..', dd + 1))) {
|
|
10210
|
-
const p = parts[dd - 1];
|
|
10211
|
-
if (p && p !== '.' && p !== '..' && p !== '**') {
|
|
10212
|
-
didSomething = true;
|
|
10213
|
-
const needDot = dd === 1 && parts[dd + 1] === '**';
|
|
10214
|
-
const splin = needDot ? ['.'] : [];
|
|
10215
|
-
parts.splice(dd - 1, 2, ...splin);
|
|
10216
|
-
if (parts.length === 0)
|
|
10217
|
-
parts.push('');
|
|
10218
|
-
dd -= 2;
|
|
10219
|
-
}
|
|
10220
|
-
}
|
|
10221
|
-
}
|
|
10222
|
-
} while (didSomething);
|
|
10223
|
-
return globParts;
|
|
10224
|
-
}
|
|
10225
|
-
// second phase: multi-pattern dedupes
|
|
10226
|
-
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
10227
|
-
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
10228
|
-
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
10229
|
-
//
|
|
10230
|
-
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
10231
|
-
// ^-- not valid because ** doens't follow symlinks
|
|
10232
|
-
secondPhasePreProcess(globParts) {
|
|
10233
|
-
for (let i = 0; i < globParts.length - 1; i++) {
|
|
10234
|
-
for (let j = i + 1; j < globParts.length; j++) {
|
|
10235
|
-
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
10236
|
-
if (matched) {
|
|
10237
|
-
globParts[i] = [];
|
|
10238
|
-
globParts[j] = matched;
|
|
10239
|
-
break;
|
|
10240
|
-
}
|
|
10241
|
-
}
|
|
10242
|
-
}
|
|
10243
|
-
return globParts.filter(gs => gs.length);
|
|
10244
|
-
}
|
|
10245
|
-
partsMatch(a, b, emptyGSMatch = false) {
|
|
10246
|
-
let ai = 0;
|
|
10247
|
-
let bi = 0;
|
|
10248
|
-
let result = [];
|
|
10249
|
-
let which = '';
|
|
10250
|
-
while (ai < a.length && bi < b.length) {
|
|
10251
|
-
if (a[ai] === b[bi]) {
|
|
10252
|
-
result.push(which === 'b' ? b[bi] : a[ai]);
|
|
10253
|
-
ai++;
|
|
10254
|
-
bi++;
|
|
10255
|
-
}
|
|
10256
|
-
else if (emptyGSMatch && a[ai] === '**' && b[bi] === a[ai + 1]) {
|
|
10257
|
-
result.push(a[ai]);
|
|
10258
|
-
ai++;
|
|
10259
|
-
}
|
|
10260
|
-
else if (emptyGSMatch && b[bi] === '**' && a[ai] === b[bi + 1]) {
|
|
10261
|
-
result.push(b[bi]);
|
|
10262
|
-
bi++;
|
|
10263
|
-
}
|
|
10264
|
-
else if (a[ai] === '*' &&
|
|
10265
|
-
b[bi] &&
|
|
10266
|
-
(this.options.dot || !b[bi].startsWith('.')) &&
|
|
10267
|
-
b[bi] !== '**') {
|
|
10268
|
-
if (which === 'b')
|
|
10269
|
-
return false;
|
|
10270
|
-
which = 'a';
|
|
10271
|
-
result.push(a[ai]);
|
|
10272
|
-
ai++;
|
|
10273
|
-
bi++;
|
|
10274
|
-
}
|
|
10275
|
-
else if (b[bi] === '*' &&
|
|
10276
|
-
a[ai] &&
|
|
10277
|
-
(this.options.dot || !a[ai].startsWith('.')) &&
|
|
10278
|
-
a[ai] !== '**') {
|
|
10279
|
-
if (which === 'a')
|
|
10280
|
-
return false;
|
|
10281
|
-
which = 'b';
|
|
10282
|
-
result.push(b[bi]);
|
|
10283
|
-
ai++;
|
|
10284
|
-
bi++;
|
|
10285
|
-
}
|
|
10286
|
-
else {
|
|
10287
|
-
return false;
|
|
10288
|
-
}
|
|
10289
|
-
}
|
|
10290
|
-
// if we fall out of the loop, it means they two are identical
|
|
10291
|
-
// as long as their lengths match
|
|
10292
|
-
return a.length === b.length && result;
|
|
10293
|
-
}
|
|
10294
|
-
parseNegate() {
|
|
10295
|
-
if (this.nonegate)
|
|
10296
|
-
return;
|
|
10297
|
-
const pattern = this.pattern;
|
|
10298
|
-
let negate = false;
|
|
10299
|
-
let negateOffset = 0;
|
|
10300
|
-
for (let i = 0; i < pattern.length && pattern.charAt(i) === '!'; i++) {
|
|
10301
|
-
negate = !negate;
|
|
10302
|
-
negateOffset++;
|
|
10303
|
-
}
|
|
10304
|
-
if (negateOffset)
|
|
10305
|
-
this.pattern = pattern.slice(negateOffset);
|
|
10306
|
-
this.negate = negate;
|
|
10307
|
-
}
|
|
10308
|
-
// set partial to true to test if, for example,
|
|
10309
|
-
// "/a/b" matches the start of "/*/b/*/d"
|
|
10310
|
-
// Partial means, if you run out of file before you run
|
|
10311
|
-
// out of pattern, then that's fine, as long as all
|
|
10312
|
-
// the parts match.
|
|
10313
|
-
matchOne(file, pattern, partial = false) {
|
|
10314
|
-
let fileStartIndex = 0;
|
|
10315
|
-
let patternStartIndex = 0;
|
|
10316
|
-
// UNC paths like //?/X:/... can match X:/... and vice versa
|
|
10317
|
-
// Drive letters in absolute drive or unc paths are always compared
|
|
10318
|
-
// case-insensitively.
|
|
10319
|
-
if (this.isWindows) {
|
|
10320
|
-
const fileDrive = typeof file[0] === 'string' && /^[a-z]:$/i.test(file[0]);
|
|
10321
|
-
const fileUNC = !fileDrive &&
|
|
10322
|
-
file[0] === '' &&
|
|
10323
|
-
file[1] === '' &&
|
|
10324
|
-
file[2] === '?' &&
|
|
10325
|
-
/^[a-z]:$/i.test(file[3]);
|
|
10326
|
-
const patternDrive = typeof pattern[0] === 'string' && /^[a-z]:$/i.test(pattern[0]);
|
|
10327
|
-
const patternUNC = !patternDrive &&
|
|
10328
|
-
pattern[0] === '' &&
|
|
10329
|
-
pattern[1] === '' &&
|
|
10330
|
-
pattern[2] === '?' &&
|
|
10331
|
-
typeof pattern[3] === 'string' &&
|
|
10332
|
-
/^[a-z]:$/i.test(pattern[3]);
|
|
10333
|
-
const fdi = fileUNC ? 3
|
|
10334
|
-
: fileDrive ? 0
|
|
10335
|
-
: undefined;
|
|
10336
|
-
const pdi = patternUNC ? 3
|
|
10337
|
-
: patternDrive ? 0
|
|
10338
|
-
: undefined;
|
|
10339
|
-
if (typeof fdi === 'number' && typeof pdi === 'number') {
|
|
10340
|
-
const [fd, pd] = [
|
|
10341
|
-
file[fdi],
|
|
10342
|
-
pattern[pdi],
|
|
10343
|
-
];
|
|
10344
|
-
// start matching at the drive letter index of each
|
|
10345
|
-
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
10346
|
-
pattern[pdi] = fd;
|
|
10347
|
-
patternStartIndex = pdi;
|
|
10348
|
-
fileStartIndex = fdi;
|
|
10349
|
-
}
|
|
10350
|
-
}
|
|
10351
|
-
}
|
|
10352
|
-
// resolve and reduce . and .. portions in the file as well.
|
|
10353
|
-
// don't need to do the second phase, because it's only one string[]
|
|
10354
|
-
const { optimizationLevel = 1 } = this.options;
|
|
10355
|
-
if (optimizationLevel >= 2) {
|
|
10356
|
-
file = this.levelTwoFileOptimize(file);
|
|
10357
|
-
}
|
|
10358
|
-
if (pattern.includes(GLOBSTAR)) {
|
|
10359
|
-
return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
10360
|
-
}
|
|
10361
|
-
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
10362
|
-
}
|
|
10363
|
-
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
10364
|
-
// split the pattern into head, tail, and middle of ** delimited parts
|
|
10365
|
-
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
10366
|
-
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
10367
|
-
// split the pattern up into globstar-delimited sections
|
|
10368
|
-
// the tail has to be at the end, and the others just have
|
|
10369
|
-
// to be found in order from the head.
|
|
10370
|
-
const [head, body, tail] = partial ? [
|
|
10371
|
-
pattern.slice(patternIndex, firstgs),
|
|
10372
|
-
pattern.slice(firstgs + 1),
|
|
10373
|
-
[],
|
|
10374
|
-
] : [
|
|
10375
|
-
pattern.slice(patternIndex, firstgs),
|
|
10376
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
10377
|
-
pattern.slice(lastgs + 1),
|
|
10378
|
-
];
|
|
10379
|
-
// check the head, from the current file/pattern index.
|
|
10380
|
-
if (head.length) {
|
|
10381
|
-
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
10382
|
-
if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
|
|
10383
|
-
return false;
|
|
10384
|
-
}
|
|
10385
|
-
fileIndex += head.length;
|
|
10386
|
-
patternIndex += head.length;
|
|
10387
|
-
}
|
|
10388
|
-
// now we know the head matches!
|
|
10389
|
-
// if the last portion is not empty, it MUST match the end
|
|
10390
|
-
// check the tail
|
|
10391
|
-
let fileTailMatch = 0;
|
|
10392
|
-
if (tail.length) {
|
|
10393
|
-
// if head + tail > file, then we cannot possibly match
|
|
10394
|
-
if (tail.length + fileIndex > file.length)
|
|
10395
|
-
return false;
|
|
10396
|
-
// try to match the tail
|
|
10397
|
-
let tailStart = file.length - tail.length;
|
|
10398
|
-
if (this.#matchOne(file, tail, partial, tailStart, 0)) {
|
|
10399
|
-
fileTailMatch = tail.length;
|
|
10400
|
-
}
|
|
10401
|
-
else {
|
|
10402
|
-
// affordance for stuff like a/**/* matching a/b/
|
|
10403
|
-
// if the last file portion is '', and there's more to the pattern
|
|
10404
|
-
// then try without the '' bit.
|
|
10405
|
-
if (file[file.length - 1] !== '' ||
|
|
10406
|
-
fileIndex + tail.length === file.length) {
|
|
10407
|
-
return false;
|
|
10408
|
-
}
|
|
10409
|
-
tailStart--;
|
|
10410
|
-
if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
|
|
10411
|
-
return false;
|
|
10412
|
-
}
|
|
10413
|
-
fileTailMatch = tail.length + 1;
|
|
10414
|
-
}
|
|
10415
|
-
}
|
|
10416
|
-
// now we know the tail matches!
|
|
10417
|
-
// the middle is zero or more portions wrapped in **, possibly
|
|
10418
|
-
// containing more ** sections.
|
|
10419
|
-
// so a/**/b/**/c/**/d has become **/b/**/c/**
|
|
10420
|
-
// if it's empty, it means a/**/b, just verify we have no bad dots
|
|
10421
|
-
// if there's no tail, so it ends on /**, then we must have *something*
|
|
10422
|
-
// after the head, or it's not a matc
|
|
10423
|
-
if (!body.length) {
|
|
10424
|
-
let sawSome = !!fileTailMatch;
|
|
10425
|
-
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
|
|
10426
|
-
const f = String(file[i]);
|
|
10427
|
-
sawSome = true;
|
|
10428
|
-
if (f === '.' ||
|
|
10429
|
-
f === '..' ||
|
|
10430
|
-
(!this.options.dot && f.startsWith('.'))) {
|
|
10431
|
-
return false;
|
|
10432
|
-
}
|
|
10433
|
-
}
|
|
10434
|
-
// in partial mode, we just need to get past all file parts
|
|
10435
|
-
return partial || sawSome;
|
|
10436
|
-
}
|
|
10437
|
-
// now we know that there's one or more body sections, which can
|
|
10438
|
-
// be matched anywhere from the 0 index (because the head was pruned)
|
|
10439
|
-
// through to the length-fileTailMatch index.
|
|
10440
|
-
// split the body up into sections, and note the minimum index it can
|
|
10441
|
-
// be found at (start with the length of all previous segments)
|
|
10442
|
-
// [section, before, after]
|
|
10443
|
-
const bodySegments = [[[], 0]];
|
|
10444
|
-
let currentBody = bodySegments[0];
|
|
10445
|
-
let nonGsParts = 0;
|
|
10446
|
-
const nonGsPartsSums = [0];
|
|
10447
|
-
for (const b of body) {
|
|
10448
|
-
if (b === GLOBSTAR) {
|
|
10449
|
-
nonGsPartsSums.push(nonGsParts);
|
|
10450
|
-
currentBody = [[], 0];
|
|
10451
|
-
bodySegments.push(currentBody);
|
|
10452
|
-
}
|
|
10453
|
-
else {
|
|
10454
|
-
currentBody[0].push(b);
|
|
10455
|
-
nonGsParts++;
|
|
10456
|
-
}
|
|
10457
|
-
}
|
|
10458
|
-
let i = bodySegments.length - 1;
|
|
10459
|
-
const fileLength = file.length - fileTailMatch;
|
|
10460
|
-
for (const b of bodySegments) {
|
|
10461
|
-
b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
10462
|
-
}
|
|
10463
|
-
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
10464
|
-
}
|
|
10465
|
-
// return false for "nope, not matching"
|
|
10466
|
-
// return null for "not matching, cannot keep trying"
|
|
10467
|
-
#matchGlobStarBodySections(file,
|
|
10468
|
-
// pattern section, last possible position for it
|
|
10469
|
-
bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
10470
|
-
// take the first body segment, and walk from fileIndex to its "after"
|
|
10471
|
-
// value at the end
|
|
10472
|
-
// If it doesn't match at that position, we increment, until we hit
|
|
10473
|
-
// that final possible position, and give up.
|
|
10474
|
-
// If it does match, then advance and try to rest.
|
|
10475
|
-
// If any of them fail we keep walking forward.
|
|
10476
|
-
// this is still a bit recursively painful, but it's more constrained
|
|
10477
|
-
// than previous implementations, because we never test something that
|
|
10478
|
-
// can't possibly be a valid matching condition.
|
|
10479
|
-
const bs = bodySegments[bodyIndex];
|
|
10480
|
-
if (!bs) {
|
|
10481
|
-
// just make sure that there's no bad dots
|
|
10482
|
-
for (let i = fileIndex; i < file.length; i++) {
|
|
10483
|
-
sawTail = true;
|
|
10484
|
-
const f = file[i];
|
|
10485
|
-
if (f === '.' ||
|
|
10486
|
-
f === '..' ||
|
|
10487
|
-
(!this.options.dot && f.startsWith('.'))) {
|
|
10488
|
-
return false;
|
|
10489
|
-
}
|
|
10490
|
-
}
|
|
10491
|
-
return sawTail;
|
|
10492
|
-
}
|
|
10493
|
-
// have a non-globstar body section to test
|
|
10494
|
-
const [body, after] = bs;
|
|
10495
|
-
while (fileIndex <= after) {
|
|
10496
|
-
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
10497
|
-
// if limit exceeded, no match. intentional false negative,
|
|
10498
|
-
// acceptable break in correctness for security.
|
|
10499
|
-
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
10500
|
-
// match! see if the rest match. if so, we're done!
|
|
10501
|
-
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
10502
|
-
if (sub !== false) {
|
|
10503
|
-
return sub;
|
|
10504
|
-
}
|
|
10505
|
-
}
|
|
10506
|
-
const f = file[fileIndex];
|
|
10507
|
-
if (f === '.' ||
|
|
10508
|
-
f === '..' ||
|
|
10509
|
-
(!this.options.dot && f.startsWith('.'))) {
|
|
10510
|
-
return false;
|
|
10511
|
-
}
|
|
10512
|
-
fileIndex++;
|
|
10513
|
-
}
|
|
10514
|
-
// walked off. no point continuing
|
|
10515
|
-
return partial || null;
|
|
10516
|
-
}
|
|
10517
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
10518
|
-
let fi;
|
|
10519
|
-
let pi;
|
|
10520
|
-
let pl;
|
|
10521
|
-
let fl;
|
|
10522
|
-
for (fi = fileIndex,
|
|
10523
|
-
pi = patternIndex,
|
|
10524
|
-
fl = file.length,
|
|
10525
|
-
pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
10526
|
-
this.debug('matchOne loop');
|
|
10527
|
-
let p = pattern[pi];
|
|
10528
|
-
let f = file[fi];
|
|
10529
|
-
this.debug(pattern, p, f);
|
|
10530
|
-
// should be impossible.
|
|
10531
|
-
// some invalid regexp stuff in the set.
|
|
10532
|
-
/* c8 ignore start */
|
|
10533
|
-
if (p === false || p === GLOBSTAR) {
|
|
10534
|
-
return false;
|
|
10535
|
-
}
|
|
10536
|
-
/* c8 ignore stop */
|
|
10537
|
-
// something other than **
|
|
10538
|
-
// non-magic patterns just have to match exactly
|
|
10539
|
-
// patterns with magic have been turned into regexps.
|
|
10540
|
-
let hit;
|
|
10541
|
-
if (typeof p === 'string') {
|
|
10542
|
-
hit = f === p;
|
|
10543
|
-
this.debug('string match', p, f, hit);
|
|
10544
|
-
}
|
|
10545
|
-
else {
|
|
10546
|
-
hit = p.test(f);
|
|
10547
|
-
this.debug('pattern match', p, f, hit);
|
|
10548
|
-
}
|
|
10549
|
-
if (!hit)
|
|
10550
|
-
return false;
|
|
10551
|
-
}
|
|
10552
|
-
// Note: ending in / means that we'll get a final ""
|
|
10553
|
-
// at the end of the pattern. This can only match a
|
|
10554
|
-
// corresponding "" at the end of the file.
|
|
10555
|
-
// If the file ends in /, then it can only match a
|
|
10556
|
-
// a pattern that ends in /, unless the pattern just
|
|
10557
|
-
// doesn't have any more for it. But, a/b/ should *not*
|
|
10558
|
-
// match "a/b/*", even though "" matches against the
|
|
10559
|
-
// [^/]*? pattern, except in partial mode, where it might
|
|
10560
|
-
// simply not be reached yet.
|
|
10561
|
-
// However, a/b/ should still satisfy a/*
|
|
10562
|
-
// now either we fell off the end of the pattern, or we're done.
|
|
10563
|
-
if (fi === fl && pi === pl) {
|
|
10564
|
-
// ran out of pattern and filename at the same time.
|
|
10565
|
-
// an exact hit!
|
|
10566
|
-
return true;
|
|
10567
|
-
}
|
|
10568
|
-
else if (fi === fl) {
|
|
10569
|
-
// ran out of file, but still had pattern left.
|
|
10570
|
-
// this is ok if we're doing the match as part of
|
|
10571
|
-
// a glob fs traversal.
|
|
10572
|
-
return partial;
|
|
10573
|
-
}
|
|
10574
|
-
else if (pi === pl) {
|
|
10575
|
-
// ran out of pattern, still have file left.
|
|
10576
|
-
// this is only acceptable if we're on the very last
|
|
10577
|
-
// empty segment of a file with a trailing slash.
|
|
10578
|
-
// a/* should match a/b/
|
|
10579
|
-
return fi === fl - 1 && file[fi] === '';
|
|
10580
|
-
/* c8 ignore start */
|
|
10581
|
-
}
|
|
10582
|
-
else {
|
|
10583
|
-
// should be unreachable.
|
|
10584
|
-
throw new Error('wtf?');
|
|
10585
|
-
}
|
|
10586
|
-
/* c8 ignore stop */
|
|
10587
|
-
}
|
|
10588
|
-
braceExpand() {
|
|
10589
|
-
return braceExpand(this.pattern, this.options);
|
|
10590
|
-
}
|
|
10591
|
-
parse(pattern) {
|
|
10592
|
-
assertValidPattern(pattern);
|
|
10593
|
-
const options = this.options;
|
|
10594
|
-
// shortcuts
|
|
10595
|
-
if (pattern === '**')
|
|
10596
|
-
return GLOBSTAR;
|
|
10597
|
-
if (pattern === '')
|
|
10598
|
-
return '';
|
|
10599
|
-
// far and away, the most common glob pattern parts are
|
|
10600
|
-
// *, *.*, and *.<ext> Add a fast check method for those.
|
|
10601
|
-
let m;
|
|
10602
|
-
let fastTest = null;
|
|
10603
|
-
if ((m = pattern.match(starRE))) {
|
|
10604
|
-
fastTest = options.dot ? starTestDot : starTest;
|
|
10605
|
-
}
|
|
10606
|
-
else if ((m = pattern.match(starDotExtRE))) {
|
|
10607
|
-
fastTest = (options.nocase ?
|
|
10608
|
-
options.dot ?
|
|
10609
|
-
starDotExtTestNocaseDot
|
|
10610
|
-
: starDotExtTestNocase
|
|
10611
|
-
: options.dot ? starDotExtTestDot
|
|
10612
|
-
: starDotExtTest)(m[1]);
|
|
10613
|
-
}
|
|
10614
|
-
else if ((m = pattern.match(qmarksRE))) {
|
|
10615
|
-
fastTest = (options.nocase ?
|
|
10616
|
-
options.dot ?
|
|
10617
|
-
qmarksTestNocaseDot
|
|
10618
|
-
: qmarksTestNocase
|
|
10619
|
-
: options.dot ? qmarksTestDot
|
|
10620
|
-
: qmarksTest)(m);
|
|
10621
|
-
}
|
|
10622
|
-
else if ((m = pattern.match(starDotStarRE))) {
|
|
10623
|
-
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
10624
|
-
}
|
|
10625
|
-
else if ((m = pattern.match(dotStarRE))) {
|
|
10626
|
-
fastTest = dotStarTest;
|
|
10627
|
-
}
|
|
10628
|
-
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
10629
|
-
if (fastTest && typeof re === 'object') {
|
|
10630
|
-
// Avoids overriding in frozen environments
|
|
10631
|
-
Reflect.defineProperty(re, 'test', { value: fastTest });
|
|
10632
|
-
}
|
|
10633
|
-
return re;
|
|
10634
|
-
}
|
|
10635
|
-
makeRe() {
|
|
10636
|
-
if (this.regexp || this.regexp === false)
|
|
10637
|
-
return this.regexp;
|
|
10638
|
-
// at this point, this.set is a 2d array of partial
|
|
10639
|
-
// pattern strings, or "**".
|
|
10640
|
-
//
|
|
10641
|
-
// It's better to use .match(). This function shouldn't
|
|
10642
|
-
// be used, really, but it's pretty convenient sometimes,
|
|
10643
|
-
// when you just want to work with a regex.
|
|
10644
|
-
const set = this.set;
|
|
10645
|
-
if (!set.length) {
|
|
10646
|
-
this.regexp = false;
|
|
10647
|
-
return this.regexp;
|
|
10648
|
-
}
|
|
10649
|
-
const options = this.options;
|
|
10650
|
-
const twoStar = options.noglobstar ? star
|
|
10651
|
-
: options.dot ? twoStarDot
|
|
10652
|
-
: twoStarNoDot;
|
|
10653
|
-
const flags = new Set(options.nocase ? ['i'] : []);
|
|
10654
|
-
// regexpify non-globstar patterns
|
|
10655
|
-
// if ** is only item, then we just do one twoStar
|
|
10656
|
-
// if ** is first, and there are more, prepend (\/|twoStar\/)? to next
|
|
10657
|
-
// if ** is last, append (\/twoStar|) to previous
|
|
10658
|
-
// if ** is in the middle, append (\/|\/twoStar\/) to previous
|
|
10659
|
-
// then filter out GLOBSTAR symbols
|
|
10660
|
-
let re = set
|
|
10661
|
-
.map(pattern => {
|
|
10662
|
-
const pp = pattern.map(p => {
|
|
10663
|
-
if (p instanceof RegExp) {
|
|
10664
|
-
for (const f of p.flags.split(''))
|
|
10665
|
-
flags.add(f);
|
|
10666
|
-
}
|
|
10667
|
-
return (typeof p === 'string' ? regExpEscape(p)
|
|
10668
|
-
: p === GLOBSTAR ? GLOBSTAR
|
|
10669
|
-
: p._src);
|
|
10670
|
-
});
|
|
10671
|
-
pp.forEach((p, i) => {
|
|
10672
|
-
const next = pp[i + 1];
|
|
10673
|
-
const prev = pp[i - 1];
|
|
10674
|
-
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
10675
|
-
return;
|
|
10676
|
-
}
|
|
10677
|
-
if (prev === undefined) {
|
|
10678
|
-
if (next !== undefined && next !== GLOBSTAR) {
|
|
10679
|
-
pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
|
|
10680
|
-
}
|
|
10681
|
-
else {
|
|
10682
|
-
pp[i] = twoStar;
|
|
10683
|
-
}
|
|
10684
|
-
}
|
|
10685
|
-
else if (next === undefined) {
|
|
10686
|
-
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + ')?';
|
|
10687
|
-
}
|
|
10688
|
-
else if (next !== GLOBSTAR) {
|
|
10689
|
-
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
|
|
10690
|
-
pp[i + 1] = GLOBSTAR;
|
|
10691
|
-
}
|
|
10692
|
-
});
|
|
10693
|
-
const filtered = pp.filter(p => p !== GLOBSTAR);
|
|
10694
|
-
// For partial matches, we need to make the pattern match
|
|
10695
|
-
// any prefix of the full path. We do this by generating
|
|
10696
|
-
// alternative patterns that match progressively longer prefixes.
|
|
10697
|
-
if (this.partial && filtered.length >= 1) {
|
|
10698
|
-
const prefixes = [];
|
|
10699
|
-
for (let i = 1; i <= filtered.length; i++) {
|
|
10700
|
-
prefixes.push(filtered.slice(0, i).join('/'));
|
|
10701
|
-
}
|
|
10702
|
-
return '(?:' + prefixes.join('|') + ')';
|
|
10703
|
-
}
|
|
10704
|
-
return filtered.join('/');
|
|
10705
|
-
})
|
|
10706
|
-
.join('|');
|
|
10707
|
-
// need to wrap in parens if we had more than one thing with |,
|
|
10708
|
-
// otherwise only the first will be anchored to ^ and the last to $
|
|
10709
|
-
const [open, close] = set.length > 1 ? ['(?:', ')'] : ['', ''];
|
|
10710
|
-
// must match entire pattern
|
|
10711
|
-
// ending in a * or ** will make it less strict.
|
|
10712
|
-
re = '^' + open + re + close + '$';
|
|
10713
|
-
// In partial mode, '/' should always match as it's a valid prefix for any pattern
|
|
10714
|
-
if (this.partial) {
|
|
10715
|
-
re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
|
|
10716
|
-
}
|
|
10717
|
-
// can match anything, as long as it's not this.
|
|
10718
|
-
if (this.negate)
|
|
10719
|
-
re = '^(?!' + re + ').+$';
|
|
10720
|
-
try {
|
|
10721
|
-
this.regexp = new RegExp(re, [...flags].join(''));
|
|
10722
|
-
/* c8 ignore start */
|
|
10723
|
-
}
|
|
10724
|
-
catch (ex) {
|
|
10725
|
-
// should be impossible
|
|
10726
|
-
this.regexp = false;
|
|
10727
|
-
}
|
|
10728
|
-
/* c8 ignore stop */
|
|
10729
|
-
return this.regexp;
|
|
10730
|
-
}
|
|
10731
|
-
slashSplit(p) {
|
|
10732
|
-
// if p starts with // on windows, we preserve that
|
|
10733
|
-
// so that UNC paths aren't broken. Otherwise, any number of
|
|
10734
|
-
// / characters are coalesced into one, unless
|
|
10735
|
-
// preserveMultipleSlashes is set to true.
|
|
10736
|
-
if (this.preserveMultipleSlashes) {
|
|
10737
|
-
return p.split('/');
|
|
10738
|
-
}
|
|
10739
|
-
else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
10740
|
-
// add an extra '' for the one we lose
|
|
10741
|
-
return ['', ...p.split(/\/+/)];
|
|
10742
|
-
}
|
|
10743
|
-
else {
|
|
10744
|
-
return p.split(/\/+/);
|
|
10745
|
-
}
|
|
10746
|
-
}
|
|
10747
|
-
match(f, partial = this.partial) {
|
|
10748
|
-
this.debug('match', f, this.pattern);
|
|
10749
|
-
// short-circuit in the case of busted things.
|
|
10750
|
-
// comments, etc.
|
|
10751
|
-
if (this.comment) {
|
|
10752
|
-
return false;
|
|
10753
|
-
}
|
|
10754
|
-
if (this.empty) {
|
|
10755
|
-
return f === '';
|
|
10756
|
-
}
|
|
10757
|
-
if (f === '/' && partial) {
|
|
10758
|
-
return true;
|
|
10759
|
-
}
|
|
10760
|
-
const options = this.options;
|
|
10761
|
-
// windows: need to use /, not \
|
|
10762
|
-
if (this.isWindows) {
|
|
10763
|
-
f = f.split('\\').join('/');
|
|
10764
|
-
}
|
|
10765
|
-
// treat the test path as a set of pathparts.
|
|
10766
|
-
const ff = this.slashSplit(f);
|
|
10767
|
-
this.debug(this.pattern, 'split', ff);
|
|
10768
|
-
// just ONE of the pattern sets in this.set needs to match
|
|
10769
|
-
// in order for it to be valid. If negating, then just one
|
|
10770
|
-
// match means that we have failed.
|
|
10771
|
-
// Either way, return on the first hit.
|
|
10772
|
-
const set = this.set;
|
|
10773
|
-
this.debug(this.pattern, 'set', set);
|
|
10774
|
-
// Find the basename of the path by looking for the last non-empty segment
|
|
10775
|
-
let filename = ff[ff.length - 1];
|
|
10776
|
-
if (!filename) {
|
|
10777
|
-
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
10778
|
-
filename = ff[i];
|
|
10779
|
-
}
|
|
10780
|
-
}
|
|
10781
|
-
for (let i = 0; i < set.length; i++) {
|
|
10782
|
-
const pattern = set[i];
|
|
10783
|
-
let file = ff;
|
|
10784
|
-
if (options.matchBase && pattern.length === 1) {
|
|
10785
|
-
file = [filename];
|
|
10786
|
-
}
|
|
10787
|
-
const hit = this.matchOne(file, pattern, partial);
|
|
10788
|
-
if (hit) {
|
|
10789
|
-
if (options.flipNegate) {
|
|
10790
|
-
return true;
|
|
10791
|
-
}
|
|
10792
|
-
return !this.negate;
|
|
10793
|
-
}
|
|
10794
|
-
}
|
|
10795
|
-
// didn't get any hits. this is success if it's a negative
|
|
10796
|
-
// pattern, failure otherwise.
|
|
10797
|
-
if (options.flipNegate) {
|
|
10798
|
-
return false;
|
|
10799
|
-
}
|
|
10800
|
-
return this.negate;
|
|
10801
|
-
}
|
|
10802
|
-
static defaults(def) {
|
|
10803
|
-
return minimatch.defaults(def).Minimatch;
|
|
10804
|
-
}
|
|
10805
|
-
}
|
|
10806
|
-
/* c8 ignore stop */
|
|
10807
|
-
minimatch.AST = AST;
|
|
10808
|
-
minimatch.Minimatch = Minimatch;
|
|
10809
|
-
minimatch.escape = escape$3;
|
|
10810
|
-
minimatch.unescape = unescape$1;
|
|
10811
|
-
|
|
10812
8410
|
const CWD = process.cwd();
|
|
10813
8411
|
const importMetaUrl = import.meta.url;
|
|
10814
8412
|
const cjsRequire = importMetaUrl
|
|
@@ -19664,8 +17262,8 @@ function keysFromSelector(selector, opts) {
|
|
|
19664
17262
|
const nsSeparator = opts?.nsSeparator ?? ':';
|
|
19665
17263
|
if (path.length > 1 && nsSeparator) {
|
|
19666
17264
|
const ns = opts?.ns;
|
|
19667
|
-
const
|
|
19668
|
-
if (
|
|
17265
|
+
const nsArray = Array.isArray(ns) ? ns : null;
|
|
17266
|
+
if (nsArray && nsArray.length > 1 && nsArray.slice(1).includes(path[0])) {
|
|
19669
17267
|
return `${path[0]}${nsSeparator}${path.slice(1).join(keySeparator)}`;
|
|
19670
17268
|
}
|
|
19671
17269
|
}
|
|
@@ -40835,7 +38433,7 @@ class ReaddirpStream extends Readable {
|
|
|
40835
38433
|
}
|
|
40836
38434
|
if (entryRealPathStats.isDirectory()) {
|
|
40837
38435
|
const len = entryRealPath.length;
|
|
40838
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) === sep
|
|
38436
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === sep) {
|
|
40839
38437
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
40840
38438
|
// @ts-ignore
|
|
40841
38439
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
@@ -40944,7 +38542,7 @@ const binaryExtensions = new Set([
|
|
|
40944
38542
|
'xmind', 'xpi', 'xpm', 'xwd', 'xz',
|
|
40945
38543
|
'z', 'zip', 'zipx',
|
|
40946
38544
|
]);
|
|
40947
|
-
const isBinaryPath = (filePath) => binaryExtensions.has(path
|
|
38545
|
+
const isBinaryPath = (filePath) => binaryExtensions.has(path.extname(filePath).slice(1).toLowerCase());
|
|
40948
38546
|
// TODO: emit errors properly. Example: EMFILE on Macos.
|
|
40949
38547
|
const foreach = (val, fn) => {
|
|
40950
38548
|
if (val instanceof Set) {
|
|
@@ -40990,18 +38588,18 @@ const FsWatchInstances = new Map();
|
|
|
40990
38588
|
* @param emitRaw emits raw event data
|
|
40991
38589
|
* @returns {NativeFsWatcher}
|
|
40992
38590
|
*/
|
|
40993
|
-
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
38591
|
+
function createFsWatchInstance(path$1, options, listener, errHandler, emitRaw) {
|
|
40994
38592
|
const handleEvent = (rawEvent, evPath) => {
|
|
40995
|
-
listener(path);
|
|
40996
|
-
emitRaw(rawEvent, evPath, { watchedPath: path });
|
|
38593
|
+
listener(path$1);
|
|
38594
|
+
emitRaw(rawEvent, evPath, { watchedPath: path$1 });
|
|
40997
38595
|
// emit based on events occurring for files from a directory's watcher in
|
|
40998
38596
|
// case the file's watcher misses it (and rely on throttling to de-dupe)
|
|
40999
|
-
if (evPath && path !== evPath) {
|
|
41000
|
-
fsWatchBroadcast(path
|
|
38597
|
+
if (evPath && path$1 !== evPath) {
|
|
38598
|
+
fsWatchBroadcast(path.resolve(path$1, evPath), KEY_LISTENERS, path.join(path$1, evPath));
|
|
41001
38599
|
}
|
|
41002
38600
|
};
|
|
41003
38601
|
try {
|
|
41004
|
-
return watch$2(path, {
|
|
38602
|
+
return watch$2(path$1, {
|
|
41005
38603
|
persistent: options.persistent,
|
|
41006
38604
|
}, handleEvent);
|
|
41007
38605
|
}
|
|
@@ -41180,13 +38778,13 @@ class NodeFsHandler {
|
|
|
41180
38778
|
* @param listener on fs change
|
|
41181
38779
|
* @returns closer for the watcher instance
|
|
41182
38780
|
*/
|
|
41183
|
-
_watchWithNodeFs(path, listener) {
|
|
38781
|
+
_watchWithNodeFs(path$1, listener) {
|
|
41184
38782
|
const opts = this.fsw.options;
|
|
41185
|
-
const directory = path
|
|
41186
|
-
const basename = path
|
|
38783
|
+
const directory = path.dirname(path$1);
|
|
38784
|
+
const basename = path.basename(path$1);
|
|
41187
38785
|
const parent = this.fsw._getWatchedDir(directory);
|
|
41188
38786
|
parent.add(basename);
|
|
41189
|
-
const absolutePath = path
|
|
38787
|
+
const absolutePath = path.resolve(path$1);
|
|
41190
38788
|
const options = {
|
|
41191
38789
|
persistent: opts.persistent,
|
|
41192
38790
|
};
|
|
@@ -41196,13 +38794,13 @@ class NodeFsHandler {
|
|
|
41196
38794
|
if (opts.usePolling) {
|
|
41197
38795
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
41198
38796
|
options.interval = enableBin && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
|
41199
|
-
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
38797
|
+
closer = setFsWatchFileListener(path$1, absolutePath, options, {
|
|
41200
38798
|
listener,
|
|
41201
38799
|
rawEmitter: this.fsw._emitRaw,
|
|
41202
38800
|
});
|
|
41203
38801
|
}
|
|
41204
38802
|
else {
|
|
41205
|
-
closer = setFsWatchListener(path, absolutePath, options, {
|
|
38803
|
+
closer = setFsWatchListener(path$1, absolutePath, options, {
|
|
41206
38804
|
listener,
|
|
41207
38805
|
errHandler: this._boundHandleError,
|
|
41208
38806
|
rawEmitter: this.fsw._emitRaw,
|
|
@@ -41218,8 +38816,8 @@ class NodeFsHandler {
|
|
|
41218
38816
|
if (this.fsw.closed) {
|
|
41219
38817
|
return;
|
|
41220
38818
|
}
|
|
41221
|
-
const dirname = path
|
|
41222
|
-
const basename = path
|
|
38819
|
+
const dirname = path.dirname(file);
|
|
38820
|
+
const basename = path.basename(file);
|
|
41223
38821
|
const parent = this.fsw._getWatchedDir(dirname);
|
|
41224
38822
|
// stats is always present
|
|
41225
38823
|
let prevStats = stats;
|
|
@@ -41326,7 +38924,7 @@ class NodeFsHandler {
|
|
|
41326
38924
|
}
|
|
41327
38925
|
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
41328
38926
|
// Normalize the directory name on Windows
|
|
41329
|
-
directory = path
|
|
38927
|
+
directory = path.join(directory, '');
|
|
41330
38928
|
const throttleKey = target ? `${directory}:${target}` : directory;
|
|
41331
38929
|
throttler = this.fsw._throttle('readdir', throttleKey, 1000);
|
|
41332
38930
|
if (!throttler)
|
|
@@ -41346,10 +38944,10 @@ class NodeFsHandler {
|
|
|
41346
38944
|
return;
|
|
41347
38945
|
}
|
|
41348
38946
|
const item = entry.path;
|
|
41349
|
-
let path = path
|
|
38947
|
+
let path$1 = path.join(directory, item);
|
|
41350
38948
|
current.add(item);
|
|
41351
38949
|
if (entry.stats.isSymbolicLink() &&
|
|
41352
|
-
(await this._handleSymlink(entry, directory, path, item))) {
|
|
38950
|
+
(await this._handleSymlink(entry, directory, path$1, item))) {
|
|
41353
38951
|
return;
|
|
41354
38952
|
}
|
|
41355
38953
|
if (this.fsw.closed) {
|
|
@@ -41362,8 +38960,8 @@ class NodeFsHandler {
|
|
|
41362
38960
|
if (item === target || (!target && !previous.has(item))) {
|
|
41363
38961
|
this.fsw._incrReadyCount();
|
|
41364
38962
|
// ensure relativeness of path is preserved in case of watcher reuse
|
|
41365
|
-
path = path
|
|
41366
|
-
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
38963
|
+
path$1 = path.join(dir, path.relative(dir, path$1));
|
|
38964
|
+
this._addToNodeFs(path$1, initialAdd, wh, depth + 1);
|
|
41367
38965
|
}
|
|
41368
38966
|
})
|
|
41369
38967
|
.on(EV.ERROR, this._boundHandleError);
|
|
@@ -41407,13 +39005,13 @@ class NodeFsHandler {
|
|
|
41407
39005
|
* @returns closer for the watcher instance.
|
|
41408
39006
|
*/
|
|
41409
39007
|
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
|
41410
|
-
const parentDir = this.fsw._getWatchedDir(path
|
|
41411
|
-
const tracked = parentDir.has(path
|
|
39008
|
+
const parentDir = this.fsw._getWatchedDir(path.dirname(dir));
|
|
39009
|
+
const tracked = parentDir.has(path.basename(dir));
|
|
41412
39010
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
|
41413
39011
|
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
41414
39012
|
}
|
|
41415
39013
|
// ensure dir is tracked (harmless if redundant)
|
|
41416
|
-
parentDir.add(path
|
|
39014
|
+
parentDir.add(path.basename(dir));
|
|
41417
39015
|
this.fsw._getWatchedDir(dir);
|
|
41418
39016
|
let throttler;
|
|
41419
39017
|
let closer;
|
|
@@ -41442,13 +39040,13 @@ class NodeFsHandler {
|
|
|
41442
39040
|
* @param depth Child path actually targeted for watch
|
|
41443
39041
|
* @param target Child path actually targeted for watch
|
|
41444
39042
|
*/
|
|
41445
|
-
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
|
39043
|
+
async _addToNodeFs(path$1, initialAdd, priorWh, depth, target) {
|
|
41446
39044
|
const ready = this.fsw._emitReady;
|
|
41447
|
-
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
|
39045
|
+
if (this.fsw._isIgnored(path$1) || this.fsw.closed) {
|
|
41448
39046
|
ready();
|
|
41449
39047
|
return false;
|
|
41450
39048
|
}
|
|
41451
|
-
const wh = this.fsw._getWatchHelpers(path);
|
|
39049
|
+
const wh = this.fsw._getWatchHelpers(path$1);
|
|
41452
39050
|
if (priorWh) {
|
|
41453
39051
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
41454
39052
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -41465,8 +39063,8 @@ class NodeFsHandler {
|
|
|
41465
39063
|
const follow = this.fsw.options.followSymlinks;
|
|
41466
39064
|
let closer;
|
|
41467
39065
|
if (stats.isDirectory()) {
|
|
41468
|
-
const absPath = path
|
|
41469
|
-
const targetPath = follow ? await realpath(path) : path;
|
|
39066
|
+
const absPath = path.resolve(path$1);
|
|
39067
|
+
const targetPath = follow ? await realpath(path$1) : path$1;
|
|
41470
39068
|
if (this.fsw.closed)
|
|
41471
39069
|
return;
|
|
41472
39070
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -41478,18 +39076,18 @@ class NodeFsHandler {
|
|
|
41478
39076
|
}
|
|
41479
39077
|
}
|
|
41480
39078
|
else if (stats.isSymbolicLink()) {
|
|
41481
|
-
const targetPath = follow ? await realpath(path) : path;
|
|
39079
|
+
const targetPath = follow ? await realpath(path$1) : path$1;
|
|
41482
39080
|
if (this.fsw.closed)
|
|
41483
39081
|
return;
|
|
41484
|
-
const parent = path
|
|
39082
|
+
const parent = path.dirname(wh.watchPath);
|
|
41485
39083
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
41486
39084
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
41487
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
39085
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path$1, wh, targetPath);
|
|
41488
39086
|
if (this.fsw.closed)
|
|
41489
39087
|
return;
|
|
41490
39088
|
// preserve this symlink's target path
|
|
41491
39089
|
if (targetPath !== undefined) {
|
|
41492
|
-
this.fsw._symlinkPaths.set(path
|
|
39090
|
+
this.fsw._symlinkPaths.set(path.resolve(path$1), targetPath);
|
|
41493
39091
|
}
|
|
41494
39092
|
}
|
|
41495
39093
|
else {
|
|
@@ -41497,13 +39095,13 @@ class NodeFsHandler {
|
|
|
41497
39095
|
}
|
|
41498
39096
|
ready();
|
|
41499
39097
|
if (closer)
|
|
41500
|
-
this.fsw._addPathCloser(path, closer);
|
|
39098
|
+
this.fsw._addPathCloser(path$1, closer);
|
|
41501
39099
|
return false;
|
|
41502
39100
|
}
|
|
41503
39101
|
catch (error) {
|
|
41504
39102
|
if (this.fsw._handleError(error)) {
|
|
41505
39103
|
ready();
|
|
41506
|
-
return path;
|
|
39104
|
+
return path$1;
|
|
41507
39105
|
}
|
|
41508
39106
|
}
|
|
41509
39107
|
}
|
|
@@ -41535,29 +39133,29 @@ function createPattern(matcher) {
|
|
|
41535
39133
|
if (matcher.path === string)
|
|
41536
39134
|
return true;
|
|
41537
39135
|
if (matcher.recursive) {
|
|
41538
|
-
const relative = path
|
|
39136
|
+
const relative = path.relative(matcher.path, string);
|
|
41539
39137
|
if (!relative) {
|
|
41540
39138
|
return false;
|
|
41541
39139
|
}
|
|
41542
|
-
return !relative.startsWith('..') && !path
|
|
39140
|
+
return !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
41543
39141
|
}
|
|
41544
39142
|
return false;
|
|
41545
39143
|
};
|
|
41546
39144
|
}
|
|
41547
39145
|
return () => false;
|
|
41548
39146
|
}
|
|
41549
|
-
function normalizePath(path) {
|
|
41550
|
-
if (typeof path !== 'string')
|
|
39147
|
+
function normalizePath(path$1) {
|
|
39148
|
+
if (typeof path$1 !== 'string')
|
|
41551
39149
|
throw new Error('string expected');
|
|
41552
|
-
path = path
|
|
41553
|
-
path = path.replace(/\\/g, '/');
|
|
39150
|
+
path$1 = path.normalize(path$1);
|
|
39151
|
+
path$1 = path$1.replace(/\\/g, '/');
|
|
41554
39152
|
let prepend = false;
|
|
41555
|
-
if (path.startsWith('//'))
|
|
39153
|
+
if (path$1.startsWith('//'))
|
|
41556
39154
|
prepend = true;
|
|
41557
|
-
path = path.replace(DOUBLE_SLASH_RE, '/');
|
|
39155
|
+
path$1 = path$1.replace(DOUBLE_SLASH_RE, '/');
|
|
41558
39156
|
if (prepend)
|
|
41559
|
-
path = '/' + path;
|
|
41560
|
-
return path;
|
|
39157
|
+
path$1 = '/' + path$1;
|
|
39158
|
+
return path$1;
|
|
41561
39159
|
}
|
|
41562
39160
|
function matchPatterns(patterns, testString, stats) {
|
|
41563
39161
|
const path = normalizePath(testString);
|
|
@@ -41605,21 +39203,21 @@ const toUnix = (string) => {
|
|
|
41605
39203
|
};
|
|
41606
39204
|
// Our version of upath.normalize
|
|
41607
39205
|
// TODO: this is not equal to path-normalize module - investigate why
|
|
41608
|
-
const normalizePathToUnix = (path) => toUnix(path
|
|
39206
|
+
const normalizePathToUnix = (path$1) => toUnix(path.normalize(toUnix(path$1)));
|
|
41609
39207
|
// TODO: refactor
|
|
41610
|
-
const normalizeIgnored = (cwd = '') => (path) => {
|
|
41611
|
-
if (typeof path === 'string') {
|
|
41612
|
-
return normalizePathToUnix(path
|
|
39208
|
+
const normalizeIgnored = (cwd = '') => (path$1) => {
|
|
39209
|
+
if (typeof path$1 === 'string') {
|
|
39210
|
+
return normalizePathToUnix(path.isAbsolute(path$1) ? path$1 : path.join(cwd, path$1));
|
|
41613
39211
|
}
|
|
41614
39212
|
else {
|
|
41615
|
-
return path;
|
|
39213
|
+
return path$1;
|
|
41616
39214
|
}
|
|
41617
39215
|
};
|
|
41618
|
-
const getAbsolutePath = (path, cwd) => {
|
|
41619
|
-
if (path
|
|
41620
|
-
return path;
|
|
39216
|
+
const getAbsolutePath = (path$1, cwd) => {
|
|
39217
|
+
if (path.isAbsolute(path$1)) {
|
|
39218
|
+
return path$1;
|
|
41621
39219
|
}
|
|
41622
|
-
return path
|
|
39220
|
+
return path.join(cwd, path$1);
|
|
41623
39221
|
};
|
|
41624
39222
|
const EMPTY_SET = Object.freeze(new Set());
|
|
41625
39223
|
/**
|
|
@@ -41654,7 +39252,7 @@ class DirEntry {
|
|
|
41654
39252
|
}
|
|
41655
39253
|
catch (err) {
|
|
41656
39254
|
if (this._removeWatcher) {
|
|
41657
|
-
this._removeWatcher(path
|
|
39255
|
+
this._removeWatcher(path.dirname(dir), path.basename(dir));
|
|
41658
39256
|
}
|
|
41659
39257
|
}
|
|
41660
39258
|
}
|
|
@@ -41688,12 +39286,12 @@ class WatchHelper {
|
|
|
41688
39286
|
dirParts;
|
|
41689
39287
|
followSymlinks;
|
|
41690
39288
|
statMethod;
|
|
41691
|
-
constructor(path, follow, fsw) {
|
|
39289
|
+
constructor(path$1, follow, fsw) {
|
|
41692
39290
|
this.fsw = fsw;
|
|
41693
|
-
const watchPath = path;
|
|
41694
|
-
this.path = path = path.replace(REPLACER_RE, '');
|
|
39291
|
+
const watchPath = path$1;
|
|
39292
|
+
this.path = path$1 = path$1.replace(REPLACER_RE, '');
|
|
41695
39293
|
this.watchPath = watchPath;
|
|
41696
|
-
this.fullWatchPath = path
|
|
39294
|
+
this.fullWatchPath = path.resolve(watchPath);
|
|
41697
39295
|
this.dirParts = [];
|
|
41698
39296
|
this.dirParts.forEach((parts) => {
|
|
41699
39297
|
if (parts.length > 1)
|
|
@@ -41703,7 +39301,7 @@ class WatchHelper {
|
|
|
41703
39301
|
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
41704
39302
|
}
|
|
41705
39303
|
entryPath(entry) {
|
|
41706
|
-
return path
|
|
39304
|
+
return path.join(this.watchPath, path.relative(this.watchPath, entry.fullPath));
|
|
41707
39305
|
}
|
|
41708
39306
|
filterPath(entry) {
|
|
41709
39307
|
const { stats } = entry;
|
|
@@ -41877,7 +39475,7 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
41877
39475
|
return;
|
|
41878
39476
|
results.forEach((item) => {
|
|
41879
39477
|
if (item)
|
|
41880
|
-
this.add(path
|
|
39478
|
+
this.add(path.dirname(item), path.basename(_origAdd || item));
|
|
41881
39479
|
});
|
|
41882
39480
|
});
|
|
41883
39481
|
return this;
|
|
@@ -41890,18 +39488,18 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
41890
39488
|
return this;
|
|
41891
39489
|
const paths = unifyPaths(paths_);
|
|
41892
39490
|
const { cwd } = this.options;
|
|
41893
|
-
paths.forEach((path) => {
|
|
39491
|
+
paths.forEach((path$1) => {
|
|
41894
39492
|
// convert to absolute path unless relative path already matches
|
|
41895
|
-
if (!path
|
|
39493
|
+
if (!path.isAbsolute(path$1) && !this._closers.has(path$1)) {
|
|
41896
39494
|
if (cwd)
|
|
41897
|
-
path = path
|
|
41898
|
-
path = path
|
|
39495
|
+
path$1 = path.join(cwd, path$1);
|
|
39496
|
+
path$1 = path.resolve(path$1);
|
|
41899
39497
|
}
|
|
41900
|
-
this._closePath(path);
|
|
41901
|
-
this._addIgnoredPath(path);
|
|
41902
|
-
if (this._watched.has(path)) {
|
|
39498
|
+
this._closePath(path$1);
|
|
39499
|
+
this._addIgnoredPath(path$1);
|
|
39500
|
+
if (this._watched.has(path$1)) {
|
|
41903
39501
|
this._addIgnoredPath({
|
|
41904
|
-
path,
|
|
39502
|
+
path: path$1,
|
|
41905
39503
|
recursive: true,
|
|
41906
39504
|
});
|
|
41907
39505
|
}
|
|
@@ -41949,7 +39547,7 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
41949
39547
|
getWatched() {
|
|
41950
39548
|
const watchList = {};
|
|
41951
39549
|
this._watched.forEach((entry, dir) => {
|
|
41952
|
-
const key = this.options.cwd ? path
|
|
39550
|
+
const key = this.options.cwd ? path.relative(this.options.cwd, dir) : dir;
|
|
41953
39551
|
const index = key || ONE_DOT;
|
|
41954
39552
|
watchList[index] = entry.getChildren().sort();
|
|
41955
39553
|
});
|
|
@@ -41970,26 +39568,26 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
41970
39568
|
* @param stats arguments to be passed with event
|
|
41971
39569
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
41972
39570
|
*/
|
|
41973
|
-
async _emit(event, path, stats) {
|
|
39571
|
+
async _emit(event, path$1, stats) {
|
|
41974
39572
|
if (this.closed)
|
|
41975
39573
|
return;
|
|
41976
39574
|
const opts = this.options;
|
|
41977
39575
|
if (isWindows)
|
|
41978
|
-
path = path
|
|
39576
|
+
path$1 = path.normalize(path$1);
|
|
41979
39577
|
if (opts.cwd)
|
|
41980
|
-
path = path
|
|
41981
|
-
const args = [path];
|
|
39578
|
+
path$1 = path.relative(opts.cwd, path$1);
|
|
39579
|
+
const args = [path$1];
|
|
41982
39580
|
if (stats != null)
|
|
41983
39581
|
args.push(stats);
|
|
41984
39582
|
const awf = opts.awaitWriteFinish;
|
|
41985
39583
|
let pw;
|
|
41986
|
-
if (awf && (pw = this._pendingWrites.get(path))) {
|
|
39584
|
+
if (awf && (pw = this._pendingWrites.get(path$1))) {
|
|
41987
39585
|
pw.lastChange = new Date();
|
|
41988
39586
|
return this;
|
|
41989
39587
|
}
|
|
41990
39588
|
if (opts.atomic) {
|
|
41991
39589
|
if (event === EVENTS.UNLINK) {
|
|
41992
|
-
this._pendingUnlinks.set(path, [event, ...args]);
|
|
39590
|
+
this._pendingUnlinks.set(path$1, [event, ...args]);
|
|
41993
39591
|
setTimeout(() => {
|
|
41994
39592
|
this._pendingUnlinks.forEach((entry, path) => {
|
|
41995
39593
|
this.emit(...entry);
|
|
@@ -41999,9 +39597,9 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
41999
39597
|
}, typeof opts.atomic === 'number' ? opts.atomic : 100);
|
|
42000
39598
|
return this;
|
|
42001
39599
|
}
|
|
42002
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
|
|
39600
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path$1)) {
|
|
42003
39601
|
event = EVENTS.CHANGE;
|
|
42004
|
-
this._pendingUnlinks.delete(path);
|
|
39602
|
+
this._pendingUnlinks.delete(path$1);
|
|
42005
39603
|
}
|
|
42006
39604
|
}
|
|
42007
39605
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -42022,18 +39620,18 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42022
39620
|
this.emitWithAll(event, args);
|
|
42023
39621
|
}
|
|
42024
39622
|
};
|
|
42025
|
-
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
|
39623
|
+
this._awaitWriteFinish(path$1, awf.stabilityThreshold, event, awfEmit);
|
|
42026
39624
|
return this;
|
|
42027
39625
|
}
|
|
42028
39626
|
if (event === EVENTS.CHANGE) {
|
|
42029
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE, path, 50);
|
|
39627
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path$1, 50);
|
|
42030
39628
|
if (isThrottled)
|
|
42031
39629
|
return this;
|
|
42032
39630
|
}
|
|
42033
39631
|
if (opts.alwaysStat &&
|
|
42034
39632
|
stats === undefined &&
|
|
42035
39633
|
(event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
42036
|
-
const fullPath = opts.cwd ? path
|
|
39634
|
+
const fullPath = opts.cwd ? path.join(opts.cwd, path$1) : path$1;
|
|
42037
39635
|
let stats;
|
|
42038
39636
|
try {
|
|
42039
39637
|
stats = await stat$1(fullPath);
|
|
@@ -42109,33 +39707,33 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42109
39707
|
* @param event
|
|
42110
39708
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
42111
39709
|
*/
|
|
42112
|
-
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
|
39710
|
+
_awaitWriteFinish(path$1, threshold, event, awfEmit) {
|
|
42113
39711
|
const awf = this.options.awaitWriteFinish;
|
|
42114
39712
|
if (typeof awf !== 'object')
|
|
42115
39713
|
return;
|
|
42116
39714
|
const pollInterval = awf.pollInterval;
|
|
42117
39715
|
let timeoutHandler;
|
|
42118
|
-
let fullPath = path;
|
|
42119
|
-
if (this.options.cwd && !path
|
|
42120
|
-
fullPath = path
|
|
39716
|
+
let fullPath = path$1;
|
|
39717
|
+
if (this.options.cwd && !path.isAbsolute(path$1)) {
|
|
39718
|
+
fullPath = path.join(this.options.cwd, path$1);
|
|
42121
39719
|
}
|
|
42122
39720
|
const now = new Date();
|
|
42123
39721
|
const writes = this._pendingWrites;
|
|
42124
39722
|
function awaitWriteFinishFn(prevStat) {
|
|
42125
39723
|
stat$2(fullPath, (err, curStat) => {
|
|
42126
|
-
if (err || !writes.has(path)) {
|
|
39724
|
+
if (err || !writes.has(path$1)) {
|
|
42127
39725
|
if (err && err.code !== 'ENOENT')
|
|
42128
39726
|
awfEmit(err);
|
|
42129
39727
|
return;
|
|
42130
39728
|
}
|
|
42131
39729
|
const now = Number(new Date());
|
|
42132
39730
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
42133
|
-
writes.get(path).lastChange = now;
|
|
39731
|
+
writes.get(path$1).lastChange = now;
|
|
42134
39732
|
}
|
|
42135
|
-
const pw = writes.get(path);
|
|
39733
|
+
const pw = writes.get(path$1);
|
|
42136
39734
|
const df = now - pw.lastChange;
|
|
42137
39735
|
if (df >= threshold) {
|
|
42138
|
-
writes.delete(path);
|
|
39736
|
+
writes.delete(path$1);
|
|
42139
39737
|
awfEmit(undefined, curStat);
|
|
42140
39738
|
}
|
|
42141
39739
|
else {
|
|
@@ -42143,11 +39741,11 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42143
39741
|
}
|
|
42144
39742
|
});
|
|
42145
39743
|
}
|
|
42146
|
-
if (!writes.has(path)) {
|
|
42147
|
-
writes.set(path, {
|
|
39744
|
+
if (!writes.has(path$1)) {
|
|
39745
|
+
writes.set(path$1, {
|
|
42148
39746
|
lastChange: now,
|
|
42149
39747
|
cancelWait: () => {
|
|
42150
|
-
writes.delete(path);
|
|
39748
|
+
writes.delete(path$1);
|
|
42151
39749
|
clearTimeout(timeoutHandler);
|
|
42152
39750
|
return event;
|
|
42153
39751
|
},
|
|
@@ -42188,7 +39786,7 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42188
39786
|
* @param directory path of the directory
|
|
42189
39787
|
*/
|
|
42190
39788
|
_getWatchedDir(directory) {
|
|
42191
|
-
const dir = path
|
|
39789
|
+
const dir = path.resolve(directory);
|
|
42192
39790
|
if (!this._watched.has(dir))
|
|
42193
39791
|
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
42194
39792
|
return this._watched.get(dir);
|
|
@@ -42214,13 +39812,13 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42214
39812
|
// if what is being deleted is a directory, get that directory's paths
|
|
42215
39813
|
// for recursive deleting and cleaning of watched object
|
|
42216
39814
|
// if it is not a directory, nestedDirectoryChildren will be empty array
|
|
42217
|
-
const path = path
|
|
42218
|
-
const fullPath = path
|
|
39815
|
+
const path$1 = path.join(directory, item);
|
|
39816
|
+
const fullPath = path.resolve(path$1);
|
|
42219
39817
|
isDirectory =
|
|
42220
|
-
isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
39818
|
+
isDirectory != null ? isDirectory : this._watched.has(path$1) || this._watched.has(fullPath);
|
|
42221
39819
|
// prevent duplicate handling in case of arriving here nearly simultaneously
|
|
42222
39820
|
// via multiple paths (such as _handleFile and _handleDir)
|
|
42223
|
-
if (!this._throttle('remove', path, 100))
|
|
39821
|
+
if (!this._throttle('remove', path$1, 100))
|
|
42224
39822
|
return;
|
|
42225
39823
|
// if the only watched file is removed, watch for its return
|
|
42226
39824
|
if (!isDirectory && this._watched.size === 1) {
|
|
@@ -42228,10 +39826,10 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42228
39826
|
}
|
|
42229
39827
|
// This will create a new entry in the watched object in either case
|
|
42230
39828
|
// so we got to do the directory check beforehand
|
|
42231
|
-
const wp = this._getWatchedDir(path);
|
|
39829
|
+
const wp = this._getWatchedDir(path$1);
|
|
42232
39830
|
const nestedDirectoryChildren = wp.getChildren();
|
|
42233
39831
|
// Recursively remove children directories / files.
|
|
42234
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
|
|
39832
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path$1, nested));
|
|
42235
39833
|
// Check if item was on the watched list and remove it
|
|
42236
39834
|
const parent = this._getWatchedDir(directory);
|
|
42237
39835
|
const wasTracked = parent.has(item);
|
|
@@ -42245,9 +39843,9 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42245
39843
|
this._symlinkPaths.delete(fullPath);
|
|
42246
39844
|
}
|
|
42247
39845
|
// If we wait for this file to be fully written, cancel the wait.
|
|
42248
|
-
let relPath = path;
|
|
39846
|
+
let relPath = path$1;
|
|
42249
39847
|
if (this.options.cwd)
|
|
42250
|
-
relPath = path
|
|
39848
|
+
relPath = path.relative(this.options.cwd, path$1);
|
|
42251
39849
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
42252
39850
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
42253
39851
|
if (event === EVENTS.ADD)
|
|
@@ -42255,21 +39853,21 @@ class FSWatcher extends EventEmitter$1 {
|
|
|
42255
39853
|
}
|
|
42256
39854
|
// The Entry will either be a directory that just got removed
|
|
42257
39855
|
// or a bogus entry to a file, in either case we have to remove it
|
|
42258
|
-
this._watched.delete(path);
|
|
39856
|
+
this._watched.delete(path$1);
|
|
42259
39857
|
this._watched.delete(fullPath);
|
|
42260
39858
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
42261
|
-
if (wasTracked && !this._isIgnored(path))
|
|
42262
|
-
this._emit(eventName, path);
|
|
39859
|
+
if (wasTracked && !this._isIgnored(path$1))
|
|
39860
|
+
this._emit(eventName, path$1);
|
|
42263
39861
|
// Avoid conflicts if we later create another file with the same name
|
|
42264
|
-
this._closePath(path);
|
|
39862
|
+
this._closePath(path$1);
|
|
42265
39863
|
}
|
|
42266
39864
|
/**
|
|
42267
39865
|
* Closes all watchers for a path
|
|
42268
39866
|
*/
|
|
42269
|
-
_closePath(path) {
|
|
42270
|
-
this._closeFile(path);
|
|
42271
|
-
const dir = path
|
|
42272
|
-
this._getWatchedDir(dir).remove(path
|
|
39867
|
+
_closePath(path$1) {
|
|
39868
|
+
this._closeFile(path$1);
|
|
39869
|
+
const dir = path.dirname(path$1);
|
|
39870
|
+
this._getWatchedDir(dir).remove(path.basename(path$1));
|
|
42273
39871
|
}
|
|
42274
39872
|
/**
|
|
42275
39873
|
* Closes only file-specific watchers
|
|
@@ -72104,5 +69702,5 @@ var typescript = /*#__PURE__*/Object.freeze({
|
|
|
72104
69702
|
parsers: ld
|
|
72105
69703
|
});
|
|
72106
69704
|
|
|
72107
|
-
export { HighlightJS as H, MarkdownIt as M, Ze$a as Z, resolveConfig as a, createTwoFilesPatch$1 as b, createSyncFn as c, dedent$1 as d, deflist_plugin as e, format2 as f, closest as g, distance as h, fm$2 as i, isCI as j,
|
|
72108
|
-
//# sourceMappingURL=vendor-
|
|
69705
|
+
export { HighlightJS as H, MarkdownIt as M, Ze$a as Z, resolveConfig as a, createTwoFilesPatch$1 as b, createSyncFn as c, dedent$1 as d, deflist_plugin as e, format2 as f, closest as g, distance as h, fm$2 as i, isCI as j, cliProgress as k, tinylr as l, moduleImporter as m, createInstance as n, fse as o, inter as p, runAsWorker as r, ts$7 as t, watch$1 as w };
|
|
69706
|
+
//# sourceMappingURL=vendor-DgbU8VP_.mjs.map
|