1"use strict"; 2var __defProp = Object.defineProperty; 3var __getOwnPropNames = Object.getOwnPropertyNames; 4var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 5var __commonJS = (cb, mod) => function __require() { 6 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 7}; 8var __publicField = (obj, key, value) => { 9 __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); 10 return value; 11}; 12var __accessCheck = (obj, member, msg) => { 13 if (!member.has(obj)) 14 throw TypeError("Cannot " + msg); 15}; 16var __privateGet = (obj, member, getter) => { 17 __accessCheck(obj, member, "read from private field"); 18 return getter ? getter.call(obj) : member.get(obj); 19}; 20var __privateAdd = (obj, member, value) => { 21 if (member.has(obj)) 22 throw TypeError("Cannot add the same private member more than once"); 23 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 24}; 25var __privateSet = (obj, member, value, setter) => { 26 __accessCheck(obj, member, "write to private field"); 27 setter ? setter.call(obj, value) : member.set(obj, value); 28 return value; 29}; 30var __privateMethod = (obj, member, method) => { 31 __accessCheck(obj, member, "access private method"); 32 return method; 33}; 34 35// node_modules/balanced-match/index.js 36var require_balanced_match = __commonJS({ 37 "node_modules/balanced-match/index.js"(exports2, module2) { 38 "use strict"; 39 module2.exports = balanced; 40 function balanced(a, b, str) { 41 if (a instanceof RegExp) 42 a = maybeMatch(a, str); 43 if (b instanceof RegExp) 44 b = maybeMatch(b, str); 45 var r = range(a, b, str); 46 return r && { 47 start: r[0], 48 end: r[1], 49 pre: str.slice(0, r[0]), 50 body: str.slice(r[0] + a.length, r[1]), 51 post: str.slice(r[1] + b.length) 52 }; 53 } 54 function maybeMatch(reg, str) { 55 var m = str.match(reg); 56 return m ? m[0] : null; 57 } 58 balanced.range = range; 59 function range(a, b, str) { 60 var begs, beg, left, right, result; 61 var ai = str.indexOf(a); 62 var bi = str.indexOf(b, ai + 1); 63 var i = ai; 64 if (ai >= 0 && bi > 0) { 65 if (a === b) { 66 return [ai, bi]; 67 } 68 begs = []; 69 left = str.length; 70 while (i >= 0 && !result) { 71 if (i == ai) { 72 begs.push(i); 73 ai = str.indexOf(a, i + 1); 74 } else if (begs.length == 1) { 75 result = [begs.pop(), bi]; 76 } else { 77 beg = begs.pop(); 78 if (beg < left) { 79 left = beg; 80 right = bi; 81 } 82 bi = str.indexOf(b, i + 1); 83 } 84 i = ai < bi && ai >= 0 ? ai : bi; 85 } 86 if (begs.length) { 87 result = [left, right]; 88 } 89 } 90 return result; 91 } 92 } 93}); 94 95// node_modules/brace-expansion/index.js 96var require_brace_expansion = __commonJS({ 97 "node_modules/brace-expansion/index.js"(exports2, module2) { 98 var balanced = require_balanced_match(); 99 module2.exports = expandTop; 100 var escSlash = "\0SLASH" + Math.random() + "\0"; 101 var escOpen = "\0OPEN" + Math.random() + "\0"; 102 var escClose = "\0CLOSE" + Math.random() + "\0"; 103 var escComma = "\0COMMA" + Math.random() + "\0"; 104 var escPeriod = "\0PERIOD" + Math.random() + "\0"; 105 function numeric(str) { 106 return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0); 107 } 108 function escapeBraces(str) { 109 return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod); 110 } 111 function unescapeBraces(str) { 112 return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join("."); 113 } 114 function parseCommaParts(str) { 115 if (!str) 116 return [""]; 117 var parts = []; 118 var m = balanced("{", "}", str); 119 if (!m) 120 return str.split(","); 121 var pre = m.pre; 122 var body = m.body; 123 var post = m.post; 124 var p = pre.split(","); 125 p[p.length - 1] += "{" + body + "}"; 126 var postParts = parseCommaParts(post); 127 if (post.length) { 128 p[p.length - 1] += postParts.shift(); 129 p.push.apply(p, postParts); 130 } 131 parts.push.apply(parts, p); 132 return parts; 133 } 134 function expandTop(str) { 135 if (!str) 136 return []; 137 if (str.substr(0, 2) === "{}") { 138 str = "\\{\\}" + str.substr(2); 139 } 140 return expand(escapeBraces(str), true).map(unescapeBraces); 141 } 142 function embrace(str) { 143 return "{" + str + "}"; 144 } 145 function isPadded(el) { 146 return /^-?0\d/.test(el); 147 } 148 function lte(i, y) { 149 return i <= y; 150 } 151 function gte(i, y) { 152 return i >= y; 153 } 154 function expand(str, isTop) { 155 var expansions = []; 156 var m = balanced("{", "}", str); 157 if (!m) 158 return [str]; 159 var pre = m.pre; 160 var post = m.post.length ? expand(m.post, false) : [""]; 161 if (/\$$/.test(m.pre)) { 162 for (var k = 0; k < post.length; k++) { 163 var expansion = pre + "{" + m.body + "}" + post[k]; 164 expansions.push(expansion); 165 } 166 } else { 167 var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); 168 var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); 169 var isSequence = isNumericSequence || isAlphaSequence; 170 var isOptions = m.body.indexOf(",") >= 0; 171 if (!isSequence && !isOptions) { 172 if (m.post.match(/,.*\}/)) { 173 str = m.pre + "{" + m.body + escClose + m.post; 174 return expand(str); 175 } 176 return [str]; 177 } 178 var n; 179 if (isSequence) { 180 n = m.body.split(/\.\./); 181 } else { 182 n = parseCommaParts(m.body); 183 if (n.length === 1) { 184 n = expand(n[0], false).map(embrace); 185 if (n.length === 1) { 186 return post.map(function(p) { 187 return m.pre + n[0] + p; 188 }); 189 } 190 } 191 } 192 var N; 193 if (isSequence) { 194 var x = numeric(n[0]); 195 var y = numeric(n[1]); 196 var width = Math.max(n[0].length, n[1].length); 197 var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1; 198 var test = lte; 199 var reverse = y < x; 200 if (reverse) { 201 incr *= -1; 202 test = gte; 203 } 204 var pad = n.some(isPadded); 205 N = []; 206 for (var i = x; test(i, y); i += incr) { 207 var c; 208 if (isAlphaSequence) { 209 c = String.fromCharCode(i); 210 if (c === "\\") 211 c = ""; 212 } else { 213 c = String(i); 214 if (pad) { 215 var need = width - c.length; 216 if (need > 0) { 217 var z = new Array(need + 1).join("0"); 218 if (i < 0) 219 c = "-" + z + c.slice(1); 220 else 221 c = z + c; 222 } 223 } 224 } 225 N.push(c); 226 } 227 } else { 228 N = []; 229 for (var j = 0; j < n.length; j++) { 230 N.push.apply(N, expand(n[j], false)); 231 } 232 } 233 for (var j = 0; j < N.length; j++) { 234 for (var k = 0; k < post.length; k++) { 235 var expansion = pre + N[j] + post[k]; 236 if (!isTop || isSequence || expansion) 237 expansions.push(expansion); 238 } 239 } 240 } 241 return expansions; 242 } 243 } 244}); 245 246// dist/cjs/assert-valid-pattern.js 247var require_assert_valid_pattern = __commonJS({ 248 "dist/cjs/assert-valid-pattern.js"(exports2) { 249 "use strict"; 250 Object.defineProperty(exports2, "__esModule", { value: true }); 251 exports2.assertValidPattern = void 0; 252 var MAX_PATTERN_LENGTH = 1024 * 64; 253 var assertValidPattern = (pattern) => { 254 if (typeof pattern !== "string") { 255 throw new TypeError("invalid pattern"); 256 } 257 if (pattern.length > MAX_PATTERN_LENGTH) { 258 throw new TypeError("pattern is too long"); 259 } 260 }; 261 exports2.assertValidPattern = assertValidPattern; 262 } 263}); 264 265// dist/cjs/brace-expressions.js 266var require_brace_expressions = __commonJS({ 267 "dist/cjs/brace-expressions.js"(exports2) { 268 "use strict"; 269 Object.defineProperty(exports2, "__esModule", { value: true }); 270 exports2.parseClass = void 0; 271 var posixClasses = { 272 "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true], 273 "[:alpha:]": ["\\p{L}\\p{Nl}", true], 274 "[:ascii:]": ["\\x00-\\x7f", false], 275 "[:blank:]": ["\\p{Zs}\\t", true], 276 "[:cntrl:]": ["\\p{Cc}", true], 277 "[:digit:]": ["\\p{Nd}", true], 278 "[:graph:]": ["\\p{Z}\\p{C}", true, true], 279 "[:lower:]": ["\\p{Ll}", true], 280 "[:print:]": ["\\p{C}", true], 281 "[:punct:]": ["\\p{P}", true], 282 "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true], 283 "[:upper:]": ["\\p{Lu}", true], 284 "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true], 285 "[:xdigit:]": ["A-Fa-f0-9", false] 286 }; 287 var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"); 288 var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 289 var rangesToString = (ranges) => ranges.join(""); 290 var parseClass = (glob, position) => { 291 const pos = position; 292 if (glob.charAt(pos) !== "[") { 293 throw new Error("not in a brace expression"); 294 } 295 const ranges = []; 296 const negs = []; 297 let i = pos + 1; 298 let sawStart = false; 299 let uflag = false; 300 let escaping = false; 301 let negate = false; 302 let endPos = pos; 303 let rangeStart = ""; 304 WHILE: 305 while (i < glob.length) { 306 const c = glob.charAt(i); 307 if ((c === "!" || c === "^") && i === pos + 1) { 308 negate = true; 309 i++; 310 continue; 311 } 312 if (c === "]" && sawStart && !escaping) { 313 endPos = i + 1; 314 break; 315 } 316 sawStart = true; 317 if (c === "\\") { 318 if (!escaping) { 319 escaping = true; 320 i++; 321 continue; 322 } 323 } 324 if (c === "[" && !escaping) { 325 for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) { 326 if (glob.startsWith(cls, i)) { 327 if (rangeStart) { 328 return ["$.", false, glob.length - pos, true]; 329 } 330 i += cls.length; 331 if (neg) 332 negs.push(unip); 333 else 334 ranges.push(unip); 335 uflag = uflag || u; 336 continue WHILE; 337 } 338 } 339 } 340 escaping = false; 341 if (rangeStart) { 342 if (c > rangeStart) { 343 ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c)); 344 } else if (c === rangeStart) { 345 ranges.push(braceEscape(c)); 346 } 347 rangeStart = ""; 348 i++; 349 continue; 350 } 351 if (glob.startsWith("-]", i + 1)) { 352 ranges.push(braceEscape(c + "-")); 353 i += 2; 354 continue; 355 } 356 if (glob.startsWith("-", i + 1)) { 357 rangeStart = c; 358 i += 2; 359 continue; 360 } 361 ranges.push(braceEscape(c)); 362 i++; 363 } 364 if (endPos < i) { 365 return ["", false, 0, false]; 366 } 367 if (!ranges.length && !negs.length) { 368 return ["$.", false, glob.length - pos, true]; 369 } 370 if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) { 371 const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0]; 372 return [regexpEscape(r), false, endPos - pos, false]; 373 } 374 const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]"; 375 const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]"; 376 const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs; 377 return [comb, uflag, endPos - pos, true]; 378 }; 379 exports2.parseClass = parseClass; 380 } 381}); 382 383// dist/cjs/unescape.js 384var require_unescape = __commonJS({ 385 "dist/cjs/unescape.js"(exports2) { 386 "use strict"; 387 Object.defineProperty(exports2, "__esModule", { value: true }); 388 exports2.unescape = void 0; 389 var unescape = (s, { windowsPathsNoEscape = false } = {}) => { 390 return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"); 391 }; 392 exports2.unescape = unescape; 393 } 394}); 395 396// dist/cjs/ast.js 397var require_ast = __commonJS({ 398 "dist/cjs/ast.js"(exports2) { 399 "use strict"; 400 Object.defineProperty(exports2, "__esModule", { value: true }); 401 exports2.AST = void 0; 402 var brace_expressions_js_1 = require_brace_expressions(); 403 var unescape_js_12 = require_unescape(); 404 var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]); 405 var isExtglobType = (c) => types.has(c); 406 var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))"; 407 var startNoDot = "(?!\\.)"; 408 var addPatternStart = /* @__PURE__ */ new Set(["[", "."]); 409 var justDots = /* @__PURE__ */ new Set(["..", "."]); 410 var reSpecials = new Set("().*{}+?[]^$\\!"); 411 var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 412 var qmark2 = "[^/]"; 413 var star2 = qmark2 + "*?"; 414 var starNoEmpty = qmark2 + "+?"; 415 var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _fillNegs, fillNegs_fn, _parseAST, parseAST_fn, _partsToRegExp, partsToRegExp_fn, _parseGlob, parseGlob_fn; 416 var _AST = class { 417 constructor(type, parent, options = {}) { 418 __privateAdd(this, _fillNegs); 419 __privateAdd(this, _partsToRegExp); 420 __publicField(this, "type"); 421 __privateAdd(this, _root, void 0); 422 __privateAdd(this, _hasMagic, void 0); 423 __privateAdd(this, _uflag, false); 424 __privateAdd(this, _parts, []); 425 __privateAdd(this, _parent, void 0); 426 __privateAdd(this, _parentIndex, void 0); 427 __privateAdd(this, _negs, void 0); 428 __privateAdd(this, _filledNegs, false); 429 __privateAdd(this, _options, void 0); 430 __privateAdd(this, _toString, void 0); 431 // set to true if it's an extglob with no children 432 // (which really means one child of '') 433 __privateAdd(this, _emptyExt, false); 434 this.type = type; 435 if (type) 436 __privateSet(this, _hasMagic, true); 437 __privateSet(this, _parent, parent); 438 __privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this); 439 __privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options)); 440 __privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs)); 441 if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs)) 442 __privateGet(this, _negs).push(this); 443 __privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0); 444 } 445 get hasMagic() { 446 if (__privateGet(this, _hasMagic) !== void 0) 447 return __privateGet(this, _hasMagic); 448 for (const p of __privateGet(this, _parts)) { 449 if (typeof p === "string") 450 continue; 451 if (p.type || p.hasMagic) 452 return __privateSet(this, _hasMagic, true); 453 } 454 return __privateGet(this, _hasMagic); 455 } 456 // reconstructs the pattern 457 toString() { 458 if (__privateGet(this, _toString) !== void 0) 459 return __privateGet(this, _toString); 460 if (!this.type) { 461 return __privateSet(this, _toString, __privateGet(this, _parts).map((p) => String(p)).join("")); 462 } else { 463 return __privateSet(this, _toString, this.type + "(" + __privateGet(this, _parts).map((p) => String(p)).join("|") + ")"); 464 } 465 } 466 push(...parts) { 467 for (const p of parts) { 468 if (p === "") 469 continue; 470 if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) { 471 throw new Error("invalid part: " + p); 472 } 473 __privateGet(this, _parts).push(p); 474 } 475 } 476 toJSON() { 477 const ret = this.type === null ? __privateGet(this, _parts).slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...__privateGet(this, _parts).map((p) => p.toJSON())]; 478 if (this.isStart() && !this.type) 479 ret.unshift([]); 480 if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && __privateGet(this, _parent)?.type === "!")) { 481 ret.push({}); 482 } 483 return ret; 484 } 485 isStart() { 486 if (__privateGet(this, _root) === this) 487 return true; 488 if (!__privateGet(this, _parent)?.isStart()) 489 return false; 490 if (__privateGet(this, _parentIndex) === 0) 491 return true; 492 const p = __privateGet(this, _parent); 493 for (let i = 0; i < __privateGet(this, _parentIndex); i++) { 494 const pp = __privateGet(p, _parts)[i]; 495 if (!(pp instanceof _AST && pp.type === "!")) { 496 return false; 497 } 498 } 499 return true; 500 } 501 isEnd() { 502 if (__privateGet(this, _root) === this) 503 return true; 504 if (__privateGet(this, _parent)?.type === "!") 505 return true; 506 if (!__privateGet(this, _parent)?.isEnd()) 507 return false; 508 if (!this.type) 509 return __privateGet(this, _parent)?.isEnd(); 510 const pl = __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0; 511 return __privateGet(this, _parentIndex) === pl - 1; 512 } 513 copyIn(part) { 514 if (typeof part === "string") 515 this.push(part); 516 else 517 this.push(part.clone(this)); 518 } 519 clone(parent) { 520 const c = new _AST(this.type, parent); 521 for (const p of __privateGet(this, _parts)) { 522 c.copyIn(p); 523 } 524 return c; 525 } 526 static fromGlob(pattern, options = {}) { 527 var _a; 528 const ast = new _AST(null, void 0, options); 529 __privateMethod(_a = _AST, _parseAST, parseAST_fn).call(_a, pattern, ast, 0, options); 530 return ast; 531 } 532 // returns the regular expression if there's magic, or the unescaped 533 // string if not. 534 toMMPattern() { 535 if (this !== __privateGet(this, _root)) 536 return __privateGet(this, _root).toMMPattern(); 537 const glob = this.toString(); 538 const [re, body, hasMagic, uflag] = this.toRegExpSource(); 539 const anyMagic = hasMagic || __privateGet(this, _hasMagic) || __privateGet(this, _options).nocase && !__privateGet(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase(); 540 if (!anyMagic) { 541 return body; 542 } 543 const flags = (__privateGet(this, _options).nocase ? "i" : "") + (uflag ? "u" : ""); 544 return Object.assign(new RegExp(`^${re}$`, flags), { 545 _src: re, 546 _glob: glob 547 }); 548 } 549 // returns the string match, the regexp source, whether there's magic 550 // in the regexp (so a regular expression is required) and whether or 551 // not the uflag is needed for the regular expression (for posix classes) 552 // TODO: instead of injecting the start/end at this point, just return 553 // the BODY of the regexp, along with the start/end portions suitable 554 // for binding the start/end in either a joined full-path makeRe context 555 // (where we bind to (^|/), or a standalone matchPart context (where 556 // we bind to ^, and not /). Otherwise slashes get duped! 557 // 558 // In part-matching mode, the start is: 559 // - if not isStart: nothing 560 // - if traversal possible, but not allowed: ^(?!\.\.?$) 561 // - if dots allowed or not possible: ^ 562 // - if dots possible and not allowed: ^(?!\.) 563 // end is: 564 // - if not isEnd(): nothing 565 // - else: $ 566 // 567 // In full-path matching mode, we put the slash at the START of the 568 // pattern, so start is: 569 // - if first pattern: same as part-matching mode 570 // - if not isStart(): nothing 571 // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/)) 572 // - if dots allowed or not possible: / 573 // - if dots possible and not allowed: /(?!\.) 574 // end is: 575 // - if last pattern, same as part-matching mode 576 // - else nothing 577 // 578 // Always put the (?:$|/) on negated tails, though, because that has to be 579 // there to bind the end of the negated pattern portion, and it's easier to 580 // just stick it in now rather than try to inject it later in the middle of 581 // the pattern. 582 // 583 // We can just always return the same end, and leave it up to the caller 584 // to know whether it's going to be used joined or in parts. 585 // And, if the start is adjusted slightly, can do the same there: 586 // - if not isStart: nothing 587 // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$) 588 // - if dots allowed or not possible: (?:/|^) 589 // - if dots possible and not allowed: (?:/|^)(?!\.) 590 // 591 // But it's better to have a simpler binding without a conditional, for 592 // performance, so probably better to return both start options. 593 // 594 // Then the caller just ignores the end if it's not the first pattern, 595 // and the start always gets applied. 596 // 597 // But that's always going to be $ if it's the ending pattern, or nothing, 598 // so the caller can just attach $ at the end of the pattern when building. 599 // 600 // So the todo is: 601 // - better detect what kind of start is needed 602 // - return both flavors of starting pattern 603 // - attach $ at the end of the pattern when creating the actual RegExp 604 // 605 // Ah, but wait, no, that all only applies to the root when the first pattern 606 // is not an extglob. If the first pattern IS an extglob, then we need all 607 // that dot prevention biz to live in the extglob portions, because eg 608 // +(*|.x*) can match .xy but not .yx. 609 // 610 // So, return the two flavors if it's #root and the first child is not an 611 // AST, otherwise leave it to the child AST to handle it, and there, 612 // use the (?:^|/) style of start binding. 613 // 614 // Even simplified further: 615 // - Since the start for a join is eg /(?!\.) and the start for a part 616 // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root 617 // or start or whatever) and prepend ^ or / at the Regexp construction. 618 toRegExpSource(allowDot) { 619 const dot = allowDot ?? !!__privateGet(this, _options).dot; 620 if (__privateGet(this, _root) === this) 621 __privateMethod(this, _fillNegs, fillNegs_fn).call(this); 622 if (!this.type) { 623 const noEmpty = this.isStart() && this.isEnd(); 624 const src = __privateGet(this, _parts).map((p) => { 625 var _a; 626 const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a = _AST, _parseGlob, parseGlob_fn).call(_a, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot); 627 __privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic); 628 __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag); 629 return re; 630 }).join(""); 631 let start2 = ""; 632 if (this.isStart()) { 633 if (typeof __privateGet(this, _parts)[0] === "string") { 634 const dotTravAllowed = __privateGet(this, _parts).length === 1 && justDots.has(__privateGet(this, _parts)[0]); 635 if (!dotTravAllowed) { 636 const aps = addPatternStart; 637 const needNoTrav = ( 638 // dots are allowed, and the pattern starts with [ or . 639 dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or . 640 src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or . 641 src.startsWith("\\.\\.") && aps.has(src.charAt(4)) 642 ); 643 const needNoDot = !dot && !allowDot && aps.has(src.charAt(0)); 644 start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : ""; 645 } 646 } 647 } 648 let end = ""; 649 if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && __privateGet(this, _parent)?.type === "!") { 650 end = "(?:$|\\/)"; 651 } 652 const final2 = start2 + src + end; 653 return [ 654 final2, 655 (0, unescape_js_12.unescape)(src), 656 __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)), 657 __privateGet(this, _uflag) 658 ]; 659 } 660 const repeated = this.type === "*" || this.type === "+"; 661 const start = this.type === "!" ? "(?:(?!(?:" : "(?:"; 662 let body = __privateMethod(this, _partsToRegExp, partsToRegExp_fn).call(this, dot); 663 if (this.isStart() && this.isEnd() && !body && this.type !== "!") { 664 const s = this.toString(); 665 __privateSet(this, _parts, [s]); 666 this.type = null; 667 __privateSet(this, _hasMagic, void 0); 668 return [s, (0, unescape_js_12.unescape)(this.toString()), false, false]; 669 } 670 let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _partsToRegExp, partsToRegExp_fn).call(this, true); 671 if (bodyDotAllowed === body) { 672 bodyDotAllowed = ""; 673 } 674 if (bodyDotAllowed) { 675 body = `(?:${body})(?:${bodyDotAllowed})*?`; 676 } 677 let final = ""; 678 if (this.type === "!" && __privateGet(this, _emptyExt)) { 679 final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty; 680 } else { 681 const close = this.type === "!" ? ( 682 // !() must match something,but !(x) can match '' 683 "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star2 + ")" 684 ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`; 685 final = start + body + close; 686 } 687 return [ 688 final, 689 (0, unescape_js_12.unescape)(body), 690 __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)), 691 __privateGet(this, _uflag) 692 ]; 693 } 694 }; 695 var AST = _AST; 696 _root = new WeakMap(); 697 _hasMagic = new WeakMap(); 698 _uflag = new WeakMap(); 699 _parts = new WeakMap(); 700 _parent = new WeakMap(); 701 _parentIndex = new WeakMap(); 702 _negs = new WeakMap(); 703 _filledNegs = new WeakMap(); 704 _options = new WeakMap(); 705 _toString = new WeakMap(); 706 _emptyExt = new WeakMap(); 707 _fillNegs = new WeakSet(); 708 fillNegs_fn = function() { 709 if (this !== __privateGet(this, _root)) 710 throw new Error("should only call on root"); 711 if (__privateGet(this, _filledNegs)) 712 return this; 713 this.toString(); 714 __privateSet(this, _filledNegs, true); 715 let n; 716 while (n = __privateGet(this, _negs).pop()) { 717 if (n.type !== "!") 718 continue; 719 let p = n; 720 let pp = __privateGet(p, _parent); 721 while (pp) { 722 for (let i = __privateGet(p, _parentIndex) + 1; !pp.type && i < __privateGet(pp, _parts).length; i++) { 723 for (const part of __privateGet(n, _parts)) { 724 if (typeof part === "string") { 725 throw new Error("string part in extglob AST??"); 726 } 727 part.copyIn(__privateGet(pp, _parts)[i]); 728 } 729 } 730 p = pp; 731 pp = __privateGet(p, _parent); 732 } 733 } 734 return this; 735 }; 736 _parseAST = new WeakSet(); 737 parseAST_fn = function(str, ast, pos, opt) { 738 var _a, _b; 739 let escaping = false; 740 let inBrace = false; 741 let braceStart = -1; 742 let braceNeg = false; 743 if (ast.type === null) { 744 let i2 = pos; 745 let acc2 = ""; 746 while (i2 < str.length) { 747 const c = str.charAt(i2++); 748 if (escaping || c === "\\") { 749 escaping = !escaping; 750 acc2 += c; 751 continue; 752 } 753 if (inBrace) { 754 if (i2 === braceStart + 1) { 755 if (c === "^" || c === "!") { 756 braceNeg = true; 757 } 758 } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) { 759 inBrace = false; 760 } 761 acc2 += c; 762 continue; 763 } else if (c === "[") { 764 inBrace = true; 765 braceStart = i2; 766 braceNeg = false; 767 acc2 += c; 768 continue; 769 } 770 if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") { 771 ast.push(acc2); 772 acc2 = ""; 773 const ext2 = new _AST(c, ast); 774 i2 = __privateMethod(_a = _AST, _parseAST, parseAST_fn).call(_a, str, ext2, i2, opt); 775 ast.push(ext2); 776 continue; 777 } 778 acc2 += c; 779 } 780 ast.push(acc2); 781 return i2; 782 } 783 let i = pos + 1; 784 let part = new _AST(null, ast); 785 const parts = []; 786 let acc = ""; 787 while (i < str.length) { 788 const c = str.charAt(i++); 789 if (escaping || c === "\\") { 790 escaping = !escaping; 791 acc += c; 792 continue; 793 } 794 if (inBrace) { 795 if (i === braceStart + 1) { 796 if (c === "^" || c === "!") { 797 braceNeg = true; 798 } 799 } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) { 800 inBrace = false; 801 } 802 acc += c; 803 continue; 804 } else if (c === "[") { 805 inBrace = true; 806 braceStart = i; 807 braceNeg = false; 808 acc += c; 809 continue; 810 } 811 if (isExtglobType(c) && str.charAt(i) === "(") { 812 part.push(acc); 813 acc = ""; 814 const ext2 = new _AST(c, part); 815 part.push(ext2); 816 i = __privateMethod(_b = _AST, _parseAST, parseAST_fn).call(_b, str, ext2, i, opt); 817 continue; 818 } 819 if (c === "|") { 820 part.push(acc); 821 acc = ""; 822 parts.push(part); 823 part = new _AST(null, ast); 824 continue; 825 } 826 if (c === ")") { 827 if (acc === "" && __privateGet(ast, _parts).length === 0) { 828 __privateSet(ast, _emptyExt, true); 829 } 830 part.push(acc); 831 acc = ""; 832 ast.push(...parts, part); 833 return i; 834 } 835 acc += c; 836 } 837 ast.type = null; 838 __privateSet(ast, _hasMagic, void 0); 839 __privateSet(ast, _parts, [str.substring(pos - 1)]); 840 return i; 841 }; 842 _partsToRegExp = new WeakSet(); 843 partsToRegExp_fn = function(dot) { 844 return __privateGet(this, _parts).map((p) => { 845 if (typeof p === "string") { 846 throw new Error("string type in extglob ast??"); 847 } 848 const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot); 849 __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag); 850 return re; 851 }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|"); 852 }; 853 _parseGlob = new WeakSet(); 854 parseGlob_fn = function(glob, hasMagic, noEmpty = false) { 855 let escaping = false; 856 let re = ""; 857 let uflag = false; 858 for (let i = 0; i < glob.length; i++) { 859 const c = glob.charAt(i); 860 if (escaping) { 861 escaping = false; 862 re += (reSpecials.has(c) ? "\\" : "") + c; 863 continue; 864 } 865 if (c === "\\") { 866 if (i === glob.length - 1) { 867 re += "\\\\"; 868 } else { 869 escaping = true; 870 } 871 continue; 872 } 873 if (c === "[") { 874 const [src, needUflag, consumed, magic] = (0, brace_expressions_js_1.parseClass)(glob, i); 875 if (consumed) { 876 re += src; 877 uflag = uflag || needUflag; 878 i += consumed - 1; 879 hasMagic = hasMagic || magic; 880 continue; 881 } 882 } 883 if (c === "*") { 884 if (noEmpty && glob === "*") 885 re += starNoEmpty; 886 else 887 re += star2; 888 hasMagic = true; 889 continue; 890 } 891 if (c === "?") { 892 re += qmark2; 893 hasMagic = true; 894 continue; 895 } 896 re += regExpEscape2(c); 897 } 898 return [re, (0, unescape_js_12.unescape)(glob), !!hasMagic, uflag]; 899 }; 900 __privateAdd(AST, _parseAST); 901 __privateAdd(AST, _parseGlob); 902 exports2.AST = AST; 903 } 904}); 905 906// dist/cjs/escape.js 907var require_escape = __commonJS({ 908 "dist/cjs/escape.js"(exports2) { 909 "use strict"; 910 Object.defineProperty(exports2, "__esModule", { value: true }); 911 exports2.escape = void 0; 912 var escape = (s, { windowsPathsNoEscape = false } = {}) => { 913 return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"); 914 }; 915 exports2.escape = escape; 916 } 917}); 918 919// dist/cjs/index.js 920var __importDefault = exports && exports.__importDefault || function(mod) { 921 return mod && mod.__esModule ? mod : { "default": mod }; 922}; 923Object.defineProperty(exports, "__esModule", { value: true }); 924exports.unescape = exports.escape = exports.AST = exports.Minimatch = exports.match = exports.makeRe = exports.braceExpand = exports.defaults = exports.filter = exports.GLOBSTAR = exports.sep = exports.minimatch = void 0; 925var brace_expansion_1 = __importDefault(require_brace_expansion()); 926var assert_valid_pattern_js_1 = require_assert_valid_pattern(); 927var ast_js_1 = require_ast(); 928var escape_js_1 = require_escape(); 929var unescape_js_1 = require_unescape(); 930var minimatch = (p, pattern, options = {}) => { 931 (0, assert_valid_pattern_js_1.assertValidPattern)(pattern); 932 if (!options.nocomment && pattern.charAt(0) === "#") { 933 return false; 934 } 935 return new Minimatch(pattern, options).match(p); 936}; 937exports.minimatch = minimatch; 938var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/; 939var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2); 940var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2); 941var starDotExtTestNocase = (ext2) => { 942 ext2 = ext2.toLowerCase(); 943 return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2); 944}; 945var starDotExtTestNocaseDot = (ext2) => { 946 ext2 = ext2.toLowerCase(); 947 return (f) => f.toLowerCase().endsWith(ext2); 948}; 949var starDotStarRE = /^\*+\.\*+$/; 950var starDotStarTest = (f) => !f.startsWith(".") && f.includes("."); 951var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes("."); 952var dotStarRE = /^\.\*+$/; 953var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith("."); 954var starRE = /^\*+$/; 955var starTest = (f) => f.length !== 0 && !f.startsWith("."); 956var starTestDot = (f) => f.length !== 0 && f !== "." && f !== ".."; 957var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/; 958var qmarksTestNocase = ([$0, ext2 = ""]) => { 959 const noext = qmarksTestNoExt([$0]); 960 if (!ext2) 961 return noext; 962 ext2 = ext2.toLowerCase(); 963 return (f) => noext(f) && f.toLowerCase().endsWith(ext2); 964}; 965var qmarksTestNocaseDot = ([$0, ext2 = ""]) => { 966 const noext = qmarksTestNoExtDot([$0]); 967 if (!ext2) 968 return noext; 969 ext2 = ext2.toLowerCase(); 970 return (f) => noext(f) && f.toLowerCase().endsWith(ext2); 971}; 972var qmarksTestDot = ([$0, ext2 = ""]) => { 973 const noext = qmarksTestNoExtDot([$0]); 974 return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2); 975}; 976var qmarksTest = ([$0, ext2 = ""]) => { 977 const noext = qmarksTestNoExt([$0]); 978 return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2); 979}; 980var qmarksTestNoExt = ([$0]) => { 981 const len = $0.length; 982 return (f) => f.length === len && !f.startsWith("."); 983}; 984var qmarksTestNoExtDot = ([$0]) => { 985 const len = $0.length; 986 return (f) => f.length === len && f !== "." && f !== ".."; 987}; 988var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix"; 989var path = { 990 win32: { sep: "\\" }, 991 posix: { sep: "/" } 992}; 993exports.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep; 994exports.minimatch.sep = exports.sep; 995exports.GLOBSTAR = Symbol("globstar **"); 996exports.minimatch.GLOBSTAR = exports.GLOBSTAR; 997var qmark = "[^/]"; 998var star = qmark + "*?"; 999var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?"; 1000var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?"; 1001var filter = (pattern, options = {}) => (p) => (0, exports.minimatch)(p, pattern, options); 1002exports.filter = filter; 1003exports.minimatch.filter = exports.filter; 1004var ext = (a, b = {}) => Object.assign({}, a, b); 1005var defaults = (def) => { 1006 if (!def || typeof def !== "object" || !Object.keys(def).length) { 1007 return exports.minimatch; 1008 } 1009 const orig = exports.minimatch; 1010 const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options)); 1011 return Object.assign(m, { 1012 Minimatch: class Minimatch extends orig.Minimatch { 1013 constructor(pattern, options = {}) { 1014 super(pattern, ext(def, options)); 1015 } 1016 static defaults(options) { 1017 return orig.defaults(ext(def, options)).Minimatch; 1018 } 1019 }, 1020 AST: class AST extends orig.AST { 1021 /* c8 ignore start */ 1022 constructor(type, parent, options = {}) { 1023 super(type, parent, ext(def, options)); 1024 } 1025 /* c8 ignore stop */ 1026 static fromGlob(pattern, options = {}) { 1027 return orig.AST.fromGlob(pattern, ext(def, options)); 1028 } 1029 }, 1030 unescape: (s, options = {}) => orig.unescape(s, ext(def, options)), 1031 escape: (s, options = {}) => orig.escape(s, ext(def, options)), 1032 filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)), 1033 defaults: (options) => orig.defaults(ext(def, options)), 1034 makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)), 1035 braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)), 1036 match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)), 1037 sep: orig.sep, 1038 GLOBSTAR: exports.GLOBSTAR 1039 }); 1040}; 1041exports.defaults = defaults; 1042exports.minimatch.defaults = exports.defaults; 1043var braceExpand = (pattern, options = {}) => { 1044 (0, assert_valid_pattern_js_1.assertValidPattern)(pattern); 1045 if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) { 1046 return [pattern]; 1047 } 1048 return (0, brace_expansion_1.default)(pattern); 1049}; 1050exports.braceExpand = braceExpand; 1051exports.minimatch.braceExpand = exports.braceExpand; 1052var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe(); 1053exports.makeRe = makeRe; 1054exports.minimatch.makeRe = exports.makeRe; 1055var match = (list, pattern, options = {}) => { 1056 const mm = new Minimatch(pattern, options); 1057 list = list.filter((f) => mm.match(f)); 1058 if (mm.options.nonull && !list.length) { 1059 list.push(pattern); 1060 } 1061 return list; 1062}; 1063exports.match = match; 1064exports.minimatch.match = exports.match; 1065var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/; 1066var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 1067var Minimatch = class { 1068 options; 1069 set; 1070 pattern; 1071 windowsPathsNoEscape; 1072 nonegate; 1073 negate; 1074 comment; 1075 empty; 1076 preserveMultipleSlashes; 1077 partial; 1078 globSet; 1079 globParts; 1080 nocase; 1081 isWindows; 1082 platform; 1083 windowsNoMagicRoot; 1084 regexp; 1085 constructor(pattern, options = {}) { 1086 (0, assert_valid_pattern_js_1.assertValidPattern)(pattern); 1087 options = options || {}; 1088 this.options = options; 1089 this.pattern = pattern; 1090 this.platform = options.platform || defaultPlatform; 1091 this.isWindows = this.platform === "win32"; 1092 this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false; 1093 if (this.windowsPathsNoEscape) { 1094 this.pattern = this.pattern.replace(/\\/g, "/"); 1095 } 1096 this.preserveMultipleSlashes = !!options.preserveMultipleSlashes; 1097 this.regexp = null; 1098 this.negate = false; 1099 this.nonegate = !!options.nonegate; 1100 this.comment = false; 1101 this.empty = false; 1102 this.partial = !!options.partial; 1103 this.nocase = !!this.options.nocase; 1104 this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase); 1105 this.globSet = []; 1106 this.globParts = []; 1107 this.set = []; 1108 this.make(); 1109 } 1110 hasMagic() { 1111 if (this.options.magicalBraces && this.set.length > 1) { 1112 return true; 1113 } 1114 for (const pattern of this.set) { 1115 for (const part of pattern) { 1116 if (typeof part !== "string") 1117 return true; 1118 } 1119 } 1120 return false; 1121 } 1122 debug(..._) { 1123 } 1124 make() { 1125 const pattern = this.pattern; 1126 const options = this.options; 1127 if (!options.nocomment && pattern.charAt(0) === "#") { 1128 this.comment = true; 1129 return; 1130 } 1131 if (!pattern) { 1132 this.empty = true; 1133 return; 1134 } 1135 this.parseNegate(); 1136 this.globSet = [...new Set(this.braceExpand())]; 1137 if (options.debug) { 1138 this.debug = (...args) => console.error(...args); 1139 } 1140 this.debug(this.pattern, this.globSet); 1141 const rawGlobParts = this.globSet.map((s) => this.slashSplit(s)); 1142 this.globParts = this.preprocess(rawGlobParts); 1143 this.debug(this.pattern, this.globParts); 1144 let set = this.globParts.map((s, _, __) => { 1145 if (this.isWindows && this.windowsNoMagicRoot) { 1146 const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]); 1147 const isDrive = /^[a-z]:/i.test(s[0]); 1148 if (isUNC) { 1149 return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))]; 1150 } else if (isDrive) { 1151 return [s[0], ...s.slice(1).map((ss) => this.parse(ss))]; 1152 } 1153 } 1154 return s.map((ss) => this.parse(ss)); 1155 }); 1156 this.debug(this.pattern, set); 1157 this.set = set.filter((s) => s.indexOf(false) === -1); 1158 if (this.isWindows) { 1159 for (let i = 0; i < this.set.length; i++) { 1160 const p = this.set[i]; 1161 if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) { 1162 p[2] = "?"; 1163 } 1164 } 1165 } 1166 this.debug(this.pattern, this.set); 1167 } 1168 // various transforms to equivalent pattern sets that are 1169 // faster to process in a filesystem walk. The goal is to 1170 // eliminate what we can, and push all ** patterns as far 1171 // to the right as possible, even if it increases the number 1172 // of patterns that we have to process. 1173 preprocess(globParts) { 1174 if (this.options.noglobstar) { 1175 for (let i = 0; i < globParts.length; i++) { 1176 for (let j = 0; j < globParts[i].length; j++) { 1177 if (globParts[i][j] === "**") { 1178 globParts[i][j] = "*"; 1179 } 1180 } 1181 } 1182 } 1183 const { optimizationLevel = 1 } = this.options; 1184 if (optimizationLevel >= 2) { 1185 globParts = this.firstPhasePreProcess(globParts); 1186 globParts = this.secondPhasePreProcess(globParts); 1187 } else if (optimizationLevel >= 1) { 1188 globParts = this.levelOneOptimize(globParts); 1189 } else { 1190 globParts = this.adjascentGlobstarOptimize(globParts); 1191 } 1192 return globParts; 1193 } 1194 // just get rid of adjascent ** portions 1195 adjascentGlobstarOptimize(globParts) { 1196 return globParts.map((parts) => { 1197 let gs = -1; 1198 while (-1 !== (gs = parts.indexOf("**", gs + 1))) { 1199 let i = gs; 1200 while (parts[i + 1] === "**") { 1201 i++; 1202 } 1203 if (i !== gs) { 1204 parts.splice(gs, i - gs); 1205 } 1206 } 1207 return parts; 1208 }); 1209 } 1210 // get rid of adjascent ** and resolve .. portions 1211 levelOneOptimize(globParts) { 1212 return globParts.map((parts) => { 1213 parts = parts.reduce((set, part) => { 1214 const prev = set[set.length - 1]; 1215 if (part === "**" && prev === "**") { 1216 return set; 1217 } 1218 if (part === "..") { 1219 if (prev && prev !== ".." && prev !== "." && prev !== "**") { 1220 set.pop(); 1221 return set; 1222 } 1223 } 1224 set.push(part); 1225 return set; 1226 }, []); 1227 return parts.length === 0 ? [""] : parts; 1228 }); 1229 } 1230 levelTwoFileOptimize(parts) { 1231 if (!Array.isArray(parts)) { 1232 parts = this.slashSplit(parts); 1233 } 1234 let didSomething = false; 1235 do { 1236 didSomething = false; 1237 if (!this.preserveMultipleSlashes) { 1238 for (let i = 1; i < parts.length - 1; i++) { 1239 const p = parts[i]; 1240 if (i === 1 && p === "" && parts[0] === "") 1241 continue; 1242 if (p === "." || p === "") { 1243 didSomething = true; 1244 parts.splice(i, 1); 1245 i--; 1246 } 1247 } 1248 if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) { 1249 didSomething = true; 1250 parts.pop(); 1251 } 1252 } 1253 let dd = 0; 1254 while (-1 !== (dd = parts.indexOf("..", dd + 1))) { 1255 const p = parts[dd - 1]; 1256 if (p && p !== "." && p !== ".." && p !== "**") { 1257 didSomething = true; 1258 parts.splice(dd - 1, 2); 1259 dd -= 2; 1260 } 1261 } 1262 } while (didSomething); 1263 return parts.length === 0 ? [""] : parts; 1264 } 1265 // First phase: single-pattern processing 1266 // <pre> is 1 or more portions 1267 // <rest> is 1 or more portions 1268 // <p> is any portion other than ., .., '', or ** 1269 // <e> is . or '' 1270 // 1271 // **/.. is *brutal* for filesystem walking performance, because 1272 // it effectively resets the recursive walk each time it occurs, 1273 // and ** cannot be reduced out by a .. pattern part like a regexp 1274 // or most strings (other than .., ., and '') can be. 1275 // 1276 // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>} 1277 // <pre>/<e>/<rest> -> <pre>/<rest> 1278 // <pre>/<p>/../<rest> -> <pre>/<rest> 1279 // **/**/<rest> -> **/<rest> 1280 // 1281 // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow 1282 // this WOULD be allowed if ** did follow symlinks, or * didn't 1283 firstPhasePreProcess(globParts) { 1284 let didSomething = false; 1285 do { 1286 didSomething = false; 1287 for (let parts of globParts) { 1288 let gs = -1; 1289 while (-1 !== (gs = parts.indexOf("**", gs + 1))) { 1290 let gss = gs; 1291 while (parts[gss + 1] === "**") { 1292 gss++; 1293 } 1294 if (gss > gs) { 1295 parts.splice(gs + 1, gss - gs); 1296 } 1297 let next = parts[gs + 1]; 1298 const p = parts[gs + 2]; 1299 const p2 = parts[gs + 3]; 1300 if (next !== "..") 1301 continue; 1302 if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") { 1303 continue; 1304 } 1305 didSomething = true; 1306 parts.splice(gs, 1); 1307 const other = parts.slice(0); 1308 other[gs] = "**"; 1309 globParts.push(other); 1310 gs--; 1311 } 1312 if (!this.preserveMultipleSlashes) { 1313 for (let i = 1; i < parts.length - 1; i++) { 1314 const p = parts[i]; 1315 if (i === 1 && p === "" && parts[0] === "") 1316 continue; 1317 if (p === "." || p === "") { 1318 didSomething = true; 1319 parts.splice(i, 1); 1320 i--; 1321 } 1322 } 1323 if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) { 1324 didSomething = true; 1325 parts.pop(); 1326 } 1327 } 1328 let dd = 0; 1329 while (-1 !== (dd = parts.indexOf("..", dd + 1))) { 1330 const p = parts[dd - 1]; 1331 if (p && p !== "." && p !== ".." && p !== "**") { 1332 didSomething = true; 1333 const needDot = dd === 1 && parts[dd + 1] === "**"; 1334 const splin = needDot ? ["."] : []; 1335 parts.splice(dd - 1, 2, ...splin); 1336 if (parts.length === 0) 1337 parts.push(""); 1338 dd -= 2; 1339 } 1340 } 1341 } 1342 } while (didSomething); 1343 return globParts; 1344 } 1345 // second phase: multi-pattern dedupes 1346 // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest> 1347 // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest> 1348 // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest> 1349 // 1350 // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest> 1351 // ^-- not valid because ** doens't follow symlinks 1352 secondPhasePreProcess(globParts) { 1353 for (let i = 0; i < globParts.length - 1; i++) { 1354 for (let j = i + 1; j < globParts.length; j++) { 1355 const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes); 1356 if (!matched) 1357 continue; 1358 globParts[i] = matched; 1359 globParts[j] = []; 1360 } 1361 } 1362 return globParts.filter((gs) => gs.length); 1363 } 1364 partsMatch(a, b, emptyGSMatch = false) { 1365 let ai = 0; 1366 let bi = 0; 1367 let result = []; 1368 let which = ""; 1369 while (ai < a.length && bi < b.length) { 1370 if (a[ai] === b[bi]) { 1371 result.push(which === "b" ? b[bi] : a[ai]); 1372 ai++; 1373 bi++; 1374 } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) { 1375 result.push(a[ai]); 1376 ai++; 1377 } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) { 1378 result.push(b[bi]); 1379 bi++; 1380 } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") { 1381 if (which === "b") 1382 return false; 1383 which = "a"; 1384 result.push(a[ai]); 1385 ai++; 1386 bi++; 1387 } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") { 1388 if (which === "a") 1389 return false; 1390 which = "b"; 1391 result.push(b[bi]); 1392 ai++; 1393 bi++; 1394 } else { 1395 return false; 1396 } 1397 } 1398 return a.length === b.length && result; 1399 } 1400 parseNegate() { 1401 if (this.nonegate) 1402 return; 1403 const pattern = this.pattern; 1404 let negate = false; 1405 let negateOffset = 0; 1406 for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) { 1407 negate = !negate; 1408 negateOffset++; 1409 } 1410 if (negateOffset) 1411 this.pattern = pattern.slice(negateOffset); 1412 this.negate = negate; 1413 } 1414 // set partial to true to test if, for example, 1415 // "/a/b" matches the start of "/*/b/*/d" 1416 // Partial means, if you run out of file before you run 1417 // out of pattern, then that's fine, as long as all 1418 // the parts match. 1419 matchOne(file, pattern, partial = false) { 1420 const options = this.options; 1421 if (this.isWindows) { 1422 const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]); 1423 const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]); 1424 const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]); 1425 const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]); 1426 const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0; 1427 const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0; 1428 if (typeof fdi === "number" && typeof pdi === "number") { 1429 const [fd, pd] = [file[fdi], pattern[pdi]]; 1430 if (fd.toLowerCase() === pd.toLowerCase()) { 1431 pattern[pdi] = fd; 1432 if (pdi > fdi) { 1433 pattern = pattern.slice(pdi); 1434 } else if (fdi > pdi) { 1435 file = file.slice(fdi); 1436 } 1437 } 1438 } 1439 } 1440 const { optimizationLevel = 1 } = this.options; 1441 if (optimizationLevel >= 2) { 1442 file = this.levelTwoFileOptimize(file); 1443 } 1444 this.debug("matchOne", this, { file, pattern }); 1445 this.debug("matchOne", file.length, pattern.length); 1446 for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) { 1447 this.debug("matchOne loop"); 1448 var p = pattern[pi]; 1449 var f = file[fi]; 1450 this.debug(pattern, p, f); 1451 if (p === false) { 1452 return false; 1453 } 1454 if (p === exports.GLOBSTAR) { 1455 this.debug("GLOBSTAR", [pattern, p, f]); 1456 var fr = fi; 1457 var pr = pi + 1; 1458 if (pr === pl) { 1459 this.debug("** at the end"); 1460 for (; fi < fl; fi++) { 1461 if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") 1462 return false; 1463 } 1464 return true; 1465 } 1466 while (fr < fl) { 1467 var swallowee = file[fr]; 1468 this.debug("\nglobstar while", file, fr, pattern, pr, swallowee); 1469 if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { 1470 this.debug("globstar found match!", fr, fl, swallowee); 1471 return true; 1472 } else { 1473 if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") { 1474 this.debug("dot detected!", file, fr, pattern, pr); 1475 break; 1476 } 1477 this.debug("globstar swallow a segment, and continue"); 1478 fr++; 1479 } 1480 } 1481 if (partial) { 1482 this.debug("\n>>> no match, partial?", file, fr, pattern, pr); 1483 if (fr === fl) { 1484 return true; 1485 } 1486 } 1487 return false; 1488 } 1489 let hit; 1490 if (typeof p === "string") { 1491 hit = f === p; 1492 this.debug("string match", p, f, hit); 1493 } else { 1494 hit = p.test(f); 1495 this.debug("pattern match", p, f, hit); 1496 } 1497 if (!hit) 1498 return false; 1499 } 1500 if (fi === fl && pi === pl) { 1501 return true; 1502 } else if (fi === fl) { 1503 return partial; 1504 } else if (pi === pl) { 1505 return fi === fl - 1 && file[fi] === ""; 1506 } else { 1507 throw new Error("wtf?"); 1508 } 1509 } 1510 braceExpand() { 1511 return (0, exports.braceExpand)(this.pattern, this.options); 1512 } 1513 parse(pattern) { 1514 (0, assert_valid_pattern_js_1.assertValidPattern)(pattern); 1515 const options = this.options; 1516 if (pattern === "**") 1517 return exports.GLOBSTAR; 1518 if (pattern === "") 1519 return ""; 1520 let m; 1521 let fastTest = null; 1522 if (m = pattern.match(starRE)) { 1523 fastTest = options.dot ? starTestDot : starTest; 1524 } else if (m = pattern.match(starDotExtRE)) { 1525 fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]); 1526 } else if (m = pattern.match(qmarksRE)) { 1527 fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m); 1528 } else if (m = pattern.match(starDotStarRE)) { 1529 fastTest = options.dot ? starDotStarTestDot : starDotStarTest; 1530 } else if (m = pattern.match(dotStarRE)) { 1531 fastTest = dotStarTest; 1532 } 1533 const re = ast_js_1.AST.fromGlob(pattern, this.options).toMMPattern(); 1534 return fastTest ? Object.assign(re, { test: fastTest }) : re; 1535 } 1536 makeRe() { 1537 if (this.regexp || this.regexp === false) 1538 return this.regexp; 1539 const set = this.set; 1540 if (!set.length) { 1541 this.regexp = false; 1542 return this.regexp; 1543 } 1544 const options = this.options; 1545 const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot; 1546 const flags = new Set(options.nocase ? ["i"] : []); 1547 let re = set.map((pattern) => { 1548 const pp = pattern.map((p) => { 1549 if (p instanceof RegExp) { 1550 for (const f of p.flags.split("")) 1551 flags.add(f); 1552 } 1553 return typeof p === "string" ? regExpEscape(p) : p === exports.GLOBSTAR ? exports.GLOBSTAR : p._src; 1554 }); 1555 pp.forEach((p, i) => { 1556 const next = pp[i + 1]; 1557 const prev = pp[i - 1]; 1558 if (p !== exports.GLOBSTAR || prev === exports.GLOBSTAR) { 1559 return; 1560 } 1561 if (prev === void 0) { 1562 if (next !== void 0 && next !== exports.GLOBSTAR) { 1563 pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next; 1564 } else { 1565 pp[i] = twoStar; 1566 } 1567 } else if (next === void 0) { 1568 pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?"; 1569 } else if (next !== exports.GLOBSTAR) { 1570 pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next; 1571 pp[i + 1] = exports.GLOBSTAR; 1572 } 1573 }); 1574 return pp.filter((p) => p !== exports.GLOBSTAR).join("/"); 1575 }).join("|"); 1576 const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""]; 1577 re = "^" + open + re + close + "$"; 1578 if (this.negate) 1579 re = "^(?!" + re + ").+$"; 1580 try { 1581 this.regexp = new RegExp(re, [...flags].join("")); 1582 } catch (ex) { 1583 this.regexp = false; 1584 } 1585 return this.regexp; 1586 } 1587 slashSplit(p) { 1588 if (this.preserveMultipleSlashes) { 1589 return p.split("/"); 1590 } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) { 1591 return ["", ...p.split(/\/+/)]; 1592 } else { 1593 return p.split(/\/+/); 1594 } 1595 } 1596 match(f, partial = this.partial) { 1597 this.debug("match", f, this.pattern); 1598 if (this.comment) { 1599 return false; 1600 } 1601 if (this.empty) { 1602 return f === ""; 1603 } 1604 if (f === "/" && partial) { 1605 return true; 1606 } 1607 const options = this.options; 1608 if (this.isWindows) { 1609 f = f.split("\\").join("/"); 1610 } 1611 const ff = this.slashSplit(f); 1612 this.debug(this.pattern, "split", ff); 1613 const set = this.set; 1614 this.debug(this.pattern, "set", set); 1615 let filename = ff[ff.length - 1]; 1616 if (!filename) { 1617 for (let i = ff.length - 2; !filename && i >= 0; i--) { 1618 filename = ff[i]; 1619 } 1620 } 1621 for (let i = 0; i < set.length; i++) { 1622 const pattern = set[i]; 1623 let file = ff; 1624 if (options.matchBase && pattern.length === 1) { 1625 file = [filename]; 1626 } 1627 const hit = this.matchOne(file, pattern, partial); 1628 if (hit) { 1629 if (options.flipNegate) { 1630 return true; 1631 } 1632 return !this.negate; 1633 } 1634 } 1635 if (options.flipNegate) { 1636 return false; 1637 } 1638 return this.negate; 1639 } 1640 static defaults(def) { 1641 return exports.minimatch.defaults(def).Minimatch; 1642 } 1643}; 1644exports.Minimatch = Minimatch; 1645var ast_js_2 = require_ast(); 1646Object.defineProperty(exports, "AST", { enumerable: true, get: function() { 1647 return ast_js_2.AST; 1648} }); 1649var escape_js_2 = require_escape(); 1650Object.defineProperty(exports, "escape", { enumerable: true, get: function() { 1651 return escape_js_2.escape; 1652} }); 1653var unescape_js_2 = require_unescape(); 1654Object.defineProperty(exports, "unescape", { enumerable: true, get: function() { 1655 return unescape_js_2.unescape; 1656} }); 1657exports.minimatch.AST = ast_js_1.AST; 1658exports.minimatch.Minimatch = Minimatch; 1659exports.minimatch.escape = escape_js_1.escape; 1660exports.minimatch.unescape = unescape_js_1.unescape; 1661