@midscene/cli 1.8.8-beta-20260602094353.0 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.mjs +1066 -1162
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/index.js +1068 -1163
- package/dist/lib/index.js.map +1 -1
- package/package.json +7 -7
package/dist/lib/index.js
CHANGED
|
@@ -262,6 +262,200 @@ var __webpack_modules__ = {
|
|
|
262
262
|
get: assembleStyles
|
|
263
263
|
});
|
|
264
264
|
},
|
|
265
|
+
"../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js" (module) {
|
|
266
|
+
"use strict";
|
|
267
|
+
module.exports = balanced;
|
|
268
|
+
function balanced(a, b, str) {
|
|
269
|
+
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
270
|
+
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
271
|
+
var r = range(a, b, str);
|
|
272
|
+
return r && {
|
|
273
|
+
start: r[0],
|
|
274
|
+
end: r[1],
|
|
275
|
+
pre: str.slice(0, r[0]),
|
|
276
|
+
body: str.slice(r[0] + a.length, r[1]),
|
|
277
|
+
post: str.slice(r[1] + b.length)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function maybeMatch(reg, str) {
|
|
281
|
+
var m = str.match(reg);
|
|
282
|
+
return m ? m[0] : null;
|
|
283
|
+
}
|
|
284
|
+
balanced.range = range;
|
|
285
|
+
function range(a, b, str) {
|
|
286
|
+
var begs, beg, left, right, result;
|
|
287
|
+
var ai = str.indexOf(a);
|
|
288
|
+
var bi = str.indexOf(b, ai + 1);
|
|
289
|
+
var i = ai;
|
|
290
|
+
if (ai >= 0 && bi > 0) {
|
|
291
|
+
if (a === b) return [
|
|
292
|
+
ai,
|
|
293
|
+
bi
|
|
294
|
+
];
|
|
295
|
+
begs = [];
|
|
296
|
+
left = str.length;
|
|
297
|
+
while(i >= 0 && !result){
|
|
298
|
+
if (i == ai) {
|
|
299
|
+
begs.push(i);
|
|
300
|
+
ai = str.indexOf(a, i + 1);
|
|
301
|
+
} else if (1 == begs.length) result = [
|
|
302
|
+
begs.pop(),
|
|
303
|
+
bi
|
|
304
|
+
];
|
|
305
|
+
else {
|
|
306
|
+
beg = begs.pop();
|
|
307
|
+
if (beg < left) {
|
|
308
|
+
left = beg;
|
|
309
|
+
right = bi;
|
|
310
|
+
}
|
|
311
|
+
bi = str.indexOf(b, i + 1);
|
|
312
|
+
}
|
|
313
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
314
|
+
}
|
|
315
|
+
if (begs.length) result = [
|
|
316
|
+
left,
|
|
317
|
+
right
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
"../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
324
|
+
var balanced = __webpack_require__("../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js");
|
|
325
|
+
module.exports = expandTop;
|
|
326
|
+
var escSlash = '\0SLASH' + Math.random() + '\0';
|
|
327
|
+
var escOpen = '\0OPEN' + Math.random() + '\0';
|
|
328
|
+
var escClose = '\0CLOSE' + Math.random() + '\0';
|
|
329
|
+
var escComma = '\0COMMA' + Math.random() + '\0';
|
|
330
|
+
var escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
331
|
+
function numeric(str) {
|
|
332
|
+
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
333
|
+
}
|
|
334
|
+
function escapeBraces(str) {
|
|
335
|
+
return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
|
|
336
|
+
}
|
|
337
|
+
function unescapeBraces(str) {
|
|
338
|
+
return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
|
|
339
|
+
}
|
|
340
|
+
function parseCommaParts(str) {
|
|
341
|
+
if (!str) return [
|
|
342
|
+
''
|
|
343
|
+
];
|
|
344
|
+
var parts = [];
|
|
345
|
+
var m = balanced('{', '}', str);
|
|
346
|
+
if (!m) return str.split(',');
|
|
347
|
+
var pre = m.pre;
|
|
348
|
+
var body = m.body;
|
|
349
|
+
var post = m.post;
|
|
350
|
+
var p = pre.split(',');
|
|
351
|
+
p[p.length - 1] += '{' + body + '}';
|
|
352
|
+
var postParts = parseCommaParts(post);
|
|
353
|
+
if (post.length) {
|
|
354
|
+
p[p.length - 1] += postParts.shift();
|
|
355
|
+
p.push.apply(p, postParts);
|
|
356
|
+
}
|
|
357
|
+
parts.push.apply(parts, p);
|
|
358
|
+
return parts;
|
|
359
|
+
}
|
|
360
|
+
function expandTop(str) {
|
|
361
|
+
if (!str) return [];
|
|
362
|
+
if ('{}' === str.substr(0, 2)) str = '\\{\\}' + str.substr(2);
|
|
363
|
+
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
364
|
+
}
|
|
365
|
+
function embrace(str) {
|
|
366
|
+
return '{' + str + '}';
|
|
367
|
+
}
|
|
368
|
+
function isPadded(el) {
|
|
369
|
+
return /^-?0\d/.test(el);
|
|
370
|
+
}
|
|
371
|
+
function lte(i, y) {
|
|
372
|
+
return i <= y;
|
|
373
|
+
}
|
|
374
|
+
function gte(i, y) {
|
|
375
|
+
return i >= y;
|
|
376
|
+
}
|
|
377
|
+
function expand(str, isTop) {
|
|
378
|
+
var expansions = [];
|
|
379
|
+
var m = balanced('{', '}', str);
|
|
380
|
+
if (!m) return [
|
|
381
|
+
str
|
|
382
|
+
];
|
|
383
|
+
var pre = m.pre;
|
|
384
|
+
var post = m.post.length ? expand(m.post, false) : [
|
|
385
|
+
''
|
|
386
|
+
];
|
|
387
|
+
if (/\$$/.test(m.pre)) for(var k = 0; k < post.length; k++){
|
|
388
|
+
var expansion = pre + '{' + m.body + '}' + post[k];
|
|
389
|
+
expansions.push(expansion);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
393
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
394
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
395
|
+
var isOptions = m.body.indexOf(',') >= 0;
|
|
396
|
+
if (!isSequence && !isOptions) {
|
|
397
|
+
if (m.post.match(/,.*\}/)) {
|
|
398
|
+
str = m.pre + '{' + m.body + escClose + m.post;
|
|
399
|
+
return expand(str);
|
|
400
|
+
}
|
|
401
|
+
return [
|
|
402
|
+
str
|
|
403
|
+
];
|
|
404
|
+
}
|
|
405
|
+
var n;
|
|
406
|
+
if (isSequence) n = m.body.split(/\.\./);
|
|
407
|
+
else {
|
|
408
|
+
n = parseCommaParts(m.body);
|
|
409
|
+
if (1 === n.length) {
|
|
410
|
+
n = expand(n[0], false).map(embrace);
|
|
411
|
+
if (1 === n.length) return post.map(function(p) {
|
|
412
|
+
return m.pre + n[0] + p;
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
var N;
|
|
417
|
+
if (isSequence) {
|
|
418
|
+
var x = numeric(n[0]);
|
|
419
|
+
var y = numeric(n[1]);
|
|
420
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
421
|
+
var incr = 3 == n.length ? Math.abs(numeric(n[2])) : 1;
|
|
422
|
+
var test = lte;
|
|
423
|
+
var reverse = y < x;
|
|
424
|
+
if (reverse) {
|
|
425
|
+
incr *= -1;
|
|
426
|
+
test = gte;
|
|
427
|
+
}
|
|
428
|
+
var pad = n.some(isPadded);
|
|
429
|
+
N = [];
|
|
430
|
+
for(var i = x; test(i, y); i += incr){
|
|
431
|
+
var c;
|
|
432
|
+
if (isAlphaSequence) {
|
|
433
|
+
c = String.fromCharCode(i);
|
|
434
|
+
if ('\\' === c) c = '';
|
|
435
|
+
} else {
|
|
436
|
+
c = String(i);
|
|
437
|
+
if (pad) {
|
|
438
|
+
var need = width - c.length;
|
|
439
|
+
if (need > 0) {
|
|
440
|
+
var z = new Array(need + 1).join('0');
|
|
441
|
+
c = i < 0 ? '-' + z + c.slice(1) : z + c;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
N.push(c);
|
|
446
|
+
}
|
|
447
|
+
} else {
|
|
448
|
+
N = [];
|
|
449
|
+
for(var j = 0; j < n.length; j++)N.push.apply(N, expand(n[j], false));
|
|
450
|
+
}
|
|
451
|
+
for(var j = 0; j < N.length; j++)for(var k = 0; k < post.length; k++){
|
|
452
|
+
var expansion = pre + N[j] + post[k];
|
|
453
|
+
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return expansions;
|
|
457
|
+
}
|
|
458
|
+
},
|
|
265
459
|
"../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
266
460
|
"use strict";
|
|
267
461
|
const ansiStyles = __webpack_require__("../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js");
|
|
@@ -3180,203 +3374,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3180
3374
|
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
3181
3375
|
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
3182
3376
|
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
3183
|
-
var package_namespaceObject =
|
|
3184
|
-
|
|
3185
|
-
const balanced = (a, b, str)=>{
|
|
3186
|
-
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
3187
|
-
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
3188
|
-
const r = null !== ma && null != mb && range(ma, mb, str);
|
|
3189
|
-
return r && {
|
|
3190
|
-
start: r[0],
|
|
3191
|
-
end: r[1],
|
|
3192
|
-
pre: str.slice(0, r[0]),
|
|
3193
|
-
body: str.slice(r[0] + ma.length, r[1]),
|
|
3194
|
-
post: str.slice(r[1] + mb.length)
|
|
3195
|
-
};
|
|
3196
|
-
};
|
|
3197
|
-
const maybeMatch = (reg, str)=>{
|
|
3198
|
-
const m = str.match(reg);
|
|
3199
|
-
return m ? m[0] : null;
|
|
3200
|
-
};
|
|
3201
|
-
const range = (a, b, str)=>{
|
|
3202
|
-
let begs, beg, left, right, result;
|
|
3203
|
-
let ai = str.indexOf(a);
|
|
3204
|
-
let bi = str.indexOf(b, ai + 1);
|
|
3205
|
-
let i = ai;
|
|
3206
|
-
if (ai >= 0 && bi > 0) {
|
|
3207
|
-
if (a === b) return [
|
|
3208
|
-
ai,
|
|
3209
|
-
bi
|
|
3210
|
-
];
|
|
3211
|
-
begs = [];
|
|
3212
|
-
left = str.length;
|
|
3213
|
-
while(i >= 0 && !result){
|
|
3214
|
-
if (i === ai) {
|
|
3215
|
-
begs.push(i);
|
|
3216
|
-
ai = str.indexOf(a, i + 1);
|
|
3217
|
-
} else if (1 === begs.length) {
|
|
3218
|
-
const r = begs.pop();
|
|
3219
|
-
if (void 0 !== r) result = [
|
|
3220
|
-
r,
|
|
3221
|
-
bi
|
|
3222
|
-
];
|
|
3223
|
-
} else {
|
|
3224
|
-
beg = begs.pop();
|
|
3225
|
-
if (void 0 !== beg && beg < left) {
|
|
3226
|
-
left = beg;
|
|
3227
|
-
right = bi;
|
|
3228
|
-
}
|
|
3229
|
-
bi = str.indexOf(b, i + 1);
|
|
3230
|
-
}
|
|
3231
|
-
i = ai < bi && ai >= 0 ? ai : bi;
|
|
3232
|
-
}
|
|
3233
|
-
if (begs.length && void 0 !== right) result = [
|
|
3234
|
-
left,
|
|
3235
|
-
right
|
|
3236
|
-
];
|
|
3237
|
-
}
|
|
3238
|
-
return result;
|
|
3377
|
+
var package_namespaceObject = {
|
|
3378
|
+
rE: "1.8.8"
|
|
3239
3379
|
};
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
const escClose = '\0CLOSE' + Math.random() + '\0';
|
|
3243
|
-
const escComma = '\0COMMA' + Math.random() + '\0';
|
|
3244
|
-
const escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
3245
|
-
const escSlashPattern = new RegExp(escSlash, 'g');
|
|
3246
|
-
const escOpenPattern = new RegExp(escOpen, 'g');
|
|
3247
|
-
const escClosePattern = new RegExp(escClose, 'g');
|
|
3248
|
-
const escCommaPattern = new RegExp(escComma, 'g');
|
|
3249
|
-
const escPeriodPattern = new RegExp(escPeriod, 'g');
|
|
3250
|
-
const slashPattern = /\\\\/g;
|
|
3251
|
-
const openPattern = /\\{/g;
|
|
3252
|
-
const closePattern = /\\}/g;
|
|
3253
|
-
const commaPattern = /\\,/g;
|
|
3254
|
-
const periodPattern = /\\\./g;
|
|
3255
|
-
const EXPANSION_MAX = 100000;
|
|
3256
|
-
function numeric(str) {
|
|
3257
|
-
return isNaN(str) ? str.charCodeAt(0) : parseInt(str, 10);
|
|
3258
|
-
}
|
|
3259
|
-
function escapeBraces(str) {
|
|
3260
|
-
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
3261
|
-
}
|
|
3262
|
-
function unescapeBraces(str) {
|
|
3263
|
-
return str.replace(escSlashPattern, '\\').replace(escOpenPattern, '{').replace(escClosePattern, '}').replace(escCommaPattern, ',').replace(escPeriodPattern, '.');
|
|
3264
|
-
}
|
|
3265
|
-
function parseCommaParts(str) {
|
|
3266
|
-
if (!str) return [
|
|
3267
|
-
''
|
|
3268
|
-
];
|
|
3269
|
-
const parts = [];
|
|
3270
|
-
const m = balanced('{', '}', str);
|
|
3271
|
-
if (!m) return str.split(',');
|
|
3272
|
-
const { pre, body, post } = m;
|
|
3273
|
-
const p = pre.split(',');
|
|
3274
|
-
p[p.length - 1] += '{' + body + '}';
|
|
3275
|
-
const postParts = parseCommaParts(post);
|
|
3276
|
-
if (post.length) {
|
|
3277
|
-
p[p.length - 1] += postParts.shift();
|
|
3278
|
-
p.push.apply(p, postParts);
|
|
3279
|
-
}
|
|
3280
|
-
parts.push.apply(parts, p);
|
|
3281
|
-
return parts;
|
|
3282
|
-
}
|
|
3283
|
-
function expand(str, options = {}) {
|
|
3284
|
-
if (!str) return [];
|
|
3285
|
-
const { max = EXPANSION_MAX } = options;
|
|
3286
|
-
if ('{}' === str.slice(0, 2)) str = '\\{\\}' + str.slice(2);
|
|
3287
|
-
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
3288
|
-
}
|
|
3289
|
-
function embrace(str) {
|
|
3290
|
-
return '{' + str + '}';
|
|
3291
|
-
}
|
|
3292
|
-
function isPadded(el) {
|
|
3293
|
-
return /^-?0\d/.test(el);
|
|
3294
|
-
}
|
|
3295
|
-
function lte(i, y) {
|
|
3296
|
-
return i <= y;
|
|
3297
|
-
}
|
|
3298
|
-
function gte(i, y) {
|
|
3299
|
-
return i >= y;
|
|
3300
|
-
}
|
|
3301
|
-
function expand_(str, max, isTop) {
|
|
3302
|
-
const expansions = [];
|
|
3303
|
-
const m = balanced('{', '}', str);
|
|
3304
|
-
if (!m) return [
|
|
3305
|
-
str
|
|
3306
|
-
];
|
|
3307
|
-
const pre = m.pre;
|
|
3308
|
-
const post = m.post.length ? expand_(m.post, max, false) : [
|
|
3309
|
-
''
|
|
3310
|
-
];
|
|
3311
|
-
if (/\$$/.test(m.pre)) for(let k = 0; k < post.length && k < max; k++){
|
|
3312
|
-
const expansion = pre + '{' + m.body + '}' + post[k];
|
|
3313
|
-
expansions.push(expansion);
|
|
3314
|
-
}
|
|
3315
|
-
else {
|
|
3316
|
-
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
3317
|
-
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
3318
|
-
const isSequence = isNumericSequence || isAlphaSequence;
|
|
3319
|
-
const isOptions = m.body.indexOf(',') >= 0;
|
|
3320
|
-
if (!isSequence && !isOptions) {
|
|
3321
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
3322
|
-
str = m.pre + '{' + m.body + escClose + m.post;
|
|
3323
|
-
return expand_(str, max, true);
|
|
3324
|
-
}
|
|
3325
|
-
return [
|
|
3326
|
-
str
|
|
3327
|
-
];
|
|
3328
|
-
}
|
|
3329
|
-
let n;
|
|
3330
|
-
if (isSequence) n = m.body.split(/\.\./);
|
|
3331
|
-
else {
|
|
3332
|
-
n = parseCommaParts(m.body);
|
|
3333
|
-
if (1 === n.length && void 0 !== n[0]) {
|
|
3334
|
-
n = expand_(n[0], max, false).map(embrace);
|
|
3335
|
-
if (1 === n.length) return post.map((p)=>m.pre + n[0] + p);
|
|
3336
|
-
}
|
|
3337
|
-
}
|
|
3338
|
-
let N;
|
|
3339
|
-
if (isSequence && void 0 !== n[0] && void 0 !== n[1]) {
|
|
3340
|
-
const x = numeric(n[0]);
|
|
3341
|
-
const y = numeric(n[1]);
|
|
3342
|
-
const width = Math.max(n[0].length, n[1].length);
|
|
3343
|
-
let incr = 3 === n.length && void 0 !== n[2] ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
3344
|
-
let test = lte;
|
|
3345
|
-
const reverse = y < x;
|
|
3346
|
-
if (reverse) {
|
|
3347
|
-
incr *= -1;
|
|
3348
|
-
test = gte;
|
|
3349
|
-
}
|
|
3350
|
-
const pad = n.some(isPadded);
|
|
3351
|
-
N = [];
|
|
3352
|
-
for(let i = x; test(i, y); i += incr){
|
|
3353
|
-
let c;
|
|
3354
|
-
if (isAlphaSequence) {
|
|
3355
|
-
c = String.fromCharCode(i);
|
|
3356
|
-
if ('\\' === c) c = '';
|
|
3357
|
-
} else {
|
|
3358
|
-
c = String(i);
|
|
3359
|
-
if (pad) {
|
|
3360
|
-
const need = width - c.length;
|
|
3361
|
-
if (need > 0) {
|
|
3362
|
-
const z = new Array(need + 1).join('0');
|
|
3363
|
-
c = i < 0 ? '-' + z + c.slice(1) : z + c;
|
|
3364
|
-
}
|
|
3365
|
-
}
|
|
3366
|
-
}
|
|
3367
|
-
N.push(c);
|
|
3368
|
-
}
|
|
3369
|
-
} else {
|
|
3370
|
-
N = [];
|
|
3371
|
-
for(let j = 0; j < n.length; j++)N.push.apply(N, expand_(n[j], max, false));
|
|
3372
|
-
}
|
|
3373
|
-
for(let j = 0; j < N.length; j++)for(let k = 0; k < post.length && expansions.length < max; k++){
|
|
3374
|
-
const expansion = pre + N[j] + post[k];
|
|
3375
|
-
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
return expansions;
|
|
3379
|
-
}
|
|
3380
|
+
var logger_ = __webpack_require__("@midscene/shared/logger");
|
|
3381
|
+
var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
|
|
3380
3382
|
const MAX_PATTERN_LENGTH = 65536;
|
|
3381
3383
|
const assertValidPattern = (pattern)=>{
|
|
3382
3384
|
if ('string' != typeof pattern) throw new TypeError('invalid pattern');
|
|
@@ -3542,11 +3544,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3542
3544
|
true
|
|
3543
3545
|
];
|
|
3544
3546
|
};
|
|
3545
|
-
const unescape_unescape = (s, { windowsPathsNoEscape = false
|
|
3546
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2').replace(/\\([^/])/g, '$1');
|
|
3547
|
-
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2').replace(/\\([^/{}])/g, '$1');
|
|
3548
|
-
};
|
|
3549
|
-
var ast_a;
|
|
3547
|
+
const unescape_unescape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1');
|
|
3550
3548
|
const types = new Set([
|
|
3551
3549
|
'!',
|
|
3552
3550
|
'?',
|
|
@@ -3555,168 +3553,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3555
3553
|
'@'
|
|
3556
3554
|
]);
|
|
3557
3555
|
const isExtglobType = (c)=>types.has(c);
|
|
3558
|
-
const isExtglobAST = (c)=>isExtglobType(c.type);
|
|
3559
|
-
const adoptionMap = new Map([
|
|
3560
|
-
[
|
|
3561
|
-
'!',
|
|
3562
|
-
[
|
|
3563
|
-
'@'
|
|
3564
|
-
]
|
|
3565
|
-
],
|
|
3566
|
-
[
|
|
3567
|
-
'?',
|
|
3568
|
-
[
|
|
3569
|
-
'?',
|
|
3570
|
-
'@'
|
|
3571
|
-
]
|
|
3572
|
-
],
|
|
3573
|
-
[
|
|
3574
|
-
'@',
|
|
3575
|
-
[
|
|
3576
|
-
'@'
|
|
3577
|
-
]
|
|
3578
|
-
],
|
|
3579
|
-
[
|
|
3580
|
-
'*',
|
|
3581
|
-
[
|
|
3582
|
-
'*',
|
|
3583
|
-
'+',
|
|
3584
|
-
'?',
|
|
3585
|
-
'@'
|
|
3586
|
-
]
|
|
3587
|
-
],
|
|
3588
|
-
[
|
|
3589
|
-
'+',
|
|
3590
|
-
[
|
|
3591
|
-
'+',
|
|
3592
|
-
'@'
|
|
3593
|
-
]
|
|
3594
|
-
]
|
|
3595
|
-
]);
|
|
3596
|
-
const adoptionWithSpaceMap = new Map([
|
|
3597
|
-
[
|
|
3598
|
-
'!',
|
|
3599
|
-
[
|
|
3600
|
-
'?'
|
|
3601
|
-
]
|
|
3602
|
-
],
|
|
3603
|
-
[
|
|
3604
|
-
'@',
|
|
3605
|
-
[
|
|
3606
|
-
'?'
|
|
3607
|
-
]
|
|
3608
|
-
],
|
|
3609
|
-
[
|
|
3610
|
-
'+',
|
|
3611
|
-
[
|
|
3612
|
-
'?',
|
|
3613
|
-
'*'
|
|
3614
|
-
]
|
|
3615
|
-
]
|
|
3616
|
-
]);
|
|
3617
|
-
const adoptionAnyMap = new Map([
|
|
3618
|
-
[
|
|
3619
|
-
'!',
|
|
3620
|
-
[
|
|
3621
|
-
'?',
|
|
3622
|
-
'@'
|
|
3623
|
-
]
|
|
3624
|
-
],
|
|
3625
|
-
[
|
|
3626
|
-
'?',
|
|
3627
|
-
[
|
|
3628
|
-
'?',
|
|
3629
|
-
'@'
|
|
3630
|
-
]
|
|
3631
|
-
],
|
|
3632
|
-
[
|
|
3633
|
-
'@',
|
|
3634
|
-
[
|
|
3635
|
-
'?',
|
|
3636
|
-
'@'
|
|
3637
|
-
]
|
|
3638
|
-
],
|
|
3639
|
-
[
|
|
3640
|
-
'*',
|
|
3641
|
-
[
|
|
3642
|
-
'*',
|
|
3643
|
-
'+',
|
|
3644
|
-
'?',
|
|
3645
|
-
'@'
|
|
3646
|
-
]
|
|
3647
|
-
],
|
|
3648
|
-
[
|
|
3649
|
-
'+',
|
|
3650
|
-
[
|
|
3651
|
-
'+',
|
|
3652
|
-
'@',
|
|
3653
|
-
'?',
|
|
3654
|
-
'*'
|
|
3655
|
-
]
|
|
3656
|
-
]
|
|
3657
|
-
]);
|
|
3658
|
-
const usurpMap = new Map([
|
|
3659
|
-
[
|
|
3660
|
-
'!',
|
|
3661
|
-
new Map([
|
|
3662
|
-
[
|
|
3663
|
-
'!',
|
|
3664
|
-
'@'
|
|
3665
|
-
]
|
|
3666
|
-
])
|
|
3667
|
-
],
|
|
3668
|
-
[
|
|
3669
|
-
'?',
|
|
3670
|
-
new Map([
|
|
3671
|
-
[
|
|
3672
|
-
'*',
|
|
3673
|
-
'*'
|
|
3674
|
-
],
|
|
3675
|
-
[
|
|
3676
|
-
'+',
|
|
3677
|
-
'*'
|
|
3678
|
-
]
|
|
3679
|
-
])
|
|
3680
|
-
],
|
|
3681
|
-
[
|
|
3682
|
-
'@',
|
|
3683
|
-
new Map([
|
|
3684
|
-
[
|
|
3685
|
-
'!',
|
|
3686
|
-
'!'
|
|
3687
|
-
],
|
|
3688
|
-
[
|
|
3689
|
-
'?',
|
|
3690
|
-
'?'
|
|
3691
|
-
],
|
|
3692
|
-
[
|
|
3693
|
-
'@',
|
|
3694
|
-
'@'
|
|
3695
|
-
],
|
|
3696
|
-
[
|
|
3697
|
-
'*',
|
|
3698
|
-
'*'
|
|
3699
|
-
],
|
|
3700
|
-
[
|
|
3701
|
-
'+',
|
|
3702
|
-
'+'
|
|
3703
|
-
]
|
|
3704
|
-
])
|
|
3705
|
-
],
|
|
3706
|
-
[
|
|
3707
|
-
'+',
|
|
3708
|
-
new Map([
|
|
3709
|
-
[
|
|
3710
|
-
'?',
|
|
3711
|
-
'*'
|
|
3712
|
-
],
|
|
3713
|
-
[
|
|
3714
|
-
'*',
|
|
3715
|
-
'*'
|
|
3716
|
-
]
|
|
3717
|
-
])
|
|
3718
|
-
]
|
|
3719
|
-
]);
|
|
3720
3556
|
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
|
|
3721
3557
|
const startNoDot = '(?!\\.)';
|
|
3722
3558
|
const addPatternStart = new Set([
|
|
@@ -3732,7 +3568,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3732
3568
|
const qmark = '[^/]';
|
|
3733
3569
|
const star = qmark + '*?';
|
|
3734
3570
|
const starNoEmpty = qmark + '+?';
|
|
3735
|
-
let ID = 0;
|
|
3736
3571
|
class ast_AST {
|
|
3737
3572
|
type;
|
|
3738
3573
|
#root;
|
|
@@ -3746,22 +3581,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3746
3581
|
#options;
|
|
3747
3582
|
#toString;
|
|
3748
3583
|
#emptyExt = false;
|
|
3749
|
-
id = ++ID;
|
|
3750
|
-
get depth() {
|
|
3751
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
3752
|
-
}
|
|
3753
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
3754
|
-
return {
|
|
3755
|
-
'@@type': 'AST',
|
|
3756
|
-
id: this.id,
|
|
3757
|
-
type: this.type,
|
|
3758
|
-
root: this.#root.id,
|
|
3759
|
-
parent: this.#parent?.id,
|
|
3760
|
-
depth: this.depth,
|
|
3761
|
-
partsLength: this.#parts.length,
|
|
3762
|
-
parts: this.#parts
|
|
3763
|
-
};
|
|
3764
|
-
}
|
|
3765
3584
|
constructor(type, parent, options = {}){
|
|
3766
3585
|
this.type = type;
|
|
3767
3586
|
if (type) this.#hasMagic = true;
|
|
@@ -3780,7 +3599,9 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3780
3599
|
return this.#hasMagic;
|
|
3781
3600
|
}
|
|
3782
3601
|
toString() {
|
|
3783
|
-
|
|
3602
|
+
if (void 0 !== this.#toString) return this.#toString;
|
|
3603
|
+
if (!this.type) return this.#toString = this.#parts.map((p)=>String(p)).join('');
|
|
3604
|
+
return this.#toString = this.type + '(' + this.#parts.map((p)=>String(p)).join('|') + ')';
|
|
3784
3605
|
}
|
|
3785
3606
|
#fillNegs() {
|
|
3786
3607
|
if (this !== this.#root) throw new Error('should only call on root');
|
|
@@ -3805,7 +3626,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3805
3626
|
}
|
|
3806
3627
|
push(...parts) {
|
|
3807
3628
|
for (const p of parts)if ('' !== p) {
|
|
3808
|
-
if ('string' != typeof p && !(p instanceof
|
|
3629
|
+
if ('string' != typeof p && !(p instanceof ast_AST && p.#parent === this)) throw new Error('invalid part: ' + p);
|
|
3809
3630
|
this.#parts.push(p);
|
|
3810
3631
|
}
|
|
3811
3632
|
}
|
|
@@ -3825,7 +3646,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3825
3646
|
const p = this.#parent;
|
|
3826
3647
|
for(let i = 0; i < this.#parentIndex; i++){
|
|
3827
3648
|
const pp = p.#parts[i];
|
|
3828
|
-
if (!(pp instanceof
|
|
3649
|
+
if (!(pp instanceof ast_AST && '!' === pp.type)) return false;
|
|
3829
3650
|
}
|
|
3830
3651
|
return true;
|
|
3831
3652
|
}
|
|
@@ -3842,12 +3663,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3842
3663
|
else this.push(part.clone(this));
|
|
3843
3664
|
}
|
|
3844
3665
|
clone(parent) {
|
|
3845
|
-
const c = new
|
|
3666
|
+
const c = new ast_AST(this.type, parent);
|
|
3846
3667
|
for (const p of this.#parts)c.copyIn(p);
|
|
3847
3668
|
return c;
|
|
3848
3669
|
}
|
|
3849
|
-
static #parseAST(str, ast, pos, opt
|
|
3850
|
-
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
3670
|
+
static #parseAST(str, ast, pos, opt) {
|
|
3851
3671
|
let escaping = false;
|
|
3852
3672
|
let inBrace = false;
|
|
3853
3673
|
let braceStart = -1;
|
|
@@ -3876,12 +3696,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3876
3696
|
acc += c;
|
|
3877
3697
|
continue;
|
|
3878
3698
|
}
|
|
3879
|
-
|
|
3880
|
-
if (doRecurse) {
|
|
3699
|
+
if (!opt.noext && isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3881
3700
|
ast.push(acc);
|
|
3882
3701
|
acc = '';
|
|
3883
|
-
const ext = new
|
|
3884
|
-
i =
|
|
3702
|
+
const ext = new ast_AST(c, ast);
|
|
3703
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3885
3704
|
ast.push(ext);
|
|
3886
3705
|
continue;
|
|
3887
3706
|
}
|
|
@@ -3891,7 +3710,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3891
3710
|
return i;
|
|
3892
3711
|
}
|
|
3893
3712
|
let i = pos + 1;
|
|
3894
|
-
let part = new
|
|
3713
|
+
let part = new ast_AST(null, ast);
|
|
3895
3714
|
const parts = [];
|
|
3896
3715
|
let acc = '';
|
|
3897
3716
|
while(i < str.length){
|
|
@@ -3915,21 +3734,19 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3915
3734
|
acc += c;
|
|
3916
3735
|
continue;
|
|
3917
3736
|
}
|
|
3918
|
-
|
|
3919
|
-
if (doRecurse) {
|
|
3920
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
3737
|
+
if (isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3921
3738
|
part.push(acc);
|
|
3922
3739
|
acc = '';
|
|
3923
|
-
const ext = new
|
|
3740
|
+
const ext = new ast_AST(c, part);
|
|
3924
3741
|
part.push(ext);
|
|
3925
|
-
i =
|
|
3742
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3926
3743
|
continue;
|
|
3927
3744
|
}
|
|
3928
3745
|
if ('|' === c) {
|
|
3929
3746
|
part.push(acc);
|
|
3930
3747
|
acc = '';
|
|
3931
3748
|
parts.push(part);
|
|
3932
|
-
part = new
|
|
3749
|
+
part = new ast_AST(null, ast);
|
|
3933
3750
|
continue;
|
|
3934
3751
|
}
|
|
3935
3752
|
if (')' === c) {
|
|
@@ -3948,55 +3765,9 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3948
3765
|
];
|
|
3949
3766
|
return i;
|
|
3950
3767
|
}
|
|
3951
|
-
#canAdoptWithSpace(child) {
|
|
3952
|
-
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
3953
|
-
}
|
|
3954
|
-
#canAdopt(child, map = adoptionMap) {
|
|
3955
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type) return false;
|
|
3956
|
-
const gc = child.#parts[0];
|
|
3957
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3958
|
-
return this.#canAdoptType(gc.type, map);
|
|
3959
|
-
}
|
|
3960
|
-
#canAdoptType(c, map = adoptionAnyMap) {
|
|
3961
|
-
return !!map.get(this.type)?.includes(c);
|
|
3962
|
-
}
|
|
3963
|
-
#adoptWithSpace(child, index) {
|
|
3964
|
-
const gc = child.#parts[0];
|
|
3965
|
-
const blank = new ast_a(null, gc, this.options);
|
|
3966
|
-
blank.#parts.push('');
|
|
3967
|
-
gc.push(blank);
|
|
3968
|
-
this.#adopt(child, index);
|
|
3969
|
-
}
|
|
3970
|
-
#adopt(child, index) {
|
|
3971
|
-
const gc = child.#parts[0];
|
|
3972
|
-
this.#parts.splice(index, 1, ...gc.#parts);
|
|
3973
|
-
for (const p of gc.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3974
|
-
this.#toString = void 0;
|
|
3975
|
-
}
|
|
3976
|
-
#canUsurpType(c) {
|
|
3977
|
-
const m = usurpMap.get(this.type);
|
|
3978
|
-
return !!m?.has(c);
|
|
3979
|
-
}
|
|
3980
|
-
#canUsurp(child) {
|
|
3981
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type || 1 !== this.#parts.length) return false;
|
|
3982
|
-
const gc = child.#parts[0];
|
|
3983
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3984
|
-
return this.#canUsurpType(gc.type);
|
|
3985
|
-
}
|
|
3986
|
-
#usurp(child) {
|
|
3987
|
-
const m = usurpMap.get(this.type);
|
|
3988
|
-
const gc = child.#parts[0];
|
|
3989
|
-
const nt = m?.get(gc.type);
|
|
3990
|
-
if (!nt) return false;
|
|
3991
|
-
this.#parts = gc.#parts;
|
|
3992
|
-
for (const p of this.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3993
|
-
this.type = nt;
|
|
3994
|
-
this.#toString = void 0;
|
|
3995
|
-
this.#emptyExt = false;
|
|
3996
|
-
}
|
|
3997
3768
|
static fromGlob(pattern, options = {}) {
|
|
3998
|
-
const ast = new
|
|
3999
|
-
|
|
3769
|
+
const ast = new ast_AST(null, void 0, options);
|
|
3770
|
+
ast_AST.#parseAST(pattern, ast, 0, options);
|
|
4000
3771
|
return ast;
|
|
4001
3772
|
}
|
|
4002
3773
|
toMMPattern() {
|
|
@@ -4016,14 +3787,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4016
3787
|
}
|
|
4017
3788
|
toRegExpSource(allowDot) {
|
|
4018
3789
|
const dot = allowDot ?? !!this.#options.dot;
|
|
4019
|
-
if (this.#root === this)
|
|
4020
|
-
|
|
4021
|
-
this
|
|
4022
|
-
}
|
|
4023
|
-
if (!isExtglobAST(this)) {
|
|
4024
|
-
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s)=>'string' != typeof s);
|
|
3790
|
+
if (this.#root === this) this.#fillNegs();
|
|
3791
|
+
if (!this.type) {
|
|
3792
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
4025
3793
|
const src = this.#parts.map((p)=>{
|
|
4026
|
-
const [re, _, hasMagic, uflag] = 'string' == typeof p ?
|
|
3794
|
+
const [re, _, hasMagic, uflag] = 'string' == typeof p ? ast_AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
4027
3795
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
4028
3796
|
this.#uflag = this.#uflag || uflag;
|
|
4029
3797
|
return re;
|
|
@@ -4055,12 +3823,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4055
3823
|
let body = this.#partsToRegExp(dot);
|
|
4056
3824
|
if (this.isStart() && this.isEnd() && !body && '!' !== this.type) {
|
|
4057
3825
|
const s = this.toString();
|
|
4058
|
-
|
|
4059
|
-
me.#parts = [
|
|
3826
|
+
this.#parts = [
|
|
4060
3827
|
s
|
|
4061
3828
|
];
|
|
4062
|
-
|
|
4063
|
-
|
|
3829
|
+
this.type = null;
|
|
3830
|
+
this.#hasMagic = void 0;
|
|
4064
3831
|
return [
|
|
4065
3832
|
s,
|
|
4066
3833
|
unescape_unescape(this.toString()),
|
|
@@ -4084,32 +3851,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4084
3851
|
this.#uflag
|
|
4085
3852
|
];
|
|
4086
3853
|
}
|
|
4087
|
-
#flatten() {
|
|
4088
|
-
if (isExtglobAST(this)) {
|
|
4089
|
-
let iterations = 0;
|
|
4090
|
-
let done = false;
|
|
4091
|
-
do {
|
|
4092
|
-
done = true;
|
|
4093
|
-
for(let i = 0; i < this.#parts.length; i++){
|
|
4094
|
-
const c = this.#parts[i];
|
|
4095
|
-
if ('object' == typeof c) {
|
|
4096
|
-
c.#flatten();
|
|
4097
|
-
if (this.#canAdopt(c)) {
|
|
4098
|
-
done = false;
|
|
4099
|
-
this.#adopt(c, i);
|
|
4100
|
-
} else if (this.#canAdoptWithSpace(c)) {
|
|
4101
|
-
done = false;
|
|
4102
|
-
this.#adoptWithSpace(c, i);
|
|
4103
|
-
} else if (this.#canUsurp(c)) {
|
|
4104
|
-
done = false;
|
|
4105
|
-
this.#usurp(c);
|
|
4106
|
-
}
|
|
4107
|
-
}
|
|
4108
|
-
}
|
|
4109
|
-
}while (!done && ++iterations < 10);
|
|
4110
|
-
} else for (const p of this.#parts)if ('object' == typeof p) p.#flatten();
|
|
4111
|
-
this.#toString = void 0;
|
|
4112
|
-
}
|
|
4113
3854
|
#partsToRegExp(dot) {
|
|
4114
3855
|
return this.#parts.map((p)=>{
|
|
4115
3856
|
if ('string' == typeof p) throw new Error('string type in extglob ast??');
|
|
@@ -4122,7 +3863,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4122
3863
|
let escaping = false;
|
|
4123
3864
|
let re = '';
|
|
4124
3865
|
let uflag = false;
|
|
4125
|
-
let inStar = false;
|
|
4126
3866
|
for(let i = 0; i < glob.length; i++){
|
|
4127
3867
|
const c = glob.charAt(i);
|
|
4128
3868
|
if (escaping) {
|
|
@@ -4130,14 +3870,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4130
3870
|
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
4131
3871
|
continue;
|
|
4132
3872
|
}
|
|
4133
|
-
if ('*' === c) {
|
|
4134
|
-
if (inStar) continue;
|
|
4135
|
-
inStar = true;
|
|
4136
|
-
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
4137
|
-
hasMagic = true;
|
|
4138
|
-
continue;
|
|
4139
|
-
}
|
|
4140
|
-
inStar = false;
|
|
4141
3873
|
if ('\\' === c) {
|
|
4142
3874
|
if (i === glob.length - 1) re += '\\\\';
|
|
4143
3875
|
else escaping = true;
|
|
@@ -4153,6 +3885,12 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4153
3885
|
continue;
|
|
4154
3886
|
}
|
|
4155
3887
|
}
|
|
3888
|
+
if ('*' === c) {
|
|
3889
|
+
if (noEmpty && '*' === glob) re += starNoEmpty;
|
|
3890
|
+
else re += star;
|
|
3891
|
+
hasMagic = true;
|
|
3892
|
+
continue;
|
|
3893
|
+
}
|
|
4156
3894
|
if ('?' === c) {
|
|
4157
3895
|
re += qmark;
|
|
4158
3896
|
hasMagic = true;
|
|
@@ -4168,17 +3906,13 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4168
3906
|
];
|
|
4169
3907
|
}
|
|
4170
3908
|
}
|
|
4171
|
-
|
|
4172
|
-
const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})=>{
|
|
4173
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, '[$&]') : s.replace(/[?*()[\]\\{}]/g, '\\$&');
|
|
4174
|
-
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
4175
|
-
};
|
|
3909
|
+
const escape_escape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
4176
3910
|
const minimatch = (p, pattern, options = {})=>{
|
|
4177
3911
|
assertValidPattern(pattern);
|
|
4178
3912
|
if (!options.nocomment && '#' === pattern.charAt(0)) return false;
|
|
4179
3913
|
return new esm_Minimatch(pattern, options).match(p);
|
|
4180
3914
|
};
|
|
4181
|
-
const starDotExtRE = /^\*+([
|
|
3915
|
+
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
4182
3916
|
const starDotExtTest = (ext)=>(f)=>!f.startsWith('.') && f.endsWith(ext);
|
|
4183
3917
|
const starDotExtTestDot = (ext)=>(f)=>f.endsWith(ext);
|
|
4184
3918
|
const starDotExtTestNocase = (ext)=>{
|
|
@@ -4197,7 +3931,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4197
3931
|
const starRE = /^\*+$/;
|
|
4198
3932
|
const starTest = (f)=>0 !== f.length && !f.startsWith('.');
|
|
4199
3933
|
const starTestDot = (f)=>0 !== f.length && '.' !== f && '..' !== f;
|
|
4200
|
-
const qmarksRE = /^\?+([
|
|
3934
|
+
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
4201
3935
|
const qmarksTestNocase = ([$0, ext = ''])=>{
|
|
4202
3936
|
const noext = qmarksTestNoExt([
|
|
4203
3937
|
$0
|
|
@@ -4292,9 +4026,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4292
4026
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [
|
|
4293
4027
|
pattern
|
|
4294
4028
|
];
|
|
4295
|
-
return
|
|
4296
|
-
max: options.braceExpandMax
|
|
4297
|
-
});
|
|
4029
|
+
return brace_expansion(pattern);
|
|
4298
4030
|
};
|
|
4299
4031
|
minimatch.braceExpand = braceExpand;
|
|
4300
4032
|
const makeRe = (pattern, options = {})=>new esm_Minimatch(pattern, options).makeRe();
|
|
@@ -4325,18 +4057,15 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4325
4057
|
isWindows;
|
|
4326
4058
|
platform;
|
|
4327
4059
|
windowsNoMagicRoot;
|
|
4328
|
-
maxGlobstarRecursion;
|
|
4329
4060
|
regexp;
|
|
4330
4061
|
constructor(pattern, options = {}){
|
|
4331
4062
|
assertValidPattern(pattern);
|
|
4332
4063
|
options = options || {};
|
|
4333
4064
|
this.options = options;
|
|
4334
|
-
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
4335
4065
|
this.pattern = pattern;
|
|
4336
4066
|
this.platform = options.platform || defaultPlatform;
|
|
4337
4067
|
this.isWindows = 'win32' === this.platform;
|
|
4338
|
-
|
|
4339
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options[awe];
|
|
4068
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options.allowWindowsEscape;
|
|
4340
4069
|
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, '/');
|
|
4341
4070
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
4342
4071
|
this.regexp = null;
|
|
@@ -4403,7 +4132,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4403
4132
|
}
|
|
4404
4133
|
preprocess(globParts) {
|
|
4405
4134
|
if (this.options.noglobstar) {
|
|
4406
|
-
for
|
|
4135
|
+
for(let i = 0; i < globParts.length; i++)for(let j = 0; j < globParts[i].length; j++)if ('**' === globParts[i][j]) globParts[i][j] = '*';
|
|
4407
4136
|
}
|
|
4408
4137
|
const { optimizationLevel = 1 } = this.options;
|
|
4409
4138
|
if (optimizationLevel >= 2) {
|
|
@@ -4466,7 +4195,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4466
4195
|
let dd = 0;
|
|
4467
4196
|
while(-1 !== (dd = parts.indexOf('..', dd + 1))){
|
|
4468
4197
|
const p = parts[dd - 1];
|
|
4469
|
-
if (p && '.' !== p && '..' !== p && '**' !== p
|
|
4198
|
+
if (p && '.' !== p && '..' !== p && '**' !== p) {
|
|
4470
4199
|
didSomething = true;
|
|
4471
4200
|
parts.splice(dd - 1, 2);
|
|
4472
4201
|
dd -= 2;
|
|
@@ -4588,8 +4317,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4588
4317
|
this.negate = negate;
|
|
4589
4318
|
}
|
|
4590
4319
|
matchOne(file, pattern, partial = false) {
|
|
4591
|
-
|
|
4592
|
-
let patternStartIndex = 0;
|
|
4320
|
+
const options = this.options;
|
|
4593
4321
|
if (this.isWindows) {
|
|
4594
4322
|
const fileDrive = 'string' == typeof file[0] && /^[a-z]:$/i.test(file[0]);
|
|
4595
4323
|
const fileUNC = !fileDrive && '' === file[0] && '' === file[1] && '?' === file[2] && /^[a-z]:$/i.test(file[3]);
|
|
@@ -4604,116 +4332,57 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4604
4332
|
];
|
|
4605
4333
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
4606
4334
|
pattern[pdi] = fd;
|
|
4607
|
-
|
|
4608
|
-
|
|
4335
|
+
if (pdi > fdi) pattern = pattern.slice(pdi);
|
|
4336
|
+
else if (fdi > pdi) file = file.slice(fdi);
|
|
4609
4337
|
}
|
|
4610
4338
|
}
|
|
4611
4339
|
}
|
|
4612
4340
|
const { optimizationLevel = 1 } = this.options;
|
|
4613
4341
|
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
const [head, body, tail] = partial ? [
|
|
4621
|
-
pattern.slice(patternIndex, firstgs),
|
|
4622
|
-
pattern.slice(firstgs + 1),
|
|
4623
|
-
[]
|
|
4624
|
-
] : [
|
|
4625
|
-
pattern.slice(patternIndex, firstgs),
|
|
4626
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
4627
|
-
pattern.slice(lastgs + 1)
|
|
4628
|
-
];
|
|
4629
|
-
if (head.length) {
|
|
4630
|
-
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
4631
|
-
if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
|
|
4632
|
-
fileIndex += head.length;
|
|
4633
|
-
patternIndex += head.length;
|
|
4634
|
-
}
|
|
4635
|
-
let fileTailMatch = 0;
|
|
4636
|
-
if (tail.length) {
|
|
4637
|
-
if (tail.length + fileIndex > file.length) return false;
|
|
4638
|
-
let tailStart = file.length - tail.length;
|
|
4639
|
-
if (this.#matchOne(file, tail, partial, tailStart, 0)) fileTailMatch = tail.length;
|
|
4640
|
-
else {
|
|
4641
|
-
if ('' !== file[file.length - 1] || fileIndex + tail.length === file.length) return false;
|
|
4642
|
-
tailStart--;
|
|
4643
|
-
if (!this.#matchOne(file, tail, partial, tailStart, 0)) return false;
|
|
4644
|
-
fileTailMatch = tail.length + 1;
|
|
4645
|
-
}
|
|
4646
|
-
}
|
|
4647
|
-
if (!body.length) {
|
|
4648
|
-
let sawSome = !!fileTailMatch;
|
|
4649
|
-
for(let i = fileIndex; i < file.length - fileTailMatch; i++){
|
|
4650
|
-
const f = String(file[i]);
|
|
4651
|
-
sawSome = true;
|
|
4652
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4653
|
-
}
|
|
4654
|
-
return partial || sawSome;
|
|
4655
|
-
}
|
|
4656
|
-
const bodySegments = [
|
|
4657
|
-
[
|
|
4658
|
-
[],
|
|
4659
|
-
0
|
|
4660
|
-
]
|
|
4661
|
-
];
|
|
4662
|
-
let currentBody = bodySegments[0];
|
|
4663
|
-
let nonGsParts = 0;
|
|
4664
|
-
const nonGsPartsSums = [
|
|
4665
|
-
0
|
|
4666
|
-
];
|
|
4667
|
-
for (const b of body)if (b === GLOBSTAR) {
|
|
4668
|
-
nonGsPartsSums.push(nonGsParts);
|
|
4669
|
-
currentBody = [
|
|
4670
|
-
[],
|
|
4671
|
-
0
|
|
4672
|
-
];
|
|
4673
|
-
bodySegments.push(currentBody);
|
|
4674
|
-
} else {
|
|
4675
|
-
currentBody[0].push(b);
|
|
4676
|
-
nonGsParts++;
|
|
4677
|
-
}
|
|
4678
|
-
let i = bodySegments.length - 1;
|
|
4679
|
-
const fileLength = file.length - fileTailMatch;
|
|
4680
|
-
for (const b of bodySegments)b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
4681
|
-
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
4682
|
-
}
|
|
4683
|
-
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
4684
|
-
const bs = bodySegments[bodyIndex];
|
|
4685
|
-
if (!bs) {
|
|
4686
|
-
for(let i = fileIndex; i < file.length; i++){
|
|
4687
|
-
sawTail = true;
|
|
4688
|
-
const f = file[i];
|
|
4689
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4690
|
-
}
|
|
4691
|
-
return sawTail;
|
|
4692
|
-
}
|
|
4693
|
-
const [body, after] = bs;
|
|
4694
|
-
while(fileIndex <= after){
|
|
4695
|
-
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
4696
|
-
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
4697
|
-
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
4698
|
-
if (false !== sub) return sub;
|
|
4699
|
-
}
|
|
4700
|
-
const f = file[fileIndex];
|
|
4701
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4702
|
-
fileIndex++;
|
|
4703
|
-
}
|
|
4704
|
-
return partial || null;
|
|
4705
|
-
}
|
|
4706
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
4707
|
-
let fi;
|
|
4708
|
-
let pi;
|
|
4709
|
-
let pl;
|
|
4710
|
-
let fl;
|
|
4711
|
-
for(fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++){
|
|
4342
|
+
this.debug('matchOne', this, {
|
|
4343
|
+
file,
|
|
4344
|
+
pattern
|
|
4345
|
+
});
|
|
4346
|
+
this.debug('matchOne', file.length, pattern.length);
|
|
4347
|
+
for(var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++){
|
|
4712
4348
|
this.debug('matchOne loop');
|
|
4713
|
-
|
|
4714
|
-
|
|
4349
|
+
var p = pattern[pi];
|
|
4350
|
+
var f = file[fi];
|
|
4715
4351
|
this.debug(pattern, p, f);
|
|
4716
|
-
if (false === p
|
|
4352
|
+
if (false === p) return false;
|
|
4353
|
+
if (p === GLOBSTAR) {
|
|
4354
|
+
this.debug('GLOBSTAR', [
|
|
4355
|
+
pattern,
|
|
4356
|
+
p,
|
|
4357
|
+
f
|
|
4358
|
+
]);
|
|
4359
|
+
var fr = fi;
|
|
4360
|
+
var pr = pi + 1;
|
|
4361
|
+
if (pr === pl) {
|
|
4362
|
+
this.debug('** at the end');
|
|
4363
|
+
for(; fi < fl; fi++)if ('.' === file[fi] || '..' === file[fi] || !options.dot && '.' === file[fi].charAt(0)) return false;
|
|
4364
|
+
return true;
|
|
4365
|
+
}
|
|
4366
|
+
while(fr < fl){
|
|
4367
|
+
var swallowee = file[fr];
|
|
4368
|
+
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
|
4369
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
4370
|
+
this.debug('globstar found match!', fr, fl, swallowee);
|
|
4371
|
+
return true;
|
|
4372
|
+
}
|
|
4373
|
+
if ('.' === swallowee || '..' === swallowee || !options.dot && '.' === swallowee.charAt(0)) {
|
|
4374
|
+
this.debug('dot detected!', file, fr, pattern, pr);
|
|
4375
|
+
break;
|
|
4376
|
+
}
|
|
4377
|
+
this.debug('globstar swallow a segment, and continue');
|
|
4378
|
+
fr++;
|
|
4379
|
+
}
|
|
4380
|
+
if (partial) {
|
|
4381
|
+
this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
|
4382
|
+
if (fr === fl) return true;
|
|
4383
|
+
}
|
|
4384
|
+
return false;
|
|
4385
|
+
}
|
|
4717
4386
|
let hit;
|
|
4718
4387
|
if ('string' == typeof p) {
|
|
4719
4388
|
hit = f === p;
|
|
@@ -4773,19 +4442,13 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4773
4442
|
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
4774
4443
|
if (void 0 === prev) if (void 0 !== next && next !== GLOBSTAR) pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
|
|
4775
4444
|
else pp[i] = twoStar;
|
|
4776
|
-
else if (void 0 === next) pp[i - 1] = prev + '(
|
|
4445
|
+
else if (void 0 === next) pp[i - 1] = prev + '(?:\\/|' + twoStar + ')?';
|
|
4777
4446
|
else if (next !== GLOBSTAR) {
|
|
4778
4447
|
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
|
|
4779
4448
|
pp[i + 1] = GLOBSTAR;
|
|
4780
4449
|
}
|
|
4781
4450
|
});
|
|
4782
|
-
|
|
4783
|
-
if (this.partial && filtered.length >= 1) {
|
|
4784
|
-
const prefixes = [];
|
|
4785
|
-
for(let i = 1; i <= filtered.length; i++)prefixes.push(filtered.slice(0, i).join('/'));
|
|
4786
|
-
return '(?:' + prefixes.join('|') + ')';
|
|
4787
|
-
}
|
|
4788
|
-
return filtered.join('/');
|
|
4451
|
+
return pp.filter((p)=>p !== GLOBSTAR).join('/');
|
|
4789
4452
|
}).join('|');
|
|
4790
4453
|
const [open, close] = set.length > 1 ? [
|
|
4791
4454
|
'(?:',
|
|
@@ -4795,20 +4458,19 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4795
4458
|
''
|
|
4796
4459
|
];
|
|
4797
4460
|
re = '^' + open + re + close + '$';
|
|
4798
|
-
if (this.partial) re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
|
|
4799
4461
|
if (this.negate) re = '^(?!' + re + ').+$';
|
|
4800
4462
|
try {
|
|
4801
4463
|
this.regexp = new RegExp(re, [
|
|
4802
4464
|
...flags
|
|
4803
4465
|
].join(''));
|
|
4804
|
-
} catch
|
|
4466
|
+
} catch (ex) {
|
|
4805
4467
|
this.regexp = false;
|
|
4806
4468
|
}
|
|
4807
4469
|
return this.regexp;
|
|
4808
4470
|
}
|
|
4809
4471
|
slashSplit(p) {
|
|
4810
4472
|
if (this.preserveMultipleSlashes) return p.split('/');
|
|
4811
|
-
if (this.isWindows && /^\/\/[
|
|
4473
|
+
if (this.isWindows && /^\/\/[^\/]+/.test(p)) return [
|
|
4812
4474
|
'',
|
|
4813
4475
|
...p.split(/\/+/)
|
|
4814
4476
|
];
|
|
@@ -4827,7 +4489,8 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4827
4489
|
this.debug(this.pattern, 'set', set);
|
|
4828
4490
|
let filename = ff[ff.length - 1];
|
|
4829
4491
|
if (!filename) for(let i = ff.length - 2; !filename && i >= 0; i--)filename = ff[i];
|
|
4830
|
-
for
|
|
4492
|
+
for(let i = 0; i < set.length; i++){
|
|
4493
|
+
const pattern = set[i];
|
|
4831
4494
|
let file = ff;
|
|
4832
4495
|
if (options.matchBase && 1 === pattern.length) file = [
|
|
4833
4496
|
filename
|
|
@@ -4850,47 +4513,85 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4850
4513
|
minimatch.escape = escape_escape;
|
|
4851
4514
|
minimatch.unescape = unescape_unescape;
|
|
4852
4515
|
var external_node_url_ = __webpack_require__("node:url");
|
|
4853
|
-
const
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4516
|
+
const perf = 'object' == typeof performance && performance && 'function' == typeof performance.now ? performance : Date;
|
|
4517
|
+
const warned = new Set();
|
|
4518
|
+
const PROCESS = 'object' == typeof process && process ? process : {};
|
|
4519
|
+
const emitWarning = (msg, type, code, fn)=>{
|
|
4520
|
+
'function' == typeof PROCESS.emitWarning ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
4521
|
+
};
|
|
4522
|
+
let AC = globalThis.AbortController;
|
|
4523
|
+
let AS = globalThis.AbortSignal;
|
|
4524
|
+
if (void 0 === AC) {
|
|
4525
|
+
AS = class {
|
|
4526
|
+
onabort;
|
|
4527
|
+
_onabort = [];
|
|
4528
|
+
reason;
|
|
4529
|
+
aborted = false;
|
|
4530
|
+
addEventListener(_, fn) {
|
|
4531
|
+
this._onabort.push(fn);
|
|
4532
|
+
}
|
|
4533
|
+
};
|
|
4534
|
+
AC = class {
|
|
4535
|
+
constructor(){
|
|
4536
|
+
warnACPolyfill();
|
|
4537
|
+
}
|
|
4538
|
+
signal = new AS();
|
|
4539
|
+
abort(reason) {
|
|
4540
|
+
if (this.signal.aborted) return;
|
|
4541
|
+
this.signal.reason = reason;
|
|
4542
|
+
this.signal.aborted = true;
|
|
4543
|
+
for (const fn of this.signal._onabort)fn(reason);
|
|
4544
|
+
this.signal.onabort?.(reason);
|
|
4545
|
+
}
|
|
4546
|
+
};
|
|
4547
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
4548
|
+
const warnACPolyfill = ()=>{
|
|
4549
|
+
if (!printACPolyfillWarning) return;
|
|
4550
|
+
printACPolyfillWarning = false;
|
|
4551
|
+
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);
|
|
4552
|
+
};
|
|
4553
|
+
}
|
|
4554
|
+
const shouldWarn = (code)=>!warned.has(code);
|
|
4555
|
+
Symbol('type');
|
|
4556
|
+
const isPosInt = (n)=>n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
4557
|
+
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;
|
|
4558
|
+
class ZeroArray extends Array {
|
|
4559
|
+
constructor(size){
|
|
4560
|
+
super(size);
|
|
4561
|
+
this.fill(0);
|
|
4562
|
+
}
|
|
4563
|
+
}
|
|
4564
|
+
class Stack {
|
|
4862
4565
|
heap;
|
|
4863
4566
|
length;
|
|
4864
|
-
static #
|
|
4865
|
-
static create(
|
|
4866
|
-
|
|
4867
|
-
if (!
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4567
|
+
static #constructing = false;
|
|
4568
|
+
static create(max) {
|
|
4569
|
+
const HeapCls = getUintArray(max);
|
|
4570
|
+
if (!HeapCls) return [];
|
|
4571
|
+
Stack.#constructing = true;
|
|
4572
|
+
const s = new Stack(max, HeapCls);
|
|
4573
|
+
Stack.#constructing = false;
|
|
4574
|
+
return s;
|
|
4575
|
+
}
|
|
4576
|
+
constructor(max, HeapCls){
|
|
4577
|
+
if (!Stack.#constructing) throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
4578
|
+
this.heap = new HeapCls(max);
|
|
4579
|
+
this.length = 0;
|
|
4580
|
+
}
|
|
4581
|
+
push(n) {
|
|
4582
|
+
this.heap[this.length++] = n;
|
|
4878
4583
|
}
|
|
4879
4584
|
pop() {
|
|
4880
4585
|
return this.heap[--this.length];
|
|
4881
4586
|
}
|
|
4882
|
-
}
|
|
4883
|
-
|
|
4884
|
-
#
|
|
4885
|
-
#
|
|
4886
|
-
#
|
|
4887
|
-
#
|
|
4888
|
-
#
|
|
4889
|
-
#
|
|
4890
|
-
#m;
|
|
4891
|
-
get perf() {
|
|
4892
|
-
return this.#m;
|
|
4893
|
-
}
|
|
4587
|
+
}
|
|
4588
|
+
class LRUCache {
|
|
4589
|
+
#max;
|
|
4590
|
+
#maxSize;
|
|
4591
|
+
#dispose;
|
|
4592
|
+
#disposeAfter;
|
|
4593
|
+
#fetchMethod;
|
|
4594
|
+
#memoMethod;
|
|
4894
4595
|
ttl;
|
|
4895
4596
|
ttlResolution;
|
|
4896
4597
|
ttlAutopurge;
|
|
@@ -4906,613 +4607,823 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4906
4607
|
allowStaleOnFetchAbort;
|
|
4907
4608
|
allowStaleOnFetchRejection;
|
|
4908
4609
|
ignoreFetchAbort;
|
|
4909
|
-
#
|
|
4910
|
-
#
|
|
4911
|
-
#
|
|
4912
|
-
#
|
|
4913
|
-
#
|
|
4914
|
-
#
|
|
4915
|
-
#
|
|
4916
|
-
#
|
|
4917
|
-
#
|
|
4918
|
-
#
|
|
4919
|
-
#
|
|
4920
|
-
#
|
|
4921
|
-
#
|
|
4922
|
-
#
|
|
4923
|
-
#
|
|
4924
|
-
#
|
|
4925
|
-
#
|
|
4926
|
-
|
|
4927
|
-
#j;
|
|
4928
|
-
static unsafeExposeInternals(e1) {
|
|
4610
|
+
#size;
|
|
4611
|
+
#calculatedSize;
|
|
4612
|
+
#keyMap;
|
|
4613
|
+
#keyList;
|
|
4614
|
+
#valList;
|
|
4615
|
+
#next;
|
|
4616
|
+
#prev;
|
|
4617
|
+
#head;
|
|
4618
|
+
#tail;
|
|
4619
|
+
#free;
|
|
4620
|
+
#disposed;
|
|
4621
|
+
#sizes;
|
|
4622
|
+
#starts;
|
|
4623
|
+
#ttls;
|
|
4624
|
+
#hasDispose;
|
|
4625
|
+
#hasFetchMethod;
|
|
4626
|
+
#hasDisposeAfter;
|
|
4627
|
+
static unsafeExposeInternals(c) {
|
|
4929
4628
|
return {
|
|
4930
|
-
starts:
|
|
4931
|
-
ttls:
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
prev: e1.#c,
|
|
4629
|
+
starts: c.#starts,
|
|
4630
|
+
ttls: c.#ttls,
|
|
4631
|
+
sizes: c.#sizes,
|
|
4632
|
+
keyMap: c.#keyMap,
|
|
4633
|
+
keyList: c.#keyList,
|
|
4634
|
+
valList: c.#valList,
|
|
4635
|
+
next: c.#next,
|
|
4636
|
+
prev: c.#prev,
|
|
4939
4637
|
get head () {
|
|
4940
|
-
return
|
|
4638
|
+
return c.#head;
|
|
4941
4639
|
},
|
|
4942
4640
|
get tail () {
|
|
4943
|
-
return
|
|
4641
|
+
return c.#tail;
|
|
4944
4642
|
},
|
|
4945
|
-
free:
|
|
4946
|
-
isBackgroundFetch: (
|
|
4947
|
-
backgroundFetch: (
|
|
4948
|
-
moveToTail: (
|
|
4949
|
-
indexes: (
|
|
4950
|
-
rindexes: (
|
|
4951
|
-
isStale: (
|
|
4643
|
+
free: c.#free,
|
|
4644
|
+
isBackgroundFetch: (p)=>c.#isBackgroundFetch(p),
|
|
4645
|
+
backgroundFetch: (k, index, options, context)=>c.#backgroundFetch(k, index, options, context),
|
|
4646
|
+
moveToTail: (index)=>c.#moveToTail(index),
|
|
4647
|
+
indexes: (options)=>c.#indexes(options),
|
|
4648
|
+
rindexes: (options)=>c.#rindexes(options),
|
|
4649
|
+
isStale: (index)=>c.#isStale(index)
|
|
4952
4650
|
};
|
|
4953
4651
|
}
|
|
4954
4652
|
get max() {
|
|
4955
|
-
return this.#
|
|
4653
|
+
return this.#max;
|
|
4956
4654
|
}
|
|
4957
4655
|
get maxSize() {
|
|
4958
|
-
return this.#
|
|
4656
|
+
return this.#maxSize;
|
|
4959
4657
|
}
|
|
4960
4658
|
get calculatedSize() {
|
|
4961
|
-
return this.#
|
|
4659
|
+
return this.#calculatedSize;
|
|
4962
4660
|
}
|
|
4963
4661
|
get size() {
|
|
4964
|
-
return this.#
|
|
4662
|
+
return this.#size;
|
|
4965
4663
|
}
|
|
4966
4664
|
get fetchMethod() {
|
|
4967
|
-
return this.#
|
|
4665
|
+
return this.#fetchMethod;
|
|
4968
4666
|
}
|
|
4969
4667
|
get memoMethod() {
|
|
4970
|
-
return this.#
|
|
4668
|
+
return this.#memoMethod;
|
|
4971
4669
|
}
|
|
4972
4670
|
get dispose() {
|
|
4973
|
-
return this.#
|
|
4974
|
-
}
|
|
4975
|
-
get onInsert() {
|
|
4976
|
-
return this.#D;
|
|
4671
|
+
return this.#dispose;
|
|
4977
4672
|
}
|
|
4978
4673
|
get disposeAfter() {
|
|
4979
|
-
return this.#
|
|
4980
|
-
}
|
|
4981
|
-
constructor(
|
|
4982
|
-
|
|
4983
|
-
if (
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
this.#
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
this
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
4674
|
+
return this.#disposeAfter;
|
|
4675
|
+
}
|
|
4676
|
+
constructor(options){
|
|
4677
|
+
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;
|
|
4678
|
+
if (0 !== max && !isPosInt(max)) throw new TypeError('max option must be a nonnegative integer');
|
|
4679
|
+
const UintArray = max ? getUintArray(max) : Array;
|
|
4680
|
+
if (!UintArray) throw new Error('invalid max value: ' + max);
|
|
4681
|
+
this.#max = max;
|
|
4682
|
+
this.#maxSize = maxSize;
|
|
4683
|
+
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
|
4684
|
+
this.sizeCalculation = sizeCalculation;
|
|
4685
|
+
if (this.sizeCalculation) {
|
|
4686
|
+
if (!this.#maxSize && !this.maxEntrySize) throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
|
|
4687
|
+
if ('function' != typeof this.sizeCalculation) throw new TypeError('sizeCalculation set to non-function');
|
|
4688
|
+
}
|
|
4689
|
+
if (void 0 !== memoMethod && 'function' != typeof memoMethod) throw new TypeError('memoMethod must be a function if defined');
|
|
4690
|
+
this.#memoMethod = memoMethod;
|
|
4691
|
+
if (void 0 !== fetchMethod && 'function' != typeof fetchMethod) throw new TypeError('fetchMethod must be a function if specified');
|
|
4692
|
+
this.#fetchMethod = fetchMethod;
|
|
4693
|
+
this.#hasFetchMethod = !!fetchMethod;
|
|
4694
|
+
this.#keyMap = new Map();
|
|
4695
|
+
this.#keyList = new Array(max).fill(void 0);
|
|
4696
|
+
this.#valList = new Array(max).fill(void 0);
|
|
4697
|
+
this.#next = new UintArray(max);
|
|
4698
|
+
this.#prev = new UintArray(max);
|
|
4699
|
+
this.#head = 0;
|
|
4700
|
+
this.#tail = 0;
|
|
4701
|
+
this.#free = Stack.create(max);
|
|
4702
|
+
this.#size = 0;
|
|
4703
|
+
this.#calculatedSize = 0;
|
|
4704
|
+
if ('function' == typeof dispose) this.#dispose = dispose;
|
|
4705
|
+
if ('function' == typeof disposeAfter) {
|
|
4706
|
+
this.#disposeAfter = disposeAfter;
|
|
4707
|
+
this.#disposed = [];
|
|
4708
|
+
} else {
|
|
4709
|
+
this.#disposeAfter = void 0;
|
|
4710
|
+
this.#disposed = void 0;
|
|
4711
|
+
}
|
|
4712
|
+
this.#hasDispose = !!this.#dispose;
|
|
4713
|
+
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
4714
|
+
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
4715
|
+
this.noUpdateTTL = !!noUpdateTTL;
|
|
4716
|
+
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
|
4717
|
+
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
|
|
4718
|
+
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
|
4719
|
+
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
|
4720
|
+
if (0 !== this.maxEntrySize) {
|
|
4721
|
+
if (0 !== this.#maxSize) {
|
|
4722
|
+
if (!isPosInt(this.#maxSize)) throw new TypeError('maxSize must be a positive integer if specified');
|
|
4723
|
+
}
|
|
4724
|
+
if (!isPosInt(this.maxEntrySize)) throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
4725
|
+
this.#initializeSizeTracking();
|
|
4726
|
+
}
|
|
4727
|
+
this.allowStale = !!allowStale;
|
|
4728
|
+
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
4729
|
+
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
4730
|
+
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
4731
|
+
this.ttlResolution = isPosInt(ttlResolution) || 0 === ttlResolution ? ttlResolution : 1;
|
|
4732
|
+
this.ttlAutopurge = !!ttlAutopurge;
|
|
4733
|
+
this.ttl = ttl || 0;
|
|
4734
|
+
if (this.ttl) {
|
|
4735
|
+
if (!isPosInt(this.ttl)) throw new TypeError('ttl must be a positive integer if specified');
|
|
4736
|
+
this.#initializeTTLTracking();
|
|
4737
|
+
}
|
|
4738
|
+
if (0 === this.#max && 0 === this.ttl && 0 === this.#maxSize) throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
4739
|
+
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
4740
|
+
const code = 'LRU_CACHE_UNBOUNDED';
|
|
4741
|
+
if (shouldWarn(code)) {
|
|
4742
|
+
warned.add(code);
|
|
4743
|
+
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
4744
|
+
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4748
|
+
getRemainingTTL(key) {
|
|
4749
|
+
return this.#keyMap.has(key) ? 1 / 0 : 0;
|
|
4750
|
+
}
|
|
4751
|
+
#initializeTTLTracking() {
|
|
4752
|
+
const ttls = new ZeroArray(this.#max);
|
|
4753
|
+
const starts = new ZeroArray(this.#max);
|
|
4754
|
+
this.#ttls = ttls;
|
|
4755
|
+
this.#starts = starts;
|
|
4756
|
+
this.#setItemTTL = (index, ttl, start = perf.now())=>{
|
|
4757
|
+
starts[index] = 0 !== ttl ? start : 0;
|
|
4758
|
+
ttls[index] = ttl;
|
|
4759
|
+
if (0 !== ttl && this.ttlAutopurge) {
|
|
4760
|
+
const t1 = setTimeout(()=>{
|
|
4761
|
+
if (this.#isStale(index)) this.#delete(this.#keyList[index], 'expire');
|
|
4762
|
+
}, ttl + 1);
|
|
4763
|
+
if (t1.unref) t1.unref();
|
|
4764
|
+
}
|
|
5025
4765
|
};
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
let f = r.now - c;
|
|
5040
|
-
r.remainingTTL = l - f;
|
|
4766
|
+
this.#updateItemAge = (index)=>{
|
|
4767
|
+
starts[index] = 0 !== ttls[index] ? perf.now() : 0;
|
|
4768
|
+
};
|
|
4769
|
+
this.#statusTTL = (status, index)=>{
|
|
4770
|
+
if (ttls[index]) {
|
|
4771
|
+
const ttl = ttls[index];
|
|
4772
|
+
const start = starts[index];
|
|
4773
|
+
if (!ttl || !start) return;
|
|
4774
|
+
status.ttl = ttl;
|
|
4775
|
+
status.start = start;
|
|
4776
|
+
status.now = cachedNow || getNow();
|
|
4777
|
+
const age = status.now - start;
|
|
4778
|
+
status.remainingTTL = ttl - age;
|
|
5041
4779
|
}
|
|
5042
4780
|
};
|
|
5043
|
-
let
|
|
5044
|
-
|
|
4781
|
+
let cachedNow = 0;
|
|
4782
|
+
const getNow = ()=>{
|
|
4783
|
+
const n = perf.now();
|
|
5045
4784
|
if (this.ttlResolution > 0) {
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
4785
|
+
cachedNow = n;
|
|
4786
|
+
const t1 = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
4787
|
+
if (t1.unref) t1.unref();
|
|
5049
4788
|
}
|
|
5050
|
-
return
|
|
4789
|
+
return n;
|
|
4790
|
+
};
|
|
4791
|
+
this.getRemainingTTL = (key)=>{
|
|
4792
|
+
const index = this.#keyMap.get(key);
|
|
4793
|
+
if (void 0 === index) return 0;
|
|
4794
|
+
const ttl = ttls[index];
|
|
4795
|
+
const start = starts[index];
|
|
4796
|
+
if (!ttl || !start) return 1 / 0;
|
|
4797
|
+
const age = (cachedNow || getNow()) - start;
|
|
4798
|
+
return ttl - age;
|
|
5051
4799
|
};
|
|
5052
|
-
this
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
if (!l || !c) return 1 / 0;
|
|
5057
|
-
let f = (n || o()) - c;
|
|
5058
|
-
return l - f;
|
|
5059
|
-
}, this.#p = (r)=>{
|
|
5060
|
-
let h = t1[r], l = e1[r];
|
|
5061
|
-
return !!l && !!h && (n || o()) - h > l;
|
|
4800
|
+
this.#isStale = (index)=>{
|
|
4801
|
+
const s = starts[index];
|
|
4802
|
+
const t1 = ttls[index];
|
|
4803
|
+
return !!t1 && !!s && (cachedNow || getNow()) - s > t1;
|
|
5062
4804
|
};
|
|
5063
4805
|
}
|
|
5064
|
-
#
|
|
5065
|
-
#
|
|
5066
|
-
#
|
|
5067
|
-
#
|
|
5068
|
-
#
|
|
5069
|
-
|
|
5070
|
-
this.#
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
4806
|
+
#updateItemAge = ()=>{};
|
|
4807
|
+
#statusTTL = ()=>{};
|
|
4808
|
+
#setItemTTL = ()=>{};
|
|
4809
|
+
#isStale = ()=>false;
|
|
4810
|
+
#initializeSizeTracking() {
|
|
4811
|
+
const sizes = new ZeroArray(this.#max);
|
|
4812
|
+
this.#calculatedSize = 0;
|
|
4813
|
+
this.#sizes = sizes;
|
|
4814
|
+
this.#removeItemSize = (index)=>{
|
|
4815
|
+
this.#calculatedSize -= sizes[index];
|
|
4816
|
+
sizes[index] = 0;
|
|
4817
|
+
};
|
|
4818
|
+
this.#requireSize = (k, v, size, sizeCalculation)=>{
|
|
4819
|
+
if (this.#isBackgroundFetch(v)) return 0;
|
|
4820
|
+
if (!isPosInt(size)) if (sizeCalculation) {
|
|
4821
|
+
if ('function' != typeof sizeCalculation) throw new TypeError('sizeCalculation must be a function');
|
|
4822
|
+
size = sizeCalculation(v, k);
|
|
4823
|
+
if (!isPosInt(size)) throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
5077
4824
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
5078
|
-
return
|
|
5079
|
-
}
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
4825
|
+
return size;
|
|
4826
|
+
};
|
|
4827
|
+
this.#addItemSize = (index, size, status)=>{
|
|
4828
|
+
sizes[index] = size;
|
|
4829
|
+
if (this.#maxSize) {
|
|
4830
|
+
const maxSize = this.#maxSize - sizes[index];
|
|
4831
|
+
while(this.#calculatedSize > maxSize)this.#evict(true);
|
|
4832
|
+
}
|
|
4833
|
+
this.#calculatedSize += sizes[index];
|
|
4834
|
+
if (status) {
|
|
4835
|
+
status.entrySize = size;
|
|
4836
|
+
status.totalCalculatedSize = this.#calculatedSize;
|
|
5083
4837
|
}
|
|
5084
|
-
this.#b += e1[t1], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
5085
4838
|
};
|
|
5086
4839
|
}
|
|
5087
|
-
#
|
|
5088
|
-
#
|
|
5089
|
-
#
|
|
5090
|
-
if (
|
|
4840
|
+
#removeItemSize = (_i)=>{};
|
|
4841
|
+
#addItemSize = (_i, _s, _st)=>{};
|
|
4842
|
+
#requireSize = (_k, _v, size, sizeCalculation)=>{
|
|
4843
|
+
if (size || sizeCalculation) throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
|
|
5091
4844
|
return 0;
|
|
5092
4845
|
};
|
|
5093
|
-
*#
|
|
5094
|
-
if (this.#
|
|
4846
|
+
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
4847
|
+
if (this.#size) for(let i = this.#tail; true;){
|
|
4848
|
+
if (!this.#isValidIndex(i)) break;
|
|
4849
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4850
|
+
if (i === this.#head) break;
|
|
4851
|
+
i = this.#prev[i];
|
|
4852
|
+
}
|
|
5095
4853
|
}
|
|
5096
|
-
*#
|
|
5097
|
-
if (this.#
|
|
4854
|
+
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
4855
|
+
if (this.#size) for(let i = this.#head; true;){
|
|
4856
|
+
if (!this.#isValidIndex(i)) break;
|
|
4857
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4858
|
+
if (i === this.#tail) break;
|
|
4859
|
+
i = this.#next[i];
|
|
4860
|
+
}
|
|
5098
4861
|
}
|
|
5099
|
-
#
|
|
5100
|
-
return void 0 !==
|
|
4862
|
+
#isValidIndex(index) {
|
|
4863
|
+
return void 0 !== index && this.#keyMap.get(this.#keyList[index]) === index;
|
|
5101
4864
|
}
|
|
5102
4865
|
*entries() {
|
|
5103
|
-
for (
|
|
5104
|
-
this.#i
|
|
5105
|
-
this.#
|
|
5106
|
-
]
|
|
4866
|
+
for (const i of this.#indexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4867
|
+
this.#keyList[i],
|
|
4868
|
+
this.#valList[i]
|
|
4869
|
+
];
|
|
5107
4870
|
}
|
|
5108
4871
|
*rentries() {
|
|
5109
|
-
for (
|
|
5110
|
-
this.#i
|
|
5111
|
-
this.#
|
|
5112
|
-
]
|
|
4872
|
+
for (const i of this.#rindexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4873
|
+
this.#keyList[i],
|
|
4874
|
+
this.#valList[i]
|
|
4875
|
+
];
|
|
5113
4876
|
}
|
|
5114
4877
|
*keys() {
|
|
5115
|
-
for (
|
|
5116
|
-
|
|
5117
|
-
void 0
|
|
4878
|
+
for (const i of this.#indexes()){
|
|
4879
|
+
const k = this.#keyList[i];
|
|
4880
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
5118
4881
|
}
|
|
5119
4882
|
}
|
|
5120
4883
|
*rkeys() {
|
|
5121
|
-
for (
|
|
5122
|
-
|
|
5123
|
-
void 0
|
|
4884
|
+
for (const i of this.#rindexes()){
|
|
4885
|
+
const k = this.#keyList[i];
|
|
4886
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
5124
4887
|
}
|
|
5125
4888
|
}
|
|
5126
4889
|
*values() {
|
|
5127
|
-
for (
|
|
4890
|
+
for (const i of this.#indexes()){
|
|
4891
|
+
const v = this.#valList[i];
|
|
4892
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4893
|
+
}
|
|
5128
4894
|
}
|
|
5129
4895
|
*rvalues() {
|
|
5130
|
-
for (
|
|
4896
|
+
for (const i of this.#rindexes()){
|
|
4897
|
+
const v = this.#valList[i];
|
|
4898
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4899
|
+
}
|
|
5131
4900
|
}
|
|
5132
4901
|
[Symbol.iterator]() {
|
|
5133
4902
|
return this.entries();
|
|
5134
4903
|
}
|
|
5135
|
-
[Symbol.toStringTag] =
|
|
5136
|
-
find(
|
|
5137
|
-
for (
|
|
5138
|
-
|
|
5139
|
-
|
|
4904
|
+
[Symbol.toStringTag] = 'LRUCache';
|
|
4905
|
+
find(fn, getOptions = {}) {
|
|
4906
|
+
for (const i of this.#indexes()){
|
|
4907
|
+
const v = this.#valList[i];
|
|
4908
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4909
|
+
if (void 0 !== value) {
|
|
4910
|
+
if (fn(value, this.#keyList[i], this)) return this.get(this.#keyList[i], getOptions);
|
|
4911
|
+
}
|
|
5140
4912
|
}
|
|
5141
4913
|
}
|
|
5142
|
-
forEach(
|
|
5143
|
-
for (
|
|
5144
|
-
|
|
5145
|
-
|
|
4914
|
+
forEach(fn, thisp = this) {
|
|
4915
|
+
for (const i of this.#indexes()){
|
|
4916
|
+
const v = this.#valList[i];
|
|
4917
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4918
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
5146
4919
|
}
|
|
5147
4920
|
}
|
|
5148
|
-
rforEach(
|
|
5149
|
-
for (
|
|
5150
|
-
|
|
5151
|
-
|
|
4921
|
+
rforEach(fn, thisp = this) {
|
|
4922
|
+
for (const i of this.#rindexes()){
|
|
4923
|
+
const v = this.#valList[i];
|
|
4924
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4925
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
5152
4926
|
}
|
|
5153
4927
|
}
|
|
5154
4928
|
purgeStale() {
|
|
5155
|
-
let
|
|
5156
|
-
for (
|
|
5157
|
-
allowStale:
|
|
5158
|
-
}))
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
4929
|
+
let deleted = false;
|
|
4930
|
+
for (const i of this.#rindexes({
|
|
4931
|
+
allowStale: true
|
|
4932
|
+
}))if (this.#isStale(i)) {
|
|
4933
|
+
this.#delete(this.#keyList[i], 'expire');
|
|
4934
|
+
deleted = true;
|
|
4935
|
+
}
|
|
4936
|
+
return deleted;
|
|
4937
|
+
}
|
|
4938
|
+
info(key) {
|
|
4939
|
+
const i = this.#keyMap.get(key);
|
|
4940
|
+
if (void 0 === i) return;
|
|
4941
|
+
const v = this.#valList[i];
|
|
4942
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4943
|
+
if (void 0 === value) return;
|
|
4944
|
+
const entry = {
|
|
4945
|
+
value
|
|
5168
4946
|
};
|
|
5169
|
-
if (this.#
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
4947
|
+
if (this.#ttls && this.#starts) {
|
|
4948
|
+
const ttl = this.#ttls[i];
|
|
4949
|
+
const start = this.#starts[i];
|
|
4950
|
+
if (ttl && start) {
|
|
4951
|
+
const remain = ttl - (perf.now() - start);
|
|
4952
|
+
entry.ttl = remain;
|
|
4953
|
+
entry.start = Date.now();
|
|
5174
4954
|
}
|
|
5175
4955
|
}
|
|
5176
|
-
|
|
4956
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4957
|
+
return entry;
|
|
5177
4958
|
}
|
|
5178
4959
|
dump() {
|
|
5179
|
-
|
|
5180
|
-
for (
|
|
5181
|
-
allowStale:
|
|
4960
|
+
const arr = [];
|
|
4961
|
+
for (const i of this.#indexes({
|
|
4962
|
+
allowStale: true
|
|
5182
4963
|
})){
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
4964
|
+
const key = this.#keyList[i];
|
|
4965
|
+
const v = this.#valList[i];
|
|
4966
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4967
|
+
if (void 0 === value || void 0 === key) continue;
|
|
4968
|
+
const entry = {
|
|
4969
|
+
value
|
|
5187
4970
|
};
|
|
5188
|
-
if (this.#
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
}
|
|
5193
|
-
this.#
|
|
5194
|
-
|
|
5195
|
-
|
|
4971
|
+
if (this.#ttls && this.#starts) {
|
|
4972
|
+
entry.ttl = this.#ttls[i];
|
|
4973
|
+
const age = perf.now() - this.#starts[i];
|
|
4974
|
+
entry.start = Math.floor(Date.now() - age);
|
|
4975
|
+
}
|
|
4976
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4977
|
+
arr.unshift([
|
|
4978
|
+
key,
|
|
4979
|
+
entry
|
|
5196
4980
|
]);
|
|
5197
4981
|
}
|
|
5198
|
-
return
|
|
4982
|
+
return arr;
|
|
5199
4983
|
}
|
|
5200
|
-
load(
|
|
4984
|
+
load(arr) {
|
|
5201
4985
|
this.clear();
|
|
5202
|
-
for (
|
|
5203
|
-
if (
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
}
|
|
5207
|
-
this
|
|
5208
|
-
}
|
|
5209
|
-
}
|
|
5210
|
-
set(
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
if (
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
4986
|
+
for (const [key, entry] of arr){
|
|
4987
|
+
if (entry.start) {
|
|
4988
|
+
const age = Date.now() - entry.start;
|
|
4989
|
+
entry.start = perf.now() - age;
|
|
4990
|
+
}
|
|
4991
|
+
this.set(key, entry.value, entry);
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
set(k, v, setOptions = {}) {
|
|
4995
|
+
if (void 0 === v) {
|
|
4996
|
+
this.delete(k);
|
|
4997
|
+
return this;
|
|
4998
|
+
}
|
|
4999
|
+
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
|
|
5000
|
+
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
5001
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
5002
|
+
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
5003
|
+
if (status) {
|
|
5004
|
+
status.set = 'miss';
|
|
5005
|
+
status.maxEntrySizeExceeded = true;
|
|
5006
|
+
}
|
|
5007
|
+
this.#delete(k, 'set');
|
|
5008
|
+
return this;
|
|
5009
|
+
}
|
|
5010
|
+
let index = 0 === this.#size ? void 0 : this.#keyMap.get(k);
|
|
5011
|
+
if (void 0 === index) {
|
|
5012
|
+
index = 0 === this.#size ? this.#tail : 0 !== this.#free.length ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
|
|
5013
|
+
this.#keyList[index] = k;
|
|
5014
|
+
this.#valList[index] = v;
|
|
5015
|
+
this.#keyMap.set(k, index);
|
|
5016
|
+
this.#next[this.#tail] = index;
|
|
5017
|
+
this.#prev[index] = this.#tail;
|
|
5018
|
+
this.#tail = index;
|
|
5019
|
+
this.#size++;
|
|
5020
|
+
this.#addItemSize(index, size, status);
|
|
5021
|
+
if (status) status.set = 'add';
|
|
5022
|
+
noUpdateTTL = false;
|
|
5023
|
+
} else {
|
|
5024
|
+
this.#moveToTail(index);
|
|
5025
|
+
const oldVal = this.#valList[index];
|
|
5026
|
+
if (v !== oldVal) {
|
|
5027
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
5028
|
+
oldVal.__abortController.abort(new Error('replaced'));
|
|
5029
|
+
const { __staleWhileFetching: s } = oldVal;
|
|
5030
|
+
if (void 0 !== s && !noDisposeOnSet) {
|
|
5031
|
+
if (this.#hasDispose) this.#dispose?.(s, k, 'set');
|
|
5032
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5033
|
+
s,
|
|
5034
|
+
k,
|
|
5035
|
+
'set'
|
|
5036
|
+
]);
|
|
5037
|
+
}
|
|
5038
|
+
} else if (!noDisposeOnSet) {
|
|
5039
|
+
if (this.#hasDispose) this.#dispose?.(oldVal, k, 'set');
|
|
5040
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5041
|
+
oldVal,
|
|
5042
|
+
k,
|
|
5043
|
+
'set'
|
|
5044
|
+
]);
|
|
5045
|
+
}
|
|
5046
|
+
this.#removeItemSize(index);
|
|
5047
|
+
this.#addItemSize(index, size, status);
|
|
5048
|
+
this.#valList[index] = v;
|
|
5049
|
+
if (status) {
|
|
5050
|
+
status.set = 'replace';
|
|
5051
|
+
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
|
5052
|
+
if (void 0 !== oldValue) status.oldValue = oldValue;
|
|
5246
5053
|
}
|
|
5247
|
-
} else
|
|
5248
|
-
this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
|
|
5054
|
+
} else if (status) status.set = 'update';
|
|
5249
5055
|
}
|
|
5250
|
-
if (0
|
|
5251
|
-
|
|
5252
|
-
|
|
5056
|
+
if (0 !== ttl && !this.#ttls) this.#initializeTTLTracking();
|
|
5057
|
+
if (this.#ttls) {
|
|
5058
|
+
if (!noUpdateTTL) this.#setItemTTL(index, ttl, start);
|
|
5059
|
+
if (status) this.#statusTTL(status, index);
|
|
5060
|
+
}
|
|
5061
|
+
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
5062
|
+
const dt = this.#disposed;
|
|
5063
|
+
let task;
|
|
5064
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5253
5065
|
}
|
|
5254
5066
|
return this;
|
|
5255
5067
|
}
|
|
5256
5068
|
pop() {
|
|
5257
5069
|
try {
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5070
|
+
while(this.#size){
|
|
5071
|
+
const val = this.#valList[this.#head];
|
|
5072
|
+
this.#evict(true);
|
|
5073
|
+
if (this.#isBackgroundFetch(val)) {
|
|
5074
|
+
if (val.__staleWhileFetching) return val.__staleWhileFetching;
|
|
5075
|
+
} else if (void 0 !== val) return val;
|
|
5263
5076
|
}
|
|
5264
5077
|
} finally{
|
|
5265
|
-
if (this.#
|
|
5266
|
-
|
|
5267
|
-
|
|
5078
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
5079
|
+
const dt = this.#disposed;
|
|
5080
|
+
let task;
|
|
5081
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5268
5082
|
}
|
|
5269
5083
|
}
|
|
5270
5084
|
}
|
|
5271
|
-
#
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
5284
|
-
}
|
|
5285
|
-
#Y(e1, t1 = {}) {
|
|
5286
|
-
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t1, n = this.#s.get(e1);
|
|
5287
|
-
if (void 0 !== n) {
|
|
5288
|
-
let o = this.#t[n];
|
|
5289
|
-
if (this.#e(o) && void 0 === o.__staleWhileFetching) return !1;
|
|
5290
|
-
if (!this.#p(n)) return i && this.#x(n), s && (s.has = "hit", this.#E(s, n)), !0;
|
|
5291
|
-
s && (s.has = "stale", this.#E(s, n));
|
|
5292
|
-
} else s && (s.has = "miss");
|
|
5293
|
-
return !1;
|
|
5294
|
-
}
|
|
5295
|
-
peek(e1, t1 = {}) {
|
|
5296
|
-
let { status: i = D() ? {} : void 0 } = t1;
|
|
5297
|
-
i && (i.op = "peek", i.key = e1), t1.status = i;
|
|
5298
|
-
let s = this.#J(e1, t1);
|
|
5299
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
5300
|
-
}
|
|
5301
|
-
#J(e1, t1) {
|
|
5302
|
-
let { status: i, allowStale: s = this.allowStale } = t1, n = this.#s.get(e1);
|
|
5303
|
-
if (void 0 === n || !s && this.#p(n)) {
|
|
5304
|
-
i && (i.peek = void 0 === n ? "miss" : "stale");
|
|
5305
|
-
return;
|
|
5085
|
+
#evict(free) {
|
|
5086
|
+
const head = this.#head;
|
|
5087
|
+
const k = this.#keyList[head];
|
|
5088
|
+
const v = this.#valList[head];
|
|
5089
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('evicted'));
|
|
5090
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
5091
|
+
if (this.#hasDispose) this.#dispose?.(v, k, 'evict');
|
|
5092
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5093
|
+
v,
|
|
5094
|
+
k,
|
|
5095
|
+
'evict'
|
|
5096
|
+
]);
|
|
5306
5097
|
}
|
|
5307
|
-
|
|
5308
|
-
|
|
5098
|
+
this.#removeItemSize(head);
|
|
5099
|
+
if (free) {
|
|
5100
|
+
this.#keyList[head] = void 0;
|
|
5101
|
+
this.#valList[head] = void 0;
|
|
5102
|
+
this.#free.push(head);
|
|
5103
|
+
}
|
|
5104
|
+
if (1 === this.#size) {
|
|
5105
|
+
this.#head = this.#tail = 0;
|
|
5106
|
+
this.#free.length = 0;
|
|
5107
|
+
} else this.#head = this.#next[head];
|
|
5108
|
+
this.#keyMap.delete(k);
|
|
5109
|
+
this.#size--;
|
|
5110
|
+
return head;
|
|
5111
|
+
}
|
|
5112
|
+
has(k, hasOptions = {}) {
|
|
5113
|
+
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
5114
|
+
const index = this.#keyMap.get(k);
|
|
5115
|
+
if (void 0 !== index) {
|
|
5116
|
+
const v = this.#valList[index];
|
|
5117
|
+
if (this.#isBackgroundFetch(v) && void 0 === v.__staleWhileFetching) return false;
|
|
5118
|
+
if (this.#isStale(index)) {
|
|
5119
|
+
if (status) {
|
|
5120
|
+
status.has = 'stale';
|
|
5121
|
+
this.#statusTTL(status, index);
|
|
5122
|
+
}
|
|
5123
|
+
} else {
|
|
5124
|
+
if (updateAgeOnHas) this.#updateItemAge(index);
|
|
5125
|
+
if (status) {
|
|
5126
|
+
status.has = 'hit';
|
|
5127
|
+
this.#statusTTL(status, index);
|
|
5128
|
+
}
|
|
5129
|
+
return true;
|
|
5130
|
+
}
|
|
5131
|
+
} else if (status) status.has = 'miss';
|
|
5132
|
+
return false;
|
|
5309
5133
|
}
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5134
|
+
peek(k, peekOptions = {}) {
|
|
5135
|
+
const { allowStale = this.allowStale } = peekOptions;
|
|
5136
|
+
const index = this.#keyMap.get(k);
|
|
5137
|
+
if (void 0 === index || !allowStale && this.#isStale(index)) return;
|
|
5138
|
+
const v = this.#valList[index];
|
|
5139
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
5140
|
+
}
|
|
5141
|
+
#backgroundFetch(k, index, options, context) {
|
|
5142
|
+
const v = void 0 === index ? void 0 : this.#valList[index];
|
|
5143
|
+
if (this.#isBackgroundFetch(v)) return v;
|
|
5144
|
+
const ac = new AC();
|
|
5145
|
+
const { signal } = options;
|
|
5146
|
+
signal?.addEventListener('abort', ()=>ac.abort(signal.reason), {
|
|
5147
|
+
signal: ac.signal
|
|
5316
5148
|
});
|
|
5317
|
-
|
|
5318
|
-
signal:
|
|
5319
|
-
options
|
|
5320
|
-
context
|
|
5321
|
-
}
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5149
|
+
const fetchOpts = {
|
|
5150
|
+
signal: ac.signal,
|
|
5151
|
+
options,
|
|
5152
|
+
context
|
|
5153
|
+
};
|
|
5154
|
+
const cb = (v, updateCache = false)=>{
|
|
5155
|
+
const { aborted } = ac.signal;
|
|
5156
|
+
const ignoreAbort = options.ignoreFetchAbort && void 0 !== v;
|
|
5157
|
+
if (options.status) if (aborted && !updateCache) {
|
|
5158
|
+
options.status.fetchAborted = true;
|
|
5159
|
+
options.status.fetchError = ac.signal.reason;
|
|
5160
|
+
if (ignoreAbort) options.status.fetchAbortIgnored = true;
|
|
5161
|
+
} else options.status.fetchResolved = true;
|
|
5162
|
+
if (aborted && !ignoreAbort && !updateCache) return fetchFail(ac.signal.reason);
|
|
5163
|
+
const bf = p;
|
|
5164
|
+
if (this.#valList[index] === p) if (void 0 === v) if (bf.__staleWhileFetching) this.#valList[index] = bf.__staleWhileFetching;
|
|
5165
|
+
else this.#delete(k, 'fetch');
|
|
5166
|
+
else {
|
|
5167
|
+
if (options.status) options.status.fetchUpdated = true;
|
|
5168
|
+
this.set(k, v, fetchOpts.options);
|
|
5169
|
+
}
|
|
5170
|
+
return v;
|
|
5171
|
+
};
|
|
5172
|
+
const eb = (er)=>{
|
|
5173
|
+
if (options.status) {
|
|
5174
|
+
options.status.fetchRejected = true;
|
|
5175
|
+
options.status.fetchError = er;
|
|
5176
|
+
}
|
|
5177
|
+
return fetchFail(er);
|
|
5178
|
+
};
|
|
5179
|
+
const fetchFail = (er)=>{
|
|
5180
|
+
const { aborted } = ac.signal;
|
|
5181
|
+
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
5182
|
+
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
5183
|
+
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
5184
|
+
const bf = p;
|
|
5185
|
+
if (this.#valList[index] === p) {
|
|
5186
|
+
const del = !noDelete || void 0 === bf.__staleWhileFetching;
|
|
5187
|
+
if (del) this.#delete(k, 'fetch');
|
|
5188
|
+
else if (!allowStaleAborted) this.#valList[index] = bf.__staleWhileFetching;
|
|
5189
|
+
}
|
|
5190
|
+
if (allowStale) {
|
|
5191
|
+
if (options.status && void 0 !== bf.__staleWhileFetching) options.status.returnedStale = true;
|
|
5192
|
+
return bf.__staleWhileFetching;
|
|
5193
|
+
}
|
|
5194
|
+
if (bf.__returned === bf) throw er;
|
|
5195
|
+
};
|
|
5196
|
+
const pcall = (res, rej)=>{
|
|
5197
|
+
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
5198
|
+
if (fmp && fmp instanceof Promise) fmp.then((v)=>res(void 0 === v ? void 0 : v), rej);
|
|
5199
|
+
ac.signal.addEventListener('abort', ()=>{
|
|
5200
|
+
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
|
5201
|
+
res(void 0);
|
|
5202
|
+
if (options.allowStaleOnFetchAbort) res = (v)=>cb(v, true);
|
|
5203
|
+
}
|
|
5334
5204
|
});
|
|
5335
5205
|
};
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5206
|
+
if (options.status) options.status.fetchDispatched = true;
|
|
5207
|
+
const p = new Promise(pcall).then(cb, eb);
|
|
5208
|
+
const bf = Object.assign(p, {
|
|
5209
|
+
__abortController: ac,
|
|
5210
|
+
__staleWhileFetching: v,
|
|
5340
5211
|
__returned: void 0
|
|
5341
5212
|
});
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5213
|
+
if (void 0 === index) {
|
|
5214
|
+
this.set(k, bf, {
|
|
5215
|
+
...fetchOpts.options,
|
|
5216
|
+
status: void 0
|
|
5217
|
+
});
|
|
5218
|
+
index = this.#keyMap.get(k);
|
|
5219
|
+
} else this.#valList[index] = bf;
|
|
5220
|
+
return bf;
|
|
5221
|
+
}
|
|
5222
|
+
#isBackgroundFetch(p) {
|
|
5223
|
+
if (!this.#hasFetchMethod) return false;
|
|
5224
|
+
const b = p;
|
|
5225
|
+
return !!b && b instanceof Promise && b.hasOwnProperty('__staleWhileFetching') && b.__abortController instanceof AC;
|
|
5226
|
+
}
|
|
5227
|
+
async fetch(k, fetchOptions = {}) {
|
|
5228
|
+
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;
|
|
5229
|
+
if (!this.#hasFetchMethod) {
|
|
5230
|
+
if (status) status.fetch = 'get';
|
|
5231
|
+
return this.get(k, {
|
|
5232
|
+
allowStale,
|
|
5233
|
+
updateAgeOnGet,
|
|
5234
|
+
noDeleteOnStaleGet,
|
|
5235
|
+
status
|
|
5236
|
+
});
|
|
5237
|
+
}
|
|
5238
|
+
const options = {
|
|
5239
|
+
allowStale,
|
|
5240
|
+
updateAgeOnGet,
|
|
5241
|
+
noDeleteOnStaleGet,
|
|
5242
|
+
ttl,
|
|
5243
|
+
noDisposeOnSet,
|
|
5244
|
+
size,
|
|
5245
|
+
sizeCalculation,
|
|
5246
|
+
noUpdateTTL,
|
|
5247
|
+
noDeleteOnFetchRejection,
|
|
5248
|
+
allowStaleOnFetchRejection,
|
|
5249
|
+
allowStaleOnFetchAbort,
|
|
5250
|
+
ignoreFetchAbort,
|
|
5251
|
+
status,
|
|
5252
|
+
signal
|
|
5253
|
+
};
|
|
5254
|
+
let index = this.#keyMap.get(k);
|
|
5255
|
+
if (void 0 === index) {
|
|
5256
|
+
if (status) status.fetch = 'miss';
|
|
5257
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
5258
|
+
return p.__returned = p;
|
|
5386
5259
|
}
|
|
5387
5260
|
{
|
|
5388
|
-
|
|
5389
|
-
if (this.#
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
}
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
if (
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5261
|
+
const v = this.#valList[index];
|
|
5262
|
+
if (this.#isBackgroundFetch(v)) {
|
|
5263
|
+
const stale = allowStale && void 0 !== v.__staleWhileFetching;
|
|
5264
|
+
if (status) {
|
|
5265
|
+
status.fetch = 'inflight';
|
|
5266
|
+
if (stale) status.returnedStale = true;
|
|
5267
|
+
}
|
|
5268
|
+
return stale ? v.__staleWhileFetching : v.__returned = v;
|
|
5269
|
+
}
|
|
5270
|
+
const isStale = this.#isStale(index);
|
|
5271
|
+
if (!forceRefresh && !isStale) {
|
|
5272
|
+
if (status) status.fetch = 'hit';
|
|
5273
|
+
this.#moveToTail(index);
|
|
5274
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
5275
|
+
if (status) this.#statusTTL(status, index);
|
|
5276
|
+
return v;
|
|
5277
|
+
}
|
|
5278
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
5279
|
+
const hasStale = void 0 !== p.__staleWhileFetching;
|
|
5280
|
+
const staleVal = hasStale && allowStale;
|
|
5281
|
+
if (status) {
|
|
5282
|
+
status.fetch = isStale ? 'stale' : 'refresh';
|
|
5283
|
+
if (staleVal && isStale) status.returnedStale = true;
|
|
5284
|
+
}
|
|
5285
|
+
return staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
async forceFetch(k, fetchOptions = {}) {
|
|
5289
|
+
const v = await this.fetch(k, fetchOptions);
|
|
5290
|
+
if (void 0 === v) throw new Error('fetch() returned undefined');
|
|
5291
|
+
return v;
|
|
5292
|
+
}
|
|
5293
|
+
memo(k, memoOptions = {}) {
|
|
5294
|
+
const memoMethod = this.#memoMethod;
|
|
5295
|
+
if (!memoMethod) throw new Error('no memoMethod provided to constructor');
|
|
5296
|
+
const { context, forceRefresh, ...options } = memoOptions;
|
|
5297
|
+
const v = this.get(k, options);
|
|
5298
|
+
if (!forceRefresh && void 0 !== v) return v;
|
|
5299
|
+
const vv = memoMethod(k, v, {
|
|
5300
|
+
options,
|
|
5301
|
+
context
|
|
5426
5302
|
});
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5303
|
+
this.set(k, vv, options);
|
|
5304
|
+
return vv;
|
|
5305
|
+
}
|
|
5306
|
+
get(k, getOptions = {}) {
|
|
5307
|
+
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
|
|
5308
|
+
const index = this.#keyMap.get(k);
|
|
5309
|
+
if (void 0 !== index) {
|
|
5310
|
+
const value = this.#valList[index];
|
|
5311
|
+
const fetching = this.#isBackgroundFetch(value);
|
|
5312
|
+
if (status) this.#statusTTL(status, index);
|
|
5313
|
+
if (this.#isStale(index)) {
|
|
5314
|
+
if (status) status.get = 'stale';
|
|
5315
|
+
if (fetching) {
|
|
5316
|
+
if (status && allowStale && void 0 !== value.__staleWhileFetching) status.returnedStale = true;
|
|
5317
|
+
return allowStale ? value.__staleWhileFetching : void 0;
|
|
5318
|
+
}
|
|
5319
|
+
if (!noDeleteOnStaleGet) this.#delete(k, 'expire');
|
|
5320
|
+
if (status && allowStale) status.returnedStale = true;
|
|
5321
|
+
return allowStale ? value : void 0;
|
|
5322
|
+
}
|
|
5323
|
+
if (status) status.get = 'hit';
|
|
5324
|
+
if (fetching) return value.__staleWhileFetching;
|
|
5325
|
+
this.#moveToTail(index);
|
|
5326
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
5327
|
+
return value;
|
|
5440
5328
|
}
|
|
5441
|
-
|
|
5442
|
-
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);
|
|
5329
|
+
if (status) status.get = 'miss';
|
|
5443
5330
|
}
|
|
5444
|
-
|
|
5445
|
-
this.#
|
|
5331
|
+
#connect(p, n) {
|
|
5332
|
+
this.#prev[n] = p;
|
|
5333
|
+
this.#next[p] = n;
|
|
5446
5334
|
}
|
|
5447
|
-
#
|
|
5448
|
-
|
|
5335
|
+
#moveToTail(index) {
|
|
5336
|
+
if (index !== this.#tail) {
|
|
5337
|
+
if (index === this.#head) this.#head = this.#next[index];
|
|
5338
|
+
else this.#connect(this.#prev[index], this.#next[index]);
|
|
5339
|
+
this.#connect(this.#tail, index);
|
|
5340
|
+
this.#tail = index;
|
|
5341
|
+
}
|
|
5449
5342
|
}
|
|
5450
|
-
delete(
|
|
5451
|
-
return this.#
|
|
5343
|
+
delete(k) {
|
|
5344
|
+
return this.#delete(k, 'delete');
|
|
5452
5345
|
}
|
|
5453
|
-
#
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
if (0 !== this.#n) {
|
|
5461
|
-
let s = this.#s.get(e1);
|
|
5462
|
-
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);
|
|
5463
|
-
else {
|
|
5464
|
-
this.#R(s);
|
|
5465
|
-
let n = this.#t[s];
|
|
5466
|
-
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([
|
|
5467
|
-
n,
|
|
5468
|
-
e1,
|
|
5469
|
-
t1
|
|
5470
|
-
])), this.#s.delete(e1), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
5471
|
-
else if (s === this.#l) this.#l = this.#a[s];
|
|
5346
|
+
#delete(k, reason) {
|
|
5347
|
+
let deleted = false;
|
|
5348
|
+
if (0 !== this.#size) {
|
|
5349
|
+
const index = this.#keyMap.get(k);
|
|
5350
|
+
if (void 0 !== index) {
|
|
5351
|
+
deleted = true;
|
|
5352
|
+
if (1 === this.#size) this.#clear(reason);
|
|
5472
5353
|
else {
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
this.#
|
|
5354
|
+
this.#removeItemSize(index);
|
|
5355
|
+
const v = this.#valList[index];
|
|
5356
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5357
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
5358
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5359
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5360
|
+
v,
|
|
5361
|
+
k,
|
|
5362
|
+
reason
|
|
5363
|
+
]);
|
|
5364
|
+
}
|
|
5365
|
+
this.#keyMap.delete(k);
|
|
5366
|
+
this.#keyList[index] = void 0;
|
|
5367
|
+
this.#valList[index] = void 0;
|
|
5368
|
+
if (index === this.#tail) this.#tail = this.#prev[index];
|
|
5369
|
+
else if (index === this.#head) this.#head = this.#next[index];
|
|
5370
|
+
else {
|
|
5371
|
+
const pi = this.#prev[index];
|
|
5372
|
+
this.#next[pi] = this.#next[index];
|
|
5373
|
+
const ni = this.#next[index];
|
|
5374
|
+
this.#prev[ni] = this.#prev[index];
|
|
5375
|
+
}
|
|
5376
|
+
this.#size--;
|
|
5377
|
+
this.#free.push(index);
|
|
5477
5378
|
}
|
|
5478
|
-
this.#n--, this.#y.push(s);
|
|
5479
5379
|
}
|
|
5480
5380
|
}
|
|
5481
|
-
if (this.#
|
|
5482
|
-
|
|
5483
|
-
|
|
5381
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
5382
|
+
const dt = this.#disposed;
|
|
5383
|
+
let task;
|
|
5384
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5484
5385
|
}
|
|
5485
|
-
return
|
|
5386
|
+
return deleted;
|
|
5486
5387
|
}
|
|
5487
5388
|
clear() {
|
|
5488
|
-
return this.#
|
|
5389
|
+
return this.#clear('delete');
|
|
5489
5390
|
}
|
|
5490
|
-
#
|
|
5491
|
-
for (
|
|
5492
|
-
allowStale:
|
|
5391
|
+
#clear(reason) {
|
|
5392
|
+
for (const index of this.#rindexes({
|
|
5393
|
+
allowStale: true
|
|
5493
5394
|
})){
|
|
5494
|
-
|
|
5495
|
-
if (this.#
|
|
5395
|
+
const v = this.#valList[index];
|
|
5396
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5496
5397
|
else {
|
|
5497
|
-
|
|
5498
|
-
this.#
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5398
|
+
const k = this.#keyList[index];
|
|
5399
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5400
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5401
|
+
v,
|
|
5402
|
+
k,
|
|
5403
|
+
reason
|
|
5502
5404
|
]);
|
|
5503
5405
|
}
|
|
5504
5406
|
}
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5407
|
+
this.#keyMap.clear();
|
|
5408
|
+
this.#valList.fill(void 0);
|
|
5409
|
+
this.#keyList.fill(void 0);
|
|
5410
|
+
if (this.#ttls && this.#starts) {
|
|
5411
|
+
this.#ttls.fill(0);
|
|
5412
|
+
this.#starts.fill(0);
|
|
5509
5413
|
}
|
|
5510
|
-
if (this.#
|
|
5511
|
-
|
|
5512
|
-
|
|
5414
|
+
if (this.#sizes) this.#sizes.fill(0);
|
|
5415
|
+
this.#head = 0;
|
|
5416
|
+
this.#tail = 0;
|
|
5417
|
+
this.#free.length = 0;
|
|
5418
|
+
this.#calculatedSize = 0;
|
|
5419
|
+
this.#size = 0;
|
|
5420
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
5421
|
+
const dt = this.#disposed;
|
|
5422
|
+
let task;
|
|
5423
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5513
5424
|
}
|
|
5514
5425
|
}
|
|
5515
|
-
}
|
|
5426
|
+
}
|
|
5516
5427
|
var external_fs_ = __webpack_require__("fs");
|
|
5517
5428
|
const promises_namespaceObject = require("node:fs/promises");
|
|
5518
5429
|
const external_node_events_namespaceObject = require("node:events");
|
|
@@ -5589,7 +5500,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
5589
5500
|
}
|
|
5590
5501
|
constructor(src, dest, opts){
|
|
5591
5502
|
super(src, dest, opts);
|
|
5592
|
-
this.proxyErrors = (er)=>
|
|
5503
|
+
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
5593
5504
|
src.on('error', this.proxyErrors);
|
|
5594
5505
|
}
|
|
5595
5506
|
}
|
|
@@ -6041,8 +5952,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6041
5952
|
return: stop,
|
|
6042
5953
|
[Symbol.asyncIterator] () {
|
|
6043
5954
|
return this;
|
|
6044
|
-
}
|
|
6045
|
-
[Symbol.asyncDispose]: async ()=>{}
|
|
5955
|
+
}
|
|
6046
5956
|
};
|
|
6047
5957
|
}
|
|
6048
5958
|
[Symbol.iterator]() {
|
|
@@ -6076,8 +5986,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6076
5986
|
return: stop,
|
|
6077
5987
|
[Symbol.iterator] () {
|
|
6078
5988
|
return this;
|
|
6079
|
-
}
|
|
6080
|
-
[Symbol.dispose]: ()=>{}
|
|
5989
|
+
}
|
|
6081
5990
|
};
|
|
6082
5991
|
}
|
|
6083
5992
|
destroy(er) {
|
|
@@ -6144,9 +6053,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6144
6053
|
const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
|
|
6145
6054
|
const TYPEMASK = 1023;
|
|
6146
6055
|
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;
|
|
6147
|
-
const normalizeCache = new
|
|
6148
|
-
max: 4096
|
|
6149
|
-
});
|
|
6056
|
+
const normalizeCache = new Map();
|
|
6150
6057
|
const normalize = (s)=>{
|
|
6151
6058
|
const c = normalizeCache.get(s);
|
|
6152
6059
|
if (c) return c;
|
|
@@ -6154,9 +6061,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6154
6061
|
normalizeCache.set(s, n);
|
|
6155
6062
|
return n;
|
|
6156
6063
|
};
|
|
6157
|
-
const normalizeNocaseCache = new
|
|
6158
|
-
max: 4096
|
|
6159
|
-
});
|
|
6064
|
+
const normalizeNocaseCache = new Map();
|
|
6160
6065
|
const normalizeNocase = (s)=>{
|
|
6161
6066
|
const c = normalizeNocaseCache.get(s);
|
|
6162
6067
|
if (c) return c;
|
|
@@ -6164,14 +6069,14 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6164
6069
|
normalizeNocaseCache.set(s, n);
|
|
6165
6070
|
return n;
|
|
6166
6071
|
};
|
|
6167
|
-
class ResolveCache extends
|
|
6072
|
+
class ResolveCache extends LRUCache {
|
|
6168
6073
|
constructor(){
|
|
6169
6074
|
super({
|
|
6170
6075
|
max: 256
|
|
6171
6076
|
});
|
|
6172
6077
|
}
|
|
6173
6078
|
}
|
|
6174
|
-
class ChildrenCache extends
|
|
6079
|
+
class ChildrenCache extends LRUCache {
|
|
6175
6080
|
constructor(maxSize = 16384){
|
|
6176
6081
|
super({
|
|
6177
6082
|
maxSize,
|
|
@@ -11305,7 +11210,7 @@ Usage:
|
|
|
11305
11210
|
type: 'boolean',
|
|
11306
11211
|
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}`
|
|
11307
11212
|
}
|
|
11308
|
-
}).version('version', 'Show version number', "1.8.8
|
|
11213
|
+
}).version('version', 'Show version number', "1.8.8").help().epilogue(`For complete list of configuration options, please visit:
|
|
11309
11214
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
11310
11215
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
11311
11216
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|