@midscene/cli 1.8.8-beta-20260603024013.0 → 1.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/framework/index.mjs +32 -18
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +1098 -1263
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +36 -18
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +1107 -1266
- package/dist/lib/index.js.map +1 -1
- package/package.json +7 -8
package/dist/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");
|
|
@@ -2941,15 +3135,8 @@ var __webpack_modules__ = {
|
|
|
2941
3135
|
const toPosixPath = (value)=>value.split(external_node_path_.sep).join('/');
|
|
2942
3136
|
const toImportLiteral = (value)=>JSON.stringify(toPosixPath(value));
|
|
2943
3137
|
const toVirtualModuleId = (fileStem)=>`virtual:midscene-yaml/${fileStem}.test.ts`;
|
|
2944
|
-
const trimEdgeHyphens = (value)=>{
|
|
2945
|
-
let start = 0;
|
|
2946
|
-
let end = value.length;
|
|
2947
|
-
while(start < end && 45 === value.charCodeAt(start))start += 1;
|
|
2948
|
-
while(end > start && 45 === value.charCodeAt(end - 1))end -= 1;
|
|
2949
|
-
return value.slice(start, end);
|
|
2950
|
-
};
|
|
2951
3138
|
const safeFileStem = (file, index)=>{
|
|
2952
|
-
const base =
|
|
3139
|
+
const base = (0, external_node_path_.basename)(file, (0, external_node_path_.extname)(file)).replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
2953
3140
|
return `${String(index + 1).padStart(3, '0')}-${base || 'case'}`;
|
|
2954
3141
|
};
|
|
2955
3142
|
const resolveTestName = (projectDir, yamlFile)=>{
|
|
@@ -3068,7 +3255,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3068
3255
|
};
|
|
3069
3256
|
}
|
|
3070
3257
|
const external_node_module_namespaceObject = require("node:module");
|
|
3071
|
-
|
|
3258
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
3072
3259
|
const requireFromCliEntry = ()=>{
|
|
3073
3260
|
const entry = process.argv[1] ? (0, external_node_path_.resolve)(process.argv[1]) : (0, external_node_path_.join)(process.cwd(), 'midscene-cli.js');
|
|
3074
3261
|
return (0, external_node_module_namespaceObject.createRequire)(entry);
|
|
@@ -3080,20 +3267,41 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3080
3267
|
};
|
|
3081
3268
|
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
3082
3269
|
async function runRstestYamlProject(options) {
|
|
3270
|
+
const [{ runRstest }, { rspack }] = await Promise.all([
|
|
3271
|
+
import("@rstest/core/api"),
|
|
3272
|
+
import((0, external_node_url_.pathToFileURL)(resolvePackageFromRstestCore('@rsbuild/core')).href)
|
|
3273
|
+
]);
|
|
3083
3274
|
const { project } = options;
|
|
3084
|
-
const
|
|
3085
|
-
|
|
3275
|
+
const maxConcurrency = void 0 !== project.maxConcurrency ? Math.max(1, project.maxConcurrency) : void 0;
|
|
3276
|
+
const inlineConfig = {
|
|
3086
3277
|
root: project.projectDir,
|
|
3087
3278
|
include: project.include,
|
|
3088
|
-
|
|
3089
|
-
rsbuildEntry: resolvePackageFromRstestCore('@rsbuild/core'),
|
|
3279
|
+
testEnvironment: 'node',
|
|
3090
3280
|
testTimeout: project.testTimeout,
|
|
3091
|
-
maxConcurrency
|
|
3092
|
-
|
|
3093
|
-
|
|
3281
|
+
...void 0 !== maxConcurrency ? {
|
|
3282
|
+
maxConcurrency
|
|
3283
|
+
} : {},
|
|
3284
|
+
...void 0 !== maxConcurrency ? {
|
|
3285
|
+
pool: {
|
|
3286
|
+
maxWorkers: maxConcurrency,
|
|
3287
|
+
minWorkers: maxConcurrency
|
|
3288
|
+
}
|
|
3289
|
+
} : {},
|
|
3290
|
+
...void 0 !== project.bail ? {
|
|
3291
|
+
bail: project.bail
|
|
3292
|
+
} : {},
|
|
3293
|
+
reporters: [],
|
|
3294
|
+
tools: {
|
|
3295
|
+
rspack: (_config, { appendPlugins })=>{
|
|
3296
|
+
appendPlugins(new rspack.experiments.VirtualModulesPlugin(project.virtualModules));
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
};
|
|
3300
|
+
const result = await runRstest({
|
|
3301
|
+
cwd: options.cwd || project.projectDir,
|
|
3302
|
+
inlineConfig
|
|
3094
3303
|
});
|
|
3095
|
-
|
|
3096
|
-
if (!result.ok && 'pipe' !== options.stdio && unhandledErrors.length) console.error(unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
|
|
3304
|
+
if (!result.ok && 'pipe' !== options.stdio && result.unhandledErrors.length) console.error(result.unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
|
|
3097
3305
|
return result.ok ? 0 : 1;
|
|
3098
3306
|
}
|
|
3099
3307
|
const createCaseOptions = (config)=>{
|
|
@@ -3166,203 +3374,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3166
3374
|
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
3167
3375
|
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
3168
3376
|
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
3169
|
-
var package_namespaceObject =
|
|
3170
|
-
|
|
3171
|
-
const balanced = (a, b, str)=>{
|
|
3172
|
-
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
3173
|
-
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
3174
|
-
const r = null !== ma && null != mb && range(ma, mb, str);
|
|
3175
|
-
return r && {
|
|
3176
|
-
start: r[0],
|
|
3177
|
-
end: r[1],
|
|
3178
|
-
pre: str.slice(0, r[0]),
|
|
3179
|
-
body: str.slice(r[0] + ma.length, r[1]),
|
|
3180
|
-
post: str.slice(r[1] + mb.length)
|
|
3181
|
-
};
|
|
3377
|
+
var package_namespaceObject = {
|
|
3378
|
+
rE: "1.8.9"
|
|
3182
3379
|
};
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
return m ? m[0] : null;
|
|
3186
|
-
};
|
|
3187
|
-
const range = (a, b, str)=>{
|
|
3188
|
-
let begs, beg, left, right, result;
|
|
3189
|
-
let ai = str.indexOf(a);
|
|
3190
|
-
let bi = str.indexOf(b, ai + 1);
|
|
3191
|
-
let i = ai;
|
|
3192
|
-
if (ai >= 0 && bi > 0) {
|
|
3193
|
-
if (a === b) return [
|
|
3194
|
-
ai,
|
|
3195
|
-
bi
|
|
3196
|
-
];
|
|
3197
|
-
begs = [];
|
|
3198
|
-
left = str.length;
|
|
3199
|
-
while(i >= 0 && !result){
|
|
3200
|
-
if (i === ai) {
|
|
3201
|
-
begs.push(i);
|
|
3202
|
-
ai = str.indexOf(a, i + 1);
|
|
3203
|
-
} else if (1 === begs.length) {
|
|
3204
|
-
const r = begs.pop();
|
|
3205
|
-
if (void 0 !== r) result = [
|
|
3206
|
-
r,
|
|
3207
|
-
bi
|
|
3208
|
-
];
|
|
3209
|
-
} else {
|
|
3210
|
-
beg = begs.pop();
|
|
3211
|
-
if (void 0 !== beg && beg < left) {
|
|
3212
|
-
left = beg;
|
|
3213
|
-
right = bi;
|
|
3214
|
-
}
|
|
3215
|
-
bi = str.indexOf(b, i + 1);
|
|
3216
|
-
}
|
|
3217
|
-
i = ai < bi && ai >= 0 ? ai : bi;
|
|
3218
|
-
}
|
|
3219
|
-
if (begs.length && void 0 !== right) result = [
|
|
3220
|
-
left,
|
|
3221
|
-
right
|
|
3222
|
-
];
|
|
3223
|
-
}
|
|
3224
|
-
return result;
|
|
3225
|
-
};
|
|
3226
|
-
const escSlash = '\0SLASH' + Math.random() + '\0';
|
|
3227
|
-
const escOpen = '\0OPEN' + Math.random() + '\0';
|
|
3228
|
-
const escClose = '\0CLOSE' + Math.random() + '\0';
|
|
3229
|
-
const escComma = '\0COMMA' + Math.random() + '\0';
|
|
3230
|
-
const escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
3231
|
-
const escSlashPattern = new RegExp(escSlash, 'g');
|
|
3232
|
-
const escOpenPattern = new RegExp(escOpen, 'g');
|
|
3233
|
-
const escClosePattern = new RegExp(escClose, 'g');
|
|
3234
|
-
const escCommaPattern = new RegExp(escComma, 'g');
|
|
3235
|
-
const escPeriodPattern = new RegExp(escPeriod, 'g');
|
|
3236
|
-
const slashPattern = /\\\\/g;
|
|
3237
|
-
const openPattern = /\\{/g;
|
|
3238
|
-
const closePattern = /\\}/g;
|
|
3239
|
-
const commaPattern = /\\,/g;
|
|
3240
|
-
const periodPattern = /\\\./g;
|
|
3241
|
-
const EXPANSION_MAX = 100000;
|
|
3242
|
-
function numeric(str) {
|
|
3243
|
-
return isNaN(str) ? str.charCodeAt(0) : parseInt(str, 10);
|
|
3244
|
-
}
|
|
3245
|
-
function escapeBraces(str) {
|
|
3246
|
-
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
3247
|
-
}
|
|
3248
|
-
function unescapeBraces(str) {
|
|
3249
|
-
return str.replace(escSlashPattern, '\\').replace(escOpenPattern, '{').replace(escClosePattern, '}').replace(escCommaPattern, ',').replace(escPeriodPattern, '.');
|
|
3250
|
-
}
|
|
3251
|
-
function parseCommaParts(str) {
|
|
3252
|
-
if (!str) return [
|
|
3253
|
-
''
|
|
3254
|
-
];
|
|
3255
|
-
const parts = [];
|
|
3256
|
-
const m = balanced('{', '}', str);
|
|
3257
|
-
if (!m) return str.split(',');
|
|
3258
|
-
const { pre, body, post } = m;
|
|
3259
|
-
const p = pre.split(',');
|
|
3260
|
-
p[p.length - 1] += '{' + body + '}';
|
|
3261
|
-
const postParts = parseCommaParts(post);
|
|
3262
|
-
if (post.length) {
|
|
3263
|
-
p[p.length - 1] += postParts.shift();
|
|
3264
|
-
p.push.apply(p, postParts);
|
|
3265
|
-
}
|
|
3266
|
-
parts.push.apply(parts, p);
|
|
3267
|
-
return parts;
|
|
3268
|
-
}
|
|
3269
|
-
function expand(str, options = {}) {
|
|
3270
|
-
if (!str) return [];
|
|
3271
|
-
const { max = EXPANSION_MAX } = options;
|
|
3272
|
-
if ('{}' === str.slice(0, 2)) str = '\\{\\}' + str.slice(2);
|
|
3273
|
-
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
3274
|
-
}
|
|
3275
|
-
function embrace(str) {
|
|
3276
|
-
return '{' + str + '}';
|
|
3277
|
-
}
|
|
3278
|
-
function isPadded(el) {
|
|
3279
|
-
return /^-?0\d/.test(el);
|
|
3280
|
-
}
|
|
3281
|
-
function lte(i, y) {
|
|
3282
|
-
return i <= y;
|
|
3283
|
-
}
|
|
3284
|
-
function gte(i, y) {
|
|
3285
|
-
return i >= y;
|
|
3286
|
-
}
|
|
3287
|
-
function expand_(str, max, isTop) {
|
|
3288
|
-
const expansions = [];
|
|
3289
|
-
const m = balanced('{', '}', str);
|
|
3290
|
-
if (!m) return [
|
|
3291
|
-
str
|
|
3292
|
-
];
|
|
3293
|
-
const pre = m.pre;
|
|
3294
|
-
const post = m.post.length ? expand_(m.post, max, false) : [
|
|
3295
|
-
''
|
|
3296
|
-
];
|
|
3297
|
-
if (/\$$/.test(m.pre)) for(let k = 0; k < post.length && k < max; k++){
|
|
3298
|
-
const expansion = pre + '{' + m.body + '}' + post[k];
|
|
3299
|
-
expansions.push(expansion);
|
|
3300
|
-
}
|
|
3301
|
-
else {
|
|
3302
|
-
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
3303
|
-
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
3304
|
-
const isSequence = isNumericSequence || isAlphaSequence;
|
|
3305
|
-
const isOptions = m.body.indexOf(',') >= 0;
|
|
3306
|
-
if (!isSequence && !isOptions) {
|
|
3307
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
3308
|
-
str = m.pre + '{' + m.body + escClose + m.post;
|
|
3309
|
-
return expand_(str, max, true);
|
|
3310
|
-
}
|
|
3311
|
-
return [
|
|
3312
|
-
str
|
|
3313
|
-
];
|
|
3314
|
-
}
|
|
3315
|
-
let n;
|
|
3316
|
-
if (isSequence) n = m.body.split(/\.\./);
|
|
3317
|
-
else {
|
|
3318
|
-
n = parseCommaParts(m.body);
|
|
3319
|
-
if (1 === n.length && void 0 !== n[0]) {
|
|
3320
|
-
n = expand_(n[0], max, false).map(embrace);
|
|
3321
|
-
if (1 === n.length) return post.map((p)=>m.pre + n[0] + p);
|
|
3322
|
-
}
|
|
3323
|
-
}
|
|
3324
|
-
let N;
|
|
3325
|
-
if (isSequence && void 0 !== n[0] && void 0 !== n[1]) {
|
|
3326
|
-
const x = numeric(n[0]);
|
|
3327
|
-
const y = numeric(n[1]);
|
|
3328
|
-
const width = Math.max(n[0].length, n[1].length);
|
|
3329
|
-
let incr = 3 === n.length && void 0 !== n[2] ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
3330
|
-
let test = lte;
|
|
3331
|
-
const reverse = y < x;
|
|
3332
|
-
if (reverse) {
|
|
3333
|
-
incr *= -1;
|
|
3334
|
-
test = gte;
|
|
3335
|
-
}
|
|
3336
|
-
const pad = n.some(isPadded);
|
|
3337
|
-
N = [];
|
|
3338
|
-
for(let i = x; test(i, y); i += incr){
|
|
3339
|
-
let c;
|
|
3340
|
-
if (isAlphaSequence) {
|
|
3341
|
-
c = String.fromCharCode(i);
|
|
3342
|
-
if ('\\' === c) c = '';
|
|
3343
|
-
} else {
|
|
3344
|
-
c = String(i);
|
|
3345
|
-
if (pad) {
|
|
3346
|
-
const need = width - c.length;
|
|
3347
|
-
if (need > 0) {
|
|
3348
|
-
const z = new Array(need + 1).join('0');
|
|
3349
|
-
c = i < 0 ? '-' + z + c.slice(1) : z + c;
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
|
-
}
|
|
3353
|
-
N.push(c);
|
|
3354
|
-
}
|
|
3355
|
-
} else {
|
|
3356
|
-
N = [];
|
|
3357
|
-
for(let j = 0; j < n.length; j++)N.push.apply(N, expand_(n[j], max, false));
|
|
3358
|
-
}
|
|
3359
|
-
for(let j = 0; j < N.length; j++)for(let k = 0; k < post.length && expansions.length < max; k++){
|
|
3360
|
-
const expansion = pre + N[j] + post[k];
|
|
3361
|
-
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
3362
|
-
}
|
|
3363
|
-
}
|
|
3364
|
-
return expansions;
|
|
3365
|
-
}
|
|
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");
|
|
3366
3382
|
const MAX_PATTERN_LENGTH = 65536;
|
|
3367
3383
|
const assertValidPattern = (pattern)=>{
|
|
3368
3384
|
if ('string' != typeof pattern) throw new TypeError('invalid pattern');
|
|
@@ -3528,11 +3544,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3528
3544
|
true
|
|
3529
3545
|
];
|
|
3530
3546
|
};
|
|
3531
|
-
const unescape_unescape = (s, { windowsPathsNoEscape = false
|
|
3532
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2').replace(/\\([^/])/g, '$1');
|
|
3533
|
-
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2').replace(/\\([^/{}])/g, '$1');
|
|
3534
|
-
};
|
|
3535
|
-
var ast_a;
|
|
3547
|
+
const unescape_unescape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1');
|
|
3536
3548
|
const types = new Set([
|
|
3537
3549
|
'!',
|
|
3538
3550
|
'?',
|
|
@@ -3541,168 +3553,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3541
3553
|
'@'
|
|
3542
3554
|
]);
|
|
3543
3555
|
const isExtglobType = (c)=>types.has(c);
|
|
3544
|
-
const isExtglobAST = (c)=>isExtglobType(c.type);
|
|
3545
|
-
const adoptionMap = new Map([
|
|
3546
|
-
[
|
|
3547
|
-
'!',
|
|
3548
|
-
[
|
|
3549
|
-
'@'
|
|
3550
|
-
]
|
|
3551
|
-
],
|
|
3552
|
-
[
|
|
3553
|
-
'?',
|
|
3554
|
-
[
|
|
3555
|
-
'?',
|
|
3556
|
-
'@'
|
|
3557
|
-
]
|
|
3558
|
-
],
|
|
3559
|
-
[
|
|
3560
|
-
'@',
|
|
3561
|
-
[
|
|
3562
|
-
'@'
|
|
3563
|
-
]
|
|
3564
|
-
],
|
|
3565
|
-
[
|
|
3566
|
-
'*',
|
|
3567
|
-
[
|
|
3568
|
-
'*',
|
|
3569
|
-
'+',
|
|
3570
|
-
'?',
|
|
3571
|
-
'@'
|
|
3572
|
-
]
|
|
3573
|
-
],
|
|
3574
|
-
[
|
|
3575
|
-
'+',
|
|
3576
|
-
[
|
|
3577
|
-
'+',
|
|
3578
|
-
'@'
|
|
3579
|
-
]
|
|
3580
|
-
]
|
|
3581
|
-
]);
|
|
3582
|
-
const adoptionWithSpaceMap = new Map([
|
|
3583
|
-
[
|
|
3584
|
-
'!',
|
|
3585
|
-
[
|
|
3586
|
-
'?'
|
|
3587
|
-
]
|
|
3588
|
-
],
|
|
3589
|
-
[
|
|
3590
|
-
'@',
|
|
3591
|
-
[
|
|
3592
|
-
'?'
|
|
3593
|
-
]
|
|
3594
|
-
],
|
|
3595
|
-
[
|
|
3596
|
-
'+',
|
|
3597
|
-
[
|
|
3598
|
-
'?',
|
|
3599
|
-
'*'
|
|
3600
|
-
]
|
|
3601
|
-
]
|
|
3602
|
-
]);
|
|
3603
|
-
const adoptionAnyMap = new Map([
|
|
3604
|
-
[
|
|
3605
|
-
'!',
|
|
3606
|
-
[
|
|
3607
|
-
'?',
|
|
3608
|
-
'@'
|
|
3609
|
-
]
|
|
3610
|
-
],
|
|
3611
|
-
[
|
|
3612
|
-
'?',
|
|
3613
|
-
[
|
|
3614
|
-
'?',
|
|
3615
|
-
'@'
|
|
3616
|
-
]
|
|
3617
|
-
],
|
|
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
|
-
const usurpMap = new Map([
|
|
3645
|
-
[
|
|
3646
|
-
'!',
|
|
3647
|
-
new Map([
|
|
3648
|
-
[
|
|
3649
|
-
'!',
|
|
3650
|
-
'@'
|
|
3651
|
-
]
|
|
3652
|
-
])
|
|
3653
|
-
],
|
|
3654
|
-
[
|
|
3655
|
-
'?',
|
|
3656
|
-
new Map([
|
|
3657
|
-
[
|
|
3658
|
-
'*',
|
|
3659
|
-
'*'
|
|
3660
|
-
],
|
|
3661
|
-
[
|
|
3662
|
-
'+',
|
|
3663
|
-
'*'
|
|
3664
|
-
]
|
|
3665
|
-
])
|
|
3666
|
-
],
|
|
3667
|
-
[
|
|
3668
|
-
'@',
|
|
3669
|
-
new Map([
|
|
3670
|
-
[
|
|
3671
|
-
'!',
|
|
3672
|
-
'!'
|
|
3673
|
-
],
|
|
3674
|
-
[
|
|
3675
|
-
'?',
|
|
3676
|
-
'?'
|
|
3677
|
-
],
|
|
3678
|
-
[
|
|
3679
|
-
'@',
|
|
3680
|
-
'@'
|
|
3681
|
-
],
|
|
3682
|
-
[
|
|
3683
|
-
'*',
|
|
3684
|
-
'*'
|
|
3685
|
-
],
|
|
3686
|
-
[
|
|
3687
|
-
'+',
|
|
3688
|
-
'+'
|
|
3689
|
-
]
|
|
3690
|
-
])
|
|
3691
|
-
],
|
|
3692
|
-
[
|
|
3693
|
-
'+',
|
|
3694
|
-
new Map([
|
|
3695
|
-
[
|
|
3696
|
-
'?',
|
|
3697
|
-
'*'
|
|
3698
|
-
],
|
|
3699
|
-
[
|
|
3700
|
-
'*',
|
|
3701
|
-
'*'
|
|
3702
|
-
]
|
|
3703
|
-
])
|
|
3704
|
-
]
|
|
3705
|
-
]);
|
|
3706
3556
|
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
|
|
3707
3557
|
const startNoDot = '(?!\\.)';
|
|
3708
3558
|
const addPatternStart = new Set([
|
|
@@ -3718,7 +3568,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3718
3568
|
const qmark = '[^/]';
|
|
3719
3569
|
const star = qmark + '*?';
|
|
3720
3570
|
const starNoEmpty = qmark + '+?';
|
|
3721
|
-
let ID = 0;
|
|
3722
3571
|
class ast_AST {
|
|
3723
3572
|
type;
|
|
3724
3573
|
#root;
|
|
@@ -3732,22 +3581,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3732
3581
|
#options;
|
|
3733
3582
|
#toString;
|
|
3734
3583
|
#emptyExt = false;
|
|
3735
|
-
id = ++ID;
|
|
3736
|
-
get depth() {
|
|
3737
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
3738
|
-
}
|
|
3739
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
3740
|
-
return {
|
|
3741
|
-
'@@type': 'AST',
|
|
3742
|
-
id: this.id,
|
|
3743
|
-
type: this.type,
|
|
3744
|
-
root: this.#root.id,
|
|
3745
|
-
parent: this.#parent?.id,
|
|
3746
|
-
depth: this.depth,
|
|
3747
|
-
partsLength: this.#parts.length,
|
|
3748
|
-
parts: this.#parts
|
|
3749
|
-
};
|
|
3750
|
-
}
|
|
3751
3584
|
constructor(type, parent, options = {}){
|
|
3752
3585
|
this.type = type;
|
|
3753
3586
|
if (type) this.#hasMagic = true;
|
|
@@ -3766,7 +3599,9 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3766
3599
|
return this.#hasMagic;
|
|
3767
3600
|
}
|
|
3768
3601
|
toString() {
|
|
3769
|
-
|
|
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('|') + ')';
|
|
3770
3605
|
}
|
|
3771
3606
|
#fillNegs() {
|
|
3772
3607
|
if (this !== this.#root) throw new Error('should only call on root');
|
|
@@ -3791,7 +3626,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3791
3626
|
}
|
|
3792
3627
|
push(...parts) {
|
|
3793
3628
|
for (const p of parts)if ('' !== p) {
|
|
3794
|
-
if ('string' != typeof p && !(p instanceof
|
|
3629
|
+
if ('string' != typeof p && !(p instanceof ast_AST && p.#parent === this)) throw new Error('invalid part: ' + p);
|
|
3795
3630
|
this.#parts.push(p);
|
|
3796
3631
|
}
|
|
3797
3632
|
}
|
|
@@ -3811,7 +3646,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3811
3646
|
const p = this.#parent;
|
|
3812
3647
|
for(let i = 0; i < this.#parentIndex; i++){
|
|
3813
3648
|
const pp = p.#parts[i];
|
|
3814
|
-
if (!(pp instanceof
|
|
3649
|
+
if (!(pp instanceof ast_AST && '!' === pp.type)) return false;
|
|
3815
3650
|
}
|
|
3816
3651
|
return true;
|
|
3817
3652
|
}
|
|
@@ -3828,12 +3663,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3828
3663
|
else this.push(part.clone(this));
|
|
3829
3664
|
}
|
|
3830
3665
|
clone(parent) {
|
|
3831
|
-
const c = new
|
|
3666
|
+
const c = new ast_AST(this.type, parent);
|
|
3832
3667
|
for (const p of this.#parts)c.copyIn(p);
|
|
3833
3668
|
return c;
|
|
3834
3669
|
}
|
|
3835
|
-
static #parseAST(str, ast, pos, opt
|
|
3836
|
-
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
3670
|
+
static #parseAST(str, ast, pos, opt) {
|
|
3837
3671
|
let escaping = false;
|
|
3838
3672
|
let inBrace = false;
|
|
3839
3673
|
let braceStart = -1;
|
|
@@ -3862,12 +3696,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3862
3696
|
acc += c;
|
|
3863
3697
|
continue;
|
|
3864
3698
|
}
|
|
3865
|
-
|
|
3866
|
-
if (doRecurse) {
|
|
3699
|
+
if (!opt.noext && isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3867
3700
|
ast.push(acc);
|
|
3868
3701
|
acc = '';
|
|
3869
|
-
const ext = new
|
|
3870
|
-
i =
|
|
3702
|
+
const ext = new ast_AST(c, ast);
|
|
3703
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3871
3704
|
ast.push(ext);
|
|
3872
3705
|
continue;
|
|
3873
3706
|
}
|
|
@@ -3877,7 +3710,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3877
3710
|
return i;
|
|
3878
3711
|
}
|
|
3879
3712
|
let i = pos + 1;
|
|
3880
|
-
let part = new
|
|
3713
|
+
let part = new ast_AST(null, ast);
|
|
3881
3714
|
const parts = [];
|
|
3882
3715
|
let acc = '';
|
|
3883
3716
|
while(i < str.length){
|
|
@@ -3901,21 +3734,19 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3901
3734
|
acc += c;
|
|
3902
3735
|
continue;
|
|
3903
3736
|
}
|
|
3904
|
-
|
|
3905
|
-
if (doRecurse) {
|
|
3906
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
3737
|
+
if (isExtglobType(c) && '(' === str.charAt(i)) {
|
|
3907
3738
|
part.push(acc);
|
|
3908
3739
|
acc = '';
|
|
3909
|
-
const ext = new
|
|
3740
|
+
const ext = new ast_AST(c, part);
|
|
3910
3741
|
part.push(ext);
|
|
3911
|
-
i =
|
|
3742
|
+
i = ast_AST.#parseAST(str, ext, i, opt);
|
|
3912
3743
|
continue;
|
|
3913
3744
|
}
|
|
3914
3745
|
if ('|' === c) {
|
|
3915
3746
|
part.push(acc);
|
|
3916
3747
|
acc = '';
|
|
3917
3748
|
parts.push(part);
|
|
3918
|
-
part = new
|
|
3749
|
+
part = new ast_AST(null, ast);
|
|
3919
3750
|
continue;
|
|
3920
3751
|
}
|
|
3921
3752
|
if (')' === c) {
|
|
@@ -3934,55 +3765,9 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3934
3765
|
];
|
|
3935
3766
|
return i;
|
|
3936
3767
|
}
|
|
3937
|
-
#canAdoptWithSpace(child) {
|
|
3938
|
-
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
3939
|
-
}
|
|
3940
|
-
#canAdopt(child, map = adoptionMap) {
|
|
3941
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type) return false;
|
|
3942
|
-
const gc = child.#parts[0];
|
|
3943
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3944
|
-
return this.#canAdoptType(gc.type, map);
|
|
3945
|
-
}
|
|
3946
|
-
#canAdoptType(c, map = adoptionAnyMap) {
|
|
3947
|
-
return !!map.get(this.type)?.includes(c);
|
|
3948
|
-
}
|
|
3949
|
-
#adoptWithSpace(child, index) {
|
|
3950
|
-
const gc = child.#parts[0];
|
|
3951
|
-
const blank = new ast_a(null, gc, this.options);
|
|
3952
|
-
blank.#parts.push('');
|
|
3953
|
-
gc.push(blank);
|
|
3954
|
-
this.#adopt(child, index);
|
|
3955
|
-
}
|
|
3956
|
-
#adopt(child, index) {
|
|
3957
|
-
const gc = child.#parts[0];
|
|
3958
|
-
this.#parts.splice(index, 1, ...gc.#parts);
|
|
3959
|
-
for (const p of gc.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3960
|
-
this.#toString = void 0;
|
|
3961
|
-
}
|
|
3962
|
-
#canUsurpType(c) {
|
|
3963
|
-
const m = usurpMap.get(this.type);
|
|
3964
|
-
return !!m?.has(c);
|
|
3965
|
-
}
|
|
3966
|
-
#canUsurp(child) {
|
|
3967
|
-
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type || 1 !== this.#parts.length) return false;
|
|
3968
|
-
const gc = child.#parts[0];
|
|
3969
|
-
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3970
|
-
return this.#canUsurpType(gc.type);
|
|
3971
|
-
}
|
|
3972
|
-
#usurp(child) {
|
|
3973
|
-
const m = usurpMap.get(this.type);
|
|
3974
|
-
const gc = child.#parts[0];
|
|
3975
|
-
const nt = m?.get(gc.type);
|
|
3976
|
-
if (!nt) return false;
|
|
3977
|
-
this.#parts = gc.#parts;
|
|
3978
|
-
for (const p of this.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3979
|
-
this.type = nt;
|
|
3980
|
-
this.#toString = void 0;
|
|
3981
|
-
this.#emptyExt = false;
|
|
3982
|
-
}
|
|
3983
3768
|
static fromGlob(pattern, options = {}) {
|
|
3984
|
-
const ast = new
|
|
3985
|
-
|
|
3769
|
+
const ast = new ast_AST(null, void 0, options);
|
|
3770
|
+
ast_AST.#parseAST(pattern, ast, 0, options);
|
|
3986
3771
|
return ast;
|
|
3987
3772
|
}
|
|
3988
3773
|
toMMPattern() {
|
|
@@ -4002,14 +3787,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4002
3787
|
}
|
|
4003
3788
|
toRegExpSource(allowDot) {
|
|
4004
3789
|
const dot = allowDot ?? !!this.#options.dot;
|
|
4005
|
-
if (this.#root === this)
|
|
4006
|
-
|
|
4007
|
-
this
|
|
4008
|
-
}
|
|
4009
|
-
if (!isExtglobAST(this)) {
|
|
4010
|
-
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();
|
|
4011
3793
|
const src = this.#parts.map((p)=>{
|
|
4012
|
-
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);
|
|
4013
3795
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
4014
3796
|
this.#uflag = this.#uflag || uflag;
|
|
4015
3797
|
return re;
|
|
@@ -4041,12 +3823,11 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4041
3823
|
let body = this.#partsToRegExp(dot);
|
|
4042
3824
|
if (this.isStart() && this.isEnd() && !body && '!' !== this.type) {
|
|
4043
3825
|
const s = this.toString();
|
|
4044
|
-
|
|
4045
|
-
me.#parts = [
|
|
3826
|
+
this.#parts = [
|
|
4046
3827
|
s
|
|
4047
3828
|
];
|
|
4048
|
-
|
|
4049
|
-
|
|
3829
|
+
this.type = null;
|
|
3830
|
+
this.#hasMagic = void 0;
|
|
4050
3831
|
return [
|
|
4051
3832
|
s,
|
|
4052
3833
|
unescape_unescape(this.toString()),
|
|
@@ -4070,32 +3851,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4070
3851
|
this.#uflag
|
|
4071
3852
|
];
|
|
4072
3853
|
}
|
|
4073
|
-
#flatten() {
|
|
4074
|
-
if (isExtglobAST(this)) {
|
|
4075
|
-
let iterations = 0;
|
|
4076
|
-
let done = false;
|
|
4077
|
-
do {
|
|
4078
|
-
done = true;
|
|
4079
|
-
for(let i = 0; i < this.#parts.length; i++){
|
|
4080
|
-
const c = this.#parts[i];
|
|
4081
|
-
if ('object' == typeof c) {
|
|
4082
|
-
c.#flatten();
|
|
4083
|
-
if (this.#canAdopt(c)) {
|
|
4084
|
-
done = false;
|
|
4085
|
-
this.#adopt(c, i);
|
|
4086
|
-
} else if (this.#canAdoptWithSpace(c)) {
|
|
4087
|
-
done = false;
|
|
4088
|
-
this.#adoptWithSpace(c, i);
|
|
4089
|
-
} else if (this.#canUsurp(c)) {
|
|
4090
|
-
done = false;
|
|
4091
|
-
this.#usurp(c);
|
|
4092
|
-
}
|
|
4093
|
-
}
|
|
4094
|
-
}
|
|
4095
|
-
}while (!done && ++iterations < 10);
|
|
4096
|
-
} else for (const p of this.#parts)if ('object' == typeof p) p.#flatten();
|
|
4097
|
-
this.#toString = void 0;
|
|
4098
|
-
}
|
|
4099
3854
|
#partsToRegExp(dot) {
|
|
4100
3855
|
return this.#parts.map((p)=>{
|
|
4101
3856
|
if ('string' == typeof p) throw new Error('string type in extglob ast??');
|
|
@@ -4108,7 +3863,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4108
3863
|
let escaping = false;
|
|
4109
3864
|
let re = '';
|
|
4110
3865
|
let uflag = false;
|
|
4111
|
-
let inStar = false;
|
|
4112
3866
|
for(let i = 0; i < glob.length; i++){
|
|
4113
3867
|
const c = glob.charAt(i);
|
|
4114
3868
|
if (escaping) {
|
|
@@ -4116,14 +3870,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4116
3870
|
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
4117
3871
|
continue;
|
|
4118
3872
|
}
|
|
4119
|
-
if ('*' === c) {
|
|
4120
|
-
if (inStar) continue;
|
|
4121
|
-
inStar = true;
|
|
4122
|
-
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
4123
|
-
hasMagic = true;
|
|
4124
|
-
continue;
|
|
4125
|
-
}
|
|
4126
|
-
inStar = false;
|
|
4127
3873
|
if ('\\' === c) {
|
|
4128
3874
|
if (i === glob.length - 1) re += '\\\\';
|
|
4129
3875
|
else escaping = true;
|
|
@@ -4139,6 +3885,12 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4139
3885
|
continue;
|
|
4140
3886
|
}
|
|
4141
3887
|
}
|
|
3888
|
+
if ('*' === c) {
|
|
3889
|
+
if (noEmpty && '*' === glob) re += starNoEmpty;
|
|
3890
|
+
else re += star;
|
|
3891
|
+
hasMagic = true;
|
|
3892
|
+
continue;
|
|
3893
|
+
}
|
|
4142
3894
|
if ('?' === c) {
|
|
4143
3895
|
re += qmark;
|
|
4144
3896
|
hasMagic = true;
|
|
@@ -4154,17 +3906,13 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4154
3906
|
];
|
|
4155
3907
|
}
|
|
4156
3908
|
}
|
|
4157
|
-
|
|
4158
|
-
const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})=>{
|
|
4159
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, '[$&]') : s.replace(/[?*()[\]\\{}]/g, '\\$&');
|
|
4160
|
-
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
4161
|
-
};
|
|
3909
|
+
const escape_escape = (s, { windowsPathsNoEscape = false } = {})=>windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
4162
3910
|
const minimatch = (p, pattern, options = {})=>{
|
|
4163
3911
|
assertValidPattern(pattern);
|
|
4164
3912
|
if (!options.nocomment && '#' === pattern.charAt(0)) return false;
|
|
4165
3913
|
return new esm_Minimatch(pattern, options).match(p);
|
|
4166
3914
|
};
|
|
4167
|
-
const starDotExtRE = /^\*+([
|
|
3915
|
+
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
4168
3916
|
const starDotExtTest = (ext)=>(f)=>!f.startsWith('.') && f.endsWith(ext);
|
|
4169
3917
|
const starDotExtTestDot = (ext)=>(f)=>f.endsWith(ext);
|
|
4170
3918
|
const starDotExtTestNocase = (ext)=>{
|
|
@@ -4183,7 +3931,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4183
3931
|
const starRE = /^\*+$/;
|
|
4184
3932
|
const starTest = (f)=>0 !== f.length && !f.startsWith('.');
|
|
4185
3933
|
const starTestDot = (f)=>0 !== f.length && '.' !== f && '..' !== f;
|
|
4186
|
-
const qmarksRE = /^\?+([
|
|
3934
|
+
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
4187
3935
|
const qmarksTestNocase = ([$0, ext = ''])=>{
|
|
4188
3936
|
const noext = qmarksTestNoExt([
|
|
4189
3937
|
$0
|
|
@@ -4278,9 +4026,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4278
4026
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [
|
|
4279
4027
|
pattern
|
|
4280
4028
|
];
|
|
4281
|
-
return
|
|
4282
|
-
max: options.braceExpandMax
|
|
4283
|
-
});
|
|
4029
|
+
return brace_expansion(pattern);
|
|
4284
4030
|
};
|
|
4285
4031
|
minimatch.braceExpand = braceExpand;
|
|
4286
4032
|
const makeRe = (pattern, options = {})=>new esm_Minimatch(pattern, options).makeRe();
|
|
@@ -4311,18 +4057,15 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4311
4057
|
isWindows;
|
|
4312
4058
|
platform;
|
|
4313
4059
|
windowsNoMagicRoot;
|
|
4314
|
-
maxGlobstarRecursion;
|
|
4315
4060
|
regexp;
|
|
4316
4061
|
constructor(pattern, options = {}){
|
|
4317
4062
|
assertValidPattern(pattern);
|
|
4318
4063
|
options = options || {};
|
|
4319
4064
|
this.options = options;
|
|
4320
|
-
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
4321
4065
|
this.pattern = pattern;
|
|
4322
4066
|
this.platform = options.platform || defaultPlatform;
|
|
4323
4067
|
this.isWindows = 'win32' === this.platform;
|
|
4324
|
-
|
|
4325
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options[awe];
|
|
4068
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options.allowWindowsEscape;
|
|
4326
4069
|
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, '/');
|
|
4327
4070
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
4328
4071
|
this.regexp = null;
|
|
@@ -4389,7 +4132,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4389
4132
|
}
|
|
4390
4133
|
preprocess(globParts) {
|
|
4391
4134
|
if (this.options.noglobstar) {
|
|
4392
|
-
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] = '*';
|
|
4393
4136
|
}
|
|
4394
4137
|
const { optimizationLevel = 1 } = this.options;
|
|
4395
4138
|
if (optimizationLevel >= 2) {
|
|
@@ -4452,7 +4195,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4452
4195
|
let dd = 0;
|
|
4453
4196
|
while(-1 !== (dd = parts.indexOf('..', dd + 1))){
|
|
4454
4197
|
const p = parts[dd - 1];
|
|
4455
|
-
if (p && '.' !== p && '..' !== p && '**' !== p
|
|
4198
|
+
if (p && '.' !== p && '..' !== p && '**' !== p) {
|
|
4456
4199
|
didSomething = true;
|
|
4457
4200
|
parts.splice(dd - 1, 2);
|
|
4458
4201
|
dd -= 2;
|
|
@@ -4574,8 +4317,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4574
4317
|
this.negate = negate;
|
|
4575
4318
|
}
|
|
4576
4319
|
matchOne(file, pattern, partial = false) {
|
|
4577
|
-
|
|
4578
|
-
let patternStartIndex = 0;
|
|
4320
|
+
const options = this.options;
|
|
4579
4321
|
if (this.isWindows) {
|
|
4580
4322
|
const fileDrive = 'string' == typeof file[0] && /^[a-z]:$/i.test(file[0]);
|
|
4581
4323
|
const fileUNC = !fileDrive && '' === file[0] && '' === file[1] && '?' === file[2] && /^[a-z]:$/i.test(file[3]);
|
|
@@ -4590,116 +4332,57 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4590
4332
|
];
|
|
4591
4333
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
4592
4334
|
pattern[pdi] = fd;
|
|
4593
|
-
|
|
4594
|
-
|
|
4335
|
+
if (pdi > fdi) pattern = pattern.slice(pdi);
|
|
4336
|
+
else if (fdi > pdi) file = file.slice(fdi);
|
|
4595
4337
|
}
|
|
4596
4338
|
}
|
|
4597
4339
|
}
|
|
4598
4340
|
const { optimizationLevel = 1 } = this.options;
|
|
4599
4341
|
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
const [head, body, tail] = partial ? [
|
|
4607
|
-
pattern.slice(patternIndex, firstgs),
|
|
4608
|
-
pattern.slice(firstgs + 1),
|
|
4609
|
-
[]
|
|
4610
|
-
] : [
|
|
4611
|
-
pattern.slice(patternIndex, firstgs),
|
|
4612
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
4613
|
-
pattern.slice(lastgs + 1)
|
|
4614
|
-
];
|
|
4615
|
-
if (head.length) {
|
|
4616
|
-
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
4617
|
-
if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
|
|
4618
|
-
fileIndex += head.length;
|
|
4619
|
-
patternIndex += head.length;
|
|
4620
|
-
}
|
|
4621
|
-
let fileTailMatch = 0;
|
|
4622
|
-
if (tail.length) {
|
|
4623
|
-
if (tail.length + fileIndex > file.length) return false;
|
|
4624
|
-
let tailStart = file.length - tail.length;
|
|
4625
|
-
if (this.#matchOne(file, tail, partial, tailStart, 0)) fileTailMatch = tail.length;
|
|
4626
|
-
else {
|
|
4627
|
-
if ('' !== file[file.length - 1] || fileIndex + tail.length === file.length) return false;
|
|
4628
|
-
tailStart--;
|
|
4629
|
-
if (!this.#matchOne(file, tail, partial, tailStart, 0)) return false;
|
|
4630
|
-
fileTailMatch = tail.length + 1;
|
|
4631
|
-
}
|
|
4632
|
-
}
|
|
4633
|
-
if (!body.length) {
|
|
4634
|
-
let sawSome = !!fileTailMatch;
|
|
4635
|
-
for(let i = fileIndex; i < file.length - fileTailMatch; i++){
|
|
4636
|
-
const f = String(file[i]);
|
|
4637
|
-
sawSome = true;
|
|
4638
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4639
|
-
}
|
|
4640
|
-
return partial || sawSome;
|
|
4641
|
-
}
|
|
4642
|
-
const bodySegments = [
|
|
4643
|
-
[
|
|
4644
|
-
[],
|
|
4645
|
-
0
|
|
4646
|
-
]
|
|
4647
|
-
];
|
|
4648
|
-
let currentBody = bodySegments[0];
|
|
4649
|
-
let nonGsParts = 0;
|
|
4650
|
-
const nonGsPartsSums = [
|
|
4651
|
-
0
|
|
4652
|
-
];
|
|
4653
|
-
for (const b of body)if (b === GLOBSTAR) {
|
|
4654
|
-
nonGsPartsSums.push(nonGsParts);
|
|
4655
|
-
currentBody = [
|
|
4656
|
-
[],
|
|
4657
|
-
0
|
|
4658
|
-
];
|
|
4659
|
-
bodySegments.push(currentBody);
|
|
4660
|
-
} else {
|
|
4661
|
-
currentBody[0].push(b);
|
|
4662
|
-
nonGsParts++;
|
|
4663
|
-
}
|
|
4664
|
-
let i = bodySegments.length - 1;
|
|
4665
|
-
const fileLength = file.length - fileTailMatch;
|
|
4666
|
-
for (const b of bodySegments)b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
4667
|
-
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
4668
|
-
}
|
|
4669
|
-
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
4670
|
-
const bs = bodySegments[bodyIndex];
|
|
4671
|
-
if (!bs) {
|
|
4672
|
-
for(let i = fileIndex; i < file.length; i++){
|
|
4673
|
-
sawTail = true;
|
|
4674
|
-
const f = file[i];
|
|
4675
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4676
|
-
}
|
|
4677
|
-
return sawTail;
|
|
4678
|
-
}
|
|
4679
|
-
const [body, after] = bs;
|
|
4680
|
-
while(fileIndex <= after){
|
|
4681
|
-
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
4682
|
-
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
4683
|
-
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
4684
|
-
if (false !== sub) return sub;
|
|
4685
|
-
}
|
|
4686
|
-
const f = file[fileIndex];
|
|
4687
|
-
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4688
|
-
fileIndex++;
|
|
4689
|
-
}
|
|
4690
|
-
return partial || null;
|
|
4691
|
-
}
|
|
4692
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
4693
|
-
let fi;
|
|
4694
|
-
let pi;
|
|
4695
|
-
let pl;
|
|
4696
|
-
let fl;
|
|
4697
|
-
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++){
|
|
4698
4348
|
this.debug('matchOne loop');
|
|
4699
|
-
|
|
4700
|
-
|
|
4349
|
+
var p = pattern[pi];
|
|
4350
|
+
var f = file[fi];
|
|
4701
4351
|
this.debug(pattern, p, f);
|
|
4702
|
-
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
|
+
}
|
|
4703
4386
|
let hit;
|
|
4704
4387
|
if ('string' == typeof p) {
|
|
4705
4388
|
hit = f === p;
|
|
@@ -4759,19 +4442,13 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4759
4442
|
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
4760
4443
|
if (void 0 === prev) if (void 0 !== next && next !== GLOBSTAR) pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
|
|
4761
4444
|
else pp[i] = twoStar;
|
|
4762
|
-
else if (void 0 === next) pp[i - 1] = prev + '(
|
|
4445
|
+
else if (void 0 === next) pp[i - 1] = prev + '(?:\\/|' + twoStar + ')?';
|
|
4763
4446
|
else if (next !== GLOBSTAR) {
|
|
4764
4447
|
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
|
|
4765
4448
|
pp[i + 1] = GLOBSTAR;
|
|
4766
4449
|
}
|
|
4767
4450
|
});
|
|
4768
|
-
|
|
4769
|
-
if (this.partial && filtered.length >= 1) {
|
|
4770
|
-
const prefixes = [];
|
|
4771
|
-
for(let i = 1; i <= filtered.length; i++)prefixes.push(filtered.slice(0, i).join('/'));
|
|
4772
|
-
return '(?:' + prefixes.join('|') + ')';
|
|
4773
|
-
}
|
|
4774
|
-
return filtered.join('/');
|
|
4451
|
+
return pp.filter((p)=>p !== GLOBSTAR).join('/');
|
|
4775
4452
|
}).join('|');
|
|
4776
4453
|
const [open, close] = set.length > 1 ? [
|
|
4777
4454
|
'(?:',
|
|
@@ -4781,20 +4458,19 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4781
4458
|
''
|
|
4782
4459
|
];
|
|
4783
4460
|
re = '^' + open + re + close + '$';
|
|
4784
|
-
if (this.partial) re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
|
|
4785
4461
|
if (this.negate) re = '^(?!' + re + ').+$';
|
|
4786
4462
|
try {
|
|
4787
4463
|
this.regexp = new RegExp(re, [
|
|
4788
4464
|
...flags
|
|
4789
4465
|
].join(''));
|
|
4790
|
-
} catch
|
|
4466
|
+
} catch (ex) {
|
|
4791
4467
|
this.regexp = false;
|
|
4792
4468
|
}
|
|
4793
4469
|
return this.regexp;
|
|
4794
4470
|
}
|
|
4795
4471
|
slashSplit(p) {
|
|
4796
4472
|
if (this.preserveMultipleSlashes) return p.split('/');
|
|
4797
|
-
if (this.isWindows && /^\/\/[
|
|
4473
|
+
if (this.isWindows && /^\/\/[^\/]+/.test(p)) return [
|
|
4798
4474
|
'',
|
|
4799
4475
|
...p.split(/\/+/)
|
|
4800
4476
|
];
|
|
@@ -4813,7 +4489,8 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4813
4489
|
this.debug(this.pattern, 'set', set);
|
|
4814
4490
|
let filename = ff[ff.length - 1];
|
|
4815
4491
|
if (!filename) for(let i = ff.length - 2; !filename && i >= 0; i--)filename = ff[i];
|
|
4816
|
-
for
|
|
4492
|
+
for(let i = 0; i < set.length; i++){
|
|
4493
|
+
const pattern = set[i];
|
|
4817
4494
|
let file = ff;
|
|
4818
4495
|
if (options.matchBase && 1 === pattern.length) file = [
|
|
4819
4496
|
filename
|
|
@@ -4835,48 +4512,86 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4835
4512
|
minimatch.Minimatch = esm_Minimatch;
|
|
4836
4513
|
minimatch.escape = escape_escape;
|
|
4837
4514
|
minimatch.unescape = unescape_unescape;
|
|
4838
|
-
|
|
4839
|
-
const
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4515
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
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 {
|
|
4848
4565
|
heap;
|
|
4849
4566
|
length;
|
|
4850
|
-
static #
|
|
4851
|
-
static create(
|
|
4852
|
-
|
|
4853
|
-
if (!
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
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;
|
|
4864
4583
|
}
|
|
4865
4584
|
pop() {
|
|
4866
4585
|
return this.heap[--this.length];
|
|
4867
4586
|
}
|
|
4868
|
-
}
|
|
4869
|
-
|
|
4870
|
-
#
|
|
4871
|
-
#
|
|
4872
|
-
#
|
|
4873
|
-
#
|
|
4874
|
-
#
|
|
4875
|
-
#
|
|
4876
|
-
#m;
|
|
4877
|
-
get perf() {
|
|
4878
|
-
return this.#m;
|
|
4879
|
-
}
|
|
4587
|
+
}
|
|
4588
|
+
class LRUCache {
|
|
4589
|
+
#max;
|
|
4590
|
+
#maxSize;
|
|
4591
|
+
#dispose;
|
|
4592
|
+
#disposeAfter;
|
|
4593
|
+
#fetchMethod;
|
|
4594
|
+
#memoMethod;
|
|
4880
4595
|
ttl;
|
|
4881
4596
|
ttlResolution;
|
|
4882
4597
|
ttlAutopurge;
|
|
@@ -4892,613 +4607,823 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4892
4607
|
allowStaleOnFetchAbort;
|
|
4893
4608
|
allowStaleOnFetchRejection;
|
|
4894
4609
|
ignoreFetchAbort;
|
|
4895
|
-
#
|
|
4896
|
-
#
|
|
4897
|
-
#
|
|
4898
|
-
#
|
|
4899
|
-
#
|
|
4900
|
-
#
|
|
4901
|
-
#
|
|
4902
|
-
#
|
|
4903
|
-
#
|
|
4904
|
-
#
|
|
4905
|
-
#
|
|
4906
|
-
#
|
|
4907
|
-
#
|
|
4908
|
-
#
|
|
4909
|
-
#
|
|
4910
|
-
#
|
|
4911
|
-
#
|
|
4912
|
-
|
|
4913
|
-
#j;
|
|
4914
|
-
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) {
|
|
4915
4628
|
return {
|
|
4916
|
-
starts:
|
|
4917
|
-
ttls:
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
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,
|
|
4925
4637
|
get head () {
|
|
4926
|
-
return
|
|
4638
|
+
return c.#head;
|
|
4927
4639
|
},
|
|
4928
4640
|
get tail () {
|
|
4929
|
-
return
|
|
4641
|
+
return c.#tail;
|
|
4930
4642
|
},
|
|
4931
|
-
free:
|
|
4932
|
-
isBackgroundFetch: (
|
|
4933
|
-
backgroundFetch: (
|
|
4934
|
-
moveToTail: (
|
|
4935
|
-
indexes: (
|
|
4936
|
-
rindexes: (
|
|
4937
|
-
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)
|
|
4938
4650
|
};
|
|
4939
4651
|
}
|
|
4940
4652
|
get max() {
|
|
4941
|
-
return this.#
|
|
4653
|
+
return this.#max;
|
|
4942
4654
|
}
|
|
4943
4655
|
get maxSize() {
|
|
4944
|
-
return this.#
|
|
4656
|
+
return this.#maxSize;
|
|
4945
4657
|
}
|
|
4946
4658
|
get calculatedSize() {
|
|
4947
|
-
return this.#
|
|
4659
|
+
return this.#calculatedSize;
|
|
4948
4660
|
}
|
|
4949
4661
|
get size() {
|
|
4950
|
-
return this.#
|
|
4662
|
+
return this.#size;
|
|
4951
4663
|
}
|
|
4952
4664
|
get fetchMethod() {
|
|
4953
|
-
return this.#
|
|
4665
|
+
return this.#fetchMethod;
|
|
4954
4666
|
}
|
|
4955
4667
|
get memoMethod() {
|
|
4956
|
-
return this.#
|
|
4668
|
+
return this.#memoMethod;
|
|
4957
4669
|
}
|
|
4958
4670
|
get dispose() {
|
|
4959
|
-
return this.#
|
|
4960
|
-
}
|
|
4961
|
-
get onInsert() {
|
|
4962
|
-
return this.#D;
|
|
4671
|
+
return this.#dispose;
|
|
4963
4672
|
}
|
|
4964
4673
|
get disposeAfter() {
|
|
4965
|
-
return this.#
|
|
4966
|
-
}
|
|
4967
|
-
constructor(
|
|
4968
|
-
|
|
4969
|
-
if (
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
this.#
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
this
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
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
|
+
}
|
|
4765
|
+
};
|
|
4766
|
+
this.#updateItemAge = (index)=>{
|
|
4767
|
+
starts[index] = 0 !== ttls[index] ? perf.now() : 0;
|
|
5011
4768
|
};
|
|
5012
|
-
|
|
5013
|
-
if (
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
let l = e1[h], c = t1[h];
|
|
5023
|
-
if (!l || !c) return;
|
|
5024
|
-
r.ttl = l, r.start = c, r.now = n || o();
|
|
5025
|
-
let f = r.now - c;
|
|
5026
|
-
r.remainingTTL = l - f;
|
|
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;
|
|
5027
4779
|
}
|
|
5028
4780
|
};
|
|
5029
|
-
let
|
|
5030
|
-
|
|
4781
|
+
let cachedNow = 0;
|
|
4782
|
+
const getNow = ()=>{
|
|
4783
|
+
const n = perf.now();
|
|
5031
4784
|
if (this.ttlResolution > 0) {
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
4785
|
+
cachedNow = n;
|
|
4786
|
+
const t1 = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
4787
|
+
if (t1.unref) t1.unref();
|
|
5035
4788
|
}
|
|
5036
|
-
return
|
|
4789
|
+
return n;
|
|
5037
4790
|
};
|
|
5038
|
-
this.getRemainingTTL = (
|
|
5039
|
-
|
|
5040
|
-
if (void 0 ===
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
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;
|
|
4799
|
+
};
|
|
4800
|
+
this.#isStale = (index)=>{
|
|
4801
|
+
const s = starts[index];
|
|
4802
|
+
const t1 = ttls[index];
|
|
4803
|
+
return !!t1 && !!s && (cachedNow || getNow()) - s > t1;
|
|
5048
4804
|
};
|
|
5049
4805
|
}
|
|
5050
|
-
#
|
|
5051
|
-
#
|
|
5052
|
-
#
|
|
5053
|
-
#
|
|
5054
|
-
#
|
|
5055
|
-
|
|
5056
|
-
this.#
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
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)');
|
|
5063
4824
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
5064
|
-
return
|
|
5065
|
-
}
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
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;
|
|
5069
4837
|
}
|
|
5070
|
-
this.#b += e1[t1], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
5071
4838
|
};
|
|
5072
4839
|
}
|
|
5073
|
-
#
|
|
5074
|
-
#
|
|
5075
|
-
#
|
|
5076
|
-
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');
|
|
5077
4844
|
return 0;
|
|
5078
4845
|
};
|
|
5079
|
-
*#
|
|
5080
|
-
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
|
+
}
|
|
5081
4853
|
}
|
|
5082
|
-
*#
|
|
5083
|
-
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
|
+
}
|
|
5084
4861
|
}
|
|
5085
|
-
#
|
|
5086
|
-
return void 0 !==
|
|
4862
|
+
#isValidIndex(index) {
|
|
4863
|
+
return void 0 !== index && this.#keyMap.get(this.#keyList[index]) === index;
|
|
5087
4864
|
}
|
|
5088
4865
|
*entries() {
|
|
5089
|
-
for (
|
|
5090
|
-
this.#i
|
|
5091
|
-
this.#
|
|
5092
|
-
]
|
|
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
|
+
];
|
|
5093
4870
|
}
|
|
5094
4871
|
*rentries() {
|
|
5095
|
-
for (
|
|
5096
|
-
this.#i
|
|
5097
|
-
this.#
|
|
5098
|
-
]
|
|
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
|
+
];
|
|
5099
4876
|
}
|
|
5100
4877
|
*keys() {
|
|
5101
|
-
for (
|
|
5102
|
-
|
|
5103
|
-
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;
|
|
5104
4881
|
}
|
|
5105
4882
|
}
|
|
5106
4883
|
*rkeys() {
|
|
5107
|
-
for (
|
|
5108
|
-
|
|
5109
|
-
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;
|
|
5110
4887
|
}
|
|
5111
4888
|
}
|
|
5112
4889
|
*values() {
|
|
5113
|
-
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
|
+
}
|
|
5114
4894
|
}
|
|
5115
4895
|
*rvalues() {
|
|
5116
|
-
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
|
+
}
|
|
5117
4900
|
}
|
|
5118
4901
|
[Symbol.iterator]() {
|
|
5119
4902
|
return this.entries();
|
|
5120
4903
|
}
|
|
5121
|
-
[Symbol.toStringTag] =
|
|
5122
|
-
find(
|
|
5123
|
-
for (
|
|
5124
|
-
|
|
5125
|
-
|
|
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
|
+
}
|
|
5126
4912
|
}
|
|
5127
4913
|
}
|
|
5128
|
-
forEach(
|
|
5129
|
-
for (
|
|
5130
|
-
|
|
5131
|
-
|
|
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);
|
|
5132
4919
|
}
|
|
5133
4920
|
}
|
|
5134
|
-
rforEach(
|
|
5135
|
-
for (
|
|
5136
|
-
|
|
5137
|
-
|
|
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);
|
|
5138
4926
|
}
|
|
5139
4927
|
}
|
|
5140
4928
|
purgeStale() {
|
|
5141
|
-
let
|
|
5142
|
-
for (
|
|
5143
|
-
allowStale:
|
|
5144
|
-
}))
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
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
|
|
5154
4946
|
};
|
|
5155
|
-
if (this.#
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
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();
|
|
5160
4954
|
}
|
|
5161
4955
|
}
|
|
5162
|
-
|
|
4956
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4957
|
+
return entry;
|
|
5163
4958
|
}
|
|
5164
4959
|
dump() {
|
|
5165
|
-
|
|
5166
|
-
for (
|
|
5167
|
-
allowStale:
|
|
4960
|
+
const arr = [];
|
|
4961
|
+
for (const i of this.#indexes({
|
|
4962
|
+
allowStale: true
|
|
5168
4963
|
})){
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
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
|
|
5173
4970
|
};
|
|
5174
|
-
if (this.#
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
}
|
|
5179
|
-
this.#
|
|
5180
|
-
|
|
5181
|
-
|
|
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
|
|
5182
4980
|
]);
|
|
5183
4981
|
}
|
|
5184
|
-
return
|
|
4982
|
+
return arr;
|
|
5185
4983
|
}
|
|
5186
|
-
load(
|
|
4984
|
+
load(arr) {
|
|
5187
4985
|
this.clear();
|
|
5188
|
-
for (
|
|
5189
|
-
if (
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
}
|
|
5193
|
-
this
|
|
5194
|
-
}
|
|
5195
|
-
}
|
|
5196
|
-
set(
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
if (
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
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;
|
|
5232
5053
|
}
|
|
5233
|
-
} else
|
|
5234
|
-
this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
|
|
5054
|
+
} else if (status) status.set = 'update';
|
|
5235
5055
|
}
|
|
5236
|
-
if (0
|
|
5237
|
-
|
|
5238
|
-
|
|
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);
|
|
5239
5065
|
}
|
|
5240
5066
|
return this;
|
|
5241
5067
|
}
|
|
5242
5068
|
pop() {
|
|
5243
5069
|
try {
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
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;
|
|
5249
5076
|
}
|
|
5250
5077
|
} finally{
|
|
5251
|
-
if (this.#
|
|
5252
|
-
|
|
5253
|
-
|
|
5078
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
5079
|
+
const dt = this.#disposed;
|
|
5080
|
+
let task;
|
|
5081
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5254
5082
|
}
|
|
5255
5083
|
}
|
|
5256
5084
|
}
|
|
5257
|
-
#
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
5270
|
-
}
|
|
5271
|
-
#Y(e1, t1 = {}) {
|
|
5272
|
-
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t1, n = this.#s.get(e1);
|
|
5273
|
-
if (void 0 !== n) {
|
|
5274
|
-
let o = this.#t[n];
|
|
5275
|
-
if (this.#e(o) && void 0 === o.__staleWhileFetching) return !1;
|
|
5276
|
-
if (!this.#p(n)) return i && this.#x(n), s && (s.has = "hit", this.#E(s, n)), !0;
|
|
5277
|
-
s && (s.has = "stale", this.#E(s, n));
|
|
5278
|
-
} else s && (s.has = "miss");
|
|
5279
|
-
return !1;
|
|
5280
|
-
}
|
|
5281
|
-
peek(e1, t1 = {}) {
|
|
5282
|
-
let { status: i = D() ? {} : void 0 } = t1;
|
|
5283
|
-
i && (i.op = "peek", i.key = e1), t1.status = i;
|
|
5284
|
-
let s = this.#J(e1, t1);
|
|
5285
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
5286
|
-
}
|
|
5287
|
-
#J(e1, t1) {
|
|
5288
|
-
let { status: i, allowStale: s = this.allowStale } = t1, n = this.#s.get(e1);
|
|
5289
|
-
if (void 0 === n || !s && this.#p(n)) {
|
|
5290
|
-
i && (i.peek = void 0 === n ? "miss" : "stale");
|
|
5291
|
-
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
|
+
]);
|
|
5292
5097
|
}
|
|
5293
|
-
|
|
5294
|
-
|
|
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;
|
|
5295
5133
|
}
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
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
|
|
5302
5148
|
});
|
|
5303
|
-
|
|
5304
|
-
signal:
|
|
5305
|
-
options
|
|
5306
|
-
context
|
|
5307
|
-
}
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
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
|
+
}
|
|
5320
5204
|
});
|
|
5321
5205
|
};
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
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,
|
|
5326
5211
|
__returned: void 0
|
|
5327
5212
|
});
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
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
|
-
|
|
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;
|
|
5372
5259
|
}
|
|
5373
5260
|
{
|
|
5374
|
-
|
|
5375
|
-
if (this.#
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
}
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
if (
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
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
|
|
5412
5302
|
});
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
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;
|
|
5426
5328
|
}
|
|
5427
|
-
|
|
5428
|
-
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';
|
|
5429
5330
|
}
|
|
5430
|
-
|
|
5431
|
-
this.#
|
|
5331
|
+
#connect(p, n) {
|
|
5332
|
+
this.#prev[n] = p;
|
|
5333
|
+
this.#next[p] = n;
|
|
5432
5334
|
}
|
|
5433
|
-
#
|
|
5434
|
-
|
|
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
|
+
}
|
|
5435
5342
|
}
|
|
5436
|
-
delete(
|
|
5437
|
-
return this.#
|
|
5343
|
+
delete(k) {
|
|
5344
|
+
return this.#delete(k, 'delete');
|
|
5438
5345
|
}
|
|
5439
|
-
#
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
if (0 !== this.#n) {
|
|
5447
|
-
let s = this.#s.get(e1);
|
|
5448
|
-
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);
|
|
5449
|
-
else {
|
|
5450
|
-
this.#R(s);
|
|
5451
|
-
let n = this.#t[s];
|
|
5452
|
-
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([
|
|
5453
|
-
n,
|
|
5454
|
-
e1,
|
|
5455
|
-
t1
|
|
5456
|
-
])), this.#s.delete(e1), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
5457
|
-
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);
|
|
5458
5353
|
else {
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
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);
|
|
5463
5378
|
}
|
|
5464
|
-
this.#n--, this.#y.push(s);
|
|
5465
5379
|
}
|
|
5466
5380
|
}
|
|
5467
|
-
if (this.#
|
|
5468
|
-
|
|
5469
|
-
|
|
5381
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
5382
|
+
const dt = this.#disposed;
|
|
5383
|
+
let task;
|
|
5384
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5470
5385
|
}
|
|
5471
|
-
return
|
|
5386
|
+
return deleted;
|
|
5472
5387
|
}
|
|
5473
5388
|
clear() {
|
|
5474
|
-
return this.#
|
|
5389
|
+
return this.#clear('delete');
|
|
5475
5390
|
}
|
|
5476
|
-
#
|
|
5477
|
-
for (
|
|
5478
|
-
allowStale:
|
|
5391
|
+
#clear(reason) {
|
|
5392
|
+
for (const index of this.#rindexes({
|
|
5393
|
+
allowStale: true
|
|
5479
5394
|
})){
|
|
5480
|
-
|
|
5481
|
-
if (this.#
|
|
5395
|
+
const v = this.#valList[index];
|
|
5396
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5482
5397
|
else {
|
|
5483
|
-
|
|
5484
|
-
this.#
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
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
|
|
5488
5404
|
]);
|
|
5489
5405
|
}
|
|
5490
5406
|
}
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
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);
|
|
5495
5413
|
}
|
|
5496
|
-
if (this.#
|
|
5497
|
-
|
|
5498
|
-
|
|
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);
|
|
5499
5424
|
}
|
|
5500
5425
|
}
|
|
5501
|
-
}
|
|
5426
|
+
}
|
|
5502
5427
|
var external_fs_ = __webpack_require__("fs");
|
|
5503
5428
|
const promises_namespaceObject = require("node:fs/promises");
|
|
5504
5429
|
const external_node_events_namespaceObject = require("node:events");
|
|
@@ -5575,7 +5500,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
5575
5500
|
}
|
|
5576
5501
|
constructor(src, dest, opts){
|
|
5577
5502
|
super(src, dest, opts);
|
|
5578
|
-
this.proxyErrors = (er)=>
|
|
5503
|
+
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
5579
5504
|
src.on('error', this.proxyErrors);
|
|
5580
5505
|
}
|
|
5581
5506
|
}
|
|
@@ -6027,8 +5952,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6027
5952
|
return: stop,
|
|
6028
5953
|
[Symbol.asyncIterator] () {
|
|
6029
5954
|
return this;
|
|
6030
|
-
}
|
|
6031
|
-
[Symbol.asyncDispose]: async ()=>{}
|
|
5955
|
+
}
|
|
6032
5956
|
};
|
|
6033
5957
|
}
|
|
6034
5958
|
[Symbol.iterator]() {
|
|
@@ -6062,8 +5986,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6062
5986
|
return: stop,
|
|
6063
5987
|
[Symbol.iterator] () {
|
|
6064
5988
|
return this;
|
|
6065
|
-
}
|
|
6066
|
-
[Symbol.dispose]: ()=>{}
|
|
5989
|
+
}
|
|
6067
5990
|
};
|
|
6068
5991
|
}
|
|
6069
5992
|
destroy(er) {
|
|
@@ -6130,9 +6053,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6130
6053
|
const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
|
|
6131
6054
|
const TYPEMASK = 1023;
|
|
6132
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;
|
|
6133
|
-
const normalizeCache = new
|
|
6134
|
-
max: 4096
|
|
6135
|
-
});
|
|
6056
|
+
const normalizeCache = new Map();
|
|
6136
6057
|
const normalize = (s)=>{
|
|
6137
6058
|
const c = normalizeCache.get(s);
|
|
6138
6059
|
if (c) return c;
|
|
@@ -6140,9 +6061,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6140
6061
|
normalizeCache.set(s, n);
|
|
6141
6062
|
return n;
|
|
6142
6063
|
};
|
|
6143
|
-
const normalizeNocaseCache = new
|
|
6144
|
-
max: 4096
|
|
6145
|
-
});
|
|
6064
|
+
const normalizeNocaseCache = new Map();
|
|
6146
6065
|
const normalizeNocase = (s)=>{
|
|
6147
6066
|
const c = normalizeNocaseCache.get(s);
|
|
6148
6067
|
if (c) return c;
|
|
@@ -6150,14 +6069,14 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6150
6069
|
normalizeNocaseCache.set(s, n);
|
|
6151
6070
|
return n;
|
|
6152
6071
|
};
|
|
6153
|
-
class ResolveCache extends
|
|
6072
|
+
class ResolveCache extends LRUCache {
|
|
6154
6073
|
constructor(){
|
|
6155
6074
|
super({
|
|
6156
6075
|
max: 256
|
|
6157
6076
|
});
|
|
6158
6077
|
}
|
|
6159
6078
|
}
|
|
6160
|
-
class ChildrenCache extends
|
|
6079
|
+
class ChildrenCache extends LRUCache {
|
|
6161
6080
|
constructor(maxSize = 16384){
|
|
6162
6081
|
super({
|
|
6163
6082
|
maxSize,
|
|
@@ -6752,7 +6671,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6752
6671
|
#fs;
|
|
6753
6672
|
constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16384, fs = defaultFS } = {}){
|
|
6754
6673
|
this.#fs = fsFromOption(fs);
|
|
6755
|
-
if (cwd instanceof URL || cwd.startsWith('file://')) cwd = (0,
|
|
6674
|
+
if (cwd instanceof URL || cwd.startsWith('file://')) cwd = (0, external_node_url_.fileURLToPath)(cwd);
|
|
6756
6675
|
const cwdPath = pathImpl.resolve(cwd);
|
|
6757
6676
|
this.roots = Object.create(null);
|
|
6758
6677
|
this.rootPath = this.parseRootPath(cwdPath);
|
|
@@ -7842,7 +7761,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
7842
7761
|
this.nodir = !!opts.nodir;
|
|
7843
7762
|
this.mark = !!opts.mark;
|
|
7844
7763
|
if (opts.cwd) {
|
|
7845
|
-
if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) opts.cwd = (0,
|
|
7764
|
+
if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) opts.cwd = (0, external_node_url_.fileURLToPath)(opts.cwd);
|
|
7846
7765
|
} else this.cwd = '';
|
|
7847
7766
|
this.cwd = opts.cwd || '';
|
|
7848
7767
|
this.root = opts.root;
|
|
@@ -11291,7 +11210,7 @@ Usage:
|
|
|
11291
11210
|
type: 'boolean',
|
|
11292
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}`
|
|
11293
11212
|
}
|
|
11294
|
-
}).version('version', 'Show version number', "1.8.
|
|
11213
|
+
}).version('version', 'Show version number', "1.8.9").help().epilogue(`For complete list of configuration options, please visit:
|
|
11295
11214
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
11296
11215
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
11297
11216
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|
|
@@ -11339,83 +11258,6 @@ Examples:
|
|
|
11339
11258
|
});
|
|
11340
11259
|
return files.filter((file)=>file.endsWith('.yml') || file.endsWith('.yaml')).sort();
|
|
11341
11260
|
}
|
|
11342
|
-
const testing_framework_namespaceObject = require("@midscene/testing-framework");
|
|
11343
|
-
const usage = 'Usage: midscene emit <out-dir> [--config <path>]';
|
|
11344
|
-
const help = `${usage}
|
|
11345
|
-
|
|
11346
|
-
Options:
|
|
11347
|
-
--config <path> Path to the source midscene.config file
|
|
11348
|
-
-h, --help Show this help message`;
|
|
11349
|
-
const normalizePackageVersion = (packageVersion, fallbackVersion)=>{
|
|
11350
|
-
if (!packageVersion || packageVersion.startsWith('workspace:')) return fallbackVersion;
|
|
11351
|
-
return packageVersion;
|
|
11352
|
-
};
|
|
11353
|
-
const defaultRstestVersion = normalizePackageVersion(package_namespaceObject.El.yR, 'latest');
|
|
11354
|
-
const parseEmitArgs = (args)=>{
|
|
11355
|
-
let outDir;
|
|
11356
|
-
let configPath;
|
|
11357
|
-
for(let index = 0; index < args.length; index += 1){
|
|
11358
|
-
const arg = args[index];
|
|
11359
|
-
if ('--help' === arg || '-h' === arg) return {
|
|
11360
|
-
help: true
|
|
11361
|
-
};
|
|
11362
|
-
if ('--config' === arg) {
|
|
11363
|
-
const value = args[index + 1];
|
|
11364
|
-
if (!value || value.startsWith('-')) return {
|
|
11365
|
-
error: '--config requires a path value'
|
|
11366
|
-
};
|
|
11367
|
-
configPath = value;
|
|
11368
|
-
index += 1;
|
|
11369
|
-
continue;
|
|
11370
|
-
}
|
|
11371
|
-
if (arg.startsWith('--config=')) {
|
|
11372
|
-
const value = arg.slice(9);
|
|
11373
|
-
if (!value) return {
|
|
11374
|
-
error: '--config requires a path value'
|
|
11375
|
-
};
|
|
11376
|
-
configPath = value;
|
|
11377
|
-
continue;
|
|
11378
|
-
}
|
|
11379
|
-
if (arg.startsWith('-')) return {
|
|
11380
|
-
error: `Unknown option: ${arg}`
|
|
11381
|
-
};
|
|
11382
|
-
if (!outDir) {
|
|
11383
|
-
outDir = arg;
|
|
11384
|
-
continue;
|
|
11385
|
-
}
|
|
11386
|
-
return {
|
|
11387
|
-
error: `Unexpected argument: ${arg}`
|
|
11388
|
-
};
|
|
11389
|
-
}
|
|
11390
|
-
return {
|
|
11391
|
-
outDir,
|
|
11392
|
-
configPath
|
|
11393
|
-
};
|
|
11394
|
-
};
|
|
11395
|
-
async function runEmitCommand(args, deps = {
|
|
11396
|
-
emit: testing_framework_namespaceObject.emitRstestProject
|
|
11397
|
-
}) {
|
|
11398
|
-
const { outDir, configPath, error, help: shouldShowHelp } = parseEmitArgs(args);
|
|
11399
|
-
if (shouldShowHelp) {
|
|
11400
|
-
console.log(help);
|
|
11401
|
-
return 0;
|
|
11402
|
-
}
|
|
11403
|
-
if (error) {
|
|
11404
|
-
console.error(`${error}\n${usage}`);
|
|
11405
|
-
return 1;
|
|
11406
|
-
}
|
|
11407
|
-
if (!outDir) {
|
|
11408
|
-
console.error(usage);
|
|
11409
|
-
return 1;
|
|
11410
|
-
}
|
|
11411
|
-
const result = await deps.emit({
|
|
11412
|
-
outDir,
|
|
11413
|
-
configPath,
|
|
11414
|
-
rstestVersion: deps.rstestVersion ?? defaultRstestVersion
|
|
11415
|
-
});
|
|
11416
|
-
console.log(`Emitted native Rstest project to ${result.outDir} (${result.caseFiles.length} case(s))`);
|
|
11417
|
-
return 0;
|
|
11418
|
-
}
|
|
11419
11261
|
var framework = __webpack_require__("./src/framework/index.ts");
|
|
11420
11262
|
Promise.resolve((async ()=>{
|
|
11421
11263
|
const rawArgs = process.argv.slice(2);
|
|
@@ -11429,11 +11271,6 @@ Options:
|
|
|
11429
11271
|
version: package_namespaceObject.rE,
|
|
11430
11272
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
11431
11273
|
});
|
|
11432
|
-
if ('emit' === firstArg) {
|
|
11433
|
-
console.log(`\nWelcome to @midscene/cli v${package_namespaceObject.rE}\n`);
|
|
11434
|
-
const exitCode = await runEmitCommand(rawArgs.slice(1));
|
|
11435
|
-
process.exit(exitCode);
|
|
11436
|
-
}
|
|
11437
11274
|
const { options, path, files: cmdFiles } = await parseProcessArgs();
|
|
11438
11275
|
const welcome = `\nWelcome to @midscene/cli v${package_namespaceObject.rE}\n`;
|
|
11439
11276
|
console.log(welcome);
|
|
@@ -11531,6 +11368,10 @@ Options:
|
|
|
11531
11368
|
"use strict";
|
|
11532
11369
|
module.exports = require("node:path");
|
|
11533
11370
|
},
|
|
11371
|
+
"node:url" (module) {
|
|
11372
|
+
"use strict";
|
|
11373
|
+
module.exports = require("node:url");
|
|
11374
|
+
},
|
|
11534
11375
|
os (module) {
|
|
11535
11376
|
"use strict";
|
|
11536
11377
|
module.exports = require("os");
|