@rollup/wasm-node 4.22.4 → 4.23.0

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.22.4
4
- Sat, 21 Sep 2024 06:10:53 GMT - commit 79c0aba353ca84c0e22c3cfe9eee433ba83f3670
3
+ Rollup.js v4.23.0
4
+ Tue, 01 Oct 2024 07:09:35 GMT - commit ed98e0821e6ad064839f0af46ceca061adbe3f14
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -12,7 +12,7 @@
12
12
  const parseAst_js = require('./parseAst.js');
13
13
  const process$1 = require('node:process');
14
14
  const tty = require('tty');
15
- const path$2 = require('node:path');
15
+ const path = require('node:path');
16
16
  const require$$0 = require('path');
17
17
  const native_js = require('../native.js');
18
18
  const node_perf_hooks = require('node:perf_hooks');
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
31
31
 
32
32
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
33
33
 
34
- var version = "4.22.4";
34
+ var version = "4.23.0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -199,7 +199,7 @@ function renderNamePattern(pattern, patternName, replacements) {
199
199
  function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }) {
200
200
  if (!reservedLowercaseBundleKeys.has(name.toLowerCase()))
201
201
  return name;
202
- const extension = path$2.extname(name);
202
+ const extension = path.extname(name);
203
203
  name = name.slice(0, Math.max(0, name.length - extension.length));
204
204
  let uniqueName, uniqueIndex = 1;
205
205
  while (reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + extension).toLowerCase()))
@@ -207,15 +207,30 @@ function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }
207
207
  return uniqueName;
208
208
  }
209
209
 
210
- function generateAssetFileName(name, source, originalFileName, sourceHash, outputOptions, bundle) {
210
+ function generateAssetFileName(name, names, source, originalFileName, originalFileNames, sourceHash, outputOptions, bundle, inputOptions) {
211
211
  const emittedName = outputOptions.sanitizeFileName(name || 'asset');
212
212
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
213
- ? outputOptions.assetFileNames({ name, originalFileName, source, type: 'asset' })
213
+ ? outputOptions.assetFileNames({
214
+ // Additionally, this should be non-enumerable in the next major
215
+ get name() {
216
+ parseAst_js.warnDeprecation('Accessing the "name" property of emitted assets when generating the file name is deprecated. Use the "names" property instead.', parseAst_js.URL_GENERATEBUNDLE, false, inputOptions);
217
+ return name;
218
+ },
219
+ names,
220
+ // Additionally, this should be non-enumerable in the next major
221
+ get originalFileName() {
222
+ parseAst_js.warnDeprecation('Accessing the "originalFileName" property of emitted assets when generating the file name is deprecated. Use the "originalFileNames" property instead.', parseAst_js.URL_GENERATEBUNDLE, false, inputOptions);
223
+ return originalFileName;
224
+ },
225
+ originalFileNames,
226
+ source,
227
+ type: 'asset'
228
+ })
214
229
  : outputOptions.assetFileNames, 'output.assetFileNames', {
215
- ext: () => path$2.extname(emittedName).slice(1),
216
- extname: () => path$2.extname(emittedName),
230
+ ext: () => path.extname(emittedName).slice(1),
231
+ extname: () => path.extname(emittedName),
217
232
  hash: size => sourceHash.slice(0, Math.max(0, size || DEFAULT_HASH_SIZE)),
218
- name: () => emittedName.slice(0, Math.max(0, emittedName.length - path$2.extname(emittedName).length))
233
+ name: () => emittedName.slice(0, Math.max(0, emittedName.length - path.extname(emittedName).length))
219
234
  }), bundle);
220
235
  }
221
236
  function reserveFileNameInBundle(fileName, { bundle }, log) {
@@ -326,7 +341,7 @@ class FileEmitter {
326
341
  const getHash = hasherByType[outputOptions.hashCharacters];
327
342
  const output = (this.output = {
328
343
  bundle,
329
- fileNamesBySource: new Map(),
344
+ fileNamesBySourceHash: new Map(),
330
345
  getHash,
331
346
  outputOptions
332
347
  });
@@ -481,15 +496,15 @@ class FileEmitter {
481
496
  }
482
497
  return referenceId;
483
498
  }
484
- finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySource, getHash, outputOptions }) {
485
- let { fileName, needsCodeReference, originalFileName, referenceId } = consumedFile;
499
+ finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySourceHash, getHash, outputOptions }) {
500
+ let { fileName, name, needsCodeReference, originalFileName, referenceId } = consumedFile;
486
501
  // Deduplicate assets if an explicit fileName is not provided
487
502
  if (!fileName) {
488
503
  const sourceHash = getHash(source);
489
- fileName = fileNamesBySource.get(sourceHash);
504
+ fileName = fileNamesBySourceHash.get(sourceHash);
490
505
  if (!fileName) {
491
- fileName = generateAssetFileName(consumedFile.name, source, originalFileName, sourceHash, outputOptions, bundle);
492
- fileNamesBySource.set(sourceHash, fileName);
506
+ fileName = generateAssetFileName(name, name ? [name] : [], source, originalFileName, originalFileName ? [originalFileName] : [], sourceHash, outputOptions, bundle, this.options);
507
+ fileNamesBySourceHash.set(sourceHash, fileName);
493
508
  }
494
509
  }
495
510
  // We must not modify the original assets to avoid interaction between outputs
@@ -498,25 +513,43 @@ class FileEmitter {
498
513
  const existingAsset = bundle[fileName];
499
514
  if (existingAsset?.type === 'asset') {
500
515
  existingAsset.needsCodeReference &&= needsCodeReference;
516
+ if (name) {
517
+ existingAsset.names.push(name);
518
+ }
519
+ if (originalFileName) {
520
+ existingAsset.originalFileNames.push(originalFileName);
521
+ }
501
522
  }
502
523
  else {
524
+ const { options } = this;
503
525
  bundle[fileName] = {
504
526
  fileName,
505
- name: consumedFile.name,
527
+ get name() {
528
+ // Additionally, this should be non-enumerable in the next major
529
+ parseAst_js.warnDeprecation('Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', parseAst_js.URL_GENERATEBUNDLE, false, options);
530
+ return name;
531
+ },
532
+ names: name ? [name] : [],
506
533
  needsCodeReference,
507
- originalFileName,
534
+ get originalFileName() {
535
+ // Additionally, this should be non-enumerable in the next major
536
+ parseAst_js.warnDeprecation('Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', parseAst_js.URL_GENERATEBUNDLE, false, options);
537
+ return originalFileName;
538
+ },
539
+ originalFileNames: originalFileName ? [originalFileName] : [],
508
540
  source,
509
541
  type: 'asset'
510
542
  };
511
543
  }
512
544
  }
513
- finalizeAssetsWithSameSource(consumedFiles, sourceHash, { bundle, fileNamesBySource, outputOptions }) {
545
+ finalizeAssetsWithSameSource(consumedFiles, sourceHash, { bundle, fileNamesBySourceHash, outputOptions }) {
546
+ const { names, originalFileNames } = getNamesFromAssets(consumedFiles);
514
547
  let fileName = '';
515
548
  let usedConsumedFile;
516
549
  let needsCodeReference = true;
517
550
  for (const consumedFile of consumedFiles) {
518
551
  needsCodeReference &&= consumedFile.needsCodeReference;
519
- const assetFileName = generateAssetFileName(consumedFile.name, consumedFile.source, consumedFile.originalFileName, sourceHash, outputOptions, bundle);
552
+ const assetFileName = generateAssetFileName(consumedFile.name, names, consumedFile.source, consumedFile.originalFileName, originalFileNames, sourceHash, outputOptions, bundle, this.options);
520
553
  if (!fileName ||
521
554
  assetFileName.length < fileName.length ||
522
555
  (assetFileName.length === fileName.length && assetFileName < fileName)) {
@@ -524,22 +557,50 @@ class FileEmitter {
524
557
  usedConsumedFile = consumedFile;
525
558
  }
526
559
  }
527
- fileNamesBySource.set(sourceHash, fileName);
560
+ fileNamesBySourceHash.set(sourceHash, fileName);
528
561
  for (const consumedFile of consumedFiles) {
529
562
  // We must not modify the original assets to avoid interaction between outputs
530
563
  const assetWithFileName = { ...consumedFile, fileName };
531
564
  this.filesByReferenceId.set(consumedFile.referenceId, assetWithFileName);
532
565
  }
566
+ const { options } = this;
533
567
  bundle[fileName] = {
534
568
  fileName,
535
- name: usedConsumedFile.name,
569
+ get name() {
570
+ // Additionally, this should be non-enumerable in the next major
571
+ parseAst_js.warnDeprecation('Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', parseAst_js.URL_GENERATEBUNDLE, false, options);
572
+ return usedConsumedFile.name;
573
+ },
574
+ names,
536
575
  needsCodeReference,
537
- originalFileName: usedConsumedFile.originalFileName,
576
+ get originalFileName() {
577
+ // Additionally, this should be non-enumerable in the next major
578
+ parseAst_js.warnDeprecation('Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', parseAst_js.URL_GENERATEBUNDLE, false, options);
579
+ return usedConsumedFile.originalFileName;
580
+ },
581
+ originalFileNames,
538
582
  source: usedConsumedFile.source,
539
583
  type: 'asset'
540
584
  };
541
585
  }
542
586
  }
587
+ function getNamesFromAssets(consumedFiles) {
588
+ const names = [];
589
+ const originalFileNames = [];
590
+ for (const { name, originalFileName } of consumedFiles) {
591
+ if (typeof name === 'string') {
592
+ names.push(name);
593
+ }
594
+ if (originalFileName) {
595
+ originalFileNames.push(originalFileName);
596
+ }
597
+ }
598
+ originalFileNames.sort();
599
+ // Sort by length first and then alphabetically so that the order is stable
600
+ // and the shortest names come first
601
+ names.sort((a, b) => a.length - b.length || (a > b ? 1 : a === b ? 0 : -1));
602
+ return { names, originalFileNames };
603
+ }
543
604
 
544
605
  const doNothing = () => { };
545
606
 
@@ -1963,7 +2024,7 @@ function getRelativePath(from, to) {
1963
2024
 
1964
2025
  const toString = Object.prototype.toString;
1965
2026
 
1966
- function isObject$1(thing) {
2027
+ function isObject(thing) {
1967
2028
  return toString.call(thing) === '[object Object]';
1968
2029
  }
1969
2030
 
@@ -2284,7 +2345,7 @@ class MagicString {
2284
2345
  indent(indentStr, options) {
2285
2346
  const pattern = /^[^\r\n]/gm;
2286
2347
 
2287
- if (isObject$1(indentStr)) {
2348
+ if (isObject(indentStr)) {
2288
2349
  options = indentStr;
2289
2350
  indentStr = undefined;
2290
2351
  }
@@ -2961,7 +3022,7 @@ let Bundle$1 = class Bundle {
2961
3022
  });
2962
3023
  }
2963
3024
 
2964
- if (!isObject$1(source) || !source.content) {
3025
+ if (!isObject(source) || !source.content) {
2965
3026
  throw new Error(
2966
3027
  'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
2967
3028
  );
@@ -8638,7 +8699,7 @@ class MetaProperty extends NodeBase {
8638
8699
  const chunkId = preliminaryChunkId;
8639
8700
  if (referenceId) {
8640
8701
  const fileName = pluginDriver.getFileName(referenceId);
8641
- const relativePath = parseAst_js.normalize(path$2.relative(path$2.dirname(chunkId), fileName));
8702
+ const relativePath = parseAst_js.normalize(path.relative(path.dirname(chunkId), fileName));
8642
8703
  const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
8643
8704
  { chunkId, fileName, format, moduleId, referenceId, relativePath }
8644
8705
  ]) || relativeUrlMechanisms[format](relativePath);
@@ -9005,7 +9066,7 @@ class ExternalChunk {
9005
9066
  const { paths } = this.options;
9006
9067
  return (this.fileName =
9007
9068
  (typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
9008
- (this.renormalizeRenderPath ? parseAst_js.normalize(path$2.relative(this.inputBase, this.id)) : this.id));
9069
+ (this.renormalizeRenderPath ? parseAst_js.normalize(path.relative(this.inputBase, this.id)) : this.id));
9009
9070
  }
9010
9071
  getImportAttributes(snippets) {
9011
9072
  return (this.importAttributes ||= formatAttributes(this.options.format === 'es' &&
@@ -9927,2069 +9988,2122 @@ function getAugmentedNamespace(n) {
9927
9988
  return a;
9928
9989
  }
9929
9990
 
9930
- var utils$3 = {};
9931
-
9932
- const path$1 = require$$0;
9933
- const WIN_SLASH = '\\\\/';
9934
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
9935
-
9936
- /**
9937
- * Posix glob regex
9938
- */
9991
+ var utils = {};
9939
9992
 
9940
- const DOT_LITERAL = '\\.';
9941
- const PLUS_LITERAL = '\\+';
9942
- const QMARK_LITERAL = '\\?';
9943
- const SLASH_LITERAL = '\\/';
9944
- const ONE_CHAR = '(?=.)';
9945
- const QMARK = '[^/]';
9946
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
9947
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
9948
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
9949
- const NO_DOT = `(?!${DOT_LITERAL})`;
9950
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
9951
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
9952
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
9953
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
9954
- const STAR = `${QMARK}*?`;
9955
-
9956
- const POSIX_CHARS = {
9957
- DOT_LITERAL,
9958
- PLUS_LITERAL,
9959
- QMARK_LITERAL,
9960
- SLASH_LITERAL,
9961
- ONE_CHAR,
9962
- QMARK,
9963
- END_ANCHOR,
9964
- DOTS_SLASH,
9965
- NO_DOT,
9966
- NO_DOTS,
9967
- NO_DOT_SLASH,
9968
- NO_DOTS_SLASH,
9969
- QMARK_NO_DOT,
9970
- STAR,
9971
- START_ANCHOR
9972
- };
9993
+ var constants;
9994
+ var hasRequiredConstants;
9973
9995
 
9974
- /**
9975
- * Windows glob regex
9976
- */
9977
-
9978
- const WINDOWS_CHARS = {
9979
- ...POSIX_CHARS,
9980
-
9981
- SLASH_LITERAL: `[${WIN_SLASH}]`,
9982
- QMARK: WIN_NO_SLASH,
9983
- STAR: `${WIN_NO_SLASH}*?`,
9984
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
9985
- NO_DOT: `(?!${DOT_LITERAL})`,
9986
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
9987
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
9988
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
9989
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
9990
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
9991
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
9992
- };
9993
-
9994
- /**
9995
- * POSIX Bracket Regex
9996
- */
9997
-
9998
- const POSIX_REGEX_SOURCE$1 = {
9999
- alnum: 'a-zA-Z0-9',
10000
- alpha: 'a-zA-Z',
10001
- ascii: '\\x00-\\x7F',
10002
- blank: ' \\t',
10003
- cntrl: '\\x00-\\x1F\\x7F',
10004
- digit: '0-9',
10005
- graph: '\\x21-\\x7E',
10006
- lower: 'a-z',
10007
- print: '\\x20-\\x7E ',
10008
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
10009
- space: ' \\t\\r\\n\\v\\f',
10010
- upper: 'A-Z',
10011
- word: 'A-Za-z0-9_',
10012
- xdigit: 'A-Fa-f0-9'
10013
- };
10014
-
10015
- var constants$2 = {
10016
- MAX_LENGTH: 1024 * 64,
10017
- POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
10018
-
10019
- // regular expressions
10020
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
10021
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
10022
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
10023
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
10024
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
10025
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
10026
-
10027
- // Replace globs with equivalent patterns to reduce parsing time.
10028
- REPLACEMENTS: {
10029
- '***': '*',
10030
- '**/**': '**',
10031
- '**/**/**': '**'
10032
- },
10033
-
10034
- // Digits
10035
- CHAR_0: 48, /* 0 */
10036
- CHAR_9: 57, /* 9 */
10037
-
10038
- // Alphabet chars.
10039
- CHAR_UPPERCASE_A: 65, /* A */
10040
- CHAR_LOWERCASE_A: 97, /* a */
10041
- CHAR_UPPERCASE_Z: 90, /* Z */
10042
- CHAR_LOWERCASE_Z: 122, /* z */
10043
-
10044
- CHAR_LEFT_PARENTHESES: 40, /* ( */
10045
- CHAR_RIGHT_PARENTHESES: 41, /* ) */
10046
-
10047
- CHAR_ASTERISK: 42, /* * */
10048
-
10049
- // Non-alphabetic chars.
10050
- CHAR_AMPERSAND: 38, /* & */
10051
- CHAR_AT: 64, /* @ */
10052
- CHAR_BACKWARD_SLASH: 92, /* \ */
10053
- CHAR_CARRIAGE_RETURN: 13, /* \r */
10054
- CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
10055
- CHAR_COLON: 58, /* : */
10056
- CHAR_COMMA: 44, /* , */
10057
- CHAR_DOT: 46, /* . */
10058
- CHAR_DOUBLE_QUOTE: 34, /* " */
10059
- CHAR_EQUAL: 61, /* = */
10060
- CHAR_EXCLAMATION_MARK: 33, /* ! */
10061
- CHAR_FORM_FEED: 12, /* \f */
10062
- CHAR_FORWARD_SLASH: 47, /* / */
10063
- CHAR_GRAVE_ACCENT: 96, /* ` */
10064
- CHAR_HASH: 35, /* # */
10065
- CHAR_HYPHEN_MINUS: 45, /* - */
10066
- CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
10067
- CHAR_LEFT_CURLY_BRACE: 123, /* { */
10068
- CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
10069
- CHAR_LINE_FEED: 10, /* \n */
10070
- CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
10071
- CHAR_PERCENT: 37, /* % */
10072
- CHAR_PLUS: 43, /* + */
10073
- CHAR_QUESTION_MARK: 63, /* ? */
10074
- CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
10075
- CHAR_RIGHT_CURLY_BRACE: 125, /* } */
10076
- CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
10077
- CHAR_SEMICOLON: 59, /* ; */
10078
- CHAR_SINGLE_QUOTE: 39, /* ' */
10079
- CHAR_SPACE: 32, /* */
10080
- CHAR_TAB: 9, /* \t */
10081
- CHAR_UNDERSCORE: 95, /* _ */
10082
- CHAR_VERTICAL_LINE: 124, /* | */
10083
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
10084
-
10085
- SEP: path$1.sep,
10086
-
10087
- /**
10088
- * Create EXTGLOB_CHARS
10089
- */
10090
-
10091
- extglobChars(chars) {
10092
- return {
10093
- '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
10094
- '?': { type: 'qmark', open: '(?:', close: ')?' },
10095
- '+': { type: 'plus', open: '(?:', close: ')+' },
10096
- '*': { type: 'star', open: '(?:', close: ')*' },
10097
- '@': { type: 'at', open: '(?:', close: ')' }
10098
- };
10099
- },
10100
-
10101
- /**
10102
- * Create GLOB_CHARS
10103
- */
10104
-
10105
- globChars(win32) {
10106
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
10107
- }
10108
- };
10109
-
10110
- (function (exports) {
9996
+ function requireConstants () {
9997
+ if (hasRequiredConstants) return constants;
9998
+ hasRequiredConstants = 1;
10111
9999
 
10112
10000
  const path = require$$0;
10113
- const win32 = process.platform === 'win32';
10114
- const {
10115
- REGEX_BACKSLASH,
10116
- REGEX_REMOVE_BACKSLASH,
10117
- REGEX_SPECIAL_CHARS,
10118
- REGEX_SPECIAL_CHARS_GLOBAL
10119
- } = constants$2;
10120
-
10121
- exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
10122
- exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
10123
- exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
10124
- exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
10125
- exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
10126
-
10127
- exports.removeBackslashes = str => {
10128
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
10129
- return match === '\\' ? '' : match;
10130
- });
10001
+ const WIN_SLASH = '\\\\/';
10002
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
10003
+
10004
+ /**
10005
+ * Posix glob regex
10006
+ */
10007
+
10008
+ const DOT_LITERAL = '\\.';
10009
+ const PLUS_LITERAL = '\\+';
10010
+ const QMARK_LITERAL = '\\?';
10011
+ const SLASH_LITERAL = '\\/';
10012
+ const ONE_CHAR = '(?=.)';
10013
+ const QMARK = '[^/]';
10014
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
10015
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
10016
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
10017
+ const NO_DOT = `(?!${DOT_LITERAL})`;
10018
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
10019
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
10020
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
10021
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
10022
+ const STAR = `${QMARK}*?`;
10023
+
10024
+ const POSIX_CHARS = {
10025
+ DOT_LITERAL,
10026
+ PLUS_LITERAL,
10027
+ QMARK_LITERAL,
10028
+ SLASH_LITERAL,
10029
+ ONE_CHAR,
10030
+ QMARK,
10031
+ END_ANCHOR,
10032
+ DOTS_SLASH,
10033
+ NO_DOT,
10034
+ NO_DOTS,
10035
+ NO_DOT_SLASH,
10036
+ NO_DOTS_SLASH,
10037
+ QMARK_NO_DOT,
10038
+ STAR,
10039
+ START_ANCHOR
10131
10040
  };
10132
10041
 
10133
- exports.supportsLookbehinds = () => {
10134
- const segs = process.version.slice(1).split('.').map(Number);
10135
- if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
10136
- return true;
10137
- }
10138
- return false;
10042
+ /**
10043
+ * Windows glob regex
10044
+ */
10045
+
10046
+ const WINDOWS_CHARS = {
10047
+ ...POSIX_CHARS,
10048
+
10049
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
10050
+ QMARK: WIN_NO_SLASH,
10051
+ STAR: `${WIN_NO_SLASH}*?`,
10052
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
10053
+ NO_DOT: `(?!${DOT_LITERAL})`,
10054
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
10055
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
10056
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
10057
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
10058
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
10059
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
10139
10060
  };
10140
10061
 
10141
- exports.isWindows = options => {
10142
- if (options && typeof options.windows === 'boolean') {
10143
- return options.windows;
10144
- }
10145
- return win32 === true || path.sep === '\\';
10062
+ /**
10063
+ * POSIX Bracket Regex
10064
+ */
10065
+
10066
+ const POSIX_REGEX_SOURCE = {
10067
+ alnum: 'a-zA-Z0-9',
10068
+ alpha: 'a-zA-Z',
10069
+ ascii: '\\x00-\\x7F',
10070
+ blank: ' \\t',
10071
+ cntrl: '\\x00-\\x1F\\x7F',
10072
+ digit: '0-9',
10073
+ graph: '\\x21-\\x7E',
10074
+ lower: 'a-z',
10075
+ print: '\\x20-\\x7E ',
10076
+ punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
10077
+ space: ' \\t\\r\\n\\v\\f',
10078
+ upper: 'A-Z',
10079
+ word: 'A-Za-z0-9_',
10080
+ xdigit: 'A-Fa-f0-9'
10146
10081
  };
10147
10082
 
10148
- exports.escapeLast = (input, char, lastIdx) => {
10149
- const idx = input.lastIndexOf(char, lastIdx);
10150
- if (idx === -1) return input;
10151
- if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
10152
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
10153
- };
10154
-
10155
- exports.removePrefix = (input, state = {}) => {
10156
- let output = input;
10157
- if (output.startsWith('./')) {
10158
- output = output.slice(2);
10159
- state.prefix = './';
10083
+ constants = {
10084
+ MAX_LENGTH: 1024 * 64,
10085
+ POSIX_REGEX_SOURCE,
10086
+
10087
+ // regular expressions
10088
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
10089
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
10090
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
10091
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
10092
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
10093
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
10094
+
10095
+ // Replace globs with equivalent patterns to reduce parsing time.
10096
+ REPLACEMENTS: {
10097
+ '***': '*',
10098
+ '**/**': '**',
10099
+ '**/**/**': '**'
10100
+ },
10101
+
10102
+ // Digits
10103
+ CHAR_0: 48, /* 0 */
10104
+ CHAR_9: 57, /* 9 */
10105
+
10106
+ // Alphabet chars.
10107
+ CHAR_UPPERCASE_A: 65, /* A */
10108
+ CHAR_LOWERCASE_A: 97, /* a */
10109
+ CHAR_UPPERCASE_Z: 90, /* Z */
10110
+ CHAR_LOWERCASE_Z: 122, /* z */
10111
+
10112
+ CHAR_LEFT_PARENTHESES: 40, /* ( */
10113
+ CHAR_RIGHT_PARENTHESES: 41, /* ) */
10114
+
10115
+ CHAR_ASTERISK: 42, /* * */
10116
+
10117
+ // Non-alphabetic chars.
10118
+ CHAR_AMPERSAND: 38, /* & */
10119
+ CHAR_AT: 64, /* @ */
10120
+ CHAR_BACKWARD_SLASH: 92, /* \ */
10121
+ CHAR_CARRIAGE_RETURN: 13, /* \r */
10122
+ CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
10123
+ CHAR_COLON: 58, /* : */
10124
+ CHAR_COMMA: 44, /* , */
10125
+ CHAR_DOT: 46, /* . */
10126
+ CHAR_DOUBLE_QUOTE: 34, /* " */
10127
+ CHAR_EQUAL: 61, /* = */
10128
+ CHAR_EXCLAMATION_MARK: 33, /* ! */
10129
+ CHAR_FORM_FEED: 12, /* \f */
10130
+ CHAR_FORWARD_SLASH: 47, /* / */
10131
+ CHAR_GRAVE_ACCENT: 96, /* ` */
10132
+ CHAR_HASH: 35, /* # */
10133
+ CHAR_HYPHEN_MINUS: 45, /* - */
10134
+ CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
10135
+ CHAR_LEFT_CURLY_BRACE: 123, /* { */
10136
+ CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
10137
+ CHAR_LINE_FEED: 10, /* \n */
10138
+ CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
10139
+ CHAR_PERCENT: 37, /* % */
10140
+ CHAR_PLUS: 43, /* + */
10141
+ CHAR_QUESTION_MARK: 63, /* ? */
10142
+ CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
10143
+ CHAR_RIGHT_CURLY_BRACE: 125, /* } */
10144
+ CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
10145
+ CHAR_SEMICOLON: 59, /* ; */
10146
+ CHAR_SINGLE_QUOTE: 39, /* ' */
10147
+ CHAR_SPACE: 32, /* */
10148
+ CHAR_TAB: 9, /* \t */
10149
+ CHAR_UNDERSCORE: 95, /* _ */
10150
+ CHAR_VERTICAL_LINE: 124, /* | */
10151
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
10152
+
10153
+ SEP: path.sep,
10154
+
10155
+ /**
10156
+ * Create EXTGLOB_CHARS
10157
+ */
10158
+
10159
+ extglobChars(chars) {
10160
+ return {
10161
+ '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
10162
+ '?': { type: 'qmark', open: '(?:', close: ')?' },
10163
+ '+': { type: 'plus', open: '(?:', close: ')+' },
10164
+ '*': { type: 'star', open: '(?:', close: ')*' },
10165
+ '@': { type: 'at', open: '(?:', close: ')' }
10166
+ };
10167
+ },
10168
+
10169
+ /**
10170
+ * Create GLOB_CHARS
10171
+ */
10172
+
10173
+ globChars(win32) {
10174
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
10160
10175
  }
10161
- return output;
10162
10176
  };
10177
+ return constants;
10178
+ }
10179
+
10180
+ var hasRequiredUtils;
10181
+
10182
+ function requireUtils () {
10183
+ if (hasRequiredUtils) return utils;
10184
+ hasRequiredUtils = 1;
10185
+ (function (exports) {
10186
+
10187
+ const path = require$$0;
10188
+ const win32 = process.platform === 'win32';
10189
+ const {
10190
+ REGEX_BACKSLASH,
10191
+ REGEX_REMOVE_BACKSLASH,
10192
+ REGEX_SPECIAL_CHARS,
10193
+ REGEX_SPECIAL_CHARS_GLOBAL
10194
+ } = /*@__PURE__*/ requireConstants();
10195
+
10196
+ exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
10197
+ exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
10198
+ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
10199
+ exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
10200
+ exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
10201
+
10202
+ exports.removeBackslashes = str => {
10203
+ return str.replace(REGEX_REMOVE_BACKSLASH, match => {
10204
+ return match === '\\' ? '' : match;
10205
+ });
10206
+ };
10163
10207
 
10164
- exports.wrapOutput = (input, state = {}, options = {}) => {
10165
- const prepend = options.contains ? '' : '^';
10166
- const append = options.contains ? '' : '$';
10167
-
10168
- let output = `${prepend}(?:${input})${append}`;
10169
- if (state.negated === true) {
10170
- output = `(?:^(?!${output}).*$)`;
10171
- }
10172
- return output;
10173
- };
10174
- } (utils$3));
10175
-
10176
- const utils$2 = utils$3;
10177
- const {
10178
- CHAR_ASTERISK, /* * */
10179
- CHAR_AT, /* @ */
10180
- CHAR_BACKWARD_SLASH, /* \ */
10181
- CHAR_COMMA, /* , */
10182
- CHAR_DOT, /* . */
10183
- CHAR_EXCLAMATION_MARK, /* ! */
10184
- CHAR_FORWARD_SLASH, /* / */
10185
- CHAR_LEFT_CURLY_BRACE, /* { */
10186
- CHAR_LEFT_PARENTHESES, /* ( */
10187
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
10188
- CHAR_PLUS, /* + */
10189
- CHAR_QUESTION_MARK, /* ? */
10190
- CHAR_RIGHT_CURLY_BRACE, /* } */
10191
- CHAR_RIGHT_PARENTHESES, /* ) */
10192
- CHAR_RIGHT_SQUARE_BRACKET /* ] */
10193
- } = constants$2;
10194
-
10195
- const isPathSeparator = code => {
10196
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
10197
- };
10198
-
10199
- const depth = token => {
10200
- if (token.isPrefix !== true) {
10201
- token.depth = token.isGlobstar ? Infinity : 1;
10202
- }
10203
- };
10204
-
10205
- /**
10206
- * Quickly scans a glob pattern and returns an object with a handful of
10207
- * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
10208
- * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
10209
- * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
10210
- *
10211
- * ```js
10212
- * const pm = require('picomatch');
10213
- * console.log(pm.scan('foo/bar/*.js'));
10214
- * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
10215
- * ```
10216
- * @param {String} `str`
10217
- * @param {Object} `options`
10218
- * @return {Object} Returns an object with tokens and regex source string.
10219
- * @api public
10220
- */
10221
-
10222
- const scan$1 = (input, options) => {
10223
- const opts = options || {};
10224
-
10225
- const length = input.length - 1;
10226
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
10227
- const slashes = [];
10228
- const tokens = [];
10229
- const parts = [];
10230
-
10231
- let str = input;
10232
- let index = -1;
10233
- let start = 0;
10234
- let lastIndex = 0;
10235
- let isBrace = false;
10236
- let isBracket = false;
10237
- let isGlob = false;
10238
- let isExtglob = false;
10239
- let isGlobstar = false;
10240
- let braceEscaped = false;
10241
- let backslashes = false;
10242
- let negated = false;
10243
- let negatedExtglob = false;
10244
- let finished = false;
10245
- let braces = 0;
10246
- let prev;
10247
- let code;
10248
- let token = { value: '', depth: 0, isGlob: false };
10249
-
10250
- const eos = () => index >= length;
10251
- const peek = () => str.charCodeAt(index + 1);
10252
- const advance = () => {
10253
- prev = code;
10254
- return str.charCodeAt(++index);
10255
- };
10256
-
10257
- while (index < length) {
10258
- code = advance();
10259
- let next;
10260
-
10261
- if (code === CHAR_BACKWARD_SLASH) {
10262
- backslashes = token.backslashes = true;
10263
- code = advance();
10264
-
10265
- if (code === CHAR_LEFT_CURLY_BRACE) {
10266
- braceEscaped = true;
10267
- }
10268
- continue;
10269
- }
10270
-
10271
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
10272
- braces++;
10273
-
10274
- while (eos() !== true && (code = advance())) {
10275
- if (code === CHAR_BACKWARD_SLASH) {
10276
- backslashes = token.backslashes = true;
10277
- advance();
10278
- continue;
10279
- }
10280
-
10281
- if (code === CHAR_LEFT_CURLY_BRACE) {
10282
- braces++;
10283
- continue;
10284
- }
10285
-
10286
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
10287
- isBrace = token.isBrace = true;
10288
- isGlob = token.isGlob = true;
10289
- finished = true;
10290
-
10291
- if (scanToEnd === true) {
10292
- continue;
10293
- }
10294
-
10295
- break;
10296
- }
10297
-
10298
- if (braceEscaped !== true && code === CHAR_COMMA) {
10299
- isBrace = token.isBrace = true;
10300
- isGlob = token.isGlob = true;
10301
- finished = true;
10302
-
10303
- if (scanToEnd === true) {
10304
- continue;
10305
- }
10306
-
10307
- break;
10308
- }
10309
-
10310
- if (code === CHAR_RIGHT_CURLY_BRACE) {
10311
- braces--;
10312
-
10313
- if (braces === 0) {
10314
- braceEscaped = false;
10315
- isBrace = token.isBrace = true;
10316
- finished = true;
10317
- break;
10318
- }
10319
- }
10320
- }
10321
-
10322
- if (scanToEnd === true) {
10323
- continue;
10324
- }
10325
-
10326
- break;
10327
- }
10328
-
10329
- if (code === CHAR_FORWARD_SLASH) {
10330
- slashes.push(index);
10331
- tokens.push(token);
10332
- token = { value: '', depth: 0, isGlob: false };
10333
-
10334
- if (finished === true) continue;
10335
- if (prev === CHAR_DOT && index === (start + 1)) {
10336
- start += 2;
10337
- continue;
10338
- }
10339
-
10340
- lastIndex = index + 1;
10341
- continue;
10342
- }
10343
-
10344
- if (opts.noext !== true) {
10345
- const isExtglobChar = code === CHAR_PLUS
10346
- || code === CHAR_AT
10347
- || code === CHAR_ASTERISK
10348
- || code === CHAR_QUESTION_MARK
10349
- || code === CHAR_EXCLAMATION_MARK;
10350
-
10351
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
10352
- isGlob = token.isGlob = true;
10353
- isExtglob = token.isExtglob = true;
10354
- finished = true;
10355
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
10356
- negatedExtglob = true;
10357
- }
10358
-
10359
- if (scanToEnd === true) {
10360
- while (eos() !== true && (code = advance())) {
10361
- if (code === CHAR_BACKWARD_SLASH) {
10362
- backslashes = token.backslashes = true;
10363
- code = advance();
10364
- continue;
10365
- }
10366
-
10367
- if (code === CHAR_RIGHT_PARENTHESES) {
10368
- isGlob = token.isGlob = true;
10369
- finished = true;
10370
- break;
10371
- }
10372
- }
10373
- continue;
10374
- }
10375
- break;
10376
- }
10377
- }
10378
-
10379
- if (code === CHAR_ASTERISK) {
10380
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
10381
- isGlob = token.isGlob = true;
10382
- finished = true;
10383
-
10384
- if (scanToEnd === true) {
10385
- continue;
10386
- }
10387
- break;
10388
- }
10389
-
10390
- if (code === CHAR_QUESTION_MARK) {
10391
- isGlob = token.isGlob = true;
10392
- finished = true;
10393
-
10394
- if (scanToEnd === true) {
10395
- continue;
10396
- }
10397
- break;
10398
- }
10399
-
10400
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
10401
- while (eos() !== true && (next = advance())) {
10402
- if (next === CHAR_BACKWARD_SLASH) {
10403
- backslashes = token.backslashes = true;
10404
- advance();
10405
- continue;
10406
- }
10407
-
10408
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
10409
- isBracket = token.isBracket = true;
10410
- isGlob = token.isGlob = true;
10411
- finished = true;
10412
- break;
10413
- }
10414
- }
10415
-
10416
- if (scanToEnd === true) {
10417
- continue;
10418
- }
10419
-
10420
- break;
10421
- }
10422
-
10423
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
10424
- negated = token.negated = true;
10425
- start++;
10426
- continue;
10427
- }
10428
-
10429
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
10430
- isGlob = token.isGlob = true;
10431
-
10432
- if (scanToEnd === true) {
10433
- while (eos() !== true && (code = advance())) {
10434
- if (code === CHAR_LEFT_PARENTHESES) {
10435
- backslashes = token.backslashes = true;
10436
- code = advance();
10437
- continue;
10438
- }
10439
-
10440
- if (code === CHAR_RIGHT_PARENTHESES) {
10441
- finished = true;
10442
- break;
10443
- }
10444
- }
10445
- continue;
10446
- }
10447
- break;
10448
- }
10449
-
10450
- if (isGlob === true) {
10451
- finished = true;
10452
-
10453
- if (scanToEnd === true) {
10454
- continue;
10455
- }
10456
-
10457
- break;
10458
- }
10459
- }
10460
-
10461
- if (opts.noext === true) {
10462
- isExtglob = false;
10463
- isGlob = false;
10464
- }
10465
-
10466
- let base = str;
10467
- let prefix = '';
10468
- let glob = '';
10469
-
10470
- if (start > 0) {
10471
- prefix = str.slice(0, start);
10472
- str = str.slice(start);
10473
- lastIndex -= start;
10474
- }
10475
-
10476
- if (base && isGlob === true && lastIndex > 0) {
10477
- base = str.slice(0, lastIndex);
10478
- glob = str.slice(lastIndex);
10479
- } else if (isGlob === true) {
10480
- base = '';
10481
- glob = str;
10482
- } else {
10483
- base = str;
10484
- }
10485
-
10486
- if (base && base !== '' && base !== '/' && base !== str) {
10487
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
10488
- base = base.slice(0, -1);
10489
- }
10490
- }
10491
-
10492
- if (opts.unescape === true) {
10493
- if (glob) glob = utils$2.removeBackslashes(glob);
10494
-
10495
- if (base && backslashes === true) {
10496
- base = utils$2.removeBackslashes(base);
10497
- }
10498
- }
10499
-
10500
- const state = {
10501
- prefix,
10502
- input,
10503
- start,
10504
- base,
10505
- glob,
10506
- isBrace,
10507
- isBracket,
10508
- isGlob,
10509
- isExtglob,
10510
- isGlobstar,
10511
- negated,
10512
- negatedExtglob
10513
- };
10514
-
10515
- if (opts.tokens === true) {
10516
- state.maxDepth = 0;
10517
- if (!isPathSeparator(code)) {
10518
- tokens.push(token);
10519
- }
10520
- state.tokens = tokens;
10521
- }
10522
-
10523
- if (opts.parts === true || opts.tokens === true) {
10524
- let prevIndex;
10525
-
10526
- for (let idx = 0; idx < slashes.length; idx++) {
10527
- const n = prevIndex ? prevIndex + 1 : start;
10528
- const i = slashes[idx];
10529
- const value = input.slice(n, i);
10530
- if (opts.tokens) {
10531
- if (idx === 0 && start !== 0) {
10532
- tokens[idx].isPrefix = true;
10533
- tokens[idx].value = prefix;
10534
- } else {
10535
- tokens[idx].value = value;
10536
- }
10537
- depth(tokens[idx]);
10538
- state.maxDepth += tokens[idx].depth;
10539
- }
10540
- if (idx !== 0 || value !== '') {
10541
- parts.push(value);
10542
- }
10543
- prevIndex = i;
10544
- }
10545
-
10546
- if (prevIndex && prevIndex + 1 < input.length) {
10547
- const value = input.slice(prevIndex + 1);
10548
- parts.push(value);
10549
-
10550
- if (opts.tokens) {
10551
- tokens[tokens.length - 1].value = value;
10552
- depth(tokens[tokens.length - 1]);
10553
- state.maxDepth += tokens[tokens.length - 1].depth;
10554
- }
10555
- }
10556
-
10557
- state.slashes = slashes;
10558
- state.parts = parts;
10559
- }
10560
-
10561
- return state;
10562
- };
10563
-
10564
- var scan_1 = scan$1;
10565
-
10566
- const constants$1 = constants$2;
10567
- const utils$1 = utils$3;
10568
-
10569
- /**
10570
- * Constants
10571
- */
10572
-
10573
- const {
10574
- MAX_LENGTH,
10575
- POSIX_REGEX_SOURCE,
10576
- REGEX_NON_SPECIAL_CHARS,
10577
- REGEX_SPECIAL_CHARS_BACKREF,
10578
- REPLACEMENTS
10579
- } = constants$1;
10580
-
10581
- /**
10582
- * Helpers
10583
- */
10584
-
10585
- const expandRange = (args, options) => {
10586
- if (typeof options.expandRange === 'function') {
10587
- return options.expandRange(...args, options);
10588
- }
10589
-
10590
- args.sort();
10591
- const value = `[${args.join('-')}]`;
10592
-
10593
- return value;
10594
- };
10595
-
10596
- /**
10597
- * Create the message for a syntax error
10598
- */
10599
-
10600
- const syntaxError = (type, char) => {
10601
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
10602
- };
10603
-
10604
- /**
10605
- * Parse the given input string.
10606
- * @param {String} input
10607
- * @param {Object} options
10608
- * @return {Object}
10609
- */
10610
-
10611
- const parse$1 = (input, options) => {
10612
- if (typeof input !== 'string') {
10613
- throw new TypeError('Expected a string');
10614
- }
10615
-
10616
- input = REPLACEMENTS[input] || input;
10617
-
10618
- const opts = { ...options };
10619
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
10620
-
10621
- let len = input.length;
10622
- if (len > max) {
10623
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
10624
- }
10625
-
10626
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
10627
- const tokens = [bos];
10628
-
10629
- const capture = opts.capture ? '' : '?:';
10630
- const win32 = utils$1.isWindows(options);
10631
-
10632
- // create constants based on platform, for windows or posix
10633
- const PLATFORM_CHARS = constants$1.globChars(win32);
10634
- const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
10635
-
10636
- const {
10637
- DOT_LITERAL,
10638
- PLUS_LITERAL,
10639
- SLASH_LITERAL,
10640
- ONE_CHAR,
10641
- DOTS_SLASH,
10642
- NO_DOT,
10643
- NO_DOT_SLASH,
10644
- NO_DOTS_SLASH,
10645
- QMARK,
10646
- QMARK_NO_DOT,
10647
- STAR,
10648
- START_ANCHOR
10649
- } = PLATFORM_CHARS;
10650
-
10651
- const globstar = opts => {
10652
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
10653
- };
10654
-
10655
- const nodot = opts.dot ? '' : NO_DOT;
10656
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
10657
- let star = opts.bash === true ? globstar(opts) : STAR;
10658
-
10659
- if (opts.capture) {
10660
- star = `(${star})`;
10661
- }
10662
-
10663
- // minimatch options support
10664
- if (typeof opts.noext === 'boolean') {
10665
- opts.noextglob = opts.noext;
10666
- }
10667
-
10668
- const state = {
10669
- input,
10670
- index: -1,
10671
- start: 0,
10672
- dot: opts.dot === true,
10673
- consumed: '',
10674
- output: '',
10675
- prefix: '',
10676
- backtrack: false,
10677
- negated: false,
10678
- brackets: 0,
10679
- braces: 0,
10680
- parens: 0,
10681
- quotes: 0,
10682
- globstar: false,
10683
- tokens
10684
- };
10685
-
10686
- input = utils$1.removePrefix(input, state);
10687
- len = input.length;
10688
-
10689
- const extglobs = [];
10690
- const braces = [];
10691
- const stack = [];
10692
- let prev = bos;
10693
- let value;
10694
-
10695
- /**
10696
- * Tokenizing helpers
10697
- */
10698
-
10699
- const eos = () => state.index === len - 1;
10700
- const peek = state.peek = (n = 1) => input[state.index + n];
10701
- const advance = state.advance = () => input[++state.index] || '';
10702
- const remaining = () => input.slice(state.index + 1);
10703
- const consume = (value = '', num = 0) => {
10704
- state.consumed += value;
10705
- state.index += num;
10706
- };
10707
-
10708
- const append = token => {
10709
- state.output += token.output != null ? token.output : token.value;
10710
- consume(token.value);
10711
- };
10712
-
10713
- const negate = () => {
10714
- let count = 1;
10715
-
10716
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
10717
- advance();
10718
- state.start++;
10719
- count++;
10720
- }
10721
-
10722
- if (count % 2 === 0) {
10723
- return false;
10724
- }
10725
-
10726
- state.negated = true;
10727
- state.start++;
10728
- return true;
10729
- };
10730
-
10731
- const increment = type => {
10732
- state[type]++;
10733
- stack.push(type);
10734
- };
10735
-
10736
- const decrement = type => {
10737
- state[type]--;
10738
- stack.pop();
10739
- };
10740
-
10741
- /**
10742
- * Push tokens onto the tokens array. This helper speeds up
10743
- * tokenizing by 1) helping us avoid backtracking as much as possible,
10744
- * and 2) helping us avoid creating extra tokens when consecutive
10745
- * characters are plain text. This improves performance and simplifies
10746
- * lookbehinds.
10747
- */
10748
-
10749
- const push = tok => {
10750
- if (prev.type === 'globstar') {
10751
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
10752
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
10753
-
10754
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
10755
- state.output = state.output.slice(0, -prev.output.length);
10756
- prev.type = 'star';
10757
- prev.value = '*';
10758
- prev.output = star;
10759
- state.output += prev.output;
10760
- }
10761
- }
10762
-
10763
- if (extglobs.length && tok.type !== 'paren') {
10764
- extglobs[extglobs.length - 1].inner += tok.value;
10765
- }
10766
-
10767
- if (tok.value || tok.output) append(tok);
10768
- if (prev && prev.type === 'text' && tok.type === 'text') {
10769
- prev.value += tok.value;
10770
- prev.output = (prev.output || '') + tok.value;
10771
- return;
10772
- }
10773
-
10774
- tok.prev = prev;
10775
- tokens.push(tok);
10776
- prev = tok;
10777
- };
10778
-
10779
- const extglobOpen = (type, value) => {
10780
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
10781
-
10782
- token.prev = prev;
10783
- token.parens = state.parens;
10784
- token.output = state.output;
10785
- const output = (opts.capture ? '(' : '') + token.open;
10786
-
10787
- increment('parens');
10788
- push({ type, value, output: state.output ? '' : ONE_CHAR });
10789
- push({ type: 'paren', extglob: true, value: advance(), output });
10790
- extglobs.push(token);
10791
- };
10792
-
10793
- const extglobClose = token => {
10794
- let output = token.close + (opts.capture ? ')' : '');
10795
- let rest;
10796
-
10797
- if (token.type === 'negate') {
10798
- let extglobStar = star;
10799
-
10800
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
10801
- extglobStar = globstar(opts);
10802
- }
10803
-
10804
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
10805
- output = token.close = `)$))${extglobStar}`;
10806
- }
10807
-
10808
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
10809
- // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
10810
- // In this case, we need to parse the string and use it in the output of the original pattern.
10811
- // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
10812
- //
10813
- // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
10814
- const expression = parse$1(rest, { ...options, fastpaths: false }).output;
10815
-
10816
- output = token.close = `)${expression})${extglobStar})`;
10817
- }
10818
-
10819
- if (token.prev.type === 'bos') {
10820
- state.negatedExtglob = true;
10821
- }
10822
- }
10823
-
10824
- push({ type: 'paren', extglob: true, value, output });
10825
- decrement('parens');
10826
- };
10827
-
10828
- /**
10829
- * Fast paths
10830
- */
10831
-
10832
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
10833
- let backslashes = false;
10834
-
10835
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
10836
- if (first === '\\') {
10837
- backslashes = true;
10838
- return m;
10839
- }
10840
-
10841
- if (first === '?') {
10842
- if (esc) {
10843
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
10844
- }
10845
- if (index === 0) {
10846
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
10847
- }
10848
- return QMARK.repeat(chars.length);
10849
- }
10850
-
10851
- if (first === '.') {
10852
- return DOT_LITERAL.repeat(chars.length);
10853
- }
10854
-
10855
- if (first === '*') {
10856
- if (esc) {
10857
- return esc + first + (rest ? star : '');
10858
- }
10859
- return star;
10860
- }
10861
- return esc ? m : `\\${m}`;
10862
- });
10863
-
10864
- if (backslashes === true) {
10865
- if (opts.unescape === true) {
10866
- output = output.replace(/\\/g, '');
10867
- } else {
10868
- output = output.replace(/\\+/g, m => {
10869
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
10870
- });
10871
- }
10872
- }
10873
-
10874
- if (output === input && opts.contains === true) {
10875
- state.output = input;
10876
- return state;
10877
- }
10878
-
10879
- state.output = utils$1.wrapOutput(output, state, options);
10880
- return state;
10881
- }
10882
-
10883
- /**
10884
- * Tokenize input until we reach end-of-string
10885
- */
10886
-
10887
- while (!eos()) {
10888
- value = advance();
10889
-
10890
- if (value === '\u0000') {
10891
- continue;
10892
- }
10893
-
10894
- /**
10895
- * Escaped characters
10896
- */
10897
-
10898
- if (value === '\\') {
10899
- const next = peek();
10900
-
10901
- if (next === '/' && opts.bash !== true) {
10902
- continue;
10903
- }
10904
-
10905
- if (next === '.' || next === ';') {
10906
- continue;
10907
- }
10908
-
10909
- if (!next) {
10910
- value += '\\';
10911
- push({ type: 'text', value });
10912
- continue;
10913
- }
10914
-
10915
- // collapse slashes to reduce potential for exploits
10916
- const match = /^\\+/.exec(remaining());
10917
- let slashes = 0;
10918
-
10919
- if (match && match[0].length > 2) {
10920
- slashes = match[0].length;
10921
- state.index += slashes;
10922
- if (slashes % 2 !== 0) {
10923
- value += '\\';
10924
- }
10925
- }
10926
-
10927
- if (opts.unescape === true) {
10928
- value = advance();
10929
- } else {
10930
- value += advance();
10931
- }
10932
-
10933
- if (state.brackets === 0) {
10934
- push({ type: 'text', value });
10935
- continue;
10936
- }
10937
- }
10938
-
10939
- /**
10940
- * If we're inside a regex character class, continue
10941
- * until we reach the closing bracket.
10942
- */
10943
-
10944
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
10945
- if (opts.posix !== false && value === ':') {
10946
- const inner = prev.value.slice(1);
10947
- if (inner.includes('[')) {
10948
- prev.posix = true;
10949
-
10950
- if (inner.includes(':')) {
10951
- const idx = prev.value.lastIndexOf('[');
10952
- const pre = prev.value.slice(0, idx);
10953
- const rest = prev.value.slice(idx + 2);
10954
- const posix = POSIX_REGEX_SOURCE[rest];
10955
- if (posix) {
10956
- prev.value = pre + posix;
10957
- state.backtrack = true;
10958
- advance();
10959
-
10960
- if (!bos.output && tokens.indexOf(prev) === 1) {
10961
- bos.output = ONE_CHAR;
10962
- }
10963
- continue;
10964
- }
10965
- }
10966
- }
10967
- }
10968
-
10969
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
10970
- value = `\\${value}`;
10971
- }
10972
-
10973
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
10974
- value = `\\${value}`;
10975
- }
10976
-
10977
- if (opts.posix === true && value === '!' && prev.value === '[') {
10978
- value = '^';
10979
- }
10980
-
10981
- prev.value += value;
10982
- append({ value });
10983
- continue;
10984
- }
10985
-
10986
- /**
10987
- * If we're inside a quoted string, continue
10988
- * until we reach the closing double quote.
10989
- */
10990
-
10991
- if (state.quotes === 1 && value !== '"') {
10992
- value = utils$1.escapeRegex(value);
10993
- prev.value += value;
10994
- append({ value });
10995
- continue;
10996
- }
10997
-
10998
- /**
10999
- * Double quotes
11000
- */
11001
-
11002
- if (value === '"') {
11003
- state.quotes = state.quotes === 1 ? 0 : 1;
11004
- if (opts.keepQuotes === true) {
11005
- push({ type: 'text', value });
11006
- }
11007
- continue;
11008
- }
11009
-
11010
- /**
11011
- * Parentheses
11012
- */
11013
-
11014
- if (value === '(') {
11015
- increment('parens');
11016
- push({ type: 'paren', value });
11017
- continue;
11018
- }
11019
-
11020
- if (value === ')') {
11021
- if (state.parens === 0 && opts.strictBrackets === true) {
11022
- throw new SyntaxError(syntaxError('opening', '('));
11023
- }
11024
-
11025
- const extglob = extglobs[extglobs.length - 1];
11026
- if (extglob && state.parens === extglob.parens + 1) {
11027
- extglobClose(extglobs.pop());
11028
- continue;
11029
- }
11030
-
11031
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
11032
- decrement('parens');
11033
- continue;
11034
- }
11035
-
11036
- /**
11037
- * Square brackets
11038
- */
11039
-
11040
- if (value === '[') {
11041
- if (opts.nobracket === true || !remaining().includes(']')) {
11042
- if (opts.nobracket !== true && opts.strictBrackets === true) {
11043
- throw new SyntaxError(syntaxError('closing', ']'));
11044
- }
11045
-
11046
- value = `\\${value}`;
11047
- } else {
11048
- increment('brackets');
11049
- }
11050
-
11051
- push({ type: 'bracket', value });
11052
- continue;
11053
- }
11054
-
11055
- if (value === ']') {
11056
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
11057
- push({ type: 'text', value, output: `\\${value}` });
11058
- continue;
11059
- }
11060
-
11061
- if (state.brackets === 0) {
11062
- if (opts.strictBrackets === true) {
11063
- throw new SyntaxError(syntaxError('opening', '['));
11064
- }
11065
-
11066
- push({ type: 'text', value, output: `\\${value}` });
11067
- continue;
11068
- }
11069
-
11070
- decrement('brackets');
11071
-
11072
- const prevValue = prev.value.slice(1);
11073
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
11074
- value = `/${value}`;
11075
- }
11076
-
11077
- prev.value += value;
11078
- append({ value });
11079
-
11080
- // when literal brackets are explicitly disabled
11081
- // assume we should match with a regex character class
11082
- if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
11083
- continue;
11084
- }
11085
-
11086
- const escaped = utils$1.escapeRegex(prev.value);
11087
- state.output = state.output.slice(0, -prev.value.length);
11088
-
11089
- // when literal brackets are explicitly enabled
11090
- // assume we should escape the brackets to match literal characters
11091
- if (opts.literalBrackets === true) {
11092
- state.output += escaped;
11093
- prev.value = escaped;
11094
- continue;
11095
- }
11096
-
11097
- // when the user specifies nothing, try to match both
11098
- prev.value = `(${capture}${escaped}|${prev.value})`;
11099
- state.output += prev.value;
11100
- continue;
11101
- }
11102
-
11103
- /**
11104
- * Braces
11105
- */
11106
-
11107
- if (value === '{' && opts.nobrace !== true) {
11108
- increment('braces');
11109
-
11110
- const open = {
11111
- type: 'brace',
11112
- value,
11113
- output: '(',
11114
- outputIndex: state.output.length,
11115
- tokensIndex: state.tokens.length
11116
- };
11117
-
11118
- braces.push(open);
11119
- push(open);
11120
- continue;
11121
- }
11122
-
11123
- if (value === '}') {
11124
- const brace = braces[braces.length - 1];
11125
-
11126
- if (opts.nobrace === true || !brace) {
11127
- push({ type: 'text', value, output: value });
11128
- continue;
11129
- }
11130
-
11131
- let output = ')';
11132
-
11133
- if (brace.dots === true) {
11134
- const arr = tokens.slice();
11135
- const range = [];
11136
-
11137
- for (let i = arr.length - 1; i >= 0; i--) {
11138
- tokens.pop();
11139
- if (arr[i].type === 'brace') {
11140
- break;
11141
- }
11142
- if (arr[i].type !== 'dots') {
11143
- range.unshift(arr[i].value);
11144
- }
11145
- }
11146
-
11147
- output = expandRange(range, opts);
11148
- state.backtrack = true;
11149
- }
11150
-
11151
- if (brace.comma !== true && brace.dots !== true) {
11152
- const out = state.output.slice(0, brace.outputIndex);
11153
- const toks = state.tokens.slice(brace.tokensIndex);
11154
- brace.value = brace.output = '\\{';
11155
- value = output = '\\}';
11156
- state.output = out;
11157
- for (const t of toks) {
11158
- state.output += (t.output || t.value);
11159
- }
11160
- }
11161
-
11162
- push({ type: 'brace', value, output });
11163
- decrement('braces');
11164
- braces.pop();
11165
- continue;
11166
- }
11167
-
11168
- /**
11169
- * Pipes
11170
- */
11171
-
11172
- if (value === '|') {
11173
- if (extglobs.length > 0) {
11174
- extglobs[extglobs.length - 1].conditions++;
11175
- }
11176
- push({ type: 'text', value });
11177
- continue;
11178
- }
11179
-
11180
- /**
11181
- * Commas
11182
- */
11183
-
11184
- if (value === ',') {
11185
- let output = value;
11186
-
11187
- const brace = braces[braces.length - 1];
11188
- if (brace && stack[stack.length - 1] === 'braces') {
11189
- brace.comma = true;
11190
- output = '|';
11191
- }
11192
-
11193
- push({ type: 'comma', value, output });
11194
- continue;
11195
- }
11196
-
11197
- /**
11198
- * Slashes
11199
- */
11200
-
11201
- if (value === '/') {
11202
- // if the beginning of the glob is "./", advance the start
11203
- // to the current index, and don't add the "./" characters
11204
- // to the state. This greatly simplifies lookbehinds when
11205
- // checking for BOS characters like "!" and "." (not "./")
11206
- if (prev.type === 'dot' && state.index === state.start + 1) {
11207
- state.start = state.index + 1;
11208
- state.consumed = '';
11209
- state.output = '';
11210
- tokens.pop();
11211
- prev = bos; // reset "prev" to the first token
11212
- continue;
11213
- }
11214
-
11215
- push({ type: 'slash', value, output: SLASH_LITERAL });
11216
- continue;
11217
- }
11218
-
11219
- /**
11220
- * Dots
11221
- */
11222
-
11223
- if (value === '.') {
11224
- if (state.braces > 0 && prev.type === 'dot') {
11225
- if (prev.value === '.') prev.output = DOT_LITERAL;
11226
- const brace = braces[braces.length - 1];
11227
- prev.type = 'dots';
11228
- prev.output += value;
11229
- prev.value += value;
11230
- brace.dots = true;
11231
- continue;
11232
- }
11233
-
11234
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
11235
- push({ type: 'text', value, output: DOT_LITERAL });
11236
- continue;
11237
- }
10208
+ exports.supportsLookbehinds = () => {
10209
+ const segs = process.version.slice(1).split('.').map(Number);
10210
+ if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
10211
+ return true;
10212
+ }
10213
+ return false;
10214
+ };
11238
10215
 
11239
- push({ type: 'dot', value, output: DOT_LITERAL });
11240
- continue;
11241
- }
10216
+ exports.isWindows = options => {
10217
+ if (options && typeof options.windows === 'boolean') {
10218
+ return options.windows;
10219
+ }
10220
+ return win32 === true || path.sep === '\\';
10221
+ };
11242
10222
 
11243
- /**
11244
- * Question marks
11245
- */
10223
+ exports.escapeLast = (input, char, lastIdx) => {
10224
+ const idx = input.lastIndexOf(char, lastIdx);
10225
+ if (idx === -1) return input;
10226
+ if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
10227
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
10228
+ };
11246
10229
 
11247
- if (value === '?') {
11248
- const isGroup = prev && prev.value === '(';
11249
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
11250
- extglobOpen('qmark', value);
11251
- continue;
11252
- }
10230
+ exports.removePrefix = (input, state = {}) => {
10231
+ let output = input;
10232
+ if (output.startsWith('./')) {
10233
+ output = output.slice(2);
10234
+ state.prefix = './';
10235
+ }
10236
+ return output;
10237
+ };
11253
10238
 
11254
- if (prev && prev.type === 'paren') {
11255
- const next = peek();
11256
- let output = value;
10239
+ exports.wrapOutput = (input, state = {}, options = {}) => {
10240
+ const prepend = options.contains ? '' : '^';
10241
+ const append = options.contains ? '' : '$';
11257
10242
 
11258
- if (next === '<' && !utils$1.supportsLookbehinds()) {
11259
- throw new Error('Node.js v10 or higher is required for regex lookbehinds');
11260
- }
11261
-
11262
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
11263
- output = `\\${value}`;
11264
- }
10243
+ let output = `${prepend}(?:${input})${append}`;
10244
+ if (state.negated === true) {
10245
+ output = `(?:^(?!${output}).*$)`;
10246
+ }
10247
+ return output;
10248
+ };
10249
+ } (utils));
10250
+ return utils;
10251
+ }
11265
10252
 
11266
- push({ type: 'text', value, output });
11267
- continue;
11268
- }
10253
+ var scan_1;
10254
+ var hasRequiredScan;
11269
10255
 
11270
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
11271
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
11272
- continue;
11273
- }
10256
+ function requireScan () {
10257
+ if (hasRequiredScan) return scan_1;
10258
+ hasRequiredScan = 1;
11274
10259
 
11275
- push({ type: 'qmark', value, output: QMARK });
11276
- continue;
11277
- }
10260
+ const utils = /*@__PURE__*/ requireUtils();
10261
+ const {
10262
+ CHAR_ASTERISK, /* * */
10263
+ CHAR_AT, /* @ */
10264
+ CHAR_BACKWARD_SLASH, /* \ */
10265
+ CHAR_COMMA, /* , */
10266
+ CHAR_DOT, /* . */
10267
+ CHAR_EXCLAMATION_MARK, /* ! */
10268
+ CHAR_FORWARD_SLASH, /* / */
10269
+ CHAR_LEFT_CURLY_BRACE, /* { */
10270
+ CHAR_LEFT_PARENTHESES, /* ( */
10271
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
10272
+ CHAR_PLUS, /* + */
10273
+ CHAR_QUESTION_MARK, /* ? */
10274
+ CHAR_RIGHT_CURLY_BRACE, /* } */
10275
+ CHAR_RIGHT_PARENTHESES, /* ) */
10276
+ CHAR_RIGHT_SQUARE_BRACKET /* ] */
10277
+ } = /*@__PURE__*/ requireConstants();
10278
+
10279
+ const isPathSeparator = code => {
10280
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
10281
+ };
11278
10282
 
11279
- /**
11280
- * Exclamation
11281
- */
10283
+ const depth = token => {
10284
+ if (token.isPrefix !== true) {
10285
+ token.depth = token.isGlobstar ? Infinity : 1;
10286
+ }
10287
+ };
11282
10288
 
11283
- if (value === '!') {
11284
- if (opts.noextglob !== true && peek() === '(') {
11285
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
11286
- extglobOpen('negate', value);
11287
- continue;
11288
- }
11289
- }
10289
+ /**
10290
+ * Quickly scans a glob pattern and returns an object with a handful of
10291
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
10292
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
10293
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
10294
+ *
10295
+ * ```js
10296
+ * const pm = require('picomatch');
10297
+ * console.log(pm.scan('foo/bar/*.js'));
10298
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
10299
+ * ```
10300
+ * @param {String} `str`
10301
+ * @param {Object} `options`
10302
+ * @return {Object} Returns an object with tokens and regex source string.
10303
+ * @api public
10304
+ */
10305
+
10306
+ const scan = (input, options) => {
10307
+ const opts = options || {};
10308
+
10309
+ const length = input.length - 1;
10310
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
10311
+ const slashes = [];
10312
+ const tokens = [];
10313
+ const parts = [];
10314
+
10315
+ let str = input;
10316
+ let index = -1;
10317
+ let start = 0;
10318
+ let lastIndex = 0;
10319
+ let isBrace = false;
10320
+ let isBracket = false;
10321
+ let isGlob = false;
10322
+ let isExtglob = false;
10323
+ let isGlobstar = false;
10324
+ let braceEscaped = false;
10325
+ let backslashes = false;
10326
+ let negated = false;
10327
+ let negatedExtglob = false;
10328
+ let finished = false;
10329
+ let braces = 0;
10330
+ let prev;
10331
+ let code;
10332
+ let token = { value: '', depth: 0, isGlob: false };
10333
+
10334
+ const eos = () => index >= length;
10335
+ const peek = () => str.charCodeAt(index + 1);
10336
+ const advance = () => {
10337
+ prev = code;
10338
+ return str.charCodeAt(++index);
10339
+ };
10340
+
10341
+ while (index < length) {
10342
+ code = advance();
10343
+ let next;
10344
+
10345
+ if (code === CHAR_BACKWARD_SLASH) {
10346
+ backslashes = token.backslashes = true;
10347
+ code = advance();
10348
+
10349
+ if (code === CHAR_LEFT_CURLY_BRACE) {
10350
+ braceEscaped = true;
10351
+ }
10352
+ continue;
10353
+ }
10354
+
10355
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
10356
+ braces++;
10357
+
10358
+ while (eos() !== true && (code = advance())) {
10359
+ if (code === CHAR_BACKWARD_SLASH) {
10360
+ backslashes = token.backslashes = true;
10361
+ advance();
10362
+ continue;
10363
+ }
10364
+
10365
+ if (code === CHAR_LEFT_CURLY_BRACE) {
10366
+ braces++;
10367
+ continue;
10368
+ }
10369
+
10370
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
10371
+ isBrace = token.isBrace = true;
10372
+ isGlob = token.isGlob = true;
10373
+ finished = true;
10374
+
10375
+ if (scanToEnd === true) {
10376
+ continue;
10377
+ }
10378
+
10379
+ break;
10380
+ }
10381
+
10382
+ if (braceEscaped !== true && code === CHAR_COMMA) {
10383
+ isBrace = token.isBrace = true;
10384
+ isGlob = token.isGlob = true;
10385
+ finished = true;
10386
+
10387
+ if (scanToEnd === true) {
10388
+ continue;
10389
+ }
10390
+
10391
+ break;
10392
+ }
10393
+
10394
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
10395
+ braces--;
10396
+
10397
+ if (braces === 0) {
10398
+ braceEscaped = false;
10399
+ isBrace = token.isBrace = true;
10400
+ finished = true;
10401
+ break;
10402
+ }
10403
+ }
10404
+ }
10405
+
10406
+ if (scanToEnd === true) {
10407
+ continue;
10408
+ }
10409
+
10410
+ break;
10411
+ }
10412
+
10413
+ if (code === CHAR_FORWARD_SLASH) {
10414
+ slashes.push(index);
10415
+ tokens.push(token);
10416
+ token = { value: '', depth: 0, isGlob: false };
10417
+
10418
+ if (finished === true) continue;
10419
+ if (prev === CHAR_DOT && index === (start + 1)) {
10420
+ start += 2;
10421
+ continue;
10422
+ }
10423
+
10424
+ lastIndex = index + 1;
10425
+ continue;
10426
+ }
10427
+
10428
+ if (opts.noext !== true) {
10429
+ const isExtglobChar = code === CHAR_PLUS
10430
+ || code === CHAR_AT
10431
+ || code === CHAR_ASTERISK
10432
+ || code === CHAR_QUESTION_MARK
10433
+ || code === CHAR_EXCLAMATION_MARK;
10434
+
10435
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
10436
+ isGlob = token.isGlob = true;
10437
+ isExtglob = token.isExtglob = true;
10438
+ finished = true;
10439
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
10440
+ negatedExtglob = true;
10441
+ }
10442
+
10443
+ if (scanToEnd === true) {
10444
+ while (eos() !== true && (code = advance())) {
10445
+ if (code === CHAR_BACKWARD_SLASH) {
10446
+ backslashes = token.backslashes = true;
10447
+ code = advance();
10448
+ continue;
10449
+ }
10450
+
10451
+ if (code === CHAR_RIGHT_PARENTHESES) {
10452
+ isGlob = token.isGlob = true;
10453
+ finished = true;
10454
+ break;
10455
+ }
10456
+ }
10457
+ continue;
10458
+ }
10459
+ break;
10460
+ }
10461
+ }
10462
+
10463
+ if (code === CHAR_ASTERISK) {
10464
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
10465
+ isGlob = token.isGlob = true;
10466
+ finished = true;
10467
+
10468
+ if (scanToEnd === true) {
10469
+ continue;
10470
+ }
10471
+ break;
10472
+ }
10473
+
10474
+ if (code === CHAR_QUESTION_MARK) {
10475
+ isGlob = token.isGlob = true;
10476
+ finished = true;
10477
+
10478
+ if (scanToEnd === true) {
10479
+ continue;
10480
+ }
10481
+ break;
10482
+ }
10483
+
10484
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
10485
+ while (eos() !== true && (next = advance())) {
10486
+ if (next === CHAR_BACKWARD_SLASH) {
10487
+ backslashes = token.backslashes = true;
10488
+ advance();
10489
+ continue;
10490
+ }
10491
+
10492
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
10493
+ isBracket = token.isBracket = true;
10494
+ isGlob = token.isGlob = true;
10495
+ finished = true;
10496
+ break;
10497
+ }
10498
+ }
10499
+
10500
+ if (scanToEnd === true) {
10501
+ continue;
10502
+ }
10503
+
10504
+ break;
10505
+ }
10506
+
10507
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
10508
+ negated = token.negated = true;
10509
+ start++;
10510
+ continue;
10511
+ }
10512
+
10513
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
10514
+ isGlob = token.isGlob = true;
10515
+
10516
+ if (scanToEnd === true) {
10517
+ while (eos() !== true && (code = advance())) {
10518
+ if (code === CHAR_LEFT_PARENTHESES) {
10519
+ backslashes = token.backslashes = true;
10520
+ code = advance();
10521
+ continue;
10522
+ }
10523
+
10524
+ if (code === CHAR_RIGHT_PARENTHESES) {
10525
+ finished = true;
10526
+ break;
10527
+ }
10528
+ }
10529
+ continue;
10530
+ }
10531
+ break;
10532
+ }
10533
+
10534
+ if (isGlob === true) {
10535
+ finished = true;
10536
+
10537
+ if (scanToEnd === true) {
10538
+ continue;
10539
+ }
10540
+
10541
+ break;
10542
+ }
10543
+ }
11290
10544
 
11291
- if (opts.nonegate !== true && state.index === 0) {
11292
- negate();
11293
- continue;
11294
- }
11295
- }
10545
+ if (opts.noext === true) {
10546
+ isExtglob = false;
10547
+ isGlob = false;
10548
+ }
11296
10549
 
11297
- /**
11298
- * Plus
11299
- */
10550
+ let base = str;
10551
+ let prefix = '';
10552
+ let glob = '';
11300
10553
 
11301
- if (value === '+') {
11302
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
11303
- extglobOpen('plus', value);
11304
- continue;
11305
- }
10554
+ if (start > 0) {
10555
+ prefix = str.slice(0, start);
10556
+ str = str.slice(start);
10557
+ lastIndex -= start;
10558
+ }
11306
10559
 
11307
- if ((prev && prev.value === '(') || opts.regex === false) {
11308
- push({ type: 'plus', value, output: PLUS_LITERAL });
11309
- continue;
11310
- }
10560
+ if (base && isGlob === true && lastIndex > 0) {
10561
+ base = str.slice(0, lastIndex);
10562
+ glob = str.slice(lastIndex);
10563
+ } else if (isGlob === true) {
10564
+ base = '';
10565
+ glob = str;
10566
+ } else {
10567
+ base = str;
10568
+ }
11311
10569
 
11312
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
11313
- push({ type: 'plus', value });
11314
- continue;
11315
- }
10570
+ if (base && base !== '' && base !== '/' && base !== str) {
10571
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
10572
+ base = base.slice(0, -1);
10573
+ }
10574
+ }
11316
10575
 
11317
- push({ type: 'plus', value: PLUS_LITERAL });
11318
- continue;
11319
- }
10576
+ if (opts.unescape === true) {
10577
+ if (glob) glob = utils.removeBackslashes(glob);
11320
10578
 
11321
- /**
11322
- * Plain text
11323
- */
10579
+ if (base && backslashes === true) {
10580
+ base = utils.removeBackslashes(base);
10581
+ }
10582
+ }
11324
10583
 
11325
- if (value === '@') {
11326
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
11327
- push({ type: 'at', extglob: true, value, output: '' });
11328
- continue;
11329
- }
10584
+ const state = {
10585
+ prefix,
10586
+ input,
10587
+ start,
10588
+ base,
10589
+ glob,
10590
+ isBrace,
10591
+ isBracket,
10592
+ isGlob,
10593
+ isExtglob,
10594
+ isGlobstar,
10595
+ negated,
10596
+ negatedExtglob
10597
+ };
10598
+
10599
+ if (opts.tokens === true) {
10600
+ state.maxDepth = 0;
10601
+ if (!isPathSeparator(code)) {
10602
+ tokens.push(token);
10603
+ }
10604
+ state.tokens = tokens;
10605
+ }
11330
10606
 
11331
- push({ type: 'text', value });
11332
- continue;
11333
- }
10607
+ if (opts.parts === true || opts.tokens === true) {
10608
+ let prevIndex;
10609
+
10610
+ for (let idx = 0; idx < slashes.length; idx++) {
10611
+ const n = prevIndex ? prevIndex + 1 : start;
10612
+ const i = slashes[idx];
10613
+ const value = input.slice(n, i);
10614
+ if (opts.tokens) {
10615
+ if (idx === 0 && start !== 0) {
10616
+ tokens[idx].isPrefix = true;
10617
+ tokens[idx].value = prefix;
10618
+ } else {
10619
+ tokens[idx].value = value;
10620
+ }
10621
+ depth(tokens[idx]);
10622
+ state.maxDepth += tokens[idx].depth;
10623
+ }
10624
+ if (idx !== 0 || value !== '') {
10625
+ parts.push(value);
10626
+ }
10627
+ prevIndex = i;
10628
+ }
10629
+
10630
+ if (prevIndex && prevIndex + 1 < input.length) {
10631
+ const value = input.slice(prevIndex + 1);
10632
+ parts.push(value);
10633
+
10634
+ if (opts.tokens) {
10635
+ tokens[tokens.length - 1].value = value;
10636
+ depth(tokens[tokens.length - 1]);
10637
+ state.maxDepth += tokens[tokens.length - 1].depth;
10638
+ }
10639
+ }
10640
+
10641
+ state.slashes = slashes;
10642
+ state.parts = parts;
10643
+ }
11334
10644
 
11335
- /**
11336
- * Plain text
11337
- */
10645
+ return state;
10646
+ };
11338
10647
 
11339
- if (value !== '*') {
11340
- if (value === '$' || value === '^') {
11341
- value = `\\${value}`;
11342
- }
10648
+ scan_1 = scan;
10649
+ return scan_1;
10650
+ }
11343
10651
 
11344
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
11345
- if (match) {
11346
- value += match[0];
11347
- state.index += match[0].length;
11348
- }
10652
+ var parse_1;
10653
+ var hasRequiredParse;
11349
10654
 
11350
- push({ type: 'text', value });
11351
- continue;
11352
- }
10655
+ function requireParse () {
10656
+ if (hasRequiredParse) return parse_1;
10657
+ hasRequiredParse = 1;
11353
10658
 
11354
- /**
11355
- * Stars
11356
- */
10659
+ const constants = /*@__PURE__*/ requireConstants();
10660
+ const utils = /*@__PURE__*/ requireUtils();
11357
10661
 
11358
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
11359
- prev.type = 'star';
11360
- prev.star = true;
11361
- prev.value += value;
11362
- prev.output = star;
11363
- state.backtrack = true;
11364
- state.globstar = true;
11365
- consume(value);
11366
- continue;
11367
- }
11368
-
11369
- let rest = remaining();
11370
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
11371
- extglobOpen('star', value);
11372
- continue;
11373
- }
11374
-
11375
- if (prev.type === 'star') {
11376
- if (opts.noglobstar === true) {
11377
- consume(value);
11378
- continue;
11379
- }
11380
-
11381
- const prior = prev.prev;
11382
- const before = prior.prev;
11383
- const isStart = prior.type === 'slash' || prior.type === 'bos';
11384
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
11385
-
11386
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
11387
- push({ type: 'star', value, output: '' });
11388
- continue;
11389
- }
11390
-
11391
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
11392
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
11393
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
11394
- push({ type: 'star', value, output: '' });
11395
- continue;
11396
- }
11397
-
11398
- // strip consecutive `/**/`
11399
- while (rest.slice(0, 3) === '/**') {
11400
- const after = input[state.index + 4];
11401
- if (after && after !== '/') {
11402
- break;
11403
- }
11404
- rest = rest.slice(3);
11405
- consume('/**', 3);
11406
- }
11407
-
11408
- if (prior.type === 'bos' && eos()) {
11409
- prev.type = 'globstar';
11410
- prev.value += value;
11411
- prev.output = globstar(opts);
11412
- state.output = prev.output;
11413
- state.globstar = true;
11414
- consume(value);
11415
- continue;
11416
- }
11417
-
11418
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
11419
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
11420
- prior.output = `(?:${prior.output}`;
11421
-
11422
- prev.type = 'globstar';
11423
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
11424
- prev.value += value;
11425
- state.globstar = true;
11426
- state.output += prior.output + prev.output;
11427
- consume(value);
11428
- continue;
11429
- }
11430
-
11431
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
11432
- const end = rest[1] !== void 0 ? '|$' : '';
11433
-
11434
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
11435
- prior.output = `(?:${prior.output}`;
11436
-
11437
- prev.type = 'globstar';
11438
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
11439
- prev.value += value;
11440
-
11441
- state.output += prior.output + prev.output;
11442
- state.globstar = true;
11443
-
11444
- consume(value + advance());
11445
-
11446
- push({ type: 'slash', value: '/', output: '' });
11447
- continue;
11448
- }
11449
-
11450
- if (prior.type === 'bos' && rest[0] === '/') {
11451
- prev.type = 'globstar';
11452
- prev.value += value;
11453
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
11454
- state.output = prev.output;
11455
- state.globstar = true;
11456
- consume(value + advance());
11457
- push({ type: 'slash', value: '/', output: '' });
11458
- continue;
11459
- }
11460
-
11461
- // remove single star from output
11462
- state.output = state.output.slice(0, -prev.output.length);
11463
-
11464
- // reset previous token to globstar
11465
- prev.type = 'globstar';
11466
- prev.output = globstar(opts);
11467
- prev.value += value;
11468
-
11469
- // reset output with globstar
11470
- state.output += prev.output;
11471
- state.globstar = true;
11472
- consume(value);
11473
- continue;
11474
- }
11475
-
11476
- const token = { type: 'star', value, output: star };
11477
-
11478
- if (opts.bash === true) {
11479
- token.output = '.*?';
11480
- if (prev.type === 'bos' || prev.type === 'slash') {
11481
- token.output = nodot + token.output;
11482
- }
11483
- push(token);
11484
- continue;
11485
- }
11486
-
11487
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
11488
- token.output = value;
11489
- push(token);
11490
- continue;
11491
- }
11492
-
11493
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
11494
- if (prev.type === 'dot') {
11495
- state.output += NO_DOT_SLASH;
11496
- prev.output += NO_DOT_SLASH;
11497
-
11498
- } else if (opts.dot === true) {
11499
- state.output += NO_DOTS_SLASH;
11500
- prev.output += NO_DOTS_SLASH;
11501
-
11502
- } else {
11503
- state.output += nodot;
11504
- prev.output += nodot;
11505
- }
11506
-
11507
- if (peek() !== '*') {
11508
- state.output += ONE_CHAR;
11509
- prev.output += ONE_CHAR;
11510
- }
11511
- }
11512
-
11513
- push(token);
11514
- }
10662
+ /**
10663
+ * Constants
10664
+ */
11515
10665
 
11516
- while (state.brackets > 0) {
11517
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
11518
- state.output = utils$1.escapeLast(state.output, '[');
11519
- decrement('brackets');
11520
- }
10666
+ const {
10667
+ MAX_LENGTH,
10668
+ POSIX_REGEX_SOURCE,
10669
+ REGEX_NON_SPECIAL_CHARS,
10670
+ REGEX_SPECIAL_CHARS_BACKREF,
10671
+ REPLACEMENTS
10672
+ } = constants;
10673
+
10674
+ /**
10675
+ * Helpers
10676
+ */
10677
+
10678
+ const expandRange = (args, options) => {
10679
+ if (typeof options.expandRange === 'function') {
10680
+ return options.expandRange(...args, options);
10681
+ }
11521
10682
 
11522
- while (state.parens > 0) {
11523
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
11524
- state.output = utils$1.escapeLast(state.output, '(');
11525
- decrement('parens');
11526
- }
10683
+ args.sort();
10684
+ const value = `[${args.join('-')}]`;
11527
10685
 
11528
- while (state.braces > 0) {
11529
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
11530
- state.output = utils$1.escapeLast(state.output, '{');
11531
- decrement('braces');
11532
- }
10686
+ return value;
10687
+ };
11533
10688
 
11534
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
11535
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
11536
- }
10689
+ /**
10690
+ * Create the message for a syntax error
10691
+ */
11537
10692
 
11538
- // rebuild the output if we had to backtrack at any point
11539
- if (state.backtrack === true) {
11540
- state.output = '';
10693
+ const syntaxError = (type, char) => {
10694
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
10695
+ };
11541
10696
 
11542
- for (const token of state.tokens) {
11543
- state.output += token.output != null ? token.output : token.value;
10697
+ /**
10698
+ * Parse the given input string.
10699
+ * @param {String} input
10700
+ * @param {Object} options
10701
+ * @return {Object}
10702
+ */
11544
10703
 
11545
- if (token.suffix) {
11546
- state.output += token.suffix;
11547
- }
11548
- }
11549
- }
10704
+ const parse = (input, options) => {
10705
+ if (typeof input !== 'string') {
10706
+ throw new TypeError('Expected a string');
10707
+ }
11550
10708
 
11551
- return state;
11552
- };
10709
+ input = REPLACEMENTS[input] || input;
11553
10710
 
11554
- /**
11555
- * Fast paths for creating regular expressions for common glob patterns.
11556
- * This can significantly speed up processing and has very little downside
11557
- * impact when none of the fast paths match.
11558
- */
10711
+ const opts = { ...options };
10712
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
11559
10713
 
11560
- parse$1.fastpaths = (input, options) => {
11561
- const opts = { ...options };
11562
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
11563
- const len = input.length;
11564
- if (len > max) {
11565
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
11566
- }
10714
+ let len = input.length;
10715
+ if (len > max) {
10716
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
10717
+ }
11567
10718
 
11568
- input = REPLACEMENTS[input] || input;
11569
- const win32 = utils$1.isWindows(options);
11570
-
11571
- // create constants based on platform, for windows or posix
11572
- const {
11573
- DOT_LITERAL,
11574
- SLASH_LITERAL,
11575
- ONE_CHAR,
11576
- DOTS_SLASH,
11577
- NO_DOT,
11578
- NO_DOTS,
11579
- NO_DOTS_SLASH,
11580
- STAR,
11581
- START_ANCHOR
11582
- } = constants$1.globChars(win32);
11583
-
11584
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
11585
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
11586
- const capture = opts.capture ? '' : '?:';
11587
- const state = { negated: false, prefix: '' };
11588
- let star = opts.bash === true ? '.*?' : STAR;
11589
-
11590
- if (opts.capture) {
11591
- star = `(${star})`;
11592
- }
10719
+ const bos = { type: 'bos', value: '', output: opts.prepend || '' };
10720
+ const tokens = [bos];
10721
+
10722
+ const capture = opts.capture ? '' : '?:';
10723
+ const win32 = utils.isWindows(options);
10724
+
10725
+ // create constants based on platform, for windows or posix
10726
+ const PLATFORM_CHARS = constants.globChars(win32);
10727
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
10728
+
10729
+ const {
10730
+ DOT_LITERAL,
10731
+ PLUS_LITERAL,
10732
+ SLASH_LITERAL,
10733
+ ONE_CHAR,
10734
+ DOTS_SLASH,
10735
+ NO_DOT,
10736
+ NO_DOT_SLASH,
10737
+ NO_DOTS_SLASH,
10738
+ QMARK,
10739
+ QMARK_NO_DOT,
10740
+ STAR,
10741
+ START_ANCHOR
10742
+ } = PLATFORM_CHARS;
10743
+
10744
+ const globstar = opts => {
10745
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
10746
+ };
10747
+
10748
+ const nodot = opts.dot ? '' : NO_DOT;
10749
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
10750
+ let star = opts.bash === true ? globstar(opts) : STAR;
10751
+
10752
+ if (opts.capture) {
10753
+ star = `(${star})`;
10754
+ }
11593
10755
 
11594
- const globstar = opts => {
11595
- if (opts.noglobstar === true) return star;
11596
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
11597
- };
10756
+ // minimatch options support
10757
+ if (typeof opts.noext === 'boolean') {
10758
+ opts.noextglob = opts.noext;
10759
+ }
11598
10760
 
11599
- const create = str => {
11600
- switch (str) {
11601
- case '*':
11602
- return `${nodot}${ONE_CHAR}${star}`;
10761
+ const state = {
10762
+ input,
10763
+ index: -1,
10764
+ start: 0,
10765
+ dot: opts.dot === true,
10766
+ consumed: '',
10767
+ output: '',
10768
+ prefix: '',
10769
+ backtrack: false,
10770
+ negated: false,
10771
+ brackets: 0,
10772
+ braces: 0,
10773
+ parens: 0,
10774
+ quotes: 0,
10775
+ globstar: false,
10776
+ tokens
10777
+ };
10778
+
10779
+ input = utils.removePrefix(input, state);
10780
+ len = input.length;
10781
+
10782
+ const extglobs = [];
10783
+ const braces = [];
10784
+ const stack = [];
10785
+ let prev = bos;
10786
+ let value;
10787
+
10788
+ /**
10789
+ * Tokenizing helpers
10790
+ */
10791
+
10792
+ const eos = () => state.index === len - 1;
10793
+ const peek = state.peek = (n = 1) => input[state.index + n];
10794
+ const advance = state.advance = () => input[++state.index] || '';
10795
+ const remaining = () => input.slice(state.index + 1);
10796
+ const consume = (value = '', num = 0) => {
10797
+ state.consumed += value;
10798
+ state.index += num;
10799
+ };
10800
+
10801
+ const append = token => {
10802
+ state.output += token.output != null ? token.output : token.value;
10803
+ consume(token.value);
10804
+ };
10805
+
10806
+ const negate = () => {
10807
+ let count = 1;
10808
+
10809
+ while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
10810
+ advance();
10811
+ state.start++;
10812
+ count++;
10813
+ }
10814
+
10815
+ if (count % 2 === 0) {
10816
+ return false;
10817
+ }
10818
+
10819
+ state.negated = true;
10820
+ state.start++;
10821
+ return true;
10822
+ };
10823
+
10824
+ const increment = type => {
10825
+ state[type]++;
10826
+ stack.push(type);
10827
+ };
10828
+
10829
+ const decrement = type => {
10830
+ state[type]--;
10831
+ stack.pop();
10832
+ };
10833
+
10834
+ /**
10835
+ * Push tokens onto the tokens array. This helper speeds up
10836
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
10837
+ * and 2) helping us avoid creating extra tokens when consecutive
10838
+ * characters are plain text. This improves performance and simplifies
10839
+ * lookbehinds.
10840
+ */
10841
+
10842
+ const push = tok => {
10843
+ if (prev.type === 'globstar') {
10844
+ const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
10845
+ const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
10846
+
10847
+ if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
10848
+ state.output = state.output.slice(0, -prev.output.length);
10849
+ prev.type = 'star';
10850
+ prev.value = '*';
10851
+ prev.output = star;
10852
+ state.output += prev.output;
10853
+ }
10854
+ }
10855
+
10856
+ if (extglobs.length && tok.type !== 'paren') {
10857
+ extglobs[extglobs.length - 1].inner += tok.value;
10858
+ }
10859
+
10860
+ if (tok.value || tok.output) append(tok);
10861
+ if (prev && prev.type === 'text' && tok.type === 'text') {
10862
+ prev.value += tok.value;
10863
+ prev.output = (prev.output || '') + tok.value;
10864
+ return;
10865
+ }
10866
+
10867
+ tok.prev = prev;
10868
+ tokens.push(tok);
10869
+ prev = tok;
10870
+ };
10871
+
10872
+ const extglobOpen = (type, value) => {
10873
+ const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
10874
+
10875
+ token.prev = prev;
10876
+ token.parens = state.parens;
10877
+ token.output = state.output;
10878
+ const output = (opts.capture ? '(' : '') + token.open;
10879
+
10880
+ increment('parens');
10881
+ push({ type, value, output: state.output ? '' : ONE_CHAR });
10882
+ push({ type: 'paren', extglob: true, value: advance(), output });
10883
+ extglobs.push(token);
10884
+ };
10885
+
10886
+ const extglobClose = token => {
10887
+ let output = token.close + (opts.capture ? ')' : '');
10888
+ let rest;
10889
+
10890
+ if (token.type === 'negate') {
10891
+ let extglobStar = star;
10892
+
10893
+ if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
10894
+ extglobStar = globstar(opts);
10895
+ }
10896
+
10897
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
10898
+ output = token.close = `)$))${extglobStar}`;
10899
+ }
10900
+
10901
+ if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
10902
+ // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
10903
+ // In this case, we need to parse the string and use it in the output of the original pattern.
10904
+ // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
10905
+ //
10906
+ // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
10907
+ const expression = parse(rest, { ...options, fastpaths: false }).output;
10908
+
10909
+ output = token.close = `)${expression})${extglobStar})`;
10910
+ }
10911
+
10912
+ if (token.prev.type === 'bos') {
10913
+ state.negatedExtglob = true;
10914
+ }
10915
+ }
10916
+
10917
+ push({ type: 'paren', extglob: true, value, output });
10918
+ decrement('parens');
10919
+ };
10920
+
10921
+ /**
10922
+ * Fast paths
10923
+ */
10924
+
10925
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
10926
+ let backslashes = false;
10927
+
10928
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
10929
+ if (first === '\\') {
10930
+ backslashes = true;
10931
+ return m;
10932
+ }
10933
+
10934
+ if (first === '?') {
10935
+ if (esc) {
10936
+ return esc + first + (rest ? QMARK.repeat(rest.length) : '');
10937
+ }
10938
+ if (index === 0) {
10939
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
10940
+ }
10941
+ return QMARK.repeat(chars.length);
10942
+ }
10943
+
10944
+ if (first === '.') {
10945
+ return DOT_LITERAL.repeat(chars.length);
10946
+ }
10947
+
10948
+ if (first === '*') {
10949
+ if (esc) {
10950
+ return esc + first + (rest ? star : '');
10951
+ }
10952
+ return star;
10953
+ }
10954
+ return esc ? m : `\\${m}`;
10955
+ });
10956
+
10957
+ if (backslashes === true) {
10958
+ if (opts.unescape === true) {
10959
+ output = output.replace(/\\/g, '');
10960
+ } else {
10961
+ output = output.replace(/\\+/g, m => {
10962
+ return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
10963
+ });
10964
+ }
10965
+ }
10966
+
10967
+ if (output === input && opts.contains === true) {
10968
+ state.output = input;
10969
+ return state;
10970
+ }
10971
+
10972
+ state.output = utils.wrapOutput(output, state, options);
10973
+ return state;
10974
+ }
11603
10975
 
11604
- case '.*':
11605
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
10976
+ /**
10977
+ * Tokenize input until we reach end-of-string
10978
+ */
10979
+
10980
+ while (!eos()) {
10981
+ value = advance();
10982
+
10983
+ if (value === '\u0000') {
10984
+ continue;
10985
+ }
10986
+
10987
+ /**
10988
+ * Escaped characters
10989
+ */
10990
+
10991
+ if (value === '\\') {
10992
+ const next = peek();
10993
+
10994
+ if (next === '/' && opts.bash !== true) {
10995
+ continue;
10996
+ }
10997
+
10998
+ if (next === '.' || next === ';') {
10999
+ continue;
11000
+ }
11001
+
11002
+ if (!next) {
11003
+ value += '\\';
11004
+ push({ type: 'text', value });
11005
+ continue;
11006
+ }
11007
+
11008
+ // collapse slashes to reduce potential for exploits
11009
+ const match = /^\\+/.exec(remaining());
11010
+ let slashes = 0;
11011
+
11012
+ if (match && match[0].length > 2) {
11013
+ slashes = match[0].length;
11014
+ state.index += slashes;
11015
+ if (slashes % 2 !== 0) {
11016
+ value += '\\';
11017
+ }
11018
+ }
11019
+
11020
+ if (opts.unescape === true) {
11021
+ value = advance();
11022
+ } else {
11023
+ value += advance();
11024
+ }
11025
+
11026
+ if (state.brackets === 0) {
11027
+ push({ type: 'text', value });
11028
+ continue;
11029
+ }
11030
+ }
11031
+
11032
+ /**
11033
+ * If we're inside a regex character class, continue
11034
+ * until we reach the closing bracket.
11035
+ */
11036
+
11037
+ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
11038
+ if (opts.posix !== false && value === ':') {
11039
+ const inner = prev.value.slice(1);
11040
+ if (inner.includes('[')) {
11041
+ prev.posix = true;
11042
+
11043
+ if (inner.includes(':')) {
11044
+ const idx = prev.value.lastIndexOf('[');
11045
+ const pre = prev.value.slice(0, idx);
11046
+ const rest = prev.value.slice(idx + 2);
11047
+ const posix = POSIX_REGEX_SOURCE[rest];
11048
+ if (posix) {
11049
+ prev.value = pre + posix;
11050
+ state.backtrack = true;
11051
+ advance();
11052
+
11053
+ if (!bos.output && tokens.indexOf(prev) === 1) {
11054
+ bos.output = ONE_CHAR;
11055
+ }
11056
+ continue;
11057
+ }
11058
+ }
11059
+ }
11060
+ }
11061
+
11062
+ if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
11063
+ value = `\\${value}`;
11064
+ }
11065
+
11066
+ if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
11067
+ value = `\\${value}`;
11068
+ }
11069
+
11070
+ if (opts.posix === true && value === '!' && prev.value === '[') {
11071
+ value = '^';
11072
+ }
11073
+
11074
+ prev.value += value;
11075
+ append({ value });
11076
+ continue;
11077
+ }
11078
+
11079
+ /**
11080
+ * If we're inside a quoted string, continue
11081
+ * until we reach the closing double quote.
11082
+ */
11083
+
11084
+ if (state.quotes === 1 && value !== '"') {
11085
+ value = utils.escapeRegex(value);
11086
+ prev.value += value;
11087
+ append({ value });
11088
+ continue;
11089
+ }
11090
+
11091
+ /**
11092
+ * Double quotes
11093
+ */
11094
+
11095
+ if (value === '"') {
11096
+ state.quotes = state.quotes === 1 ? 0 : 1;
11097
+ if (opts.keepQuotes === true) {
11098
+ push({ type: 'text', value });
11099
+ }
11100
+ continue;
11101
+ }
11102
+
11103
+ /**
11104
+ * Parentheses
11105
+ */
11106
+
11107
+ if (value === '(') {
11108
+ increment('parens');
11109
+ push({ type: 'paren', value });
11110
+ continue;
11111
+ }
11112
+
11113
+ if (value === ')') {
11114
+ if (state.parens === 0 && opts.strictBrackets === true) {
11115
+ throw new SyntaxError(syntaxError('opening', '('));
11116
+ }
11117
+
11118
+ const extglob = extglobs[extglobs.length - 1];
11119
+ if (extglob && state.parens === extglob.parens + 1) {
11120
+ extglobClose(extglobs.pop());
11121
+ continue;
11122
+ }
11123
+
11124
+ push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
11125
+ decrement('parens');
11126
+ continue;
11127
+ }
11128
+
11129
+ /**
11130
+ * Square brackets
11131
+ */
11132
+
11133
+ if (value === '[') {
11134
+ if (opts.nobracket === true || !remaining().includes(']')) {
11135
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
11136
+ throw new SyntaxError(syntaxError('closing', ']'));
11137
+ }
11138
+
11139
+ value = `\\${value}`;
11140
+ } else {
11141
+ increment('brackets');
11142
+ }
11143
+
11144
+ push({ type: 'bracket', value });
11145
+ continue;
11146
+ }
11147
+
11148
+ if (value === ']') {
11149
+ if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
11150
+ push({ type: 'text', value, output: `\\${value}` });
11151
+ continue;
11152
+ }
11153
+
11154
+ if (state.brackets === 0) {
11155
+ if (opts.strictBrackets === true) {
11156
+ throw new SyntaxError(syntaxError('opening', '['));
11157
+ }
11158
+
11159
+ push({ type: 'text', value, output: `\\${value}` });
11160
+ continue;
11161
+ }
11162
+
11163
+ decrement('brackets');
11164
+
11165
+ const prevValue = prev.value.slice(1);
11166
+ if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
11167
+ value = `/${value}`;
11168
+ }
11169
+
11170
+ prev.value += value;
11171
+ append({ value });
11172
+
11173
+ // when literal brackets are explicitly disabled
11174
+ // assume we should match with a regex character class
11175
+ if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
11176
+ continue;
11177
+ }
11178
+
11179
+ const escaped = utils.escapeRegex(prev.value);
11180
+ state.output = state.output.slice(0, -prev.value.length);
11181
+
11182
+ // when literal brackets are explicitly enabled
11183
+ // assume we should escape the brackets to match literal characters
11184
+ if (opts.literalBrackets === true) {
11185
+ state.output += escaped;
11186
+ prev.value = escaped;
11187
+ continue;
11188
+ }
11189
+
11190
+ // when the user specifies nothing, try to match both
11191
+ prev.value = `(${capture}${escaped}|${prev.value})`;
11192
+ state.output += prev.value;
11193
+ continue;
11194
+ }
11195
+
11196
+ /**
11197
+ * Braces
11198
+ */
11199
+
11200
+ if (value === '{' && opts.nobrace !== true) {
11201
+ increment('braces');
11202
+
11203
+ const open = {
11204
+ type: 'brace',
11205
+ value,
11206
+ output: '(',
11207
+ outputIndex: state.output.length,
11208
+ tokensIndex: state.tokens.length
11209
+ };
11210
+
11211
+ braces.push(open);
11212
+ push(open);
11213
+ continue;
11214
+ }
11215
+
11216
+ if (value === '}') {
11217
+ const brace = braces[braces.length - 1];
11218
+
11219
+ if (opts.nobrace === true || !brace) {
11220
+ push({ type: 'text', value, output: value });
11221
+ continue;
11222
+ }
11223
+
11224
+ let output = ')';
11225
+
11226
+ if (brace.dots === true) {
11227
+ const arr = tokens.slice();
11228
+ const range = [];
11229
+
11230
+ for (let i = arr.length - 1; i >= 0; i--) {
11231
+ tokens.pop();
11232
+ if (arr[i].type === 'brace') {
11233
+ break;
11234
+ }
11235
+ if (arr[i].type !== 'dots') {
11236
+ range.unshift(arr[i].value);
11237
+ }
11238
+ }
11239
+
11240
+ output = expandRange(range, opts);
11241
+ state.backtrack = true;
11242
+ }
11243
+
11244
+ if (brace.comma !== true && brace.dots !== true) {
11245
+ const out = state.output.slice(0, brace.outputIndex);
11246
+ const toks = state.tokens.slice(brace.tokensIndex);
11247
+ brace.value = brace.output = '\\{';
11248
+ value = output = '\\}';
11249
+ state.output = out;
11250
+ for (const t of toks) {
11251
+ state.output += (t.output || t.value);
11252
+ }
11253
+ }
11254
+
11255
+ push({ type: 'brace', value, output });
11256
+ decrement('braces');
11257
+ braces.pop();
11258
+ continue;
11259
+ }
11260
+
11261
+ /**
11262
+ * Pipes
11263
+ */
11264
+
11265
+ if (value === '|') {
11266
+ if (extglobs.length > 0) {
11267
+ extglobs[extglobs.length - 1].conditions++;
11268
+ }
11269
+ push({ type: 'text', value });
11270
+ continue;
11271
+ }
11272
+
11273
+ /**
11274
+ * Commas
11275
+ */
11276
+
11277
+ if (value === ',') {
11278
+ let output = value;
11279
+
11280
+ const brace = braces[braces.length - 1];
11281
+ if (brace && stack[stack.length - 1] === 'braces') {
11282
+ brace.comma = true;
11283
+ output = '|';
11284
+ }
11285
+
11286
+ push({ type: 'comma', value, output });
11287
+ continue;
11288
+ }
11289
+
11290
+ /**
11291
+ * Slashes
11292
+ */
11293
+
11294
+ if (value === '/') {
11295
+ // if the beginning of the glob is "./", advance the start
11296
+ // to the current index, and don't add the "./" characters
11297
+ // to the state. This greatly simplifies lookbehinds when
11298
+ // checking for BOS characters like "!" and "." (not "./")
11299
+ if (prev.type === 'dot' && state.index === state.start + 1) {
11300
+ state.start = state.index + 1;
11301
+ state.consumed = '';
11302
+ state.output = '';
11303
+ tokens.pop();
11304
+ prev = bos; // reset "prev" to the first token
11305
+ continue;
11306
+ }
11307
+
11308
+ push({ type: 'slash', value, output: SLASH_LITERAL });
11309
+ continue;
11310
+ }
11311
+
11312
+ /**
11313
+ * Dots
11314
+ */
11315
+
11316
+ if (value === '.') {
11317
+ if (state.braces > 0 && prev.type === 'dot') {
11318
+ if (prev.value === '.') prev.output = DOT_LITERAL;
11319
+ const brace = braces[braces.length - 1];
11320
+ prev.type = 'dots';
11321
+ prev.output += value;
11322
+ prev.value += value;
11323
+ brace.dots = true;
11324
+ continue;
11325
+ }
11326
+
11327
+ if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
11328
+ push({ type: 'text', value, output: DOT_LITERAL });
11329
+ continue;
11330
+ }
11331
+
11332
+ push({ type: 'dot', value, output: DOT_LITERAL });
11333
+ continue;
11334
+ }
11335
+
11336
+ /**
11337
+ * Question marks
11338
+ */
11339
+
11340
+ if (value === '?') {
11341
+ const isGroup = prev && prev.value === '(';
11342
+ if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
11343
+ extglobOpen('qmark', value);
11344
+ continue;
11345
+ }
11346
+
11347
+ if (prev && prev.type === 'paren') {
11348
+ const next = peek();
11349
+ let output = value;
11350
+
11351
+ if (next === '<' && !utils.supportsLookbehinds()) {
11352
+ throw new Error('Node.js v10 or higher is required for regex lookbehinds');
11353
+ }
11354
+
11355
+ if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
11356
+ output = `\\${value}`;
11357
+ }
11358
+
11359
+ push({ type: 'text', value, output });
11360
+ continue;
11361
+ }
11362
+
11363
+ if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
11364
+ push({ type: 'qmark', value, output: QMARK_NO_DOT });
11365
+ continue;
11366
+ }
11367
+
11368
+ push({ type: 'qmark', value, output: QMARK });
11369
+ continue;
11370
+ }
11371
+
11372
+ /**
11373
+ * Exclamation
11374
+ */
11375
+
11376
+ if (value === '!') {
11377
+ if (opts.noextglob !== true && peek() === '(') {
11378
+ if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
11379
+ extglobOpen('negate', value);
11380
+ continue;
11381
+ }
11382
+ }
11383
+
11384
+ if (opts.nonegate !== true && state.index === 0) {
11385
+ negate();
11386
+ continue;
11387
+ }
11388
+ }
11389
+
11390
+ /**
11391
+ * Plus
11392
+ */
11393
+
11394
+ if (value === '+') {
11395
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
11396
+ extglobOpen('plus', value);
11397
+ continue;
11398
+ }
11399
+
11400
+ if ((prev && prev.value === '(') || opts.regex === false) {
11401
+ push({ type: 'plus', value, output: PLUS_LITERAL });
11402
+ continue;
11403
+ }
11404
+
11405
+ if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
11406
+ push({ type: 'plus', value });
11407
+ continue;
11408
+ }
11409
+
11410
+ push({ type: 'plus', value: PLUS_LITERAL });
11411
+ continue;
11412
+ }
11413
+
11414
+ /**
11415
+ * Plain text
11416
+ */
11417
+
11418
+ if (value === '@') {
11419
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
11420
+ push({ type: 'at', extglob: true, value, output: '' });
11421
+ continue;
11422
+ }
11423
+
11424
+ push({ type: 'text', value });
11425
+ continue;
11426
+ }
11427
+
11428
+ /**
11429
+ * Plain text
11430
+ */
11431
+
11432
+ if (value !== '*') {
11433
+ if (value === '$' || value === '^') {
11434
+ value = `\\${value}`;
11435
+ }
11436
+
11437
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
11438
+ if (match) {
11439
+ value += match[0];
11440
+ state.index += match[0].length;
11441
+ }
11442
+
11443
+ push({ type: 'text', value });
11444
+ continue;
11445
+ }
11446
+
11447
+ /**
11448
+ * Stars
11449
+ */
11450
+
11451
+ if (prev && (prev.type === 'globstar' || prev.star === true)) {
11452
+ prev.type = 'star';
11453
+ prev.star = true;
11454
+ prev.value += value;
11455
+ prev.output = star;
11456
+ state.backtrack = true;
11457
+ state.globstar = true;
11458
+ consume(value);
11459
+ continue;
11460
+ }
11461
+
11462
+ let rest = remaining();
11463
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
11464
+ extglobOpen('star', value);
11465
+ continue;
11466
+ }
11467
+
11468
+ if (prev.type === 'star') {
11469
+ if (opts.noglobstar === true) {
11470
+ consume(value);
11471
+ continue;
11472
+ }
11473
+
11474
+ const prior = prev.prev;
11475
+ const before = prior.prev;
11476
+ const isStart = prior.type === 'slash' || prior.type === 'bos';
11477
+ const afterStar = before && (before.type === 'star' || before.type === 'globstar');
11478
+
11479
+ if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
11480
+ push({ type: 'star', value, output: '' });
11481
+ continue;
11482
+ }
11483
+
11484
+ const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
11485
+ const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
11486
+ if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
11487
+ push({ type: 'star', value, output: '' });
11488
+ continue;
11489
+ }
11490
+
11491
+ // strip consecutive `/**/`
11492
+ while (rest.slice(0, 3) === '/**') {
11493
+ const after = input[state.index + 4];
11494
+ if (after && after !== '/') {
11495
+ break;
11496
+ }
11497
+ rest = rest.slice(3);
11498
+ consume('/**', 3);
11499
+ }
11500
+
11501
+ if (prior.type === 'bos' && eos()) {
11502
+ prev.type = 'globstar';
11503
+ prev.value += value;
11504
+ prev.output = globstar(opts);
11505
+ state.output = prev.output;
11506
+ state.globstar = true;
11507
+ consume(value);
11508
+ continue;
11509
+ }
11510
+
11511
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
11512
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
11513
+ prior.output = `(?:${prior.output}`;
11514
+
11515
+ prev.type = 'globstar';
11516
+ prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
11517
+ prev.value += value;
11518
+ state.globstar = true;
11519
+ state.output += prior.output + prev.output;
11520
+ consume(value);
11521
+ continue;
11522
+ }
11523
+
11524
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
11525
+ const end = rest[1] !== void 0 ? '|$' : '';
11526
+
11527
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
11528
+ prior.output = `(?:${prior.output}`;
11529
+
11530
+ prev.type = 'globstar';
11531
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
11532
+ prev.value += value;
11533
+
11534
+ state.output += prior.output + prev.output;
11535
+ state.globstar = true;
11536
+
11537
+ consume(value + advance());
11538
+
11539
+ push({ type: 'slash', value: '/', output: '' });
11540
+ continue;
11541
+ }
11542
+
11543
+ if (prior.type === 'bos' && rest[0] === '/') {
11544
+ prev.type = 'globstar';
11545
+ prev.value += value;
11546
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
11547
+ state.output = prev.output;
11548
+ state.globstar = true;
11549
+ consume(value + advance());
11550
+ push({ type: 'slash', value: '/', output: '' });
11551
+ continue;
11552
+ }
11553
+
11554
+ // remove single star from output
11555
+ state.output = state.output.slice(0, -prev.output.length);
11556
+
11557
+ // reset previous token to globstar
11558
+ prev.type = 'globstar';
11559
+ prev.output = globstar(opts);
11560
+ prev.value += value;
11561
+
11562
+ // reset output with globstar
11563
+ state.output += prev.output;
11564
+ state.globstar = true;
11565
+ consume(value);
11566
+ continue;
11567
+ }
11568
+
11569
+ const token = { type: 'star', value, output: star };
11570
+
11571
+ if (opts.bash === true) {
11572
+ token.output = '.*?';
11573
+ if (prev.type === 'bos' || prev.type === 'slash') {
11574
+ token.output = nodot + token.output;
11575
+ }
11576
+ push(token);
11577
+ continue;
11578
+ }
11579
+
11580
+ if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
11581
+ token.output = value;
11582
+ push(token);
11583
+ continue;
11584
+ }
11585
+
11586
+ if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
11587
+ if (prev.type === 'dot') {
11588
+ state.output += NO_DOT_SLASH;
11589
+ prev.output += NO_DOT_SLASH;
11590
+
11591
+ } else if (opts.dot === true) {
11592
+ state.output += NO_DOTS_SLASH;
11593
+ prev.output += NO_DOTS_SLASH;
11594
+
11595
+ } else {
11596
+ state.output += nodot;
11597
+ prev.output += nodot;
11598
+ }
11599
+
11600
+ if (peek() !== '*') {
11601
+ state.output += ONE_CHAR;
11602
+ prev.output += ONE_CHAR;
11603
+ }
11604
+ }
11605
+
11606
+ push(token);
11607
+ }
11606
11608
 
11607
- case '*.*':
11608
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
11609
+ while (state.brackets > 0) {
11610
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
11611
+ state.output = utils.escapeLast(state.output, '[');
11612
+ decrement('brackets');
11613
+ }
11609
11614
 
11610
- case '*/*':
11611
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
11615
+ while (state.parens > 0) {
11616
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
11617
+ state.output = utils.escapeLast(state.output, '(');
11618
+ decrement('parens');
11619
+ }
11612
11620
 
11613
- case '**':
11614
- return nodot + globstar(opts);
11621
+ while (state.braces > 0) {
11622
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
11623
+ state.output = utils.escapeLast(state.output, '{');
11624
+ decrement('braces');
11625
+ }
11615
11626
 
11616
- case '**/*':
11617
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
11627
+ if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
11628
+ push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
11629
+ }
11618
11630
 
11619
- case '**/*.*':
11620
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
11631
+ // rebuild the output if we had to backtrack at any point
11632
+ if (state.backtrack === true) {
11633
+ state.output = '';
11621
11634
 
11622
- case '**/.*':
11623
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
11635
+ for (const token of state.tokens) {
11636
+ state.output += token.output != null ? token.output : token.value;
11624
11637
 
11625
- default: {
11626
- const match = /^(.*?)\.(\w+)$/.exec(str);
11627
- if (!match) return;
11638
+ if (token.suffix) {
11639
+ state.output += token.suffix;
11640
+ }
11641
+ }
11642
+ }
11628
11643
 
11629
- const source = create(match[1]);
11630
- if (!source) return;
11644
+ return state;
11645
+ };
11631
11646
 
11632
- return source + DOT_LITERAL + match[2];
11633
- }
11634
- }
11635
- };
11647
+ /**
11648
+ * Fast paths for creating regular expressions for common glob patterns.
11649
+ * This can significantly speed up processing and has very little downside
11650
+ * impact when none of the fast paths match.
11651
+ */
11652
+
11653
+ parse.fastpaths = (input, options) => {
11654
+ const opts = { ...options };
11655
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
11656
+ const len = input.length;
11657
+ if (len > max) {
11658
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
11659
+ }
11636
11660
 
11637
- const output = utils$1.removePrefix(input, state);
11638
- let source = create(output);
11661
+ input = REPLACEMENTS[input] || input;
11662
+ const win32 = utils.isWindows(options);
11663
+
11664
+ // create constants based on platform, for windows or posix
11665
+ const {
11666
+ DOT_LITERAL,
11667
+ SLASH_LITERAL,
11668
+ ONE_CHAR,
11669
+ DOTS_SLASH,
11670
+ NO_DOT,
11671
+ NO_DOTS,
11672
+ NO_DOTS_SLASH,
11673
+ STAR,
11674
+ START_ANCHOR
11675
+ } = constants.globChars(win32);
11676
+
11677
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
11678
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
11679
+ const capture = opts.capture ? '' : '?:';
11680
+ const state = { negated: false, prefix: '' };
11681
+ let star = opts.bash === true ? '.*?' : STAR;
11682
+
11683
+ if (opts.capture) {
11684
+ star = `(${star})`;
11685
+ }
11639
11686
 
11640
- if (source && opts.strictSlashes !== true) {
11641
- source += `${SLASH_LITERAL}?`;
11642
- }
11687
+ const globstar = opts => {
11688
+ if (opts.noglobstar === true) return star;
11689
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
11690
+ };
11643
11691
 
11644
- return source;
11645
- };
11692
+ const create = str => {
11693
+ switch (str) {
11694
+ case '*':
11695
+ return `${nodot}${ONE_CHAR}${star}`;
11646
11696
 
11647
- var parse_1 = parse$1;
11697
+ case '.*':
11698
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
11648
11699
 
11649
- const path = require$$0;
11650
- const scan = scan_1;
11651
- const parse = parse_1;
11652
- const utils = utils$3;
11653
- const constants = constants$2;
11654
- const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
11700
+ case '*.*':
11701
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
11655
11702
 
11656
- /**
11657
- * Creates a matcher function from one or more glob patterns. The
11658
- * returned function takes a string to match as its first argument,
11659
- * and returns true if the string is a match. The returned matcher
11660
- * function also takes a boolean as the second argument that, when true,
11661
- * returns an object with additional information.
11662
- *
11663
- * ```js
11664
- * const picomatch = require('picomatch');
11665
- * // picomatch(glob[, options]);
11666
- *
11667
- * const isMatch = picomatch('*.!(*a)');
11668
- * console.log(isMatch('a.a')); //=> false
11669
- * console.log(isMatch('a.b')); //=> true
11670
- * ```
11671
- * @name picomatch
11672
- * @param {String|Array} `globs` One or more glob patterns.
11673
- * @param {Object=} `options`
11674
- * @return {Function=} Returns a matcher function.
11675
- * @api public
11676
- */
11703
+ case '*/*':
11704
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
11677
11705
 
11678
- const picomatch$1 = (glob, options, returnState = false) => {
11679
- if (Array.isArray(glob)) {
11680
- const fns = glob.map(input => picomatch$1(input, options, returnState));
11681
- const arrayMatcher = str => {
11682
- for (const isMatch of fns) {
11683
- const state = isMatch(str);
11684
- if (state) return state;
11685
- }
11686
- return false;
11687
- };
11688
- return arrayMatcher;
11689
- }
11706
+ case '**':
11707
+ return nodot + globstar(opts);
11690
11708
 
11691
- const isState = isObject(glob) && glob.tokens && glob.input;
11709
+ case '**/*':
11710
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
11692
11711
 
11693
- if (glob === '' || (typeof glob !== 'string' && !isState)) {
11694
- throw new TypeError('Expected pattern to be a non-empty string');
11695
- }
11712
+ case '**/*.*':
11713
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
11696
11714
 
11697
- const opts = options || {};
11698
- const posix = utils.isWindows(options);
11699
- const regex = isState
11700
- ? picomatch$1.compileRe(glob, options)
11701
- : picomatch$1.makeRe(glob, options, false, true);
11715
+ case '**/.*':
11716
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
11702
11717
 
11703
- const state = regex.state;
11704
- delete regex.state;
11718
+ default: {
11719
+ const match = /^(.*?)\.(\w+)$/.exec(str);
11720
+ if (!match) return;
11705
11721
 
11706
- let isIgnored = () => false;
11707
- if (opts.ignore) {
11708
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
11709
- isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
11710
- }
11722
+ const source = create(match[1]);
11723
+ if (!source) return;
11711
11724
 
11712
- const matcher = (input, returnObject = false) => {
11713
- const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
11714
- const result = { glob, state, regex, posix, input, output, match, isMatch };
11725
+ return source + DOT_LITERAL + match[2];
11726
+ }
11727
+ }
11728
+ };
11715
11729
 
11716
- if (typeof opts.onResult === 'function') {
11717
- opts.onResult(result);
11718
- }
11730
+ const output = utils.removePrefix(input, state);
11731
+ let source = create(output);
11719
11732
 
11720
- if (isMatch === false) {
11721
- result.isMatch = false;
11722
- return returnObject ? result : false;
11723
- }
11733
+ if (source && opts.strictSlashes !== true) {
11734
+ source += `${SLASH_LITERAL}?`;
11735
+ }
11724
11736
 
11725
- if (isIgnored(input)) {
11726
- if (typeof opts.onIgnore === 'function') {
11727
- opts.onIgnore(result);
11728
- }
11729
- result.isMatch = false;
11730
- return returnObject ? result : false;
11731
- }
11737
+ return source;
11738
+ };
11732
11739
 
11733
- if (typeof opts.onMatch === 'function') {
11734
- opts.onMatch(result);
11735
- }
11736
- return returnObject ? result : true;
11737
- };
11740
+ parse_1 = parse;
11741
+ return parse_1;
11742
+ }
11738
11743
 
11739
- if (returnState) {
11740
- matcher.state = state;
11741
- }
11744
+ var picomatch_1;
11745
+ var hasRequiredPicomatch$1;
11742
11746
 
11743
- return matcher;
11744
- };
11747
+ function requirePicomatch$1 () {
11748
+ if (hasRequiredPicomatch$1) return picomatch_1;
11749
+ hasRequiredPicomatch$1 = 1;
11745
11750
 
11746
- /**
11747
- * Test `input` with the given `regex`. This is used by the main
11748
- * `picomatch()` function to test the input string.
11749
- *
11750
- * ```js
11751
- * const picomatch = require('picomatch');
11752
- * // picomatch.test(input, regex[, options]);
11753
- *
11754
- * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
11755
- * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
11756
- * ```
11757
- * @param {String} `input` String to test.
11758
- * @param {RegExp} `regex`
11759
- * @return {Object} Returns an object with matching info.
11760
- * @api public
11761
- */
11751
+ const path = require$$0;
11752
+ const scan = /*@__PURE__*/ requireScan();
11753
+ const parse = /*@__PURE__*/ requireParse();
11754
+ const utils = /*@__PURE__*/ requireUtils();
11755
+ const constants = /*@__PURE__*/ requireConstants();
11756
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
11757
+
11758
+ /**
11759
+ * Creates a matcher function from one or more glob patterns. The
11760
+ * returned function takes a string to match as its first argument,
11761
+ * and returns true if the string is a match. The returned matcher
11762
+ * function also takes a boolean as the second argument that, when true,
11763
+ * returns an object with additional information.
11764
+ *
11765
+ * ```js
11766
+ * const picomatch = require('picomatch');
11767
+ * // picomatch(glob[, options]);
11768
+ *
11769
+ * const isMatch = picomatch('*.!(*a)');
11770
+ * console.log(isMatch('a.a')); //=> false
11771
+ * console.log(isMatch('a.b')); //=> true
11772
+ * ```
11773
+ * @name picomatch
11774
+ * @param {String|Array} `globs` One or more glob patterns.
11775
+ * @param {Object=} `options`
11776
+ * @return {Function=} Returns a matcher function.
11777
+ * @api public
11778
+ */
11779
+
11780
+ const picomatch = (glob, options, returnState = false) => {
11781
+ if (Array.isArray(glob)) {
11782
+ const fns = glob.map(input => picomatch(input, options, returnState));
11783
+ const arrayMatcher = str => {
11784
+ for (const isMatch of fns) {
11785
+ const state = isMatch(str);
11786
+ if (state) return state;
11787
+ }
11788
+ return false;
11789
+ };
11790
+ return arrayMatcher;
11791
+ }
11762
11792
 
11763
- picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
11764
- if (typeof input !== 'string') {
11765
- throw new TypeError('Expected input to be a string');
11766
- }
11793
+ const isState = isObject(glob) && glob.tokens && glob.input;
11767
11794
 
11768
- if (input === '') {
11769
- return { isMatch: false, output: '' };
11770
- }
11795
+ if (glob === '' || (typeof glob !== 'string' && !isState)) {
11796
+ throw new TypeError('Expected pattern to be a non-empty string');
11797
+ }
11771
11798
 
11772
- const opts = options || {};
11773
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
11774
- let match = input === glob;
11775
- let output = (match && format) ? format(input) : input;
11799
+ const opts = options || {};
11800
+ const posix = utils.isWindows(options);
11801
+ const regex = isState
11802
+ ? picomatch.compileRe(glob, options)
11803
+ : picomatch.makeRe(glob, options, false, true);
11776
11804
 
11777
- if (match === false) {
11778
- output = format ? format(input) : input;
11779
- match = output === glob;
11780
- }
11805
+ const state = regex.state;
11806
+ delete regex.state;
11781
11807
 
11782
- if (match === false || opts.capture === true) {
11783
- if (opts.matchBase === true || opts.basename === true) {
11784
- match = picomatch$1.matchBase(input, regex, options, posix);
11785
- } else {
11786
- match = regex.exec(output);
11787
- }
11788
- }
11808
+ let isIgnored = () => false;
11809
+ if (opts.ignore) {
11810
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
11811
+ isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
11812
+ }
11789
11813
 
11790
- return { isMatch: Boolean(match), match, output };
11791
- };
11814
+ const matcher = (input, returnObject = false) => {
11815
+ const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
11816
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
11817
+
11818
+ if (typeof opts.onResult === 'function') {
11819
+ opts.onResult(result);
11820
+ }
11821
+
11822
+ if (isMatch === false) {
11823
+ result.isMatch = false;
11824
+ return returnObject ? result : false;
11825
+ }
11826
+
11827
+ if (isIgnored(input)) {
11828
+ if (typeof opts.onIgnore === 'function') {
11829
+ opts.onIgnore(result);
11830
+ }
11831
+ result.isMatch = false;
11832
+ return returnObject ? result : false;
11833
+ }
11834
+
11835
+ if (typeof opts.onMatch === 'function') {
11836
+ opts.onMatch(result);
11837
+ }
11838
+ return returnObject ? result : true;
11839
+ };
11840
+
11841
+ if (returnState) {
11842
+ matcher.state = state;
11843
+ }
11792
11844
 
11793
- /**
11794
- * Match the basename of a filepath.
11795
- *
11796
- * ```js
11797
- * const picomatch = require('picomatch');
11798
- * // picomatch.matchBase(input, glob[, options]);
11799
- * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
11800
- * ```
11801
- * @param {String} `input` String to test.
11802
- * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
11803
- * @return {Boolean}
11804
- * @api public
11805
- */
11845
+ return matcher;
11846
+ };
11806
11847
 
11807
- picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
11808
- const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
11809
- return regex.test(path.basename(input));
11810
- };
11848
+ /**
11849
+ * Test `input` with the given `regex`. This is used by the main
11850
+ * `picomatch()` function to test the input string.
11851
+ *
11852
+ * ```js
11853
+ * const picomatch = require('picomatch');
11854
+ * // picomatch.test(input, regex[, options]);
11855
+ *
11856
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
11857
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
11858
+ * ```
11859
+ * @param {String} `input` String to test.
11860
+ * @param {RegExp} `regex`
11861
+ * @return {Object} Returns an object with matching info.
11862
+ * @api public
11863
+ */
11864
+
11865
+ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
11866
+ if (typeof input !== 'string') {
11867
+ throw new TypeError('Expected input to be a string');
11868
+ }
11811
11869
 
11812
- /**
11813
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
11814
- *
11815
- * ```js
11816
- * const picomatch = require('picomatch');
11817
- * // picomatch.isMatch(string, patterns[, options]);
11818
- *
11819
- * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
11820
- * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
11821
- * ```
11822
- * @param {String|Array} str The string to test.
11823
- * @param {String|Array} patterns One or more glob patterns to use for matching.
11824
- * @param {Object} [options] See available [options](#options).
11825
- * @return {Boolean} Returns true if any patterns match `str`
11826
- * @api public
11827
- */
11870
+ if (input === '') {
11871
+ return { isMatch: false, output: '' };
11872
+ }
11828
11873
 
11829
- picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
11874
+ const opts = options || {};
11875
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
11876
+ let match = input === glob;
11877
+ let output = (match && format) ? format(input) : input;
11830
11878
 
11831
- /**
11832
- * Parse a glob pattern to create the source string for a regular
11833
- * expression.
11834
- *
11835
- * ```js
11836
- * const picomatch = require('picomatch');
11837
- * const result = picomatch.parse(pattern[, options]);
11838
- * ```
11839
- * @param {String} `pattern`
11840
- * @param {Object} `options`
11841
- * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
11842
- * @api public
11843
- */
11879
+ if (match === false) {
11880
+ output = format ? format(input) : input;
11881
+ match = output === glob;
11882
+ }
11844
11883
 
11845
- picomatch$1.parse = (pattern, options) => {
11846
- if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
11847
- return parse(pattern, { ...options, fastpaths: false });
11848
- };
11884
+ if (match === false || opts.capture === true) {
11885
+ if (opts.matchBase === true || opts.basename === true) {
11886
+ match = picomatch.matchBase(input, regex, options, posix);
11887
+ } else {
11888
+ match = regex.exec(output);
11889
+ }
11890
+ }
11849
11891
 
11850
- /**
11851
- * Scan a glob pattern to separate the pattern into segments.
11852
- *
11853
- * ```js
11854
- * const picomatch = require('picomatch');
11855
- * // picomatch.scan(input[, options]);
11856
- *
11857
- * const result = picomatch.scan('!./foo/*.js');
11858
- * console.log(result);
11859
- * { prefix: '!./',
11860
- * input: '!./foo/*.js',
11861
- * start: 3,
11862
- * base: 'foo',
11863
- * glob: '*.js',
11864
- * isBrace: false,
11865
- * isBracket: false,
11866
- * isGlob: true,
11867
- * isExtglob: false,
11868
- * isGlobstar: false,
11869
- * negated: true }
11870
- * ```
11871
- * @param {String} `input` Glob pattern to scan.
11872
- * @param {Object} `options`
11873
- * @return {Object} Returns an object with
11874
- * @api public
11875
- */
11892
+ return { isMatch: Boolean(match), match, output };
11893
+ };
11876
11894
 
11877
- picomatch$1.scan = (input, options) => scan(input, options);
11895
+ /**
11896
+ * Match the basename of a filepath.
11897
+ *
11898
+ * ```js
11899
+ * const picomatch = require('picomatch');
11900
+ * // picomatch.matchBase(input, glob[, options]);
11901
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
11902
+ * ```
11903
+ * @param {String} `input` String to test.
11904
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
11905
+ * @return {Boolean}
11906
+ * @api public
11907
+ */
11908
+
11909
+ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
11910
+ const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
11911
+ return regex.test(path.basename(input));
11912
+ };
11878
11913
 
11879
- /**
11880
- * Compile a regular expression from the `state` object returned by the
11881
- * [parse()](#parse) method.
11882
- *
11883
- * @param {Object} `state`
11884
- * @param {Object} `options`
11885
- * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
11886
- * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
11887
- * @return {RegExp}
11888
- * @api public
11889
- */
11914
+ /**
11915
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
11916
+ *
11917
+ * ```js
11918
+ * const picomatch = require('picomatch');
11919
+ * // picomatch.isMatch(string, patterns[, options]);
11920
+ *
11921
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
11922
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
11923
+ * ```
11924
+ * @param {String|Array} str The string to test.
11925
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
11926
+ * @param {Object} [options] See available [options](#options).
11927
+ * @return {Boolean} Returns true if any patterns match `str`
11928
+ * @api public
11929
+ */
11930
+
11931
+ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
11932
+
11933
+ /**
11934
+ * Parse a glob pattern to create the source string for a regular
11935
+ * expression.
11936
+ *
11937
+ * ```js
11938
+ * const picomatch = require('picomatch');
11939
+ * const result = picomatch.parse(pattern[, options]);
11940
+ * ```
11941
+ * @param {String} `pattern`
11942
+ * @param {Object} `options`
11943
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
11944
+ * @api public
11945
+ */
11946
+
11947
+ picomatch.parse = (pattern, options) => {
11948
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
11949
+ return parse(pattern, { ...options, fastpaths: false });
11950
+ };
11890
11951
 
11891
- picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
11892
- if (returnOutput === true) {
11893
- return state.output;
11894
- }
11952
+ /**
11953
+ * Scan a glob pattern to separate the pattern into segments.
11954
+ *
11955
+ * ```js
11956
+ * const picomatch = require('picomatch');
11957
+ * // picomatch.scan(input[, options]);
11958
+ *
11959
+ * const result = picomatch.scan('!./foo/*.js');
11960
+ * console.log(result);
11961
+ * { prefix: '!./',
11962
+ * input: '!./foo/*.js',
11963
+ * start: 3,
11964
+ * base: 'foo',
11965
+ * glob: '*.js',
11966
+ * isBrace: false,
11967
+ * isBracket: false,
11968
+ * isGlob: true,
11969
+ * isExtglob: false,
11970
+ * isGlobstar: false,
11971
+ * negated: true }
11972
+ * ```
11973
+ * @param {String} `input` Glob pattern to scan.
11974
+ * @param {Object} `options`
11975
+ * @return {Object} Returns an object with
11976
+ * @api public
11977
+ */
11978
+
11979
+ picomatch.scan = (input, options) => scan(input, options);
11980
+
11981
+ /**
11982
+ * Compile a regular expression from the `state` object returned by the
11983
+ * [parse()](#parse) method.
11984
+ *
11985
+ * @param {Object} `state`
11986
+ * @param {Object} `options`
11987
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
11988
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
11989
+ * @return {RegExp}
11990
+ * @api public
11991
+ */
11992
+
11993
+ picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
11994
+ if (returnOutput === true) {
11995
+ return state.output;
11996
+ }
11895
11997
 
11896
- const opts = options || {};
11897
- const prepend = opts.contains ? '' : '^';
11898
- const append = opts.contains ? '' : '$';
11998
+ const opts = options || {};
11999
+ const prepend = opts.contains ? '' : '^';
12000
+ const append = opts.contains ? '' : '$';
11899
12001
 
11900
- let source = `${prepend}(?:${state.output})${append}`;
11901
- if (state && state.negated === true) {
11902
- source = `^(?!${source}).*$`;
11903
- }
12002
+ let source = `${prepend}(?:${state.output})${append}`;
12003
+ if (state && state.negated === true) {
12004
+ source = `^(?!${source}).*$`;
12005
+ }
11904
12006
 
11905
- const regex = picomatch$1.toRegex(source, options);
11906
- if (returnState === true) {
11907
- regex.state = state;
11908
- }
12007
+ const regex = picomatch.toRegex(source, options);
12008
+ if (returnState === true) {
12009
+ regex.state = state;
12010
+ }
11909
12011
 
11910
- return regex;
11911
- };
12012
+ return regex;
12013
+ };
11912
12014
 
11913
- /**
11914
- * Create a regular expression from a parsed glob pattern.
11915
- *
11916
- * ```js
11917
- * const picomatch = require('picomatch');
11918
- * const state = picomatch.parse('*.js');
11919
- * // picomatch.compileRe(state[, options]);
11920
- *
11921
- * console.log(picomatch.compileRe(state));
11922
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
11923
- * ```
11924
- * @param {String} `state` The object returned from the `.parse` method.
11925
- * @param {Object} `options`
11926
- * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
11927
- * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
11928
- * @return {RegExp} Returns a regex created from the given pattern.
11929
- * @api public
11930
- */
12015
+ /**
12016
+ * Create a regular expression from a parsed glob pattern.
12017
+ *
12018
+ * ```js
12019
+ * const picomatch = require('picomatch');
12020
+ * const state = picomatch.parse('*.js');
12021
+ * // picomatch.compileRe(state[, options]);
12022
+ *
12023
+ * console.log(picomatch.compileRe(state));
12024
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
12025
+ * ```
12026
+ * @param {String} `state` The object returned from the `.parse` method.
12027
+ * @param {Object} `options`
12028
+ * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
12029
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
12030
+ * @return {RegExp} Returns a regex created from the given pattern.
12031
+ * @api public
12032
+ */
12033
+
12034
+ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
12035
+ if (!input || typeof input !== 'string') {
12036
+ throw new TypeError('Expected a non-empty string');
12037
+ }
11931
12038
 
11932
- picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
11933
- if (!input || typeof input !== 'string') {
11934
- throw new TypeError('Expected a non-empty string');
11935
- }
12039
+ let parsed = { negated: false, fastpaths: true };
11936
12040
 
11937
- let parsed = { negated: false, fastpaths: true };
12041
+ if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
12042
+ parsed.output = parse.fastpaths(input, options);
12043
+ }
11938
12044
 
11939
- if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
11940
- parsed.output = parse.fastpaths(input, options);
11941
- }
12045
+ if (!parsed.output) {
12046
+ parsed = parse(input, options);
12047
+ }
11942
12048
 
11943
- if (!parsed.output) {
11944
- parsed = parse(input, options);
11945
- }
12049
+ return picomatch.compileRe(parsed, options, returnOutput, returnState);
12050
+ };
11946
12051
 
11947
- return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
11948
- };
12052
+ /**
12053
+ * Create a regular expression from the given regex source string.
12054
+ *
12055
+ * ```js
12056
+ * const picomatch = require('picomatch');
12057
+ * // picomatch.toRegex(source[, options]);
12058
+ *
12059
+ * const { output } = picomatch.parse('*.js');
12060
+ * console.log(picomatch.toRegex(output));
12061
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
12062
+ * ```
12063
+ * @param {String} `source` Regular expression source string.
12064
+ * @param {Object} `options`
12065
+ * @return {RegExp}
12066
+ * @api public
12067
+ */
12068
+
12069
+ picomatch.toRegex = (source, options) => {
12070
+ try {
12071
+ const opts = options || {};
12072
+ return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
12073
+ } catch (err) {
12074
+ if (options && options.debug === true) throw err;
12075
+ return /$^/;
12076
+ }
12077
+ };
11949
12078
 
11950
- /**
11951
- * Create a regular expression from the given regex source string.
11952
- *
11953
- * ```js
11954
- * const picomatch = require('picomatch');
11955
- * // picomatch.toRegex(source[, options]);
11956
- *
11957
- * const { output } = picomatch.parse('*.js');
11958
- * console.log(picomatch.toRegex(output));
11959
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
11960
- * ```
11961
- * @param {String} `source` Regular expression source string.
11962
- * @param {Object} `options`
11963
- * @return {RegExp}
11964
- * @api public
11965
- */
12079
+ /**
12080
+ * Picomatch constants.
12081
+ * @return {Object}
12082
+ */
11966
12083
 
11967
- picomatch$1.toRegex = (source, options) => {
11968
- try {
11969
- const opts = options || {};
11970
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
11971
- } catch (err) {
11972
- if (options && options.debug === true) throw err;
11973
- return /$^/;
11974
- }
11975
- };
12084
+ picomatch.constants = constants;
11976
12085
 
11977
- /**
11978
- * Picomatch constants.
11979
- * @return {Object}
11980
- */
12086
+ /**
12087
+ * Expose "picomatch"
12088
+ */
11981
12089
 
11982
- picomatch$1.constants = constants;
12090
+ picomatch_1 = picomatch;
12091
+ return picomatch_1;
12092
+ }
11983
12093
 
11984
- /**
11985
- * Expose "picomatch"
11986
- */
12094
+ var picomatch;
12095
+ var hasRequiredPicomatch;
11987
12096
 
11988
- var picomatch_1 = picomatch$1;
12097
+ function requirePicomatch () {
12098
+ if (hasRequiredPicomatch) return picomatch;
12099
+ hasRequiredPicomatch = 1;
11989
12100
 
11990
- var picomatch = picomatch_1;
12101
+ picomatch = /*@__PURE__*/ requirePicomatch$1();
12102
+ return picomatch;
12103
+ }
11991
12104
 
11992
- const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
12105
+ var picomatchExports = /*@__PURE__*/ requirePicomatch();
12106
+ const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
11993
12107
 
11994
12108
  const extractors = {
11995
12109
  ArrayPattern(names, param) {
@@ -12038,8 +12152,9 @@ function ensureArray(thing) {
12038
12152
  return [thing];
12039
12153
  }
12040
12154
 
12155
+ const normalizePathRegExp = new RegExp(`\\${require$$0.win32.sep}`, 'g');
12041
12156
  const normalizePath = function normalizePath(filename) {
12042
- return filename.split(require$$0.win32.sep).join(require$$0.posix.sep);
12157
+ return filename.replace(normalizePathRegExp, require$$0.posix.sep);
12043
12158
  };
12044
12159
 
12045
12160
  function getMatcherString(id, resolutionBase) {
@@ -12071,10 +12186,12 @@ const createFilter = function createFilter(include, exclude, options) {
12071
12186
  };
12072
12187
  const includeMatchers = ensureArray(include).map(getMatcher);
12073
12188
  const excludeMatchers = ensureArray(exclude).map(getMatcher);
12189
+ if (!includeMatchers.length && !excludeMatchers.length)
12190
+ return (id) => typeof id === 'string' && !id.includes('\0');
12074
12191
  return function result(id) {
12075
12192
  if (typeof id !== 'string')
12076
12193
  return false;
12077
- if (/\0/.test(id))
12194
+ if (id.includes('\0'))
12078
12195
  return false;
12079
12196
  const pathId = normalizePath(id);
12080
12197
  for (let i = 0; i < excludeMatchers.length; ++i) {
@@ -16262,8 +16379,8 @@ class Module {
16262
16379
  };
16263
16380
  }
16264
16381
  basename() {
16265
- const base = path$2.basename(this.id);
16266
- const extension = path$2.extname(this.id);
16382
+ const base = path.basename(this.id);
16383
+ const extension = path.extname(this.id);
16267
16384
  return makeLegal(extension ? base.slice(0, -extension.length) : base);
16268
16385
  }
16269
16386
  bindReferences() {
@@ -17617,7 +17734,7 @@ class Chunk {
17617
17734
  let hashPlaceholder = null;
17618
17735
  const { chunkFileNames, entryFileNames, file, format, preserveModules } = this.outputOptions;
17619
17736
  if (file) {
17620
- fileName = path$2.basename(file);
17737
+ fileName = path.basename(file);
17621
17738
  }
17622
17739
  else if (this.fileName === null) {
17623
17740
  const [pattern, patternName] = preserveModules || this.facadeModule?.isUserDefinedEntryPoint
@@ -18068,12 +18185,12 @@ class Chunk {
18068
18185
  return predefinedChunkName;
18069
18186
  const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
18070
18187
  const sanitizedId = sanitizeFileName(parseAst_js.normalize(module.id.split(QUERY_HASH_REGEX, 1)[0]));
18071
- const extensionName = path$2.extname(sanitizedId);
18188
+ const extensionName = path.extname(sanitizedId);
18072
18189
  const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName)
18073
18190
  ? sanitizedId.slice(0, -extensionName.length)
18074
18191
  : sanitizedId;
18075
18192
  if (parseAst_js.isAbsolute(idWithoutExtension)) {
18076
- if (preserveModulesRoot && path$2.resolve(idWithoutExtension).startsWith(preserveModulesRoot)) {
18193
+ if (preserveModulesRoot && path.resolve(idWithoutExtension).startsWith(preserveModulesRoot)) {
18077
18194
  return idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[/\\]/, '');
18078
18195
  }
18079
18196
  else {
@@ -18085,7 +18202,7 @@ class Chunk {
18085
18202
  }
18086
18203
  }
18087
18204
  else {
18088
- return (this.outputOptions.virtualDirname.replace(/\/$/, '') + '/' + path$2.basename(idWithoutExtension));
18205
+ return (this.outputOptions.virtualDirname.replace(/\/$/, '') + '/' + path.basename(idWithoutExtension));
18089
18206
  }
18090
18207
  }
18091
18208
  getReexportSpecifiers() {
@@ -19068,7 +19185,7 @@ function commondir(files) {
19068
19185
  if (files.length === 0)
19069
19186
  return '/';
19070
19187
  if (files.length === 1)
19071
- return path$2.dirname(files[0]);
19188
+ return path.dirname(files[0]);
19072
19189
  const commonSegments = files.slice(1).reduce((commonSegments, file) => {
19073
19190
  const pathSegments = file.split(/\/+|\\+/);
19074
19191
  let index;
@@ -19326,9 +19443,9 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
19326
19443
  if (originalSourcemap) {
19327
19444
  const sources = originalSourcemap.sources;
19328
19445
  const sourcesContent = originalSourcemap.sourcesContent || [];
19329
- const directory = path$2.dirname(id) || '.';
19446
+ const directory = path.dirname(id) || '.';
19330
19447
  const sourceRoot = originalSourcemap.sourceRoot || '.';
19331
- const baseSources = sources.map((source, index) => new Source(path$2.resolve(directory, sourceRoot, source), sourcesContent[index]));
19448
+ const baseSources = sources.map((source, index) => new Source(path.resolve(directory, sourceRoot, source), sourcesContent[index]));
19332
19449
  source = new Link(originalSourcemap, baseSources);
19333
19450
  }
19334
19451
  else {
@@ -19345,9 +19462,9 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
19345
19462
  const source = bundleSourcemapChain.reduce(linkMap, link);
19346
19463
  let { sources, sourcesContent, names, mappings } = source.traceMappings();
19347
19464
  if (file) {
19348
- const directory = path$2.dirname(file);
19349
- sources = sources.map((source) => path$2.relative(directory, source));
19350
- file = path$2.basename(file);
19465
+ const directory = path.dirname(file);
19466
+ sources = sources.map((source) => path.relative(directory, source));
19467
+ file = path.basename(file);
19351
19468
  }
19352
19469
  sourcesContent = (excludeContent ? null : sourcesContent);
19353
19470
  for (const module of modules) {
@@ -19421,11 +19538,11 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
19421
19538
  timeStart('sourcemaps', 3);
19422
19539
  let resultingFile;
19423
19540
  if (file)
19424
- resultingFile = path$2.resolve(sourcemapFile || file);
19541
+ resultingFile = path.resolve(sourcemapFile || file);
19425
19542
  else if (dir)
19426
- resultingFile = path$2.resolve(dir, fileName);
19543
+ resultingFile = path.resolve(dir, fileName);
19427
19544
  else
19428
- resultingFile = path$2.resolve(fileName);
19545
+ resultingFile = path.resolve(fileName);
19429
19546
  const decodedMap = magicString.generateDecodedMap({});
19430
19547
  map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, log);
19431
19548
  for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
@@ -19573,7 +19690,7 @@ function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, so
19573
19690
  url = map.toUrl();
19574
19691
  }
19575
19692
  else {
19576
- const sourcemapFileName = path$2.basename(fileName);
19693
+ const sourcemapFileName = path.basename(fileName);
19577
19694
  url = sourcemapBaseUrl
19578
19695
  ? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
19579
19696
  : sourcemapFileName;
@@ -19867,7 +19984,7 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
19867
19984
  // absolute path is created. Absolute importees therefore shortcircuit the
19868
19985
  // resolve call and require no special handing on our part.
19869
19986
  // See https://nodejs.org/api/path.html#path_path_resolve_paths
19870
- return addJsExtensionIfNecessary(importer ? path$2.resolve(path$2.dirname(importer), source) : path$2.resolve(source), preserveSymlinks);
19987
+ return addJsExtensionIfNecessary(importer ? path.resolve(path.dirname(importer), source) : path.resolve(source), preserveSymlinks);
19871
19988
  }
19872
19989
  async function addJsExtensionIfNecessary(file, preserveSymlinks) {
19873
19990
  return ((await findFile(file, preserveSymlinks)) ??
@@ -19881,8 +19998,8 @@ async function findFile(file, preserveSymlinks) {
19881
19998
  return await findFile(await promises.realpath(file), preserveSymlinks);
19882
19999
  if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) {
19883
20000
  // check case
19884
- const name = path$2.basename(file);
19885
- const files = await promises.readdir(path$2.dirname(file));
20001
+ const name = path.basename(file);
20002
+ const files = await promises.readdir(path.dirname(file));
19886
20003
  if (files.includes(name))
19887
20004
  return file;
19888
20005
  }
@@ -20437,8 +20554,8 @@ class ModuleLoader {
20437
20554
  function normalizeRelativeExternalId(source, importer) {
20438
20555
  return parseAst_js.isRelative(source)
20439
20556
  ? importer
20440
- ? path$2.resolve(importer, '..', source)
20441
- : path$2.resolve(source)
20557
+ ? path.resolve(importer, '..', source)
20558
+ : path.resolve(source)
20442
20559
  : source;
20443
20560
  }
20444
20561
  function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
@@ -20811,7 +20928,7 @@ const getModuleContext = (config, context) => {
20811
20928
  if (configModuleContext) {
20812
20929
  const contextByModuleId = Object.create(null);
20813
20930
  for (const [key, moduleContext] of Object.entries(configModuleContext)) {
20814
- contextByModuleId[path$2.resolve(key)] = moduleContext;
20931
+ contextByModuleId[path.resolve(key)] = moduleContext;
20815
20932
  }
20816
20933
  return id => contextByModuleId[id] ?? context;
20817
20934
  }
@@ -21004,7 +21121,7 @@ const getPreserveModulesRoot = (config) => {
21004
21121
  if (preserveModulesRoot === null || preserveModulesRoot === undefined) {
21005
21122
  return undefined;
21006
21123
  }
21007
- return path$2.resolve(preserveModulesRoot);
21124
+ return path.resolve(preserveModulesRoot);
21008
21125
  };
21009
21126
  const getAmd = (config) => {
21010
21127
  const mergedOption = {
@@ -21301,9 +21418,9 @@ function getSortingFileType(file) {
21301
21418
  return SortingFileType.SECONDARY_CHUNK;
21302
21419
  }
21303
21420
  async function writeOutputFile(outputFile, outputOptions) {
21304
- const fileName = path$2.resolve(outputOptions.dir || path$2.dirname(outputOptions.file), outputFile.fileName);
21421
+ const fileName = path.resolve(outputOptions.dir || path.dirname(outputOptions.file), outputFile.fileName);
21305
21422
  // 'recursive: true' does not throw if the folder structure, or parts of it, already exist
21306
- await promises.mkdir(path$2.dirname(fileName), { recursive: true });
21423
+ await promises.mkdir(path.dirname(fileName), { recursive: true });
21307
21424
  return promises.writeFile(fileName, outputFile.type === 'asset' ? outputFile.source : outputFile.code);
21308
21425
  }
21309
21426
  /**
@@ -21325,6 +21442,7 @@ exports.cyan$1 = cyan;
21325
21442
  exports.defineConfig = defineConfig;
21326
21443
  exports.ensureArray = ensureArray$1;
21327
21444
  exports.getAugmentedNamespace = getAugmentedNamespace;
21445
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
21328
21446
  exports.getNewArray = getNewArray;
21329
21447
  exports.getOrCreate = getOrCreate;
21330
21448
  exports.gray = gray;
@@ -21333,7 +21451,6 @@ exports.handleError = handleError;
21333
21451
  exports.isWatchEnabled = isWatchEnabled;
21334
21452
  exports.mergeOptions = mergeOptions;
21335
21453
  exports.normalizePluginOption = normalizePluginOption;
21336
- exports.picomatch = picomatch;
21337
21454
  exports.rollup = rollup;
21338
21455
  exports.rollupInternal = rollupInternal;
21339
21456
  exports.stderr = stderr;