@parcel/utils 2.0.0-dev.1712 → 2.0.0-dev.1781
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 +1557 -630
- package/lib/index.js.map +1 -1
- package/package.json +9 -10
- package/src/config.js +3 -3
- package/src/index.js +1 -0
- package/src/svgo.js +50 -0
- package/test/PromiseQueue.test.js +1 -2
package/lib/index.js
CHANGED
|
@@ -2506,6 +2506,11 @@ function makeParserClass(Parser) {
|
|
|
2506
2506
|
else if (this.atEndOfWord()) throw this.error(new TomlError('Incomplete number'));
|
|
2507
2507
|
return this.returnNow();
|
|
2508
2508
|
}
|
|
2509
|
+
parseNoUnderHexOctBinLiteral() {
|
|
2510
|
+
if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) throw this.error(new TomlError('Unexpected character, expected digit'));
|
|
2511
|
+
else if (this.atEndOfWord()) throw this.error(new TomlError('Incomplete number'));
|
|
2512
|
+
return this.returnNow();
|
|
2513
|
+
}
|
|
2509
2514
|
parseNumberFloat() {
|
|
2510
2515
|
if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnder, this.parseNumberFloat);
|
|
2511
2516
|
else if (isDigit(this.char)) this.consume();
|
|
@@ -2561,20 +2566,20 @@ function makeParserClass(Parser) {
|
|
|
2561
2566
|
parseNumberBaseOrDateTime() {
|
|
2562
2567
|
if (this.char === CHAR_b) {
|
|
2563
2568
|
this.consume();
|
|
2564
|
-
return this.call(this.
|
|
2569
|
+
return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin);
|
|
2565
2570
|
} else if (this.char === CHAR_o) {
|
|
2566
2571
|
this.consume();
|
|
2567
|
-
return this.call(this.
|
|
2572
|
+
return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct);
|
|
2568
2573
|
} else if (this.char === CHAR_x) {
|
|
2569
2574
|
this.consume();
|
|
2570
|
-
return this.call(this.
|
|
2575
|
+
return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex);
|
|
2571
2576
|
} else if (this.char === CHAR_PERIOD) return this.goto(this.parseNumberInteger);
|
|
2572
2577
|
else if (isDigit(this.char)) return this.goto(this.parseDateTimeOnly);
|
|
2573
2578
|
else return this.returnNow(Integer(this.state.buf));
|
|
2574
2579
|
}
|
|
2575
2580
|
parseIntegerHex() {
|
|
2576
2581
|
if (isHexit(this.char)) this.consume();
|
|
2577
|
-
else if (this.char === CHAR_LOWBAR) return this.call(this.
|
|
2582
|
+
else if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
2578
2583
|
else {
|
|
2579
2584
|
const result = Integer(this.state.buf);
|
|
2580
2585
|
/* istanbul ignore if */ if (result.isNaN()) throw this.error(new TomlError('Invalid number'));
|
|
@@ -2583,7 +2588,7 @@ function makeParserClass(Parser) {
|
|
|
2583
2588
|
}
|
|
2584
2589
|
parseIntegerOct() {
|
|
2585
2590
|
if (isOctit(this.char)) this.consume();
|
|
2586
|
-
else if (this.char === CHAR_LOWBAR) return this.call(this.
|
|
2591
|
+
else if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
2587
2592
|
else {
|
|
2588
2593
|
const result = Integer(this.state.buf);
|
|
2589
2594
|
/* istanbul ignore if */ if (result.isNaN()) throw this.error(new TomlError('Invalid number'));
|
|
@@ -2592,7 +2597,7 @@ function makeParserClass(Parser) {
|
|
|
2592
2597
|
}
|
|
2593
2598
|
parseIntegerBin() {
|
|
2594
2599
|
if (isBit(this.char)) this.consume();
|
|
2595
|
-
else if (this.char === CHAR_LOWBAR) return this.call(this.
|
|
2600
|
+
else if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
2596
2601
|
else {
|
|
2597
2602
|
const result = Integer(this.state.buf);
|
|
2598
2603
|
/* istanbul ignore if */ if (result.isNaN()) throw this.error(new TomlError('Invalid number'));
|
|
@@ -2621,7 +2626,7 @@ function makeParserClass(Parser) {
|
|
|
2621
2626
|
this.state.result += '-' + this.state.buf;
|
|
2622
2627
|
this.state.buf = '';
|
|
2623
2628
|
return this.next(this.parseStartTimeHour);
|
|
2624
|
-
} else if (this.atEndOfWord()) return this.
|
|
2629
|
+
} else if (this.atEndOfWord()) return this.returnNow($juH0i(this.state.result + '-' + this.state.buf));
|
|
2625
2630
|
else if (isDigit(this.char)) this.consume();
|
|
2626
2631
|
else throw this.error(new TomlError('Incomplete datetime'));
|
|
2627
2632
|
}
|
|
@@ -3404,16 +3409,6 @@ function $d3ba36a78a2cb705$var$stringifyComplexTable(prefix, indent, key, value)
|
|
|
3404
3409
|
|
|
3405
3410
|
});
|
|
3406
3411
|
|
|
3407
|
-
parcelRegister("ff5ZV", function(module, exports) {
|
|
3408
|
-
'use strict';
|
|
3409
|
-
module.exports = function(Yallist) {
|
|
3410
|
-
Yallist.prototype[Symbol.iterator] = function*() {
|
|
3411
|
-
for(let walker = this.head; walker; walker = walker.next)yield walker.value;
|
|
3412
|
-
};
|
|
3413
|
-
};
|
|
3414
|
-
|
|
3415
|
-
});
|
|
3416
|
-
|
|
3417
3412
|
|
|
3418
3413
|
$parcel$export(module.exports, "countLines", () => $2dffa662028edb3d$export$2e2bcd8739ae039);
|
|
3419
3414
|
$parcel$export(module.exports, "generateBuildMetrics", () => $4ada344be2626398$export$2e2bcd8739ae039);
|
|
@@ -3487,6 +3482,7 @@ $parcel$export(module.exports, "loadSourceMapUrl", () => $3d4b4a41954c6194$expor
|
|
|
3487
3482
|
$parcel$export(module.exports, "loadSourceMap", () => $3d4b4a41954c6194$export$c500fecaca54de65);
|
|
3488
3483
|
$parcel$export(module.exports, "remapSourceLocation", () => $3d4b4a41954c6194$export$2fed780245c466c1);
|
|
3489
3484
|
$parcel$export(module.exports, "stripAnsi", () => (/*@__PURE__*/$parcel$interopDefault($c6e7686f671d96bd$exports)));
|
|
3485
|
+
$parcel$export(module.exports, "detectSVGOVersion", () => $898ec9690c913f83$export$d9e46360b4510851);
|
|
3490
3486
|
function $2dffa662028edb3d$export$2e2bcd8739ae039(string, startIndex = 0) {
|
|
3491
3487
|
let lines = 1;
|
|
3492
3488
|
for(let i = startIndex; i < string.length; i++)if (string.charAt(i) === '\n') lines++;
|
|
@@ -15274,6 +15270,9 @@ var $e581af606dac1487$var$digestInfoValidator = {
|
|
|
15274
15270
|
name: 'DigestInfo.DigestAlgorithm.parameters',
|
|
15275
15271
|
tagClass: $e581af606dac1487$var$asn1.Class.UNIVERSAL,
|
|
15276
15272
|
type: $e581af606dac1487$var$asn1.Type.NULL,
|
|
15273
|
+
// captured only to check existence for md2 and md5
|
|
15274
|
+
capture: 'parameters',
|
|
15275
|
+
optional: true,
|
|
15277
15276
|
constructed: false
|
|
15278
15277
|
}
|
|
15279
15278
|
]
|
|
@@ -16027,6 +16026,10 @@ var $e581af606dac1487$var$digestInfoValidator = {
|
|
|
16027
16026
|
error.oid = oid;
|
|
16028
16027
|
throw error;
|
|
16029
16028
|
}
|
|
16029
|
+
// special check for md2 and md5 that NULL parameters exist
|
|
16030
|
+
if (oid === $ctKnW.oids.md2 || oid === $ctKnW.oids.md5) {
|
|
16031
|
+
if (!('parameters' in capture)) throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");
|
|
16032
|
+
}
|
|
16030
16033
|
// compare the given digest to the decrypted one
|
|
16031
16034
|
return digest === capture.digest;
|
|
16032
16035
|
}
|
|
@@ -29836,12 +29839,28 @@ var $5de4bfe78cb104cd$exports = {};
|
|
|
29836
29839
|
Object.defineProperty($5de4bfe78cb104cd$exports, "__esModule", {
|
|
29837
29840
|
value: true
|
|
29838
29841
|
});
|
|
29839
|
-
$5de4bfe78cb104cd$exports.
|
|
29842
|
+
$5de4bfe78cb104cd$exports.convertPosixPathToPattern = $5de4bfe78cb104cd$exports.convertWindowsPathToPattern = $5de4bfe78cb104cd$exports.convertPathToPattern = $5de4bfe78cb104cd$exports.escapePosixPath = $5de4bfe78cb104cd$exports.escapeWindowsPath = $5de4bfe78cb104cd$exports.escape = $5de4bfe78cb104cd$exports.removeLeadingDotSegment = $5de4bfe78cb104cd$exports.makeAbsolute = $5de4bfe78cb104cd$exports.unixify = void 0;
|
|
29843
|
+
|
|
29840
29844
|
|
|
29845
|
+
const $5de4bfe78cb104cd$var$IS_WINDOWS_PLATFORM = $houHs$os.platform() === 'win32';
|
|
29841
29846
|
const $5de4bfe78cb104cd$var$LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
29842
|
-
|
|
29843
|
-
|
|
29844
|
-
*
|
|
29847
|
+
/**
|
|
29848
|
+
* All non-escaped special characters.
|
|
29849
|
+
* Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
|
|
29850
|
+
* Windows: (){}[], !+@ before (, ! at the beginning.
|
|
29851
|
+
*/ const $5de4bfe78cb104cd$var$POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
29852
|
+
const $5de4bfe78cb104cd$var$WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
29853
|
+
/**
|
|
29854
|
+
* The device path (\\.\ or \\?\).
|
|
29855
|
+
* https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
|
|
29856
|
+
*/ const $5de4bfe78cb104cd$var$DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
|
|
29857
|
+
/**
|
|
29858
|
+
* All backslashes except those escaping special characters.
|
|
29859
|
+
* Windows: !()+@{}
|
|
29860
|
+
* https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
|
29861
|
+
*/ const $5de4bfe78cb104cd$var$WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
|
|
29862
|
+
/**
|
|
29863
|
+
* Designed to work only with simple paths: `dir\\file`.
|
|
29845
29864
|
*/ function $5de4bfe78cb104cd$var$unixify(filepath) {
|
|
29846
29865
|
return filepath.replace(/\\/g, '/');
|
|
29847
29866
|
}
|
|
@@ -29850,10 +29869,6 @@ function $5de4bfe78cb104cd$var$makeAbsolute(cwd, filepath) {
|
|
|
29850
29869
|
return $houHs$path.resolve(cwd, filepath);
|
|
29851
29870
|
}
|
|
29852
29871
|
$5de4bfe78cb104cd$exports.makeAbsolute = $5de4bfe78cb104cd$var$makeAbsolute;
|
|
29853
|
-
function $5de4bfe78cb104cd$var$escape(pattern) {
|
|
29854
|
-
return pattern.replace($5de4bfe78cb104cd$var$UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
|
|
29855
|
-
}
|
|
29856
|
-
$5de4bfe78cb104cd$exports.escape = $5de4bfe78cb104cd$var$escape;
|
|
29857
29872
|
function $5de4bfe78cb104cd$var$removeLeadingDotSegment(entry) {
|
|
29858
29873
|
// We do not use `startsWith` because this is 10x slower than current implementation for some cases.
|
|
29859
29874
|
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
|
|
@@ -29864,6 +29879,24 @@ function $5de4bfe78cb104cd$var$removeLeadingDotSegment(entry) {
|
|
|
29864
29879
|
return entry;
|
|
29865
29880
|
}
|
|
29866
29881
|
$5de4bfe78cb104cd$exports.removeLeadingDotSegment = $5de4bfe78cb104cd$var$removeLeadingDotSegment;
|
|
29882
|
+
$5de4bfe78cb104cd$exports.escape = $5de4bfe78cb104cd$var$IS_WINDOWS_PLATFORM ? $5de4bfe78cb104cd$var$escapeWindowsPath : $5de4bfe78cb104cd$var$escapePosixPath;
|
|
29883
|
+
function $5de4bfe78cb104cd$var$escapeWindowsPath(pattern) {
|
|
29884
|
+
return pattern.replace($5de4bfe78cb104cd$var$WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
|
|
29885
|
+
}
|
|
29886
|
+
$5de4bfe78cb104cd$exports.escapeWindowsPath = $5de4bfe78cb104cd$var$escapeWindowsPath;
|
|
29887
|
+
function $5de4bfe78cb104cd$var$escapePosixPath(pattern) {
|
|
29888
|
+
return pattern.replace($5de4bfe78cb104cd$var$POSIX_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
|
|
29889
|
+
}
|
|
29890
|
+
$5de4bfe78cb104cd$exports.escapePosixPath = $5de4bfe78cb104cd$var$escapePosixPath;
|
|
29891
|
+
$5de4bfe78cb104cd$exports.convertPathToPattern = $5de4bfe78cb104cd$var$IS_WINDOWS_PLATFORM ? $5de4bfe78cb104cd$var$convertWindowsPathToPattern : $5de4bfe78cb104cd$var$convertPosixPathToPattern;
|
|
29892
|
+
function $5de4bfe78cb104cd$var$convertWindowsPathToPattern(filepath) {
|
|
29893
|
+
return $5de4bfe78cb104cd$var$escapeWindowsPath(filepath).replace($5de4bfe78cb104cd$var$DOS_DEVICE_PATH_RE, '//$1').replace($5de4bfe78cb104cd$var$WINDOWS_BACKSLASHES_RE, '/');
|
|
29894
|
+
}
|
|
29895
|
+
$5de4bfe78cb104cd$exports.convertWindowsPathToPattern = $5de4bfe78cb104cd$var$convertWindowsPathToPattern;
|
|
29896
|
+
function $5de4bfe78cb104cd$var$convertPosixPathToPattern(filepath) {
|
|
29897
|
+
return $5de4bfe78cb104cd$var$escapePosixPath(filepath);
|
|
29898
|
+
}
|
|
29899
|
+
$5de4bfe78cb104cd$exports.convertPosixPathToPattern = $5de4bfe78cb104cd$var$convertPosixPathToPattern;
|
|
29867
29900
|
|
|
29868
29901
|
|
|
29869
29902
|
$51df6bfca103aef8$exports.path = $5de4bfe78cb104cd$exports;
|
|
@@ -29872,7 +29905,7 @@ var $a1480222e26dd21e$exports = {};
|
|
|
29872
29905
|
Object.defineProperty($a1480222e26dd21e$exports, "__esModule", {
|
|
29873
29906
|
value: true
|
|
29874
29907
|
});
|
|
29875
|
-
$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;
|
|
29908
|
+
$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;
|
|
29876
29909
|
|
|
29877
29910
|
var $61d87f3276971c3e$exports = {};
|
|
29878
29911
|
'use strict';
|
|
@@ -31032,7 +31065,11 @@ $f30ff4896fda5c70$exports = (parcelRequire("6TnoJ"));
|
|
|
31032
31065
|
|
|
31033
31066
|
|
|
31034
31067
|
var $7UcG9 = parcelRequire("7UcG9");
|
|
31035
|
-
const $00cf20914f274048$var$isEmptyString = (
|
|
31068
|
+
const $00cf20914f274048$var$isEmptyString = (v)=>v === '' || v === './';
|
|
31069
|
+
const $00cf20914f274048$var$hasBraces = (v)=>{
|
|
31070
|
+
const index = v.indexOf('{');
|
|
31071
|
+
return index > -1 && v.indexOf('}', index) > -1;
|
|
31072
|
+
};
|
|
31036
31073
|
/**
|
|
31037
31074
|
* Returns an array of strings that match one or more glob patterns.
|
|
31038
31075
|
*
|
|
@@ -31389,7 +31426,7 @@ const $00cf20914f274048$var$isEmptyString = (val)=>val === '' || val === './';
|
|
|
31389
31426
|
* @api public
|
|
31390
31427
|
*/ $00cf20914f274048$var$micromatch.braces = (pattern, options)=>{
|
|
31391
31428
|
if (typeof pattern !== 'string') throw new TypeError('Expected a string');
|
|
31392
|
-
if (options && options.nobrace === true ||
|
|
31429
|
+
if (options && options.nobrace === true || !$00cf20914f274048$var$hasBraces(pattern)) return [
|
|
31393
31430
|
pattern
|
|
31394
31431
|
];
|
|
31395
31432
|
return $5a424cf505ecaf3c$exports(pattern, options);
|
|
@@ -31405,7 +31442,9 @@ const $00cf20914f274048$var$isEmptyString = (val)=>val === '' || val === './';
|
|
|
31405
31442
|
};
|
|
31406
31443
|
/**
|
|
31407
31444
|
* Expose micromatch
|
|
31408
|
-
*/
|
|
31445
|
+
*/ // exposed for tests
|
|
31446
|
+
$00cf20914f274048$var$micromatch.hasBraces = $00cf20914f274048$var$hasBraces;
|
|
31447
|
+
$00cf20914f274048$exports = $00cf20914f274048$var$micromatch;
|
|
31409
31448
|
|
|
31410
31449
|
|
|
31411
31450
|
const $a1480222e26dd21e$var$GLOBSTAR = '**';
|
|
@@ -31415,19 +31454,23 @@ const $a1480222e26dd21e$var$REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
|
|
|
31415
31454
|
const $a1480222e26dd21e$var$REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
|
|
31416
31455
|
const $a1480222e26dd21e$var$GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
|
|
31417
31456
|
const $a1480222e26dd21e$var$BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
|
|
31457
|
+
/**
|
|
31458
|
+
* Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
|
|
31459
|
+
* The latter is due to the presence of the device path at the beginning of the UNC path.
|
|
31460
|
+
*/ const $a1480222e26dd21e$var$DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
|
|
31418
31461
|
function $a1480222e26dd21e$var$isStaticPattern(pattern, options = {}) {
|
|
31419
31462
|
return !$a1480222e26dd21e$var$isDynamicPattern(pattern, options);
|
|
31420
31463
|
}
|
|
31421
31464
|
$a1480222e26dd21e$exports.isStaticPattern = $a1480222e26dd21e$var$isStaticPattern;
|
|
31422
31465
|
function $a1480222e26dd21e$var$isDynamicPattern(pattern, options = {}) {
|
|
31423
|
-
/**
|
|
31424
|
-
* A special case with an empty string is necessary for matching patterns that start with a forward slash.
|
|
31425
|
-
* An empty string cannot be a dynamic pattern.
|
|
31426
|
-
* For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
|
|
31466
|
+
/**
|
|
31467
|
+
* A special case with an empty string is necessary for matching patterns that start with a forward slash.
|
|
31468
|
+
* An empty string cannot be a dynamic pattern.
|
|
31469
|
+
* For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
|
|
31427
31470
|
*/ if (pattern === '') return false;
|
|
31428
|
-
/**
|
|
31429
|
-
* When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
|
|
31430
|
-
* filepath directly (without read directory).
|
|
31471
|
+
/**
|
|
31472
|
+
* When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
|
|
31473
|
+
* filepath directly (without read directory).
|
|
31431
31474
|
*/ if (options.caseSensitiveMatch === false || pattern.includes($a1480222e26dd21e$var$ESCAPE_SYMBOL)) return true;
|
|
31432
31475
|
if ($a1480222e26dd21e$var$COMMON_GLOB_SYMBOLS_RE.test(pattern) || $a1480222e26dd21e$var$REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || $a1480222e26dd21e$var$REGEX_GROUP_SYMBOLS_RE.test(pattern)) return true;
|
|
31433
31476
|
if (options.extglob !== false && $a1480222e26dd21e$var$GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) return true;
|
|
@@ -31467,22 +31510,22 @@ function $a1480222e26dd21e$var$getPositivePatterns(patterns) {
|
|
|
31467
31510
|
return patterns.filter($a1480222e26dd21e$var$isPositivePattern);
|
|
31468
31511
|
}
|
|
31469
31512
|
$a1480222e26dd21e$exports.getPositivePatterns = $a1480222e26dd21e$var$getPositivePatterns;
|
|
31470
|
-
/**
|
|
31471
|
-
* Returns patterns that can be applied inside the current directory.
|
|
31472
|
-
*
|
|
31473
|
-
* @example
|
|
31474
|
-
* // ['./*', '*', 'a/*']
|
|
31475
|
-
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
31513
|
+
/**
|
|
31514
|
+
* Returns patterns that can be applied inside the current directory.
|
|
31515
|
+
*
|
|
31516
|
+
* @example
|
|
31517
|
+
* // ['./*', '*', 'a/*']
|
|
31518
|
+
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
31476
31519
|
*/ function $a1480222e26dd21e$var$getPatternsInsideCurrentDirectory(patterns) {
|
|
31477
31520
|
return patterns.filter((pattern)=>!$a1480222e26dd21e$var$isPatternRelatedToParentDirectory(pattern));
|
|
31478
31521
|
}
|
|
31479
31522
|
$a1480222e26dd21e$exports.getPatternsInsideCurrentDirectory = $a1480222e26dd21e$var$getPatternsInsideCurrentDirectory;
|
|
31480
|
-
/**
|
|
31481
|
-
* Returns patterns to be expanded relative to (outside) the current directory.
|
|
31482
|
-
*
|
|
31483
|
-
* @example
|
|
31484
|
-
* // ['../*', './../*']
|
|
31485
|
-
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
31523
|
+
/**
|
|
31524
|
+
* Returns patterns to be expanded relative to (outside) the current directory.
|
|
31525
|
+
*
|
|
31526
|
+
* @example
|
|
31527
|
+
* // ['../*', './../*']
|
|
31528
|
+
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
31486
31529
|
*/ function $a1480222e26dd21e$var$getPatternsOutsideCurrentDirectory(patterns) {
|
|
31487
31530
|
return patterns.filter($a1480222e26dd21e$var$isPatternRelatedToParentDirectory);
|
|
31488
31531
|
}
|
|
@@ -31517,25 +31560,33 @@ function $a1480222e26dd21e$var$expandPatternsWithBraceExpansion(patterns) {
|
|
|
31517
31560
|
}
|
|
31518
31561
|
$a1480222e26dd21e$exports.expandPatternsWithBraceExpansion = $a1480222e26dd21e$var$expandPatternsWithBraceExpansion;
|
|
31519
31562
|
function $a1480222e26dd21e$var$expandBraceExpansion(pattern) {
|
|
31520
|
-
|
|
31563
|
+
const patterns = $00cf20914f274048$exports.braces(pattern, {
|
|
31521
31564
|
expand: true,
|
|
31522
|
-
nodupes: true
|
|
31565
|
+
nodupes: true,
|
|
31566
|
+
keepEscaping: true
|
|
31523
31567
|
});
|
|
31568
|
+
/**
|
|
31569
|
+
* Sort the patterns by length so that the same depth patterns are processed side by side.
|
|
31570
|
+
* `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
|
|
31571
|
+
*/ patterns.sort((a, b)=>a.length - b.length);
|
|
31572
|
+
/**
|
|
31573
|
+
* Micromatch can return an empty string in the case of patterns like `{a,}`.
|
|
31574
|
+
*/ return patterns.filter((pattern)=>pattern !== '');
|
|
31524
31575
|
}
|
|
31525
31576
|
$a1480222e26dd21e$exports.expandBraceExpansion = $a1480222e26dd21e$var$expandBraceExpansion;
|
|
31526
31577
|
function $a1480222e26dd21e$var$getPatternParts(pattern, options) {
|
|
31527
31578
|
let { parts: parts } = $00cf20914f274048$exports.scan(pattern, Object.assign(Object.assign({}, options), {
|
|
31528
31579
|
parts: true
|
|
31529
31580
|
}));
|
|
31530
|
-
/**
|
|
31531
|
-
* The scan method returns an empty array in some cases.
|
|
31532
|
-
* See micromatch/picomatch#58 for more details.
|
|
31581
|
+
/**
|
|
31582
|
+
* The scan method returns an empty array in some cases.
|
|
31583
|
+
* See micromatch/picomatch#58 for more details.
|
|
31533
31584
|
*/ if (parts.length === 0) parts = [
|
|
31534
31585
|
pattern
|
|
31535
31586
|
];
|
|
31536
|
-
/**
|
|
31537
|
-
* The scan method does not return an empty part for the pattern with a forward slash.
|
|
31538
|
-
* This is another part of micromatch/picomatch#58.
|
|
31587
|
+
/**
|
|
31588
|
+
* The scan method does not return an empty part for the pattern with a forward slash.
|
|
31589
|
+
* This is another part of micromatch/picomatch#58.
|
|
31539
31590
|
*/ if (parts[0].startsWith('/')) {
|
|
31540
31591
|
parts[0] = parts[0].slice(1);
|
|
31541
31592
|
parts.unshift('');
|
|
@@ -31555,6 +31606,13 @@ function $a1480222e26dd21e$var$matchAny(entry, patternsRe) {
|
|
|
31555
31606
|
return patternsRe.some((patternRe)=>patternRe.test(entry));
|
|
31556
31607
|
}
|
|
31557
31608
|
$a1480222e26dd21e$exports.matchAny = $a1480222e26dd21e$var$matchAny;
|
|
31609
|
+
/**
|
|
31610
|
+
* This package only works with forward slashes as a path separator.
|
|
31611
|
+
* Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
|
|
31612
|
+
*/ function $a1480222e26dd21e$var$removeDuplicateSlashes(pattern) {
|
|
31613
|
+
return pattern.replace($a1480222e26dd21e$var$DOUBLE_SLASH_RE, '/');
|
|
31614
|
+
}
|
|
31615
|
+
$a1480222e26dd21e$exports.removeDuplicateSlashes = $a1480222e26dd21e$var$removeDuplicateSlashes;
|
|
31558
31616
|
|
|
31559
31617
|
|
|
31560
31618
|
$51df6bfca103aef8$exports.pattern = $a1480222e26dd21e$exports;
|
|
@@ -31689,9 +31747,11 @@ $bd079c5b262030e8$exports.isEmpty = $bd079c5b262030e8$var$isEmpty;
|
|
|
31689
31747
|
$51df6bfca103aef8$exports.string = $bd079c5b262030e8$exports;
|
|
31690
31748
|
|
|
31691
31749
|
|
|
31692
|
-
function $4e7c1394e7ae525e$var$generate(
|
|
31750
|
+
function $4e7c1394e7ae525e$var$generate(input, settings) {
|
|
31751
|
+
const patterns = $4e7c1394e7ae525e$var$processPatterns(input, settings);
|
|
31752
|
+
const ignore = $4e7c1394e7ae525e$var$processPatterns(settings.ignore, settings);
|
|
31693
31753
|
const positivePatterns = $4e7c1394e7ae525e$var$getPositivePatterns(patterns);
|
|
31694
|
-
const negativePatterns = $4e7c1394e7ae525e$var$getNegativePatternsAsPositive(patterns,
|
|
31754
|
+
const negativePatterns = $4e7c1394e7ae525e$var$getNegativePatternsAsPositive(patterns, ignore);
|
|
31695
31755
|
const staticPatterns = positivePatterns.filter((pattern)=>$51df6bfca103aef8$exports.pattern.isStaticPattern(pattern, settings));
|
|
31696
31756
|
const dynamicPatterns = positivePatterns.filter((pattern)=>$51df6bfca103aef8$exports.pattern.isDynamicPattern(pattern, settings));
|
|
31697
31757
|
const staticTasks = $4e7c1394e7ae525e$var$convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false);
|
|
@@ -31699,11 +31759,32 @@ function $4e7c1394e7ae525e$var$generate(patterns, settings) {
|
|
|
31699
31759
|
return staticTasks.concat(dynamicTasks);
|
|
31700
31760
|
}
|
|
31701
31761
|
$4e7c1394e7ae525e$exports.generate = $4e7c1394e7ae525e$var$generate;
|
|
31702
|
-
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
31706
|
-
|
|
31762
|
+
function $4e7c1394e7ae525e$var$processPatterns(input, settings) {
|
|
31763
|
+
let patterns = input;
|
|
31764
|
+
/**
|
|
31765
|
+
* The original pattern like `{,*,**,a/*}` can lead to problems checking the depth when matching entry
|
|
31766
|
+
* and some problems with the micromatch package (see fast-glob issues: #365, #394).
|
|
31767
|
+
*
|
|
31768
|
+
* To solve this problem, we expand all patterns containing brace expansion. This can lead to a slight slowdown
|
|
31769
|
+
* in matching in the case of a large set of patterns after expansion.
|
|
31770
|
+
*/ if (settings.braceExpansion) patterns = $51df6bfca103aef8$exports.pattern.expandPatternsWithBraceExpansion(patterns);
|
|
31771
|
+
/**
|
|
31772
|
+
* If the `baseNameMatch` option is enabled, we must add globstar to patterns, so that they can be used
|
|
31773
|
+
* at any nesting level.
|
|
31774
|
+
*
|
|
31775
|
+
* We do this here, because otherwise we have to complicate the filtering logic. For example, we need to change
|
|
31776
|
+
* the pattern in the filter before creating a regular expression. There is no need to change the patterns
|
|
31777
|
+
* in the application. Only on the input.
|
|
31778
|
+
*/ if (settings.baseNameMatch) patterns = patterns.map((pattern)=>pattern.includes('/') ? pattern : `**/${pattern}`);
|
|
31779
|
+
/**
|
|
31780
|
+
* This method also removes duplicate slashes that may have been in the pattern or formed as a result of expansion.
|
|
31781
|
+
*/ return patterns.map((pattern)=>$51df6bfca103aef8$exports.pattern.removeDuplicateSlashes(pattern));
|
|
31782
|
+
}
|
|
31783
|
+
/**
|
|
31784
|
+
* Returns tasks grouped by basic pattern directories.
|
|
31785
|
+
*
|
|
31786
|
+
* Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
|
|
31787
|
+
* This is necessary because directory traversal starts at the base directory and goes deeper.
|
|
31707
31788
|
*/ function $4e7c1394e7ae525e$var$convertPatternsToTasks(positive, negative, dynamic) {
|
|
31708
31789
|
const tasks = [];
|
|
31709
31790
|
const patternsOutsideCurrentDirectory = $51df6bfca103aef8$exports.pattern.getPatternsOutsideCurrentDirectory(positive);
|
|
@@ -31711,9 +31792,9 @@ $4e7c1394e7ae525e$exports.generate = $4e7c1394e7ae525e$var$generate;
|
|
|
31711
31792
|
const outsideCurrentDirectoryGroup = $4e7c1394e7ae525e$var$groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
|
|
31712
31793
|
const insideCurrentDirectoryGroup = $4e7c1394e7ae525e$var$groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
|
|
31713
31794
|
tasks.push(...$4e7c1394e7ae525e$var$convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
|
|
31714
|
-
/*
|
|
31715
|
-
* For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
|
|
31716
|
-
* into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
|
|
31795
|
+
/*
|
|
31796
|
+
* For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
|
|
31797
|
+
* into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
|
|
31717
31798
|
*/ if ('.' in insideCurrentDirectoryGroup) tasks.push($4e7c1394e7ae525e$var$convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
|
|
31718
31799
|
else tasks.push(...$4e7c1394e7ae525e$var$convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
|
|
31719
31800
|
return tasks;
|
|
@@ -31759,30 +31840,6 @@ function $4e7c1394e7ae525e$var$convertPatternGroupToTask(base, positive, negativ
|
|
|
31759
31840
|
$4e7c1394e7ae525e$exports.convertPatternGroupToTask = $4e7c1394e7ae525e$var$convertPatternGroupToTask;
|
|
31760
31841
|
|
|
31761
31842
|
|
|
31762
|
-
var $a992000eaa98f3bf$exports = {};
|
|
31763
|
-
"use strict";
|
|
31764
|
-
Object.defineProperty($a992000eaa98f3bf$exports, "__esModule", {
|
|
31765
|
-
value: true
|
|
31766
|
-
});
|
|
31767
|
-
$a992000eaa98f3bf$exports.removeDuplicateSlashes = $a992000eaa98f3bf$exports.transform = void 0;
|
|
31768
|
-
/**
|
|
31769
|
-
* Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
|
|
31770
|
-
* The latter is due to the presence of the device path at the beginning of the UNC path.
|
|
31771
|
-
* @todo rewrite to negative lookbehind with the next major release.
|
|
31772
|
-
*/ const $a992000eaa98f3bf$var$DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
|
|
31773
|
-
function $a992000eaa98f3bf$var$transform(patterns) {
|
|
31774
|
-
return patterns.map((pattern)=>$a992000eaa98f3bf$var$removeDuplicateSlashes(pattern));
|
|
31775
|
-
}
|
|
31776
|
-
$a992000eaa98f3bf$exports.transform = $a992000eaa98f3bf$var$transform;
|
|
31777
|
-
/**
|
|
31778
|
-
* This package only works with forward slashes as a path separator.
|
|
31779
|
-
* Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
|
|
31780
|
-
*/ function $a992000eaa98f3bf$var$removeDuplicateSlashes(pattern) {
|
|
31781
|
-
return pattern.replace($a992000eaa98f3bf$var$DOUBLE_SLASH_RE, '/');
|
|
31782
|
-
}
|
|
31783
|
-
$a992000eaa98f3bf$exports.removeDuplicateSlashes = $a992000eaa98f3bf$var$removeDuplicateSlashes;
|
|
31784
|
-
|
|
31785
|
-
|
|
31786
31843
|
var $d5f482eed45d3ecd$exports = {};
|
|
31787
31844
|
"use strict";
|
|
31788
31845
|
Object.defineProperty($d5f482eed45d3ecd$exports, "__esModule", {
|
|
@@ -31949,10 +32006,17 @@ function $4c8e6850a1bebfbe$var$getSettings(settingsOrOptions = {}) {
|
|
|
31949
32006
|
|
|
31950
32007
|
|
|
31951
32008
|
var $0d6c86794ef4c7c7$exports = {};
|
|
31952
|
-
$0d6c86794ef4c7c7$exports = $0d6c86794ef4c7c7$var$runParallel;
|
|
32009
|
+
/*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ $0d6c86794ef4c7c7$exports = $0d6c86794ef4c7c7$var$runParallel;
|
|
32010
|
+
var $61ec8239bfa07984$exports = {};
|
|
32011
|
+
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ let $61ec8239bfa07984$var$promise;
|
|
32012
|
+
$61ec8239bfa07984$exports = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : $parcel$global) : (cb)=>($61ec8239bfa07984$var$promise || ($61ec8239bfa07984$var$promise = Promise.resolve())).then(cb).catch((err)=>setTimeout(()=>{
|
|
32013
|
+
throw err;
|
|
32014
|
+
}, 0));
|
|
32015
|
+
|
|
32016
|
+
|
|
31953
32017
|
function $0d6c86794ef4c7c7$var$runParallel(tasks, cb) {
|
|
31954
|
-
|
|
31955
|
-
|
|
32018
|
+
let results, pending, keys;
|
|
32019
|
+
let isSync = true;
|
|
31956
32020
|
if (Array.isArray(tasks)) {
|
|
31957
32021
|
results = [];
|
|
31958
32022
|
pending = tasks.length;
|
|
@@ -31966,7 +32030,7 @@ function $0d6c86794ef4c7c7$var$runParallel(tasks, cb) {
|
|
|
31966
32030
|
if (cb) cb(err, results);
|
|
31967
32031
|
cb = null;
|
|
31968
32032
|
}
|
|
31969
|
-
if (isSync)
|
|
32033
|
+
if (isSync) $61ec8239bfa07984$exports(end);
|
|
31970
32034
|
else end();
|
|
31971
32035
|
}
|
|
31972
32036
|
function each(i, err, result) {
|
|
@@ -32296,31 +32360,46 @@ function $a7ad4ca5714a1988$var$reusify(Constructor) {
|
|
|
32296
32360
|
$a7ad4ca5714a1988$exports = $a7ad4ca5714a1988$var$reusify;
|
|
32297
32361
|
|
|
32298
32362
|
|
|
32299
|
-
function $8f292469f9b1e0ce$var$fastqueue(context, worker,
|
|
32363
|
+
function $8f292469f9b1e0ce$var$fastqueue(context, worker, _concurrency) {
|
|
32300
32364
|
if (typeof context === 'function') {
|
|
32301
|
-
|
|
32365
|
+
_concurrency = worker;
|
|
32302
32366
|
worker = context;
|
|
32303
32367
|
context = null;
|
|
32304
32368
|
}
|
|
32369
|
+
if (!(_concurrency >= 1)) throw new Error('fastqueue concurrency must be equal to or greater than 1');
|
|
32305
32370
|
var cache = $a7ad4ca5714a1988$exports($8f292469f9b1e0ce$var$Task);
|
|
32306
32371
|
var queueHead = null;
|
|
32307
32372
|
var queueTail = null;
|
|
32308
32373
|
var _running = 0;
|
|
32374
|
+
var errorHandler = null;
|
|
32309
32375
|
var self = {
|
|
32310
32376
|
push: push,
|
|
32311
32377
|
drain: $8f292469f9b1e0ce$var$noop,
|
|
32312
32378
|
saturated: $8f292469f9b1e0ce$var$noop,
|
|
32313
32379
|
pause: pause,
|
|
32314
32380
|
paused: false,
|
|
32315
|
-
concurrency
|
|
32381
|
+
get concurrency () {
|
|
32382
|
+
return _concurrency;
|
|
32383
|
+
},
|
|
32384
|
+
set concurrency (value){
|
|
32385
|
+
if (!(value >= 1)) throw new Error('fastqueue concurrency must be equal to or greater than 1');
|
|
32386
|
+
_concurrency = value;
|
|
32387
|
+
if (self.paused) return;
|
|
32388
|
+
for(; queueHead && _running < _concurrency;){
|
|
32389
|
+
_running++;
|
|
32390
|
+
release();
|
|
32391
|
+
}
|
|
32392
|
+
},
|
|
32316
32393
|
running: running,
|
|
32317
32394
|
resume: resume,
|
|
32318
32395
|
idle: idle,
|
|
32319
32396
|
length: length,
|
|
32397
|
+
getQueue: getQueue,
|
|
32320
32398
|
unshift: unshift,
|
|
32321
32399
|
empty: $8f292469f9b1e0ce$var$noop,
|
|
32322
32400
|
kill: kill,
|
|
32323
|
-
killAndDrain: killAndDrain
|
|
32401
|
+
killAndDrain: killAndDrain,
|
|
32402
|
+
error: error
|
|
32324
32403
|
};
|
|
32325
32404
|
return self;
|
|
32326
32405
|
function running() {
|
|
@@ -32338,10 +32417,24 @@ function $8f292469f9b1e0ce$var$fastqueue(context, worker, concurrency) {
|
|
|
32338
32417
|
}
|
|
32339
32418
|
return counter;
|
|
32340
32419
|
}
|
|
32420
|
+
function getQueue() {
|
|
32421
|
+
var current = queueHead;
|
|
32422
|
+
var tasks = [];
|
|
32423
|
+
while(current){
|
|
32424
|
+
tasks.push(current.value);
|
|
32425
|
+
current = current.next;
|
|
32426
|
+
}
|
|
32427
|
+
return tasks;
|
|
32428
|
+
}
|
|
32341
32429
|
function resume() {
|
|
32342
32430
|
if (!self.paused) return;
|
|
32343
32431
|
self.paused = false;
|
|
32344
|
-
|
|
32432
|
+
if (queueHead === null) {
|
|
32433
|
+
_running++;
|
|
32434
|
+
release();
|
|
32435
|
+
return;
|
|
32436
|
+
}
|
|
32437
|
+
for(; queueHead && _running < _concurrency;){
|
|
32345
32438
|
_running++;
|
|
32346
32439
|
release();
|
|
32347
32440
|
}
|
|
@@ -32349,13 +32442,14 @@ function $8f292469f9b1e0ce$var$fastqueue(context, worker, concurrency) {
|
|
|
32349
32442
|
function idle() {
|
|
32350
32443
|
return _running === 0 && self.length() === 0;
|
|
32351
32444
|
}
|
|
32352
|
-
function push(
|
|
32445
|
+
function push(value1, done) {
|
|
32353
32446
|
var current = cache.get();
|
|
32354
32447
|
current.context = context;
|
|
32355
32448
|
current.release = release;
|
|
32356
|
-
current.value =
|
|
32449
|
+
current.value = value1;
|
|
32357
32450
|
current.callback = done || $8f292469f9b1e0ce$var$noop;
|
|
32358
|
-
|
|
32451
|
+
current.errorHandler = errorHandler;
|
|
32452
|
+
if (_running >= _concurrency || self.paused) {
|
|
32359
32453
|
if (queueTail) {
|
|
32360
32454
|
queueTail.next = current;
|
|
32361
32455
|
queueTail = current;
|
|
@@ -32369,13 +32463,14 @@ function $8f292469f9b1e0ce$var$fastqueue(context, worker, concurrency) {
|
|
|
32369
32463
|
worker.call(context, current.value, current.worked);
|
|
32370
32464
|
}
|
|
32371
32465
|
}
|
|
32372
|
-
function unshift(
|
|
32466
|
+
function unshift(value1, done) {
|
|
32373
32467
|
var current = cache.get();
|
|
32374
32468
|
current.context = context;
|
|
32375
32469
|
current.release = release;
|
|
32376
|
-
current.value =
|
|
32470
|
+
current.value = value1;
|
|
32377
32471
|
current.callback = done || $8f292469f9b1e0ce$var$noop;
|
|
32378
|
-
|
|
32472
|
+
current.errorHandler = errorHandler;
|
|
32473
|
+
if (_running >= _concurrency || self.paused) {
|
|
32379
32474
|
if (queueHead) {
|
|
32380
32475
|
current.next = queueHead;
|
|
32381
32476
|
queueHead = current;
|
|
@@ -32392,7 +32487,7 @@ function $8f292469f9b1e0ce$var$fastqueue(context, worker, concurrency) {
|
|
|
32392
32487
|
function release(holder) {
|
|
32393
32488
|
if (holder) cache.release(holder);
|
|
32394
32489
|
var next = queueHead;
|
|
32395
|
-
if (next) {
|
|
32490
|
+
if (next && _running <= _concurrency) {
|
|
32396
32491
|
if (!self.paused) {
|
|
32397
32492
|
if (queueTail === queueHead) queueTail = null;
|
|
32398
32493
|
queueHead = next.next;
|
|
@@ -32413,6 +32508,9 @@ function $8f292469f9b1e0ce$var$fastqueue(context, worker, concurrency) {
|
|
|
32413
32508
|
self.drain();
|
|
32414
32509
|
self.drain = $8f292469f9b1e0ce$var$noop;
|
|
32415
32510
|
}
|
|
32511
|
+
function error(handler) {
|
|
32512
|
+
errorHandler = handler;
|
|
32513
|
+
}
|
|
32416
32514
|
}
|
|
32417
32515
|
function $8f292469f9b1e0ce$var$noop() {}
|
|
32418
32516
|
function $8f292469f9b1e0ce$var$Task() {
|
|
@@ -32421,16 +32519,85 @@ function $8f292469f9b1e0ce$var$Task() {
|
|
|
32421
32519
|
this.next = null;
|
|
32422
32520
|
this.release = $8f292469f9b1e0ce$var$noop;
|
|
32423
32521
|
this.context = null;
|
|
32522
|
+
this.errorHandler = null;
|
|
32424
32523
|
var self = this;
|
|
32425
32524
|
this.worked = function worked(err, result) {
|
|
32426
32525
|
var callback = self.callback;
|
|
32526
|
+
var errorHandler = self.errorHandler;
|
|
32527
|
+
var val = self.value;
|
|
32427
32528
|
self.value = null;
|
|
32428
32529
|
self.callback = $8f292469f9b1e0ce$var$noop;
|
|
32530
|
+
if (self.errorHandler) errorHandler(err, val);
|
|
32429
32531
|
callback.call(self.context, err, result);
|
|
32430
32532
|
self.release(self);
|
|
32431
32533
|
};
|
|
32432
32534
|
}
|
|
32535
|
+
function $8f292469f9b1e0ce$var$queueAsPromised(context, worker, _concurrency) {
|
|
32536
|
+
if (typeof context === 'function') {
|
|
32537
|
+
_concurrency = worker;
|
|
32538
|
+
worker = context;
|
|
32539
|
+
context = null;
|
|
32540
|
+
}
|
|
32541
|
+
function asyncWrapper(arg, cb) {
|
|
32542
|
+
worker.call(this, arg).then(function(res) {
|
|
32543
|
+
cb(null, res);
|
|
32544
|
+
}, cb);
|
|
32545
|
+
}
|
|
32546
|
+
var queue = $8f292469f9b1e0ce$var$fastqueue(context, asyncWrapper, _concurrency);
|
|
32547
|
+
var pushCb = queue.push;
|
|
32548
|
+
var unshiftCb = queue.unshift;
|
|
32549
|
+
queue.push = push;
|
|
32550
|
+
queue.unshift = unshift;
|
|
32551
|
+
queue.drained = drained;
|
|
32552
|
+
return queue;
|
|
32553
|
+
function push(value1) {
|
|
32554
|
+
var p = new Promise(function(resolve, reject) {
|
|
32555
|
+
pushCb(value1, function(err, result) {
|
|
32556
|
+
if (err) {
|
|
32557
|
+
reject(err);
|
|
32558
|
+
return;
|
|
32559
|
+
}
|
|
32560
|
+
resolve(result);
|
|
32561
|
+
});
|
|
32562
|
+
});
|
|
32563
|
+
// Let's fork the promise chain to
|
|
32564
|
+
// make the error bubble up to the user but
|
|
32565
|
+
// not lead to a unhandledRejection
|
|
32566
|
+
p.catch($8f292469f9b1e0ce$var$noop);
|
|
32567
|
+
return p;
|
|
32568
|
+
}
|
|
32569
|
+
function unshift(value1) {
|
|
32570
|
+
var p = new Promise(function(resolve, reject) {
|
|
32571
|
+
unshiftCb(value1, function(err, result) {
|
|
32572
|
+
if (err) {
|
|
32573
|
+
reject(err);
|
|
32574
|
+
return;
|
|
32575
|
+
}
|
|
32576
|
+
resolve(result);
|
|
32577
|
+
});
|
|
32578
|
+
});
|
|
32579
|
+
// Let's fork the promise chain to
|
|
32580
|
+
// make the error bubble up to the user but
|
|
32581
|
+
// not lead to a unhandledRejection
|
|
32582
|
+
p.catch($8f292469f9b1e0ce$var$noop);
|
|
32583
|
+
return p;
|
|
32584
|
+
}
|
|
32585
|
+
function drained() {
|
|
32586
|
+
if (queue.idle()) return new Promise(function(resolve) {
|
|
32587
|
+
resolve();
|
|
32588
|
+
});
|
|
32589
|
+
var previousDrain = queue.drain;
|
|
32590
|
+
var p = new Promise(function(resolve) {
|
|
32591
|
+
queue.drain = function() {
|
|
32592
|
+
previousDrain();
|
|
32593
|
+
resolve();
|
|
32594
|
+
};
|
|
32595
|
+
});
|
|
32596
|
+
return p;
|
|
32597
|
+
}
|
|
32598
|
+
}
|
|
32433
32599
|
$8f292469f9b1e0ce$exports = $8f292469f9b1e0ce$var$fastqueue;
|
|
32600
|
+
$8f292469f9b1e0ce$exports.promise = $8f292469f9b1e0ce$var$queueAsPromised;
|
|
32434
32601
|
|
|
32435
32602
|
|
|
32436
32603
|
var $76fb3934979f92a5$exports = {};
|
|
@@ -32897,11 +33064,7 @@ class $7d9735c4e337a8a3$var$Matcher {
|
|
|
32897
33064
|
this._fillStorage();
|
|
32898
33065
|
}
|
|
32899
33066
|
_fillStorage() {
|
|
32900
|
-
|
|
32901
|
-
* The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
|
|
32902
|
-
* So, before expand patterns with brace expansion into separated patterns.
|
|
32903
|
-
*/ const patterns = $51df6bfca103aef8$exports.pattern.expandPatternsWithBraceExpansion(this._patterns);
|
|
32904
|
-
for (const pattern of patterns){
|
|
33067
|
+
for (const pattern of this._patterns){
|
|
32905
33068
|
const segments = this._getPatternSegments(pattern);
|
|
32906
33069
|
const sections = this._splitSegmentsIntoSections(segments);
|
|
32907
33070
|
this._storage.push({
|
|
@@ -32941,12 +33104,12 @@ class $504a6f29c6af5a30$var$PartialMatcher extends $7d9735c4e337a8a3$exports.def
|
|
|
32941
33104
|
const patterns = this._storage.filter((info)=>!info.complete || info.segments.length > levels);
|
|
32942
33105
|
for (const pattern of patterns){
|
|
32943
33106
|
const section = pattern.sections[0];
|
|
32944
|
-
/**
|
|
32945
|
-
* In this case, the pattern has a globstar and we must read all directories unconditionally,
|
|
32946
|
-
* but only if the level has reached the end of the first group.
|
|
32947
|
-
*
|
|
32948
|
-
* fixtures/{a,b}/**
|
|
32949
|
-
* ^ true/false ^ always true
|
|
33107
|
+
/**
|
|
33108
|
+
* In this case, the pattern has a globstar and we must read all directories unconditionally,
|
|
33109
|
+
* but only if the level has reached the end of the first group.
|
|
33110
|
+
*
|
|
33111
|
+
* fixtures/{a,b}/**
|
|
33112
|
+
* ^ true/false ^ always true
|
|
32950
33113
|
*/ if (!pattern.complete && levels > section.length) return true;
|
|
32951
33114
|
const match = parts.every((part, index)=>{
|
|
32952
33115
|
const segment = pattern.segments[index];
|
|
@@ -32987,8 +33150,8 @@ class $43d93e4c4fb70606$var$DeepFilter {
|
|
|
32987
33150
|
return this._isSkippedByNegativePatterns(filepath, negativeRe);
|
|
32988
33151
|
}
|
|
32989
33152
|
_isSkippedByDeep(basePath, entryPath) {
|
|
32990
|
-
/**
|
|
32991
|
-
* Avoid unnecessary depth calculations when it doesn't matter.
|
|
33153
|
+
/**
|
|
33154
|
+
* Avoid unnecessary depth calculations when it doesn't matter.
|
|
32992
33155
|
*/ if (this._settings.deep === Infinity) return false;
|
|
32993
33156
|
return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
|
|
32994
33157
|
}
|
|
@@ -33025,24 +33188,26 @@ class $b326f718dda03c34$var$EntryFilter {
|
|
|
33025
33188
|
}
|
|
33026
33189
|
getFilter(positive, negative) {
|
|
33027
33190
|
const positiveRe = $51df6bfca103aef8$exports.pattern.convertPatternsToRe(positive, this._micromatchOptions);
|
|
33028
|
-
const negativeRe = $51df6bfca103aef8$exports.pattern.convertPatternsToRe(negative, this._micromatchOptions)
|
|
33191
|
+
const negativeRe = $51df6bfca103aef8$exports.pattern.convertPatternsToRe(negative, Object.assign(Object.assign({}, this._micromatchOptions), {
|
|
33192
|
+
dot: true
|
|
33193
|
+
}));
|
|
33029
33194
|
return (entry)=>this._filter(entry, positiveRe, negativeRe);
|
|
33030
33195
|
}
|
|
33031
33196
|
_filter(entry, positiveRe, negativeRe) {
|
|
33032
|
-
|
|
33197
|
+
const filepath = $51df6bfca103aef8$exports.path.removeLeadingDotSegment(entry.path);
|
|
33198
|
+
if (this._settings.unique && this._isDuplicateEntry(filepath)) return false;
|
|
33033
33199
|
if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) return false;
|
|
33034
|
-
if (this._isSkippedByAbsoluteNegativePatterns(
|
|
33035
|
-
const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
|
|
33200
|
+
if (this._isSkippedByAbsoluteNegativePatterns(filepath, negativeRe)) return false;
|
|
33036
33201
|
const isDirectory = entry.dirent.isDirectory();
|
|
33037
|
-
const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(
|
|
33038
|
-
if (this._settings.unique && isMatched) this._createIndexRecord(
|
|
33202
|
+
const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(filepath, negativeRe, isDirectory);
|
|
33203
|
+
if (this._settings.unique && isMatched) this._createIndexRecord(filepath);
|
|
33039
33204
|
return isMatched;
|
|
33040
33205
|
}
|
|
33041
|
-
_isDuplicateEntry(
|
|
33042
|
-
return this.index.has(
|
|
33206
|
+
_isDuplicateEntry(filepath) {
|
|
33207
|
+
return this.index.has(filepath);
|
|
33043
33208
|
}
|
|
33044
|
-
_createIndexRecord(
|
|
33045
|
-
this.index.set(
|
|
33209
|
+
_createIndexRecord(filepath) {
|
|
33210
|
+
this.index.set(filepath, undefined);
|
|
33046
33211
|
}
|
|
33047
33212
|
_onlyFileFilter(entry) {
|
|
33048
33213
|
return this._settings.onlyFiles && !entry.dirent.isFile();
|
|
@@ -33055,8 +33220,7 @@ class $b326f718dda03c34$var$EntryFilter {
|
|
|
33055
33220
|
const fullpath = $51df6bfca103aef8$exports.path.makeAbsolute(this._settings.cwd, entryPath);
|
|
33056
33221
|
return $51df6bfca103aef8$exports.pattern.matchAny(fullpath, patternsRe);
|
|
33057
33222
|
}
|
|
33058
|
-
_isMatchToPatterns(
|
|
33059
|
-
const filepath = $51df6bfca103aef8$exports.path.removeLeadingDotSegment(entryPath);
|
|
33223
|
+
_isMatchToPatterns(filepath, patternsRe, isDirectory) {
|
|
33060
33224
|
// Trying to match files and directories by patterns.
|
|
33061
33225
|
const isMatched = $51df6bfca103aef8$exports.pattern.matchAny(filepath, patternsRe);
|
|
33062
33226
|
// A pattern with a trailling slash can be used for directory matching.
|
|
@@ -33288,9 +33452,9 @@ Object.defineProperty($bf5054003fcf818c$exports, "__esModule", {
|
|
|
33288
33452
|
$bf5054003fcf818c$exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
33289
33453
|
|
|
33290
33454
|
|
|
33291
|
-
/**
|
|
33292
|
-
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
33293
|
-
* https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
|
|
33455
|
+
/**
|
|
33456
|
+
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
33457
|
+
* https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
|
|
33294
33458
|
*/ const $bf5054003fcf818c$var$CPU_COUNT = Math.max($houHs$os.cpus().length, 1);
|
|
33295
33459
|
$bf5054003fcf818c$exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
33296
33460
|
lstat: $houHs$fs.lstat,
|
|
@@ -33326,6 +33490,8 @@ class $bf5054003fcf818c$var$Settings {
|
|
|
33326
33490
|
this.unique = this._getValue(this._options.unique, true);
|
|
33327
33491
|
if (this.onlyDirectories) this.onlyFiles = false;
|
|
33328
33492
|
if (this.stats) this.objectMode = true;
|
|
33493
|
+
// Remove the cast to the array in the next major (#404).
|
|
33494
|
+
this.ignore = [].concat(this.ignore);
|
|
33329
33495
|
}
|
|
33330
33496
|
_getValue(option, value) {
|
|
33331
33497
|
return option === undefined ? value : option;
|
|
@@ -33347,6 +33513,10 @@ async function $9166a0561447d9cc$var$FastGlob(source, options) {
|
|
|
33347
33513
|
// https://github.com/typescript-eslint/typescript-eslint/issues/60
|
|
33348
33514
|
// eslint-disable-next-line no-redeclare
|
|
33349
33515
|
(function(FastGlob) {
|
|
33516
|
+
FastGlob.glob = FastGlob;
|
|
33517
|
+
FastGlob.globSync = sync;
|
|
33518
|
+
FastGlob.globStream = stream;
|
|
33519
|
+
FastGlob.async = FastGlob;
|
|
33350
33520
|
function sync(source, options) {
|
|
33351
33521
|
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33352
33522
|
const works = $9166a0561447d9cc$var$getWorks(source, $7d557658c028e930$exports.default, options);
|
|
@@ -33356,16 +33526,16 @@ async function $9166a0561447d9cc$var$FastGlob(source, options) {
|
|
|
33356
33526
|
function stream(source, options) {
|
|
33357
33527
|
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33358
33528
|
const works = $9166a0561447d9cc$var$getWorks(source, $f44fe1a517197b2c$exports.default, options);
|
|
33359
|
-
/**
|
|
33360
|
-
* The stream returned by the provider cannot work with an asynchronous iterator.
|
|
33361
|
-
* To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
|
|
33362
|
-
* This affects performance (+25%). I don't see best solution right now.
|
|
33529
|
+
/**
|
|
33530
|
+
* The stream returned by the provider cannot work with an asynchronous iterator.
|
|
33531
|
+
* To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
|
|
33532
|
+
* This affects performance (+25%). I don't see best solution right now.
|
|
33363
33533
|
*/ return $51df6bfca103aef8$exports.stream.merge(works);
|
|
33364
33534
|
}
|
|
33365
33535
|
FastGlob.stream = stream;
|
|
33366
33536
|
function generateTasks(source, options) {
|
|
33367
33537
|
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33368
|
-
const patterns =
|
|
33538
|
+
const patterns = [].concat(source);
|
|
33369
33539
|
const settings = new $bf5054003fcf818c$exports.default(options);
|
|
33370
33540
|
return $4e7c1394e7ae525e$exports.generate(patterns, settings);
|
|
33371
33541
|
}
|
|
@@ -33381,9 +33551,40 @@ async function $9166a0561447d9cc$var$FastGlob(source, options) {
|
|
|
33381
33551
|
return $51df6bfca103aef8$exports.path.escape(source);
|
|
33382
33552
|
}
|
|
33383
33553
|
FastGlob.escapePath = escapePath;
|
|
33554
|
+
function convertPathToPattern(source) {
|
|
33555
|
+
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33556
|
+
return $51df6bfca103aef8$exports.path.convertPathToPattern(source);
|
|
33557
|
+
}
|
|
33558
|
+
FastGlob.convertPathToPattern = convertPathToPattern;
|
|
33559
|
+
let posix;
|
|
33560
|
+
(function(posix) {
|
|
33561
|
+
function escapePath(source) {
|
|
33562
|
+
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33563
|
+
return $51df6bfca103aef8$exports.path.escapePosixPath(source);
|
|
33564
|
+
}
|
|
33565
|
+
posix.escapePath = escapePath;
|
|
33566
|
+
function convertPathToPattern(source) {
|
|
33567
|
+
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33568
|
+
return $51df6bfca103aef8$exports.path.convertPosixPathToPattern(source);
|
|
33569
|
+
}
|
|
33570
|
+
posix.convertPathToPattern = convertPathToPattern;
|
|
33571
|
+
})(posix = FastGlob.posix || (FastGlob.posix = {}));
|
|
33572
|
+
let win32;
|
|
33573
|
+
(function(win32) {
|
|
33574
|
+
function escapePath(source) {
|
|
33575
|
+
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33576
|
+
return $51df6bfca103aef8$exports.path.escapeWindowsPath(source);
|
|
33577
|
+
}
|
|
33578
|
+
win32.escapePath = escapePath;
|
|
33579
|
+
function convertPathToPattern(source) {
|
|
33580
|
+
$9166a0561447d9cc$var$assertPatternsInput(source);
|
|
33581
|
+
return $51df6bfca103aef8$exports.path.convertWindowsPathToPattern(source);
|
|
33582
|
+
}
|
|
33583
|
+
win32.convertPathToPattern = convertPathToPattern;
|
|
33584
|
+
})(win32 = FastGlob.win32 || (FastGlob.win32 = {}));
|
|
33384
33585
|
})($9166a0561447d9cc$var$FastGlob || ($9166a0561447d9cc$var$FastGlob = {}));
|
|
33385
33586
|
function $9166a0561447d9cc$var$getWorks(source, _Provider, options) {
|
|
33386
|
-
const patterns =
|
|
33587
|
+
const patterns = [].concat(source);
|
|
33387
33588
|
const settings = new $bf5054003fcf818c$exports.default(options);
|
|
33388
33589
|
const tasks = $4e7c1394e7ae525e$exports.generate(patterns, settings);
|
|
33389
33590
|
const provider = new _Provider(settings);
|
|
@@ -33783,11 +33984,12 @@ function $7bda2fb2ffff63e7$var$supportsHyperlink(stream) {
|
|
|
33783
33984
|
if ('FORCE_HYPERLINK' in env) return !(env.FORCE_HYPERLINK.length > 0 && parseInt(env.FORCE_HYPERLINK, 10) === 0);
|
|
33784
33985
|
if ($211adde7638cc347$exports('no-hyperlink') || $211adde7638cc347$exports('no-hyperlinks') || $211adde7638cc347$exports('hyperlink=false') || $211adde7638cc347$exports('hyperlink=never')) return false;
|
|
33785
33986
|
if ($211adde7638cc347$exports('hyperlink=true') || $211adde7638cc347$exports('hyperlink=always')) return true;
|
|
33987
|
+
// Netlify does not run a TTY, it does not need `supportsColor` check
|
|
33988
|
+
if ('NETLIFY' in env) return true;
|
|
33786
33989
|
// If they specify no colors, they probably don't want hyperlinks.
|
|
33787
33990
|
if (!$e79b7a51795d2321$exports.supportsColor(stream)) return false;
|
|
33788
33991
|
if (stream && !stream.isTTY) return false;
|
|
33789
33992
|
if (process.platform === 'win32') return false;
|
|
33790
|
-
if ('NETLIFY' in env) return true;
|
|
33791
33993
|
if ('CI' in env) return false;
|
|
33792
33994
|
if ('TEAMCITY_VERSION' in env) return false;
|
|
33793
33995
|
if ('TERM_PROGRAM' in env) {
|
|
@@ -33796,6 +33998,10 @@ function $7bda2fb2ffff63e7$var$supportsHyperlink(stream) {
|
|
|
33796
33998
|
case 'iTerm.app':
|
|
33797
33999
|
if (version.major === 3) return version.minor >= 1;
|
|
33798
34000
|
return version.major > 3;
|
|
34001
|
+
case 'WezTerm':
|
|
34002
|
+
return version.major >= 20200620;
|
|
34003
|
+
case 'vscode':
|
|
34004
|
+
return version.major > 1 || version.major === 1 && version.minor >= 72;
|
|
33799
34005
|
}
|
|
33800
34006
|
}
|
|
33801
34007
|
if ('VTE_VERSION' in env) {
|
|
@@ -35956,524 +36162,1205 @@ $9a7a296607515479$export$98e6a39c04603d36 = (parcelRequire("a5HPM"));
|
|
|
35956
36162
|
$9a7a296607515479$export$fac44ee5b035f737 = (parcelRequire("ib1eJ"));
|
|
35957
36163
|
|
|
35958
36164
|
|
|
35959
|
-
|
|
35960
|
-
|
|
35961
|
-
|
|
35962
|
-
|
|
35963
|
-
|
|
35964
|
-
$
|
|
35965
|
-
$
|
|
35966
|
-
function $1ba40dc599466f23$var$Yallist(list) {
|
|
35967
|
-
var self = this;
|
|
35968
|
-
if (!(self instanceof $1ba40dc599466f23$var$Yallist)) self = new $1ba40dc599466f23$var$Yallist();
|
|
35969
|
-
self.tail = null;
|
|
35970
|
-
self.head = null;
|
|
35971
|
-
self.length = 0;
|
|
35972
|
-
if (list && typeof list.forEach === 'function') list.forEach(function(item) {
|
|
35973
|
-
self.push(item);
|
|
35974
|
-
});
|
|
35975
|
-
else if (arguments.length > 0) for(var i = 0, l = arguments.length; i < l; i++)self.push(arguments[i]);
|
|
35976
|
-
return self;
|
|
35977
|
-
}
|
|
35978
|
-
$1ba40dc599466f23$var$Yallist.prototype.removeNode = function(node) {
|
|
35979
|
-
if (node.list !== this) throw new Error('removing node which does not belong to this list');
|
|
35980
|
-
var next = node.next;
|
|
35981
|
-
var prev = node.prev;
|
|
35982
|
-
if (next) next.prev = prev;
|
|
35983
|
-
if (prev) prev.next = next;
|
|
35984
|
-
if (node === this.head) this.head = next;
|
|
35985
|
-
if (node === this.tail) this.tail = prev;
|
|
35986
|
-
node.list.length--;
|
|
35987
|
-
node.next = null;
|
|
35988
|
-
node.prev = null;
|
|
35989
|
-
node.list = null;
|
|
35990
|
-
return next;
|
|
35991
|
-
};
|
|
35992
|
-
$1ba40dc599466f23$var$Yallist.prototype.unshiftNode = function(node) {
|
|
35993
|
-
if (node === this.head) return;
|
|
35994
|
-
if (node.list) node.list.removeNode(node);
|
|
35995
|
-
var head = this.head;
|
|
35996
|
-
node.list = this;
|
|
35997
|
-
node.next = head;
|
|
35998
|
-
if (head) head.prev = node;
|
|
35999
|
-
this.head = node;
|
|
36000
|
-
if (!this.tail) this.tail = node;
|
|
36001
|
-
this.length++;
|
|
36002
|
-
};
|
|
36003
|
-
$1ba40dc599466f23$var$Yallist.prototype.pushNode = function(node) {
|
|
36004
|
-
if (node === this.tail) return;
|
|
36005
|
-
if (node.list) node.list.removeNode(node);
|
|
36006
|
-
var tail = this.tail;
|
|
36007
|
-
node.list = this;
|
|
36008
|
-
node.prev = tail;
|
|
36009
|
-
if (tail) tail.next = node;
|
|
36010
|
-
this.tail = node;
|
|
36011
|
-
if (!this.head) this.head = node;
|
|
36012
|
-
this.length++;
|
|
36013
|
-
};
|
|
36014
|
-
$1ba40dc599466f23$var$Yallist.prototype.push = function() {
|
|
36015
|
-
for(var i = 0, l = arguments.length; i < l; i++)$1ba40dc599466f23$var$push(this, arguments[i]);
|
|
36016
|
-
return this.length;
|
|
36017
|
-
};
|
|
36018
|
-
$1ba40dc599466f23$var$Yallist.prototype.unshift = function() {
|
|
36019
|
-
for(var i = 0, l = arguments.length; i < l; i++)$1ba40dc599466f23$var$unshift(this, arguments[i]);
|
|
36020
|
-
return this.length;
|
|
36021
|
-
};
|
|
36022
|
-
$1ba40dc599466f23$var$Yallist.prototype.pop = function() {
|
|
36023
|
-
if (!this.tail) return undefined;
|
|
36024
|
-
var res = this.tail.value;
|
|
36025
|
-
this.tail = this.tail.prev;
|
|
36026
|
-
if (this.tail) this.tail.next = null;
|
|
36027
|
-
else this.head = null;
|
|
36028
|
-
this.length--;
|
|
36029
|
-
return res;
|
|
36030
|
-
};
|
|
36031
|
-
$1ba40dc599466f23$var$Yallist.prototype.shift = function() {
|
|
36032
|
-
if (!this.head) return undefined;
|
|
36033
|
-
var res = this.head.value;
|
|
36034
|
-
this.head = this.head.next;
|
|
36035
|
-
if (this.head) this.head.prev = null;
|
|
36036
|
-
else this.tail = null;
|
|
36037
|
-
this.length--;
|
|
36038
|
-
return res;
|
|
36165
|
+
/**
|
|
36166
|
+
* @module LRUCache
|
|
36167
|
+
*/ const $34c2e4b61193a7f9$var$perf = typeof performance === 'object' && performance && typeof performance.now === 'function' ? performance : Date;
|
|
36168
|
+
const $34c2e4b61193a7f9$var$warned = new Set();
|
|
36169
|
+
/* c8 ignore start */ const $34c2e4b61193a7f9$var$PROCESS = typeof process === 'object' && !!process ? process : {};
|
|
36170
|
+
/* c8 ignore start */ const $34c2e4b61193a7f9$var$emitWarning = (msg, type, code, fn)=>{
|
|
36171
|
+
typeof $34c2e4b61193a7f9$var$PROCESS.emitWarning === 'function' ? $34c2e4b61193a7f9$var$PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
36039
36172
|
};
|
|
36040
|
-
$
|
|
36041
|
-
|
|
36042
|
-
|
|
36043
|
-
|
|
36044
|
-
|
|
36173
|
+
let $34c2e4b61193a7f9$var$AC = globalThis.AbortController;
|
|
36174
|
+
let $34c2e4b61193a7f9$var$AS = globalThis.AbortSignal;
|
|
36175
|
+
/* c8 ignore start */ if (typeof $34c2e4b61193a7f9$var$AC === 'undefined') {
|
|
36176
|
+
//@ts-ignore
|
|
36177
|
+
$34c2e4b61193a7f9$var$AS = class AbortSignal {
|
|
36178
|
+
onabort;
|
|
36179
|
+
_onabort = [];
|
|
36180
|
+
reason;
|
|
36181
|
+
aborted = false;
|
|
36182
|
+
addEventListener(_, fn) {
|
|
36183
|
+
this._onabort.push(fn);
|
|
36184
|
+
}
|
|
36185
|
+
};
|
|
36186
|
+
//@ts-ignore
|
|
36187
|
+
$34c2e4b61193a7f9$var$AC = class AbortController {
|
|
36188
|
+
constructor(){
|
|
36189
|
+
warnACPolyfill();
|
|
36190
|
+
}
|
|
36191
|
+
signal = new $34c2e4b61193a7f9$var$AS();
|
|
36192
|
+
abort(reason) {
|
|
36193
|
+
if (this.signal.aborted) return;
|
|
36194
|
+
//@ts-ignore
|
|
36195
|
+
this.signal.reason = reason;
|
|
36196
|
+
//@ts-ignore
|
|
36197
|
+
this.signal.aborted = true;
|
|
36198
|
+
//@ts-ignore
|
|
36199
|
+
for (const fn of this.signal._onabort)fn(reason);
|
|
36200
|
+
this.signal.onabort?.(reason);
|
|
36201
|
+
}
|
|
36202
|
+
};
|
|
36203
|
+
let printACPolyfillWarning = $34c2e4b61193a7f9$var$PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
36204
|
+
const warnACPolyfill = ()=>{
|
|
36205
|
+
if (!printACPolyfillWarning) return;
|
|
36206
|
+
printACPolyfillWarning = false;
|
|
36207
|
+
$34c2e4b61193a7f9$var$emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
|
|
36208
|
+
};
|
|
36209
|
+
}
|
|
36210
|
+
/* c8 ignore stop */ const $34c2e4b61193a7f9$var$shouldWarn = (code)=>!$34c2e4b61193a7f9$var$warned.has(code);
|
|
36211
|
+
const $34c2e4b61193a7f9$var$TYPE = Symbol('type');
|
|
36212
|
+
const $34c2e4b61193a7f9$var$isPosInt = (n)=>n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
36213
|
+
/* c8 ignore start */ // This is a little bit ridiculous, tbh.
|
|
36214
|
+
// The maximum array length is 2^32-1 or thereabouts on most JS impls.
|
|
36215
|
+
// And well before that point, you're caching the entire world, I mean,
|
|
36216
|
+
// that's ~32GB of just integers for the next/prev links, plus whatever
|
|
36217
|
+
// else to hold that many keys and values. Just filling the memory with
|
|
36218
|
+
// zeroes at init time is brutal when you get that big.
|
|
36219
|
+
// But why not be complete?
|
|
36220
|
+
// Maybe in the future, these limits will have expanded.
|
|
36221
|
+
const $34c2e4b61193a7f9$var$getUintArray = (max)=>!$34c2e4b61193a7f9$var$isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? $34c2e4b61193a7f9$var$ZeroArray : null;
|
|
36222
|
+
/* c8 ignore stop */ class $34c2e4b61193a7f9$var$ZeroArray extends Array {
|
|
36223
|
+
constructor(size){
|
|
36224
|
+
super(size);
|
|
36225
|
+
this.fill(0);
|
|
36226
|
+
}
|
|
36227
|
+
}
|
|
36228
|
+
class $34c2e4b61193a7f9$var$Stack {
|
|
36229
|
+
heap;
|
|
36230
|
+
length;
|
|
36231
|
+
// private constructor
|
|
36232
|
+
static #constructing = false;
|
|
36233
|
+
static create(max) {
|
|
36234
|
+
const HeapCls = $34c2e4b61193a7f9$var$getUintArray(max);
|
|
36235
|
+
if (!HeapCls) return [];
|
|
36236
|
+
$34c2e4b61193a7f9$var$Stack.#constructing = true;
|
|
36237
|
+
const s = new $34c2e4b61193a7f9$var$Stack(max, HeapCls);
|
|
36238
|
+
$34c2e4b61193a7f9$var$Stack.#constructing = false;
|
|
36239
|
+
return s;
|
|
36240
|
+
}
|
|
36241
|
+
constructor(max, HeapCls){
|
|
36242
|
+
/* c8 ignore start */ if (!$34c2e4b61193a7f9$var$Stack.#constructing) throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
36243
|
+
/* c8 ignore stop */ this.heap = new HeapCls(max);
|
|
36244
|
+
this.length = 0;
|
|
36245
|
+
}
|
|
36246
|
+
push(n) {
|
|
36247
|
+
this.heap[this.length++] = n;
|
|
36045
36248
|
}
|
|
36046
|
-
|
|
36047
|
-
|
|
36048
|
-
thisp = thisp || this;
|
|
36049
|
-
for(var walker = this.tail, i = this.length - 1; walker !== null; i--){
|
|
36050
|
-
fn.call(thisp, walker.value, i, this);
|
|
36051
|
-
walker = walker.prev;
|
|
36249
|
+
pop() {
|
|
36250
|
+
return this.heap[--this.length];
|
|
36052
36251
|
}
|
|
36053
|
-
}
|
|
36054
|
-
$
|
|
36055
|
-
|
|
36056
|
-
|
|
36057
|
-
|
|
36058
|
-
|
|
36059
|
-
|
|
36060
|
-
|
|
36061
|
-
|
|
36062
|
-
|
|
36063
|
-
}
|
|
36064
|
-
|
|
36065
|
-
|
|
36066
|
-
|
|
36067
|
-
|
|
36068
|
-
|
|
36069
|
-
|
|
36252
|
+
}
|
|
36253
|
+
class $34c2e4b61193a7f9$export$182500e6725aad9a {
|
|
36254
|
+
// options that cannot be changed without disaster
|
|
36255
|
+
#max;
|
|
36256
|
+
#maxSize;
|
|
36257
|
+
#dispose;
|
|
36258
|
+
#disposeAfter;
|
|
36259
|
+
#fetchMethod;
|
|
36260
|
+
#memoMethod;
|
|
36261
|
+
/**
|
|
36262
|
+
* {@link LRUCache.OptionsBase.ttl}
|
|
36263
|
+
*/ ttl;
|
|
36264
|
+
/**
|
|
36265
|
+
* {@link LRUCache.OptionsBase.ttlResolution}
|
|
36266
|
+
*/ ttlResolution;
|
|
36267
|
+
/**
|
|
36268
|
+
* {@link LRUCache.OptionsBase.ttlAutopurge}
|
|
36269
|
+
*/ ttlAutopurge;
|
|
36270
|
+
/**
|
|
36271
|
+
* {@link LRUCache.OptionsBase.updateAgeOnGet}
|
|
36272
|
+
*/ updateAgeOnGet;
|
|
36273
|
+
/**
|
|
36274
|
+
* {@link LRUCache.OptionsBase.updateAgeOnHas}
|
|
36275
|
+
*/ updateAgeOnHas;
|
|
36276
|
+
/**
|
|
36277
|
+
* {@link LRUCache.OptionsBase.allowStale}
|
|
36278
|
+
*/ allowStale;
|
|
36279
|
+
/**
|
|
36280
|
+
* {@link LRUCache.OptionsBase.noDisposeOnSet}
|
|
36281
|
+
*/ noDisposeOnSet;
|
|
36282
|
+
/**
|
|
36283
|
+
* {@link LRUCache.OptionsBase.noUpdateTTL}
|
|
36284
|
+
*/ noUpdateTTL;
|
|
36285
|
+
/**
|
|
36286
|
+
* {@link LRUCache.OptionsBase.maxEntrySize}
|
|
36287
|
+
*/ maxEntrySize;
|
|
36288
|
+
/**
|
|
36289
|
+
* {@link LRUCache.OptionsBase.sizeCalculation}
|
|
36290
|
+
*/ sizeCalculation;
|
|
36291
|
+
/**
|
|
36292
|
+
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
|
|
36293
|
+
*/ noDeleteOnFetchRejection;
|
|
36294
|
+
/**
|
|
36295
|
+
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
|
|
36296
|
+
*/ noDeleteOnStaleGet;
|
|
36297
|
+
/**
|
|
36298
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
|
|
36299
|
+
*/ allowStaleOnFetchAbort;
|
|
36300
|
+
/**
|
|
36301
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
|
|
36302
|
+
*/ allowStaleOnFetchRejection;
|
|
36303
|
+
/**
|
|
36304
|
+
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
|
36305
|
+
*/ ignoreFetchAbort;
|
|
36306
|
+
// computed properties
|
|
36307
|
+
#size;
|
|
36308
|
+
#calculatedSize;
|
|
36309
|
+
#keyMap;
|
|
36310
|
+
#keyList;
|
|
36311
|
+
#valList;
|
|
36312
|
+
#next;
|
|
36313
|
+
#prev;
|
|
36314
|
+
#head;
|
|
36315
|
+
#tail;
|
|
36316
|
+
#free;
|
|
36317
|
+
#disposed;
|
|
36318
|
+
#sizes;
|
|
36319
|
+
#starts;
|
|
36320
|
+
#ttls;
|
|
36321
|
+
#hasDispose;
|
|
36322
|
+
#hasFetchMethod;
|
|
36323
|
+
#hasDisposeAfter;
|
|
36324
|
+
/**
|
|
36325
|
+
* Do not call this method unless you need to inspect the
|
|
36326
|
+
* inner workings of the cache. If anything returned by this
|
|
36327
|
+
* object is modified in any way, strange breakage may occur.
|
|
36328
|
+
*
|
|
36329
|
+
* These fields are private for a reason!
|
|
36330
|
+
*
|
|
36331
|
+
* @internal
|
|
36332
|
+
*/ static unsafeExposeInternals(c) {
|
|
36333
|
+
return {
|
|
36334
|
+
// properties
|
|
36335
|
+
starts: c.#starts,
|
|
36336
|
+
ttls: c.#ttls,
|
|
36337
|
+
sizes: c.#sizes,
|
|
36338
|
+
keyMap: c.#keyMap,
|
|
36339
|
+
keyList: c.#keyList,
|
|
36340
|
+
valList: c.#valList,
|
|
36341
|
+
next: c.#next,
|
|
36342
|
+
prev: c.#prev,
|
|
36343
|
+
get head () {
|
|
36344
|
+
return c.#head;
|
|
36345
|
+
},
|
|
36346
|
+
get tail () {
|
|
36347
|
+
return c.#tail;
|
|
36348
|
+
},
|
|
36349
|
+
free: c.#free,
|
|
36350
|
+
// methods
|
|
36351
|
+
isBackgroundFetch: (p)=>c.#isBackgroundFetch(p),
|
|
36352
|
+
backgroundFetch: (k, index, options, context)=>c.#backgroundFetch(k, index, options, context),
|
|
36353
|
+
moveToTail: (index)=>c.#moveToTail(index),
|
|
36354
|
+
indexes: (options)=>c.#indexes(options),
|
|
36355
|
+
rindexes: (options)=>c.#rindexes(options),
|
|
36356
|
+
isStale: (index)=>c.#isStale(index)
|
|
36357
|
+
};
|
|
36070
36358
|
}
|
|
36071
|
-
|
|
36072
|
-
|
|
36073
|
-
|
|
36074
|
-
|
|
36075
|
-
|
|
36076
|
-
for(var walker = this.tail; walker !== null;){
|
|
36077
|
-
res.push(fn.call(thisp, walker.value, this));
|
|
36078
|
-
walker = walker.prev;
|
|
36359
|
+
// Protected read-only members
|
|
36360
|
+
/**
|
|
36361
|
+
* {@link LRUCache.OptionsBase.max} (read-only)
|
|
36362
|
+
*/ get max() {
|
|
36363
|
+
return this.#max;
|
|
36079
36364
|
}
|
|
36080
|
-
|
|
36081
|
-
}
|
|
36082
|
-
|
|
36083
|
-
|
|
36084
|
-
var walker = this.head;
|
|
36085
|
-
if (arguments.length > 1) acc = initial;
|
|
36086
|
-
else if (this.head) {
|
|
36087
|
-
walker = this.head.next;
|
|
36088
|
-
acc = this.head.value;
|
|
36089
|
-
} else throw new TypeError('Reduce of empty list with no initial value');
|
|
36090
|
-
for(var i = 0; walker !== null; i++){
|
|
36091
|
-
acc = fn(acc, walker.value, i);
|
|
36092
|
-
walker = walker.next;
|
|
36093
|
-
}
|
|
36094
|
-
return acc;
|
|
36095
|
-
};
|
|
36096
|
-
$1ba40dc599466f23$var$Yallist.prototype.reduceReverse = function(fn, initial) {
|
|
36097
|
-
var acc;
|
|
36098
|
-
var walker = this.tail;
|
|
36099
|
-
if (arguments.length > 1) acc = initial;
|
|
36100
|
-
else if (this.tail) {
|
|
36101
|
-
walker = this.tail.prev;
|
|
36102
|
-
acc = this.tail.value;
|
|
36103
|
-
} else throw new TypeError('Reduce of empty list with no initial value');
|
|
36104
|
-
for(var i = this.length - 1; walker !== null; i--){
|
|
36105
|
-
acc = fn(acc, walker.value, i);
|
|
36106
|
-
walker = walker.prev;
|
|
36107
|
-
}
|
|
36108
|
-
return acc;
|
|
36109
|
-
};
|
|
36110
|
-
$1ba40dc599466f23$var$Yallist.prototype.toArray = function() {
|
|
36111
|
-
var arr = new Array(this.length);
|
|
36112
|
-
for(var i = 0, walker = this.head; walker !== null; i++){
|
|
36113
|
-
arr[i] = walker.value;
|
|
36114
|
-
walker = walker.next;
|
|
36365
|
+
/**
|
|
36366
|
+
* {@link LRUCache.OptionsBase.maxSize} (read-only)
|
|
36367
|
+
*/ get maxSize() {
|
|
36368
|
+
return this.#maxSize;
|
|
36115
36369
|
}
|
|
36116
|
-
|
|
36117
|
-
|
|
36118
|
-
|
|
36119
|
-
|
|
36120
|
-
for(var i = 0, walker = this.tail; walker !== null; i++){
|
|
36121
|
-
arr[i] = walker.value;
|
|
36122
|
-
walker = walker.prev;
|
|
36370
|
+
/**
|
|
36371
|
+
* The total computed size of items in the cache (read-only)
|
|
36372
|
+
*/ get calculatedSize() {
|
|
36373
|
+
return this.#calculatedSize;
|
|
36123
36374
|
}
|
|
36124
|
-
|
|
36125
|
-
|
|
36126
|
-
|
|
36127
|
-
|
|
36128
|
-
if (to < 0) to += this.length;
|
|
36129
|
-
from = from || 0;
|
|
36130
|
-
if (from < 0) from += this.length;
|
|
36131
|
-
var ret = new $1ba40dc599466f23$var$Yallist();
|
|
36132
|
-
if (to < from || to < 0) return ret;
|
|
36133
|
-
if (from < 0) from = 0;
|
|
36134
|
-
if (to > this.length) to = this.length;
|
|
36135
|
-
for(var i = 0, walker = this.head; walker !== null && i < from; i++)walker = walker.next;
|
|
36136
|
-
for(; walker !== null && i < to; i++, walker = walker.next)ret.push(walker.value);
|
|
36137
|
-
return ret;
|
|
36138
|
-
};
|
|
36139
|
-
$1ba40dc599466f23$var$Yallist.prototype.sliceReverse = function(from, to) {
|
|
36140
|
-
to = to || this.length;
|
|
36141
|
-
if (to < 0) to += this.length;
|
|
36142
|
-
from = from || 0;
|
|
36143
|
-
if (from < 0) from += this.length;
|
|
36144
|
-
var ret = new $1ba40dc599466f23$var$Yallist();
|
|
36145
|
-
if (to < from || to < 0) return ret;
|
|
36146
|
-
if (from < 0) from = 0;
|
|
36147
|
-
if (to > this.length) to = this.length;
|
|
36148
|
-
for(var i = this.length, walker = this.tail; walker !== null && i > to; i--)walker = walker.prev;
|
|
36149
|
-
for(; walker !== null && i > from; i--, walker = walker.prev)ret.push(walker.value);
|
|
36150
|
-
return ret;
|
|
36151
|
-
};
|
|
36152
|
-
$1ba40dc599466f23$var$Yallist.prototype.splice = function(start, deleteCount, ...nodes) {
|
|
36153
|
-
if (start > this.length) start = this.length - 1;
|
|
36154
|
-
if (start < 0) start = this.length + start;
|
|
36155
|
-
for(var i = 0, walker = this.head; walker !== null && i < start; i++)walker = walker.next;
|
|
36156
|
-
var ret = [];
|
|
36157
|
-
for(var i = 0; walker && i < deleteCount; i++){
|
|
36158
|
-
ret.push(walker.value);
|
|
36159
|
-
walker = this.removeNode(walker);
|
|
36375
|
+
/**
|
|
36376
|
+
* The number of items stored in the cache (read-only)
|
|
36377
|
+
*/ get size() {
|
|
36378
|
+
return this.#size;
|
|
36160
36379
|
}
|
|
36161
|
-
|
|
36162
|
-
|
|
36163
|
-
|
|
36164
|
-
|
|
36165
|
-
}
|
|
36166
|
-
|
|
36167
|
-
|
|
36168
|
-
|
|
36169
|
-
|
|
36170
|
-
|
|
36171
|
-
|
|
36172
|
-
|
|
36380
|
+
/**
|
|
36381
|
+
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
|
|
36382
|
+
*/ get fetchMethod() {
|
|
36383
|
+
return this.#fetchMethod;
|
|
36384
|
+
}
|
|
36385
|
+
get memoMethod() {
|
|
36386
|
+
return this.#memoMethod;
|
|
36387
|
+
}
|
|
36388
|
+
/**
|
|
36389
|
+
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
36390
|
+
*/ get dispose() {
|
|
36391
|
+
return this.#dispose;
|
|
36392
|
+
}
|
|
36393
|
+
/**
|
|
36394
|
+
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
36395
|
+
*/ get disposeAfter() {
|
|
36396
|
+
return this.#disposeAfter;
|
|
36173
36397
|
}
|
|
36174
|
-
this.head = tail;
|
|
36175
|
-
this.tail = head;
|
|
36176
|
-
return this;
|
|
36177
|
-
};
|
|
36178
|
-
function $1ba40dc599466f23$var$insert(self, node, value) {
|
|
36179
|
-
var inserted = node === self.head ? new $1ba40dc599466f23$var$Node(value, null, node, self) : new $1ba40dc599466f23$var$Node(value, node, node.next, self);
|
|
36180
|
-
if (inserted.next === null) self.tail = inserted;
|
|
36181
|
-
if (inserted.prev === null) self.head = inserted;
|
|
36182
|
-
self.length++;
|
|
36183
|
-
return inserted;
|
|
36184
|
-
}
|
|
36185
|
-
function $1ba40dc599466f23$var$push(self, item) {
|
|
36186
|
-
self.tail = new $1ba40dc599466f23$var$Node(item, self.tail, null, self);
|
|
36187
|
-
if (!self.head) self.head = self.tail;
|
|
36188
|
-
self.length++;
|
|
36189
|
-
}
|
|
36190
|
-
function $1ba40dc599466f23$var$unshift(self, item) {
|
|
36191
|
-
self.head = new $1ba40dc599466f23$var$Node(item, null, self.head, self);
|
|
36192
|
-
if (!self.tail) self.tail = self.head;
|
|
36193
|
-
self.length++;
|
|
36194
|
-
}
|
|
36195
|
-
function $1ba40dc599466f23$var$Node(value, prev, next, list) {
|
|
36196
|
-
if (!(this instanceof $1ba40dc599466f23$var$Node)) return new $1ba40dc599466f23$var$Node(value, prev, next, list);
|
|
36197
|
-
this.list = list;
|
|
36198
|
-
this.value = value;
|
|
36199
|
-
if (prev) {
|
|
36200
|
-
prev.next = this;
|
|
36201
|
-
this.prev = prev;
|
|
36202
|
-
} else this.prev = null;
|
|
36203
|
-
if (next) {
|
|
36204
|
-
next.prev = this;
|
|
36205
|
-
this.next = next;
|
|
36206
|
-
} else this.next = null;
|
|
36207
|
-
}
|
|
36208
|
-
|
|
36209
|
-
try {
|
|
36210
|
-
// add if support for Symbol.iterator is present
|
|
36211
|
-
(parcelRequire("ff5ZV"))($1ba40dc599466f23$var$Yallist);
|
|
36212
|
-
} catch (er) {}
|
|
36213
|
-
|
|
36214
|
-
|
|
36215
|
-
const $15592b8231ef184c$var$MAX = Symbol('max');
|
|
36216
|
-
const $15592b8231ef184c$var$LENGTH = Symbol('length');
|
|
36217
|
-
const $15592b8231ef184c$var$LENGTH_CALCULATOR = Symbol('lengthCalculator');
|
|
36218
|
-
const $15592b8231ef184c$var$ALLOW_STALE = Symbol('allowStale');
|
|
36219
|
-
const $15592b8231ef184c$var$MAX_AGE = Symbol('maxAge');
|
|
36220
|
-
const $15592b8231ef184c$var$DISPOSE = Symbol('dispose');
|
|
36221
|
-
const $15592b8231ef184c$var$NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
|
|
36222
|
-
const $15592b8231ef184c$var$LRU_LIST = Symbol('lruList');
|
|
36223
|
-
const $15592b8231ef184c$var$CACHE = Symbol('cache');
|
|
36224
|
-
const $15592b8231ef184c$var$UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
|
|
36225
|
-
const $15592b8231ef184c$var$naiveLength = ()=>1;
|
|
36226
|
-
// lruList is a yallist where the head is the youngest
|
|
36227
|
-
// item, and the tail is the oldest. the list contains the Hit
|
|
36228
|
-
// objects as the entries.
|
|
36229
|
-
// Each Hit object has a reference to its Yallist.Node. This
|
|
36230
|
-
// never changes.
|
|
36231
|
-
//
|
|
36232
|
-
// cache is a Map (or PseudoMap) that matches the keys to
|
|
36233
|
-
// the Yallist.Node object.
|
|
36234
|
-
class $15592b8231ef184c$var$LRUCache {
|
|
36235
36398
|
constructor(options){
|
|
36236
|
-
|
|
36237
|
-
|
|
36238
|
-
|
|
36239
|
-
if (!
|
|
36240
|
-
|
|
36241
|
-
|
|
36242
|
-
|
|
36243
|
-
|
|
36244
|
-
this
|
|
36245
|
-
|
|
36246
|
-
|
|
36247
|
-
|
|
36248
|
-
|
|
36249
|
-
this
|
|
36250
|
-
|
|
36251
|
-
this
|
|
36252
|
-
|
|
36253
|
-
|
|
36254
|
-
|
|
36255
|
-
|
|
36256
|
-
this
|
|
36257
|
-
|
|
36258
|
-
|
|
36259
|
-
|
|
36260
|
-
|
|
36261
|
-
|
|
36262
|
-
|
|
36263
|
-
this
|
|
36264
|
-
|
|
36265
|
-
|
|
36266
|
-
|
|
36267
|
-
|
|
36268
|
-
|
|
36269
|
-
|
|
36270
|
-
|
|
36271
|
-
|
|
36272
|
-
|
|
36273
|
-
|
|
36274
|
-
|
|
36275
|
-
|
|
36276
|
-
|
|
36277
|
-
|
|
36278
|
-
|
|
36279
|
-
|
|
36280
|
-
|
|
36281
|
-
this
|
|
36282
|
-
|
|
36283
|
-
|
|
36284
|
-
|
|
36285
|
-
|
|
36399
|
+
const { max: max = 0, ttl: ttl, ttlResolution: ttlResolution = 1, ttlAutopurge: ttlAutopurge, updateAgeOnGet: updateAgeOnGet, updateAgeOnHas: updateAgeOnHas, allowStale: allowStale, dispose: dispose, disposeAfter: disposeAfter, noDisposeOnSet: noDisposeOnSet, noUpdateTTL: noUpdateTTL, maxSize: maxSize = 0, maxEntrySize: maxEntrySize = 0, sizeCalculation: sizeCalculation, fetchMethod: fetchMethod, memoMethod: memoMethod, noDeleteOnFetchRejection: noDeleteOnFetchRejection, noDeleteOnStaleGet: noDeleteOnStaleGet, allowStaleOnFetchRejection: allowStaleOnFetchRejection, allowStaleOnFetchAbort: allowStaleOnFetchAbort, ignoreFetchAbort: ignoreFetchAbort } = options;
|
|
36400
|
+
if (max !== 0 && !$34c2e4b61193a7f9$var$isPosInt(max)) throw new TypeError('max option must be a nonnegative integer');
|
|
36401
|
+
const UintArray = max ? $34c2e4b61193a7f9$var$getUintArray(max) : Array;
|
|
36402
|
+
if (!UintArray) throw new Error('invalid max value: ' + max);
|
|
36403
|
+
this.#max = max;
|
|
36404
|
+
this.#maxSize = maxSize;
|
|
36405
|
+
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
|
36406
|
+
this.sizeCalculation = sizeCalculation;
|
|
36407
|
+
if (this.sizeCalculation) {
|
|
36408
|
+
if (!this.#maxSize && !this.maxEntrySize) throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
|
|
36409
|
+
if (typeof this.sizeCalculation !== 'function') throw new TypeError('sizeCalculation set to non-function');
|
|
36410
|
+
}
|
|
36411
|
+
if (memoMethod !== undefined && typeof memoMethod !== 'function') throw new TypeError('memoMethod must be a function if defined');
|
|
36412
|
+
this.#memoMethod = memoMethod;
|
|
36413
|
+
if (fetchMethod !== undefined && typeof fetchMethod !== 'function') throw new TypeError('fetchMethod must be a function if specified');
|
|
36414
|
+
this.#fetchMethod = fetchMethod;
|
|
36415
|
+
this.#hasFetchMethod = !!fetchMethod;
|
|
36416
|
+
this.#keyMap = new Map();
|
|
36417
|
+
this.#keyList = new Array(max).fill(undefined);
|
|
36418
|
+
this.#valList = new Array(max).fill(undefined);
|
|
36419
|
+
this.#next = new UintArray(max);
|
|
36420
|
+
this.#prev = new UintArray(max);
|
|
36421
|
+
this.#head = 0;
|
|
36422
|
+
this.#tail = 0;
|
|
36423
|
+
this.#free = $34c2e4b61193a7f9$var$Stack.create(max);
|
|
36424
|
+
this.#size = 0;
|
|
36425
|
+
this.#calculatedSize = 0;
|
|
36426
|
+
if (typeof dispose === 'function') this.#dispose = dispose;
|
|
36427
|
+
if (typeof disposeAfter === 'function') {
|
|
36428
|
+
this.#disposeAfter = disposeAfter;
|
|
36429
|
+
this.#disposed = [];
|
|
36430
|
+
} else {
|
|
36431
|
+
this.#disposeAfter = undefined;
|
|
36432
|
+
this.#disposed = undefined;
|
|
36433
|
+
}
|
|
36434
|
+
this.#hasDispose = !!this.#dispose;
|
|
36435
|
+
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
36436
|
+
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
36437
|
+
this.noUpdateTTL = !!noUpdateTTL;
|
|
36438
|
+
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
|
36439
|
+
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
|
|
36440
|
+
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
|
36441
|
+
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
|
36442
|
+
// NB: maxEntrySize is set to maxSize if it's set
|
|
36443
|
+
if (this.maxEntrySize !== 0) {
|
|
36444
|
+
if (this.#maxSize !== 0) {
|
|
36445
|
+
if (!$34c2e4b61193a7f9$var$isPosInt(this.#maxSize)) throw new TypeError('maxSize must be a positive integer if specified');
|
|
36446
|
+
}
|
|
36447
|
+
if (!$34c2e4b61193a7f9$var$isPosInt(this.maxEntrySize)) throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
36448
|
+
this.#initializeSizeTracking();
|
|
36449
|
+
}
|
|
36450
|
+
this.allowStale = !!allowStale;
|
|
36451
|
+
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
36452
|
+
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
36453
|
+
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
36454
|
+
this.ttlResolution = $34c2e4b61193a7f9$var$isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
|
|
36455
|
+
this.ttlAutopurge = !!ttlAutopurge;
|
|
36456
|
+
this.ttl = ttl || 0;
|
|
36457
|
+
if (this.ttl) {
|
|
36458
|
+
if (!$34c2e4b61193a7f9$var$isPosInt(this.ttl)) throw new TypeError('ttl must be a positive integer if specified');
|
|
36459
|
+
this.#initializeTTLTracking();
|
|
36460
|
+
}
|
|
36461
|
+
// do not allow completely unbounded caches
|
|
36462
|
+
if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
36463
|
+
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
36464
|
+
const code = 'LRU_CACHE_UNBOUNDED';
|
|
36465
|
+
if ($34c2e4b61193a7f9$var$shouldWarn(code)) {
|
|
36466
|
+
$34c2e4b61193a7f9$var$warned.add(code);
|
|
36467
|
+
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
36468
|
+
$34c2e4b61193a7f9$var$emitWarning(msg, 'UnboundedCacheWarning', code, $34c2e4b61193a7f9$export$182500e6725aad9a);
|
|
36469
|
+
}
|
|
36286
36470
|
}
|
|
36287
|
-
|
|
36288
|
-
|
|
36289
|
-
|
|
36290
|
-
|
|
36291
|
-
|
|
36292
|
-
|
|
36293
|
-
|
|
36294
|
-
|
|
36295
|
-
|
|
36296
|
-
|
|
36297
|
-
|
|
36298
|
-
|
|
36299
|
-
|
|
36300
|
-
|
|
36301
|
-
|
|
36302
|
-
|
|
36303
|
-
|
|
36304
|
-
|
|
36305
|
-
|
|
36306
|
-
|
|
36307
|
-
|
|
36308
|
-
|
|
36309
|
-
|
|
36310
|
-
|
|
36311
|
-
|
|
36312
|
-
}
|
|
36313
|
-
|
|
36314
|
-
|
|
36315
|
-
|
|
36316
|
-
|
|
36317
|
-
|
|
36318
|
-
|
|
36319
|
-
|
|
36320
|
-
|
|
36321
|
-
|
|
36322
|
-
|
|
36323
|
-
;
|
|
36324
|
-
this[$15592b8231ef184c$var$LRU_LIST] = new $1ba40dc599466f23$exports() // list of items in order of use recency
|
|
36325
|
-
;
|
|
36326
|
-
this[$15592b8231ef184c$var$LENGTH] = 0 // length of items in the list
|
|
36327
|
-
;
|
|
36328
|
-
}
|
|
36329
|
-
dump() {
|
|
36330
|
-
return this[$15592b8231ef184c$var$LRU_LIST].map((hit)=>$15592b8231ef184c$var$isStale(this, hit) ? false : {
|
|
36331
|
-
k: hit.key,
|
|
36332
|
-
v: hit.value,
|
|
36333
|
-
e: hit.now + (hit.maxAge || 0)
|
|
36334
|
-
}).toArray().filter((h)=>h);
|
|
36335
|
-
}
|
|
36336
|
-
dumpLru() {
|
|
36337
|
-
return this[$15592b8231ef184c$var$LRU_LIST];
|
|
36338
|
-
}
|
|
36339
|
-
set(key, value, maxAge) {
|
|
36340
|
-
maxAge = maxAge || this[$15592b8231ef184c$var$MAX_AGE];
|
|
36341
|
-
if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number');
|
|
36342
|
-
const now = maxAge ? Date.now() : 0;
|
|
36343
|
-
const len = this[$15592b8231ef184c$var$LENGTH_CALCULATOR](value, key);
|
|
36344
|
-
if (this[$15592b8231ef184c$var$CACHE].has(key)) {
|
|
36345
|
-
if (len > this[$15592b8231ef184c$var$MAX]) {
|
|
36346
|
-
$15592b8231ef184c$var$del(this, this[$15592b8231ef184c$var$CACHE].get(key));
|
|
36347
|
-
return false;
|
|
36471
|
+
}
|
|
36472
|
+
/**
|
|
36473
|
+
* Return the number of ms left in the item's TTL. If item is not in cache,
|
|
36474
|
+
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
|
36475
|
+
*/ getRemainingTTL(key) {
|
|
36476
|
+
return this.#keyMap.has(key) ? Infinity : 0;
|
|
36477
|
+
}
|
|
36478
|
+
#initializeTTLTracking() {
|
|
36479
|
+
const ttls = new $34c2e4b61193a7f9$var$ZeroArray(this.#max);
|
|
36480
|
+
const starts = new $34c2e4b61193a7f9$var$ZeroArray(this.#max);
|
|
36481
|
+
this.#ttls = ttls;
|
|
36482
|
+
this.#starts = starts;
|
|
36483
|
+
this.#setItemTTL = (index, ttl, start = $34c2e4b61193a7f9$var$perf.now())=>{
|
|
36484
|
+
starts[index] = ttl !== 0 ? start : 0;
|
|
36485
|
+
ttls[index] = ttl;
|
|
36486
|
+
if (ttl !== 0 && this.ttlAutopurge) {
|
|
36487
|
+
const t = setTimeout(()=>{
|
|
36488
|
+
if (this.#isStale(index)) this.#delete(this.#keyList[index], 'expire');
|
|
36489
|
+
}, ttl + 1);
|
|
36490
|
+
// unref() not supported on all platforms
|
|
36491
|
+
/* c8 ignore start */ if (t.unref) t.unref();
|
|
36492
|
+
/* c8 ignore stop */ }
|
|
36493
|
+
};
|
|
36494
|
+
this.#updateItemAge = (index)=>{
|
|
36495
|
+
starts[index] = ttls[index] !== 0 ? $34c2e4b61193a7f9$var$perf.now() : 0;
|
|
36496
|
+
};
|
|
36497
|
+
this.#statusTTL = (status, index)=>{
|
|
36498
|
+
if (ttls[index]) {
|
|
36499
|
+
const ttl = ttls[index];
|
|
36500
|
+
const start = starts[index];
|
|
36501
|
+
/* c8 ignore next */ if (!ttl || !start) return;
|
|
36502
|
+
status.ttl = ttl;
|
|
36503
|
+
status.start = start;
|
|
36504
|
+
status.now = cachedNow || getNow();
|
|
36505
|
+
const age = status.now - start;
|
|
36506
|
+
status.remainingTTL = ttl - age;
|
|
36348
36507
|
}
|
|
36349
|
-
|
|
36350
|
-
|
|
36351
|
-
|
|
36352
|
-
|
|
36353
|
-
|
|
36354
|
-
|
|
36355
|
-
|
|
36356
|
-
|
|
36357
|
-
|
|
36358
|
-
|
|
36359
|
-
|
|
36360
|
-
|
|
36361
|
-
|
|
36362
|
-
|
|
36363
|
-
|
|
36508
|
+
};
|
|
36509
|
+
// debounce calls to perf.now() to 1s so we're not hitting
|
|
36510
|
+
// that costly call repeatedly.
|
|
36511
|
+
let cachedNow = 0;
|
|
36512
|
+
const getNow = ()=>{
|
|
36513
|
+
const n = $34c2e4b61193a7f9$var$perf.now();
|
|
36514
|
+
if (this.ttlResolution > 0) {
|
|
36515
|
+
cachedNow = n;
|
|
36516
|
+
const t = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
36517
|
+
// not available on all platforms
|
|
36518
|
+
/* c8 ignore start */ if (t.unref) t.unref();
|
|
36519
|
+
/* c8 ignore stop */ }
|
|
36520
|
+
return n;
|
|
36521
|
+
};
|
|
36522
|
+
this.getRemainingTTL = (key)=>{
|
|
36523
|
+
const index = this.#keyMap.get(key);
|
|
36524
|
+
if (index === undefined) return 0;
|
|
36525
|
+
const ttl = ttls[index];
|
|
36526
|
+
const start = starts[index];
|
|
36527
|
+
if (!ttl || !start) return Infinity;
|
|
36528
|
+
const age = (cachedNow || getNow()) - start;
|
|
36529
|
+
return ttl - age;
|
|
36530
|
+
};
|
|
36531
|
+
this.#isStale = (index)=>{
|
|
36532
|
+
const s = starts[index];
|
|
36533
|
+
const t = ttls[index];
|
|
36534
|
+
return !!t && !!s && (cachedNow || getNow()) - s > t;
|
|
36535
|
+
};
|
|
36536
|
+
}
|
|
36537
|
+
// conditionally set private methods related to TTL
|
|
36538
|
+
#updateItemAge = ()=>{};
|
|
36539
|
+
#statusTTL = ()=>{};
|
|
36540
|
+
#setItemTTL = ()=>{};
|
|
36541
|
+
/* c8 ignore stop */ #isStale = ()=>false;
|
|
36542
|
+
#initializeSizeTracking() {
|
|
36543
|
+
const sizes = new $34c2e4b61193a7f9$var$ZeroArray(this.#max);
|
|
36544
|
+
this.#calculatedSize = 0;
|
|
36545
|
+
this.#sizes = sizes;
|
|
36546
|
+
this.#removeItemSize = (index)=>{
|
|
36547
|
+
this.#calculatedSize -= sizes[index];
|
|
36548
|
+
sizes[index] = 0;
|
|
36549
|
+
};
|
|
36550
|
+
this.#requireSize = (k, v, size, sizeCalculation)=>{
|
|
36551
|
+
// provisionally accept background fetches.
|
|
36552
|
+
// actual value size will be checked when they return.
|
|
36553
|
+
if (this.#isBackgroundFetch(v)) return 0;
|
|
36554
|
+
if (!$34c2e4b61193a7f9$var$isPosInt(size)) {
|
|
36555
|
+
if (sizeCalculation) {
|
|
36556
|
+
if (typeof sizeCalculation !== 'function') throw new TypeError('sizeCalculation must be a function');
|
|
36557
|
+
size = sizeCalculation(v, k);
|
|
36558
|
+
if (!$34c2e4b61193a7f9$var$isPosInt(size)) throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
36559
|
+
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
36560
|
+
}
|
|
36561
|
+
return size;
|
|
36562
|
+
};
|
|
36563
|
+
this.#addItemSize = (index, size, status)=>{
|
|
36564
|
+
sizes[index] = size;
|
|
36565
|
+
if (this.#maxSize) {
|
|
36566
|
+
const maxSize = this.#maxSize - sizes[index];
|
|
36567
|
+
while(this.#calculatedSize > maxSize)this.#evict(true);
|
|
36568
|
+
}
|
|
36569
|
+
this.#calculatedSize += sizes[index];
|
|
36570
|
+
if (status) {
|
|
36571
|
+
status.entrySize = size;
|
|
36572
|
+
status.totalCalculatedSize = this.#calculatedSize;
|
|
36573
|
+
}
|
|
36574
|
+
};
|
|
36575
|
+
}
|
|
36576
|
+
#removeItemSize = (_i)=>{};
|
|
36577
|
+
#addItemSize = (_i, _s, _st)=>{};
|
|
36578
|
+
#requireSize = (_k, _v, size, sizeCalculation)=>{
|
|
36579
|
+
if (size || sizeCalculation) throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
|
|
36580
|
+
return 0;
|
|
36581
|
+
};
|
|
36582
|
+
*#indexes({ allowStale: allowStale = this.allowStale } = {}) {
|
|
36583
|
+
if (this.#size) for(let i = this.#tail;;){
|
|
36584
|
+
if (!this.#isValidIndex(i)) break;
|
|
36585
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
36586
|
+
if (i === this.#head) break;
|
|
36587
|
+
else i = this.#prev[i];
|
|
36364
36588
|
}
|
|
36365
|
-
|
|
36366
|
-
|
|
36367
|
-
if (
|
|
36368
|
-
if (this
|
|
36369
|
-
|
|
36589
|
+
}
|
|
36590
|
+
*#rindexes({ allowStale: allowStale = this.allowStale } = {}) {
|
|
36591
|
+
if (this.#size) for(let i = this.#head;;){
|
|
36592
|
+
if (!this.#isValidIndex(i)) break;
|
|
36593
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
36594
|
+
if (i === this.#tail) break;
|
|
36595
|
+
else i = this.#next[i];
|
|
36370
36596
|
}
|
|
36371
|
-
this[$15592b8231ef184c$var$LENGTH] += hit.length;
|
|
36372
|
-
this[$15592b8231ef184c$var$LRU_LIST].unshift(hit);
|
|
36373
|
-
this[$15592b8231ef184c$var$CACHE].set(key, this[$15592b8231ef184c$var$LRU_LIST].head);
|
|
36374
|
-
$15592b8231ef184c$var$trim(this);
|
|
36375
|
-
return true;
|
|
36376
36597
|
}
|
|
36377
|
-
|
|
36378
|
-
|
|
36379
|
-
const hit = this[$15592b8231ef184c$var$CACHE].get(key).value;
|
|
36380
|
-
return !$15592b8231ef184c$var$isStale(this, hit);
|
|
36598
|
+
#isValidIndex(index) {
|
|
36599
|
+
return index !== undefined && this.#keyMap.get(this.#keyList[index]) === index;
|
|
36381
36600
|
}
|
|
36382
|
-
|
|
36383
|
-
|
|
36601
|
+
/**
|
|
36602
|
+
* Return a generator yielding `[key, value]` pairs,
|
|
36603
|
+
* in order from most recently used to least recently used.
|
|
36604
|
+
*/ *entries() {
|
|
36605
|
+
for (const i of this.#indexes())if (this.#valList[i] !== undefined && this.#keyList[i] !== undefined && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
36606
|
+
this.#keyList[i],
|
|
36607
|
+
this.#valList[i]
|
|
36608
|
+
];
|
|
36384
36609
|
}
|
|
36385
|
-
|
|
36386
|
-
|
|
36610
|
+
/**
|
|
36611
|
+
* Inverse order version of {@link LRUCache.entries}
|
|
36612
|
+
*
|
|
36613
|
+
* Return a generator yielding `[key, value]` pairs,
|
|
36614
|
+
* in order from least recently used to most recently used.
|
|
36615
|
+
*/ *rentries() {
|
|
36616
|
+
for (const i of this.#rindexes())if (this.#valList[i] !== undefined && this.#keyList[i] !== undefined && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
36617
|
+
this.#keyList[i],
|
|
36618
|
+
this.#valList[i]
|
|
36619
|
+
];
|
|
36387
36620
|
}
|
|
36388
|
-
|
|
36389
|
-
|
|
36390
|
-
|
|
36391
|
-
|
|
36392
|
-
|
|
36393
|
-
|
|
36394
|
-
|
|
36395
|
-
|
|
36396
|
-
}
|
|
36397
|
-
|
|
36398
|
-
|
|
36399
|
-
|
|
36400
|
-
|
|
36401
|
-
|
|
36402
|
-
|
|
36403
|
-
|
|
36404
|
-
const
|
|
36405
|
-
if (
|
|
36406
|
-
|
|
36407
|
-
|
|
36408
|
-
|
|
36409
|
-
|
|
36410
|
-
|
|
36621
|
+
/**
|
|
36622
|
+
* Return a generator yielding the keys in the cache,
|
|
36623
|
+
* in order from most recently used to least recently used.
|
|
36624
|
+
*/ *keys() {
|
|
36625
|
+
for (const i of this.#indexes()){
|
|
36626
|
+
const k = this.#keyList[i];
|
|
36627
|
+
if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
36628
|
+
}
|
|
36629
|
+
}
|
|
36630
|
+
/**
|
|
36631
|
+
* Inverse order version of {@link LRUCache.keys}
|
|
36632
|
+
*
|
|
36633
|
+
* Return a generator yielding the keys in the cache,
|
|
36634
|
+
* in order from least recently used to most recently used.
|
|
36635
|
+
*/ *rkeys() {
|
|
36636
|
+
for (const i of this.#rindexes()){
|
|
36637
|
+
const k = this.#keyList[i];
|
|
36638
|
+
if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
36639
|
+
}
|
|
36640
|
+
}
|
|
36641
|
+
/**
|
|
36642
|
+
* Return a generator yielding the values in the cache,
|
|
36643
|
+
* in order from most recently used to least recently used.
|
|
36644
|
+
*/ *values() {
|
|
36645
|
+
for (const i of this.#indexes()){
|
|
36646
|
+
const v = this.#valList[i];
|
|
36647
|
+
if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
36648
|
+
}
|
|
36649
|
+
}
|
|
36650
|
+
/**
|
|
36651
|
+
* Inverse order version of {@link LRUCache.values}
|
|
36652
|
+
*
|
|
36653
|
+
* Return a generator yielding the values in the cache,
|
|
36654
|
+
* in order from least recently used to most recently used.
|
|
36655
|
+
*/ *rvalues() {
|
|
36656
|
+
for (const i of this.#rindexes()){
|
|
36657
|
+
const v = this.#valList[i];
|
|
36658
|
+
if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
36659
|
+
}
|
|
36660
|
+
}
|
|
36661
|
+
/**
|
|
36662
|
+
* Iterating over the cache itself yields the same results as
|
|
36663
|
+
* {@link LRUCache.entries}
|
|
36664
|
+
*/ [Symbol.iterator]() {
|
|
36665
|
+
return this.entries();
|
|
36666
|
+
}
|
|
36667
|
+
/**
|
|
36668
|
+
* A String value that is used in the creation of the default string
|
|
36669
|
+
* description of an object. Called by the built-in method
|
|
36670
|
+
* `Object.prototype.toString`.
|
|
36671
|
+
*/ [Symbol.toStringTag] = 'LRUCache';
|
|
36672
|
+
/**
|
|
36673
|
+
* Find a value for which the supplied fn method returns a truthy value,
|
|
36674
|
+
* similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
|
|
36675
|
+
*/ find(fn, getOptions = {}) {
|
|
36676
|
+
for (const i of this.#indexes()){
|
|
36677
|
+
const v = this.#valList[i];
|
|
36678
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
36679
|
+
if (value === undefined) continue;
|
|
36680
|
+
if (fn(value, this.#keyList[i], this)) return this.get(this.#keyList[i], getOptions);
|
|
36681
|
+
}
|
|
36682
|
+
}
|
|
36683
|
+
/**
|
|
36684
|
+
* Call the supplied function on each item in the cache, in order from most
|
|
36685
|
+
* recently used to least recently used.
|
|
36686
|
+
*
|
|
36687
|
+
* `fn` is called as `fn(value, key, cache)`.
|
|
36688
|
+
*
|
|
36689
|
+
* If `thisp` is provided, function will be called in the `this`-context of
|
|
36690
|
+
* the provided object, or the cache if no `thisp` object is provided.
|
|
36691
|
+
*
|
|
36692
|
+
* Does not update age or recenty of use, or iterate over stale values.
|
|
36693
|
+
*/ forEach(fn, thisp = this) {
|
|
36694
|
+
for (const i of this.#indexes()){
|
|
36695
|
+
const v = this.#valList[i];
|
|
36696
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
36697
|
+
if (value === undefined) continue;
|
|
36698
|
+
fn.call(thisp, value, this.#keyList[i], this);
|
|
36699
|
+
}
|
|
36700
|
+
}
|
|
36701
|
+
/**
|
|
36702
|
+
* The same as {@link LRUCache.forEach} but items are iterated over in
|
|
36703
|
+
* reverse order. (ie, less recently used items are iterated over first.)
|
|
36704
|
+
*/ rforEach(fn, thisp = this) {
|
|
36705
|
+
for (const i of this.#rindexes()){
|
|
36706
|
+
const v = this.#valList[i];
|
|
36707
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
36708
|
+
if (value === undefined) continue;
|
|
36709
|
+
fn.call(thisp, value, this.#keyList[i], this);
|
|
36710
|
+
}
|
|
36711
|
+
}
|
|
36712
|
+
/**
|
|
36713
|
+
* Delete any stale entries. Returns true if anything was removed,
|
|
36714
|
+
* false otherwise.
|
|
36715
|
+
*/ purgeStale() {
|
|
36716
|
+
let deleted = false;
|
|
36717
|
+
for (const i of this.#rindexes({
|
|
36718
|
+
allowStale: true
|
|
36719
|
+
}))if (this.#isStale(i)) {
|
|
36720
|
+
this.#delete(this.#keyList[i], 'expire');
|
|
36721
|
+
deleted = true;
|
|
36722
|
+
}
|
|
36723
|
+
return deleted;
|
|
36724
|
+
}
|
|
36725
|
+
/**
|
|
36726
|
+
* Get the extended info about a given entry, to get its value, size, and
|
|
36727
|
+
* TTL info simultaneously. Returns `undefined` if the key is not present.
|
|
36728
|
+
*
|
|
36729
|
+
* Unlike {@link LRUCache#dump}, which is designed to be portable and survive
|
|
36730
|
+
* serialization, the `start` value is always the current timestamp, and the
|
|
36731
|
+
* `ttl` is a calculated remaining time to live (negative if expired).
|
|
36732
|
+
*
|
|
36733
|
+
* Always returns stale values, if their info is found in the cache, so be
|
|
36734
|
+
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
|
|
36735
|
+
* if relevant.
|
|
36736
|
+
*/ info(key) {
|
|
36737
|
+
const i = this.#keyMap.get(key);
|
|
36738
|
+
if (i === undefined) return undefined;
|
|
36739
|
+
const v = this.#valList[i];
|
|
36740
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
36741
|
+
if (value === undefined) return undefined;
|
|
36742
|
+
const entry = {
|
|
36743
|
+
value: value
|
|
36744
|
+
};
|
|
36745
|
+
if (this.#ttls && this.#starts) {
|
|
36746
|
+
const ttl = this.#ttls[i];
|
|
36747
|
+
const start = this.#starts[i];
|
|
36748
|
+
if (ttl && start) {
|
|
36749
|
+
const remain = ttl - ($34c2e4b61193a7f9$var$perf.now() - start);
|
|
36750
|
+
entry.ttl = remain;
|
|
36751
|
+
entry.start = Date.now();
|
|
36411
36752
|
}
|
|
36412
36753
|
}
|
|
36754
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
36755
|
+
return entry;
|
|
36413
36756
|
}
|
|
36414
|
-
|
|
36415
|
-
|
|
36757
|
+
/**
|
|
36758
|
+
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
36759
|
+
* passed to {@link LRLUCache#load}.
|
|
36760
|
+
*
|
|
36761
|
+
* The `start` fields are calculated relative to a portable `Date.now()`
|
|
36762
|
+
* timestamp, even if `performance.now()` is available.
|
|
36763
|
+
*
|
|
36764
|
+
* Stale entries are always included in the `dump`, even if
|
|
36765
|
+
* {@link LRUCache.OptionsBase.allowStale} is false.
|
|
36766
|
+
*
|
|
36767
|
+
* Note: this returns an actual array, not a generator, so it can be more
|
|
36768
|
+
* easily passed around.
|
|
36769
|
+
*/ dump() {
|
|
36770
|
+
const arr = [];
|
|
36771
|
+
for (const i of this.#indexes({
|
|
36772
|
+
allowStale: true
|
|
36773
|
+
})){
|
|
36774
|
+
const key = this.#keyList[i];
|
|
36775
|
+
const v = this.#valList[i];
|
|
36776
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
36777
|
+
if (value === undefined || key === undefined) continue;
|
|
36778
|
+
const entry = {
|
|
36779
|
+
value: value
|
|
36780
|
+
};
|
|
36781
|
+
if (this.#ttls && this.#starts) {
|
|
36782
|
+
entry.ttl = this.#ttls[i];
|
|
36783
|
+
// always dump the start relative to a portable timestamp
|
|
36784
|
+
// it's ok for this to be a bit slow, it's a rare operation.
|
|
36785
|
+
const age = $34c2e4b61193a7f9$var$perf.now() - this.#starts[i];
|
|
36786
|
+
entry.start = Math.floor(Date.now() - age);
|
|
36787
|
+
}
|
|
36788
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
36789
|
+
arr.unshift([
|
|
36790
|
+
key,
|
|
36791
|
+
entry
|
|
36792
|
+
]);
|
|
36793
|
+
}
|
|
36794
|
+
return arr;
|
|
36416
36795
|
}
|
|
36417
|
-
|
|
36418
|
-
|
|
36419
|
-
|
|
36420
|
-
|
|
36421
|
-
|
|
36422
|
-
|
|
36423
|
-
|
|
36424
|
-
|
|
36425
|
-
|
|
36426
|
-
|
|
36427
|
-
|
|
36796
|
+
/**
|
|
36797
|
+
* Reset the cache and load in the items in entries in the order listed.
|
|
36798
|
+
*
|
|
36799
|
+
* The shape of the resulting cache may be different if the same options are
|
|
36800
|
+
* not used in both caches.
|
|
36801
|
+
*
|
|
36802
|
+
* The `start` fields are assumed to be calculated relative to a portable
|
|
36803
|
+
* `Date.now()` timestamp, even if `performance.now()` is available.
|
|
36804
|
+
*/ load(arr) {
|
|
36805
|
+
this.clear();
|
|
36806
|
+
for (const [key, entry] of arr){
|
|
36807
|
+
if (entry.start) {
|
|
36808
|
+
// entry.start is a portable timestamp, but we may be using
|
|
36809
|
+
// node's performance.now(), so calculate the offset, so that
|
|
36810
|
+
// we get the intended remaining TTL, no matter how long it's
|
|
36811
|
+
// been on ice.
|
|
36812
|
+
//
|
|
36813
|
+
// it's ok for this to be a bit slow, it's a rare operation.
|
|
36814
|
+
const age = Date.now() - entry.start;
|
|
36815
|
+
entry.start = $34c2e4b61193a7f9$var$perf.now() - age;
|
|
36816
|
+
}
|
|
36817
|
+
this.set(key, entry.value, entry);
|
|
36428
36818
|
}
|
|
36429
|
-
return hit.value;
|
|
36430
36819
|
}
|
|
36431
|
-
|
|
36432
|
-
|
|
36433
|
-
|
|
36434
|
-
|
|
36435
|
-
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
|
|
36444
|
-
|
|
36820
|
+
/**
|
|
36821
|
+
* Add a value to the cache.
|
|
36822
|
+
*
|
|
36823
|
+
* Note: if `undefined` is specified as a value, this is an alias for
|
|
36824
|
+
* {@link LRUCache#delete}
|
|
36825
|
+
*
|
|
36826
|
+
* Fields on the {@link LRUCache.SetOptions} options param will override
|
|
36827
|
+
* their corresponding values in the constructor options for the scope
|
|
36828
|
+
* of this single `set()` operation.
|
|
36829
|
+
*
|
|
36830
|
+
* If `start` is provided, then that will set the effective start
|
|
36831
|
+
* time for the TTL calculation. Note that this must be a previous
|
|
36832
|
+
* value of `performance.now()` if supported, or a previous value of
|
|
36833
|
+
* `Date.now()` if not.
|
|
36834
|
+
*
|
|
36835
|
+
* Options object may also include `size`, which will prevent
|
|
36836
|
+
* calling the `sizeCalculation` function and just use the specified
|
|
36837
|
+
* number if it is a positive integer, and `noDisposeOnSet` which
|
|
36838
|
+
* will prevent calling a `dispose` function in the case of
|
|
36839
|
+
* overwrites.
|
|
36840
|
+
*
|
|
36841
|
+
* If the `size` (or return value of `sizeCalculation`) for a given
|
|
36842
|
+
* entry is greater than `maxEntrySize`, then the item will not be
|
|
36843
|
+
* added to the cache.
|
|
36844
|
+
*
|
|
36845
|
+
* Will update the recency of the entry.
|
|
36846
|
+
*
|
|
36847
|
+
* If the value is `undefined`, then this is an alias for
|
|
36848
|
+
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
36849
|
+
*/ set(k, v, setOptions = {}) {
|
|
36850
|
+
if (v === undefined) {
|
|
36851
|
+
this.delete(k);
|
|
36852
|
+
return this;
|
|
36853
|
+
}
|
|
36854
|
+
const { ttl: ttl = this.ttl, start: start, noDisposeOnSet: noDisposeOnSet = this.noDisposeOnSet, sizeCalculation: sizeCalculation = this.sizeCalculation, status: status } = setOptions;
|
|
36855
|
+
let { noUpdateTTL: noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
36856
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
36857
|
+
// if the item doesn't fit, don't do anything
|
|
36858
|
+
// NB: maxEntrySize set to maxSize by default
|
|
36859
|
+
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
36860
|
+
if (status) {
|
|
36861
|
+
status.set = 'miss';
|
|
36862
|
+
status.maxEntrySizeExceeded = true;
|
|
36863
|
+
}
|
|
36864
|
+
// have to delete, in case something is there already.
|
|
36865
|
+
this.#delete(k, 'set');
|
|
36866
|
+
return this;
|
|
36867
|
+
}
|
|
36868
|
+
let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
|
|
36869
|
+
if (index === undefined) {
|
|
36870
|
+
// addition
|
|
36871
|
+
index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
|
|
36872
|
+
this.#keyList[index] = k;
|
|
36873
|
+
this.#valList[index] = v;
|
|
36874
|
+
this.#keyMap.set(k, index);
|
|
36875
|
+
this.#next[this.#tail] = index;
|
|
36876
|
+
this.#prev[index] = this.#tail;
|
|
36877
|
+
this.#tail = index;
|
|
36878
|
+
this.#size++;
|
|
36879
|
+
this.#addItemSize(index, size, status);
|
|
36880
|
+
if (status) status.set = 'add';
|
|
36881
|
+
noUpdateTTL = false;
|
|
36882
|
+
} else {
|
|
36883
|
+
// update
|
|
36884
|
+
this.#moveToTail(index);
|
|
36885
|
+
const oldVal = this.#valList[index];
|
|
36886
|
+
if (v !== oldVal) {
|
|
36887
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
36888
|
+
oldVal.__abortController.abort(new Error('replaced'));
|
|
36889
|
+
const { __staleWhileFetching: s } = oldVal;
|
|
36890
|
+
if (s !== undefined && !noDisposeOnSet) {
|
|
36891
|
+
if (this.#hasDispose) this.#dispose?.(s, k, 'set');
|
|
36892
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
36893
|
+
s,
|
|
36894
|
+
k,
|
|
36895
|
+
'set'
|
|
36896
|
+
]);
|
|
36897
|
+
}
|
|
36898
|
+
} else if (!noDisposeOnSet) {
|
|
36899
|
+
if (this.#hasDispose) this.#dispose?.(oldVal, k, 'set');
|
|
36900
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
36901
|
+
oldVal,
|
|
36902
|
+
k,
|
|
36903
|
+
'set'
|
|
36904
|
+
]);
|
|
36905
|
+
}
|
|
36906
|
+
this.#removeItemSize(index);
|
|
36907
|
+
this.#addItemSize(index, size, status);
|
|
36908
|
+
this.#valList[index] = v;
|
|
36909
|
+
if (status) {
|
|
36910
|
+
status.set = 'replace';
|
|
36911
|
+
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
|
36912
|
+
if (oldValue !== undefined) status.oldValue = oldValue;
|
|
36913
|
+
}
|
|
36914
|
+
} else if (status) status.set = 'update';
|
|
36915
|
+
}
|
|
36916
|
+
if (ttl !== 0 && !this.#ttls) this.#initializeTTLTracking();
|
|
36917
|
+
if (this.#ttls) {
|
|
36918
|
+
if (!noUpdateTTL) this.#setItemTTL(index, ttl, start);
|
|
36919
|
+
if (status) this.#statusTTL(status, index);
|
|
36920
|
+
}
|
|
36921
|
+
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
36922
|
+
const dt = this.#disposed;
|
|
36923
|
+
let task;
|
|
36924
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
36925
|
+
}
|
|
36926
|
+
return this;
|
|
36445
36927
|
}
|
|
36446
|
-
|
|
36447
|
-
|
|
36448
|
-
|
|
36449
|
-
|
|
36450
|
-
|
|
36451
|
-
|
|
36452
|
-
|
|
36453
|
-
|
|
36928
|
+
/**
|
|
36929
|
+
* Evict the least recently used item, returning its value or
|
|
36930
|
+
* `undefined` if cache is empty.
|
|
36931
|
+
*/ pop() {
|
|
36932
|
+
try {
|
|
36933
|
+
while(this.#size){
|
|
36934
|
+
const val = this.#valList[this.#head];
|
|
36935
|
+
this.#evict(true);
|
|
36936
|
+
if (this.#isBackgroundFetch(val)) {
|
|
36937
|
+
if (val.__staleWhileFetching) return val.__staleWhileFetching;
|
|
36938
|
+
} else if (val !== undefined) return val;
|
|
36939
|
+
}
|
|
36940
|
+
} finally{
|
|
36941
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
36942
|
+
const dt = this.#disposed;
|
|
36943
|
+
let task;
|
|
36944
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
36945
|
+
}
|
|
36946
|
+
}
|
|
36454
36947
|
}
|
|
36455
|
-
|
|
36456
|
-
|
|
36457
|
-
|
|
36458
|
-
|
|
36459
|
-
this.
|
|
36460
|
-
this
|
|
36461
|
-
|
|
36462
|
-
|
|
36948
|
+
#evict(free) {
|
|
36949
|
+
const head = this.#head;
|
|
36950
|
+
const k = this.#keyList[head];
|
|
36951
|
+
const v = this.#valList[head];
|
|
36952
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('evicted'));
|
|
36953
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
36954
|
+
if (this.#hasDispose) this.#dispose?.(v, k, 'evict');
|
|
36955
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
36956
|
+
v,
|
|
36957
|
+
k,
|
|
36958
|
+
'evict'
|
|
36959
|
+
]);
|
|
36960
|
+
}
|
|
36961
|
+
this.#removeItemSize(head);
|
|
36962
|
+
// if we aren't about to use the index, then null these out
|
|
36963
|
+
if (free) {
|
|
36964
|
+
this.#keyList[head] = undefined;
|
|
36965
|
+
this.#valList[head] = undefined;
|
|
36966
|
+
this.#free.push(head);
|
|
36967
|
+
}
|
|
36968
|
+
if (this.#size === 1) {
|
|
36969
|
+
this.#head = this.#tail = 0;
|
|
36970
|
+
this.#free.length = 0;
|
|
36971
|
+
} else this.#head = this.#next[head];
|
|
36972
|
+
this.#keyMap.delete(k);
|
|
36973
|
+
this.#size--;
|
|
36974
|
+
return head;
|
|
36463
36975
|
}
|
|
36464
|
-
|
|
36465
|
-
|
|
36466
|
-
|
|
36467
|
-
|
|
36468
|
-
|
|
36469
|
-
|
|
36976
|
+
/**
|
|
36977
|
+
* Check if a key is in the cache, without updating the recency of use.
|
|
36978
|
+
* Will return false if the item is stale, even though it is technically
|
|
36979
|
+
* in the cache.
|
|
36980
|
+
*
|
|
36981
|
+
* Check if a key is in the cache, without updating the recency of
|
|
36982
|
+
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
|
|
36983
|
+
* to `true` in either the options or the constructor.
|
|
36984
|
+
*
|
|
36985
|
+
* Will return `false` if the item is stale, even though it is technically in
|
|
36986
|
+
* the cache. The difference can be determined (if it matters) by using a
|
|
36987
|
+
* `status` argument, and inspecting the `has` field.
|
|
36988
|
+
*
|
|
36989
|
+
* Will not update item age unless
|
|
36990
|
+
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
36991
|
+
*/ has(k, hasOptions = {}) {
|
|
36992
|
+
const { updateAgeOnHas: updateAgeOnHas = this.updateAgeOnHas, status: status } = hasOptions;
|
|
36993
|
+
const index = this.#keyMap.get(k);
|
|
36994
|
+
if (index !== undefined) {
|
|
36995
|
+
const v = this.#valList[index];
|
|
36996
|
+
if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === undefined) return false;
|
|
36997
|
+
if (!this.#isStale(index)) {
|
|
36998
|
+
if (updateAgeOnHas) this.#updateItemAge(index);
|
|
36999
|
+
if (status) {
|
|
37000
|
+
status.has = 'hit';
|
|
37001
|
+
this.#statusTTL(status, index);
|
|
37002
|
+
}
|
|
37003
|
+
return true;
|
|
37004
|
+
} else if (status) {
|
|
37005
|
+
status.has = 'stale';
|
|
37006
|
+
this.#statusTTL(status, index);
|
|
37007
|
+
}
|
|
37008
|
+
} else if (status) status.has = 'miss';
|
|
37009
|
+
return false;
|
|
36470
37010
|
}
|
|
36471
|
-
|
|
36472
|
-
}
|
|
36473
|
-
|
|
37011
|
+
/**
|
|
37012
|
+
* Like {@link LRUCache#get} but doesn't update recency or delete stale
|
|
37013
|
+
* items.
|
|
37014
|
+
*
|
|
37015
|
+
* Returns `undefined` if the item is stale, unless
|
|
37016
|
+
* {@link LRUCache.OptionsBase.allowStale} is set.
|
|
37017
|
+
*/ peek(k, peekOptions = {}) {
|
|
37018
|
+
const { allowStale: allowStale = this.allowStale } = peekOptions;
|
|
37019
|
+
const index = this.#keyMap.get(k);
|
|
37020
|
+
if (index === undefined || !allowStale && this.#isStale(index)) return;
|
|
37021
|
+
const v = this.#valList[index];
|
|
37022
|
+
// either stale and allowed, or forcing a refresh of non-stale value
|
|
37023
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
37024
|
+
}
|
|
37025
|
+
#backgroundFetch(k, index, options, context) {
|
|
37026
|
+
const v = index === undefined ? undefined : this.#valList[index];
|
|
37027
|
+
if (this.#isBackgroundFetch(v)) return v;
|
|
37028
|
+
const ac = new $34c2e4b61193a7f9$var$AC();
|
|
37029
|
+
const { signal: signal } = options;
|
|
37030
|
+
// when/if our AC signals, then stop listening to theirs.
|
|
37031
|
+
signal?.addEventListener('abort', ()=>ac.abort(signal.reason), {
|
|
37032
|
+
signal: ac.signal
|
|
37033
|
+
});
|
|
37034
|
+
const fetchOpts = {
|
|
37035
|
+
signal: ac.signal,
|
|
37036
|
+
options: options,
|
|
37037
|
+
context: context
|
|
37038
|
+
};
|
|
37039
|
+
const cb = (v, updateCache = false)=>{
|
|
37040
|
+
const { aborted: aborted } = ac.signal;
|
|
37041
|
+
const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
|
|
37042
|
+
if (options.status) {
|
|
37043
|
+
if (aborted && !updateCache) {
|
|
37044
|
+
options.status.fetchAborted = true;
|
|
37045
|
+
options.status.fetchError = ac.signal.reason;
|
|
37046
|
+
if (ignoreAbort) options.status.fetchAbortIgnored = true;
|
|
37047
|
+
} else options.status.fetchResolved = true;
|
|
37048
|
+
}
|
|
37049
|
+
if (aborted && !ignoreAbort && !updateCache) return fetchFail(ac.signal.reason);
|
|
37050
|
+
// either we didn't abort, and are still here, or we did, and ignored
|
|
37051
|
+
const bf = p;
|
|
37052
|
+
if (this.#valList[index] === p) {
|
|
37053
|
+
if (v === undefined) {
|
|
37054
|
+
if (bf.__staleWhileFetching) this.#valList[index] = bf.__staleWhileFetching;
|
|
37055
|
+
else this.#delete(k, 'fetch');
|
|
37056
|
+
} else {
|
|
37057
|
+
if (options.status) options.status.fetchUpdated = true;
|
|
37058
|
+
this.set(k, v, fetchOpts.options);
|
|
37059
|
+
}
|
|
37060
|
+
}
|
|
37061
|
+
return v;
|
|
37062
|
+
};
|
|
37063
|
+
const eb = (er)=>{
|
|
37064
|
+
if (options.status) {
|
|
37065
|
+
options.status.fetchRejected = true;
|
|
37066
|
+
options.status.fetchError = er;
|
|
37067
|
+
}
|
|
37068
|
+
return fetchFail(er);
|
|
37069
|
+
};
|
|
37070
|
+
const fetchFail = (er)=>{
|
|
37071
|
+
const { aborted: aborted } = ac.signal;
|
|
37072
|
+
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
37073
|
+
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
37074
|
+
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
37075
|
+
const bf = p;
|
|
37076
|
+
if (this.#valList[index] === p) {
|
|
37077
|
+
// if we allow stale on fetch rejections, then we need to ensure that
|
|
37078
|
+
// the stale value is not removed from the cache when the fetch fails.
|
|
37079
|
+
const del = !noDelete || bf.__staleWhileFetching === undefined;
|
|
37080
|
+
if (del) this.#delete(k, 'fetch');
|
|
37081
|
+
else if (!allowStaleAborted) // still replace the *promise* with the stale value,
|
|
37082
|
+
// since we are done with the promise at this point.
|
|
37083
|
+
// leave it untouched if we're still waiting for an
|
|
37084
|
+
// aborted background fetch that hasn't yet returned.
|
|
37085
|
+
this.#valList[index] = bf.__staleWhileFetching;
|
|
37086
|
+
}
|
|
37087
|
+
if (allowStale) {
|
|
37088
|
+
if (options.status && bf.__staleWhileFetching !== undefined) options.status.returnedStale = true;
|
|
37089
|
+
return bf.__staleWhileFetching;
|
|
37090
|
+
} else if (bf.__returned === bf) throw er;
|
|
37091
|
+
};
|
|
37092
|
+
const pcall = (res, rej)=>{
|
|
37093
|
+
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
37094
|
+
if (fmp && fmp instanceof Promise) fmp.then((v)=>res(v === undefined ? undefined : v), rej);
|
|
37095
|
+
// ignored, we go until we finish, regardless.
|
|
37096
|
+
// defer check until we are actually aborting,
|
|
37097
|
+
// so fetchMethod can override.
|
|
37098
|
+
ac.signal.addEventListener('abort', ()=>{
|
|
37099
|
+
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
|
37100
|
+
res(undefined);
|
|
37101
|
+
// when it eventually resolves, update the cache.
|
|
37102
|
+
if (options.allowStaleOnFetchAbort) res = (v)=>cb(v, true);
|
|
37103
|
+
}
|
|
37104
|
+
});
|
|
37105
|
+
};
|
|
37106
|
+
if (options.status) options.status.fetchDispatched = true;
|
|
37107
|
+
const p = new Promise(pcall).then(cb, eb);
|
|
37108
|
+
const bf = Object.assign(p, {
|
|
37109
|
+
__abortController: ac,
|
|
37110
|
+
__staleWhileFetching: v,
|
|
37111
|
+
__returned: undefined
|
|
37112
|
+
});
|
|
37113
|
+
if (index === undefined) {
|
|
37114
|
+
// internal, don't expose status.
|
|
37115
|
+
this.set(k, bf, {
|
|
37116
|
+
...fetchOpts.options,
|
|
37117
|
+
status: undefined
|
|
37118
|
+
});
|
|
37119
|
+
index = this.#keyMap.get(k);
|
|
37120
|
+
} else this.#valList[index] = bf;
|
|
37121
|
+
return bf;
|
|
37122
|
+
}
|
|
37123
|
+
#isBackgroundFetch(p) {
|
|
37124
|
+
if (!this.#hasFetchMethod) return false;
|
|
37125
|
+
const b = p;
|
|
37126
|
+
return !!b && b instanceof Promise && b.hasOwnProperty('__staleWhileFetching') && b.__abortController instanceof $34c2e4b61193a7f9$var$AC;
|
|
37127
|
+
}
|
|
37128
|
+
async fetch(k, fetchOptions = {}) {
|
|
37129
|
+
const { allowStale: // get options
|
|
37130
|
+
allowStale = this.allowStale, updateAgeOnGet: updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet: noDeleteOnStaleGet = this.noDeleteOnStaleGet, ttl: // set options
|
|
37131
|
+
ttl = this.ttl, noDisposeOnSet: noDisposeOnSet = this.noDisposeOnSet, size: size = 0, sizeCalculation: sizeCalculation = this.sizeCalculation, noUpdateTTL: noUpdateTTL = this.noUpdateTTL, noDeleteOnFetchRejection: // fetch exclusive options
|
|
37132
|
+
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort: ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort: allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context: context, forceRefresh: forceRefresh = false, status: status, signal: signal } = fetchOptions;
|
|
37133
|
+
if (!this.#hasFetchMethod) {
|
|
37134
|
+
if (status) status.fetch = 'get';
|
|
37135
|
+
return this.get(k, {
|
|
37136
|
+
allowStale: allowStale,
|
|
37137
|
+
updateAgeOnGet: updateAgeOnGet,
|
|
37138
|
+
noDeleteOnStaleGet: noDeleteOnStaleGet,
|
|
37139
|
+
status: status
|
|
37140
|
+
});
|
|
37141
|
+
}
|
|
37142
|
+
const options = {
|
|
37143
|
+
allowStale: allowStale,
|
|
37144
|
+
updateAgeOnGet: updateAgeOnGet,
|
|
37145
|
+
noDeleteOnStaleGet: noDeleteOnStaleGet,
|
|
37146
|
+
ttl: ttl,
|
|
37147
|
+
noDisposeOnSet: noDisposeOnSet,
|
|
37148
|
+
size: size,
|
|
37149
|
+
sizeCalculation: sizeCalculation,
|
|
37150
|
+
noUpdateTTL: noUpdateTTL,
|
|
37151
|
+
noDeleteOnFetchRejection: noDeleteOnFetchRejection,
|
|
37152
|
+
allowStaleOnFetchRejection: allowStaleOnFetchRejection,
|
|
37153
|
+
allowStaleOnFetchAbort: allowStaleOnFetchAbort,
|
|
37154
|
+
ignoreFetchAbort: ignoreFetchAbort,
|
|
37155
|
+
status: status,
|
|
37156
|
+
signal: signal
|
|
37157
|
+
};
|
|
37158
|
+
let index = this.#keyMap.get(k);
|
|
37159
|
+
if (index === undefined) {
|
|
37160
|
+
if (status) status.fetch = 'miss';
|
|
37161
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
37162
|
+
return p.__returned = p;
|
|
37163
|
+
} else {
|
|
37164
|
+
// in cache, maybe already fetching
|
|
37165
|
+
const v = this.#valList[index];
|
|
37166
|
+
if (this.#isBackgroundFetch(v)) {
|
|
37167
|
+
const stale = allowStale && v.__staleWhileFetching !== undefined;
|
|
37168
|
+
if (status) {
|
|
37169
|
+
status.fetch = 'inflight';
|
|
37170
|
+
if (stale) status.returnedStale = true;
|
|
37171
|
+
}
|
|
37172
|
+
return stale ? v.__staleWhileFetching : v.__returned = v;
|
|
37173
|
+
}
|
|
37174
|
+
// if we force a refresh, that means do NOT serve the cached value,
|
|
37175
|
+
// unless we are already in the process of refreshing the cache.
|
|
37176
|
+
const isStale = this.#isStale(index);
|
|
37177
|
+
if (!forceRefresh && !isStale) {
|
|
37178
|
+
if (status) status.fetch = 'hit';
|
|
37179
|
+
this.#moveToTail(index);
|
|
37180
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
37181
|
+
if (status) this.#statusTTL(status, index);
|
|
37182
|
+
return v;
|
|
37183
|
+
}
|
|
37184
|
+
// ok, it is stale or a forced refresh, and not already fetching.
|
|
37185
|
+
// refresh the cache.
|
|
37186
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
37187
|
+
const hasStale = p.__staleWhileFetching !== undefined;
|
|
37188
|
+
const staleVal = hasStale && allowStale;
|
|
37189
|
+
if (status) {
|
|
37190
|
+
status.fetch = isStale ? 'stale' : 'refresh';
|
|
37191
|
+
if (staleVal && isStale) status.returnedStale = true;
|
|
37192
|
+
}
|
|
37193
|
+
return staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
37194
|
+
}
|
|
37195
|
+
}
|
|
37196
|
+
async forceFetch(k, fetchOptions = {}) {
|
|
37197
|
+
const v = await this.fetch(k, fetchOptions);
|
|
37198
|
+
if (v === undefined) throw new Error('fetch() returned undefined');
|
|
37199
|
+
return v;
|
|
37200
|
+
}
|
|
37201
|
+
memo(k, memoOptions = {}) {
|
|
37202
|
+
const memoMethod = this.#memoMethod;
|
|
37203
|
+
if (!memoMethod) throw new Error('no memoMethod provided to constructor');
|
|
37204
|
+
const { context: context, forceRefresh: forceRefresh, ...options } = memoOptions;
|
|
37205
|
+
const v = this.get(k, options);
|
|
37206
|
+
if (!forceRefresh && v !== undefined) return v;
|
|
37207
|
+
const vv = memoMethod(k, v, {
|
|
37208
|
+
options: options,
|
|
37209
|
+
context: context
|
|
37210
|
+
});
|
|
37211
|
+
this.set(k, vv, options);
|
|
37212
|
+
return vv;
|
|
37213
|
+
}
|
|
37214
|
+
/**
|
|
37215
|
+
* Return a value from the cache. Will update the recency of the cache
|
|
37216
|
+
* entry found.
|
|
37217
|
+
*
|
|
37218
|
+
* If the key is not found, get() will return `undefined`.
|
|
37219
|
+
*/ get(k, getOptions = {}) {
|
|
37220
|
+
const { allowStale: allowStale = this.allowStale, updateAgeOnGet: updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet: noDeleteOnStaleGet = this.noDeleteOnStaleGet, status: status } = getOptions;
|
|
37221
|
+
const index = this.#keyMap.get(k);
|
|
37222
|
+
if (index !== undefined) {
|
|
37223
|
+
const value = this.#valList[index];
|
|
37224
|
+
const fetching = this.#isBackgroundFetch(value);
|
|
37225
|
+
if (status) this.#statusTTL(status, index);
|
|
37226
|
+
if (this.#isStale(index)) {
|
|
37227
|
+
if (status) status.get = 'stale';
|
|
37228
|
+
// delete only if not an in-flight background fetch
|
|
37229
|
+
if (!fetching) {
|
|
37230
|
+
if (!noDeleteOnStaleGet) this.#delete(k, 'expire');
|
|
37231
|
+
if (status && allowStale) status.returnedStale = true;
|
|
37232
|
+
return allowStale ? value : undefined;
|
|
37233
|
+
} else {
|
|
37234
|
+
if (status && allowStale && value.__staleWhileFetching !== undefined) status.returnedStale = true;
|
|
37235
|
+
return allowStale ? value.__staleWhileFetching : undefined;
|
|
37236
|
+
}
|
|
37237
|
+
} else {
|
|
37238
|
+
if (status) status.get = 'hit';
|
|
37239
|
+
// if we're currently fetching it, we don't actually have it yet
|
|
37240
|
+
// it's not stale, which means this isn't a staleWhileRefetching.
|
|
37241
|
+
// If it's not stale, and fetching, AND has a __staleWhileFetching
|
|
37242
|
+
// value, then that means the user fetched with {forceRefresh:true},
|
|
37243
|
+
// so it's safe to return that value.
|
|
37244
|
+
if (fetching) return value.__staleWhileFetching;
|
|
37245
|
+
this.#moveToTail(index);
|
|
37246
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
37247
|
+
return value;
|
|
37248
|
+
}
|
|
37249
|
+
} else if (status) status.get = 'miss';
|
|
37250
|
+
}
|
|
37251
|
+
#connect(p, n) {
|
|
37252
|
+
this.#prev[n] = p;
|
|
37253
|
+
this.#next[p] = n;
|
|
37254
|
+
}
|
|
37255
|
+
#moveToTail(index) {
|
|
37256
|
+
// if tail already, nothing to do
|
|
37257
|
+
// if head, move head to next[index]
|
|
37258
|
+
// else
|
|
37259
|
+
// move next[prev[index]] to next[index] (head has no prev)
|
|
37260
|
+
// move prev[next[index]] to prev[index]
|
|
37261
|
+
// prev[index] = tail
|
|
37262
|
+
// next[tail] = index
|
|
37263
|
+
// tail = index
|
|
37264
|
+
if (index !== this.#tail) {
|
|
37265
|
+
if (index === this.#head) this.#head = this.#next[index];
|
|
37266
|
+
else this.#connect(this.#prev[index], this.#next[index]);
|
|
37267
|
+
this.#connect(this.#tail, index);
|
|
37268
|
+
this.#tail = index;
|
|
37269
|
+
}
|
|
37270
|
+
}
|
|
37271
|
+
/**
|
|
37272
|
+
* Deletes a key out of the cache.
|
|
37273
|
+
*
|
|
37274
|
+
* Returns true if the key was deleted, false otherwise.
|
|
37275
|
+
*/ delete(k) {
|
|
37276
|
+
return this.#delete(k, 'delete');
|
|
37277
|
+
}
|
|
37278
|
+
#delete(k, reason) {
|
|
37279
|
+
let deleted = false;
|
|
37280
|
+
if (this.#size !== 0) {
|
|
37281
|
+
const index = this.#keyMap.get(k);
|
|
37282
|
+
if (index !== undefined) {
|
|
37283
|
+
deleted = true;
|
|
37284
|
+
if (this.#size === 1) this.#clear(reason);
|
|
37285
|
+
else {
|
|
37286
|
+
this.#removeItemSize(index);
|
|
37287
|
+
const v = this.#valList[index];
|
|
37288
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
37289
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
37290
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
37291
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
37292
|
+
v,
|
|
37293
|
+
k,
|
|
37294
|
+
reason
|
|
37295
|
+
]);
|
|
37296
|
+
}
|
|
37297
|
+
this.#keyMap.delete(k);
|
|
37298
|
+
this.#keyList[index] = undefined;
|
|
37299
|
+
this.#valList[index] = undefined;
|
|
37300
|
+
if (index === this.#tail) this.#tail = this.#prev[index];
|
|
37301
|
+
else if (index === this.#head) this.#head = this.#next[index];
|
|
37302
|
+
else {
|
|
37303
|
+
const pi = this.#prev[index];
|
|
37304
|
+
this.#next[pi] = this.#next[index];
|
|
37305
|
+
const ni = this.#next[index];
|
|
37306
|
+
this.#prev[ni] = this.#prev[index];
|
|
37307
|
+
}
|
|
37308
|
+
this.#size--;
|
|
37309
|
+
this.#free.push(index);
|
|
37310
|
+
}
|
|
37311
|
+
}
|
|
37312
|
+
}
|
|
37313
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
37314
|
+
const dt = this.#disposed;
|
|
37315
|
+
let task;
|
|
37316
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
37317
|
+
}
|
|
37318
|
+
return deleted;
|
|
37319
|
+
}
|
|
37320
|
+
/**
|
|
37321
|
+
* Clear the cache entirely, throwing away all values.
|
|
37322
|
+
*/ clear() {
|
|
37323
|
+
return this.#clear('delete');
|
|
37324
|
+
}
|
|
37325
|
+
#clear(reason) {
|
|
37326
|
+
for (const index of this.#rindexes({
|
|
37327
|
+
allowStale: true
|
|
37328
|
+
})){
|
|
37329
|
+
const v = this.#valList[index];
|
|
37330
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
37331
|
+
else {
|
|
37332
|
+
const k = this.#keyList[index];
|
|
37333
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
37334
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
37335
|
+
v,
|
|
37336
|
+
k,
|
|
37337
|
+
reason
|
|
37338
|
+
]);
|
|
37339
|
+
}
|
|
37340
|
+
}
|
|
37341
|
+
this.#keyMap.clear();
|
|
37342
|
+
this.#valList.fill(undefined);
|
|
37343
|
+
this.#keyList.fill(undefined);
|
|
37344
|
+
if (this.#ttls && this.#starts) {
|
|
37345
|
+
this.#ttls.fill(0);
|
|
37346
|
+
this.#starts.fill(0);
|
|
37347
|
+
}
|
|
37348
|
+
if (this.#sizes) this.#sizes.fill(0);
|
|
37349
|
+
this.#head = 0;
|
|
37350
|
+
this.#tail = 0;
|
|
37351
|
+
this.#free.length = 0;
|
|
37352
|
+
this.#calculatedSize = 0;
|
|
37353
|
+
this.#size = 0;
|
|
37354
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
37355
|
+
const dt = this.#disposed;
|
|
37356
|
+
let task;
|
|
37357
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
37358
|
+
}
|
|
37359
|
+
}
|
|
37360
|
+
}
|
|
36474
37361
|
|
|
36475
37362
|
|
|
36476
|
-
const $37dda638e06feff5$var$configCache = new (0,
|
|
37363
|
+
const $37dda638e06feff5$var$configCache = new (0, $34c2e4b61193a7f9$export$182500e6725aad9a)({
|
|
36477
37364
|
max: 500
|
|
36478
37365
|
});
|
|
36479
37366
|
const $37dda638e06feff5$var$resolveCache = new Map();
|
|
@@ -36520,7 +37407,7 @@ async function $37dda638e06feff5$export$c1a4367d4847eb06(fs, filepath, filenames
|
|
|
36520
37407
|
return null;
|
|
36521
37408
|
}
|
|
36522
37409
|
$37dda638e06feff5$export$c1a4367d4847eb06.clear = ()=>{
|
|
36523
|
-
$37dda638e06feff5$var$configCache.
|
|
37410
|
+
$37dda638e06feff5$var$configCache.clear();
|
|
36524
37411
|
$37dda638e06feff5$var$resolveCache.clear();
|
|
36525
37412
|
};
|
|
36526
37413
|
async function $37dda638e06feff5$export$f5327b421858c8cd(fs, configFile, opts) {
|
|
@@ -37323,6 +38210,46 @@ $7865b56d1a966ce7$exports = ({ onlyFirst: onlyFirst = false } = {})=>{
|
|
|
37323
38210
|
$c6e7686f671d96bd$exports = (string)=>typeof string === 'string' ? string.replace($7865b56d1a966ce7$exports(), '') : string;
|
|
37324
38211
|
|
|
37325
38212
|
|
|
38213
|
+
function $898ec9690c913f83$export$d9e46360b4510851(config) {
|
|
38214
|
+
if (!config) return {
|
|
38215
|
+
version: 3
|
|
38216
|
+
};
|
|
38217
|
+
// These options were removed in v2.
|
|
38218
|
+
if (config.full != null || config.svg2js != null) return {
|
|
38219
|
+
version: 2,
|
|
38220
|
+
path: config.full != null ? '/full' : '/svg2js'
|
|
38221
|
+
};
|
|
38222
|
+
if (Array.isArray(config.plugins)) {
|
|
38223
|
+
// Custom plugins in v2 had additional (required) fields that don't exist anymore.
|
|
38224
|
+
let v2Plugin = config.plugins.findIndex((p)=>p?.type != null || p?.fn && p?.params != null);
|
|
38225
|
+
if (v2Plugin !== -1) {
|
|
38226
|
+
let field = config.plugins[v2Plugin].type != null ? 'type' : 'params';
|
|
38227
|
+
return {
|
|
38228
|
+
version: 2,
|
|
38229
|
+
path: `/plugins/${v2Plugin}/${field}`
|
|
38230
|
+
};
|
|
38231
|
+
}
|
|
38232
|
+
// the cleanupIDs plugin lost the prefix option in v3.
|
|
38233
|
+
let cleanupIdsIndex = config.plugins.findIndex((p)=>p?.name === 'cleanupIDs');
|
|
38234
|
+
let cleanupIDs = cleanupIdsIndex !== -1 ? config.plugins[cleanupIdsIndex] : null;
|
|
38235
|
+
if (cleanupIDs?.params?.prefix != null) return {
|
|
38236
|
+
version: 2,
|
|
38237
|
+
path: `/plugins/${cleanupIdsIndex}/params/prefix`
|
|
38238
|
+
};
|
|
38239
|
+
// Automatically migrate some options from SVGO 2 config files.
|
|
38240
|
+
config.plugins = config.plugins.filter((p)=>p?.active !== false);
|
|
38241
|
+
for(let i = 0; i < config.plugins.length; i++){
|
|
38242
|
+
let p = config.plugins[i];
|
|
38243
|
+
if (p === 'cleanupIDs') config.plugins[i] = 'cleanupIds';
|
|
38244
|
+
if (p?.name === 'cleanupIDs') config.plugins[i].name = 'cleanupIds';
|
|
38245
|
+
}
|
|
38246
|
+
}
|
|
38247
|
+
return {
|
|
38248
|
+
version: 3
|
|
38249
|
+
};
|
|
38250
|
+
}
|
|
38251
|
+
|
|
38252
|
+
|
|
37326
38253
|
|
|
37327
38254
|
|
|
37328
38255
|
//# sourceMappingURL=index.js.map
|