rollup 4.22.4 → 4.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +2091 -1974
- package/dist/es/shared/parseAst.js +5 -4
- package/dist/es/shared/watch.js +8304 -3891
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +4 -0
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +8532 -4119
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +5 -3
- package/dist/shared/rollup.js +2121 -2004
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +2 -2
- package/package.json +39 -39
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.23.0
|
|
4
|
+
Tue, 01 Oct 2024 07:09:35 GMT - commit ed98e0821e6ad064839f0af46ceca061adbe3f14
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
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,
|
|
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, warnDeprecation, URL_GENERATEBUNDLE, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, logInvalidExportOptionValue, 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, {
|
|
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.
|
|
19
|
+
var version = "4.23.0";
|
|
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
|
|
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
|
|
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
|
|
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
|
);
|
|
@@ -8473,2069 +8473,2122 @@ function getAugmentedNamespace(n) {
|
|
|
8473
8473
|
return a;
|
|
8474
8474
|
}
|
|
8475
8475
|
|
|
8476
|
-
var utils
|
|
8476
|
+
var utils = {};
|
|
8477
8477
|
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
8478
|
+
var constants;
|
|
8479
|
+
var hasRequiredConstants;
|
|
8481
8480
|
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
const DOT_LITERAL = '\\.';
|
|
8487
|
-
const PLUS_LITERAL = '\\+';
|
|
8488
|
-
const QMARK_LITERAL = '\\?';
|
|
8489
|
-
const SLASH_LITERAL = '\\/';
|
|
8490
|
-
const ONE_CHAR = '(?=.)';
|
|
8491
|
-
const QMARK = '[^/]';
|
|
8492
|
-
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
8493
|
-
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
8494
|
-
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
8495
|
-
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
8496
|
-
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
8497
|
-
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
8498
|
-
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
8499
|
-
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
8500
|
-
const STAR = `${QMARK}*?`;
|
|
8501
|
-
|
|
8502
|
-
const POSIX_CHARS = {
|
|
8503
|
-
DOT_LITERAL,
|
|
8504
|
-
PLUS_LITERAL,
|
|
8505
|
-
QMARK_LITERAL,
|
|
8506
|
-
SLASH_LITERAL,
|
|
8507
|
-
ONE_CHAR,
|
|
8508
|
-
QMARK,
|
|
8509
|
-
END_ANCHOR,
|
|
8510
|
-
DOTS_SLASH,
|
|
8511
|
-
NO_DOT,
|
|
8512
|
-
NO_DOTS,
|
|
8513
|
-
NO_DOT_SLASH,
|
|
8514
|
-
NO_DOTS_SLASH,
|
|
8515
|
-
QMARK_NO_DOT,
|
|
8516
|
-
STAR,
|
|
8517
|
-
START_ANCHOR
|
|
8518
|
-
};
|
|
8519
|
-
|
|
8520
|
-
/**
|
|
8521
|
-
* Windows glob regex
|
|
8522
|
-
*/
|
|
8523
|
-
|
|
8524
|
-
const WINDOWS_CHARS = {
|
|
8525
|
-
...POSIX_CHARS,
|
|
8526
|
-
|
|
8527
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
8528
|
-
QMARK: WIN_NO_SLASH,
|
|
8529
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
8530
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
8531
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
8532
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
8533
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
8534
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
8535
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
8536
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
8537
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
8538
|
-
};
|
|
8539
|
-
|
|
8540
|
-
/**
|
|
8541
|
-
* POSIX Bracket Regex
|
|
8542
|
-
*/
|
|
8543
|
-
|
|
8544
|
-
const POSIX_REGEX_SOURCE$1 = {
|
|
8545
|
-
alnum: 'a-zA-Z0-9',
|
|
8546
|
-
alpha: 'a-zA-Z',
|
|
8547
|
-
ascii: '\\x00-\\x7F',
|
|
8548
|
-
blank: ' \\t',
|
|
8549
|
-
cntrl: '\\x00-\\x1F\\x7F',
|
|
8550
|
-
digit: '0-9',
|
|
8551
|
-
graph: '\\x21-\\x7E',
|
|
8552
|
-
lower: 'a-z',
|
|
8553
|
-
print: '\\x20-\\x7E ',
|
|
8554
|
-
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
8555
|
-
space: ' \\t\\r\\n\\v\\f',
|
|
8556
|
-
upper: 'A-Z',
|
|
8557
|
-
word: 'A-Za-z0-9_',
|
|
8558
|
-
xdigit: 'A-Fa-f0-9'
|
|
8559
|
-
};
|
|
8560
|
-
|
|
8561
|
-
var constants$2 = {
|
|
8562
|
-
MAX_LENGTH: 1024 * 64,
|
|
8563
|
-
POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
|
|
8564
|
-
|
|
8565
|
-
// regular expressions
|
|
8566
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
8567
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
8568
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
8569
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
8570
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
8571
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
8572
|
-
|
|
8573
|
-
// Replace globs with equivalent patterns to reduce parsing time.
|
|
8574
|
-
REPLACEMENTS: {
|
|
8575
|
-
'***': '*',
|
|
8576
|
-
'**/**': '**',
|
|
8577
|
-
'**/**/**': '**'
|
|
8578
|
-
},
|
|
8579
|
-
|
|
8580
|
-
// Digits
|
|
8581
|
-
CHAR_0: 48, /* 0 */
|
|
8582
|
-
CHAR_9: 57, /* 9 */
|
|
8583
|
-
|
|
8584
|
-
// Alphabet chars.
|
|
8585
|
-
CHAR_UPPERCASE_A: 65, /* A */
|
|
8586
|
-
CHAR_LOWERCASE_A: 97, /* a */
|
|
8587
|
-
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
8588
|
-
CHAR_LOWERCASE_Z: 122, /* z */
|
|
8589
|
-
|
|
8590
|
-
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
8591
|
-
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
8592
|
-
|
|
8593
|
-
CHAR_ASTERISK: 42, /* * */
|
|
8594
|
-
|
|
8595
|
-
// Non-alphabetic chars.
|
|
8596
|
-
CHAR_AMPERSAND: 38, /* & */
|
|
8597
|
-
CHAR_AT: 64, /* @ */
|
|
8598
|
-
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
8599
|
-
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
8600
|
-
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
8601
|
-
CHAR_COLON: 58, /* : */
|
|
8602
|
-
CHAR_COMMA: 44, /* , */
|
|
8603
|
-
CHAR_DOT: 46, /* . */
|
|
8604
|
-
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
8605
|
-
CHAR_EQUAL: 61, /* = */
|
|
8606
|
-
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
8607
|
-
CHAR_FORM_FEED: 12, /* \f */
|
|
8608
|
-
CHAR_FORWARD_SLASH: 47, /* / */
|
|
8609
|
-
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
8610
|
-
CHAR_HASH: 35, /* # */
|
|
8611
|
-
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
8612
|
-
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
8613
|
-
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
8614
|
-
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
8615
|
-
CHAR_LINE_FEED: 10, /* \n */
|
|
8616
|
-
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
8617
|
-
CHAR_PERCENT: 37, /* % */
|
|
8618
|
-
CHAR_PLUS: 43, /* + */
|
|
8619
|
-
CHAR_QUESTION_MARK: 63, /* ? */
|
|
8620
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
8621
|
-
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
8622
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
8623
|
-
CHAR_SEMICOLON: 59, /* ; */
|
|
8624
|
-
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
8625
|
-
CHAR_SPACE: 32, /* */
|
|
8626
|
-
CHAR_TAB: 9, /* \t */
|
|
8627
|
-
CHAR_UNDERSCORE: 95, /* _ */
|
|
8628
|
-
CHAR_VERTICAL_LINE: 124, /* | */
|
|
8629
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
8630
|
-
|
|
8631
|
-
SEP: path$1.sep,
|
|
8632
|
-
|
|
8633
|
-
/**
|
|
8634
|
-
* Create EXTGLOB_CHARS
|
|
8635
|
-
*/
|
|
8636
|
-
|
|
8637
|
-
extglobChars(chars) {
|
|
8638
|
-
return {
|
|
8639
|
-
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
8640
|
-
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
8641
|
-
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
8642
|
-
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
8643
|
-
'@': { type: 'at', open: '(?:', close: ')' }
|
|
8644
|
-
};
|
|
8645
|
-
},
|
|
8646
|
-
|
|
8647
|
-
/**
|
|
8648
|
-
* Create GLOB_CHARS
|
|
8649
|
-
*/
|
|
8650
|
-
|
|
8651
|
-
globChars(win32) {
|
|
8652
|
-
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
8653
|
-
}
|
|
8654
|
-
};
|
|
8655
|
-
|
|
8656
|
-
(function (exports) {
|
|
8481
|
+
function requireConstants () {
|
|
8482
|
+
if (hasRequiredConstants) return constants;
|
|
8483
|
+
hasRequiredConstants = 1;
|
|
8657
8484
|
|
|
8658
8485
|
const path = require$$0;
|
|
8659
|
-
const
|
|
8660
|
-
const {
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
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
|
|
8677
8525
|
};
|
|
8678
8526
|
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
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}]|$)`
|
|
8685
8545
|
};
|
|
8686
8546
|
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
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'
|
|
8692
8566
|
};
|
|
8693
8567
|
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
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;
|
|
8706
8660
|
}
|
|
8707
|
-
return output;
|
|
8708
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
|
+
};
|
|
8709
8692
|
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
}
|
|
8718
|
-
return output;
|
|
8719
|
-
};
|
|
8720
|
-
} (utils$3));
|
|
8721
|
-
|
|
8722
|
-
const utils$2 = utils$3;
|
|
8723
|
-
const {
|
|
8724
|
-
CHAR_ASTERISK, /* * */
|
|
8725
|
-
CHAR_AT, /* @ */
|
|
8726
|
-
CHAR_BACKWARD_SLASH, /* \ */
|
|
8727
|
-
CHAR_COMMA, /* , */
|
|
8728
|
-
CHAR_DOT, /* . */
|
|
8729
|
-
CHAR_EXCLAMATION_MARK, /* ! */
|
|
8730
|
-
CHAR_FORWARD_SLASH, /* / */
|
|
8731
|
-
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
8732
|
-
CHAR_LEFT_PARENTHESES, /* ( */
|
|
8733
|
-
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
8734
|
-
CHAR_PLUS, /* + */
|
|
8735
|
-
CHAR_QUESTION_MARK, /* ? */
|
|
8736
|
-
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
8737
|
-
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
8738
|
-
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
8739
|
-
} = constants$2;
|
|
8740
|
-
|
|
8741
|
-
const isPathSeparator = code => {
|
|
8742
|
-
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
8743
|
-
};
|
|
8744
|
-
|
|
8745
|
-
const depth = token => {
|
|
8746
|
-
if (token.isPrefix !== true) {
|
|
8747
|
-
token.depth = token.isGlobstar ? Infinity : 1;
|
|
8748
|
-
}
|
|
8749
|
-
};
|
|
8750
|
-
|
|
8751
|
-
/**
|
|
8752
|
-
* Quickly scans a glob pattern and returns an object with a handful of
|
|
8753
|
-
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
8754
|
-
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
8755
|
-
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
8756
|
-
*
|
|
8757
|
-
* ```js
|
|
8758
|
-
* const pm = require('picomatch');
|
|
8759
|
-
* console.log(pm.scan('foo/bar/*.js'));
|
|
8760
|
-
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
8761
|
-
* ```
|
|
8762
|
-
* @param {String} `str`
|
|
8763
|
-
* @param {Object} `options`
|
|
8764
|
-
* @return {Object} Returns an object with tokens and regex source string.
|
|
8765
|
-
* @api public
|
|
8766
|
-
*/
|
|
8767
|
-
|
|
8768
|
-
const scan$1 = (input, options) => {
|
|
8769
|
-
const opts = options || {};
|
|
8770
|
-
|
|
8771
|
-
const length = input.length - 1;
|
|
8772
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
8773
|
-
const slashes = [];
|
|
8774
|
-
const tokens = [];
|
|
8775
|
-
const parts = [];
|
|
8776
|
-
|
|
8777
|
-
let str = input;
|
|
8778
|
-
let index = -1;
|
|
8779
|
-
let start = 0;
|
|
8780
|
-
let lastIndex = 0;
|
|
8781
|
-
let isBrace = false;
|
|
8782
|
-
let isBracket = false;
|
|
8783
|
-
let isGlob = false;
|
|
8784
|
-
let isExtglob = false;
|
|
8785
|
-
let isGlobstar = false;
|
|
8786
|
-
let braceEscaped = false;
|
|
8787
|
-
let backslashes = false;
|
|
8788
|
-
let negated = false;
|
|
8789
|
-
let negatedExtglob = false;
|
|
8790
|
-
let finished = false;
|
|
8791
|
-
let braces = 0;
|
|
8792
|
-
let prev;
|
|
8793
|
-
let code;
|
|
8794
|
-
let token = { value: '', depth: 0, isGlob: false };
|
|
8795
|
-
|
|
8796
|
-
const eos = () => index >= length;
|
|
8797
|
-
const peek = () => str.charCodeAt(index + 1);
|
|
8798
|
-
const advance = () => {
|
|
8799
|
-
prev = code;
|
|
8800
|
-
return str.charCodeAt(++index);
|
|
8801
|
-
};
|
|
8802
|
-
|
|
8803
|
-
while (index < length) {
|
|
8804
|
-
code = advance();
|
|
8805
|
-
let next;
|
|
8806
|
-
|
|
8807
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
8808
|
-
backslashes = token.backslashes = true;
|
|
8809
|
-
code = advance();
|
|
8810
|
-
|
|
8811
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
8812
|
-
braceEscaped = true;
|
|
8813
|
-
}
|
|
8814
|
-
continue;
|
|
8815
|
-
}
|
|
8816
|
-
|
|
8817
|
-
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
8818
|
-
braces++;
|
|
8819
|
-
|
|
8820
|
-
while (eos() !== true && (code = advance())) {
|
|
8821
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
8822
|
-
backslashes = token.backslashes = true;
|
|
8823
|
-
advance();
|
|
8824
|
-
continue;
|
|
8825
|
-
}
|
|
8826
|
-
|
|
8827
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
8828
|
-
braces++;
|
|
8829
|
-
continue;
|
|
8830
|
-
}
|
|
8831
|
-
|
|
8832
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
8833
|
-
isBrace = token.isBrace = true;
|
|
8834
|
-
isGlob = token.isGlob = true;
|
|
8835
|
-
finished = true;
|
|
8836
|
-
|
|
8837
|
-
if (scanToEnd === true) {
|
|
8838
|
-
continue;
|
|
8839
|
-
}
|
|
8840
|
-
|
|
8841
|
-
break;
|
|
8842
|
-
}
|
|
8843
|
-
|
|
8844
|
-
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
8845
|
-
isBrace = token.isBrace = true;
|
|
8846
|
-
isGlob = token.isGlob = true;
|
|
8847
|
-
finished = true;
|
|
8848
|
-
|
|
8849
|
-
if (scanToEnd === true) {
|
|
8850
|
-
continue;
|
|
8851
|
-
}
|
|
8852
|
-
|
|
8853
|
-
break;
|
|
8854
|
-
}
|
|
8855
|
-
|
|
8856
|
-
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
8857
|
-
braces--;
|
|
8858
|
-
|
|
8859
|
-
if (braces === 0) {
|
|
8860
|
-
braceEscaped = false;
|
|
8861
|
-
isBrace = token.isBrace = true;
|
|
8862
|
-
finished = true;
|
|
8863
|
-
break;
|
|
8864
|
-
}
|
|
8865
|
-
}
|
|
8866
|
-
}
|
|
8867
|
-
|
|
8868
|
-
if (scanToEnd === true) {
|
|
8869
|
-
continue;
|
|
8870
|
-
}
|
|
8871
|
-
|
|
8872
|
-
break;
|
|
8873
|
-
}
|
|
8874
|
-
|
|
8875
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
8876
|
-
slashes.push(index);
|
|
8877
|
-
tokens.push(token);
|
|
8878
|
-
token = { value: '', depth: 0, isGlob: false };
|
|
8879
|
-
|
|
8880
|
-
if (finished === true) continue;
|
|
8881
|
-
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
8882
|
-
start += 2;
|
|
8883
|
-
continue;
|
|
8884
|
-
}
|
|
8885
|
-
|
|
8886
|
-
lastIndex = index + 1;
|
|
8887
|
-
continue;
|
|
8888
|
-
}
|
|
8889
|
-
|
|
8890
|
-
if (opts.noext !== true) {
|
|
8891
|
-
const isExtglobChar = code === CHAR_PLUS
|
|
8892
|
-
|| code === CHAR_AT
|
|
8893
|
-
|| code === CHAR_ASTERISK
|
|
8894
|
-
|| code === CHAR_QUESTION_MARK
|
|
8895
|
-
|| code === CHAR_EXCLAMATION_MARK;
|
|
8896
|
-
|
|
8897
|
-
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
8898
|
-
isGlob = token.isGlob = true;
|
|
8899
|
-
isExtglob = token.isExtglob = true;
|
|
8900
|
-
finished = true;
|
|
8901
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
8902
|
-
negatedExtglob = true;
|
|
8903
|
-
}
|
|
8904
|
-
|
|
8905
|
-
if (scanToEnd === true) {
|
|
8906
|
-
while (eos() !== true && (code = advance())) {
|
|
8907
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
8908
|
-
backslashes = token.backslashes = true;
|
|
8909
|
-
code = advance();
|
|
8910
|
-
continue;
|
|
8911
|
-
}
|
|
8912
|
-
|
|
8913
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
8914
|
-
isGlob = token.isGlob = true;
|
|
8915
|
-
finished = true;
|
|
8916
|
-
break;
|
|
8917
|
-
}
|
|
8918
|
-
}
|
|
8919
|
-
continue;
|
|
8920
|
-
}
|
|
8921
|
-
break;
|
|
8922
|
-
}
|
|
8923
|
-
}
|
|
8924
|
-
|
|
8925
|
-
if (code === CHAR_ASTERISK) {
|
|
8926
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
8927
|
-
isGlob = token.isGlob = true;
|
|
8928
|
-
finished = true;
|
|
8929
|
-
|
|
8930
|
-
if (scanToEnd === true) {
|
|
8931
|
-
continue;
|
|
8932
|
-
}
|
|
8933
|
-
break;
|
|
8934
|
-
}
|
|
8935
|
-
|
|
8936
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
8937
|
-
isGlob = token.isGlob = true;
|
|
8938
|
-
finished = true;
|
|
8939
|
-
|
|
8940
|
-
if (scanToEnd === true) {
|
|
8941
|
-
continue;
|
|
8942
|
-
}
|
|
8943
|
-
break;
|
|
8944
|
-
}
|
|
8945
|
-
|
|
8946
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
8947
|
-
while (eos() !== true && (next = advance())) {
|
|
8948
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
8949
|
-
backslashes = token.backslashes = true;
|
|
8950
|
-
advance();
|
|
8951
|
-
continue;
|
|
8952
|
-
}
|
|
8953
|
-
|
|
8954
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
8955
|
-
isBracket = token.isBracket = true;
|
|
8956
|
-
isGlob = token.isGlob = true;
|
|
8957
|
-
finished = true;
|
|
8958
|
-
break;
|
|
8959
|
-
}
|
|
8960
|
-
}
|
|
8961
|
-
|
|
8962
|
-
if (scanToEnd === true) {
|
|
8963
|
-
continue;
|
|
8964
|
-
}
|
|
8965
|
-
|
|
8966
|
-
break;
|
|
8967
|
-
}
|
|
8968
|
-
|
|
8969
|
-
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
8970
|
-
negated = token.negated = true;
|
|
8971
|
-
start++;
|
|
8972
|
-
continue;
|
|
8973
|
-
}
|
|
8974
|
-
|
|
8975
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
8976
|
-
isGlob = token.isGlob = true;
|
|
8977
|
-
|
|
8978
|
-
if (scanToEnd === true) {
|
|
8979
|
-
while (eos() !== true && (code = advance())) {
|
|
8980
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
8981
|
-
backslashes = token.backslashes = true;
|
|
8982
|
-
code = advance();
|
|
8983
|
-
continue;
|
|
8984
|
-
}
|
|
8985
|
-
|
|
8986
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
8987
|
-
finished = true;
|
|
8988
|
-
break;
|
|
8989
|
-
}
|
|
8990
|
-
}
|
|
8991
|
-
continue;
|
|
8992
|
-
}
|
|
8993
|
-
break;
|
|
8994
|
-
}
|
|
8995
|
-
|
|
8996
|
-
if (isGlob === true) {
|
|
8997
|
-
finished = true;
|
|
8998
|
-
|
|
8999
|
-
if (scanToEnd === true) {
|
|
9000
|
-
continue;
|
|
9001
|
-
}
|
|
9002
|
-
|
|
9003
|
-
break;
|
|
9004
|
-
}
|
|
9005
|
-
}
|
|
9006
|
-
|
|
9007
|
-
if (opts.noext === true) {
|
|
9008
|
-
isExtglob = false;
|
|
9009
|
-
isGlob = false;
|
|
9010
|
-
}
|
|
9011
|
-
|
|
9012
|
-
let base = str;
|
|
9013
|
-
let prefix = '';
|
|
9014
|
-
let glob = '';
|
|
9015
|
-
|
|
9016
|
-
if (start > 0) {
|
|
9017
|
-
prefix = str.slice(0, start);
|
|
9018
|
-
str = str.slice(start);
|
|
9019
|
-
lastIndex -= start;
|
|
9020
|
-
}
|
|
9021
|
-
|
|
9022
|
-
if (base && isGlob === true && lastIndex > 0) {
|
|
9023
|
-
base = str.slice(0, lastIndex);
|
|
9024
|
-
glob = str.slice(lastIndex);
|
|
9025
|
-
} else if (isGlob === true) {
|
|
9026
|
-
base = '';
|
|
9027
|
-
glob = str;
|
|
9028
|
-
} else {
|
|
9029
|
-
base = str;
|
|
9030
|
-
}
|
|
9031
|
-
|
|
9032
|
-
if (base && base !== '' && base !== '/' && base !== str) {
|
|
9033
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
9034
|
-
base = base.slice(0, -1);
|
|
9035
|
-
}
|
|
9036
|
-
}
|
|
9037
|
-
|
|
9038
|
-
if (opts.unescape === true) {
|
|
9039
|
-
if (glob) glob = utils$2.removeBackslashes(glob);
|
|
9040
|
-
|
|
9041
|
-
if (base && backslashes === true) {
|
|
9042
|
-
base = utils$2.removeBackslashes(base);
|
|
9043
|
-
}
|
|
9044
|
-
}
|
|
9045
|
-
|
|
9046
|
-
const state = {
|
|
9047
|
-
prefix,
|
|
9048
|
-
input,
|
|
9049
|
-
start,
|
|
9050
|
-
base,
|
|
9051
|
-
glob,
|
|
9052
|
-
isBrace,
|
|
9053
|
-
isBracket,
|
|
9054
|
-
isGlob,
|
|
9055
|
-
isExtglob,
|
|
9056
|
-
isGlobstar,
|
|
9057
|
-
negated,
|
|
9058
|
-
negatedExtglob
|
|
9059
|
-
};
|
|
9060
|
-
|
|
9061
|
-
if (opts.tokens === true) {
|
|
9062
|
-
state.maxDepth = 0;
|
|
9063
|
-
if (!isPathSeparator(code)) {
|
|
9064
|
-
tokens.push(token);
|
|
9065
|
-
}
|
|
9066
|
-
state.tokens = tokens;
|
|
9067
|
-
}
|
|
9068
|
-
|
|
9069
|
-
if (opts.parts === true || opts.tokens === true) {
|
|
9070
|
-
let prevIndex;
|
|
9071
|
-
|
|
9072
|
-
for (let idx = 0; idx < slashes.length; idx++) {
|
|
9073
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
9074
|
-
const i = slashes[idx];
|
|
9075
|
-
const value = input.slice(n, i);
|
|
9076
|
-
if (opts.tokens) {
|
|
9077
|
-
if (idx === 0 && start !== 0) {
|
|
9078
|
-
tokens[idx].isPrefix = true;
|
|
9079
|
-
tokens[idx].value = prefix;
|
|
9080
|
-
} else {
|
|
9081
|
-
tokens[idx].value = value;
|
|
9082
|
-
}
|
|
9083
|
-
depth(tokens[idx]);
|
|
9084
|
-
state.maxDepth += tokens[idx].depth;
|
|
9085
|
-
}
|
|
9086
|
-
if (idx !== 0 || value !== '') {
|
|
9087
|
-
parts.push(value);
|
|
9088
|
-
}
|
|
9089
|
-
prevIndex = i;
|
|
9090
|
-
}
|
|
9091
|
-
|
|
9092
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
9093
|
-
const value = input.slice(prevIndex + 1);
|
|
9094
|
-
parts.push(value);
|
|
9095
|
-
|
|
9096
|
-
if (opts.tokens) {
|
|
9097
|
-
tokens[tokens.length - 1].value = value;
|
|
9098
|
-
depth(tokens[tokens.length - 1]);
|
|
9099
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
9100
|
-
}
|
|
9101
|
-
}
|
|
9102
|
-
|
|
9103
|
-
state.slashes = slashes;
|
|
9104
|
-
state.parts = parts;
|
|
9105
|
-
}
|
|
9106
|
-
|
|
9107
|
-
return state;
|
|
9108
|
-
};
|
|
9109
|
-
|
|
9110
|
-
var scan_1 = scan$1;
|
|
9111
|
-
|
|
9112
|
-
const constants$1 = constants$2;
|
|
9113
|
-
const utils$1 = utils$3;
|
|
9114
|
-
|
|
9115
|
-
/**
|
|
9116
|
-
* Constants
|
|
9117
|
-
*/
|
|
9118
|
-
|
|
9119
|
-
const {
|
|
9120
|
-
MAX_LENGTH,
|
|
9121
|
-
POSIX_REGEX_SOURCE,
|
|
9122
|
-
REGEX_NON_SPECIAL_CHARS,
|
|
9123
|
-
REGEX_SPECIAL_CHARS_BACKREF,
|
|
9124
|
-
REPLACEMENTS
|
|
9125
|
-
} = constants$1;
|
|
9126
|
-
|
|
9127
|
-
/**
|
|
9128
|
-
* Helpers
|
|
9129
|
-
*/
|
|
9130
|
-
|
|
9131
|
-
const expandRange = (args, options) => {
|
|
9132
|
-
if (typeof options.expandRange === 'function') {
|
|
9133
|
-
return options.expandRange(...args, options);
|
|
9134
|
-
}
|
|
9135
|
-
|
|
9136
|
-
args.sort();
|
|
9137
|
-
const value = `[${args.join('-')}]`;
|
|
9138
|
-
|
|
9139
|
-
return value;
|
|
9140
|
-
};
|
|
9141
|
-
|
|
9142
|
-
/**
|
|
9143
|
-
* Create the message for a syntax error
|
|
9144
|
-
*/
|
|
9145
|
-
|
|
9146
|
-
const syntaxError = (type, char) => {
|
|
9147
|
-
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
9148
|
-
};
|
|
9149
|
-
|
|
9150
|
-
/**
|
|
9151
|
-
* Parse the given input string.
|
|
9152
|
-
* @param {String} input
|
|
9153
|
-
* @param {Object} options
|
|
9154
|
-
* @return {Object}
|
|
9155
|
-
*/
|
|
9156
|
-
|
|
9157
|
-
const parse$1 = (input, options) => {
|
|
9158
|
-
if (typeof input !== 'string') {
|
|
9159
|
-
throw new TypeError('Expected a string');
|
|
9160
|
-
}
|
|
9161
|
-
|
|
9162
|
-
input = REPLACEMENTS[input] || input;
|
|
9163
|
-
|
|
9164
|
-
const opts = { ...options };
|
|
9165
|
-
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
9166
|
-
|
|
9167
|
-
let len = input.length;
|
|
9168
|
-
if (len > max) {
|
|
9169
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
9170
|
-
}
|
|
9171
|
-
|
|
9172
|
-
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
9173
|
-
const tokens = [bos];
|
|
9174
|
-
|
|
9175
|
-
const capture = opts.capture ? '' : '?:';
|
|
9176
|
-
const win32 = utils$1.isWindows(options);
|
|
9177
|
-
|
|
9178
|
-
// create constants based on platform, for windows or posix
|
|
9179
|
-
const PLATFORM_CHARS = constants$1.globChars(win32);
|
|
9180
|
-
const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
|
|
9181
|
-
|
|
9182
|
-
const {
|
|
9183
|
-
DOT_LITERAL,
|
|
9184
|
-
PLUS_LITERAL,
|
|
9185
|
-
SLASH_LITERAL,
|
|
9186
|
-
ONE_CHAR,
|
|
9187
|
-
DOTS_SLASH,
|
|
9188
|
-
NO_DOT,
|
|
9189
|
-
NO_DOT_SLASH,
|
|
9190
|
-
NO_DOTS_SLASH,
|
|
9191
|
-
QMARK,
|
|
9192
|
-
QMARK_NO_DOT,
|
|
9193
|
-
STAR,
|
|
9194
|
-
START_ANCHOR
|
|
9195
|
-
} = PLATFORM_CHARS;
|
|
9196
|
-
|
|
9197
|
-
const globstar = opts => {
|
|
9198
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
9199
|
-
};
|
|
9200
|
-
|
|
9201
|
-
const nodot = opts.dot ? '' : NO_DOT;
|
|
9202
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
9203
|
-
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
9204
|
-
|
|
9205
|
-
if (opts.capture) {
|
|
9206
|
-
star = `(${star})`;
|
|
9207
|
-
}
|
|
9208
|
-
|
|
9209
|
-
// minimatch options support
|
|
9210
|
-
if (typeof opts.noext === 'boolean') {
|
|
9211
|
-
opts.noextglob = opts.noext;
|
|
9212
|
-
}
|
|
9213
|
-
|
|
9214
|
-
const state = {
|
|
9215
|
-
input,
|
|
9216
|
-
index: -1,
|
|
9217
|
-
start: 0,
|
|
9218
|
-
dot: opts.dot === true,
|
|
9219
|
-
consumed: '',
|
|
9220
|
-
output: '',
|
|
9221
|
-
prefix: '',
|
|
9222
|
-
backtrack: false,
|
|
9223
|
-
negated: false,
|
|
9224
|
-
brackets: 0,
|
|
9225
|
-
braces: 0,
|
|
9226
|
-
parens: 0,
|
|
9227
|
-
quotes: 0,
|
|
9228
|
-
globstar: false,
|
|
9229
|
-
tokens
|
|
9230
|
-
};
|
|
9231
|
-
|
|
9232
|
-
input = utils$1.removePrefix(input, state);
|
|
9233
|
-
len = input.length;
|
|
9234
|
-
|
|
9235
|
-
const extglobs = [];
|
|
9236
|
-
const braces = [];
|
|
9237
|
-
const stack = [];
|
|
9238
|
-
let prev = bos;
|
|
9239
|
-
let value;
|
|
9240
|
-
|
|
9241
|
-
/**
|
|
9242
|
-
* Tokenizing helpers
|
|
9243
|
-
*/
|
|
9244
|
-
|
|
9245
|
-
const eos = () => state.index === len - 1;
|
|
9246
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
9247
|
-
const advance = state.advance = () => input[++state.index] || '';
|
|
9248
|
-
const remaining = () => input.slice(state.index + 1);
|
|
9249
|
-
const consume = (value = '', num = 0) => {
|
|
9250
|
-
state.consumed += value;
|
|
9251
|
-
state.index += num;
|
|
9252
|
-
};
|
|
9253
|
-
|
|
9254
|
-
const append = token => {
|
|
9255
|
-
state.output += token.output != null ? token.output : token.value;
|
|
9256
|
-
consume(token.value);
|
|
9257
|
-
};
|
|
9258
|
-
|
|
9259
|
-
const negate = () => {
|
|
9260
|
-
let count = 1;
|
|
9261
|
-
|
|
9262
|
-
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
9263
|
-
advance();
|
|
9264
|
-
state.start++;
|
|
9265
|
-
count++;
|
|
9266
|
-
}
|
|
9267
|
-
|
|
9268
|
-
if (count % 2 === 0) {
|
|
9269
|
-
return false;
|
|
9270
|
-
}
|
|
9271
|
-
|
|
9272
|
-
state.negated = true;
|
|
9273
|
-
state.start++;
|
|
9274
|
-
return true;
|
|
9275
|
-
};
|
|
9276
|
-
|
|
9277
|
-
const increment = type => {
|
|
9278
|
-
state[type]++;
|
|
9279
|
-
stack.push(type);
|
|
9280
|
-
};
|
|
9281
|
-
|
|
9282
|
-
const decrement = type => {
|
|
9283
|
-
state[type]--;
|
|
9284
|
-
stack.pop();
|
|
9285
|
-
};
|
|
9286
|
-
|
|
9287
|
-
/**
|
|
9288
|
-
* Push tokens onto the tokens array. This helper speeds up
|
|
9289
|
-
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
9290
|
-
* and 2) helping us avoid creating extra tokens when consecutive
|
|
9291
|
-
* characters are plain text. This improves performance and simplifies
|
|
9292
|
-
* lookbehinds.
|
|
9293
|
-
*/
|
|
9294
|
-
|
|
9295
|
-
const push = tok => {
|
|
9296
|
-
if (prev.type === 'globstar') {
|
|
9297
|
-
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
9298
|
-
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
9299
|
-
|
|
9300
|
-
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
9301
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
9302
|
-
prev.type = 'star';
|
|
9303
|
-
prev.value = '*';
|
|
9304
|
-
prev.output = star;
|
|
9305
|
-
state.output += prev.output;
|
|
9306
|
-
}
|
|
9307
|
-
}
|
|
9308
|
-
|
|
9309
|
-
if (extglobs.length && tok.type !== 'paren') {
|
|
9310
|
-
extglobs[extglobs.length - 1].inner += tok.value;
|
|
9311
|
-
}
|
|
9312
|
-
|
|
9313
|
-
if (tok.value || tok.output) append(tok);
|
|
9314
|
-
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
9315
|
-
prev.value += tok.value;
|
|
9316
|
-
prev.output = (prev.output || '') + tok.value;
|
|
9317
|
-
return;
|
|
9318
|
-
}
|
|
9319
|
-
|
|
9320
|
-
tok.prev = prev;
|
|
9321
|
-
tokens.push(tok);
|
|
9322
|
-
prev = tok;
|
|
9323
|
-
};
|
|
9324
|
-
|
|
9325
|
-
const extglobOpen = (type, value) => {
|
|
9326
|
-
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
9327
|
-
|
|
9328
|
-
token.prev = prev;
|
|
9329
|
-
token.parens = state.parens;
|
|
9330
|
-
token.output = state.output;
|
|
9331
|
-
const output = (opts.capture ? '(' : '') + token.open;
|
|
9332
|
-
|
|
9333
|
-
increment('parens');
|
|
9334
|
-
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
9335
|
-
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
9336
|
-
extglobs.push(token);
|
|
9337
|
-
};
|
|
9338
|
-
|
|
9339
|
-
const extglobClose = token => {
|
|
9340
|
-
let output = token.close + (opts.capture ? ')' : '');
|
|
9341
|
-
let rest;
|
|
9342
|
-
|
|
9343
|
-
if (token.type === 'negate') {
|
|
9344
|
-
let extglobStar = star;
|
|
9345
|
-
|
|
9346
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
9347
|
-
extglobStar = globstar(opts);
|
|
9348
|
-
}
|
|
9349
|
-
|
|
9350
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
9351
|
-
output = token.close = `)$))${extglobStar}`;
|
|
9352
|
-
}
|
|
9353
|
-
|
|
9354
|
-
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
9355
|
-
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
9356
|
-
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
9357
|
-
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
9358
|
-
//
|
|
9359
|
-
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
9360
|
-
const expression = parse$1(rest, { ...options, fastpaths: false }).output;
|
|
9361
|
-
|
|
9362
|
-
output = token.close = `)${expression})${extglobStar})`;
|
|
9363
|
-
}
|
|
9364
|
-
|
|
9365
|
-
if (token.prev.type === 'bos') {
|
|
9366
|
-
state.negatedExtglob = true;
|
|
9367
|
-
}
|
|
9368
|
-
}
|
|
9369
|
-
|
|
9370
|
-
push({ type: 'paren', extglob: true, value, output });
|
|
9371
|
-
decrement('parens');
|
|
9372
|
-
};
|
|
9373
|
-
|
|
9374
|
-
/**
|
|
9375
|
-
* Fast paths
|
|
9376
|
-
*/
|
|
9377
|
-
|
|
9378
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
9379
|
-
let backslashes = false;
|
|
9380
|
-
|
|
9381
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
9382
|
-
if (first === '\\') {
|
|
9383
|
-
backslashes = true;
|
|
9384
|
-
return m;
|
|
9385
|
-
}
|
|
9386
|
-
|
|
9387
|
-
if (first === '?') {
|
|
9388
|
-
if (esc) {
|
|
9389
|
-
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
9390
|
-
}
|
|
9391
|
-
if (index === 0) {
|
|
9392
|
-
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
9393
|
-
}
|
|
9394
|
-
return QMARK.repeat(chars.length);
|
|
9395
|
-
}
|
|
9396
|
-
|
|
9397
|
-
if (first === '.') {
|
|
9398
|
-
return DOT_LITERAL.repeat(chars.length);
|
|
9399
|
-
}
|
|
9400
|
-
|
|
9401
|
-
if (first === '*') {
|
|
9402
|
-
if (esc) {
|
|
9403
|
-
return esc + first + (rest ? star : '');
|
|
9404
|
-
}
|
|
9405
|
-
return star;
|
|
9406
|
-
}
|
|
9407
|
-
return esc ? m : `\\${m}`;
|
|
9408
|
-
});
|
|
9409
|
-
|
|
9410
|
-
if (backslashes === true) {
|
|
9411
|
-
if (opts.unescape === true) {
|
|
9412
|
-
output = output.replace(/\\/g, '');
|
|
9413
|
-
} else {
|
|
9414
|
-
output = output.replace(/\\+/g, m => {
|
|
9415
|
-
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
9416
|
-
});
|
|
9417
|
-
}
|
|
9418
|
-
}
|
|
9419
|
-
|
|
9420
|
-
if (output === input && opts.contains === true) {
|
|
9421
|
-
state.output = input;
|
|
9422
|
-
return state;
|
|
9423
|
-
}
|
|
9424
|
-
|
|
9425
|
-
state.output = utils$1.wrapOutput(output, state, options);
|
|
9426
|
-
return state;
|
|
9427
|
-
}
|
|
9428
|
-
|
|
9429
|
-
/**
|
|
9430
|
-
* Tokenize input until we reach end-of-string
|
|
9431
|
-
*/
|
|
9432
|
-
|
|
9433
|
-
while (!eos()) {
|
|
9434
|
-
value = advance();
|
|
9435
|
-
|
|
9436
|
-
if (value === '\u0000') {
|
|
9437
|
-
continue;
|
|
9438
|
-
}
|
|
9439
|
-
|
|
9440
|
-
/**
|
|
9441
|
-
* Escaped characters
|
|
9442
|
-
*/
|
|
9443
|
-
|
|
9444
|
-
if (value === '\\') {
|
|
9445
|
-
const next = peek();
|
|
9446
|
-
|
|
9447
|
-
if (next === '/' && opts.bash !== true) {
|
|
9448
|
-
continue;
|
|
9449
|
-
}
|
|
9450
|
-
|
|
9451
|
-
if (next === '.' || next === ';') {
|
|
9452
|
-
continue;
|
|
9453
|
-
}
|
|
9454
|
-
|
|
9455
|
-
if (!next) {
|
|
9456
|
-
value += '\\';
|
|
9457
|
-
push({ type: 'text', value });
|
|
9458
|
-
continue;
|
|
9459
|
-
}
|
|
9460
|
-
|
|
9461
|
-
// collapse slashes to reduce potential for exploits
|
|
9462
|
-
const match = /^\\+/.exec(remaining());
|
|
9463
|
-
let slashes = 0;
|
|
9464
|
-
|
|
9465
|
-
if (match && match[0].length > 2) {
|
|
9466
|
-
slashes = match[0].length;
|
|
9467
|
-
state.index += slashes;
|
|
9468
|
-
if (slashes % 2 !== 0) {
|
|
9469
|
-
value += '\\';
|
|
9470
|
-
}
|
|
9471
|
-
}
|
|
9472
|
-
|
|
9473
|
-
if (opts.unescape === true) {
|
|
9474
|
-
value = advance();
|
|
9475
|
-
} else {
|
|
9476
|
-
value += advance();
|
|
9477
|
-
}
|
|
9478
|
-
|
|
9479
|
-
if (state.brackets === 0) {
|
|
9480
|
-
push({ type: 'text', value });
|
|
9481
|
-
continue;
|
|
9482
|
-
}
|
|
9483
|
-
}
|
|
9484
|
-
|
|
9485
|
-
/**
|
|
9486
|
-
* If we're inside a regex character class, continue
|
|
9487
|
-
* until we reach the closing bracket.
|
|
9488
|
-
*/
|
|
9489
|
-
|
|
9490
|
-
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
9491
|
-
if (opts.posix !== false && value === ':') {
|
|
9492
|
-
const inner = prev.value.slice(1);
|
|
9493
|
-
if (inner.includes('[')) {
|
|
9494
|
-
prev.posix = true;
|
|
9495
|
-
|
|
9496
|
-
if (inner.includes(':')) {
|
|
9497
|
-
const idx = prev.value.lastIndexOf('[');
|
|
9498
|
-
const pre = prev.value.slice(0, idx);
|
|
9499
|
-
const rest = prev.value.slice(idx + 2);
|
|
9500
|
-
const posix = POSIX_REGEX_SOURCE[rest];
|
|
9501
|
-
if (posix) {
|
|
9502
|
-
prev.value = pre + posix;
|
|
9503
|
-
state.backtrack = true;
|
|
9504
|
-
advance();
|
|
9505
|
-
|
|
9506
|
-
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
9507
|
-
bos.output = ONE_CHAR;
|
|
9508
|
-
}
|
|
9509
|
-
continue;
|
|
9510
|
-
}
|
|
9511
|
-
}
|
|
9512
|
-
}
|
|
9513
|
-
}
|
|
9514
|
-
|
|
9515
|
-
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
9516
|
-
value = `\\${value}`;
|
|
9517
|
-
}
|
|
9518
|
-
|
|
9519
|
-
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
9520
|
-
value = `\\${value}`;
|
|
9521
|
-
}
|
|
9522
|
-
|
|
9523
|
-
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
9524
|
-
value = '^';
|
|
9525
|
-
}
|
|
9526
|
-
|
|
9527
|
-
prev.value += value;
|
|
9528
|
-
append({ value });
|
|
9529
|
-
continue;
|
|
9530
|
-
}
|
|
9531
|
-
|
|
9532
|
-
/**
|
|
9533
|
-
* If we're inside a quoted string, continue
|
|
9534
|
-
* until we reach the closing double quote.
|
|
9535
|
-
*/
|
|
9536
|
-
|
|
9537
|
-
if (state.quotes === 1 && value !== '"') {
|
|
9538
|
-
value = utils$1.escapeRegex(value);
|
|
9539
|
-
prev.value += value;
|
|
9540
|
-
append({ value });
|
|
9541
|
-
continue;
|
|
9542
|
-
}
|
|
9543
|
-
|
|
9544
|
-
/**
|
|
9545
|
-
* Double quotes
|
|
9546
|
-
*/
|
|
9547
|
-
|
|
9548
|
-
if (value === '"') {
|
|
9549
|
-
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
9550
|
-
if (opts.keepQuotes === true) {
|
|
9551
|
-
push({ type: 'text', value });
|
|
9552
|
-
}
|
|
9553
|
-
continue;
|
|
9554
|
-
}
|
|
9555
|
-
|
|
9556
|
-
/**
|
|
9557
|
-
* Parentheses
|
|
9558
|
-
*/
|
|
9559
|
-
|
|
9560
|
-
if (value === '(') {
|
|
9561
|
-
increment('parens');
|
|
9562
|
-
push({ type: 'paren', value });
|
|
9563
|
-
continue;
|
|
9564
|
-
}
|
|
9565
|
-
|
|
9566
|
-
if (value === ')') {
|
|
9567
|
-
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
9568
|
-
throw new SyntaxError(syntaxError('opening', '('));
|
|
9569
|
-
}
|
|
9570
|
-
|
|
9571
|
-
const extglob = extglobs[extglobs.length - 1];
|
|
9572
|
-
if (extglob && state.parens === extglob.parens + 1) {
|
|
9573
|
-
extglobClose(extglobs.pop());
|
|
9574
|
-
continue;
|
|
9575
|
-
}
|
|
9576
|
-
|
|
9577
|
-
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
9578
|
-
decrement('parens');
|
|
9579
|
-
continue;
|
|
9580
|
-
}
|
|
9581
|
-
|
|
9582
|
-
/**
|
|
9583
|
-
* Square brackets
|
|
9584
|
-
*/
|
|
9585
|
-
|
|
9586
|
-
if (value === '[') {
|
|
9587
|
-
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
9588
|
-
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
9589
|
-
throw new SyntaxError(syntaxError('closing', ']'));
|
|
9590
|
-
}
|
|
9591
|
-
|
|
9592
|
-
value = `\\${value}`;
|
|
9593
|
-
} else {
|
|
9594
|
-
increment('brackets');
|
|
9595
|
-
}
|
|
9596
|
-
|
|
9597
|
-
push({ type: 'bracket', value });
|
|
9598
|
-
continue;
|
|
9599
|
-
}
|
|
9600
|
-
|
|
9601
|
-
if (value === ']') {
|
|
9602
|
-
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
9603
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
9604
|
-
continue;
|
|
9605
|
-
}
|
|
9606
|
-
|
|
9607
|
-
if (state.brackets === 0) {
|
|
9608
|
-
if (opts.strictBrackets === true) {
|
|
9609
|
-
throw new SyntaxError(syntaxError('opening', '['));
|
|
9610
|
-
}
|
|
9611
|
-
|
|
9612
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
9613
|
-
continue;
|
|
9614
|
-
}
|
|
9615
|
-
|
|
9616
|
-
decrement('brackets');
|
|
9617
|
-
|
|
9618
|
-
const prevValue = prev.value.slice(1);
|
|
9619
|
-
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
9620
|
-
value = `/${value}`;
|
|
9621
|
-
}
|
|
9622
|
-
|
|
9623
|
-
prev.value += value;
|
|
9624
|
-
append({ value });
|
|
9625
|
-
|
|
9626
|
-
// when literal brackets are explicitly disabled
|
|
9627
|
-
// assume we should match with a regex character class
|
|
9628
|
-
if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
|
|
9629
|
-
continue;
|
|
9630
|
-
}
|
|
9631
|
-
|
|
9632
|
-
const escaped = utils$1.escapeRegex(prev.value);
|
|
9633
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
9634
|
-
|
|
9635
|
-
// when literal brackets are explicitly enabled
|
|
9636
|
-
// assume we should escape the brackets to match literal characters
|
|
9637
|
-
if (opts.literalBrackets === true) {
|
|
9638
|
-
state.output += escaped;
|
|
9639
|
-
prev.value = escaped;
|
|
9640
|
-
continue;
|
|
9641
|
-
}
|
|
9642
|
-
|
|
9643
|
-
// when the user specifies nothing, try to match both
|
|
9644
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
9645
|
-
state.output += prev.value;
|
|
9646
|
-
continue;
|
|
9647
|
-
}
|
|
9648
|
-
|
|
9649
|
-
/**
|
|
9650
|
-
* Braces
|
|
9651
|
-
*/
|
|
9652
|
-
|
|
9653
|
-
if (value === '{' && opts.nobrace !== true) {
|
|
9654
|
-
increment('braces');
|
|
9655
|
-
|
|
9656
|
-
const open = {
|
|
9657
|
-
type: 'brace',
|
|
9658
|
-
value,
|
|
9659
|
-
output: '(',
|
|
9660
|
-
outputIndex: state.output.length,
|
|
9661
|
-
tokensIndex: state.tokens.length
|
|
9662
|
-
};
|
|
9663
|
-
|
|
9664
|
-
braces.push(open);
|
|
9665
|
-
push(open);
|
|
9666
|
-
continue;
|
|
9667
|
-
}
|
|
9668
|
-
|
|
9669
|
-
if (value === '}') {
|
|
9670
|
-
const brace = braces[braces.length - 1];
|
|
9671
|
-
|
|
9672
|
-
if (opts.nobrace === true || !brace) {
|
|
9673
|
-
push({ type: 'text', value, output: value });
|
|
9674
|
-
continue;
|
|
9675
|
-
}
|
|
9676
|
-
|
|
9677
|
-
let output = ')';
|
|
9678
|
-
|
|
9679
|
-
if (brace.dots === true) {
|
|
9680
|
-
const arr = tokens.slice();
|
|
9681
|
-
const range = [];
|
|
9682
|
-
|
|
9683
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
9684
|
-
tokens.pop();
|
|
9685
|
-
if (arr[i].type === 'brace') {
|
|
9686
|
-
break;
|
|
9687
|
-
}
|
|
9688
|
-
if (arr[i].type !== 'dots') {
|
|
9689
|
-
range.unshift(arr[i].value);
|
|
9690
|
-
}
|
|
9691
|
-
}
|
|
9692
|
-
|
|
9693
|
-
output = expandRange(range, opts);
|
|
9694
|
-
state.backtrack = true;
|
|
9695
|
-
}
|
|
9696
|
-
|
|
9697
|
-
if (brace.comma !== true && brace.dots !== true) {
|
|
9698
|
-
const out = state.output.slice(0, brace.outputIndex);
|
|
9699
|
-
const toks = state.tokens.slice(brace.tokensIndex);
|
|
9700
|
-
brace.value = brace.output = '\\{';
|
|
9701
|
-
value = output = '\\}';
|
|
9702
|
-
state.output = out;
|
|
9703
|
-
for (const t of toks) {
|
|
9704
|
-
state.output += (t.output || t.value);
|
|
9705
|
-
}
|
|
9706
|
-
}
|
|
9707
|
-
|
|
9708
|
-
push({ type: 'brace', value, output });
|
|
9709
|
-
decrement('braces');
|
|
9710
|
-
braces.pop();
|
|
9711
|
-
continue;
|
|
9712
|
-
}
|
|
9713
|
-
|
|
9714
|
-
/**
|
|
9715
|
-
* Pipes
|
|
9716
|
-
*/
|
|
9717
|
-
|
|
9718
|
-
if (value === '|') {
|
|
9719
|
-
if (extglobs.length > 0) {
|
|
9720
|
-
extglobs[extglobs.length - 1].conditions++;
|
|
9721
|
-
}
|
|
9722
|
-
push({ type: 'text', value });
|
|
9723
|
-
continue;
|
|
9724
|
-
}
|
|
9725
|
-
|
|
9726
|
-
/**
|
|
9727
|
-
* Commas
|
|
9728
|
-
*/
|
|
9729
|
-
|
|
9730
|
-
if (value === ',') {
|
|
9731
|
-
let output = value;
|
|
9732
|
-
|
|
9733
|
-
const brace = braces[braces.length - 1];
|
|
9734
|
-
if (brace && stack[stack.length - 1] === 'braces') {
|
|
9735
|
-
brace.comma = true;
|
|
9736
|
-
output = '|';
|
|
9737
|
-
}
|
|
9738
|
-
|
|
9739
|
-
push({ type: 'comma', value, output });
|
|
9740
|
-
continue;
|
|
9741
|
-
}
|
|
9742
|
-
|
|
9743
|
-
/**
|
|
9744
|
-
* Slashes
|
|
9745
|
-
*/
|
|
9746
|
-
|
|
9747
|
-
if (value === '/') {
|
|
9748
|
-
// if the beginning of the glob is "./", advance the start
|
|
9749
|
-
// to the current index, and don't add the "./" characters
|
|
9750
|
-
// to the state. This greatly simplifies lookbehinds when
|
|
9751
|
-
// checking for BOS characters like "!" and "." (not "./")
|
|
9752
|
-
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
9753
|
-
state.start = state.index + 1;
|
|
9754
|
-
state.consumed = '';
|
|
9755
|
-
state.output = '';
|
|
9756
|
-
tokens.pop();
|
|
9757
|
-
prev = bos; // reset "prev" to the first token
|
|
9758
|
-
continue;
|
|
9759
|
-
}
|
|
9760
|
-
|
|
9761
|
-
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
9762
|
-
continue;
|
|
9763
|
-
}
|
|
9764
|
-
|
|
9765
|
-
/**
|
|
9766
|
-
* Dots
|
|
9767
|
-
*/
|
|
9768
|
-
|
|
9769
|
-
if (value === '.') {
|
|
9770
|
-
if (state.braces > 0 && prev.type === 'dot') {
|
|
9771
|
-
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
9772
|
-
const brace = braces[braces.length - 1];
|
|
9773
|
-
prev.type = 'dots';
|
|
9774
|
-
prev.output += value;
|
|
9775
|
-
prev.value += value;
|
|
9776
|
-
brace.dots = true;
|
|
9777
|
-
continue;
|
|
9778
|
-
}
|
|
9779
|
-
|
|
9780
|
-
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
9781
|
-
push({ type: 'text', value, output: DOT_LITERAL });
|
|
9782
|
-
continue;
|
|
9783
|
-
}
|
|
9784
|
-
|
|
9785
|
-
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
9786
|
-
continue;
|
|
9787
|
-
}
|
|
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
|
+
};
|
|
9788
8700
|
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
8701
|
+
exports.isWindows = options => {
|
|
8702
|
+
if (options && typeof options.windows === 'boolean') {
|
|
8703
|
+
return options.windows;
|
|
8704
|
+
}
|
|
8705
|
+
return win32 === true || path.sep === '\\';
|
|
8706
|
+
};
|
|
9792
8707
|
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
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
|
+
};
|
|
9799
8714
|
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
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
|
+
};
|
|
9803
8723
|
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
8724
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
8725
|
+
const prepend = options.contains ? '' : '^';
|
|
8726
|
+
const append = options.contains ? '' : '$';
|
|
9807
8727
|
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
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
|
+
}
|
|
9811
8737
|
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
}
|
|
8738
|
+
var scan_1;
|
|
8739
|
+
var hasRequiredScan;
|
|
9815
8740
|
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
}
|
|
8741
|
+
function requireScan () {
|
|
8742
|
+
if (hasRequiredScan) return scan_1;
|
|
8743
|
+
hasRequiredScan = 1;
|
|
9820
8744
|
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
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
|
+
};
|
|
9824
8767
|
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
8768
|
+
const depth = token => {
|
|
8769
|
+
if (token.isPrefix !== true) {
|
|
8770
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
8771
|
+
}
|
|
8772
|
+
};
|
|
9828
8773
|
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
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
|
+
}
|
|
9836
9029
|
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
}
|
|
9030
|
+
if (opts.noext === true) {
|
|
9031
|
+
isExtglob = false;
|
|
9032
|
+
isGlob = false;
|
|
9033
|
+
}
|
|
9842
9034
|
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9035
|
+
let base = str;
|
|
9036
|
+
let prefix = '';
|
|
9037
|
+
let glob = '';
|
|
9846
9038
|
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9039
|
+
if (start > 0) {
|
|
9040
|
+
prefix = str.slice(0, start);
|
|
9041
|
+
str = str.slice(start);
|
|
9042
|
+
lastIndex -= start;
|
|
9043
|
+
}
|
|
9852
9044
|
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
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
|
+
}
|
|
9857
9054
|
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
|
|
9055
|
+
if (base && base !== '' && base !== '/' && base !== str) {
|
|
9056
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
9057
|
+
base = base.slice(0, -1);
|
|
9058
|
+
}
|
|
9059
|
+
}
|
|
9862
9060
|
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
}
|
|
9061
|
+
if (opts.unescape === true) {
|
|
9062
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
9866
9063
|
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9064
|
+
if (base && backslashes === true) {
|
|
9065
|
+
base = utils.removeBackslashes(base);
|
|
9066
|
+
}
|
|
9067
|
+
}
|
|
9870
9068
|
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
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
|
+
}
|
|
9876
9091
|
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
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
|
+
}
|
|
9880
9129
|
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
*/
|
|
9130
|
+
return state;
|
|
9131
|
+
};
|
|
9884
9132
|
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
}
|
|
9133
|
+
scan_1 = scan;
|
|
9134
|
+
return scan_1;
|
|
9135
|
+
}
|
|
9889
9136
|
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
value += match[0];
|
|
9893
|
-
state.index += match[0].length;
|
|
9894
|
-
}
|
|
9137
|
+
var parse_1;
|
|
9138
|
+
var hasRequiredParse;
|
|
9895
9139
|
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9140
|
+
function requireParse () {
|
|
9141
|
+
if (hasRequiredParse) return parse_1;
|
|
9142
|
+
hasRequiredParse = 1;
|
|
9899
9143
|
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
*/
|
|
9144
|
+
const constants = /*@__PURE__*/ requireConstants();
|
|
9145
|
+
const utils = /*@__PURE__*/ requireUtils();
|
|
9903
9146
|
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
prev.value += value;
|
|
9908
|
-
prev.output = star;
|
|
9909
|
-
state.backtrack = true;
|
|
9910
|
-
state.globstar = true;
|
|
9911
|
-
consume(value);
|
|
9912
|
-
continue;
|
|
9913
|
-
}
|
|
9914
|
-
|
|
9915
|
-
let rest = remaining();
|
|
9916
|
-
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
9917
|
-
extglobOpen('star', value);
|
|
9918
|
-
continue;
|
|
9919
|
-
}
|
|
9920
|
-
|
|
9921
|
-
if (prev.type === 'star') {
|
|
9922
|
-
if (opts.noglobstar === true) {
|
|
9923
|
-
consume(value);
|
|
9924
|
-
continue;
|
|
9925
|
-
}
|
|
9926
|
-
|
|
9927
|
-
const prior = prev.prev;
|
|
9928
|
-
const before = prior.prev;
|
|
9929
|
-
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
9930
|
-
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
9931
|
-
|
|
9932
|
-
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
9933
|
-
push({ type: 'star', value, output: '' });
|
|
9934
|
-
continue;
|
|
9935
|
-
}
|
|
9936
|
-
|
|
9937
|
-
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
9938
|
-
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
9939
|
-
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
9940
|
-
push({ type: 'star', value, output: '' });
|
|
9941
|
-
continue;
|
|
9942
|
-
}
|
|
9943
|
-
|
|
9944
|
-
// strip consecutive `/**/`
|
|
9945
|
-
while (rest.slice(0, 3) === '/**') {
|
|
9946
|
-
const after = input[state.index + 4];
|
|
9947
|
-
if (after && after !== '/') {
|
|
9948
|
-
break;
|
|
9949
|
-
}
|
|
9950
|
-
rest = rest.slice(3);
|
|
9951
|
-
consume('/**', 3);
|
|
9952
|
-
}
|
|
9953
|
-
|
|
9954
|
-
if (prior.type === 'bos' && eos()) {
|
|
9955
|
-
prev.type = 'globstar';
|
|
9956
|
-
prev.value += value;
|
|
9957
|
-
prev.output = globstar(opts);
|
|
9958
|
-
state.output = prev.output;
|
|
9959
|
-
state.globstar = true;
|
|
9960
|
-
consume(value);
|
|
9961
|
-
continue;
|
|
9962
|
-
}
|
|
9963
|
-
|
|
9964
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
9965
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
9966
|
-
prior.output = `(?:${prior.output}`;
|
|
9967
|
-
|
|
9968
|
-
prev.type = 'globstar';
|
|
9969
|
-
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
9970
|
-
prev.value += value;
|
|
9971
|
-
state.globstar = true;
|
|
9972
|
-
state.output += prior.output + prev.output;
|
|
9973
|
-
consume(value);
|
|
9974
|
-
continue;
|
|
9975
|
-
}
|
|
9976
|
-
|
|
9977
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
9978
|
-
const end = rest[1] !== void 0 ? '|$' : '';
|
|
9979
|
-
|
|
9980
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
9981
|
-
prior.output = `(?:${prior.output}`;
|
|
9982
|
-
|
|
9983
|
-
prev.type = 'globstar';
|
|
9984
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
9985
|
-
prev.value += value;
|
|
9986
|
-
|
|
9987
|
-
state.output += prior.output + prev.output;
|
|
9988
|
-
state.globstar = true;
|
|
9989
|
-
|
|
9990
|
-
consume(value + advance());
|
|
9991
|
-
|
|
9992
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
9993
|
-
continue;
|
|
9994
|
-
}
|
|
9995
|
-
|
|
9996
|
-
if (prior.type === 'bos' && rest[0] === '/') {
|
|
9997
|
-
prev.type = 'globstar';
|
|
9998
|
-
prev.value += value;
|
|
9999
|
-
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
10000
|
-
state.output = prev.output;
|
|
10001
|
-
state.globstar = true;
|
|
10002
|
-
consume(value + advance());
|
|
10003
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
10004
|
-
continue;
|
|
10005
|
-
}
|
|
10006
|
-
|
|
10007
|
-
// remove single star from output
|
|
10008
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
10009
|
-
|
|
10010
|
-
// reset previous token to globstar
|
|
10011
|
-
prev.type = 'globstar';
|
|
10012
|
-
prev.output = globstar(opts);
|
|
10013
|
-
prev.value += value;
|
|
10014
|
-
|
|
10015
|
-
// reset output with globstar
|
|
10016
|
-
state.output += prev.output;
|
|
10017
|
-
state.globstar = true;
|
|
10018
|
-
consume(value);
|
|
10019
|
-
continue;
|
|
10020
|
-
}
|
|
10021
|
-
|
|
10022
|
-
const token = { type: 'star', value, output: star };
|
|
10023
|
-
|
|
10024
|
-
if (opts.bash === true) {
|
|
10025
|
-
token.output = '.*?';
|
|
10026
|
-
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
10027
|
-
token.output = nodot + token.output;
|
|
10028
|
-
}
|
|
10029
|
-
push(token);
|
|
10030
|
-
continue;
|
|
10031
|
-
}
|
|
10032
|
-
|
|
10033
|
-
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
10034
|
-
token.output = value;
|
|
10035
|
-
push(token);
|
|
10036
|
-
continue;
|
|
10037
|
-
}
|
|
10038
|
-
|
|
10039
|
-
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
10040
|
-
if (prev.type === 'dot') {
|
|
10041
|
-
state.output += NO_DOT_SLASH;
|
|
10042
|
-
prev.output += NO_DOT_SLASH;
|
|
10043
|
-
|
|
10044
|
-
} else if (opts.dot === true) {
|
|
10045
|
-
state.output += NO_DOTS_SLASH;
|
|
10046
|
-
prev.output += NO_DOTS_SLASH;
|
|
10047
|
-
|
|
10048
|
-
} else {
|
|
10049
|
-
state.output += nodot;
|
|
10050
|
-
prev.output += nodot;
|
|
10051
|
-
}
|
|
10052
|
-
|
|
10053
|
-
if (peek() !== '*') {
|
|
10054
|
-
state.output += ONE_CHAR;
|
|
10055
|
-
prev.output += ONE_CHAR;
|
|
10056
|
-
}
|
|
10057
|
-
}
|
|
10058
|
-
|
|
10059
|
-
push(token);
|
|
10060
|
-
}
|
|
10061
|
-
|
|
10062
|
-
while (state.brackets > 0) {
|
|
10063
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
10064
|
-
state.output = utils$1.escapeLast(state.output, '[');
|
|
10065
|
-
decrement('brackets');
|
|
10066
|
-
}
|
|
9147
|
+
/**
|
|
9148
|
+
* Constants
|
|
9149
|
+
*/
|
|
10067
9150
|
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
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
|
+
}
|
|
10073
9167
|
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
state.output = utils$1.escapeLast(state.output, '{');
|
|
10077
|
-
decrement('braces');
|
|
10078
|
-
}
|
|
9168
|
+
args.sort();
|
|
9169
|
+
const value = `[${args.join('-')}]`;
|
|
10079
9170
|
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
}
|
|
9171
|
+
return value;
|
|
9172
|
+
};
|
|
10083
9173
|
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
9174
|
+
/**
|
|
9175
|
+
* Create the message for a syntax error
|
|
9176
|
+
*/
|
|
10087
9177
|
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
if (token.suffix) {
|
|
10092
|
-
state.output += token.suffix;
|
|
10093
|
-
}
|
|
10094
|
-
}
|
|
10095
|
-
}
|
|
10096
|
-
|
|
10097
|
-
return state;
|
|
10098
|
-
};
|
|
9178
|
+
const syntaxError = (type, char) => {
|
|
9179
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
9180
|
+
};
|
|
10099
9181
|
|
|
10100
|
-
/**
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
9182
|
+
/**
|
|
9183
|
+
* Parse the given input string.
|
|
9184
|
+
* @param {String} input
|
|
9185
|
+
* @param {Object} options
|
|
9186
|
+
* @return {Object}
|
|
9187
|
+
*/
|
|
10105
9188
|
|
|
10106
|
-
parse
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
if (len > max) {
|
|
10111
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
10112
|
-
}
|
|
9189
|
+
const parse = (input, options) => {
|
|
9190
|
+
if (typeof input !== 'string') {
|
|
9191
|
+
throw new TypeError('Expected a string');
|
|
9192
|
+
}
|
|
10113
9193
|
|
|
10114
|
-
|
|
10115
|
-
const win32 = utils$1.isWindows(options);
|
|
9194
|
+
input = REPLACEMENTS[input] || input;
|
|
10116
9195
|
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
DOT_LITERAL,
|
|
10120
|
-
SLASH_LITERAL,
|
|
10121
|
-
ONE_CHAR,
|
|
10122
|
-
DOTS_SLASH,
|
|
10123
|
-
NO_DOT,
|
|
10124
|
-
NO_DOTS,
|
|
10125
|
-
NO_DOTS_SLASH,
|
|
10126
|
-
STAR,
|
|
10127
|
-
START_ANCHOR
|
|
10128
|
-
} = constants$1.globChars(win32);
|
|
9196
|
+
const opts = { ...options };
|
|
9197
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
10129
9198
|
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
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
|
+
}
|
|
10135
9203
|
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
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
|
+
}
|
|
10139
9240
|
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
9241
|
+
// minimatch options support
|
|
9242
|
+
if (typeof opts.noext === 'boolean') {
|
|
9243
|
+
opts.noextglob = opts.noext;
|
|
9244
|
+
}
|
|
10144
9245
|
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
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
|
+
}
|
|
10149
9460
|
|
|
10150
|
-
|
|
10151
|
-
|
|
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
|
+
}
|
|
10152
10093
|
|
|
10153
|
-
|
|
10154
|
-
|
|
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
|
+
}
|
|
10155
10099
|
|
|
10156
|
-
|
|
10157
|
-
|
|
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
|
+
}
|
|
10158
10105
|
|
|
10159
|
-
|
|
10160
|
-
|
|
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
|
+
}
|
|
10161
10111
|
|
|
10162
|
-
|
|
10163
|
-
|
|
10112
|
+
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
10113
|
+
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
10114
|
+
}
|
|
10164
10115
|
|
|
10165
|
-
|
|
10166
|
-
|
|
10116
|
+
// rebuild the output if we had to backtrack at any point
|
|
10117
|
+
if (state.backtrack === true) {
|
|
10118
|
+
state.output = '';
|
|
10167
10119
|
|
|
10168
|
-
|
|
10169
|
-
|
|
10120
|
+
for (const token of state.tokens) {
|
|
10121
|
+
state.output += token.output != null ? token.output : token.value;
|
|
10170
10122
|
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10123
|
+
if (token.suffix) {
|
|
10124
|
+
state.output += token.suffix;
|
|
10125
|
+
}
|
|
10126
|
+
}
|
|
10127
|
+
}
|
|
10174
10128
|
|
|
10175
|
-
|
|
10176
|
-
|
|
10129
|
+
return state;
|
|
10130
|
+
};
|
|
10177
10131
|
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
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
|
+
}
|
|
10182
10145
|
|
|
10183
|
-
|
|
10184
|
-
|
|
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
|
+
}
|
|
10185
10171
|
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10172
|
+
const globstar = opts => {
|
|
10173
|
+
if (opts.noglobstar === true) return star;
|
|
10174
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
10175
|
+
};
|
|
10189
10176
|
|
|
10190
|
-
|
|
10191
|
-
|
|
10177
|
+
const create = str => {
|
|
10178
|
+
switch (str) {
|
|
10179
|
+
case '*':
|
|
10180
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
10192
10181
|
|
|
10193
|
-
|
|
10182
|
+
case '.*':
|
|
10183
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
10194
10184
|
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
const parse = parse_1;
|
|
10198
|
-
const utils = utils$3;
|
|
10199
|
-
const constants = constants$2;
|
|
10200
|
-
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
10185
|
+
case '*.*':
|
|
10186
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
10201
10187
|
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
* returned function takes a string to match as its first argument,
|
|
10205
|
-
* and returns true if the string is a match. The returned matcher
|
|
10206
|
-
* function also takes a boolean as the second argument that, when true,
|
|
10207
|
-
* returns an object with additional information.
|
|
10208
|
-
*
|
|
10209
|
-
* ```js
|
|
10210
|
-
* const picomatch = require('picomatch');
|
|
10211
|
-
* // picomatch(glob[, options]);
|
|
10212
|
-
*
|
|
10213
|
-
* const isMatch = picomatch('*.!(*a)');
|
|
10214
|
-
* console.log(isMatch('a.a')); //=> false
|
|
10215
|
-
* console.log(isMatch('a.b')); //=> true
|
|
10216
|
-
* ```
|
|
10217
|
-
* @name picomatch
|
|
10218
|
-
* @param {String|Array} `globs` One or more glob patterns.
|
|
10219
|
-
* @param {Object=} `options`
|
|
10220
|
-
* @return {Function=} Returns a matcher function.
|
|
10221
|
-
* @api public
|
|
10222
|
-
*/
|
|
10188
|
+
case '*/*':
|
|
10189
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
10223
10190
|
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
const fns = glob.map(input => picomatch$1(input, options, returnState));
|
|
10227
|
-
const arrayMatcher = str => {
|
|
10228
|
-
for (const isMatch of fns) {
|
|
10229
|
-
const state = isMatch(str);
|
|
10230
|
-
if (state) return state;
|
|
10231
|
-
}
|
|
10232
|
-
return false;
|
|
10233
|
-
};
|
|
10234
|
-
return arrayMatcher;
|
|
10235
|
-
}
|
|
10191
|
+
case '**':
|
|
10192
|
+
return nodot + globstar(opts);
|
|
10236
10193
|
|
|
10237
|
-
|
|
10194
|
+
case '**/*':
|
|
10195
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
10238
10196
|
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
}
|
|
10197
|
+
case '**/*.*':
|
|
10198
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
10242
10199
|
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
const regex = isState
|
|
10246
|
-
? picomatch$1.compileRe(glob, options)
|
|
10247
|
-
: picomatch$1.makeRe(glob, options, false, true);
|
|
10200
|
+
case '**/.*':
|
|
10201
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
10248
10202
|
|
|
10249
|
-
|
|
10250
|
-
|
|
10203
|
+
default: {
|
|
10204
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
10205
|
+
if (!match) return;
|
|
10251
10206
|
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
10255
|
-
isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
|
|
10256
|
-
}
|
|
10207
|
+
const source = create(match[1]);
|
|
10208
|
+
if (!source) return;
|
|
10257
10209
|
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10210
|
+
return source + DOT_LITERAL + match[2];
|
|
10211
|
+
}
|
|
10212
|
+
}
|
|
10213
|
+
};
|
|
10261
10214
|
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
}
|
|
10215
|
+
const output = utils.removePrefix(input, state);
|
|
10216
|
+
let source = create(output);
|
|
10265
10217
|
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
}
|
|
10218
|
+
if (source && opts.strictSlashes !== true) {
|
|
10219
|
+
source += `${SLASH_LITERAL}?`;
|
|
10220
|
+
}
|
|
10270
10221
|
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
opts.onIgnore(result);
|
|
10274
|
-
}
|
|
10275
|
-
result.isMatch = false;
|
|
10276
|
-
return returnObject ? result : false;
|
|
10277
|
-
}
|
|
10222
|
+
return source;
|
|
10223
|
+
};
|
|
10278
10224
|
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
return returnObject ? result : true;
|
|
10283
|
-
};
|
|
10225
|
+
parse_1 = parse;
|
|
10226
|
+
return parse_1;
|
|
10227
|
+
}
|
|
10284
10228
|
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
}
|
|
10229
|
+
var picomatch_1;
|
|
10230
|
+
var hasRequiredPicomatch$1;
|
|
10288
10231
|
|
|
10289
|
-
|
|
10290
|
-
|
|
10232
|
+
function requirePicomatch$1 () {
|
|
10233
|
+
if (hasRequiredPicomatch$1) return picomatch_1;
|
|
10234
|
+
hasRequiredPicomatch$1 = 1;
|
|
10291
10235
|
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
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
|
+
}
|
|
10308
10277
|
|
|
10309
|
-
|
|
10310
|
-
if (typeof input !== 'string') {
|
|
10311
|
-
throw new TypeError('Expected input to be a string');
|
|
10312
|
-
}
|
|
10278
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
10313
10279
|
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10280
|
+
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
10281
|
+
throw new TypeError('Expected pattern to be a non-empty string');
|
|
10282
|
+
}
|
|
10317
10283
|
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
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);
|
|
10322
10289
|
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
match = output === glob;
|
|
10326
|
-
}
|
|
10290
|
+
const state = regex.state;
|
|
10291
|
+
delete regex.state;
|
|
10327
10292
|
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
}
|
|
10334
|
-
}
|
|
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
|
+
}
|
|
10335
10298
|
|
|
10336
|
-
|
|
10337
|
-
};
|
|
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
|
+
}
|
|
10338
10329
|
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
*
|
|
10342
|
-
* ```js
|
|
10343
|
-
* const picomatch = require('picomatch');
|
|
10344
|
-
* // picomatch.matchBase(input, glob[, options]);
|
|
10345
|
-
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
10346
|
-
* ```
|
|
10347
|
-
* @param {String} `input` String to test.
|
|
10348
|
-
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
10349
|
-
* @return {Boolean}
|
|
10350
|
-
* @api public
|
|
10351
|
-
*/
|
|
10330
|
+
return matcher;
|
|
10331
|
+
};
|
|
10352
10332
|
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
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
|
+
}
|
|
10357
10354
|
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
* ```js
|
|
10362
|
-
* const picomatch = require('picomatch');
|
|
10363
|
-
* // picomatch.isMatch(string, patterns[, options]);
|
|
10364
|
-
*
|
|
10365
|
-
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
10366
|
-
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
10367
|
-
* ```
|
|
10368
|
-
* @param {String|Array} str The string to test.
|
|
10369
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
10370
|
-
* @param {Object} [options] See available [options](#options).
|
|
10371
|
-
* @return {Boolean} Returns true if any patterns match `str`
|
|
10372
|
-
* @api public
|
|
10373
|
-
*/
|
|
10355
|
+
if (input === '') {
|
|
10356
|
+
return { isMatch: false, output: '' };
|
|
10357
|
+
}
|
|
10374
10358
|
|
|
10375
|
-
|
|
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;
|
|
10376
10363
|
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
* ```js
|
|
10382
|
-
* const picomatch = require('picomatch');
|
|
10383
|
-
* const result = picomatch.parse(pattern[, options]);
|
|
10384
|
-
* ```
|
|
10385
|
-
* @param {String} `pattern`
|
|
10386
|
-
* @param {Object} `options`
|
|
10387
|
-
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
10388
|
-
* @api public
|
|
10389
|
-
*/
|
|
10364
|
+
if (match === false) {
|
|
10365
|
+
output = format ? format(input) : input;
|
|
10366
|
+
match = output === glob;
|
|
10367
|
+
}
|
|
10390
10368
|
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
}
|
|
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
|
+
}
|
|
10395
10376
|
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
*
|
|
10399
|
-
* ```js
|
|
10400
|
-
* const picomatch = require('picomatch');
|
|
10401
|
-
* // picomatch.scan(input[, options]);
|
|
10402
|
-
*
|
|
10403
|
-
* const result = picomatch.scan('!./foo/*.js');
|
|
10404
|
-
* console.log(result);
|
|
10405
|
-
* { prefix: '!./',
|
|
10406
|
-
* input: '!./foo/*.js',
|
|
10407
|
-
* start: 3,
|
|
10408
|
-
* base: 'foo',
|
|
10409
|
-
* glob: '*.js',
|
|
10410
|
-
* isBrace: false,
|
|
10411
|
-
* isBracket: false,
|
|
10412
|
-
* isGlob: true,
|
|
10413
|
-
* isExtglob: false,
|
|
10414
|
-
* isGlobstar: false,
|
|
10415
|
-
* negated: true }
|
|
10416
|
-
* ```
|
|
10417
|
-
* @param {String} `input` Glob pattern to scan.
|
|
10418
|
-
* @param {Object} `options`
|
|
10419
|
-
* @return {Object} Returns an object with
|
|
10420
|
-
* @api public
|
|
10421
|
-
*/
|
|
10377
|
+
return { isMatch: Boolean(match), match, output };
|
|
10378
|
+
};
|
|
10422
10379
|
|
|
10423
|
-
|
|
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
|
+
};
|
|
10424
10398
|
|
|
10425
|
-
/**
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
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
|
+
};
|
|
10436
10436
|
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
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
|
+
}
|
|
10441
10482
|
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10483
|
+
const opts = options || {};
|
|
10484
|
+
const prepend = opts.contains ? '' : '^';
|
|
10485
|
+
const append = opts.contains ? '' : '$';
|
|
10445
10486
|
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10487
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
10488
|
+
if (state && state.negated === true) {
|
|
10489
|
+
source = `^(?!${source}).*$`;
|
|
10490
|
+
}
|
|
10450
10491
|
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10492
|
+
const regex = picomatch.toRegex(source, options);
|
|
10493
|
+
if (returnState === true) {
|
|
10494
|
+
regex.state = state;
|
|
10495
|
+
}
|
|
10455
10496
|
|
|
10456
|
-
|
|
10457
|
-
};
|
|
10497
|
+
return regex;
|
|
10498
|
+
};
|
|
10458
10499
|
|
|
10459
|
-
/**
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
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
|
+
}
|
|
10477
10523
|
|
|
10478
|
-
|
|
10479
|
-
if (!input || typeof input !== 'string') {
|
|
10480
|
-
throw new TypeError('Expected a non-empty string');
|
|
10481
|
-
}
|
|
10524
|
+
let parsed = { negated: false, fastpaths: true };
|
|
10482
10525
|
|
|
10483
|
-
|
|
10526
|
+
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
10527
|
+
parsed.output = parse.fastpaths(input, options);
|
|
10528
|
+
}
|
|
10484
10529
|
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10530
|
+
if (!parsed.output) {
|
|
10531
|
+
parsed = parse(input, options);
|
|
10532
|
+
}
|
|
10488
10533
|
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
}
|
|
10534
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
10535
|
+
};
|
|
10492
10536
|
|
|
10493
|
-
|
|
10494
|
-
|
|
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
|
+
};
|
|
10495
10563
|
|
|
10496
|
-
/**
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
* const picomatch = require('picomatch');
|
|
10501
|
-
* // picomatch.toRegex(source[, options]);
|
|
10502
|
-
*
|
|
10503
|
-
* const { output } = picomatch.parse('*.js');
|
|
10504
|
-
* console.log(picomatch.toRegex(output));
|
|
10505
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
10506
|
-
* ```
|
|
10507
|
-
* @param {String} `source` Regular expression source string.
|
|
10508
|
-
* @param {Object} `options`
|
|
10509
|
-
* @return {RegExp}
|
|
10510
|
-
* @api public
|
|
10511
|
-
*/
|
|
10564
|
+
/**
|
|
10565
|
+
* Picomatch constants.
|
|
10566
|
+
* @return {Object}
|
|
10567
|
+
*/
|
|
10512
10568
|
|
|
10513
|
-
picomatch
|
|
10514
|
-
try {
|
|
10515
|
-
const opts = options || {};
|
|
10516
|
-
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
10517
|
-
} catch (err) {
|
|
10518
|
-
if (options && options.debug === true) throw err;
|
|
10519
|
-
return /$^/;
|
|
10520
|
-
}
|
|
10521
|
-
};
|
|
10569
|
+
picomatch.constants = constants;
|
|
10522
10570
|
|
|
10523
|
-
/**
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
*/
|
|
10571
|
+
/**
|
|
10572
|
+
* Expose "picomatch"
|
|
10573
|
+
*/
|
|
10527
10574
|
|
|
10528
|
-
|
|
10575
|
+
picomatch_1 = picomatch;
|
|
10576
|
+
return picomatch_1;
|
|
10577
|
+
}
|
|
10529
10578
|
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
*/
|
|
10579
|
+
var picomatch;
|
|
10580
|
+
var hasRequiredPicomatch;
|
|
10533
10581
|
|
|
10534
|
-
|
|
10582
|
+
function requirePicomatch () {
|
|
10583
|
+
if (hasRequiredPicomatch) return picomatch;
|
|
10584
|
+
hasRequiredPicomatch = 1;
|
|
10535
10585
|
|
|
10536
|
-
|
|
10586
|
+
picomatch = /*@__PURE__*/ requirePicomatch$1();
|
|
10587
|
+
return picomatch;
|
|
10588
|
+
}
|
|
10537
10589
|
|
|
10538
|
-
|
|
10590
|
+
var picomatchExports = /*@__PURE__*/ requirePicomatch();
|
|
10591
|
+
const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
|
|
10539
10592
|
|
|
10540
10593
|
const extractors = {
|
|
10541
10594
|
ArrayPattern(names, param) {
|
|
@@ -10584,8 +10637,9 @@ function ensureArray$1(thing) {
|
|
|
10584
10637
|
return [thing];
|
|
10585
10638
|
}
|
|
10586
10639
|
|
|
10640
|
+
const normalizePathRegExp = new RegExp(`\\${win32.sep}`, 'g');
|
|
10587
10641
|
const normalizePath = function normalizePath(filename) {
|
|
10588
|
-
return filename.
|
|
10642
|
+
return filename.replace(normalizePathRegExp, posix.sep);
|
|
10589
10643
|
};
|
|
10590
10644
|
|
|
10591
10645
|
function getMatcherString(id, resolutionBase) {
|
|
@@ -10617,10 +10671,12 @@ const createFilter = function createFilter(include, exclude, options) {
|
|
|
10617
10671
|
};
|
|
10618
10672
|
const includeMatchers = ensureArray$1(include).map(getMatcher);
|
|
10619
10673
|
const excludeMatchers = ensureArray$1(exclude).map(getMatcher);
|
|
10674
|
+
if (!includeMatchers.length && !excludeMatchers.length)
|
|
10675
|
+
return (id) => typeof id === 'string' && !id.includes('\0');
|
|
10620
10676
|
return function result(id) {
|
|
10621
10677
|
if (typeof id !== 'string')
|
|
10622
10678
|
return false;
|
|
10623
|
-
if (
|
|
10679
|
+
if (id.includes('\0'))
|
|
10624
10680
|
return false;
|
|
10625
10681
|
const pathId = normalizePath(id);
|
|
10626
10682
|
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
@@ -19364,10 +19420,25 @@ async function waitForDependencyResolution(loadPromise) {
|
|
|
19364
19420
|
return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]);
|
|
19365
19421
|
}
|
|
19366
19422
|
|
|
19367
|
-
function generateAssetFileName(name, source, originalFileName, sourceHash, outputOptions, bundle) {
|
|
19423
|
+
function generateAssetFileName(name, names, source, originalFileName, originalFileNames, sourceHash, outputOptions, bundle, inputOptions) {
|
|
19368
19424
|
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
19369
19425
|
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
19370
|
-
? outputOptions.assetFileNames({
|
|
19426
|
+
? outputOptions.assetFileNames({
|
|
19427
|
+
// Additionally, this should be non-enumerable in the next major
|
|
19428
|
+
get name() {
|
|
19429
|
+
warnDeprecation('Accessing the "name" property of emitted assets when generating the file name is deprecated. Use the "names" property instead.', URL_GENERATEBUNDLE, false, inputOptions);
|
|
19430
|
+
return name;
|
|
19431
|
+
},
|
|
19432
|
+
names,
|
|
19433
|
+
// Additionally, this should be non-enumerable in the next major
|
|
19434
|
+
get originalFileName() {
|
|
19435
|
+
warnDeprecation('Accessing the "originalFileName" property of emitted assets when generating the file name is deprecated. Use the "originalFileNames" property instead.', URL_GENERATEBUNDLE, false, inputOptions);
|
|
19436
|
+
return originalFileName;
|
|
19437
|
+
},
|
|
19438
|
+
originalFileNames,
|
|
19439
|
+
source,
|
|
19440
|
+
type: 'asset'
|
|
19441
|
+
})
|
|
19371
19442
|
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
19372
19443
|
ext: () => extname(emittedName).slice(1),
|
|
19373
19444
|
extname: () => extname(emittedName),
|
|
@@ -19483,7 +19554,7 @@ class FileEmitter {
|
|
|
19483
19554
|
const getHash = hasherByType[outputOptions.hashCharacters];
|
|
19484
19555
|
const output = (this.output = {
|
|
19485
19556
|
bundle,
|
|
19486
|
-
|
|
19557
|
+
fileNamesBySourceHash: new Map(),
|
|
19487
19558
|
getHash,
|
|
19488
19559
|
outputOptions
|
|
19489
19560
|
});
|
|
@@ -19638,15 +19709,15 @@ class FileEmitter {
|
|
|
19638
19709
|
}
|
|
19639
19710
|
return referenceId;
|
|
19640
19711
|
}
|
|
19641
|
-
finalizeAdditionalAsset(consumedFile, source, { bundle,
|
|
19642
|
-
let { fileName, needsCodeReference, originalFileName, referenceId } = consumedFile;
|
|
19712
|
+
finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySourceHash, getHash, outputOptions }) {
|
|
19713
|
+
let { fileName, name, needsCodeReference, originalFileName, referenceId } = consumedFile;
|
|
19643
19714
|
// Deduplicate assets if an explicit fileName is not provided
|
|
19644
19715
|
if (!fileName) {
|
|
19645
19716
|
const sourceHash = getHash(source);
|
|
19646
|
-
fileName =
|
|
19717
|
+
fileName = fileNamesBySourceHash.get(sourceHash);
|
|
19647
19718
|
if (!fileName) {
|
|
19648
|
-
fileName = generateAssetFileName(
|
|
19649
|
-
|
|
19719
|
+
fileName = generateAssetFileName(name, name ? [name] : [], source, originalFileName, originalFileName ? [originalFileName] : [], sourceHash, outputOptions, bundle, this.options);
|
|
19720
|
+
fileNamesBySourceHash.set(sourceHash, fileName);
|
|
19650
19721
|
}
|
|
19651
19722
|
}
|
|
19652
19723
|
// We must not modify the original assets to avoid interaction between outputs
|
|
@@ -19655,25 +19726,43 @@ class FileEmitter {
|
|
|
19655
19726
|
const existingAsset = bundle[fileName];
|
|
19656
19727
|
if (existingAsset?.type === 'asset') {
|
|
19657
19728
|
existingAsset.needsCodeReference &&= needsCodeReference;
|
|
19729
|
+
if (name) {
|
|
19730
|
+
existingAsset.names.push(name);
|
|
19731
|
+
}
|
|
19732
|
+
if (originalFileName) {
|
|
19733
|
+
existingAsset.originalFileNames.push(originalFileName);
|
|
19734
|
+
}
|
|
19658
19735
|
}
|
|
19659
19736
|
else {
|
|
19737
|
+
const { options } = this;
|
|
19660
19738
|
bundle[fileName] = {
|
|
19661
19739
|
fileName,
|
|
19662
|
-
name
|
|
19740
|
+
get name() {
|
|
19741
|
+
// Additionally, this should be non-enumerable in the next major
|
|
19742
|
+
warnDeprecation('Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', URL_GENERATEBUNDLE, false, options);
|
|
19743
|
+
return name;
|
|
19744
|
+
},
|
|
19745
|
+
names: name ? [name] : [],
|
|
19663
19746
|
needsCodeReference,
|
|
19664
|
-
originalFileName
|
|
19747
|
+
get originalFileName() {
|
|
19748
|
+
// Additionally, this should be non-enumerable in the next major
|
|
19749
|
+
warnDeprecation('Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', URL_GENERATEBUNDLE, false, options);
|
|
19750
|
+
return originalFileName;
|
|
19751
|
+
},
|
|
19752
|
+
originalFileNames: originalFileName ? [originalFileName] : [],
|
|
19665
19753
|
source,
|
|
19666
19754
|
type: 'asset'
|
|
19667
19755
|
};
|
|
19668
19756
|
}
|
|
19669
19757
|
}
|
|
19670
|
-
finalizeAssetsWithSameSource(consumedFiles, sourceHash, { bundle,
|
|
19758
|
+
finalizeAssetsWithSameSource(consumedFiles, sourceHash, { bundle, fileNamesBySourceHash, outputOptions }) {
|
|
19759
|
+
const { names, originalFileNames } = getNamesFromAssets(consumedFiles);
|
|
19671
19760
|
let fileName = '';
|
|
19672
19761
|
let usedConsumedFile;
|
|
19673
19762
|
let needsCodeReference = true;
|
|
19674
19763
|
for (const consumedFile of consumedFiles) {
|
|
19675
19764
|
needsCodeReference &&= consumedFile.needsCodeReference;
|
|
19676
|
-
const assetFileName = generateAssetFileName(consumedFile.name, consumedFile.source, consumedFile.originalFileName, sourceHash, outputOptions, bundle);
|
|
19765
|
+
const assetFileName = generateAssetFileName(consumedFile.name, names, consumedFile.source, consumedFile.originalFileName, originalFileNames, sourceHash, outputOptions, bundle, this.options);
|
|
19677
19766
|
if (!fileName ||
|
|
19678
19767
|
assetFileName.length < fileName.length ||
|
|
19679
19768
|
(assetFileName.length === fileName.length && assetFileName < fileName)) {
|
|
@@ -19681,22 +19770,50 @@ class FileEmitter {
|
|
|
19681
19770
|
usedConsumedFile = consumedFile;
|
|
19682
19771
|
}
|
|
19683
19772
|
}
|
|
19684
|
-
|
|
19773
|
+
fileNamesBySourceHash.set(sourceHash, fileName);
|
|
19685
19774
|
for (const consumedFile of consumedFiles) {
|
|
19686
19775
|
// We must not modify the original assets to avoid interaction between outputs
|
|
19687
19776
|
const assetWithFileName = { ...consumedFile, fileName };
|
|
19688
19777
|
this.filesByReferenceId.set(consumedFile.referenceId, assetWithFileName);
|
|
19689
19778
|
}
|
|
19779
|
+
const { options } = this;
|
|
19690
19780
|
bundle[fileName] = {
|
|
19691
19781
|
fileName,
|
|
19692
|
-
name
|
|
19782
|
+
get name() {
|
|
19783
|
+
// Additionally, this should be non-enumerable in the next major
|
|
19784
|
+
warnDeprecation('Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', URL_GENERATEBUNDLE, false, options);
|
|
19785
|
+
return usedConsumedFile.name;
|
|
19786
|
+
},
|
|
19787
|
+
names,
|
|
19693
19788
|
needsCodeReference,
|
|
19694
|
-
originalFileName
|
|
19789
|
+
get originalFileName() {
|
|
19790
|
+
// Additionally, this should be non-enumerable in the next major
|
|
19791
|
+
warnDeprecation('Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', URL_GENERATEBUNDLE, false, options);
|
|
19792
|
+
return usedConsumedFile.originalFileName;
|
|
19793
|
+
},
|
|
19794
|
+
originalFileNames,
|
|
19695
19795
|
source: usedConsumedFile.source,
|
|
19696
19796
|
type: 'asset'
|
|
19697
19797
|
};
|
|
19698
19798
|
}
|
|
19699
19799
|
}
|
|
19800
|
+
function getNamesFromAssets(consumedFiles) {
|
|
19801
|
+
const names = [];
|
|
19802
|
+
const originalFileNames = [];
|
|
19803
|
+
for (const { name, originalFileName } of consumedFiles) {
|
|
19804
|
+
if (typeof name === 'string') {
|
|
19805
|
+
names.push(name);
|
|
19806
|
+
}
|
|
19807
|
+
if (originalFileName) {
|
|
19808
|
+
originalFileNames.push(originalFileName);
|
|
19809
|
+
}
|
|
19810
|
+
}
|
|
19811
|
+
originalFileNames.sort();
|
|
19812
|
+
// Sort by length first and then alphabetically so that the order is stable
|
|
19813
|
+
// and the shortest names come first
|
|
19814
|
+
names.sort((a, b) => a.length - b.length || (a > b ? 1 : a === b ? 0 : -1));
|
|
19815
|
+
return { names, originalFileNames };
|
|
19816
|
+
}
|
|
19700
19817
|
|
|
19701
19818
|
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
19702
19819
|
if (logLevelPriority[level] < logLevelPriority[logLevel]) {
|
|
@@ -21347,4 +21464,4 @@ async function watchInternal(configs, emitter) {
|
|
|
21347
21464
|
new Watcher(watchOptionsList, emitter);
|
|
21348
21465
|
}
|
|
21349
21466
|
|
|
21350
|
-
export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace,
|
|
21467
|
+
export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, version, watch };
|