@parcel/utils 2.0.0-canary.1826 → 2.0.0-canary.1832

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/lib/index.js CHANGED
@@ -29908,7 +29908,7 @@ var $a1480222e26dd21e$exports = {};
29908
29908
  Object.defineProperty($a1480222e26dd21e$exports, "__esModule", {
29909
29909
  value: true
29910
29910
  });
29911
- $a1480222e26dd21e$exports.removeDuplicateSlashes = $a1480222e26dd21e$exports.matchAny = $a1480222e26dd21e$exports.convertPatternsToRe = $a1480222e26dd21e$exports.makeRe = $a1480222e26dd21e$exports.getPatternParts = $a1480222e26dd21e$exports.expandBraceExpansion = $a1480222e26dd21e$exports.expandPatternsWithBraceExpansion = $a1480222e26dd21e$exports.isAffectDepthOfReadingPattern = $a1480222e26dd21e$exports.endsWithSlashGlobStar = $a1480222e26dd21e$exports.hasGlobStar = $a1480222e26dd21e$exports.getBaseDirectory = $a1480222e26dd21e$exports.isPatternRelatedToParentDirectory = $a1480222e26dd21e$exports.getPatternsOutsideCurrentDirectory = $a1480222e26dd21e$exports.getPatternsInsideCurrentDirectory = $a1480222e26dd21e$exports.getPositivePatterns = $a1480222e26dd21e$exports.getNegativePatterns = $a1480222e26dd21e$exports.isPositivePattern = $a1480222e26dd21e$exports.isNegativePattern = $a1480222e26dd21e$exports.convertToNegativePattern = $a1480222e26dd21e$exports.convertToPositivePattern = $a1480222e26dd21e$exports.isDynamicPattern = $a1480222e26dd21e$exports.isStaticPattern = void 0;
29911
+ $a1480222e26dd21e$exports.isAbsolute = $a1480222e26dd21e$exports.partitionAbsoluteAndRelative = $a1480222e26dd21e$exports.removeDuplicateSlashes = $a1480222e26dd21e$exports.matchAny = $a1480222e26dd21e$exports.convertPatternsToRe = $a1480222e26dd21e$exports.makeRe = $a1480222e26dd21e$exports.getPatternParts = $a1480222e26dd21e$exports.expandBraceExpansion = $a1480222e26dd21e$exports.expandPatternsWithBraceExpansion = $a1480222e26dd21e$exports.isAffectDepthOfReadingPattern = $a1480222e26dd21e$exports.endsWithSlashGlobStar = $a1480222e26dd21e$exports.hasGlobStar = $a1480222e26dd21e$exports.getBaseDirectory = $a1480222e26dd21e$exports.isPatternRelatedToParentDirectory = $a1480222e26dd21e$exports.getPatternsOutsideCurrentDirectory = $a1480222e26dd21e$exports.getPatternsInsideCurrentDirectory = $a1480222e26dd21e$exports.getPositivePatterns = $a1480222e26dd21e$exports.getNegativePatterns = $a1480222e26dd21e$exports.isPositivePattern = $a1480222e26dd21e$exports.isNegativePattern = $a1480222e26dd21e$exports.convertToNegativePattern = $a1480222e26dd21e$exports.convertToPositivePattern = $a1480222e26dd21e$exports.isDynamicPattern = $a1480222e26dd21e$exports.isStaticPattern = void 0;
29912
29912
 
29913
29913
  var $61d87f3276971c3e$exports = {};
29914
29914
  'use strict';
@@ -31616,6 +31616,21 @@ $a1480222e26dd21e$exports.matchAny = $a1480222e26dd21e$var$matchAny;
31616
31616
  return pattern.replace($a1480222e26dd21e$var$DOUBLE_SLASH_RE, '/');
31617
31617
  }
31618
31618
  $a1480222e26dd21e$exports.removeDuplicateSlashes = $a1480222e26dd21e$var$removeDuplicateSlashes;
31619
+ function $a1480222e26dd21e$var$partitionAbsoluteAndRelative(patterns) {
31620
+ const absolute = [];
31621
+ const relative = [];
31622
+ for (const pattern of patterns)if ($a1480222e26dd21e$var$isAbsolute(pattern)) absolute.push(pattern);
31623
+ else relative.push(pattern);
31624
+ return [
31625
+ absolute,
31626
+ relative
31627
+ ];
31628
+ }
31629
+ $a1480222e26dd21e$exports.partitionAbsoluteAndRelative = $a1480222e26dd21e$var$partitionAbsoluteAndRelative;
31630
+ function $a1480222e26dd21e$var$isAbsolute(pattern) {
31631
+ return $houHs$path.isAbsolute(pattern);
31632
+ }
31633
+ $a1480222e26dd21e$exports.isAbsolute = $a1480222e26dd21e$var$isAbsolute;
31619
31634
 
31620
31635
 
31621
31636
  $51df6bfca103aef8$exports.pattern = $a1480222e26dd21e$exports;
@@ -33190,19 +33205,27 @@ class $b326f718dda03c34$var$EntryFilter {
33190
33205
  this.index = new Map();
33191
33206
  }
33192
33207
  getFilter(positive, negative) {
33193
- const positiveRe = $51df6bfca103aef8$exports.pattern.convertPatternsToRe(positive, this._micromatchOptions);
33194
- const negativeRe = $51df6bfca103aef8$exports.pattern.convertPatternsToRe(negative, Object.assign(Object.assign({}, this._micromatchOptions), {
33195
- dot: true
33196
- }));
33197
- return (entry)=>this._filter(entry, positiveRe, negativeRe);
33208
+ const [absoluteNegative, relativeNegative] = $51df6bfca103aef8$exports.pattern.partitionAbsoluteAndRelative(negative);
33209
+ const patterns = {
33210
+ positive: {
33211
+ all: $51df6bfca103aef8$exports.pattern.convertPatternsToRe(positive, this._micromatchOptions)
33212
+ },
33213
+ negative: {
33214
+ absolute: $51df6bfca103aef8$exports.pattern.convertPatternsToRe(absoluteNegative, Object.assign(Object.assign({}, this._micromatchOptions), {
33215
+ dot: true
33216
+ })),
33217
+ relative: $51df6bfca103aef8$exports.pattern.convertPatternsToRe(relativeNegative, Object.assign(Object.assign({}, this._micromatchOptions), {
33218
+ dot: true
33219
+ }))
33220
+ }
33221
+ };
33222
+ return (entry)=>this._filter(entry, patterns);
33198
33223
  }
33199
- _filter(entry, positiveRe, negativeRe) {
33224
+ _filter(entry, patterns) {
33200
33225
  const filepath = $51df6bfca103aef8$exports.path.removeLeadingDotSegment(entry.path);
33201
33226
  if (this._settings.unique && this._isDuplicateEntry(filepath)) return false;
33202
33227
  if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) return false;
33203
- if (this._isSkippedByAbsoluteNegativePatterns(filepath, negativeRe)) return false;
33204
- const isDirectory = entry.dirent.isDirectory();
33205
- const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(filepath, negativeRe, isDirectory);
33228
+ const isMatched = this._isMatchToPatternsSet(filepath, patterns, entry.dirent.isDirectory());
33206
33229
  if (this._settings.unique && isMatched) this._createIndexRecord(filepath);
33207
33230
  return isMatched;
33208
33231
  }
@@ -33218,12 +33241,22 @@ class $b326f718dda03c34$var$EntryFilter {
33218
33241
  _onlyDirectoryFilter(entry) {
33219
33242
  return this._settings.onlyDirectories && !entry.dirent.isDirectory();
33220
33243
  }
33221
- _isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
33222
- if (!this._settings.absolute) return false;
33223
- const fullpath = $51df6bfca103aef8$exports.path.makeAbsolute(this._settings.cwd, entryPath);
33224
- return $51df6bfca103aef8$exports.pattern.matchAny(fullpath, patternsRe);
33244
+ _isMatchToPatternsSet(filepath, patterns, isDirectory) {
33245
+ const isMatched = this._isMatchToPatterns(filepath, patterns.positive.all, isDirectory);
33246
+ if (!isMatched) return false;
33247
+ const isMatchedByRelativeNegative = this._isMatchToPatterns(filepath, patterns.negative.relative, isDirectory);
33248
+ if (isMatchedByRelativeNegative) return false;
33249
+ const isMatchedByAbsoluteNegative = this._isMatchToAbsoluteNegative(filepath, patterns.negative.absolute, isDirectory);
33250
+ if (isMatchedByAbsoluteNegative) return false;
33251
+ return true;
33252
+ }
33253
+ _isMatchToAbsoluteNegative(filepath, patternsRe, isDirectory) {
33254
+ if (patternsRe.length === 0) return false;
33255
+ const fullpath = $51df6bfca103aef8$exports.path.makeAbsolute(this._settings.cwd, filepath);
33256
+ return this._isMatchToPatterns(fullpath, patternsRe, isDirectory);
33225
33257
  }
33226
33258
  _isMatchToPatterns(filepath, patternsRe, isDirectory) {
33259
+ if (patternsRe.length === 0) return false;
33227
33260
  // Trying to match files and directories by patterns.
33228
33261
  const isMatched = $51df6bfca103aef8$exports.pattern.matchAny(filepath, patternsRe);
33229
33262
  // A pattern with a trailling slash can be used for directory matching.