@midscene/cli 1.8.8-beta-20260603024013.0 → 1.8.9
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/framework/index.mjs +32 -18
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +1098 -1263
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +36 -18
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +1107 -1266
- package/dist/lib/index.js.map +1 -1
- package/package.json +7 -8
package/dist/es/index.mjs
CHANGED
|
@@ -3,8 +3,7 @@ import { basename as external_node_path_basename, dirname as external_node_path_
|
|
|
3
3
|
import { createReportCliCommands } from "@midscene/core";
|
|
4
4
|
import { runToolsCLI } from "@midscene/shared/cli";
|
|
5
5
|
import { getDebug } from "@midscene/shared/logger";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { channel, tracingChannel } from "node:diagnostics_channel";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
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";
|
|
@@ -13,10 +12,8 @@ import { fileURLToPath as external_url_fileURLToPath } from "url";
|
|
|
13
12
|
import { cwd as external_node_process_cwd } from "node:process";
|
|
14
13
|
import { interpolateEnvVars } from "@midscene/core/yaml";
|
|
15
14
|
import lodash_merge from "lodash.merge";
|
|
16
|
-
import { emitRstestProject } from "@midscene/testing-framework";
|
|
17
15
|
import { getMidsceneRunSubDir } from "@midscene/shared/common";
|
|
18
16
|
import { createRequire } from "node:module";
|
|
19
|
-
import { runRstestWithVirtualModules } from "@midscene/shared/rstest";
|
|
20
17
|
import "@rstest/core";
|
|
21
18
|
import "@midscene/web/puppeteer-agent-launcher";
|
|
22
19
|
import "puppeteer";
|
|
@@ -295,6 +292,199 @@ var __webpack_modules__ = {
|
|
|
295
292
|
get: assembleStyles
|
|
296
293
|
});
|
|
297
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
|
+
},
|
|
298
488
|
"../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
299
489
|
const ansiStyles = __webpack_require__("../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js");
|
|
300
490
|
const { stdout: stdoutColor, stderr: stderrColor } = __webpack_require__("../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js");
|
|
@@ -2836,202 +3026,10 @@ var __webpack_modules__ = {
|
|
|
2836
3026
|
"./src/index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
2837
3027
|
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
2838
3028
|
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
2839
|
-
var package_namespaceObject =
|
|
2840
|
-
|
|
2841
|
-
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
2842
|
-
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
2843
|
-
const r = null !== ma && null != mb && range(ma, mb, str);
|
|
2844
|
-
return r && {
|
|
2845
|
-
start: r[0],
|
|
2846
|
-
end: r[1],
|
|
2847
|
-
pre: str.slice(0, r[0]),
|
|
2848
|
-
body: str.slice(r[0] + ma.length, r[1]),
|
|
2849
|
-
post: str.slice(r[1] + mb.length)
|
|
2850
|
-
};
|
|
3029
|
+
var package_namespaceObject = {
|
|
3030
|
+
rE: "1.8.9"
|
|
2851
3031
|
};
|
|
2852
|
-
|
|
2853
|
-
const m = str.match(reg);
|
|
2854
|
-
return m ? m[0] : null;
|
|
2855
|
-
};
|
|
2856
|
-
const range = (a, b, str)=>{
|
|
2857
|
-
let begs, beg, left, right, result;
|
|
2858
|
-
let ai = str.indexOf(a);
|
|
2859
|
-
let bi = str.indexOf(b, ai + 1);
|
|
2860
|
-
let i = ai;
|
|
2861
|
-
if (ai >= 0 && bi > 0) {
|
|
2862
|
-
if (a === b) return [
|
|
2863
|
-
ai,
|
|
2864
|
-
bi
|
|
2865
|
-
];
|
|
2866
|
-
begs = [];
|
|
2867
|
-
left = str.length;
|
|
2868
|
-
while(i >= 0 && !result){
|
|
2869
|
-
if (i === ai) {
|
|
2870
|
-
begs.push(i);
|
|
2871
|
-
ai = str.indexOf(a, i + 1);
|
|
2872
|
-
} else if (1 === begs.length) {
|
|
2873
|
-
const r = begs.pop();
|
|
2874
|
-
if (void 0 !== r) result = [
|
|
2875
|
-
r,
|
|
2876
|
-
bi
|
|
2877
|
-
];
|
|
2878
|
-
} else {
|
|
2879
|
-
beg = begs.pop();
|
|
2880
|
-
if (void 0 !== beg && beg < left) {
|
|
2881
|
-
left = beg;
|
|
2882
|
-
right = bi;
|
|
2883
|
-
}
|
|
2884
|
-
bi = str.indexOf(b, i + 1);
|
|
2885
|
-
}
|
|
2886
|
-
i = ai < bi && ai >= 0 ? ai : bi;
|
|
2887
|
-
}
|
|
2888
|
-
if (begs.length && void 0 !== right) result = [
|
|
2889
|
-
left,
|
|
2890
|
-
right
|
|
2891
|
-
];
|
|
2892
|
-
}
|
|
2893
|
-
return result;
|
|
2894
|
-
};
|
|
2895
|
-
const escSlash = '\0SLASH' + Math.random() + '\0';
|
|
2896
|
-
const escOpen = '\0OPEN' + Math.random() + '\0';
|
|
2897
|
-
const escClose = '\0CLOSE' + Math.random() + '\0';
|
|
2898
|
-
const escComma = '\0COMMA' + Math.random() + '\0';
|
|
2899
|
-
const escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
2900
|
-
const escSlashPattern = new RegExp(escSlash, 'g');
|
|
2901
|
-
const escOpenPattern = new RegExp(escOpen, 'g');
|
|
2902
|
-
const escClosePattern = new RegExp(escClose, 'g');
|
|
2903
|
-
const escCommaPattern = new RegExp(escComma, 'g');
|
|
2904
|
-
const escPeriodPattern = new RegExp(escPeriod, 'g');
|
|
2905
|
-
const slashPattern = /\\\\/g;
|
|
2906
|
-
const openPattern = /\\{/g;
|
|
2907
|
-
const closePattern = /\\}/g;
|
|
2908
|
-
const commaPattern = /\\,/g;
|
|
2909
|
-
const periodPattern = /\\\./g;
|
|
2910
|
-
const EXPANSION_MAX = 100000;
|
|
2911
|
-
function numeric(str) {
|
|
2912
|
-
return isNaN(str) ? str.charCodeAt(0) : parseInt(str, 10);
|
|
2913
|
-
}
|
|
2914
|
-
function escapeBraces(str) {
|
|
2915
|
-
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
2916
|
-
}
|
|
2917
|
-
function unescapeBraces(str) {
|
|
2918
|
-
return str.replace(escSlashPattern, '\\').replace(escOpenPattern, '{').replace(escClosePattern, '}').replace(escCommaPattern, ',').replace(escPeriodPattern, '.');
|
|
2919
|
-
}
|
|
2920
|
-
function parseCommaParts(str) {
|
|
2921
|
-
if (!str) return [
|
|
2922
|
-
''
|
|
2923
|
-
];
|
|
2924
|
-
const parts = [];
|
|
2925
|
-
const m = balanced('{', '}', str);
|
|
2926
|
-
if (!m) return str.split(',');
|
|
2927
|
-
const { pre, body, post } = m;
|
|
2928
|
-
const p = pre.split(',');
|
|
2929
|
-
p[p.length - 1] += '{' + body + '}';
|
|
2930
|
-
const postParts = parseCommaParts(post);
|
|
2931
|
-
if (post.length) {
|
|
2932
|
-
p[p.length - 1] += postParts.shift();
|
|
2933
|
-
p.push.apply(p, postParts);
|
|
2934
|
-
}
|
|
2935
|
-
parts.push.apply(parts, p);
|
|
2936
|
-
return parts;
|
|
2937
|
-
}
|
|
2938
|
-
function expand(str, options = {}) {
|
|
2939
|
-
if (!str) return [];
|
|
2940
|
-
const { max = EXPANSION_MAX } = options;
|
|
2941
|
-
if ('{}' === str.slice(0, 2)) str = '\\{\\}' + str.slice(2);
|
|
2942
|
-
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
2943
|
-
}
|
|
2944
|
-
function embrace(str) {
|
|
2945
|
-
return '{' + str + '}';
|
|
2946
|
-
}
|
|
2947
|
-
function isPadded(el) {
|
|
2948
|
-
return /^-?0\d/.test(el);
|
|
2949
|
-
}
|
|
2950
|
-
function lte(i, y) {
|
|
2951
|
-
return i <= y;
|
|
2952
|
-
}
|
|
2953
|
-
function gte(i, y) {
|
|
2954
|
-
return i >= y;
|
|
2955
|
-
}
|
|
2956
|
-
function expand_(str, max, isTop) {
|
|
2957
|
-
const expansions = [];
|
|
2958
|
-
const m = balanced('{', '}', str);
|
|
2959
|
-
if (!m) return [
|
|
2960
|
-
str
|
|
2961
|
-
];
|
|
2962
|
-
const pre = m.pre;
|
|
2963
|
-
const post = m.post.length ? expand_(m.post, max, false) : [
|
|
2964
|
-
''
|
|
2965
|
-
];
|
|
2966
|
-
if (/\$$/.test(m.pre)) for(let k = 0; k < post.length && k < max; k++){
|
|
2967
|
-
const expansion = pre + '{' + m.body + '}' + post[k];
|
|
2968
|
-
expansions.push(expansion);
|
|
2969
|
-
}
|
|
2970
|
-
else {
|
|
2971
|
-
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
2972
|
-
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
2973
|
-
const isSequence = isNumericSequence || isAlphaSequence;
|
|
2974
|
-
const isOptions = m.body.indexOf(',') >= 0;
|
|
2975
|
-
if (!isSequence && !isOptions) {
|
|
2976
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
2977
|
-
str = m.pre + '{' + m.body + escClose + m.post;
|
|
2978
|
-
return expand_(str, max, true);
|
|
2979
|
-
}
|
|
2980
|
-
return [
|
|
2981
|
-
str
|
|
2982
|
-
];
|
|
2983
|
-
}
|
|
2984
|
-
let n;
|
|
2985
|
-
if (isSequence) n = m.body.split(/\.\./);
|
|
2986
|
-
else {
|
|
2987
|
-
n = parseCommaParts(m.body);
|
|
2988
|
-
if (1 === n.length && void 0 !== n[0]) {
|
|
2989
|
-
n = expand_(n[0], max, false).map(embrace);
|
|
2990
|
-
if (1 === n.length) return post.map((p)=>m.pre + n[0] + p);
|
|
2991
|
-
}
|
|
2992
|
-
}
|
|
2993
|
-
let N;
|
|
2994
|
-
if (isSequence && void 0 !== n[0] && void 0 !== n[1]) {
|
|
2995
|
-
const x = numeric(n[0]);
|
|
2996
|
-
const y = numeric(n[1]);
|
|
2997
|
-
const width = Math.max(n[0].length, n[1].length);
|
|
2998
|
-
let incr = 3 === n.length && void 0 !== n[2] ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
2999
|
-
let test = lte;
|
|
3000
|
-
const reverse = y < x;
|
|
3001
|
-
if (reverse) {
|
|
3002
|
-
incr *= -1;
|
|
3003
|
-
test = gte;
|
|
3004
|
-
}
|
|
3005
|
-
const pad = n.some(isPadded);
|
|
3006
|
-
N = [];
|
|
3007
|
-
for(let i = x; test(i, y); i += incr){
|
|
3008
|
-
let c;
|
|
3009
|
-
if (isAlphaSequence) {
|
|
3010
|
-
c = String.fromCharCode(i);
|
|
3011
|
-
if ('\\' === c) c = '';
|
|
3012
|
-
} else {
|
|
3013
|
-
c = String(i);
|
|
3014
|
-
if (pad) {
|
|
3015
|
-
const need = width - c.length;
|
|
3016
|
-
if (need > 0) {
|
|
3017
|
-
const z = new Array(need + 1).join('0');
|
|
3018
|
-
c = i < 0 ? '-' + z + c.slice(1) : z + c;
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
}
|
|
3022
|
-
N.push(c);
|
|
3023
|
-
}
|
|
3024
|
-
} else {
|
|
3025
|
-
N = [];
|
|
3026
|
-
for(let j = 0; j < n.length; j++)N.push.apply(N, expand_(n[j], max, false));
|
|
3027
|
-
}
|
|
3028
|
-
for(let j = 0; j < N.length; j++)for(let k = 0; k < post.length && expansions.length < max; k++){
|
|
3029
|
-
const expansion = pre + N[j] + post[k];
|
|
3030
|
-
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3033
|
-
return expansions;
|
|
3034
|
-
}
|
|
3032
|
+
var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
|
|
3035
3033
|
const MAX_PATTERN_LENGTH = 65536;
|
|
3036
3034
|
const assertValidPattern = (pattern)=>{
|
|
3037
3035
|
if ('string' != typeof pattern) throw new TypeError('invalid pattern');
|
|
@@ -3197,11 +3195,7 @@ var __webpack_modules__ = {
|
|
|
3197
3195
|
true
|
|
3198
3196
|
];
|
|
3199
3197
|
};
|
|
3200
|
-
const unescape_unescape = (s, { windowsPathsNoEscape = false
|
|
3201
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2').replace(/\\([^/])/g, '$1');
|
|
3202
|
-
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2').replace(/\\([^/{}])/g, '$1');
|
|
3203
|
-
};
|
|
3204
|
-
var ast_a;
|
|
3198
|
+
const unescape_unescape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1');
|
|
3205
3199
|
const types = new Set([
|
|
3206
3200
|
'!',
|
|
3207
3201
|
'?',
|
|
@@ -3210,168 +3204,6 @@ var __webpack_modules__ = {
|
|
|
3210
3204
|
'@'
|
|
3211
3205
|
]);
|
|
3212
3206
|
const isExtglobType = (c)=>types.has(c);
|
|
3213
|
-
const isExtglobAST = (c)=>isExtglobType(c.type);
|
|
3214
|
-
const adoptionMap = new Map([
|
|
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
|
-
]
|
|
3250
|
-
]);
|
|
3251
|
-
const adoptionWithSpaceMap = new Map([
|
|
3252
|
-
[
|
|
3253
|
-
'!',
|
|
3254
|
-
[
|
|
3255
|
-
'?'
|
|
3256
|
-
]
|
|
3257
|
-
],
|
|
3258
|
-
[
|
|
3259
|
-
'@',
|
|
3260
|
-
[
|
|
3261
|
-
'?'
|
|
3262
|
-
]
|
|
3263
|
-
],
|
|
3264
|
-
[
|
|
3265
|
-
'+',
|
|
3266
|
-
[
|
|
3267
|
-
'?',
|
|
3268
|
-
'*'
|
|
3269
|
-
]
|
|
3270
|
-
]
|
|
3271
|
-
]);
|
|
3272
|
-
const adoptionAnyMap = new Map([
|
|
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
|
-
]
|
|
3312
|
-
]);
|
|
3313
|
-
const usurpMap = new Map([
|
|
3314
|
-
[
|
|
3315
|
-
'!',
|
|
3316
|
-
new Map([
|
|
3317
|
-
[
|
|
3318
|
-
'!',
|
|
3319
|
-
'@'
|
|
3320
|
-
]
|
|
3321
|
-
])
|
|
3322
|
-
],
|
|
3323
|
-
[
|
|
3324
|
-
'?',
|
|
3325
|
-
new Map([
|
|
3326
|
-
[
|
|
3327
|
-
'*',
|
|
3328
|
-
'*'
|
|
3329
|
-
],
|
|
3330
|
-
[
|
|
3331
|
-
'+',
|
|
3332
|
-
'*'
|
|
3333
|
-
]
|
|
3334
|
-
])
|
|
3335
|
-
],
|
|
3336
|
-
[
|
|
3337
|
-
'@',
|
|
3338
|
-
new Map([
|
|
3339
|
-
[
|
|
3340
|
-
'!',
|
|
3341
|
-
'!'
|
|
3342
|
-
],
|
|
3343
|
-
[
|
|
3344
|
-
'?',
|
|
3345
|
-
'?'
|
|
3346
|
-
],
|
|
3347
|
-
[
|
|
3348
|
-
'@',
|
|
3349
|
-
'@'
|
|
3350
|
-
],
|
|
3351
|
-
[
|
|
3352
|
-
'*',
|
|
3353
|
-
'*'
|
|
3354
|
-
],
|
|
3355
|
-
[
|
|
3356
|
-
'+',
|
|
3357
|
-
'+'
|
|
3358
|
-
]
|
|
3359
|
-
])
|
|
3360
|
-
],
|
|
3361
|
-
[
|
|
3362
|
-
'+',
|
|
3363
|
-
new Map([
|
|
3364
|
-
[
|
|
3365
|
-
'?',
|
|
3366
|
-
'*'
|
|
3367
|
-
],
|
|
3368
|
-
[
|
|
3369
|
-
'*',
|
|
3370
|
-
'*'
|
|
3371
|
-
]
|
|
3372
|
-
])
|
|
3373
|
-
]
|
|
3374
|
-
]);
|
|
3375
3207
|
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
|
|
3376
3208
|
const startNoDot = '(?!\\.)';
|
|
3377
3209
|
const addPatternStart = new Set([
|
|
@@ -3387,7 +3219,6 @@ var __webpack_modules__ = {
|
|
|
3387
3219
|
const qmark = '[^/]';
|
|
3388
3220
|
const star = qmark + '*?';
|
|
3389
3221
|
const starNoEmpty = qmark + '+?';
|
|
3390
|
-
let ID = 0;
|
|
3391
3222
|
class ast_AST {
|
|
3392
3223
|
type;
|
|
3393
3224
|
#root;
|
|
@@ -3401,22 +3232,6 @@ var __webpack_modules__ = {
|
|
|
3401
3232
|
#options;
|
|
3402
3233
|
#toString;
|
|
3403
3234
|
#emptyExt = false;
|
|
3404
|
-
id = ++ID;
|
|
3405
|
-
get depth() {
|
|
3406
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
3407
|
-
}
|
|
3408
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
3409
|
-
return {
|
|
3410
|
-
'@@type': 'AST',
|
|
3411
|
-
id: this.id,
|
|
3412
|
-
type: this.type,
|
|
3413
|
-
root: this.#root.id,
|
|
3414
|
-
parent: this.#parent?.id,
|
|
3415
|
-
depth: this.depth,
|
|
3416
|
-
partsLength: this.#parts.length,
|
|
3417
|
-
parts: this.#parts
|
|
3418
|
-
};
|
|
3419
|
-
}
|
|
3420
3235
|
constructor(type, parent, options = {}){
|
|
3421
3236
|
this.type = type;
|
|
3422
3237
|
if (type) this.#hasMagic = true;
|
|
@@ -3435,7 +3250,9 @@ var __webpack_modules__ = {
|
|
|
3435
3250
|
return this.#hasMagic;
|
|
3436
3251
|
}
|
|
3437
3252
|
toString() {
|
|
3438
|
-
|
|
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('|') + ')';
|
|
3439
3256
|
}
|
|
3440
3257
|
#fillNegs() {
|
|
3441
3258
|
if (this !== this.#root) throw new Error('should only call on root');
|
|
@@ -3460,7 +3277,7 @@ var __webpack_modules__ = {
|
|
|
3460
3277
|
}
|
|
3461
3278
|
push(...parts) {
|
|
3462
3279
|
for (const p of parts)if ('' !== p) {
|
|
3463
|
-
if ('string' != typeof p && !(p instanceof
|
|
3280
|
+
if ('string' != typeof p && !(p instanceof ast_AST && p.#parent === this)) throw new Error('invalid part: ' + p);
|
|
3464
3281
|
this.#parts.push(p);
|
|
3465
3282
|
}
|
|
3466
3283
|
}
|
|
@@ -3480,7 +3297,7 @@ var __webpack_modules__ = {
|
|
|
3480
3297
|
const p = this.#parent;
|
|
3481
3298
|
for(let i = 0; i < this.#parentIndex; i++){
|
|
3482
3299
|
const pp = p.#parts[i];
|
|
3483
|
-
if (!(pp instanceof
|
|
3300
|
+
if (!(pp instanceof ast_AST && '!' === pp.type)) return false;
|
|
3484
3301
|
}
|
|
3485
3302
|
return true;
|
|
3486
3303
|
}
|
|
@@ -3497,12 +3314,11 @@ var __webpack_modules__ = {
|
|
|
3497
3314
|
else this.push(part.clone(this));
|
|
3498
3315
|
}
|
|
3499
3316
|
clone(parent) {
|
|
3500
|
-
const c = new
|
|
3317
|
+
const c = new ast_AST(this.type, parent);
|
|
3501
3318
|
for (const p of this.#parts)c.copyIn(p);
|
|
3502
3319
|
return c;
|
|
3503
3320
|
}
|
|
3504
|
-
static #parseAST(str, ast, pos, opt
|
|
3505
|
-
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
3321
|
+
static #parseAST(str, ast, pos, opt) {
|
|
3506
3322
|
let escaping = false;
|
|
3507
3323
|
let inBrace = false;
|
|
3508
3324
|
let braceStart = -1;
|
|
@@ -3531,12 +3347,11 @@ var __webpack_modules__ = {
|
|
|
3531
3347
|
acc += c;
|
|
3532
3348
|
continue;
|
|
3533
3349
|
}
|
|
3534
|
-
|
|
3535
|
-
if (doRecurse) {
|
|
3350
|
+
if (!opt.noext && isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3536
3351
|
ast.push(acc);
|
|
3537
3352
|
acc = '';
|
|
3538
|
-
const ext = new
|
|
3539
|
-
i =
|
|
3353
|
+
const ext = new ast_AST(c, ast);
|
|
3354
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3540
3355
|
ast.push(ext);
|
|
3541
3356
|
continue;
|
|
3542
3357
|
}
|
|
@@ -3546,7 +3361,7 @@ var __webpack_modules__ = {
|
|
|
3546
3361
|
return i;
|
|
3547
3362
|
}
|
|
3548
3363
|
let i = pos + 1;
|
|
3549
|
-
let part = new
|
|
3364
|
+
let part = new ast_AST(null, ast);
|
|
3550
3365
|
const parts = [];
|
|
3551
3366
|
let acc = '';
|
|
3552
3367
|
while(i < str.length){
|
|
@@ -3570,21 +3385,19 @@ var __webpack_modules__ = {
|
|
|
3570
3385
|
acc += c;
|
|
3571
3386
|
continue;
|
|
3572
3387
|
}
|
|
3573
|
-
|
|
3574
|
-
if (doRecurse) {
|
|
3575
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
3388
|
+
if (isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3576
3389
|
part.push(acc);
|
|
3577
3390
|
acc = '';
|
|
3578
|
-
const ext = new
|
|
3391
|
+
const ext = new ast_AST(c, part);
|
|
3579
3392
|
part.push(ext);
|
|
3580
|
-
i =
|
|
3393
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3581
3394
|
continue;
|
|
3582
3395
|
}
|
|
3583
3396
|
if ('|' === c) {
|
|
3584
3397
|
part.push(acc);
|
|
3585
3398
|
acc = '';
|
|
3586
3399
|
parts.push(part);
|
|
3587
|
-
part = new
|
|
3400
|
+
part = new ast_AST(null, ast);
|
|
3588
3401
|
continue;
|
|
3589
3402
|
}
|
|
3590
3403
|
if (')' === c) {
|
|
@@ -3603,55 +3416,9 @@ var __webpack_modules__ = {
|
|
|
3603
3416
|
];
|
|
3604
3417
|
return i;
|
|
3605
3418
|
}
|
|
3606
|
-
#canAdoptWithSpace(child) {
|
|
3607
|
-
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
3608
|
-
}
|
|
3609
|
-
#canAdopt(child, map = adoptionMap) {
|
|
3610
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type) return false;
|
|
3611
|
-
const gc = child.#parts[0];
|
|
3612
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3613
|
-
return this.#canAdoptType(gc.type, map);
|
|
3614
|
-
}
|
|
3615
|
-
#canAdoptType(c, map = adoptionAnyMap) {
|
|
3616
|
-
return !!map.get(this.type)?.includes(c);
|
|
3617
|
-
}
|
|
3618
|
-
#adoptWithSpace(child, index) {
|
|
3619
|
-
const gc = child.#parts[0];
|
|
3620
|
-
const blank = new ast_a(null, gc, this.options);
|
|
3621
|
-
blank.#parts.push('');
|
|
3622
|
-
gc.push(blank);
|
|
3623
|
-
this.#adopt(child, index);
|
|
3624
|
-
}
|
|
3625
|
-
#adopt(child, index) {
|
|
3626
|
-
const gc = child.#parts[0];
|
|
3627
|
-
this.#parts.splice(index, 1, ...gc.#parts);
|
|
3628
|
-
for (const p of gc.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3629
|
-
this.#toString = void 0;
|
|
3630
|
-
}
|
|
3631
|
-
#canUsurpType(c) {
|
|
3632
|
-
const m = usurpMap.get(this.type);
|
|
3633
|
-
return !!m?.has(c);
|
|
3634
|
-
}
|
|
3635
|
-
#canUsurp(child) {
|
|
3636
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type || 1 !== this.#parts.length) return false;
|
|
3637
|
-
const gc = child.#parts[0];
|
|
3638
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3639
|
-
return this.#canUsurpType(gc.type);
|
|
3640
|
-
}
|
|
3641
|
-
#usurp(child) {
|
|
3642
|
-
const m = usurpMap.get(this.type);
|
|
3643
|
-
const gc = child.#parts[0];
|
|
3644
|
-
const nt = m?.get(gc.type);
|
|
3645
|
-
if (!nt) return false;
|
|
3646
|
-
this.#parts = gc.#parts;
|
|
3647
|
-
for (const p of this.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3648
|
-
this.type = nt;
|
|
3649
|
-
this.#toString = void 0;
|
|
3650
|
-
this.#emptyExt = false;
|
|
3651
|
-
}
|
|
3652
3419
|
static fromGlob(pattern, options = {}) {
|
|
3653
|
-
const ast = new
|
|
3654
|
-
|
|
3420
|
+
const ast = new ast_AST(null, void 0, options);
|
|
3421
|
+
ast_AST.#parseAST(pattern, ast, 0, options);
|
|
3655
3422
|
return ast;
|
|
3656
3423
|
}
|
|
3657
3424
|
toMMPattern() {
|
|
@@ -3671,14 +3438,11 @@ var __webpack_modules__ = {
|
|
|
3671
3438
|
}
|
|
3672
3439
|
toRegExpSource(allowDot) {
|
|
3673
3440
|
const dot = allowDot ?? !!this.#options.dot;
|
|
3674
|
-
if (this.#root === this)
|
|
3675
|
-
|
|
3676
|
-
this
|
|
3677
|
-
}
|
|
3678
|
-
if (!isExtglobAST(this)) {
|
|
3679
|
-
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();
|
|
3680
3444
|
const src = this.#parts.map((p)=>{
|
|
3681
|
-
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);
|
|
3682
3446
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
3683
3447
|
this.#uflag = this.#uflag || uflag;
|
|
3684
3448
|
return re;
|
|
@@ -3710,12 +3474,11 @@ var __webpack_modules__ = {
|
|
|
3710
3474
|
let body = this.#partsToRegExp(dot);
|
|
3711
3475
|
if (this.isStart() && this.isEnd() && !body && '!' !== this.type) {
|
|
3712
3476
|
const s = this.toString();
|
|
3713
|
-
|
|
3714
|
-
me.#parts = [
|
|
3477
|
+
this.#parts = [
|
|
3715
3478
|
s
|
|
3716
3479
|
];
|
|
3717
|
-
|
|
3718
|
-
|
|
3480
|
+
this.type = null;
|
|
3481
|
+
this.#hasMagic = void 0;
|
|
3719
3482
|
return [
|
|
3720
3483
|
s,
|
|
3721
3484
|
unescape_unescape(this.toString()),
|
|
@@ -3739,32 +3502,6 @@ var __webpack_modules__ = {
|
|
|
3739
3502
|
this.#uflag
|
|
3740
3503
|
];
|
|
3741
3504
|
}
|
|
3742
|
-
#flatten() {
|
|
3743
|
-
if (isExtglobAST(this)) {
|
|
3744
|
-
let iterations = 0;
|
|
3745
|
-
let done = false;
|
|
3746
|
-
do {
|
|
3747
|
-
done = true;
|
|
3748
|
-
for(let i = 0; i < this.#parts.length; i++){
|
|
3749
|
-
const c = this.#parts[i];
|
|
3750
|
-
if ('object' == typeof c) {
|
|
3751
|
-
c.#flatten();
|
|
3752
|
-
if (this.#canAdopt(c)) {
|
|
3753
|
-
done = false;
|
|
3754
|
-
this.#adopt(c, i);
|
|
3755
|
-
} else if (this.#canAdoptWithSpace(c)) {
|
|
3756
|
-
done = false;
|
|
3757
|
-
this.#adoptWithSpace(c, i);
|
|
3758
|
-
} else if (this.#canUsurp(c)) {
|
|
3759
|
-
done = false;
|
|
3760
|
-
this.#usurp(c);
|
|
3761
|
-
}
|
|
3762
|
-
}
|
|
3763
|
-
}
|
|
3764
|
-
}while (!done && ++iterations < 10);
|
|
3765
|
-
} else for (const p of this.#parts)if ('object' == typeof p) p.#flatten();
|
|
3766
|
-
this.#toString = void 0;
|
|
3767
|
-
}
|
|
3768
3505
|
#partsToRegExp(dot) {
|
|
3769
3506
|
return this.#parts.map((p)=>{
|
|
3770
3507
|
if ('string' == typeof p) throw new Error('string type in extglob ast??');
|
|
@@ -3777,7 +3514,6 @@ var __webpack_modules__ = {
|
|
|
3777
3514
|
let escaping = false;
|
|
3778
3515
|
let re = '';
|
|
3779
3516
|
let uflag = false;
|
|
3780
|
-
let inStar = false;
|
|
3781
3517
|
for(let i = 0; i < glob.length; i++){
|
|
3782
3518
|
const c = glob.charAt(i);
|
|
3783
3519
|
if (escaping) {
|
|
@@ -3785,14 +3521,6 @@ var __webpack_modules__ = {
|
|
|
3785
3521
|
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
3786
3522
|
continue;
|
|
3787
3523
|
}
|
|
3788
|
-
if ('*' === c) {
|
|
3789
|
-
if (inStar) continue;
|
|
3790
|
-
inStar = true;
|
|
3791
|
-
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
3792
|
-
hasMagic = true;
|
|
3793
|
-
continue;
|
|
3794
|
-
}
|
|
3795
|
-
inStar = false;
|
|
3796
3524
|
if ('\\' === c) {
|
|
3797
3525
|
if (i === glob.length - 1) re += '\\\\';
|
|
3798
3526
|
else escaping = true;
|
|
@@ -3808,6 +3536,12 @@ var __webpack_modules__ = {
|
|
|
3808
3536
|
continue;
|
|
3809
3537
|
}
|
|
3810
3538
|
}
|
|
3539
|
+
if ('*' === c) {
|
|
3540
|
+
if (noEmpty && '*' === glob) re += starNoEmpty;
|
|
3541
|
+
else re += star;
|
|
3542
|
+
hasMagic = true;
|
|
3543
|
+
continue;
|
|
3544
|
+
}
|
|
3811
3545
|
if ('?' === c) {
|
|
3812
3546
|
re += qmark;
|
|
3813
3547
|
hasMagic = true;
|
|
@@ -3823,17 +3557,13 @@ var __webpack_modules__ = {
|
|
|
3823
3557
|
];
|
|
3824
3558
|
}
|
|
3825
3559
|
}
|
|
3826
|
-
|
|
3827
|
-
const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})=>{
|
|
3828
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, '[$&]') : s.replace(/[?*()[\]\\{}]/g, '\\$&');
|
|
3829
|
-
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
3830
|
-
};
|
|
3560
|
+
const escape_escape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
3831
3561
|
const minimatch = (p, pattern, options = {})=>{
|
|
3832
3562
|
assertValidPattern(pattern);
|
|
3833
3563
|
if (!options.nocomment && '#' === pattern.charAt(0)) return false;
|
|
3834
3564
|
return new esm_Minimatch(pattern, options).match(p);
|
|
3835
3565
|
};
|
|
3836
|
-
const starDotExtRE = /^\*+([
|
|
3566
|
+
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
3837
3567
|
const starDotExtTest = (ext)=>(f)=>!f.startsWith('.') && f.endsWith(ext);
|
|
3838
3568
|
const starDotExtTestDot = (ext)=>(f)=>f.endsWith(ext);
|
|
3839
3569
|
const starDotExtTestNocase = (ext)=>{
|
|
@@ -3852,7 +3582,7 @@ var __webpack_modules__ = {
|
|
|
3852
3582
|
const starRE = /^\*+$/;
|
|
3853
3583
|
const starTest = (f)=>0 !== f.length && !f.startsWith('.');
|
|
3854
3584
|
const starTestDot = (f)=>0 !== f.length && '.' !== f && '..' !== f;
|
|
3855
|
-
const qmarksRE = /^\?+([
|
|
3585
|
+
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
3856
3586
|
const qmarksTestNocase = ([$0, ext = ''])=>{
|
|
3857
3587
|
const noext = qmarksTestNoExt([
|
|
3858
3588
|
$0
|
|
@@ -3947,9 +3677,7 @@ var __webpack_modules__ = {
|
|
|
3947
3677
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [
|
|
3948
3678
|
pattern
|
|
3949
3679
|
];
|
|
3950
|
-
return
|
|
3951
|
-
max: options.braceExpandMax
|
|
3952
|
-
});
|
|
3680
|
+
return brace_expansion(pattern);
|
|
3953
3681
|
};
|
|
3954
3682
|
minimatch.braceExpand = braceExpand;
|
|
3955
3683
|
const makeRe = (pattern, options = {})=>new esm_Minimatch(pattern, options).makeRe();
|
|
@@ -3980,18 +3708,15 @@ var __webpack_modules__ = {
|
|
|
3980
3708
|
isWindows;
|
|
3981
3709
|
platform;
|
|
3982
3710
|
windowsNoMagicRoot;
|
|
3983
|
-
maxGlobstarRecursion;
|
|
3984
3711
|
regexp;
|
|
3985
3712
|
constructor(pattern, options = {}){
|
|
3986
3713
|
assertValidPattern(pattern);
|
|
3987
3714
|
options = options || {};
|
|
3988
3715
|
this.options = options;
|
|
3989
|
-
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
3990
3716
|
this.pattern = pattern;
|
|
3991
3717
|
this.platform = options.platform || defaultPlatform;
|
|
3992
3718
|
this.isWindows = 'win32' === this.platform;
|
|
3993
|
-
|
|
3994
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options[awe];
|
|
3719
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options.allowWindowsEscape;
|
|
3995
3720
|
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, '/');
|
|
3996
3721
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
3997
3722
|
this.regexp = null;
|
|
@@ -4058,7 +3783,7 @@ var __webpack_modules__ = {
|
|
|
4058
3783
|
}
|
|
4059
3784
|
preprocess(globParts) {
|
|
4060
3785
|
if (this.options.noglobstar) {
|
|
4061
|
-
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] = '*';
|
|
4062
3787
|
}
|
|
4063
3788
|
const { optimizationLevel = 1 } = this.options;
|
|
4064
3789
|
if (optimizationLevel >= 2) {
|
|
@@ -4121,7 +3846,7 @@ var __webpack_modules__ = {
|
|
|
4121
3846
|
let dd = 0;
|
|
4122
3847
|
while(-1 !== (dd = parts.indexOf('..', dd + 1))){
|
|
4123
3848
|
const p = parts[dd - 1];
|
|
4124
|
-
if (p && '.' !== p && '..' !== p && '**' !== p
|
|
3849
|
+
if (p && '.' !== p && '..' !== p && '**' !== p) {
|
|
4125
3850
|
didSomething = true;
|
|
4126
3851
|
parts.splice(dd - 1, 2);
|
|
4127
3852
|
dd -= 2;
|
|
@@ -4243,8 +3968,7 @@ var __webpack_modules__ = {
|
|
|
4243
3968
|
this.negate = negate;
|
|
4244
3969
|
}
|
|
4245
3970
|
matchOne(file, pattern, partial = false) {
|
|
4246
|
-
|
|
4247
|
-
let patternStartIndex = 0;
|
|
3971
|
+
const options = this.options;
|
|
4248
3972
|
if (this.isWindows) {
|
|
4249
3973
|
const fileDrive = 'string' == typeof file[0] && /^[a-z]:$/i.test(file[0]);
|
|
4250
3974
|
const fileUNC = !fileDrive && '' === file[0] && '' === file[1] && '?' === file[2] && /^[a-z]:$/i.test(file[3]);
|
|
@@ -4259,116 +3983,57 @@ var __webpack_modules__ = {
|
|
|
4259
3983
|
];
|
|
4260
3984
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
4261
3985
|
pattern[pdi] = fd;
|
|
4262
|
-
|
|
4263
|
-
|
|
3986
|
+
if (pdi > fdi) pattern = pattern.slice(pdi);
|
|
3987
|
+
else if (fdi > pdi) file = file.slice(fdi);
|
|
4264
3988
|
}
|
|
4265
3989
|
}
|
|
4266
3990
|
}
|
|
4267
3991
|
const { optimizationLevel = 1 } = this.options;
|
|
4268
3992
|
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
const [head, body, tail] = partial ? [
|
|
4276
|
-
pattern.slice(patternIndex, firstgs),
|
|
4277
|
-
pattern.slice(firstgs + 1),
|
|
4278
|
-
[]
|
|
4279
|
-
] : [
|
|
4280
|
-
pattern.slice(patternIndex, firstgs),
|
|
4281
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
4282
|
-
pattern.slice(lastgs + 1)
|
|
4283
|
-
];
|
|
4284
|
-
if (head.length) {
|
|
4285
|
-
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
4286
|
-
if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
|
|
4287
|
-
fileIndex += head.length;
|
|
4288
|
-
patternIndex += head.length;
|
|
4289
|
-
}
|
|
4290
|
-
let fileTailMatch = 0;
|
|
4291
|
-
if (tail.length) {
|
|
4292
|
-
if (tail.length + fileIndex > file.length) return false;
|
|
4293
|
-
let tailStart = file.length - tail.length;
|
|
4294
|
-
if (this.#matchOne(file, tail, partial, tailStart, 0)) fileTailMatch = tail.length;
|
|
4295
|
-
else {
|
|
4296
|
-
if ('' !== file[file.length - 1] || fileIndex + tail.length === file.length) return false;
|
|
4297
|
-
tailStart--;
|
|
4298
|
-
if (!this.#matchOne(file, tail, partial, tailStart, 0)) return false;
|
|
4299
|
-
fileTailMatch = tail.length + 1;
|
|
4300
|
-
}
|
|
4301
|
-
}
|
|
4302
|
-
if (!body.length) {
|
|
4303
|
-
let sawSome = !!fileTailMatch;
|
|
4304
|
-
for(let i = fileIndex; i < file.length - fileTailMatch; i++){
|
|
4305
|
-
const f = String(file[i]);
|
|
4306
|
-
sawSome = true;
|
|
4307
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4308
|
-
}
|
|
4309
|
-
return partial || sawSome;
|
|
4310
|
-
}
|
|
4311
|
-
const bodySegments = [
|
|
4312
|
-
[
|
|
4313
|
-
[],
|
|
4314
|
-
0
|
|
4315
|
-
]
|
|
4316
|
-
];
|
|
4317
|
-
let currentBody = bodySegments[0];
|
|
4318
|
-
let nonGsParts = 0;
|
|
4319
|
-
const nonGsPartsSums = [
|
|
4320
|
-
0
|
|
4321
|
-
];
|
|
4322
|
-
for (const b of body)if (b === GLOBSTAR) {
|
|
4323
|
-
nonGsPartsSums.push(nonGsParts);
|
|
4324
|
-
currentBody = [
|
|
4325
|
-
[],
|
|
4326
|
-
0
|
|
4327
|
-
];
|
|
4328
|
-
bodySegments.push(currentBody);
|
|
4329
|
-
} else {
|
|
4330
|
-
currentBody[0].push(b);
|
|
4331
|
-
nonGsParts++;
|
|
4332
|
-
}
|
|
4333
|
-
let i = bodySegments.length - 1;
|
|
4334
|
-
const fileLength = file.length - fileTailMatch;
|
|
4335
|
-
for (const b of bodySegments)b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
4336
|
-
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
4337
|
-
}
|
|
4338
|
-
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
4339
|
-
const bs = bodySegments[bodyIndex];
|
|
4340
|
-
if (!bs) {
|
|
4341
|
-
for(let i = fileIndex; i < file.length; i++){
|
|
4342
|
-
sawTail = true;
|
|
4343
|
-
const f = file[i];
|
|
4344
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4345
|
-
}
|
|
4346
|
-
return sawTail;
|
|
4347
|
-
}
|
|
4348
|
-
const [body, after] = bs;
|
|
4349
|
-
while(fileIndex <= after){
|
|
4350
|
-
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
4351
|
-
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
4352
|
-
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
4353
|
-
if (false !== sub) return sub;
|
|
4354
|
-
}
|
|
4355
|
-
const f = file[fileIndex];
|
|
4356
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4357
|
-
fileIndex++;
|
|
4358
|
-
}
|
|
4359
|
-
return partial || null;
|
|
4360
|
-
}
|
|
4361
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
4362
|
-
let fi;
|
|
4363
|
-
let pi;
|
|
4364
|
-
let pl;
|
|
4365
|
-
let fl;
|
|
4366
|
-
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++){
|
|
4367
3999
|
this.debug('matchOne loop');
|
|
4368
|
-
|
|
4369
|
-
|
|
4000
|
+
var p = pattern[pi];
|
|
4001
|
+
var f = file[fi];
|
|
4370
4002
|
this.debug(pattern, p, f);
|
|
4371
|
-
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
|
+
}
|
|
4372
4037
|
let hit;
|
|
4373
4038
|
if ('string' == typeof p) {
|
|
4374
4039
|
hit = f === p;
|
|
@@ -4428,19 +4093,13 @@ var __webpack_modules__ = {
|
|
|
4428
4093
|
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
4429
4094
|
if (void 0 === prev) if (void 0 !== next && next !== GLOBSTAR) pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
|
|
4430
4095
|
else pp[i] = twoStar;
|
|
4431
|
-
else if (void 0 === next) pp[i - 1] = prev + '(
|
|
4096
|
+
else if (void 0 === next) pp[i - 1] = prev + '(?:\\/|' + twoStar + ')?';
|
|
4432
4097
|
else if (next !== GLOBSTAR) {
|
|
4433
4098
|
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
|
|
4434
4099
|
pp[i + 1] = GLOBSTAR;
|
|
4435
4100
|
}
|
|
4436
4101
|
});
|
|
4437
|
-
|
|
4438
|
-
if (this.partial && filtered.length >= 1) {
|
|
4439
|
-
const prefixes = [];
|
|
4440
|
-
for(let i = 1; i <= filtered.length; i++)prefixes.push(filtered.slice(0, i).join('/'));
|
|
4441
|
-
return '(?:' + prefixes.join('|') + ')';
|
|
4442
|
-
}
|
|
4443
|
-
return filtered.join('/');
|
|
4102
|
+
return pp.filter((p)=>p !== GLOBSTAR).join('/');
|
|
4444
4103
|
}).join('|');
|
|
4445
4104
|
const [open, close] = set.length > 1 ? [
|
|
4446
4105
|
'(?:',
|
|
@@ -4450,20 +4109,19 @@ var __webpack_modules__ = {
|
|
|
4450
4109
|
''
|
|
4451
4110
|
];
|
|
4452
4111
|
re = '^' + open + re + close + '$';
|
|
4453
|
-
if (this.partial) re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
|
|
4454
4112
|
if (this.negate) re = '^(?!' + re + ').+$';
|
|
4455
4113
|
try {
|
|
4456
4114
|
this.regexp = new RegExp(re, [
|
|
4457
4115
|
...flags
|
|
4458
4116
|
].join(''));
|
|
4459
|
-
} catch
|
|
4117
|
+
} catch (ex) {
|
|
4460
4118
|
this.regexp = false;
|
|
4461
4119
|
}
|
|
4462
4120
|
return this.regexp;
|
|
4463
4121
|
}
|
|
4464
4122
|
slashSplit(p) {
|
|
4465
4123
|
if (this.preserveMultipleSlashes) return p.split('/');
|
|
4466
|
-
if (this.isWindows && /^\/\/[
|
|
4124
|
+
if (this.isWindows && /^\/\/[^\/]+/.test(p)) return [
|
|
4467
4125
|
'',
|
|
4468
4126
|
...p.split(/\/+/)
|
|
4469
4127
|
];
|
|
@@ -4482,7 +4140,8 @@ var __webpack_modules__ = {
|
|
|
4482
4140
|
this.debug(this.pattern, 'set', set);
|
|
4483
4141
|
let filename = ff[ff.length - 1];
|
|
4484
4142
|
if (!filename) for(let i = ff.length - 2; !filename && i >= 0; i--)filename = ff[i];
|
|
4485
|
-
for
|
|
4143
|
+
for(let i = 0; i < set.length; i++){
|
|
4144
|
+
const pattern = set[i];
|
|
4486
4145
|
let file = ff;
|
|
4487
4146
|
if (options.matchBase && 1 === pattern.length) file = [
|
|
4488
4147
|
filename
|
|
@@ -4504,46 +4163,85 @@ var __webpack_modules__ = {
|
|
|
4504
4163
|
minimatch.Minimatch = esm_Minimatch;
|
|
4505
4164
|
minimatch.escape = escape_escape;
|
|
4506
4165
|
minimatch.unescape = unescape_unescape;
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
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 {
|
|
4515
4215
|
heap;
|
|
4516
4216
|
length;
|
|
4517
|
-
static #
|
|
4518
|
-
static create(
|
|
4519
|
-
|
|
4520
|
-
if (!
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
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;
|
|
4531
4233
|
}
|
|
4532
4234
|
pop() {
|
|
4533
4235
|
return this.heap[--this.length];
|
|
4534
4236
|
}
|
|
4535
|
-
}
|
|
4536
|
-
|
|
4537
|
-
#
|
|
4538
|
-
#
|
|
4539
|
-
#
|
|
4540
|
-
#
|
|
4541
|
-
#
|
|
4542
|
-
#
|
|
4543
|
-
#m;
|
|
4544
|
-
get perf() {
|
|
4545
|
-
return this.#m;
|
|
4546
|
-
}
|
|
4237
|
+
}
|
|
4238
|
+
class LRUCache {
|
|
4239
|
+
#max;
|
|
4240
|
+
#maxSize;
|
|
4241
|
+
#dispose;
|
|
4242
|
+
#disposeAfter;
|
|
4243
|
+
#fetchMethod;
|
|
4244
|
+
#memoMethod;
|
|
4547
4245
|
ttl;
|
|
4548
4246
|
ttlResolution;
|
|
4549
4247
|
ttlAutopurge;
|
|
@@ -4559,613 +4257,823 @@ var __webpack_modules__ = {
|
|
|
4559
4257
|
allowStaleOnFetchAbort;
|
|
4560
4258
|
allowStaleOnFetchRejection;
|
|
4561
4259
|
ignoreFetchAbort;
|
|
4562
|
-
#
|
|
4563
|
-
#
|
|
4564
|
-
#
|
|
4565
|
-
#
|
|
4566
|
-
#
|
|
4567
|
-
#
|
|
4568
|
-
#
|
|
4569
|
-
#
|
|
4570
|
-
#
|
|
4571
|
-
#
|
|
4572
|
-
#
|
|
4573
|
-
#
|
|
4574
|
-
#
|
|
4575
|
-
#
|
|
4576
|
-
#
|
|
4577
|
-
#
|
|
4578
|
-
#
|
|
4579
|
-
|
|
4580
|
-
#j;
|
|
4581
|
-
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) {
|
|
4582
4278
|
return {
|
|
4583
|
-
starts:
|
|
4584
|
-
ttls:
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
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,
|
|
4592
4287
|
get head () {
|
|
4593
|
-
return
|
|
4288
|
+
return c.#head;
|
|
4594
4289
|
},
|
|
4595
4290
|
get tail () {
|
|
4596
|
-
return
|
|
4291
|
+
return c.#tail;
|
|
4597
4292
|
},
|
|
4598
|
-
free:
|
|
4599
|
-
isBackgroundFetch: (
|
|
4600
|
-
backgroundFetch: (
|
|
4601
|
-
moveToTail: (
|
|
4602
|
-
indexes: (
|
|
4603
|
-
rindexes: (
|
|
4604
|
-
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)
|
|
4605
4300
|
};
|
|
4606
4301
|
}
|
|
4607
4302
|
get max() {
|
|
4608
|
-
return this.#
|
|
4303
|
+
return this.#max;
|
|
4609
4304
|
}
|
|
4610
4305
|
get maxSize() {
|
|
4611
|
-
return this.#
|
|
4306
|
+
return this.#maxSize;
|
|
4612
4307
|
}
|
|
4613
4308
|
get calculatedSize() {
|
|
4614
|
-
return this.#
|
|
4309
|
+
return this.#calculatedSize;
|
|
4615
4310
|
}
|
|
4616
4311
|
get size() {
|
|
4617
|
-
return this.#
|
|
4312
|
+
return this.#size;
|
|
4618
4313
|
}
|
|
4619
4314
|
get fetchMethod() {
|
|
4620
|
-
return this.#
|
|
4315
|
+
return this.#fetchMethod;
|
|
4621
4316
|
}
|
|
4622
4317
|
get memoMethod() {
|
|
4623
|
-
return this.#
|
|
4318
|
+
return this.#memoMethod;
|
|
4624
4319
|
}
|
|
4625
4320
|
get dispose() {
|
|
4626
|
-
return this.#
|
|
4627
|
-
}
|
|
4628
|
-
get onInsert() {
|
|
4629
|
-
return this.#D;
|
|
4321
|
+
return this.#dispose;
|
|
4630
4322
|
}
|
|
4631
4323
|
get disposeAfter() {
|
|
4632
|
-
return this.#
|
|
4633
|
-
}
|
|
4634
|
-
constructor(
|
|
4635
|
-
|
|
4636
|
-
if (
|
|
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
|
-
|
|
4669
|
-
|
|
4670
|
-
this.#
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
this
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
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
|
+
}
|
|
4678
4415
|
};
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
let f = r.now - c;
|
|
4693
|
-
r.remainingTTL = l - f;
|
|
4416
|
+
this.#updateItemAge = (index)=>{
|
|
4417
|
+
starts[index] = 0 !== ttls[index] ? perf.now() : 0;
|
|
4418
|
+
};
|
|
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;
|
|
4694
4429
|
}
|
|
4695
4430
|
};
|
|
4696
|
-
let
|
|
4697
|
-
|
|
4431
|
+
let cachedNow = 0;
|
|
4432
|
+
const getNow = ()=>{
|
|
4433
|
+
const n = perf.now();
|
|
4698
4434
|
if (this.ttlResolution > 0) {
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4435
|
+
cachedNow = n;
|
|
4436
|
+
const t1 = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
4437
|
+
if (t1.unref) t1.unref();
|
|
4702
4438
|
}
|
|
4703
|
-
return
|
|
4439
|
+
return n;
|
|
4440
|
+
};
|
|
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;
|
|
4704
4449
|
};
|
|
4705
|
-
this
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
if (!l || !c) return 1 / 0;
|
|
4710
|
-
let f = (n || o()) - c;
|
|
4711
|
-
return l - f;
|
|
4712
|
-
}, this.#p = (r)=>{
|
|
4713
|
-
let h = t1[r], l = e1[r];
|
|
4714
|
-
return !!l && !!h && (n || o()) - h > l;
|
|
4450
|
+
this.#isStale = (index)=>{
|
|
4451
|
+
const s = starts[index];
|
|
4452
|
+
const t1 = ttls[index];
|
|
4453
|
+
return !!t1 && !!s && (cachedNow || getNow()) - s > t1;
|
|
4715
4454
|
};
|
|
4716
4455
|
}
|
|
4717
|
-
#
|
|
4718
|
-
#
|
|
4719
|
-
#
|
|
4720
|
-
#
|
|
4721
|
-
#
|
|
4722
|
-
|
|
4723
|
-
this.#
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
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)');
|
|
4730
4474
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
4731
|
-
return
|
|
4732
|
-
}
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
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;
|
|
4736
4487
|
}
|
|
4737
|
-
this.#b += e1[t1], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
4738
4488
|
};
|
|
4739
4489
|
}
|
|
4740
|
-
#
|
|
4741
|
-
#
|
|
4742
|
-
#
|
|
4743
|
-
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');
|
|
4744
4494
|
return 0;
|
|
4745
4495
|
};
|
|
4746
|
-
*#
|
|
4747
|
-
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
|
+
}
|
|
4748
4503
|
}
|
|
4749
|
-
*#
|
|
4750
|
-
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
|
+
}
|
|
4751
4511
|
}
|
|
4752
|
-
#
|
|
4753
|
-
return void 0 !==
|
|
4512
|
+
#isValidIndex(index) {
|
|
4513
|
+
return void 0 !== index && this.#keyMap.get(this.#keyList[index]) === index;
|
|
4754
4514
|
}
|
|
4755
4515
|
*entries() {
|
|
4756
|
-
for (
|
|
4757
|
-
this.#i
|
|
4758
|
-
this.#
|
|
4759
|
-
]
|
|
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
|
+
];
|
|
4760
4520
|
}
|
|
4761
4521
|
*rentries() {
|
|
4762
|
-
for (
|
|
4763
|
-
this.#i
|
|
4764
|
-
this.#
|
|
4765
|
-
]
|
|
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
|
+
];
|
|
4766
4526
|
}
|
|
4767
4527
|
*keys() {
|
|
4768
|
-
for (
|
|
4769
|
-
|
|
4770
|
-
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;
|
|
4771
4531
|
}
|
|
4772
4532
|
}
|
|
4773
4533
|
*rkeys() {
|
|
4774
|
-
for (
|
|
4775
|
-
|
|
4776
|
-
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;
|
|
4777
4537
|
}
|
|
4778
4538
|
}
|
|
4779
4539
|
*values() {
|
|
4780
|
-
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
|
+
}
|
|
4781
4544
|
}
|
|
4782
4545
|
*rvalues() {
|
|
4783
|
-
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
|
+
}
|
|
4784
4550
|
}
|
|
4785
4551
|
[Symbol.iterator]() {
|
|
4786
4552
|
return this.entries();
|
|
4787
4553
|
}
|
|
4788
|
-
[Symbol.toStringTag] =
|
|
4789
|
-
find(
|
|
4790
|
-
for (
|
|
4791
|
-
|
|
4792
|
-
|
|
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
|
+
}
|
|
4793
4562
|
}
|
|
4794
4563
|
}
|
|
4795
|
-
forEach(
|
|
4796
|
-
for (
|
|
4797
|
-
|
|
4798
|
-
|
|
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);
|
|
4799
4569
|
}
|
|
4800
4570
|
}
|
|
4801
|
-
rforEach(
|
|
4802
|
-
for (
|
|
4803
|
-
|
|
4804
|
-
|
|
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);
|
|
4805
4576
|
}
|
|
4806
4577
|
}
|
|
4807
4578
|
purgeStale() {
|
|
4808
|
-
let
|
|
4809
|
-
for (
|
|
4810
|
-
allowStale:
|
|
4811
|
-
}))
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
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
|
|
4821
4596
|
};
|
|
4822
|
-
if (this.#
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
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();
|
|
4827
4604
|
}
|
|
4828
4605
|
}
|
|
4829
|
-
|
|
4606
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4607
|
+
return entry;
|
|
4830
4608
|
}
|
|
4831
4609
|
dump() {
|
|
4832
|
-
|
|
4833
|
-
for (
|
|
4834
|
-
allowStale:
|
|
4610
|
+
const arr = [];
|
|
4611
|
+
for (const i of this.#indexes({
|
|
4612
|
+
allowStale: true
|
|
4835
4613
|
})){
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
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
|
|
4840
4620
|
};
|
|
4841
|
-
if (this.#
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
}
|
|
4846
|
-
this.#
|
|
4847
|
-
|
|
4848
|
-
|
|
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
|
|
4849
4630
|
]);
|
|
4850
4631
|
}
|
|
4851
|
-
return
|
|
4632
|
+
return arr;
|
|
4852
4633
|
}
|
|
4853
|
-
load(
|
|
4634
|
+
load(arr) {
|
|
4854
4635
|
this.clear();
|
|
4855
|
-
for (
|
|
4856
|
-
if (
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
}
|
|
4860
|
-
this
|
|
4861
|
-
}
|
|
4862
|
-
}
|
|
4863
|
-
set(
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
if (
|
|
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
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
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;
|
|
4899
4703
|
}
|
|
4900
|
-
} else
|
|
4901
|
-
this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
|
|
4704
|
+
} else if (status) status.set = 'update';
|
|
4902
4705
|
}
|
|
4903
|
-
if (0
|
|
4904
|
-
|
|
4905
|
-
|
|
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);
|
|
4906
4715
|
}
|
|
4907
4716
|
return this;
|
|
4908
4717
|
}
|
|
4909
4718
|
pop() {
|
|
4910
4719
|
try {
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
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;
|
|
4916
4726
|
}
|
|
4917
4727
|
} finally{
|
|
4918
|
-
if (this.#
|
|
4919
|
-
|
|
4920
|
-
|
|
4728
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
4729
|
+
const dt = this.#disposed;
|
|
4730
|
+
let task;
|
|
4731
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4921
4732
|
}
|
|
4922
4733
|
}
|
|
4923
4734
|
}
|
|
4924
|
-
#
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4937
|
-
}
|
|
4938
|
-
#Y(e1, t1 = {}) {
|
|
4939
|
-
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t1, n = this.#s.get(e1);
|
|
4940
|
-
if (void 0 !== n) {
|
|
4941
|
-
let o = this.#t[n];
|
|
4942
|
-
if (this.#e(o) && void 0 === o.__staleWhileFetching) return !1;
|
|
4943
|
-
if (!this.#p(n)) return i && this.#x(n), s && (s.has = "hit", this.#E(s, n)), !0;
|
|
4944
|
-
s && (s.has = "stale", this.#E(s, n));
|
|
4945
|
-
} else s && (s.has = "miss");
|
|
4946
|
-
return !1;
|
|
4947
|
-
}
|
|
4948
|
-
peek(e1, t1 = {}) {
|
|
4949
|
-
let { status: i = D() ? {} : void 0 } = t1;
|
|
4950
|
-
i && (i.op = "peek", i.key = e1), t1.status = i;
|
|
4951
|
-
let s = this.#J(e1, t1);
|
|
4952
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4953
|
-
}
|
|
4954
|
-
#J(e1, t1) {
|
|
4955
|
-
let { status: i, allowStale: s = this.allowStale } = t1, n = this.#s.get(e1);
|
|
4956
|
-
if (void 0 === n || !s && this.#p(n)) {
|
|
4957
|
-
i && (i.peek = void 0 === n ? "miss" : "stale");
|
|
4958
|
-
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
|
+
]);
|
|
4959
4747
|
}
|
|
4960
|
-
|
|
4961
|
-
|
|
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;
|
|
4962
4783
|
}
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
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
|
|
4969
4798
|
});
|
|
4970
|
-
|
|
4971
|
-
signal:
|
|
4972
|
-
options
|
|
4973
|
-
context
|
|
4974
|
-
}
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
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
|
+
}
|
|
4987
4854
|
});
|
|
4988
4855
|
};
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
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,
|
|
4993
4861
|
__returned: void 0
|
|
4994
4862
|
});
|
|
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
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
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;
|
|
5039
4909
|
}
|
|
5040
4910
|
{
|
|
5041
|
-
|
|
5042
|
-
if (this.#
|
|
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
|
-
|
|
5074
|
-
|
|
5075
|
-
if (
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
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
|
|
5079
4952
|
});
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
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;
|
|
5093
4978
|
}
|
|
5094
|
-
|
|
5095
|
-
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';
|
|
5096
4980
|
}
|
|
5097
|
-
|
|
5098
|
-
this.#
|
|
4981
|
+
#connect(p, n) {
|
|
4982
|
+
this.#prev[n] = p;
|
|
4983
|
+
this.#next[p] = n;
|
|
5099
4984
|
}
|
|
5100
|
-
#
|
|
5101
|
-
|
|
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
|
+
}
|
|
5102
4992
|
}
|
|
5103
|
-
delete(
|
|
5104
|
-
return this.#
|
|
4993
|
+
delete(k) {
|
|
4994
|
+
return this.#delete(k, 'delete');
|
|
5105
4995
|
}
|
|
5106
|
-
#
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
if (0 !== this.#n) {
|
|
5114
|
-
let s = this.#s.get(e1);
|
|
5115
|
-
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);
|
|
5116
|
-
else {
|
|
5117
|
-
this.#R(s);
|
|
5118
|
-
let n = this.#t[s];
|
|
5119
|
-
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([
|
|
5120
|
-
n,
|
|
5121
|
-
e1,
|
|
5122
|
-
t1
|
|
5123
|
-
])), this.#s.delete(e1), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
5124
|
-
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);
|
|
5125
5003
|
else {
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
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);
|
|
5130
5028
|
}
|
|
5131
|
-
this.#n--, this.#y.push(s);
|
|
5132
5029
|
}
|
|
5133
5030
|
}
|
|
5134
|
-
if (this.#
|
|
5135
|
-
|
|
5136
|
-
|
|
5031
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
5032
|
+
const dt = this.#disposed;
|
|
5033
|
+
let task;
|
|
5034
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5137
5035
|
}
|
|
5138
|
-
return
|
|
5036
|
+
return deleted;
|
|
5139
5037
|
}
|
|
5140
5038
|
clear() {
|
|
5141
|
-
return this.#
|
|
5039
|
+
return this.#clear('delete');
|
|
5142
5040
|
}
|
|
5143
|
-
#
|
|
5144
|
-
for (
|
|
5145
|
-
allowStale:
|
|
5041
|
+
#clear(reason) {
|
|
5042
|
+
for (const index of this.#rindexes({
|
|
5043
|
+
allowStale: true
|
|
5146
5044
|
})){
|
|
5147
|
-
|
|
5148
|
-
if (this.#
|
|
5045
|
+
const v = this.#valList[index];
|
|
5046
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5149
5047
|
else {
|
|
5150
|
-
|
|
5151
|
-
this.#
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
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
|
|
5155
5054
|
]);
|
|
5156
5055
|
}
|
|
5157
5056
|
}
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
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);
|
|
5162
5063
|
}
|
|
5163
|
-
if (this.#
|
|
5164
|
-
|
|
5165
|
-
|
|
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);
|
|
5166
5074
|
}
|
|
5167
5075
|
}
|
|
5168
|
-
}
|
|
5076
|
+
}
|
|
5169
5077
|
var external_fs_ = __webpack_require__("fs");
|
|
5170
5078
|
const proc = 'object' == typeof process && process ? process : {
|
|
5171
5079
|
stdout: null,
|
|
@@ -5238,7 +5146,7 @@ var __webpack_modules__ = {
|
|
|
5238
5146
|
}
|
|
5239
5147
|
constructor(src, dest, opts){
|
|
5240
5148
|
super(src, dest, opts);
|
|
5241
|
-
this.proxyErrors = (er)=>
|
|
5149
|
+
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
5242
5150
|
src.on('error', this.proxyErrors);
|
|
5243
5151
|
}
|
|
5244
5152
|
}
|
|
@@ -5690,8 +5598,7 @@ var __webpack_modules__ = {
|
|
|
5690
5598
|
return: stop,
|
|
5691
5599
|
[Symbol.asyncIterator] () {
|
|
5692
5600
|
return this;
|
|
5693
|
-
}
|
|
5694
|
-
[Symbol.asyncDispose]: async ()=>{}
|
|
5601
|
+
}
|
|
5695
5602
|
};
|
|
5696
5603
|
}
|
|
5697
5604
|
[Symbol.iterator]() {
|
|
@@ -5725,8 +5632,7 @@ var __webpack_modules__ = {
|
|
|
5725
5632
|
return: stop,
|
|
5726
5633
|
[Symbol.iterator] () {
|
|
5727
5634
|
return this;
|
|
5728
|
-
}
|
|
5729
|
-
[Symbol.dispose]: ()=>{}
|
|
5635
|
+
}
|
|
5730
5636
|
};
|
|
5731
5637
|
}
|
|
5732
5638
|
destroy(er) {
|
|
@@ -5793,9 +5699,7 @@ var __webpack_modules__ = {
|
|
|
5793
5699
|
const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
|
|
5794
5700
|
const TYPEMASK = 1023;
|
|
5795
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;
|
|
5796
|
-
const normalizeCache = new
|
|
5797
|
-
max: 4096
|
|
5798
|
-
});
|
|
5702
|
+
const normalizeCache = new Map();
|
|
5799
5703
|
const normalize = (s)=>{
|
|
5800
5704
|
const c = normalizeCache.get(s);
|
|
5801
5705
|
if (c) return c;
|
|
@@ -5803,9 +5707,7 @@ var __webpack_modules__ = {
|
|
|
5803
5707
|
normalizeCache.set(s, n);
|
|
5804
5708
|
return n;
|
|
5805
5709
|
};
|
|
5806
|
-
const normalizeNocaseCache = new
|
|
5807
|
-
max: 4096
|
|
5808
|
-
});
|
|
5710
|
+
const normalizeNocaseCache = new Map();
|
|
5809
5711
|
const normalizeNocase = (s)=>{
|
|
5810
5712
|
const c = normalizeNocaseCache.get(s);
|
|
5811
5713
|
if (c) return c;
|
|
@@ -5813,14 +5715,14 @@ var __webpack_modules__ = {
|
|
|
5813
5715
|
normalizeNocaseCache.set(s, n);
|
|
5814
5716
|
return n;
|
|
5815
5717
|
};
|
|
5816
|
-
class ResolveCache extends
|
|
5718
|
+
class ResolveCache extends LRUCache {
|
|
5817
5719
|
constructor(){
|
|
5818
5720
|
super({
|
|
5819
5721
|
max: 256
|
|
5820
5722
|
});
|
|
5821
5723
|
}
|
|
5822
5724
|
}
|
|
5823
|
-
class ChildrenCache extends
|
|
5725
|
+
class ChildrenCache extends LRUCache {
|
|
5824
5726
|
constructor(maxSize = 16384){
|
|
5825
5727
|
super({
|
|
5826
5728
|
maxSize,
|
|
@@ -10949,7 +10851,7 @@ Usage:
|
|
|
10949
10851
|
type: 'boolean',
|
|
10950
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}`
|
|
10951
10853
|
}
|
|
10952
|
-
}).version('version', 'Show version number', "1.8.
|
|
10854
|
+
}).version('version', 'Show version number', "1.8.9").help().epilogue(`For complete list of configuration options, please visit:
|
|
10953
10855
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
10954
10856
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
10955
10857
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|
|
@@ -10997,82 +10899,6 @@ Examples:
|
|
|
10997
10899
|
});
|
|
10998
10900
|
return files.filter((file)=>file.endsWith('.yml') || file.endsWith('.yaml')).sort();
|
|
10999
10901
|
}
|
|
11000
|
-
const usage = 'Usage: midscene emit <out-dir> [--config <path>]';
|
|
11001
|
-
const help = `${usage}
|
|
11002
|
-
|
|
11003
|
-
Options:
|
|
11004
|
-
--config <path> Path to the source midscene.config file
|
|
11005
|
-
-h, --help Show this help message`;
|
|
11006
|
-
const normalizePackageVersion = (packageVersion, fallbackVersion)=>{
|
|
11007
|
-
if (!packageVersion || packageVersion.startsWith('workspace:')) return fallbackVersion;
|
|
11008
|
-
return packageVersion;
|
|
11009
|
-
};
|
|
11010
|
-
const defaultRstestVersion = normalizePackageVersion(package_namespaceObject.El.yR, 'latest');
|
|
11011
|
-
const parseEmitArgs = (args)=>{
|
|
11012
|
-
let outDir;
|
|
11013
|
-
let configPath;
|
|
11014
|
-
for(let index = 0; index < args.length; index += 1){
|
|
11015
|
-
const arg = args[index];
|
|
11016
|
-
if ('--help' === arg || '-h' === arg) return {
|
|
11017
|
-
help: true
|
|
11018
|
-
};
|
|
11019
|
-
if ('--config' === arg) {
|
|
11020
|
-
const value = args[index + 1];
|
|
11021
|
-
if (!value || value.startsWith('-')) return {
|
|
11022
|
-
error: '--config requires a path value'
|
|
11023
|
-
};
|
|
11024
|
-
configPath = value;
|
|
11025
|
-
index += 1;
|
|
11026
|
-
continue;
|
|
11027
|
-
}
|
|
11028
|
-
if (arg.startsWith('--config=')) {
|
|
11029
|
-
const value = arg.slice(9);
|
|
11030
|
-
if (!value) return {
|
|
11031
|
-
error: '--config requires a path value'
|
|
11032
|
-
};
|
|
11033
|
-
configPath = value;
|
|
11034
|
-
continue;
|
|
11035
|
-
}
|
|
11036
|
-
if (arg.startsWith('-')) return {
|
|
11037
|
-
error: `Unknown option: ${arg}`
|
|
11038
|
-
};
|
|
11039
|
-
if (!outDir) {
|
|
11040
|
-
outDir = arg;
|
|
11041
|
-
continue;
|
|
11042
|
-
}
|
|
11043
|
-
return {
|
|
11044
|
-
error: `Unexpected argument: ${arg}`
|
|
11045
|
-
};
|
|
11046
|
-
}
|
|
11047
|
-
return {
|
|
11048
|
-
outDir,
|
|
11049
|
-
configPath
|
|
11050
|
-
};
|
|
11051
|
-
};
|
|
11052
|
-
async function runEmitCommand(args, deps = {
|
|
11053
|
-
emit: emitRstestProject
|
|
11054
|
-
}) {
|
|
11055
|
-
const { outDir, configPath, error, help: shouldShowHelp } = parseEmitArgs(args);
|
|
11056
|
-
if (shouldShowHelp) {
|
|
11057
|
-
console.log(help);
|
|
11058
|
-
return 0;
|
|
11059
|
-
}
|
|
11060
|
-
if (error) {
|
|
11061
|
-
console.error(`${error}\n${usage}`);
|
|
11062
|
-
return 1;
|
|
11063
|
-
}
|
|
11064
|
-
if (!outDir) {
|
|
11065
|
-
console.error(usage);
|
|
11066
|
-
return 1;
|
|
11067
|
-
}
|
|
11068
|
-
const result = await deps.emit({
|
|
11069
|
-
outDir,
|
|
11070
|
-
configPath,
|
|
11071
|
-
rstestVersion: deps.rstestVersion ?? defaultRstestVersion
|
|
11072
|
-
});
|
|
11073
|
-
console.log(`Emitted native Rstest project to ${result.outDir} (${result.caseFiles.length} case(s))`);
|
|
11074
|
-
return 0;
|
|
11075
|
-
}
|
|
11076
10902
|
const notExecutedError = 'Not executed (previous task failed)';
|
|
11077
10903
|
function execution_summary_createNotExecutedYamlResult(file) {
|
|
11078
10904
|
return {
|
|
@@ -11193,15 +11019,8 @@ Options:
|
|
|
11193
11019
|
const toPosixPath = (value)=>value.split(external_node_path_sep).join('/');
|
|
11194
11020
|
const toImportLiteral = (value)=>JSON.stringify(toPosixPath(value));
|
|
11195
11021
|
const toVirtualModuleId = (fileStem)=>`virtual:midscene-yaml/${fileStem}.test.ts`;
|
|
11196
|
-
const trimEdgeHyphens = (value)=>{
|
|
11197
|
-
let start = 0;
|
|
11198
|
-
let end = value.length;
|
|
11199
|
-
while(start < end && 45 === value.charCodeAt(start))start += 1;
|
|
11200
|
-
while(end > start && 45 === value.charCodeAt(end - 1))end -= 1;
|
|
11201
|
-
return value.slice(start, end);
|
|
11202
|
-
};
|
|
11203
11022
|
const safeFileStem = (file, index)=>{
|
|
11204
|
-
const base =
|
|
11023
|
+
const base = external_node_path_basename(file, external_node_path_extname(file)).replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
11205
11024
|
return `${String(index + 1).padStart(3, '0')}-${base || 'case'}`;
|
|
11206
11025
|
};
|
|
11207
11026
|
const resolveTestName = (projectDir, yamlFile)=>{
|
|
@@ -11330,20 +11149,41 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
11330
11149
|
};
|
|
11331
11150
|
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
11332
11151
|
async function runRstestYamlProject(options) {
|
|
11152
|
+
const [{ runRstest }, { rspack }] = await Promise.all([
|
|
11153
|
+
import("@rstest/core/api"),
|
|
11154
|
+
import(pathToFileURL(resolvePackageFromRstestCore('@rsbuild/core')).href)
|
|
11155
|
+
]);
|
|
11333
11156
|
const { project } = options;
|
|
11334
|
-
const
|
|
11335
|
-
|
|
11157
|
+
const maxConcurrency = void 0 !== project.maxConcurrency ? Math.max(1, project.maxConcurrency) : void 0;
|
|
11158
|
+
const inlineConfig = {
|
|
11336
11159
|
root: project.projectDir,
|
|
11337
11160
|
include: project.include,
|
|
11338
|
-
|
|
11339
|
-
rsbuildEntry: resolvePackageFromRstestCore('@rsbuild/core'),
|
|
11161
|
+
testEnvironment: 'node',
|
|
11340
11162
|
testTimeout: project.testTimeout,
|
|
11341
|
-
maxConcurrency
|
|
11342
|
-
|
|
11343
|
-
|
|
11163
|
+
...void 0 !== maxConcurrency ? {
|
|
11164
|
+
maxConcurrency
|
|
11165
|
+
} : {},
|
|
11166
|
+
...void 0 !== maxConcurrency ? {
|
|
11167
|
+
pool: {
|
|
11168
|
+
maxWorkers: maxConcurrency,
|
|
11169
|
+
minWorkers: maxConcurrency
|
|
11170
|
+
}
|
|
11171
|
+
} : {},
|
|
11172
|
+
...void 0 !== project.bail ? {
|
|
11173
|
+
bail: project.bail
|
|
11174
|
+
} : {},
|
|
11175
|
+
reporters: [],
|
|
11176
|
+
tools: {
|
|
11177
|
+
rspack: (_config, { appendPlugins })=>{
|
|
11178
|
+
appendPlugins(new rspack.experiments.VirtualModulesPlugin(project.virtualModules));
|
|
11179
|
+
}
|
|
11180
|
+
}
|
|
11181
|
+
};
|
|
11182
|
+
const result = await runRstest({
|
|
11183
|
+
cwd: options.cwd || project.projectDir,
|
|
11184
|
+
inlineConfig
|
|
11344
11185
|
});
|
|
11345
|
-
|
|
11346
|
-
if (!result.ok && 'pipe' !== options.stdio && unhandledErrors.length) console.error(unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
|
|
11186
|
+
if (!result.ok && 'pipe' !== options.stdio && result.unhandledErrors.length) console.error(result.unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
|
|
11347
11187
|
return result.ok ? 0 : 1;
|
|
11348
11188
|
}
|
|
11349
11189
|
const createCaseOptions = (config)=>{
|
|
@@ -11406,11 +11246,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
11406
11246
|
version: package_namespaceObject.rE,
|
|
11407
11247
|
extraCommands: createReportCliCommands()
|
|
11408
11248
|
});
|
|
11409
|
-
if ('emit' === firstArg) {
|
|
11410
|
-
console.log(`\nWelcome to @midscene/cli v${package_namespaceObject.rE}\n`);
|
|
11411
|
-
const exitCode = await runEmitCommand(rawArgs.slice(1));
|
|
11412
|
-
process.exit(exitCode);
|
|
11413
|
-
}
|
|
11414
11249
|
const { options, path, files: cmdFiles } = await parseProcessArgs();
|
|
11415
11250
|
const welcome = `\nWelcome to @midscene/cli v${package_namespaceObject.rE}\n`;
|
|
11416
11251
|
console.log(welcome);
|