vite-plugin-sitemap 0.4.2 → 0.5.1

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/index.mjs CHANGED
@@ -10,8 +10,8 @@ import require$$1$1 from 'string_decoder';
10
10
  import require$$1$2 from 'zlib';
11
11
  import require$$0$3 from 'util';
12
12
  import { isAbsolute, resolve, parse as parse$4, join } from 'node:path';
13
- import require$$2$1 from 'os';
14
- import require$$0$4 from 'events';
13
+ import require$$0$4 from 'os';
14
+ import require$$0$5 from 'events';
15
15
 
16
16
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17
17
 
@@ -1452,6 +1452,7 @@ var sax = {};
1452
1452
  } catch (ex) {
1453
1453
  Stream = function () {};
1454
1454
  }
1455
+ if (!Stream) Stream = function () {};
1455
1456
 
1456
1457
  var streamWraps = sax.EVENTS.filter(function (ev) {
1457
1458
  return ev !== 'error' && ev !== 'end'
@@ -2768,9 +2769,16 @@ var sax = {};
2768
2769
  }
2769
2770
 
2770
2771
  if (c === ';') {
2771
- parser[buffer] += parseEntity(parser);
2772
- parser.entity = '';
2773
- parser.state = returnState;
2772
+ if (parser.opt.unparsedEntities) {
2773
+ var parsedEntity = parseEntity(parser);
2774
+ parser.entity = '';
2775
+ parser.state = returnState;
2776
+ parser.write(parsedEntity);
2777
+ } else {
2778
+ parser[buffer] += parseEntity(parser);
2779
+ parser.entity = '';
2780
+ parser.state = returnState;
2781
+ }
2774
2782
  } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
2775
2783
  parser.entity += c;
2776
2784
  } else {
@@ -2782,8 +2790,9 @@ var sax = {};
2782
2790
 
2783
2791
  continue
2784
2792
 
2785
- default:
2793
+ default: /* istanbul ignore next */ {
2786
2794
  throw new Error(parser, 'Unknown state: ' + parser.state)
2795
+ }
2787
2796
  }
2788
2797
  } // while
2789
2798
 
@@ -3699,8 +3708,6 @@ var cjs$1 = {exports: {}};
3699
3708
 
3700
3709
  var cjs = {exports: {}};
3701
3710
 
3702
- cjs.exports;
3703
-
3704
3711
  (function (module, exports) {
3705
3712
  Object.defineProperty(exports, "__esModule", { value: true });
3706
3713
  exports.ParsingError = void 0;
@@ -3814,14 +3821,28 @@ cjs.exports;
3814
3821
  child = nextChild();
3815
3822
  }
3816
3823
  // closing
3817
- match(/^<\/\s*[\w-:.\u00C0-\u00FF]+>/);
3824
+ if (parsingState.options.strictMode) {
3825
+ const closingTag = `</${node.name}>`;
3826
+ if (parsingState.xml.startsWith(closingTag)) {
3827
+ parsingState.xml = parsingState.xml.slice(closingTag.length);
3828
+ }
3829
+ else {
3830
+ throw new ParsingError('Failed to parse XML', `Closing tag not matching "${closingTag}"`);
3831
+ }
3832
+ }
3833
+ else {
3834
+ match(/^<\/\s*[\w-:.\u00C0-\u00FF]+>/);
3835
+ }
3818
3836
  return {
3819
3837
  excluded,
3820
3838
  node
3821
3839
  };
3822
3840
  }
3823
3841
  function doctype() {
3824
- const m = match(/^<!DOCTYPE\s+[^>]*>/);
3842
+ const m = match(/^<!DOCTYPE\s+\S+\s+SYSTEM[^>]*>/) ||
3843
+ match(/^<!DOCTYPE\s+\S+\s+PUBLIC[^>]*>/) ||
3844
+ match(/^<!DOCTYPE\s+\S+\s*\[[^\]]*]>/) ||
3845
+ match(/^<!DOCTYPE\s+\S+\s*>/);
3825
3846
  if (m) {
3826
3847
  const node = {
3827
3848
  type: 'DocumentType',
@@ -3918,7 +3939,7 @@ cjs.exports;
3918
3939
  const filter = options.filter || (() => true);
3919
3940
  parsingState = {
3920
3941
  xml,
3921
- options: Object.assign(Object.assign({}, options), { filter })
3942
+ options: Object.assign(Object.assign({}, options), { filter, strictMode: options.strictMode === true })
3922
3943
  };
3923
3944
  return parseDocument();
3924
3945
  }
@@ -3931,8 +3952,6 @@ cjs.exports;
3931
3952
 
3932
3953
  var cjsExports$1 = cjs.exports;
3933
3954
 
3934
- cjs$1.exports;
3935
-
3936
3955
  (function (module, exports) {
3937
3956
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
3938
3957
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -3948,6 +3967,13 @@ cjs$1.exports;
3948
3967
  state.content += state.options.indentation;
3949
3968
  }
3950
3969
  }
3970
+ function indent(state) {
3971
+ state.content = state.content.replace(/ +$/, '');
3972
+ let i;
3973
+ for (i = 0; i < state.level; i++) {
3974
+ state.content += state.options.indentation;
3975
+ }
3976
+ }
3951
3977
  function appendContent(state, content) {
3952
3978
  state.content += content;
3953
3979
  }
@@ -3982,13 +4008,19 @@ cjs$1.exports;
3982
4008
  appendContent(state, content);
3983
4009
  }
3984
4010
  }
4011
+ function isPathMatchingIgnoredPaths(path, ignoredPaths) {
4012
+ const fullPath = '/' + path.join('/');
4013
+ const pathLastPart = path[path.length - 1];
4014
+ return ignoredPaths.includes(pathLastPart) || ignoredPaths.includes(fullPath);
4015
+ }
3985
4016
  function processElementNode(node, state, preserveSpace) {
4017
+ state.path.push(node.name);
3986
4018
  if (!preserveSpace && state.content.length > 0) {
3987
4019
  newLine(state);
3988
4020
  }
3989
4021
  appendContent(state, '<' + node.name);
3990
4022
  processAttributes(state, node.attributes);
3991
- if (node.children === null) {
4023
+ if (node.children === null || (state.options.forceSelfClosingEmptyTag && node.children.length === 0)) {
3992
4024
  const selfClosingNodeClosingTag = state.options.whiteSpaceAtEndOfSelfclosingTag ? ' />' : '/>';
3993
4025
  // self-closing node
3994
4026
  appendContent(state, selfClosingNodeClosingTag);
@@ -4002,6 +4034,11 @@ cjs$1.exports;
4002
4034
  appendContent(state, '>');
4003
4035
  state.level++;
4004
4036
  let nodePreserveSpace = node.attributes['xml:space'] === 'preserve';
4037
+ let ignoredPath = false;
4038
+ if (!nodePreserveSpace && state.options.ignoredPaths) {
4039
+ ignoredPath = isPathMatchingIgnoredPaths(state.path, state.options.ignoredPaths);
4040
+ nodePreserveSpace = ignoredPath;
4041
+ }
4005
4042
  if (!nodePreserveSpace && state.options.collapseContent) {
4006
4043
  let containsTextNodes = false;
4007
4044
  let containsTextNodesWithLineBreaks = false;
@@ -4040,8 +4077,12 @@ cjs$1.exports;
4040
4077
  if (!preserveSpace && !nodePreserveSpace) {
4041
4078
  newLine(state);
4042
4079
  }
4080
+ if (ignoredPath) {
4081
+ indent(state);
4082
+ }
4043
4083
  appendContent(state, '</' + node.name + '>');
4044
4084
  }
4085
+ state.path.pop();
4045
4086
  }
4046
4087
  function processAttributes(state, attributes) {
4047
4088
  Object.keys(attributes).forEach(function (attr) {
@@ -4067,8 +4108,8 @@ cjs$1.exports;
4067
4108
  options.whiteSpaceAtEndOfSelfclosingTag = options.whiteSpaceAtEndOfSelfclosingTag === true;
4068
4109
  options.throwOnFailure = options.throwOnFailure !== false;
4069
4110
  try {
4070
- const parsedXml = (0, xml_parser_xo_1.default)(xml, { filter: options.filter });
4071
- const state = { content: '', level: 0, options: options };
4111
+ const parsedXml = (0, xml_parser_xo_1.default)(xml, { filter: options.filter, strictMode: options.strictMode });
4112
+ const state = { content: '', level: 0, options: options, path: [] };
4072
4113
  if (parsedXml.declaration) {
4073
4114
  processProcessingIntruction(parsedXml.declaration, state);
4074
4115
  }
@@ -4122,92 +4163,127 @@ var utils$k = {};
4122
4163
 
4123
4164
  var array$1 = {};
4124
4165
 
4125
- Object.defineProperty(array$1, "__esModule", { value: true });
4126
- array$1.splitWhen = array$1.flatten = void 0;
4127
- function flatten(items) {
4128
- return items.reduce((collection, item) => [].concat(collection, item), []);
4129
- }
4130
- array$1.flatten = flatten;
4131
- function splitWhen(items, predicate) {
4132
- const result = [[]];
4133
- let groupIndex = 0;
4134
- for (const item of items) {
4135
- if (predicate(item)) {
4136
- groupIndex++;
4137
- result[groupIndex] = [];
4138
- }
4139
- else {
4140
- result[groupIndex].push(item);
4141
- }
4142
- }
4143
- return result;
4144
- }
4166
+ Object.defineProperty(array$1, "__esModule", { value: true });
4167
+ array$1.splitWhen = array$1.flatten = void 0;
4168
+ function flatten(items) {
4169
+ return items.reduce((collection, item) => [].concat(collection, item), []);
4170
+ }
4171
+ array$1.flatten = flatten;
4172
+ function splitWhen(items, predicate) {
4173
+ const result = [[]];
4174
+ let groupIndex = 0;
4175
+ for (const item of items) {
4176
+ if (predicate(item)) {
4177
+ groupIndex++;
4178
+ result[groupIndex] = [];
4179
+ }
4180
+ else {
4181
+ result[groupIndex].push(item);
4182
+ }
4183
+ }
4184
+ return result;
4185
+ }
4145
4186
  array$1.splitWhen = splitWhen;
4146
4187
 
4147
4188
  var errno$1 = {};
4148
4189
 
4149
- Object.defineProperty(errno$1, "__esModule", { value: true });
4150
- errno$1.isEnoentCodeError = void 0;
4151
- function isEnoentCodeError(error) {
4152
- return error.code === 'ENOENT';
4153
- }
4190
+ Object.defineProperty(errno$1, "__esModule", { value: true });
4191
+ errno$1.isEnoentCodeError = void 0;
4192
+ function isEnoentCodeError(error) {
4193
+ return error.code === 'ENOENT';
4194
+ }
4154
4195
  errno$1.isEnoentCodeError = isEnoentCodeError;
4155
4196
 
4156
4197
  var fs$7 = {};
4157
4198
 
4158
- Object.defineProperty(fs$7, "__esModule", { value: true });
4159
- fs$7.createDirentFromStats = void 0;
4160
- class DirentFromStats$1 {
4161
- constructor(name, stats) {
4162
- this.name = name;
4163
- this.isBlockDevice = stats.isBlockDevice.bind(stats);
4164
- this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
4165
- this.isDirectory = stats.isDirectory.bind(stats);
4166
- this.isFIFO = stats.isFIFO.bind(stats);
4167
- this.isFile = stats.isFile.bind(stats);
4168
- this.isSocket = stats.isSocket.bind(stats);
4169
- this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
4170
- }
4171
- }
4172
- function createDirentFromStats$1(name, stats) {
4173
- return new DirentFromStats$1(name, stats);
4174
- }
4199
+ Object.defineProperty(fs$7, "__esModule", { value: true });
4200
+ fs$7.createDirentFromStats = void 0;
4201
+ let DirentFromStats$1 = class DirentFromStats {
4202
+ constructor(name, stats) {
4203
+ this.name = name;
4204
+ this.isBlockDevice = stats.isBlockDevice.bind(stats);
4205
+ this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
4206
+ this.isDirectory = stats.isDirectory.bind(stats);
4207
+ this.isFIFO = stats.isFIFO.bind(stats);
4208
+ this.isFile = stats.isFile.bind(stats);
4209
+ this.isSocket = stats.isSocket.bind(stats);
4210
+ this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
4211
+ }
4212
+ };
4213
+ function createDirentFromStats$1(name, stats) {
4214
+ return new DirentFromStats$1(name, stats);
4215
+ }
4175
4216
  fs$7.createDirentFromStats = createDirentFromStats$1;
4176
4217
 
4177
4218
  var path$9 = {};
4178
4219
 
4179
- Object.defineProperty(path$9, "__esModule", { value: true });
4180
- path$9.removeLeadingDotSegment = path$9.escape = path$9.makeAbsolute = path$9.unixify = void 0;
4181
- const path$8 = require$$0$2;
4182
- const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
4183
- const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
4184
- /**
4185
- * Designed to work only with simple paths: `dir\\file`.
4186
- */
4187
- function unixify(filepath) {
4188
- return filepath.replace(/\\/g, '/');
4189
- }
4190
- path$9.unixify = unixify;
4191
- function makeAbsolute(cwd, filepath) {
4192
- return path$8.resolve(cwd, filepath);
4193
- }
4194
- path$9.makeAbsolute = makeAbsolute;
4195
- function escape(pattern) {
4196
- return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
4197
- }
4198
- path$9.escape = escape;
4199
- function removeLeadingDotSegment(entry) {
4200
- // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
4201
- // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
4202
- if (entry.charAt(0) === '.') {
4203
- const secondCharactery = entry.charAt(1);
4204
- if (secondCharactery === '/' || secondCharactery === '\\') {
4205
- return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
4206
- }
4207
- }
4208
- return entry;
4209
- }
4220
+ Object.defineProperty(path$9, "__esModule", { value: true });
4221
+ path$9.convertPosixPathToPattern = path$9.convertWindowsPathToPattern = path$9.convertPathToPattern = path$9.escapePosixPath = path$9.escapeWindowsPath = path$9.escape = path$9.removeLeadingDotSegment = path$9.makeAbsolute = path$9.unixify = void 0;
4222
+ const os = require$$0$4;
4223
+ const path$8 = require$$0$2;
4224
+ const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
4225
+ const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
4226
+ /**
4227
+ * All non-escaped special characters.
4228
+ * Posix: ()*?[\]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
4229
+ * Windows: (){}, !+@ before (, ! at the beginning.
4230
+ */
4231
+ const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
4232
+ const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g;
4233
+ /**
4234
+ * The device path (\\.\ or \\?\).
4235
+ * https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
4236
+ */
4237
+ const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
4238
+ /**
4239
+ * All backslashes except those escaping special characters.
4240
+ * Windows: !()+@{}
4241
+ * https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
4242
+ */
4243
+ const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
4244
+ /**
4245
+ * Designed to work only with simple paths: `dir\\file`.
4246
+ */
4247
+ function unixify(filepath) {
4248
+ return filepath.replace(/\\/g, '/');
4249
+ }
4250
+ path$9.unixify = unixify;
4251
+ function makeAbsolute(cwd, filepath) {
4252
+ return path$8.resolve(cwd, filepath);
4253
+ }
4254
+ path$9.makeAbsolute = makeAbsolute;
4255
+ function removeLeadingDotSegment(entry) {
4256
+ // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
4257
+ // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
4258
+ if (entry.charAt(0) === '.') {
4259
+ const secondCharactery = entry.charAt(1);
4260
+ if (secondCharactery === '/' || secondCharactery === '\\') {
4261
+ return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
4262
+ }
4263
+ }
4264
+ return entry;
4265
+ }
4210
4266
  path$9.removeLeadingDotSegment = removeLeadingDotSegment;
4267
+ path$9.escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath;
4268
+ function escapeWindowsPath(pattern) {
4269
+ return pattern.replace(WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
4270
+ }
4271
+ path$9.escapeWindowsPath = escapeWindowsPath;
4272
+ function escapePosixPath(pattern) {
4273
+ return pattern.replace(POSIX_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
4274
+ }
4275
+ path$9.escapePosixPath = escapePosixPath;
4276
+ path$9.convertPathToPattern = IS_WINDOWS_PLATFORM ? convertWindowsPathToPattern : convertPosixPathToPattern;
4277
+ function convertWindowsPathToPattern(filepath) {
4278
+ return escapeWindowsPath(filepath)
4279
+ .replace(DOS_DEVICE_PATH_RE, '//$1')
4280
+ .replace(WINDOWS_BACKSLASHES_RE, '/');
4281
+ }
4282
+ path$9.convertWindowsPathToPattern = convertWindowsPathToPattern;
4283
+ function convertPosixPathToPattern(filepath) {
4284
+ return escapePosixPath(filepath);
4285
+ }
4286
+ path$9.convertPosixPathToPattern = convertPosixPathToPattern;
4211
4287
 
4212
4288
  var pattern$1 = {};
4213
4289
 
@@ -4385,7 +4461,7 @@ var isGlob$1 = function isGlob(str, options) {
4385
4461
 
4386
4462
  var isGlob = isGlob$1;
4387
4463
  var pathPosixDirname = require$$0$2.posix.dirname;
4388
- var isWin32 = require$$2$1.platform() === 'win32';
4464
+ var isWin32 = require$$0$4.platform() === 'win32';
4389
4465
 
4390
4466
  var slash = '/';
4391
4467
  var backslash = /\\/g;
@@ -4886,7 +4962,7 @@ const toRegexRange = toRegexRange_1;
4886
4962
 
4887
4963
  const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
4888
4964
 
4889
- const transform$1 = toNumber => {
4965
+ const transform = toNumber => {
4890
4966
  return value => toNumber === true ? Number(value) : String(value);
4891
4967
  };
4892
4968
 
@@ -5023,7 +5099,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
5023
5099
  let padded = zeros(startString) || zeros(endString) || zeros(stepString);
5024
5100
  let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
5025
5101
  let toNumber = padded === false && stringify$3(start, end, options) === false;
5026
- let format = options.transform || transform$1(toNumber);
5102
+ let format = options.transform || transform(toNumber);
5027
5103
 
5028
5104
  if (options.toRegex && step === 1) {
5029
5105
  return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
@@ -8379,174 +8455,193 @@ micromatch$1.braceExpand = (pattern, options) => {
8379
8455
 
8380
8456
  var micromatch_1 = micromatch$1;
8381
8457
 
8382
- Object.defineProperty(pattern$1, "__esModule", { value: true });
8383
- pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
8384
- const path$5 = require$$0$2;
8385
- const globParent = globParent$1;
8386
- const micromatch = micromatch_1;
8387
- const GLOBSTAR = '**';
8388
- const ESCAPE_SYMBOL = '\\';
8389
- const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
8390
- const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
8391
- const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
8392
- const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
8393
- const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
8394
- function isStaticPattern(pattern, options = {}) {
8395
- return !isDynamicPattern(pattern, options);
8396
- }
8397
- pattern$1.isStaticPattern = isStaticPattern;
8398
- function isDynamicPattern(pattern, options = {}) {
8399
- /**
8400
- * A special case with an empty string is necessary for matching patterns that start with a forward slash.
8401
- * An empty string cannot be a dynamic pattern.
8402
- * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
8403
- */
8404
- if (pattern === '') {
8405
- return false;
8406
- }
8407
- /**
8408
- * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
8409
- * filepath directly (without read directory).
8410
- */
8411
- if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
8412
- return true;
8413
- }
8414
- if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
8415
- return true;
8416
- }
8417
- if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
8418
- return true;
8419
- }
8420
- if (options.braceExpansion !== false && hasBraceExpansion(pattern)) {
8421
- return true;
8422
- }
8423
- return false;
8424
- }
8425
- pattern$1.isDynamicPattern = isDynamicPattern;
8426
- function hasBraceExpansion(pattern) {
8427
- const openingBraceIndex = pattern.indexOf('{');
8428
- if (openingBraceIndex === -1) {
8429
- return false;
8430
- }
8431
- const closingBraceIndex = pattern.indexOf('}', openingBraceIndex + 1);
8432
- if (closingBraceIndex === -1) {
8433
- return false;
8434
- }
8435
- const braceContent = pattern.slice(openingBraceIndex, closingBraceIndex);
8436
- return BRACE_EXPANSION_SEPARATORS_RE.test(braceContent);
8437
- }
8438
- function convertToPositivePattern(pattern) {
8439
- return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
8440
- }
8441
- pattern$1.convertToPositivePattern = convertToPositivePattern;
8442
- function convertToNegativePattern(pattern) {
8443
- return '!' + pattern;
8444
- }
8445
- pattern$1.convertToNegativePattern = convertToNegativePattern;
8446
- function isNegativePattern(pattern) {
8447
- return pattern.startsWith('!') && pattern[1] !== '(';
8448
- }
8449
- pattern$1.isNegativePattern = isNegativePattern;
8450
- function isPositivePattern(pattern) {
8451
- return !isNegativePattern(pattern);
8452
- }
8453
- pattern$1.isPositivePattern = isPositivePattern;
8454
- function getNegativePatterns(patterns) {
8455
- return patterns.filter(isNegativePattern);
8456
- }
8457
- pattern$1.getNegativePatterns = getNegativePatterns;
8458
- function getPositivePatterns$1(patterns) {
8459
- return patterns.filter(isPositivePattern);
8460
- }
8461
- pattern$1.getPositivePatterns = getPositivePatterns$1;
8462
- /**
8463
- * Returns patterns that can be applied inside the current directory.
8464
- *
8465
- * @example
8466
- * // ['./*', '*', 'a/*']
8467
- * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
8468
- */
8469
- function getPatternsInsideCurrentDirectory(patterns) {
8470
- return patterns.filter((pattern) => !isPatternRelatedToParentDirectory(pattern));
8471
- }
8472
- pattern$1.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
8473
- /**
8474
- * Returns patterns to be expanded relative to (outside) the current directory.
8475
- *
8476
- * @example
8477
- * // ['../*', './../*']
8478
- * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
8479
- */
8480
- function getPatternsOutsideCurrentDirectory(patterns) {
8481
- return patterns.filter(isPatternRelatedToParentDirectory);
8482
- }
8483
- pattern$1.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
8484
- function isPatternRelatedToParentDirectory(pattern) {
8485
- return pattern.startsWith('..') || pattern.startsWith('./..');
8486
- }
8487
- pattern$1.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
8488
- function getBaseDirectory(pattern) {
8489
- return globParent(pattern, { flipBackslashes: false });
8490
- }
8491
- pattern$1.getBaseDirectory = getBaseDirectory;
8492
- function hasGlobStar(pattern) {
8493
- return pattern.includes(GLOBSTAR);
8494
- }
8495
- pattern$1.hasGlobStar = hasGlobStar;
8496
- function endsWithSlashGlobStar(pattern) {
8497
- return pattern.endsWith('/' + GLOBSTAR);
8498
- }
8499
- pattern$1.endsWithSlashGlobStar = endsWithSlashGlobStar;
8500
- function isAffectDepthOfReadingPattern(pattern) {
8501
- const basename = path$5.basename(pattern);
8502
- return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
8503
- }
8504
- pattern$1.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
8505
- function expandPatternsWithBraceExpansion(patterns) {
8506
- return patterns.reduce((collection, pattern) => {
8507
- return collection.concat(expandBraceExpansion(pattern));
8508
- }, []);
8509
- }
8510
- pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
8511
- function expandBraceExpansion(pattern) {
8512
- return micromatch.braces(pattern, {
8513
- expand: true,
8514
- nodupes: true
8515
- });
8516
- }
8517
- pattern$1.expandBraceExpansion = expandBraceExpansion;
8518
- function getPatternParts(pattern, options) {
8519
- let { parts } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true }));
8520
- /**
8521
- * The scan method returns an empty array in some cases.
8522
- * See micromatch/picomatch#58 for more details.
8523
- */
8524
- if (parts.length === 0) {
8525
- parts = [pattern];
8526
- }
8527
- /**
8528
- * The scan method does not return an empty part for the pattern with a forward slash.
8529
- * This is another part of micromatch/picomatch#58.
8530
- */
8531
- if (parts[0].startsWith('/')) {
8532
- parts[0] = parts[0].slice(1);
8533
- parts.unshift('');
8534
- }
8535
- return parts;
8536
- }
8537
- pattern$1.getPatternParts = getPatternParts;
8538
- function makeRe(pattern, options) {
8539
- return micromatch.makeRe(pattern, options);
8540
- }
8541
- pattern$1.makeRe = makeRe;
8542
- function convertPatternsToRe(patterns, options) {
8543
- return patterns.map((pattern) => makeRe(pattern, options));
8544
- }
8545
- pattern$1.convertPatternsToRe = convertPatternsToRe;
8546
- function matchAny(entry, patternsRe) {
8547
- return patternsRe.some((patternRe) => patternRe.test(entry));
8548
- }
8458
+ Object.defineProperty(pattern$1, "__esModule", { value: true });
8459
+ pattern$1.removeDuplicateSlashes = pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
8460
+ const path$5 = require$$0$2;
8461
+ const globParent = globParent$1;
8462
+ const micromatch = micromatch_1;
8463
+ const GLOBSTAR = '**';
8464
+ const ESCAPE_SYMBOL = '\\';
8465
+ const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
8466
+ const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
8467
+ const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
8468
+ const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
8469
+ const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
8470
+ /**
8471
+ * Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
8472
+ * The latter is due to the presence of the device path at the beginning of the UNC path.
8473
+ */
8474
+ const DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
8475
+ function isStaticPattern(pattern, options = {}) {
8476
+ return !isDynamicPattern(pattern, options);
8477
+ }
8478
+ pattern$1.isStaticPattern = isStaticPattern;
8479
+ function isDynamicPattern(pattern, options = {}) {
8480
+ /**
8481
+ * A special case with an empty string is necessary for matching patterns that start with a forward slash.
8482
+ * An empty string cannot be a dynamic pattern.
8483
+ * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
8484
+ */
8485
+ if (pattern === '') {
8486
+ return false;
8487
+ }
8488
+ /**
8489
+ * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
8490
+ * filepath directly (without read directory).
8491
+ */
8492
+ if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
8493
+ return true;
8494
+ }
8495
+ if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
8496
+ return true;
8497
+ }
8498
+ if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
8499
+ return true;
8500
+ }
8501
+ if (options.braceExpansion !== false && hasBraceExpansion(pattern)) {
8502
+ return true;
8503
+ }
8504
+ return false;
8505
+ }
8506
+ pattern$1.isDynamicPattern = isDynamicPattern;
8507
+ function hasBraceExpansion(pattern) {
8508
+ const openingBraceIndex = pattern.indexOf('{');
8509
+ if (openingBraceIndex === -1) {
8510
+ return false;
8511
+ }
8512
+ const closingBraceIndex = pattern.indexOf('}', openingBraceIndex + 1);
8513
+ if (closingBraceIndex === -1) {
8514
+ return false;
8515
+ }
8516
+ const braceContent = pattern.slice(openingBraceIndex, closingBraceIndex);
8517
+ return BRACE_EXPANSION_SEPARATORS_RE.test(braceContent);
8518
+ }
8519
+ function convertToPositivePattern(pattern) {
8520
+ return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
8521
+ }
8522
+ pattern$1.convertToPositivePattern = convertToPositivePattern;
8523
+ function convertToNegativePattern(pattern) {
8524
+ return '!' + pattern;
8525
+ }
8526
+ pattern$1.convertToNegativePattern = convertToNegativePattern;
8527
+ function isNegativePattern(pattern) {
8528
+ return pattern.startsWith('!') && pattern[1] !== '(';
8529
+ }
8530
+ pattern$1.isNegativePattern = isNegativePattern;
8531
+ function isPositivePattern(pattern) {
8532
+ return !isNegativePattern(pattern);
8533
+ }
8534
+ pattern$1.isPositivePattern = isPositivePattern;
8535
+ function getNegativePatterns(patterns) {
8536
+ return patterns.filter(isNegativePattern);
8537
+ }
8538
+ pattern$1.getNegativePatterns = getNegativePatterns;
8539
+ function getPositivePatterns$1(patterns) {
8540
+ return patterns.filter(isPositivePattern);
8541
+ }
8542
+ pattern$1.getPositivePatterns = getPositivePatterns$1;
8543
+ /**
8544
+ * Returns patterns that can be applied inside the current directory.
8545
+ *
8546
+ * @example
8547
+ * // ['./*', '*', 'a/*']
8548
+ * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
8549
+ */
8550
+ function getPatternsInsideCurrentDirectory(patterns) {
8551
+ return patterns.filter((pattern) => !isPatternRelatedToParentDirectory(pattern));
8552
+ }
8553
+ pattern$1.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
8554
+ /**
8555
+ * Returns patterns to be expanded relative to (outside) the current directory.
8556
+ *
8557
+ * @example
8558
+ * // ['../*', './../*']
8559
+ * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
8560
+ */
8561
+ function getPatternsOutsideCurrentDirectory(patterns) {
8562
+ return patterns.filter(isPatternRelatedToParentDirectory);
8563
+ }
8564
+ pattern$1.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
8565
+ function isPatternRelatedToParentDirectory(pattern) {
8566
+ return pattern.startsWith('..') || pattern.startsWith('./..');
8567
+ }
8568
+ pattern$1.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
8569
+ function getBaseDirectory(pattern) {
8570
+ return globParent(pattern, { flipBackslashes: false });
8571
+ }
8572
+ pattern$1.getBaseDirectory = getBaseDirectory;
8573
+ function hasGlobStar(pattern) {
8574
+ return pattern.includes(GLOBSTAR);
8575
+ }
8576
+ pattern$1.hasGlobStar = hasGlobStar;
8577
+ function endsWithSlashGlobStar(pattern) {
8578
+ return pattern.endsWith('/' + GLOBSTAR);
8579
+ }
8580
+ pattern$1.endsWithSlashGlobStar = endsWithSlashGlobStar;
8581
+ function isAffectDepthOfReadingPattern(pattern) {
8582
+ const basename = path$5.basename(pattern);
8583
+ return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
8584
+ }
8585
+ pattern$1.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
8586
+ function expandPatternsWithBraceExpansion(patterns) {
8587
+ return patterns.reduce((collection, pattern) => {
8588
+ return collection.concat(expandBraceExpansion(pattern));
8589
+ }, []);
8590
+ }
8591
+ pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
8592
+ function expandBraceExpansion(pattern) {
8593
+ const patterns = micromatch.braces(pattern, { expand: true, nodupes: true });
8594
+ /**
8595
+ * Sort the patterns by length so that the same depth patterns are processed side by side.
8596
+ * `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
8597
+ */
8598
+ patterns.sort((a, b) => a.length - b.length);
8599
+ /**
8600
+ * Micromatch can return an empty string in the case of patterns like `{a,}`.
8601
+ */
8602
+ return patterns.filter((pattern) => pattern !== '');
8603
+ }
8604
+ pattern$1.expandBraceExpansion = expandBraceExpansion;
8605
+ function getPatternParts(pattern, options) {
8606
+ let { parts } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true }));
8607
+ /**
8608
+ * The scan method returns an empty array in some cases.
8609
+ * See micromatch/picomatch#58 for more details.
8610
+ */
8611
+ if (parts.length === 0) {
8612
+ parts = [pattern];
8613
+ }
8614
+ /**
8615
+ * The scan method does not return an empty part for the pattern with a forward slash.
8616
+ * This is another part of micromatch/picomatch#58.
8617
+ */
8618
+ if (parts[0].startsWith('/')) {
8619
+ parts[0] = parts[0].slice(1);
8620
+ parts.unshift('');
8621
+ }
8622
+ return parts;
8623
+ }
8624
+ pattern$1.getPatternParts = getPatternParts;
8625
+ function makeRe(pattern, options) {
8626
+ return micromatch.makeRe(pattern, options);
8627
+ }
8628
+ pattern$1.makeRe = makeRe;
8629
+ function convertPatternsToRe(patterns, options) {
8630
+ return patterns.map((pattern) => makeRe(pattern, options));
8631
+ }
8632
+ pattern$1.convertPatternsToRe = convertPatternsToRe;
8633
+ function matchAny(entry, patternsRe) {
8634
+ return patternsRe.some((patternRe) => patternRe.test(entry));
8635
+ }
8549
8636
  pattern$1.matchAny = matchAny;
8637
+ /**
8638
+ * This package only works with forward slashes as a path separator.
8639
+ * Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
8640
+ */
8641
+ function removeDuplicateSlashes(pattern) {
8642
+ return pattern.replace(DOUBLE_SLASH_RE, '/');
8643
+ }
8644
+ pattern$1.removeDuplicateSlashes = removeDuplicateSlashes;
8550
8645
 
8551
8646
  var stream$4 = {};
8552
8647
 
@@ -8694,156 +8789,163 @@ function pauseStreams (streams, options) {
8694
8789
  return streams
8695
8790
  }
8696
8791
 
8697
- Object.defineProperty(stream$4, "__esModule", { value: true });
8698
- stream$4.merge = void 0;
8699
- const merge2 = merge2_1;
8700
- function merge(streams) {
8701
- const mergedStream = merge2(streams);
8702
- streams.forEach((stream) => {
8703
- stream.once('error', (error) => mergedStream.emit('error', error));
8704
- });
8705
- mergedStream.once('close', () => propagateCloseEventToSources(streams));
8706
- mergedStream.once('end', () => propagateCloseEventToSources(streams));
8707
- return mergedStream;
8708
- }
8709
- stream$4.merge = merge;
8710
- function propagateCloseEventToSources(streams) {
8711
- streams.forEach((stream) => stream.emit('close'));
8792
+ Object.defineProperty(stream$4, "__esModule", { value: true });
8793
+ stream$4.merge = void 0;
8794
+ const merge2 = merge2_1;
8795
+ function merge(streams) {
8796
+ const mergedStream = merge2(streams);
8797
+ streams.forEach((stream) => {
8798
+ stream.once('error', (error) => mergedStream.emit('error', error));
8799
+ });
8800
+ mergedStream.once('close', () => propagateCloseEventToSources(streams));
8801
+ mergedStream.once('end', () => propagateCloseEventToSources(streams));
8802
+ return mergedStream;
8803
+ }
8804
+ stream$4.merge = merge;
8805
+ function propagateCloseEventToSources(streams) {
8806
+ streams.forEach((stream) => stream.emit('close'));
8712
8807
  }
8713
8808
 
8714
8809
  var string$1 = {};
8715
8810
 
8716
- Object.defineProperty(string$1, "__esModule", { value: true });
8717
- string$1.isEmpty = string$1.isString = void 0;
8718
- function isString(input) {
8719
- return typeof input === 'string';
8720
- }
8721
- string$1.isString = isString;
8722
- function isEmpty(input) {
8723
- return input === '';
8724
- }
8811
+ Object.defineProperty(string$1, "__esModule", { value: true });
8812
+ string$1.isEmpty = string$1.isString = void 0;
8813
+ function isString(input) {
8814
+ return typeof input === 'string';
8815
+ }
8816
+ string$1.isString = isString;
8817
+ function isEmpty(input) {
8818
+ return input === '';
8819
+ }
8725
8820
  string$1.isEmpty = isEmpty;
8726
8821
 
8727
- Object.defineProperty(utils$k, "__esModule", { value: true });
8728
- utils$k.string = utils$k.stream = utils$k.pattern = utils$k.path = utils$k.fs = utils$k.errno = utils$k.array = void 0;
8729
- const array = array$1;
8730
- utils$k.array = array;
8731
- const errno = errno$1;
8732
- utils$k.errno = errno;
8733
- const fs$6 = fs$7;
8734
- utils$k.fs = fs$6;
8735
- const path$4 = path$9;
8736
- utils$k.path = path$4;
8737
- const pattern = pattern$1;
8738
- utils$k.pattern = pattern;
8739
- const stream$3 = stream$4;
8740
- utils$k.stream = stream$3;
8741
- const string = string$1;
8822
+ Object.defineProperty(utils$k, "__esModule", { value: true });
8823
+ utils$k.string = utils$k.stream = utils$k.pattern = utils$k.path = utils$k.fs = utils$k.errno = utils$k.array = void 0;
8824
+ const array = array$1;
8825
+ utils$k.array = array;
8826
+ const errno = errno$1;
8827
+ utils$k.errno = errno;
8828
+ const fs$6 = fs$7;
8829
+ utils$k.fs = fs$6;
8830
+ const path$4 = path$9;
8831
+ utils$k.path = path$4;
8832
+ const pattern = pattern$1;
8833
+ utils$k.pattern = pattern;
8834
+ const stream$3 = stream$4;
8835
+ utils$k.stream = stream$3;
8836
+ const string = string$1;
8742
8837
  utils$k.string = string;
8743
8838
 
8744
- Object.defineProperty(tasks, "__esModule", { value: true });
8745
- tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
8746
- const utils$a = utils$k;
8747
- function generate(patterns, settings) {
8748
- const positivePatterns = getPositivePatterns(patterns);
8749
- const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
8750
- const staticPatterns = positivePatterns.filter((pattern) => utils$a.pattern.isStaticPattern(pattern, settings));
8751
- const dynamicPatterns = positivePatterns.filter((pattern) => utils$a.pattern.isDynamicPattern(pattern, settings));
8752
- const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false);
8753
- const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true);
8754
- return staticTasks.concat(dynamicTasks);
8755
- }
8756
- tasks.generate = generate;
8757
- /**
8758
- * Returns tasks grouped by basic pattern directories.
8759
- *
8760
- * Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
8761
- * This is necessary because directory traversal starts at the base directory and goes deeper.
8762
- */
8763
- function convertPatternsToTasks(positive, negative, dynamic) {
8764
- const tasks = [];
8765
- const patternsOutsideCurrentDirectory = utils$a.pattern.getPatternsOutsideCurrentDirectory(positive);
8766
- const patternsInsideCurrentDirectory = utils$a.pattern.getPatternsInsideCurrentDirectory(positive);
8767
- const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
8768
- const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
8769
- tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
8770
- /*
8771
- * For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
8772
- * into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
8773
- */
8774
- if ('.' in insideCurrentDirectoryGroup) {
8775
- tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
8776
- }
8777
- else {
8778
- tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
8779
- }
8780
- return tasks;
8781
- }
8782
- tasks.convertPatternsToTasks = convertPatternsToTasks;
8783
- function getPositivePatterns(patterns) {
8784
- return utils$a.pattern.getPositivePatterns(patterns);
8785
- }
8786
- tasks.getPositivePatterns = getPositivePatterns;
8787
- function getNegativePatternsAsPositive(patterns, ignore) {
8788
- const negative = utils$a.pattern.getNegativePatterns(patterns).concat(ignore);
8789
- const positive = negative.map(utils$a.pattern.convertToPositivePattern);
8790
- return positive;
8791
- }
8792
- tasks.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
8793
- function groupPatternsByBaseDirectory(patterns) {
8794
- const group = {};
8795
- return patterns.reduce((collection, pattern) => {
8796
- const base = utils$a.pattern.getBaseDirectory(pattern);
8797
- if (base in collection) {
8798
- collection[base].push(pattern);
8799
- }
8800
- else {
8801
- collection[base] = [pattern];
8802
- }
8803
- return collection;
8804
- }, group);
8805
- }
8806
- tasks.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
8807
- function convertPatternGroupsToTasks(positive, negative, dynamic) {
8808
- return Object.keys(positive).map((base) => {
8809
- return convertPatternGroupToTask(base, positive[base], negative, dynamic);
8810
- });
8811
- }
8812
- tasks.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
8813
- function convertPatternGroupToTask(base, positive, negative, dynamic) {
8814
- return {
8815
- dynamic,
8816
- positive,
8817
- negative,
8818
- base,
8819
- patterns: [].concat(positive, negative.map(utils$a.pattern.convertToNegativePattern))
8820
- };
8821
- }
8839
+ Object.defineProperty(tasks, "__esModule", { value: true });
8840
+ tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
8841
+ const utils$a = utils$k;
8842
+ function generate(input, settings) {
8843
+ const patterns = processPatterns(input, settings);
8844
+ const ignore = processPatterns(settings.ignore, settings);
8845
+ const positivePatterns = getPositivePatterns(patterns);
8846
+ const negativePatterns = getNegativePatternsAsPositive(patterns, ignore);
8847
+ const staticPatterns = positivePatterns.filter((pattern) => utils$a.pattern.isStaticPattern(pattern, settings));
8848
+ const dynamicPatterns = positivePatterns.filter((pattern) => utils$a.pattern.isDynamicPattern(pattern, settings));
8849
+ const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false);
8850
+ const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true);
8851
+ return staticTasks.concat(dynamicTasks);
8852
+ }
8853
+ tasks.generate = generate;
8854
+ function processPatterns(input, settings) {
8855
+ let patterns = input;
8856
+ /**
8857
+ * The original pattern like `{,*,**,a/*}` can lead to problems checking the depth when matching entry
8858
+ * and some problems with the micromatch package (see fast-glob issues: #365, #394).
8859
+ *
8860
+ * To solve this problem, we expand all patterns containing brace expansion. This can lead to a slight slowdown
8861
+ * in matching in the case of a large set of patterns after expansion.
8862
+ */
8863
+ if (settings.braceExpansion) {
8864
+ patterns = utils$a.pattern.expandPatternsWithBraceExpansion(patterns);
8865
+ }
8866
+ /**
8867
+ * If the `baseNameMatch` option is enabled, we must add globstar to patterns, so that they can be used
8868
+ * at any nesting level.
8869
+ *
8870
+ * We do this here, because otherwise we have to complicate the filtering logic. For example, we need to change
8871
+ * the pattern in the filter before creating a regular expression. There is no need to change the patterns
8872
+ * in the application. Only on the input.
8873
+ */
8874
+ if (settings.baseNameMatch) {
8875
+ patterns = patterns.map((pattern) => pattern.includes('/') ? pattern : `**/${pattern}`);
8876
+ }
8877
+ /**
8878
+ * This method also removes duplicate slashes that may have been in the pattern or formed as a result of expansion.
8879
+ */
8880
+ return patterns.map((pattern) => utils$a.pattern.removeDuplicateSlashes(pattern));
8881
+ }
8882
+ /**
8883
+ * Returns tasks grouped by basic pattern directories.
8884
+ *
8885
+ * Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
8886
+ * This is necessary because directory traversal starts at the base directory and goes deeper.
8887
+ */
8888
+ function convertPatternsToTasks(positive, negative, dynamic) {
8889
+ const tasks = [];
8890
+ const patternsOutsideCurrentDirectory = utils$a.pattern.getPatternsOutsideCurrentDirectory(positive);
8891
+ const patternsInsideCurrentDirectory = utils$a.pattern.getPatternsInsideCurrentDirectory(positive);
8892
+ const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
8893
+ const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
8894
+ tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
8895
+ /*
8896
+ * For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
8897
+ * into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
8898
+ */
8899
+ if ('.' in insideCurrentDirectoryGroup) {
8900
+ tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
8901
+ }
8902
+ else {
8903
+ tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
8904
+ }
8905
+ return tasks;
8906
+ }
8907
+ tasks.convertPatternsToTasks = convertPatternsToTasks;
8908
+ function getPositivePatterns(patterns) {
8909
+ return utils$a.pattern.getPositivePatterns(patterns);
8910
+ }
8911
+ tasks.getPositivePatterns = getPositivePatterns;
8912
+ function getNegativePatternsAsPositive(patterns, ignore) {
8913
+ const negative = utils$a.pattern.getNegativePatterns(patterns).concat(ignore);
8914
+ const positive = negative.map(utils$a.pattern.convertToPositivePattern);
8915
+ return positive;
8916
+ }
8917
+ tasks.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
8918
+ function groupPatternsByBaseDirectory(patterns) {
8919
+ const group = {};
8920
+ return patterns.reduce((collection, pattern) => {
8921
+ const base = utils$a.pattern.getBaseDirectory(pattern);
8922
+ if (base in collection) {
8923
+ collection[base].push(pattern);
8924
+ }
8925
+ else {
8926
+ collection[base] = [pattern];
8927
+ }
8928
+ return collection;
8929
+ }, group);
8930
+ }
8931
+ tasks.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
8932
+ function convertPatternGroupsToTasks(positive, negative, dynamic) {
8933
+ return Object.keys(positive).map((base) => {
8934
+ return convertPatternGroupToTask(base, positive[base], negative, dynamic);
8935
+ });
8936
+ }
8937
+ tasks.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
8938
+ function convertPatternGroupToTask(base, positive, negative, dynamic) {
8939
+ return {
8940
+ dynamic,
8941
+ positive,
8942
+ negative,
8943
+ base,
8944
+ patterns: [].concat(positive, negative.map(utils$a.pattern.convertToNegativePattern))
8945
+ };
8946
+ }
8822
8947
  tasks.convertPatternGroupToTask = convertPatternGroupToTask;
8823
8948
 
8824
- var patterns = {};
8825
-
8826
- Object.defineProperty(patterns, "__esModule", { value: true });
8827
- patterns.removeDuplicateSlashes = patterns.transform = void 0;
8828
- /**
8829
- * Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
8830
- * The latter is due to the presence of the device path at the beginning of the UNC path.
8831
- * @todo rewrite to negative lookbehind with the next major release.
8832
- */
8833
- const DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
8834
- function transform(patterns) {
8835
- return patterns.map((pattern) => removeDuplicateSlashes(pattern));
8836
- }
8837
- patterns.transform = transform;
8838
- /**
8839
- * This package only works with forward slashes as a path separator.
8840
- * Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
8841
- */
8842
- function removeDuplicateSlashes(pattern) {
8843
- return pattern.replace(DOUBLE_SLASH_RE, '/');
8844
- }
8845
- patterns.removeDuplicateSlashes = removeDuplicateSlashes;
8846
-
8847
8949
  var async$7 = {};
8848
8950
 
8849
8951
  var async$6 = {};
@@ -8948,7 +9050,7 @@ var fs$5 = {};
8948
9050
 
8949
9051
  Object.defineProperty(settings$3, "__esModule", { value: true });
8950
9052
  const fs$4 = fs$5;
8951
- class Settings$2 {
9053
+ let Settings$2 = class Settings {
8952
9054
  constructor(_options = {}) {
8953
9055
  this._options = _options;
8954
9056
  this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
@@ -8959,7 +9061,7 @@ class Settings$2 {
8959
9061
  _getValue(option, value) {
8960
9062
  return option !== null && option !== void 0 ? option : value;
8961
9063
  }
8962
- }
9064
+ };
8963
9065
  settings$3.default = Settings$2;
8964
9066
 
8965
9067
  Object.defineProperty(out$1, "__esModule", { value: true });
@@ -9303,7 +9405,7 @@ Object.defineProperty(settings$2, "__esModule", { value: true });
9303
9405
  const path$3 = require$$0$2;
9304
9406
  const fsStat$3 = out$1;
9305
9407
  const fs = fs$1;
9306
- class Settings$1 {
9408
+ let Settings$1 = class Settings {
9307
9409
  constructor(_options = {}) {
9308
9410
  this._options = _options;
9309
9411
  this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
@@ -9320,7 +9422,7 @@ class Settings$1 {
9320
9422
  _getValue(option, value) {
9321
9423
  return option !== null && option !== void 0 ? option : value;
9322
9424
  }
9323
- }
9425
+ };
9324
9426
  settings$2.default = Settings$1;
9325
9427
 
9326
9428
  Object.defineProperty(out$2, "__esModule", { value: true });
@@ -9649,6 +9751,12 @@ function queueAsPromised (context, worker, concurrency) {
9649
9751
  }
9650
9752
 
9651
9753
  function drained () {
9754
+ if (queue.idle()) {
9755
+ return new Promise(function (resolve) {
9756
+ resolve();
9757
+ })
9758
+ }
9759
+
9652
9760
  var previousDrain = queue.drain;
9653
9761
 
9654
9762
  var p = new Promise(function (resolve) {
@@ -9704,17 +9812,17 @@ var reader$1 = {};
9704
9812
 
9705
9813
  Object.defineProperty(reader$1, "__esModule", { value: true });
9706
9814
  const common$2 = common$3;
9707
- class Reader$1 {
9815
+ let Reader$1 = class Reader {
9708
9816
  constructor(_root, _settings) {
9709
9817
  this._root = _root;
9710
9818
  this._settings = _settings;
9711
9819
  this._root = common$2.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
9712
9820
  }
9713
- }
9821
+ };
9714
9822
  reader$1.default = Reader$1;
9715
9823
 
9716
9824
  Object.defineProperty(async$4, "__esModule", { value: true });
9717
- const events_1 = require$$0$4;
9825
+ const events_1 = require$$0$5;
9718
9826
  const fsScandir$2 = out$2;
9719
9827
  const fastq = queueExports;
9720
9828
  const common$1 = common$3;
@@ -10017,129 +10125,129 @@ function getSettings(settingsOrOptions = {}) {
10017
10125
 
10018
10126
  var reader = {};
10019
10127
 
10020
- Object.defineProperty(reader, "__esModule", { value: true });
10021
- const path$1 = require$$0$2;
10022
- const fsStat$2 = out$1;
10023
- const utils$6 = utils$k;
10024
- class Reader {
10025
- constructor(_settings) {
10026
- this._settings = _settings;
10027
- this._fsStatSettings = new fsStat$2.Settings({
10028
- followSymbolicLink: this._settings.followSymbolicLinks,
10029
- fs: this._settings.fs,
10030
- throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
10031
- });
10032
- }
10033
- _getFullEntryPath(filepath) {
10034
- return path$1.resolve(this._settings.cwd, filepath);
10035
- }
10036
- _makeEntry(stats, pattern) {
10037
- const entry = {
10038
- name: pattern,
10039
- path: pattern,
10040
- dirent: utils$6.fs.createDirentFromStats(pattern, stats)
10041
- };
10042
- if (this._settings.stats) {
10043
- entry.stats = stats;
10044
- }
10045
- return entry;
10046
- }
10047
- _isFatalError(error) {
10048
- return !utils$6.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
10049
- }
10050
- }
10128
+ Object.defineProperty(reader, "__esModule", { value: true });
10129
+ const path$1 = require$$0$2;
10130
+ const fsStat$2 = out$1;
10131
+ const utils$6 = utils$k;
10132
+ class Reader {
10133
+ constructor(_settings) {
10134
+ this._settings = _settings;
10135
+ this._fsStatSettings = new fsStat$2.Settings({
10136
+ followSymbolicLink: this._settings.followSymbolicLinks,
10137
+ fs: this._settings.fs,
10138
+ throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
10139
+ });
10140
+ }
10141
+ _getFullEntryPath(filepath) {
10142
+ return path$1.resolve(this._settings.cwd, filepath);
10143
+ }
10144
+ _makeEntry(stats, pattern) {
10145
+ const entry = {
10146
+ name: pattern,
10147
+ path: pattern,
10148
+ dirent: utils$6.fs.createDirentFromStats(pattern, stats)
10149
+ };
10150
+ if (this._settings.stats) {
10151
+ entry.stats = stats;
10152
+ }
10153
+ return entry;
10154
+ }
10155
+ _isFatalError(error) {
10156
+ return !utils$6.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
10157
+ }
10158
+ }
10051
10159
  reader.default = Reader;
10052
10160
 
10053
10161
  var stream$1 = {};
10054
10162
 
10055
- Object.defineProperty(stream$1, "__esModule", { value: true });
10056
- const stream_1$3 = require$$0;
10057
- const fsStat$1 = out$1;
10058
- const fsWalk$2 = out$3;
10059
- const reader_1$2 = reader;
10060
- class ReaderStream extends reader_1$2.default {
10061
- constructor() {
10062
- super(...arguments);
10063
- this._walkStream = fsWalk$2.walkStream;
10064
- this._stat = fsStat$1.stat;
10065
- }
10066
- dynamic(root, options) {
10067
- return this._walkStream(root, options);
10068
- }
10069
- static(patterns, options) {
10070
- const filepaths = patterns.map(this._getFullEntryPath, this);
10071
- const stream = new stream_1$3.PassThrough({ objectMode: true });
10072
- stream._write = (index, _enc, done) => {
10073
- return this._getEntry(filepaths[index], patterns[index], options)
10074
- .then((entry) => {
10075
- if (entry !== null && options.entryFilter(entry)) {
10076
- stream.push(entry);
10077
- }
10078
- if (index === filepaths.length - 1) {
10079
- stream.end();
10080
- }
10081
- done();
10082
- })
10083
- .catch(done);
10084
- };
10085
- for (let i = 0; i < filepaths.length; i++) {
10086
- stream.write(i);
10087
- }
10088
- return stream;
10089
- }
10090
- _getEntry(filepath, pattern, options) {
10091
- return this._getStat(filepath)
10092
- .then((stats) => this._makeEntry(stats, pattern))
10093
- .catch((error) => {
10094
- if (options.errorFilter(error)) {
10095
- return null;
10096
- }
10097
- throw error;
10098
- });
10099
- }
10100
- _getStat(filepath) {
10101
- return new Promise((resolve, reject) => {
10102
- this._stat(filepath, this._fsStatSettings, (error, stats) => {
10103
- return error === null ? resolve(stats) : reject(error);
10104
- });
10105
- });
10106
- }
10107
- }
10163
+ Object.defineProperty(stream$1, "__esModule", { value: true });
10164
+ const stream_1$3 = require$$0;
10165
+ const fsStat$1 = out$1;
10166
+ const fsWalk$2 = out$3;
10167
+ const reader_1$2 = reader;
10168
+ class ReaderStream extends reader_1$2.default {
10169
+ constructor() {
10170
+ super(...arguments);
10171
+ this._walkStream = fsWalk$2.walkStream;
10172
+ this._stat = fsStat$1.stat;
10173
+ }
10174
+ dynamic(root, options) {
10175
+ return this._walkStream(root, options);
10176
+ }
10177
+ static(patterns, options) {
10178
+ const filepaths = patterns.map(this._getFullEntryPath, this);
10179
+ const stream = new stream_1$3.PassThrough({ objectMode: true });
10180
+ stream._write = (index, _enc, done) => {
10181
+ return this._getEntry(filepaths[index], patterns[index], options)
10182
+ .then((entry) => {
10183
+ if (entry !== null && options.entryFilter(entry)) {
10184
+ stream.push(entry);
10185
+ }
10186
+ if (index === filepaths.length - 1) {
10187
+ stream.end();
10188
+ }
10189
+ done();
10190
+ })
10191
+ .catch(done);
10192
+ };
10193
+ for (let i = 0; i < filepaths.length; i++) {
10194
+ stream.write(i);
10195
+ }
10196
+ return stream;
10197
+ }
10198
+ _getEntry(filepath, pattern, options) {
10199
+ return this._getStat(filepath)
10200
+ .then((stats) => this._makeEntry(stats, pattern))
10201
+ .catch((error) => {
10202
+ if (options.errorFilter(error)) {
10203
+ return null;
10204
+ }
10205
+ throw error;
10206
+ });
10207
+ }
10208
+ _getStat(filepath) {
10209
+ return new Promise((resolve, reject) => {
10210
+ this._stat(filepath, this._fsStatSettings, (error, stats) => {
10211
+ return error === null ? resolve(stats) : reject(error);
10212
+ });
10213
+ });
10214
+ }
10215
+ }
10108
10216
  stream$1.default = ReaderStream;
10109
10217
 
10110
- Object.defineProperty(async$6, "__esModule", { value: true });
10111
- const fsWalk$1 = out$3;
10112
- const reader_1$1 = reader;
10113
- const stream_1$2 = stream$1;
10114
- class ReaderAsync extends reader_1$1.default {
10115
- constructor() {
10116
- super(...arguments);
10117
- this._walkAsync = fsWalk$1.walk;
10118
- this._readerStream = new stream_1$2.default(this._settings);
10119
- }
10120
- dynamic(root, options) {
10121
- return new Promise((resolve, reject) => {
10122
- this._walkAsync(root, options, (error, entries) => {
10123
- if (error === null) {
10124
- resolve(entries);
10125
- }
10126
- else {
10127
- reject(error);
10128
- }
10129
- });
10130
- });
10131
- }
10132
- async static(patterns, options) {
10133
- const entries = [];
10134
- const stream = this._readerStream.static(patterns, options);
10135
- // After #235, replace it with an asynchronous iterator.
10136
- return new Promise((resolve, reject) => {
10137
- stream.once('error', reject);
10138
- stream.on('data', (entry) => entries.push(entry));
10139
- stream.once('end', () => resolve(entries));
10140
- });
10141
- }
10142
- }
10218
+ Object.defineProperty(async$6, "__esModule", { value: true });
10219
+ const fsWalk$1 = out$3;
10220
+ const reader_1$1 = reader;
10221
+ const stream_1$2 = stream$1;
10222
+ class ReaderAsync extends reader_1$1.default {
10223
+ constructor() {
10224
+ super(...arguments);
10225
+ this._walkAsync = fsWalk$1.walk;
10226
+ this._readerStream = new stream_1$2.default(this._settings);
10227
+ }
10228
+ dynamic(root, options) {
10229
+ return new Promise((resolve, reject) => {
10230
+ this._walkAsync(root, options, (error, entries) => {
10231
+ if (error === null) {
10232
+ resolve(entries);
10233
+ }
10234
+ else {
10235
+ reject(error);
10236
+ }
10237
+ });
10238
+ });
10239
+ }
10240
+ async static(patterns, options) {
10241
+ const entries = [];
10242
+ const stream = this._readerStream.static(patterns, options);
10243
+ // After #235, replace it with an asynchronous iterator.
10244
+ return new Promise((resolve, reject) => {
10245
+ stream.once('error', reject);
10246
+ stream.on('data', (entry) => entries.push(entry));
10247
+ stream.once('end', () => resolve(entries));
10248
+ });
10249
+ }
10250
+ }
10143
10251
  async$6.default = ReaderAsync;
10144
10252
 
10145
10253
  var provider = {};
@@ -10150,591 +10258,621 @@ var partial = {};
10150
10258
 
10151
10259
  var matcher = {};
10152
10260
 
10153
- Object.defineProperty(matcher, "__esModule", { value: true });
10154
- const utils$5 = utils$k;
10155
- class Matcher {
10156
- constructor(_patterns, _settings, _micromatchOptions) {
10157
- this._patterns = _patterns;
10158
- this._settings = _settings;
10159
- this._micromatchOptions = _micromatchOptions;
10160
- this._storage = [];
10161
- this._fillStorage();
10162
- }
10163
- _fillStorage() {
10164
- /**
10165
- * The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
10166
- * So, before expand patterns with brace expansion into separated patterns.
10167
- */
10168
- const patterns = utils$5.pattern.expandPatternsWithBraceExpansion(this._patterns);
10169
- for (const pattern of patterns) {
10170
- const segments = this._getPatternSegments(pattern);
10171
- const sections = this._splitSegmentsIntoSections(segments);
10172
- this._storage.push({
10173
- complete: sections.length <= 1,
10174
- pattern,
10175
- segments,
10176
- sections
10177
- });
10178
- }
10179
- }
10180
- _getPatternSegments(pattern) {
10181
- const parts = utils$5.pattern.getPatternParts(pattern, this._micromatchOptions);
10182
- return parts.map((part) => {
10183
- const dynamic = utils$5.pattern.isDynamicPattern(part, this._settings);
10184
- if (!dynamic) {
10185
- return {
10186
- dynamic: false,
10187
- pattern: part
10188
- };
10189
- }
10190
- return {
10191
- dynamic: true,
10192
- pattern: part,
10193
- patternRe: utils$5.pattern.makeRe(part, this._micromatchOptions)
10194
- };
10195
- });
10196
- }
10197
- _splitSegmentsIntoSections(segments) {
10198
- return utils$5.array.splitWhen(segments, (segment) => segment.dynamic && utils$5.pattern.hasGlobStar(segment.pattern));
10199
- }
10200
- }
10261
+ Object.defineProperty(matcher, "__esModule", { value: true });
10262
+ const utils$5 = utils$k;
10263
+ class Matcher {
10264
+ constructor(_patterns, _settings, _micromatchOptions) {
10265
+ this._patterns = _patterns;
10266
+ this._settings = _settings;
10267
+ this._micromatchOptions = _micromatchOptions;
10268
+ this._storage = [];
10269
+ this._fillStorage();
10270
+ }
10271
+ _fillStorage() {
10272
+ for (const pattern of this._patterns) {
10273
+ const segments = this._getPatternSegments(pattern);
10274
+ const sections = this._splitSegmentsIntoSections(segments);
10275
+ this._storage.push({
10276
+ complete: sections.length <= 1,
10277
+ pattern,
10278
+ segments,
10279
+ sections
10280
+ });
10281
+ }
10282
+ }
10283
+ _getPatternSegments(pattern) {
10284
+ const parts = utils$5.pattern.getPatternParts(pattern, this._micromatchOptions);
10285
+ return parts.map((part) => {
10286
+ const dynamic = utils$5.pattern.isDynamicPattern(part, this._settings);
10287
+ if (!dynamic) {
10288
+ return {
10289
+ dynamic: false,
10290
+ pattern: part
10291
+ };
10292
+ }
10293
+ return {
10294
+ dynamic: true,
10295
+ pattern: part,
10296
+ patternRe: utils$5.pattern.makeRe(part, this._micromatchOptions)
10297
+ };
10298
+ });
10299
+ }
10300
+ _splitSegmentsIntoSections(segments) {
10301
+ return utils$5.array.splitWhen(segments, (segment) => segment.dynamic && utils$5.pattern.hasGlobStar(segment.pattern));
10302
+ }
10303
+ }
10201
10304
  matcher.default = Matcher;
10202
10305
 
10203
- Object.defineProperty(partial, "__esModule", { value: true });
10204
- const matcher_1 = matcher;
10205
- class PartialMatcher extends matcher_1.default {
10206
- match(filepath) {
10207
- const parts = filepath.split('/');
10208
- const levels = parts.length;
10209
- const patterns = this._storage.filter((info) => !info.complete || info.segments.length > levels);
10210
- for (const pattern of patterns) {
10211
- const section = pattern.sections[0];
10212
- /**
10213
- * In this case, the pattern has a globstar and we must read all directories unconditionally,
10214
- * but only if the level has reached the end of the first group.
10215
- *
10216
- * fixtures/{a,b}/**
10217
- * ^ true/false ^ always true
10218
- */
10219
- if (!pattern.complete && levels > section.length) {
10220
- return true;
10221
- }
10222
- const match = parts.every((part, index) => {
10223
- const segment = pattern.segments[index];
10224
- if (segment.dynamic && segment.patternRe.test(part)) {
10225
- return true;
10226
- }
10227
- if (!segment.dynamic && segment.pattern === part) {
10228
- return true;
10229
- }
10230
- return false;
10231
- });
10232
- if (match) {
10233
- return true;
10234
- }
10235
- }
10236
- return false;
10237
- }
10238
- }
10306
+ Object.defineProperty(partial, "__esModule", { value: true });
10307
+ const matcher_1 = matcher;
10308
+ class PartialMatcher extends matcher_1.default {
10309
+ match(filepath) {
10310
+ const parts = filepath.split('/');
10311
+ const levels = parts.length;
10312
+ const patterns = this._storage.filter((info) => !info.complete || info.segments.length > levels);
10313
+ for (const pattern of patterns) {
10314
+ const section = pattern.sections[0];
10315
+ /**
10316
+ * In this case, the pattern has a globstar and we must read all directories unconditionally,
10317
+ * but only if the level has reached the end of the first group.
10318
+ *
10319
+ * fixtures/{a,b}/**
10320
+ * ^ true/false ^ always true
10321
+ */
10322
+ if (!pattern.complete && levels > section.length) {
10323
+ return true;
10324
+ }
10325
+ const match = parts.every((part, index) => {
10326
+ const segment = pattern.segments[index];
10327
+ if (segment.dynamic && segment.patternRe.test(part)) {
10328
+ return true;
10329
+ }
10330
+ if (!segment.dynamic && segment.pattern === part) {
10331
+ return true;
10332
+ }
10333
+ return false;
10334
+ });
10335
+ if (match) {
10336
+ return true;
10337
+ }
10338
+ }
10339
+ return false;
10340
+ }
10341
+ }
10239
10342
  partial.default = PartialMatcher;
10240
10343
 
10241
- Object.defineProperty(deep, "__esModule", { value: true });
10242
- const utils$4 = utils$k;
10243
- const partial_1 = partial;
10244
- class DeepFilter {
10245
- constructor(_settings, _micromatchOptions) {
10246
- this._settings = _settings;
10247
- this._micromatchOptions = _micromatchOptions;
10248
- }
10249
- getFilter(basePath, positive, negative) {
10250
- const matcher = this._getMatcher(positive);
10251
- const negativeRe = this._getNegativePatternsRe(negative);
10252
- return (entry) => this._filter(basePath, entry, matcher, negativeRe);
10253
- }
10254
- _getMatcher(patterns) {
10255
- return new partial_1.default(patterns, this._settings, this._micromatchOptions);
10256
- }
10257
- _getNegativePatternsRe(patterns) {
10258
- const affectDepthOfReadingPatterns = patterns.filter(utils$4.pattern.isAffectDepthOfReadingPattern);
10259
- return utils$4.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
10260
- }
10261
- _filter(basePath, entry, matcher, negativeRe) {
10262
- if (this._isSkippedByDeep(basePath, entry.path)) {
10263
- return false;
10264
- }
10265
- if (this._isSkippedSymbolicLink(entry)) {
10266
- return false;
10267
- }
10268
- const filepath = utils$4.path.removeLeadingDotSegment(entry.path);
10269
- if (this._isSkippedByPositivePatterns(filepath, matcher)) {
10270
- return false;
10271
- }
10272
- return this._isSkippedByNegativePatterns(filepath, negativeRe);
10273
- }
10274
- _isSkippedByDeep(basePath, entryPath) {
10275
- /**
10276
- * Avoid unnecessary depth calculations when it doesn't matter.
10277
- */
10278
- if (this._settings.deep === Infinity) {
10279
- return false;
10280
- }
10281
- return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
10282
- }
10283
- _getEntryLevel(basePath, entryPath) {
10284
- const entryPathDepth = entryPath.split('/').length;
10285
- if (basePath === '') {
10286
- return entryPathDepth;
10287
- }
10288
- const basePathDepth = basePath.split('/').length;
10289
- return entryPathDepth - basePathDepth;
10290
- }
10291
- _isSkippedSymbolicLink(entry) {
10292
- return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
10293
- }
10294
- _isSkippedByPositivePatterns(entryPath, matcher) {
10295
- return !this._settings.baseNameMatch && !matcher.match(entryPath);
10296
- }
10297
- _isSkippedByNegativePatterns(entryPath, patternsRe) {
10298
- return !utils$4.pattern.matchAny(entryPath, patternsRe);
10299
- }
10300
- }
10344
+ Object.defineProperty(deep, "__esModule", { value: true });
10345
+ const utils$4 = utils$k;
10346
+ const partial_1 = partial;
10347
+ class DeepFilter {
10348
+ constructor(_settings, _micromatchOptions) {
10349
+ this._settings = _settings;
10350
+ this._micromatchOptions = _micromatchOptions;
10351
+ }
10352
+ getFilter(basePath, positive, negative) {
10353
+ const matcher = this._getMatcher(positive);
10354
+ const negativeRe = this._getNegativePatternsRe(negative);
10355
+ return (entry) => this._filter(basePath, entry, matcher, negativeRe);
10356
+ }
10357
+ _getMatcher(patterns) {
10358
+ return new partial_1.default(patterns, this._settings, this._micromatchOptions);
10359
+ }
10360
+ _getNegativePatternsRe(patterns) {
10361
+ const affectDepthOfReadingPatterns = patterns.filter(utils$4.pattern.isAffectDepthOfReadingPattern);
10362
+ return utils$4.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
10363
+ }
10364
+ _filter(basePath, entry, matcher, negativeRe) {
10365
+ if (this._isSkippedByDeep(basePath, entry.path)) {
10366
+ return false;
10367
+ }
10368
+ if (this._isSkippedSymbolicLink(entry)) {
10369
+ return false;
10370
+ }
10371
+ const filepath = utils$4.path.removeLeadingDotSegment(entry.path);
10372
+ if (this._isSkippedByPositivePatterns(filepath, matcher)) {
10373
+ return false;
10374
+ }
10375
+ return this._isSkippedByNegativePatterns(filepath, negativeRe);
10376
+ }
10377
+ _isSkippedByDeep(basePath, entryPath) {
10378
+ /**
10379
+ * Avoid unnecessary depth calculations when it doesn't matter.
10380
+ */
10381
+ if (this._settings.deep === Infinity) {
10382
+ return false;
10383
+ }
10384
+ return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
10385
+ }
10386
+ _getEntryLevel(basePath, entryPath) {
10387
+ const entryPathDepth = entryPath.split('/').length;
10388
+ if (basePath === '') {
10389
+ return entryPathDepth;
10390
+ }
10391
+ const basePathDepth = basePath.split('/').length;
10392
+ return entryPathDepth - basePathDepth;
10393
+ }
10394
+ _isSkippedSymbolicLink(entry) {
10395
+ return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
10396
+ }
10397
+ _isSkippedByPositivePatterns(entryPath, matcher) {
10398
+ return !this._settings.baseNameMatch && !matcher.match(entryPath);
10399
+ }
10400
+ _isSkippedByNegativePatterns(entryPath, patternsRe) {
10401
+ return !utils$4.pattern.matchAny(entryPath, patternsRe);
10402
+ }
10403
+ }
10301
10404
  deep.default = DeepFilter;
10302
10405
 
10303
10406
  var entry$1 = {};
10304
10407
 
10305
- Object.defineProperty(entry$1, "__esModule", { value: true });
10306
- const utils$3 = utils$k;
10307
- class EntryFilter {
10308
- constructor(_settings, _micromatchOptions) {
10309
- this._settings = _settings;
10310
- this._micromatchOptions = _micromatchOptions;
10311
- this.index = new Map();
10312
- }
10313
- getFilter(positive, negative) {
10314
- const positiveRe = utils$3.pattern.convertPatternsToRe(positive, this._micromatchOptions);
10315
- const negativeRe = utils$3.pattern.convertPatternsToRe(negative, this._micromatchOptions);
10316
- return (entry) => this._filter(entry, positiveRe, negativeRe);
10317
- }
10318
- _filter(entry, positiveRe, negativeRe) {
10319
- if (this._settings.unique && this._isDuplicateEntry(entry)) {
10320
- return false;
10321
- }
10322
- if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
10323
- return false;
10324
- }
10325
- if (this._isSkippedByAbsoluteNegativePatterns(entry.path, negativeRe)) {
10326
- return false;
10327
- }
10328
- const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
10329
- const isDirectory = entry.dirent.isDirectory();
10330
- const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(entry.path, negativeRe, isDirectory);
10331
- if (this._settings.unique && isMatched) {
10332
- this._createIndexRecord(entry);
10333
- }
10334
- return isMatched;
10335
- }
10336
- _isDuplicateEntry(entry) {
10337
- return this.index.has(entry.path);
10338
- }
10339
- _createIndexRecord(entry) {
10340
- this.index.set(entry.path, undefined);
10341
- }
10342
- _onlyFileFilter(entry) {
10343
- return this._settings.onlyFiles && !entry.dirent.isFile();
10344
- }
10345
- _onlyDirectoryFilter(entry) {
10346
- return this._settings.onlyDirectories && !entry.dirent.isDirectory();
10347
- }
10348
- _isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
10349
- if (!this._settings.absolute) {
10350
- return false;
10351
- }
10352
- const fullpath = utils$3.path.makeAbsolute(this._settings.cwd, entryPath);
10353
- return utils$3.pattern.matchAny(fullpath, patternsRe);
10354
- }
10355
- _isMatchToPatterns(entryPath, patternsRe, isDirectory) {
10356
- const filepath = utils$3.path.removeLeadingDotSegment(entryPath);
10357
- // Trying to match files and directories by patterns.
10358
- const isMatched = utils$3.pattern.matchAny(filepath, patternsRe);
10359
- // A pattern with a trailling slash can be used for directory matching.
10360
- // To apply such pattern, we need to add a tralling slash to the path.
10361
- if (!isMatched && isDirectory) {
10362
- return utils$3.pattern.matchAny(filepath + '/', patternsRe);
10363
- }
10364
- return isMatched;
10365
- }
10366
- }
10408
+ Object.defineProperty(entry$1, "__esModule", { value: true });
10409
+ const utils$3 = utils$k;
10410
+ class EntryFilter {
10411
+ constructor(_settings, _micromatchOptions) {
10412
+ this._settings = _settings;
10413
+ this._micromatchOptions = _micromatchOptions;
10414
+ this.index = new Map();
10415
+ }
10416
+ getFilter(positive, negative) {
10417
+ const positiveRe = utils$3.pattern.convertPatternsToRe(positive, this._micromatchOptions);
10418
+ const negativeRe = utils$3.pattern.convertPatternsToRe(negative, Object.assign(Object.assign({}, this._micromatchOptions), { dot: true }));
10419
+ return (entry) => this._filter(entry, positiveRe, negativeRe);
10420
+ }
10421
+ _filter(entry, positiveRe, negativeRe) {
10422
+ const filepath = utils$3.path.removeLeadingDotSegment(entry.path);
10423
+ if (this._settings.unique && this._isDuplicateEntry(filepath)) {
10424
+ return false;
10425
+ }
10426
+ if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
10427
+ return false;
10428
+ }
10429
+ if (this._isSkippedByAbsoluteNegativePatterns(filepath, negativeRe)) {
10430
+ return false;
10431
+ }
10432
+ const isDirectory = entry.dirent.isDirectory();
10433
+ const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(filepath, negativeRe, isDirectory);
10434
+ if (this._settings.unique && isMatched) {
10435
+ this._createIndexRecord(filepath);
10436
+ }
10437
+ return isMatched;
10438
+ }
10439
+ _isDuplicateEntry(filepath) {
10440
+ return this.index.has(filepath);
10441
+ }
10442
+ _createIndexRecord(filepath) {
10443
+ this.index.set(filepath, undefined);
10444
+ }
10445
+ _onlyFileFilter(entry) {
10446
+ return this._settings.onlyFiles && !entry.dirent.isFile();
10447
+ }
10448
+ _onlyDirectoryFilter(entry) {
10449
+ return this._settings.onlyDirectories && !entry.dirent.isDirectory();
10450
+ }
10451
+ _isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
10452
+ if (!this._settings.absolute) {
10453
+ return false;
10454
+ }
10455
+ const fullpath = utils$3.path.makeAbsolute(this._settings.cwd, entryPath);
10456
+ return utils$3.pattern.matchAny(fullpath, patternsRe);
10457
+ }
10458
+ _isMatchToPatterns(filepath, patternsRe, isDirectory) {
10459
+ // Trying to match files and directories by patterns.
10460
+ const isMatched = utils$3.pattern.matchAny(filepath, patternsRe);
10461
+ // A pattern with a trailling slash can be used for directory matching.
10462
+ // To apply such pattern, we need to add a tralling slash to the path.
10463
+ if (!isMatched && isDirectory) {
10464
+ return utils$3.pattern.matchAny(filepath + '/', patternsRe);
10465
+ }
10466
+ return isMatched;
10467
+ }
10468
+ }
10367
10469
  entry$1.default = EntryFilter;
10368
10470
 
10369
10471
  var error = {};
10370
10472
 
10371
- Object.defineProperty(error, "__esModule", { value: true });
10372
- const utils$2 = utils$k;
10373
- class ErrorFilter {
10374
- constructor(_settings) {
10375
- this._settings = _settings;
10376
- }
10377
- getFilter() {
10378
- return (error) => this._isNonFatalError(error);
10379
- }
10380
- _isNonFatalError(error) {
10381
- return utils$2.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
10382
- }
10383
- }
10473
+ Object.defineProperty(error, "__esModule", { value: true });
10474
+ const utils$2 = utils$k;
10475
+ class ErrorFilter {
10476
+ constructor(_settings) {
10477
+ this._settings = _settings;
10478
+ }
10479
+ getFilter() {
10480
+ return (error) => this._isNonFatalError(error);
10481
+ }
10482
+ _isNonFatalError(error) {
10483
+ return utils$2.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
10484
+ }
10485
+ }
10384
10486
  error.default = ErrorFilter;
10385
10487
 
10386
10488
  var entry = {};
10387
10489
 
10388
- Object.defineProperty(entry, "__esModule", { value: true });
10389
- const utils$1 = utils$k;
10390
- class EntryTransformer {
10391
- constructor(_settings) {
10392
- this._settings = _settings;
10393
- }
10394
- getTransformer() {
10395
- return (entry) => this._transform(entry);
10396
- }
10397
- _transform(entry) {
10398
- let filepath = entry.path;
10399
- if (this._settings.absolute) {
10400
- filepath = utils$1.path.makeAbsolute(this._settings.cwd, filepath);
10401
- filepath = utils$1.path.unixify(filepath);
10402
- }
10403
- if (this._settings.markDirectories && entry.dirent.isDirectory()) {
10404
- filepath += '/';
10405
- }
10406
- if (!this._settings.objectMode) {
10407
- return filepath;
10408
- }
10409
- return Object.assign(Object.assign({}, entry), { path: filepath });
10410
- }
10411
- }
10490
+ Object.defineProperty(entry, "__esModule", { value: true });
10491
+ const utils$1 = utils$k;
10492
+ class EntryTransformer {
10493
+ constructor(_settings) {
10494
+ this._settings = _settings;
10495
+ }
10496
+ getTransformer() {
10497
+ return (entry) => this._transform(entry);
10498
+ }
10499
+ _transform(entry) {
10500
+ let filepath = entry.path;
10501
+ if (this._settings.absolute) {
10502
+ filepath = utils$1.path.makeAbsolute(this._settings.cwd, filepath);
10503
+ filepath = utils$1.path.unixify(filepath);
10504
+ }
10505
+ if (this._settings.markDirectories && entry.dirent.isDirectory()) {
10506
+ filepath += '/';
10507
+ }
10508
+ if (!this._settings.objectMode) {
10509
+ return filepath;
10510
+ }
10511
+ return Object.assign(Object.assign({}, entry), { path: filepath });
10512
+ }
10513
+ }
10412
10514
  entry.default = EntryTransformer;
10413
10515
 
10414
- Object.defineProperty(provider, "__esModule", { value: true });
10415
- const path = require$$0$2;
10416
- const deep_1 = deep;
10417
- const entry_1 = entry$1;
10418
- const error_1 = error;
10419
- const entry_2 = entry;
10420
- class Provider {
10421
- constructor(_settings) {
10422
- this._settings = _settings;
10423
- this.errorFilter = new error_1.default(this._settings);
10424
- this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions());
10425
- this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions());
10426
- this.entryTransformer = new entry_2.default(this._settings);
10427
- }
10428
- _getRootDirectory(task) {
10429
- return path.resolve(this._settings.cwd, task.base);
10430
- }
10431
- _getReaderOptions(task) {
10432
- const basePath = task.base === '.' ? '' : task.base;
10433
- return {
10434
- basePath,
10435
- pathSegmentSeparator: '/',
10436
- concurrency: this._settings.concurrency,
10437
- deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
10438
- entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
10439
- errorFilter: this.errorFilter.getFilter(),
10440
- followSymbolicLinks: this._settings.followSymbolicLinks,
10441
- fs: this._settings.fs,
10442
- stats: this._settings.stats,
10443
- throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
10444
- transform: this.entryTransformer.getTransformer()
10445
- };
10446
- }
10447
- _getMicromatchOptions() {
10448
- return {
10449
- dot: this._settings.dot,
10450
- matchBase: this._settings.baseNameMatch,
10451
- nobrace: !this._settings.braceExpansion,
10452
- nocase: !this._settings.caseSensitiveMatch,
10453
- noext: !this._settings.extglob,
10454
- noglobstar: !this._settings.globstar,
10455
- posix: true,
10456
- strictSlashes: false
10457
- };
10458
- }
10459
- }
10516
+ Object.defineProperty(provider, "__esModule", { value: true });
10517
+ const path = require$$0$2;
10518
+ const deep_1 = deep;
10519
+ const entry_1 = entry$1;
10520
+ const error_1 = error;
10521
+ const entry_2 = entry;
10522
+ class Provider {
10523
+ constructor(_settings) {
10524
+ this._settings = _settings;
10525
+ this.errorFilter = new error_1.default(this._settings);
10526
+ this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions());
10527
+ this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions());
10528
+ this.entryTransformer = new entry_2.default(this._settings);
10529
+ }
10530
+ _getRootDirectory(task) {
10531
+ return path.resolve(this._settings.cwd, task.base);
10532
+ }
10533
+ _getReaderOptions(task) {
10534
+ const basePath = task.base === '.' ? '' : task.base;
10535
+ return {
10536
+ basePath,
10537
+ pathSegmentSeparator: '/',
10538
+ concurrency: this._settings.concurrency,
10539
+ deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
10540
+ entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
10541
+ errorFilter: this.errorFilter.getFilter(),
10542
+ followSymbolicLinks: this._settings.followSymbolicLinks,
10543
+ fs: this._settings.fs,
10544
+ stats: this._settings.stats,
10545
+ throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
10546
+ transform: this.entryTransformer.getTransformer()
10547
+ };
10548
+ }
10549
+ _getMicromatchOptions() {
10550
+ return {
10551
+ dot: this._settings.dot,
10552
+ matchBase: this._settings.baseNameMatch,
10553
+ nobrace: !this._settings.braceExpansion,
10554
+ nocase: !this._settings.caseSensitiveMatch,
10555
+ noext: !this._settings.extglob,
10556
+ noglobstar: !this._settings.globstar,
10557
+ posix: true,
10558
+ strictSlashes: false
10559
+ };
10560
+ }
10561
+ }
10460
10562
  provider.default = Provider;
10461
10563
 
10462
- Object.defineProperty(async$7, "__esModule", { value: true });
10463
- const async_1$1 = async$6;
10464
- const provider_1$2 = provider;
10465
- class ProviderAsync extends provider_1$2.default {
10466
- constructor() {
10467
- super(...arguments);
10468
- this._reader = new async_1$1.default(this._settings);
10469
- }
10470
- async read(task) {
10471
- const root = this._getRootDirectory(task);
10472
- const options = this._getReaderOptions(task);
10473
- const entries = await this.api(root, task, options);
10474
- return entries.map((entry) => options.transform(entry));
10475
- }
10476
- api(root, task, options) {
10477
- if (task.dynamic) {
10478
- return this._reader.dynamic(root, options);
10479
- }
10480
- return this._reader.static(task.patterns, options);
10481
- }
10482
- }
10564
+ Object.defineProperty(async$7, "__esModule", { value: true });
10565
+ const async_1$1 = async$6;
10566
+ const provider_1$2 = provider;
10567
+ class ProviderAsync extends provider_1$2.default {
10568
+ constructor() {
10569
+ super(...arguments);
10570
+ this._reader = new async_1$1.default(this._settings);
10571
+ }
10572
+ async read(task) {
10573
+ const root = this._getRootDirectory(task);
10574
+ const options = this._getReaderOptions(task);
10575
+ const entries = await this.api(root, task, options);
10576
+ return entries.map((entry) => options.transform(entry));
10577
+ }
10578
+ api(root, task, options) {
10579
+ if (task.dynamic) {
10580
+ return this._reader.dynamic(root, options);
10581
+ }
10582
+ return this._reader.static(task.patterns, options);
10583
+ }
10584
+ }
10483
10585
  async$7.default = ProviderAsync;
10484
10586
 
10485
10587
  var stream = {};
10486
10588
 
10487
- Object.defineProperty(stream, "__esModule", { value: true });
10488
- const stream_1$1 = require$$0;
10489
- const stream_2 = stream$1;
10490
- const provider_1$1 = provider;
10491
- class ProviderStream extends provider_1$1.default {
10492
- constructor() {
10493
- super(...arguments);
10494
- this._reader = new stream_2.default(this._settings);
10495
- }
10496
- read(task) {
10497
- const root = this._getRootDirectory(task);
10498
- const options = this._getReaderOptions(task);
10499
- const source = this.api(root, task, options);
10500
- const destination = new stream_1$1.Readable({ objectMode: true, read: () => { } });
10501
- source
10502
- .once('error', (error) => destination.emit('error', error))
10503
- .on('data', (entry) => destination.emit('data', options.transform(entry)))
10504
- .once('end', () => destination.emit('end'));
10505
- destination
10506
- .once('close', () => source.destroy());
10507
- return destination;
10508
- }
10509
- api(root, task, options) {
10510
- if (task.dynamic) {
10511
- return this._reader.dynamic(root, options);
10512
- }
10513
- return this._reader.static(task.patterns, options);
10514
- }
10515
- }
10589
+ Object.defineProperty(stream, "__esModule", { value: true });
10590
+ const stream_1$1 = require$$0;
10591
+ const stream_2 = stream$1;
10592
+ const provider_1$1 = provider;
10593
+ class ProviderStream extends provider_1$1.default {
10594
+ constructor() {
10595
+ super(...arguments);
10596
+ this._reader = new stream_2.default(this._settings);
10597
+ }
10598
+ read(task) {
10599
+ const root = this._getRootDirectory(task);
10600
+ const options = this._getReaderOptions(task);
10601
+ const source = this.api(root, task, options);
10602
+ const destination = new stream_1$1.Readable({ objectMode: true, read: () => { } });
10603
+ source
10604
+ .once('error', (error) => destination.emit('error', error))
10605
+ .on('data', (entry) => destination.emit('data', options.transform(entry)))
10606
+ .once('end', () => destination.emit('end'));
10607
+ destination
10608
+ .once('close', () => source.destroy());
10609
+ return destination;
10610
+ }
10611
+ api(root, task, options) {
10612
+ if (task.dynamic) {
10613
+ return this._reader.dynamic(root, options);
10614
+ }
10615
+ return this._reader.static(task.patterns, options);
10616
+ }
10617
+ }
10516
10618
  stream.default = ProviderStream;
10517
10619
 
10518
10620
  var sync$1 = {};
10519
10621
 
10520
10622
  var sync = {};
10521
10623
 
10522
- Object.defineProperty(sync, "__esModule", { value: true });
10523
- const fsStat = out$1;
10524
- const fsWalk = out$3;
10525
- const reader_1 = reader;
10526
- class ReaderSync extends reader_1.default {
10527
- constructor() {
10528
- super(...arguments);
10529
- this._walkSync = fsWalk.walkSync;
10530
- this._statSync = fsStat.statSync;
10531
- }
10532
- dynamic(root, options) {
10533
- return this._walkSync(root, options);
10534
- }
10535
- static(patterns, options) {
10536
- const entries = [];
10537
- for (const pattern of patterns) {
10538
- const filepath = this._getFullEntryPath(pattern);
10539
- const entry = this._getEntry(filepath, pattern, options);
10540
- if (entry === null || !options.entryFilter(entry)) {
10541
- continue;
10542
- }
10543
- entries.push(entry);
10544
- }
10545
- return entries;
10546
- }
10547
- _getEntry(filepath, pattern, options) {
10548
- try {
10549
- const stats = this._getStat(filepath);
10550
- return this._makeEntry(stats, pattern);
10551
- }
10552
- catch (error) {
10553
- if (options.errorFilter(error)) {
10554
- return null;
10555
- }
10556
- throw error;
10557
- }
10558
- }
10559
- _getStat(filepath) {
10560
- return this._statSync(filepath, this._fsStatSettings);
10561
- }
10562
- }
10624
+ Object.defineProperty(sync, "__esModule", { value: true });
10625
+ const fsStat = out$1;
10626
+ const fsWalk = out$3;
10627
+ const reader_1 = reader;
10628
+ class ReaderSync extends reader_1.default {
10629
+ constructor() {
10630
+ super(...arguments);
10631
+ this._walkSync = fsWalk.walkSync;
10632
+ this._statSync = fsStat.statSync;
10633
+ }
10634
+ dynamic(root, options) {
10635
+ return this._walkSync(root, options);
10636
+ }
10637
+ static(patterns, options) {
10638
+ const entries = [];
10639
+ for (const pattern of patterns) {
10640
+ const filepath = this._getFullEntryPath(pattern);
10641
+ const entry = this._getEntry(filepath, pattern, options);
10642
+ if (entry === null || !options.entryFilter(entry)) {
10643
+ continue;
10644
+ }
10645
+ entries.push(entry);
10646
+ }
10647
+ return entries;
10648
+ }
10649
+ _getEntry(filepath, pattern, options) {
10650
+ try {
10651
+ const stats = this._getStat(filepath);
10652
+ return this._makeEntry(stats, pattern);
10653
+ }
10654
+ catch (error) {
10655
+ if (options.errorFilter(error)) {
10656
+ return null;
10657
+ }
10658
+ throw error;
10659
+ }
10660
+ }
10661
+ _getStat(filepath) {
10662
+ return this._statSync(filepath, this._fsStatSettings);
10663
+ }
10664
+ }
10563
10665
  sync.default = ReaderSync;
10564
10666
 
10565
- Object.defineProperty(sync$1, "__esModule", { value: true });
10566
- const sync_1$1 = sync;
10567
- const provider_1 = provider;
10568
- class ProviderSync extends provider_1.default {
10569
- constructor() {
10570
- super(...arguments);
10571
- this._reader = new sync_1$1.default(this._settings);
10572
- }
10573
- read(task) {
10574
- const root = this._getRootDirectory(task);
10575
- const options = this._getReaderOptions(task);
10576
- const entries = this.api(root, task, options);
10577
- return entries.map(options.transform);
10578
- }
10579
- api(root, task, options) {
10580
- if (task.dynamic) {
10581
- return this._reader.dynamic(root, options);
10582
- }
10583
- return this._reader.static(task.patterns, options);
10584
- }
10585
- }
10667
+ Object.defineProperty(sync$1, "__esModule", { value: true });
10668
+ const sync_1$1 = sync;
10669
+ const provider_1 = provider;
10670
+ class ProviderSync extends provider_1.default {
10671
+ constructor() {
10672
+ super(...arguments);
10673
+ this._reader = new sync_1$1.default(this._settings);
10674
+ }
10675
+ read(task) {
10676
+ const root = this._getRootDirectory(task);
10677
+ const options = this._getReaderOptions(task);
10678
+ const entries = this.api(root, task, options);
10679
+ return entries.map(options.transform);
10680
+ }
10681
+ api(root, task, options) {
10682
+ if (task.dynamic) {
10683
+ return this._reader.dynamic(root, options);
10684
+ }
10685
+ return this._reader.static(task.patterns, options);
10686
+ }
10687
+ }
10586
10688
  sync$1.default = ProviderSync;
10587
10689
 
10588
10690
  var settings = {};
10589
10691
 
10590
10692
  (function (exports) {
10591
- Object.defineProperty(exports, "__esModule", { value: true });
10592
- exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
10593
- const fs = require$$0$1;
10594
- const os = require$$2$1;
10595
- /**
10596
- * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
10597
- * https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
10598
- */
10599
- const CPU_COUNT = Math.max(os.cpus().length, 1);
10600
- exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
10601
- lstat: fs.lstat,
10602
- lstatSync: fs.lstatSync,
10603
- stat: fs.stat,
10604
- statSync: fs.statSync,
10605
- readdir: fs.readdir,
10606
- readdirSync: fs.readdirSync
10607
- };
10608
- class Settings {
10609
- constructor(_options = {}) {
10610
- this._options = _options;
10611
- this.absolute = this._getValue(this._options.absolute, false);
10612
- this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
10613
- this.braceExpansion = this._getValue(this._options.braceExpansion, true);
10614
- this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
10615
- this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
10616
- this.cwd = this._getValue(this._options.cwd, process.cwd());
10617
- this.deep = this._getValue(this._options.deep, Infinity);
10618
- this.dot = this._getValue(this._options.dot, false);
10619
- this.extglob = this._getValue(this._options.extglob, true);
10620
- this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
10621
- this.fs = this._getFileSystemMethods(this._options.fs);
10622
- this.globstar = this._getValue(this._options.globstar, true);
10623
- this.ignore = this._getValue(this._options.ignore, []);
10624
- this.markDirectories = this._getValue(this._options.markDirectories, false);
10625
- this.objectMode = this._getValue(this._options.objectMode, false);
10626
- this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
10627
- this.onlyFiles = this._getValue(this._options.onlyFiles, true);
10628
- this.stats = this._getValue(this._options.stats, false);
10629
- this.suppressErrors = this._getValue(this._options.suppressErrors, false);
10630
- this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
10631
- this.unique = this._getValue(this._options.unique, true);
10632
- if (this.onlyDirectories) {
10633
- this.onlyFiles = false;
10634
- }
10635
- if (this.stats) {
10636
- this.objectMode = true;
10637
- }
10638
- }
10639
- _getValue(option, value) {
10640
- return option === undefined ? value : option;
10641
- }
10642
- _getFileSystemMethods(methods = {}) {
10643
- return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
10644
- }
10645
- }
10693
+ Object.defineProperty(exports, "__esModule", { value: true });
10694
+ exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
10695
+ const fs = require$$0$1;
10696
+ const os = require$$0$4;
10697
+ /**
10698
+ * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
10699
+ * https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
10700
+ */
10701
+ const CPU_COUNT = Math.max(os.cpus().length, 1);
10702
+ exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
10703
+ lstat: fs.lstat,
10704
+ lstatSync: fs.lstatSync,
10705
+ stat: fs.stat,
10706
+ statSync: fs.statSync,
10707
+ readdir: fs.readdir,
10708
+ readdirSync: fs.readdirSync
10709
+ };
10710
+ class Settings {
10711
+ constructor(_options = {}) {
10712
+ this._options = _options;
10713
+ this.absolute = this._getValue(this._options.absolute, false);
10714
+ this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
10715
+ this.braceExpansion = this._getValue(this._options.braceExpansion, true);
10716
+ this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
10717
+ this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
10718
+ this.cwd = this._getValue(this._options.cwd, process.cwd());
10719
+ this.deep = this._getValue(this._options.deep, Infinity);
10720
+ this.dot = this._getValue(this._options.dot, false);
10721
+ this.extglob = this._getValue(this._options.extglob, true);
10722
+ this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
10723
+ this.fs = this._getFileSystemMethods(this._options.fs);
10724
+ this.globstar = this._getValue(this._options.globstar, true);
10725
+ this.ignore = this._getValue(this._options.ignore, []);
10726
+ this.markDirectories = this._getValue(this._options.markDirectories, false);
10727
+ this.objectMode = this._getValue(this._options.objectMode, false);
10728
+ this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
10729
+ this.onlyFiles = this._getValue(this._options.onlyFiles, true);
10730
+ this.stats = this._getValue(this._options.stats, false);
10731
+ this.suppressErrors = this._getValue(this._options.suppressErrors, false);
10732
+ this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
10733
+ this.unique = this._getValue(this._options.unique, true);
10734
+ if (this.onlyDirectories) {
10735
+ this.onlyFiles = false;
10736
+ }
10737
+ if (this.stats) {
10738
+ this.objectMode = true;
10739
+ }
10740
+ // Remove the cast to the array in the next major (#404).
10741
+ this.ignore = [].concat(this.ignore);
10742
+ }
10743
+ _getValue(option, value) {
10744
+ return option === undefined ? value : option;
10745
+ }
10746
+ _getFileSystemMethods(methods = {}) {
10747
+ return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
10748
+ }
10749
+ }
10646
10750
  exports.default = Settings;
10647
10751
  } (settings));
10648
10752
 
10649
- const taskManager = tasks;
10650
- const patternManager = patterns;
10651
- const async_1 = async$7;
10652
- const stream_1 = stream;
10653
- const sync_1 = sync$1;
10654
- const settings_1 = settings;
10655
- const utils = utils$k;
10656
- async function FastGlob(source, options) {
10657
- assertPatternsInput(source);
10658
- const works = getWorks(source, async_1.default, options);
10659
- const result = await Promise.all(works);
10660
- return utils.array.flatten(result);
10661
- }
10662
- // https://github.com/typescript-eslint/typescript-eslint/issues/60
10663
- // eslint-disable-next-line no-redeclare
10664
- (function (FastGlob) {
10665
- function sync(source, options) {
10666
- assertPatternsInput(source);
10667
- const works = getWorks(source, sync_1.default, options);
10668
- return utils.array.flatten(works);
10669
- }
10670
- FastGlob.sync = sync;
10671
- function stream(source, options) {
10672
- assertPatternsInput(source);
10673
- const works = getWorks(source, stream_1.default, options);
10674
- /**
10675
- * The stream returned by the provider cannot work with an asynchronous iterator.
10676
- * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
10677
- * This affects performance (+25%). I don't see best solution right now.
10678
- */
10679
- return utils.stream.merge(works);
10680
- }
10681
- FastGlob.stream = stream;
10682
- function generateTasks(source, options) {
10683
- assertPatternsInput(source);
10684
- const patterns = patternManager.transform([].concat(source));
10685
- const settings = new settings_1.default(options);
10686
- return taskManager.generate(patterns, settings);
10687
- }
10688
- FastGlob.generateTasks = generateTasks;
10689
- function isDynamicPattern(source, options) {
10690
- assertPatternsInput(source);
10691
- const settings = new settings_1.default(options);
10692
- return utils.pattern.isDynamicPattern(source, settings);
10693
- }
10694
- FastGlob.isDynamicPattern = isDynamicPattern;
10695
- function escapePath(source) {
10696
- assertPatternsInput(source);
10697
- return utils.path.escape(source);
10698
- }
10699
- FastGlob.escapePath = escapePath;
10700
- })(FastGlob || (FastGlob = {}));
10701
- function getWorks(source, _Provider, options) {
10702
- const patterns = patternManager.transform([].concat(source));
10703
- const settings = new settings_1.default(options);
10704
- const tasks = taskManager.generate(patterns, settings);
10705
- const provider = new _Provider(settings);
10706
- return tasks.map(provider.read, provider);
10707
- }
10708
- function assertPatternsInput(input) {
10709
- const source = [].concat(input);
10710
- const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
10711
- if (!isValidSource) {
10712
- throw new TypeError('Patterns must be a string (non empty) or an array of strings');
10713
- }
10714
- }
10753
+ const taskManager = tasks;
10754
+ const async_1 = async$7;
10755
+ const stream_1 = stream;
10756
+ const sync_1 = sync$1;
10757
+ const settings_1 = settings;
10758
+ const utils = utils$k;
10759
+ async function FastGlob(source, options) {
10760
+ assertPatternsInput(source);
10761
+ const works = getWorks(source, async_1.default, options);
10762
+ const result = await Promise.all(works);
10763
+ return utils.array.flatten(result);
10764
+ }
10765
+ // https://github.com/typescript-eslint/typescript-eslint/issues/60
10766
+ // eslint-disable-next-line no-redeclare
10767
+ (function (FastGlob) {
10768
+ FastGlob.glob = FastGlob;
10769
+ FastGlob.globSync = sync;
10770
+ FastGlob.globStream = stream;
10771
+ FastGlob.async = FastGlob;
10772
+ function sync(source, options) {
10773
+ assertPatternsInput(source);
10774
+ const works = getWorks(source, sync_1.default, options);
10775
+ return utils.array.flatten(works);
10776
+ }
10777
+ FastGlob.sync = sync;
10778
+ function stream(source, options) {
10779
+ assertPatternsInput(source);
10780
+ const works = getWorks(source, stream_1.default, options);
10781
+ /**
10782
+ * The stream returned by the provider cannot work with an asynchronous iterator.
10783
+ * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
10784
+ * This affects performance (+25%). I don't see best solution right now.
10785
+ */
10786
+ return utils.stream.merge(works);
10787
+ }
10788
+ FastGlob.stream = stream;
10789
+ function generateTasks(source, options) {
10790
+ assertPatternsInput(source);
10791
+ const patterns = [].concat(source);
10792
+ const settings = new settings_1.default(options);
10793
+ return taskManager.generate(patterns, settings);
10794
+ }
10795
+ FastGlob.generateTasks = generateTasks;
10796
+ function isDynamicPattern(source, options) {
10797
+ assertPatternsInput(source);
10798
+ const settings = new settings_1.default(options);
10799
+ return utils.pattern.isDynamicPattern(source, settings);
10800
+ }
10801
+ FastGlob.isDynamicPattern = isDynamicPattern;
10802
+ function escapePath(source) {
10803
+ assertPatternsInput(source);
10804
+ return utils.path.escape(source);
10805
+ }
10806
+ FastGlob.escapePath = escapePath;
10807
+ function convertPathToPattern(source) {
10808
+ assertPatternsInput(source);
10809
+ return utils.path.convertPathToPattern(source);
10810
+ }
10811
+ FastGlob.convertPathToPattern = convertPathToPattern;
10812
+ (function (posix) {
10813
+ function escapePath(source) {
10814
+ assertPatternsInput(source);
10815
+ return utils.path.escapePosixPath(source);
10816
+ }
10817
+ posix.escapePath = escapePath;
10818
+ function convertPathToPattern(source) {
10819
+ assertPatternsInput(source);
10820
+ return utils.path.convertPosixPathToPattern(source);
10821
+ }
10822
+ posix.convertPathToPattern = convertPathToPattern;
10823
+ })(FastGlob.posix || (FastGlob.posix = {}));
10824
+ (function (win32) {
10825
+ function escapePath(source) {
10826
+ assertPatternsInput(source);
10827
+ return utils.path.escapeWindowsPath(source);
10828
+ }
10829
+ win32.escapePath = escapePath;
10830
+ function convertPathToPattern(source) {
10831
+ assertPatternsInput(source);
10832
+ return utils.path.convertWindowsPathToPattern(source);
10833
+ }
10834
+ win32.convertPathToPattern = convertPathToPattern;
10835
+ })(FastGlob.win32 || (FastGlob.win32 = {}));
10836
+ })(FastGlob || (FastGlob = {}));
10837
+ function getWorks(source, _Provider, options) {
10838
+ const patterns = [].concat(source);
10839
+ const settings = new settings_1.default(options);
10840
+ const tasks = taskManager.generate(patterns, settings);
10841
+ const provider = new _Provider(settings);
10842
+ return tasks.map(provider.read, provider);
10843
+ }
10844
+ function assertPatternsInput(input) {
10845
+ const source = [].concat(input);
10846
+ const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
10847
+ if (!isValidSource) {
10848
+ throw new TypeError('Patterns must be a string (non empty) or an array of strings');
10849
+ }
10850
+ }
10715
10851
  var out = FastGlob;
10716
10852
 
10717
10853
  var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
10718
10854
 
10855
+ const defaultOptions = {
10856
+ hostname: "http://localhost/",
10857
+ dynamicRoutes: [],
10858
+ exclude: [],
10859
+ basePath: "",
10860
+ outDir: "dist",
10861
+ extensions: "html",
10862
+ changefreq: "daily",
10863
+ priority: 1,
10864
+ lastmod: /* @__PURE__ */ new Date(),
10865
+ readable: false,
10866
+ generateRobotsTxt: true,
10867
+ robots: [{
10868
+ userAgent: "*",
10869
+ allow: "/"
10870
+ }]
10871
+ };
10719
10872
  function resolveOptions(userOptions) {
10720
10873
  return Object.assign(
10721
- {
10722
- hostname: "http://localhost/",
10723
- dynamicRoutes: [],
10724
- exclude: [],
10725
- basePath: "",
10726
- outDir: "dist",
10727
- extensions: "html",
10728
- changefreq: "daily",
10729
- priority: 1,
10730
- lastmod: /* @__PURE__ */ new Date(),
10731
- readable: false,
10732
- generateRobotsTxt: true,
10733
- robots: [{
10734
- userAgent: "*",
10735
- allow: "/"
10736
- }]
10737
- },
10874
+ {},
10875
+ defaultOptions,
10738
10876
  userOptions
10739
10877
  );
10740
10878
  }
@@ -10799,12 +10937,22 @@ function getRoutes(options) {
10799
10937
  ...options.dynamicRoutes.map((route) => slash$1(join("/", join(parse$4(route).dir, parse$4(route).name))))
10800
10938
  ].filter((route) => !options.exclude.includes(route));
10801
10939
  }
10940
+ function getOptionByRoute(options, route) {
10941
+ if (options instanceof Date || typeof options === "string" || typeof options === "number")
10942
+ return options;
10943
+ const givenRoutes = Object.keys(options);
10944
+ if (givenRoutes.includes(route))
10945
+ return options[route];
10946
+ if (givenRoutes.includes("*"))
10947
+ return options["*"];
10948
+ return void 0;
10949
+ }
10802
10950
  function getFormattedSitemap(options, routes) {
10803
10951
  return routes.map((route) => ({
10804
10952
  url: new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href,
10805
- changefreq: options.changefreq,
10806
- priority: options.priority,
10807
- lastmod: options.lastmod
10953
+ changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
10954
+ priority: getOptionByRoute(options.priority, route) ?? defaultOptions.priority,
10955
+ lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
10808
10956
  }));
10809
10957
  }
10810
10958