@midscene/cli 1.8.8-beta-20260602094353.0 → 1.8.8
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/es/index.mjs +1066 -1162
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/index.js +1068 -1163
- package/dist/lib/index.js.map +1 -1
- package/package.json +7 -7
package/dist/es/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { createReportCliCommands } from "@midscene/core";
|
|
|
4
4
|
import { runToolsCLI } from "@midscene/shared/cli";
|
|
5
5
|
import { getDebug } from "@midscene/shared/logger";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
-
import { channel, tracingChannel } from "node:diagnostics_channel";
|
|
8
7
|
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
9
8
|
import { EventEmitter } from "node:events";
|
|
10
9
|
import node_stream from "node:stream";
|
|
@@ -293,6 +292,199 @@ var __webpack_modules__ = {
|
|
|
293
292
|
get: assembleStyles
|
|
294
293
|
});
|
|
295
294
|
},
|
|
295
|
+
"../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js" (module) {
|
|
296
|
+
module.exports = balanced;
|
|
297
|
+
function balanced(a, b, str) {
|
|
298
|
+
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
299
|
+
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
300
|
+
var r = range(a, b, str);
|
|
301
|
+
return r && {
|
|
302
|
+
start: r[0],
|
|
303
|
+
end: r[1],
|
|
304
|
+
pre: str.slice(0, r[0]),
|
|
305
|
+
body: str.slice(r[0] + a.length, r[1]),
|
|
306
|
+
post: str.slice(r[1] + b.length)
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function maybeMatch(reg, str) {
|
|
310
|
+
var m = str.match(reg);
|
|
311
|
+
return m ? m[0] : null;
|
|
312
|
+
}
|
|
313
|
+
balanced.range = range;
|
|
314
|
+
function range(a, b, str) {
|
|
315
|
+
var begs, beg, left, right, result;
|
|
316
|
+
var ai = str.indexOf(a);
|
|
317
|
+
var bi = str.indexOf(b, ai + 1);
|
|
318
|
+
var i = ai;
|
|
319
|
+
if (ai >= 0 && bi > 0) {
|
|
320
|
+
if (a === b) return [
|
|
321
|
+
ai,
|
|
322
|
+
bi
|
|
323
|
+
];
|
|
324
|
+
begs = [];
|
|
325
|
+
left = str.length;
|
|
326
|
+
while(i >= 0 && !result){
|
|
327
|
+
if (i == ai) {
|
|
328
|
+
begs.push(i);
|
|
329
|
+
ai = str.indexOf(a, i + 1);
|
|
330
|
+
} else if (1 == begs.length) result = [
|
|
331
|
+
begs.pop(),
|
|
332
|
+
bi
|
|
333
|
+
];
|
|
334
|
+
else {
|
|
335
|
+
beg = begs.pop();
|
|
336
|
+
if (beg < left) {
|
|
337
|
+
left = beg;
|
|
338
|
+
right = bi;
|
|
339
|
+
}
|
|
340
|
+
bi = str.indexOf(b, i + 1);
|
|
341
|
+
}
|
|
342
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
343
|
+
}
|
|
344
|
+
if (begs.length) result = [
|
|
345
|
+
left,
|
|
346
|
+
right
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
"../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
353
|
+
var balanced = __webpack_require__("../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js");
|
|
354
|
+
module.exports = expandTop;
|
|
355
|
+
var escSlash = '\0SLASH' + Math.random() + '\0';
|
|
356
|
+
var escOpen = '\0OPEN' + Math.random() + '\0';
|
|
357
|
+
var escClose = '\0CLOSE' + Math.random() + '\0';
|
|
358
|
+
var escComma = '\0COMMA' + Math.random() + '\0';
|
|
359
|
+
var escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
360
|
+
function numeric(str) {
|
|
361
|
+
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
362
|
+
}
|
|
363
|
+
function escapeBraces(str) {
|
|
364
|
+
return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
|
|
365
|
+
}
|
|
366
|
+
function unescapeBraces(str) {
|
|
367
|
+
return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
|
|
368
|
+
}
|
|
369
|
+
function parseCommaParts(str) {
|
|
370
|
+
if (!str) return [
|
|
371
|
+
''
|
|
372
|
+
];
|
|
373
|
+
var parts = [];
|
|
374
|
+
var m = balanced('{', '}', str);
|
|
375
|
+
if (!m) return str.split(',');
|
|
376
|
+
var pre = m.pre;
|
|
377
|
+
var body = m.body;
|
|
378
|
+
var post = m.post;
|
|
379
|
+
var p = pre.split(',');
|
|
380
|
+
p[p.length - 1] += '{' + body + '}';
|
|
381
|
+
var postParts = parseCommaParts(post);
|
|
382
|
+
if (post.length) {
|
|
383
|
+
p[p.length - 1] += postParts.shift();
|
|
384
|
+
p.push.apply(p, postParts);
|
|
385
|
+
}
|
|
386
|
+
parts.push.apply(parts, p);
|
|
387
|
+
return parts;
|
|
388
|
+
}
|
|
389
|
+
function expandTop(str) {
|
|
390
|
+
if (!str) return [];
|
|
391
|
+
if ('{}' === str.substr(0, 2)) str = '\\{\\}' + str.substr(2);
|
|
392
|
+
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
393
|
+
}
|
|
394
|
+
function embrace(str) {
|
|
395
|
+
return '{' + str + '}';
|
|
396
|
+
}
|
|
397
|
+
function isPadded(el) {
|
|
398
|
+
return /^-?0\d/.test(el);
|
|
399
|
+
}
|
|
400
|
+
function lte(i, y) {
|
|
401
|
+
return i <= y;
|
|
402
|
+
}
|
|
403
|
+
function gte(i, y) {
|
|
404
|
+
return i >= y;
|
|
405
|
+
}
|
|
406
|
+
function expand(str, isTop) {
|
|
407
|
+
var expansions = [];
|
|
408
|
+
var m = balanced('{', '}', str);
|
|
409
|
+
if (!m) return [
|
|
410
|
+
str
|
|
411
|
+
];
|
|
412
|
+
var pre = m.pre;
|
|
413
|
+
var post = m.post.length ? expand(m.post, false) : [
|
|
414
|
+
''
|
|
415
|
+
];
|
|
416
|
+
if (/\$$/.test(m.pre)) for(var k = 0; k < post.length; k++){
|
|
417
|
+
var expansion = pre + '{' + m.body + '}' + post[k];
|
|
418
|
+
expansions.push(expansion);
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
422
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
423
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
424
|
+
var isOptions = m.body.indexOf(',') >= 0;
|
|
425
|
+
if (!isSequence && !isOptions) {
|
|
426
|
+
if (m.post.match(/,.*\}/)) {
|
|
427
|
+
str = m.pre + '{' + m.body + escClose + m.post;
|
|
428
|
+
return expand(str);
|
|
429
|
+
}
|
|
430
|
+
return [
|
|
431
|
+
str
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
var n;
|
|
435
|
+
if (isSequence) n = m.body.split(/\.\./);
|
|
436
|
+
else {
|
|
437
|
+
n = parseCommaParts(m.body);
|
|
438
|
+
if (1 === n.length) {
|
|
439
|
+
n = expand(n[0], false).map(embrace);
|
|
440
|
+
if (1 === n.length) return post.map(function(p) {
|
|
441
|
+
return m.pre + n[0] + p;
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
var N;
|
|
446
|
+
if (isSequence) {
|
|
447
|
+
var x = numeric(n[0]);
|
|
448
|
+
var y = numeric(n[1]);
|
|
449
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
450
|
+
var incr = 3 == n.length ? Math.abs(numeric(n[2])) : 1;
|
|
451
|
+
var test = lte;
|
|
452
|
+
var reverse = y < x;
|
|
453
|
+
if (reverse) {
|
|
454
|
+
incr *= -1;
|
|
455
|
+
test = gte;
|
|
456
|
+
}
|
|
457
|
+
var pad = n.some(isPadded);
|
|
458
|
+
N = [];
|
|
459
|
+
for(var i = x; test(i, y); i += incr){
|
|
460
|
+
var c;
|
|
461
|
+
if (isAlphaSequence) {
|
|
462
|
+
c = String.fromCharCode(i);
|
|
463
|
+
if ('\\' === c) c = '';
|
|
464
|
+
} else {
|
|
465
|
+
c = String(i);
|
|
466
|
+
if (pad) {
|
|
467
|
+
var need = width - c.length;
|
|
468
|
+
if (need > 0) {
|
|
469
|
+
var z = new Array(need + 1).join('0');
|
|
470
|
+
c = i < 0 ? '-' + z + c.slice(1) : z + c;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
N.push(c);
|
|
475
|
+
}
|
|
476
|
+
} else {
|
|
477
|
+
N = [];
|
|
478
|
+
for(var j = 0; j < n.length; j++)N.push.apply(N, expand(n[j], false));
|
|
479
|
+
}
|
|
480
|
+
for(var j = 0; j < N.length; j++)for(var k = 0; k < post.length; k++){
|
|
481
|
+
var expansion = pre + N[j] + post[k];
|
|
482
|
+
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return expansions;
|
|
486
|
+
}
|
|
487
|
+
},
|
|
296
488
|
"../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
297
489
|
const ansiStyles = __webpack_require__("../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js");
|
|
298
490
|
const { stdout: stdoutColor, stderr: stderrColor } = __webpack_require__("../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js");
|
|
@@ -2834,202 +3026,10 @@ var __webpack_modules__ = {
|
|
|
2834
3026
|
"./src/index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
2835
3027
|
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
2836
3028
|
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
2837
|
-
var package_namespaceObject =
|
|
2838
|
-
|
|
2839
|
-
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
2840
|
-
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
2841
|
-
const r = null !== ma && null != mb && range(ma, mb, str);
|
|
2842
|
-
return r && {
|
|
2843
|
-
start: r[0],
|
|
2844
|
-
end: r[1],
|
|
2845
|
-
pre: str.slice(0, r[0]),
|
|
2846
|
-
body: str.slice(r[0] + ma.length, r[1]),
|
|
2847
|
-
post: str.slice(r[1] + mb.length)
|
|
2848
|
-
};
|
|
2849
|
-
};
|
|
2850
|
-
const maybeMatch = (reg, str)=>{
|
|
2851
|
-
const m = str.match(reg);
|
|
2852
|
-
return m ? m[0] : null;
|
|
2853
|
-
};
|
|
2854
|
-
const range = (a, b, str)=>{
|
|
2855
|
-
let begs, beg, left, right, result;
|
|
2856
|
-
let ai = str.indexOf(a);
|
|
2857
|
-
let bi = str.indexOf(b, ai + 1);
|
|
2858
|
-
let i = ai;
|
|
2859
|
-
if (ai >= 0 && bi > 0) {
|
|
2860
|
-
if (a === b) return [
|
|
2861
|
-
ai,
|
|
2862
|
-
bi
|
|
2863
|
-
];
|
|
2864
|
-
begs = [];
|
|
2865
|
-
left = str.length;
|
|
2866
|
-
while(i >= 0 && !result){
|
|
2867
|
-
if (i === ai) {
|
|
2868
|
-
begs.push(i);
|
|
2869
|
-
ai = str.indexOf(a, i + 1);
|
|
2870
|
-
} else if (1 === begs.length) {
|
|
2871
|
-
const r = begs.pop();
|
|
2872
|
-
if (void 0 !== r) result = [
|
|
2873
|
-
r,
|
|
2874
|
-
bi
|
|
2875
|
-
];
|
|
2876
|
-
} else {
|
|
2877
|
-
beg = begs.pop();
|
|
2878
|
-
if (void 0 !== beg && beg < left) {
|
|
2879
|
-
left = beg;
|
|
2880
|
-
right = bi;
|
|
2881
|
-
}
|
|
2882
|
-
bi = str.indexOf(b, i + 1);
|
|
2883
|
-
}
|
|
2884
|
-
i = ai < bi && ai >= 0 ? ai : bi;
|
|
2885
|
-
}
|
|
2886
|
-
if (begs.length && void 0 !== right) result = [
|
|
2887
|
-
left,
|
|
2888
|
-
right
|
|
2889
|
-
];
|
|
2890
|
-
}
|
|
2891
|
-
return result;
|
|
3029
|
+
var package_namespaceObject = {
|
|
3030
|
+
rE: "1.8.8"
|
|
2892
3031
|
};
|
|
2893
|
-
|
|
2894
|
-
const escOpen = '\0OPEN' + Math.random() + '\0';
|
|
2895
|
-
const escClose = '\0CLOSE' + Math.random() + '\0';
|
|
2896
|
-
const escComma = '\0COMMA' + Math.random() + '\0';
|
|
2897
|
-
const escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
2898
|
-
const escSlashPattern = new RegExp(escSlash, 'g');
|
|
2899
|
-
const escOpenPattern = new RegExp(escOpen, 'g');
|
|
2900
|
-
const escClosePattern = new RegExp(escClose, 'g');
|
|
2901
|
-
const escCommaPattern = new RegExp(escComma, 'g');
|
|
2902
|
-
const escPeriodPattern = new RegExp(escPeriod, 'g');
|
|
2903
|
-
const slashPattern = /\\\\/g;
|
|
2904
|
-
const openPattern = /\\{/g;
|
|
2905
|
-
const closePattern = /\\}/g;
|
|
2906
|
-
const commaPattern = /\\,/g;
|
|
2907
|
-
const periodPattern = /\\\./g;
|
|
2908
|
-
const EXPANSION_MAX = 100000;
|
|
2909
|
-
function numeric(str) {
|
|
2910
|
-
return isNaN(str) ? str.charCodeAt(0) : parseInt(str, 10);
|
|
2911
|
-
}
|
|
2912
|
-
function escapeBraces(str) {
|
|
2913
|
-
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
2914
|
-
}
|
|
2915
|
-
function unescapeBraces(str) {
|
|
2916
|
-
return str.replace(escSlashPattern, '\\').replace(escOpenPattern, '{').replace(escClosePattern, '}').replace(escCommaPattern, ',').replace(escPeriodPattern, '.');
|
|
2917
|
-
}
|
|
2918
|
-
function parseCommaParts(str) {
|
|
2919
|
-
if (!str) return [
|
|
2920
|
-
''
|
|
2921
|
-
];
|
|
2922
|
-
const parts = [];
|
|
2923
|
-
const m = balanced('{', '}', str);
|
|
2924
|
-
if (!m) return str.split(',');
|
|
2925
|
-
const { pre, body, post } = m;
|
|
2926
|
-
const p = pre.split(',');
|
|
2927
|
-
p[p.length - 1] += '{' + body + '}';
|
|
2928
|
-
const postParts = parseCommaParts(post);
|
|
2929
|
-
if (post.length) {
|
|
2930
|
-
p[p.length - 1] += postParts.shift();
|
|
2931
|
-
p.push.apply(p, postParts);
|
|
2932
|
-
}
|
|
2933
|
-
parts.push.apply(parts, p);
|
|
2934
|
-
return parts;
|
|
2935
|
-
}
|
|
2936
|
-
function expand(str, options = {}) {
|
|
2937
|
-
if (!str) return [];
|
|
2938
|
-
const { max = EXPANSION_MAX } = options;
|
|
2939
|
-
if ('{}' === str.slice(0, 2)) str = '\\{\\}' + str.slice(2);
|
|
2940
|
-
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
2941
|
-
}
|
|
2942
|
-
function embrace(str) {
|
|
2943
|
-
return '{' + str + '}';
|
|
2944
|
-
}
|
|
2945
|
-
function isPadded(el) {
|
|
2946
|
-
return /^-?0\d/.test(el);
|
|
2947
|
-
}
|
|
2948
|
-
function lte(i, y) {
|
|
2949
|
-
return i <= y;
|
|
2950
|
-
}
|
|
2951
|
-
function gte(i, y) {
|
|
2952
|
-
return i >= y;
|
|
2953
|
-
}
|
|
2954
|
-
function expand_(str, max, isTop) {
|
|
2955
|
-
const expansions = [];
|
|
2956
|
-
const m = balanced('{', '}', str);
|
|
2957
|
-
if (!m) return [
|
|
2958
|
-
str
|
|
2959
|
-
];
|
|
2960
|
-
const pre = m.pre;
|
|
2961
|
-
const post = m.post.length ? expand_(m.post, max, false) : [
|
|
2962
|
-
''
|
|
2963
|
-
];
|
|
2964
|
-
if (/\$$/.test(m.pre)) for(let k = 0; k < post.length && k < max; k++){
|
|
2965
|
-
const expansion = pre + '{' + m.body + '}' + post[k];
|
|
2966
|
-
expansions.push(expansion);
|
|
2967
|
-
}
|
|
2968
|
-
else {
|
|
2969
|
-
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
2970
|
-
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
2971
|
-
const isSequence = isNumericSequence || isAlphaSequence;
|
|
2972
|
-
const isOptions = m.body.indexOf(',') >= 0;
|
|
2973
|
-
if (!isSequence && !isOptions) {
|
|
2974
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
2975
|
-
str = m.pre + '{' + m.body + escClose + m.post;
|
|
2976
|
-
return expand_(str, max, true);
|
|
2977
|
-
}
|
|
2978
|
-
return [
|
|
2979
|
-
str
|
|
2980
|
-
];
|
|
2981
|
-
}
|
|
2982
|
-
let n;
|
|
2983
|
-
if (isSequence) n = m.body.split(/\.\./);
|
|
2984
|
-
else {
|
|
2985
|
-
n = parseCommaParts(m.body);
|
|
2986
|
-
if (1 === n.length && void 0 !== n[0]) {
|
|
2987
|
-
n = expand_(n[0], max, false).map(embrace);
|
|
2988
|
-
if (1 === n.length) return post.map((p)=>m.pre + n[0] + p);
|
|
2989
|
-
}
|
|
2990
|
-
}
|
|
2991
|
-
let N;
|
|
2992
|
-
if (isSequence && void 0 !== n[0] && void 0 !== n[1]) {
|
|
2993
|
-
const x = numeric(n[0]);
|
|
2994
|
-
const y = numeric(n[1]);
|
|
2995
|
-
const width = Math.max(n[0].length, n[1].length);
|
|
2996
|
-
let incr = 3 === n.length && void 0 !== n[2] ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
2997
|
-
let test = lte;
|
|
2998
|
-
const reverse = y < x;
|
|
2999
|
-
if (reverse) {
|
|
3000
|
-
incr *= -1;
|
|
3001
|
-
test = gte;
|
|
3002
|
-
}
|
|
3003
|
-
const pad = n.some(isPadded);
|
|
3004
|
-
N = [];
|
|
3005
|
-
for(let i = x; test(i, y); i += incr){
|
|
3006
|
-
let c;
|
|
3007
|
-
if (isAlphaSequence) {
|
|
3008
|
-
c = String.fromCharCode(i);
|
|
3009
|
-
if ('\\' === c) c = '';
|
|
3010
|
-
} else {
|
|
3011
|
-
c = String(i);
|
|
3012
|
-
if (pad) {
|
|
3013
|
-
const need = width - c.length;
|
|
3014
|
-
if (need > 0) {
|
|
3015
|
-
const z = new Array(need + 1).join('0');
|
|
3016
|
-
c = i < 0 ? '-' + z + c.slice(1) : z + c;
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
N.push(c);
|
|
3021
|
-
}
|
|
3022
|
-
} else {
|
|
3023
|
-
N = [];
|
|
3024
|
-
for(let j = 0; j < n.length; j++)N.push.apply(N, expand_(n[j], max, false));
|
|
3025
|
-
}
|
|
3026
|
-
for(let j = 0; j < N.length; j++)for(let k = 0; k < post.length && expansions.length < max; k++){
|
|
3027
|
-
const expansion = pre + N[j] + post[k];
|
|
3028
|
-
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
3029
|
-
}
|
|
3030
|
-
}
|
|
3031
|
-
return expansions;
|
|
3032
|
-
}
|
|
3032
|
+
var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
|
|
3033
3033
|
const MAX_PATTERN_LENGTH = 65536;
|
|
3034
3034
|
const assertValidPattern = (pattern)=>{
|
|
3035
3035
|
if ('string' != typeof pattern) throw new TypeError('invalid pattern');
|
|
@@ -3195,11 +3195,7 @@ var __webpack_modules__ = {
|
|
|
3195
3195
|
true
|
|
3196
3196
|
];
|
|
3197
3197
|
};
|
|
3198
|
-
const unescape_unescape = (s, { windowsPathsNoEscape = false
|
|
3199
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2').replace(/\\([^/])/g, '$1');
|
|
3200
|
-
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2').replace(/\\([^/{}])/g, '$1');
|
|
3201
|
-
};
|
|
3202
|
-
var ast_a;
|
|
3198
|
+
const unescape_unescape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1');
|
|
3203
3199
|
const types = new Set([
|
|
3204
3200
|
'!',
|
|
3205
3201
|
'?',
|
|
@@ -3208,168 +3204,6 @@ var __webpack_modules__ = {
|
|
|
3208
3204
|
'@'
|
|
3209
3205
|
]);
|
|
3210
3206
|
const isExtglobType = (c)=>types.has(c);
|
|
3211
|
-
const isExtglobAST = (c)=>isExtglobType(c.type);
|
|
3212
|
-
const adoptionMap = new Map([
|
|
3213
|
-
[
|
|
3214
|
-
'!',
|
|
3215
|
-
[
|
|
3216
|
-
'@'
|
|
3217
|
-
]
|
|
3218
|
-
],
|
|
3219
|
-
[
|
|
3220
|
-
'?',
|
|
3221
|
-
[
|
|
3222
|
-
'?',
|
|
3223
|
-
'@'
|
|
3224
|
-
]
|
|
3225
|
-
],
|
|
3226
|
-
[
|
|
3227
|
-
'@',
|
|
3228
|
-
[
|
|
3229
|
-
'@'
|
|
3230
|
-
]
|
|
3231
|
-
],
|
|
3232
|
-
[
|
|
3233
|
-
'*',
|
|
3234
|
-
[
|
|
3235
|
-
'*',
|
|
3236
|
-
'+',
|
|
3237
|
-
'?',
|
|
3238
|
-
'@'
|
|
3239
|
-
]
|
|
3240
|
-
],
|
|
3241
|
-
[
|
|
3242
|
-
'+',
|
|
3243
|
-
[
|
|
3244
|
-
'+',
|
|
3245
|
-
'@'
|
|
3246
|
-
]
|
|
3247
|
-
]
|
|
3248
|
-
]);
|
|
3249
|
-
const adoptionWithSpaceMap = new Map([
|
|
3250
|
-
[
|
|
3251
|
-
'!',
|
|
3252
|
-
[
|
|
3253
|
-
'?'
|
|
3254
|
-
]
|
|
3255
|
-
],
|
|
3256
|
-
[
|
|
3257
|
-
'@',
|
|
3258
|
-
[
|
|
3259
|
-
'?'
|
|
3260
|
-
]
|
|
3261
|
-
],
|
|
3262
|
-
[
|
|
3263
|
-
'+',
|
|
3264
|
-
[
|
|
3265
|
-
'?',
|
|
3266
|
-
'*'
|
|
3267
|
-
]
|
|
3268
|
-
]
|
|
3269
|
-
]);
|
|
3270
|
-
const adoptionAnyMap = new Map([
|
|
3271
|
-
[
|
|
3272
|
-
'!',
|
|
3273
|
-
[
|
|
3274
|
-
'?',
|
|
3275
|
-
'@'
|
|
3276
|
-
]
|
|
3277
|
-
],
|
|
3278
|
-
[
|
|
3279
|
-
'?',
|
|
3280
|
-
[
|
|
3281
|
-
'?',
|
|
3282
|
-
'@'
|
|
3283
|
-
]
|
|
3284
|
-
],
|
|
3285
|
-
[
|
|
3286
|
-
'@',
|
|
3287
|
-
[
|
|
3288
|
-
'?',
|
|
3289
|
-
'@'
|
|
3290
|
-
]
|
|
3291
|
-
],
|
|
3292
|
-
[
|
|
3293
|
-
'*',
|
|
3294
|
-
[
|
|
3295
|
-
'*',
|
|
3296
|
-
'+',
|
|
3297
|
-
'?',
|
|
3298
|
-
'@'
|
|
3299
|
-
]
|
|
3300
|
-
],
|
|
3301
|
-
[
|
|
3302
|
-
'+',
|
|
3303
|
-
[
|
|
3304
|
-
'+',
|
|
3305
|
-
'@',
|
|
3306
|
-
'?',
|
|
3307
|
-
'*'
|
|
3308
|
-
]
|
|
3309
|
-
]
|
|
3310
|
-
]);
|
|
3311
|
-
const usurpMap = new Map([
|
|
3312
|
-
[
|
|
3313
|
-
'!',
|
|
3314
|
-
new Map([
|
|
3315
|
-
[
|
|
3316
|
-
'!',
|
|
3317
|
-
'@'
|
|
3318
|
-
]
|
|
3319
|
-
])
|
|
3320
|
-
],
|
|
3321
|
-
[
|
|
3322
|
-
'?',
|
|
3323
|
-
new Map([
|
|
3324
|
-
[
|
|
3325
|
-
'*',
|
|
3326
|
-
'*'
|
|
3327
|
-
],
|
|
3328
|
-
[
|
|
3329
|
-
'+',
|
|
3330
|
-
'*'
|
|
3331
|
-
]
|
|
3332
|
-
])
|
|
3333
|
-
],
|
|
3334
|
-
[
|
|
3335
|
-
'@',
|
|
3336
|
-
new Map([
|
|
3337
|
-
[
|
|
3338
|
-
'!',
|
|
3339
|
-
'!'
|
|
3340
|
-
],
|
|
3341
|
-
[
|
|
3342
|
-
'?',
|
|
3343
|
-
'?'
|
|
3344
|
-
],
|
|
3345
|
-
[
|
|
3346
|
-
'@',
|
|
3347
|
-
'@'
|
|
3348
|
-
],
|
|
3349
|
-
[
|
|
3350
|
-
'*',
|
|
3351
|
-
'*'
|
|
3352
|
-
],
|
|
3353
|
-
[
|
|
3354
|
-
'+',
|
|
3355
|
-
'+'
|
|
3356
|
-
]
|
|
3357
|
-
])
|
|
3358
|
-
],
|
|
3359
|
-
[
|
|
3360
|
-
'+',
|
|
3361
|
-
new Map([
|
|
3362
|
-
[
|
|
3363
|
-
'?',
|
|
3364
|
-
'*'
|
|
3365
|
-
],
|
|
3366
|
-
[
|
|
3367
|
-
'*',
|
|
3368
|
-
'*'
|
|
3369
|
-
]
|
|
3370
|
-
])
|
|
3371
|
-
]
|
|
3372
|
-
]);
|
|
3373
3207
|
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
|
|
3374
3208
|
const startNoDot = '(?!\\.)';
|
|
3375
3209
|
const addPatternStart = new Set([
|
|
@@ -3385,7 +3219,6 @@ var __webpack_modules__ = {
|
|
|
3385
3219
|
const qmark = '[^/]';
|
|
3386
3220
|
const star = qmark + '*?';
|
|
3387
3221
|
const starNoEmpty = qmark + '+?';
|
|
3388
|
-
let ID = 0;
|
|
3389
3222
|
class ast_AST {
|
|
3390
3223
|
type;
|
|
3391
3224
|
#root;
|
|
@@ -3399,22 +3232,6 @@ var __webpack_modules__ = {
|
|
|
3399
3232
|
#options;
|
|
3400
3233
|
#toString;
|
|
3401
3234
|
#emptyExt = false;
|
|
3402
|
-
id = ++ID;
|
|
3403
|
-
get depth() {
|
|
3404
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
3405
|
-
}
|
|
3406
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
3407
|
-
return {
|
|
3408
|
-
'@@type': 'AST',
|
|
3409
|
-
id: this.id,
|
|
3410
|
-
type: this.type,
|
|
3411
|
-
root: this.#root.id,
|
|
3412
|
-
parent: this.#parent?.id,
|
|
3413
|
-
depth: this.depth,
|
|
3414
|
-
partsLength: this.#parts.length,
|
|
3415
|
-
parts: this.#parts
|
|
3416
|
-
};
|
|
3417
|
-
}
|
|
3418
3235
|
constructor(type, parent, options = {}){
|
|
3419
3236
|
this.type = type;
|
|
3420
3237
|
if (type) this.#hasMagic = true;
|
|
@@ -3433,7 +3250,9 @@ var __webpack_modules__ = {
|
|
|
3433
3250
|
return this.#hasMagic;
|
|
3434
3251
|
}
|
|
3435
3252
|
toString() {
|
|
3436
|
-
|
|
3253
|
+
if (void 0 !== this.#toString) return this.#toString;
|
|
3254
|
+
if (!this.type) return this.#toString = this.#parts.map((p)=>String(p)).join('');
|
|
3255
|
+
return this.#toString = this.type + '(' + this.#parts.map((p)=>String(p)).join('|') + ')';
|
|
3437
3256
|
}
|
|
3438
3257
|
#fillNegs() {
|
|
3439
3258
|
if (this !== this.#root) throw new Error('should only call on root');
|
|
@@ -3458,7 +3277,7 @@ var __webpack_modules__ = {
|
|
|
3458
3277
|
}
|
|
3459
3278
|
push(...parts) {
|
|
3460
3279
|
for (const p of parts)if ('' !== p) {
|
|
3461
|
-
if ('string' != typeof p && !(p instanceof
|
|
3280
|
+
if ('string' != typeof p && !(p instanceof ast_AST && p.#parent === this)) throw new Error('invalid part: ' + p);
|
|
3462
3281
|
this.#parts.push(p);
|
|
3463
3282
|
}
|
|
3464
3283
|
}
|
|
@@ -3478,7 +3297,7 @@ var __webpack_modules__ = {
|
|
|
3478
3297
|
const p = this.#parent;
|
|
3479
3298
|
for(let i = 0; i < this.#parentIndex; i++){
|
|
3480
3299
|
const pp = p.#parts[i];
|
|
3481
|
-
if (!(pp instanceof
|
|
3300
|
+
if (!(pp instanceof ast_AST && '!' === pp.type)) return false;
|
|
3482
3301
|
}
|
|
3483
3302
|
return true;
|
|
3484
3303
|
}
|
|
@@ -3495,12 +3314,11 @@ var __webpack_modules__ = {
|
|
|
3495
3314
|
else this.push(part.clone(this));
|
|
3496
3315
|
}
|
|
3497
3316
|
clone(parent) {
|
|
3498
|
-
const c = new
|
|
3317
|
+
const c = new ast_AST(this.type, parent);
|
|
3499
3318
|
for (const p of this.#parts)c.copyIn(p);
|
|
3500
3319
|
return c;
|
|
3501
3320
|
}
|
|
3502
|
-
static #parseAST(str, ast, pos, opt
|
|
3503
|
-
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
3321
|
+
static #parseAST(str, ast, pos, opt) {
|
|
3504
3322
|
let escaping = false;
|
|
3505
3323
|
let inBrace = false;
|
|
3506
3324
|
let braceStart = -1;
|
|
@@ -3529,12 +3347,11 @@ var __webpack_modules__ = {
|
|
|
3529
3347
|
acc += c;
|
|
3530
3348
|
continue;
|
|
3531
3349
|
}
|
|
3532
|
-
|
|
3533
|
-
if (doRecurse) {
|
|
3350
|
+
if (!opt.noext && isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3534
3351
|
ast.push(acc);
|
|
3535
3352
|
acc = '';
|
|
3536
|
-
const ext = new
|
|
3537
|
-
i =
|
|
3353
|
+
const ext = new ast_AST(c, ast);
|
|
3354
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3538
3355
|
ast.push(ext);
|
|
3539
3356
|
continue;
|
|
3540
3357
|
}
|
|
@@ -3544,7 +3361,7 @@ var __webpack_modules__ = {
|
|
|
3544
3361
|
return i;
|
|
3545
3362
|
}
|
|
3546
3363
|
let i = pos + 1;
|
|
3547
|
-
let part = new
|
|
3364
|
+
let part = new ast_AST(null, ast);
|
|
3548
3365
|
const parts = [];
|
|
3549
3366
|
let acc = '';
|
|
3550
3367
|
while(i < str.length){
|
|
@@ -3568,21 +3385,19 @@ var __webpack_modules__ = {
|
|
|
3568
3385
|
acc += c;
|
|
3569
3386
|
continue;
|
|
3570
3387
|
}
|
|
3571
|
-
|
|
3572
|
-
if (doRecurse) {
|
|
3573
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
3388
|
+
if (isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3574
3389
|
part.push(acc);
|
|
3575
3390
|
acc = '';
|
|
3576
|
-
const ext = new
|
|
3391
|
+
const ext = new ast_AST(c, part);
|
|
3577
3392
|
part.push(ext);
|
|
3578
|
-
i =
|
|
3393
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3579
3394
|
continue;
|
|
3580
3395
|
}
|
|
3581
3396
|
if ('|' === c) {
|
|
3582
3397
|
part.push(acc);
|
|
3583
3398
|
acc = '';
|
|
3584
3399
|
parts.push(part);
|
|
3585
|
-
part = new
|
|
3400
|
+
part = new ast_AST(null, ast);
|
|
3586
3401
|
continue;
|
|
3587
3402
|
}
|
|
3588
3403
|
if (')' === c) {
|
|
@@ -3601,55 +3416,9 @@ var __webpack_modules__ = {
|
|
|
3601
3416
|
];
|
|
3602
3417
|
return i;
|
|
3603
3418
|
}
|
|
3604
|
-
#canAdoptWithSpace(child) {
|
|
3605
|
-
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
3606
|
-
}
|
|
3607
|
-
#canAdopt(child, map = adoptionMap) {
|
|
3608
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type) return false;
|
|
3609
|
-
const gc = child.#parts[0];
|
|
3610
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3611
|
-
return this.#canAdoptType(gc.type, map);
|
|
3612
|
-
}
|
|
3613
|
-
#canAdoptType(c, map = adoptionAnyMap) {
|
|
3614
|
-
return !!map.get(this.type)?.includes(c);
|
|
3615
|
-
}
|
|
3616
|
-
#adoptWithSpace(child, index) {
|
|
3617
|
-
const gc = child.#parts[0];
|
|
3618
|
-
const blank = new ast_a(null, gc, this.options);
|
|
3619
|
-
blank.#parts.push('');
|
|
3620
|
-
gc.push(blank);
|
|
3621
|
-
this.#adopt(child, index);
|
|
3622
|
-
}
|
|
3623
|
-
#adopt(child, index) {
|
|
3624
|
-
const gc = child.#parts[0];
|
|
3625
|
-
this.#parts.splice(index, 1, ...gc.#parts);
|
|
3626
|
-
for (const p of gc.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3627
|
-
this.#toString = void 0;
|
|
3628
|
-
}
|
|
3629
|
-
#canUsurpType(c) {
|
|
3630
|
-
const m = usurpMap.get(this.type);
|
|
3631
|
-
return !!m?.has(c);
|
|
3632
|
-
}
|
|
3633
|
-
#canUsurp(child) {
|
|
3634
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type || 1 !== this.#parts.length) return false;
|
|
3635
|
-
const gc = child.#parts[0];
|
|
3636
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3637
|
-
return this.#canUsurpType(gc.type);
|
|
3638
|
-
}
|
|
3639
|
-
#usurp(child) {
|
|
3640
|
-
const m = usurpMap.get(this.type);
|
|
3641
|
-
const gc = child.#parts[0];
|
|
3642
|
-
const nt = m?.get(gc.type);
|
|
3643
|
-
if (!nt) return false;
|
|
3644
|
-
this.#parts = gc.#parts;
|
|
3645
|
-
for (const p of this.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3646
|
-
this.type = nt;
|
|
3647
|
-
this.#toString = void 0;
|
|
3648
|
-
this.#emptyExt = false;
|
|
3649
|
-
}
|
|
3650
3419
|
static fromGlob(pattern, options = {}) {
|
|
3651
|
-
const ast = new
|
|
3652
|
-
|
|
3420
|
+
const ast = new ast_AST(null, void 0, options);
|
|
3421
|
+
ast_AST.#parseAST(pattern, ast, 0, options);
|
|
3653
3422
|
return ast;
|
|
3654
3423
|
}
|
|
3655
3424
|
toMMPattern() {
|
|
@@ -3669,14 +3438,11 @@ var __webpack_modules__ = {
|
|
|
3669
3438
|
}
|
|
3670
3439
|
toRegExpSource(allowDot) {
|
|
3671
3440
|
const dot = allowDot ?? !!this.#options.dot;
|
|
3672
|
-
if (this.#root === this)
|
|
3673
|
-
|
|
3674
|
-
this
|
|
3675
|
-
}
|
|
3676
|
-
if (!isExtglobAST(this)) {
|
|
3677
|
-
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s)=>'string' != typeof s);
|
|
3441
|
+
if (this.#root === this) this.#fillNegs();
|
|
3442
|
+
if (!this.type) {
|
|
3443
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
3678
3444
|
const src = this.#parts.map((p)=>{
|
|
3679
|
-
const [re, _, hasMagic, uflag] = 'string' == typeof p ?
|
|
3445
|
+
const [re, _, hasMagic, uflag] = 'string' == typeof p ? ast_AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
3680
3446
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
3681
3447
|
this.#uflag = this.#uflag || uflag;
|
|
3682
3448
|
return re;
|
|
@@ -3708,12 +3474,11 @@ var __webpack_modules__ = {
|
|
|
3708
3474
|
let body = this.#partsToRegExp(dot);
|
|
3709
3475
|
if (this.isStart() && this.isEnd() && !body && '!' !== this.type) {
|
|
3710
3476
|
const s = this.toString();
|
|
3711
|
-
|
|
3712
|
-
me.#parts = [
|
|
3477
|
+
this.#parts = [
|
|
3713
3478
|
s
|
|
3714
3479
|
];
|
|
3715
|
-
|
|
3716
|
-
|
|
3480
|
+
this.type = null;
|
|
3481
|
+
this.#hasMagic = void 0;
|
|
3717
3482
|
return [
|
|
3718
3483
|
s,
|
|
3719
3484
|
unescape_unescape(this.toString()),
|
|
@@ -3737,32 +3502,6 @@ var __webpack_modules__ = {
|
|
|
3737
3502
|
this.#uflag
|
|
3738
3503
|
];
|
|
3739
3504
|
}
|
|
3740
|
-
#flatten() {
|
|
3741
|
-
if (isExtglobAST(this)) {
|
|
3742
|
-
let iterations = 0;
|
|
3743
|
-
let done = false;
|
|
3744
|
-
do {
|
|
3745
|
-
done = true;
|
|
3746
|
-
for(let i = 0; i < this.#parts.length; i++){
|
|
3747
|
-
const c = this.#parts[i];
|
|
3748
|
-
if ('object' == typeof c) {
|
|
3749
|
-
c.#flatten();
|
|
3750
|
-
if (this.#canAdopt(c)) {
|
|
3751
|
-
done = false;
|
|
3752
|
-
this.#adopt(c, i);
|
|
3753
|
-
} else if (this.#canAdoptWithSpace(c)) {
|
|
3754
|
-
done = false;
|
|
3755
|
-
this.#adoptWithSpace(c, i);
|
|
3756
|
-
} else if (this.#canUsurp(c)) {
|
|
3757
|
-
done = false;
|
|
3758
|
-
this.#usurp(c);
|
|
3759
|
-
}
|
|
3760
|
-
}
|
|
3761
|
-
}
|
|
3762
|
-
}while (!done && ++iterations < 10);
|
|
3763
|
-
} else for (const p of this.#parts)if ('object' == typeof p) p.#flatten();
|
|
3764
|
-
this.#toString = void 0;
|
|
3765
|
-
}
|
|
3766
3505
|
#partsToRegExp(dot) {
|
|
3767
3506
|
return this.#parts.map((p)=>{
|
|
3768
3507
|
if ('string' == typeof p) throw new Error('string type in extglob ast??');
|
|
@@ -3775,7 +3514,6 @@ var __webpack_modules__ = {
|
|
|
3775
3514
|
let escaping = false;
|
|
3776
3515
|
let re = '';
|
|
3777
3516
|
let uflag = false;
|
|
3778
|
-
let inStar = false;
|
|
3779
3517
|
for(let i = 0; i < glob.length; i++){
|
|
3780
3518
|
const c = glob.charAt(i);
|
|
3781
3519
|
if (escaping) {
|
|
@@ -3783,14 +3521,6 @@ var __webpack_modules__ = {
|
|
|
3783
3521
|
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
3784
3522
|
continue;
|
|
3785
3523
|
}
|
|
3786
|
-
if ('*' === c) {
|
|
3787
|
-
if (inStar) continue;
|
|
3788
|
-
inStar = true;
|
|
3789
|
-
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
3790
|
-
hasMagic = true;
|
|
3791
|
-
continue;
|
|
3792
|
-
}
|
|
3793
|
-
inStar = false;
|
|
3794
3524
|
if ('\\' === c) {
|
|
3795
3525
|
if (i === glob.length - 1) re += '\\\\';
|
|
3796
3526
|
else escaping = true;
|
|
@@ -3806,6 +3536,12 @@ var __webpack_modules__ = {
|
|
|
3806
3536
|
continue;
|
|
3807
3537
|
}
|
|
3808
3538
|
}
|
|
3539
|
+
if ('*' === c) {
|
|
3540
|
+
if (noEmpty && '*' === glob) re += starNoEmpty;
|
|
3541
|
+
else re += star;
|
|
3542
|
+
hasMagic = true;
|
|
3543
|
+
continue;
|
|
3544
|
+
}
|
|
3809
3545
|
if ('?' === c) {
|
|
3810
3546
|
re += qmark;
|
|
3811
3547
|
hasMagic = true;
|
|
@@ -3821,17 +3557,13 @@ var __webpack_modules__ = {
|
|
|
3821
3557
|
];
|
|
3822
3558
|
}
|
|
3823
3559
|
}
|
|
3824
|
-
|
|
3825
|
-
const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})=>{
|
|
3826
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, '[$&]') : s.replace(/[?*()[\]\\{}]/g, '\\$&');
|
|
3827
|
-
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
3828
|
-
};
|
|
3560
|
+
const escape_escape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
3829
3561
|
const minimatch = (p, pattern, options = {})=>{
|
|
3830
3562
|
assertValidPattern(pattern);
|
|
3831
3563
|
if (!options.nocomment && '#' === pattern.charAt(0)) return false;
|
|
3832
3564
|
return new esm_Minimatch(pattern, options).match(p);
|
|
3833
3565
|
};
|
|
3834
|
-
const starDotExtRE = /^\*+([
|
|
3566
|
+
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
3835
3567
|
const starDotExtTest = (ext)=>(f)=>!f.startsWith('.') && f.endsWith(ext);
|
|
3836
3568
|
const starDotExtTestDot = (ext)=>(f)=>f.endsWith(ext);
|
|
3837
3569
|
const starDotExtTestNocase = (ext)=>{
|
|
@@ -3850,7 +3582,7 @@ var __webpack_modules__ = {
|
|
|
3850
3582
|
const starRE = /^\*+$/;
|
|
3851
3583
|
const starTest = (f)=>0 !== f.length && !f.startsWith('.');
|
|
3852
3584
|
const starTestDot = (f)=>0 !== f.length && '.' !== f && '..' !== f;
|
|
3853
|
-
const qmarksRE = /^\?+([
|
|
3585
|
+
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
3854
3586
|
const qmarksTestNocase = ([$0, ext = ''])=>{
|
|
3855
3587
|
const noext = qmarksTestNoExt([
|
|
3856
3588
|
$0
|
|
@@ -3945,9 +3677,7 @@ var __webpack_modules__ = {
|
|
|
3945
3677
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [
|
|
3946
3678
|
pattern
|
|
3947
3679
|
];
|
|
3948
|
-
return
|
|
3949
|
-
max: options.braceExpandMax
|
|
3950
|
-
});
|
|
3680
|
+
return brace_expansion(pattern);
|
|
3951
3681
|
};
|
|
3952
3682
|
minimatch.braceExpand = braceExpand;
|
|
3953
3683
|
const makeRe = (pattern, options = {})=>new esm_Minimatch(pattern, options).makeRe();
|
|
@@ -3978,18 +3708,15 @@ var __webpack_modules__ = {
|
|
|
3978
3708
|
isWindows;
|
|
3979
3709
|
platform;
|
|
3980
3710
|
windowsNoMagicRoot;
|
|
3981
|
-
maxGlobstarRecursion;
|
|
3982
3711
|
regexp;
|
|
3983
3712
|
constructor(pattern, options = {}){
|
|
3984
3713
|
assertValidPattern(pattern);
|
|
3985
3714
|
options = options || {};
|
|
3986
3715
|
this.options = options;
|
|
3987
|
-
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
3988
3716
|
this.pattern = pattern;
|
|
3989
3717
|
this.platform = options.platform || defaultPlatform;
|
|
3990
3718
|
this.isWindows = 'win32' === this.platform;
|
|
3991
|
-
|
|
3992
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options[awe];
|
|
3719
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options.allowWindowsEscape;
|
|
3993
3720
|
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, '/');
|
|
3994
3721
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
3995
3722
|
this.regexp = null;
|
|
@@ -4056,7 +3783,7 @@ var __webpack_modules__ = {
|
|
|
4056
3783
|
}
|
|
4057
3784
|
preprocess(globParts) {
|
|
4058
3785
|
if (this.options.noglobstar) {
|
|
4059
|
-
for
|
|
3786
|
+
for(let i = 0; i < globParts.length; i++)for(let j = 0; j < globParts[i].length; j++)if ('**' === globParts[i][j]) globParts[i][j] = '*';
|
|
4060
3787
|
}
|
|
4061
3788
|
const { optimizationLevel = 1 } = this.options;
|
|
4062
3789
|
if (optimizationLevel >= 2) {
|
|
@@ -4119,7 +3846,7 @@ var __webpack_modules__ = {
|
|
|
4119
3846
|
let dd = 0;
|
|
4120
3847
|
while(-1 !== (dd = parts.indexOf('..', dd + 1))){
|
|
4121
3848
|
const p = parts[dd - 1];
|
|
4122
|
-
if (p && '.' !== p && '..' !== p && '**' !== p
|
|
3849
|
+
if (p && '.' !== p && '..' !== p && '**' !== p) {
|
|
4123
3850
|
didSomething = true;
|
|
4124
3851
|
parts.splice(dd - 1, 2);
|
|
4125
3852
|
dd -= 2;
|
|
@@ -4241,8 +3968,7 @@ var __webpack_modules__ = {
|
|
|
4241
3968
|
this.negate = negate;
|
|
4242
3969
|
}
|
|
4243
3970
|
matchOne(file, pattern, partial = false) {
|
|
4244
|
-
|
|
4245
|
-
let patternStartIndex = 0;
|
|
3971
|
+
const options = this.options;
|
|
4246
3972
|
if (this.isWindows) {
|
|
4247
3973
|
const fileDrive = 'string' == typeof file[0] && /^[a-z]:$/i.test(file[0]);
|
|
4248
3974
|
const fileUNC = !fileDrive && '' === file[0] && '' === file[1] && '?' === file[2] && /^[a-z]:$/i.test(file[3]);
|
|
@@ -4257,116 +3983,57 @@ var __webpack_modules__ = {
|
|
|
4257
3983
|
];
|
|
4258
3984
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
4259
3985
|
pattern[pdi] = fd;
|
|
4260
|
-
|
|
4261
|
-
|
|
3986
|
+
if (pdi > fdi) pattern = pattern.slice(pdi);
|
|
3987
|
+
else if (fdi > pdi) file = file.slice(fdi);
|
|
4262
3988
|
}
|
|
4263
3989
|
}
|
|
4264
3990
|
}
|
|
4265
3991
|
const { optimizationLevel = 1 } = this.options;
|
|
4266
3992
|
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
const [head, body, tail] = partial ? [
|
|
4274
|
-
pattern.slice(patternIndex, firstgs),
|
|
4275
|
-
pattern.slice(firstgs + 1),
|
|
4276
|
-
[]
|
|
4277
|
-
] : [
|
|
4278
|
-
pattern.slice(patternIndex, firstgs),
|
|
4279
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
4280
|
-
pattern.slice(lastgs + 1)
|
|
4281
|
-
];
|
|
4282
|
-
if (head.length) {
|
|
4283
|
-
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
4284
|
-
if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
|
|
4285
|
-
fileIndex += head.length;
|
|
4286
|
-
patternIndex += head.length;
|
|
4287
|
-
}
|
|
4288
|
-
let fileTailMatch = 0;
|
|
4289
|
-
if (tail.length) {
|
|
4290
|
-
if (tail.length + fileIndex > file.length) return false;
|
|
4291
|
-
let tailStart = file.length - tail.length;
|
|
4292
|
-
if (this.#matchOne(file, tail, partial, tailStart, 0)) fileTailMatch = tail.length;
|
|
4293
|
-
else {
|
|
4294
|
-
if ('' !== file[file.length - 1] || fileIndex + tail.length === file.length) return false;
|
|
4295
|
-
tailStart--;
|
|
4296
|
-
if (!this.#matchOne(file, tail, partial, tailStart, 0)) return false;
|
|
4297
|
-
fileTailMatch = tail.length + 1;
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
if (!body.length) {
|
|
4301
|
-
let sawSome = !!fileTailMatch;
|
|
4302
|
-
for(let i = fileIndex; i < file.length - fileTailMatch; i++){
|
|
4303
|
-
const f = String(file[i]);
|
|
4304
|
-
sawSome = true;
|
|
4305
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4306
|
-
}
|
|
4307
|
-
return partial || sawSome;
|
|
4308
|
-
}
|
|
4309
|
-
const bodySegments = [
|
|
4310
|
-
[
|
|
4311
|
-
[],
|
|
4312
|
-
0
|
|
4313
|
-
]
|
|
4314
|
-
];
|
|
4315
|
-
let currentBody = bodySegments[0];
|
|
4316
|
-
let nonGsParts = 0;
|
|
4317
|
-
const nonGsPartsSums = [
|
|
4318
|
-
0
|
|
4319
|
-
];
|
|
4320
|
-
for (const b of body)if (b === GLOBSTAR) {
|
|
4321
|
-
nonGsPartsSums.push(nonGsParts);
|
|
4322
|
-
currentBody = [
|
|
4323
|
-
[],
|
|
4324
|
-
0
|
|
4325
|
-
];
|
|
4326
|
-
bodySegments.push(currentBody);
|
|
4327
|
-
} else {
|
|
4328
|
-
currentBody[0].push(b);
|
|
4329
|
-
nonGsParts++;
|
|
4330
|
-
}
|
|
4331
|
-
let i = bodySegments.length - 1;
|
|
4332
|
-
const fileLength = file.length - fileTailMatch;
|
|
4333
|
-
for (const b of bodySegments)b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
4334
|
-
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
4335
|
-
}
|
|
4336
|
-
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
4337
|
-
const bs = bodySegments[bodyIndex];
|
|
4338
|
-
if (!bs) {
|
|
4339
|
-
for(let i = fileIndex; i < file.length; i++){
|
|
4340
|
-
sawTail = true;
|
|
4341
|
-
const f = file[i];
|
|
4342
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4343
|
-
}
|
|
4344
|
-
return sawTail;
|
|
4345
|
-
}
|
|
4346
|
-
const [body, after] = bs;
|
|
4347
|
-
while(fileIndex <= after){
|
|
4348
|
-
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
4349
|
-
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
4350
|
-
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
4351
|
-
if (false !== sub) return sub;
|
|
4352
|
-
}
|
|
4353
|
-
const f = file[fileIndex];
|
|
4354
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4355
|
-
fileIndex++;
|
|
4356
|
-
}
|
|
4357
|
-
return partial || null;
|
|
4358
|
-
}
|
|
4359
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
4360
|
-
let fi;
|
|
4361
|
-
let pi;
|
|
4362
|
-
let pl;
|
|
4363
|
-
let fl;
|
|
4364
|
-
for(fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++){
|
|
3993
|
+
this.debug('matchOne', this, {
|
|
3994
|
+
file,
|
|
3995
|
+
pattern
|
|
3996
|
+
});
|
|
3997
|
+
this.debug('matchOne', file.length, pattern.length);
|
|
3998
|
+
for(var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++){
|
|
4365
3999
|
this.debug('matchOne loop');
|
|
4366
|
-
|
|
4367
|
-
|
|
4000
|
+
var p = pattern[pi];
|
|
4001
|
+
var f = file[fi];
|
|
4368
4002
|
this.debug(pattern, p, f);
|
|
4369
|
-
if (false === p
|
|
4003
|
+
if (false === p) return false;
|
|
4004
|
+
if (p === GLOBSTAR) {
|
|
4005
|
+
this.debug('GLOBSTAR', [
|
|
4006
|
+
pattern,
|
|
4007
|
+
p,
|
|
4008
|
+
f
|
|
4009
|
+
]);
|
|
4010
|
+
var fr = fi;
|
|
4011
|
+
var pr = pi + 1;
|
|
4012
|
+
if (pr === pl) {
|
|
4013
|
+
this.debug('** at the end');
|
|
4014
|
+
for(; fi < fl; fi++)if ('.' === file[fi] || '..' === file[fi] || !options.dot && '.' === file[fi].charAt(0)) return false;
|
|
4015
|
+
return true;
|
|
4016
|
+
}
|
|
4017
|
+
while(fr < fl){
|
|
4018
|
+
var swallowee = file[fr];
|
|
4019
|
+
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
|
4020
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
4021
|
+
this.debug('globstar found match!', fr, fl, swallowee);
|
|
4022
|
+
return true;
|
|
4023
|
+
}
|
|
4024
|
+
if ('.' === swallowee || '..' === swallowee || !options.dot && '.' === swallowee.charAt(0)) {
|
|
4025
|
+
this.debug('dot detected!', file, fr, pattern, pr);
|
|
4026
|
+
break;
|
|
4027
|
+
}
|
|
4028
|
+
this.debug('globstar swallow a segment, and continue');
|
|
4029
|
+
fr++;
|
|
4030
|
+
}
|
|
4031
|
+
if (partial) {
|
|
4032
|
+
this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
|
4033
|
+
if (fr === fl) return true;
|
|
4034
|
+
}
|
|
4035
|
+
return false;
|
|
4036
|
+
}
|
|
4370
4037
|
let hit;
|
|
4371
4038
|
if ('string' == typeof p) {
|
|
4372
4039
|
hit = f === p;
|
|
@@ -4426,19 +4093,13 @@ var __webpack_modules__ = {
|
|
|
4426
4093
|
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
4427
4094
|
if (void 0 === prev) if (void 0 !== next && next !== GLOBSTAR) pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
|
|
4428
4095
|
else pp[i] = twoStar;
|
|
4429
|
-
else if (void 0 === next) pp[i - 1] = prev + '(
|
|
4096
|
+
else if (void 0 === next) pp[i - 1] = prev + '(?:\\/|' + twoStar + ')?';
|
|
4430
4097
|
else if (next !== GLOBSTAR) {
|
|
4431
4098
|
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
|
|
4432
4099
|
pp[i + 1] = GLOBSTAR;
|
|
4433
4100
|
}
|
|
4434
4101
|
});
|
|
4435
|
-
|
|
4436
|
-
if (this.partial && filtered.length >= 1) {
|
|
4437
|
-
const prefixes = [];
|
|
4438
|
-
for(let i = 1; i <= filtered.length; i++)prefixes.push(filtered.slice(0, i).join('/'));
|
|
4439
|
-
return '(?:' + prefixes.join('|') + ')';
|
|
4440
|
-
}
|
|
4441
|
-
return filtered.join('/');
|
|
4102
|
+
return pp.filter((p)=>p !== GLOBSTAR).join('/');
|
|
4442
4103
|
}).join('|');
|
|
4443
4104
|
const [open, close] = set.length > 1 ? [
|
|
4444
4105
|
'(?:',
|
|
@@ -4448,20 +4109,19 @@ var __webpack_modules__ = {
|
|
|
4448
4109
|
''
|
|
4449
4110
|
];
|
|
4450
4111
|
re = '^' + open + re + close + '$';
|
|
4451
|
-
if (this.partial) re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
|
|
4452
4112
|
if (this.negate) re = '^(?!' + re + ').+$';
|
|
4453
4113
|
try {
|
|
4454
4114
|
this.regexp = new RegExp(re, [
|
|
4455
4115
|
...flags
|
|
4456
4116
|
].join(''));
|
|
4457
|
-
} catch
|
|
4117
|
+
} catch (ex) {
|
|
4458
4118
|
this.regexp = false;
|
|
4459
4119
|
}
|
|
4460
4120
|
return this.regexp;
|
|
4461
4121
|
}
|
|
4462
4122
|
slashSplit(p) {
|
|
4463
4123
|
if (this.preserveMultipleSlashes) return p.split('/');
|
|
4464
|
-
if (this.isWindows && /^\/\/[
|
|
4124
|
+
if (this.isWindows && /^\/\/[^\/]+/.test(p)) return [
|
|
4465
4125
|
'',
|
|
4466
4126
|
...p.split(/\/+/)
|
|
4467
4127
|
];
|
|
@@ -4480,7 +4140,8 @@ var __webpack_modules__ = {
|
|
|
4480
4140
|
this.debug(this.pattern, 'set', set);
|
|
4481
4141
|
let filename = ff[ff.length - 1];
|
|
4482
4142
|
if (!filename) for(let i = ff.length - 2; !filename && i >= 0; i--)filename = ff[i];
|
|
4483
|
-
for
|
|
4143
|
+
for(let i = 0; i < set.length; i++){
|
|
4144
|
+
const pattern = set[i];
|
|
4484
4145
|
let file = ff;
|
|
4485
4146
|
if (options.matchBase && 1 === pattern.length) file = [
|
|
4486
4147
|
filename
|
|
@@ -4502,46 +4163,85 @@ var __webpack_modules__ = {
|
|
|
4502
4163
|
minimatch.Minimatch = esm_Minimatch;
|
|
4503
4164
|
minimatch.escape = escape_escape;
|
|
4504
4165
|
minimatch.unescape = unescape_unescape;
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4166
|
+
const perf = 'object' == typeof performance && performance && 'function' == typeof performance.now ? performance : Date;
|
|
4167
|
+
const warned = new Set();
|
|
4168
|
+
const PROCESS = 'object' == typeof process && process ? process : {};
|
|
4169
|
+
const emitWarning = (msg, type, code, fn)=>{
|
|
4170
|
+
'function' == typeof PROCESS.emitWarning ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
4171
|
+
};
|
|
4172
|
+
let AC = globalThis.AbortController;
|
|
4173
|
+
let AS = globalThis.AbortSignal;
|
|
4174
|
+
if (void 0 === AC) {
|
|
4175
|
+
AS = class {
|
|
4176
|
+
onabort;
|
|
4177
|
+
_onabort = [];
|
|
4178
|
+
reason;
|
|
4179
|
+
aborted = false;
|
|
4180
|
+
addEventListener(_, fn) {
|
|
4181
|
+
this._onabort.push(fn);
|
|
4182
|
+
}
|
|
4183
|
+
};
|
|
4184
|
+
AC = class {
|
|
4185
|
+
constructor(){
|
|
4186
|
+
warnACPolyfill();
|
|
4187
|
+
}
|
|
4188
|
+
signal = new AS();
|
|
4189
|
+
abort(reason) {
|
|
4190
|
+
if (this.signal.aborted) return;
|
|
4191
|
+
this.signal.reason = reason;
|
|
4192
|
+
this.signal.aborted = true;
|
|
4193
|
+
for (const fn of this.signal._onabort)fn(reason);
|
|
4194
|
+
this.signal.onabort?.(reason);
|
|
4195
|
+
}
|
|
4196
|
+
};
|
|
4197
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
4198
|
+
const warnACPolyfill = ()=>{
|
|
4199
|
+
if (!printACPolyfillWarning) return;
|
|
4200
|
+
printACPolyfillWarning = false;
|
|
4201
|
+
emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
|
|
4202
|
+
};
|
|
4203
|
+
}
|
|
4204
|
+
const shouldWarn = (code)=>!warned.has(code);
|
|
4205
|
+
Symbol('type');
|
|
4206
|
+
const isPosInt = (n)=>n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
4207
|
+
const getUintArray = (max)=>isPosInt(max) ? max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null : null;
|
|
4208
|
+
class ZeroArray extends Array {
|
|
4209
|
+
constructor(size){
|
|
4210
|
+
super(size);
|
|
4211
|
+
this.fill(0);
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
class Stack {
|
|
4513
4215
|
heap;
|
|
4514
4216
|
length;
|
|
4515
|
-
static #
|
|
4516
|
-
static create(
|
|
4517
|
-
|
|
4518
|
-
if (!
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4217
|
+
static #constructing = false;
|
|
4218
|
+
static create(max) {
|
|
4219
|
+
const HeapCls = getUintArray(max);
|
|
4220
|
+
if (!HeapCls) return [];
|
|
4221
|
+
Stack.#constructing = true;
|
|
4222
|
+
const s = new Stack(max, HeapCls);
|
|
4223
|
+
Stack.#constructing = false;
|
|
4224
|
+
return s;
|
|
4225
|
+
}
|
|
4226
|
+
constructor(max, HeapCls){
|
|
4227
|
+
if (!Stack.#constructing) throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
4228
|
+
this.heap = new HeapCls(max);
|
|
4229
|
+
this.length = 0;
|
|
4230
|
+
}
|
|
4231
|
+
push(n) {
|
|
4232
|
+
this.heap[this.length++] = n;
|
|
4529
4233
|
}
|
|
4530
4234
|
pop() {
|
|
4531
4235
|
return this.heap[--this.length];
|
|
4532
4236
|
}
|
|
4533
|
-
}
|
|
4534
|
-
|
|
4535
|
-
#
|
|
4536
|
-
#
|
|
4537
|
-
#
|
|
4538
|
-
#
|
|
4539
|
-
#
|
|
4540
|
-
#
|
|
4541
|
-
#m;
|
|
4542
|
-
get perf() {
|
|
4543
|
-
return this.#m;
|
|
4544
|
-
}
|
|
4237
|
+
}
|
|
4238
|
+
class LRUCache {
|
|
4239
|
+
#max;
|
|
4240
|
+
#maxSize;
|
|
4241
|
+
#dispose;
|
|
4242
|
+
#disposeAfter;
|
|
4243
|
+
#fetchMethod;
|
|
4244
|
+
#memoMethod;
|
|
4545
4245
|
ttl;
|
|
4546
4246
|
ttlResolution;
|
|
4547
4247
|
ttlAutopurge;
|
|
@@ -4557,613 +4257,823 @@ var __webpack_modules__ = {
|
|
|
4557
4257
|
allowStaleOnFetchAbort;
|
|
4558
4258
|
allowStaleOnFetchRejection;
|
|
4559
4259
|
ignoreFetchAbort;
|
|
4560
|
-
#
|
|
4561
|
-
#
|
|
4562
|
-
#
|
|
4563
|
-
#
|
|
4564
|
-
#
|
|
4565
|
-
#
|
|
4566
|
-
#
|
|
4567
|
-
#
|
|
4568
|
-
#
|
|
4569
|
-
#
|
|
4570
|
-
#
|
|
4571
|
-
#
|
|
4572
|
-
#
|
|
4573
|
-
#
|
|
4574
|
-
#
|
|
4575
|
-
#
|
|
4576
|
-
#
|
|
4577
|
-
|
|
4578
|
-
#j;
|
|
4579
|
-
static unsafeExposeInternals(e1) {
|
|
4260
|
+
#size;
|
|
4261
|
+
#calculatedSize;
|
|
4262
|
+
#keyMap;
|
|
4263
|
+
#keyList;
|
|
4264
|
+
#valList;
|
|
4265
|
+
#next;
|
|
4266
|
+
#prev;
|
|
4267
|
+
#head;
|
|
4268
|
+
#tail;
|
|
4269
|
+
#free;
|
|
4270
|
+
#disposed;
|
|
4271
|
+
#sizes;
|
|
4272
|
+
#starts;
|
|
4273
|
+
#ttls;
|
|
4274
|
+
#hasDispose;
|
|
4275
|
+
#hasFetchMethod;
|
|
4276
|
+
#hasDisposeAfter;
|
|
4277
|
+
static unsafeExposeInternals(c) {
|
|
4580
4278
|
return {
|
|
4581
|
-
starts:
|
|
4582
|
-
ttls:
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
prev: e1.#c,
|
|
4279
|
+
starts: c.#starts,
|
|
4280
|
+
ttls: c.#ttls,
|
|
4281
|
+
sizes: c.#sizes,
|
|
4282
|
+
keyMap: c.#keyMap,
|
|
4283
|
+
keyList: c.#keyList,
|
|
4284
|
+
valList: c.#valList,
|
|
4285
|
+
next: c.#next,
|
|
4286
|
+
prev: c.#prev,
|
|
4590
4287
|
get head () {
|
|
4591
|
-
return
|
|
4288
|
+
return c.#head;
|
|
4592
4289
|
},
|
|
4593
4290
|
get tail () {
|
|
4594
|
-
return
|
|
4291
|
+
return c.#tail;
|
|
4595
4292
|
},
|
|
4596
|
-
free:
|
|
4597
|
-
isBackgroundFetch: (
|
|
4598
|
-
backgroundFetch: (
|
|
4599
|
-
moveToTail: (
|
|
4600
|
-
indexes: (
|
|
4601
|
-
rindexes: (
|
|
4602
|
-
isStale: (
|
|
4293
|
+
free: c.#free,
|
|
4294
|
+
isBackgroundFetch: (p)=>c.#isBackgroundFetch(p),
|
|
4295
|
+
backgroundFetch: (k, index, options, context)=>c.#backgroundFetch(k, index, options, context),
|
|
4296
|
+
moveToTail: (index)=>c.#moveToTail(index),
|
|
4297
|
+
indexes: (options)=>c.#indexes(options),
|
|
4298
|
+
rindexes: (options)=>c.#rindexes(options),
|
|
4299
|
+
isStale: (index)=>c.#isStale(index)
|
|
4603
4300
|
};
|
|
4604
4301
|
}
|
|
4605
4302
|
get max() {
|
|
4606
|
-
return this.#
|
|
4303
|
+
return this.#max;
|
|
4607
4304
|
}
|
|
4608
4305
|
get maxSize() {
|
|
4609
|
-
return this.#
|
|
4306
|
+
return this.#maxSize;
|
|
4610
4307
|
}
|
|
4611
4308
|
get calculatedSize() {
|
|
4612
|
-
return this.#
|
|
4309
|
+
return this.#calculatedSize;
|
|
4613
4310
|
}
|
|
4614
4311
|
get size() {
|
|
4615
|
-
return this.#
|
|
4312
|
+
return this.#size;
|
|
4616
4313
|
}
|
|
4617
4314
|
get fetchMethod() {
|
|
4618
|
-
return this.#
|
|
4315
|
+
return this.#fetchMethod;
|
|
4619
4316
|
}
|
|
4620
4317
|
get memoMethod() {
|
|
4621
|
-
return this.#
|
|
4318
|
+
return this.#memoMethod;
|
|
4622
4319
|
}
|
|
4623
4320
|
get dispose() {
|
|
4624
|
-
return this.#
|
|
4625
|
-
}
|
|
4626
|
-
get onInsert() {
|
|
4627
|
-
return this.#D;
|
|
4321
|
+
return this.#dispose;
|
|
4628
4322
|
}
|
|
4629
4323
|
get disposeAfter() {
|
|
4630
|
-
return this.#
|
|
4631
|
-
}
|
|
4632
|
-
constructor(
|
|
4633
|
-
|
|
4634
|
-
if (
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
this.#
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
this
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4324
|
+
return this.#disposeAfter;
|
|
4325
|
+
}
|
|
4326
|
+
constructor(options){
|
|
4327
|
+
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
|
4328
|
+
if (0 !== max && !isPosInt(max)) throw new TypeError('max option must be a nonnegative integer');
|
|
4329
|
+
const UintArray = max ? getUintArray(max) : Array;
|
|
4330
|
+
if (!UintArray) throw new Error('invalid max value: ' + max);
|
|
4331
|
+
this.#max = max;
|
|
4332
|
+
this.#maxSize = maxSize;
|
|
4333
|
+
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
|
4334
|
+
this.sizeCalculation = sizeCalculation;
|
|
4335
|
+
if (this.sizeCalculation) {
|
|
4336
|
+
if (!this.#maxSize && !this.maxEntrySize) throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
|
|
4337
|
+
if ('function' != typeof this.sizeCalculation) throw new TypeError('sizeCalculation set to non-function');
|
|
4338
|
+
}
|
|
4339
|
+
if (void 0 !== memoMethod && 'function' != typeof memoMethod) throw new TypeError('memoMethod must be a function if defined');
|
|
4340
|
+
this.#memoMethod = memoMethod;
|
|
4341
|
+
if (void 0 !== fetchMethod && 'function' != typeof fetchMethod) throw new TypeError('fetchMethod must be a function if specified');
|
|
4342
|
+
this.#fetchMethod = fetchMethod;
|
|
4343
|
+
this.#hasFetchMethod = !!fetchMethod;
|
|
4344
|
+
this.#keyMap = new Map();
|
|
4345
|
+
this.#keyList = new Array(max).fill(void 0);
|
|
4346
|
+
this.#valList = new Array(max).fill(void 0);
|
|
4347
|
+
this.#next = new UintArray(max);
|
|
4348
|
+
this.#prev = new UintArray(max);
|
|
4349
|
+
this.#head = 0;
|
|
4350
|
+
this.#tail = 0;
|
|
4351
|
+
this.#free = Stack.create(max);
|
|
4352
|
+
this.#size = 0;
|
|
4353
|
+
this.#calculatedSize = 0;
|
|
4354
|
+
if ('function' == typeof dispose) this.#dispose = dispose;
|
|
4355
|
+
if ('function' == typeof disposeAfter) {
|
|
4356
|
+
this.#disposeAfter = disposeAfter;
|
|
4357
|
+
this.#disposed = [];
|
|
4358
|
+
} else {
|
|
4359
|
+
this.#disposeAfter = void 0;
|
|
4360
|
+
this.#disposed = void 0;
|
|
4361
|
+
}
|
|
4362
|
+
this.#hasDispose = !!this.#dispose;
|
|
4363
|
+
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
4364
|
+
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
4365
|
+
this.noUpdateTTL = !!noUpdateTTL;
|
|
4366
|
+
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
|
4367
|
+
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
|
|
4368
|
+
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
|
4369
|
+
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
|
4370
|
+
if (0 !== this.maxEntrySize) {
|
|
4371
|
+
if (0 !== this.#maxSize) {
|
|
4372
|
+
if (!isPosInt(this.#maxSize)) throw new TypeError('maxSize must be a positive integer if specified');
|
|
4373
|
+
}
|
|
4374
|
+
if (!isPosInt(this.maxEntrySize)) throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
4375
|
+
this.#initializeSizeTracking();
|
|
4376
|
+
}
|
|
4377
|
+
this.allowStale = !!allowStale;
|
|
4378
|
+
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
4379
|
+
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
4380
|
+
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
4381
|
+
this.ttlResolution = isPosInt(ttlResolution) || 0 === ttlResolution ? ttlResolution : 1;
|
|
4382
|
+
this.ttlAutopurge = !!ttlAutopurge;
|
|
4383
|
+
this.ttl = ttl || 0;
|
|
4384
|
+
if (this.ttl) {
|
|
4385
|
+
if (!isPosInt(this.ttl)) throw new TypeError('ttl must be a positive integer if specified');
|
|
4386
|
+
this.#initializeTTLTracking();
|
|
4387
|
+
}
|
|
4388
|
+
if (0 === this.#max && 0 === this.ttl && 0 === this.#maxSize) throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
4389
|
+
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
4390
|
+
const code = 'LRU_CACHE_UNBOUNDED';
|
|
4391
|
+
if (shouldWarn(code)) {
|
|
4392
|
+
warned.add(code);
|
|
4393
|
+
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
4394
|
+
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
|
|
4395
|
+
}
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4398
|
+
getRemainingTTL(key) {
|
|
4399
|
+
return this.#keyMap.has(key) ? 1 / 0 : 0;
|
|
4400
|
+
}
|
|
4401
|
+
#initializeTTLTracking() {
|
|
4402
|
+
const ttls = new ZeroArray(this.#max);
|
|
4403
|
+
const starts = new ZeroArray(this.#max);
|
|
4404
|
+
this.#ttls = ttls;
|
|
4405
|
+
this.#starts = starts;
|
|
4406
|
+
this.#setItemTTL = (index, ttl, start = perf.now())=>{
|
|
4407
|
+
starts[index] = 0 !== ttl ? start : 0;
|
|
4408
|
+
ttls[index] = ttl;
|
|
4409
|
+
if (0 !== ttl && this.ttlAutopurge) {
|
|
4410
|
+
const t1 = setTimeout(()=>{
|
|
4411
|
+
if (this.#isStale(index)) this.#delete(this.#keyList[index], 'expire');
|
|
4412
|
+
}, ttl + 1);
|
|
4413
|
+
if (t1.unref) t1.unref();
|
|
4414
|
+
}
|
|
4415
|
+
};
|
|
4416
|
+
this.#updateItemAge = (index)=>{
|
|
4417
|
+
starts[index] = 0 !== ttls[index] ? perf.now() : 0;
|
|
4676
4418
|
};
|
|
4677
|
-
|
|
4678
|
-
if (
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
let l = e1[h], c = t1[h];
|
|
4688
|
-
if (!l || !c) return;
|
|
4689
|
-
r.ttl = l, r.start = c, r.now = n || o();
|
|
4690
|
-
let f = r.now - c;
|
|
4691
|
-
r.remainingTTL = l - f;
|
|
4419
|
+
this.#statusTTL = (status, index)=>{
|
|
4420
|
+
if (ttls[index]) {
|
|
4421
|
+
const ttl = ttls[index];
|
|
4422
|
+
const start = starts[index];
|
|
4423
|
+
if (!ttl || !start) return;
|
|
4424
|
+
status.ttl = ttl;
|
|
4425
|
+
status.start = start;
|
|
4426
|
+
status.now = cachedNow || getNow();
|
|
4427
|
+
const age = status.now - start;
|
|
4428
|
+
status.remainingTTL = ttl - age;
|
|
4692
4429
|
}
|
|
4693
4430
|
};
|
|
4694
|
-
let
|
|
4695
|
-
|
|
4431
|
+
let cachedNow = 0;
|
|
4432
|
+
const getNow = ()=>{
|
|
4433
|
+
const n = perf.now();
|
|
4696
4434
|
if (this.ttlResolution > 0) {
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4435
|
+
cachedNow = n;
|
|
4436
|
+
const t1 = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
4437
|
+
if (t1.unref) t1.unref();
|
|
4700
4438
|
}
|
|
4701
|
-
return
|
|
4439
|
+
return n;
|
|
4702
4440
|
};
|
|
4703
|
-
this.getRemainingTTL = (
|
|
4704
|
-
|
|
4705
|
-
if (void 0 ===
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4441
|
+
this.getRemainingTTL = (key)=>{
|
|
4442
|
+
const index = this.#keyMap.get(key);
|
|
4443
|
+
if (void 0 === index) return 0;
|
|
4444
|
+
const ttl = ttls[index];
|
|
4445
|
+
const start = starts[index];
|
|
4446
|
+
if (!ttl || !start) return 1 / 0;
|
|
4447
|
+
const age = (cachedNow || getNow()) - start;
|
|
4448
|
+
return ttl - age;
|
|
4449
|
+
};
|
|
4450
|
+
this.#isStale = (index)=>{
|
|
4451
|
+
const s = starts[index];
|
|
4452
|
+
const t1 = ttls[index];
|
|
4453
|
+
return !!t1 && !!s && (cachedNow || getNow()) - s > t1;
|
|
4713
4454
|
};
|
|
4714
4455
|
}
|
|
4715
|
-
#
|
|
4716
|
-
#
|
|
4717
|
-
#
|
|
4718
|
-
#
|
|
4719
|
-
#
|
|
4720
|
-
|
|
4721
|
-
this.#
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4456
|
+
#updateItemAge = ()=>{};
|
|
4457
|
+
#statusTTL = ()=>{};
|
|
4458
|
+
#setItemTTL = ()=>{};
|
|
4459
|
+
#isStale = ()=>false;
|
|
4460
|
+
#initializeSizeTracking() {
|
|
4461
|
+
const sizes = new ZeroArray(this.#max);
|
|
4462
|
+
this.#calculatedSize = 0;
|
|
4463
|
+
this.#sizes = sizes;
|
|
4464
|
+
this.#removeItemSize = (index)=>{
|
|
4465
|
+
this.#calculatedSize -= sizes[index];
|
|
4466
|
+
sizes[index] = 0;
|
|
4467
|
+
};
|
|
4468
|
+
this.#requireSize = (k, v, size, sizeCalculation)=>{
|
|
4469
|
+
if (this.#isBackgroundFetch(v)) return 0;
|
|
4470
|
+
if (!isPosInt(size)) if (sizeCalculation) {
|
|
4471
|
+
if ('function' != typeof sizeCalculation) throw new TypeError('sizeCalculation must be a function');
|
|
4472
|
+
size = sizeCalculation(v, k);
|
|
4473
|
+
if (!isPosInt(size)) throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
4728
4474
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
4729
|
-
return
|
|
4730
|
-
}
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4475
|
+
return size;
|
|
4476
|
+
};
|
|
4477
|
+
this.#addItemSize = (index, size, status)=>{
|
|
4478
|
+
sizes[index] = size;
|
|
4479
|
+
if (this.#maxSize) {
|
|
4480
|
+
const maxSize = this.#maxSize - sizes[index];
|
|
4481
|
+
while(this.#calculatedSize > maxSize)this.#evict(true);
|
|
4482
|
+
}
|
|
4483
|
+
this.#calculatedSize += sizes[index];
|
|
4484
|
+
if (status) {
|
|
4485
|
+
status.entrySize = size;
|
|
4486
|
+
status.totalCalculatedSize = this.#calculatedSize;
|
|
4734
4487
|
}
|
|
4735
|
-
this.#b += e1[t1], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
4736
4488
|
};
|
|
4737
4489
|
}
|
|
4738
|
-
#
|
|
4739
|
-
#
|
|
4740
|
-
#
|
|
4741
|
-
if (
|
|
4490
|
+
#removeItemSize = (_i)=>{};
|
|
4491
|
+
#addItemSize = (_i, _s, _st)=>{};
|
|
4492
|
+
#requireSize = (_k, _v, size, sizeCalculation)=>{
|
|
4493
|
+
if (size || sizeCalculation) throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
|
|
4742
4494
|
return 0;
|
|
4743
4495
|
};
|
|
4744
|
-
*#
|
|
4745
|
-
if (this.#
|
|
4496
|
+
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
4497
|
+
if (this.#size) for(let i = this.#tail; true;){
|
|
4498
|
+
if (!this.#isValidIndex(i)) break;
|
|
4499
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4500
|
+
if (i === this.#head) break;
|
|
4501
|
+
i = this.#prev[i];
|
|
4502
|
+
}
|
|
4746
4503
|
}
|
|
4747
|
-
*#
|
|
4748
|
-
if (this.#
|
|
4504
|
+
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
4505
|
+
if (this.#size) for(let i = this.#head; true;){
|
|
4506
|
+
if (!this.#isValidIndex(i)) break;
|
|
4507
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4508
|
+
if (i === this.#tail) break;
|
|
4509
|
+
i = this.#next[i];
|
|
4510
|
+
}
|
|
4749
4511
|
}
|
|
4750
|
-
#
|
|
4751
|
-
return void 0 !==
|
|
4512
|
+
#isValidIndex(index) {
|
|
4513
|
+
return void 0 !== index && this.#keyMap.get(this.#keyList[index]) === index;
|
|
4752
4514
|
}
|
|
4753
4515
|
*entries() {
|
|
4754
|
-
for (
|
|
4755
|
-
this.#i
|
|
4756
|
-
this.#
|
|
4757
|
-
]
|
|
4516
|
+
for (const i of this.#indexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4517
|
+
this.#keyList[i],
|
|
4518
|
+
this.#valList[i]
|
|
4519
|
+
];
|
|
4758
4520
|
}
|
|
4759
4521
|
*rentries() {
|
|
4760
|
-
for (
|
|
4761
|
-
this.#i
|
|
4762
|
-
this.#
|
|
4763
|
-
]
|
|
4522
|
+
for (const i of this.#rindexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4523
|
+
this.#keyList[i],
|
|
4524
|
+
this.#valList[i]
|
|
4525
|
+
];
|
|
4764
4526
|
}
|
|
4765
4527
|
*keys() {
|
|
4766
|
-
for (
|
|
4767
|
-
|
|
4768
|
-
void 0
|
|
4528
|
+
for (const i of this.#indexes()){
|
|
4529
|
+
const k = this.#keyList[i];
|
|
4530
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
4769
4531
|
}
|
|
4770
4532
|
}
|
|
4771
4533
|
*rkeys() {
|
|
4772
|
-
for (
|
|
4773
|
-
|
|
4774
|
-
void 0
|
|
4534
|
+
for (const i of this.#rindexes()){
|
|
4535
|
+
const k = this.#keyList[i];
|
|
4536
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
4775
4537
|
}
|
|
4776
4538
|
}
|
|
4777
4539
|
*values() {
|
|
4778
|
-
for (
|
|
4540
|
+
for (const i of this.#indexes()){
|
|
4541
|
+
const v = this.#valList[i];
|
|
4542
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4543
|
+
}
|
|
4779
4544
|
}
|
|
4780
4545
|
*rvalues() {
|
|
4781
|
-
for (
|
|
4546
|
+
for (const i of this.#rindexes()){
|
|
4547
|
+
const v = this.#valList[i];
|
|
4548
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4549
|
+
}
|
|
4782
4550
|
}
|
|
4783
4551
|
[Symbol.iterator]() {
|
|
4784
4552
|
return this.entries();
|
|
4785
4553
|
}
|
|
4786
|
-
[Symbol.toStringTag] =
|
|
4787
|
-
find(
|
|
4788
|
-
for (
|
|
4789
|
-
|
|
4790
|
-
|
|
4554
|
+
[Symbol.toStringTag] = 'LRUCache';
|
|
4555
|
+
find(fn, getOptions = {}) {
|
|
4556
|
+
for (const i of this.#indexes()){
|
|
4557
|
+
const v = this.#valList[i];
|
|
4558
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4559
|
+
if (void 0 !== value) {
|
|
4560
|
+
if (fn(value, this.#keyList[i], this)) return this.get(this.#keyList[i], getOptions);
|
|
4561
|
+
}
|
|
4791
4562
|
}
|
|
4792
4563
|
}
|
|
4793
|
-
forEach(
|
|
4794
|
-
for (
|
|
4795
|
-
|
|
4796
|
-
|
|
4564
|
+
forEach(fn, thisp = this) {
|
|
4565
|
+
for (const i of this.#indexes()){
|
|
4566
|
+
const v = this.#valList[i];
|
|
4567
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4568
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
4797
4569
|
}
|
|
4798
4570
|
}
|
|
4799
|
-
rforEach(
|
|
4800
|
-
for (
|
|
4801
|
-
|
|
4802
|
-
|
|
4571
|
+
rforEach(fn, thisp = this) {
|
|
4572
|
+
for (const i of this.#rindexes()){
|
|
4573
|
+
const v = this.#valList[i];
|
|
4574
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4575
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
4803
4576
|
}
|
|
4804
4577
|
}
|
|
4805
4578
|
purgeStale() {
|
|
4806
|
-
let
|
|
4807
|
-
for (
|
|
4808
|
-
allowStale:
|
|
4809
|
-
}))
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4579
|
+
let deleted = false;
|
|
4580
|
+
for (const i of this.#rindexes({
|
|
4581
|
+
allowStale: true
|
|
4582
|
+
}))if (this.#isStale(i)) {
|
|
4583
|
+
this.#delete(this.#keyList[i], 'expire');
|
|
4584
|
+
deleted = true;
|
|
4585
|
+
}
|
|
4586
|
+
return deleted;
|
|
4587
|
+
}
|
|
4588
|
+
info(key) {
|
|
4589
|
+
const i = this.#keyMap.get(key);
|
|
4590
|
+
if (void 0 === i) return;
|
|
4591
|
+
const v = this.#valList[i];
|
|
4592
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4593
|
+
if (void 0 === value) return;
|
|
4594
|
+
const entry = {
|
|
4595
|
+
value
|
|
4819
4596
|
};
|
|
4820
|
-
if (this.#
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4597
|
+
if (this.#ttls && this.#starts) {
|
|
4598
|
+
const ttl = this.#ttls[i];
|
|
4599
|
+
const start = this.#starts[i];
|
|
4600
|
+
if (ttl && start) {
|
|
4601
|
+
const remain = ttl - (perf.now() - start);
|
|
4602
|
+
entry.ttl = remain;
|
|
4603
|
+
entry.start = Date.now();
|
|
4825
4604
|
}
|
|
4826
4605
|
}
|
|
4827
|
-
|
|
4606
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4607
|
+
return entry;
|
|
4828
4608
|
}
|
|
4829
4609
|
dump() {
|
|
4830
|
-
|
|
4831
|
-
for (
|
|
4832
|
-
allowStale:
|
|
4610
|
+
const arr = [];
|
|
4611
|
+
for (const i of this.#indexes({
|
|
4612
|
+
allowStale: true
|
|
4833
4613
|
})){
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4614
|
+
const key = this.#keyList[i];
|
|
4615
|
+
const v = this.#valList[i];
|
|
4616
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4617
|
+
if (void 0 === value || void 0 === key) continue;
|
|
4618
|
+
const entry = {
|
|
4619
|
+
value
|
|
4838
4620
|
};
|
|
4839
|
-
if (this.#
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
}
|
|
4844
|
-
this.#
|
|
4845
|
-
|
|
4846
|
-
|
|
4621
|
+
if (this.#ttls && this.#starts) {
|
|
4622
|
+
entry.ttl = this.#ttls[i];
|
|
4623
|
+
const age = perf.now() - this.#starts[i];
|
|
4624
|
+
entry.start = Math.floor(Date.now() - age);
|
|
4625
|
+
}
|
|
4626
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4627
|
+
arr.unshift([
|
|
4628
|
+
key,
|
|
4629
|
+
entry
|
|
4847
4630
|
]);
|
|
4848
4631
|
}
|
|
4849
|
-
return
|
|
4632
|
+
return arr;
|
|
4850
4633
|
}
|
|
4851
|
-
load(
|
|
4634
|
+
load(arr) {
|
|
4852
4635
|
this.clear();
|
|
4853
|
-
for (
|
|
4854
|
-
if (
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
}
|
|
4858
|
-
this
|
|
4859
|
-
}
|
|
4860
|
-
}
|
|
4861
|
-
set(
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
if (
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4636
|
+
for (const [key, entry] of arr){
|
|
4637
|
+
if (entry.start) {
|
|
4638
|
+
const age = Date.now() - entry.start;
|
|
4639
|
+
entry.start = perf.now() - age;
|
|
4640
|
+
}
|
|
4641
|
+
this.set(key, entry.value, entry);
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
set(k, v, setOptions = {}) {
|
|
4645
|
+
if (void 0 === v) {
|
|
4646
|
+
this.delete(k);
|
|
4647
|
+
return this;
|
|
4648
|
+
}
|
|
4649
|
+
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
|
|
4650
|
+
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
4651
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
4652
|
+
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
4653
|
+
if (status) {
|
|
4654
|
+
status.set = 'miss';
|
|
4655
|
+
status.maxEntrySizeExceeded = true;
|
|
4656
|
+
}
|
|
4657
|
+
this.#delete(k, 'set');
|
|
4658
|
+
return this;
|
|
4659
|
+
}
|
|
4660
|
+
let index = 0 === this.#size ? void 0 : this.#keyMap.get(k);
|
|
4661
|
+
if (void 0 === index) {
|
|
4662
|
+
index = 0 === this.#size ? this.#tail : 0 !== this.#free.length ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
|
|
4663
|
+
this.#keyList[index] = k;
|
|
4664
|
+
this.#valList[index] = v;
|
|
4665
|
+
this.#keyMap.set(k, index);
|
|
4666
|
+
this.#next[this.#tail] = index;
|
|
4667
|
+
this.#prev[index] = this.#tail;
|
|
4668
|
+
this.#tail = index;
|
|
4669
|
+
this.#size++;
|
|
4670
|
+
this.#addItemSize(index, size, status);
|
|
4671
|
+
if (status) status.set = 'add';
|
|
4672
|
+
noUpdateTTL = false;
|
|
4673
|
+
} else {
|
|
4674
|
+
this.#moveToTail(index);
|
|
4675
|
+
const oldVal = this.#valList[index];
|
|
4676
|
+
if (v !== oldVal) {
|
|
4677
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
4678
|
+
oldVal.__abortController.abort(new Error('replaced'));
|
|
4679
|
+
const { __staleWhileFetching: s } = oldVal;
|
|
4680
|
+
if (void 0 !== s && !noDisposeOnSet) {
|
|
4681
|
+
if (this.#hasDispose) this.#dispose?.(s, k, 'set');
|
|
4682
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
4683
|
+
s,
|
|
4684
|
+
k,
|
|
4685
|
+
'set'
|
|
4686
|
+
]);
|
|
4687
|
+
}
|
|
4688
|
+
} else if (!noDisposeOnSet) {
|
|
4689
|
+
if (this.#hasDispose) this.#dispose?.(oldVal, k, 'set');
|
|
4690
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
4691
|
+
oldVal,
|
|
4692
|
+
k,
|
|
4693
|
+
'set'
|
|
4694
|
+
]);
|
|
4695
|
+
}
|
|
4696
|
+
this.#removeItemSize(index);
|
|
4697
|
+
this.#addItemSize(index, size, status);
|
|
4698
|
+
this.#valList[index] = v;
|
|
4699
|
+
if (status) {
|
|
4700
|
+
status.set = 'replace';
|
|
4701
|
+
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
|
4702
|
+
if (void 0 !== oldValue) status.oldValue = oldValue;
|
|
4897
4703
|
}
|
|
4898
|
-
} else
|
|
4899
|
-
this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
|
|
4704
|
+
} else if (status) status.set = 'update';
|
|
4900
4705
|
}
|
|
4901
|
-
if (0
|
|
4902
|
-
|
|
4903
|
-
|
|
4706
|
+
if (0 !== ttl && !this.#ttls) this.#initializeTTLTracking();
|
|
4707
|
+
if (this.#ttls) {
|
|
4708
|
+
if (!noUpdateTTL) this.#setItemTTL(index, ttl, start);
|
|
4709
|
+
if (status) this.#statusTTL(status, index);
|
|
4710
|
+
}
|
|
4711
|
+
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
4712
|
+
const dt = this.#disposed;
|
|
4713
|
+
let task;
|
|
4714
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4904
4715
|
}
|
|
4905
4716
|
return this;
|
|
4906
4717
|
}
|
|
4907
4718
|
pop() {
|
|
4908
4719
|
try {
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4720
|
+
while(this.#size){
|
|
4721
|
+
const val = this.#valList[this.#head];
|
|
4722
|
+
this.#evict(true);
|
|
4723
|
+
if (this.#isBackgroundFetch(val)) {
|
|
4724
|
+
if (val.__staleWhileFetching) return val.__staleWhileFetching;
|
|
4725
|
+
} else if (void 0 !== val) return val;
|
|
4914
4726
|
}
|
|
4915
4727
|
} finally{
|
|
4916
|
-
if (this.#
|
|
4917
|
-
|
|
4918
|
-
|
|
4728
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
4729
|
+
const dt = this.#disposed;
|
|
4730
|
+
let task;
|
|
4731
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4919
4732
|
}
|
|
4920
4733
|
}
|
|
4921
4734
|
}
|
|
4922
|
-
#
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4935
|
-
}
|
|
4936
|
-
#Y(e1, t1 = {}) {
|
|
4937
|
-
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t1, n = this.#s.get(e1);
|
|
4938
|
-
if (void 0 !== n) {
|
|
4939
|
-
let o = this.#t[n];
|
|
4940
|
-
if (this.#e(o) && void 0 === o.__staleWhileFetching) return !1;
|
|
4941
|
-
if (!this.#p(n)) return i && this.#x(n), s && (s.has = "hit", this.#E(s, n)), !0;
|
|
4942
|
-
s && (s.has = "stale", this.#E(s, n));
|
|
4943
|
-
} else s && (s.has = "miss");
|
|
4944
|
-
return !1;
|
|
4945
|
-
}
|
|
4946
|
-
peek(e1, t1 = {}) {
|
|
4947
|
-
let { status: i = D() ? {} : void 0 } = t1;
|
|
4948
|
-
i && (i.op = "peek", i.key = e1), t1.status = i;
|
|
4949
|
-
let s = this.#J(e1, t1);
|
|
4950
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4951
|
-
}
|
|
4952
|
-
#J(e1, t1) {
|
|
4953
|
-
let { status: i, allowStale: s = this.allowStale } = t1, n = this.#s.get(e1);
|
|
4954
|
-
if (void 0 === n || !s && this.#p(n)) {
|
|
4955
|
-
i && (i.peek = void 0 === n ? "miss" : "stale");
|
|
4956
|
-
return;
|
|
4735
|
+
#evict(free) {
|
|
4736
|
+
const head = this.#head;
|
|
4737
|
+
const k = this.#keyList[head];
|
|
4738
|
+
const v = this.#valList[head];
|
|
4739
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('evicted'));
|
|
4740
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
4741
|
+
if (this.#hasDispose) this.#dispose?.(v, k, 'evict');
|
|
4742
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
4743
|
+
v,
|
|
4744
|
+
k,
|
|
4745
|
+
'evict'
|
|
4746
|
+
]);
|
|
4957
4747
|
}
|
|
4958
|
-
|
|
4959
|
-
|
|
4748
|
+
this.#removeItemSize(head);
|
|
4749
|
+
if (free) {
|
|
4750
|
+
this.#keyList[head] = void 0;
|
|
4751
|
+
this.#valList[head] = void 0;
|
|
4752
|
+
this.#free.push(head);
|
|
4753
|
+
}
|
|
4754
|
+
if (1 === this.#size) {
|
|
4755
|
+
this.#head = this.#tail = 0;
|
|
4756
|
+
this.#free.length = 0;
|
|
4757
|
+
} else this.#head = this.#next[head];
|
|
4758
|
+
this.#keyMap.delete(k);
|
|
4759
|
+
this.#size--;
|
|
4760
|
+
return head;
|
|
4761
|
+
}
|
|
4762
|
+
has(k, hasOptions = {}) {
|
|
4763
|
+
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
4764
|
+
const index = this.#keyMap.get(k);
|
|
4765
|
+
if (void 0 !== index) {
|
|
4766
|
+
const v = this.#valList[index];
|
|
4767
|
+
if (this.#isBackgroundFetch(v) && void 0 === v.__staleWhileFetching) return false;
|
|
4768
|
+
if (this.#isStale(index)) {
|
|
4769
|
+
if (status) {
|
|
4770
|
+
status.has = 'stale';
|
|
4771
|
+
this.#statusTTL(status, index);
|
|
4772
|
+
}
|
|
4773
|
+
} else {
|
|
4774
|
+
if (updateAgeOnHas) this.#updateItemAge(index);
|
|
4775
|
+
if (status) {
|
|
4776
|
+
status.has = 'hit';
|
|
4777
|
+
this.#statusTTL(status, index);
|
|
4778
|
+
}
|
|
4779
|
+
return true;
|
|
4780
|
+
}
|
|
4781
|
+
} else if (status) status.has = 'miss';
|
|
4782
|
+
return false;
|
|
4960
4783
|
}
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4784
|
+
peek(k, peekOptions = {}) {
|
|
4785
|
+
const { allowStale = this.allowStale } = peekOptions;
|
|
4786
|
+
const index = this.#keyMap.get(k);
|
|
4787
|
+
if (void 0 === index || !allowStale && this.#isStale(index)) return;
|
|
4788
|
+
const v = this.#valList[index];
|
|
4789
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4790
|
+
}
|
|
4791
|
+
#backgroundFetch(k, index, options, context) {
|
|
4792
|
+
const v = void 0 === index ? void 0 : this.#valList[index];
|
|
4793
|
+
if (this.#isBackgroundFetch(v)) return v;
|
|
4794
|
+
const ac = new AC();
|
|
4795
|
+
const { signal } = options;
|
|
4796
|
+
signal?.addEventListener('abort', ()=>ac.abort(signal.reason), {
|
|
4797
|
+
signal: ac.signal
|
|
4967
4798
|
});
|
|
4968
|
-
|
|
4969
|
-
signal:
|
|
4970
|
-
options
|
|
4971
|
-
context
|
|
4972
|
-
}
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4799
|
+
const fetchOpts = {
|
|
4800
|
+
signal: ac.signal,
|
|
4801
|
+
options,
|
|
4802
|
+
context
|
|
4803
|
+
};
|
|
4804
|
+
const cb = (v, updateCache = false)=>{
|
|
4805
|
+
const { aborted } = ac.signal;
|
|
4806
|
+
const ignoreAbort = options.ignoreFetchAbort && void 0 !== v;
|
|
4807
|
+
if (options.status) if (aborted && !updateCache) {
|
|
4808
|
+
options.status.fetchAborted = true;
|
|
4809
|
+
options.status.fetchError = ac.signal.reason;
|
|
4810
|
+
if (ignoreAbort) options.status.fetchAbortIgnored = true;
|
|
4811
|
+
} else options.status.fetchResolved = true;
|
|
4812
|
+
if (aborted && !ignoreAbort && !updateCache) return fetchFail(ac.signal.reason);
|
|
4813
|
+
const bf = p;
|
|
4814
|
+
if (this.#valList[index] === p) if (void 0 === v) if (bf.__staleWhileFetching) this.#valList[index] = bf.__staleWhileFetching;
|
|
4815
|
+
else this.#delete(k, 'fetch');
|
|
4816
|
+
else {
|
|
4817
|
+
if (options.status) options.status.fetchUpdated = true;
|
|
4818
|
+
this.set(k, v, fetchOpts.options);
|
|
4819
|
+
}
|
|
4820
|
+
return v;
|
|
4821
|
+
};
|
|
4822
|
+
const eb = (er)=>{
|
|
4823
|
+
if (options.status) {
|
|
4824
|
+
options.status.fetchRejected = true;
|
|
4825
|
+
options.status.fetchError = er;
|
|
4826
|
+
}
|
|
4827
|
+
return fetchFail(er);
|
|
4828
|
+
};
|
|
4829
|
+
const fetchFail = (er)=>{
|
|
4830
|
+
const { aborted } = ac.signal;
|
|
4831
|
+
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
4832
|
+
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
4833
|
+
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
4834
|
+
const bf = p;
|
|
4835
|
+
if (this.#valList[index] === p) {
|
|
4836
|
+
const del = !noDelete || void 0 === bf.__staleWhileFetching;
|
|
4837
|
+
if (del) this.#delete(k, 'fetch');
|
|
4838
|
+
else if (!allowStaleAborted) this.#valList[index] = bf.__staleWhileFetching;
|
|
4839
|
+
}
|
|
4840
|
+
if (allowStale) {
|
|
4841
|
+
if (options.status && void 0 !== bf.__staleWhileFetching) options.status.returnedStale = true;
|
|
4842
|
+
return bf.__staleWhileFetching;
|
|
4843
|
+
}
|
|
4844
|
+
if (bf.__returned === bf) throw er;
|
|
4845
|
+
};
|
|
4846
|
+
const pcall = (res, rej)=>{
|
|
4847
|
+
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
4848
|
+
if (fmp && fmp instanceof Promise) fmp.then((v)=>res(void 0 === v ? void 0 : v), rej);
|
|
4849
|
+
ac.signal.addEventListener('abort', ()=>{
|
|
4850
|
+
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
|
4851
|
+
res(void 0);
|
|
4852
|
+
if (options.allowStaleOnFetchAbort) res = (v)=>cb(v, true);
|
|
4853
|
+
}
|
|
4985
4854
|
});
|
|
4986
4855
|
};
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4856
|
+
if (options.status) options.status.fetchDispatched = true;
|
|
4857
|
+
const p = new Promise(pcall).then(cb, eb);
|
|
4858
|
+
const bf = Object.assign(p, {
|
|
4859
|
+
__abortController: ac,
|
|
4860
|
+
__staleWhileFetching: v,
|
|
4991
4861
|
__returned: void 0
|
|
4992
4862
|
});
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
4863
|
+
if (void 0 === index) {
|
|
4864
|
+
this.set(k, bf, {
|
|
4865
|
+
...fetchOpts.options,
|
|
4866
|
+
status: void 0
|
|
4867
|
+
});
|
|
4868
|
+
index = this.#keyMap.get(k);
|
|
4869
|
+
} else this.#valList[index] = bf;
|
|
4870
|
+
return bf;
|
|
4871
|
+
}
|
|
4872
|
+
#isBackgroundFetch(p) {
|
|
4873
|
+
if (!this.#hasFetchMethod) return false;
|
|
4874
|
+
const b = p;
|
|
4875
|
+
return !!b && b instanceof Promise && b.hasOwnProperty('__staleWhileFetching') && b.__abortController instanceof AC;
|
|
4876
|
+
}
|
|
4877
|
+
async fetch(k, fetchOptions = {}) {
|
|
4878
|
+
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL, noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal } = fetchOptions;
|
|
4879
|
+
if (!this.#hasFetchMethod) {
|
|
4880
|
+
if (status) status.fetch = 'get';
|
|
4881
|
+
return this.get(k, {
|
|
4882
|
+
allowStale,
|
|
4883
|
+
updateAgeOnGet,
|
|
4884
|
+
noDeleteOnStaleGet,
|
|
4885
|
+
status
|
|
4886
|
+
});
|
|
4887
|
+
}
|
|
4888
|
+
const options = {
|
|
4889
|
+
allowStale,
|
|
4890
|
+
updateAgeOnGet,
|
|
4891
|
+
noDeleteOnStaleGet,
|
|
4892
|
+
ttl,
|
|
4893
|
+
noDisposeOnSet,
|
|
4894
|
+
size,
|
|
4895
|
+
sizeCalculation,
|
|
4896
|
+
noUpdateTTL,
|
|
4897
|
+
noDeleteOnFetchRejection,
|
|
4898
|
+
allowStaleOnFetchRejection,
|
|
4899
|
+
allowStaleOnFetchAbort,
|
|
4900
|
+
ignoreFetchAbort,
|
|
4901
|
+
status,
|
|
4902
|
+
signal
|
|
4903
|
+
};
|
|
4904
|
+
let index = this.#keyMap.get(k);
|
|
4905
|
+
if (void 0 === index) {
|
|
4906
|
+
if (status) status.fetch = 'miss';
|
|
4907
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
4908
|
+
return p.__returned = p;
|
|
5037
4909
|
}
|
|
5038
4910
|
{
|
|
5039
|
-
|
|
5040
|
-
if (this.#
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
}
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
if (
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
4911
|
+
const v = this.#valList[index];
|
|
4912
|
+
if (this.#isBackgroundFetch(v)) {
|
|
4913
|
+
const stale = allowStale && void 0 !== v.__staleWhileFetching;
|
|
4914
|
+
if (status) {
|
|
4915
|
+
status.fetch = 'inflight';
|
|
4916
|
+
if (stale) status.returnedStale = true;
|
|
4917
|
+
}
|
|
4918
|
+
return stale ? v.__staleWhileFetching : v.__returned = v;
|
|
4919
|
+
}
|
|
4920
|
+
const isStale = this.#isStale(index);
|
|
4921
|
+
if (!forceRefresh && !isStale) {
|
|
4922
|
+
if (status) status.fetch = 'hit';
|
|
4923
|
+
this.#moveToTail(index);
|
|
4924
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
4925
|
+
if (status) this.#statusTTL(status, index);
|
|
4926
|
+
return v;
|
|
4927
|
+
}
|
|
4928
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
4929
|
+
const hasStale = void 0 !== p.__staleWhileFetching;
|
|
4930
|
+
const staleVal = hasStale && allowStale;
|
|
4931
|
+
if (status) {
|
|
4932
|
+
status.fetch = isStale ? 'stale' : 'refresh';
|
|
4933
|
+
if (staleVal && isStale) status.returnedStale = true;
|
|
4934
|
+
}
|
|
4935
|
+
return staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
async forceFetch(k, fetchOptions = {}) {
|
|
4939
|
+
const v = await this.fetch(k, fetchOptions);
|
|
4940
|
+
if (void 0 === v) throw new Error('fetch() returned undefined');
|
|
4941
|
+
return v;
|
|
4942
|
+
}
|
|
4943
|
+
memo(k, memoOptions = {}) {
|
|
4944
|
+
const memoMethod = this.#memoMethod;
|
|
4945
|
+
if (!memoMethod) throw new Error('no memoMethod provided to constructor');
|
|
4946
|
+
const { context, forceRefresh, ...options } = memoOptions;
|
|
4947
|
+
const v = this.get(k, options);
|
|
4948
|
+
if (!forceRefresh && void 0 !== v) return v;
|
|
4949
|
+
const vv = memoMethod(k, v, {
|
|
4950
|
+
options,
|
|
4951
|
+
context
|
|
5077
4952
|
});
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
4953
|
+
this.set(k, vv, options);
|
|
4954
|
+
return vv;
|
|
4955
|
+
}
|
|
4956
|
+
get(k, getOptions = {}) {
|
|
4957
|
+
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
|
|
4958
|
+
const index = this.#keyMap.get(k);
|
|
4959
|
+
if (void 0 !== index) {
|
|
4960
|
+
const value = this.#valList[index];
|
|
4961
|
+
const fetching = this.#isBackgroundFetch(value);
|
|
4962
|
+
if (status) this.#statusTTL(status, index);
|
|
4963
|
+
if (this.#isStale(index)) {
|
|
4964
|
+
if (status) status.get = 'stale';
|
|
4965
|
+
if (fetching) {
|
|
4966
|
+
if (status && allowStale && void 0 !== value.__staleWhileFetching) status.returnedStale = true;
|
|
4967
|
+
return allowStale ? value.__staleWhileFetching : void 0;
|
|
4968
|
+
}
|
|
4969
|
+
if (!noDeleteOnStaleGet) this.#delete(k, 'expire');
|
|
4970
|
+
if (status && allowStale) status.returnedStale = true;
|
|
4971
|
+
return allowStale ? value : void 0;
|
|
4972
|
+
}
|
|
4973
|
+
if (status) status.get = 'hit';
|
|
4974
|
+
if (fetching) return value.__staleWhileFetching;
|
|
4975
|
+
this.#moveToTail(index);
|
|
4976
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
4977
|
+
return value;
|
|
5091
4978
|
}
|
|
5092
|
-
|
|
5093
|
-
return o && this.#E(o, r), this.#p(r) ? l ? (o && (o.get = "stale-fetching"), i && void 0 !== h.__staleWhileFetching ? (o && (o.returnedStale = !0), h.__staleWhileFetching) : void 0) : (n || this.#v(e1, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = !0), h) : void 0) : (o && (o.get = l ? "fetching" : "hit"), this.#L(r), s && this.#x(r), l ? h.__staleWhileFetching : h);
|
|
4979
|
+
if (status) status.get = 'miss';
|
|
5094
4980
|
}
|
|
5095
|
-
|
|
5096
|
-
this.#
|
|
4981
|
+
#connect(p, n) {
|
|
4982
|
+
this.#prev[n] = p;
|
|
4983
|
+
this.#next[p] = n;
|
|
5097
4984
|
}
|
|
5098
|
-
#
|
|
5099
|
-
|
|
4985
|
+
#moveToTail(index) {
|
|
4986
|
+
if (index !== this.#tail) {
|
|
4987
|
+
if (index === this.#head) this.#head = this.#next[index];
|
|
4988
|
+
else this.#connect(this.#prev[index], this.#next[index]);
|
|
4989
|
+
this.#connect(this.#tail, index);
|
|
4990
|
+
this.#tail = index;
|
|
4991
|
+
}
|
|
5100
4992
|
}
|
|
5101
|
-
delete(
|
|
5102
|
-
return this.#
|
|
4993
|
+
delete(k) {
|
|
4994
|
+
return this.#delete(k, 'delete');
|
|
5103
4995
|
}
|
|
5104
|
-
#
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
if (0 !== this.#n) {
|
|
5112
|
-
let s = this.#s.get(e1);
|
|
5113
|
-
if (void 0 !== s) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = !0, 1 === this.#n) this.#q(t1);
|
|
5114
|
-
else {
|
|
5115
|
-
this.#R(s);
|
|
5116
|
-
let n = this.#t[s];
|
|
5117
|
-
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, e1, t1), this.#f && this.#r?.push([
|
|
5118
|
-
n,
|
|
5119
|
-
e1,
|
|
5120
|
-
t1
|
|
5121
|
-
])), this.#s.delete(e1), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
5122
|
-
else if (s === this.#l) this.#l = this.#a[s];
|
|
4996
|
+
#delete(k, reason) {
|
|
4997
|
+
let deleted = false;
|
|
4998
|
+
if (0 !== this.#size) {
|
|
4999
|
+
const index = this.#keyMap.get(k);
|
|
5000
|
+
if (void 0 !== index) {
|
|
5001
|
+
deleted = true;
|
|
5002
|
+
if (1 === this.#size) this.#clear(reason);
|
|
5123
5003
|
else {
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
this.#
|
|
5004
|
+
this.#removeItemSize(index);
|
|
5005
|
+
const v = this.#valList[index];
|
|
5006
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5007
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
5008
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5009
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5010
|
+
v,
|
|
5011
|
+
k,
|
|
5012
|
+
reason
|
|
5013
|
+
]);
|
|
5014
|
+
}
|
|
5015
|
+
this.#keyMap.delete(k);
|
|
5016
|
+
this.#keyList[index] = void 0;
|
|
5017
|
+
this.#valList[index] = void 0;
|
|
5018
|
+
if (index === this.#tail) this.#tail = this.#prev[index];
|
|
5019
|
+
else if (index === this.#head) this.#head = this.#next[index];
|
|
5020
|
+
else {
|
|
5021
|
+
const pi = this.#prev[index];
|
|
5022
|
+
this.#next[pi] = this.#next[index];
|
|
5023
|
+
const ni = this.#next[index];
|
|
5024
|
+
this.#prev[ni] = this.#prev[index];
|
|
5025
|
+
}
|
|
5026
|
+
this.#size--;
|
|
5027
|
+
this.#free.push(index);
|
|
5128
5028
|
}
|
|
5129
|
-
this.#n--, this.#y.push(s);
|
|
5130
5029
|
}
|
|
5131
5030
|
}
|
|
5132
|
-
if (this.#
|
|
5133
|
-
|
|
5134
|
-
|
|
5031
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
5032
|
+
const dt = this.#disposed;
|
|
5033
|
+
let task;
|
|
5034
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5135
5035
|
}
|
|
5136
|
-
return
|
|
5036
|
+
return deleted;
|
|
5137
5037
|
}
|
|
5138
5038
|
clear() {
|
|
5139
|
-
return this.#
|
|
5039
|
+
return this.#clear('delete');
|
|
5140
5040
|
}
|
|
5141
|
-
#
|
|
5142
|
-
for (
|
|
5143
|
-
allowStale:
|
|
5041
|
+
#clear(reason) {
|
|
5042
|
+
for (const index of this.#rindexes({
|
|
5043
|
+
allowStale: true
|
|
5144
5044
|
})){
|
|
5145
|
-
|
|
5146
|
-
if (this.#
|
|
5045
|
+
const v = this.#valList[index];
|
|
5046
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5147
5047
|
else {
|
|
5148
|
-
|
|
5149
|
-
this.#
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5048
|
+
const k = this.#keyList[index];
|
|
5049
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5050
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5051
|
+
v,
|
|
5052
|
+
k,
|
|
5053
|
+
reason
|
|
5153
5054
|
]);
|
|
5154
5055
|
}
|
|
5155
5056
|
}
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5057
|
+
this.#keyMap.clear();
|
|
5058
|
+
this.#valList.fill(void 0);
|
|
5059
|
+
this.#keyList.fill(void 0);
|
|
5060
|
+
if (this.#ttls && this.#starts) {
|
|
5061
|
+
this.#ttls.fill(0);
|
|
5062
|
+
this.#starts.fill(0);
|
|
5160
5063
|
}
|
|
5161
|
-
if (this.#
|
|
5162
|
-
|
|
5163
|
-
|
|
5064
|
+
if (this.#sizes) this.#sizes.fill(0);
|
|
5065
|
+
this.#head = 0;
|
|
5066
|
+
this.#tail = 0;
|
|
5067
|
+
this.#free.length = 0;
|
|
5068
|
+
this.#calculatedSize = 0;
|
|
5069
|
+
this.#size = 0;
|
|
5070
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
5071
|
+
const dt = this.#disposed;
|
|
5072
|
+
let task;
|
|
5073
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5164
5074
|
}
|
|
5165
5075
|
}
|
|
5166
|
-
}
|
|
5076
|
+
}
|
|
5167
5077
|
var external_fs_ = __webpack_require__("fs");
|
|
5168
5078
|
const proc = 'object' == typeof process && process ? process : {
|
|
5169
5079
|
stdout: null,
|
|
@@ -5236,7 +5146,7 @@ var __webpack_modules__ = {
|
|
|
5236
5146
|
}
|
|
5237
5147
|
constructor(src, dest, opts){
|
|
5238
5148
|
super(src, dest, opts);
|
|
5239
|
-
this.proxyErrors = (er)=>
|
|
5149
|
+
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
5240
5150
|
src.on('error', this.proxyErrors);
|
|
5241
5151
|
}
|
|
5242
5152
|
}
|
|
@@ -5688,8 +5598,7 @@ var __webpack_modules__ = {
|
|
|
5688
5598
|
return: stop,
|
|
5689
5599
|
[Symbol.asyncIterator] () {
|
|
5690
5600
|
return this;
|
|
5691
|
-
}
|
|
5692
|
-
[Symbol.asyncDispose]: async ()=>{}
|
|
5601
|
+
}
|
|
5693
5602
|
};
|
|
5694
5603
|
}
|
|
5695
5604
|
[Symbol.iterator]() {
|
|
@@ -5723,8 +5632,7 @@ var __webpack_modules__ = {
|
|
|
5723
5632
|
return: stop,
|
|
5724
5633
|
[Symbol.iterator] () {
|
|
5725
5634
|
return this;
|
|
5726
|
-
}
|
|
5727
|
-
[Symbol.dispose]: ()=>{}
|
|
5635
|
+
}
|
|
5728
5636
|
};
|
|
5729
5637
|
}
|
|
5730
5638
|
destroy(er) {
|
|
@@ -5791,9 +5699,7 @@ var __webpack_modules__ = {
|
|
|
5791
5699
|
const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
|
|
5792
5700
|
const TYPEMASK = 1023;
|
|
5793
5701
|
const entToType = (s)=>s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN;
|
|
5794
|
-
const normalizeCache = new
|
|
5795
|
-
max: 4096
|
|
5796
|
-
});
|
|
5702
|
+
const normalizeCache = new Map();
|
|
5797
5703
|
const normalize = (s)=>{
|
|
5798
5704
|
const c = normalizeCache.get(s);
|
|
5799
5705
|
if (c) return c;
|
|
@@ -5801,9 +5707,7 @@ var __webpack_modules__ = {
|
|
|
5801
5707
|
normalizeCache.set(s, n);
|
|
5802
5708
|
return n;
|
|
5803
5709
|
};
|
|
5804
|
-
const normalizeNocaseCache = new
|
|
5805
|
-
max: 4096
|
|
5806
|
-
});
|
|
5710
|
+
const normalizeNocaseCache = new Map();
|
|
5807
5711
|
const normalizeNocase = (s)=>{
|
|
5808
5712
|
const c = normalizeNocaseCache.get(s);
|
|
5809
5713
|
if (c) return c;
|
|
@@ -5811,14 +5715,14 @@ var __webpack_modules__ = {
|
|
|
5811
5715
|
normalizeNocaseCache.set(s, n);
|
|
5812
5716
|
return n;
|
|
5813
5717
|
};
|
|
5814
|
-
class ResolveCache extends
|
|
5718
|
+
class ResolveCache extends LRUCache {
|
|
5815
5719
|
constructor(){
|
|
5816
5720
|
super({
|
|
5817
5721
|
max: 256
|
|
5818
5722
|
});
|
|
5819
5723
|
}
|
|
5820
5724
|
}
|
|
5821
|
-
class ChildrenCache extends
|
|
5725
|
+
class ChildrenCache extends LRUCache {
|
|
5822
5726
|
constructor(maxSize = 16384){
|
|
5823
5727
|
super({
|
|
5824
5728
|
maxSize,
|
|
@@ -10947,7 +10851,7 @@ Usage:
|
|
|
10947
10851
|
type: 'boolean',
|
|
10948
10852
|
description: `Turn on logging to help debug why certain keys or values are not being set as you expect, default is ${config_factory_defaultConfig.dotenvDebug}`
|
|
10949
10853
|
}
|
|
10950
|
-
}).version('version', 'Show version number', "1.8.8
|
|
10854
|
+
}).version('version', 'Show version number', "1.8.8").help().epilogue(`For complete list of configuration options, please visit:
|
|
10951
10855
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
10952
10856
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
10953
10857
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|