@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/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 = JSON.parse('{"rE":"1.8.8-beta-20260603024013.0","El":{"yR":"0.10.3"}}');
2840
- const balanced = (a, b, str)=>{
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
- const maybeMatch = (reg, str)=>{
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, magicalBraces = true } = {})=>{
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
- return void 0 !== this.#toString ? this.#toString : this.type ? this.#toString = this.type + '(' + this.#parts.map((p)=>String(p)).join('|') + ')' : this.#toString = this.#parts.map((p)=>String(p)).join('');
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 ast_a && p.#parent === this)) throw new Error('invalid part: ' + p);
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 ast_a && '!' === pp.type)) return false;
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 ast_a(this.type, parent);
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, extDepth) {
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
- const doRecurse = !opt.noext && isExtglobType(c) && '(' === str.charAt(i) && extDepth <= maxDepth;
3535
- if (doRecurse) {
3350
+ if (!opt.noext && isExtglobType(c) && '(' === str.charAt(i)) {
3536
3351
  ast.push(acc);
3537
3352
  acc = '';
3538
- const ext = new ast_a(c, ast);
3539
- i = ast_a.#parseAST(str, ext, i, opt, extDepth + 1);
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 ast_a(null, ast);
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
- const doRecurse = !opt.noext && isExtglobType(c) && '(' === str.charAt(i) && (extDepth <= maxDepth || ast && ast.#canAdoptType(c));
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 ast_a(c, part);
3391
+ const ext = new ast_AST(c, part);
3579
3392
  part.push(ext);
3580
- i = ast_a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
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 ast_a(null, ast);
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 ast_a(null, void 0, options);
3654
- ast_a.#parseAST(pattern, ast, 0, options, 0);
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
- this.#flatten();
3676
- this.#fillNegs();
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 ? ast_a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
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
- const me = this;
3714
- me.#parts = [
3477
+ this.#parts = [
3715
3478
  s
3716
3479
  ];
3717
- me.type = null;
3718
- me.#hasMagic = void 0;
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
- ast_a = ast_AST;
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 expand(pattern, {
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
- const awe = "allowWindowsEscape";
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 (const partset of globParts)for(let j = 0; j < partset.length; j++)if ('**' === partset[j]) partset[j] = '*';
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 && !(this.isWindows && /^[a-z]:$/i.test(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
- let fileStartIndex = 0;
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
- patternStartIndex = pdi;
4263
- fileStartIndex = fdi;
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
- if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
4270
- return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
4271
- }
4272
- #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
4273
- const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
4274
- const lastgs = pattern.lastIndexOf(GLOBSTAR);
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
- let p = pattern[pi];
4369
- let f = file[fi];
4000
+ var p = pattern[pi];
4001
+ var f = file[fi];
4370
4002
  this.debug(pattern, p, f);
4371
- if (false === p || p === GLOBSTAR) return false;
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 + '(?:\\/|\\/' + twoStar + ')?';
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
- const filtered = pp.filter((p)=>p !== GLOBSTAR);
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 && /^\/\/[^/]+/.test(p)) return [
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 (const pattern of set){
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
- var S = channel("lru-cache:metrics"), W = tracingChannel("lru-cache");
4508
- var D = ()=>S.hasSubscribers || W.hasSubscribers, G = "object" == typeof performance && performance && "function" == typeof performance.now ? performance : Date, M = new Set, C = "object" == typeof process && process ? process : {}, P = (u, e1, t1, i)=>{
4509
- "function" == typeof C.emitWarning ? C.emitWarning(u, e1, t1, i) : console.error(`[${t1}] ${e1}: ${u}`);
4510
- }, H = (u)=>!M.has(u), F = (Symbol("type"), (u)=>!!u && u === Math.floor(u) && u > 0 && isFinite(u)), U = (u)=>F(u) ? u <= Math.pow(2, 8) ? Uint8Array : u <= Math.pow(2, 16) ? Uint16Array : u <= Math.pow(2, 32) ? Uint32Array : u <= Number.MAX_SAFE_INTEGER ? O : null : null, O = class extends Array {
4511
- constructor(e1){
4512
- super(e1), this.fill(0);
4513
- }
4514
- }, R = class u {
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 #o = !1;
4518
- static create(e1) {
4519
- let t1 = U(e1);
4520
- if (!t1) return [];
4521
- u.#o = !0;
4522
- let i = new u(e1, t1);
4523
- return u.#o = !1, i;
4524
- }
4525
- constructor(e1, t1){
4526
- if (!u.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
4527
- this.heap = new t1(e1), this.length = 0;
4528
- }
4529
- push(e1) {
4530
- this.heap[this.length++] = e1;
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
- }, L = class u {
4536
- #o;
4537
- #u;
4538
- #w;
4539
- #D;
4540
- #S;
4541
- #M;
4542
- #U;
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
- #n;
4563
- #b;
4564
- #s;
4565
- #i;
4566
- #t;
4567
- #a;
4568
- #c;
4569
- #l;
4570
- #h;
4571
- #y;
4572
- #r;
4573
- #_;
4574
- #F;
4575
- #d;
4576
- #g;
4577
- #T;
4578
- #W;
4579
- #f;
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: e1.#F,
4584
- ttls: e1.#d,
4585
- autopurgeTimers: e1.#g,
4586
- sizes: e1.#_,
4587
- keyMap: e1.#s,
4588
- keyList: e1.#i,
4589
- valList: e1.#t,
4590
- next: e1.#a,
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 e1.#l;
4288
+ return c.#head;
4594
4289
  },
4595
4290
  get tail () {
4596
- return e1.#h;
4291
+ return c.#tail;
4597
4292
  },
4598
- free: e1.#y,
4599
- isBackgroundFetch: (t1)=>e1.#e(t1),
4600
- backgroundFetch: (t1, i, s, n)=>e1.#P(t1, i, s, n),
4601
- moveToTail: (t1)=>e1.#L(t1),
4602
- indexes: (t1)=>e1.#A(t1),
4603
- rindexes: (t1)=>e1.#z(t1),
4604
- isStale: (t1)=>e1.#p(t1)
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.#o;
4303
+ return this.#max;
4609
4304
  }
4610
4305
  get maxSize() {
4611
- return this.#u;
4306
+ return this.#maxSize;
4612
4307
  }
4613
4308
  get calculatedSize() {
4614
- return this.#b;
4309
+ return this.#calculatedSize;
4615
4310
  }
4616
4311
  get size() {
4617
- return this.#n;
4312
+ return this.#size;
4618
4313
  }
4619
4314
  get fetchMethod() {
4620
- return this.#M;
4315
+ return this.#fetchMethod;
4621
4316
  }
4622
4317
  get memoMethod() {
4623
- return this.#U;
4318
+ return this.#memoMethod;
4624
4319
  }
4625
4320
  get dispose() {
4626
- return this.#w;
4627
- }
4628
- get onInsert() {
4629
- return this.#D;
4321
+ return this.#dispose;
4630
4322
  }
4631
4323
  get disposeAfter() {
4632
- return this.#S;
4633
- }
4634
- constructor(e1){
4635
- let { max: t1 = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: r, allowStale: h, dispose: l, onInsert: c, disposeAfter: f, noDisposeOnSet: g, noUpdateTTL: p, maxSize: T = 0, maxEntrySize: w = 0, sizeCalculation: y, fetchMethod: a, memoMethod: m, noDeleteOnFetchRejection: _, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, perf: x } = e1;
4636
- if (void 0 !== x && "function" != typeof x?.now) throw new TypeError("perf option must have a now() method if specified");
4637
- if (this.#m = x ?? G, 0 !== t1 && !F(t1)) throw new TypeError("max option must be a nonnegative integer");
4638
- let v = t1 ? U(t1) : Array;
4639
- if (!v) throw new Error("invalid max value: " + t1);
4640
- if (this.#o = t1, this.#u = T, this.maxEntrySize = w || this.#u, this.sizeCalculation = y, this.sizeCalculation) {
4641
- if (!this.#u && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
4642
- if ("function" != typeof this.sizeCalculation) throw new TypeError("sizeCalculation set to non-function");
4643
- }
4644
- if (void 0 !== m && "function" != typeof m) throw new TypeError("memoMethod must be a function if defined");
4645
- if (this.#U = m, void 0 !== a && "function" != typeof a) throw new TypeError("fetchMethod must be a function if specified");
4646
- if (this.#M = a, this.#W = !!a, this.#s = new Map, this.#i = Array.from({
4647
- length: t1
4648
- }).fill(void 0), this.#t = Array.from({
4649
- length: t1
4650
- }).fill(void 0), this.#a = new v(t1), this.#c = new v(t1), this.#l = 0, this.#h = 0, this.#y = R.create(t1), this.#n = 0, this.#b = 0, "function" == typeof l && (this.#w = l), "function" == typeof c && (this.#D = c), "function" == typeof f ? (this.#S = f, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#j = !!this.#D, this.#f = !!this.#S, this.noDisposeOnSet = !!g, this.noUpdateTTL = !!p, this.noDeleteOnFetchRejection = !!_, this.allowStaleOnFetchRejection = !!d, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, 0 !== this.maxEntrySize) {
4651
- if (0 !== this.#u && !F(this.#u)) throw new TypeError("maxSize must be a positive integer if specified");
4652
- if (!F(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
4653
- this.#X();
4654
- }
4655
- if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!r, this.ttlResolution = F(s) || 0 === s ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
4656
- if (!F(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
4657
- this.#H();
4658
- }
4659
- if (0 === this.#o && 0 === this.ttl && 0 === this.#u) throw new TypeError("At least one of max, maxSize, or ttl is required");
4660
- if (!this.ttlAutopurge && !this.#o && !this.#u) {
4661
- let E = "LRU_CACHE_UNBOUNDED";
4662
- H(E) && (M.add(E), P("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, u));
4663
- }
4664
- }
4665
- getRemainingTTL(e1) {
4666
- return this.#s.has(e1) ? 1 / 0 : 0;
4667
- }
4668
- #H() {
4669
- let e1 = new O(this.#o), t1 = new O(this.#o);
4670
- this.#d = e1, this.#F = t1;
4671
- let i = this.ttlAutopurge ? Array.from({
4672
- length: this.#o
4673
- }) : void 0;
4674
- this.#g = i, this.#N = (r, h, l = this.#m.now())=>{
4675
- t1[r] = 0 !== h ? l : 0, e1[r] = h, s(r, h);
4676
- }, this.#x = (r)=>{
4677
- t1[r] = 0 !== e1[r] ? this.#m.now() : 0, s(r, e1[r]);
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
- let s = this.ttlAutopurge ? (r, h)=>{
4680
- if (i?.[r] && (clearTimeout(i[r]), i[r] = void 0), h && 0 !== h && i) {
4681
- let l = setTimeout(()=>{
4682
- this.#p(r) && this.#v(this.#i[r], "expire");
4683
- }, h + 1);
4684
- l.unref && l.unref(), i[r] = l;
4685
- }
4686
- } : ()=>{};
4687
- this.#E = (r, h)=>{
4688
- if (e1[h]) {
4689
- let l = e1[h], c = t1[h];
4690
- if (!l || !c) return;
4691
- r.ttl = l, r.start = c, r.now = n || o();
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 n = 0, o = ()=>{
4697
- let r = this.#m.now();
4431
+ let cachedNow = 0;
4432
+ const getNow = ()=>{
4433
+ const n = perf.now();
4698
4434
  if (this.ttlResolution > 0) {
4699
- n = r;
4700
- let h = setTimeout(()=>n = 0, this.ttlResolution);
4701
- h.unref && h.unref();
4435
+ cachedNow = n;
4436
+ const t1 = setTimeout(()=>cachedNow = 0, this.ttlResolution);
4437
+ if (t1.unref) t1.unref();
4702
4438
  }
4703
- return r;
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.getRemainingTTL = (r)=>{
4706
- let h = this.#s.get(r);
4707
- if (void 0 === h) return 0;
4708
- let l = e1[h], c = t1[h];
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
- #x = ()=>{};
4718
- #E = ()=>{};
4719
- #N = ()=>{};
4720
- #p = ()=>!1;
4721
- #X() {
4722
- let e1 = new O(this.#o);
4723
- this.#b = 0, this.#_ = e1, this.#R = (t1)=>{
4724
- this.#b -= e1[t1], e1[t1] = 0;
4725
- }, this.#k = (t1, i, s, n)=>{
4726
- if (this.#e(i)) return 0;
4727
- if (!F(s)) if (n) {
4728
- if ("function" != typeof n) throw new TypeError("sizeCalculation must be a function");
4729
- if (s = n(i, t1), !F(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
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 s;
4732
- }, this.#I = (t1, i, s)=>{
4733
- if (e1[t1] = i, this.#u) {
4734
- let n = this.#u - e1[t1];
4735
- for(; this.#b > n;)this.#G(!0);
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
- #R = (e1)=>{};
4741
- #I = (e1, t1, i)=>{};
4742
- #k = (e1, t1, i, s)=>{
4743
- if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
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
- *#A({ allowStale: e1 = this.allowStale } = {}) {
4747
- if (this.#n) for(let t1 = this.#h; this.#V(t1) && ((e1 || !this.#p(t1)) && (yield t1), t1 !== this.#l);)t1 = this.#c[t1];
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
- *#z({ allowStale: e1 = this.allowStale } = {}) {
4750
- if (this.#n) for(let t1 = this.#l; this.#V(t1) && ((e1 || !this.#p(t1)) && (yield t1), t1 !== this.#h);)t1 = this.#a[t1];
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
- #V(e1) {
4753
- return void 0 !== e1 && this.#s.get(this.#i[e1]) === e1;
4512
+ #isValidIndex(index) {
4513
+ return void 0 !== index && this.#keyMap.get(this.#keyList[index]) === index;
4754
4514
  }
4755
4515
  *entries() {
4756
- for (let e1 of this.#A())void 0 === this.#t[e1] || void 0 === this.#i[e1] || this.#e(this.#t[e1]) || (yield [
4757
- this.#i[e1],
4758
- this.#t[e1]
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 (let e1 of this.#z())void 0 === this.#t[e1] || void 0 === this.#i[e1] || this.#e(this.#t[e1]) || (yield [
4763
- this.#i[e1],
4764
- this.#t[e1]
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 (let e1 of this.#A()){
4769
- let t1 = this.#i[e1];
4770
- void 0 === t1 || this.#e(this.#t[e1]) || (yield t1);
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 (let e1 of this.#z()){
4775
- let t1 = this.#i[e1];
4776
- void 0 === t1 || this.#e(this.#t[e1]) || (yield t1);
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 (let e1 of this.#A())void 0 === this.#t[e1] || this.#e(this.#t[e1]) || (yield this.#t[e1]);
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 (let e1 of this.#z())void 0 === this.#t[e1] || this.#e(this.#t[e1]) || (yield this.#t[e1]);
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] = "LRUCache";
4789
- find(e1, t1 = {}) {
4790
- for (let i of this.#A()){
4791
- let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4792
- if (void 0 !== n && e1(n, this.#i[i], this)) return this.#C(this.#i[i], t1);
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(e1, t1 = this) {
4796
- for (let i of this.#A()){
4797
- let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4798
- void 0 !== n && e1.call(t1, n, this.#i[i], this);
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(e1, t1 = this) {
4802
- for (let i of this.#z()){
4803
- let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4804
- void 0 !== n && e1.call(t1, n, this.#i[i], this);
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 e1 = !1;
4809
- for (let t1 of this.#z({
4810
- allowStale: !0
4811
- }))this.#p(t1) && (this.#v(this.#i[t1], "expire"), e1 = !0);
4812
- return e1;
4813
- }
4814
- info(e1) {
4815
- let t1 = this.#s.get(e1);
4816
- if (void 0 === t1) return;
4817
- let i = this.#t[t1], s = this.#e(i) ? i.__staleWhileFetching : i;
4818
- if (void 0 === s) return;
4819
- let n = {
4820
- value: s
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.#d && this.#F) {
4823
- let o = this.#d[t1], r = this.#F[t1];
4824
- if (o && r) {
4825
- let h = o - (this.#m.now() - r);
4826
- n.ttl = h, n.start = Date.now();
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
- return this.#_ && (n.size = this.#_[t1]), n;
4606
+ if (this.#sizes) entry.size = this.#sizes[i];
4607
+ return entry;
4830
4608
  }
4831
4609
  dump() {
4832
- let e1 = [];
4833
- for (let t1 of this.#A({
4834
- allowStale: !0
4610
+ const arr = [];
4611
+ for (const i of this.#indexes({
4612
+ allowStale: true
4835
4613
  })){
4836
- let i = this.#i[t1], s = this.#t[t1], n = this.#e(s) ? s.__staleWhileFetching : s;
4837
- if (void 0 === n || void 0 === i) continue;
4838
- let o = {
4839
- value: n
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.#d && this.#F) {
4842
- o.ttl = this.#d[t1];
4843
- let r = this.#m.now() - this.#F[t1];
4844
- o.start = Math.floor(Date.now() - r);
4845
- }
4846
- this.#_ && (o.size = this.#_[t1]), e1.unshift([
4847
- i,
4848
- o
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 e1;
4632
+ return arr;
4852
4633
  }
4853
- load(e1) {
4634
+ load(arr) {
4854
4635
  this.clear();
4855
- for (let [t1, i] of e1){
4856
- if (i.start) {
4857
- let s = Date.now() - i.start;
4858
- i.start = this.#m.now() - s;
4859
- }
4860
- this.#O(t1, i.value, i);
4861
- }
4862
- }
4863
- set(e1, t1, i = {}) {
4864
- let { status: s = S.hasSubscribers ? {} : void 0 } = i;
4865
- i.status = s, s && (s.op = "set", s.key = e1, void 0 !== t1 && (s.value = t1));
4866
- let n = this.#O(e1, t1, i);
4867
- return s && S.hasSubscribers && S.publish(s), n;
4868
- }
4869
- #O(e1, t1, i = {}) {
4870
- let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: r = this.sizeCalculation, status: h } = i;
4871
- if (void 0 === t1) return h && (h.set = "deleted"), this.delete(e1), this;
4872
- let { noUpdateTTL: l = this.noUpdateTTL } = i;
4873
- h && !this.#e(t1) && (h.value = t1);
4874
- let c = this.#k(e1, t1, i.size || 0, r, h);
4875
- if (this.maxEntrySize && c > this.maxEntrySize) return this.#v(e1, "set"), h && (h.set = "miss", h.maxEntrySizeExceeded = !0), this;
4876
- let f = 0 === this.#n ? void 0 : this.#s.get(e1);
4877
- if (void 0 === f) f = 0 === this.#n ? this.#h : 0 !== this.#y.length ? this.#y.pop() : this.#n === this.#o ? this.#G(!1) : this.#n, this.#i[f] = e1, this.#t[f] = t1, this.#s.set(e1, f), this.#a[this.#h] = f, this.#c[f] = this.#h, this.#h = f, this.#n++, this.#I(f, c, h), h && (h.set = "add"), l = !1, this.#j && this.#D?.(t1, e1, "add");
4878
- else {
4879
- this.#L(f);
4880
- let g = this.#t[f];
4881
- if (t1 !== g) {
4882
- if (this.#W && this.#e(g)) {
4883
- g.__abortController.abort(new Error("replaced"));
4884
- let { __staleWhileFetching: p } = g;
4885
- void 0 !== p && !o && (this.#T && this.#w?.(p, e1, "set"), this.#f && this.#r?.push([
4886
- p,
4887
- e1,
4888
- "set"
4889
- ]));
4890
- } else o || (this.#T && this.#w?.(g, e1, "set"), this.#f && this.#r?.push([
4891
- g,
4892
- e1,
4893
- "set"
4894
- ]));
4895
- if (this.#R(f), this.#I(f, c, h), this.#t[f] = t1, h) {
4896
- h.set = "replace";
4897
- let p = g && this.#e(g) ? g.__staleWhileFetching : g;
4898
- void 0 !== p && (h.oldValue = p);
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 h && (h.set = "update");
4901
- this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
4704
+ } else if (status) status.set = 'update';
4902
4705
  }
4903
- if (0 === s || this.#d || this.#H(), this.#d && (l || this.#N(f, s, n), h && this.#E(h, f)), !o && this.#f && this.#r) {
4904
- let g = this.#r, p;
4905
- for(; p = g?.shift();)this.#S?.(...p);
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
- for(; this.#n;){
4912
- let e1 = this.#t[this.#l];
4913
- if (this.#G(!0), this.#e(e1)) {
4914
- if (e1.__staleWhileFetching) return e1.__staleWhileFetching;
4915
- } else if (void 0 !== e1) return e1;
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.#f && this.#r) {
4919
- let e1 = this.#r, t1;
4920
- for(; t1 = e1?.shift();)this.#S?.(...t1);
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
- #G(e1) {
4925
- let t1 = this.#l, i = this.#i[t1], s = this.#t[t1];
4926
- return this.#W && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i, "evict"), this.#f && this.#r?.push([
4927
- s,
4928
- i,
4929
- "evict"
4930
- ])), this.#R(t1), this.#g?.[t1] && (clearTimeout(this.#g[t1]), this.#g[t1] = void 0), e1 && (this.#i[t1] = void 0, this.#t[t1] = void 0, this.#y.push(t1)), 1 === this.#n ? (this.#l = this.#h = 0, this.#y.length = 0) : this.#l = this.#a[t1], this.#s.delete(i), this.#n--, t1;
4931
- }
4932
- has(e1, t1 = {}) {
4933
- let { status: i = S.hasSubscribers ? {} : void 0 } = t1;
4934
- t1.status = i, i && (i.op = "has", i.key = e1);
4935
- let s = this.#Y(e1, t1);
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
- let o = this.#t[n], r = this.#e(o) ? o.__staleWhileFetching : o;
4961
- return i && (void 0 !== r ? (i.peek = "hit", i.value = r) : i.peek = "miss"), r;
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
- #P(e1, t1, i, s) {
4964
- let n = void 0 === t1 ? void 0 : this.#t[t1];
4965
- if (this.#e(n)) return n;
4966
- let o = new AbortController, { signal: r } = i;
4967
- r?.addEventListener("abort", ()=>o.abort(r.reason), {
4968
- signal: o.signal
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
- let h = {
4971
- signal: o.signal,
4972
- options: i,
4973
- context: s
4974
- }, l = (w, y = !1)=>{
4975
- let { aborted: a } = o.signal, m = i.ignoreFetchAbort && void 0 !== w, _ = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && void 0 !== w);
4976
- if (i.status && (a && !y ? (i.status.fetchAborted = !0, i.status.fetchError = o.signal.reason, m && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), a && !m && !y) return f(o.signal.reason, _);
4977
- let b = p, d = this.#t[t1];
4978
- return (d === p || void 0 === d && m && y) && (void 0 === w ? void 0 !== b.__staleWhileFetching ? this.#t[t1] = b.__staleWhileFetching : this.#v(e1, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.#O(e1, w, h.options))), w;
4979
- }, c = (w)=>(i.status && (i.status.fetchRejected = !0, i.status.fetchError = w), f(w, !1)), f = (w, y)=>{
4980
- let { aborted: a } = o.signal, m = a && i.allowStaleOnFetchAbort, _ = m || i.allowStaleOnFetchRejection, b = _ || i.noDeleteOnFetchRejection, d = p;
4981
- if (this.#t[t1] === p && (b && (y || void 0 !== d.__staleWhileFetching) ? m || (this.#t[t1] = d.__staleWhileFetching) : this.#v(e1, "fetch")), _) return i.status && void 0 !== d.__staleWhileFetching && (i.status.returnedStale = !0), d.__staleWhileFetching;
4982
- if (d.__returned === d) throw w;
4983
- }, g = (w, y)=>{
4984
- let a = this.#M?.(e1, n, h);
4985
- a && a instanceof Promise && a.then((m)=>w(void 0 === m ? void 0 : m), y), o.signal.addEventListener("abort", ()=>{
4986
- (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (w(void 0), i.allowStaleOnFetchAbort && (w = (m)=>l(m, !0)));
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
- i.status && (i.status.fetchDispatched = !0);
4990
- let p = new Promise(g).then(l, c), T = Object.assign(p, {
4991
- __abortController: o,
4992
- __staleWhileFetching: n,
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
- return void 0 === t1 ? (this.#O(e1, T, {
4996
- ...h.options,
4997
- status: void 0
4998
- }), t1 = this.#s.get(e1)) : this.#t[t1] = T, T;
4999
- }
5000
- #e(e1) {
5001
- if (!this.#W) return !1;
5002
- let t1 = e1;
5003
- return !!t1 && t1 instanceof Promise && t1.hasOwnProperty("__staleWhileFetching") && t1.__abortController instanceof AbortController;
5004
- }
5005
- fetch(e1, t1 = {}) {
5006
- let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t1;
5007
- t1.status = s, s && t1.context && (s.context = t1.context);
5008
- let n = this.#B(e1, t1);
5009
- return s && D() && i && (s.trace = !0, W.tracePromise(()=>n, s).catch(()=>{})), n;
5010
- }
5011
- async #B(e1, t1 = {}) {
5012
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: r = this.noDisposeOnSet, size: h = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: g = this.allowStaleOnFetchRejection, ignoreFetchAbort: p = this.ignoreFetchAbort, allowStaleOnFetchAbort: T = this.allowStaleOnFetchAbort, context: w, forceRefresh: y = !1, status: a, signal: m } = t1;
5013
- if (a && (a.op = "fetch", a.key = e1, y && (a.forceRefresh = !0)), !this.#W) return a && (a.fetch = "get"), this.#C(e1, {
5014
- allowStale: i,
5015
- updateAgeOnGet: s,
5016
- noDeleteOnStaleGet: n,
5017
- status: a
5018
- });
5019
- let _ = {
5020
- allowStale: i,
5021
- updateAgeOnGet: s,
5022
- noDeleteOnStaleGet: n,
5023
- ttl: o,
5024
- noDisposeOnSet: r,
5025
- size: h,
5026
- sizeCalculation: l,
5027
- noUpdateTTL: c,
5028
- noDeleteOnFetchRejection: f,
5029
- allowStaleOnFetchRejection: g,
5030
- allowStaleOnFetchAbort: T,
5031
- ignoreFetchAbort: p,
5032
- status: a,
5033
- signal: m
5034
- }, b = this.#s.get(e1);
5035
- if (void 0 === b) {
5036
- a && (a.fetch = "miss");
5037
- let d = this.#P(e1, b, _, w);
5038
- return d.__returned = d;
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
- let d = this.#t[b];
5042
- if (this.#e(d)) {
5043
- let E = i && void 0 !== d.__staleWhileFetching;
5044
- return a && (a.fetch = "inflight", E && (a.returnedStale = !0)), E ? d.__staleWhileFetching : d.__returned = d;
5045
- }
5046
- let A = this.#p(b);
5047
- if (!y && !A) return a && (a.fetch = "hit"), this.#L(b), s && this.#x(b), a && this.#E(a, b), d;
5048
- let z = this.#P(e1, b, _, w), v = void 0 !== z.__staleWhileFetching && i;
5049
- return a && (a.fetch = A ? "stale" : "refresh", v && A && (a.returnedStale = !0)), v ? z.__staleWhileFetching : z.__returned = z;
5050
- }
5051
- }
5052
- forceFetch(e1, t1 = {}) {
5053
- let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t1;
5054
- t1.status = s, s && t1.context && (s.context = t1.context);
5055
- let n = this.#K(e1, t1);
5056
- return s && D() && i && (s.trace = !0, W.tracePromise(()=>n, s).catch(()=>{})), n;
5057
- }
5058
- async #K(e1, t1 = {}) {
5059
- let i = await this.#B(e1, t1);
5060
- if (void 0 === i) throw new Error("fetch() returned undefined");
5061
- return i;
5062
- }
5063
- memo(e1, t1 = {}) {
5064
- let { status: i = S.hasSubscribers ? {} : void 0 } = t1;
5065
- t1.status = i, i && (i.op = "memo", i.key = e1, t1.context && (i.context = t1.context));
5066
- let s = this.#Q(e1, t1);
5067
- return i && (i.value = s), S.hasSubscribers && S.publish(i), s;
5068
- }
5069
- #Q(e1, t1 = {}) {
5070
- let i = this.#U;
5071
- if (!i) throw new Error("no memoMethod provided to constructor");
5072
- let { context: s, status: n, forceRefresh: o, ...r } = t1;
5073
- n && o && (n.forceRefresh = !0);
5074
- let h = this.#C(e1, r), l = o || void 0 === h;
5075
- if (n && (n.memo = l ? "miss" : "hit", l || (n.value = h)), !l) return h;
5076
- let c = i(e1, h, {
5077
- options: r,
5078
- context: s
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
- return n && (n.value = c), this.#O(e1, c, r), c;
5081
- }
5082
- get(e1, t1 = {}) {
5083
- let { status: i = S.hasSubscribers ? {} : void 0 } = t1;
5084
- t1.status = i, i && (i.op = "get", i.key = e1);
5085
- let s = this.#C(e1, t1);
5086
- return i && (void 0 !== s && (i.value = s), S.hasSubscribers && S.publish(i)), s;
5087
- }
5088
- #C(e1, t1 = {}) {
5089
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = t1, r = this.#s.get(e1);
5090
- if (void 0 === r) {
5091
- o && (o.get = "miss");
5092
- return;
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
- let h = this.#t[r], l = this.#e(h);
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
- #$(e1, t1) {
5098
- this.#c[t1] = e1, this.#a[e1] = t1;
4981
+ #connect(p, n) {
4982
+ this.#prev[n] = p;
4983
+ this.#next[p] = n;
5099
4984
  }
5100
- #L(e1) {
5101
- e1 !== this.#h && (e1 === this.#l ? this.#l = this.#a[e1] : this.#$(this.#c[e1], this.#a[e1]), this.#$(this.#h, e1), this.#h = e1);
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(e1) {
5104
- return this.#v(e1, "delete");
4993
+ delete(k) {
4994
+ return this.#delete(k, 'delete');
5105
4995
  }
5106
- #v(e1, t1) {
5107
- S.hasSubscribers && S.publish({
5108
- op: "delete",
5109
- delete: t1,
5110
- key: e1
5111
- });
5112
- let i = !1;
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
- let o = this.#c[s];
5127
- this.#a[o] = this.#a[s];
5128
- let r = this.#a[s];
5129
- this.#c[r] = this.#c[s];
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.#f && this.#r?.length) {
5135
- let s = this.#r, n;
5136
- for(; n = s?.shift();)this.#S?.(...n);
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 i;
5036
+ return deleted;
5139
5037
  }
5140
5038
  clear() {
5141
- return this.#q("delete");
5039
+ return this.#clear('delete');
5142
5040
  }
5143
- #q(e1) {
5144
- for (let t1 of this.#z({
5145
- allowStale: !0
5041
+ #clear(reason) {
5042
+ for (const index of this.#rindexes({
5043
+ allowStale: true
5146
5044
  })){
5147
- let i = this.#t[t1];
5148
- if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
5045
+ const v = this.#valList[index];
5046
+ if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
5149
5047
  else {
5150
- let s = this.#i[t1];
5151
- this.#T && this.#w?.(i, s, e1), this.#f && this.#r?.push([
5152
- i,
5153
- s,
5154
- e1
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
- if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
5159
- this.#d.fill(0), this.#F.fill(0);
5160
- for (let t1 of this.#g ?? [])void 0 !== t1 && clearTimeout(t1);
5161
- this.#g?.fill(void 0);
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.#_ && this.#_.fill(0), this.#l = 0, this.#h = 0, this.#y.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
5164
- let t1 = this.#r, i;
5165
- for(; i = t1?.shift();)this.#S?.(...i);
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)=>this.dest.emit('error', 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 L({
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 L({
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 L {
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 L {
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.8-beta-20260603024013.0").help().epilogue(`For complete list of configuration options, please visit:
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 = trimEdgeHyphens(external_node_path_basename(file, external_node_path_extname(file)).replace(/[^a-zA-Z0-9._-]+/g, '-'));
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 result = await runRstestWithVirtualModules({
11335
- cwd: options.cwd || project.projectDir,
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
- virtualModules: project.virtualModules,
11339
- rsbuildEntry: resolvePackageFromRstestCore('@rsbuild/core'),
11161
+ testEnvironment: 'node',
11340
11162
  testTimeout: project.testTimeout,
11341
- maxConcurrency: project.maxConcurrency,
11342
- bail: project.bail,
11343
- reporters: []
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
- const unhandledErrors = result.unhandledErrors ?? [];
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);