rollup 4.22.3 → 4.22.5

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.3
4
- Sat, 21 Sep 2024 05:02:38 GMT - commit e1cba8e84a0c01dd16580ba7a2536a988dfb4e18
3
+ Rollup.js v4.22.5
4
+ Fri, 27 Sep 2024 11:47:46 GMT - commit bc7780c322e134492f40a76bf64afe561670425c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -9,14 +9,14 @@
9
9
  */
10
10
  import { ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, Program as Program$1, BLANK, logIllegalImportReassignment, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, ExpressionStatement as ExpressionStatement$1, logMissingExport, normalize, getImportPath, logMissingNodeBuiltins, logReservedNamespace, error, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, Property as Property$1, logConstVariableReassignError, ArrowFunctionExpression as ArrowFunctionExpression$1, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logParseError, logModuleParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, EMPTY_OBJECT, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logCircularReexport, logInvalidFormatForTopLevelAwait, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, logInvalidExportOptionValue, warnDeprecation, URL_OUTPUT_INTEROP, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
11
11
  import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
12
- import require$$0, { win32, posix, isAbsolute, resolve } from 'path';
12
+ import require$$0, { posix, win32, isAbsolute, resolve } from 'path';
13
13
  import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
14
14
  import process$1, { env as env$1 } from 'node:process';
15
15
  import { performance } from 'node:perf_hooks';
16
16
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version = "4.22.3";
19
+ var version = "4.22.5";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -479,7 +479,7 @@ function getRelativePath(from, to) {
479
479
 
480
480
  const toString = Object.prototype.toString;
481
481
 
482
- function isObject$1(thing) {
482
+ function isObject(thing) {
483
483
  return toString.call(thing) === '[object Object]';
484
484
  }
485
485
 
@@ -800,7 +800,7 @@ class MagicString {
800
800
  indent(indentStr, options) {
801
801
  const pattern = /^[^\r\n]/gm;
802
802
 
803
- if (isObject$1(indentStr)) {
803
+ if (isObject(indentStr)) {
804
804
  options = indentStr;
805
805
  indentStr = undefined;
806
806
  }
@@ -1477,7 +1477,7 @@ let Bundle$1 = class Bundle {
1477
1477
  });
1478
1478
  }
1479
1479
 
1480
- if (!isObject$1(source) || !source.content) {
1480
+ if (!isObject(source) || !source.content) {
1481
1481
  throw new Error(
1482
1482
  'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
1483
1483
  );
@@ -7235,7 +7235,7 @@ const accessedFileUrlGlobals = {
7235
7235
  umd: ['document', 'require', 'URL']
7236
7236
  };
7237
7237
  const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
7238
- const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(relativePath)}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
7238
+ const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(relativePath)}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI`);
7239
7239
  const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
7240
7240
  const urlMechanism = getUrl(chunkId);
7241
7241
  return property === null
@@ -7246,7 +7246,7 @@ const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
7246
7246
  };
7247
7247
  const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
7248
7248
  const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
7249
- const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
7249
+ const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.tagName.toUpperCase() === 'SCRIPT' && ${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
7250
7250
  const relativeUrlMechanisms = {
7251
7251
  amd: relativePath => {
7252
7252
  if (relativePath[0] !== '.')
@@ -8069,14 +8069,17 @@ const keypath = (keypath, getPropertyAccess) => keypath.split('.').map(getProper
8069
8069
 
8070
8070
  function setupNamespace(name, root, globals, { _, getPropertyAccess, s }, compact, log) {
8071
8071
  const parts = name.split('.');
8072
- // Check if the key is exist in the prototype of the object
8073
- const isReserved = parts[0] in {};
8072
+ // Check if the key exists in the object's prototype.
8073
+ const isReserved = parts[0] in Object.prototype;
8074
8074
  if (log && isReserved) {
8075
8075
  log(LOGLEVEL_WARN, logReservedNamespace(parts[0]));
8076
8076
  }
8077
8077
  parts[0] =
8078
- (typeof globals === 'function' ? globals(parts[0]) : isReserved ? null : globals[parts[0]]) ||
8079
- parts[0];
8078
+ (typeof globals === 'function'
8079
+ ? globals(parts[0])
8080
+ : isReserved
8081
+ ? parts[0]
8082
+ : globals[parts[0]]) || parts[0];
8080
8083
  parts.pop();
8081
8084
  let propertyPath = root;
8082
8085
  return (parts
@@ -8088,14 +8091,17 @@ function setupNamespace(name, root, globals, { _, getPropertyAccess, s }, compac
8088
8091
  }
8089
8092
  function assignToDeepVariable(deepName, root, globals, assignment, { _, getPropertyAccess }, log) {
8090
8093
  const parts = deepName.split('.');
8091
- // Check if the key is exist in the prototype of the object
8092
- const isReserved = parts[0] in {};
8094
+ // Check if the key exists in the object's prototype.
8095
+ const isReserved = parts[0] in Object.prototype;
8093
8096
  if (log && isReserved) {
8094
8097
  log(LOGLEVEL_WARN, logReservedNamespace(parts[0]));
8095
8098
  }
8096
8099
  parts[0] =
8097
- (typeof globals === 'function' ? globals(parts[0]) : isReserved ? null : globals[parts[0]]) ||
8098
- parts[0];
8100
+ (typeof globals === 'function'
8101
+ ? globals(parts[0])
8102
+ : isReserved
8103
+ ? parts[0]
8104
+ : globals[parts[0]]) || parts[0];
8099
8105
  const last = parts.pop();
8100
8106
  let propertyPath = root;
8101
8107
  let deepAssignment = [
@@ -8467,2069 +8473,2122 @@ function getAugmentedNamespace(n) {
8467
8473
  return a;
8468
8474
  }
8469
8475
 
8470
- var utils$3 = {};
8476
+ var utils = {};
8471
8477
 
8472
- const path$1 = require$$0;
8473
- const WIN_SLASH = '\\\\/';
8474
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
8478
+ var constants;
8479
+ var hasRequiredConstants;
8475
8480
 
8476
- /**
8477
- * Posix glob regex
8478
- */
8479
-
8480
- const DOT_LITERAL = '\\.';
8481
- const PLUS_LITERAL = '\\+';
8482
- const QMARK_LITERAL = '\\?';
8483
- const SLASH_LITERAL = '\\/';
8484
- const ONE_CHAR = '(?=.)';
8485
- const QMARK = '[^/]';
8486
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
8487
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
8488
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
8489
- const NO_DOT = `(?!${DOT_LITERAL})`;
8490
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
8491
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
8492
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
8493
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
8494
- const STAR = `${QMARK}*?`;
8495
-
8496
- const POSIX_CHARS = {
8497
- DOT_LITERAL,
8498
- PLUS_LITERAL,
8499
- QMARK_LITERAL,
8500
- SLASH_LITERAL,
8501
- ONE_CHAR,
8502
- QMARK,
8503
- END_ANCHOR,
8504
- DOTS_SLASH,
8505
- NO_DOT,
8506
- NO_DOTS,
8507
- NO_DOT_SLASH,
8508
- NO_DOTS_SLASH,
8509
- QMARK_NO_DOT,
8510
- STAR,
8511
- START_ANCHOR
8512
- };
8513
-
8514
- /**
8515
- * Windows glob regex
8516
- */
8517
-
8518
- const WINDOWS_CHARS = {
8519
- ...POSIX_CHARS,
8520
-
8521
- SLASH_LITERAL: `[${WIN_SLASH}]`,
8522
- QMARK: WIN_NO_SLASH,
8523
- STAR: `${WIN_NO_SLASH}*?`,
8524
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
8525
- NO_DOT: `(?!${DOT_LITERAL})`,
8526
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
8527
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
8528
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
8529
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
8530
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
8531
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
8532
- };
8533
-
8534
- /**
8535
- * POSIX Bracket Regex
8536
- */
8537
-
8538
- const POSIX_REGEX_SOURCE$1 = {
8539
- alnum: 'a-zA-Z0-9',
8540
- alpha: 'a-zA-Z',
8541
- ascii: '\\x00-\\x7F',
8542
- blank: ' \\t',
8543
- cntrl: '\\x00-\\x1F\\x7F',
8544
- digit: '0-9',
8545
- graph: '\\x21-\\x7E',
8546
- lower: 'a-z',
8547
- print: '\\x20-\\x7E ',
8548
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
8549
- space: ' \\t\\r\\n\\v\\f',
8550
- upper: 'A-Z',
8551
- word: 'A-Za-z0-9_',
8552
- xdigit: 'A-Fa-f0-9'
8553
- };
8554
-
8555
- var constants$2 = {
8556
- MAX_LENGTH: 1024 * 64,
8557
- POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
8558
-
8559
- // regular expressions
8560
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
8561
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
8562
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
8563
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
8564
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
8565
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
8566
-
8567
- // Replace globs with equivalent patterns to reduce parsing time.
8568
- REPLACEMENTS: {
8569
- '***': '*',
8570
- '**/**': '**',
8571
- '**/**/**': '**'
8572
- },
8573
-
8574
- // Digits
8575
- CHAR_0: 48, /* 0 */
8576
- CHAR_9: 57, /* 9 */
8577
-
8578
- // Alphabet chars.
8579
- CHAR_UPPERCASE_A: 65, /* A */
8580
- CHAR_LOWERCASE_A: 97, /* a */
8581
- CHAR_UPPERCASE_Z: 90, /* Z */
8582
- CHAR_LOWERCASE_Z: 122, /* z */
8583
-
8584
- CHAR_LEFT_PARENTHESES: 40, /* ( */
8585
- CHAR_RIGHT_PARENTHESES: 41, /* ) */
8586
-
8587
- CHAR_ASTERISK: 42, /* * */
8588
-
8589
- // Non-alphabetic chars.
8590
- CHAR_AMPERSAND: 38, /* & */
8591
- CHAR_AT: 64, /* @ */
8592
- CHAR_BACKWARD_SLASH: 92, /* \ */
8593
- CHAR_CARRIAGE_RETURN: 13, /* \r */
8594
- CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
8595
- CHAR_COLON: 58, /* : */
8596
- CHAR_COMMA: 44, /* , */
8597
- CHAR_DOT: 46, /* . */
8598
- CHAR_DOUBLE_QUOTE: 34, /* " */
8599
- CHAR_EQUAL: 61, /* = */
8600
- CHAR_EXCLAMATION_MARK: 33, /* ! */
8601
- CHAR_FORM_FEED: 12, /* \f */
8602
- CHAR_FORWARD_SLASH: 47, /* / */
8603
- CHAR_GRAVE_ACCENT: 96, /* ` */
8604
- CHAR_HASH: 35, /* # */
8605
- CHAR_HYPHEN_MINUS: 45, /* - */
8606
- CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
8607
- CHAR_LEFT_CURLY_BRACE: 123, /* { */
8608
- CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
8609
- CHAR_LINE_FEED: 10, /* \n */
8610
- CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
8611
- CHAR_PERCENT: 37, /* % */
8612
- CHAR_PLUS: 43, /* + */
8613
- CHAR_QUESTION_MARK: 63, /* ? */
8614
- CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
8615
- CHAR_RIGHT_CURLY_BRACE: 125, /* } */
8616
- CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
8617
- CHAR_SEMICOLON: 59, /* ; */
8618
- CHAR_SINGLE_QUOTE: 39, /* ' */
8619
- CHAR_SPACE: 32, /* */
8620
- CHAR_TAB: 9, /* \t */
8621
- CHAR_UNDERSCORE: 95, /* _ */
8622
- CHAR_VERTICAL_LINE: 124, /* | */
8623
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
8624
-
8625
- SEP: path$1.sep,
8626
-
8627
- /**
8628
- * Create EXTGLOB_CHARS
8629
- */
8630
-
8631
- extglobChars(chars) {
8632
- return {
8633
- '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
8634
- '?': { type: 'qmark', open: '(?:', close: ')?' },
8635
- '+': { type: 'plus', open: '(?:', close: ')+' },
8636
- '*': { type: 'star', open: '(?:', close: ')*' },
8637
- '@': { type: 'at', open: '(?:', close: ')' }
8638
- };
8639
- },
8640
-
8641
- /**
8642
- * Create GLOB_CHARS
8643
- */
8644
-
8645
- globChars(win32) {
8646
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
8647
- }
8648
- };
8649
-
8650
- (function (exports) {
8481
+ function requireConstants () {
8482
+ if (hasRequiredConstants) return constants;
8483
+ hasRequiredConstants = 1;
8651
8484
 
8652
8485
  const path = require$$0;
8653
- const win32 = process.platform === 'win32';
8654
- const {
8655
- REGEX_BACKSLASH,
8656
- REGEX_REMOVE_BACKSLASH,
8657
- REGEX_SPECIAL_CHARS,
8658
- REGEX_SPECIAL_CHARS_GLOBAL
8659
- } = constants$2;
8660
-
8661
- exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
8662
- exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
8663
- exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
8664
- exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
8665
- exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
8666
-
8667
- exports.removeBackslashes = str => {
8668
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
8669
- return match === '\\' ? '' : match;
8670
- });
8486
+ const WIN_SLASH = '\\\\/';
8487
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
8488
+
8489
+ /**
8490
+ * Posix glob regex
8491
+ */
8492
+
8493
+ const DOT_LITERAL = '\\.';
8494
+ const PLUS_LITERAL = '\\+';
8495
+ const QMARK_LITERAL = '\\?';
8496
+ const SLASH_LITERAL = '\\/';
8497
+ const ONE_CHAR = '(?=.)';
8498
+ const QMARK = '[^/]';
8499
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
8500
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
8501
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
8502
+ const NO_DOT = `(?!${DOT_LITERAL})`;
8503
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
8504
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
8505
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
8506
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
8507
+ const STAR = `${QMARK}*?`;
8508
+
8509
+ const POSIX_CHARS = {
8510
+ DOT_LITERAL,
8511
+ PLUS_LITERAL,
8512
+ QMARK_LITERAL,
8513
+ SLASH_LITERAL,
8514
+ ONE_CHAR,
8515
+ QMARK,
8516
+ END_ANCHOR,
8517
+ DOTS_SLASH,
8518
+ NO_DOT,
8519
+ NO_DOTS,
8520
+ NO_DOT_SLASH,
8521
+ NO_DOTS_SLASH,
8522
+ QMARK_NO_DOT,
8523
+ STAR,
8524
+ START_ANCHOR
8671
8525
  };
8672
8526
 
8673
- exports.supportsLookbehinds = () => {
8674
- const segs = process.version.slice(1).split('.').map(Number);
8675
- if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
8676
- return true;
8677
- }
8678
- return false;
8527
+ /**
8528
+ * Windows glob regex
8529
+ */
8530
+
8531
+ const WINDOWS_CHARS = {
8532
+ ...POSIX_CHARS,
8533
+
8534
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
8535
+ QMARK: WIN_NO_SLASH,
8536
+ STAR: `${WIN_NO_SLASH}*?`,
8537
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
8538
+ NO_DOT: `(?!${DOT_LITERAL})`,
8539
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
8540
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
8541
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
8542
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
8543
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
8544
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
8679
8545
  };
8680
8546
 
8681
- exports.isWindows = options => {
8682
- if (options && typeof options.windows === 'boolean') {
8683
- return options.windows;
8684
- }
8685
- return win32 === true || path.sep === '\\';
8547
+ /**
8548
+ * POSIX Bracket Regex
8549
+ */
8550
+
8551
+ const POSIX_REGEX_SOURCE = {
8552
+ alnum: 'a-zA-Z0-9',
8553
+ alpha: 'a-zA-Z',
8554
+ ascii: '\\x00-\\x7F',
8555
+ blank: ' \\t',
8556
+ cntrl: '\\x00-\\x1F\\x7F',
8557
+ digit: '0-9',
8558
+ graph: '\\x21-\\x7E',
8559
+ lower: 'a-z',
8560
+ print: '\\x20-\\x7E ',
8561
+ punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
8562
+ space: ' \\t\\r\\n\\v\\f',
8563
+ upper: 'A-Z',
8564
+ word: 'A-Za-z0-9_',
8565
+ xdigit: 'A-Fa-f0-9'
8686
8566
  };
8687
8567
 
8688
- exports.escapeLast = (input, char, lastIdx) => {
8689
- const idx = input.lastIndexOf(char, lastIdx);
8690
- if (idx === -1) return input;
8691
- if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
8692
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
8693
- };
8694
-
8695
- exports.removePrefix = (input, state = {}) => {
8696
- let output = input;
8697
- if (output.startsWith('./')) {
8698
- output = output.slice(2);
8699
- state.prefix = './';
8568
+ constants = {
8569
+ MAX_LENGTH: 1024 * 64,
8570
+ POSIX_REGEX_SOURCE,
8571
+
8572
+ // regular expressions
8573
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
8574
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
8575
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
8576
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
8577
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
8578
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
8579
+
8580
+ // Replace globs with equivalent patterns to reduce parsing time.
8581
+ REPLACEMENTS: {
8582
+ '***': '*',
8583
+ '**/**': '**',
8584
+ '**/**/**': '**'
8585
+ },
8586
+
8587
+ // Digits
8588
+ CHAR_0: 48, /* 0 */
8589
+ CHAR_9: 57, /* 9 */
8590
+
8591
+ // Alphabet chars.
8592
+ CHAR_UPPERCASE_A: 65, /* A */
8593
+ CHAR_LOWERCASE_A: 97, /* a */
8594
+ CHAR_UPPERCASE_Z: 90, /* Z */
8595
+ CHAR_LOWERCASE_Z: 122, /* z */
8596
+
8597
+ CHAR_LEFT_PARENTHESES: 40, /* ( */
8598
+ CHAR_RIGHT_PARENTHESES: 41, /* ) */
8599
+
8600
+ CHAR_ASTERISK: 42, /* * */
8601
+
8602
+ // Non-alphabetic chars.
8603
+ CHAR_AMPERSAND: 38, /* & */
8604
+ CHAR_AT: 64, /* @ */
8605
+ CHAR_BACKWARD_SLASH: 92, /* \ */
8606
+ CHAR_CARRIAGE_RETURN: 13, /* \r */
8607
+ CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
8608
+ CHAR_COLON: 58, /* : */
8609
+ CHAR_COMMA: 44, /* , */
8610
+ CHAR_DOT: 46, /* . */
8611
+ CHAR_DOUBLE_QUOTE: 34, /* " */
8612
+ CHAR_EQUAL: 61, /* = */
8613
+ CHAR_EXCLAMATION_MARK: 33, /* ! */
8614
+ CHAR_FORM_FEED: 12, /* \f */
8615
+ CHAR_FORWARD_SLASH: 47, /* / */
8616
+ CHAR_GRAVE_ACCENT: 96, /* ` */
8617
+ CHAR_HASH: 35, /* # */
8618
+ CHAR_HYPHEN_MINUS: 45, /* - */
8619
+ CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
8620
+ CHAR_LEFT_CURLY_BRACE: 123, /* { */
8621
+ CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
8622
+ CHAR_LINE_FEED: 10, /* \n */
8623
+ CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
8624
+ CHAR_PERCENT: 37, /* % */
8625
+ CHAR_PLUS: 43, /* + */
8626
+ CHAR_QUESTION_MARK: 63, /* ? */
8627
+ CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
8628
+ CHAR_RIGHT_CURLY_BRACE: 125, /* } */
8629
+ CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
8630
+ CHAR_SEMICOLON: 59, /* ; */
8631
+ CHAR_SINGLE_QUOTE: 39, /* ' */
8632
+ CHAR_SPACE: 32, /* */
8633
+ CHAR_TAB: 9, /* \t */
8634
+ CHAR_UNDERSCORE: 95, /* _ */
8635
+ CHAR_VERTICAL_LINE: 124, /* | */
8636
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
8637
+
8638
+ SEP: path.sep,
8639
+
8640
+ /**
8641
+ * Create EXTGLOB_CHARS
8642
+ */
8643
+
8644
+ extglobChars(chars) {
8645
+ return {
8646
+ '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
8647
+ '?': { type: 'qmark', open: '(?:', close: ')?' },
8648
+ '+': { type: 'plus', open: '(?:', close: ')+' },
8649
+ '*': { type: 'star', open: '(?:', close: ')*' },
8650
+ '@': { type: 'at', open: '(?:', close: ')' }
8651
+ };
8652
+ },
8653
+
8654
+ /**
8655
+ * Create GLOB_CHARS
8656
+ */
8657
+
8658
+ globChars(win32) {
8659
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
8700
8660
  }
8701
- return output;
8702
8661
  };
8662
+ return constants;
8663
+ }
8664
+
8665
+ var hasRequiredUtils;
8666
+
8667
+ function requireUtils () {
8668
+ if (hasRequiredUtils) return utils;
8669
+ hasRequiredUtils = 1;
8670
+ (function (exports) {
8671
+
8672
+ const path = require$$0;
8673
+ const win32 = process.platform === 'win32';
8674
+ const {
8675
+ REGEX_BACKSLASH,
8676
+ REGEX_REMOVE_BACKSLASH,
8677
+ REGEX_SPECIAL_CHARS,
8678
+ REGEX_SPECIAL_CHARS_GLOBAL
8679
+ } = /*@__PURE__*/ requireConstants();
8680
+
8681
+ exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
8682
+ exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
8683
+ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
8684
+ exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
8685
+ exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
8686
+
8687
+ exports.removeBackslashes = str => {
8688
+ return str.replace(REGEX_REMOVE_BACKSLASH, match => {
8689
+ return match === '\\' ? '' : match;
8690
+ });
8691
+ };
8703
8692
 
8704
- exports.wrapOutput = (input, state = {}, options = {}) => {
8705
- const prepend = options.contains ? '' : '^';
8706
- const append = options.contains ? '' : '$';
8707
-
8708
- let output = `${prepend}(?:${input})${append}`;
8709
- if (state.negated === true) {
8710
- output = `(?:^(?!${output}).*$)`;
8711
- }
8712
- return output;
8713
- };
8714
- } (utils$3));
8715
-
8716
- const utils$2 = utils$3;
8717
- const {
8718
- CHAR_ASTERISK, /* * */
8719
- CHAR_AT, /* @ */
8720
- CHAR_BACKWARD_SLASH, /* \ */
8721
- CHAR_COMMA, /* , */
8722
- CHAR_DOT, /* . */
8723
- CHAR_EXCLAMATION_MARK, /* ! */
8724
- CHAR_FORWARD_SLASH, /* / */
8725
- CHAR_LEFT_CURLY_BRACE, /* { */
8726
- CHAR_LEFT_PARENTHESES, /* ( */
8727
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
8728
- CHAR_PLUS, /* + */
8729
- CHAR_QUESTION_MARK, /* ? */
8730
- CHAR_RIGHT_CURLY_BRACE, /* } */
8731
- CHAR_RIGHT_PARENTHESES, /* ) */
8732
- CHAR_RIGHT_SQUARE_BRACKET /* ] */
8733
- } = constants$2;
8734
-
8735
- const isPathSeparator = code => {
8736
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
8737
- };
8738
-
8739
- const depth = token => {
8740
- if (token.isPrefix !== true) {
8741
- token.depth = token.isGlobstar ? Infinity : 1;
8742
- }
8743
- };
8744
-
8745
- /**
8746
- * Quickly scans a glob pattern and returns an object with a handful of
8747
- * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
8748
- * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
8749
- * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
8750
- *
8751
- * ```js
8752
- * const pm = require('picomatch');
8753
- * console.log(pm.scan('foo/bar/*.js'));
8754
- * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
8755
- * ```
8756
- * @param {String} `str`
8757
- * @param {Object} `options`
8758
- * @return {Object} Returns an object with tokens and regex source string.
8759
- * @api public
8760
- */
8761
-
8762
- const scan$1 = (input, options) => {
8763
- const opts = options || {};
8764
-
8765
- const length = input.length - 1;
8766
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
8767
- const slashes = [];
8768
- const tokens = [];
8769
- const parts = [];
8770
-
8771
- let str = input;
8772
- let index = -1;
8773
- let start = 0;
8774
- let lastIndex = 0;
8775
- let isBrace = false;
8776
- let isBracket = false;
8777
- let isGlob = false;
8778
- let isExtglob = false;
8779
- let isGlobstar = false;
8780
- let braceEscaped = false;
8781
- let backslashes = false;
8782
- let negated = false;
8783
- let negatedExtglob = false;
8784
- let finished = false;
8785
- let braces = 0;
8786
- let prev;
8787
- let code;
8788
- let token = { value: '', depth: 0, isGlob: false };
8789
-
8790
- const eos = () => index >= length;
8791
- const peek = () => str.charCodeAt(index + 1);
8792
- const advance = () => {
8793
- prev = code;
8794
- return str.charCodeAt(++index);
8795
- };
8796
-
8797
- while (index < length) {
8798
- code = advance();
8799
- let next;
8800
-
8801
- if (code === CHAR_BACKWARD_SLASH) {
8802
- backslashes = token.backslashes = true;
8803
- code = advance();
8804
-
8805
- if (code === CHAR_LEFT_CURLY_BRACE) {
8806
- braceEscaped = true;
8807
- }
8808
- continue;
8809
- }
8810
-
8811
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
8812
- braces++;
8813
-
8814
- while (eos() !== true && (code = advance())) {
8815
- if (code === CHAR_BACKWARD_SLASH) {
8816
- backslashes = token.backslashes = true;
8817
- advance();
8818
- continue;
8819
- }
8820
-
8821
- if (code === CHAR_LEFT_CURLY_BRACE) {
8822
- braces++;
8823
- continue;
8824
- }
8825
-
8826
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
8827
- isBrace = token.isBrace = true;
8828
- isGlob = token.isGlob = true;
8829
- finished = true;
8830
-
8831
- if (scanToEnd === true) {
8832
- continue;
8833
- }
8834
-
8835
- break;
8836
- }
8837
-
8838
- if (braceEscaped !== true && code === CHAR_COMMA) {
8839
- isBrace = token.isBrace = true;
8840
- isGlob = token.isGlob = true;
8841
- finished = true;
8842
-
8843
- if (scanToEnd === true) {
8844
- continue;
8845
- }
8846
-
8847
- break;
8848
- }
8849
-
8850
- if (code === CHAR_RIGHT_CURLY_BRACE) {
8851
- braces--;
8852
-
8853
- if (braces === 0) {
8854
- braceEscaped = false;
8855
- isBrace = token.isBrace = true;
8856
- finished = true;
8857
- break;
8858
- }
8859
- }
8860
- }
8861
-
8862
- if (scanToEnd === true) {
8863
- continue;
8864
- }
8865
-
8866
- break;
8867
- }
8868
-
8869
- if (code === CHAR_FORWARD_SLASH) {
8870
- slashes.push(index);
8871
- tokens.push(token);
8872
- token = { value: '', depth: 0, isGlob: false };
8873
-
8874
- if (finished === true) continue;
8875
- if (prev === CHAR_DOT && index === (start + 1)) {
8876
- start += 2;
8877
- continue;
8878
- }
8879
-
8880
- lastIndex = index + 1;
8881
- continue;
8882
- }
8883
-
8884
- if (opts.noext !== true) {
8885
- const isExtglobChar = code === CHAR_PLUS
8886
- || code === CHAR_AT
8887
- || code === CHAR_ASTERISK
8888
- || code === CHAR_QUESTION_MARK
8889
- || code === CHAR_EXCLAMATION_MARK;
8890
-
8891
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
8892
- isGlob = token.isGlob = true;
8893
- isExtglob = token.isExtglob = true;
8894
- finished = true;
8895
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
8896
- negatedExtglob = true;
8897
- }
8898
-
8899
- if (scanToEnd === true) {
8900
- while (eos() !== true && (code = advance())) {
8901
- if (code === CHAR_BACKWARD_SLASH) {
8902
- backslashes = token.backslashes = true;
8903
- code = advance();
8904
- continue;
8905
- }
8906
-
8907
- if (code === CHAR_RIGHT_PARENTHESES) {
8908
- isGlob = token.isGlob = true;
8909
- finished = true;
8910
- break;
8911
- }
8912
- }
8913
- continue;
8914
- }
8915
- break;
8916
- }
8917
- }
8918
-
8919
- if (code === CHAR_ASTERISK) {
8920
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
8921
- isGlob = token.isGlob = true;
8922
- finished = true;
8923
-
8924
- if (scanToEnd === true) {
8925
- continue;
8926
- }
8927
- break;
8928
- }
8929
-
8930
- if (code === CHAR_QUESTION_MARK) {
8931
- isGlob = token.isGlob = true;
8932
- finished = true;
8933
-
8934
- if (scanToEnd === true) {
8935
- continue;
8936
- }
8937
- break;
8938
- }
8939
-
8940
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
8941
- while (eos() !== true && (next = advance())) {
8942
- if (next === CHAR_BACKWARD_SLASH) {
8943
- backslashes = token.backslashes = true;
8944
- advance();
8945
- continue;
8946
- }
8947
-
8948
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
8949
- isBracket = token.isBracket = true;
8950
- isGlob = token.isGlob = true;
8951
- finished = true;
8952
- break;
8953
- }
8954
- }
8955
-
8956
- if (scanToEnd === true) {
8957
- continue;
8958
- }
8959
-
8960
- break;
8961
- }
8962
-
8963
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
8964
- negated = token.negated = true;
8965
- start++;
8966
- continue;
8967
- }
8968
-
8969
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
8970
- isGlob = token.isGlob = true;
8971
-
8972
- if (scanToEnd === true) {
8973
- while (eos() !== true && (code = advance())) {
8974
- if (code === CHAR_LEFT_PARENTHESES) {
8975
- backslashes = token.backslashes = true;
8976
- code = advance();
8977
- continue;
8978
- }
8979
-
8980
- if (code === CHAR_RIGHT_PARENTHESES) {
8981
- finished = true;
8982
- break;
8983
- }
8984
- }
8985
- continue;
8986
- }
8987
- break;
8988
- }
8989
-
8990
- if (isGlob === true) {
8991
- finished = true;
8992
-
8993
- if (scanToEnd === true) {
8994
- continue;
8995
- }
8996
-
8997
- break;
8998
- }
8999
- }
9000
-
9001
- if (opts.noext === true) {
9002
- isExtglob = false;
9003
- isGlob = false;
9004
- }
9005
-
9006
- let base = str;
9007
- let prefix = '';
9008
- let glob = '';
9009
-
9010
- if (start > 0) {
9011
- prefix = str.slice(0, start);
9012
- str = str.slice(start);
9013
- lastIndex -= start;
9014
- }
9015
-
9016
- if (base && isGlob === true && lastIndex > 0) {
9017
- base = str.slice(0, lastIndex);
9018
- glob = str.slice(lastIndex);
9019
- } else if (isGlob === true) {
9020
- base = '';
9021
- glob = str;
9022
- } else {
9023
- base = str;
9024
- }
9025
-
9026
- if (base && base !== '' && base !== '/' && base !== str) {
9027
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
9028
- base = base.slice(0, -1);
9029
- }
9030
- }
9031
-
9032
- if (opts.unescape === true) {
9033
- if (glob) glob = utils$2.removeBackslashes(glob);
9034
-
9035
- if (base && backslashes === true) {
9036
- base = utils$2.removeBackslashes(base);
9037
- }
9038
- }
9039
-
9040
- const state = {
9041
- prefix,
9042
- input,
9043
- start,
9044
- base,
9045
- glob,
9046
- isBrace,
9047
- isBracket,
9048
- isGlob,
9049
- isExtglob,
9050
- isGlobstar,
9051
- negated,
9052
- negatedExtglob
9053
- };
9054
-
9055
- if (opts.tokens === true) {
9056
- state.maxDepth = 0;
9057
- if (!isPathSeparator(code)) {
9058
- tokens.push(token);
9059
- }
9060
- state.tokens = tokens;
9061
- }
9062
-
9063
- if (opts.parts === true || opts.tokens === true) {
9064
- let prevIndex;
9065
-
9066
- for (let idx = 0; idx < slashes.length; idx++) {
9067
- const n = prevIndex ? prevIndex + 1 : start;
9068
- const i = slashes[idx];
9069
- const value = input.slice(n, i);
9070
- if (opts.tokens) {
9071
- if (idx === 0 && start !== 0) {
9072
- tokens[idx].isPrefix = true;
9073
- tokens[idx].value = prefix;
9074
- } else {
9075
- tokens[idx].value = value;
9076
- }
9077
- depth(tokens[idx]);
9078
- state.maxDepth += tokens[idx].depth;
9079
- }
9080
- if (idx !== 0 || value !== '') {
9081
- parts.push(value);
9082
- }
9083
- prevIndex = i;
9084
- }
9085
-
9086
- if (prevIndex && prevIndex + 1 < input.length) {
9087
- const value = input.slice(prevIndex + 1);
9088
- parts.push(value);
9089
-
9090
- if (opts.tokens) {
9091
- tokens[tokens.length - 1].value = value;
9092
- depth(tokens[tokens.length - 1]);
9093
- state.maxDepth += tokens[tokens.length - 1].depth;
9094
- }
9095
- }
9096
-
9097
- state.slashes = slashes;
9098
- state.parts = parts;
9099
- }
9100
-
9101
- return state;
9102
- };
9103
-
9104
- var scan_1 = scan$1;
9105
-
9106
- const constants$1 = constants$2;
9107
- const utils$1 = utils$3;
9108
-
9109
- /**
9110
- * Constants
9111
- */
9112
-
9113
- const {
9114
- MAX_LENGTH,
9115
- POSIX_REGEX_SOURCE,
9116
- REGEX_NON_SPECIAL_CHARS,
9117
- REGEX_SPECIAL_CHARS_BACKREF,
9118
- REPLACEMENTS
9119
- } = constants$1;
9120
-
9121
- /**
9122
- * Helpers
9123
- */
9124
-
9125
- const expandRange = (args, options) => {
9126
- if (typeof options.expandRange === 'function') {
9127
- return options.expandRange(...args, options);
9128
- }
9129
-
9130
- args.sort();
9131
- const value = `[${args.join('-')}]`;
9132
-
9133
- return value;
9134
- };
9135
-
9136
- /**
9137
- * Create the message for a syntax error
9138
- */
9139
-
9140
- const syntaxError = (type, char) => {
9141
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
9142
- };
9143
-
9144
- /**
9145
- * Parse the given input string.
9146
- * @param {String} input
9147
- * @param {Object} options
9148
- * @return {Object}
9149
- */
9150
-
9151
- const parse$1 = (input, options) => {
9152
- if (typeof input !== 'string') {
9153
- throw new TypeError('Expected a string');
9154
- }
9155
-
9156
- input = REPLACEMENTS[input] || input;
9157
-
9158
- const opts = { ...options };
9159
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
9160
-
9161
- let len = input.length;
9162
- if (len > max) {
9163
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
9164
- }
9165
-
9166
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
9167
- const tokens = [bos];
9168
-
9169
- const capture = opts.capture ? '' : '?:';
9170
- const win32 = utils$1.isWindows(options);
9171
-
9172
- // create constants based on platform, for windows or posix
9173
- const PLATFORM_CHARS = constants$1.globChars(win32);
9174
- const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
9175
-
9176
- const {
9177
- DOT_LITERAL,
9178
- PLUS_LITERAL,
9179
- SLASH_LITERAL,
9180
- ONE_CHAR,
9181
- DOTS_SLASH,
9182
- NO_DOT,
9183
- NO_DOT_SLASH,
9184
- NO_DOTS_SLASH,
9185
- QMARK,
9186
- QMARK_NO_DOT,
9187
- STAR,
9188
- START_ANCHOR
9189
- } = PLATFORM_CHARS;
9190
-
9191
- const globstar = opts => {
9192
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
9193
- };
9194
-
9195
- const nodot = opts.dot ? '' : NO_DOT;
9196
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
9197
- let star = opts.bash === true ? globstar(opts) : STAR;
9198
-
9199
- if (opts.capture) {
9200
- star = `(${star})`;
9201
- }
9202
-
9203
- // minimatch options support
9204
- if (typeof opts.noext === 'boolean') {
9205
- opts.noextglob = opts.noext;
9206
- }
9207
-
9208
- const state = {
9209
- input,
9210
- index: -1,
9211
- start: 0,
9212
- dot: opts.dot === true,
9213
- consumed: '',
9214
- output: '',
9215
- prefix: '',
9216
- backtrack: false,
9217
- negated: false,
9218
- brackets: 0,
9219
- braces: 0,
9220
- parens: 0,
9221
- quotes: 0,
9222
- globstar: false,
9223
- tokens
9224
- };
9225
-
9226
- input = utils$1.removePrefix(input, state);
9227
- len = input.length;
9228
-
9229
- const extglobs = [];
9230
- const braces = [];
9231
- const stack = [];
9232
- let prev = bos;
9233
- let value;
9234
-
9235
- /**
9236
- * Tokenizing helpers
9237
- */
9238
-
9239
- const eos = () => state.index === len - 1;
9240
- const peek = state.peek = (n = 1) => input[state.index + n];
9241
- const advance = state.advance = () => input[++state.index] || '';
9242
- const remaining = () => input.slice(state.index + 1);
9243
- const consume = (value = '', num = 0) => {
9244
- state.consumed += value;
9245
- state.index += num;
9246
- };
9247
-
9248
- const append = token => {
9249
- state.output += token.output != null ? token.output : token.value;
9250
- consume(token.value);
9251
- };
9252
-
9253
- const negate = () => {
9254
- let count = 1;
9255
-
9256
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
9257
- advance();
9258
- state.start++;
9259
- count++;
9260
- }
9261
-
9262
- if (count % 2 === 0) {
9263
- return false;
9264
- }
9265
-
9266
- state.negated = true;
9267
- state.start++;
9268
- return true;
9269
- };
9270
-
9271
- const increment = type => {
9272
- state[type]++;
9273
- stack.push(type);
9274
- };
9275
-
9276
- const decrement = type => {
9277
- state[type]--;
9278
- stack.pop();
9279
- };
9280
-
9281
- /**
9282
- * Push tokens onto the tokens array. This helper speeds up
9283
- * tokenizing by 1) helping us avoid backtracking as much as possible,
9284
- * and 2) helping us avoid creating extra tokens when consecutive
9285
- * characters are plain text. This improves performance and simplifies
9286
- * lookbehinds.
9287
- */
9288
-
9289
- const push = tok => {
9290
- if (prev.type === 'globstar') {
9291
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
9292
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
9293
-
9294
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
9295
- state.output = state.output.slice(0, -prev.output.length);
9296
- prev.type = 'star';
9297
- prev.value = '*';
9298
- prev.output = star;
9299
- state.output += prev.output;
9300
- }
9301
- }
9302
-
9303
- if (extglobs.length && tok.type !== 'paren') {
9304
- extglobs[extglobs.length - 1].inner += tok.value;
9305
- }
9306
-
9307
- if (tok.value || tok.output) append(tok);
9308
- if (prev && prev.type === 'text' && tok.type === 'text') {
9309
- prev.value += tok.value;
9310
- prev.output = (prev.output || '') + tok.value;
9311
- return;
9312
- }
9313
-
9314
- tok.prev = prev;
9315
- tokens.push(tok);
9316
- prev = tok;
9317
- };
9318
-
9319
- const extglobOpen = (type, value) => {
9320
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
9321
-
9322
- token.prev = prev;
9323
- token.parens = state.parens;
9324
- token.output = state.output;
9325
- const output = (opts.capture ? '(' : '') + token.open;
9326
-
9327
- increment('parens');
9328
- push({ type, value, output: state.output ? '' : ONE_CHAR });
9329
- push({ type: 'paren', extglob: true, value: advance(), output });
9330
- extglobs.push(token);
9331
- };
9332
-
9333
- const extglobClose = token => {
9334
- let output = token.close + (opts.capture ? ')' : '');
9335
- let rest;
9336
-
9337
- if (token.type === 'negate') {
9338
- let extglobStar = star;
9339
-
9340
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
9341
- extglobStar = globstar(opts);
9342
- }
9343
-
9344
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
9345
- output = token.close = `)$))${extglobStar}`;
9346
- }
9347
-
9348
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
9349
- // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
9350
- // In this case, we need to parse the string and use it in the output of the original pattern.
9351
- // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
9352
- //
9353
- // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
9354
- const expression = parse$1(rest, { ...options, fastpaths: false }).output;
9355
-
9356
- output = token.close = `)${expression})${extglobStar})`;
9357
- }
9358
-
9359
- if (token.prev.type === 'bos') {
9360
- state.negatedExtglob = true;
9361
- }
9362
- }
9363
-
9364
- push({ type: 'paren', extglob: true, value, output });
9365
- decrement('parens');
9366
- };
9367
-
9368
- /**
9369
- * Fast paths
9370
- */
9371
-
9372
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
9373
- let backslashes = false;
9374
-
9375
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
9376
- if (first === '\\') {
9377
- backslashes = true;
9378
- return m;
9379
- }
9380
-
9381
- if (first === '?') {
9382
- if (esc) {
9383
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
9384
- }
9385
- if (index === 0) {
9386
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
9387
- }
9388
- return QMARK.repeat(chars.length);
9389
- }
9390
-
9391
- if (first === '.') {
9392
- return DOT_LITERAL.repeat(chars.length);
9393
- }
9394
-
9395
- if (first === '*') {
9396
- if (esc) {
9397
- return esc + first + (rest ? star : '');
9398
- }
9399
- return star;
9400
- }
9401
- return esc ? m : `\\${m}`;
9402
- });
9403
-
9404
- if (backslashes === true) {
9405
- if (opts.unescape === true) {
9406
- output = output.replace(/\\/g, '');
9407
- } else {
9408
- output = output.replace(/\\+/g, m => {
9409
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
9410
- });
9411
- }
9412
- }
9413
-
9414
- if (output === input && opts.contains === true) {
9415
- state.output = input;
9416
- return state;
9417
- }
9418
-
9419
- state.output = utils$1.wrapOutput(output, state, options);
9420
- return state;
9421
- }
9422
-
9423
- /**
9424
- * Tokenize input until we reach end-of-string
9425
- */
9426
-
9427
- while (!eos()) {
9428
- value = advance();
9429
-
9430
- if (value === '\u0000') {
9431
- continue;
9432
- }
9433
-
9434
- /**
9435
- * Escaped characters
9436
- */
9437
-
9438
- if (value === '\\') {
9439
- const next = peek();
9440
-
9441
- if (next === '/' && opts.bash !== true) {
9442
- continue;
9443
- }
9444
-
9445
- if (next === '.' || next === ';') {
9446
- continue;
9447
- }
9448
-
9449
- if (!next) {
9450
- value += '\\';
9451
- push({ type: 'text', value });
9452
- continue;
9453
- }
9454
-
9455
- // collapse slashes to reduce potential for exploits
9456
- const match = /^\\+/.exec(remaining());
9457
- let slashes = 0;
9458
-
9459
- if (match && match[0].length > 2) {
9460
- slashes = match[0].length;
9461
- state.index += slashes;
9462
- if (slashes % 2 !== 0) {
9463
- value += '\\';
9464
- }
9465
- }
9466
-
9467
- if (opts.unescape === true) {
9468
- value = advance();
9469
- } else {
9470
- value += advance();
9471
- }
9472
-
9473
- if (state.brackets === 0) {
9474
- push({ type: 'text', value });
9475
- continue;
9476
- }
9477
- }
9478
-
9479
- /**
9480
- * If we're inside a regex character class, continue
9481
- * until we reach the closing bracket.
9482
- */
9483
-
9484
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
9485
- if (opts.posix !== false && value === ':') {
9486
- const inner = prev.value.slice(1);
9487
- if (inner.includes('[')) {
9488
- prev.posix = true;
9489
-
9490
- if (inner.includes(':')) {
9491
- const idx = prev.value.lastIndexOf('[');
9492
- const pre = prev.value.slice(0, idx);
9493
- const rest = prev.value.slice(idx + 2);
9494
- const posix = POSIX_REGEX_SOURCE[rest];
9495
- if (posix) {
9496
- prev.value = pre + posix;
9497
- state.backtrack = true;
9498
- advance();
9499
-
9500
- if (!bos.output && tokens.indexOf(prev) === 1) {
9501
- bos.output = ONE_CHAR;
9502
- }
9503
- continue;
9504
- }
9505
- }
9506
- }
9507
- }
9508
-
9509
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
9510
- value = `\\${value}`;
9511
- }
9512
-
9513
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
9514
- value = `\\${value}`;
9515
- }
9516
-
9517
- if (opts.posix === true && value === '!' && prev.value === '[') {
9518
- value = '^';
9519
- }
9520
-
9521
- prev.value += value;
9522
- append({ value });
9523
- continue;
9524
- }
9525
-
9526
- /**
9527
- * If we're inside a quoted string, continue
9528
- * until we reach the closing double quote.
9529
- */
9530
-
9531
- if (state.quotes === 1 && value !== '"') {
9532
- value = utils$1.escapeRegex(value);
9533
- prev.value += value;
9534
- append({ value });
9535
- continue;
9536
- }
9537
-
9538
- /**
9539
- * Double quotes
9540
- */
9541
-
9542
- if (value === '"') {
9543
- state.quotes = state.quotes === 1 ? 0 : 1;
9544
- if (opts.keepQuotes === true) {
9545
- push({ type: 'text', value });
9546
- }
9547
- continue;
9548
- }
9549
-
9550
- /**
9551
- * Parentheses
9552
- */
9553
-
9554
- if (value === '(') {
9555
- increment('parens');
9556
- push({ type: 'paren', value });
9557
- continue;
9558
- }
9559
-
9560
- if (value === ')') {
9561
- if (state.parens === 0 && opts.strictBrackets === true) {
9562
- throw new SyntaxError(syntaxError('opening', '('));
9563
- }
9564
-
9565
- const extglob = extglobs[extglobs.length - 1];
9566
- if (extglob && state.parens === extglob.parens + 1) {
9567
- extglobClose(extglobs.pop());
9568
- continue;
9569
- }
9570
-
9571
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
9572
- decrement('parens');
9573
- continue;
9574
- }
9575
-
9576
- /**
9577
- * Square brackets
9578
- */
9579
-
9580
- if (value === '[') {
9581
- if (opts.nobracket === true || !remaining().includes(']')) {
9582
- if (opts.nobracket !== true && opts.strictBrackets === true) {
9583
- throw new SyntaxError(syntaxError('closing', ']'));
9584
- }
9585
-
9586
- value = `\\${value}`;
9587
- } else {
9588
- increment('brackets');
9589
- }
9590
-
9591
- push({ type: 'bracket', value });
9592
- continue;
9593
- }
9594
-
9595
- if (value === ']') {
9596
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
9597
- push({ type: 'text', value, output: `\\${value}` });
9598
- continue;
9599
- }
9600
-
9601
- if (state.brackets === 0) {
9602
- if (opts.strictBrackets === true) {
9603
- throw new SyntaxError(syntaxError('opening', '['));
9604
- }
9605
-
9606
- push({ type: 'text', value, output: `\\${value}` });
9607
- continue;
9608
- }
9609
-
9610
- decrement('brackets');
9611
-
9612
- const prevValue = prev.value.slice(1);
9613
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
9614
- value = `/${value}`;
9615
- }
9616
-
9617
- prev.value += value;
9618
- append({ value });
9619
-
9620
- // when literal brackets are explicitly disabled
9621
- // assume we should match with a regex character class
9622
- if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
9623
- continue;
9624
- }
9625
-
9626
- const escaped = utils$1.escapeRegex(prev.value);
9627
- state.output = state.output.slice(0, -prev.value.length);
9628
-
9629
- // when literal brackets are explicitly enabled
9630
- // assume we should escape the brackets to match literal characters
9631
- if (opts.literalBrackets === true) {
9632
- state.output += escaped;
9633
- prev.value = escaped;
9634
- continue;
9635
- }
9636
-
9637
- // when the user specifies nothing, try to match both
9638
- prev.value = `(${capture}${escaped}|${prev.value})`;
9639
- state.output += prev.value;
9640
- continue;
9641
- }
9642
-
9643
- /**
9644
- * Braces
9645
- */
9646
-
9647
- if (value === '{' && opts.nobrace !== true) {
9648
- increment('braces');
9649
-
9650
- const open = {
9651
- type: 'brace',
9652
- value,
9653
- output: '(',
9654
- outputIndex: state.output.length,
9655
- tokensIndex: state.tokens.length
9656
- };
9657
-
9658
- braces.push(open);
9659
- push(open);
9660
- continue;
9661
- }
9662
-
9663
- if (value === '}') {
9664
- const brace = braces[braces.length - 1];
9665
-
9666
- if (opts.nobrace === true || !brace) {
9667
- push({ type: 'text', value, output: value });
9668
- continue;
9669
- }
9670
-
9671
- let output = ')';
9672
-
9673
- if (brace.dots === true) {
9674
- const arr = tokens.slice();
9675
- const range = [];
9676
-
9677
- for (let i = arr.length - 1; i >= 0; i--) {
9678
- tokens.pop();
9679
- if (arr[i].type === 'brace') {
9680
- break;
9681
- }
9682
- if (arr[i].type !== 'dots') {
9683
- range.unshift(arr[i].value);
9684
- }
9685
- }
9686
-
9687
- output = expandRange(range, opts);
9688
- state.backtrack = true;
9689
- }
9690
-
9691
- if (brace.comma !== true && brace.dots !== true) {
9692
- const out = state.output.slice(0, brace.outputIndex);
9693
- const toks = state.tokens.slice(brace.tokensIndex);
9694
- brace.value = brace.output = '\\{';
9695
- value = output = '\\}';
9696
- state.output = out;
9697
- for (const t of toks) {
9698
- state.output += (t.output || t.value);
9699
- }
9700
- }
9701
-
9702
- push({ type: 'brace', value, output });
9703
- decrement('braces');
9704
- braces.pop();
9705
- continue;
9706
- }
9707
-
9708
- /**
9709
- * Pipes
9710
- */
9711
-
9712
- if (value === '|') {
9713
- if (extglobs.length > 0) {
9714
- extglobs[extglobs.length - 1].conditions++;
9715
- }
9716
- push({ type: 'text', value });
9717
- continue;
9718
- }
9719
-
9720
- /**
9721
- * Commas
9722
- */
9723
-
9724
- if (value === ',') {
9725
- let output = value;
9726
-
9727
- const brace = braces[braces.length - 1];
9728
- if (brace && stack[stack.length - 1] === 'braces') {
9729
- brace.comma = true;
9730
- output = '|';
9731
- }
9732
-
9733
- push({ type: 'comma', value, output });
9734
- continue;
9735
- }
9736
-
9737
- /**
9738
- * Slashes
9739
- */
9740
-
9741
- if (value === '/') {
9742
- // if the beginning of the glob is "./", advance the start
9743
- // to the current index, and don't add the "./" characters
9744
- // to the state. This greatly simplifies lookbehinds when
9745
- // checking for BOS characters like "!" and "." (not "./")
9746
- if (prev.type === 'dot' && state.index === state.start + 1) {
9747
- state.start = state.index + 1;
9748
- state.consumed = '';
9749
- state.output = '';
9750
- tokens.pop();
9751
- prev = bos; // reset "prev" to the first token
9752
- continue;
9753
- }
9754
-
9755
- push({ type: 'slash', value, output: SLASH_LITERAL });
9756
- continue;
9757
- }
9758
-
9759
- /**
9760
- * Dots
9761
- */
9762
-
9763
- if (value === '.') {
9764
- if (state.braces > 0 && prev.type === 'dot') {
9765
- if (prev.value === '.') prev.output = DOT_LITERAL;
9766
- const brace = braces[braces.length - 1];
9767
- prev.type = 'dots';
9768
- prev.output += value;
9769
- prev.value += value;
9770
- brace.dots = true;
9771
- continue;
9772
- }
9773
-
9774
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
9775
- push({ type: 'text', value, output: DOT_LITERAL });
9776
- continue;
9777
- }
8693
+ exports.supportsLookbehinds = () => {
8694
+ const segs = process.version.slice(1).split('.').map(Number);
8695
+ if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
8696
+ return true;
8697
+ }
8698
+ return false;
8699
+ };
9778
8700
 
9779
- push({ type: 'dot', value, output: DOT_LITERAL });
9780
- continue;
9781
- }
8701
+ exports.isWindows = options => {
8702
+ if (options && typeof options.windows === 'boolean') {
8703
+ return options.windows;
8704
+ }
8705
+ return win32 === true || path.sep === '\\';
8706
+ };
9782
8707
 
9783
- /**
9784
- * Question marks
9785
- */
8708
+ exports.escapeLast = (input, char, lastIdx) => {
8709
+ const idx = input.lastIndexOf(char, lastIdx);
8710
+ if (idx === -1) return input;
8711
+ if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
8712
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
8713
+ };
9786
8714
 
9787
- if (value === '?') {
9788
- const isGroup = prev && prev.value === '(';
9789
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
9790
- extglobOpen('qmark', value);
9791
- continue;
9792
- }
8715
+ exports.removePrefix = (input, state = {}) => {
8716
+ let output = input;
8717
+ if (output.startsWith('./')) {
8718
+ output = output.slice(2);
8719
+ state.prefix = './';
8720
+ }
8721
+ return output;
8722
+ };
9793
8723
 
9794
- if (prev && prev.type === 'paren') {
9795
- const next = peek();
9796
- let output = value;
8724
+ exports.wrapOutput = (input, state = {}, options = {}) => {
8725
+ const prepend = options.contains ? '' : '^';
8726
+ const append = options.contains ? '' : '$';
9797
8727
 
9798
- if (next === '<' && !utils$1.supportsLookbehinds()) {
9799
- throw new Error('Node.js v10 or higher is required for regex lookbehinds');
9800
- }
8728
+ let output = `${prepend}(?:${input})${append}`;
8729
+ if (state.negated === true) {
8730
+ output = `(?:^(?!${output}).*$)`;
8731
+ }
8732
+ return output;
8733
+ };
8734
+ } (utils));
8735
+ return utils;
8736
+ }
9801
8737
 
9802
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
9803
- output = `\\${value}`;
9804
- }
8738
+ var scan_1;
8739
+ var hasRequiredScan;
9805
8740
 
9806
- push({ type: 'text', value, output });
9807
- continue;
9808
- }
8741
+ function requireScan () {
8742
+ if (hasRequiredScan) return scan_1;
8743
+ hasRequiredScan = 1;
9809
8744
 
9810
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
9811
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
9812
- continue;
9813
- }
8745
+ const utils = /*@__PURE__*/ requireUtils();
8746
+ const {
8747
+ CHAR_ASTERISK, /* * */
8748
+ CHAR_AT, /* @ */
8749
+ CHAR_BACKWARD_SLASH, /* \ */
8750
+ CHAR_COMMA, /* , */
8751
+ CHAR_DOT, /* . */
8752
+ CHAR_EXCLAMATION_MARK, /* ! */
8753
+ CHAR_FORWARD_SLASH, /* / */
8754
+ CHAR_LEFT_CURLY_BRACE, /* { */
8755
+ CHAR_LEFT_PARENTHESES, /* ( */
8756
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
8757
+ CHAR_PLUS, /* + */
8758
+ CHAR_QUESTION_MARK, /* ? */
8759
+ CHAR_RIGHT_CURLY_BRACE, /* } */
8760
+ CHAR_RIGHT_PARENTHESES, /* ) */
8761
+ CHAR_RIGHT_SQUARE_BRACKET /* ] */
8762
+ } = /*@__PURE__*/ requireConstants();
8763
+
8764
+ const isPathSeparator = code => {
8765
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
8766
+ };
9814
8767
 
9815
- push({ type: 'qmark', value, output: QMARK });
9816
- continue;
9817
- }
8768
+ const depth = token => {
8769
+ if (token.isPrefix !== true) {
8770
+ token.depth = token.isGlobstar ? Infinity : 1;
8771
+ }
8772
+ };
9818
8773
 
9819
- /**
9820
- * Exclamation
9821
- */
8774
+ /**
8775
+ * Quickly scans a glob pattern and returns an object with a handful of
8776
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
8777
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
8778
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
8779
+ *
8780
+ * ```js
8781
+ * const pm = require('picomatch');
8782
+ * console.log(pm.scan('foo/bar/*.js'));
8783
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
8784
+ * ```
8785
+ * @param {String} `str`
8786
+ * @param {Object} `options`
8787
+ * @return {Object} Returns an object with tokens and regex source string.
8788
+ * @api public
8789
+ */
8790
+
8791
+ const scan = (input, options) => {
8792
+ const opts = options || {};
8793
+
8794
+ const length = input.length - 1;
8795
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
8796
+ const slashes = [];
8797
+ const tokens = [];
8798
+ const parts = [];
8799
+
8800
+ let str = input;
8801
+ let index = -1;
8802
+ let start = 0;
8803
+ let lastIndex = 0;
8804
+ let isBrace = false;
8805
+ let isBracket = false;
8806
+ let isGlob = false;
8807
+ let isExtglob = false;
8808
+ let isGlobstar = false;
8809
+ let braceEscaped = false;
8810
+ let backslashes = false;
8811
+ let negated = false;
8812
+ let negatedExtglob = false;
8813
+ let finished = false;
8814
+ let braces = 0;
8815
+ let prev;
8816
+ let code;
8817
+ let token = { value: '', depth: 0, isGlob: false };
8818
+
8819
+ const eos = () => index >= length;
8820
+ const peek = () => str.charCodeAt(index + 1);
8821
+ const advance = () => {
8822
+ prev = code;
8823
+ return str.charCodeAt(++index);
8824
+ };
8825
+
8826
+ while (index < length) {
8827
+ code = advance();
8828
+ let next;
8829
+
8830
+ if (code === CHAR_BACKWARD_SLASH) {
8831
+ backslashes = token.backslashes = true;
8832
+ code = advance();
8833
+
8834
+ if (code === CHAR_LEFT_CURLY_BRACE) {
8835
+ braceEscaped = true;
8836
+ }
8837
+ continue;
8838
+ }
8839
+
8840
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
8841
+ braces++;
8842
+
8843
+ while (eos() !== true && (code = advance())) {
8844
+ if (code === CHAR_BACKWARD_SLASH) {
8845
+ backslashes = token.backslashes = true;
8846
+ advance();
8847
+ continue;
8848
+ }
8849
+
8850
+ if (code === CHAR_LEFT_CURLY_BRACE) {
8851
+ braces++;
8852
+ continue;
8853
+ }
8854
+
8855
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
8856
+ isBrace = token.isBrace = true;
8857
+ isGlob = token.isGlob = true;
8858
+ finished = true;
8859
+
8860
+ if (scanToEnd === true) {
8861
+ continue;
8862
+ }
8863
+
8864
+ break;
8865
+ }
8866
+
8867
+ if (braceEscaped !== true && code === CHAR_COMMA) {
8868
+ isBrace = token.isBrace = true;
8869
+ isGlob = token.isGlob = true;
8870
+ finished = true;
8871
+
8872
+ if (scanToEnd === true) {
8873
+ continue;
8874
+ }
8875
+
8876
+ break;
8877
+ }
8878
+
8879
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
8880
+ braces--;
8881
+
8882
+ if (braces === 0) {
8883
+ braceEscaped = false;
8884
+ isBrace = token.isBrace = true;
8885
+ finished = true;
8886
+ break;
8887
+ }
8888
+ }
8889
+ }
8890
+
8891
+ if (scanToEnd === true) {
8892
+ continue;
8893
+ }
8894
+
8895
+ break;
8896
+ }
8897
+
8898
+ if (code === CHAR_FORWARD_SLASH) {
8899
+ slashes.push(index);
8900
+ tokens.push(token);
8901
+ token = { value: '', depth: 0, isGlob: false };
8902
+
8903
+ if (finished === true) continue;
8904
+ if (prev === CHAR_DOT && index === (start + 1)) {
8905
+ start += 2;
8906
+ continue;
8907
+ }
8908
+
8909
+ lastIndex = index + 1;
8910
+ continue;
8911
+ }
8912
+
8913
+ if (opts.noext !== true) {
8914
+ const isExtglobChar = code === CHAR_PLUS
8915
+ || code === CHAR_AT
8916
+ || code === CHAR_ASTERISK
8917
+ || code === CHAR_QUESTION_MARK
8918
+ || code === CHAR_EXCLAMATION_MARK;
8919
+
8920
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
8921
+ isGlob = token.isGlob = true;
8922
+ isExtglob = token.isExtglob = true;
8923
+ finished = true;
8924
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
8925
+ negatedExtglob = true;
8926
+ }
8927
+
8928
+ if (scanToEnd === true) {
8929
+ while (eos() !== true && (code = advance())) {
8930
+ if (code === CHAR_BACKWARD_SLASH) {
8931
+ backslashes = token.backslashes = true;
8932
+ code = advance();
8933
+ continue;
8934
+ }
8935
+
8936
+ if (code === CHAR_RIGHT_PARENTHESES) {
8937
+ isGlob = token.isGlob = true;
8938
+ finished = true;
8939
+ break;
8940
+ }
8941
+ }
8942
+ continue;
8943
+ }
8944
+ break;
8945
+ }
8946
+ }
8947
+
8948
+ if (code === CHAR_ASTERISK) {
8949
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
8950
+ isGlob = token.isGlob = true;
8951
+ finished = true;
8952
+
8953
+ if (scanToEnd === true) {
8954
+ continue;
8955
+ }
8956
+ break;
8957
+ }
8958
+
8959
+ if (code === CHAR_QUESTION_MARK) {
8960
+ isGlob = token.isGlob = true;
8961
+ finished = true;
8962
+
8963
+ if (scanToEnd === true) {
8964
+ continue;
8965
+ }
8966
+ break;
8967
+ }
8968
+
8969
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
8970
+ while (eos() !== true && (next = advance())) {
8971
+ if (next === CHAR_BACKWARD_SLASH) {
8972
+ backslashes = token.backslashes = true;
8973
+ advance();
8974
+ continue;
8975
+ }
8976
+
8977
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
8978
+ isBracket = token.isBracket = true;
8979
+ isGlob = token.isGlob = true;
8980
+ finished = true;
8981
+ break;
8982
+ }
8983
+ }
8984
+
8985
+ if (scanToEnd === true) {
8986
+ continue;
8987
+ }
8988
+
8989
+ break;
8990
+ }
8991
+
8992
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
8993
+ negated = token.negated = true;
8994
+ start++;
8995
+ continue;
8996
+ }
8997
+
8998
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
8999
+ isGlob = token.isGlob = true;
9000
+
9001
+ if (scanToEnd === true) {
9002
+ while (eos() !== true && (code = advance())) {
9003
+ if (code === CHAR_LEFT_PARENTHESES) {
9004
+ backslashes = token.backslashes = true;
9005
+ code = advance();
9006
+ continue;
9007
+ }
9008
+
9009
+ if (code === CHAR_RIGHT_PARENTHESES) {
9010
+ finished = true;
9011
+ break;
9012
+ }
9013
+ }
9014
+ continue;
9015
+ }
9016
+ break;
9017
+ }
9018
+
9019
+ if (isGlob === true) {
9020
+ finished = true;
9021
+
9022
+ if (scanToEnd === true) {
9023
+ continue;
9024
+ }
9025
+
9026
+ break;
9027
+ }
9028
+ }
9822
9029
 
9823
- if (value === '!') {
9824
- if (opts.noextglob !== true && peek() === '(') {
9825
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
9826
- extglobOpen('negate', value);
9827
- continue;
9828
- }
9829
- }
9030
+ if (opts.noext === true) {
9031
+ isExtglob = false;
9032
+ isGlob = false;
9033
+ }
9830
9034
 
9831
- if (opts.nonegate !== true && state.index === 0) {
9832
- negate();
9833
- continue;
9834
- }
9835
- }
9035
+ let base = str;
9036
+ let prefix = '';
9037
+ let glob = '';
9836
9038
 
9837
- /**
9838
- * Plus
9839
- */
9039
+ if (start > 0) {
9040
+ prefix = str.slice(0, start);
9041
+ str = str.slice(start);
9042
+ lastIndex -= start;
9043
+ }
9840
9044
 
9841
- if (value === '+') {
9842
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
9843
- extglobOpen('plus', value);
9844
- continue;
9845
- }
9045
+ if (base && isGlob === true && lastIndex > 0) {
9046
+ base = str.slice(0, lastIndex);
9047
+ glob = str.slice(lastIndex);
9048
+ } else if (isGlob === true) {
9049
+ base = '';
9050
+ glob = str;
9051
+ } else {
9052
+ base = str;
9053
+ }
9846
9054
 
9847
- if ((prev && prev.value === '(') || opts.regex === false) {
9848
- push({ type: 'plus', value, output: PLUS_LITERAL });
9849
- continue;
9850
- }
9055
+ if (base && base !== '' && base !== '/' && base !== str) {
9056
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
9057
+ base = base.slice(0, -1);
9058
+ }
9059
+ }
9851
9060
 
9852
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
9853
- push({ type: 'plus', value });
9854
- continue;
9855
- }
9061
+ if (opts.unescape === true) {
9062
+ if (glob) glob = utils.removeBackslashes(glob);
9856
9063
 
9857
- push({ type: 'plus', value: PLUS_LITERAL });
9858
- continue;
9859
- }
9064
+ if (base && backslashes === true) {
9065
+ base = utils.removeBackslashes(base);
9066
+ }
9067
+ }
9860
9068
 
9861
- /**
9862
- * Plain text
9863
- */
9069
+ const state = {
9070
+ prefix,
9071
+ input,
9072
+ start,
9073
+ base,
9074
+ glob,
9075
+ isBrace,
9076
+ isBracket,
9077
+ isGlob,
9078
+ isExtglob,
9079
+ isGlobstar,
9080
+ negated,
9081
+ negatedExtglob
9082
+ };
9083
+
9084
+ if (opts.tokens === true) {
9085
+ state.maxDepth = 0;
9086
+ if (!isPathSeparator(code)) {
9087
+ tokens.push(token);
9088
+ }
9089
+ state.tokens = tokens;
9090
+ }
9864
9091
 
9865
- if (value === '@') {
9866
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
9867
- push({ type: 'at', extglob: true, value, output: '' });
9868
- continue;
9869
- }
9092
+ if (opts.parts === true || opts.tokens === true) {
9093
+ let prevIndex;
9094
+
9095
+ for (let idx = 0; idx < slashes.length; idx++) {
9096
+ const n = prevIndex ? prevIndex + 1 : start;
9097
+ const i = slashes[idx];
9098
+ const value = input.slice(n, i);
9099
+ if (opts.tokens) {
9100
+ if (idx === 0 && start !== 0) {
9101
+ tokens[idx].isPrefix = true;
9102
+ tokens[idx].value = prefix;
9103
+ } else {
9104
+ tokens[idx].value = value;
9105
+ }
9106
+ depth(tokens[idx]);
9107
+ state.maxDepth += tokens[idx].depth;
9108
+ }
9109
+ if (idx !== 0 || value !== '') {
9110
+ parts.push(value);
9111
+ }
9112
+ prevIndex = i;
9113
+ }
9114
+
9115
+ if (prevIndex && prevIndex + 1 < input.length) {
9116
+ const value = input.slice(prevIndex + 1);
9117
+ parts.push(value);
9118
+
9119
+ if (opts.tokens) {
9120
+ tokens[tokens.length - 1].value = value;
9121
+ depth(tokens[tokens.length - 1]);
9122
+ state.maxDepth += tokens[tokens.length - 1].depth;
9123
+ }
9124
+ }
9125
+
9126
+ state.slashes = slashes;
9127
+ state.parts = parts;
9128
+ }
9870
9129
 
9871
- push({ type: 'text', value });
9872
- continue;
9873
- }
9130
+ return state;
9131
+ };
9874
9132
 
9875
- /**
9876
- * Plain text
9877
- */
9133
+ scan_1 = scan;
9134
+ return scan_1;
9135
+ }
9878
9136
 
9879
- if (value !== '*') {
9880
- if (value === '$' || value === '^') {
9881
- value = `\\${value}`;
9882
- }
9137
+ var parse_1;
9138
+ var hasRequiredParse;
9883
9139
 
9884
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
9885
- if (match) {
9886
- value += match[0];
9887
- state.index += match[0].length;
9888
- }
9140
+ function requireParse () {
9141
+ if (hasRequiredParse) return parse_1;
9142
+ hasRequiredParse = 1;
9889
9143
 
9890
- push({ type: 'text', value });
9891
- continue;
9892
- }
9144
+ const constants = /*@__PURE__*/ requireConstants();
9145
+ const utils = /*@__PURE__*/ requireUtils();
9893
9146
 
9894
- /**
9895
- * Stars
9896
- */
9147
+ /**
9148
+ * Constants
9149
+ */
9897
9150
 
9898
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
9899
- prev.type = 'star';
9900
- prev.star = true;
9901
- prev.value += value;
9902
- prev.output = star;
9903
- state.backtrack = true;
9904
- state.globstar = true;
9905
- consume(value);
9906
- continue;
9907
- }
9908
-
9909
- let rest = remaining();
9910
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
9911
- extglobOpen('star', value);
9912
- continue;
9913
- }
9914
-
9915
- if (prev.type === 'star') {
9916
- if (opts.noglobstar === true) {
9917
- consume(value);
9918
- continue;
9919
- }
9920
-
9921
- const prior = prev.prev;
9922
- const before = prior.prev;
9923
- const isStart = prior.type === 'slash' || prior.type === 'bos';
9924
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
9925
-
9926
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
9927
- push({ type: 'star', value, output: '' });
9928
- continue;
9929
- }
9930
-
9931
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
9932
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
9933
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
9934
- push({ type: 'star', value, output: '' });
9935
- continue;
9936
- }
9937
-
9938
- // strip consecutive `/**/`
9939
- while (rest.slice(0, 3) === '/**') {
9940
- const after = input[state.index + 4];
9941
- if (after && after !== '/') {
9942
- break;
9943
- }
9944
- rest = rest.slice(3);
9945
- consume('/**', 3);
9946
- }
9947
-
9948
- if (prior.type === 'bos' && eos()) {
9949
- prev.type = 'globstar';
9950
- prev.value += value;
9951
- prev.output = globstar(opts);
9952
- state.output = prev.output;
9953
- state.globstar = true;
9954
- consume(value);
9955
- continue;
9956
- }
9957
-
9958
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
9959
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
9960
- prior.output = `(?:${prior.output}`;
9961
-
9962
- prev.type = 'globstar';
9963
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
9964
- prev.value += value;
9965
- state.globstar = true;
9966
- state.output += prior.output + prev.output;
9967
- consume(value);
9968
- continue;
9969
- }
9970
-
9971
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
9972
- const end = rest[1] !== void 0 ? '|$' : '';
9973
-
9974
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
9975
- prior.output = `(?:${prior.output}`;
9976
-
9977
- prev.type = 'globstar';
9978
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
9979
- prev.value += value;
9980
-
9981
- state.output += prior.output + prev.output;
9982
- state.globstar = true;
9983
-
9984
- consume(value + advance());
9985
-
9986
- push({ type: 'slash', value: '/', output: '' });
9987
- continue;
9988
- }
9989
-
9990
- if (prior.type === 'bos' && rest[0] === '/') {
9991
- prev.type = 'globstar';
9992
- prev.value += value;
9993
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
9994
- state.output = prev.output;
9995
- state.globstar = true;
9996
- consume(value + advance());
9997
- push({ type: 'slash', value: '/', output: '' });
9998
- continue;
9999
- }
10000
-
10001
- // remove single star from output
10002
- state.output = state.output.slice(0, -prev.output.length);
10003
-
10004
- // reset previous token to globstar
10005
- prev.type = 'globstar';
10006
- prev.output = globstar(opts);
10007
- prev.value += value;
10008
-
10009
- // reset output with globstar
10010
- state.output += prev.output;
10011
- state.globstar = true;
10012
- consume(value);
10013
- continue;
10014
- }
10015
-
10016
- const token = { type: 'star', value, output: star };
10017
-
10018
- if (opts.bash === true) {
10019
- token.output = '.*?';
10020
- if (prev.type === 'bos' || prev.type === 'slash') {
10021
- token.output = nodot + token.output;
10022
- }
10023
- push(token);
10024
- continue;
10025
- }
10026
-
10027
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
10028
- token.output = value;
10029
- push(token);
10030
- continue;
10031
- }
10032
-
10033
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
10034
- if (prev.type === 'dot') {
10035
- state.output += NO_DOT_SLASH;
10036
- prev.output += NO_DOT_SLASH;
10037
-
10038
- } else if (opts.dot === true) {
10039
- state.output += NO_DOTS_SLASH;
10040
- prev.output += NO_DOTS_SLASH;
10041
-
10042
- } else {
10043
- state.output += nodot;
10044
- prev.output += nodot;
10045
- }
10046
-
10047
- if (peek() !== '*') {
10048
- state.output += ONE_CHAR;
10049
- prev.output += ONE_CHAR;
10050
- }
10051
- }
10052
-
10053
- push(token);
10054
- }
10055
-
10056
- while (state.brackets > 0) {
10057
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
10058
- state.output = utils$1.escapeLast(state.output, '[');
10059
- decrement('brackets');
10060
- }
9151
+ const {
9152
+ MAX_LENGTH,
9153
+ POSIX_REGEX_SOURCE,
9154
+ REGEX_NON_SPECIAL_CHARS,
9155
+ REGEX_SPECIAL_CHARS_BACKREF,
9156
+ REPLACEMENTS
9157
+ } = constants;
9158
+
9159
+ /**
9160
+ * Helpers
9161
+ */
9162
+
9163
+ const expandRange = (args, options) => {
9164
+ if (typeof options.expandRange === 'function') {
9165
+ return options.expandRange(...args, options);
9166
+ }
10061
9167
 
10062
- while (state.parens > 0) {
10063
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
10064
- state.output = utils$1.escapeLast(state.output, '(');
10065
- decrement('parens');
10066
- }
9168
+ args.sort();
9169
+ const value = `[${args.join('-')}]`;
10067
9170
 
10068
- while (state.braces > 0) {
10069
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
10070
- state.output = utils$1.escapeLast(state.output, '{');
10071
- decrement('braces');
10072
- }
9171
+ return value;
9172
+ };
10073
9173
 
10074
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
10075
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
10076
- }
9174
+ /**
9175
+ * Create the message for a syntax error
9176
+ */
10077
9177
 
10078
- // rebuild the output if we had to backtrack at any point
10079
- if (state.backtrack === true) {
10080
- state.output = '';
9178
+ const syntaxError = (type, char) => {
9179
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
9180
+ };
10081
9181
 
10082
- for (const token of state.tokens) {
10083
- state.output += token.output != null ? token.output : token.value;
10084
-
10085
- if (token.suffix) {
10086
- state.output += token.suffix;
10087
- }
10088
- }
10089
- }
10090
-
10091
- return state;
10092
- };
9182
+ /**
9183
+ * Parse the given input string.
9184
+ * @param {String} input
9185
+ * @param {Object} options
9186
+ * @return {Object}
9187
+ */
10093
9188
 
10094
- /**
10095
- * Fast paths for creating regular expressions for common glob patterns.
10096
- * This can significantly speed up processing and has very little downside
10097
- * impact when none of the fast paths match.
10098
- */
10099
-
10100
- parse$1.fastpaths = (input, options) => {
10101
- const opts = { ...options };
10102
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
10103
- const len = input.length;
10104
- if (len > max) {
10105
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
10106
- }
9189
+ const parse = (input, options) => {
9190
+ if (typeof input !== 'string') {
9191
+ throw new TypeError('Expected a string');
9192
+ }
10107
9193
 
10108
- input = REPLACEMENTS[input] || input;
10109
- const win32 = utils$1.isWindows(options);
9194
+ input = REPLACEMENTS[input] || input;
10110
9195
 
10111
- // create constants based on platform, for windows or posix
10112
- const {
10113
- DOT_LITERAL,
10114
- SLASH_LITERAL,
10115
- ONE_CHAR,
10116
- DOTS_SLASH,
10117
- NO_DOT,
10118
- NO_DOTS,
10119
- NO_DOTS_SLASH,
10120
- STAR,
10121
- START_ANCHOR
10122
- } = constants$1.globChars(win32);
9196
+ const opts = { ...options };
9197
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
10123
9198
 
10124
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
10125
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
10126
- const capture = opts.capture ? '' : '?:';
10127
- const state = { negated: false, prefix: '' };
10128
- let star = opts.bash === true ? '.*?' : STAR;
9199
+ let len = input.length;
9200
+ if (len > max) {
9201
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
9202
+ }
10129
9203
 
10130
- if (opts.capture) {
10131
- star = `(${star})`;
10132
- }
9204
+ const bos = { type: 'bos', value: '', output: opts.prepend || '' };
9205
+ const tokens = [bos];
9206
+
9207
+ const capture = opts.capture ? '' : '?:';
9208
+ const win32 = utils.isWindows(options);
9209
+
9210
+ // create constants based on platform, for windows or posix
9211
+ const PLATFORM_CHARS = constants.globChars(win32);
9212
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
9213
+
9214
+ const {
9215
+ DOT_LITERAL,
9216
+ PLUS_LITERAL,
9217
+ SLASH_LITERAL,
9218
+ ONE_CHAR,
9219
+ DOTS_SLASH,
9220
+ NO_DOT,
9221
+ NO_DOT_SLASH,
9222
+ NO_DOTS_SLASH,
9223
+ QMARK,
9224
+ QMARK_NO_DOT,
9225
+ STAR,
9226
+ START_ANCHOR
9227
+ } = PLATFORM_CHARS;
9228
+
9229
+ const globstar = opts => {
9230
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
9231
+ };
9232
+
9233
+ const nodot = opts.dot ? '' : NO_DOT;
9234
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
9235
+ let star = opts.bash === true ? globstar(opts) : STAR;
9236
+
9237
+ if (opts.capture) {
9238
+ star = `(${star})`;
9239
+ }
10133
9240
 
10134
- const globstar = opts => {
10135
- if (opts.noglobstar === true) return star;
10136
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
10137
- };
9241
+ // minimatch options support
9242
+ if (typeof opts.noext === 'boolean') {
9243
+ opts.noextglob = opts.noext;
9244
+ }
10138
9245
 
10139
- const create = str => {
10140
- switch (str) {
10141
- case '*':
10142
- return `${nodot}${ONE_CHAR}${star}`;
9246
+ const state = {
9247
+ input,
9248
+ index: -1,
9249
+ start: 0,
9250
+ dot: opts.dot === true,
9251
+ consumed: '',
9252
+ output: '',
9253
+ prefix: '',
9254
+ backtrack: false,
9255
+ negated: false,
9256
+ brackets: 0,
9257
+ braces: 0,
9258
+ parens: 0,
9259
+ quotes: 0,
9260
+ globstar: false,
9261
+ tokens
9262
+ };
9263
+
9264
+ input = utils.removePrefix(input, state);
9265
+ len = input.length;
9266
+
9267
+ const extglobs = [];
9268
+ const braces = [];
9269
+ const stack = [];
9270
+ let prev = bos;
9271
+ let value;
9272
+
9273
+ /**
9274
+ * Tokenizing helpers
9275
+ */
9276
+
9277
+ const eos = () => state.index === len - 1;
9278
+ const peek = state.peek = (n = 1) => input[state.index + n];
9279
+ const advance = state.advance = () => input[++state.index] || '';
9280
+ const remaining = () => input.slice(state.index + 1);
9281
+ const consume = (value = '', num = 0) => {
9282
+ state.consumed += value;
9283
+ state.index += num;
9284
+ };
9285
+
9286
+ const append = token => {
9287
+ state.output += token.output != null ? token.output : token.value;
9288
+ consume(token.value);
9289
+ };
9290
+
9291
+ const negate = () => {
9292
+ let count = 1;
9293
+
9294
+ while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
9295
+ advance();
9296
+ state.start++;
9297
+ count++;
9298
+ }
9299
+
9300
+ if (count % 2 === 0) {
9301
+ return false;
9302
+ }
9303
+
9304
+ state.negated = true;
9305
+ state.start++;
9306
+ return true;
9307
+ };
9308
+
9309
+ const increment = type => {
9310
+ state[type]++;
9311
+ stack.push(type);
9312
+ };
9313
+
9314
+ const decrement = type => {
9315
+ state[type]--;
9316
+ stack.pop();
9317
+ };
9318
+
9319
+ /**
9320
+ * Push tokens onto the tokens array. This helper speeds up
9321
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
9322
+ * and 2) helping us avoid creating extra tokens when consecutive
9323
+ * characters are plain text. This improves performance and simplifies
9324
+ * lookbehinds.
9325
+ */
9326
+
9327
+ const push = tok => {
9328
+ if (prev.type === 'globstar') {
9329
+ const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
9330
+ const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
9331
+
9332
+ if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
9333
+ state.output = state.output.slice(0, -prev.output.length);
9334
+ prev.type = 'star';
9335
+ prev.value = '*';
9336
+ prev.output = star;
9337
+ state.output += prev.output;
9338
+ }
9339
+ }
9340
+
9341
+ if (extglobs.length && tok.type !== 'paren') {
9342
+ extglobs[extglobs.length - 1].inner += tok.value;
9343
+ }
9344
+
9345
+ if (tok.value || tok.output) append(tok);
9346
+ if (prev && prev.type === 'text' && tok.type === 'text') {
9347
+ prev.value += tok.value;
9348
+ prev.output = (prev.output || '') + tok.value;
9349
+ return;
9350
+ }
9351
+
9352
+ tok.prev = prev;
9353
+ tokens.push(tok);
9354
+ prev = tok;
9355
+ };
9356
+
9357
+ const extglobOpen = (type, value) => {
9358
+ const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
9359
+
9360
+ token.prev = prev;
9361
+ token.parens = state.parens;
9362
+ token.output = state.output;
9363
+ const output = (opts.capture ? '(' : '') + token.open;
9364
+
9365
+ increment('parens');
9366
+ push({ type, value, output: state.output ? '' : ONE_CHAR });
9367
+ push({ type: 'paren', extglob: true, value: advance(), output });
9368
+ extglobs.push(token);
9369
+ };
9370
+
9371
+ const extglobClose = token => {
9372
+ let output = token.close + (opts.capture ? ')' : '');
9373
+ let rest;
9374
+
9375
+ if (token.type === 'negate') {
9376
+ let extglobStar = star;
9377
+
9378
+ if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
9379
+ extglobStar = globstar(opts);
9380
+ }
9381
+
9382
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
9383
+ output = token.close = `)$))${extglobStar}`;
9384
+ }
9385
+
9386
+ if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
9387
+ // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
9388
+ // In this case, we need to parse the string and use it in the output of the original pattern.
9389
+ // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
9390
+ //
9391
+ // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
9392
+ const expression = parse(rest, { ...options, fastpaths: false }).output;
9393
+
9394
+ output = token.close = `)${expression})${extglobStar})`;
9395
+ }
9396
+
9397
+ if (token.prev.type === 'bos') {
9398
+ state.negatedExtglob = true;
9399
+ }
9400
+ }
9401
+
9402
+ push({ type: 'paren', extglob: true, value, output });
9403
+ decrement('parens');
9404
+ };
9405
+
9406
+ /**
9407
+ * Fast paths
9408
+ */
9409
+
9410
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
9411
+ let backslashes = false;
9412
+
9413
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
9414
+ if (first === '\\') {
9415
+ backslashes = true;
9416
+ return m;
9417
+ }
9418
+
9419
+ if (first === '?') {
9420
+ if (esc) {
9421
+ return esc + first + (rest ? QMARK.repeat(rest.length) : '');
9422
+ }
9423
+ if (index === 0) {
9424
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
9425
+ }
9426
+ return QMARK.repeat(chars.length);
9427
+ }
9428
+
9429
+ if (first === '.') {
9430
+ return DOT_LITERAL.repeat(chars.length);
9431
+ }
9432
+
9433
+ if (first === '*') {
9434
+ if (esc) {
9435
+ return esc + first + (rest ? star : '');
9436
+ }
9437
+ return star;
9438
+ }
9439
+ return esc ? m : `\\${m}`;
9440
+ });
9441
+
9442
+ if (backslashes === true) {
9443
+ if (opts.unescape === true) {
9444
+ output = output.replace(/\\/g, '');
9445
+ } else {
9446
+ output = output.replace(/\\+/g, m => {
9447
+ return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
9448
+ });
9449
+ }
9450
+ }
9451
+
9452
+ if (output === input && opts.contains === true) {
9453
+ state.output = input;
9454
+ return state;
9455
+ }
9456
+
9457
+ state.output = utils.wrapOutput(output, state, options);
9458
+ return state;
9459
+ }
10143
9460
 
10144
- case '.*':
10145
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
9461
+ /**
9462
+ * Tokenize input until we reach end-of-string
9463
+ */
9464
+
9465
+ while (!eos()) {
9466
+ value = advance();
9467
+
9468
+ if (value === '\u0000') {
9469
+ continue;
9470
+ }
9471
+
9472
+ /**
9473
+ * Escaped characters
9474
+ */
9475
+
9476
+ if (value === '\\') {
9477
+ const next = peek();
9478
+
9479
+ if (next === '/' && opts.bash !== true) {
9480
+ continue;
9481
+ }
9482
+
9483
+ if (next === '.' || next === ';') {
9484
+ continue;
9485
+ }
9486
+
9487
+ if (!next) {
9488
+ value += '\\';
9489
+ push({ type: 'text', value });
9490
+ continue;
9491
+ }
9492
+
9493
+ // collapse slashes to reduce potential for exploits
9494
+ const match = /^\\+/.exec(remaining());
9495
+ let slashes = 0;
9496
+
9497
+ if (match && match[0].length > 2) {
9498
+ slashes = match[0].length;
9499
+ state.index += slashes;
9500
+ if (slashes % 2 !== 0) {
9501
+ value += '\\';
9502
+ }
9503
+ }
9504
+
9505
+ if (opts.unescape === true) {
9506
+ value = advance();
9507
+ } else {
9508
+ value += advance();
9509
+ }
9510
+
9511
+ if (state.brackets === 0) {
9512
+ push({ type: 'text', value });
9513
+ continue;
9514
+ }
9515
+ }
9516
+
9517
+ /**
9518
+ * If we're inside a regex character class, continue
9519
+ * until we reach the closing bracket.
9520
+ */
9521
+
9522
+ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
9523
+ if (opts.posix !== false && value === ':') {
9524
+ const inner = prev.value.slice(1);
9525
+ if (inner.includes('[')) {
9526
+ prev.posix = true;
9527
+
9528
+ if (inner.includes(':')) {
9529
+ const idx = prev.value.lastIndexOf('[');
9530
+ const pre = prev.value.slice(0, idx);
9531
+ const rest = prev.value.slice(idx + 2);
9532
+ const posix = POSIX_REGEX_SOURCE[rest];
9533
+ if (posix) {
9534
+ prev.value = pre + posix;
9535
+ state.backtrack = true;
9536
+ advance();
9537
+
9538
+ if (!bos.output && tokens.indexOf(prev) === 1) {
9539
+ bos.output = ONE_CHAR;
9540
+ }
9541
+ continue;
9542
+ }
9543
+ }
9544
+ }
9545
+ }
9546
+
9547
+ if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
9548
+ value = `\\${value}`;
9549
+ }
9550
+
9551
+ if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
9552
+ value = `\\${value}`;
9553
+ }
9554
+
9555
+ if (opts.posix === true && value === '!' && prev.value === '[') {
9556
+ value = '^';
9557
+ }
9558
+
9559
+ prev.value += value;
9560
+ append({ value });
9561
+ continue;
9562
+ }
9563
+
9564
+ /**
9565
+ * If we're inside a quoted string, continue
9566
+ * until we reach the closing double quote.
9567
+ */
9568
+
9569
+ if (state.quotes === 1 && value !== '"') {
9570
+ value = utils.escapeRegex(value);
9571
+ prev.value += value;
9572
+ append({ value });
9573
+ continue;
9574
+ }
9575
+
9576
+ /**
9577
+ * Double quotes
9578
+ */
9579
+
9580
+ if (value === '"') {
9581
+ state.quotes = state.quotes === 1 ? 0 : 1;
9582
+ if (opts.keepQuotes === true) {
9583
+ push({ type: 'text', value });
9584
+ }
9585
+ continue;
9586
+ }
9587
+
9588
+ /**
9589
+ * Parentheses
9590
+ */
9591
+
9592
+ if (value === '(') {
9593
+ increment('parens');
9594
+ push({ type: 'paren', value });
9595
+ continue;
9596
+ }
9597
+
9598
+ if (value === ')') {
9599
+ if (state.parens === 0 && opts.strictBrackets === true) {
9600
+ throw new SyntaxError(syntaxError('opening', '('));
9601
+ }
9602
+
9603
+ const extglob = extglobs[extglobs.length - 1];
9604
+ if (extglob && state.parens === extglob.parens + 1) {
9605
+ extglobClose(extglobs.pop());
9606
+ continue;
9607
+ }
9608
+
9609
+ push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
9610
+ decrement('parens');
9611
+ continue;
9612
+ }
9613
+
9614
+ /**
9615
+ * Square brackets
9616
+ */
9617
+
9618
+ if (value === '[') {
9619
+ if (opts.nobracket === true || !remaining().includes(']')) {
9620
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
9621
+ throw new SyntaxError(syntaxError('closing', ']'));
9622
+ }
9623
+
9624
+ value = `\\${value}`;
9625
+ } else {
9626
+ increment('brackets');
9627
+ }
9628
+
9629
+ push({ type: 'bracket', value });
9630
+ continue;
9631
+ }
9632
+
9633
+ if (value === ']') {
9634
+ if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
9635
+ push({ type: 'text', value, output: `\\${value}` });
9636
+ continue;
9637
+ }
9638
+
9639
+ if (state.brackets === 0) {
9640
+ if (opts.strictBrackets === true) {
9641
+ throw new SyntaxError(syntaxError('opening', '['));
9642
+ }
9643
+
9644
+ push({ type: 'text', value, output: `\\${value}` });
9645
+ continue;
9646
+ }
9647
+
9648
+ decrement('brackets');
9649
+
9650
+ const prevValue = prev.value.slice(1);
9651
+ if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
9652
+ value = `/${value}`;
9653
+ }
9654
+
9655
+ prev.value += value;
9656
+ append({ value });
9657
+
9658
+ // when literal brackets are explicitly disabled
9659
+ // assume we should match with a regex character class
9660
+ if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
9661
+ continue;
9662
+ }
9663
+
9664
+ const escaped = utils.escapeRegex(prev.value);
9665
+ state.output = state.output.slice(0, -prev.value.length);
9666
+
9667
+ // when literal brackets are explicitly enabled
9668
+ // assume we should escape the brackets to match literal characters
9669
+ if (opts.literalBrackets === true) {
9670
+ state.output += escaped;
9671
+ prev.value = escaped;
9672
+ continue;
9673
+ }
9674
+
9675
+ // when the user specifies nothing, try to match both
9676
+ prev.value = `(${capture}${escaped}|${prev.value})`;
9677
+ state.output += prev.value;
9678
+ continue;
9679
+ }
9680
+
9681
+ /**
9682
+ * Braces
9683
+ */
9684
+
9685
+ if (value === '{' && opts.nobrace !== true) {
9686
+ increment('braces');
9687
+
9688
+ const open = {
9689
+ type: 'brace',
9690
+ value,
9691
+ output: '(',
9692
+ outputIndex: state.output.length,
9693
+ tokensIndex: state.tokens.length
9694
+ };
9695
+
9696
+ braces.push(open);
9697
+ push(open);
9698
+ continue;
9699
+ }
9700
+
9701
+ if (value === '}') {
9702
+ const brace = braces[braces.length - 1];
9703
+
9704
+ if (opts.nobrace === true || !brace) {
9705
+ push({ type: 'text', value, output: value });
9706
+ continue;
9707
+ }
9708
+
9709
+ let output = ')';
9710
+
9711
+ if (brace.dots === true) {
9712
+ const arr = tokens.slice();
9713
+ const range = [];
9714
+
9715
+ for (let i = arr.length - 1; i >= 0; i--) {
9716
+ tokens.pop();
9717
+ if (arr[i].type === 'brace') {
9718
+ break;
9719
+ }
9720
+ if (arr[i].type !== 'dots') {
9721
+ range.unshift(arr[i].value);
9722
+ }
9723
+ }
9724
+
9725
+ output = expandRange(range, opts);
9726
+ state.backtrack = true;
9727
+ }
9728
+
9729
+ if (brace.comma !== true && brace.dots !== true) {
9730
+ const out = state.output.slice(0, brace.outputIndex);
9731
+ const toks = state.tokens.slice(brace.tokensIndex);
9732
+ brace.value = brace.output = '\\{';
9733
+ value = output = '\\}';
9734
+ state.output = out;
9735
+ for (const t of toks) {
9736
+ state.output += (t.output || t.value);
9737
+ }
9738
+ }
9739
+
9740
+ push({ type: 'brace', value, output });
9741
+ decrement('braces');
9742
+ braces.pop();
9743
+ continue;
9744
+ }
9745
+
9746
+ /**
9747
+ * Pipes
9748
+ */
9749
+
9750
+ if (value === '|') {
9751
+ if (extglobs.length > 0) {
9752
+ extglobs[extglobs.length - 1].conditions++;
9753
+ }
9754
+ push({ type: 'text', value });
9755
+ continue;
9756
+ }
9757
+
9758
+ /**
9759
+ * Commas
9760
+ */
9761
+
9762
+ if (value === ',') {
9763
+ let output = value;
9764
+
9765
+ const brace = braces[braces.length - 1];
9766
+ if (brace && stack[stack.length - 1] === 'braces') {
9767
+ brace.comma = true;
9768
+ output = '|';
9769
+ }
9770
+
9771
+ push({ type: 'comma', value, output });
9772
+ continue;
9773
+ }
9774
+
9775
+ /**
9776
+ * Slashes
9777
+ */
9778
+
9779
+ if (value === '/') {
9780
+ // if the beginning of the glob is "./", advance the start
9781
+ // to the current index, and don't add the "./" characters
9782
+ // to the state. This greatly simplifies lookbehinds when
9783
+ // checking for BOS characters like "!" and "." (not "./")
9784
+ if (prev.type === 'dot' && state.index === state.start + 1) {
9785
+ state.start = state.index + 1;
9786
+ state.consumed = '';
9787
+ state.output = '';
9788
+ tokens.pop();
9789
+ prev = bos; // reset "prev" to the first token
9790
+ continue;
9791
+ }
9792
+
9793
+ push({ type: 'slash', value, output: SLASH_LITERAL });
9794
+ continue;
9795
+ }
9796
+
9797
+ /**
9798
+ * Dots
9799
+ */
9800
+
9801
+ if (value === '.') {
9802
+ if (state.braces > 0 && prev.type === 'dot') {
9803
+ if (prev.value === '.') prev.output = DOT_LITERAL;
9804
+ const brace = braces[braces.length - 1];
9805
+ prev.type = 'dots';
9806
+ prev.output += value;
9807
+ prev.value += value;
9808
+ brace.dots = true;
9809
+ continue;
9810
+ }
9811
+
9812
+ if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
9813
+ push({ type: 'text', value, output: DOT_LITERAL });
9814
+ continue;
9815
+ }
9816
+
9817
+ push({ type: 'dot', value, output: DOT_LITERAL });
9818
+ continue;
9819
+ }
9820
+
9821
+ /**
9822
+ * Question marks
9823
+ */
9824
+
9825
+ if (value === '?') {
9826
+ const isGroup = prev && prev.value === '(';
9827
+ if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
9828
+ extglobOpen('qmark', value);
9829
+ continue;
9830
+ }
9831
+
9832
+ if (prev && prev.type === 'paren') {
9833
+ const next = peek();
9834
+ let output = value;
9835
+
9836
+ if (next === '<' && !utils.supportsLookbehinds()) {
9837
+ throw new Error('Node.js v10 or higher is required for regex lookbehinds');
9838
+ }
9839
+
9840
+ if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
9841
+ output = `\\${value}`;
9842
+ }
9843
+
9844
+ push({ type: 'text', value, output });
9845
+ continue;
9846
+ }
9847
+
9848
+ if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
9849
+ push({ type: 'qmark', value, output: QMARK_NO_DOT });
9850
+ continue;
9851
+ }
9852
+
9853
+ push({ type: 'qmark', value, output: QMARK });
9854
+ continue;
9855
+ }
9856
+
9857
+ /**
9858
+ * Exclamation
9859
+ */
9860
+
9861
+ if (value === '!') {
9862
+ if (opts.noextglob !== true && peek() === '(') {
9863
+ if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
9864
+ extglobOpen('negate', value);
9865
+ continue;
9866
+ }
9867
+ }
9868
+
9869
+ if (opts.nonegate !== true && state.index === 0) {
9870
+ negate();
9871
+ continue;
9872
+ }
9873
+ }
9874
+
9875
+ /**
9876
+ * Plus
9877
+ */
9878
+
9879
+ if (value === '+') {
9880
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
9881
+ extglobOpen('plus', value);
9882
+ continue;
9883
+ }
9884
+
9885
+ if ((prev && prev.value === '(') || opts.regex === false) {
9886
+ push({ type: 'plus', value, output: PLUS_LITERAL });
9887
+ continue;
9888
+ }
9889
+
9890
+ if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
9891
+ push({ type: 'plus', value });
9892
+ continue;
9893
+ }
9894
+
9895
+ push({ type: 'plus', value: PLUS_LITERAL });
9896
+ continue;
9897
+ }
9898
+
9899
+ /**
9900
+ * Plain text
9901
+ */
9902
+
9903
+ if (value === '@') {
9904
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
9905
+ push({ type: 'at', extglob: true, value, output: '' });
9906
+ continue;
9907
+ }
9908
+
9909
+ push({ type: 'text', value });
9910
+ continue;
9911
+ }
9912
+
9913
+ /**
9914
+ * Plain text
9915
+ */
9916
+
9917
+ if (value !== '*') {
9918
+ if (value === '$' || value === '^') {
9919
+ value = `\\${value}`;
9920
+ }
9921
+
9922
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
9923
+ if (match) {
9924
+ value += match[0];
9925
+ state.index += match[0].length;
9926
+ }
9927
+
9928
+ push({ type: 'text', value });
9929
+ continue;
9930
+ }
9931
+
9932
+ /**
9933
+ * Stars
9934
+ */
9935
+
9936
+ if (prev && (prev.type === 'globstar' || prev.star === true)) {
9937
+ prev.type = 'star';
9938
+ prev.star = true;
9939
+ prev.value += value;
9940
+ prev.output = star;
9941
+ state.backtrack = true;
9942
+ state.globstar = true;
9943
+ consume(value);
9944
+ continue;
9945
+ }
9946
+
9947
+ let rest = remaining();
9948
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
9949
+ extglobOpen('star', value);
9950
+ continue;
9951
+ }
9952
+
9953
+ if (prev.type === 'star') {
9954
+ if (opts.noglobstar === true) {
9955
+ consume(value);
9956
+ continue;
9957
+ }
9958
+
9959
+ const prior = prev.prev;
9960
+ const before = prior.prev;
9961
+ const isStart = prior.type === 'slash' || prior.type === 'bos';
9962
+ const afterStar = before && (before.type === 'star' || before.type === 'globstar');
9963
+
9964
+ if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
9965
+ push({ type: 'star', value, output: '' });
9966
+ continue;
9967
+ }
9968
+
9969
+ const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
9970
+ const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
9971
+ if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
9972
+ push({ type: 'star', value, output: '' });
9973
+ continue;
9974
+ }
9975
+
9976
+ // strip consecutive `/**/`
9977
+ while (rest.slice(0, 3) === '/**') {
9978
+ const after = input[state.index + 4];
9979
+ if (after && after !== '/') {
9980
+ break;
9981
+ }
9982
+ rest = rest.slice(3);
9983
+ consume('/**', 3);
9984
+ }
9985
+
9986
+ if (prior.type === 'bos' && eos()) {
9987
+ prev.type = 'globstar';
9988
+ prev.value += value;
9989
+ prev.output = globstar(opts);
9990
+ state.output = prev.output;
9991
+ state.globstar = true;
9992
+ consume(value);
9993
+ continue;
9994
+ }
9995
+
9996
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
9997
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
9998
+ prior.output = `(?:${prior.output}`;
9999
+
10000
+ prev.type = 'globstar';
10001
+ prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
10002
+ prev.value += value;
10003
+ state.globstar = true;
10004
+ state.output += prior.output + prev.output;
10005
+ consume(value);
10006
+ continue;
10007
+ }
10008
+
10009
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
10010
+ const end = rest[1] !== void 0 ? '|$' : '';
10011
+
10012
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
10013
+ prior.output = `(?:${prior.output}`;
10014
+
10015
+ prev.type = 'globstar';
10016
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
10017
+ prev.value += value;
10018
+
10019
+ state.output += prior.output + prev.output;
10020
+ state.globstar = true;
10021
+
10022
+ consume(value + advance());
10023
+
10024
+ push({ type: 'slash', value: '/', output: '' });
10025
+ continue;
10026
+ }
10027
+
10028
+ if (prior.type === 'bos' && rest[0] === '/') {
10029
+ prev.type = 'globstar';
10030
+ prev.value += value;
10031
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
10032
+ state.output = prev.output;
10033
+ state.globstar = true;
10034
+ consume(value + advance());
10035
+ push({ type: 'slash', value: '/', output: '' });
10036
+ continue;
10037
+ }
10038
+
10039
+ // remove single star from output
10040
+ state.output = state.output.slice(0, -prev.output.length);
10041
+
10042
+ // reset previous token to globstar
10043
+ prev.type = 'globstar';
10044
+ prev.output = globstar(opts);
10045
+ prev.value += value;
10046
+
10047
+ // reset output with globstar
10048
+ state.output += prev.output;
10049
+ state.globstar = true;
10050
+ consume(value);
10051
+ continue;
10052
+ }
10053
+
10054
+ const token = { type: 'star', value, output: star };
10055
+
10056
+ if (opts.bash === true) {
10057
+ token.output = '.*?';
10058
+ if (prev.type === 'bos' || prev.type === 'slash') {
10059
+ token.output = nodot + token.output;
10060
+ }
10061
+ push(token);
10062
+ continue;
10063
+ }
10064
+
10065
+ if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
10066
+ token.output = value;
10067
+ push(token);
10068
+ continue;
10069
+ }
10070
+
10071
+ if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
10072
+ if (prev.type === 'dot') {
10073
+ state.output += NO_DOT_SLASH;
10074
+ prev.output += NO_DOT_SLASH;
10075
+
10076
+ } else if (opts.dot === true) {
10077
+ state.output += NO_DOTS_SLASH;
10078
+ prev.output += NO_DOTS_SLASH;
10079
+
10080
+ } else {
10081
+ state.output += nodot;
10082
+ prev.output += nodot;
10083
+ }
10084
+
10085
+ if (peek() !== '*') {
10086
+ state.output += ONE_CHAR;
10087
+ prev.output += ONE_CHAR;
10088
+ }
10089
+ }
10090
+
10091
+ push(token);
10092
+ }
10146
10093
 
10147
- case '*.*':
10148
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
10094
+ while (state.brackets > 0) {
10095
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
10096
+ state.output = utils.escapeLast(state.output, '[');
10097
+ decrement('brackets');
10098
+ }
10149
10099
 
10150
- case '*/*':
10151
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
10100
+ while (state.parens > 0) {
10101
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
10102
+ state.output = utils.escapeLast(state.output, '(');
10103
+ decrement('parens');
10104
+ }
10152
10105
 
10153
- case '**':
10154
- return nodot + globstar(opts);
10106
+ while (state.braces > 0) {
10107
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
10108
+ state.output = utils.escapeLast(state.output, '{');
10109
+ decrement('braces');
10110
+ }
10155
10111
 
10156
- case '**/*':
10157
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
10112
+ if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
10113
+ push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
10114
+ }
10158
10115
 
10159
- case '**/*.*':
10160
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
10116
+ // rebuild the output if we had to backtrack at any point
10117
+ if (state.backtrack === true) {
10118
+ state.output = '';
10161
10119
 
10162
- case '**/.*':
10163
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
10120
+ for (const token of state.tokens) {
10121
+ state.output += token.output != null ? token.output : token.value;
10164
10122
 
10165
- default: {
10166
- const match = /^(.*?)\.(\w+)$/.exec(str);
10167
- if (!match) return;
10123
+ if (token.suffix) {
10124
+ state.output += token.suffix;
10125
+ }
10126
+ }
10127
+ }
10168
10128
 
10169
- const source = create(match[1]);
10170
- if (!source) return;
10129
+ return state;
10130
+ };
10171
10131
 
10172
- return source + DOT_LITERAL + match[2];
10173
- }
10174
- }
10175
- };
10132
+ /**
10133
+ * Fast paths for creating regular expressions for common glob patterns.
10134
+ * This can significantly speed up processing and has very little downside
10135
+ * impact when none of the fast paths match.
10136
+ */
10137
+
10138
+ parse.fastpaths = (input, options) => {
10139
+ const opts = { ...options };
10140
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
10141
+ const len = input.length;
10142
+ if (len > max) {
10143
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
10144
+ }
10176
10145
 
10177
- const output = utils$1.removePrefix(input, state);
10178
- let source = create(output);
10146
+ input = REPLACEMENTS[input] || input;
10147
+ const win32 = utils.isWindows(options);
10148
+
10149
+ // create constants based on platform, for windows or posix
10150
+ const {
10151
+ DOT_LITERAL,
10152
+ SLASH_LITERAL,
10153
+ ONE_CHAR,
10154
+ DOTS_SLASH,
10155
+ NO_DOT,
10156
+ NO_DOTS,
10157
+ NO_DOTS_SLASH,
10158
+ STAR,
10159
+ START_ANCHOR
10160
+ } = constants.globChars(win32);
10161
+
10162
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
10163
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
10164
+ const capture = opts.capture ? '' : '?:';
10165
+ const state = { negated: false, prefix: '' };
10166
+ let star = opts.bash === true ? '.*?' : STAR;
10167
+
10168
+ if (opts.capture) {
10169
+ star = `(${star})`;
10170
+ }
10179
10171
 
10180
- if (source && opts.strictSlashes !== true) {
10181
- source += `${SLASH_LITERAL}?`;
10182
- }
10172
+ const globstar = opts => {
10173
+ if (opts.noglobstar === true) return star;
10174
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
10175
+ };
10183
10176
 
10184
- return source;
10185
- };
10177
+ const create = str => {
10178
+ switch (str) {
10179
+ case '*':
10180
+ return `${nodot}${ONE_CHAR}${star}`;
10186
10181
 
10187
- var parse_1 = parse$1;
10182
+ case '.*':
10183
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
10188
10184
 
10189
- const path = require$$0;
10190
- const scan = scan_1;
10191
- const parse = parse_1;
10192
- const utils = utils$3;
10193
- const constants = constants$2;
10194
- const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
10185
+ case '*.*':
10186
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
10195
10187
 
10196
- /**
10197
- * Creates a matcher function from one or more glob patterns. The
10198
- * returned function takes a string to match as its first argument,
10199
- * and returns true if the string is a match. The returned matcher
10200
- * function also takes a boolean as the second argument that, when true,
10201
- * returns an object with additional information.
10202
- *
10203
- * ```js
10204
- * const picomatch = require('picomatch');
10205
- * // picomatch(glob[, options]);
10206
- *
10207
- * const isMatch = picomatch('*.!(*a)');
10208
- * console.log(isMatch('a.a')); //=> false
10209
- * console.log(isMatch('a.b')); //=> true
10210
- * ```
10211
- * @name picomatch
10212
- * @param {String|Array} `globs` One or more glob patterns.
10213
- * @param {Object=} `options`
10214
- * @return {Function=} Returns a matcher function.
10215
- * @api public
10216
- */
10188
+ case '*/*':
10189
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
10217
10190
 
10218
- const picomatch$1 = (glob, options, returnState = false) => {
10219
- if (Array.isArray(glob)) {
10220
- const fns = glob.map(input => picomatch$1(input, options, returnState));
10221
- const arrayMatcher = str => {
10222
- for (const isMatch of fns) {
10223
- const state = isMatch(str);
10224
- if (state) return state;
10225
- }
10226
- return false;
10227
- };
10228
- return arrayMatcher;
10229
- }
10191
+ case '**':
10192
+ return nodot + globstar(opts);
10230
10193
 
10231
- const isState = isObject(glob) && glob.tokens && glob.input;
10194
+ case '**/*':
10195
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
10232
10196
 
10233
- if (glob === '' || (typeof glob !== 'string' && !isState)) {
10234
- throw new TypeError('Expected pattern to be a non-empty string');
10235
- }
10197
+ case '**/*.*':
10198
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
10236
10199
 
10237
- const opts = options || {};
10238
- const posix = utils.isWindows(options);
10239
- const regex = isState
10240
- ? picomatch$1.compileRe(glob, options)
10241
- : picomatch$1.makeRe(glob, options, false, true);
10200
+ case '**/.*':
10201
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
10242
10202
 
10243
- const state = regex.state;
10244
- delete regex.state;
10203
+ default: {
10204
+ const match = /^(.*?)\.(\w+)$/.exec(str);
10205
+ if (!match) return;
10245
10206
 
10246
- let isIgnored = () => false;
10247
- if (opts.ignore) {
10248
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
10249
- isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
10250
- }
10207
+ const source = create(match[1]);
10208
+ if (!source) return;
10251
10209
 
10252
- const matcher = (input, returnObject = false) => {
10253
- const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
10254
- const result = { glob, state, regex, posix, input, output, match, isMatch };
10210
+ return source + DOT_LITERAL + match[2];
10211
+ }
10212
+ }
10213
+ };
10255
10214
 
10256
- if (typeof opts.onResult === 'function') {
10257
- opts.onResult(result);
10258
- }
10215
+ const output = utils.removePrefix(input, state);
10216
+ let source = create(output);
10259
10217
 
10260
- if (isMatch === false) {
10261
- result.isMatch = false;
10262
- return returnObject ? result : false;
10263
- }
10218
+ if (source && opts.strictSlashes !== true) {
10219
+ source += `${SLASH_LITERAL}?`;
10220
+ }
10264
10221
 
10265
- if (isIgnored(input)) {
10266
- if (typeof opts.onIgnore === 'function') {
10267
- opts.onIgnore(result);
10268
- }
10269
- result.isMatch = false;
10270
- return returnObject ? result : false;
10271
- }
10222
+ return source;
10223
+ };
10272
10224
 
10273
- if (typeof opts.onMatch === 'function') {
10274
- opts.onMatch(result);
10275
- }
10276
- return returnObject ? result : true;
10277
- };
10225
+ parse_1 = parse;
10226
+ return parse_1;
10227
+ }
10278
10228
 
10279
- if (returnState) {
10280
- matcher.state = state;
10281
- }
10229
+ var picomatch_1;
10230
+ var hasRequiredPicomatch$1;
10282
10231
 
10283
- return matcher;
10284
- };
10232
+ function requirePicomatch$1 () {
10233
+ if (hasRequiredPicomatch$1) return picomatch_1;
10234
+ hasRequiredPicomatch$1 = 1;
10285
10235
 
10286
- /**
10287
- * Test `input` with the given `regex`. This is used by the main
10288
- * `picomatch()` function to test the input string.
10289
- *
10290
- * ```js
10291
- * const picomatch = require('picomatch');
10292
- * // picomatch.test(input, regex[, options]);
10293
- *
10294
- * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
10295
- * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
10296
- * ```
10297
- * @param {String} `input` String to test.
10298
- * @param {RegExp} `regex`
10299
- * @return {Object} Returns an object with matching info.
10300
- * @api public
10301
- */
10236
+ const path = require$$0;
10237
+ const scan = /*@__PURE__*/ requireScan();
10238
+ const parse = /*@__PURE__*/ requireParse();
10239
+ const utils = /*@__PURE__*/ requireUtils();
10240
+ const constants = /*@__PURE__*/ requireConstants();
10241
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
10242
+
10243
+ /**
10244
+ * Creates a matcher function from one or more glob patterns. The
10245
+ * returned function takes a string to match as its first argument,
10246
+ * and returns true if the string is a match. The returned matcher
10247
+ * function also takes a boolean as the second argument that, when true,
10248
+ * returns an object with additional information.
10249
+ *
10250
+ * ```js
10251
+ * const picomatch = require('picomatch');
10252
+ * // picomatch(glob[, options]);
10253
+ *
10254
+ * const isMatch = picomatch('*.!(*a)');
10255
+ * console.log(isMatch('a.a')); //=> false
10256
+ * console.log(isMatch('a.b')); //=> true
10257
+ * ```
10258
+ * @name picomatch
10259
+ * @param {String|Array} `globs` One or more glob patterns.
10260
+ * @param {Object=} `options`
10261
+ * @return {Function=} Returns a matcher function.
10262
+ * @api public
10263
+ */
10264
+
10265
+ const picomatch = (glob, options, returnState = false) => {
10266
+ if (Array.isArray(glob)) {
10267
+ const fns = glob.map(input => picomatch(input, options, returnState));
10268
+ const arrayMatcher = str => {
10269
+ for (const isMatch of fns) {
10270
+ const state = isMatch(str);
10271
+ if (state) return state;
10272
+ }
10273
+ return false;
10274
+ };
10275
+ return arrayMatcher;
10276
+ }
10302
10277
 
10303
- picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
10304
- if (typeof input !== 'string') {
10305
- throw new TypeError('Expected input to be a string');
10306
- }
10278
+ const isState = isObject(glob) && glob.tokens && glob.input;
10307
10279
 
10308
- if (input === '') {
10309
- return { isMatch: false, output: '' };
10310
- }
10280
+ if (glob === '' || (typeof glob !== 'string' && !isState)) {
10281
+ throw new TypeError('Expected pattern to be a non-empty string');
10282
+ }
10311
10283
 
10312
- const opts = options || {};
10313
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
10314
- let match = input === glob;
10315
- let output = (match && format) ? format(input) : input;
10284
+ const opts = options || {};
10285
+ const posix = utils.isWindows(options);
10286
+ const regex = isState
10287
+ ? picomatch.compileRe(glob, options)
10288
+ : picomatch.makeRe(glob, options, false, true);
10316
10289
 
10317
- if (match === false) {
10318
- output = format ? format(input) : input;
10319
- match = output === glob;
10320
- }
10290
+ const state = regex.state;
10291
+ delete regex.state;
10321
10292
 
10322
- if (match === false || opts.capture === true) {
10323
- if (opts.matchBase === true || opts.basename === true) {
10324
- match = picomatch$1.matchBase(input, regex, options, posix);
10325
- } else {
10326
- match = regex.exec(output);
10327
- }
10328
- }
10293
+ let isIgnored = () => false;
10294
+ if (opts.ignore) {
10295
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
10296
+ isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
10297
+ }
10329
10298
 
10330
- return { isMatch: Boolean(match), match, output };
10331
- };
10299
+ const matcher = (input, returnObject = false) => {
10300
+ const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
10301
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
10302
+
10303
+ if (typeof opts.onResult === 'function') {
10304
+ opts.onResult(result);
10305
+ }
10306
+
10307
+ if (isMatch === false) {
10308
+ result.isMatch = false;
10309
+ return returnObject ? result : false;
10310
+ }
10311
+
10312
+ if (isIgnored(input)) {
10313
+ if (typeof opts.onIgnore === 'function') {
10314
+ opts.onIgnore(result);
10315
+ }
10316
+ result.isMatch = false;
10317
+ return returnObject ? result : false;
10318
+ }
10319
+
10320
+ if (typeof opts.onMatch === 'function') {
10321
+ opts.onMatch(result);
10322
+ }
10323
+ return returnObject ? result : true;
10324
+ };
10325
+
10326
+ if (returnState) {
10327
+ matcher.state = state;
10328
+ }
10332
10329
 
10333
- /**
10334
- * Match the basename of a filepath.
10335
- *
10336
- * ```js
10337
- * const picomatch = require('picomatch');
10338
- * // picomatch.matchBase(input, glob[, options]);
10339
- * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
10340
- * ```
10341
- * @param {String} `input` String to test.
10342
- * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
10343
- * @return {Boolean}
10344
- * @api public
10345
- */
10330
+ return matcher;
10331
+ };
10346
10332
 
10347
- picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
10348
- const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
10349
- return regex.test(path.basename(input));
10350
- };
10333
+ /**
10334
+ * Test `input` with the given `regex`. This is used by the main
10335
+ * `picomatch()` function to test the input string.
10336
+ *
10337
+ * ```js
10338
+ * const picomatch = require('picomatch');
10339
+ * // picomatch.test(input, regex[, options]);
10340
+ *
10341
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
10342
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
10343
+ * ```
10344
+ * @param {String} `input` String to test.
10345
+ * @param {RegExp} `regex`
10346
+ * @return {Object} Returns an object with matching info.
10347
+ * @api public
10348
+ */
10349
+
10350
+ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
10351
+ if (typeof input !== 'string') {
10352
+ throw new TypeError('Expected input to be a string');
10353
+ }
10351
10354
 
10352
- /**
10353
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
10354
- *
10355
- * ```js
10356
- * const picomatch = require('picomatch');
10357
- * // picomatch.isMatch(string, patterns[, options]);
10358
- *
10359
- * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
10360
- * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
10361
- * ```
10362
- * @param {String|Array} str The string to test.
10363
- * @param {String|Array} patterns One or more glob patterns to use for matching.
10364
- * @param {Object} [options] See available [options](#options).
10365
- * @return {Boolean} Returns true if any patterns match `str`
10366
- * @api public
10367
- */
10355
+ if (input === '') {
10356
+ return { isMatch: false, output: '' };
10357
+ }
10368
10358
 
10369
- picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
10359
+ const opts = options || {};
10360
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
10361
+ let match = input === glob;
10362
+ let output = (match && format) ? format(input) : input;
10370
10363
 
10371
- /**
10372
- * Parse a glob pattern to create the source string for a regular
10373
- * expression.
10374
- *
10375
- * ```js
10376
- * const picomatch = require('picomatch');
10377
- * const result = picomatch.parse(pattern[, options]);
10378
- * ```
10379
- * @param {String} `pattern`
10380
- * @param {Object} `options`
10381
- * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
10382
- * @api public
10383
- */
10364
+ if (match === false) {
10365
+ output = format ? format(input) : input;
10366
+ match = output === glob;
10367
+ }
10384
10368
 
10385
- picomatch$1.parse = (pattern, options) => {
10386
- if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
10387
- return parse(pattern, { ...options, fastpaths: false });
10388
- };
10369
+ if (match === false || opts.capture === true) {
10370
+ if (opts.matchBase === true || opts.basename === true) {
10371
+ match = picomatch.matchBase(input, regex, options, posix);
10372
+ } else {
10373
+ match = regex.exec(output);
10374
+ }
10375
+ }
10389
10376
 
10390
- /**
10391
- * Scan a glob pattern to separate the pattern into segments.
10392
- *
10393
- * ```js
10394
- * const picomatch = require('picomatch');
10395
- * // picomatch.scan(input[, options]);
10396
- *
10397
- * const result = picomatch.scan('!./foo/*.js');
10398
- * console.log(result);
10399
- * { prefix: '!./',
10400
- * input: '!./foo/*.js',
10401
- * start: 3,
10402
- * base: 'foo',
10403
- * glob: '*.js',
10404
- * isBrace: false,
10405
- * isBracket: false,
10406
- * isGlob: true,
10407
- * isExtglob: false,
10408
- * isGlobstar: false,
10409
- * negated: true }
10410
- * ```
10411
- * @param {String} `input` Glob pattern to scan.
10412
- * @param {Object} `options`
10413
- * @return {Object} Returns an object with
10414
- * @api public
10415
- */
10377
+ return { isMatch: Boolean(match), match, output };
10378
+ };
10416
10379
 
10417
- picomatch$1.scan = (input, options) => scan(input, options);
10380
+ /**
10381
+ * Match the basename of a filepath.
10382
+ *
10383
+ * ```js
10384
+ * const picomatch = require('picomatch');
10385
+ * // picomatch.matchBase(input, glob[, options]);
10386
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
10387
+ * ```
10388
+ * @param {String} `input` String to test.
10389
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
10390
+ * @return {Boolean}
10391
+ * @api public
10392
+ */
10393
+
10394
+ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
10395
+ const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
10396
+ return regex.test(path.basename(input));
10397
+ };
10418
10398
 
10419
- /**
10420
- * Compile a regular expression from the `state` object returned by the
10421
- * [parse()](#parse) method.
10422
- *
10423
- * @param {Object} `state`
10424
- * @param {Object} `options`
10425
- * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
10426
- * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
10427
- * @return {RegExp}
10428
- * @api public
10429
- */
10399
+ /**
10400
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
10401
+ *
10402
+ * ```js
10403
+ * const picomatch = require('picomatch');
10404
+ * // picomatch.isMatch(string, patterns[, options]);
10405
+ *
10406
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
10407
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
10408
+ * ```
10409
+ * @param {String|Array} str The string to test.
10410
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
10411
+ * @param {Object} [options] See available [options](#options).
10412
+ * @return {Boolean} Returns true if any patterns match `str`
10413
+ * @api public
10414
+ */
10415
+
10416
+ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
10417
+
10418
+ /**
10419
+ * Parse a glob pattern to create the source string for a regular
10420
+ * expression.
10421
+ *
10422
+ * ```js
10423
+ * const picomatch = require('picomatch');
10424
+ * const result = picomatch.parse(pattern[, options]);
10425
+ * ```
10426
+ * @param {String} `pattern`
10427
+ * @param {Object} `options`
10428
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
10429
+ * @api public
10430
+ */
10431
+
10432
+ picomatch.parse = (pattern, options) => {
10433
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
10434
+ return parse(pattern, { ...options, fastpaths: false });
10435
+ };
10430
10436
 
10431
- picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
10432
- if (returnOutput === true) {
10433
- return state.output;
10434
- }
10437
+ /**
10438
+ * Scan a glob pattern to separate the pattern into segments.
10439
+ *
10440
+ * ```js
10441
+ * const picomatch = require('picomatch');
10442
+ * // picomatch.scan(input[, options]);
10443
+ *
10444
+ * const result = picomatch.scan('!./foo/*.js');
10445
+ * console.log(result);
10446
+ * { prefix: '!./',
10447
+ * input: '!./foo/*.js',
10448
+ * start: 3,
10449
+ * base: 'foo',
10450
+ * glob: '*.js',
10451
+ * isBrace: false,
10452
+ * isBracket: false,
10453
+ * isGlob: true,
10454
+ * isExtglob: false,
10455
+ * isGlobstar: false,
10456
+ * negated: true }
10457
+ * ```
10458
+ * @param {String} `input` Glob pattern to scan.
10459
+ * @param {Object} `options`
10460
+ * @return {Object} Returns an object with
10461
+ * @api public
10462
+ */
10463
+
10464
+ picomatch.scan = (input, options) => scan(input, options);
10465
+
10466
+ /**
10467
+ * Compile a regular expression from the `state` object returned by the
10468
+ * [parse()](#parse) method.
10469
+ *
10470
+ * @param {Object} `state`
10471
+ * @param {Object} `options`
10472
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
10473
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
10474
+ * @return {RegExp}
10475
+ * @api public
10476
+ */
10477
+
10478
+ picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
10479
+ if (returnOutput === true) {
10480
+ return state.output;
10481
+ }
10435
10482
 
10436
- const opts = options || {};
10437
- const prepend = opts.contains ? '' : '^';
10438
- const append = opts.contains ? '' : '$';
10483
+ const opts = options || {};
10484
+ const prepend = opts.contains ? '' : '^';
10485
+ const append = opts.contains ? '' : '$';
10439
10486
 
10440
- let source = `${prepend}(?:${state.output})${append}`;
10441
- if (state && state.negated === true) {
10442
- source = `^(?!${source}).*$`;
10443
- }
10487
+ let source = `${prepend}(?:${state.output})${append}`;
10488
+ if (state && state.negated === true) {
10489
+ source = `^(?!${source}).*$`;
10490
+ }
10444
10491
 
10445
- const regex = picomatch$1.toRegex(source, options);
10446
- if (returnState === true) {
10447
- regex.state = state;
10448
- }
10492
+ const regex = picomatch.toRegex(source, options);
10493
+ if (returnState === true) {
10494
+ regex.state = state;
10495
+ }
10449
10496
 
10450
- return regex;
10451
- };
10497
+ return regex;
10498
+ };
10452
10499
 
10453
- /**
10454
- * Create a regular expression from a parsed glob pattern.
10455
- *
10456
- * ```js
10457
- * const picomatch = require('picomatch');
10458
- * const state = picomatch.parse('*.js');
10459
- * // picomatch.compileRe(state[, options]);
10460
- *
10461
- * console.log(picomatch.compileRe(state));
10462
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
10463
- * ```
10464
- * @param {String} `state` The object returned from the `.parse` method.
10465
- * @param {Object} `options`
10466
- * @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.
10467
- * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
10468
- * @return {RegExp} Returns a regex created from the given pattern.
10469
- * @api public
10470
- */
10500
+ /**
10501
+ * Create a regular expression from a parsed glob pattern.
10502
+ *
10503
+ * ```js
10504
+ * const picomatch = require('picomatch');
10505
+ * const state = picomatch.parse('*.js');
10506
+ * // picomatch.compileRe(state[, options]);
10507
+ *
10508
+ * console.log(picomatch.compileRe(state));
10509
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
10510
+ * ```
10511
+ * @param {String} `state` The object returned from the `.parse` method.
10512
+ * @param {Object} `options`
10513
+ * @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.
10514
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
10515
+ * @return {RegExp} Returns a regex created from the given pattern.
10516
+ * @api public
10517
+ */
10518
+
10519
+ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
10520
+ if (!input || typeof input !== 'string') {
10521
+ throw new TypeError('Expected a non-empty string');
10522
+ }
10471
10523
 
10472
- picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
10473
- if (!input || typeof input !== 'string') {
10474
- throw new TypeError('Expected a non-empty string');
10475
- }
10524
+ let parsed = { negated: false, fastpaths: true };
10476
10525
 
10477
- let parsed = { negated: false, fastpaths: true };
10526
+ if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
10527
+ parsed.output = parse.fastpaths(input, options);
10528
+ }
10478
10529
 
10479
- if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
10480
- parsed.output = parse.fastpaths(input, options);
10481
- }
10530
+ if (!parsed.output) {
10531
+ parsed = parse(input, options);
10532
+ }
10482
10533
 
10483
- if (!parsed.output) {
10484
- parsed = parse(input, options);
10485
- }
10534
+ return picomatch.compileRe(parsed, options, returnOutput, returnState);
10535
+ };
10486
10536
 
10487
- return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
10488
- };
10537
+ /**
10538
+ * Create a regular expression from the given regex source string.
10539
+ *
10540
+ * ```js
10541
+ * const picomatch = require('picomatch');
10542
+ * // picomatch.toRegex(source[, options]);
10543
+ *
10544
+ * const { output } = picomatch.parse('*.js');
10545
+ * console.log(picomatch.toRegex(output));
10546
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
10547
+ * ```
10548
+ * @param {String} `source` Regular expression source string.
10549
+ * @param {Object} `options`
10550
+ * @return {RegExp}
10551
+ * @api public
10552
+ */
10553
+
10554
+ picomatch.toRegex = (source, options) => {
10555
+ try {
10556
+ const opts = options || {};
10557
+ return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
10558
+ } catch (err) {
10559
+ if (options && options.debug === true) throw err;
10560
+ return /$^/;
10561
+ }
10562
+ };
10489
10563
 
10490
- /**
10491
- * Create a regular expression from the given regex source string.
10492
- *
10493
- * ```js
10494
- * const picomatch = require('picomatch');
10495
- * // picomatch.toRegex(source[, options]);
10496
- *
10497
- * const { output } = picomatch.parse('*.js');
10498
- * console.log(picomatch.toRegex(output));
10499
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
10500
- * ```
10501
- * @param {String} `source` Regular expression source string.
10502
- * @param {Object} `options`
10503
- * @return {RegExp}
10504
- * @api public
10505
- */
10564
+ /**
10565
+ * Picomatch constants.
10566
+ * @return {Object}
10567
+ */
10506
10568
 
10507
- picomatch$1.toRegex = (source, options) => {
10508
- try {
10509
- const opts = options || {};
10510
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
10511
- } catch (err) {
10512
- if (options && options.debug === true) throw err;
10513
- return /$^/;
10514
- }
10515
- };
10569
+ picomatch.constants = constants;
10516
10570
 
10517
- /**
10518
- * Picomatch constants.
10519
- * @return {Object}
10520
- */
10571
+ /**
10572
+ * Expose "picomatch"
10573
+ */
10521
10574
 
10522
- picomatch$1.constants = constants;
10575
+ picomatch_1 = picomatch;
10576
+ return picomatch_1;
10577
+ }
10523
10578
 
10524
- /**
10525
- * Expose "picomatch"
10526
- */
10579
+ var picomatch;
10580
+ var hasRequiredPicomatch;
10527
10581
 
10528
- var picomatch_1 = picomatch$1;
10582
+ function requirePicomatch () {
10583
+ if (hasRequiredPicomatch) return picomatch;
10584
+ hasRequiredPicomatch = 1;
10529
10585
 
10530
- var picomatch = picomatch_1;
10586
+ picomatch = /*@__PURE__*/ requirePicomatch$1();
10587
+ return picomatch;
10588
+ }
10531
10589
 
10532
- const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
10590
+ var picomatchExports = /*@__PURE__*/ requirePicomatch();
10591
+ const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
10533
10592
 
10534
10593
  const extractors = {
10535
10594
  ArrayPattern(names, param) {
@@ -10578,8 +10637,9 @@ function ensureArray$1(thing) {
10578
10637
  return [thing];
10579
10638
  }
10580
10639
 
10640
+ const normalizePathRegExp = new RegExp(`\\${win32.sep}`, 'g');
10581
10641
  const normalizePath = function normalizePath(filename) {
10582
- return filename.split(win32.sep).join(posix.sep);
10642
+ return filename.replace(normalizePathRegExp, posix.sep);
10583
10643
  };
10584
10644
 
10585
10645
  function getMatcherString(id, resolutionBase) {
@@ -10611,10 +10671,12 @@ const createFilter = function createFilter(include, exclude, options) {
10611
10671
  };
10612
10672
  const includeMatchers = ensureArray$1(include).map(getMatcher);
10613
10673
  const excludeMatchers = ensureArray$1(exclude).map(getMatcher);
10674
+ if (!includeMatchers.length && !excludeMatchers.length)
10675
+ return (id) => typeof id === 'string' && !id.includes('\0');
10614
10676
  return function result(id) {
10615
10677
  if (typeof id !== 'string')
10616
10678
  return false;
10617
- if (/\0/.test(id))
10679
+ if (id.includes('\0'))
10618
10680
  return false;
10619
10681
  const pathId = normalizePath(id);
10620
10682
  for (let i = 0; i < excludeMatchers.length; ++i) {
@@ -21341,4 +21403,4 @@ async function watchInternal(configs, emitter) {
21341
21403
  new Watcher(watchOptionsList, emitter);
21342
21404
  }
21343
21405
 
21344
- export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, picomatch, rollup, rollupInternal, version, watch };
21406
+ export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, version, watch };