@testream/junit-reporter 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{697.index.js → 759.index.js} +588 -1808
- package/dist/cli/{697.index.js → 759.index.js} +588 -1808
- package/dist/cli/converter.d.ts +1 -1
- package/dist/cli/converter.d.ts.map +1 -1
- package/dist/cli/index.d.ts +7 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/source-snippets.d.ts +13 -0
- package/dist/cli/source-snippets.d.ts.map +1 -0
- package/dist/cli/test-locations.d.ts +11 -0
- package/dist/cli/test-locations.d.ts.map +1 -0
- package/dist/cli/types.d.ts +14 -2
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/uploader.d.ts +3 -2
- package/dist/cli/uploader.d.ts.map +1 -1
- package/dist/converter.d.ts +1 -1
- package/dist/converter.d.ts.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/source-snippets.d.ts +14 -0
- package/dist/source-snippets.d.ts.map +1 -0
- package/dist/test-locations.d.ts +12 -0
- package/dist/test-locations.d.ts.map +1 -0
- package/dist/types.d.ts +14 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/uploader.d.ts +3 -2
- package/dist/uploader.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
exports.id =
|
|
2
|
-
exports.ids = [
|
|
1
|
+
exports.id = 759;
|
|
2
|
+
exports.ids = [759];
|
|
3
3
|
exports.modules = {
|
|
4
4
|
|
|
5
5
|
/***/ 8875:
|
|
@@ -9512,7 +9512,7 @@ exports.fromPromise = function (fn) {
|
|
|
9512
9512
|
|
|
9513
9513
|
/***/ }),
|
|
9514
9514
|
|
|
9515
|
-
/***/
|
|
9515
|
+
/***/ 3759:
|
|
9516
9516
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
9517
9517
|
|
|
9518
9518
|
"use strict";
|
|
@@ -9528,7 +9528,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
9528
9528
|
var lib = __webpack_require__(1348);
|
|
9529
9529
|
// EXTERNAL MODULE: ../../node_modules/xml2js/lib/xml2js.js
|
|
9530
9530
|
var xml2js = __webpack_require__(610);
|
|
9531
|
-
;// CONCATENATED MODULE: ../../node_modules
|
|
9531
|
+
;// CONCATENATED MODULE: ../../node_modules/minimatch/node_modules/balanced-match/dist/esm/index.js
|
|
9532
9532
|
const balanced = (a, b, str) => {
|
|
9533
9533
|
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
9534
9534
|
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
@@ -9583,7 +9583,7 @@ const range = (a, b, str) => {
|
|
|
9583
9583
|
return result;
|
|
9584
9584
|
};
|
|
9585
9585
|
//# sourceMappingURL=index.js.map
|
|
9586
|
-
;// CONCATENATED MODULE: ../../node_modules
|
|
9586
|
+
;// CONCATENATED MODULE: ../../node_modules/minimatch/node_modules/brace-expansion/dist/esm/index.js
|
|
9587
9587
|
|
|
9588
9588
|
const escSlash = '\0SLASH' + Math.random() + '\0';
|
|
9589
9589
|
const escOpen = '\0OPEN' + Math.random() + '\0';
|
|
@@ -9599,7 +9599,8 @@ const slashPattern = /\\\\/g;
|
|
|
9599
9599
|
const openPattern = /\\{/g;
|
|
9600
9600
|
const closePattern = /\\}/g;
|
|
9601
9601
|
const commaPattern = /\\,/g;
|
|
9602
|
-
const periodPattern =
|
|
9602
|
+
const periodPattern = /\\\./g;
|
|
9603
|
+
const EXPANSION_MAX = 100_000;
|
|
9603
9604
|
function numeric(str) {
|
|
9604
9605
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
9605
9606
|
}
|
|
@@ -9645,10 +9646,11 @@ function parseCommaParts(str) {
|
|
|
9645
9646
|
parts.push.apply(parts, p);
|
|
9646
9647
|
return parts;
|
|
9647
9648
|
}
|
|
9648
|
-
function expand(str) {
|
|
9649
|
+
function expand(str, options = {}) {
|
|
9649
9650
|
if (!str) {
|
|
9650
9651
|
return [];
|
|
9651
9652
|
}
|
|
9653
|
+
const { max = EXPANSION_MAX } = options;
|
|
9652
9654
|
// I don't know why Bash 4.3 does this, but it does.
|
|
9653
9655
|
// Anything starting with {} will have the first two bytes preserved
|
|
9654
9656
|
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
@@ -9658,7 +9660,7 @@ function expand(str) {
|
|
|
9658
9660
|
if (str.slice(0, 2) === '{}') {
|
|
9659
9661
|
str = '\\{\\}' + str.slice(2);
|
|
9660
9662
|
}
|
|
9661
|
-
return expand_(escapeBraces(str), true).map(unescapeBraces);
|
|
9663
|
+
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
9662
9664
|
}
|
|
9663
9665
|
function embrace(str) {
|
|
9664
9666
|
return '{' + str + '}';
|
|
@@ -9672,7 +9674,7 @@ function lte(i, y) {
|
|
|
9672
9674
|
function gte(i, y) {
|
|
9673
9675
|
return i >= y;
|
|
9674
9676
|
}
|
|
9675
|
-
function expand_(str, isTop) {
|
|
9677
|
+
function expand_(str, max, isTop) {
|
|
9676
9678
|
/** @type {string[]} */
|
|
9677
9679
|
const expansions = [];
|
|
9678
9680
|
const m = balanced('{', '}', str);
|
|
@@ -9680,9 +9682,9 @@ function expand_(str, isTop) {
|
|
|
9680
9682
|
return [str];
|
|
9681
9683
|
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
9682
9684
|
const pre = m.pre;
|
|
9683
|
-
const post = m.post.length ? expand_(m.post, false) : [''];
|
|
9685
|
+
const post = m.post.length ? expand_(m.post, max, false) : [''];
|
|
9684
9686
|
if (/\$$/.test(m.pre)) {
|
|
9685
|
-
for (let k = 0; k < post.length; k++) {
|
|
9687
|
+
for (let k = 0; k < post.length && k < max; k++) {
|
|
9686
9688
|
const expansion = pre + '{' + m.body + '}' + post[k];
|
|
9687
9689
|
expansions.push(expansion);
|
|
9688
9690
|
}
|
|
@@ -9696,7 +9698,7 @@ function expand_(str, isTop) {
|
|
|
9696
9698
|
// {a},b}
|
|
9697
9699
|
if (m.post.match(/,(?!,).*\}/)) {
|
|
9698
9700
|
str = m.pre + '{' + m.body + escClose + m.post;
|
|
9699
|
-
return expand_(str);
|
|
9701
|
+
return expand_(str, max, true);
|
|
9700
9702
|
}
|
|
9701
9703
|
return [str];
|
|
9702
9704
|
}
|
|
@@ -9708,7 +9710,7 @@ function expand_(str, isTop) {
|
|
|
9708
9710
|
n = parseCommaParts(m.body);
|
|
9709
9711
|
if (n.length === 1 && n[0] !== undefined) {
|
|
9710
9712
|
// x{{a,b}}y ==> x{a}y x{b}y
|
|
9711
|
-
n = expand_(n[0], false).map(embrace);
|
|
9713
|
+
n = expand_(n[0], max, false).map(embrace);
|
|
9712
9714
|
//XXX is this necessary? Can't seem to hit it in tests.
|
|
9713
9715
|
/* c8 ignore start */
|
|
9714
9716
|
if (n.length === 1) {
|
|
@@ -9724,7 +9726,9 @@ function expand_(str, isTop) {
|
|
|
9724
9726
|
const x = numeric(n[0]);
|
|
9725
9727
|
const y = numeric(n[1]);
|
|
9726
9728
|
const width = Math.max(n[0].length, n[1].length);
|
|
9727
|
-
let incr = n.length === 3 && n[2] !== undefined ?
|
|
9729
|
+
let incr = n.length === 3 && n[2] !== undefined ?
|
|
9730
|
+
Math.max(Math.abs(numeric(n[2])), 1)
|
|
9731
|
+
: 1;
|
|
9728
9732
|
let test = lte;
|
|
9729
9733
|
const reverse = y < x;
|
|
9730
9734
|
if (reverse) {
|
|
@@ -9733,7 +9737,7 @@ function expand_(str, isTop) {
|
|
|
9733
9737
|
}
|
|
9734
9738
|
const pad = n.some(isPadded);
|
|
9735
9739
|
N = [];
|
|
9736
|
-
for (let i = x; test(i, y); i += incr) {
|
|
9740
|
+
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
|
9737
9741
|
let c;
|
|
9738
9742
|
if (isAlphaSequence) {
|
|
9739
9743
|
c = String.fromCharCode(i);
|
|
@@ -9762,11 +9766,11 @@ function expand_(str, isTop) {
|
|
|
9762
9766
|
else {
|
|
9763
9767
|
N = [];
|
|
9764
9768
|
for (let j = 0; j < n.length; j++) {
|
|
9765
|
-
N.push.apply(N, expand_(n[j], false));
|
|
9769
|
+
N.push.apply(N, expand_(n[j], max, false));
|
|
9766
9770
|
}
|
|
9767
9771
|
}
|
|
9768
9772
|
for (let j = 0; j < N.length; j++) {
|
|
9769
|
-
for (let k = 0; k < post.length; k++) {
|
|
9773
|
+
for (let k = 0; k < post.length && expansions.length < max; k++) {
|
|
9770
9774
|
const expansion = pre + N[j] + post[k];
|
|
9771
9775
|
if (!isTop || isSequence || expansion) {
|
|
9772
9776
|
expansions.push(expansion);
|
|
@@ -9929,10 +9933,8 @@ const parseClass = (glob, position) => {
|
|
|
9929
9933
|
}
|
|
9930
9934
|
const sranges = '[' + (negate ? '^' : '') + rangesToString(ranges) + ']';
|
|
9931
9935
|
const snegs = '[' + (negate ? '' : '^') + rangesToString(negs) + ']';
|
|
9932
|
-
const comb = ranges.length && negs.length
|
|
9933
|
-
|
|
9934
|
-
: ranges.length
|
|
9935
|
-
? sranges
|
|
9936
|
+
const comb = ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'
|
|
9937
|
+
: ranges.length ? sranges
|
|
9936
9938
|
: snegs;
|
|
9937
9939
|
return [comb, uflag, endPos - pos, true];
|
|
9938
9940
|
};
|
|
@@ -9959,25 +9961,127 @@ const parseClass = (glob, position) => {
|
|
|
9959
9961
|
*/
|
|
9960
9962
|
const unescape_unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true, } = {}) => {
|
|
9961
9963
|
if (magicalBraces) {
|
|
9962
|
-
return windowsPathsNoEscape
|
|
9963
|
-
|
|
9964
|
+
return windowsPathsNoEscape ?
|
|
9965
|
+
s.replace(/\[([^/\\])\]/g, '$1')
|
|
9964
9966
|
: s
|
|
9965
|
-
.replace(/((?!\\).|^)\[([
|
|
9966
|
-
.replace(/\\([
|
|
9967
|
+
.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2')
|
|
9968
|
+
.replace(/\\([^/])/g, '$1');
|
|
9967
9969
|
}
|
|
9968
|
-
return windowsPathsNoEscape
|
|
9969
|
-
|
|
9970
|
+
return windowsPathsNoEscape ?
|
|
9971
|
+
s.replace(/\[([^/\\{}])\]/g, '$1')
|
|
9970
9972
|
: s
|
|
9971
|
-
.replace(/((?!\\).|^)\[([
|
|
9972
|
-
.replace(/\\([
|
|
9973
|
+
.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2')
|
|
9974
|
+
.replace(/\\([^/{}])/g, '$1');
|
|
9973
9975
|
};
|
|
9974
9976
|
//# sourceMappingURL=unescape.js.map
|
|
9975
9977
|
;// CONCATENATED MODULE: ../../node_modules/minimatch/dist/esm/ast.js
|
|
9976
9978
|
// parse a single path portion
|
|
9979
|
+
var _a;
|
|
9977
9980
|
|
|
9978
9981
|
|
|
9979
9982
|
const types = new Set(['!', '?', '+', '*', '@']);
|
|
9980
9983
|
const isExtglobType = (c) => types.has(c);
|
|
9984
|
+
const isExtglobAST = (c) => isExtglobType(c.type);
|
|
9985
|
+
// Map of which extglob types can adopt the children of a nested extglob
|
|
9986
|
+
//
|
|
9987
|
+
// anything but ! can adopt a matching type:
|
|
9988
|
+
// +(a|+(b|c)|d) => +(a|b|c|d)
|
|
9989
|
+
// *(a|*(b|c)|d) => *(a|b|c|d)
|
|
9990
|
+
// @(a|@(b|c)|d) => @(a|b|c|d)
|
|
9991
|
+
// ?(a|?(b|c)|d) => ?(a|b|c|d)
|
|
9992
|
+
//
|
|
9993
|
+
// * can adopt anything, because 0 or repetition is allowed
|
|
9994
|
+
// *(a|?(b|c)|d) => *(a|b|c|d)
|
|
9995
|
+
// *(a|+(b|c)|d) => *(a|b|c|d)
|
|
9996
|
+
// *(a|@(b|c)|d) => *(a|b|c|d)
|
|
9997
|
+
//
|
|
9998
|
+
// + can adopt @, because 1 or repetition is allowed
|
|
9999
|
+
// +(a|@(b|c)|d) => +(a|b|c|d)
|
|
10000
|
+
//
|
|
10001
|
+
// + and @ CANNOT adopt *, because 0 would be allowed
|
|
10002
|
+
// +(a|*(b|c)|d) => would match "", on *(b|c)
|
|
10003
|
+
// @(a|*(b|c)|d) => would match "", on *(b|c)
|
|
10004
|
+
//
|
|
10005
|
+
// + and @ CANNOT adopt ?, because 0 would be allowed
|
|
10006
|
+
// +(a|?(b|c)|d) => would match "", on ?(b|c)
|
|
10007
|
+
// @(a|?(b|c)|d) => would match "", on ?(b|c)
|
|
10008
|
+
//
|
|
10009
|
+
// ? can adopt @, because 0 or 1 is allowed
|
|
10010
|
+
// ?(a|@(b|c)|d) => ?(a|b|c|d)
|
|
10011
|
+
//
|
|
10012
|
+
// ? and @ CANNOT adopt * or +, because >1 would be allowed
|
|
10013
|
+
// ?(a|*(b|c)|d) => would match bbb on *(b|c)
|
|
10014
|
+
// @(a|*(b|c)|d) => would match bbb on *(b|c)
|
|
10015
|
+
// ?(a|+(b|c)|d) => would match bbb on +(b|c)
|
|
10016
|
+
// @(a|+(b|c)|d) => would match bbb on +(b|c)
|
|
10017
|
+
//
|
|
10018
|
+
// ! CANNOT adopt ! (nothing else can either)
|
|
10019
|
+
// !(a|!(b|c)|d) => !(a|b|c|d) would fail to match on b (not not b|c)
|
|
10020
|
+
//
|
|
10021
|
+
// ! can adopt @
|
|
10022
|
+
// !(a|@(b|c)|d) => !(a|b|c|d)
|
|
10023
|
+
//
|
|
10024
|
+
// ! CANNOT adopt *
|
|
10025
|
+
// !(a|*(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
|
|
10026
|
+
//
|
|
10027
|
+
// ! CANNOT adopt +
|
|
10028
|
+
// !(a|+(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
|
|
10029
|
+
//
|
|
10030
|
+
// ! CANNOT adopt ?
|
|
10031
|
+
// x!(a|?(b|c)|d) => x!(a|b|c|d) would fail to match "x"
|
|
10032
|
+
const adoptionMap = new Map([
|
|
10033
|
+
['!', ['@']],
|
|
10034
|
+
['?', ['?', '@']],
|
|
10035
|
+
['@', ['@']],
|
|
10036
|
+
['*', ['*', '+', '?', '@']],
|
|
10037
|
+
['+', ['+', '@']],
|
|
10038
|
+
]);
|
|
10039
|
+
// nested extglobs that can be adopted in, but with the addition of
|
|
10040
|
+
// a blank '' element.
|
|
10041
|
+
const adoptionWithSpaceMap = new Map([
|
|
10042
|
+
['!', ['?']],
|
|
10043
|
+
['@', ['?']],
|
|
10044
|
+
['+', ['?', '*']],
|
|
10045
|
+
]);
|
|
10046
|
+
// union of the previous two maps
|
|
10047
|
+
const adoptionAnyMap = new Map([
|
|
10048
|
+
['!', ['?', '@']],
|
|
10049
|
+
['?', ['?', '@']],
|
|
10050
|
+
['@', ['?', '@']],
|
|
10051
|
+
['*', ['*', '+', '?', '@']],
|
|
10052
|
+
['+', ['+', '@', '?', '*']],
|
|
10053
|
+
]);
|
|
10054
|
+
// Extglobs that can take over their parent if they are the only child
|
|
10055
|
+
// the key is parent, value maps child to resulting extglob parent type
|
|
10056
|
+
// '@' is omitted because it's a special case. An `@` extglob with a single
|
|
10057
|
+
// member can always be usurped by that subpattern.
|
|
10058
|
+
const usurpMap = new Map([
|
|
10059
|
+
['!', new Map([['!', '@']])],
|
|
10060
|
+
[
|
|
10061
|
+
'?',
|
|
10062
|
+
new Map([
|
|
10063
|
+
['*', '*'],
|
|
10064
|
+
['+', '*'],
|
|
10065
|
+
]),
|
|
10066
|
+
],
|
|
10067
|
+
[
|
|
10068
|
+
'@',
|
|
10069
|
+
new Map([
|
|
10070
|
+
['!', '!'],
|
|
10071
|
+
['?', '?'],
|
|
10072
|
+
['@', '@'],
|
|
10073
|
+
['*', '*'],
|
|
10074
|
+
['+', '+'],
|
|
10075
|
+
]),
|
|
10076
|
+
],
|
|
10077
|
+
[
|
|
10078
|
+
'+',
|
|
10079
|
+
new Map([
|
|
10080
|
+
['?', '*'],
|
|
10081
|
+
['*', '*'],
|
|
10082
|
+
]),
|
|
10083
|
+
],
|
|
10084
|
+
]);
|
|
9981
10085
|
// Patterns that get prepended to bind to the start of either the
|
|
9982
10086
|
// entire string, or just a single path portion, to prevent dots
|
|
9983
10087
|
// and/or traversal patterns, when needed.
|
|
@@ -10001,6 +10105,7 @@ const star = qmark + '*?';
|
|
|
10001
10105
|
const starNoEmpty = qmark + '+?';
|
|
10002
10106
|
// remove the \ chars that we added if we end up doing a nonmagic compare
|
|
10003
10107
|
// const deslash = (s: string) => s.replace(/\\(.)/g, '$1')
|
|
10108
|
+
let ID = 0;
|
|
10004
10109
|
class AST {
|
|
10005
10110
|
type;
|
|
10006
10111
|
#root;
|
|
@@ -10016,6 +10121,22 @@ class AST {
|
|
|
10016
10121
|
// set to true if it's an extglob with no children
|
|
10017
10122
|
// (which really means one child of '')
|
|
10018
10123
|
#emptyExt = false;
|
|
10124
|
+
id = ++ID;
|
|
10125
|
+
get depth() {
|
|
10126
|
+
return (this.#parent?.depth ?? -1) + 1;
|
|
10127
|
+
}
|
|
10128
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
10129
|
+
return {
|
|
10130
|
+
'@@type': 'AST',
|
|
10131
|
+
id: this.id,
|
|
10132
|
+
type: this.type,
|
|
10133
|
+
root: this.#root.id,
|
|
10134
|
+
parent: this.#parent?.id,
|
|
10135
|
+
depth: this.depth,
|
|
10136
|
+
partsLength: this.#parts.length,
|
|
10137
|
+
parts: this.#parts,
|
|
10138
|
+
};
|
|
10139
|
+
}
|
|
10019
10140
|
constructor(type, parent, options = {}) {
|
|
10020
10141
|
this.type = type;
|
|
10021
10142
|
// extglobs are inherently magical
|
|
@@ -10045,15 +10166,14 @@ class AST {
|
|
|
10045
10166
|
}
|
|
10046
10167
|
// reconstructs the pattern
|
|
10047
10168
|
toString() {
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
}
|
|
10169
|
+
return (this.#toString !== undefined ? this.#toString
|
|
10170
|
+
: !this.type ?
|
|
10171
|
+
(this.#toString = this.#parts.map(p => String(p)).join(''))
|
|
10172
|
+
: (this.#toString =
|
|
10173
|
+
this.type +
|
|
10174
|
+
'(' +
|
|
10175
|
+
this.#parts.map(p => String(p)).join('|') +
|
|
10176
|
+
')'));
|
|
10057
10177
|
}
|
|
10058
10178
|
#fillNegs() {
|
|
10059
10179
|
/* c8 ignore start */
|
|
@@ -10094,7 +10214,8 @@ class AST {
|
|
|
10094
10214
|
if (p === '')
|
|
10095
10215
|
continue;
|
|
10096
10216
|
/* c8 ignore start */
|
|
10097
|
-
if (typeof p !== 'string' &&
|
|
10217
|
+
if (typeof p !== 'string' &&
|
|
10218
|
+
!(p instanceof _a && p.#parent === this)) {
|
|
10098
10219
|
throw new Error('invalid part: ' + p);
|
|
10099
10220
|
}
|
|
10100
10221
|
/* c8 ignore stop */
|
|
@@ -10102,8 +10223,10 @@ class AST {
|
|
|
10102
10223
|
}
|
|
10103
10224
|
}
|
|
10104
10225
|
toJSON() {
|
|
10105
|
-
const ret = this.type === null
|
|
10106
|
-
|
|
10226
|
+
const ret = this.type === null ?
|
|
10227
|
+
this.#parts
|
|
10228
|
+
.slice()
|
|
10229
|
+
.map(p => (typeof p === 'string' ? p : p.toJSON()))
|
|
10107
10230
|
: [this.type, ...this.#parts.map(p => p.toJSON())];
|
|
10108
10231
|
if (this.isStart() && !this.type)
|
|
10109
10232
|
ret.unshift([]);
|
|
@@ -10126,7 +10249,7 @@ class AST {
|
|
|
10126
10249
|
const p = this.#parent;
|
|
10127
10250
|
for (let i = 0; i < this.#parentIndex; i++) {
|
|
10128
10251
|
const pp = p.#parts[i];
|
|
10129
|
-
if (!(pp instanceof
|
|
10252
|
+
if (!(pp instanceof _a && pp.type === '!')) {
|
|
10130
10253
|
return false;
|
|
10131
10254
|
}
|
|
10132
10255
|
}
|
|
@@ -10154,13 +10277,14 @@ class AST {
|
|
|
10154
10277
|
this.push(part.clone(this));
|
|
10155
10278
|
}
|
|
10156
10279
|
clone(parent) {
|
|
10157
|
-
const c = new
|
|
10280
|
+
const c = new _a(this.type, parent);
|
|
10158
10281
|
for (const p of this.#parts) {
|
|
10159
10282
|
c.copyIn(p);
|
|
10160
10283
|
}
|
|
10161
10284
|
return c;
|
|
10162
10285
|
}
|
|
10163
|
-
static #parseAST(str, ast, pos, opt) {
|
|
10286
|
+
static #parseAST(str, ast, pos, opt, extDepth) {
|
|
10287
|
+
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
10164
10288
|
let escaping = false;
|
|
10165
10289
|
let inBrace = false;
|
|
10166
10290
|
let braceStart = -1;
|
|
@@ -10197,11 +10321,17 @@ class AST {
|
|
|
10197
10321
|
acc += c;
|
|
10198
10322
|
continue;
|
|
10199
10323
|
}
|
|
10200
|
-
|
|
10324
|
+
// we don't have to check for adoption here, because that's
|
|
10325
|
+
// done at the other recursion point.
|
|
10326
|
+
const doRecurse = !opt.noext &&
|
|
10327
|
+
isExtglobType(c) &&
|
|
10328
|
+
str.charAt(i) === '(' &&
|
|
10329
|
+
extDepth <= maxDepth;
|
|
10330
|
+
if (doRecurse) {
|
|
10201
10331
|
ast.push(acc);
|
|
10202
10332
|
acc = '';
|
|
10203
|
-
const ext = new
|
|
10204
|
-
i =
|
|
10333
|
+
const ext = new _a(c, ast);
|
|
10334
|
+
i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
|
|
10205
10335
|
ast.push(ext);
|
|
10206
10336
|
continue;
|
|
10207
10337
|
}
|
|
@@ -10213,7 +10343,7 @@ class AST {
|
|
|
10213
10343
|
// some kind of extglob, pos is at the (
|
|
10214
10344
|
// find the next | or )
|
|
10215
10345
|
let i = pos + 1;
|
|
10216
|
-
let part = new
|
|
10346
|
+
let part = new _a(null, ast);
|
|
10217
10347
|
const parts = [];
|
|
10218
10348
|
let acc = '';
|
|
10219
10349
|
while (i < str.length) {
|
|
@@ -10244,19 +10374,26 @@ class AST {
|
|
|
10244
10374
|
acc += c;
|
|
10245
10375
|
continue;
|
|
10246
10376
|
}
|
|
10247
|
-
|
|
10377
|
+
const doRecurse = !opt.noext &&
|
|
10378
|
+
isExtglobType(c) &&
|
|
10379
|
+
str.charAt(i) === '(' &&
|
|
10380
|
+
/* c8 ignore start - the maxDepth is sufficient here */
|
|
10381
|
+
(extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
|
|
10382
|
+
/* c8 ignore stop */
|
|
10383
|
+
if (doRecurse) {
|
|
10384
|
+
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
10248
10385
|
part.push(acc);
|
|
10249
10386
|
acc = '';
|
|
10250
|
-
const ext = new
|
|
10387
|
+
const ext = new _a(c, part);
|
|
10251
10388
|
part.push(ext);
|
|
10252
|
-
i =
|
|
10389
|
+
i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
|
10253
10390
|
continue;
|
|
10254
10391
|
}
|
|
10255
10392
|
if (c === '|') {
|
|
10256
10393
|
part.push(acc);
|
|
10257
10394
|
acc = '';
|
|
10258
10395
|
parts.push(part);
|
|
10259
|
-
part = new
|
|
10396
|
+
part = new _a(null, ast);
|
|
10260
10397
|
continue;
|
|
10261
10398
|
}
|
|
10262
10399
|
if (c === ')') {
|
|
@@ -10278,9 +10415,82 @@ class AST {
|
|
|
10278
10415
|
ast.#parts = [str.substring(pos - 1)];
|
|
10279
10416
|
return i;
|
|
10280
10417
|
}
|
|
10418
|
+
#canAdoptWithSpace(child) {
|
|
10419
|
+
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
10420
|
+
}
|
|
10421
|
+
#canAdopt(child, map = adoptionMap) {
|
|
10422
|
+
if (!child ||
|
|
10423
|
+
typeof child !== 'object' ||
|
|
10424
|
+
child.type !== null ||
|
|
10425
|
+
child.#parts.length !== 1 ||
|
|
10426
|
+
this.type === null) {
|
|
10427
|
+
return false;
|
|
10428
|
+
}
|
|
10429
|
+
const gc = child.#parts[0];
|
|
10430
|
+
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
|
10431
|
+
return false;
|
|
10432
|
+
}
|
|
10433
|
+
return this.#canAdoptType(gc.type, map);
|
|
10434
|
+
}
|
|
10435
|
+
#canAdoptType(c, map = adoptionAnyMap) {
|
|
10436
|
+
return !!map.get(this.type)?.includes(c);
|
|
10437
|
+
}
|
|
10438
|
+
#adoptWithSpace(child, index) {
|
|
10439
|
+
const gc = child.#parts[0];
|
|
10440
|
+
const blank = new _a(null, gc, this.options);
|
|
10441
|
+
blank.#parts.push('');
|
|
10442
|
+
gc.push(blank);
|
|
10443
|
+
this.#adopt(child, index);
|
|
10444
|
+
}
|
|
10445
|
+
#adopt(child, index) {
|
|
10446
|
+
const gc = child.#parts[0];
|
|
10447
|
+
this.#parts.splice(index, 1, ...gc.#parts);
|
|
10448
|
+
for (const p of gc.#parts) {
|
|
10449
|
+
if (typeof p === 'object')
|
|
10450
|
+
p.#parent = this;
|
|
10451
|
+
}
|
|
10452
|
+
this.#toString = undefined;
|
|
10453
|
+
}
|
|
10454
|
+
#canUsurpType(c) {
|
|
10455
|
+
const m = usurpMap.get(this.type);
|
|
10456
|
+
return !!m?.has(c);
|
|
10457
|
+
}
|
|
10458
|
+
#canUsurp(child) {
|
|
10459
|
+
if (!child ||
|
|
10460
|
+
typeof child !== 'object' ||
|
|
10461
|
+
child.type !== null ||
|
|
10462
|
+
child.#parts.length !== 1 ||
|
|
10463
|
+
this.type === null ||
|
|
10464
|
+
this.#parts.length !== 1) {
|
|
10465
|
+
return false;
|
|
10466
|
+
}
|
|
10467
|
+
const gc = child.#parts[0];
|
|
10468
|
+
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
|
10469
|
+
return false;
|
|
10470
|
+
}
|
|
10471
|
+
return this.#canUsurpType(gc.type);
|
|
10472
|
+
}
|
|
10473
|
+
#usurp(child) {
|
|
10474
|
+
const m = usurpMap.get(this.type);
|
|
10475
|
+
const gc = child.#parts[0];
|
|
10476
|
+
const nt = m?.get(gc.type);
|
|
10477
|
+
/* c8 ignore start - impossible */
|
|
10478
|
+
if (!nt)
|
|
10479
|
+
return false;
|
|
10480
|
+
/* c8 ignore stop */
|
|
10481
|
+
this.#parts = gc.#parts;
|
|
10482
|
+
for (const p of this.#parts) {
|
|
10483
|
+
if (typeof p === 'object') {
|
|
10484
|
+
p.#parent = this;
|
|
10485
|
+
}
|
|
10486
|
+
}
|
|
10487
|
+
this.type = nt;
|
|
10488
|
+
this.#toString = undefined;
|
|
10489
|
+
this.#emptyExt = false;
|
|
10490
|
+
}
|
|
10281
10491
|
static fromGlob(pattern, options = {}) {
|
|
10282
|
-
const ast = new
|
|
10283
|
-
|
|
10492
|
+
const ast = new _a(null, undefined, options);
|
|
10493
|
+
_a.#parseAST(pattern, ast, 0, options, 0);
|
|
10284
10494
|
return ast;
|
|
10285
10495
|
}
|
|
10286
10496
|
// returns the regular expression if there's magic, or the unescaped
|
|
@@ -10384,16 +10594,18 @@ class AST {
|
|
|
10384
10594
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
10385
10595
|
toRegExpSource(allowDot) {
|
|
10386
10596
|
const dot = allowDot ?? !!this.#options.dot;
|
|
10387
|
-
if (this.#root === this)
|
|
10597
|
+
if (this.#root === this) {
|
|
10598
|
+
this.#flatten();
|
|
10388
10599
|
this.#fillNegs();
|
|
10389
|
-
|
|
10600
|
+
}
|
|
10601
|
+
if (!isExtglobAST(this)) {
|
|
10390
10602
|
const noEmpty = this.isStart() &&
|
|
10391
10603
|
this.isEnd() &&
|
|
10392
10604
|
!this.#parts.some(s => typeof s !== 'string');
|
|
10393
10605
|
const src = this.#parts
|
|
10394
10606
|
.map(p => {
|
|
10395
|
-
const [re, _, hasMagic, uflag] = typeof p === 'string'
|
|
10396
|
-
|
|
10607
|
+
const [re, _, hasMagic, uflag] = typeof p === 'string' ?
|
|
10608
|
+
_a.#parseGlob(p, this.#hasMagic, noEmpty)
|
|
10397
10609
|
: p.toRegExpSource(allowDot);
|
|
10398
10610
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
10399
10611
|
this.#uflag = this.#uflag || uflag;
|
|
@@ -10422,7 +10634,10 @@ class AST {
|
|
|
10422
10634
|
// no need to prevent dots if it can't match a dot, or if a
|
|
10423
10635
|
// sub-pattern will be preventing it anyway.
|
|
10424
10636
|
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
10425
|
-
start =
|
|
10637
|
+
start =
|
|
10638
|
+
needNoTrav ? startNoTraversal
|
|
10639
|
+
: needNoDot ? startNoDot
|
|
10640
|
+
: '';
|
|
10426
10641
|
}
|
|
10427
10642
|
}
|
|
10428
10643
|
}
|
|
@@ -10452,14 +10667,14 @@ class AST {
|
|
|
10452
10667
|
// invalid extglob, has to at least be *something* present, if it's
|
|
10453
10668
|
// the entire path portion.
|
|
10454
10669
|
const s = this.toString();
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10670
|
+
const me = this;
|
|
10671
|
+
me.#parts = [s];
|
|
10672
|
+
me.type = null;
|
|
10673
|
+
me.#hasMagic = undefined;
|
|
10458
10674
|
return [s, unescape_unescape(this.toString()), false, false];
|
|
10459
10675
|
}
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
? ''
|
|
10676
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ?
|
|
10677
|
+
''
|
|
10463
10678
|
: this.#partsToRegExp(true);
|
|
10464
10679
|
if (bodyDotAllowed === body) {
|
|
10465
10680
|
bodyDotAllowed = '';
|
|
@@ -10473,20 +10688,16 @@ class AST {
|
|
|
10473
10688
|
final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
|
|
10474
10689
|
}
|
|
10475
10690
|
else {
|
|
10476
|
-
const close = this.type === '!'
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
: this.type === '@'
|
|
10483
|
-
? ')'
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
: this.type === '+' && bodyDotAllowed
|
|
10487
|
-
? ')'
|
|
10488
|
-
: this.type === '*' && bodyDotAllowed
|
|
10489
|
-
? `)?`
|
|
10691
|
+
const close = this.type === '!' ?
|
|
10692
|
+
// !() must match something,but !(x) can match ''
|
|
10693
|
+
'))' +
|
|
10694
|
+
(this.isStart() && !dot && !allowDot ? startNoDot : '') +
|
|
10695
|
+
star +
|
|
10696
|
+
')'
|
|
10697
|
+
: this.type === '@' ? ')'
|
|
10698
|
+
: this.type === '?' ? ')?'
|
|
10699
|
+
: this.type === '+' && bodyDotAllowed ? ')'
|
|
10700
|
+
: this.type === '*' && bodyDotAllowed ? `)?`
|
|
10490
10701
|
: `)${this.type}`;
|
|
10491
10702
|
final = start + body + close;
|
|
10492
10703
|
}
|
|
@@ -10497,6 +10708,42 @@ class AST {
|
|
|
10497
10708
|
this.#uflag,
|
|
10498
10709
|
];
|
|
10499
10710
|
}
|
|
10711
|
+
#flatten() {
|
|
10712
|
+
if (!isExtglobAST(this)) {
|
|
10713
|
+
for (const p of this.#parts) {
|
|
10714
|
+
if (typeof p === 'object') {
|
|
10715
|
+
p.#flatten();
|
|
10716
|
+
}
|
|
10717
|
+
}
|
|
10718
|
+
}
|
|
10719
|
+
else {
|
|
10720
|
+
// do up to 10 passes to flatten as much as possible
|
|
10721
|
+
let iterations = 0;
|
|
10722
|
+
let done = false;
|
|
10723
|
+
do {
|
|
10724
|
+
done = true;
|
|
10725
|
+
for (let i = 0; i < this.#parts.length; i++) {
|
|
10726
|
+
const c = this.#parts[i];
|
|
10727
|
+
if (typeof c === 'object') {
|
|
10728
|
+
c.#flatten();
|
|
10729
|
+
if (this.#canAdopt(c)) {
|
|
10730
|
+
done = false;
|
|
10731
|
+
this.#adopt(c, i);
|
|
10732
|
+
}
|
|
10733
|
+
else if (this.#canAdoptWithSpace(c)) {
|
|
10734
|
+
done = false;
|
|
10735
|
+
this.#adoptWithSpace(c, i);
|
|
10736
|
+
}
|
|
10737
|
+
else if (this.#canUsurp(c)) {
|
|
10738
|
+
done = false;
|
|
10739
|
+
this.#usurp(c);
|
|
10740
|
+
}
|
|
10741
|
+
}
|
|
10742
|
+
}
|
|
10743
|
+
} while (!done && ++iterations < 10);
|
|
10744
|
+
}
|
|
10745
|
+
this.#toString = undefined;
|
|
10746
|
+
}
|
|
10500
10747
|
#partsToRegExp(dot) {
|
|
10501
10748
|
return this.#parts
|
|
10502
10749
|
.map(p => {
|
|
@@ -10518,6 +10765,8 @@ class AST {
|
|
|
10518
10765
|
let escaping = false;
|
|
10519
10766
|
let re = '';
|
|
10520
10767
|
let uflag = false;
|
|
10768
|
+
// multiple stars that aren't globstars coalesce into one *
|
|
10769
|
+
let inStar = false;
|
|
10521
10770
|
for (let i = 0; i < glob.length; i++) {
|
|
10522
10771
|
const c = glob.charAt(i);
|
|
10523
10772
|
if (escaping) {
|
|
@@ -10525,6 +10774,17 @@ class AST {
|
|
|
10525
10774
|
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
10526
10775
|
continue;
|
|
10527
10776
|
}
|
|
10777
|
+
if (c === '*') {
|
|
10778
|
+
if (inStar)
|
|
10779
|
+
continue;
|
|
10780
|
+
inStar = true;
|
|
10781
|
+
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
10782
|
+
hasMagic = true;
|
|
10783
|
+
continue;
|
|
10784
|
+
}
|
|
10785
|
+
else {
|
|
10786
|
+
inStar = false;
|
|
10787
|
+
}
|
|
10528
10788
|
if (c === '\\') {
|
|
10529
10789
|
if (i === glob.length - 1) {
|
|
10530
10790
|
re += '\\\\';
|
|
@@ -10544,11 +10804,6 @@ class AST {
|
|
|
10544
10804
|
continue;
|
|
10545
10805
|
}
|
|
10546
10806
|
}
|
|
10547
|
-
if (c === '*') {
|
|
10548
|
-
re += noEmpty && glob === '*' ? starNoEmpty : star;
|
|
10549
|
-
hasMagic = true;
|
|
10550
|
-
continue;
|
|
10551
|
-
}
|
|
10552
10807
|
if (c === '?') {
|
|
10553
10808
|
re += qmark;
|
|
10554
10809
|
hasMagic = true;
|
|
@@ -10559,6 +10814,7 @@ class AST {
|
|
|
10559
10814
|
return [re, unescape_unescape(glob), !!hasMagic, uflag];
|
|
10560
10815
|
}
|
|
10561
10816
|
}
|
|
10817
|
+
_a = AST;
|
|
10562
10818
|
//# sourceMappingURL=ast.js.map
|
|
10563
10819
|
;// CONCATENATED MODULE: ../../node_modules/minimatch/dist/esm/escape.js
|
|
10564
10820
|
/**
|
|
@@ -10578,12 +10834,12 @@ const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false,
|
|
|
10578
10834
|
// that make those magic, and escaping ! as [!] isn't valid,
|
|
10579
10835
|
// because [!]] is a valid glob class meaning not ']'.
|
|
10580
10836
|
if (magicalBraces) {
|
|
10581
|
-
return windowsPathsNoEscape
|
|
10582
|
-
|
|
10837
|
+
return windowsPathsNoEscape ?
|
|
10838
|
+
s.replace(/[?*()[\]{}]/g, '[$&]')
|
|
10583
10839
|
: s.replace(/[?*()[\]\\{}]/g, '\\$&');
|
|
10584
10840
|
}
|
|
10585
|
-
return windowsPathsNoEscape
|
|
10586
|
-
|
|
10841
|
+
return windowsPathsNoEscape ?
|
|
10842
|
+
s.replace(/[?*()[\]]/g, '[$&]')
|
|
10587
10843
|
: s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
10588
10844
|
};
|
|
10589
10845
|
//# sourceMappingURL=escape.js.map
|
|
@@ -10602,7 +10858,7 @@ const minimatch = (p, pattern, options = {}) => {
|
|
|
10602
10858
|
return new Minimatch(pattern, options).match(p);
|
|
10603
10859
|
};
|
|
10604
10860
|
// Optimized checking for the most common glob patterns.
|
|
10605
|
-
const starDotExtRE = /^\*+([
|
|
10861
|
+
const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
|
|
10606
10862
|
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext);
|
|
10607
10863
|
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
|
|
10608
10864
|
const starDotExtTestNocase = (ext) => {
|
|
@@ -10621,7 +10877,7 @@ const dotStarTest = (f) => f !== '.' && f !== '..' && f.startsWith('.');
|
|
|
10621
10877
|
const starRE = /^\*+$/;
|
|
10622
10878
|
const starTest = (f) => f.length !== 0 && !f.startsWith('.');
|
|
10623
10879
|
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..';
|
|
10624
|
-
const qmarksRE = /^\?+([
|
|
10880
|
+
const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
|
|
10625
10881
|
const qmarksTestNocase = ([$0, ext = '']) => {
|
|
10626
10882
|
const noext = qmarksTestNoExt([$0]);
|
|
10627
10883
|
if (!ext)
|
|
@@ -10653,8 +10909,8 @@ const qmarksTestNoExtDot = ([$0]) => {
|
|
|
10653
10909
|
return (f) => f.length === len && f !== '.' && f !== '..';
|
|
10654
10910
|
};
|
|
10655
10911
|
/* c8 ignore start */
|
|
10656
|
-
const defaultPlatform = (typeof process === 'object' && process
|
|
10657
|
-
|
|
10912
|
+
const defaultPlatform = (typeof process === 'object' && process ?
|
|
10913
|
+
(typeof process.env === 'object' &&
|
|
10658
10914
|
process.env &&
|
|
10659
10915
|
process.env.__MINIMATCH_TESTING_PLATFORM__) ||
|
|
10660
10916
|
process.platform
|
|
@@ -10738,7 +10994,7 @@ const braceExpand = (pattern, options = {}) => {
|
|
|
10738
10994
|
// shortcut. no need to expand.
|
|
10739
10995
|
return [pattern];
|
|
10740
10996
|
}
|
|
10741
|
-
return expand(pattern);
|
|
10997
|
+
return expand(pattern, { max: options.braceExpandMax });
|
|
10742
10998
|
};
|
|
10743
10999
|
minimatch.braceExpand = braceExpand;
|
|
10744
11000
|
// parse a component of the expanded set.
|
|
@@ -10783,16 +11039,20 @@ class Minimatch {
|
|
|
10783
11039
|
isWindows;
|
|
10784
11040
|
platform;
|
|
10785
11041
|
windowsNoMagicRoot;
|
|
11042
|
+
maxGlobstarRecursion;
|
|
10786
11043
|
regexp;
|
|
10787
11044
|
constructor(pattern, options = {}) {
|
|
10788
11045
|
assertValidPattern(pattern);
|
|
10789
11046
|
options = options || {};
|
|
10790
11047
|
this.options = options;
|
|
11048
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
10791
11049
|
this.pattern = pattern;
|
|
10792
11050
|
this.platform = options.platform || defaultPlatform;
|
|
10793
11051
|
this.isWindows = this.platform === 'win32';
|
|
11052
|
+
// avoid the annoying deprecation flag lol
|
|
11053
|
+
const awe = ('allowWindow' + 'sEscape');
|
|
10794
11054
|
this.windowsPathsNoEscape =
|
|
10795
|
-
!!options.windowsPathsNoEscape || options
|
|
11055
|
+
!!options.windowsPathsNoEscape || options[awe] === false;
|
|
10796
11056
|
if (this.windowsPathsNoEscape) {
|
|
10797
11057
|
this.pattern = this.pattern.replace(/\\/g, '/');
|
|
10798
11058
|
}
|
|
@@ -10805,8 +11065,8 @@ class Minimatch {
|
|
|
10805
11065
|
this.partial = !!options.partial;
|
|
10806
11066
|
this.nocase = !!this.options.nocase;
|
|
10807
11067
|
this.windowsNoMagicRoot =
|
|
10808
|
-
options.windowsNoMagicRoot !== undefined
|
|
10809
|
-
|
|
11068
|
+
options.windowsNoMagicRoot !== undefined ?
|
|
11069
|
+
options.windowsNoMagicRoot
|
|
10810
11070
|
: !!(this.isWindows && this.nocase);
|
|
10811
11071
|
this.globSet = [];
|
|
10812
11072
|
this.globParts = [];
|
|
@@ -10844,6 +11104,7 @@ class Minimatch {
|
|
|
10844
11104
|
// step 2: expand braces
|
|
10845
11105
|
this.globSet = [...new Set(this.braceExpand())];
|
|
10846
11106
|
if (options.debug) {
|
|
11107
|
+
//oxlint-disable-next-line no-console
|
|
10847
11108
|
this.debug = (...args) => console.error(...args);
|
|
10848
11109
|
}
|
|
10849
11110
|
this.debug(this.pattern, this.globSet);
|
|
@@ -10869,7 +11130,10 @@ class Minimatch {
|
|
|
10869
11130
|
!globMagic.test(s[3]);
|
|
10870
11131
|
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
10871
11132
|
if (isUNC) {
|
|
10872
|
-
return [
|
|
11133
|
+
return [
|
|
11134
|
+
...s.slice(0, 4),
|
|
11135
|
+
...s.slice(4).map(ss => this.parse(ss)),
|
|
11136
|
+
];
|
|
10873
11137
|
}
|
|
10874
11138
|
else if (isDrive) {
|
|
10875
11139
|
return [s[0], ...s.slice(1).map(ss => this.parse(ss))];
|
|
@@ -10901,12 +11165,12 @@ class Minimatch {
|
|
|
10901
11165
|
// to the right as possible, even if it increases the number
|
|
10902
11166
|
// of patterns that we have to process.
|
|
10903
11167
|
preprocess(globParts) {
|
|
10904
|
-
// if we're not in globstar mode, then turn
|
|
11168
|
+
// if we're not in globstar mode, then turn ** into *
|
|
10905
11169
|
if (this.options.noglobstar) {
|
|
10906
|
-
for (
|
|
10907
|
-
for (let j = 0; j <
|
|
10908
|
-
if (
|
|
10909
|
-
|
|
11170
|
+
for (const partset of globParts) {
|
|
11171
|
+
for (let j = 0; j < partset.length; j++) {
|
|
11172
|
+
if (partset[j] === '**') {
|
|
11173
|
+
partset[j] = '*';
|
|
10910
11174
|
}
|
|
10911
11175
|
}
|
|
10912
11176
|
}
|
|
@@ -10994,7 +11258,11 @@ class Minimatch {
|
|
|
10994
11258
|
let dd = 0;
|
|
10995
11259
|
while (-1 !== (dd = parts.indexOf('..', dd + 1))) {
|
|
10996
11260
|
const p = parts[dd - 1];
|
|
10997
|
-
if (p &&
|
|
11261
|
+
if (p &&
|
|
11262
|
+
p !== '.' &&
|
|
11263
|
+
p !== '..' &&
|
|
11264
|
+
p !== '**' &&
|
|
11265
|
+
!(this.isWindows && /^[a-z]:$/i.test(p))) {
|
|
10998
11266
|
didSomething = true;
|
|
10999
11267
|
parts.splice(dd - 1, 2);
|
|
11000
11268
|
dd -= 2;
|
|
@@ -11187,7 +11455,8 @@ class Minimatch {
|
|
|
11187
11455
|
// out of pattern, then that's fine, as long as all
|
|
11188
11456
|
// the parts match.
|
|
11189
11457
|
matchOne(file, pattern, partial = false) {
|
|
11190
|
-
|
|
11458
|
+
let fileStartIndex = 0;
|
|
11459
|
+
let patternStartIndex = 0;
|
|
11191
11460
|
// UNC paths like //?/X:/... can match X:/... and vice versa
|
|
11192
11461
|
// Drive letters in absolute drive or unc paths are always compared
|
|
11193
11462
|
// case-insensitively.
|
|
@@ -11205,18 +11474,22 @@ class Minimatch {
|
|
|
11205
11474
|
pattern[2] === '?' &&
|
|
11206
11475
|
typeof pattern[3] === 'string' &&
|
|
11207
11476
|
/^[a-z]:$/i.test(pattern[3]);
|
|
11208
|
-
const fdi = fileUNC ? 3
|
|
11209
|
-
|
|
11477
|
+
const fdi = fileUNC ? 3
|
|
11478
|
+
: fileDrive ? 0
|
|
11479
|
+
: undefined;
|
|
11480
|
+
const pdi = patternUNC ? 3
|
|
11481
|
+
: patternDrive ? 0
|
|
11482
|
+
: undefined;
|
|
11210
11483
|
if (typeof fdi === 'number' && typeof pdi === 'number') {
|
|
11211
|
-
const [fd, pd] = [
|
|
11484
|
+
const [fd, pd] = [
|
|
11485
|
+
file[fdi],
|
|
11486
|
+
pattern[pdi],
|
|
11487
|
+
];
|
|
11488
|
+
// start matching at the drive letter index of each
|
|
11212
11489
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
11213
11490
|
pattern[pdi] = fd;
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
}
|
|
11217
|
-
else if (fdi > pdi) {
|
|
11218
|
-
file = file.slice(fdi);
|
|
11219
|
-
}
|
|
11491
|
+
patternStartIndex = pdi;
|
|
11492
|
+
fileStartIndex = fdi;
|
|
11220
11493
|
}
|
|
11221
11494
|
}
|
|
11222
11495
|
}
|
|
@@ -11226,99 +11499,187 @@ class Minimatch {
|
|
|
11226
11499
|
if (optimizationLevel >= 2) {
|
|
11227
11500
|
file = this.levelTwoFileOptimize(file);
|
|
11228
11501
|
}
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11502
|
+
if (pattern.includes(GLOBSTAR)) {
|
|
11503
|
+
return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
11504
|
+
}
|
|
11505
|
+
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
11506
|
+
}
|
|
11507
|
+
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
11508
|
+
// split the pattern into head, tail, and middle of ** delimited parts
|
|
11509
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
11510
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
11511
|
+
// split the pattern up into globstar-delimited sections
|
|
11512
|
+
// the tail has to be at the end, and the others just have
|
|
11513
|
+
// to be found in order from the head.
|
|
11514
|
+
const [head, body, tail] = partial ?
|
|
11515
|
+
[
|
|
11516
|
+
pattern.slice(patternIndex, firstgs),
|
|
11517
|
+
pattern.slice(firstgs + 1),
|
|
11518
|
+
[],
|
|
11519
|
+
]
|
|
11520
|
+
: [
|
|
11521
|
+
pattern.slice(patternIndex, firstgs),
|
|
11522
|
+
pattern.slice(firstgs + 1, lastgs),
|
|
11523
|
+
pattern.slice(lastgs + 1),
|
|
11524
|
+
];
|
|
11525
|
+
// check the head, from the current file/pattern index.
|
|
11526
|
+
if (head.length) {
|
|
11527
|
+
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
11528
|
+
if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
|
|
11529
|
+
return false;
|
|
11530
|
+
}
|
|
11531
|
+
fileIndex += head.length;
|
|
11532
|
+
patternIndex += head.length;
|
|
11533
|
+
}
|
|
11534
|
+
// now we know the head matches!
|
|
11535
|
+
// if the last portion is not empty, it MUST match the end
|
|
11536
|
+
// check the tail
|
|
11537
|
+
let fileTailMatch = 0;
|
|
11538
|
+
if (tail.length) {
|
|
11539
|
+
// if head + tail > file, then we cannot possibly match
|
|
11540
|
+
if (tail.length + fileIndex > file.length)
|
|
11541
|
+
return false;
|
|
11542
|
+
// try to match the tail
|
|
11543
|
+
let tailStart = file.length - tail.length;
|
|
11544
|
+
if (this.#matchOne(file, tail, partial, tailStart, 0)) {
|
|
11545
|
+
fileTailMatch = tail.length;
|
|
11546
|
+
}
|
|
11547
|
+
else {
|
|
11548
|
+
// affordance for stuff like a/**/* matching a/b/
|
|
11549
|
+
// if the last file portion is '', and there's more to the pattern
|
|
11550
|
+
// then try without the '' bit.
|
|
11551
|
+
if (file[file.length - 1] !== '' ||
|
|
11552
|
+
fileIndex + tail.length === file.length) {
|
|
11553
|
+
return false;
|
|
11554
|
+
}
|
|
11555
|
+
tailStart--;
|
|
11556
|
+
if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
|
|
11557
|
+
return false;
|
|
11558
|
+
}
|
|
11559
|
+
fileTailMatch = tail.length + 1;
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
// now we know the tail matches!
|
|
11563
|
+
// the middle is zero or more portions wrapped in **, possibly
|
|
11564
|
+
// containing more ** sections.
|
|
11565
|
+
// so a/**/b/**/c/**/d has become **/b/**/c/**
|
|
11566
|
+
// if it's empty, it means a/**/b, just verify we have no bad dots
|
|
11567
|
+
// if there's no tail, so it ends on /**, then we must have *something*
|
|
11568
|
+
// after the head, or it's not a matc
|
|
11569
|
+
if (!body.length) {
|
|
11570
|
+
let sawSome = !!fileTailMatch;
|
|
11571
|
+
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
|
|
11572
|
+
const f = String(file[i]);
|
|
11573
|
+
sawSome = true;
|
|
11574
|
+
if (f === '.' ||
|
|
11575
|
+
f === '..' ||
|
|
11576
|
+
(!this.options.dot && f.startsWith('.'))) {
|
|
11577
|
+
return false;
|
|
11578
|
+
}
|
|
11579
|
+
}
|
|
11580
|
+
// in partial mode, we just need to get past all file parts
|
|
11581
|
+
return partial || sawSome;
|
|
11582
|
+
}
|
|
11583
|
+
// now we know that there's one or more body sections, which can
|
|
11584
|
+
// be matched anywhere from the 0 index (because the head was pruned)
|
|
11585
|
+
// through to the length-fileTailMatch index.
|
|
11586
|
+
// split the body up into sections, and note the minimum index it can
|
|
11587
|
+
// be found at (start with the length of all previous segments)
|
|
11588
|
+
// [section, before, after]
|
|
11589
|
+
const bodySegments = [[[], 0]];
|
|
11590
|
+
let currentBody = bodySegments[0];
|
|
11591
|
+
let nonGsParts = 0;
|
|
11592
|
+
const nonGsPartsSums = [0];
|
|
11593
|
+
for (const b of body) {
|
|
11594
|
+
if (b === GLOBSTAR) {
|
|
11595
|
+
nonGsPartsSums.push(nonGsParts);
|
|
11596
|
+
currentBody = [[], 0];
|
|
11597
|
+
bodySegments.push(currentBody);
|
|
11598
|
+
}
|
|
11599
|
+
else {
|
|
11600
|
+
currentBody[0].push(b);
|
|
11601
|
+
nonGsParts++;
|
|
11602
|
+
}
|
|
11603
|
+
}
|
|
11604
|
+
let i = bodySegments.length - 1;
|
|
11605
|
+
const fileLength = file.length - fileTailMatch;
|
|
11606
|
+
for (const b of bodySegments) {
|
|
11607
|
+
b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
11608
|
+
}
|
|
11609
|
+
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
11610
|
+
}
|
|
11611
|
+
// return false for "nope, not matching"
|
|
11612
|
+
// return null for "not matching, cannot keep trying"
|
|
11613
|
+
#matchGlobStarBodySections(file,
|
|
11614
|
+
// pattern section, last possible position for it
|
|
11615
|
+
bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
11616
|
+
// take the first body segment, and walk from fileIndex to its "after"
|
|
11617
|
+
// value at the end
|
|
11618
|
+
// If it doesn't match at that position, we increment, until we hit
|
|
11619
|
+
// that final possible position, and give up.
|
|
11620
|
+
// If it does match, then advance and try to rest.
|
|
11621
|
+
// If any of them fail we keep walking forward.
|
|
11622
|
+
// this is still a bit recursively painful, but it's more constrained
|
|
11623
|
+
// than previous implementations, because we never test something that
|
|
11624
|
+
// can't possibly be a valid matching condition.
|
|
11625
|
+
const bs = bodySegments[bodyIndex];
|
|
11626
|
+
if (!bs) {
|
|
11627
|
+
// just make sure that there's no bad dots
|
|
11628
|
+
for (let i = fileIndex; i < file.length; i++) {
|
|
11629
|
+
sawTail = true;
|
|
11630
|
+
const f = file[i];
|
|
11631
|
+
if (f === '.' ||
|
|
11632
|
+
f === '..' ||
|
|
11633
|
+
(!this.options.dot && f.startsWith('.'))) {
|
|
11634
|
+
return false;
|
|
11635
|
+
}
|
|
11636
|
+
}
|
|
11637
|
+
return sawTail;
|
|
11638
|
+
}
|
|
11639
|
+
// have a non-globstar body section to test
|
|
11640
|
+
const [body, after] = bs;
|
|
11641
|
+
while (fileIndex <= after) {
|
|
11642
|
+
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
11643
|
+
// if limit exceeded, no match. intentional false negative,
|
|
11644
|
+
// acceptable break in correctness for security.
|
|
11645
|
+
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
11646
|
+
// match! see if the rest match. if so, we're done!
|
|
11647
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
11648
|
+
if (sub !== false) {
|
|
11649
|
+
return sub;
|
|
11650
|
+
}
|
|
11651
|
+
}
|
|
11652
|
+
const f = file[fileIndex];
|
|
11653
|
+
if (f === '.' ||
|
|
11654
|
+
f === '..' ||
|
|
11655
|
+
(!this.options.dot && f.startsWith('.'))) {
|
|
11656
|
+
return false;
|
|
11657
|
+
}
|
|
11658
|
+
fileIndex++;
|
|
11659
|
+
}
|
|
11660
|
+
// walked off. no point continuing
|
|
11661
|
+
return partial || null;
|
|
11662
|
+
}
|
|
11663
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
11664
|
+
let fi;
|
|
11665
|
+
let pi;
|
|
11666
|
+
let pl;
|
|
11667
|
+
let fl;
|
|
11668
|
+
for (fi = fileIndex,
|
|
11669
|
+
pi = patternIndex,
|
|
11670
|
+
fl = file.length,
|
|
11671
|
+
pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
11232
11672
|
this.debug('matchOne loop');
|
|
11233
|
-
|
|
11234
|
-
|
|
11673
|
+
let p = pattern[pi];
|
|
11674
|
+
let f = file[fi];
|
|
11235
11675
|
this.debug(pattern, p, f);
|
|
11236
11676
|
// should be impossible.
|
|
11237
11677
|
// some invalid regexp stuff in the set.
|
|
11238
11678
|
/* c8 ignore start */
|
|
11239
|
-
if (p === false) {
|
|
11679
|
+
if (p === false || p === GLOBSTAR) {
|
|
11240
11680
|
return false;
|
|
11241
11681
|
}
|
|
11242
11682
|
/* c8 ignore stop */
|
|
11243
|
-
if (p === GLOBSTAR) {
|
|
11244
|
-
this.debug('GLOBSTAR', [pattern, p, f]);
|
|
11245
|
-
// "**"
|
|
11246
|
-
// a/**/b/**/c would match the following:
|
|
11247
|
-
// a/b/x/y/z/c
|
|
11248
|
-
// a/x/y/z/b/c
|
|
11249
|
-
// a/b/x/b/x/c
|
|
11250
|
-
// a/b/c
|
|
11251
|
-
// To do this, take the rest of the pattern after
|
|
11252
|
-
// the **, and see if it would match the file remainder.
|
|
11253
|
-
// If so, return success.
|
|
11254
|
-
// If not, the ** "swallows" a segment, and try again.
|
|
11255
|
-
// This is recursively awful.
|
|
11256
|
-
//
|
|
11257
|
-
// a/**/b/**/c matching a/b/x/y/z/c
|
|
11258
|
-
// - a matches a
|
|
11259
|
-
// - doublestar
|
|
11260
|
-
// - matchOne(b/x/y/z/c, b/**/c)
|
|
11261
|
-
// - b matches b
|
|
11262
|
-
// - doublestar
|
|
11263
|
-
// - matchOne(x/y/z/c, c) -> no
|
|
11264
|
-
// - matchOne(y/z/c, c) -> no
|
|
11265
|
-
// - matchOne(z/c, c) -> no
|
|
11266
|
-
// - matchOne(c, c) yes, hit
|
|
11267
|
-
var fr = fi;
|
|
11268
|
-
var pr = pi + 1;
|
|
11269
|
-
if (pr === pl) {
|
|
11270
|
-
this.debug('** at the end');
|
|
11271
|
-
// a ** at the end will just swallow the rest.
|
|
11272
|
-
// We have found a match.
|
|
11273
|
-
// however, it will not swallow /.x, unless
|
|
11274
|
-
// options.dot is set.
|
|
11275
|
-
// . and .. are *never* matched by **, for explosively
|
|
11276
|
-
// exponential reasons.
|
|
11277
|
-
for (; fi < fl; fi++) {
|
|
11278
|
-
if (file[fi] === '.' ||
|
|
11279
|
-
file[fi] === '..' ||
|
|
11280
|
-
(!options.dot && file[fi].charAt(0) === '.'))
|
|
11281
|
-
return false;
|
|
11282
|
-
}
|
|
11283
|
-
return true;
|
|
11284
|
-
}
|
|
11285
|
-
// ok, let's see if we can swallow whatever we can.
|
|
11286
|
-
while (fr < fl) {
|
|
11287
|
-
var swallowee = file[fr];
|
|
11288
|
-
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
|
11289
|
-
// XXX remove this slice. Just pass the start index.
|
|
11290
|
-
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
11291
|
-
this.debug('globstar found match!', fr, fl, swallowee);
|
|
11292
|
-
// found a match.
|
|
11293
|
-
return true;
|
|
11294
|
-
}
|
|
11295
|
-
else {
|
|
11296
|
-
// can't swallow "." or ".." ever.
|
|
11297
|
-
// can only swallow ".foo" when explicitly asked.
|
|
11298
|
-
if (swallowee === '.' ||
|
|
11299
|
-
swallowee === '..' ||
|
|
11300
|
-
(!options.dot && swallowee.charAt(0) === '.')) {
|
|
11301
|
-
this.debug('dot detected!', file, fr, pattern, pr);
|
|
11302
|
-
break;
|
|
11303
|
-
}
|
|
11304
|
-
// ** swallows a segment, and continue.
|
|
11305
|
-
this.debug('globstar swallow a segment, and continue');
|
|
11306
|
-
fr++;
|
|
11307
|
-
}
|
|
11308
|
-
}
|
|
11309
|
-
// no match was found.
|
|
11310
|
-
// However, in partial mode, we can't say this is necessarily over.
|
|
11311
|
-
/* c8 ignore start */
|
|
11312
|
-
if (partial) {
|
|
11313
|
-
// ran out of file
|
|
11314
|
-
this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
|
11315
|
-
if (fr === fl) {
|
|
11316
|
-
return true;
|
|
11317
|
-
}
|
|
11318
|
-
}
|
|
11319
|
-
/* c8 ignore stop */
|
|
11320
|
-
return false;
|
|
11321
|
-
}
|
|
11322
11683
|
// something other than **
|
|
11323
11684
|
// non-magic patterns just have to match exactly
|
|
11324
11685
|
// patterns with magic have been turned into regexps.
|
|
@@ -11389,21 +11750,19 @@ class Minimatch {
|
|
|
11389
11750
|
fastTest = options.dot ? starTestDot : starTest;
|
|
11390
11751
|
}
|
|
11391
11752
|
else if ((m = pattern.match(starDotExtRE))) {
|
|
11392
|
-
fastTest = (options.nocase
|
|
11393
|
-
|
|
11394
|
-
|
|
11753
|
+
fastTest = (options.nocase ?
|
|
11754
|
+
options.dot ?
|
|
11755
|
+
starDotExtTestNocaseDot
|
|
11395
11756
|
: starDotExtTestNocase
|
|
11396
|
-
: options.dot
|
|
11397
|
-
? starDotExtTestDot
|
|
11757
|
+
: options.dot ? starDotExtTestDot
|
|
11398
11758
|
: starDotExtTest)(m[1]);
|
|
11399
11759
|
}
|
|
11400
11760
|
else if ((m = pattern.match(qmarksRE))) {
|
|
11401
|
-
fastTest = (options.nocase
|
|
11402
|
-
|
|
11403
|
-
|
|
11761
|
+
fastTest = (options.nocase ?
|
|
11762
|
+
options.dot ?
|
|
11763
|
+
qmarksTestNocaseDot
|
|
11404
11764
|
: qmarksTestNocase
|
|
11405
|
-
: options.dot
|
|
11406
|
-
? qmarksTestDot
|
|
11765
|
+
: options.dot ? qmarksTestDot
|
|
11407
11766
|
: qmarksTest)(m);
|
|
11408
11767
|
}
|
|
11409
11768
|
else if ((m = pattern.match(starDotStarRE))) {
|
|
@@ -11434,10 +11793,8 @@ class Minimatch {
|
|
|
11434
11793
|
return this.regexp;
|
|
11435
11794
|
}
|
|
11436
11795
|
const options = this.options;
|
|
11437
|
-
const twoStar = options.noglobstar
|
|
11438
|
-
?
|
|
11439
|
-
: options.dot
|
|
11440
|
-
? twoStarDot
|
|
11796
|
+
const twoStar = options.noglobstar ? esm_star
|
|
11797
|
+
: options.dot ? twoStarDot
|
|
11441
11798
|
: twoStarNoDot;
|
|
11442
11799
|
const flags = new Set(options.nocase ? ['i'] : []);
|
|
11443
11800
|
// regexpify non-globstar patterns
|
|
@@ -11453,11 +11810,9 @@ class Minimatch {
|
|
|
11453
11810
|
for (const f of p.flags.split(''))
|
|
11454
11811
|
flags.add(f);
|
|
11455
11812
|
}
|
|
11456
|
-
return typeof p === 'string'
|
|
11457
|
-
?
|
|
11458
|
-
|
|
11459
|
-
? GLOBSTAR
|
|
11460
|
-
: p._src;
|
|
11813
|
+
return (typeof p === 'string' ? esm_regExpEscape(p)
|
|
11814
|
+
: p === GLOBSTAR ? GLOBSTAR
|
|
11815
|
+
: p._src);
|
|
11461
11816
|
});
|
|
11462
11817
|
pp.forEach((p, i) => {
|
|
11463
11818
|
const next = pp[i + 1];
|
|
@@ -11512,7 +11867,7 @@ class Minimatch {
|
|
|
11512
11867
|
this.regexp = new RegExp(re, [...flags].join(''));
|
|
11513
11868
|
/* c8 ignore start */
|
|
11514
11869
|
}
|
|
11515
|
-
catch
|
|
11870
|
+
catch {
|
|
11516
11871
|
// should be impossible
|
|
11517
11872
|
this.regexp = false;
|
|
11518
11873
|
}
|
|
@@ -11527,7 +11882,7 @@ class Minimatch {
|
|
|
11527
11882
|
if (this.preserveMultipleSlashes) {
|
|
11528
11883
|
return p.split('/');
|
|
11529
11884
|
}
|
|
11530
|
-
else if (this.isWindows && /^\/\/[
|
|
11885
|
+
else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
|
|
11531
11886
|
// add an extra '' for the one we lose
|
|
11532
11887
|
return ['', ...p.split(/\/+/)];
|
|
11533
11888
|
}
|
|
@@ -11569,8 +11924,7 @@ class Minimatch {
|
|
|
11569
11924
|
filename = ff[i];
|
|
11570
11925
|
}
|
|
11571
11926
|
}
|
|
11572
|
-
for (
|
|
11573
|
-
const pattern = set[i];
|
|
11927
|
+
for (const pattern of set) {
|
|
11574
11928
|
let file = ff;
|
|
11575
11929
|
if (options.matchBase && pattern.length === 1) {
|
|
11576
11930
|
file = [filename];
|
|
@@ -11606,1588 +11960,12 @@ minimatch.unescape = unescape_unescape;
|
|
|
11606
11960
|
//# sourceMappingURL=index.js.map
|
|
11607
11961
|
// EXTERNAL MODULE: external "node:url"
|
|
11608
11962
|
var external_node_url_ = __webpack_require__(3136);
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
*/
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
typeof performance.now === 'function') ?
|
|
11616
|
-
performance
|
|
11617
|
-
: Date;
|
|
11618
|
-
const warned = new Set();
|
|
11619
|
-
/* c8 ignore start */
|
|
11620
|
-
const PROCESS = (typeof process === 'object' && !!process ?
|
|
11621
|
-
process
|
|
11622
|
-
: {});
|
|
11623
|
-
/* c8 ignore start */
|
|
11624
|
-
const emitWarning = (msg, type, code, fn) => {
|
|
11625
|
-
typeof PROCESS.emitWarning === 'function' ?
|
|
11626
|
-
PROCESS.emitWarning(msg, type, code, fn)
|
|
11627
|
-
: console.error(`[${code}] ${type}: ${msg}`);
|
|
11628
|
-
};
|
|
11629
|
-
let AC = globalThis.AbortController;
|
|
11630
|
-
let AS = globalThis.AbortSignal;
|
|
11631
|
-
/* c8 ignore start */
|
|
11632
|
-
if (typeof AC === 'undefined') {
|
|
11633
|
-
//@ts-ignore
|
|
11634
|
-
AS = class AbortSignal {
|
|
11635
|
-
onabort;
|
|
11636
|
-
_onabort = [];
|
|
11637
|
-
reason;
|
|
11638
|
-
aborted = false;
|
|
11639
|
-
addEventListener(_, fn) {
|
|
11640
|
-
this._onabort.push(fn);
|
|
11641
|
-
}
|
|
11642
|
-
};
|
|
11643
|
-
//@ts-ignore
|
|
11644
|
-
AC = class AbortController {
|
|
11645
|
-
constructor() {
|
|
11646
|
-
warnACPolyfill();
|
|
11647
|
-
}
|
|
11648
|
-
signal = new AS();
|
|
11649
|
-
abort(reason) {
|
|
11650
|
-
if (this.signal.aborted)
|
|
11651
|
-
return;
|
|
11652
|
-
//@ts-ignore
|
|
11653
|
-
this.signal.reason = reason;
|
|
11654
|
-
//@ts-ignore
|
|
11655
|
-
this.signal.aborted = true;
|
|
11656
|
-
//@ts-ignore
|
|
11657
|
-
for (const fn of this.signal._onabort) {
|
|
11658
|
-
fn(reason);
|
|
11659
|
-
}
|
|
11660
|
-
this.signal.onabort?.(reason);
|
|
11661
|
-
}
|
|
11662
|
-
};
|
|
11663
|
-
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
11664
|
-
const warnACPolyfill = () => {
|
|
11665
|
-
if (!printACPolyfillWarning)
|
|
11666
|
-
return;
|
|
11667
|
-
printACPolyfillWarning = false;
|
|
11668
|
-
emitWarning('AbortController is not defined. If using lru-cache in ' +
|
|
11669
|
-
'node 14, load an AbortController polyfill from the ' +
|
|
11670
|
-
'`node-abort-controller` package. A minimal polyfill is ' +
|
|
11671
|
-
'provided for use by LRUCache.fetch(), but it should not be ' +
|
|
11672
|
-
'relied upon in other contexts (eg, passing it to other APIs that ' +
|
|
11673
|
-
'use AbortController/AbortSignal might have undesirable effects). ' +
|
|
11674
|
-
'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.', 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
|
|
11675
|
-
};
|
|
11676
|
-
}
|
|
11677
|
-
/* c8 ignore stop */
|
|
11678
|
-
const shouldWarn = (code) => !warned.has(code);
|
|
11679
|
-
const TYPE = Symbol('type');
|
|
11680
|
-
const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
11681
|
-
/* c8 ignore start */
|
|
11682
|
-
// This is a little bit ridiculous, tbh.
|
|
11683
|
-
// The maximum array length is 2^32-1 or thereabouts on most JS impls.
|
|
11684
|
-
// And well before that point, you're caching the entire world, I mean,
|
|
11685
|
-
// that's ~32GB of just integers for the next/prev links, plus whatever
|
|
11686
|
-
// else to hold that many keys and values. Just filling the memory with
|
|
11687
|
-
// zeroes at init time is brutal when you get that big.
|
|
11688
|
-
// But why not be complete?
|
|
11689
|
-
// Maybe in the future, these limits will have expanded.
|
|
11690
|
-
const getUintArray = (max) => !isPosInt(max) ? null
|
|
11691
|
-
: max <= Math.pow(2, 8) ? Uint8Array
|
|
11692
|
-
: max <= Math.pow(2, 16) ? Uint16Array
|
|
11693
|
-
: max <= Math.pow(2, 32) ? Uint32Array
|
|
11694
|
-
: max <= Number.MAX_SAFE_INTEGER ? ZeroArray
|
|
11695
|
-
: null;
|
|
11696
|
-
/* c8 ignore stop */
|
|
11697
|
-
class ZeroArray extends Array {
|
|
11698
|
-
constructor(size) {
|
|
11699
|
-
super(size);
|
|
11700
|
-
this.fill(0);
|
|
11701
|
-
}
|
|
11702
|
-
}
|
|
11703
|
-
class Stack {
|
|
11704
|
-
heap;
|
|
11705
|
-
length;
|
|
11706
|
-
// private constructor
|
|
11707
|
-
static #constructing = false;
|
|
11708
|
-
static create(max) {
|
|
11709
|
-
const HeapCls = getUintArray(max);
|
|
11710
|
-
if (!HeapCls)
|
|
11711
|
-
return [];
|
|
11712
|
-
Stack.#constructing = true;
|
|
11713
|
-
const s = new Stack(max, HeapCls);
|
|
11714
|
-
Stack.#constructing = false;
|
|
11715
|
-
return s;
|
|
11716
|
-
}
|
|
11717
|
-
constructor(max, HeapCls) {
|
|
11718
|
-
/* c8 ignore start */
|
|
11719
|
-
if (!Stack.#constructing) {
|
|
11720
|
-
throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
11721
|
-
}
|
|
11722
|
-
/* c8 ignore stop */
|
|
11723
|
-
this.heap = new HeapCls(max);
|
|
11724
|
-
this.length = 0;
|
|
11725
|
-
}
|
|
11726
|
-
push(n) {
|
|
11727
|
-
this.heap[this.length++] = n;
|
|
11728
|
-
}
|
|
11729
|
-
pop() {
|
|
11730
|
-
return this.heap[--this.length];
|
|
11731
|
-
}
|
|
11732
|
-
}
|
|
11733
|
-
/**
|
|
11734
|
-
* Default export, the thing you're using this module to get.
|
|
11735
|
-
*
|
|
11736
|
-
* The `K` and `V` types define the key and value types, respectively. The
|
|
11737
|
-
* optional `FC` type defines the type of the `context` object passed to
|
|
11738
|
-
* `cache.fetch()` and `cache.memo()`.
|
|
11739
|
-
*
|
|
11740
|
-
* Keys and values **must not** be `null` or `undefined`.
|
|
11741
|
-
*
|
|
11742
|
-
* All properties from the options object (with the exception of `max`,
|
|
11743
|
-
* `maxSize`, `fetchMethod`, `memoMethod`, `dispose` and `disposeAfter`) are
|
|
11744
|
-
* added as normal public members. (The listed options are read-only getters.)
|
|
11745
|
-
*
|
|
11746
|
-
* Changing any of these will alter the defaults for subsequent method calls.
|
|
11747
|
-
*/
|
|
11748
|
-
class LRUCache {
|
|
11749
|
-
// options that cannot be changed without disaster
|
|
11750
|
-
#max;
|
|
11751
|
-
#maxSize;
|
|
11752
|
-
#dispose;
|
|
11753
|
-
#onInsert;
|
|
11754
|
-
#disposeAfter;
|
|
11755
|
-
#fetchMethod;
|
|
11756
|
-
#memoMethod;
|
|
11757
|
-
#perf;
|
|
11758
|
-
/**
|
|
11759
|
-
* {@link LRUCache.OptionsBase.perf}
|
|
11760
|
-
*/
|
|
11761
|
-
get perf() {
|
|
11762
|
-
return this.#perf;
|
|
11763
|
-
}
|
|
11764
|
-
/**
|
|
11765
|
-
* {@link LRUCache.OptionsBase.ttl}
|
|
11766
|
-
*/
|
|
11767
|
-
ttl;
|
|
11768
|
-
/**
|
|
11769
|
-
* {@link LRUCache.OptionsBase.ttlResolution}
|
|
11770
|
-
*/
|
|
11771
|
-
ttlResolution;
|
|
11772
|
-
/**
|
|
11773
|
-
* {@link LRUCache.OptionsBase.ttlAutopurge}
|
|
11774
|
-
*/
|
|
11775
|
-
ttlAutopurge;
|
|
11776
|
-
/**
|
|
11777
|
-
* {@link LRUCache.OptionsBase.updateAgeOnGet}
|
|
11778
|
-
*/
|
|
11779
|
-
updateAgeOnGet;
|
|
11780
|
-
/**
|
|
11781
|
-
* {@link LRUCache.OptionsBase.updateAgeOnHas}
|
|
11782
|
-
*/
|
|
11783
|
-
updateAgeOnHas;
|
|
11784
|
-
/**
|
|
11785
|
-
* {@link LRUCache.OptionsBase.allowStale}
|
|
11786
|
-
*/
|
|
11787
|
-
allowStale;
|
|
11788
|
-
/**
|
|
11789
|
-
* {@link LRUCache.OptionsBase.noDisposeOnSet}
|
|
11790
|
-
*/
|
|
11791
|
-
noDisposeOnSet;
|
|
11792
|
-
/**
|
|
11793
|
-
* {@link LRUCache.OptionsBase.noUpdateTTL}
|
|
11794
|
-
*/
|
|
11795
|
-
noUpdateTTL;
|
|
11796
|
-
/**
|
|
11797
|
-
* {@link LRUCache.OptionsBase.maxEntrySize}
|
|
11798
|
-
*/
|
|
11799
|
-
maxEntrySize;
|
|
11800
|
-
/**
|
|
11801
|
-
* {@link LRUCache.OptionsBase.sizeCalculation}
|
|
11802
|
-
*/
|
|
11803
|
-
sizeCalculation;
|
|
11804
|
-
/**
|
|
11805
|
-
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
|
|
11806
|
-
*/
|
|
11807
|
-
noDeleteOnFetchRejection;
|
|
11808
|
-
/**
|
|
11809
|
-
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
|
|
11810
|
-
*/
|
|
11811
|
-
noDeleteOnStaleGet;
|
|
11812
|
-
/**
|
|
11813
|
-
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
|
|
11814
|
-
*/
|
|
11815
|
-
allowStaleOnFetchAbort;
|
|
11816
|
-
/**
|
|
11817
|
-
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
|
|
11818
|
-
*/
|
|
11819
|
-
allowStaleOnFetchRejection;
|
|
11820
|
-
/**
|
|
11821
|
-
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
|
11822
|
-
*/
|
|
11823
|
-
ignoreFetchAbort;
|
|
11824
|
-
// computed properties
|
|
11825
|
-
#size;
|
|
11826
|
-
#calculatedSize;
|
|
11827
|
-
#keyMap;
|
|
11828
|
-
#keyList;
|
|
11829
|
-
#valList;
|
|
11830
|
-
#next;
|
|
11831
|
-
#prev;
|
|
11832
|
-
#head;
|
|
11833
|
-
#tail;
|
|
11834
|
-
#free;
|
|
11835
|
-
#disposed;
|
|
11836
|
-
#sizes;
|
|
11837
|
-
#starts;
|
|
11838
|
-
#ttls;
|
|
11839
|
-
#autopurgeTimers;
|
|
11840
|
-
#hasDispose;
|
|
11841
|
-
#hasFetchMethod;
|
|
11842
|
-
#hasDisposeAfter;
|
|
11843
|
-
#hasOnInsert;
|
|
11844
|
-
/**
|
|
11845
|
-
* Do not call this method unless you need to inspect the
|
|
11846
|
-
* inner workings of the cache. If anything returned by this
|
|
11847
|
-
* object is modified in any way, strange breakage may occur.
|
|
11848
|
-
*
|
|
11849
|
-
* These fields are private for a reason!
|
|
11850
|
-
*
|
|
11851
|
-
* @internal
|
|
11852
|
-
*/
|
|
11853
|
-
static unsafeExposeInternals(c) {
|
|
11854
|
-
return {
|
|
11855
|
-
// properties
|
|
11856
|
-
starts: c.#starts,
|
|
11857
|
-
ttls: c.#ttls,
|
|
11858
|
-
autopurgeTimers: c.#autopurgeTimers,
|
|
11859
|
-
sizes: c.#sizes,
|
|
11860
|
-
keyMap: c.#keyMap,
|
|
11861
|
-
keyList: c.#keyList,
|
|
11862
|
-
valList: c.#valList,
|
|
11863
|
-
next: c.#next,
|
|
11864
|
-
prev: c.#prev,
|
|
11865
|
-
get head() {
|
|
11866
|
-
return c.#head;
|
|
11867
|
-
},
|
|
11868
|
-
get tail() {
|
|
11869
|
-
return c.#tail;
|
|
11870
|
-
},
|
|
11871
|
-
free: c.#free,
|
|
11872
|
-
// methods
|
|
11873
|
-
isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
|
|
11874
|
-
backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
|
|
11875
|
-
moveToTail: (index) => c.#moveToTail(index),
|
|
11876
|
-
indexes: (options) => c.#indexes(options),
|
|
11877
|
-
rindexes: (options) => c.#rindexes(options),
|
|
11878
|
-
isStale: (index) => c.#isStale(index),
|
|
11879
|
-
};
|
|
11880
|
-
}
|
|
11881
|
-
// Protected read-only members
|
|
11882
|
-
/**
|
|
11883
|
-
* {@link LRUCache.OptionsBase.max} (read-only)
|
|
11884
|
-
*/
|
|
11885
|
-
get max() {
|
|
11886
|
-
return this.#max;
|
|
11887
|
-
}
|
|
11888
|
-
/**
|
|
11889
|
-
* {@link LRUCache.OptionsBase.maxSize} (read-only)
|
|
11890
|
-
*/
|
|
11891
|
-
get maxSize() {
|
|
11892
|
-
return this.#maxSize;
|
|
11893
|
-
}
|
|
11894
|
-
/**
|
|
11895
|
-
* The total computed size of items in the cache (read-only)
|
|
11896
|
-
*/
|
|
11897
|
-
get calculatedSize() {
|
|
11898
|
-
return this.#calculatedSize;
|
|
11899
|
-
}
|
|
11900
|
-
/**
|
|
11901
|
-
* The number of items stored in the cache (read-only)
|
|
11902
|
-
*/
|
|
11903
|
-
get size() {
|
|
11904
|
-
return this.#size;
|
|
11905
|
-
}
|
|
11906
|
-
/**
|
|
11907
|
-
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
|
|
11908
|
-
*/
|
|
11909
|
-
get fetchMethod() {
|
|
11910
|
-
return this.#fetchMethod;
|
|
11911
|
-
}
|
|
11912
|
-
get memoMethod() {
|
|
11913
|
-
return this.#memoMethod;
|
|
11914
|
-
}
|
|
11915
|
-
/**
|
|
11916
|
-
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
11917
|
-
*/
|
|
11918
|
-
get dispose() {
|
|
11919
|
-
return this.#dispose;
|
|
11920
|
-
}
|
|
11921
|
-
/**
|
|
11922
|
-
* {@link LRUCache.OptionsBase.onInsert} (read-only)
|
|
11923
|
-
*/
|
|
11924
|
-
get onInsert() {
|
|
11925
|
-
return this.#onInsert;
|
|
11926
|
-
}
|
|
11927
|
-
/**
|
|
11928
|
-
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
11929
|
-
*/
|
|
11930
|
-
get disposeAfter() {
|
|
11931
|
-
return this.#disposeAfter;
|
|
11932
|
-
}
|
|
11933
|
-
constructor(options) {
|
|
11934
|
-
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf, } = options;
|
|
11935
|
-
if (perf !== undefined) {
|
|
11936
|
-
if (typeof perf?.now !== 'function') {
|
|
11937
|
-
throw new TypeError('perf option must have a now() method if specified');
|
|
11938
|
-
}
|
|
11939
|
-
}
|
|
11940
|
-
this.#perf = perf ?? defaultPerf;
|
|
11941
|
-
if (max !== 0 && !isPosInt(max)) {
|
|
11942
|
-
throw new TypeError('max option must be a nonnegative integer');
|
|
11943
|
-
}
|
|
11944
|
-
const UintArray = max ? getUintArray(max) : Array;
|
|
11945
|
-
if (!UintArray) {
|
|
11946
|
-
throw new Error('invalid max value: ' + max);
|
|
11947
|
-
}
|
|
11948
|
-
this.#max = max;
|
|
11949
|
-
this.#maxSize = maxSize;
|
|
11950
|
-
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
|
11951
|
-
this.sizeCalculation = sizeCalculation;
|
|
11952
|
-
if (this.sizeCalculation) {
|
|
11953
|
-
if (!this.#maxSize && !this.maxEntrySize) {
|
|
11954
|
-
throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
|
|
11955
|
-
}
|
|
11956
|
-
if (typeof this.sizeCalculation !== 'function') {
|
|
11957
|
-
throw new TypeError('sizeCalculation set to non-function');
|
|
11958
|
-
}
|
|
11959
|
-
}
|
|
11960
|
-
if (memoMethod !== undefined && typeof memoMethod !== 'function') {
|
|
11961
|
-
throw new TypeError('memoMethod must be a function if defined');
|
|
11962
|
-
}
|
|
11963
|
-
this.#memoMethod = memoMethod;
|
|
11964
|
-
if (fetchMethod !== undefined && typeof fetchMethod !== 'function') {
|
|
11965
|
-
throw new TypeError('fetchMethod must be a function if specified');
|
|
11966
|
-
}
|
|
11967
|
-
this.#fetchMethod = fetchMethod;
|
|
11968
|
-
this.#hasFetchMethod = !!fetchMethod;
|
|
11969
|
-
this.#keyMap = new Map();
|
|
11970
|
-
this.#keyList = new Array(max).fill(undefined);
|
|
11971
|
-
this.#valList = new Array(max).fill(undefined);
|
|
11972
|
-
this.#next = new UintArray(max);
|
|
11973
|
-
this.#prev = new UintArray(max);
|
|
11974
|
-
this.#head = 0;
|
|
11975
|
-
this.#tail = 0;
|
|
11976
|
-
this.#free = Stack.create(max);
|
|
11977
|
-
this.#size = 0;
|
|
11978
|
-
this.#calculatedSize = 0;
|
|
11979
|
-
if (typeof dispose === 'function') {
|
|
11980
|
-
this.#dispose = dispose;
|
|
11981
|
-
}
|
|
11982
|
-
if (typeof onInsert === 'function') {
|
|
11983
|
-
this.#onInsert = onInsert;
|
|
11984
|
-
}
|
|
11985
|
-
if (typeof disposeAfter === 'function') {
|
|
11986
|
-
this.#disposeAfter = disposeAfter;
|
|
11987
|
-
this.#disposed = [];
|
|
11988
|
-
}
|
|
11989
|
-
else {
|
|
11990
|
-
this.#disposeAfter = undefined;
|
|
11991
|
-
this.#disposed = undefined;
|
|
11992
|
-
}
|
|
11993
|
-
this.#hasDispose = !!this.#dispose;
|
|
11994
|
-
this.#hasOnInsert = !!this.#onInsert;
|
|
11995
|
-
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
11996
|
-
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
11997
|
-
this.noUpdateTTL = !!noUpdateTTL;
|
|
11998
|
-
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
|
11999
|
-
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
|
|
12000
|
-
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
|
12001
|
-
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
|
12002
|
-
// NB: maxEntrySize is set to maxSize if it's set
|
|
12003
|
-
if (this.maxEntrySize !== 0) {
|
|
12004
|
-
if (this.#maxSize !== 0) {
|
|
12005
|
-
if (!isPosInt(this.#maxSize)) {
|
|
12006
|
-
throw new TypeError('maxSize must be a positive integer if specified');
|
|
12007
|
-
}
|
|
12008
|
-
}
|
|
12009
|
-
if (!isPosInt(this.maxEntrySize)) {
|
|
12010
|
-
throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
12011
|
-
}
|
|
12012
|
-
this.#initializeSizeTracking();
|
|
12013
|
-
}
|
|
12014
|
-
this.allowStale = !!allowStale;
|
|
12015
|
-
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
12016
|
-
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
12017
|
-
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
12018
|
-
this.ttlResolution =
|
|
12019
|
-
isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
|
|
12020
|
-
this.ttlAutopurge = !!ttlAutopurge;
|
|
12021
|
-
this.ttl = ttl || 0;
|
|
12022
|
-
if (this.ttl) {
|
|
12023
|
-
if (!isPosInt(this.ttl)) {
|
|
12024
|
-
throw new TypeError('ttl must be a positive integer if specified');
|
|
12025
|
-
}
|
|
12026
|
-
this.#initializeTTLTracking();
|
|
12027
|
-
}
|
|
12028
|
-
// do not allow completely unbounded caches
|
|
12029
|
-
if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
|
|
12030
|
-
throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
12031
|
-
}
|
|
12032
|
-
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
12033
|
-
const code = 'LRU_CACHE_UNBOUNDED';
|
|
12034
|
-
if (shouldWarn(code)) {
|
|
12035
|
-
warned.add(code);
|
|
12036
|
-
const msg = 'TTL caching without ttlAutopurge, max, or maxSize can ' +
|
|
12037
|
-
'result in unbounded memory consumption.';
|
|
12038
|
-
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
|
|
12039
|
-
}
|
|
12040
|
-
}
|
|
12041
|
-
}
|
|
12042
|
-
/**
|
|
12043
|
-
* Return the number of ms left in the item's TTL. If item is not in cache,
|
|
12044
|
-
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
|
12045
|
-
*/
|
|
12046
|
-
getRemainingTTL(key) {
|
|
12047
|
-
return this.#keyMap.has(key) ? Infinity : 0;
|
|
12048
|
-
}
|
|
12049
|
-
#initializeTTLTracking() {
|
|
12050
|
-
const ttls = new ZeroArray(this.#max);
|
|
12051
|
-
const starts = new ZeroArray(this.#max);
|
|
12052
|
-
this.#ttls = ttls;
|
|
12053
|
-
this.#starts = starts;
|
|
12054
|
-
const purgeTimers = this.ttlAutopurge ?
|
|
12055
|
-
new Array(this.#max)
|
|
12056
|
-
: undefined;
|
|
12057
|
-
this.#autopurgeTimers = purgeTimers;
|
|
12058
|
-
this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
|
|
12059
|
-
starts[index] = ttl !== 0 ? start : 0;
|
|
12060
|
-
ttls[index] = ttl;
|
|
12061
|
-
// clear out the purge timer if we're setting TTL to 0, and
|
|
12062
|
-
// previously had a ttl purge timer running, so it doesn't
|
|
12063
|
-
// fire unnecessarily.
|
|
12064
|
-
if (purgeTimers?.[index]) {
|
|
12065
|
-
clearTimeout(purgeTimers[index]);
|
|
12066
|
-
purgeTimers[index] = undefined;
|
|
12067
|
-
}
|
|
12068
|
-
if (ttl !== 0 && purgeTimers) {
|
|
12069
|
-
const t = setTimeout(() => {
|
|
12070
|
-
if (this.#isStale(index)) {
|
|
12071
|
-
this.#delete(this.#keyList[index], 'expire');
|
|
12072
|
-
}
|
|
12073
|
-
}, ttl + 1);
|
|
12074
|
-
// unref() not supported on all platforms
|
|
12075
|
-
/* c8 ignore start */
|
|
12076
|
-
if (t.unref) {
|
|
12077
|
-
t.unref();
|
|
12078
|
-
}
|
|
12079
|
-
/* c8 ignore stop */
|
|
12080
|
-
purgeTimers[index] = t;
|
|
12081
|
-
}
|
|
12082
|
-
};
|
|
12083
|
-
this.#updateItemAge = index => {
|
|
12084
|
-
starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
|
|
12085
|
-
};
|
|
12086
|
-
this.#statusTTL = (status, index) => {
|
|
12087
|
-
if (ttls[index]) {
|
|
12088
|
-
const ttl = ttls[index];
|
|
12089
|
-
const start = starts[index];
|
|
12090
|
-
/* c8 ignore next */
|
|
12091
|
-
if (!ttl || !start)
|
|
12092
|
-
return;
|
|
12093
|
-
status.ttl = ttl;
|
|
12094
|
-
status.start = start;
|
|
12095
|
-
status.now = cachedNow || getNow();
|
|
12096
|
-
const age = status.now - start;
|
|
12097
|
-
status.remainingTTL = ttl - age;
|
|
12098
|
-
}
|
|
12099
|
-
};
|
|
12100
|
-
// debounce calls to perf.now() to 1s so we're not hitting
|
|
12101
|
-
// that costly call repeatedly.
|
|
12102
|
-
let cachedNow = 0;
|
|
12103
|
-
const getNow = () => {
|
|
12104
|
-
const n = this.#perf.now();
|
|
12105
|
-
if (this.ttlResolution > 0) {
|
|
12106
|
-
cachedNow = n;
|
|
12107
|
-
const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
|
|
12108
|
-
// not available on all platforms
|
|
12109
|
-
/* c8 ignore start */
|
|
12110
|
-
if (t.unref) {
|
|
12111
|
-
t.unref();
|
|
12112
|
-
}
|
|
12113
|
-
/* c8 ignore stop */
|
|
12114
|
-
}
|
|
12115
|
-
return n;
|
|
12116
|
-
};
|
|
12117
|
-
this.getRemainingTTL = key => {
|
|
12118
|
-
const index = this.#keyMap.get(key);
|
|
12119
|
-
if (index === undefined) {
|
|
12120
|
-
return 0;
|
|
12121
|
-
}
|
|
12122
|
-
const ttl = ttls[index];
|
|
12123
|
-
const start = starts[index];
|
|
12124
|
-
if (!ttl || !start) {
|
|
12125
|
-
return Infinity;
|
|
12126
|
-
}
|
|
12127
|
-
const age = (cachedNow || getNow()) - start;
|
|
12128
|
-
return ttl - age;
|
|
12129
|
-
};
|
|
12130
|
-
this.#isStale = index => {
|
|
12131
|
-
const s = starts[index];
|
|
12132
|
-
const t = ttls[index];
|
|
12133
|
-
return !!t && !!s && (cachedNow || getNow()) - s > t;
|
|
12134
|
-
};
|
|
12135
|
-
}
|
|
12136
|
-
// conditionally set private methods related to TTL
|
|
12137
|
-
#updateItemAge = () => { };
|
|
12138
|
-
#statusTTL = () => { };
|
|
12139
|
-
#setItemTTL = () => { };
|
|
12140
|
-
/* c8 ignore stop */
|
|
12141
|
-
#isStale = () => false;
|
|
12142
|
-
#initializeSizeTracking() {
|
|
12143
|
-
const sizes = new ZeroArray(this.#max);
|
|
12144
|
-
this.#calculatedSize = 0;
|
|
12145
|
-
this.#sizes = sizes;
|
|
12146
|
-
this.#removeItemSize = index => {
|
|
12147
|
-
this.#calculatedSize -= sizes[index];
|
|
12148
|
-
sizes[index] = 0;
|
|
12149
|
-
};
|
|
12150
|
-
this.#requireSize = (k, v, size, sizeCalculation) => {
|
|
12151
|
-
// provisionally accept background fetches.
|
|
12152
|
-
// actual value size will be checked when they return.
|
|
12153
|
-
if (this.#isBackgroundFetch(v)) {
|
|
12154
|
-
return 0;
|
|
12155
|
-
}
|
|
12156
|
-
if (!isPosInt(size)) {
|
|
12157
|
-
if (sizeCalculation) {
|
|
12158
|
-
if (typeof sizeCalculation !== 'function') {
|
|
12159
|
-
throw new TypeError('sizeCalculation must be a function');
|
|
12160
|
-
}
|
|
12161
|
-
size = sizeCalculation(v, k);
|
|
12162
|
-
if (!isPosInt(size)) {
|
|
12163
|
-
throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
12164
|
-
}
|
|
12165
|
-
}
|
|
12166
|
-
else {
|
|
12167
|
-
throw new TypeError('invalid size value (must be positive integer). ' +
|
|
12168
|
-
'When maxSize or maxEntrySize is used, sizeCalculation ' +
|
|
12169
|
-
'or size must be set.');
|
|
12170
|
-
}
|
|
12171
|
-
}
|
|
12172
|
-
return size;
|
|
12173
|
-
};
|
|
12174
|
-
this.#addItemSize = (index, size, status) => {
|
|
12175
|
-
sizes[index] = size;
|
|
12176
|
-
if (this.#maxSize) {
|
|
12177
|
-
const maxSize = this.#maxSize - sizes[index];
|
|
12178
|
-
while (this.#calculatedSize > maxSize) {
|
|
12179
|
-
this.#evict(true);
|
|
12180
|
-
}
|
|
12181
|
-
}
|
|
12182
|
-
this.#calculatedSize += sizes[index];
|
|
12183
|
-
if (status) {
|
|
12184
|
-
status.entrySize = size;
|
|
12185
|
-
status.totalCalculatedSize = this.#calculatedSize;
|
|
12186
|
-
}
|
|
12187
|
-
};
|
|
12188
|
-
}
|
|
12189
|
-
#removeItemSize = _i => { };
|
|
12190
|
-
#addItemSize = (_i, _s, _st) => { };
|
|
12191
|
-
#requireSize = (_k, _v, size, sizeCalculation) => {
|
|
12192
|
-
if (size || sizeCalculation) {
|
|
12193
|
-
throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
|
|
12194
|
-
}
|
|
12195
|
-
return 0;
|
|
12196
|
-
};
|
|
12197
|
-
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
12198
|
-
if (this.#size) {
|
|
12199
|
-
for (let i = this.#tail; true;) {
|
|
12200
|
-
if (!this.#isValidIndex(i)) {
|
|
12201
|
-
break;
|
|
12202
|
-
}
|
|
12203
|
-
if (allowStale || !this.#isStale(i)) {
|
|
12204
|
-
yield i;
|
|
12205
|
-
}
|
|
12206
|
-
if (i === this.#head) {
|
|
12207
|
-
break;
|
|
12208
|
-
}
|
|
12209
|
-
else {
|
|
12210
|
-
i = this.#prev[i];
|
|
12211
|
-
}
|
|
12212
|
-
}
|
|
12213
|
-
}
|
|
12214
|
-
}
|
|
12215
|
-
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
12216
|
-
if (this.#size) {
|
|
12217
|
-
for (let i = this.#head; true;) {
|
|
12218
|
-
if (!this.#isValidIndex(i)) {
|
|
12219
|
-
break;
|
|
12220
|
-
}
|
|
12221
|
-
if (allowStale || !this.#isStale(i)) {
|
|
12222
|
-
yield i;
|
|
12223
|
-
}
|
|
12224
|
-
if (i === this.#tail) {
|
|
12225
|
-
break;
|
|
12226
|
-
}
|
|
12227
|
-
else {
|
|
12228
|
-
i = this.#next[i];
|
|
12229
|
-
}
|
|
12230
|
-
}
|
|
12231
|
-
}
|
|
12232
|
-
}
|
|
12233
|
-
#isValidIndex(index) {
|
|
12234
|
-
return (index !== undefined &&
|
|
12235
|
-
this.#keyMap.get(this.#keyList[index]) === index);
|
|
12236
|
-
}
|
|
12237
|
-
/**
|
|
12238
|
-
* Return a generator yielding `[key, value]` pairs,
|
|
12239
|
-
* in order from most recently used to least recently used.
|
|
12240
|
-
*/
|
|
12241
|
-
*entries() {
|
|
12242
|
-
for (const i of this.#indexes()) {
|
|
12243
|
-
if (this.#valList[i] !== undefined &&
|
|
12244
|
-
this.#keyList[i] !== undefined &&
|
|
12245
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
12246
|
-
yield [this.#keyList[i], this.#valList[i]];
|
|
12247
|
-
}
|
|
12248
|
-
}
|
|
12249
|
-
}
|
|
12250
|
-
/**
|
|
12251
|
-
* Inverse order version of {@link LRUCache.entries}
|
|
12252
|
-
*
|
|
12253
|
-
* Return a generator yielding `[key, value]` pairs,
|
|
12254
|
-
* in order from least recently used to most recently used.
|
|
12255
|
-
*/
|
|
12256
|
-
*rentries() {
|
|
12257
|
-
for (const i of this.#rindexes()) {
|
|
12258
|
-
if (this.#valList[i] !== undefined &&
|
|
12259
|
-
this.#keyList[i] !== undefined &&
|
|
12260
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
12261
|
-
yield [this.#keyList[i], this.#valList[i]];
|
|
12262
|
-
}
|
|
12263
|
-
}
|
|
12264
|
-
}
|
|
12265
|
-
/**
|
|
12266
|
-
* Return a generator yielding the keys in the cache,
|
|
12267
|
-
* in order from most recently used to least recently used.
|
|
12268
|
-
*/
|
|
12269
|
-
*keys() {
|
|
12270
|
-
for (const i of this.#indexes()) {
|
|
12271
|
-
const k = this.#keyList[i];
|
|
12272
|
-
if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
|
|
12273
|
-
yield k;
|
|
12274
|
-
}
|
|
12275
|
-
}
|
|
12276
|
-
}
|
|
12277
|
-
/**
|
|
12278
|
-
* Inverse order version of {@link LRUCache.keys}
|
|
12279
|
-
*
|
|
12280
|
-
* Return a generator yielding the keys in the cache,
|
|
12281
|
-
* in order from least recently used to most recently used.
|
|
12282
|
-
*/
|
|
12283
|
-
*rkeys() {
|
|
12284
|
-
for (const i of this.#rindexes()) {
|
|
12285
|
-
const k = this.#keyList[i];
|
|
12286
|
-
if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
|
|
12287
|
-
yield k;
|
|
12288
|
-
}
|
|
12289
|
-
}
|
|
12290
|
-
}
|
|
12291
|
-
/**
|
|
12292
|
-
* Return a generator yielding the values in the cache,
|
|
12293
|
-
* in order from most recently used to least recently used.
|
|
12294
|
-
*/
|
|
12295
|
-
*values() {
|
|
12296
|
-
for (const i of this.#indexes()) {
|
|
12297
|
-
const v = this.#valList[i];
|
|
12298
|
-
if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
|
|
12299
|
-
yield this.#valList[i];
|
|
12300
|
-
}
|
|
12301
|
-
}
|
|
12302
|
-
}
|
|
12303
|
-
/**
|
|
12304
|
-
* Inverse order version of {@link LRUCache.values}
|
|
12305
|
-
*
|
|
12306
|
-
* Return a generator yielding the values in the cache,
|
|
12307
|
-
* in order from least recently used to most recently used.
|
|
12308
|
-
*/
|
|
12309
|
-
*rvalues() {
|
|
12310
|
-
for (const i of this.#rindexes()) {
|
|
12311
|
-
const v = this.#valList[i];
|
|
12312
|
-
if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
|
|
12313
|
-
yield this.#valList[i];
|
|
12314
|
-
}
|
|
12315
|
-
}
|
|
12316
|
-
}
|
|
12317
|
-
/**
|
|
12318
|
-
* Iterating over the cache itself yields the same results as
|
|
12319
|
-
* {@link LRUCache.entries}
|
|
12320
|
-
*/
|
|
12321
|
-
[Symbol.iterator]() {
|
|
12322
|
-
return this.entries();
|
|
12323
|
-
}
|
|
12324
|
-
/**
|
|
12325
|
-
* A String value that is used in the creation of the default string
|
|
12326
|
-
* description of an object. Called by the built-in method
|
|
12327
|
-
* `Object.prototype.toString`.
|
|
12328
|
-
*/
|
|
12329
|
-
[Symbol.toStringTag] = 'LRUCache';
|
|
12330
|
-
/**
|
|
12331
|
-
* Find a value for which the supplied fn method returns a truthy value,
|
|
12332
|
-
* similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
|
|
12333
|
-
*/
|
|
12334
|
-
find(fn, getOptions = {}) {
|
|
12335
|
-
for (const i of this.#indexes()) {
|
|
12336
|
-
const v = this.#valList[i];
|
|
12337
|
-
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
12338
|
-
if (value === undefined)
|
|
12339
|
-
continue;
|
|
12340
|
-
if (fn(value, this.#keyList[i], this)) {
|
|
12341
|
-
return this.get(this.#keyList[i], getOptions);
|
|
12342
|
-
}
|
|
12343
|
-
}
|
|
12344
|
-
}
|
|
12345
|
-
/**
|
|
12346
|
-
* Call the supplied function on each item in the cache, in order from most
|
|
12347
|
-
* recently used to least recently used.
|
|
12348
|
-
*
|
|
12349
|
-
* `fn` is called as `fn(value, key, cache)`.
|
|
12350
|
-
*
|
|
12351
|
-
* If `thisp` is provided, function will be called in the `this`-context of
|
|
12352
|
-
* the provided object, or the cache if no `thisp` object is provided.
|
|
12353
|
-
*
|
|
12354
|
-
* Does not update age or recenty of use, or iterate over stale values.
|
|
12355
|
-
*/
|
|
12356
|
-
forEach(fn, thisp = this) {
|
|
12357
|
-
for (const i of this.#indexes()) {
|
|
12358
|
-
const v = this.#valList[i];
|
|
12359
|
-
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
12360
|
-
if (value === undefined)
|
|
12361
|
-
continue;
|
|
12362
|
-
fn.call(thisp, value, this.#keyList[i], this);
|
|
12363
|
-
}
|
|
12364
|
-
}
|
|
12365
|
-
/**
|
|
12366
|
-
* The same as {@link LRUCache.forEach} but items are iterated over in
|
|
12367
|
-
* reverse order. (ie, less recently used items are iterated over first.)
|
|
12368
|
-
*/
|
|
12369
|
-
rforEach(fn, thisp = this) {
|
|
12370
|
-
for (const i of this.#rindexes()) {
|
|
12371
|
-
const v = this.#valList[i];
|
|
12372
|
-
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
12373
|
-
if (value === undefined)
|
|
12374
|
-
continue;
|
|
12375
|
-
fn.call(thisp, value, this.#keyList[i], this);
|
|
12376
|
-
}
|
|
12377
|
-
}
|
|
12378
|
-
/**
|
|
12379
|
-
* Delete any stale entries. Returns true if anything was removed,
|
|
12380
|
-
* false otherwise.
|
|
12381
|
-
*/
|
|
12382
|
-
purgeStale() {
|
|
12383
|
-
let deleted = false;
|
|
12384
|
-
for (const i of this.#rindexes({ allowStale: true })) {
|
|
12385
|
-
if (this.#isStale(i)) {
|
|
12386
|
-
this.#delete(this.#keyList[i], 'expire');
|
|
12387
|
-
deleted = true;
|
|
12388
|
-
}
|
|
12389
|
-
}
|
|
12390
|
-
return deleted;
|
|
12391
|
-
}
|
|
12392
|
-
/**
|
|
12393
|
-
* Get the extended info about a given entry, to get its value, size, and
|
|
12394
|
-
* TTL info simultaneously. Returns `undefined` if the key is not present.
|
|
12395
|
-
*
|
|
12396
|
-
* Unlike {@link LRUCache#dump}, which is designed to be portable and survive
|
|
12397
|
-
* serialization, the `start` value is always the current timestamp, and the
|
|
12398
|
-
* `ttl` is a calculated remaining time to live (negative if expired).
|
|
12399
|
-
*
|
|
12400
|
-
* Always returns stale values, if their info is found in the cache, so be
|
|
12401
|
-
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
|
|
12402
|
-
* if relevant.
|
|
12403
|
-
*/
|
|
12404
|
-
info(key) {
|
|
12405
|
-
const i = this.#keyMap.get(key);
|
|
12406
|
-
if (i === undefined)
|
|
12407
|
-
return undefined;
|
|
12408
|
-
const v = this.#valList[i];
|
|
12409
|
-
/* c8 ignore start - this isn't tested for the info function,
|
|
12410
|
-
* but it's the same logic as found in other places. */
|
|
12411
|
-
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
12412
|
-
if (value === undefined)
|
|
12413
|
-
return undefined;
|
|
12414
|
-
/* c8 ignore end */
|
|
12415
|
-
const entry = { value };
|
|
12416
|
-
if (this.#ttls && this.#starts) {
|
|
12417
|
-
const ttl = this.#ttls[i];
|
|
12418
|
-
const start = this.#starts[i];
|
|
12419
|
-
if (ttl && start) {
|
|
12420
|
-
const remain = ttl - (this.#perf.now() - start);
|
|
12421
|
-
entry.ttl = remain;
|
|
12422
|
-
entry.start = Date.now();
|
|
12423
|
-
}
|
|
12424
|
-
}
|
|
12425
|
-
if (this.#sizes) {
|
|
12426
|
-
entry.size = this.#sizes[i];
|
|
12427
|
-
}
|
|
12428
|
-
return entry;
|
|
12429
|
-
}
|
|
12430
|
-
/**
|
|
12431
|
-
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
12432
|
-
* passed to {@link LRUCache#load}.
|
|
12433
|
-
*
|
|
12434
|
-
* The `start` fields are calculated relative to a portable `Date.now()`
|
|
12435
|
-
* timestamp, even if `performance.now()` is available.
|
|
12436
|
-
*
|
|
12437
|
-
* Stale entries are always included in the `dump`, even if
|
|
12438
|
-
* {@link LRUCache.OptionsBase.allowStale} is false.
|
|
12439
|
-
*
|
|
12440
|
-
* Note: this returns an actual array, not a generator, so it can be more
|
|
12441
|
-
* easily passed around.
|
|
12442
|
-
*/
|
|
12443
|
-
dump() {
|
|
12444
|
-
const arr = [];
|
|
12445
|
-
for (const i of this.#indexes({ allowStale: true })) {
|
|
12446
|
-
const key = this.#keyList[i];
|
|
12447
|
-
const v = this.#valList[i];
|
|
12448
|
-
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
12449
|
-
if (value === undefined || key === undefined)
|
|
12450
|
-
continue;
|
|
12451
|
-
const entry = { value };
|
|
12452
|
-
if (this.#ttls && this.#starts) {
|
|
12453
|
-
entry.ttl = this.#ttls[i];
|
|
12454
|
-
// always dump the start relative to a portable timestamp
|
|
12455
|
-
// it's ok for this to be a bit slow, it's a rare operation.
|
|
12456
|
-
const age = this.#perf.now() - this.#starts[i];
|
|
12457
|
-
entry.start = Math.floor(Date.now() - age);
|
|
12458
|
-
}
|
|
12459
|
-
if (this.#sizes) {
|
|
12460
|
-
entry.size = this.#sizes[i];
|
|
12461
|
-
}
|
|
12462
|
-
arr.unshift([key, entry]);
|
|
12463
|
-
}
|
|
12464
|
-
return arr;
|
|
12465
|
-
}
|
|
12466
|
-
/**
|
|
12467
|
-
* Reset the cache and load in the items in entries in the order listed.
|
|
12468
|
-
*
|
|
12469
|
-
* The shape of the resulting cache may be different if the same options are
|
|
12470
|
-
* not used in both caches.
|
|
12471
|
-
*
|
|
12472
|
-
* The `start` fields are assumed to be calculated relative to a portable
|
|
12473
|
-
* `Date.now()` timestamp, even if `performance.now()` is available.
|
|
12474
|
-
*/
|
|
12475
|
-
load(arr) {
|
|
12476
|
-
this.clear();
|
|
12477
|
-
for (const [key, entry] of arr) {
|
|
12478
|
-
if (entry.start) {
|
|
12479
|
-
// entry.start is a portable timestamp, but we may be using
|
|
12480
|
-
// node's performance.now(), so calculate the offset, so that
|
|
12481
|
-
// we get the intended remaining TTL, no matter how long it's
|
|
12482
|
-
// been on ice.
|
|
12483
|
-
//
|
|
12484
|
-
// it's ok for this to be a bit slow, it's a rare operation.
|
|
12485
|
-
const age = Date.now() - entry.start;
|
|
12486
|
-
entry.start = this.#perf.now() - age;
|
|
12487
|
-
}
|
|
12488
|
-
this.set(key, entry.value, entry);
|
|
12489
|
-
}
|
|
12490
|
-
}
|
|
12491
|
-
/**
|
|
12492
|
-
* Add a value to the cache.
|
|
12493
|
-
*
|
|
12494
|
-
* Note: if `undefined` is specified as a value, this is an alias for
|
|
12495
|
-
* {@link LRUCache#delete}
|
|
12496
|
-
*
|
|
12497
|
-
* Fields on the {@link LRUCache.SetOptions} options param will override
|
|
12498
|
-
* their corresponding values in the constructor options for the scope
|
|
12499
|
-
* of this single `set()` operation.
|
|
12500
|
-
*
|
|
12501
|
-
* If `start` is provided, then that will set the effective start
|
|
12502
|
-
* time for the TTL calculation. Note that this must be a previous
|
|
12503
|
-
* value of `performance.now()` if supported, or a previous value of
|
|
12504
|
-
* `Date.now()` if not.
|
|
12505
|
-
*
|
|
12506
|
-
* Options object may also include `size`, which will prevent
|
|
12507
|
-
* calling the `sizeCalculation` function and just use the specified
|
|
12508
|
-
* number if it is a positive integer, and `noDisposeOnSet` which
|
|
12509
|
-
* will prevent calling a `dispose` function in the case of
|
|
12510
|
-
* overwrites.
|
|
12511
|
-
*
|
|
12512
|
-
* If the `size` (or return value of `sizeCalculation`) for a given
|
|
12513
|
-
* entry is greater than `maxEntrySize`, then the item will not be
|
|
12514
|
-
* added to the cache.
|
|
12515
|
-
*
|
|
12516
|
-
* Will update the recency of the entry.
|
|
12517
|
-
*
|
|
12518
|
-
* If the value is `undefined`, then this is an alias for
|
|
12519
|
-
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
12520
|
-
*/
|
|
12521
|
-
set(k, v, setOptions = {}) {
|
|
12522
|
-
if (v === undefined) {
|
|
12523
|
-
this.delete(k);
|
|
12524
|
-
return this;
|
|
12525
|
-
}
|
|
12526
|
-
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
|
|
12527
|
-
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
12528
|
-
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
12529
|
-
// if the item doesn't fit, don't do anything
|
|
12530
|
-
// NB: maxEntrySize set to maxSize by default
|
|
12531
|
-
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
12532
|
-
if (status) {
|
|
12533
|
-
status.set = 'miss';
|
|
12534
|
-
status.maxEntrySizeExceeded = true;
|
|
12535
|
-
}
|
|
12536
|
-
// have to delete, in case something is there already.
|
|
12537
|
-
this.#delete(k, 'set');
|
|
12538
|
-
return this;
|
|
12539
|
-
}
|
|
12540
|
-
let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
|
|
12541
|
-
if (index === undefined) {
|
|
12542
|
-
// addition
|
|
12543
|
-
index = (this.#size === 0 ? this.#tail
|
|
12544
|
-
: this.#free.length !== 0 ? this.#free.pop()
|
|
12545
|
-
: this.#size === this.#max ? this.#evict(false)
|
|
12546
|
-
: this.#size);
|
|
12547
|
-
this.#keyList[index] = k;
|
|
12548
|
-
this.#valList[index] = v;
|
|
12549
|
-
this.#keyMap.set(k, index);
|
|
12550
|
-
this.#next[this.#tail] = index;
|
|
12551
|
-
this.#prev[index] = this.#tail;
|
|
12552
|
-
this.#tail = index;
|
|
12553
|
-
this.#size++;
|
|
12554
|
-
this.#addItemSize(index, size, status);
|
|
12555
|
-
if (status)
|
|
12556
|
-
status.set = 'add';
|
|
12557
|
-
noUpdateTTL = false;
|
|
12558
|
-
if (this.#hasOnInsert) {
|
|
12559
|
-
this.#onInsert?.(v, k, 'add');
|
|
12560
|
-
}
|
|
12561
|
-
}
|
|
12562
|
-
else {
|
|
12563
|
-
// update
|
|
12564
|
-
this.#moveToTail(index);
|
|
12565
|
-
const oldVal = this.#valList[index];
|
|
12566
|
-
if (v !== oldVal) {
|
|
12567
|
-
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
12568
|
-
oldVal.__abortController.abort(new Error('replaced'));
|
|
12569
|
-
const { __staleWhileFetching: s } = oldVal;
|
|
12570
|
-
if (s !== undefined && !noDisposeOnSet) {
|
|
12571
|
-
if (this.#hasDispose) {
|
|
12572
|
-
this.#dispose?.(s, k, 'set');
|
|
12573
|
-
}
|
|
12574
|
-
if (this.#hasDisposeAfter) {
|
|
12575
|
-
this.#disposed?.push([s, k, 'set']);
|
|
12576
|
-
}
|
|
12577
|
-
}
|
|
12578
|
-
}
|
|
12579
|
-
else if (!noDisposeOnSet) {
|
|
12580
|
-
if (this.#hasDispose) {
|
|
12581
|
-
this.#dispose?.(oldVal, k, 'set');
|
|
12582
|
-
}
|
|
12583
|
-
if (this.#hasDisposeAfter) {
|
|
12584
|
-
this.#disposed?.push([oldVal, k, 'set']);
|
|
12585
|
-
}
|
|
12586
|
-
}
|
|
12587
|
-
this.#removeItemSize(index);
|
|
12588
|
-
this.#addItemSize(index, size, status);
|
|
12589
|
-
this.#valList[index] = v;
|
|
12590
|
-
if (status) {
|
|
12591
|
-
status.set = 'replace';
|
|
12592
|
-
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ?
|
|
12593
|
-
oldVal.__staleWhileFetching
|
|
12594
|
-
: oldVal;
|
|
12595
|
-
if (oldValue !== undefined)
|
|
12596
|
-
status.oldValue = oldValue;
|
|
12597
|
-
}
|
|
12598
|
-
}
|
|
12599
|
-
else if (status) {
|
|
12600
|
-
status.set = 'update';
|
|
12601
|
-
}
|
|
12602
|
-
if (this.#hasOnInsert) {
|
|
12603
|
-
this.onInsert?.(v, k, v === oldVal ? 'update' : 'replace');
|
|
12604
|
-
}
|
|
12605
|
-
}
|
|
12606
|
-
if (ttl !== 0 && !this.#ttls) {
|
|
12607
|
-
this.#initializeTTLTracking();
|
|
12608
|
-
}
|
|
12609
|
-
if (this.#ttls) {
|
|
12610
|
-
if (!noUpdateTTL) {
|
|
12611
|
-
this.#setItemTTL(index, ttl, start);
|
|
12612
|
-
}
|
|
12613
|
-
if (status)
|
|
12614
|
-
this.#statusTTL(status, index);
|
|
12615
|
-
}
|
|
12616
|
-
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
12617
|
-
const dt = this.#disposed;
|
|
12618
|
-
let task;
|
|
12619
|
-
while ((task = dt?.shift())) {
|
|
12620
|
-
this.#disposeAfter?.(...task);
|
|
12621
|
-
}
|
|
12622
|
-
}
|
|
12623
|
-
return this;
|
|
12624
|
-
}
|
|
12625
|
-
/**
|
|
12626
|
-
* Evict the least recently used item, returning its value or
|
|
12627
|
-
* `undefined` if cache is empty.
|
|
12628
|
-
*/
|
|
12629
|
-
pop() {
|
|
12630
|
-
try {
|
|
12631
|
-
while (this.#size) {
|
|
12632
|
-
const val = this.#valList[this.#head];
|
|
12633
|
-
this.#evict(true);
|
|
12634
|
-
if (this.#isBackgroundFetch(val)) {
|
|
12635
|
-
if (val.__staleWhileFetching) {
|
|
12636
|
-
return val.__staleWhileFetching;
|
|
12637
|
-
}
|
|
12638
|
-
}
|
|
12639
|
-
else if (val !== undefined) {
|
|
12640
|
-
return val;
|
|
12641
|
-
}
|
|
12642
|
-
}
|
|
12643
|
-
}
|
|
12644
|
-
finally {
|
|
12645
|
-
if (this.#hasDisposeAfter && this.#disposed) {
|
|
12646
|
-
const dt = this.#disposed;
|
|
12647
|
-
let task;
|
|
12648
|
-
while ((task = dt?.shift())) {
|
|
12649
|
-
this.#disposeAfter?.(...task);
|
|
12650
|
-
}
|
|
12651
|
-
}
|
|
12652
|
-
}
|
|
12653
|
-
}
|
|
12654
|
-
#evict(free) {
|
|
12655
|
-
const head = this.#head;
|
|
12656
|
-
const k = this.#keyList[head];
|
|
12657
|
-
const v = this.#valList[head];
|
|
12658
|
-
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
|
|
12659
|
-
v.__abortController.abort(new Error('evicted'));
|
|
12660
|
-
}
|
|
12661
|
-
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
12662
|
-
if (this.#hasDispose) {
|
|
12663
|
-
this.#dispose?.(v, k, 'evict');
|
|
12664
|
-
}
|
|
12665
|
-
if (this.#hasDisposeAfter) {
|
|
12666
|
-
this.#disposed?.push([v, k, 'evict']);
|
|
12667
|
-
}
|
|
12668
|
-
}
|
|
12669
|
-
this.#removeItemSize(head);
|
|
12670
|
-
if (this.#autopurgeTimers?.[head]) {
|
|
12671
|
-
clearTimeout(this.#autopurgeTimers[head]);
|
|
12672
|
-
this.#autopurgeTimers[head] = undefined;
|
|
12673
|
-
}
|
|
12674
|
-
// if we aren't about to use the index, then null these out
|
|
12675
|
-
if (free) {
|
|
12676
|
-
this.#keyList[head] = undefined;
|
|
12677
|
-
this.#valList[head] = undefined;
|
|
12678
|
-
this.#free.push(head);
|
|
12679
|
-
}
|
|
12680
|
-
if (this.#size === 1) {
|
|
12681
|
-
this.#head = this.#tail = 0;
|
|
12682
|
-
this.#free.length = 0;
|
|
12683
|
-
}
|
|
12684
|
-
else {
|
|
12685
|
-
this.#head = this.#next[head];
|
|
12686
|
-
}
|
|
12687
|
-
this.#keyMap.delete(k);
|
|
12688
|
-
this.#size--;
|
|
12689
|
-
return head;
|
|
12690
|
-
}
|
|
12691
|
-
/**
|
|
12692
|
-
* Check if a key is in the cache, without updating the recency of use.
|
|
12693
|
-
* Will return false if the item is stale, even though it is technically
|
|
12694
|
-
* in the cache.
|
|
12695
|
-
*
|
|
12696
|
-
* Check if a key is in the cache, without updating the recency of
|
|
12697
|
-
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
|
|
12698
|
-
* to `true` in either the options or the constructor.
|
|
12699
|
-
*
|
|
12700
|
-
* Will return `false` if the item is stale, even though it is technically in
|
|
12701
|
-
* the cache. The difference can be determined (if it matters) by using a
|
|
12702
|
-
* `status` argument, and inspecting the `has` field.
|
|
12703
|
-
*
|
|
12704
|
-
* Will not update item age unless
|
|
12705
|
-
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
12706
|
-
*/
|
|
12707
|
-
has(k, hasOptions = {}) {
|
|
12708
|
-
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
12709
|
-
const index = this.#keyMap.get(k);
|
|
12710
|
-
if (index !== undefined) {
|
|
12711
|
-
const v = this.#valList[index];
|
|
12712
|
-
if (this.#isBackgroundFetch(v) &&
|
|
12713
|
-
v.__staleWhileFetching === undefined) {
|
|
12714
|
-
return false;
|
|
12715
|
-
}
|
|
12716
|
-
if (!this.#isStale(index)) {
|
|
12717
|
-
if (updateAgeOnHas) {
|
|
12718
|
-
this.#updateItemAge(index);
|
|
12719
|
-
}
|
|
12720
|
-
if (status) {
|
|
12721
|
-
status.has = 'hit';
|
|
12722
|
-
this.#statusTTL(status, index);
|
|
12723
|
-
}
|
|
12724
|
-
return true;
|
|
12725
|
-
}
|
|
12726
|
-
else if (status) {
|
|
12727
|
-
status.has = 'stale';
|
|
12728
|
-
this.#statusTTL(status, index);
|
|
12729
|
-
}
|
|
12730
|
-
}
|
|
12731
|
-
else if (status) {
|
|
12732
|
-
status.has = 'miss';
|
|
12733
|
-
}
|
|
12734
|
-
return false;
|
|
12735
|
-
}
|
|
12736
|
-
/**
|
|
12737
|
-
* Like {@link LRUCache#get} but doesn't update recency or delete stale
|
|
12738
|
-
* items.
|
|
12739
|
-
*
|
|
12740
|
-
* Returns `undefined` if the item is stale, unless
|
|
12741
|
-
* {@link LRUCache.OptionsBase.allowStale} is set.
|
|
12742
|
-
*/
|
|
12743
|
-
peek(k, peekOptions = {}) {
|
|
12744
|
-
const { allowStale = this.allowStale } = peekOptions;
|
|
12745
|
-
const index = this.#keyMap.get(k);
|
|
12746
|
-
if (index === undefined || (!allowStale && this.#isStale(index))) {
|
|
12747
|
-
return;
|
|
12748
|
-
}
|
|
12749
|
-
const v = this.#valList[index];
|
|
12750
|
-
// either stale and allowed, or forcing a refresh of non-stale value
|
|
12751
|
-
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
12752
|
-
}
|
|
12753
|
-
#backgroundFetch(k, index, options, context) {
|
|
12754
|
-
const v = index === undefined ? undefined : this.#valList[index];
|
|
12755
|
-
if (this.#isBackgroundFetch(v)) {
|
|
12756
|
-
return v;
|
|
12757
|
-
}
|
|
12758
|
-
const ac = new AC();
|
|
12759
|
-
const { signal } = options;
|
|
12760
|
-
// when/if our AC signals, then stop listening to theirs.
|
|
12761
|
-
signal?.addEventListener('abort', () => ac.abort(signal.reason), {
|
|
12762
|
-
signal: ac.signal,
|
|
12763
|
-
});
|
|
12764
|
-
const fetchOpts = {
|
|
12765
|
-
signal: ac.signal,
|
|
12766
|
-
options,
|
|
12767
|
-
context,
|
|
12768
|
-
};
|
|
12769
|
-
const cb = (v, updateCache = false) => {
|
|
12770
|
-
const { aborted } = ac.signal;
|
|
12771
|
-
const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
|
|
12772
|
-
if (options.status) {
|
|
12773
|
-
if (aborted && !updateCache) {
|
|
12774
|
-
options.status.fetchAborted = true;
|
|
12775
|
-
options.status.fetchError = ac.signal.reason;
|
|
12776
|
-
if (ignoreAbort)
|
|
12777
|
-
options.status.fetchAbortIgnored = true;
|
|
12778
|
-
}
|
|
12779
|
-
else {
|
|
12780
|
-
options.status.fetchResolved = true;
|
|
12781
|
-
}
|
|
12782
|
-
}
|
|
12783
|
-
if (aborted && !ignoreAbort && !updateCache) {
|
|
12784
|
-
return fetchFail(ac.signal.reason);
|
|
12785
|
-
}
|
|
12786
|
-
// either we didn't abort, and are still here, or we did, and ignored
|
|
12787
|
-
const bf = p;
|
|
12788
|
-
// if nothing else has been written there but we're set to update the
|
|
12789
|
-
// cache and ignore the abort, or if it's still pending on this specific
|
|
12790
|
-
// background request, then write it to the cache.
|
|
12791
|
-
const vl = this.#valList[index];
|
|
12792
|
-
if (vl === p || (ignoreAbort && updateCache && vl === undefined)) {
|
|
12793
|
-
if (v === undefined) {
|
|
12794
|
-
if (bf.__staleWhileFetching !== undefined) {
|
|
12795
|
-
this.#valList[index] = bf.__staleWhileFetching;
|
|
12796
|
-
}
|
|
12797
|
-
else {
|
|
12798
|
-
this.#delete(k, 'fetch');
|
|
12799
|
-
}
|
|
12800
|
-
}
|
|
12801
|
-
else {
|
|
12802
|
-
if (options.status)
|
|
12803
|
-
options.status.fetchUpdated = true;
|
|
12804
|
-
this.set(k, v, fetchOpts.options);
|
|
12805
|
-
}
|
|
12806
|
-
}
|
|
12807
|
-
return v;
|
|
12808
|
-
};
|
|
12809
|
-
const eb = (er) => {
|
|
12810
|
-
if (options.status) {
|
|
12811
|
-
options.status.fetchRejected = true;
|
|
12812
|
-
options.status.fetchError = er;
|
|
12813
|
-
}
|
|
12814
|
-
return fetchFail(er);
|
|
12815
|
-
};
|
|
12816
|
-
const fetchFail = (er) => {
|
|
12817
|
-
const { aborted } = ac.signal;
|
|
12818
|
-
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
12819
|
-
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
12820
|
-
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
12821
|
-
const bf = p;
|
|
12822
|
-
if (this.#valList[index] === p) {
|
|
12823
|
-
// if we allow stale on fetch rejections, then we need to ensure that
|
|
12824
|
-
// the stale value is not removed from the cache when the fetch fails.
|
|
12825
|
-
const del = !noDelete || bf.__staleWhileFetching === undefined;
|
|
12826
|
-
if (del) {
|
|
12827
|
-
this.#delete(k, 'fetch');
|
|
12828
|
-
}
|
|
12829
|
-
else if (!allowStaleAborted) {
|
|
12830
|
-
// still replace the *promise* with the stale value,
|
|
12831
|
-
// since we are done with the promise at this point.
|
|
12832
|
-
// leave it untouched if we're still waiting for an
|
|
12833
|
-
// aborted background fetch that hasn't yet returned.
|
|
12834
|
-
this.#valList[index] = bf.__staleWhileFetching;
|
|
12835
|
-
}
|
|
12836
|
-
}
|
|
12837
|
-
if (allowStale) {
|
|
12838
|
-
if (options.status && bf.__staleWhileFetching !== undefined) {
|
|
12839
|
-
options.status.returnedStale = true;
|
|
12840
|
-
}
|
|
12841
|
-
return bf.__staleWhileFetching;
|
|
12842
|
-
}
|
|
12843
|
-
else if (bf.__returned === bf) {
|
|
12844
|
-
throw er;
|
|
12845
|
-
}
|
|
12846
|
-
};
|
|
12847
|
-
const pcall = (res, rej) => {
|
|
12848
|
-
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
12849
|
-
if (fmp && fmp instanceof Promise) {
|
|
12850
|
-
fmp.then(v => res(v === undefined ? undefined : v), rej);
|
|
12851
|
-
}
|
|
12852
|
-
// ignored, we go until we finish, regardless.
|
|
12853
|
-
// defer check until we are actually aborting,
|
|
12854
|
-
// so fetchMethod can override.
|
|
12855
|
-
ac.signal.addEventListener('abort', () => {
|
|
12856
|
-
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
|
12857
|
-
res(undefined);
|
|
12858
|
-
// when it eventually resolves, update the cache.
|
|
12859
|
-
if (options.allowStaleOnFetchAbort) {
|
|
12860
|
-
res = v => cb(v, true);
|
|
12861
|
-
}
|
|
12862
|
-
}
|
|
12863
|
-
});
|
|
12864
|
-
};
|
|
12865
|
-
if (options.status)
|
|
12866
|
-
options.status.fetchDispatched = true;
|
|
12867
|
-
const p = new Promise(pcall).then(cb, eb);
|
|
12868
|
-
const bf = Object.assign(p, {
|
|
12869
|
-
__abortController: ac,
|
|
12870
|
-
__staleWhileFetching: v,
|
|
12871
|
-
__returned: undefined,
|
|
12872
|
-
});
|
|
12873
|
-
if (index === undefined) {
|
|
12874
|
-
// internal, don't expose status.
|
|
12875
|
-
this.set(k, bf, { ...fetchOpts.options, status: undefined });
|
|
12876
|
-
index = this.#keyMap.get(k);
|
|
12877
|
-
}
|
|
12878
|
-
else {
|
|
12879
|
-
this.#valList[index] = bf;
|
|
12880
|
-
}
|
|
12881
|
-
return bf;
|
|
12882
|
-
}
|
|
12883
|
-
#isBackgroundFetch(p) {
|
|
12884
|
-
if (!this.#hasFetchMethod)
|
|
12885
|
-
return false;
|
|
12886
|
-
const b = p;
|
|
12887
|
-
return (!!b &&
|
|
12888
|
-
b instanceof Promise &&
|
|
12889
|
-
b.hasOwnProperty('__staleWhileFetching') &&
|
|
12890
|
-
b.__abortController instanceof AC);
|
|
12891
|
-
}
|
|
12892
|
-
async fetch(k, fetchOptions = {}) {
|
|
12893
|
-
const {
|
|
12894
|
-
// get options
|
|
12895
|
-
allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
|
12896
|
-
// set options
|
|
12897
|
-
ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
|
|
12898
|
-
// fetch exclusive options
|
|
12899
|
-
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
|
|
12900
|
-
if (!this.#hasFetchMethod) {
|
|
12901
|
-
if (status)
|
|
12902
|
-
status.fetch = 'get';
|
|
12903
|
-
return this.get(k, {
|
|
12904
|
-
allowStale,
|
|
12905
|
-
updateAgeOnGet,
|
|
12906
|
-
noDeleteOnStaleGet,
|
|
12907
|
-
status,
|
|
12908
|
-
});
|
|
12909
|
-
}
|
|
12910
|
-
const options = {
|
|
12911
|
-
allowStale,
|
|
12912
|
-
updateAgeOnGet,
|
|
12913
|
-
noDeleteOnStaleGet,
|
|
12914
|
-
ttl,
|
|
12915
|
-
noDisposeOnSet,
|
|
12916
|
-
size,
|
|
12917
|
-
sizeCalculation,
|
|
12918
|
-
noUpdateTTL,
|
|
12919
|
-
noDeleteOnFetchRejection,
|
|
12920
|
-
allowStaleOnFetchRejection,
|
|
12921
|
-
allowStaleOnFetchAbort,
|
|
12922
|
-
ignoreFetchAbort,
|
|
12923
|
-
status,
|
|
12924
|
-
signal,
|
|
12925
|
-
};
|
|
12926
|
-
let index = this.#keyMap.get(k);
|
|
12927
|
-
if (index === undefined) {
|
|
12928
|
-
if (status)
|
|
12929
|
-
status.fetch = 'miss';
|
|
12930
|
-
const p = this.#backgroundFetch(k, index, options, context);
|
|
12931
|
-
return (p.__returned = p);
|
|
12932
|
-
}
|
|
12933
|
-
else {
|
|
12934
|
-
// in cache, maybe already fetching
|
|
12935
|
-
const v = this.#valList[index];
|
|
12936
|
-
if (this.#isBackgroundFetch(v)) {
|
|
12937
|
-
const stale = allowStale && v.__staleWhileFetching !== undefined;
|
|
12938
|
-
if (status) {
|
|
12939
|
-
status.fetch = 'inflight';
|
|
12940
|
-
if (stale)
|
|
12941
|
-
status.returnedStale = true;
|
|
12942
|
-
}
|
|
12943
|
-
return stale ? v.__staleWhileFetching : (v.__returned = v);
|
|
12944
|
-
}
|
|
12945
|
-
// if we force a refresh, that means do NOT serve the cached value,
|
|
12946
|
-
// unless we are already in the process of refreshing the cache.
|
|
12947
|
-
const isStale = this.#isStale(index);
|
|
12948
|
-
if (!forceRefresh && !isStale) {
|
|
12949
|
-
if (status)
|
|
12950
|
-
status.fetch = 'hit';
|
|
12951
|
-
this.#moveToTail(index);
|
|
12952
|
-
if (updateAgeOnGet) {
|
|
12953
|
-
this.#updateItemAge(index);
|
|
12954
|
-
}
|
|
12955
|
-
if (status)
|
|
12956
|
-
this.#statusTTL(status, index);
|
|
12957
|
-
return v;
|
|
12958
|
-
}
|
|
12959
|
-
// ok, it is stale or a forced refresh, and not already fetching.
|
|
12960
|
-
// refresh the cache.
|
|
12961
|
-
const p = this.#backgroundFetch(k, index, options, context);
|
|
12962
|
-
const hasStale = p.__staleWhileFetching !== undefined;
|
|
12963
|
-
const staleVal = hasStale && allowStale;
|
|
12964
|
-
if (status) {
|
|
12965
|
-
status.fetch = isStale ? 'stale' : 'refresh';
|
|
12966
|
-
if (staleVal && isStale)
|
|
12967
|
-
status.returnedStale = true;
|
|
12968
|
-
}
|
|
12969
|
-
return staleVal ? p.__staleWhileFetching : (p.__returned = p);
|
|
12970
|
-
}
|
|
12971
|
-
}
|
|
12972
|
-
async forceFetch(k, fetchOptions = {}) {
|
|
12973
|
-
const v = await this.fetch(k, fetchOptions);
|
|
12974
|
-
if (v === undefined)
|
|
12975
|
-
throw new Error('fetch() returned undefined');
|
|
12976
|
-
return v;
|
|
12977
|
-
}
|
|
12978
|
-
memo(k, memoOptions = {}) {
|
|
12979
|
-
const memoMethod = this.#memoMethod;
|
|
12980
|
-
if (!memoMethod) {
|
|
12981
|
-
throw new Error('no memoMethod provided to constructor');
|
|
12982
|
-
}
|
|
12983
|
-
const { context, forceRefresh, ...options } = memoOptions;
|
|
12984
|
-
const v = this.get(k, options);
|
|
12985
|
-
if (!forceRefresh && v !== undefined)
|
|
12986
|
-
return v;
|
|
12987
|
-
const vv = memoMethod(k, v, {
|
|
12988
|
-
options,
|
|
12989
|
-
context,
|
|
12990
|
-
});
|
|
12991
|
-
this.set(k, vv, options);
|
|
12992
|
-
return vv;
|
|
12993
|
-
}
|
|
12994
|
-
/**
|
|
12995
|
-
* Return a value from the cache. Will update the recency of the cache
|
|
12996
|
-
* entry found.
|
|
12997
|
-
*
|
|
12998
|
-
* If the key is not found, get() will return `undefined`.
|
|
12999
|
-
*/
|
|
13000
|
-
get(k, getOptions = {}) {
|
|
13001
|
-
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
|
|
13002
|
-
const index = this.#keyMap.get(k);
|
|
13003
|
-
if (index !== undefined) {
|
|
13004
|
-
const value = this.#valList[index];
|
|
13005
|
-
const fetching = this.#isBackgroundFetch(value);
|
|
13006
|
-
if (status)
|
|
13007
|
-
this.#statusTTL(status, index);
|
|
13008
|
-
if (this.#isStale(index)) {
|
|
13009
|
-
if (status)
|
|
13010
|
-
status.get = 'stale';
|
|
13011
|
-
// delete only if not an in-flight background fetch
|
|
13012
|
-
if (!fetching) {
|
|
13013
|
-
if (!noDeleteOnStaleGet) {
|
|
13014
|
-
this.#delete(k, 'expire');
|
|
13015
|
-
}
|
|
13016
|
-
if (status && allowStale)
|
|
13017
|
-
status.returnedStale = true;
|
|
13018
|
-
return allowStale ? value : undefined;
|
|
13019
|
-
}
|
|
13020
|
-
else {
|
|
13021
|
-
if (status &&
|
|
13022
|
-
allowStale &&
|
|
13023
|
-
value.__staleWhileFetching !== undefined) {
|
|
13024
|
-
status.returnedStale = true;
|
|
13025
|
-
}
|
|
13026
|
-
return allowStale ? value.__staleWhileFetching : undefined;
|
|
13027
|
-
}
|
|
13028
|
-
}
|
|
13029
|
-
else {
|
|
13030
|
-
if (status)
|
|
13031
|
-
status.get = 'hit';
|
|
13032
|
-
// if we're currently fetching it, we don't actually have it yet
|
|
13033
|
-
// it's not stale, which means this isn't a staleWhileRefetching.
|
|
13034
|
-
// If it's not stale, and fetching, AND has a __staleWhileFetching
|
|
13035
|
-
// value, then that means the user fetched with {forceRefresh:true},
|
|
13036
|
-
// so it's safe to return that value.
|
|
13037
|
-
if (fetching) {
|
|
13038
|
-
return value.__staleWhileFetching;
|
|
13039
|
-
}
|
|
13040
|
-
this.#moveToTail(index);
|
|
13041
|
-
if (updateAgeOnGet) {
|
|
13042
|
-
this.#updateItemAge(index);
|
|
13043
|
-
}
|
|
13044
|
-
return value;
|
|
13045
|
-
}
|
|
13046
|
-
}
|
|
13047
|
-
else if (status) {
|
|
13048
|
-
status.get = 'miss';
|
|
13049
|
-
}
|
|
13050
|
-
}
|
|
13051
|
-
#connect(p, n) {
|
|
13052
|
-
this.#prev[n] = p;
|
|
13053
|
-
this.#next[p] = n;
|
|
13054
|
-
}
|
|
13055
|
-
#moveToTail(index) {
|
|
13056
|
-
// if tail already, nothing to do
|
|
13057
|
-
// if head, move head to next[index]
|
|
13058
|
-
// else
|
|
13059
|
-
// move next[prev[index]] to next[index] (head has no prev)
|
|
13060
|
-
// move prev[next[index]] to prev[index]
|
|
13061
|
-
// prev[index] = tail
|
|
13062
|
-
// next[tail] = index
|
|
13063
|
-
// tail = index
|
|
13064
|
-
if (index !== this.#tail) {
|
|
13065
|
-
if (index === this.#head) {
|
|
13066
|
-
this.#head = this.#next[index];
|
|
13067
|
-
}
|
|
13068
|
-
else {
|
|
13069
|
-
this.#connect(this.#prev[index], this.#next[index]);
|
|
13070
|
-
}
|
|
13071
|
-
this.#connect(this.#tail, index);
|
|
13072
|
-
this.#tail = index;
|
|
13073
|
-
}
|
|
13074
|
-
}
|
|
13075
|
-
/**
|
|
13076
|
-
* Deletes a key out of the cache.
|
|
13077
|
-
*
|
|
13078
|
-
* Returns true if the key was deleted, false otherwise.
|
|
13079
|
-
*/
|
|
13080
|
-
delete(k) {
|
|
13081
|
-
return this.#delete(k, 'delete');
|
|
13082
|
-
}
|
|
13083
|
-
#delete(k, reason) {
|
|
13084
|
-
let deleted = false;
|
|
13085
|
-
if (this.#size !== 0) {
|
|
13086
|
-
const index = this.#keyMap.get(k);
|
|
13087
|
-
if (index !== undefined) {
|
|
13088
|
-
if (this.#autopurgeTimers?.[index]) {
|
|
13089
|
-
clearTimeout(this.#autopurgeTimers?.[index]);
|
|
13090
|
-
this.#autopurgeTimers[index] = undefined;
|
|
13091
|
-
}
|
|
13092
|
-
deleted = true;
|
|
13093
|
-
if (this.#size === 1) {
|
|
13094
|
-
this.#clear(reason);
|
|
13095
|
-
}
|
|
13096
|
-
else {
|
|
13097
|
-
this.#removeItemSize(index);
|
|
13098
|
-
const v = this.#valList[index];
|
|
13099
|
-
if (this.#isBackgroundFetch(v)) {
|
|
13100
|
-
v.__abortController.abort(new Error('deleted'));
|
|
13101
|
-
}
|
|
13102
|
-
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
13103
|
-
if (this.#hasDispose) {
|
|
13104
|
-
this.#dispose?.(v, k, reason);
|
|
13105
|
-
}
|
|
13106
|
-
if (this.#hasDisposeAfter) {
|
|
13107
|
-
this.#disposed?.push([v, k, reason]);
|
|
13108
|
-
}
|
|
13109
|
-
}
|
|
13110
|
-
this.#keyMap.delete(k);
|
|
13111
|
-
this.#keyList[index] = undefined;
|
|
13112
|
-
this.#valList[index] = undefined;
|
|
13113
|
-
if (index === this.#tail) {
|
|
13114
|
-
this.#tail = this.#prev[index];
|
|
13115
|
-
}
|
|
13116
|
-
else if (index === this.#head) {
|
|
13117
|
-
this.#head = this.#next[index];
|
|
13118
|
-
}
|
|
13119
|
-
else {
|
|
13120
|
-
const pi = this.#prev[index];
|
|
13121
|
-
this.#next[pi] = this.#next[index];
|
|
13122
|
-
const ni = this.#next[index];
|
|
13123
|
-
this.#prev[ni] = this.#prev[index];
|
|
13124
|
-
}
|
|
13125
|
-
this.#size--;
|
|
13126
|
-
this.#free.push(index);
|
|
13127
|
-
}
|
|
13128
|
-
}
|
|
13129
|
-
}
|
|
13130
|
-
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
13131
|
-
const dt = this.#disposed;
|
|
13132
|
-
let task;
|
|
13133
|
-
while ((task = dt?.shift())) {
|
|
13134
|
-
this.#disposeAfter?.(...task);
|
|
13135
|
-
}
|
|
13136
|
-
}
|
|
13137
|
-
return deleted;
|
|
13138
|
-
}
|
|
13139
|
-
/**
|
|
13140
|
-
* Clear the cache entirely, throwing away all values.
|
|
13141
|
-
*/
|
|
13142
|
-
clear() {
|
|
13143
|
-
return this.#clear('delete');
|
|
13144
|
-
}
|
|
13145
|
-
#clear(reason) {
|
|
13146
|
-
for (const index of this.#rindexes({ allowStale: true })) {
|
|
13147
|
-
const v = this.#valList[index];
|
|
13148
|
-
if (this.#isBackgroundFetch(v)) {
|
|
13149
|
-
v.__abortController.abort(new Error('deleted'));
|
|
13150
|
-
}
|
|
13151
|
-
else {
|
|
13152
|
-
const k = this.#keyList[index];
|
|
13153
|
-
if (this.#hasDispose) {
|
|
13154
|
-
this.#dispose?.(v, k, reason);
|
|
13155
|
-
}
|
|
13156
|
-
if (this.#hasDisposeAfter) {
|
|
13157
|
-
this.#disposed?.push([v, k, reason]);
|
|
13158
|
-
}
|
|
13159
|
-
}
|
|
13160
|
-
}
|
|
13161
|
-
this.#keyMap.clear();
|
|
13162
|
-
this.#valList.fill(undefined);
|
|
13163
|
-
this.#keyList.fill(undefined);
|
|
13164
|
-
if (this.#ttls && this.#starts) {
|
|
13165
|
-
this.#ttls.fill(0);
|
|
13166
|
-
this.#starts.fill(0);
|
|
13167
|
-
for (const t of this.#autopurgeTimers ?? []) {
|
|
13168
|
-
if (t !== undefined)
|
|
13169
|
-
clearTimeout(t);
|
|
13170
|
-
}
|
|
13171
|
-
this.#autopurgeTimers?.fill(undefined);
|
|
13172
|
-
}
|
|
13173
|
-
if (this.#sizes) {
|
|
13174
|
-
this.#sizes.fill(0);
|
|
13175
|
-
}
|
|
13176
|
-
this.#head = 0;
|
|
13177
|
-
this.#tail = 0;
|
|
13178
|
-
this.#free.length = 0;
|
|
13179
|
-
this.#calculatedSize = 0;
|
|
13180
|
-
this.#size = 0;
|
|
13181
|
-
if (this.#hasDisposeAfter && this.#disposed) {
|
|
13182
|
-
const dt = this.#disposed;
|
|
13183
|
-
let task;
|
|
13184
|
-
while ((task = dt?.shift())) {
|
|
13185
|
-
this.#disposeAfter?.(...task);
|
|
13186
|
-
}
|
|
13187
|
-
}
|
|
13188
|
-
}
|
|
13189
|
-
}
|
|
13190
|
-
//# sourceMappingURL=index.js.map
|
|
11963
|
+
// EXTERNAL MODULE: external "node:diagnostics_channel"
|
|
11964
|
+
var external_node_diagnostics_channel_ = __webpack_require__(3053);
|
|
11965
|
+
;// CONCATENATED MODULE: ../../node_modules/lru-cache/dist/esm/node/index.min.js
|
|
11966
|
+
var S=(0,external_node_diagnostics_channel_.channel)("lru-cache:metrics"),W=(0,external_node_diagnostics_channel_.tracingChannel)("lru-cache");var L=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date;var D=()=>S.hasSubscribers||W.hasSubscribers,U=new Set,M=typeof process=="object"&&process?process:{},k=(u,e,t,i)=>{typeof M.emitWarning=="function"?M.emitWarning(u,e,t,i):console.error(`[${t}] ${e}: ${u}`)},H=u=>!U.has(u);var T=u=>!!u&&u===Math.floor(u)&&u>0&&isFinite(u),j=u=>T(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?O:null:null,O=class extends Array{constructor(e){super(e),this.fill(0)}},R=class u{heap;length;static#o=!1;static create(e){let t=j(e);if(!t)return[];u.#o=!0;let i=new u(e,t);return u.#o=!1,i}constructor(e,t){if(!u.#o)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},I=class u{#o;#c;#S;#O;#w;#M;#I;#m;get perf(){return this.#m}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;backgroundFetchSize;#n;#b;#s;#i;#t;#l;#u;#a;#h;#y;#r;#_;#F;#d;#g;#T;#U;#f;#x;static unsafeExposeInternals(e){return{starts:e.#F,ttls:e.#d,autopurgeTimers:e.#g,sizes:e.#_,keyMap:e.#s,keyList:e.#i,valList:e.#t,next:e.#l,prev:e.#u,get head(){return e.#a},get tail(){return e.#h},free:e.#y,isBackgroundFetch:t=>e.#e(t),backgroundFetch:(t,i,s,n)=>e.#P(t,i,s,n),moveToTail:t=>e.#L(t),indexes:t=>e.#A(t),rindexes:t=>e.#z(t),isStale:t=>e.#p(t)}}get max(){return this.#o}get maxSize(){return this.#c}get calculatedSize(){return this.#b}get size(){return this.#n}get fetchMethod(){return this.#M}get memoMethod(){return this.#I}get dispose(){return this.#S}get onInsert(){return this.#O}get disposeAfter(){return this.#w}constructor(e){let{max:t=0,ttl:i,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:h,allowStale:a,dispose:o,onInsert:d,disposeAfter:y,noDisposeOnSet:_,noUpdateTTL:c,maxSize:g=0,maxEntrySize:f=0,sizeCalculation:b,fetchMethod:l,memoMethod:w,noDeleteOnFetchRejection:F,noDeleteOnStaleGet:m,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:A,ignoreFetchAbort:z,backgroundFetchSize:C=1,perf:E}=e;if(this.backgroundFetchSize=C,E!==void 0&&typeof E?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#m=E??L,t!==0&&!T(t))throw new TypeError("max option must be a nonnegative integer");let v=t?j(t):Array;if(!v)throw new Error("invalid max value: "+t);if(this.#o=t,this.#c=g,this.maxEntrySize=f||this.#c,this.sizeCalculation=b,this.sizeCalculation){if(!this.#c&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#I=w,l!==void 0&&typeof l!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#M=l,this.#U=!!l,this.#s=new Map,this.#i=Array.from({length:t}).fill(void 0),this.#t=Array.from({length:t}).fill(void 0),this.#l=new v(t),this.#u=new v(t),this.#a=0,this.#h=0,this.#y=R.create(t),this.#n=0,this.#b=0,typeof o=="function"&&(this.#S=o),typeof d=="function"&&(this.#O=d),typeof y=="function"?(this.#w=y,this.#r=[]):(this.#w=void 0,this.#r=void 0),this.#T=!!this.#S,this.#x=!!this.#O,this.#f=!!this.#w,this.noDisposeOnSet=!!_,this.noUpdateTTL=!!c,this.noDeleteOnFetchRejection=!!F,this.allowStaleOnFetchRejection=!!p,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!z,this.maxEntrySize!==0){if(this.#c!==0&&!T(this.#c))throw new TypeError("maxSize must be a positive integer if specified");if(!T(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#X()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!m,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!h,this.ttlResolution=T(s)||s===0?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!T(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#o===0&&this.ttl===0&&this.#c===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#o&&!this.#c){let x="LRU_CACHE_UNBOUNDED";H(x)&&(U.add(x),k("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",x,u))}}getRemainingTTL(e){return this.#s.has(e)?1/0:0}#k(){let e=new O(this.#o),t=new O(this.#o);this.#d=e,this.#F=t;let i=this.ttlAutopurge?Array.from({length:this.#o}):void 0;this.#g=i,this.#H=(h,a,o=this.#m.now())=>{t[h]=a!==0?o:0,e[h]=a,s(h,a)},this.#D=h=>{t[h]=e[h]!==0?this.#m.now():0,s(h,e[h])};let s=this.ttlAutopurge?(h,a)=>{if(i?.[h]&&(clearTimeout(i[h]),i[h]=void 0),a&&a!==0&&i){let o=setTimeout(()=>{this.#p(h)&&this.#E(this.#i[h],"expire")},a+1);o.unref&&o.unref(),i[h]=o}}:()=>{};this.#v=(h,a)=>{if(e[a]){let o=e[a],d=t[a];if(!o||!d)return;h.ttl=o,h.start=d,h.now=n||r();let y=h.now-d;h.remainingTTL=o-y}};let n=0,r=()=>{let h=this.#m.now();if(this.ttlResolution>0){n=h;let a=setTimeout(()=>n=0,this.ttlResolution);a.unref&&a.unref()}return h};this.getRemainingTTL=h=>{let a=this.#s.get(h);if(a===void 0)return 0;let o=e[a],d=t[a];if(!o||!d)return 1/0;let y=(n||r())-d;return o-y},this.#p=h=>{let a=t[h],o=e[h];return!!o&&!!a&&(n||r())-a>o}}#D=()=>{};#v=()=>{};#H=()=>{};#p=()=>!1;#X(){let e=new O(this.#o);this.#b=0,this.#_=e,this.#R=t=>{this.#b-=e[t],e[t]=0},this.#N=(t,i,s,n)=>{if(!T(s)){if(this.#e(i))return this.backgroundFetchSize;if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(s=n(i,t),!T(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return s},this.#j=(t,i,s)=>{if(e[t]=i,this.#c){let n=this.#c-e[t];for(;this.#b>n;)this.#G(!0)}this.#b+=e[t],s&&(s.entrySize=i,s.totalCalculatedSize=this.#b)}}#R=e=>{};#j=(e,t,i)=>{};#N=(e,t,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#h;this.#V(t)&&((e||!this.#p(t))&&(yield t),t!==this.#a);)t=this.#u[t]}*#z({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#a;this.#V(t)&&((e||!this.#p(t))&&(yield t),t!==this.#h);)t=this.#l[t]}#V(e){return e!==void 0&&this.#s.get(this.#i[e])===e}*entries(){for(let e of this.#A())this.#t[e]!==void 0&&this.#i[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#i[e],this.#t[e]])}*rentries(){for(let e of this.#z())this.#t[e]!==void 0&&this.#i[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#i[e],this.#t[e]])}*keys(){for(let e of this.#A()){let t=this.#i[e];t!==void 0&&!this.#e(this.#t[e])&&(yield t)}}*rkeys(){for(let e of this.#z()){let t=this.#i[e];t!==void 0&&!this.#e(this.#t[e])&&(yield t)}}*values(){for(let e of this.#A())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}*rvalues(){for(let e of this.#z())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;if(n!==void 0&&e(n,this.#i[i],this))return this.#C(this.#i[i],t)}}forEach(e,t=this){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&e.call(t,n,this.#i[i],this)}}rforEach(e,t=this){for(let i of this.#z()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&e.call(t,n,this.#i[i],this)}}purgeStale(){let e=!1;for(let t of this.#z({allowStale:!0}))this.#p(t)&&(this.#E(this.#i[t],"expire"),e=!0);return e}info(e){let t=this.#s.get(e);if(t===void 0)return;let i=this.#t[t],s=this.#e(i)?i.__staleWhileFetching:i;if(s===void 0)return;let n={value:s};if(this.#d&&this.#F){let r=this.#d[t],h=this.#F[t];if(r&&h){let a=r-(this.#m.now()-h);n.ttl=a,n.start=Date.now()}}return this.#_&&(n.size=this.#_[t]),n}dump(){let e=[];for(let t of this.#A({allowStale:!0})){let i=this.#i[t],s=this.#t[t],n=this.#e(s)?s.__staleWhileFetching:s;if(n===void 0||i===void 0)continue;let r={value:n};if(this.#d&&this.#F){r.ttl=this.#d[t];let h=this.#m.now()-this.#F[t];r.start=Math.floor(Date.now()-h)}this.#_&&(r.size=this.#_[t]),e.unshift([i,r])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let s=Date.now()-i.start;i.start=this.#m.now()-s}this.#W(t,i.value,i)}}set(e,t,i={}){let{status:s=S.hasSubscribers?{}:void 0}=i;i.status=s,s&&(s.op="set",s.key=e,t!==void 0&&(s.value=t),s.cache=this);let n=this.#W(e,t,i);return s&&S.hasSubscribers&&S.publish(s),n}#W(e,t,i,s){let{ttl:n=this.ttl,start:r,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:o}=i,d=this.#e(t);if(t===void 0)return o&&(o.set="deleted"),this.delete(e),this;let{noUpdateTTL:y=this.noUpdateTTL}=i;o&&!d&&(o.value=t);let _=this.#N(e,t,i.size||0,a,o);if(this.maxEntrySize&&_>this.maxEntrySize)return this.#E(e,"set"),o&&(o.set="miss",o.maxEntrySizeExceeded=!0),this;let c=this.#n===0?void 0:this.#s.get(e);if(c===void 0)c=this.#n===0?this.#h:this.#y.length!==0?this.#y.pop():this.#n===this.#o?this.#G(!1):this.#n,this.#i[c]=e,this.#t[c]=t,this.#s.set(e,c),this.#l[this.#h]=c,this.#u[c]=this.#h,this.#h=c,this.#n++,this.#j(c,_,o),o&&(o.set="add"),y=!1,this.#x&&!d&&this.#O?.(t,e,"add");else{this.#L(c);let g=this.#t[c];if(t!==g){if(!h)if(this.#e(g)){g!==s&&g.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=g;f!==void 0&&f!==t&&(this.#T&&this.#S?.(f,e,"set"),this.#f&&this.#r?.push([f,e,"set"]))}else this.#T&&this.#S?.(g,e,"set"),this.#f&&this.#r?.push([g,e,"set"]);if(this.#R(c),this.#j(c,_,o),this.#t[c]=t,!d){let f=g&&this.#e(g)?g.__staleWhileFetching:g,b=f===void 0?"add":t!==f?"replace":"update";o&&(o.set=b,f!==void 0&&(o.oldValue=f)),this.#x&&this.onInsert?.(t,e,b)}}else d||(o&&(o.set="update"),this.#x&&this.onInsert?.(t,e,"update"))}if(n!==0&&!this.#d&&this.#k(),this.#d&&(y||this.#H(c,n,r),o&&this.#v(o,c)),!h&&this.#f&&this.#r){let g=this.#r,f;for(;f=g?.shift();)this.#w?.(...f)}return this}pop(){try{for(;this.#n;){let e=this.#t[this.#a];if(this.#G(!0),this.#e(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#f&&this.#r){let e=this.#r,t;for(;t=e?.shift();)this.#w?.(...t)}}}#G(e){let t=this.#a,i=this.#i[t],s=this.#t[t],n=this.#e(s);n&&s.__abortController.abort(new Error("evicted"));let r=n?s.__staleWhileFetching:s;return(this.#T||this.#f)&&r!==void 0&&(this.#T&&this.#S?.(r,i,"evict"),this.#f&&this.#r?.push([r,i,"evict"])),this.#R(t),this.#g?.[t]&&(clearTimeout(this.#g[t]),this.#g[t]=void 0),e&&(this.#i[t]=void 0,this.#t[t]=void 0,this.#y.push(t)),this.#n===1?(this.#a=this.#h=0,this.#y.length=0):this.#a=this.#l[t],this.#s.delete(i),this.#n--,t}has(e,t={}){let{status:i=S.hasSubscribers?{}:void 0}=t;t.status=i,i&&(i.op="has",i.key=e,i.cache=this);let s=this.#Y(e,t);return S.hasSubscribers&&S.publish(i),s}#Y(e,t={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=t,n=this.#s.get(e);if(n!==void 0){let r=this.#t[n];if(this.#e(r)&&r.__staleWhileFetching===void 0)return!1;if(this.#p(n))s&&(s.has="stale",this.#v(s,n));else return i&&this.#D(n),s&&(s.has="hit",this.#v(s,n)),!0}else s&&(s.has="miss");return!1}peek(e,t={}){let{status:i=D()?{}:void 0}=t;i&&(i.op="peek",i.key=e,i.cache=this),t.status=i;let s=this.#J(e,t);return S.hasSubscribers&&S.publish(i),s}#J(e,t){let{status:i,allowStale:s=this.allowStale}=t,n=this.#s.get(e);if(n===void 0||!s&&this.#p(n)){i&&(i.peek=n===void 0?"miss":"stale");return}let r=this.#t[n],h=this.#e(r)?r.__staleWhileFetching:r;return i&&(h!==void 0?(i.peek="hit",i.value=h):i.peek="miss"),h}#P(e,t,i,s){let n=t===void 0?void 0:this.#t[t];if(this.#e(n))return n;let r=new AbortController,{signal:h}=i;h?.addEventListener("abort",()=>r.abort(h.reason),{signal:r.signal});let a={signal:r.signal,options:i,context:s},o=(f,b=!1)=>{let{aborted:l}=r.signal,w=i.ignoreFetchAbort&&f!==void 0,F=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&f!==void 0);if(i.status&&(l&&!b?(i.status.fetchAborted=!0,i.status.fetchError=r.signal.reason,w&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),l&&!w&&!b)return y(r.signal.reason,F);let m=c,p=this.#t[t];return(p===c||p===void 0&&w&&b)&&(f===void 0?m.__staleWhileFetching!==void 0?this.#t[t]=m.__staleWhileFetching:this.#E(e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.#W(e,f,a.options,m))),f},d=f=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=f),y(f,!1)),y=(f,b)=>{let{aborted:l}=r.signal,w=l&&i.allowStaleOnFetchAbort,F=w||i.allowStaleOnFetchRejection,m=F||i.noDeleteOnFetchRejection,p=c;if(this.#t[t]===c&&(!m||!b&&p.__staleWhileFetching===void 0?this.#E(e,"fetch"):w||(this.#t[t]=p.__staleWhileFetching)),F)return i.status&&p.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),p.__staleWhileFetching;if(p.__returned===p)throw f},_=(f,b)=>{let l=this.#M?.(e,n,a);r.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(f(void 0),i.allowStaleOnFetchAbort&&(f=w=>o(w,!0)))}),l&&l instanceof Promise?l.then(w=>f(w===void 0?void 0:w),b):l!==void 0&&f(l)};i.status&&(i.status.fetchDispatched=!0);let c=new Promise(_).then(o,d),g=Object.assign(c,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return t===void 0?(this.#W(e,g,{...a.options,status:void 0}),t=this.#s.get(e)):this.#t[t]=g,g}#e(e){if(!this.#U)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController}fetch(e,t={}){let i=W.hasSubscribers,{status:s=D()?{}:void 0}=t;t.status=s,s&&t.context&&(s.context=t.context);let n=this.#B(e,t);return s&&i&&(s.trace=!0,W.tracePromise(()=>n,s).catch(()=>{})),n}async#B(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:a=0,sizeCalculation:o=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:y=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:c=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:f,forceRefresh:b=!1,status:l,signal:w}=t;if(l&&(l.op="fetch",l.key=e,b&&(l.forceRefresh=!0),l.cache=this),!this.#U)return l&&(l.fetch="get"),this.#C(e,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:l});let F={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:h,size:a,sizeCalculation:o,noUpdateTTL:d,noDeleteOnFetchRejection:y,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:g,ignoreFetchAbort:c,status:l,signal:w},m=this.#s.get(e);if(m===void 0){l&&(l.fetch="miss");let p=this.#P(e,m,F,f);return p.__returned=p}else{let p=this.#t[m];if(this.#e(p)){let v=i&&p.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",v&&(l.returnedStale=!0)),v?p.__staleWhileFetching:p.__returned=p}let A=this.#p(m);if(!b&&!A)return l&&(l.fetch="hit"),this.#L(m),s&&this.#D(m),l&&this.#v(l,m),p;let z=this.#P(e,m,F,f),E=z.__staleWhileFetching!==void 0&&i;return l&&(l.fetch=A?"stale":"refresh",E&&A&&(l.returnedStale=!0)),E?z.__staleWhileFetching:z.__returned=z}}forceFetch(e,t={}){let i=W.hasSubscribers,{status:s=D()?{}:void 0}=t;t.status=s,s&&t.context&&(s.context=t.context);let n=this.#K(e,t);return s&&i&&(s.trace=!0,W.tracePromise(()=>n,s).catch(()=>{})),n}async#K(e,t={}){let i=await this.#B(e,t);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,t={}){let{status:i=S.hasSubscribers?{}:void 0}=t;t.status=i,i&&(i.op="memo",i.key=e,t.context&&(i.context=t.context),i.cache=this);let s=this.#Q(e,t);return i&&(i.value=s),S.hasSubscribers&&S.publish(i),s}#Q(e,t={}){let i=this.#I;if(!i)throw new Error("no memoMethod provided to constructor");let{context:s,status:n,forceRefresh:r,...h}=t;n&&r&&(n.forceRefresh=!0);let a=this.#C(e,h),o=r||a===void 0;if(n&&(n.memo=o?"miss":"hit",o||(n.value=a)),!o)return a;let d=i(e,a,{options:h,context:s});return n&&(n.value=d),this.#W(e,d,h),d}get(e,t={}){let{status:i=S.hasSubscribers?{}:void 0}=t;t.status=i,i&&(i.op="get",i.key=e,i.cache=this);let s=this.#C(e,t);return i&&(s!==void 0&&(i.value=s),S.hasSubscribers&&S.publish(i)),s}#C(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=t,h=this.#s.get(e);if(h===void 0){r&&(r.get="miss");return}let a=this.#t[h],o=this.#e(a);return r&&this.#v(r,h),this.#p(h)?o?(r&&(r.get="stale-fetching"),i&&a.__staleWhileFetching!==void 0?(r&&(r.returnedStale=!0),a.__staleWhileFetching):void 0):(n||this.#E(e,"expire"),r&&(r.get="stale"),i?(r&&(r.returnedStale=!0),a):void 0):(r&&(r.get=o?"fetching":"hit"),this.#L(h),s&&this.#D(h),o?a.__staleWhileFetching:a)}#$(e,t){this.#u[t]=e,this.#l[e]=t}#L(e){e!==this.#h&&(e===this.#a?this.#a=this.#l[e]:this.#$(this.#u[e],this.#l[e]),this.#$(this.#h,e),this.#h=e)}delete(e){return this.#E(e,"delete")}#E(e,t){S.hasSubscribers&&S.publish({op:"delete",delete:t,key:e,cache:this});let i=!1;if(this.#n!==0){let s=this.#s.get(e);if(s!==void 0)if(this.#g?.[s]&&(clearTimeout(this.#g?.[s]),this.#g[s]=void 0),i=!0,this.#n===1)this.#q(t);else{this.#R(s);let n=this.#t[s];if(this.#e(n)?n.__abortController.abort(new Error("deleted")):(this.#T||this.#f)&&(this.#T&&this.#S?.(n,e,t),this.#f&&this.#r?.push([n,e,t])),this.#s.delete(e),this.#i[s]=void 0,this.#t[s]=void 0,s===this.#h)this.#h=this.#u[s];else if(s===this.#a)this.#a=this.#l[s];else{let r=this.#u[s];this.#l[r]=this.#l[s];let h=this.#l[s];this.#u[h]=this.#u[s]}this.#n--,this.#y.push(s)}}if(this.#f&&this.#r?.length){let s=this.#r,n;for(;n=s?.shift();)this.#w?.(...n)}return i}clear(){return this.#q("delete")}#q(e){for(let t of this.#z({allowStale:!0})){let i=this.#t[t];if(this.#e(i))i.__abortController.abort(new Error("deleted"));else{let s=this.#i[t];this.#T&&this.#S?.(i,s,e),this.#f&&this.#r?.push([i,s,e])}}if(this.#s.clear(),this.#t.fill(void 0),this.#i.fill(void 0),this.#d&&this.#F){this.#d.fill(0),this.#F.fill(0);for(let t of this.#g??[])t!==void 0&&clearTimeout(t);this.#g?.fill(void 0)}if(this.#_&&this.#_.fill(0),this.#a=0,this.#h=0,this.#y.length=0,this.#b=0,this.#n=0,this.#f&&this.#r){let t=this.#r,i;for(;i=t?.shift();)this.#w?.(...i)}}};
|
|
11967
|
+
//# sourceMappingURL=index.min.js.map
|
|
11968
|
+
|
|
13191
11969
|
// EXTERNAL MODULE: external "node:path"
|
|
13192
11970
|
var external_node_path_ = __webpack_require__(6760);
|
|
13193
11971
|
// EXTERNAL MODULE: external "fs"
|
|
@@ -13326,7 +12104,7 @@ class PipeProxyErrors extends Pipe {
|
|
|
13326
12104
|
}
|
|
13327
12105
|
constructor(src, dest, opts) {
|
|
13328
12106
|
super(src, dest, opts);
|
|
13329
|
-
this.proxyErrors = er => dest.emit('error', er);
|
|
12107
|
+
this.proxyErrors = (er) => this.dest.emit('error', er);
|
|
13330
12108
|
src.on('error', this.proxyErrors);
|
|
13331
12109
|
}
|
|
13332
12110
|
}
|
|
@@ -14136,6 +12914,7 @@ class Minipass extends external_node_events_.EventEmitter {
|
|
|
14136
12914
|
[Symbol.asyncIterator]() {
|
|
14137
12915
|
return this;
|
|
14138
12916
|
},
|
|
12917
|
+
[Symbol.asyncDispose]: async () => { },
|
|
14139
12918
|
};
|
|
14140
12919
|
}
|
|
14141
12920
|
/**
|
|
@@ -14173,6 +12952,7 @@ class Minipass extends external_node_events_.EventEmitter {
|
|
|
14173
12952
|
[Symbol.iterator]() {
|
|
14174
12953
|
return this;
|
|
14175
12954
|
},
|
|
12955
|
+
[Symbol.dispose]: () => { },
|
|
14176
12956
|
};
|
|
14177
12957
|
}
|
|
14178
12958
|
/**
|
|
@@ -14298,7 +13078,7 @@ const entToType = (s) => s.isFile() ? IFREG
|
|
|
14298
13078
|
: s.isFIFO() ? IFIFO
|
|
14299
13079
|
: UNKNOWN;
|
|
14300
13080
|
// normalize unicode path names
|
|
14301
|
-
const normalizeCache = new
|
|
13081
|
+
const normalizeCache = new I({ max: 2 ** 12 });
|
|
14302
13082
|
const normalize = (s) => {
|
|
14303
13083
|
const c = normalizeCache.get(s);
|
|
14304
13084
|
if (c)
|
|
@@ -14307,7 +13087,7 @@ const normalize = (s) => {
|
|
|
14307
13087
|
normalizeCache.set(s, n);
|
|
14308
13088
|
return n;
|
|
14309
13089
|
};
|
|
14310
|
-
const normalizeNocaseCache = new
|
|
13090
|
+
const normalizeNocaseCache = new I({ max: 2 ** 12 });
|
|
14311
13091
|
const normalizeNocase = (s) => {
|
|
14312
13092
|
const c = normalizeNocaseCache.get(s);
|
|
14313
13093
|
if (c)
|
|
@@ -14320,7 +13100,7 @@ const normalizeNocase = (s) => {
|
|
|
14320
13100
|
* An LRUCache for storing resolved path strings or Path objects.
|
|
14321
13101
|
* @internal
|
|
14322
13102
|
*/
|
|
14323
|
-
class ResolveCache extends
|
|
13103
|
+
class ResolveCache extends I {
|
|
14324
13104
|
constructor() {
|
|
14325
13105
|
super({ max: 256 });
|
|
14326
13106
|
}
|
|
@@ -14340,7 +13120,7 @@ class ResolveCache extends LRUCache {
|
|
|
14340
13120
|
* an LRUCache for storing child entries.
|
|
14341
13121
|
* @internal
|
|
14342
13122
|
*/
|
|
14343
|
-
class ChildrenCache extends
|
|
13123
|
+
class ChildrenCache extends I {
|
|
14344
13124
|
constructor(maxSize = 16 * 1024) {
|
|
14345
13125
|
super({
|
|
14346
13126
|
maxSize,
|